r262817 - [CLANG][AVX512][BUILTIN] Adding vpmultishiftqb{128|256|512}

2016-03-07 Thread Michael Zuckerman via cfe-commits
Author: mzuckerm
Date: Mon Mar  7 02:29:10 2016
New Revision: 262817

URL: http://llvm.org/viewvc/llvm-project?rev=262817&view=rev
Log:
[CLANG][AVX512][BUILTIN] Adding vpmultishiftqb{128|256|512}

Differential Revision: http://reviews.llvm.org/D17914


Modified:
cfe/trunk/include/clang/Basic/BuiltinsX86.def
cfe/trunk/lib/Headers/avx512bwintrin.h
cfe/trunk/lib/Headers/avx512vlbwintrin.h
cfe/trunk/lib/Headers/avx512vlintrin.h
cfe/trunk/test/CodeGen/avx512bw-builtins.c
cfe/trunk/test/CodeGen/avx512vl-builtins.c

Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=262817&r1=262816&r2=262817&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Mon Mar  7 02:29:10 2016
@@ -1719,6 +1719,13 @@ TARGET_BUILTIN(__builtin_ia32_movdquqi25
 TARGET_BUILTIN(__builtin_ia32_movddup512_mask, "V8dV8dV8dUc","","avx512f")
 TARGET_BUILTIN(__builtin_ia32_movddup128_mask, "V2dV2dV2dUc","","avx512vl")
 TARGET_BUILTIN(__builtin_ia32_movddup256_mask, "V4dV4dV4dUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_pbroadcastb512_gpr_mask, 
"V64ccV64cULLi","","avx512bw")
+TARGET_BUILTIN(__builtin_ia32_pbroadcastb128_gpr_mask, 
"V16ccV16cUs","","avx512bw,avx512vl")
+TARGET_BUILTIN(__builtin_ia32_pbroadcastb256_gpr_mask, 
"V32ccV32cUi","","avx512bw,avx512vl")
+TARGET_BUILTIN(__builtin_ia32_pbroadcastd128_gpr_mask, 
"V4iiV4iUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_pbroadcastd256_gpr_mask, 
"V8iiV8iUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_pbroadcastq128_gpr_mask, 
"V2LLiULLiV2LLiUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_pbroadcastq256_gpr_mask, 
"V4LLiULLiV4LLiUc","","avx512vl")
 
 #undef BUILTIN
 #undef TARGET_BUILTIN

Modified: cfe/trunk/lib/Headers/avx512bwintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512bwintrin.h?rev=262817&r1=262816&r2=262817&view=diff
==
--- cfe/trunk/lib/Headers/avx512bwintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512bwintrin.h Mon Mar  7 02:29:10 2016
@@ -1917,6 +1917,23 @@ _mm512_maskz_mov_epi8 (__mmask64 __U, __
 }
 
 
+static __inline__ __m512i __DEFAULT_FN_ATTRS
+_mm512_mask_set1_epi8 (__m512i __O, __mmask64 __M, char __A)
+{
+  return (__m512i) __builtin_ia32_pbroadcastb512_gpr_mask (__A,
+ (__v64qi) __O,
+ __M);
+}
+
+static __inline__ __m512i __DEFAULT_FN_ATTRS
+_mm512_maskz_set1_epi8 (__mmask64 __M, char __A)
+{
+  return (__m512i) __builtin_ia32_pbroadcastb512_gpr_mask (__A,
+ (__v64qi)
+ _mm512_setzero_qi(),
+ __M);
+}
+
 #undef __DEFAULT_FN_ATTRS
 
 #endif

Modified: cfe/trunk/lib/Headers/avx512vlbwintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512vlbwintrin.h?rev=262817&r1=262816&r2=262817&view=diff
==
--- cfe/trunk/lib/Headers/avx512vlbwintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512vlbwintrin.h Mon Mar  7 02:29:10 2016
@@ -2919,6 +2919,39 @@ _mm256_maskz_mov_epi8 (__mmask32 __U, __
 }
 
 
+static __inline__ __m128i __DEFAULT_FN_ATTRS
+_mm_mask_set1_epi8 (__m128i __O, __mmask16 __M, char __A)
+{
+  return (__m128i) __builtin_ia32_pbroadcastb128_gpr_mask (__A,
+ (__v16qi) __O,
+ __M);
+}
+
+static __inline__ __m128i __DEFAULT_FN_ATTRS
+_mm_maskz_set1_epi8 (__mmask16 __M, char __A)
+{
+  return (__m128i) __builtin_ia32_pbroadcastb128_gpr_mask (__A,
+ (__v16qi)
+ _mm_setzero_si128 (),
+ __M);
+}
+
+static __inline__ __m256i __DEFAULT_FN_ATTRS
+_mm256_mask_set1_epi8 (__m256i __O, __mmask32 __M, char __A)
+{
+  return (__m256i) __builtin_ia32_pbroadcastb256_gpr_mask (__A,
+ (__v32qi) __O,
+ __M);
+}
+
+static __inline__ __m256i __DEFAULT_FN_ATTRS
+_mm256_maskz_set1_epi8 (__mmask32 __M, char __A)
+{
+  return (__m256i) __builtin_ia32_pbroadcastb256_gpr_mask (__A,
+ (__v32qi)
+ _mm256_setzero_si256 (),
+ __M);
+}
 #undef __DEFAULT_FN_ATTRS
 
 #endif /* __AVX512VLBWINTRIN_H */

Modified: cfe/trunk/lib/Headers/avx512vlintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512vlintrin.h?rev=262817&r1=262816&r2=262817&view=diff
==
--- cfe/trunk/lib/Headers/avx512vlintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512vlintrin.h Mon Mar  7 02:29:10 2016
@@ -6012,6 +6012,62 @@ _mm256_maskz_movedup_pd (__mmask8 __U, _
(__mmask8) __U);
 }
 
+
+#define _mm_mask_set1_epi32( __O, __M, __A) __extension__ ({ \
+__builtin_ia32_pbroadcastd128_gpr_mask (__A, (__v4si)( __O),\
+

r262818 - [MS ABI] Mangle symbols names longer than 4096 characters correctly

2016-03-07 Thread David Majnemer via cfe-commits
Author: majnemer
Date: Mon Mar  7 02:51:17 2016
New Revision: 262818

URL: http://llvm.org/viewvc/llvm-project?rev=262818&view=rev
Log:
[MS ABI] Mangle symbols names longer than 4096 characters correctly

Really long symbols are hashed using MD5 and prefixed/suffixed with the
usual sigils.  There is an additional reason beyond the usual
compatibility with MSVC, it is important to keep COFF symbols shorter
than 0x because the CodeView debugging format has a maximum
symbol/record size of 0x.

There are some quirks worth noting:
- Some mangled names reference other entities which are mangled
separately.  A quick example:

int I;
template  struct S {};
S s;

In this case, the mangling for 's' doesn't depend directly on the
mangling for 'I'.  While 's' would need an MD5 hash if 'I' also needed
one, the hash for 's' applied to the fully realized mangled name.  In
other words, the mangled name for 's' will not depend on the MD5 of the
mangled name for 'I'.

- Some mangled names, like the venerable CatchableType, embed the MD5
verbatim.

- Finally, the complete object locator is handled as a special case.
A complete object locators are mangled exactly like a VFTable except for
a small deviation in the prefix sigils.  However, complete object
locators for hashed vftables result in a complete object locator whose
name is identical to the vftable except for an additional suffix.

Added:
cfe/trunk/test/CodeGenCXX/mangle-ms-md5.cpp
Modified:
cfe/trunk/lib/AST/MicrosoftMangle.cpp

Modified: cfe/trunk/lib/AST/MicrosoftMangle.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/MicrosoftMangle.cpp?rev=262818&r1=262817&r2=262818&view=diff
==
--- cfe/trunk/lib/AST/MicrosoftMangle.cpp (original)
+++ cfe/trunk/lib/AST/MicrosoftMangle.cpp Mon Mar  7 02:51:17 2016
@@ -28,13 +28,44 @@
 #include "clang/Basic/DiagnosticOptions.h"
 #include "clang/Basic/TargetInfo.h"
 #include "llvm/ADT/StringExtras.h"
-#include "llvm/Support/MathExtras.h"
 #include "llvm/Support/JamCRC.h"
+#include "llvm/Support/MD5.h"
+#include "llvm/Support/MathExtras.h"
 
 using namespace clang;
 
 namespace {
 
+struct msvc_hashing_ostream : public llvm::raw_svector_ostream {
+  raw_ostream &OS;
+  llvm::SmallString<64> Buffer;
+
+  msvc_hashing_ostream(raw_ostream &OS)
+  : llvm::raw_svector_ostream(Buffer), OS(OS) {}
+  ~msvc_hashing_ostream() override {
+StringRef MangledName = str();
+bool StartsWithEscape = MangledName.startswith("\01");
+if (StartsWithEscape)
+  MangledName = MangledName.drop_front(1);
+if (MangledName.size() <= 4096) {
+  OS << str();
+  return;
+}
+
+llvm::MD5 Hasher;
+llvm::MD5::MD5Result Hash;
+Hasher.update(MangledName);
+Hasher.final(Hash);
+
+SmallString<32> HexString;
+llvm::MD5::stringifyResult(Hash, HexString);
+
+if (StartsWithEscape)
+  OS << '\01';
+OS << "??@" << HexString << '@';
+  }
+};
+
 /// \brief Retrieve the declaration context that should be used when mangling
 /// the given declaration.
 static const DeclContext *getEffectiveDeclContext(const Decl *D) {
@@ -206,7 +237,7 @@ public:
   }
 
 private:
-  void mangleInitFiniStub(const VarDecl *D, raw_ostream &Out, char CharCode);
+  void mangleInitFiniStub(const VarDecl *D, char CharCode, raw_ostream &Out);
 };
 
 /// MicrosoftCXXNameMangler - Manage the mangling of a single name for the
@@ -2458,7 +2489,8 @@ void MicrosoftMangleContextImpl::mangleC
  getASTContext().getSourceManager(),
  "Mangling declaration");
 
-  MicrosoftCXXNameMangler Mangler(*this, Out);
+  msvc_hashing_ostream MHO(Out);
+  MicrosoftCXXNameMangler Mangler(*this, MHO);
   return Mangler.mangle(D);
 }
 
@@ -2558,7 +2590,8 @@ MicrosoftMangleContextImpl::mangleVirtua
   const MicrosoftVTableContext::MethodVFTableLocation &ML =
   VTContext->getMethodVFTableLocation(GlobalDecl(MD));
 
-  MicrosoftCXXNameMangler Mangler(*this, Out);
+  msvc_hashing_ostream MHO(Out);
+  MicrosoftCXXNameMangler Mangler(*this, MHO);
   Mangler.getStream() << "\01?";
   Mangler.mangleVirtualMemPtrThunk(MD, ML);
 }
@@ -2566,10 +2599,11 @@ MicrosoftMangleContextImpl::mangleVirtua
 void MicrosoftMangleContextImpl::mangleThunk(const CXXMethodDecl *MD,
  const ThunkInfo &Thunk,
  raw_ostream &Out) {
-  MicrosoftCXXNameMangler Mangler(*this, Out);
-  Out << "\01?";
+  msvc_hashing_ostream MHO(Out);
+  MicrosoftCXXNameMangler Mangler(*this, MHO);
+  Mangler.getStream() << "\01?";
   Mangler.mangleName(MD);
-  mangleThunkThisAdjustment(MD, Thunk.This, Mangler, Out);
+  mangleThunkThisAdjustment(MD, Thunk.This, Mangler, MHO);
   if (!Thunk.Return.isEmpty())
 assert(Thunk.Method != nullptr &&
"Thunk info should hold the overridee decl");
@@ -2586,10 +2620,11 @@ void MicrosoftMangleContextIm

Re: [PATCH] D17762: Fix an assertion failure in setPointOfInstantiation.

2016-03-07 Thread Haojian Wu via cfe-commits
hokein added a comment.

In http://reviews.llvm.org/D17762#367182, @bkramer wrote:

> This doesn't look right to me. Aborting tree transform on a bad source 
> location seems just wrong. Where is the invalid source location coming from? 
> Also the backtrace seems related to typo correction, maybe the bug is there?


I have post the whole stack trace in PR25668 
.
The invalid source location comes from `TypoExpr` which is returned by 
`ArraySubscriptExpr->getLHS()`, this is also why there is a FIXME in code line 
. After 
reading the code more throughly, I find that the invalid source location is 
expected when constructing a `TypoExpr`.

I updated the fixing patch now. We probably don't call `RequireCompleteType` 
with an invalid source location, which is the same as  trunk@84793.


http://reviews.llvm.org/D17762



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r262820 - [CLANG][AVX512][BUILTIN] Adding new feature flag header file and new builtin vpmadd52{h|l}uq{128|256|512}{mask|maskz}

2016-03-07 Thread Michael Zuckerman via cfe-commits
Author: mzuckerm
Date: Mon Mar  7 03:55:55 2016
New Revision: 262820

URL: http://llvm.org/viewvc/llvm-project?rev=262820&view=rev
Log:
[CLANG][AVX512][BUILTIN] Adding new feature flag header file and new builtin 
vpmadd52{h|l}uq{128|256|512}{mask|maskz}

Differential Revision: http://reviews.llvm.org/D17915


Added:
cfe/trunk/lib/Headers/avx512ifmaintrin.h
cfe/trunk/lib/Headers/avx512ifmavlintrin.h
cfe/trunk/test/CodeGen/avx512ifma-builtins.c
cfe/trunk/test/CodeGen/avx512ifmavl-builtins.c
Modified:
cfe/trunk/include/clang/Basic/BuiltinsX86.def
cfe/trunk/lib/Headers/CMakeLists.txt
cfe/trunk/lib/Headers/immintrin.h

Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=262820&r1=262819&r2=262820&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Mon Mar  7 03:55:55 2016
@@ -1726,6 +1726,18 @@ TARGET_BUILTIN(__builtin_ia32_pbroadcast
 TARGET_BUILTIN(__builtin_ia32_pbroadcastd256_gpr_mask, 
"V8iiV8iUc","","avx512vl")
 TARGET_BUILTIN(__builtin_ia32_pbroadcastq128_gpr_mask, 
"V2LLiULLiV2LLiUc","","avx512vl")
 TARGET_BUILTIN(__builtin_ia32_pbroadcastq256_gpr_mask, 
"V4LLiULLiV4LLiUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_vpmadd52huq512_mask, 
"V8LLiV8LLiV8LLiV8LLiUc","","avx512ifma")
+TARGET_BUILTIN(__builtin_ia32_vpmadd52huq512_maskz, 
"V8LLiV8LLiV8LLiV8LLiUc","","avx512ifma")
+TARGET_BUILTIN(__builtin_ia32_vpmadd52luq512_mask, 
"V8LLiV8LLiV8LLiV8LLiUc","","avx512ifma")
+TARGET_BUILTIN(__builtin_ia32_vpmadd52luq512_maskz, 
"V8LLiV8LLiV8LLiV8LLiUc","","avx512ifma")
+TARGET_BUILTIN(__builtin_ia32_vpmadd52huq128_mask, 
"V2LLiV2LLiV2LLiV2LLiUc","","avx512ifma,avx512vl")
+TARGET_BUILTIN(__builtin_ia32_vpmadd52huq128_maskz, 
"V2LLiV2LLiV2LLiV2LLiUc","","avx512ifma,avx512vl")
+TARGET_BUILTIN(__builtin_ia32_vpmadd52huq256_mask, 
"V4LLiV4LLiV4LLiV4LLiUc","","avx512ifma,avx512vl")
+TARGET_BUILTIN(__builtin_ia32_vpmadd52huq256_maskz, 
"V4LLiV4LLiV4LLiV4LLiUc","","avx512ifma,avx512vl")
+TARGET_BUILTIN(__builtin_ia32_vpmadd52luq128_mask, 
"V2LLiV2LLiV2LLiV2LLiUc","","avx512ifma,avx512vl")
+TARGET_BUILTIN(__builtin_ia32_vpmadd52luq128_maskz, 
"V2LLiV2LLiV2LLiV2LLiUc","","avx512ifma,avx512vl")
+TARGET_BUILTIN(__builtin_ia32_vpmadd52luq256_mask, 
"V4LLiV4LLiV4LLiV4LLiUc","","avx512ifma,avx512vl")
+TARGET_BUILTIN(__builtin_ia32_vpmadd52luq256_maskz, 
"V4LLiV4LLiV4LLiV4LLiUc","","avx512ifma,avx512vl")
 
 #undef BUILTIN
 #undef TARGET_BUILTIN

Modified: cfe/trunk/lib/Headers/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/CMakeLists.txt?rev=262820&r1=262819&r2=262820&view=diff
==
--- cfe/trunk/lib/Headers/CMakeLists.txt (original)
+++ cfe/trunk/lib/Headers/CMakeLists.txt Mon Mar  7 03:55:55 2016
@@ -74,6 +74,8 @@ set(files
   xsavecintrin.h
   xsavesintrin.h
   xtestintrin.h
+  avx512ifmaintrin.h
+  avx512ifmavlintrin.h
   )
 
 set(output_dir ${LLVM_LIBRARY_OUTPUT_INTDIR}/clang/${CLANG_VERSION}/include)

Added: cfe/trunk/lib/Headers/avx512ifmaintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512ifmaintrin.h?rev=262820&view=auto
==
--- cfe/trunk/lib/Headers/avx512ifmaintrin.h (added)
+++ cfe/trunk/lib/Headers/avx512ifmaintrin.h Mon Mar  7 03:55:55 2016
@@ -0,0 +1,92 @@
+/*===- avx512ifmaintrin.h - IFMA intrinsics --===
+ *
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to 
deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ *===---===
+ */
+#ifndef __IMMINTRIN_H
+#error "Never use  directly; include  
instead."
+#endif
+
+#ifndef __IFMAINTRIN_H
+#define __IFMAINTRIN_H
+
+/* Defin

Re: [PATCH] D17762: Fix an assertion failure in setPointOfInstantiation.

2016-03-07 Thread Haojian Wu via cfe-commits
hokein updated this revision to Diff 49939.
hokein added a comment.

Update.


http://reviews.llvm.org/D17762

Files:
  lib/Sema/SemaExpr.cpp
  test/Sema/PR25668.cpp

Index: test/Sema/PR25668.cpp
===
--- /dev/null
+++ test/Sema/PR25668.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -verify -fsyntax-only -std=c++11 %s
+// expected-no-assertion-crash
+
+template  class A {};
+struct B {
+  A operator[](int);
+} mask_ {
+  mask[2]; // expected-error{{use of undeclared identifier 'mask'}}
+};
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -14044,6 +14044,9 @@
   if (ReturnType->isVoidType() || !ReturnType->isIncompleteType())
 return false;
 
+  if (Loc.isInvalid())
+return true;
+
   // If we're inside a decltype's expression, don't check for a valid return
   // type or construct temporaries until we know whether this is the last call.
   if (ExprEvalContexts.back().IsDecltype) {


Index: test/Sema/PR25668.cpp
===
--- /dev/null
+++ test/Sema/PR25668.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -verify -fsyntax-only -std=c++11 %s
+// expected-no-assertion-crash
+
+template  class A {};
+struct B {
+  A operator[](int);
+} mask_ {
+  mask[2]; // expected-error{{use of undeclared identifier 'mask'}}
+};
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -14044,6 +14044,9 @@
   if (ReturnType->isVoidType() || !ReturnType->isIncompleteType())
 return false;
 
+  if (Loc.isInvalid())
+return true;
+
   // If we're inside a decltype's expression, don't check for a valid return
   // type or construct temporaries until we know whether this is the last call.
   if (ExprEvalContexts.back().IsDecltype) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [modules] PR24954

2016-03-07 Thread Vassil Vassilev via cfe-commits

ping...
On 22/02/16 21:51, Vassil Vassilev wrote:

On 02/02/16 02:52, Richard Smith via cfe-commits wrote:
On Thu, Jan 28, 2016 at 8:23 AM, Vassil Vassilev  
wrote:

Would this patch be more reasonable? It follows what
RegisterTemplateSpecialization (introduced in r245779) does. AFAICT 
this

adds an update record far less often.

It's still adding redundant update records. We'll write the
appropriate update record as part of serializing the declaration
itself, so we only need to ensure that the declaration is emitted, not
actually emit an update record for it. Perhaps you could store a list
of such declarations on the ASTWriter, and call GetDeclRef on each of
them once we start emitting the AST file (or maybe just push them into
UpdatingVisibleDecls). Please also restrict this to the template
friend corner case.
The attached patch fixes the issues more or less in the direction you 
suggest. I am not sure if I expressed well enough the conditions of 
the template friend corner case. Could you have a look?



--Vassil

On 12/12/15 16:13, Vassil Vassilev wrote:

I couldn't find GetDecl routine in the ASTWriter. Could you elaborate?

Assuming you meant ASTWriter::GetDeclRef(D): It seems that the 
conditions

when calling GetDeclRef differ from the conditions of
AddedCXXTemplateSpecialization. Eg:

ASTWriter::AddedCXXTemplateSpecialization {
   assert(!WritingAST && "Already writing the AST!");
   ...
}
ASTWriter::GetDeclRef {
   assert(WritingAST && "Cannot request a declaration ID before AST
writing");
   ..
}

IIUC this particular instantiation happens *after* module B was 
built, thus
it needs to be retrospectively added to the serialized namespace. It 
looks
like even avoiding somehow the asserts of GetDeclRef it wouldn't 
help much.


Alternatively I could try to reduce the redundant update records by
narrowing down to instantiations coming in the context of friends.

--Vassil

On 12/12/15 01:07, Richard Smith wrote:

Instead of adding an update record directly in this case (which will 
emit
far more update records than necessary), how about just calling 
GetDecl(D)

from AddedCXXTemplateSpecialization to ensure that it gets emitted?

On Fri, Dec 4, 2015 at 7:46 AM, Vassil Vassilev  
wrote:

Hi,
   Could you review my fix please.
Many thanks,
Vassil

On 08/10/15 15:53, Vassil Vassilev wrote:

Hi Richard,
   I started working on https://llvm.org/bugs/show_bug.cgi?id=24954

   IIUC r228485 introduces an abstraction to deal with
not-really-anonymous friend decls
(serialization::needsAnonymousDeclarationNumber in ASTCommon.cpp).

   A comment explicitly says:
   "// This doesn't apply to friend tag decls; Sema makes those 
available

to name
// lookup in the surrounding context."

   In the bug reproducer, the friend function (wrt __iom_t10) is 
forward
declared in the same namespace, where Sema makes the friend 
available for a

name lookup.

   It seems that the friend operator<< in __iom_t10 (sorry about 
the names
they come from libcxx) doesn't get registered in the ASTWriter's 
DeclIDs but

it gets registered in outer namespace's lookup table. Thus, assert is
triggered when finalizing module A, since it rebuilds the lookups 
of the

updated contexts.

   The issue only appears when building module A deserializes/uses 
module

B.

   Currently I was assume that something wrong happens in either
needsAnonymousDeclarationNumber or I hit a predicted issue
ASTWriterDecl.cpp:1602
 // FIXME: This is not correct; when we reach an imported 
declaration

we
 // won't emit its previous declaration.
 (void)Writer.GetDeclRef(D->getPreviousDecl());
 (void)Writer.GetDeclRef(MostRecent);

   The issue seems a fairly complex one and I am a bit stuck.

   Any hints are very very welcome ;)
Many thanks,
Vassil







___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits




___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17762: Fix an assertion failure in setPointOfInstantiation.

2016-03-07 Thread Benjamin Kramer via cfe-commits
bkramer added a comment.

I'm still not sure if this is the right way to fix it. Maybe @rsmith has an 
opinion?


http://reviews.llvm.org/D17762



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17766: [ms-inline-asm][AVX512] Add ability to use k registers in MS inline asm + fix bag with curly braces

2016-03-07 Thread Marina Yatsina via cfe-commits
myatsina added a subscriber: cfe-commits.
myatsina updated this revision to Diff 49945.
myatsina marked an inline comment as done.
myatsina added a comment.

Updated test to reflect changes in the llvm part of the review 
(http://reviews.llvm.org/D17767)


Repository:
  rL LLVM

http://reviews.llvm.org/D17766

Files:
  lib/Parse/ParseStmtAsm.cpp
  test/CodeGen/ms-inline-asm-avx512.c
  test/CodeGen/ms-inline-asm.c
  test/Parser/ms-inline-asm.c

Index: lib/Parse/ParseStmtAsm.cpp
===
--- lib/Parse/ParseStmtAsm.cpp
+++ lib/Parse/ParseStmtAsm.cpp
@@ -390,6 +390,7 @@
 if (!InAsmComment && Tok.is(tok::l_brace)) {
   // Consume the opening brace.
   SkippedStartOfLine = Tok.isAtStartOfLine();
+  AsmToks.push_back(Tok);
   EndLoc = ConsumeBrace();
   BraceNesting++;
   LBraceLocs.push_back(EndLoc);
@@ -442,6 +443,11 @@
 BraceCount == (savedBraceCount + BraceNesting)) {
   // Consume the closing brace.
   SkippedStartOfLine = Tok.isAtStartOfLine();
+  // Don't want to add the closing brace of the whole asm block
+  if (SingleLineMode || BraceNesting > 1) {
+Tok.clearFlag(Token::LeadingSpace);
+AsmToks.push_back(Tok);
+  }
   EndLoc = ConsumeBrace();
   BraceNesting--;
   // Finish if all of the opened braces in the inline asm section were
Index: test/CodeGen/ms-inline-asm.c
===
--- test/CodeGen/ms-inline-asm.c
+++ test/CodeGen/ms-inline-asm.c
@@ -86,7 +86,7 @@
 __asm { pop ebx }
   }
 // CHECK: t9
-// CHECK: call void asm sideeffect inteldialect "push ebx\0A\09mov ebx, 
$$0x07\0A\09pop ebx", "~{ebx},~{esp},~{dirflag},~{fpsr},~{flags}"()
+// CHECK: call void asm sideeffect inteldialect "push ebx\0A\09mov ebx, 
$$0x07\0A\09pop ebx\0A\09", "~{ebx},~{esp},~{dirflag},~{fpsr},~{flags}"()
 }
 
 unsigned t10(void) {
Index: test/CodeGen/ms-inline-asm-avx512.c
===
--- test/CodeGen/ms-inline-asm-avx512.c
+++ test/CodeGen/ms-inline-asm-avx512.c
@@ -9,3 +9,13 @@
  vaddpd zmm8, zmm27, zmm6
   }
 }
+
+
+void t2() {
+// CHECK: @t2
+// CHECK: call void asm sideeffect inteldialect "vaddpd zmm8 {k1}, zmm27, 
zmm6", "~{zmm8},~{dirflag},~{fpsr},~{flags}"()
+// CHECK: ret void
+  __asm {
+ vaddpd zmm8 {k1}, zmm27, zmm6
+  }
+}
Index: test/Parser/ms-inline-asm.c
===
--- test/Parser/ms-inline-asm.c
+++ test/Parser/ms-inline-asm.c
@@ -53,6 +53,10 @@
 void t12() {
   __asm jmp label // expected-error {{use of undeclared label 'label'}}
 }
+void t13() {
+  __asm m{o}v eax, ebx // expected-error {{expected identifier}} 
expected-error {{use of undeclared label '{o}v eax, ebx'}}
+}
+
 int t_fail() { // expected-note {{to match this}}
   __asm 
   __asm { // expected-error 3 {{expected}} expected-note {{to match this}}


Index: lib/Parse/ParseStmtAsm.cpp
===
--- lib/Parse/ParseStmtAsm.cpp
+++ lib/Parse/ParseStmtAsm.cpp
@@ -390,6 +390,7 @@
 if (!InAsmComment && Tok.is(tok::l_brace)) {
   // Consume the opening brace.
   SkippedStartOfLine = Tok.isAtStartOfLine();
+  AsmToks.push_back(Tok);
   EndLoc = ConsumeBrace();
   BraceNesting++;
   LBraceLocs.push_back(EndLoc);
@@ -442,6 +443,11 @@
 BraceCount == (savedBraceCount + BraceNesting)) {
   // Consume the closing brace.
   SkippedStartOfLine = Tok.isAtStartOfLine();
+  // Don't want to add the closing brace of the whole asm block
+  if (SingleLineMode || BraceNesting > 1) {
+Tok.clearFlag(Token::LeadingSpace);
+AsmToks.push_back(Tok);
+  }
   EndLoc = ConsumeBrace();
   BraceNesting--;
   // Finish if all of the opened braces in the inline asm section were
Index: test/CodeGen/ms-inline-asm.c
===
--- test/CodeGen/ms-inline-asm.c
+++ test/CodeGen/ms-inline-asm.c
@@ -86,7 +86,7 @@
 __asm { pop ebx }
   }
 // CHECK: t9
-// CHECK: call void asm sideeffect inteldialect "push ebx\0A\09mov ebx, $$0x07\0A\09pop ebx", "~{ebx},~{esp},~{dirflag},~{fpsr},~{flags}"()
+// CHECK: call void asm sideeffect inteldialect "push ebx\0A\09mov ebx, $$0x07\0A\09pop ebx\0A\09", "~{ebx},~{esp},~{dirflag},~{fpsr},~{flags}"()
 }
 
 unsigned t10(void) {
Index: test/CodeGen/ms-inline-asm-avx512.c
===
--- test/CodeGen/ms-inline-asm-avx512.c
+++ test/CodeGen/ms-inline-asm-avx512.c
@@ -9,3 +9,13 @@
 	  vaddpd zmm8, zmm27, zmm6
   }
 }
+
+
+void t2() {
+// CHECK: @t2
+// CHECK: call void asm sideeffect inteldialect "vaddpd zmm8 {k1}, zmm27, zmm6", "~{zmm8},~{dirflag},~{fpsr},~{flags}"()
+// CHECK: ret void
+  __asm {
+	  vaddpd zmm8 {k1}, zmm27, zmm6
+  }
+}
Index: test/Parser/ms-inline-asm.c
=

Re: [PATCH] D17764: Add attributes for AMD GPU Tools

2016-03-07 Thread Tom Stellard via cfe-commits
tstellarAMD added inline comments.


Comment at: include/clang/Basic/AttrDocs.td:969-973
@@ +968,7 @@
+
+Clang supports the ``__attribute__((amdgpu_tools_num_reserved_vgpr()))``
+attribute on AMD Southern Islands GPUs and later. If specified, it causes AMD
+GPU Backend to reserve  number of vector registers and do not use 
those
+registers throughout kernel function execution. Index of the first reserved
+vector register is recorded in the ``amd_kernel_code_t``.
+

What does the value of this attribute mean?  If I pass 16, does it reserve 
VGPRS 0 - 15 or
VGPRS 240 - 255 ?  Can you clarify this in the documentation?




http://reviews.llvm.org/D17764



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17811: [clang-tidy] Add check to detect dangling references in value handlers.

2016-03-07 Thread Alexander Kornienko via cfe-commits
alexfh added inline comments.


Comment at: clang-tidy/misc/DanglingHandleCheck.cpp:24
@@ +23,3 @@
+
+std::vector parseClasses(StringRef Option) {
+  SmallVector Classes;

A very similar code has been added recently to 
clang-tidy/utils/HeaderFileExtensionsUtils.*. Maybe make that code generic 
enough and reuse it?


Comment at: clang-tidy/misc/DanglingHandleCheck.cpp:82
@@ +81,3 @@
+  anyOf(
+  // For sequences:
+  // assign, push_back, resize

nit: The comment can well fit on a single line without making it less readable. 
Also, please add a trailing period.


Comment at: clang-tidy/misc/DanglingHandleCheck.cpp:116
@@ +115,3 @@
+  return cxxRecordDecl(internal::Matcher(
+   new internal::HasNameMatcher(HandleClasses)))
+  .bind("handle");

This use of internal classes doesn't look nice. Can you add a `hasAnyName` 
overload taking a `set` or an `ArrayRef` of names (or maybe a template version 
that'll take a range of something convertible to StringRef)?


Comment at: clang-tidy/misc/DanglingHandleCheck.cpp:162
@@ +161,3 @@
+hasAutomaticStorageDuration(),
+// and it is a local array or Value
+anyOf(hasType(arrayType()),

nit: Please add a trailing period (and optionally an ellipsis at the start of 
the comment and at the end of the previous comment).


Comment at: clang-tidy/misc/DanglingHandleCheck.cpp:175
@@ +174,3 @@
+ IsAHandle, handleFromTemporaryValue(IsAHandle))
+  .bind("bad"),
+  this);

`handleFromTemporaryValue` already binds something to `bad`, which looks 
suspicious. Should we try to place all .binds() on the upper-most level, when 
it's possible, to make the whole picture easier to see?


Comment at: test/clang-tidy/misc-dangling-handle.cpp:85
@@ +84,3 @@
+  std::string_view view_2 = ReturnsAString();
+  // CHECK-MESSAGES: [[@LINE-1]]:29: warning: std::basic_string_view outlives
+

jbcoe wrote:
> This (and other) check-messages line looks truncated.
This is intentional. It makes sense to specify the whole message once and 
remove repeated static text from other CHECK-MESSAGES lines to make them 
shorter and the whole test more readable.


http://reviews.llvm.org/D17811



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17926: [clang-tidy] Don't delete unused parameter in class override method in anonymous namespace.

2016-03-07 Thread Alexander Kornienko via cfe-commits
alexfh added inline comments.


Comment at: clang-tidy/misc/UnusedParametersCheck.cpp:20
@@ +19,3 @@
+namespace {
+bool isOverrideMethod(const FunctionDecl *Function) {
+  if (const auto *MD = dyn_cast(Function))

There's a matcher for this: `isOverride`.


Repository:
  rL LLVM

http://reviews.llvm.org/D17926



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17908: Add Visual Studio Visualizers for more Clang types

2016-03-07 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.


Comment at: clang.natvis:1-3
@@ -1,4 +1,4 @@
 
 

Re: [PATCH] D17853: Disable tail-call optimization for X86 interrupt handlers

2016-03-07 Thread Amjad Aboud via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL262830: Resolved Bug 26414. (authored by aaboud).

Changed prior to commit:
  http://reviews.llvm.org/D17853?vs=49746&id=49953#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D17853

Files:
  cfe/trunk/lib/CodeGen/CGCall.cpp
  cfe/trunk/test/CodeGen/attr-x86-interrupt.c

Index: cfe/trunk/lib/CodeGen/CGCall.cpp
===
--- cfe/trunk/lib/CodeGen/CGCall.cpp
+++ cfe/trunk/lib/CodeGen/CGCall.cpp
@@ -1451,6 +1451,7 @@
 
   const Decl *TargetDecl = CalleeInfo.getCalleeDecl();
 
+  bool HasAnyX86InterruptAttr = false;
   // FIXME: handle sseregparm someday...
   if (TargetDecl) {
 if (TargetDecl->hasAttr())
@@ -1488,6 +1489,7 @@
 if (TargetDecl->hasAttr())
   RetAttrs.addAttribute(llvm::Attribute::NonNull);
 
+HasAnyX86InterruptAttr = TargetDecl->hasAttr();
 HasOptnone = TargetDecl->hasAttr();
   }
 
@@ -1527,10 +1529,11 @@
 }
 
 bool DisableTailCalls =
-CodeGenOpts.DisableTailCalls ||
+CodeGenOpts.DisableTailCalls || HasAnyX86InterruptAttr ||
 (TargetDecl && TargetDecl->hasAttr());
-FuncAttrs.addAttribute("disable-tail-calls",
-   llvm::toStringRef(DisableTailCalls));
+FuncAttrs.addAttribute(
+"disable-tail-calls",
+llvm::toStringRef(DisableTailCalls));
 
 FuncAttrs.addAttribute("less-precise-fpmad",
llvm::toStringRef(CodeGenOpts.LessPreciseFPMAD));
Index: cfe/trunk/test/CodeGen/attr-x86-interrupt.c
===
--- cfe/trunk/test/CodeGen/attr-x86-interrupt.c
+++ cfe/trunk/test/CodeGen/attr-x86-interrupt.c
@@ -15,12 +15,20 @@
 // X86_64_LINUX: @llvm.used = appending global [2 x i8*] [i8* bitcast (void 
(i32*, i64)* @foo7 to i8*), i8* bitcast (void (i32*)* @foo8 to i8*)], section 
"llvm.metadata"
 // X86_64_LINUX: define x86_intrcc void @foo7(i32* %{{.+}}, i64 %{{.+}})
 // X86_64_LINUX: define x86_intrcc void @foo8(i32* %{{.+}})
+// X86_64_LINUX: "disable-tail-calls"="true"
+// X86_64_LINUX-NOT: "disable-tail-calls"="false"
 // X86_LINUX: @llvm.used = appending global [2 x i8*] [i8* bitcast (void 
(i32*, i32)* @foo7 to i8*), i8* bitcast (void (i32*)* @foo8 to i8*)], section 
"llvm.metadata"
 // X86_LINUX: define x86_intrcc void @foo7(i32* %{{.+}}, i32 %{{.+}})
 // X86_LINUX: define x86_intrcc void @foo8(i32* %{{.+}})
+// X86_LINUX: "disable-tail-calls"="true"
+// X86_LINUX-NOT: "disable-tail-calls"="false"
 // X86_64_WIN: @llvm.used = appending global [2 x i8*] [i8* bitcast (void 
(i32*, i64)* @foo7 to i8*), i8* bitcast (void (i32*)* @foo8 to i8*)], section 
"llvm.metadata"
 // X86_64_WIN: define x86_intrcc void @foo7(i32* %{{.+}}, i64 %{{.+}})
 // X86_64_WIN: define x86_intrcc void @foo8(i32* %{{.+}})
+// X86_64_Win: "disable-tail-calls"="true"
+// X86_64_Win-NOT: "disable-tail-calls"="false"
 // X86_WIN: @llvm.used = appending global [2 x i8*] [i8* bitcast (void (i32*, 
i32)* @foo7 to i8*), i8* bitcast (void (i32*)* @foo8 to i8*)], section 
"llvm.metadata"
 // X86_WIN: define x86_intrcc void @foo7(i32* %{{.+}}, i32 %{{.+}})
 // X86_WIN: define x86_intrcc void @foo8(i32* %{{.+}})
+// X86_Win: "disable-tail-calls"="true"
+// X86_Win-NOT: "disable-tail-calls"="false"


Index: cfe/trunk/lib/CodeGen/CGCall.cpp
===
--- cfe/trunk/lib/CodeGen/CGCall.cpp
+++ cfe/trunk/lib/CodeGen/CGCall.cpp
@@ -1451,6 +1451,7 @@
 
   const Decl *TargetDecl = CalleeInfo.getCalleeDecl();
 
+  bool HasAnyX86InterruptAttr = false;
   // FIXME: handle sseregparm someday...
   if (TargetDecl) {
 if (TargetDecl->hasAttr())
@@ -1488,6 +1489,7 @@
 if (TargetDecl->hasAttr())
   RetAttrs.addAttribute(llvm::Attribute::NonNull);
 
+HasAnyX86InterruptAttr = TargetDecl->hasAttr();
 HasOptnone = TargetDecl->hasAttr();
   }
 
@@ -1527,10 +1529,11 @@
 }
 
 bool DisableTailCalls =
-CodeGenOpts.DisableTailCalls ||
+CodeGenOpts.DisableTailCalls || HasAnyX86InterruptAttr ||
 (TargetDecl && TargetDecl->hasAttr());
-FuncAttrs.addAttribute("disable-tail-calls",
-   llvm::toStringRef(DisableTailCalls));
+FuncAttrs.addAttribute(
+"disable-tail-calls",
+llvm::toStringRef(DisableTailCalls));
 
 FuncAttrs.addAttribute("less-precise-fpmad",
llvm::toStringRef(CodeGenOpts.LessPreciseFPMAD));
Index: cfe/trunk/test/CodeGen/attr-x86-interrupt.c
===
--- cfe/trunk/test/CodeGen/attr-x86-interrupt.c
+++ cfe/trunk/test/CodeGen/attr-x86-interrupt.c
@@ -15,12 +15,20 @@
 // X86_64_LINUX: @llvm.used = appending global [2 x i8*] [i8* bitcast (void (i32*, i64)* @foo7 to i8*), i8* bitcast (void (i32*)* @foo8 to i8*)], section "llvm.metadata"
 // X86_64_LINUX: define x86_intrcc void @foo7(i32*

r262830 - Resolved Bug 26414.

2016-03-07 Thread Amjad Aboud via cfe-commits
Author: aaboud
Date: Mon Mar  7 08:22:46 2016
New Revision: 262830

URL: http://llvm.org/viewvc/llvm-project?rev=262830&view=rev
Log:
Resolved Bug 26414.
https://llvm.org/bugs/show_bug.cgi?id=26414
Since interrupt handler must be returned with iret, tail call can't be used.

Differential Revision: http://reviews.llvm.org/D17853

Modified:
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/test/CodeGen/attr-x86-interrupt.c

Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=262830&r1=262829&r2=262830&view=diff
==
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Mon Mar  7 08:22:46 2016
@@ -1451,6 +1451,7 @@ void CodeGenModule::ConstructAttributeLi
 
   const Decl *TargetDecl = CalleeInfo.getCalleeDecl();
 
+  bool HasAnyX86InterruptAttr = false;
   // FIXME: handle sseregparm someday...
   if (TargetDecl) {
 if (TargetDecl->hasAttr())
@@ -1488,6 +1489,7 @@ void CodeGenModule::ConstructAttributeLi
 if (TargetDecl->hasAttr())
   RetAttrs.addAttribute(llvm::Attribute::NonNull);
 
+HasAnyX86InterruptAttr = TargetDecl->hasAttr();
 HasOptnone = TargetDecl->hasAttr();
   }
 
@@ -1527,10 +1529,11 @@ void CodeGenModule::ConstructAttributeLi
 }
 
 bool DisableTailCalls =
-CodeGenOpts.DisableTailCalls ||
+CodeGenOpts.DisableTailCalls || HasAnyX86InterruptAttr ||
 (TargetDecl && TargetDecl->hasAttr());
-FuncAttrs.addAttribute("disable-tail-calls",
-   llvm::toStringRef(DisableTailCalls));
+FuncAttrs.addAttribute(
+"disable-tail-calls",
+llvm::toStringRef(DisableTailCalls));
 
 FuncAttrs.addAttribute("less-precise-fpmad",
llvm::toStringRef(CodeGenOpts.LessPreciseFPMAD));

Modified: cfe/trunk/test/CodeGen/attr-x86-interrupt.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/attr-x86-interrupt.c?rev=262830&r1=262829&r2=262830&view=diff
==
--- cfe/trunk/test/CodeGen/attr-x86-interrupt.c (original)
+++ cfe/trunk/test/CodeGen/attr-x86-interrupt.c Mon Mar  7 08:22:46 2016
@@ -15,12 +15,20 @@ __attribute__((interrupt)) void foo8(int
 // X86_64_LINUX: @llvm.used = appending global [2 x i8*] [i8* bitcast (void 
(i32*, i64)* @foo7 to i8*), i8* bitcast (void (i32*)* @foo8 to i8*)], section 
"llvm.metadata"
 // X86_64_LINUX: define x86_intrcc void @foo7(i32* %{{.+}}, i64 %{{.+}})
 // X86_64_LINUX: define x86_intrcc void @foo8(i32* %{{.+}})
+// X86_64_LINUX: "disable-tail-calls"="true"
+// X86_64_LINUX-NOT: "disable-tail-calls"="false"
 // X86_LINUX: @llvm.used = appending global [2 x i8*] [i8* bitcast (void 
(i32*, i32)* @foo7 to i8*), i8* bitcast (void (i32*)* @foo8 to i8*)], section 
"llvm.metadata"
 // X86_LINUX: define x86_intrcc void @foo7(i32* %{{.+}}, i32 %{{.+}})
 // X86_LINUX: define x86_intrcc void @foo8(i32* %{{.+}})
+// X86_LINUX: "disable-tail-calls"="true"
+// X86_LINUX-NOT: "disable-tail-calls"="false"
 // X86_64_WIN: @llvm.used = appending global [2 x i8*] [i8* bitcast (void 
(i32*, i64)* @foo7 to i8*), i8* bitcast (void (i32*)* @foo8 to i8*)], section 
"llvm.metadata"
 // X86_64_WIN: define x86_intrcc void @foo7(i32* %{{.+}}, i64 %{{.+}})
 // X86_64_WIN: define x86_intrcc void @foo8(i32* %{{.+}})
+// X86_64_Win: "disable-tail-calls"="true"
+// X86_64_Win-NOT: "disable-tail-calls"="false"
 // X86_WIN: @llvm.used = appending global [2 x i8*] [i8* bitcast (void (i32*, 
i32)* @foo7 to i8*), i8* bitcast (void (i32*)* @foo8 to i8*)], section 
"llvm.metadata"
 // X86_WIN: define x86_intrcc void @foo7(i32* %{{.+}}, i32 %{{.+}})
 // X86_WIN: define x86_intrcc void @foo8(i32* %{{.+}})
+// X86_Win: "disable-tail-calls"="true"
+// X86_Win-NOT: "disable-tail-calls"="false"


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17446: ASTMatchers: add new statement/decl matchers

2016-03-07 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.


Comment at: docs/LibASTMatchersReference.html:512
@@ +511,3 @@
+MatcherStmt>addrLabelExprMatcherAddrLabelExpr>...
+Matches address of 
label statements (GNU extension).
+

We name matchers after the AST node they represent. If we change the name of 
the AST node to include GNU, then I think it would make sense. I'm not certain 
whether we want to rename the AST nodes though (it would be a larger discussion 
than this review), so I would say we shouldn't put gnu in the matcher names, 
but call it out in the documentation (as the author is now doing).


Comment at: include/clang/ASTMatchers/ASTMatchers.h:1012
@@ +1011,3 @@
+/// \brief Matches paren list expressions.
+/// ParenListExprs don't have a predefined type and are used for latter 
parsing.
+/// In final AST, they can be met in template declarations.

late parsing instead of latter parsing?


Comment at: include/clang/ASTMatchers/ASTMatchers.h:1013
@@ +1012,3 @@
+/// ParenListExprs don't have a predefined type and are used for latter 
parsing.
+/// In final AST, they can be met in template declarations.
+///

In the final AST (insert the).


Comment at: include/clang/ASTMatchers/ASTMatchers.h:1022
@@ +1021,3 @@
+///
+/// Given
+/// \code

Combine the two examples into one. e.g.,
```
template class X {
  void f() {
X x(*this);
int a = 0, b = 1; int i = (a, b);
   }
};
```


Comment at: include/clang/ASTMatchers/ASTMatchers.h:1614
@@ +1613,3 @@
+
+/// \brief Matches GNU statement expression.
+///

Matches a statement expression (GNU extension).

(This way we can consistently search for GNU extension.)


http://reviews.llvm.org/D17446



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17926: [clang-tidy] Don't delete unused parameter in class override method in anonymous namespace.

2016-03-07 Thread Haojian Wu via cfe-commits
hokein updated this revision to Diff 49954.
hokein added a comment.

Use internal isOverride method.


http://reviews.llvm.org/D17926

Files:
  clang-tidy/misc/UnusedParametersCheck.cpp
  test/clang-tidy/misc-unused-parameters.cpp

Index: test/clang-tidy/misc-unused-parameters.cpp
===
--- test/clang-tidy/misc-unused-parameters.cpp
+++ test/clang-tidy/misc-unused-parameters.cpp
@@ -127,6 +127,16 @@
   useFunction(&C::h);
 }
 
+class Base {
+  virtual void f(int i);
+};
+
+class Derived : public Base {
+  void f(int i) override {}
+// CHECK-MESSAGES: :[[@LINE-1]]:14: warning
+// CHECK-FIXES: void f(int  /*i*/) override {}
+};
+
 } // end namespace
 
 template  void someFunctionTemplate(T b, T e) { (void)b; (void)e; }
Index: clang-tidy/misc/UnusedParametersCheck.cpp
===
--- clang-tidy/misc/UnusedParametersCheck.cpp
+++ clang-tidy/misc/UnusedParametersCheck.cpp
@@ -76,7 +76,10 @@
   // Comment out parameter name for non-local functions.
   if (Function->isExternallyVisible() ||
   !Result.SourceManager->isInMainFile(Function->getLocation()) ||
-  UsedByRef()) {
+  UsedByRef() ||
+  !ast_matchers::match(cxxMethodDecl(isOverride()), *Function,
+   *Result.Context)
+   .empty()) {
 SourceRange RemovalRange(Param->getLocation(), Param->getLocEnd());
 // Note: We always add a space before the '/*' to not accidentally create a
 // '*/*' for pointer types, which doesn't start a comment. clang-format 
will


Index: test/clang-tidy/misc-unused-parameters.cpp
===
--- test/clang-tidy/misc-unused-parameters.cpp
+++ test/clang-tidy/misc-unused-parameters.cpp
@@ -127,6 +127,16 @@
   useFunction(&C::h);
 }
 
+class Base {
+  virtual void f(int i);
+};
+
+class Derived : public Base {
+  void f(int i) override {}
+// CHECK-MESSAGES: :[[@LINE-1]]:14: warning
+// CHECK-FIXES: void f(int  /*i*/) override {}
+};
+
 } // end namespace
 
 template  void someFunctionTemplate(T b, T e) { (void)b; (void)e; }
Index: clang-tidy/misc/UnusedParametersCheck.cpp
===
--- clang-tidy/misc/UnusedParametersCheck.cpp
+++ clang-tidy/misc/UnusedParametersCheck.cpp
@@ -76,7 +76,10 @@
   // Comment out parameter name for non-local functions.
   if (Function->isExternallyVisible() ||
   !Result.SourceManager->isInMainFile(Function->getLocation()) ||
-  UsedByRef()) {
+  UsedByRef() ||
+  !ast_matchers::match(cxxMethodDecl(isOverride()), *Function,
+   *Result.Context)
+   .empty()) {
 SourceRange RemovalRange(Param->getLocation(), Param->getLocEnd());
 // Note: We always add a space before the '/*' to not accidentally create a
 // '*/*' for pointer types, which doesn't start a comment. clang-format will
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17926: [clang-tidy] Don't delete unused parameter in class override method in anonymous namespace.

2016-03-07 Thread Haojian Wu via cfe-commits
hokein marked an inline comment as done.
hokein added a comment.

http://reviews.llvm.org/D17926



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D16376: clang-tidy check: misc-deprecated-special-member-functions

2016-03-07 Thread Aaron Ballman via cfe-commits
aaron.ballman added a comment.

In http://reviews.llvm.org/D16376#360527, @jbcoe wrote:

> The Sema diagnostic warning is only produced if a deprecated special member 
> function is used whereas I want to find places where it would be 
> compiler-generated and explicitly delete them. This is useful for library 
> code where I don't have control over the warnings my users will run with.
>
> The AST Matcher I use are simple enough and I'm not convinced that it's worth 
> refactoring Sema to expose what I need. If someone (Richard?) with a deeper 
> understanding can point me in the right direction I'm happy to be corrected.
>
> SemaDeclCXX.cpp `diagnoseDeprecatedCopyOperation` is producing Sema's 
> diagnostics.


I'm on the fence about whether this functionality should be in both clang-tidy 
and Sema, but lean towards leaving it separated because of your use case as a 
library author. However, that suggests perhaps it should be under the modernize 
umbrella instead of misc because already-modern code shouldn't be using 
deprecated functionality. Also, the documentation should probably spell out 
that this differs from warn_deprecated_copy_operation, how it differs, and why 
that's useful.


http://reviews.llvm.org/D16376



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17926: [clang-tidy] Don't delete unused parameter in class override method in anonymous namespace.

2016-03-07 Thread Alexander Kornienko via cfe-commits
alexfh added inline comments.


Comment at: clang-tidy/misc/UnusedParametersCheck.cpp:80
@@ +79,3 @@
+  UsedByRef() ||
+  !ast_matchers::match(cxxMethodDecl(isOverride()), *Function,
+   *Result.Context)

I meant, you can use it inside `UsedByRef`.


http://reviews.llvm.org/D17926



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17908: Add Visual Studio Visualizers for more Clang types

2016-03-07 Thread Zachary Turner via cfe-commits
Better yet, just delete the number
On Mon, Mar 7, 2016 at 6:21 AM Aaron Ballman 
wrote:

> aaron.ballman added inline comments.
>
> 
> Comment at: clang.natvis:1-3
> @@ -1,4 +1,4 @@
>  
>   Do you know if these visualizers will work in MSVC 2013 as well, or are
> you using MSVC 2015-specific features? I ask because 2013 is our base MSVC
> version currently, so it would be good to know if this will break anyone.
> If the features work in 2013, we should probably change it from 2012 to
> 2013 in the comment.
>
>
> http://reviews.llvm.org/D17908
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17908: Add Visual Studio Visualizers for more Clang types

2016-03-07 Thread Zachary Turner via cfe-commits
zturner added a subscriber: zturner.
zturner added a comment.

Better yet, just delete the number


http://reviews.llvm.org/D17908



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17908: Add Visual Studio Visualizers for more Clang types

2016-03-07 Thread Aaron Ballman via cfe-commits
aaron.ballman added a comment.

In http://reviews.llvm.org/D17908#368969, @zturner wrote:

> Better yet, just delete the number


The number is sort of helpful since it's the only documentation as to what 
least common denominator we support. I don't have a strong attachment to the 
number, however.


http://reviews.llvm.org/D17908



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17908: Add Visual Studio Visualizers for more Clang types

2016-03-07 Thread Zachary Turner via cfe-commits
zturner added a comment.

Natvis has hardly changed at all since it was introduced, so I'm guessing
the lowest common denominator is always going to be our minimum required VS
version


http://reviews.llvm.org/D17908



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17908: Add Visual Studio Visualizers for more Clang types

2016-03-07 Thread Zachary Turner via cfe-commits
Natvis has hardly changed at all since it was introduced, so I'm guessing
the lowest common denominator is always going to be our minimum required VS
version
On Mon, Mar 7, 2016 at 7:09 AM Aaron Ballman 
wrote:

> aaron.ballman added a comment.
>
> In http://reviews.llvm.org/D17908#368969, @zturner wrote:
>
> > Better yet, just delete the number
>
>
> The number is sort of helpful since it's the only documentation as to what
> least common denominator we support. I don't have a strong attachment to
> the number, however.
>
>
> http://reviews.llvm.org/D17908
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17908: Add Visual Studio Visualizers for more Clang types

2016-03-07 Thread Aaron Ballman via cfe-commits
aaron.ballman added a comment.

In http://reviews.llvm.org/D17908#368972, @zturner wrote:

> Natvis has hardly changed at all since it was introduced, so I'm guessing
>  the lowest common denominator is always going to be our minimum required VS
> version


Awesome! Sold on removing the date.


http://reviews.llvm.org/D17908



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17567: [GCC] PR23529 Sema part of attrbute abi_tag support

2016-03-07 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.


Comment at: docs/ItaniumMangleAbiTags.rst:2
@@ +1,3 @@
+
+Abi Tags
+

ABI tags (since it's an acronym). Elsewhere as well.


Comment at: docs/ItaniumMangleAbiTags.rst:30
@@ +29,3 @@
+
+All tags that are "active" on a  are emitted after the
+, before  or , and are part of

an 


Comment at: docs/ItaniumMangleAbiTags.rst:49
@@ +48,3 @@
+
+A namespace has never any active tags; for types (class / struct / union /
+enum) the explicit tags are the active tags.

A namespace does not have any active tags.


Comment at: docs/ItaniumMangleAbiTags.rst:50
@@ +49,3 @@
+A namespace has never any active tags; for types (class / struct / union /
+enum) the explicit tags are the active tags.
+

Comma after "enum)".


Comment at: docs/ItaniumMangleAbiTags.rst:52
@@ +51,3 @@
+
+For variables and functions the active tags are the explicit tags plus any
+"required tags" which are not in the "available tags" set:

Comma after "functions".


Comment at: docs/ItaniumMangleAbiTags.rst:68
@@ +67,3 @@
+Otherwise the function requires any implicit or explicit tag used in the name
+for the return type.
+

Code examples for these might be useful for the reader.


Comment at: docs/ItaniumMangleAbiTags.rst:79
@@ +78,3 @@
+All tags used in the prefix and in the template arguments for a name are
+available; for functions also all  tags from the  (which
+might include the return type for template functions) are available.

Separate into two sentences instead of using a semicolon.

"Also, for functions, all tags from the..."


Comment at: docs/ItaniumMangleAbiTags.rst:83
@@ +82,3 @@
+For s all active tags used in the local part () are available, but not implicit tags which were not active!
+

Replace the ! with a .

Also, an example might be useful for the reader.


Comment at: docs/ItaniumMangleAbiTags.rst:89
@@ +88,3 @@
+Example: a cast operator to std::string (which is
+std::__cxx11::basic_string<...>) will use 'cxx11' as active tag, as it is
+required from the return type `std::string` but not available.

as an active tag.


Comment at: include/clang/Basic/AttrDocs.td:1965
@@ +1964,3 @@
+The ``abi_tag`` attribute can be applied to a function, variable, class or
+inline namespace declaration to modify mangled name of the entity. It allows
+to distinguish different versions of the same entity but with different ABI

to modify the mangled name


Comment at: include/clang/Basic/AttrDocs.td:1966
@@ +1965,3 @@
+inline namespace declaration to modify mangled name of the entity. It allows
+to distinguish different versions of the same entity but with different ABI
+version supported. For example, newer version of a class could have more or 
less

the ability to distinguish between different versions


Comment at: include/clang/Basic/AttrDocs.td:1967
@@ +1966,3 @@
+to distinguish different versions of the same entity but with different ABI
+version supported. For example, newer version of a class could have more or 
less
+data members and thus have different size. Using the ``abi_tag`` attribute it 
is

versions supported.

a newer version of a class could have a different set of data members


Comment at: include/clang/Basic/AttrDocs.td:1968
@@ +1967,3 @@
+version supported. For example, newer version of a class could have more or 
less
+data members and thus have different size. Using the ``abi_tag`` attribute it 
is
+possible to have different mangled name for a global variable of the class 
type.

a different size. 

Comma after attribute.


Comment at: include/clang/Basic/AttrDocs.td:1969
@@ +1968,3 @@
+data members and thus have different size. Using the ``abi_tag`` attribute it 
is
+possible to have different mangled name for a global variable of the class 
type.
+Therefor old code could keep using old manged name and new code will use new

names


Comment at: include/clang/Basic/AttrDocs.td:1970
@@ +1969,3 @@
+possible to have different mangled name for a global variable of the class 
type.
+Therefor old code could keep using old manged name and new code will use new
+mangled name with tags.

Therefore, (note the comma)

the old mangled name

will use the new


Comment at: include/clang/Basic/DiagnosticSemaKinds.td:2465
@@ -2465,1 +2464,3 @@
+  "variables, enums, fields and typedefs|"
+  "structs, classes, variables, functions and inline namespaces}1">,
   InGroup;

Comma after functions.


Comment at: include/clang/Basic/DiagnosticSemaKinds.td:4179
@@ +4178,3 @@
+d

Re: [PATCH] D17908: Add Visual Studio Visualizers for more Clang types

2016-03-07 Thread Mike Spertus via cfe-commits
mspertus added a comment.

I believe that it will all work on VS2013 (and have kicked off a build to 
confirm). I guess I would rather drop the number so it doesn't get out of sync 
whenever the base compiler version changes.


http://reviews.llvm.org/D17908



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D16993: Add missing __builtin_bitreverse8

2016-03-07 Thread Matt Arsenault via cfe-commits
arsenm retitled this revision from "Add documentation for bitreverse builtins" 
to "Add missing __builtin_bitreverse8".
arsenm updated the summary for this revision.
arsenm updated this revision to Diff 49960.

http://reviews.llvm.org/D16993

Files:
  docs/LanguageExtensions.rst
  include/clang/Basic/Builtins.def
  test/CodeGen/builtins.c

Index: test/CodeGen/builtins.c
===
--- test/CodeGen/builtins.c
+++ test/CodeGen/builtins.c
@@ -117,9 +117,11 @@
   P(bswap32, (N));
   P(bswap64, (N));
 
+  // CHECK: @llvm.bitreverse.i8
   // CHECK: @llvm.bitreverse.i16
   // CHECK: @llvm.bitreverse.i32
   // CHECK: @llvm.bitreverse.i64
+  P(bitreverse8, (N));
   P(bitreverse16, (N));
   P(bitreverse32, (N));
   P(bitreverse64, (N));
Index: include/clang/Basic/Builtins.def
===
--- include/clang/Basic/Builtins.def
+++ include/clang/Basic/Builtins.def
@@ -409,6 +409,7 @@
 BUILTIN(__builtin_bswap32, "UiUi", "nc")
 BUILTIN(__builtin_bswap64, "ULLiULLi", "nc")
 
+BUILTIN(__builtin_bitreverse8, "UcUc", "nc")
 BUILTIN(__builtin_bitreverse16, "UsUs", "nc")
 BUILTIN(__builtin_bitreverse32, "UiUi", "nc")
 BUILTIN(__builtin_bitreverse64, "ULLiULLi", "nc")
Index: docs/LanguageExtensions.rst
===
--- docs/LanguageExtensions.rst
+++ docs/LanguageExtensions.rst
@@ -1505,6 +1505,33 @@
 
 Query for this feature with ``__has_builtin(__builtin_convertvector)``.
 
+``__builtin_bitreverse``
+-
+
+* ``__builtin_bitreverse8``
+* ``__builtin_bitreverse16``
+* ``__builtin_bitreverse32``
+* ``__builtin_bitreverse64``
+
+**Syntax**:
+
+.. code-block:: c++
+ __builtin_bitreverse32(x)
+
+**Examples**:
+
+.. code-block:: c++
+  uint8_t rev_x = __builtin_bitreverse8(x);
+  uint16_t rev_x = __builtin_bitreverse16(x);
+  uint32_t rev_y = __builtin_bitreverse32(y);
+  uint64_t rev_z = __builtin_bitreverse64(z);
+
+**Description**:
+
+The '``__builtin_bitreverse``' family of builtins is used to reverse
+the bitpattern of an integer value; for example ``0b1234567`` becomes
+``0b7654321``.
+
 ``__builtin_unreachable``
 -
 


Index: test/CodeGen/builtins.c
===
--- test/CodeGen/builtins.c
+++ test/CodeGen/builtins.c
@@ -117,9 +117,11 @@
   P(bswap32, (N));
   P(bswap64, (N));
 
+  // CHECK: @llvm.bitreverse.i8
   // CHECK: @llvm.bitreverse.i16
   // CHECK: @llvm.bitreverse.i32
   // CHECK: @llvm.bitreverse.i64
+  P(bitreverse8, (N));
   P(bitreverse16, (N));
   P(bitreverse32, (N));
   P(bitreverse64, (N));
Index: include/clang/Basic/Builtins.def
===
--- include/clang/Basic/Builtins.def
+++ include/clang/Basic/Builtins.def
@@ -409,6 +409,7 @@
 BUILTIN(__builtin_bswap32, "UiUi", "nc")
 BUILTIN(__builtin_bswap64, "ULLiULLi", "nc")
 
+BUILTIN(__builtin_bitreverse8, "UcUc", "nc")
 BUILTIN(__builtin_bitreverse16, "UsUs", "nc")
 BUILTIN(__builtin_bitreverse32, "UiUi", "nc")
 BUILTIN(__builtin_bitreverse64, "ULLiULLi", "nc")
Index: docs/LanguageExtensions.rst
===
--- docs/LanguageExtensions.rst
+++ docs/LanguageExtensions.rst
@@ -1505,6 +1505,33 @@
 
 Query for this feature with ``__has_builtin(__builtin_convertvector)``.
 
+``__builtin_bitreverse``
+-
+
+* ``__builtin_bitreverse8``
+* ``__builtin_bitreverse16``
+* ``__builtin_bitreverse32``
+* ``__builtin_bitreverse64``
+
+**Syntax**:
+
+.. code-block:: c++
+ __builtin_bitreverse32(x)
+
+**Examples**:
+
+.. code-block:: c++
+  uint8_t rev_x = __builtin_bitreverse8(x);
+  uint16_t rev_x = __builtin_bitreverse16(x);
+  uint32_t rev_y = __builtin_bitreverse32(y);
+  uint64_t rev_z = __builtin_bitreverse64(z);
+
+**Description**:
+
+The '``__builtin_bitreverse``' family of builtins is used to reverse
+the bitpattern of an integer value; for example ``0b1234567`` becomes
+``0b7654321``.
+
 ``__builtin_unreachable``
 -
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D16529: [clang-tidy] Add modernize-raw-string-literal check

2016-03-07 Thread Aaron Ballman via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

In http://reviews.llvm.org/D16529#366433, @LegalizeAdulthood wrote:

> Squeak.  This has been waiting on review for over two weeks


Sorry for the delay, I was at WG21 meetings last week, so code reviews mostly 
were ignored by me.

I think this check LGTM, but please wait for @alexfh before committing.



Comment at: clang-tidy/modernize/RawStringLiteralCheck.cpp:82
@@ +81,3 @@
+? std::string{R"lit()")lit"}
+: (")" + Delimiter + R"(")")) != StringRef::npos;
+}

This is a wonderful demonstration of why I hate raw string literals on shorter 
strings. I had to stare at that raw string for quite some time to figure it 
out. :-(


http://reviews.llvm.org/D16529



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D16971: [Sema] PR26077 Fixed crash when partial specialization is missing required parameters

2016-03-07 Thread don hinton via cfe-commits
hintonda added a comment.

ping...


http://reviews.llvm.org/D16971



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D17933: Set MaxAtomicInlineWidth properly for i386, i486, and x86-64 cpus without cmpxchg16b.

2016-03-07 Thread James Y Knight via cfe-commits
jyknight created this revision.
jyknight added a reviewer: t.p.northover.
jyknight added a subscriber: cfe-commits.
Herald added subscribers: dschuff, jfb, aemerson.

Also, remove all the manual definition of
__GCC_HAVE_SYNC_COMPARE_AND_SWAP_* macros. Instead, define it based on
MaxAtomicInlineWidth, just like the __GCC_ATOMIC_*_LOCK_FREE macros.

Previously, the __GCC_HAVE_SYNC_COMPARE_AND_SWAP_* defines had been
computed separately, and *were* being set appropriately for older x86
targets, while MaxAtomicInlineWidth was not.

(Note the one FIXME comment: __GCC_ATOMIC_LLONG_LOCK_FREE is (still) set
improperly for i586, due to checking alignment where it ought not to.)

Test changes of note:

A few test invocations of clang -cc1 needed to have a "-target-cpu i686"
argument added -- the Driver would do so automatically based on the
"i686" in the triple, but in the tests cases cc1 invocations, it was
missing.

Some of the OpenMP tests needed a "-target-cpu core2" added: they were
assuming that cmpxchg16b was available, even though it's not in the base
x86_64 architecture.

An ARM test was asserting that V8M doesn't have
__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1. This was wrong: V8M *does* support
atomic operations.

http://reviews.llvm.org/D17933

Files:
  lib/Basic/Targets.cpp
  lib/Frontend/InitPreprocessor.cpp
  test/CodeGen/atomic-ops.c
  test/CodeGen/ms-volatile.c
  test/CodeGenCXX/atomicinit.cpp
  test/OpenMP/atomic_capture_codegen.cpp
  test/OpenMP/atomic_read_codegen.c
  test/OpenMP/atomic_update_codegen.cpp
  test/OpenMP/atomic_write_codegen.c
  test/Preprocessor/arm-target-features.c
  test/Preprocessor/init.c
  test/Preprocessor/predefined-arch-macros.c
  test/Preprocessor/predefined-macros.c
  test/Preprocessor/x86_target_features.c
  test/Sema/atomic-ops.c

Index: test/Sema/atomic-ops.c
===
--- test/Sema/atomic-ops.c
+++ test/Sema/atomic-ops.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -verify -ffreestanding -fsyntax-only -triple=i686-linux-gnu -std=c11
+// RUN: %clang_cc1 %s -verify -ffreestanding -fsyntax-only -triple=i686-linux-gnu -target-cpu i686 -std=c11
 
 // Basic parsing/Sema tests for __c11_atomic_*
 
@@ -499,5 +499,3 @@
   (void)__atomic_compare_exchange_n(p, p, val, 0, memory_order_acq_rel, memory_order_relaxed);
   (void)__atomic_compare_exchange_n(p, p, val, 0, memory_order_seq_cst, memory_order_relaxed);
 }
-
-
Index: test/Preprocessor/x86_target_features.c
===
--- test/Preprocessor/x86_target_features.c
+++ test/Preprocessor/x86_target_features.c
@@ -291,8 +291,13 @@
 
 // NOTBM-NOT: #define __TBM__ 1
 
-// RUN: %clang -target i386-unknown-unknown -march=pentiumpro -mcx16 -x c -E -dM -o - %s | FileCheck --check-prefix=MCX16 %s
+// RUN: %clang -target i386-unknown-unknown -march=pentiumpro -mcx16 -x c -E -dM -o - %s | FileCheck --check-prefix=MCX16-386 %s
 
+// MCX16-386-NOT: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_16 1
+
+// RUN: %clang -target x86_64-unknown-unknown -mcx16 -x c -E -dM -o - %s | FileCheck --check-prefix=MCX16 %s
+
+// MCX16: #define __GCC_ATOMIC_LLONG_LOCK_FREE 2
 // MCX16: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_16 1
 
 // RUN: %clang -target i386-unknown-unknown -march=atom -mprfchw -x c -E -dM -o - %s | FileCheck --check-prefix=PRFCHW %s
Index: test/Preprocessor/predefined-macros.c
===
--- test/Preprocessor/predefined-macros.c
+++ test/Preprocessor/predefined-macros.c
@@ -102,45 +102,110 @@
 // RUN: %clang_cc1 %s -E -dM -o - -triple i686 -target-cpu i386 \
 // RUN:   | FileCheck %s --check-prefix=CHECK-SYNC_CAS_I386
 // CHECK-SYNC_CAS_I386-NOT: __GCC_HAVE_SYNC_COMPARE_AND_SWAP
+// CHECK-SYNC_CAS_I386-NOT: __GCC_ATOMIC_{{.*}}_LOCK_FREE 2
 //
 // RUN: %clang_cc1 %s -E -dM -o - -triple i686 -target-cpu i486 \
 // RUN:   | FileCheck %s --check-prefix=CHECK-SYNC_CAS_I486
-// CHECK-SYNC_CAS_I486: __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1
-// CHECK-SYNC_CAS_I486: __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2
-// CHECK-SYNC_CAS_I486: __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
+// CHECK-SYNC_CAS_I486: #define __GCC_ATOMIC_BOOL_LOCK_FREE 2
+// CHECK-SYNC_CAS_I486: #define __GCC_ATOMIC_CHAR16_T_LOCK_FREE 2
+// CHECK-SYNC_CAS_I486: #define __GCC_ATOMIC_CHAR32_T_LOCK_FREE 2
+// CHECK-SYNC_CAS_I486: #define __GCC_ATOMIC_CHAR_LOCK_FREE 2
+// CHECK-SYNC_CAS_I486: #define __GCC_ATOMIC_INT_LOCK_FREE 2
+// CHECK-SYNC_CAS_I486: #define __GCC_ATOMIC_LLONG_LOCK_FREE 1
+// CHECK-SYNC_CAS_I486: #define __GCC_ATOMIC_LONG_LOCK_FREE 2
+// CHECK-SYNC_CAS_I486: #define __GCC_ATOMIC_POINTER_LOCK_FREE 2
+// CHECK-SYNC_CAS_I486: #define __GCC_ATOMIC_SHORT_LOCK_FREE 2
+// CHECK-SYNC_CAS_I486: #define __GCC_ATOMIC_TEST_AND_SET_TRUEVAL 1
+// CHECK-SYNC_CAS_I486: #define __GCC_ATOMIC_WCHAR_T_LOCK_FREE 2
+// CHECK-SYNC_CAS_I486: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1
+// CHECK-SYNC_CAS_I486: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2
+// 

r262832 - Reapply r262741 [OPENMP] Codegen for distribute directive

2016-03-07 Thread Carlo Bertolli via cfe-commits
Author: cbertol
Date: Mon Mar  7 10:04:49 2016
New Revision: 262832

URL: http://llvm.org/viewvc/llvm-project?rev=262832&view=rev
Log:
Reapply r262741 [OPENMP] Codegen for distribute directive

This patch provide basic implementation of codegen for teams directive, 
excluding all clauses except dist_schedule. It also fixes parts of AST 
reader/writer to enable correct pre-compiled header handling.

http://reviews.llvm.org/D17170


Added:
cfe/trunk/test/OpenMP/distribute_codegen.cpp
Modified:
cfe/trunk/include/clang/AST/StmtOpenMP.h
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
cfe/trunk/lib/Serialization/ASTWriterStmt.cpp

Modified: cfe/trunk/include/clang/AST/StmtOpenMP.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/StmtOpenMP.h?rev=262832&r1=262831&r2=262832&view=diff
==
--- cfe/trunk/include/clang/AST/StmtOpenMP.h (original)
+++ cfe/trunk/include/clang/AST/StmtOpenMP.h Mon Mar  7 10:04:49 2016
@@ -595,49 +595,56 @@ public:
   }
   Expr *getIsLastIterVariable() const {
 assert((isOpenMPWorksharingDirective(getDirectiveKind()) ||
-isOpenMPTaskLoopDirective(getDirectiveKind())) &&
+isOpenMPTaskLoopDirective(getDirectiveKind()) ||
+isOpenMPDistributeDirective(getDirectiveKind())) &&
"expected worksharing loop directive");
 return const_cast(reinterpret_cast(
 *std::next(child_begin(), IsLastIterVariableOffset)));
   }
   Expr *getLowerBoundVariable() const {
 assert((isOpenMPWorksharingDirective(getDirectiveKind()) ||
-isOpenMPTaskLoopDirective(getDirectiveKind())) &&
+isOpenMPTaskLoopDirective(getDirectiveKind()) ||
+isOpenMPDistributeDirective(getDirectiveKind())) &&
"expected worksharing loop directive");
 return const_cast(reinterpret_cast(
 *std::next(child_begin(), LowerBoundVariableOffset)));
   }
   Expr *getUpperBoundVariable() const {
 assert((isOpenMPWorksharingDirective(getDirectiveKind()) ||
-isOpenMPTaskLoopDirective(getDirectiveKind())) &&
+isOpenMPTaskLoopDirective(getDirectiveKind()) ||
+isOpenMPDistributeDirective(getDirectiveKind())) &&
"expected worksharing loop directive");
 return const_cast(reinterpret_cast(
 *std::next(child_begin(), UpperBoundVariableOffset)));
   }
   Expr *getStrideVariable() const {
 assert((isOpenMPWorksharingDirective(getDirectiveKind()) ||
-isOpenMPTaskLoopDirective(getDirectiveKind())) &&
+isOpenMPTaskLoopDirective(getDirectiveKind()) ||
+isOpenMPDistributeDirective(getDirectiveKind())) &&
"expected worksharing loop directive");
 return const_cast(reinterpret_cast(
 *std::next(child_begin(), StrideVariableOffset)));
   }
   Expr *getEnsureUpperBound() const {
 assert((isOpenMPWorksharingDirective(getDirectiveKind()) ||
-isOpenMPTaskLoopDirective(getDirectiveKind())) &&
+isOpenMPTaskLoopDirective(getDirectiveKind()) ||
+isOpenMPDistributeDirective(getDirectiveKind())) &&
"expected worksharing loop directive");
 return const_cast(reinterpret_cast(
 *std::next(child_begin(), EnsureUpperBoundOffset)));
   }
   Expr *getNextLowerBound() const {
 assert((isOpenMPWorksharingDirective(getDirectiveKind()) ||
-isOpenMPTaskLoopDirective(getDirectiveKind())) &&
+isOpenMPTaskLoopDirective(getDirectiveKind()) ||
+isOpenMPDistributeDirective(getDirectiveKind())) &&
"expected worksharing loop directive");
 return const_cast(reinterpret_cast(
 *std::next(child_begin(), NextLowerBoundOffset)));
   }
   Expr *getNextUpperBound() const {
 assert((isOpenMPWorksharingDirective(getDirectiveKind()) ||
-isOpenMPTaskLoopDirective(getDirectiveKind())) &&
+isOpenMPTaskLoopDirective(getDirectiveKind()) ||
+isOpenMPDistributeDirective(getDirectiveKind())) &&
"expected worksharing loop directive");
 return const_cast(reinterpret_cast(
 *std::next(child_begin(), NextUpperBoundOffset)));

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=262832&r1=262831&r2=262832&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Mon Mar  7 10:04:49 2016
@@ -425,6 +425,9 @@ enum OpenMPSchedType {
   OMP_ord_runtime = 69,
   OMP_ord_auto = 70,
   OMP_sch_default = OMP_sch_static,
+  /// \brief dist_schedule types
+  OMP_dist_sch_static_chunked = 91,
+  O

Re: [PATCH] D17248: [Sema] PR26444 fix crash when alignment value is >= 2**16

2016-03-07 Thread don hinton via cfe-commits
hintonda added a comment.

I don't have commit access, so could someone commit for me.  Thanks...


http://reviews.llvm.org/D17248



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r262833 - [OPENMP] Codegen for distribute directive: fix bug in ordering of parameters.

2016-03-07 Thread Carlo Bertolli via cfe-commits
Author: cbertol
Date: Mon Mar  7 10:19:13 2016
New Revision: 262833

URL: http://llvm.org/viewvc/llvm-project?rev=262833&view=rev
Log:
[OPENMP] Codegen for distribute directive: fix bug in ordering of parameters.

Modified:
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp

Modified: cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp?rev=262833&r1=262832&r2=262833&view=diff
==
--- cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp Mon Mar  7 10:19:13 2016
@@ -1577,7 +1577,7 @@ void CodeGenFunction::EmitOMPForOuterLoo
  Ordered, IL, LB, UB, ST, Chunk);
   }
 
-  EmitOMPOuterLoop(IsMonotonic, DynamicOrOrdered, S, LoopScope, Ordered, LB, 
UB,
+  EmitOMPOuterLoop(DynamicOrOrdered, IsMonotonic, S, LoopScope, Ordered, LB, 
UB,
ST, IL, Chunk);
 }
 


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17926: [clang-tidy] Don't delete unused parameter in class override method in anonymous namespace.

2016-03-07 Thread Haojian Wu via cfe-commits
hokein added inline comments.


Comment at: clang-tidy/misc/UnusedParametersCheck.cpp:80
@@ +79,3 @@
+  UsedByRef() ||
+  !ast_matchers::match(cxxMethodDecl(isOverride()), *Function,
+   *Result.Context)

alexfh wrote:
> I meant, you can use it inside `UsedByRef`.
Looks like we can't make it in `UsedByRef`.

The `ast_matchers::match` argument passed in `UsedByRef` is a 
`TranslationUnitDecl` type, which isn't used to match `CXXMethodDecl`. the code 
below is always true:

```
ast_matchers::match(
  cxxMethodDecl(isOverride()),
  *Result.Context->getTranslationUnitDecl(), *Result.Context).empty() 
```


http://reviews.llvm.org/D17926



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17002: [lanai] Add Lanai backend to clang driver

2016-03-07 Thread Jacques Pienaar via cfe-commits
jpienaar updated this revision to Diff 49969.
jpienaar added a comment.

Updated to use resetDataLayout.


http://reviews.llvm.org/D17002

Files:
  lib/Basic/Targets.cpp
  lib/CodeGen/TargetInfo.cpp
  lib/Driver/Driver.cpp
  lib/Driver/ToolChains.h
  lib/Driver/Tools.cpp
  lib/Driver/Tools.h
  test/CodeGen/lanai-arguments.c
  test/CodeGen/lanai-regparm.c
  test/CodeGen/target-data.c
  test/Driver/lanai-toolchain.c
  test/Driver/lanai-unknown-unknown.cpp
  test/Preprocessor/init.c

Index: test/Preprocessor/init.c
===
--- test/Preprocessor/init.c
+++ test/Preprocessor/init.c
@@ -8414,6 +8414,9 @@
 // RUN: %clang_cc1 -triple arm-linux-androideabi -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix ANDROID %s
 // ANDROID:#define __ANDROID__ 1
 //
+// RUN: %clang_cc1 -triple lanai-unknown-unknown -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix LANAI %s
+// LANAI: #define __lanai__ 1
+//
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-unknown-freebsd < /dev/null | FileCheck -match-full-lines -check-prefix PPC64-FREEBSD %s
 // PPC64-FREEBSD-NOT: #define __LONG_DOUBLE_128__ 1
 //
Index: test/Driver/lanai-unknown-unknown.cpp
===
--- test/Driver/lanai-unknown-unknown.cpp
+++ test/Driver/lanai-unknown-unknown.cpp
@@ -0,0 +1,86 @@
+// RUN: %clang -target lanai-unknown-unknown -### %s -emit-llvm-only -c 2>&1 \
+// RUN:   | FileCheck %s -check-prefix=ECHO
+// RUN: %clang -target lanai-unknown-unknown %s -emit-llvm -S -o - \
+// RUN:   | FileCheck %s
+
+// ECHO: {{.*}} "-cc1" {{.*}}lanai-unknown-unknown.c
+
+typedef __builtin_va_list va_list;
+typedef __SIZE_TYPE__ size_t;
+typedef __PTRDIFF_TYPE__ ptrdiff_t;
+
+extern "C" {
+
+// CHECK: @align_c = global i32 1
+int align_c = __alignof(char);
+
+// CHECK: @align_s = global i32 2
+int align_s = __alignof(short);
+
+// CHECK: @align_i = global i32 4
+int align_i = __alignof(int);
+
+// CHECK: @align_l = global i32 4
+int align_l = __alignof(long);
+
+// CHECK: @align_ll = global i32 8
+int align_ll = __alignof(long long);
+
+// CHECK: @align_p = global i32 4
+int align_p = __alignof(void*);
+
+// CHECK: @align_vl = global i32 4
+int align_vl = __alignof(va_list);
+
+// Check types
+
+// CHECK: signext i8 @check_char()
+char check_char() { return 0; }
+
+// CHECK: signext i16 @check_short()
+short check_short() { return 0; }
+
+// CHECK: i32 @check_int()
+int check_int() { return 0; }
+
+// CHECK: i32 @check_long()
+long check_long() { return 0; }
+
+// CHECK: i64 @check_longlong()
+long long check_longlong() { return 0; }
+
+// CHECK: zeroext i8 @check_uchar()
+unsigned char check_uchar() { return 0; }
+
+// CHECK: zeroext i16 @check_ushort()
+unsigned short check_ushort() { return 0; }
+
+// CHECK: i32 @check_uint()
+unsigned int check_uint() { return 0; }
+
+// CHECK: i32 @check_ulong()
+unsigned long check_ulong() { return 0; }
+
+// CHECK: i64 @check_ulonglong()
+unsigned long long check_ulonglong() { return 0; }
+
+// CHECK: i32 @check_size_t()
+size_t check_size_t() { return 0; }
+
+}
+
+template void Switch();
+template<> void Switch<4>();
+template<> void Switch<8>();
+template<> void Switch<16>();
+
+void check_pointer_size() {
+  // CHECK: SwitchILi4
+  Switch();
+
+  // CHECK: SwitchILi8
+  Switch();
+
+  // CHECK: SwitchILi4
+  Switch();
+}
Index: test/Driver/lanai-toolchain.c
===
--- test/Driver/lanai-toolchain.c
+++ test/Driver/lanai-toolchain.c
@@ -0,0 +1,2 @@
+// RUN: %clang -target lanai-unknown-unknown -v 2> %t
+// RUN: grep 'Target: lanai-unknown-unknown' %t
Index: test/CodeGen/target-data.c
===
--- test/CodeGen/target-data.c
+++ test/CodeGen/target-data.c
@@ -86,6 +86,10 @@
 // RUN: FileCheck %s -check-prefix=WEBASSEMBLY64
 // WEBASSEMBLY64: target datalayout = "e-m:e-p:64:64-i64:64-n32:64-S128"
 
+// RUN: %clang_cc1 -triple lanai-unknown-unknown -o - -emit-llvm %s | \
+// RUN: FileCheck %s -check-prefix=LANAI
+// LANAI: target datalayout = "E-m:e-p:32:32-i64:64-a:0:32-n32-S64"
+
 // RUN: %clang_cc1 -triple powerpc-unknown -o - -emit-llvm %s | \
 // RUN: FileCheck %s -check-prefix=PPC
 // PPC: target datalayout = "E-m:e-p:32:32-i64:64-n32"
Index: test/CodeGen/lanai-regparm.c
===
--- test/CodeGen/lanai-regparm.c
+++ test/CodeGen/lanai-regparm.c
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -triple lanai-unknown-unknown -mregparm 4 %s -emit-llvm -o - | FileCheck %s
+
+void f1(int a, int b, int c, int d,
+int e, int f, int g, int h);
+
+void f2(int a, int b) __attribute((regparm(0)));
+
+void f0() {
+// CHECK: call void @f1(i32 inreg 1, i32 inreg 2, i32 inreg 3, i32 inreg 4,
+// CHECK: i32 5, i32 6, i32 7, i32 8)
+  f1(1, 2, 3, 4, 5, 6, 7, 8);
+// CHECK: call void @f2(i32 1, i32 2)
+  f2(1, 2);
+}
+
+// CH

Re: [PATCH] D17248: [Sema] PR26444 fix crash when alignment value is >= 2**16

2016-03-07 Thread David Majnemer via cfe-commits
majnemer closed this revision.
majnemer added a comment.

I committed this a few days ago in http://reviews.llvm.org/rL262466.  Closing 
this differential.


http://reviews.llvm.org/D17248



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r262834 - [CLANG][AVX512][BUILTIN] Adding new feature flag headed files and new BUILTIN vpermi2varq{i|t}{128|256|512}{mask|maskz}

2016-03-07 Thread Michael Zuckerman via cfe-commits
Author: mzuckerm
Date: Mon Mar  7 11:04:11 2016
New Revision: 262834

URL: http://llvm.org/viewvc/llvm-project?rev=262834&view=rev
Log:
[CLANG][AVX512][BUILTIN] Adding new feature flag headed files and new BUILTIN 
vpermi2varq{i|t}{128|256|512}{mask|maskz}

Differential Revision: http://reviews.llvm.org/D17917

Added:
cfe/trunk/lib/Headers/avx512vbmiintrin.h
cfe/trunk/lib/Headers/avx512vbmivlintrin.h
cfe/trunk/test/CodeGen/avx512vbmi-builtins.c
cfe/trunk/test/CodeGen/avx512vbmivl-builtin.c
Modified:
cfe/trunk/include/clang/Basic/BuiltinsX86.def
cfe/trunk/lib/Headers/CMakeLists.txt
cfe/trunk/lib/Headers/immintrin.h

Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=262834&r1=262833&r2=262834&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Mon Mar  7 11:04:11 2016
@@ -1738,6 +1738,15 @@ TARGET_BUILTIN(__builtin_ia32_vpmadd52lu
 TARGET_BUILTIN(__builtin_ia32_vpmadd52luq128_maskz, 
"V2LLiV2LLiV2LLiV2LLiUc","","avx512ifma,avx512vl")
 TARGET_BUILTIN(__builtin_ia32_vpmadd52luq256_mask, 
"V4LLiV4LLiV4LLiV4LLiUc","","avx512ifma,avx512vl")
 TARGET_BUILTIN(__builtin_ia32_vpmadd52luq256_maskz, 
"V4LLiV4LLiV4LLiV4LLiUc","","avx512ifma,avx512vl")
+TARGET_BUILTIN(__builtin_ia32_vpermi2varqi512_mask, 
"V64cV64cV64cV64cULLi","","avx512vbmi")
+TARGET_BUILTIN(__builtin_ia32_vpermt2varqi512_mask, 
"V64cV64cV64cV64cULLi","","avx512vbmi")
+TARGET_BUILTIN(__builtin_ia32_vpermt2varqi512_maskz, 
"V64cV64cV64cV64cULLi","","avx512vbmi")
+TARGET_BUILTIN(__builtin_ia32_vpermi2varqi128_mask, 
"V16cV16cV16cV16cUs","","avx512vbmi,avx512vl")
+TARGET_BUILTIN(__builtin_ia32_vpermi2varqi256_mask, 
"V32cV32cV32cV32cUi","","avx512vbmi,avx512vl")
+TARGET_BUILTIN(__builtin_ia32_vpermt2varqi128_mask, 
"V16cV16cV16cV16cUs","","avx512vbmi,avx512vl")
+TARGET_BUILTIN(__builtin_ia32_vpermt2varqi128_maskz, 
"V16cV16cV16cV16cUs","","avx512vbmi,avx512vl")
+TARGET_BUILTIN(__builtin_ia32_vpermt2varqi256_mask, 
"V32cV32cV32cV32cUi","","avx512vbmi,avx512vl")
+TARGET_BUILTIN(__builtin_ia32_vpermt2varqi256_maskz, 
"V32cV32cV32cV32cUi","","avx512vbmi,avx512vl")
 
 #undef BUILTIN
 #undef TARGET_BUILTIN

Modified: cfe/trunk/lib/Headers/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/CMakeLists.txt?rev=262834&r1=262833&r2=262834&view=diff
==
--- cfe/trunk/lib/Headers/CMakeLists.txt (original)
+++ cfe/trunk/lib/Headers/CMakeLists.txt Mon Mar  7 11:04:11 2016
@@ -12,6 +12,8 @@ set(files
   avx512vlintrin.h
   avx512dqintrin.h
   avx512vldqintrin.h
+  avx512vbmiintrin.h
+  avx512vbmivlintrin.h
   pkuintrin.h
   avxintrin.h
   bmi2intrin.h

Added: cfe/trunk/lib/Headers/avx512vbmiintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512vbmiintrin.h?rev=262834&view=auto
==
--- cfe/trunk/lib/Headers/avx512vbmiintrin.h (added)
+++ cfe/trunk/lib/Headers/avx512vbmiintrin.h Mon Mar  7 11:04:11 2016
@@ -0,0 +1,84 @@
+/*===- avx512vbmiintrin.h - IFMA intrinsics --===
+ *
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to 
deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ *===---===
+ */
+#ifndef __IMMINTRIN_H
+#error "Never use  directly; include  
instead."
+#endif
+
+#ifndef __VBMIINTRIN_H
+#define __VBMIINTRIN_H
+
+/* Define the default attributes for the functions in this file. */
+#define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, 
__target__("avx512vbmi")))
+
+
+static __inline__ __m512i __DEFAULT_FN_ATTRS
+_mm512_mask2_permutex2var_epi8 (__m512i __A, __m512i __I,
+ __mmask64 __U, __m512i __B)

Re: [PATCH] D17248: [Sema] PR26444 fix crash when alignment value is >= 2**16

2016-03-07 Thread don hinton via cfe-commits
hintonda added a comment.

Great, thanks David.


http://reviews.llvm.org/D17248



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r262837 - Describe the magic numbers returned by getEHDataRegisterNumber.

2016-03-07 Thread Joerg Sonnenberger via cfe-commits
Author: joerg
Date: Mon Mar  7 11:18:41 2016
New Revision: 262837

URL: http://llvm.org/viewvc/llvm-project?rev=262837&view=rev
Log:
Describe the magic numbers returned by getEHDataRegisterNumber.

Modified:
cfe/trunk/include/clang/Basic/TargetInfo.h

Modified: cfe/trunk/include/clang/Basic/TargetInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TargetInfo.h?rev=262837&r1=262836&r2=262837&view=diff
==
--- cfe/trunk/include/clang/Basic/TargetInfo.h (original)
+++ cfe/trunk/include/clang/Basic/TargetInfo.h Mon Mar  7 11:18:41 2016
@@ -873,6 +873,8 @@ public:
 
   /// \brief Return the register number that __builtin_eh_return_regno would
   /// return with the specified argument.
+  /// This corresponds with TargetLowering's getExceptionPointerRegister
+  /// and getExceptionSelectorRegister in the backend.
   virtual int getEHDataRegisterNumber(unsigned RegNo) const {
 return -1;
   }


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r262838 - Implement __builtin_eh_return_data_regno for SPARC and SPARC64.

2016-03-07 Thread Joerg Sonnenberger via cfe-commits
Author: joerg
Date: Mon Mar  7 11:19:15 2016
New Revision: 262838

URL: http://llvm.org/viewvc/llvm-project?rev=262838&view=rev
Log:
Implement __builtin_eh_return_data_regno for SPARC and SPARC64.

Added:
cfe/trunk/test/CodeGen/builtins-sparc.c
Modified:
cfe/trunk/lib/Basic/Targets.cpp

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=262838&r1=262837&r2=262838&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Mon Mar  7 11:19:15 2016
@@ -5952,6 +5952,12 @@ public:
   SparcTargetInfo(const llvm::Triple &Triple)
   : TargetInfo(Triple), SoftFloat(false) {}
 
+  int getEHDataRegisterNumber(unsigned RegNo) const override {
+if (RegNo == 0) return 24;
+if (RegNo == 1) return 25;
+return -1;
+  }
+
   bool handleTargetFeatures(std::vector &Features,
 DiagnosticsEngine &Diags) override {
 // The backend doesn't actually handle soft float yet, but in case someone

Added: cfe/trunk/test/CodeGen/builtins-sparc.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins-sparc.c?rev=262838&view=auto
==
--- cfe/trunk/test/CodeGen/builtins-sparc.c (added)
+++ cfe/trunk/test/CodeGen/builtins-sparc.c Mon Mar  7 11:19:15 2016
@@ -0,0 +1,10 @@
+// REQUIRES: sparc-registered-target
+// RUN: %clang_cc1 -triple sparc-unknown-unknown -emit-llvm %s -o - | 
FileCheck %s
+// RUN: %clang_cc1 -triple sparc64-unknown-unknown -emit-llvm %s -o - | 
FileCheck %s
+
+void test_eh_return_data_regno(void)
+{
+  volatile int res;
+  res = __builtin_eh_return_data_regno(0);  // CHECK: store volatile i32 24
+  res = __builtin_eh_return_data_regno(1);  // CHECK: store volatile i32 25
+}


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r262838 - Implement __builtin_eh_return_data_regno for SPARC and SPARC64.

2016-03-07 Thread Joerg Sonnenberger via cfe-commits
On Mon, Mar 07, 2016 at 05:19:16PM -, Joerg Sonnenberger via cfe-commits 
wrote:
> Author: joerg
> Date: Mon Mar  7 11:19:15 2016
> New Revision: 262838
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=262838&view=rev
> Log:
> Implement __builtin_eh_return_data_regno for SPARC and SPARC64.

Hans, please merge this into the 3.8 branch, it unbreaks personality
routines on SPARC/SPARC64.

Joerg
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r262842 - [ms-inline-asm][AVX512] Add ability to use k registers in MS inline asm + fix bag with curly braces

2016-03-07 Thread Marina Yatsina via cfe-commits
Author: myatsina
Date: Mon Mar  7 12:10:25 2016
New Revision: 262842

URL: http://llvm.org/viewvc/llvm-project?rev=262842&view=rev
Log:
[ms-inline-asm][AVX512] Add ability to use k registers in MS inline asm + fix 
bag with curly braces

Until now curly braces could only be used in MS inline assembly to mark block 
start/end.
All curly braces were removed completely at a very early stage.
This approach caused bugs like:
"m{o}v eax, ebx" turned into "mov eax, ebx" without any error.

In addition, AVX-512 added special operands (e.g., k registers), which are also 
surrounded by curly braces that mark them as such.
Now, we need to keep the curly braces and identify at a later stage if they are 
marking block start/end (if so, ignore them), or surrounding special AVX-512 
operands (if so, parse them as such).

This patch fixes the bug described above and enables the use of AVX-512 special 
operands.

This commit is the the clang part of the patch.
The clang part of the review is: http://reviews.llvm.org/D17766
The llvm part of the review is: http://reviews.llvm.org/D17767

Differential Revision: http://reviews.llvm.org/D17766


Modified:
cfe/trunk/lib/Parse/ParseStmtAsm.cpp
cfe/trunk/test/CodeGen/ms-inline-asm-avx512.c
cfe/trunk/test/CodeGen/ms-inline-asm.c
cfe/trunk/test/Parser/ms-inline-asm.c

Modified: cfe/trunk/lib/Parse/ParseStmtAsm.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseStmtAsm.cpp?rev=262842&r1=262841&r2=262842&view=diff
==
--- cfe/trunk/lib/Parse/ParseStmtAsm.cpp (original)
+++ cfe/trunk/lib/Parse/ParseStmtAsm.cpp Mon Mar  7 12:10:25 2016
@@ -390,6 +390,7 @@ StmtResult Parser::ParseMicrosoftAsmStat
 if (!InAsmComment && Tok.is(tok::l_brace)) {
   // Consume the opening brace.
   SkippedStartOfLine = Tok.isAtStartOfLine();
+  AsmToks.push_back(Tok);
   EndLoc = ConsumeBrace();
   BraceNesting++;
   LBraceLocs.push_back(EndLoc);
@@ -442,6 +443,11 @@ StmtResult Parser::ParseMicrosoftAsmStat
 BraceCount == (savedBraceCount + BraceNesting)) {
   // Consume the closing brace.
   SkippedStartOfLine = Tok.isAtStartOfLine();
+  // Don't want to add the closing brace of the whole asm block
+  if (SingleLineMode || BraceNesting > 1) {
+Tok.clearFlag(Token::LeadingSpace);
+AsmToks.push_back(Tok);
+  }
   EndLoc = ConsumeBrace();
   BraceNesting--;
   // Finish if all of the opened braces in the inline asm section were

Modified: cfe/trunk/test/CodeGen/ms-inline-asm-avx512.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ms-inline-asm-avx512.c?rev=262842&r1=262841&r2=262842&view=diff
==
--- cfe/trunk/test/CodeGen/ms-inline-asm-avx512.c (original)
+++ cfe/trunk/test/CodeGen/ms-inline-asm-avx512.c Mon Mar  7 12:10:25 2016
@@ -9,3 +9,13 @@ void t1() {
  vaddpd zmm8, zmm27, zmm6
   }
 }
+
+
+void t2() {
+// CHECK: @t2
+// CHECK: call void asm sideeffect inteldialect "vaddpd zmm8 {k1}, zmm27, 
zmm6", "~{zmm8},~{dirflag},~{fpsr},~{flags}"()
+// CHECK: ret void
+  __asm {
+ vaddpd zmm8 {k1}, zmm27, zmm6
+  }
+}

Modified: cfe/trunk/test/CodeGen/ms-inline-asm.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ms-inline-asm.c?rev=262842&r1=262841&r2=262842&view=diff
==
--- cfe/trunk/test/CodeGen/ms-inline-asm.c (original)
+++ cfe/trunk/test/CodeGen/ms-inline-asm.c Mon Mar  7 12:10:25 2016
@@ -86,7 +86,7 @@ void t9() {
 __asm { pop ebx }
   }
 // CHECK: t9
-// CHECK: call void asm sideeffect inteldialect "push ebx\0A\09mov ebx, 
$$0x07\0A\09pop ebx", "~{ebx},~{esp},~{dirflag},~{fpsr},~{flags}"()
+// CHECK: call void asm sideeffect inteldialect "push ebx\0A\09mov ebx, 
$$0x07\0A\09pop ebx\0A\09", "~{ebx},~{esp},~{dirflag},~{fpsr},~{flags}"()
 }
 
 unsigned t10(void) {

Modified: cfe/trunk/test/Parser/ms-inline-asm.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/ms-inline-asm.c?rev=262842&r1=262841&r2=262842&view=diff
==
--- cfe/trunk/test/Parser/ms-inline-asm.c (original)
+++ cfe/trunk/test/Parser/ms-inline-asm.c Mon Mar  7 12:10:25 2016
@@ -53,6 +53,10 @@ void t11() {
 void t12() {
   __asm jmp label // expected-error {{use of undeclared label 'label'}}
 }
+void t13() {
+  __asm m{o}v eax, ebx // expected-error {{expected identifier}} 
expected-error {{use of undeclared label '{o}v eax, ebx'}}
+}
+
 int t_fail() { // expected-note {{to match this}}
   __asm 
   __asm { // expected-error 3 {{expected}} expected-note {{to match this}}


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17766: [ms-inline-asm][AVX512] Add ability to use k registers in MS inline asm + fix bag with curly braces

2016-03-07 Thread Marina Yatsina via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL262842: [ms-inline-asm][AVX512] Add ability to use k 
registers in MS inline asm + fix… (authored by myatsina).

Changed prior to commit:
  http://reviews.llvm.org/D17766?vs=49945&id=49978#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D17766

Files:
  cfe/trunk/lib/Parse/ParseStmtAsm.cpp
  cfe/trunk/test/CodeGen/ms-inline-asm-avx512.c
  cfe/trunk/test/CodeGen/ms-inline-asm.c
  cfe/trunk/test/Parser/ms-inline-asm.c

Index: cfe/trunk/test/Parser/ms-inline-asm.c
===
--- cfe/trunk/test/Parser/ms-inline-asm.c
+++ cfe/trunk/test/Parser/ms-inline-asm.c
@@ -53,6 +53,10 @@
 void t12() {
   __asm jmp label // expected-error {{use of undeclared label 'label'}}
 }
+void t13() {
+  __asm m{o}v eax, ebx // expected-error {{expected identifier}} 
expected-error {{use of undeclared label '{o}v eax, ebx'}}
+}
+
 int t_fail() { // expected-note {{to match this}}
   __asm 
   __asm { // expected-error 3 {{expected}} expected-note {{to match this}}
Index: cfe/trunk/test/CodeGen/ms-inline-asm.c
===
--- cfe/trunk/test/CodeGen/ms-inline-asm.c
+++ cfe/trunk/test/CodeGen/ms-inline-asm.c
@@ -86,7 +86,7 @@
 __asm { pop ebx }
   }
 // CHECK: t9
-// CHECK: call void asm sideeffect inteldialect "push ebx\0A\09mov ebx, 
$$0x07\0A\09pop ebx", "~{ebx},~{esp},~{dirflag},~{fpsr},~{flags}"()
+// CHECK: call void asm sideeffect inteldialect "push ebx\0A\09mov ebx, 
$$0x07\0A\09pop ebx\0A\09", "~{ebx},~{esp},~{dirflag},~{fpsr},~{flags}"()
 }
 
 unsigned t10(void) {
Index: cfe/trunk/test/CodeGen/ms-inline-asm-avx512.c
===
--- cfe/trunk/test/CodeGen/ms-inline-asm-avx512.c
+++ cfe/trunk/test/CodeGen/ms-inline-asm-avx512.c
@@ -9,3 +9,13 @@
  vaddpd zmm8, zmm27, zmm6
   }
 }
+
+
+void t2() {
+// CHECK: @t2
+// CHECK: call void asm sideeffect inteldialect "vaddpd zmm8 {k1}, zmm27, 
zmm6", "~{zmm8},~{dirflag},~{fpsr},~{flags}"()
+// CHECK: ret void
+  __asm {
+ vaddpd zmm8 {k1}, zmm27, zmm6
+  }
+}
Index: cfe/trunk/lib/Parse/ParseStmtAsm.cpp
===
--- cfe/trunk/lib/Parse/ParseStmtAsm.cpp
+++ cfe/trunk/lib/Parse/ParseStmtAsm.cpp
@@ -390,6 +390,7 @@
 if (!InAsmComment && Tok.is(tok::l_brace)) {
   // Consume the opening brace.
   SkippedStartOfLine = Tok.isAtStartOfLine();
+  AsmToks.push_back(Tok);
   EndLoc = ConsumeBrace();
   BraceNesting++;
   LBraceLocs.push_back(EndLoc);
@@ -442,6 +443,11 @@
 BraceCount == (savedBraceCount + BraceNesting)) {
   // Consume the closing brace.
   SkippedStartOfLine = Tok.isAtStartOfLine();
+  // Don't want to add the closing brace of the whole asm block
+  if (SingleLineMode || BraceNesting > 1) {
+Tok.clearFlag(Token::LeadingSpace);
+AsmToks.push_back(Tok);
+  }
   EndLoc = ConsumeBrace();
   BraceNesting--;
   // Finish if all of the opened braces in the inline asm section were


Index: cfe/trunk/test/Parser/ms-inline-asm.c
===
--- cfe/trunk/test/Parser/ms-inline-asm.c
+++ cfe/trunk/test/Parser/ms-inline-asm.c
@@ -53,6 +53,10 @@
 void t12() {
   __asm jmp label // expected-error {{use of undeclared label 'label'}}
 }
+void t13() {
+  __asm m{o}v eax, ebx // expected-error {{expected identifier}} expected-error {{use of undeclared label '{o}v eax, ebx'}}
+}
+
 int t_fail() { // expected-note {{to match this}}
   __asm 
   __asm { // expected-error 3 {{expected}} expected-note {{to match this}}
Index: cfe/trunk/test/CodeGen/ms-inline-asm.c
===
--- cfe/trunk/test/CodeGen/ms-inline-asm.c
+++ cfe/trunk/test/CodeGen/ms-inline-asm.c
@@ -86,7 +86,7 @@
 __asm { pop ebx }
   }
 // CHECK: t9
-// CHECK: call void asm sideeffect inteldialect "push ebx\0A\09mov ebx, $$0x07\0A\09pop ebx", "~{ebx},~{esp},~{dirflag},~{fpsr},~{flags}"()
+// CHECK: call void asm sideeffect inteldialect "push ebx\0A\09mov ebx, $$0x07\0A\09pop ebx\0A\09", "~{ebx},~{esp},~{dirflag},~{fpsr},~{flags}"()
 }
 
 unsigned t10(void) {
Index: cfe/trunk/test/CodeGen/ms-inline-asm-avx512.c
===
--- cfe/trunk/test/CodeGen/ms-inline-asm-avx512.c
+++ cfe/trunk/test/CodeGen/ms-inline-asm-avx512.c
@@ -9,3 +9,13 @@
 	  vaddpd zmm8, zmm27, zmm6
   }
 }
+
+
+void t2() {
+// CHECK: @t2
+// CHECK: call void asm sideeffect inteldialect "vaddpd zmm8 {k1}, zmm27, zmm6", "~{zmm8},~{dirflag},~{fpsr},~{flags}"()
+// CHECK: ret void
+  __asm {
+	  vaddpd zmm8 {k1}, zmm27, zmm6
+  }
+}
Index: cfe/trunk/lib/Parse/ParseStmtAsm.cpp
===
--- cfe/trunk/lib/Parse/ParseStmtAsm.cpp
+++

r262845 - python binding: expose compile command filename

2016-03-07 Thread Guillaume Papin via cfe-commits
Author: papin_g
Date: Mon Mar  7 12:44:42 2016
New Revision: 262845

URL: http://llvm.org/viewvc/llvm-project?rev=262845&view=rev
Log:
python binding: expose compile command filename

Reviewers: compnerd, skalinichev

Differential Revision: http://reviews.llvm.org/D17278

Modified:
cfe/trunk/bindings/python/clang/cindex.py
cfe/trunk/bindings/python/tests/cindex/test_cdb.py

Modified: cfe/trunk/bindings/python/clang/cindex.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/clang/cindex.py?rev=262845&r1=262844&r2=262845&view=diff
==
--- cfe/trunk/bindings/python/clang/cindex.py (original)
+++ cfe/trunk/bindings/python/clang/cindex.py Mon Mar  7 12:44:42 2016
@@ -2703,6 +2703,11 @@ class CompileCommand(object):
 return conf.lib.clang_CompileCommand_getDirectory(self.cmd)
 
 @property
+def filename(self):
+"""Get the working filename for this CompileCommand"""
+return conf.lib.clang_CompileCommand_getFilename(self.cmd)
+
+@property
 def arguments(self):
 """
 Get an iterable object providing each argument in the
@@ -2883,6 +2888,11 @@ functionList = [
[c_object_p],
_CXString,
_CXString.from_result),
+
+  ("clang_CompileCommand_getFilename",
+   [c_object_p],
+   _CXString,
+   _CXString.from_result),
 
   ("clang_CompileCommand_getNumArgs",
[c_object_p],

Modified: cfe/trunk/bindings/python/tests/cindex/test_cdb.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/tests/cindex/test_cdb.py?rev=262845&r1=262844&r2=262845&view=diff
==
--- cfe/trunk/bindings/python/tests/cindex/test_cdb.py (original)
+++ cfe/trunk/bindings/python/tests/cindex/test_cdb.py Mon Mar  7 12:44:42 2016
@@ -38,27 +38,34 @@ def test_all_compilecommand():
 cmds = cdb.getAllCompileCommands()
 assert len(cmds) == 3
 expected = [
+{ 'wd': '/home/john.doe/MyProject',
+  'file': '/home/john.doe/MyProject/project.cpp',
+  'line': ['clang++', '-o', 'project.o', '-c',
+   '/home/john.doe/MyProject/project.cpp']},
 { 'wd': '/home/john.doe/MyProjectA',
+  'file': '/home/john.doe/MyProject/project2.cpp',
   'line': ['clang++', '-o', 'project2.o', '-c',
'/home/john.doe/MyProject/project2.cpp']},
 { 'wd': '/home/john.doe/MyProjectB',
+  'file': '/home/john.doe/MyProject/project2.cpp',
   'line': ['clang++', '-DFEATURE=1', '-o', 'project2-feature.o', '-c',
'/home/john.doe/MyProject/project2.cpp']},
-{ 'wd': '/home/john.doe/MyProject',
-  'line': ['clang++', '-o', 'project.o', '-c',
-   '/home/john.doe/MyProject/project.cpp']}
+
 ]
 for i in range(len(cmds)):
 assert cmds[i].directory == expected[i]['wd']
+assert cmds[i].filename == expected[i]['file']
 for arg, exp in zip(cmds[i].arguments, expected[i]['line']):
 assert arg == exp
 
 def test_1_compilecommand():
 """Check file with single compile command"""
 cdb = CompilationDatabase.fromDirectory(kInputsDir)
-cmds = cdb.getCompileCommands('/home/john.doe/MyProject/project.cpp')
+file = '/home/john.doe/MyProject/project.cpp'
+cmds = cdb.getCompileCommands(file)
 assert len(cmds) == 1
-assert cmds[0].directory == '/home/john.doe/MyProject'
+assert cmds[0].directory == os.path.dirname(file)
+assert cmds[0].filename == file
 expected = [ 'clang++', '-o', 'project.o', '-c',
  '/home/john.doe/MyProject/project.cpp']
 for arg, exp in zip(cmds[0].arguments, expected):


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r262847 - [CLANG][AVX512][BUILTIN] Add builtin vcomi{ss|sd}

2016-03-07 Thread Michael Zuckerman via cfe-commits
Author: mzuckerm
Date: Mon Mar  7 13:15:00 2016
New Revision: 262847

URL: http://llvm.org/viewvc/llvm-project?rev=262847&view=rev
Log:
[CLANG][AVX512][BUILTIN] Add builtin vcomi{ss|sd}

Differential Revision: http://reviews.llvm.org/D17919


Modified:
cfe/trunk/include/clang/Basic/BuiltinsX86.def
cfe/trunk/lib/Headers/avx512fintrin.h
cfe/trunk/test/CodeGen/avx512f-builtins.c

Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=262847&r1=262846&r2=262847&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Mon Mar  7 13:15:00 2016
@@ -1747,6 +1747,8 @@ TARGET_BUILTIN(__builtin_ia32_vpermt2var
 TARGET_BUILTIN(__builtin_ia32_vpermt2varqi128_maskz, 
"V16cV16cV16cV16cUs","","avx512vbmi,avx512vl")
 TARGET_BUILTIN(__builtin_ia32_vpermt2varqi256_mask, 
"V32cV32cV32cV32cUi","","avx512vbmi,avx512vl")
 TARGET_BUILTIN(__builtin_ia32_vpermt2varqi256_maskz, 
"V32cV32cV32cV32cUi","","avx512vbmi,avx512vl")
+TARGET_BUILTIN(__builtin_ia32_vcomisd, "iV2dV2dIiIi","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_vcomiss, "iV4fV4fIiIi","","avx512f")
 
 #undef BUILTIN
 #undef TARGET_BUILTIN

Modified: cfe/trunk/lib/Headers/avx512fintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512fintrin.h?rev=262847&r1=262846&r2=262847&view=diff
==
--- cfe/trunk/lib/Headers/avx512fintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512fintrin.h Mon Mar  7 13:15:00 2016
@@ -3695,6 +3695,14 @@ _mm512_maskz_movedup_pd (__mmask8 __U, _
(__mmask8) __U);
 }
 
+#define _mm_comi_round_sd(__A, __B, __P, __R) __extension__ ({\
+__builtin_ia32_vcomisd ((__v2df) (__A), (__v2df) (__B), ( __P), (  __R));\
+})
+
+#define _mm_comi_round_ss( __A,  __B, __P, __R) __extension__ ({\
+__builtin_ia32_vcomiss ((__v4sf) (__A), (__v4sf) (__B), ( __P), ( __R));\
+})
+
 
 #undef __DEFAULT_FN_ATTRS
 

Modified: cfe/trunk/test/CodeGen/avx512f-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/avx512f-builtins.c?rev=262847&r1=262846&r2=262847&view=diff
==
--- cfe/trunk/test/CodeGen/avx512f-builtins.c (original)
+++ cfe/trunk/test/CodeGen/avx512f-builtins.c Mon Mar  7 13:15:00 2016
@@ -2364,4 +2364,14 @@ __m512d test_mm512_maskz_movedup_pd(__mm
   return _mm512_maskz_movedup_pd(__U, __A); 
 }
 
+int test_mm_comi_round_sd(__m128d __A, __m128d __B) {
+  // CHECK-LABEL: @test_mm_comi_round_sd
+  // CHECK: @llvm.x86.avx512.vcomi.sd
+  return _mm_comi_round_sd(__A, __B, 5, 3); 
+}
 
+int test_mm_comi_round_ss(__m128 __A, __m128 __B) {
+  // CHECK-LABEL: @test_mm_comi_round_ss
+  // CHECK: @llvm.x86.avx512.vcomi.ss
+  return _mm_comi_round_ss(__A, __B, 5, 3); 
+}


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D16993: Add missing __builtin_bitreverse8

2016-03-07 Thread Matt Arsenault via cfe-commits
arsenm added a comment.

I directly copied this from the bit reverse intrinsic documentation, so that 
will need to be fixed too



From: Arthur O'Dwyer 
Sent: Monday, March 7, 2016 11:56 AM
To: 
reviews+http://reviews.llvm.org/d16993+public+3e6e84ed28c57...@reviews.llvm.org;
 Arsenault, Matthew
Subject: Re: [PATCH] http://reviews.llvm.org/D16993: Add missing 
__builtin_bitreverse8


http://reviews.llvm.org/D16993



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D16044: getVariableName() for MemRegion

2016-03-07 Thread Alexander Droste via cfe-commits
Alexander_Droste added a comment.

Hi Devin,
thanks for taking the time! Yes, this is kind of implicitly tested by the MPI 
patch but I agree that it is necessary to add tests to MemRegion.



Comment at: include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h:160
@@ -153,1 +159,3 @@
+  /// \returns variable name for memory region
+  std::string getVariableName() const;
 };

dcoughlin wrote:
> I'm not sure that 'getVariableName()' conveys what this function does. The 
> returned name is not always the name of a variable. How do you intend to use 
> this method? How is it different than than printPretty()? Is it for debugging 
> purposes? If so, then perhaps 'getDebugDescription()'? Is it for presentation 
> to the user? Then perhaps 'getDescriptiveName()'?
> The returned name is not always the name of a variable.
In which cases doesn't this function return the name? Isn't the worst case when 
`printPretty` can't be called and the string is empty?

The function is intended to return the variable name and collects index 
variable names / `ConcreteInt`s along the way if the passed region is an 
`ElementRegion`. So `printPretty` is called on the 'top' region of an array at 
the end of this function. If the passed region is no `ElementRegion` the 
functionality is identical to `printPretty`. 

The main motivation to write this function was to include specific indices in a 
diagnostic if obtainable, like presented in the MPI-Checker testfile  
http://reviews.llvm.org/D12761#3c51dfcf.
E.g. `Request 'sendReq1[1][7][9]' has no matching nonblocking call.` My intent 
was not to use the function for debugging purposes.

So should we use `getDescriptiveName` or maybe sth. like 
`getVariableNameWithIndices`?.


Comment at: lib/StaticAnalyzer/Core/MemRegion.cpp:635
@@ -634,1 +634,3 @@
 
+std::string MemRegion::getVariableName() const {
+  std::string VariableName;

dcoughlin wrote:
> It seems like this could potentially be simplified by adding a recursive 
> helper that threads the output stream and appends to it after the base case 
> has been hit. You could also modify prettyPrint() to take a flag indicating 
> whether it should be quoted or not (and defaulting to true). What do you 
> think?
Modifying `printPretty` seems like a nice solution to me. If you don't prefer 
the other idea, I would go this route.


http://reviews.llvm.org/D16044



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17764: Add attributes for AMD GPU Tools

2016-03-07 Thread Konstantin Zhuravlyov via cfe-commits
kzhuravl-AMD marked 2 inline comments as done.
kzhuravl-AMD added a comment.

http://reviews.llvm.org/D17764



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17764: Add attributes for AMD GPU Tools

2016-03-07 Thread Konstantin Zhuravlyov via cfe-commits
kzhuravl-AMD updated this revision to Diff 49990.
kzhuravl-AMD added a comment.

Review Feedback - Updated diff


http://reviews.llvm.org/D17764

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.def
  lib/CodeGen/CGCall.cpp
  lib/CodeGen/TargetInfo.cpp
  lib/Driver/Tools.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/CodeGenOpenCL/amdgpu-tools-attrs-opts-precedence.cl
  test/CodeGenOpenCL/amdgpu-tools-attrs.cl
  test/CodeGenOpenCL/amdgpu-tools-opts.cl
  test/SemaOpenCL/amdgpu-tools-attrs.cl

Index: test/SemaOpenCL/amdgpu-tools-attrs.cl
===
--- /dev/null
+++ test/SemaOpenCL/amdgpu-tools-attrs.cl
@@ -0,0 +1,50 @@
+// RUN: %clang_cc1 -triple amdgcn--amdhsa -verify -fsyntax-only %s
+
+// Check attributes with non kernel function
+__attribute__((amdgpu_tools_insert_nops)) void not_kernel0() {} // expected-error {{'amdgpu_tools_insert_nops' attribute only applies to kernel functions}}
+__attribute__((amdgpu_tools_num_reserved_vgpr(8))) void not_kernel1() {} // expected-error {{'amdgpu_tools_num_reserved_vgpr' attribute only applies to kernel functions}}
+__attribute__((amdgpu_tools_num_reserved_sgpr(4))) void not_kernel2() {} // expected-error {{'amdgpu_tools_num_reserved_sgpr' attribute only applies to kernel functions}}
+typedef __attribute__((amdgpu_tools_insert_nops)) struct foo0_s { // expected-error {{'amdgpu_tools_insert_nops' attribute only applies to kernel functions}}
+  int x;
+  int y;
+} foo0_t;
+typedef __attribute__((amdgpu_tools_num_reserved_vgpr(8))) struct foo1_s { // expected-error {{'amdgpu_tools_num_reserved_vgpr' attribute only applies to kernel functions}}
+  int x;
+  int y;
+} foo1_t;
+typedef __attribute__((amdgpu_tools_num_reserved_sgpr(4))) struct foo2_s { // expected-error {{'amdgpu_tools_num_reserved_sgpr' attribute only applies to kernel functions}}
+  int x;
+  int y;
+} foo2_t;
+
+// Check non integer attribute values.
+__attribute__((amdgpu_tools_num_reserved_vgpr("ABC"))) kernel void foo3() {} // expected-error {{'amdgpu_tools_num_reserved_vgpr' attribute requires an integer constant}}
+__attribute__((amdgpu_tools_num_reserved_sgpr("DEF"))) kernel void foo4() {} // expected-error {{'amdgpu_tools_num_reserved_sgpr' attribute requires an integer constant}}
+
+// Check large attribute values.
+__attribute__((amdgpu_tools_num_reserved_vgpr(4294967296))) kernel void foo5() {} // expected-error {{integer constant expression evaluates to value 4294967296 that cannot be represented in a 32-bit unsigned integer type}}
+__attribute__((amdgpu_tools_num_reserved_sgpr(4294967296))) kernel void foo6() {} // expected-error {{integer constant expression evaluates to value 4294967296 that cannot be represented in a 32-bit unsigned integer type}}
+__attribute__((amdgpu_tools_num_reserved_vgpr(4294967296), amdgpu_tools_num_reserved_sgpr(4294967296))) kernel void foo7() {} // expected-error 2 {{integer constant expression evaluates to value 4294967296 that cannot be represented in a 32-bit unsigned integer type}}
+
+// Check valid attributes.
+__attribute__((amdgpu_tools_insert_nops)) kernel void foo8() {}
+__attribute__((amdgpu_tools_num_reserved_vgpr(8))) kernel void foo9() {}
+__attribute__((amdgpu_tools_insert_nops, amdgpu_tools_num_reserved_vgpr(8))) kernel void foo10() {}
+__attribute__((amdgpu_tools_num_reserved_sgpr(4))) kernel void foo11() {}
+__attribute__((amdgpu_tools_insert_nops, amdgpu_tools_num_reserved_sgpr(4))) kernel void foo12() {}
+__attribute__((amdgpu_tools_num_reserved_vgpr(8), amdgpu_tools_num_reserved_sgpr(4))) kernel void foo13() {}
+__attribute__((amdgpu_tools_insert_nops, amdgpu_tools_num_reserved_vgpr(8), amdgpu_tools_num_reserved_sgpr(4))) kernel void foo14() {}
+// Make sure 0 VGPRs is accepted.
+__attribute__((amdgpu_tools_num_reserved_vgpr(0))) kernel void foo15() {}
+// Make sure 0 SGPRs is accepted.
+__attribute__((amdgpu_tools_num_reserved_sgpr(0))) kernel void foo16() {}
+// Make sure 0 VGPRs and 0 SGPRs is accepted.
+__attribute__((amdgpu_tools_num_reserved_vgpr(0), amdgpu_tools_num_reserved_sgpr(0))) kernel void foo17() {}
+// Make sure kernel keyword can go before __attribute__ keyword.
+kernel __attribute__((amdgpu_tools_insert_nops)) void foo18() {}
+kernel __attribute__((amdgpu_tools_num_reserved_vgpr(8))) void foo19() {}
+kernel __attribute__((amdgpu_tools_insert_nops, amdgpu_tools_num_reserved_vgpr(8))) void foo20() {}
+kernel __attribute__((amdgpu_tools_num_reserved_sgpr(4))) void foo21() {}
+kernel __attribute__((amdgpu_tools_insert_nops, amdgpu_tools_num_reserved_sgpr(4))) void foo22() {}
+kernel __attribute__((amdgpu_tools_num_reserved_vgpr(8), amdgpu_tools_num_reserved_sgpr(4))) void foo23() {}
+kernel __attribute__((amdgpu_tools_insert_nops, amdgpu_tools_num_reserved_vgpr(8), amdgpu_tools_num_reserved_sgpr(4))) void foo24() {}
Index: test/CodeGenOpenCL/amdgpu-t

r262851 - Module Debugging: Fix a crash when emitting debug info for nested tag types

2016-03-07 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Mon Mar  7 14:58:52 2016
New Revision: 262851

URL: http://llvm.org/viewvc/llvm-project?rev=262851&view=rev
Log:
Module Debugging: Fix a crash when emitting debug info for nested tag types
whose DeclContext is not yet complete by deferring their emission.

rdar://problem/24918680

Modified:
cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
cfe/trunk/test/Modules/Inputs/DebugCXX.h
cfe/trunk/test/Modules/ModuleDebugInfo.cpp

Modified: cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp?rev=262851&r1=262850&r2=262851&view=diff
==
--- cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp (original)
+++ cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp Mon Mar  7 
14:58:52 2016
@@ -201,6 +201,15 @@ public:
 if (D->getName().empty())
   return;
 
+// Defer tag decls until their declcontext is complete.
+auto *DeclCtx = D->getDeclContext();
+while (DeclCtx) {
+  if (auto *D = dyn_cast(DeclCtx))
+if (!D->isCompleteDefinition())
+  return;
+  DeclCtx = DeclCtx->getParent();
+}
+
 DebugTypeVisitor DTV(*Builder->getModuleDebugInfo(), *Ctx);
 DTV.TraverseDecl(D);
 Builder->UpdateCompletedType(D);

Modified: cfe/trunk/test/Modules/Inputs/DebugCXX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/DebugCXX.h?rev=262851&r1=262850&r2=262851&view=diff
==
--- cfe/trunk/test/Modules/Inputs/DebugCXX.h (original)
+++ cfe/trunk/test/Modules/Inputs/DebugCXX.h Mon Mar  7 14:58:52 2016
@@ -72,3 +72,14 @@ namespace {
 struct InAnonymousNamespace { int i; };
   }
 }
+
+class Base;
+class A {
+  virtual Base *getParent() const;
+};
+class Base {};
+class Derived : Base {
+  class B : A {
+Derived *getParent() const override;
+  };
+};

Modified: cfe/trunk/test/Modules/ModuleDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/ModuleDebugInfo.cpp?rev=262851&r1=262850&r2=262851&view=diff
==
--- cfe/trunk/test/Modules/ModuleDebugInfo.cpp (original)
+++ cfe/trunk/test/Modules/ModuleDebugInfo.cpp Mon Mar  7 14:58:52 2016
@@ -71,6 +71,13 @@
 // CHECK-NOT:  name:
 // CHECK-SAME: identifier: "_ZTS13TypedefStruct")
 
+// CHECK: !DICompositeType(tag: DW_TAG_class_type, name: "Derived",
+// CHECK-SAME: identifier: "_ZTS7Derived")
+// CHECK: !DICompositeType(tag: DW_TAG_class_type, name: "B", scope: 
!"_ZTS7Derived",
+// CHECK-SAME: elements: ![[B_MBRS:.*]], vtableHolder: !"_ZTS1A"
+// CHECK: ![[B_MBRS]] = !{{{.*}}, ![[GET_PARENT:.*]]}
+// CHECK: ![[GET_PARENT]] = !DISubprogram(name: "getParent"
+
 // CHECK: !DIDerivedType(tag: DW_TAG_typedef, name: "FloatInstatiation"
 // no mangled name here yet.
 


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D16044: getVariableName() for MemRegion

2016-03-07 Thread Devin Coughlin via cfe-commits
dcoughlin added inline comments.


Comment at: include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h:160
@@ -153,1 +159,3 @@
+  /// \returns variable name for memory region
+  std::string getVariableName() const;
 };

Alexander_Droste wrote:
> dcoughlin wrote:
> > I'm not sure that 'getVariableName()' conveys what this function does. The 
> > returned name is not always the name of a variable. How do you intend to 
> > use this method? How is it different than than printPretty()? Is it for 
> > debugging purposes? If so, then perhaps 'getDebugDescription()'? Is it for 
> > presentation to the user? Then perhaps 'getDescriptiveName()'?
> > The returned name is not always the name of a variable.
> In which cases doesn't this function return the name? Isn't the worst case 
> when `printPretty` can't be called and the string is empty?
> 
> The function is intended to return the variable name and collects index 
> variable names / `ConcreteInt`s along the way if the passed region is an 
> `ElementRegion`. So `printPretty` is called on the 'top' region of an array 
> at the end of this function. If the passed region is no `ElementRegion` the 
> functionality is identical to `printPretty`. 
> 
> The main motivation to write this function was to include specific indices in 
> a diagnostic if obtainable, like presented in the MPI-Checker testfile  
> http://reviews.llvm.org/D12761#3c51dfcf.
> E.g. `Request 'sendReq1[1][7][9]' has no matching nonblocking call.` My 
> intent was not to use the function for debugging purposes.
> 
> So should we use `getDescriptiveName` or maybe sth. like 
> `getVariableNameWithIndices`?.
Can the string ever be something like 'a.f[0][1]' (i.e., with a field name)? Or 
is it always 'a[0][1]'? If the first is possible I would suggest 
`getDescriptiveName` -- if not, then `getVariableNameWithIndices` seems fine.


Comment at: lib/StaticAnalyzer/Core/MemRegion.cpp:635
@@ -634,1 +634,3 @@
 
+std::string MemRegion::getVariableName() const {
+  std::string VariableName;

Alexander_Droste wrote:
> dcoughlin wrote:
> > It seems like this could potentially be simplified by adding a recursive 
> > helper that threads the output stream and appends to it after the base case 
> > has been hit. You could also modify prettyPrint() to take a flag indicating 
> > whether it should be quoted or not (and defaulting to true). What do you 
> > think?
> Modifying `printPretty` seems like a nice solution to me. If you don't prefer 
> the other idea, I would go this route.
Sounds good to me!


http://reviews.llvm.org/D16044



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r262866 - non-member swap for array was mistakenly taking const ref params. Fixed and added test. Thanks to Ben Craig for the catch

2016-03-07 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Mon Mar  7 15:57:10 2016
New Revision: 262866

URL: http://llvm.org/viewvc/llvm-project?rev=262866&view=rev
Log:
non-member swap for array was mistakenly taking const ref params. Fixed and 
added test. Thanks to Ben Craig for the catch

Modified:
libcxx/trunk/include/array
libcxx/trunk/test/std/containers/sequences/array/array.swap/swap.pass.cpp

Modified: libcxx/trunk/include/array
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/array?rev=262866&r1=262865&r2=262866&view=diff
==
--- libcxx/trunk/include/array (original)
+++ libcxx/trunk/include/array Mon Mar  7 15:57:10 2016
@@ -279,7 +279,7 @@ typename enable_if
 __is_swappable<_Tp>::value,
 void
 >::type
-swap(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
+swap(array<_Tp, _Size>& __x, array<_Tp, _Size>& __y)
   
_NOEXCEPT_(__is_nothrow_swappable<_Tp>::value)
 {
 __x.swap(__y);

Modified: 
libcxx/trunk/test/std/containers/sequences/array/array.swap/swap.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/array/array.swap/swap.pass.cpp?rev=262866&r1=262865&r2=262866&view=diff
==
--- libcxx/trunk/test/std/containers/sequences/array/array.swap/swap.pass.cpp 
(original)
+++ libcxx/trunk/test/std/containers/sequences/array/array.swap/swap.pass.cpp 
Mon Mar  7 15:57:10 2016
@@ -10,9 +10,10 @@
 // 
 
 // void swap(array& a);
+// namespace std { void swap(array &x, array &y);
 
-#include 
 #include 
+#include 
 
 // std::array is explicitly allowed to be initialized with A a = { init-list 
};.
 // Disable the missing braces warning for this reason.
@@ -37,6 +38,22 @@ int main()
 }
 {
 typedef double T;
+typedef std::array C;
+C c1 = {1, 2, 3.5};
+C c2 = {4, 5, 6.5};
+std::swap(c1, c2);
+assert(c1.size() == 3);
+assert(c1[0] == 4);
+assert(c1[1] == 5);
+assert(c1[2] == 6.5);
+assert(c2.size() == 3);
+assert(c2[0] == 1);
+assert(c2[1] == 2);
+assert(c2[2] == 3.5);
+}
+
+{
+typedef double T;
 typedef std::array C;
 C c1 = {};
 C c2 = {};
@@ -44,4 +61,14 @@ int main()
 assert(c1.size() == 0);
 assert(c2.size() == 0);
 }
+{
+typedef double T;
+typedef std::array C;
+C c1 = {};
+C c2 = {};
+std::swap(c1, c2);
+assert(c1.size() == 0);
+assert(c2.size() == 0);
+}
+
 }


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17700: [clang-format] Proposal for changes to Objective-C block formatting

2016-03-07 Thread Tony Arnold via cfe-commits
tonyarnold added a comment.

> Blocks aren't the same as braces


Yeah, good point. I guess I was just seeing the brace in the block, but that's 
the wrong way to think about it.


http://reviews.llvm.org/D17700



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D17941: add fix-its for format-security warnings

2016-03-07 Thread Bob Wilson via cfe-commits
bob.wilson created this revision.
bob.wilson added reviewers: bcraig, rjmccall, dblaikie.
bob.wilson added a subscriber: cfe-commits.
Herald added a subscriber: mcrosier.

The format-security warning is a special case of format-nonliteral that applies 
when there are no arguments besides the format string. In those cases, for 
printf and NSLog-style functions, there is an easy fix to provide a literal 
format string of "%s" (or @"%@" for Objective-C), with the nonliteral string as 
the argument. This patch teaches clang to provide fix-its for those cases.

http://reviews.llvm.org/D17941

Files:
  lib/Sema/SemaChecking.cpp
  test/Sema/format-strings-fixit.c
  test/SemaObjC/format-strings-objc-fixit.m

Index: test/SemaObjC/format-strings-objc-fixit.m
===
--- /dev/null
+++ test/SemaObjC/format-strings-objc-fixit.m
@@ -0,0 +1,31 @@
+// RUN: cp %s %t
+// RUN: %clang_cc1 -x objective-c -triple x86_64-apple-darwin -Wno-objc-root-class -pedantic -Wall -fixit %t
+// RUN: %clang_cc1 -x objective-c -triple x86_64-apple-darwin -Wno-objc-root-class -fsyntax-only -pedantic -Wall -Werror %t
+// RUN: %clang_cc1 -x objective-c -triple x86_64-apple-darwin -Wno-objc-root-class -E -o - %t | FileCheck %s
+
+typedef signed char BOOL;
+typedef unsigned int NSUInteger;
+typedef struct _NSZone NSZone;
+@class NSCoder, NSString, NSEnumerator;
+@protocol NSObject  - (BOOL)isEqual:(id)object; @end
+@protocol NSCopying  - (id)copyWithZone:(NSZone *)zone; @end
+@protocol NSMutableCopying  - (id)mutableCopyWithZone:(NSZone *)zone; @end
+@protocol NSCoding  - (void)encodeWithCoder:(NSCoder *)aCoder; @end
+@interface NSObject  {} @end
+@interface NSString : NSObject   - (NSUInteger)length; @end
+extern void NSLog(NSString *format, ...);
+
+/* This is a test of the various code modification hints that are
+   provided as part of warning or extension diagnostics. All of the
+   warnings will be fixed by -fixit, and the resulting file should
+   compile cleanly with -Werror -pedantic. */
+
+extern NSString *NonliteralString;
+
+void test() {
+  // nonliteral format
+  NSLog(NonliteralString);
+}
+
+// Validate the fixes.
+// CHECK: NSLog(@"%@", NonliteralString);
Index: test/Sema/format-strings-fixit.c
===
--- test/Sema/format-strings-fixit.c
+++ test/Sema/format-strings-fixit.c
@@ -16,6 +16,8 @@
 typedef __PTRDIFF_TYPE__ ptrdiff_t;
 typedef __WCHAR_TYPE__ wchar_t;
 
+extern const char *NonliteralString;
+
 void test() {
   // Basic types
   printf("%s", (int) 123);
@@ -94,6 +96,9 @@
   printf("%G", (long double) 42);
   printf("%a", (long double) 42);
   printf("%A", (long double) 42);
+
+  // nonliteral format
+  printf(NonliteralString);
 }
 
 int scanf(char const *, ...);
@@ -218,6 +223,7 @@
 // CHECK: printf("%LG", (long double) 42);
 // CHECK: printf("%La", (long double) 42);
 // CHECK: printf("%LA", (long double) 42);
+// CHECK: printf("%s", NonliteralString);
 
 // CHECK: scanf("%99s", str);
 // CHECK: scanf("%s", vstr);
Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -3621,20 +3621,32 @@
   // format is either NSString or CFString. This is a hack to prevent
   // diag when using the NSLocalizedString and CFCopyLocalizedString macros
   // which are usually used in place of NS and CF string literals.
-  if (Type == FST_NSString &&
-  SourceMgr.isInSystemMacro(Args[format_idx]->getLocStart()))
+  SourceLocation FormatLoc = Args[format_idx]->getLocStart();
+  if (Type == FST_NSString && SourceMgr.isInSystemMacro(FormatLoc))
 return false;
 
   // If there are no arguments specified, warn with -Wformat-security, otherwise
   // warn only with -Wformat-nonliteral.
-  if (Args.size() == firstDataArg)
-Diag(Args[format_idx]->getLocStart(),
- diag::warn_format_nonliteral_noargs)
+  if (Args.size() == firstDataArg) {
+const SemaDiagnosticBuilder &D =
+  Diag(FormatLoc, diag::warn_format_nonliteral_noargs);
+switch (Type) {
+default:
+  D << OrigFormatExpr->getSourceRange();
+  break;
+case FST_Kprintf:
+case FST_FreeBSDKPrintf:
+case FST_Printf:
+  D << FixItHint::CreateInsertion(FormatLoc, "\"%s\", ");
+  break;
+case FST_NSString:
+  D << FixItHint::CreateInsertion(FormatLoc, "@\"%@\", ");
+  break;
+}
+  } else {
+Diag(FormatLoc, diag::warn_format_nonliteral)
   << OrigFormatExpr->getSourceRange();
-  else
-Diag(Args[format_idx]->getLocStart(),
- diag::warn_format_nonliteral)
-   << OrigFormatExpr->getSourceRange();
+  }
   return false;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r262871 - Implement P0025R0: 'An algorithm to clamp a value between a pair of boundary values' for C++17

2016-03-07 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Mon Mar  7 16:43:49 2016
New Revision: 262871

URL: http://llvm.org/viewvc/llvm-project?rev=262871&view=rev
Log:
Implement P0025R0: 'An algorithm to clamp a value between a pair of boundary 
values' for C++17

Added:
libcxx/trunk/test/std/algorithms/alg.sorting/alg.clamp/
libcxx/trunk/test/std/algorithms/alg.sorting/alg.clamp/clamp.comp.pass.cpp
libcxx/trunk/test/std/algorithms/alg.sorting/alg.clamp/clamp.pass.cpp
Modified:
libcxx/trunk/include/algorithm
libcxx/trunk/www/cxx1z_status.html

Modified: libcxx/trunk/include/algorithm
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/algorithm?rev=262871&r1=262870&r2=262871&view=diff
==
--- libcxx/trunk/include/algorithm (original)
+++ libcxx/trunk/include/algorithm Mon Mar  7 16:43:49 2016
@@ -543,6 +543,12 @@ template
 T
 min(initializer_list t, Compare comp);  // constexpr in C++14
 
+template
+constexpr const T& clamp( const T& v, const T& lo, const T& hi );  
 // C++17
+
+template
+constexpr const T& clamp( const T& v, const T& lo, const T& hi, Compare 
comp ); // C++17
+
 template 
 ForwardIterator
 max_element(ForwardIterator first, ForwardIterator last);  // constexpr in 
C++14
@@ -2657,6 +2663,27 @@ max(initializer_list<_Tp> __t)
 
 #endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
 
+#if _LIBCPP_STD_VER > 14
+// clamp
+template
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+const _Tp&
+clamp(const _Tp& __v, const _Tp& __lo, const _Tp& __hi, _Compare __comp)
+{
+_LIBCPP_ASSERT(!__comp(__hi, __lo), "Bad bounds passed to std::clamp");
+return __comp(__v, __lo) ? __lo : __comp(__hi, __v) ? __hi : __v;
+
+}
+
+template
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+const _Tp&
+clamp(const _Tp& __v, const _Tp& __lo, const _Tp& __hi)
+{
+return _VSTD::clamp(__v, __lo, __hi, __less<_Tp>());
+}
+#endif
+
 // minmax_element
 
 template 

Added: 
libcxx/trunk/test/std/algorithms/alg.sorting/alg.clamp/clamp.comp.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/algorithms/alg.sorting/alg.clamp/clamp.comp.pass.cpp?rev=262871&view=auto
==
--- libcxx/trunk/test/std/algorithms/alg.sorting/alg.clamp/clamp.comp.pass.cpp 
(added)
+++ libcxx/trunk/test/std/algorithms/alg.sorting/alg.clamp/clamp.comp.pass.cpp 
Mon Mar  7 16:43:49 2016
@@ -0,0 +1,61 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// 
+// XFAIL: c++03, c++11, c++14
+
+// template
+//   const T&
+//   clamp(const T& v, const T& lo, const T& hi, Compare comp);
+
+#include 
+#include 
+#include 
+
+template 
+void
+test(const T& v, const T& lo, const T& hi, C c, const T& x)
+{
+assert(&std::clamp(v, lo, hi, c) == &x);
+}
+
+int main()
+{
+{
+int x = 0;
+int y = 0;
+int z = 0;
+test(x, y, z, std::greater(), x);
+test(y, x, z, std::greater(), y);
+}
+{
+int x = 0;
+int y = 1;
+int z = -1;
+test(x, y, z, std::greater(), x);
+test(y, x, z, std::greater(), x);
+}
+{
+int x = 1;
+int y = 0;
+int z = 0;
+test(x, y, z, std::greater(), y);
+test(y, x, z, std::greater(), y);
+}
+#if _LIBCPP_STD_VER > 11
+{
+typedef int T;
+constexpr T x = 1;
+constexpr T y = 0;
+constexpr T z = 0;
+static_assert(std::clamp(x, y, z, std::greater()) == y, "" );
+static_assert(std::clamp(y, x, z, std::greater()) == y, "" );
+}
+#endif
+}

Added: libcxx/trunk/test/std/algorithms/alg.sorting/alg.clamp/clamp.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/algorithms/alg.sorting/alg.clamp/clamp.pass.cpp?rev=262871&view=auto
==
--- libcxx/trunk/test/std/algorithms/alg.sorting/alg.clamp/clamp.pass.cpp 
(added)
+++ libcxx/trunk/test/std/algorithms/alg.sorting/alg.clamp/clamp.pass.cpp Mon 
Mar  7 16:43:49 2016
@@ -0,0 +1,60 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// 
+// XFAIL: c++03, c++11, c++14
+
+// template
+//   const T&
+//   clamp(const T& v, const T& lo, const T& hi);
+
+#include 
+#include 
+
+template 
+void
+test(const T& a, const T& lo, const T& hi, const T& x)
+{
+assert(&std::clamp(a, l

r262872 - Implement support for [[nodiscard]] in C++1z that is based off existing support for warn_unused_result, and treat it as an extension pre-C++1z. This also means extending the existing warn_un

2016-03-07 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Mon Mar  7 16:44:55 2016
New Revision: 262872

URL: http://llvm.org/viewvc/llvm-project?rev=262872&view=rev
Log:
Implement support for [[nodiscard]] in C++1z that is based off existing support 
for warn_unused_result, and treat it as an extension pre-C++1z. This also means 
extending the existing warn_unused_result attribute so that it can be placed on 
an enum as well as a class.

Added:
cfe/trunk/test/SemaCXX/nodiscard.cpp
Modified:
cfe/trunk/include/clang/AST/Decl.h
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/include/clang/Basic/AttrDocs.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Sema/AttributeList.h
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/lib/Parse/ParseDeclCXX.cpp
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/lib/Sema/SemaStmt.cpp
cfe/trunk/test/Sema/unused-expr.c
cfe/trunk/test/SemaObjC/method-warn-unused-attribute.m
cfe/trunk/www/cxx_status.html

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=262872&r1=262871&r2=262872&view=diff
==
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Mon Mar  7 16:44:55 2016
@@ -2025,12 +2025,16 @@ public:
 return 
getType()->getAs()->getCallResultType(getASTContext());
   }
 
+  /// \brief Returns the WarnUnusedResultAttr that is either declared on this
+  /// function, or its return type declaration.
+  const Attr *getUnusedResultAttr() const;
+
   /// \brief Returns true if this function or its return type has the
   /// warn_unused_result attribute. If the return type has the attribute and
   /// this function is a method of the return type's class, then false will be
   /// returned to avoid spurious warnings on member methods such as assignment
   /// operators.
-  bool hasUnusedResultAttr() const;
+  bool hasUnusedResultAttr() const { return getUnusedResultAttr() != nullptr; }
 
   /// \brief Returns the storage class as written in the source. For the
   /// computed linkage of symbol, see getLinkage.

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=262872&r1=262871&r2=262872&view=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Mon Mar  7 16:44:55 2016
@@ -1537,11 +1537,12 @@ def WarnUnused : InheritableAttr {
 }
 
 def WarnUnusedResult : InheritableAttr {
-  let Spellings = [GCC<"warn_unused_result">,
-   CXX11<"clang", "warn_unused_result">];
-  let Subjects = SubjectList<[ObjCMethod, CXXRecord, FunctionLike], WarnDiag,
- "ExpectedFunctionMethodOrClass">;
-  let Documentation = [Undocumented];
+  let Spellings = [CXX11<"", "nodiscard", 201603>,
+   CXX11<"clang", "warn_unused_result">,
+   GCC<"warn_unused_result">];
+  let Subjects = SubjectList<[ObjCMethod, Enum, CXXRecord, FunctionLike],
+ WarnDiag, "ExpectedFunctionMethodEnumOrClass">;
+  let Documentation = [WarnUnusedResultsDocs];
 }
 
 def Weak : InheritableAttr {

Modified: cfe/trunk/include/clang/Basic/AttrDocs.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrDocs.td?rev=262872&r1=262871&r2=262872&view=diff
==
--- cfe/trunk/include/clang/Basic/AttrDocs.td (original)
+++ cfe/trunk/include/clang/Basic/AttrDocs.td Mon Mar  7 16:44:55 2016
@@ -729,6 +729,31 @@ When one method overrides another, the o
   }];
 }
 
+def WarnUnusedResultsDocs : Documentation {
+  let Category = DocCatFunction;
+  let Heading = "nodiscard, warn_unused_result, clang::warn_unused_result, 
gnu::warn_unused_result";
+  let Content  = [{
+Clang supports the ability to diagnose when the results of a function call
+expression are discarded under suspicious circumstances. A diagnostic is
+generated when a function or its return type is marked with ``[[nodiscard]]``
+(or ``__attribute__((warn_unused_result))``) and the function call appears as a
+potentially-evaluated discarded-value expression that is not explicitly cast to
+`void`.
+
+.. code-block: c++
+  struct [[nodiscard]] error_info { /*...*/ };
+  error_info enable_missile_safety_mode();
+  
+  void launch_missiles();
+  void test_missiles() {
+enable_missile_safety_mode(); // diagnoses
+launch_missiles();
+  }
+  error_info &foo();
+  void f() { foo(); } // Does not diagnose, error_info is a reference.  
+  }];
+}
+
 def FallthroughDocs : Documentation {
   let Category = DocCatStmt;
   let Content = [{

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Diagno

Re: [PATCH] D17811: [clang-tidy] Add check to detect dangling references in value handlers.

2016-03-07 Thread Samuel Benzaquen via cfe-commits
sbenza added inline comments.


Comment at: clang-tidy/misc/DanglingHandleCheck.cpp:24
@@ +23,3 @@
+
+std::vector parseClasses(StringRef Option) {
+  SmallVector Classes;

alexfh wrote:
> A very similar code has been added recently to 
> clang-tidy/utils/HeaderFileExtensionsUtils.*. Maybe make that code generic 
> enough and reuse it?
It is not the same.
That one is filtering the characters using isAlphanumeric.
Type names can have non-alpha chars as part of template instantiations.

On the other hand, it is a copy of the one from FasterStringFindCheck.
We could move it to a central location.


Comment at: clang-tidy/misc/DanglingHandleCheck.cpp:57
@@ +56,3 @@
+ast_matchers::internal::Matcher isASequence() {
+  return hasAnyName("::std::deque", "::std::forward_list", "::std::list",
+"::std::vector");

jbcoe wrote:
> Will this (and similar checkers) handle inline namespaces?
Yes. hasName() and hasAnyName() have been fixed to look through inline 
namespaces.


Comment at: clang-tidy/misc/DanglingHandleCheck.cpp:116
@@ +115,3 @@
+  return cxxRecordDecl(internal::Matcher(
+   new internal::HasNameMatcher(HandleClasses)))
+  .bind("handle");

alexfh wrote:
> This use of internal classes doesn't look nice. Can you add a `hasAnyName` 
> overload taking a `set` or an `ArrayRef` of names (or maybe a template 
> version that'll take a range of something convertible to StringRef)?
Will do.


Comment at: test/clang-tidy/misc-dangling-handle.cpp:73
@@ +72,3 @@
+  StringRef(const char*);  // NOLINT
+  StringRef(const std::string&);  // NOLINT
+};

jbcoe wrote:
> What does `NOLINT` do here?
Removed. Not needed here.


Comment at: test/clang-tidy/misc-dangling-handle.cpp:85
@@ +84,3 @@
+  std::string_view view_2 = ReturnsAString();
+  // CHECK-MESSAGES: [[@LINE-1]]:29: warning: std::basic_string_view outlives
+

jbcoe wrote:
> This (and other) check-messages line looks truncated.
They are truncated on purpose.
We use the full message in the first one to check the message.
The rest are truncated to fit in 80 chars.


http://reviews.llvm.org/D17811



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17811: [clang-tidy] Add check to detect dangling references in value handlers.

2016-03-07 Thread Samuel Benzaquen via cfe-commits
sbenza updated this revision to Diff 49998.
sbenza marked 3 inline comments as done.
sbenza added a comment.

Minor fixes


http://reviews.llvm.org/D17811

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/DanglingHandleCheck.cpp
  clang-tidy/misc/DanglingHandleCheck.h
  clang-tidy/misc/MiscTidyModule.cpp
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-dangling-handle.rst
  test/clang-tidy/misc-dangling-handle.cpp

Index: test/clang-tidy/misc-dangling-handle.cpp
===
--- /dev/null
+++ test/clang-tidy/misc-dangling-handle.cpp
@@ -0,0 +1,191 @@
+// RUN: %check_clang_tidy %s misc-dangling-handle %t -- \
+// RUN:   -config="{CheckOptions: \
+// RUN: [{key: misc-dangling-handle.HandleClasses, \
+// RUN:   value: 'std::basic_string_view; ::llvm::StringRef;'}]}" \
+// RUN:   -- -std=c++11
+
+namespace std {
+
+template 
+class vector {
+ public:
+  using const_iterator = const T*;
+  using iterator = T*;
+  using size_type = int;
+
+  void assign(size_type count, const T& value);
+  iterator insert(const_iterator pos, const T& value);
+  iterator insert(const_iterator pos, T&& value);
+  iterator insert(const_iterator pos, size_type count, const T& value);
+  void push_back(const T&);
+  void push_back(T&&);
+  void resize(size_type count, const T& value);
+};
+
+template 
+class pair {};
+
+template 
+class set {
+ public:
+  using const_iterator = const T*;
+  using iterator = T*;
+
+  std::pair insert(const T& value);
+  std::pair insert(T&& value);
+  iterator insert(const_iterator hint, const T& value);
+  iterator insert(const_iterator hint, T&& value);
+};
+
+template 
+class map {
+ public:
+  using value_type = pair;
+  value_type& operator[](const Key& key);
+  value_type& operator[](Key&& key);
+};
+
+class basic_string {
+ public:
+  basic_string();
+  basic_string(const char*);
+  ~basic_string();
+};
+
+typedef basic_string string;
+
+class basic_string_view {
+ public:
+  basic_string_view(const char*);
+  basic_string_view(const basic_string&);
+};
+
+typedef basic_string_view string_view;
+
+}  // namespace std
+
+namespace llvm {
+
+class StringRef {
+ public:
+  StringRef();
+  StringRef(const char*);
+  StringRef(const std::string&);
+};
+
+}  // namespace llvm
+
+std::string ReturnsAString();
+
+void Positives() {
+  std::string_view view1 = std::string();
+  // CHECK-MESSAGES: [[@LINE-1]]:20: warning: std::basic_string_view outlives its value [misc-dangling-handle]
+
+  std::string_view view_2 = ReturnsAString();
+  // CHECK-MESSAGES: [[@LINE-1]]:20: warning: std::basic_string_view outlives
+
+  view1 = std::string();
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: std::basic_string_view outlives
+
+  const std::string& str_ref = "";
+  std::string_view view3 = true ? "A" : str_ref;
+  // CHECK-MESSAGES: [[@LINE-1]]:20: warning: std::basic_string_view outlives
+  view3 = true ? "A" : str_ref;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: std::basic_string_view outlives
+
+  std::string_view view4(ReturnsAString());
+  // CHECK-MESSAGES: [[@LINE-1]]:20: warning: std::basic_string_view outlives
+}
+
+void OtherTypes() {
+  llvm::StringRef ref = std::string();
+  // CHECK-MESSAGES: [[@LINE-1]]:19: warning: llvm::StringRef outlives its value
+}
+
+const char static_array[] = "A";
+std::string_view ReturnStatements(int i, std::string value_arg,
+  const std::string &ref_arg) {
+  const char array[] = "A";
+  const char* ptr = "A";
+  std::string s;
+  static std::string ss;
+  switch (i) {
+// Bad cases
+case 0:
+  return array;  // refers to local
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: std::basic_string_view outliv
+case 1:
+  return s;  // refers to local
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: std::basic_string_view outliv
+case 2:
+  return std::string();  // refers to temporary
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: std::basic_string_view outliv
+case 3:
+  return value_arg;  // refers to by-value arg
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: std::basic_string_view outliv
+
+// Ok cases
+case 100:
+  return ss;  // refers to static
+case 101:
+  return static_array;  // refers to static
+case 102:
+  return ptr;  // pointer is ok
+case 103:
+  return ref_arg;  // refers to by-ref arg
+  }
+
+  struct S {
+std::string_view view() { return value; }
+std::string value;
+  };
+
+  (void)[&]()->std::string_view {
+// This should not warn. The string is bound by reference.
+return s;
+  };
+  (void)[=]() -> std::string_view {
+// This should not warn. The reference is valid as long as the lambda.
+return s;
+  };
+  (void)[=]() -> std::string_view {
+// FIXME: This one should warn. We are returning a reference to a local
+// lambda variable.
+std::string local;
+return local;
+  };
+  return "";
+}
+
+void Con

Re: [PATCH] D15729: Load compiler plugins in ASTUnit, too

2016-03-07 Thread Kevin Funk via cfe-commits
kfunk updated this revision to Diff 4.
kfunk added a comment.
This revision is now accepted and ready to land.

Remove TODO statement


http://reviews.llvm.org/D15729

Files:
  include/clang/Frontend/CompilerInstance.h
  lib/Frontend/ASTUnit.cpp
  lib/Frontend/CompilerInstance.cpp
  lib/FrontendTool/ExecuteCompilerInvocation.cpp
  test/CXX/drs/dr3xx.cpp
  unittests/Frontend/CMakeLists.txt
  unittests/Frontend/FrontendActionTest.cpp
  unittests/Frontend/PrintFunctionNamesTestPlugin/CMakeLists.txt
  
unittests/Frontend/PrintFunctionNamesTestPlugin/PrintFunctionNamesTestPlugin.cpp

Index: unittests/Frontend/PrintFunctionNamesTestPlugin/PrintFunctionNamesTestPlugin.cpp
===
--- /dev/null
+++ unittests/Frontend/PrintFunctionNamesTestPlugin/PrintFunctionNamesTestPlugin.cpp
@@ -0,0 +1,123 @@
+//===- PrintFunctionNames.cpp -===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// Example clang plugin which simply prints the names of all the top-level decls
+// in the input file.
+//
+//===--===//
+
+#include "clang/Frontend/FrontendPluginRegistry.h"
+#include "clang/AST/AST.h"
+#include "clang/AST/ASTConsumer.h"
+#include "clang/AST/RecursiveASTVisitor.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Sema/Sema.h"
+#include "llvm/Support/raw_ostream.h"
+using namespace clang;
+
+namespace {
+
+class PrintFunctionsConsumer : public ASTConsumer {
+  CompilerInstance &Instance;
+  std::set ParsedTemplates;
+
+public:
+  PrintFunctionsConsumer(CompilerInstance &Instance,
+ std::set ParsedTemplates)
+  : Instance(Instance), ParsedTemplates(ParsedTemplates) {}
+
+  bool HandleTopLevelDecl(DeclGroupRef DG) override {
+for (DeclGroupRef::iterator i = DG.begin(), e = DG.end(); i != e; ++i) {
+  const Decl *D = *i;
+  if (const NamedDecl *ND = dyn_cast(D))
+llvm::errs() << "top-level-decl: \"" << ND->getNameAsString() << "\"\n";
+}
+
+return true;
+  }
+
+  void HandleTranslationUnit(ASTContext& context) override {
+if (!Instance.getLangOpts().DelayedTemplateParsing)
+  return;
+
+// This demonstrates how to force instantiation of some templates in
+// -fdelayed-template-parsing mode. (Note: Doing this unconditionally for
+// all templates is similar to not using -fdelayed-template-parsig in the
+// first place.)
+// The advantage of doing this in HandleTranslationUnit() is that all
+// codegen (when using -add-plugin) is completely finished and this can't
+// affect the compiler output.
+struct Visitor : public RecursiveASTVisitor {
+  const std::set &ParsedTemplates;
+  Visitor(const std::set &ParsedTemplates)
+  : ParsedTemplates(ParsedTemplates) {}
+  bool VisitFunctionDecl(FunctionDecl *FD) {
+if (FD->isLateTemplateParsed() &&
+ParsedTemplates.count(FD->getNameAsString()))
+  LateParsedDecls.insert(FD);
+return true;
+  }
+
+  std::set LateParsedDecls;
+} v(ParsedTemplates);
+v.TraverseDecl(context.getTranslationUnitDecl());
+clang::Sema &sema = Instance.getSema();
+for (const FunctionDecl *FD : v.LateParsedDecls) {
+  clang::LateParsedTemplate* LPT = sema.LateParsedTemplateMap.lookup(FD);
+  sema.LateTemplateParser(sema.OpaqueParser, *LPT);
+  llvm::errs() << "late-parsed-decl: \"" << FD->getNameAsString() << "\"\n";
+}
+  }
+};
+
+class PrintFunctionNamesAction : public PluginASTAction {
+  std::set ParsedTemplates;
+protected:
+  std::unique_ptr CreateASTConsumer(CompilerInstance &CI,
+ llvm::StringRef) override {
+return llvm::make_unique(CI, ParsedTemplates);
+  }
+
+  bool ParseArgs(const CompilerInstance &CI,
+ const std::vector &args) override {
+for (unsigned i = 0, e = args.size(); i != e; ++i) {
+  llvm::errs() << "PrintFunctionNames arg = " << args[i] << "\n";
+
+  // Example error handling.
+  DiagnosticsEngine &D = CI.getDiagnostics();
+  if (args[i] == "-an-error") {
+unsigned DiagID = D.getCustomDiagID(DiagnosticsEngine::Error,
+"invalid argument '%0'");
+D.Report(DiagID) << args[i];
+return false;
+  } else if (args[i] == "-parse-template") {
+if (i + 1 >= e) {
+  D.Report(D.getCustomDiagID(DiagnosticsEngine::Error,
+ "missing -parse-template argument"));
+  return false;
+}
+++i;
+ParsedTemplates.insert(args[i]);
+  }
+}
+if (!args.empty() && args[0] 

Re: [PATCH] D15921: [analyzer] Utility to match function calls.

2016-03-07 Thread Anna Zaks via cfe-commits
zaks.anna added a comment.

> Side note: Has anybody ever considered just treating fopen and fclose like 
> malloc and free?


Yes, there are a few checkers that follow the same open/close rule and could in 
theory be merged together.



Comment at: cfe/trunk/lib/StaticAnalyzer/Checkers/SimpleStreamChecker.cpp:106
@@ -108,3 +105,3 @@
 SimpleStreamChecker::SimpleStreamChecker()
-: IIfopen(nullptr), IIfclose(nullptr) {
+: OpenFn("fopen"), CloseFn("fclose", 1) {
   // Initialize the bug types.

ariccio wrote:
> Why specify the RequiredArgs for `fclose`,  and not `fopen`?
Not sure. Maybe it's an omission.


Repository:
  rL LLVM

http://reviews.llvm.org/D15921



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15729: Load compiler plugins in ASTUnit, too

2016-03-07 Thread Kevin Funk via cfe-commits
kfunk added a comment.

Okay, just gave this another look. Unit test seems fine as-is. Let's call 
`loadPlugins` there explicitly.

@LLVM/Clang devs: Please review!

I'm especially interested in whether you think there's a better location for 
calling `CompilerInstance::loadPlugins` than in `ASTUnit::Parse`.


http://reviews.llvm.org/D15729



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17908: Add Visual Studio Visualizers for more Clang types

2016-03-07 Thread Mike Spertus via cfe-commits
mspertus added a comment.

Hmm, testing reveals that the preexisting clang.natvis does not work in VS2013!

  Natvis: E:\Users\mspertus\Documents\Visual Studio 
2013\Visualizers\clang.natvis(59,21): Error: identifier 
"clang::TypeAlignmentInBits" is undefined

If I change all clang.natvis occurrences of clang::TypeAlignmentInBits to 4, it 
now works in VS2013 and VS2015, including all my edits. While this kind of 
hardwiring is brittle, it seems like the best option until we drop VS2013 
support.

Is it ok for me to make that change?


http://reviews.llvm.org/D17908



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17908: Add Visual Studio Visualizers for more Clang types

2016-03-07 Thread Aaron Ballman via cfe-commits
aaron.ballman added a comment.

In http://reviews.llvm.org/D17908#369337, @mspertus wrote:

> Hmm, testing reveals that the preexisting clang.natvis does not work in 
> VS2013!
>
>   Natvis: E:\Users\mspertus\Documents\Visual Studio 
> 2013\Visualizers\clang.natvis(59,21): Error: identifier 
> "clang::TypeAlignmentInBits" is undefined
>   
>
> If I change all clang.natvis occurrences of clang::TypeAlignmentInBits to 4, 
> it now works in VS2013 and VS2015, including all my edits. While this kind of 
> hardwiring is brittle, it seems like the best option until we drop VS2013 
> support.
>
> Is it ok for me to make that change?


Yeah, I think that change makes sense. We can always rectify it when we drop 
support for MSVC 2013. Good catch!


http://reviews.llvm.org/D17908



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D17947: [Driver] [Darwin] Fix linking libclang_rt.profile_*sim.a

2016-03-07 Thread Chris Bieneman via cfe-commits
beanz created this revision.
beanz added reviewers: zaks.anna, bogner.
beanz added a subscriber: cfe-commits.

isTarget*() calls are order-dependent. This is because iOS Sim *is* iOS. This 
means checks for the simulator version of the platform must always be ahead of 
checks for the embedded platform.

http://reviews.llvm.org/D17947

Files:
  lib/Driver/ToolChains.cpp
  test/Driver/darwin-ld.c

Index: test/Driver/darwin-ld.c
===
--- test/Driver/darwin-ld.c
+++ test/Driver/darwin-ld.c
@@ -152,6 +152,12 @@
 // RUN: FileCheck -check-prefix=LINK_NO_IOS_ARM64_CRT1 %s < %t.log
 // LINK_NO_IOS_ARM64_CRT1-NOT: crt
 
+// RUN: %clang -target x86_64-apple-ios6.0 -miphoneos-version-min=6.0 
-fprofile-instr-generate -### %t.o 2> %t.log
+// RUN: FileCheck -check-prefix=LINK_IOSSIM_PROFILE %s < %t.log
+// LINK_IOSSIM_PROFILE: {{ld(.exe)?"}}
+// LINK_IOSSIM_PROFILE: libclang_rt.profile_iossim.a
+// LINK_IOSSIM_PROFILE: libclang_rt.ios.a
+
 // RUN: %clang -target arm64-apple-tvos8.3 -mtvos-version-min=8.3 -### %t.o 2> 
%t.log
 // RUN: FileCheck -check-prefix=LINK_TVOS_ARM64 %s < %t.log
 // LINK_TVOS_ARM64: {{ld(.exe)?"}}
Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -359,24 +359,24 @@
   const char *Library = "libclang_rt.profile_osx.a";
 
   // Select the appropriate runtime library for the target.
-  if (isTargetWatchOS()) {
-Library = "libclang_rt.profile_watchos.a";
-  } else if (isTargetWatchOSSimulator()) {
+  if (isTargetWatchOSSimulator()) {
 llvm::sys::path::append(P, "libclang_rt.profile_watchossim.a");
 Library = getVFS().exists(P) ? "libclang_rt.profile_watchossim.a"
  : "libclang_rt.profile_watchos.a";
-  } else if (isTargetTvOS()) {
-Library = "libclang_rt.profile_tvos.a";
+  } else if (isTargetWatchOS()) {
+Library = "libclang_rt.profile_watchos.a";
   } else if (isTargetTvOSSimulator()) {
 llvm::sys::path::append(P, "libclang_rt.profile_tvossim.a");
 Library = getVFS().exists(P) ? "libclang_rt.profile_tvossim.a"
  : "libclang_rt.profile_tvos.a";
-  } else if (isTargetIPhoneOS()) {
-Library = "libclang_rt.profile_ios.a";
+  } else if (isTargetTvOS()) {
+Library = "libclang_rt.profile_tvos.a";
   } else if (isTargetIOSSimulator()) {
 llvm::sys::path::append(P, "libclang_rt.profile_iossim.a");
 Library = getVFS().exists(P) ? "libclang_rt.profile_iossim.a"
  : "libclang_rt.profile_ios.a";
+  } else if (isTargetIPhoneOS()) {
+Library = "libclang_rt.profile_ios.a";
   } else {
 assert(isTargetMacOS() && "unexpected non MacOS platform");
   }


Index: test/Driver/darwin-ld.c
===
--- test/Driver/darwin-ld.c
+++ test/Driver/darwin-ld.c
@@ -152,6 +152,12 @@
 // RUN: FileCheck -check-prefix=LINK_NO_IOS_ARM64_CRT1 %s < %t.log
 // LINK_NO_IOS_ARM64_CRT1-NOT: crt
 
+// RUN: %clang -target x86_64-apple-ios6.0 -miphoneos-version-min=6.0 -fprofile-instr-generate -### %t.o 2> %t.log
+// RUN: FileCheck -check-prefix=LINK_IOSSIM_PROFILE %s < %t.log
+// LINK_IOSSIM_PROFILE: {{ld(.exe)?"}}
+// LINK_IOSSIM_PROFILE: libclang_rt.profile_iossim.a
+// LINK_IOSSIM_PROFILE: libclang_rt.ios.a
+
 // RUN: %clang -target arm64-apple-tvos8.3 -mtvos-version-min=8.3 -### %t.o 2> %t.log
 // RUN: FileCheck -check-prefix=LINK_TVOS_ARM64 %s < %t.log
 // LINK_TVOS_ARM64: {{ld(.exe)?"}}
Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -359,24 +359,24 @@
   const char *Library = "libclang_rt.profile_osx.a";
 
   // Select the appropriate runtime library for the target.
-  if (isTargetWatchOS()) {
-Library = "libclang_rt.profile_watchos.a";
-  } else if (isTargetWatchOSSimulator()) {
+  if (isTargetWatchOSSimulator()) {
 llvm::sys::path::append(P, "libclang_rt.profile_watchossim.a");
 Library = getVFS().exists(P) ? "libclang_rt.profile_watchossim.a"
  : "libclang_rt.profile_watchos.a";
-  } else if (isTargetTvOS()) {
-Library = "libclang_rt.profile_tvos.a";
+  } else if (isTargetWatchOS()) {
+Library = "libclang_rt.profile_watchos.a";
   } else if (isTargetTvOSSimulator()) {
 llvm::sys::path::append(P, "libclang_rt.profile_tvossim.a");
 Library = getVFS().exists(P) ? "libclang_rt.profile_tvossim.a"
  : "libclang_rt.profile_tvos.a";
-  } else if (isTargetIPhoneOS()) {
-Library = "libclang_rt.profile_ios.a";
+  } else if (isTargetTvOS()) {
+Library = "libclang_rt.profile_tvos.a";
   } else if (isTargetIOSSimulator()) {
 llvm::sys::path::append(P, "libclang_rt.profile_iossim.a");
 Library = getVFS().exists(P) ? "libclang_rt.profile_iossim.a"
 

r262881 - P0188R1: add support for standard [[fallthrough]] attribute. This is almost

2016-03-07 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Mon Mar  7 18:32:55 2016
New Revision: 262881

URL: http://llvm.org/viewvc/llvm-project?rev=262881&view=rev
Log:
P0188R1: add support for standard [[fallthrough]] attribute. This is almost
exactly the same as clang's existing [[clang::fallthrough]] attribute, which
has been updated to have the same semantics. The one significant difference
is that [[fallthrough]] is ill-formed if it's not used immediately before a
switch label (even when -Wimplicit-fallthrough is disabled). To support that,
we now build a CFG of any function that uses a '[[fallthrough]];' statement
to check.

In passing, fix some bugs with our support for statement attributes -- in
particular, diagnose their use on declarations, rather than asserting.

Modified:
cfe/trunk/include/clang/AST/Attr.h
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/include/clang/Basic/AttrDocs.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Sema/AttributeList.h
cfe/trunk/include/clang/Sema/ScopeInfo.h
cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
cfe/trunk/lib/Sema/AttributeList.cpp
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/lib/Sema/SemaStmtAttr.cpp
cfe/trunk/test/Analysis/cxx11-crashes.cpp
cfe/trunk/test/PCH/Inputs/cxx11-statement-attributes.h
cfe/trunk/test/PCH/cxx11-statement-attributes.cpp
cfe/trunk/test/Parser/cxx0x-attributes.cpp
cfe/trunk/test/SemaCXX/for-range-examples.cpp
cfe/trunk/test/SemaCXX/generalized-deprecated.cpp
cfe/trunk/test/SemaCXX/nodiscard.cpp
cfe/trunk/test/SemaCXX/switch-implicit-fallthrough-macro.cpp
cfe/trunk/test/SemaCXX/switch-implicit-fallthrough-per-method.cpp
cfe/trunk/test/SemaCXX/switch-implicit-fallthrough.cpp
cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp
cfe/trunk/www/cxx_status.html

Modified: cfe/trunk/include/clang/AST/Attr.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Attr.h?rev=262881&r1=262880&r2=262881&view=diff
==
--- cfe/trunk/include/clang/AST/Attr.h (original)
+++ cfe/trunk/include/clang/AST/Attr.h Mon Mar  7 18:32:55 2016
@@ -118,6 +118,19 @@ public:
   bool duplicatesAllowed() const { return DuplicatesAllowed; }
 };
 
+class StmtAttr : public Attr {
+protected:
+  StmtAttr(attr::Kind AK, SourceRange R, unsigned SpellingListIndex,
+  bool IsLateParsed, bool DuplicatesAllowed)
+  : Attr(AK, R, SpellingListIndex, IsLateParsed, DuplicatesAllowed) {}
+
+public:
+  static bool classof(const Attr *A) {
+return A->getKind() >= attr::FirstStmtAttr &&
+   A->getKind() <= attr::LastStmtAttr;
+  }
+};
+
 class InheritableAttr : public Attr {
 protected:
   InheritableAttr(attr::Kind AK, SourceRange R, unsigned SpellingListIndex,

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=262881&r1=262880&r2=262881&view=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Mon Mar  7 18:32:55 2016
@@ -311,6 +311,9 @@ class TypeAttr : Attr {
   let ASTNode = 0;
 }
 
+/// A stmt attribute is not processed on a declaration or a type.
+class StmtAttr : Attr;
+
 /// An inheritable attribute is inherited by later redeclarations.
 class InheritableAttr : Attr;
 
@@ -738,8 +741,9 @@ def ExtVectorType : Attr {
   let Documentation = [Undocumented];
 }
 
-def FallThrough : Attr {
-  let Spellings = [CXX11<"clang", "fallthrough">];
+def FallThrough : StmtAttr {
+  let Spellings = [CXX11<"", "fallthrough", 201503>,
+   CXX11<"clang", "fallthrough">];
 //  let Subjects = [NullStmt];
   let Documentation = [FallthroughDocs];
 }

Modified: cfe/trunk/include/clang/Basic/AttrDocs.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrDocs.td?rev=262881&r1=262880&r2=262881&view=diff
==
--- cfe/trunk/include/clang/Basic/AttrDocs.td (original)
+++ cfe/trunk/include/clang/Basic/AttrDocs.td Mon Mar  7 18:32:55 2016
@@ -756,9 +756,10 @@ potentially-evaluated discarded-value ex
 
 def FallthroughDocs : Documentation {
   let Category = DocCatStmt;
+  let Heading = "fallthrough, clang::fallthrough";
   let Content = [{
-The ``clang::fallthrough`` attribute is used along with the
-``-Wimplicit-fallthrough`` argument to annotate intentional fall-through
+The ``fallthrough`` (or ``clang::fallthrough``) attribute is used
+to annotate intentional fall-through
 between switch labels.  It can only be applied to a null statement placed at a
 point of execution between any statement and the next switch label.  It is
 common to mark these places with a specific comment, but this attribute is
@@ -769,6 +770,10 @@ control-flow statements like ``break;``,
 where ``break;`` can, but 

r262882 - Add accidentally forgotten testcase from r262881.

2016-03-07 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Mon Mar  7 18:34:49 2016
New Revision: 262882

URL: http://llvm.org/viewvc/llvm-project?rev=262882&view=rev
Log:
Add accidentally forgotten testcase from r262881.

Added:
cfe/trunk/test/CXX/dcl.dcl/dcl.attr/dcl.attr.fallthrough/
cfe/trunk/test/CXX/dcl.dcl/dcl.attr/dcl.attr.fallthrough/p1.cpp

Added: cfe/trunk/test/CXX/dcl.dcl/dcl.attr/dcl.attr.fallthrough/p1.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/dcl.dcl/dcl.attr/dcl.attr.fallthrough/p1.cpp?rev=262882&view=auto
==
--- cfe/trunk/test/CXX/dcl.dcl/dcl.attr/dcl.attr.fallthrough/p1.cpp (added)
+++ cfe/trunk/test/CXX/dcl.dcl/dcl.attr/dcl.attr.fallthrough/p1.cpp Mon Mar  7 
18:34:49 2016
@@ -0,0 +1,70 @@
+// RUN: %clang_cc1 -std=c++1z -verify %s
+
+void f(int n) {
+  switch (n) {
+  case 0:
+n += 1;
+[[fallthrough]]; // ok
+  case 1:
+if (n) {
+  [[fallthrough]]; // ok
+} else {
+  return;
+}
+  case 2:
+for (int n = 0; n != 10; ++n)
+  [[fallthrough]]; // expected-error {{does not directly precede switch 
label}}
+  case 3:
+while (true)
+  [[fallthrough]]; // expected-error {{does not directly precede switch 
label}}
+  case 4:
+while (false)
+  [[fallthrough]]; // expected-error {{does not directly precede switch 
label}}
+  case 5:
+do [[fallthrough]]; while (true); // expected-error {{does not directly 
precede switch label}}
+  case 6:
+do [[fallthrough]]; while (false); // expected-error {{does not directly 
precede switch label}}
+  case 7:
+switch (n) {
+case 0:
+  // FIXME: This should be an error, even though the next thing we do is to
+  // fall through in an outer switch statement.
+  [[fallthrough]];
+}
+  case 8:
+[[fallthrough]]; // expected-error {{does not directly precede switch 
label}}
+goto label;
+  label:
+  case 9:
+n += 1;
+  case 10: // no warning, -Wimplicit-fallthrough is not enabled in this test, 
and does not need to
+   // be enabled for these diagnostics to be produced.
+break;
+  }
+}
+
+[[fallthrough]] typedef int n; // expected-error {{'fallthrough' attribute 
cannot be applied to a declaration}}
+typedef int [[fallthrough]] n; // expected-error {{'fallthrough' attribute 
cannot be applied to types}}
+typedef int n [[fallthrough]]; // expected-error {{'fallthrough' attribute 
cannot be applied to a declaration}}
+
+enum [[fallthrough]] E {}; // expected-error {{'fallthrough' attribute cannot 
be applied to a declaration}}
+class [[fallthrough]] C {}; // expected-error {{'fallthrough' attribute cannot 
be applied to a declaration}}
+
+[[fallthrough]] // expected-error {{'fallthrough' attribute cannot be applied 
to a declaration}}
+void g() {
+  [[fallthrough]] int n; // expected-error {{'fallthrough' attribute cannot be 
applied to a declaration}}
+  [[fallthrough]] ++n; // expected-error-re ^}}fallthrough attribute is 
only allowed on empty statements}}
+
+  switch (n) {
+// FIXME: This should be an error.
+[[fallthrough]];
+return;
+
+  case 0:
+[[fallthrough, fallthrough]]; // expected-error {{multiple times}}
+  case 1:
+[[fallthrough(0)]]; // expected-error {{argument list}}
+  case 2:
+break;
+  }
+}


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r262887 - Define __has_cpp_attribute(fallthrough) to a more reasonable value. (What year is it?!)

2016-03-07 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Mon Mar  7 18:40:32 2016
New Revision: 262887

URL: http://llvm.org/viewvc/llvm-project?rev=262887&view=rev
Log:
Define __has_cpp_attribute(fallthrough) to a more reasonable value. (What year 
is it?!)

Modified:
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/test/Preprocessor/has_attribute.cpp
cfe/trunk/test/SemaCXX/nodiscard.cpp

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=262887&r1=262886&r2=262887&view=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Mon Mar  7 18:40:32 2016
@@ -742,7 +742,7 @@ def ExtVectorType : Attr {
 }
 
 def FallThrough : StmtAttr {
-  let Spellings = [CXX11<"", "fallthrough", 201503>,
+  let Spellings = [CXX11<"", "fallthrough", 201603>,
CXX11<"clang", "fallthrough">];
 //  let Subjects = [NullStmt];
   let Documentation = [FallthroughDocs];

Modified: cfe/trunk/test/Preprocessor/has_attribute.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/has_attribute.cpp?rev=262887&r1=262886&r2=262887&view=diff
==
--- cfe/trunk/test/Preprocessor/has_attribute.cpp (original)
+++ cfe/trunk/test/Preprocessor/has_attribute.cpp Mon Mar  7 18:40:32 2016
@@ -52,6 +52,16 @@
   int has_cxx14_deprecated_vers();
 #endif
 
+// CHECK: has_cxx1z_nodiscard
+#if __has_cpp_attribute(nodiscard) == 201603
+  int has_cxx1z_nodiscard();
+#endif
+
+// CHECK: has_cxx1z_fallthrough
+#if __has_cpp_attribute(fallthrough) == 201603
+  int has_cxx1z_fallthrough();
+#endif
+
 // CHECK: has_declspec_uuid
 #if __has_declspec_attribute(uuid)
   int has_declspec_uuid();

Modified: cfe/trunk/test/SemaCXX/nodiscard.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/nodiscard.cpp?rev=262887&r1=262886&r2=262887&view=diff
==
--- cfe/trunk/test/SemaCXX/nodiscard.cpp (original)
+++ cfe/trunk/test/SemaCXX/nodiscard.cpp Mon Mar  7 18:40:32 2016
@@ -1,9 +1,6 @@
 // RUN: %clang_cc1 -fsyntax-only -std=c++1z -verify -Wc++1z-extensions %s
 // RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify -DEXT -Wc++1z-extensions %s
 
-#if !defined(EXT)
-static_assert(__has_cpp_attribute(nodiscard) == 201603);
-
 struct [[nodiscard]] S {};
 S get_s();
 S& get_s_ref();
@@ -28,6 +25,10 @@ void f() {
 [[nodiscard nodiscard]] int wrong1(); // expected-error {{attribute 
'nodiscard' cannot appear multiple times in an attribute specifier}}
 
 namespace [[nodiscard]] N {} // expected-warning {{'nodiscard' attribute only 
applies to functions, methods, enums, and classes}}
-#else
-struct [[nodiscard]] S {}; // expected-warning {{use of the 'nodiscard' 
attribute is a C++1z extension}}
-#endif // EXT
+
+#ifdef EXT
+// expected-warning@4 {{use of the 'nodiscard' attribute is a C++1z extension}}
+// expected-warning@8 {{use of the 'nodiscard' attribute is a C++1z extension}}
+// expected-warning@11 {{use of the 'nodiscard' attribute is a C++1z 
extension}}
+// expected-warning@25 2{{use of the 'nodiscard' attribute is a C++1z 
extension}}
+#endif


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r262888 - Move [[nodiscard]] tests into test/CXX tree.

2016-03-07 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Mon Mar  7 18:44:49 2016
New Revision: 262888

URL: http://llvm.org/viewvc/llvm-project?rev=262888&view=rev
Log:
Move [[nodiscard]] tests into test/CXX tree.

Added:
cfe/trunk/test/CXX/dcl.dcl/dcl.attr/dcl.attr.nodiscard/
cfe/trunk/test/CXX/dcl.dcl/dcl.attr/dcl.attr.nodiscard/p2.cpp
  - copied, changed from r262887, cfe/trunk/test/SemaCXX/nodiscard.cpp
cfe/trunk/test/CXX/dcl.dcl/dcl.attr/dcl.attr.nodiscard/p3.cpp
Removed:
cfe/trunk/test/SemaCXX/nodiscard.cpp

Copied: cfe/trunk/test/CXX/dcl.dcl/dcl.attr/dcl.attr.nodiscard/p2.cpp (from 
r262887, cfe/trunk/test/SemaCXX/nodiscard.cpp)
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/dcl.dcl/dcl.attr/dcl.attr.nodiscard/p2.cpp?p2=cfe/trunk/test/CXX/dcl.dcl/dcl.attr/dcl.attr.nodiscard/p2.cpp&p1=cfe/trunk/test/SemaCXX/nodiscard.cpp&r1=262887&r2=262888&rev=262888&view=diff
==
--- cfe/trunk/test/SemaCXX/nodiscard.cpp (original)
+++ cfe/trunk/test/CXX/dcl.dcl/dcl.attr/dcl.attr.nodiscard/p2.cpp Mon Mar  7 
18:44:49 2016
@@ -22,13 +22,8 @@ void f() {
   (void)get_e();
 }
 
-[[nodiscard nodiscard]] int wrong1(); // expected-error {{attribute 
'nodiscard' cannot appear multiple times in an attribute specifier}}
-
-namespace [[nodiscard]] N {} // expected-warning {{'nodiscard' attribute only 
applies to functions, methods, enums, and classes}}
-
 #ifdef EXT
 // expected-warning@4 {{use of the 'nodiscard' attribute is a C++1z extension}}
 // expected-warning@8 {{use of the 'nodiscard' attribute is a C++1z extension}}
 // expected-warning@11 {{use of the 'nodiscard' attribute is a C++1z 
extension}}
-// expected-warning@25 2{{use of the 'nodiscard' attribute is a C++1z 
extension}}
 #endif

Added: cfe/trunk/test/CXX/dcl.dcl/dcl.attr/dcl.attr.nodiscard/p3.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/dcl.dcl/dcl.attr/dcl.attr.nodiscard/p3.cpp?rev=262888&view=auto
==
--- cfe/trunk/test/CXX/dcl.dcl/dcl.attr/dcl.attr.nodiscard/p3.cpp (added)
+++ cfe/trunk/test/CXX/dcl.dcl/dcl.attr/dcl.attr.nodiscard/p3.cpp Mon Mar  7 
18:44:49 2016
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -std=c++1z -verify %s
+
+namespace std_example {
+  struct [[nodiscard]] error_info{
+// ...
+  };
+
+  error_info enable_missile_safety_mode();
+  void launch_missiles();
+  void test_missiles() {
+enable_missile_safety_mode(); // expected-warning {{ignoring return value 
of function declared with 'nodiscard'}}
+launch_missiles();
+  }
+
+  error_info &foo();
+  void f() { foo(); } // no warning
+}

Removed: cfe/trunk/test/SemaCXX/nodiscard.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/nodiscard.cpp?rev=262887&view=auto
==
--- cfe/trunk/test/SemaCXX/nodiscard.cpp (original)
+++ cfe/trunk/test/SemaCXX/nodiscard.cpp (removed)
@@ -1,34 +0,0 @@
-// RUN: %clang_cc1 -fsyntax-only -std=c++1z -verify -Wc++1z-extensions %s
-// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify -DEXT -Wc++1z-extensions %s
-
-struct [[nodiscard]] S {};
-S get_s();
-S& get_s_ref();
-
-enum [[nodiscard]] E {};
-E get_e();
-
-[[nodiscard]] int get_i();
-
-void f() {
-  get_s(); // expected-warning {{ignoring return value of function declared 
with 'nodiscard' attribute}}
-  get_i(); // expected-warning {{ignoring return value of function declared 
with 'nodiscard' attribute}}
-  get_e(); // expected-warning {{ignoring return value of function declared 
with 'nodiscard' attribute}}
-
-  // Okay, warnings are not encouraged
-  get_s_ref();
-  (void)get_s();
-  (void)get_i();
-  (void)get_e();
-}
-
-[[nodiscard nodiscard]] int wrong1(); // expected-error {{attribute 
'nodiscard' cannot appear multiple times in an attribute specifier}}
-
-namespace [[nodiscard]] N {} // expected-warning {{'nodiscard' attribute only 
applies to functions, methods, enums, and classes}}
-
-#ifdef EXT
-// expected-warning@4 {{use of the 'nodiscard' attribute is a C++1z extension}}
-// expected-warning@8 {{use of the 'nodiscard' attribute is a C++1z extension}}
-// expected-warning@11 {{use of the 'nodiscard' attribute is a C++1z 
extension}}
-// expected-warning@25 2{{use of the 'nodiscard' attribute is a C++1z 
extension}}
-#endif


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r262889 - Use class="svn" for features with SVN status.

2016-03-07 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Mon Mar  7 18:45:37 2016
New Revision: 262889

URL: http://llvm.org/viewvc/llvm-project?rev=262889&view=rev
Log:
Use class="svn" for features with SVN status.

Modified:
cfe/trunk/www/cxx_status.html

Modified: cfe/trunk/www/cxx_status.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/www/cxx_status.html?rev=262889&r1=262888&r2=262889&view=diff
==
--- cfe/trunk/www/cxx_status.html (original)
+++ cfe/trunk/www/cxx_status.html Mon Mar  7 18:45:37 2016
@@ -629,12 +629,12 @@ as the draft C++1z standard evolves.
 
   [[fallthrough]] attribute
   http://wg21.link/p0188r1";>P0188R1
-  SVN
+  SVN
 
 
   [[nodiscard]] attribute
   http://wg21.link/p0189r1";>P0189R1
-  SVN
+  SVN
 
 
   [[maybe_unused]] attribute


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r262894 - [analyzer] Fix missed leak from MSVC specific allocation functions

2016-03-07 Thread Anna Zaks via cfe-commits
Author: zaks
Date: Mon Mar  7 19:21:51 2016
New Revision: 262894

URL: http://llvm.org/viewvc/llvm-project?rev=262894&view=rev
Log:
[analyzer] Fix missed leak from MSVC specific allocation functions

Add the wide character strdup variants (wcsdup, _wcsdup) and the MSVC
version of alloca (_alloca) and other differently named function used
by the Malloc checker.

A patch by Alexander Riccio!

Differential Revision: http://reviews.llvm.org/D17688

Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
cfe/trunk/test/Analysis/malloc.c

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp?rev=262894&r1=262893&r2=262894&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp Mon Mar  7 19:21:51 
2016
@@ -169,11 +169,12 @@ class MallocChecker : public Checker BT_MismatchedDealloc;
   mutable std::unique_ptr BT_OffsetFree[CK_NumCheckKinds];
   mutable std::unique_ptr BT_UseZerroAllocated[CK_NumCheckKinds];
-  mutable IdentifierInfo *II_alloca, *II_malloc, *II_free, *II_realloc,
- *II_calloc, *II_valloc, *II_reallocf, *II_strndup,
- *II_strdup, *II_kmalloc, *II_if_nameindex,
- *II_if_freenameindex;
+  mutable IdentifierInfo *II_alloca, *II_win_alloca, *II_malloc, *II_free,
+ *II_realloc, *II_calloc, *II_valloc, *II_reallocf,
+ *II_strndup, *II_strdup, *II_win_strdup, *II_kmalloc,
+ *II_if_nameindex, *II_if_freenameindex, *II_wcsdup,
+ *II_win_wcsdup;
   mutable Optional KernelZeroFlagVal;
 
   void initIdentifierInfo(ASTContext &C) const;
@@ -540,9 +542,15 @@ void MallocChecker::initIdentifierInfo(A
   II_valloc = &Ctx.Idents.get("valloc");
   II_strdup = &Ctx.Idents.get("strdup");
   II_strndup = &Ctx.Idents.get("strndup");
+  II_wcsdup = &Ctx.Idents.get("wcsdup");
   II_kmalloc = &Ctx.Idents.get("kmalloc");
   II_if_nameindex = &Ctx.Idents.get("if_nameindex");
   II_if_freenameindex = &Ctx.Idents.get("if_freenameindex");
+
+  //MSVC uses `_`-prefixed instead, so we check for them too.
+  II_win_strdup = &Ctx.Idents.get("_strdup");
+  II_win_wcsdup = &Ctx.Idents.get("_wcsdup");
+  II_win_alloca = &Ctx.Idents.get("_alloca");
 }
 
 bool MallocChecker::isMemFunction(const FunctionDecl *FD, ASTContext &C) const 
{
@@ -585,7 +593,8 @@ bool MallocChecker::isCMemFunction(const
 if (Family == AF_Malloc && CheckAlloc) {
   if (FunI == II_malloc || FunI == II_realloc || FunI == II_reallocf ||
   FunI == II_calloc || FunI == II_valloc || FunI == II_strdup ||
-  FunI == II_strndup || FunI == II_kmalloc)
+  FunI == II_win_strdup || FunI == II_strndup || FunI == II_wcsdup ||
+  FunI == II_win_wcsdup || FunI == II_kmalloc)
 return true;
 }
 
@@ -600,7 +609,7 @@ bool MallocChecker::isCMemFunction(const
 }
 
 if (Family == AF_Alloca && CheckAlloc) {
-  if (FunI == II_alloca)
+  if (FunI == II_alloca || FunI == II_win_alloca)
 return true;
 }
   }
@@ -789,11 +798,12 @@ void MallocChecker::checkPostStmt(const
   State = ProcessZeroAllocation(C, CE, 1, State);
 } else if (FunI == II_free) {
   State = FreeMemAux(C, CE, State, 0, false, ReleasedAllocatedMemory);
-} else if (FunI == II_strdup) {
+} else if (FunI == II_strdup || FunI == II_win_strdup ||
+   FunI == II_wcsdup || FunI == II_win_wcsdup) {
   State = MallocUpdateRefState(C, CE, State);
 } else if (FunI == II_strndup) {
   State = MallocUpdateRefState(C, CE, State);
-} else if (FunI == II_alloca) {
+} else if (FunI == II_alloca || FunI == II_win_alloca) {
   State = MallocMemAux(C, CE, CE->getArg(0), UndefinedVal(), State,
AF_Alloca);
   State = ProcessZeroAllocation(C, CE, 0, State);

Modified: cfe/trunk/test/Analysis/malloc.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/malloc.c?rev=262894&r1=262893&r2=262894&view=diff
==
--- cfe/trunk/test/Analysis/malloc.c (original)
+++ cfe/trunk/test/Analysis/malloc.c Mon Mar  7 19:21:51 2016
@@ -4,6 +4,21 @@
 
 void clang_analyzer_eval(int);
 
+// Without -fms-compatibility, wchar_t isn't a builtin type. MSVC defines
+// _WCHAR_T_DEFINED if wchar_t is available. Microsoft recommends that you use
+// the builtin type: "Using the typedef version can cause portability
+// problems", but we're ok here because we're not actually running anything.
+// Also of note is this cryptic warning: "The wchar_t type is not supported
+// when you compile C code".
+//
+// See the docs for more:
+// https://msdn.microsoft.com/en-us/library/

Re: [PATCH] D17688: Fix missed leak from MSVC specific allocation functions

2016-03-07 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL262894: [analyzer] Fix missed leak from MSVC specific 
allocation functions (authored by zaks).

Changed prior to commit:
  http://reviews.llvm.org/D17688?vs=49845&id=50013#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D17688

Files:
  cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
  cfe/trunk/test/Analysis/malloc.c

Index: cfe/trunk/test/Analysis/malloc.c
===
--- cfe/trunk/test/Analysis/malloc.c
+++ cfe/trunk/test/Analysis/malloc.c
@@ -4,6 +4,21 @@
 
 void clang_analyzer_eval(int);
 
+// Without -fms-compatibility, wchar_t isn't a builtin type. MSVC defines
+// _WCHAR_T_DEFINED if wchar_t is available. Microsoft recommends that you use
+// the builtin type: "Using the typedef version can cause portability
+// problems", but we're ok here because we're not actually running anything.
+// Also of note is this cryptic warning: "The wchar_t type is not supported
+// when you compile C code".
+//
+// See the docs for more:
+// https://msdn.microsoft.com/en-us/library/dh8che7s.aspx
+#if !defined(_WCHAR_T_DEFINED)
+// "Microsoft implements wchar_t as a two-byte unsigned value"
+typedef unsigned short wchar_t;
+#define _WCHAR_T_DEFINED
+#endif // !defined(_WCHAR_T_DEFINED)
+
 typedef __typeof(sizeof(int)) size_t;
 void *malloc(size_t);
 void *alloca(size_t);
@@ -13,9 +28,15 @@
 void *reallocf(void *ptr, size_t size);
 void *calloc(size_t nmemb, size_t size);
 char *strdup(const char *s);
+wchar_t *wcsdup(const wchar_t *s);
 char *strndup(const char *s, size_t n);
 int memcmp(const void *s1, const void *s2, size_t n);
 
+// Windows variants
+char *_strdup(const char *strSource);
+wchar_t *_wcsdup(const wchar_t *strSource);
+void *_alloca(size_t size);
+
 void myfoo(int *p);
 void myfooint(int p);
 char *fooRetPtr();
@@ -55,6 +76,10 @@
   int *p = alloca(sizeof(int));
 } // no warn
 
+void winAllocaTest() {
+  int *p = _alloca(sizeof(int));
+} // no warn
+
 void allocaBuiltinTest() {
   int *p = __builtin_alloca(sizeof(int));
 } // no warn
@@ -210,6 +235,11 @@
   int *p = alloca(0); // no warning
 }
 
+void CheckUseZeroWinAllocatedNoWarn2() {
+  int *p = _alloca(0); // no warning
+}
+
+
 void CheckUseZeroAllocatedNoWarn3() {
   int *p = malloc(0);
   int *q = realloc(p, 8); // no warning
@@ -233,6 +263,11 @@
   return *p; // expected-warning {{Use of zero-allocated memory}}
 }
 
+char CheckUseZeroWinAllocated2() {
+  char *p = _alloca(0);
+  return *p; // expected-warning {{Use of zero-allocated memory}}
+}
+
 void UseZeroAllocated(int *p) {
   if (p)
 *p = 7; // expected-warning {{Use of zero-allocated memory}}
@@ -1076,6 +,21 @@
   s2[validIndex + 1] = 'b';
 } // expected-warning {{Potential leak of memory pointed to by}}
 
+void testWinStrdup(const char *s, unsigned validIndex) {
+  char *s2 = _strdup(s);
+  s2[validIndex + 1] = 'b';
+} // expected-warning {{Potential leak of memory pointed to by}}
+
+void testWcsdup(const wchar_t *s, unsigned validIndex) {
+  wchar_t *s2 = wcsdup(s);
+  s2[validIndex + 1] = 'b';
+} // expected-warning {{Potential leak of memory pointed to by}}
+
+void testWinWcsdup(const wchar_t *s, unsigned validIndex) {
+  wchar_t *s2 = _wcsdup(s);
+  s2[validIndex + 1] = 'b';
+} // expected-warning {{Potential leak of memory pointed to by}}
+
 int testStrndup(const char *s, unsigned validIndex, unsigned size) {
   char *s2 = strndup(s, size);
   s2 [validIndex + 1] = 'b';
@@ -1091,6 +1141,24 @@
   free(s2);
 }
 
+void testWinStrdupContentIsDefined(const char *s, unsigned validIndex) {
+  char *s2 = _strdup(s);
+  char result = s2[1];// no warning
+  free(s2);
+}
+
+void testWcsdupContentIsDefined(const wchar_t *s, unsigned validIndex) {
+  wchar_t *s2 = wcsdup(s);
+  wchar_t result = s2[1];// no warning
+  free(s2);
+}
+
+void testWinWcsdupContentIsDefined(const wchar_t *s, unsigned validIndex) {
+  wchar_t *s2 = _wcsdup(s);
+  wchar_t result = s2[1];// no warning
+  free(s2);
+}
+
 // 
 // Test the system library functions to which the pointer can escape.
 // This tests false positive suppression.
@@ -1444,6 +1512,14 @@
   return strdup(strdup(str)); // expected-warning{{leak}}
 }
 
+char *testWinLeakWithinReturn(char *str) {
+  return _strdup(_strdup(str)); // expected-warning{{leak}}
+}
+
+wchar_t *testWinWideLeakWithinReturn(wchar_t *str) {
+  return _wcsdup(_wcsdup(str)); // expected-warning{{leak}}
+}
+
 void passConstPtr(const char * ptr);
 
 void testPassConstPointer() {
Index: cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
@@ -169,11 +169,12 @@
 {
 public:
   MallocChecker()
-  : II_alloca(nullptr), II_malloc(nullptr), II_free(nullptr)

Re: [PATCH] D17947: [Driver] [Darwin] Fix linking libclang_rt.profile_*sim.a

2016-03-07 Thread Anna Zaks via cfe-commits
zaks.anna added a comment.

You should be able to use the switch like in Darwin::getOSLibraryNameSuffix(), 
right? That's much better.


http://reviews.llvm.org/D17947



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r262895 - Add doxygen comments to bmiintrin.h's intrinsics.

2016-03-07 Thread Ekaterina Romanova via cfe-commits
Author: kromanova
Date: Mon Mar  7 19:36:59 2016
New Revision: 262895

URL: http://llvm.org/viewvc/llvm-project?rev=262895&view=rev
Log:
Add doxygen comments to bmiintrin.h's intrinsics.
The doxygen comments are automatically generated based on Sony's intrinsics 
document.

I got an OK from Eric Christopher to commit doxygen comments without prior code 
review upstream.


Modified:
cfe/trunk/lib/Headers/bmiintrin.h

Modified: cfe/trunk/lib/Headers/bmiintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/bmiintrin.h?rev=262895&r1=262894&r2=262895&view=diff
==
--- cfe/trunk/lib/Headers/bmiintrin.h (original)
+++ cfe/trunk/lib/Headers/bmiintrin.h Mon Mar  7 19:36:59 2016
@@ -28,12 +28,107 @@
 #ifndef __BMIINTRIN_H
 #define __BMIINTRIN_H
 
+/// \brief Counts the number of trailing zero bits in the operand.
+///
+/// \headerfile 
+///
+/// \code
+/// unsigned short _tzcnt_u16(unsigned short a);
+/// \endcode
+///
+/// This intrinsic corresponds to the \c TZCNT instruction.
+///
+/// \param a
+///An unsigned 16-bit integer whose trailing zeros are to be counted.
+/// \returns An unsigned 16-bit integer containing the number of trailing zero
+///bits in the operand.
 #define _tzcnt_u16(a) (__tzcnt_u16((a)))
+
+/// \brief Performs a bitwise AND of the second operand with the one's
+///complement of the first operand.
+///
+/// \headerfile 
+///
+/// \code
+/// unsigned int _andn_u32(unsigned int a, unsigned int b);
+/// \endcode
+///
+/// This intrinsic corresponds to the \c ANDN instruction.
+///
+/// \param a
+///An unsigned integer containing one of the operands.
+/// \param b
+///An unsigned integer containing one of the operands.
+/// \returns An unsigned integer containing the bitwise AND of the second
+///operand with the one's complement of the first operand.
 #define _andn_u32(a, b)   (__andn_u32((a), (b)))
+
 /* _bextr_u32 != __bextr_u32 */
+/// \brief Clears all bits in the source except for the least significant bit
+///containing a value of 1 and returns the result.
+///
+/// \headerfile 
+///
+/// \code
+/// unsigned int _blsi_u32(unsigned int a);
+/// \endcode
+///
+/// This intrinsic corresponds to the \c BLSI instruction.
+///
+/// \parama a
+///An unsigned integer whose bits are to be cleared.
+/// \returns An unsigned integer containing the result of clearing the bits 
from
+///the source operand.
 #define _blsi_u32(a)  (__blsi_u32((a)))
+
+/// \brief Creates a mask whose bits are set to 1, using bit 0 up to and
+///including the least siginificant bit that is set to 1 in the source
+///operand and returns the result.
+///
+/// \headerfile 
+///
+/// \code
+/// unsigned int _blsmsk_u32(unsigned int a);
+/// \endcode
+///
+/// This intrinsic corresponds to the \c BLSMSK instruction.
+///
+/// \param a
+///An unsigned integer used to create the mask.
+/// \returns An unsigned integer containing the newly created mask.
 #define _blsmsk_u32(a)(__blsmsk_u32((a)))
+
+/// \brief Clears the least siginificant bit that is set to 1 in the source
+///operand and returns the result.
+///
+/// \headerfile 
+///
+/// \code
+/// unsigned int _blsr_u32(unsigned int a);
+/// \endcode
+///
+/// This intrinsic corresponds to the \c BLSR instruction.
+///
+/// \param a
+///An unsigned integer containing the operand to be cleared.
+/// \returns An unsigned integer containing the result of clearing the source
+///operand.
 #define _blsr_u32(a)  (__blsr_u32((a)))
+
+/// \brief Counts the number of trailing zero bits in the operand.
+///
+/// \headerfile 
+///
+/// \code
+/// unsigned int _tzcnt_u32(unsigned int a);
+/// \endcode
+///
+/// This intrinsic corresponds to the \c TZCNT instruction.
+///
+/// \param a
+///An unsigned 32-bit integer whose trailing zeros are to be counted.
+/// \returns An unsigned 32-bit integer containing the number of trailing zero
+///bits in the operand.
 #define _tzcnt_u32(a) (__tzcnt_u32((a)))
 
 /* Define the default attributes for the functions in this file. */
@@ -44,12 +139,35 @@
to use it as a potentially faster version of BSF. */
 #define __RELAXED_FN_ATTRS __attribute__((__always_inline__, __nodebug__))
 
+/// \brief Counts the number of trailing zero bits in the operand.
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the \c TZCNT instruction.
+///
+/// \param __X
+///An unsigned 16-bit integer whose trailing zeros are to be counted.
+/// \returns An unsigned 16-bit integer containing the number of trailing zero
+///bits in the operand.
 static __inline__ unsigned short __RELAXED_FN_ATTRS
 __tzcnt_u16(unsigned short __X)
 {
   return __X ? __builtin_ctzs(__X) : 16;
 }
 
+/// \brief Performs a bitwise AND of the second operand with the one's
+///complement of the first operand.
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the \c ANDN instruction.

Re: [PATCH] D17908: Add Visual Studio Visualizers for more Clang types

2016-03-07 Thread Mike Spertus via cfe-commits
mspertus updated this revision to Diff 50015.
mspertus added a comment.

Updated in response to review comments to fix issues around MSVC  versions


http://reviews.llvm.org/D17908

Files:
  clang.natvis

Index: clang.natvis
===
--- clang.natvis
+++ clang.natvis
@@ -1,18 +1,81 @@
 
 
 http://schemas.microsoft.com/vstudio/debugger/natvis/2010";>
   
-Builtin Type={(clang::BuiltinType::Kind)BuiltinTypeBits.Kind}
-Modified Type={((clang::AttributedType*)this)->ModifiedType} Attribute={(clang::AttributedType::Kind)AttributedTypeBits.AttrKind}
-Type Class={(clang::Type::TypeClass)TypeBits.TC}
+{(clang::Type::TypeClass)TypeBits.TC}
+Builtin Type={*(clang::BuiltinType *)this}
+Modified Type={((clang::AttributedType*)this)->ModifiedType} Attribute={(clang::AttributedType::Kind)AttributedTypeBits.AttrKind}
+{*(clang::SubstTemplateTypeParmType *)this}
+{*(clang::RecordType *)this}
+{(clang::Type::TypeClass)TypeBits.TC}
+
+  (clang::Type::TypeClass)TypeBits.TC
+  TypeBits
+  CanonicalType
+  *(clang::BuiltinType *)this
+  (clang::SubstTemplateTypeParmType *)this
+  (clang::RecordType *)this
+
+  
+  
+{*decl}
+
+  decl
+
+  
+  
+{*(clang::Type *)this, view(BaseOnly)}, {*(clang::TagType *)this}
+
+  *(clang::TagType *)this
+
+  
+  
+{*(clang::Type *)this, view(BaseOnly)}: {*Replaced} => {CanonicalType}
+
+  *(clang::Type *)this, view(BaseOnly)
+  *Replaced
+
+  
+  
+{*TTPDecl}
   
   
-{((clang::ExtQualsTypeCommonBase *)(((uintptr_t)Value.Value) & ~(uintptr_t)((1 << clang::TypeAlignmentInBits) - 1)))->BaseType}
+
+{*((clang::ExtQualsTypeCommonBase *)(((uintptr_t)Value.Value) & ~(uintptr_t)((1 << 4) - 1)))->BaseType}
+
+  *((clang::ExtQualsTypeCommonBase *)(((uintptr_t)Value.Value) & ~(uintptr_t)((1 << 4) - 1)))->BaseType
+
+  
+  
+{Argument}
+
+  Argument
+
+  
+  
+{(clang::TemplateArgument::ArgKind)TypeOrValue.Kind}, {*(clang::QualType *)&TypeOrValue.V}
+
+  *(clang::QualType *)&TypeOrValue.V
+  
+
+  
+  
+{(clang::BuiltinType::Kind)BuiltinTypeBits.Kind}
+
+  (clang::BuiltinType::Kind)BuiltinTypeBits.Kind
+
+  
+  
+{Name}
+  
+  
+{(clang::TemplateDecl *)((Template.Storage.Val.Val.Value >> 2) << 2)}
+{Template.Storage}
   
   
 ({((llvm::StringMapEntry*)Entry)+1,s})
@@ -65,4 +128,10 @@
   ParmVarDeclBits
 
   
+  
+{($T1 *)Ptr
+
+  ($T1 *)Ptr
+
+  
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D17950: Implement is_always_lock_free

2016-03-07 Thread JF Bastien via cfe-commits
jfb created this revision.
jfb added reviewers: mclow.lists, rsmith.
jfb added a subscriber: cfe-commits.
Herald added subscribers: dschuff, jfb.

This was voted into C++17 at last week's Jacksonville meeting. The final 
P0152R1 paper will be in the upcoming post-Jacksonville mailing, and is also 
available here:
  http://jfbastien.github.io/papers/P0152R1.html

The libc++ part of this implementation is in the following code review:
  

http://reviews.llvm.org/D17950

Files:
  lib/Frontend/InitPreprocessor.cpp
  test/Lexer/cxx-features.cpp
  test/Preprocessor/init.c

Index: test/Preprocessor/init.c
===
--- test/Preprocessor/init.c
+++ test/Preprocessor/init.c
@@ -3282,7 +3282,10 @@
 // MIPSN32BE: #define __GCC_ATOMIC_CHAR16_T_LOCK_FREE 2
 // MIPSN32BE: #define __GCC_ATOMIC_CHAR32_T_LOCK_FREE 2
 // MIPSN32BE: #define __GCC_ATOMIC_CHAR_LOCK_FREE 2
+// MIPSN32BE: #define __GCC_ATOMIC_DOUBLE_LOCK_FREE 2
+// MIPSN32BE: #define __GCC_ATOMIC_FLOAT_LOCK_FREE 2
 // MIPSN32BE: #define __GCC_ATOMIC_INT_LOCK_FREE 2
+// MIPSN32BE: #define __GCC_ATOMIC_LDOUBLE_LOCK_FREE 1
 // MIPSN32BE: #define __GCC_ATOMIC_LLONG_LOCK_FREE 2
 // MIPSN32BE: #define __GCC_ATOMIC_LONG_LOCK_FREE 2
 // MIPSN32BE: #define __GCC_ATOMIC_POINTER_LOCK_FREE 2
@@ -3372,6 +3375,12 @@
 // MIPSN32BE: #define __LDBL_MIN_10_EXP__ (-4931)
 // MIPSN32BE: #define __LDBL_MIN_EXP__ (-16381)
 // MIPSN32BE: #define __LDBL_MIN__ 3.36210314311209350626267781732175260e-4932L
+// MIPSN32BE: #define __LLVM_ATOMIC_16_BYTES_LOCK_FREE 1
+// MIPSN32BE: #define __LLVM_ATOMIC_1_BYTES_LOCK_FREE 2
+// MIPSN32BE: #define __LLVM_ATOMIC_2_BYTES_LOCK_FREE 2
+// MIPSN32BE: #define __LLVM_ATOMIC_4_BYTES_LOCK_FREE 2
+// MIPSN32BE: #define __LLVM_ATOMIC_8_BYTES_LOCK_FREE 2
+// MIPSN32BE: #define __LLVM_LOCK_FREE_IS_SIZE_BASED 1
 // MIPSN32BE: #define __LONG_LONG_MAX__ 9223372036854775807LL
 // MIPSN32BE: #define __LONG_MAX__ 2147483647L
 // MIPSN32BE: #define __MIPSEB 1
@@ -3587,7 +3596,10 @@
 // MIPSN32EL: #define __GCC_ATOMIC_CHAR16_T_LOCK_FREE 2
 // MIPSN32EL: #define __GCC_ATOMIC_CHAR32_T_LOCK_FREE 2
 // MIPSN32EL: #define __GCC_ATOMIC_CHAR_LOCK_FREE 2
+// MIPSN32EL: #define __GCC_ATOMIC_DOUBLE_LOCK_FREE 2
+// MIPSN32EL: #define __GCC_ATOMIC_FLOAT_LOCK_FREE 2
 // MIPSN32EL: #define __GCC_ATOMIC_INT_LOCK_FREE 2
+// MIPSN32EL: #define __GCC_ATOMIC_LDOUBLE_LOCK_FREE 1
 // MIPSN32EL: #define __GCC_ATOMIC_LLONG_LOCK_FREE 2
 // MIPSN32EL: #define __GCC_ATOMIC_LONG_LOCK_FREE 2
 // MIPSN32EL: #define __GCC_ATOMIC_POINTER_LOCK_FREE 2
@@ -3678,6 +3690,12 @@
 // MIPSN32EL: #define __LDBL_MIN_EXP__ (-16381)
 // MIPSN32EL: #define __LDBL_MIN__ 3.36210314311209350626267781732175260e-4932L
 // MIPSN32EL: #define __LITTLE_ENDIAN__ 1
+// MIPSN32EL: #define __LLVM_ATOMIC_16_BYTES_LOCK_FREE 1
+// MIPSN32EL: #define __LLVM_ATOMIC_1_BYTES_LOCK_FREE 2
+// MIPSN32EL: #define __LLVM_ATOMIC_2_BYTES_LOCK_FREE 2
+// MIPSN32EL: #define __LLVM_ATOMIC_4_BYTES_LOCK_FREE 2
+// MIPSN32EL: #define __LLVM_ATOMIC_8_BYTES_LOCK_FREE 2
+// MIPSN32EL: #define __LLVM_LOCK_FREE_IS_SIZE_BASED 1
 // MIPSN32EL: #define __LONG_LONG_MAX__ 9223372036854775807LL
 // MIPSN32EL: #define __LONG_MAX__ 2147483647L
 // MIPSN32EL: #define __MIPSEL 1
@@ -7614,7 +7632,10 @@
 // X86_64-CLOUDABI:#define __GCC_ATOMIC_CHAR16_T_LOCK_FREE 2
 // X86_64-CLOUDABI:#define __GCC_ATOMIC_CHAR32_T_LOCK_FREE 2
 // X86_64-CLOUDABI:#define __GCC_ATOMIC_CHAR_LOCK_FREE 2
+// X86_64-CLOUDABI:#define __GCC_ATOMIC_DOUBLE_LOCK_FREE 2
+// X86_64-CLOUDABI:#define __GCC_ATOMIC_FLOAT_LOCK_FREE 2
 // X86_64-CLOUDABI:#define __GCC_ATOMIC_INT_LOCK_FREE 2
+// X86_64-CLOUDABI:#define __GCC_ATOMIC_LDOUBLE_LOCK_FREE 2
 // X86_64-CLOUDABI:#define __GCC_ATOMIC_LLONG_LOCK_FREE 2
 // X86_64-CLOUDABI:#define __GCC_ATOMIC_LONG_LOCK_FREE 2
 // X86_64-CLOUDABI:#define __GCC_ATOMIC_POINTER_LOCK_FREE 2
@@ -7705,6 +7726,12 @@
 // X86_64-CLOUDABI:#define __LDBL_MIN_EXP__ (-16381)
 // X86_64-CLOUDABI:#define __LDBL_MIN__ 3.36210314311209350626e-4932L
 // X86_64-CLOUDABI:#define __LITTLE_ENDIAN__ 1
+// X86_64-CLOUDABI:#define __LLVM_ATOMIC_16_BYTES_LOCK_FREE 2
+// X86_64-CLOUDABI:#define __LLVM_ATOMIC_1_BYTES_LOCK_FREE 2
+// X86_64-CLOUDABI:#define __LLVM_ATOMIC_2_BYTES_LOCK_FREE 2
+// X86_64-CLOUDABI:#define __LLVM_ATOMIC_4_BYTES_LOCK_FREE 2
+// X86_64-CLOUDABI:#define __LLVM_ATOMIC_8_BYTES_LOCK_FREE 2
+// X86_64-CLOUDABI:#define __LLVM_LOCK_FREE_IS_SIZE_BASED 1
 // X86_64-CLOUDABI:#define __LONG_LONG_MAX__ 9223372036854775807LL
 // X86_64-CLOUDABI:#define __LONG_MAX__ 9223372036854775807L
 // X86_64-CLOUDABI:#define __LP64__ 1
@@ -8478,7 +8505,10 @@
 // WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_CHAR16_T_LOCK_FREE 2
 // WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_CHAR32_T_LOCK_FREE 2
 // WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_CHAR_LOCK_FREE 2
+// WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_DOUBLE_LOCK_FREE 1
+// WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_FLOAT_LOCK_FREE 2
 // WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_INT_LOCK_FREE

[PATCH] D17951: Implement is_always_lock_free

2016-03-07 Thread JF Bastien via cfe-commits
jfb created this revision.
jfb added reviewers: mclow.lists, rsmith.
jfb added a subscriber: cfe-commits.

This was voted into C++17 at last week's Jacksonville meeting. The final 
P0152R1 paper will be in the upcoming post-Jacksonville mailing, and is also 
available here:
  http://jfbastien.github.io/papers/P0152R1.html

The clang part of this implementation is in the following code review:
  http://reviews.llvm.org/D17950

http://reviews.llvm.org/D17951

Files:
  include/atomic
  test/std/atomics/atomics.lockfree/lockfree.pass.cpp

Index: test/std/atomics/atomics.lockfree/lockfree.pass.cpp
===
--- test/std/atomics/atomics.lockfree/lockfree.pass.cpp
+++ test/std/atomics/atomics.lockfree/lockfree.pass.cpp
@@ -11,20 +11,30 @@
 
 // 
 
+// #define ATOMIC_BOOL_LOCK_FREE unspecified
 // #define ATOMIC_CHAR_LOCK_FREE unspecified
 // #define ATOMIC_CHAR16_T_LOCK_FREE unspecified
 // #define ATOMIC_CHAR32_T_LOCK_FREE unspecified
 // #define ATOMIC_WCHAR_T_LOCK_FREE unspecified
 // #define ATOMIC_SHORT_LOCK_FREE unspecified
 // #define ATOMIC_INT_LOCK_FREE unspecified
 // #define ATOMIC_LONG_LOCK_FREE unspecified
 // #define ATOMIC_LLONG_LOCK_FREE unspecified
+// #define ATOMIC_POINTER_LOCK_FREE unspecified
 
 #include 
 #include 
 
+template  void checkAlwaysLockFree() {
+  if (std::atomic::is_always_lock_free)
+assert(std::atomic().is_lock_free());
+}
+
 int main()
 {
+assert(ATOMIC_BOOL_LOCK_FREE == 0 ||
+   ATOMIC_BOOL_LOCK_FREE == 1 ||
+   ATOMIC_BOOL_LOCK_FREE == 2);
 assert(ATOMIC_CHAR_LOCK_FREE == 0 ||
ATOMIC_CHAR_LOCK_FREE == 1 ||
ATOMIC_CHAR_LOCK_FREE == 2);
@@ -49,4 +59,60 @@
 assert(ATOMIC_LLONG_LOCK_FREE == 0 ||
ATOMIC_LLONG_LOCK_FREE == 1 ||
ATOMIC_LLONG_LOCK_FREE == 2);
+assert(ATOMIC_POINTER_LOCK_FREE == 0 ||
+   ATOMIC_POINTER_LOCK_FREE == 1 ||
+   ATOMIC_POINTER_LOCK_FREE == 2);
+
+// structs and unions can't be defined in the template invocation.
+// Work around this with a typedef.
+#define CHECK_ALWAYS_LOCK_FREE(T)  \
+  do { \
+typedef T type;\
+checkAlwaysLockFree();   \
+  } while (0)
+
+CHECK_ALWAYS_LOCK_FREE(bool);
+CHECK_ALWAYS_LOCK_FREE(char);
+CHECK_ALWAYS_LOCK_FREE(signed char);
+CHECK_ALWAYS_LOCK_FREE(unsigned char);
+CHECK_ALWAYS_LOCK_FREE(char16_t);
+CHECK_ALWAYS_LOCK_FREE(char32_t);
+CHECK_ALWAYS_LOCK_FREE(wchar_t);
+CHECK_ALWAYS_LOCK_FREE(short);
+CHECK_ALWAYS_LOCK_FREE(unsigned short);
+CHECK_ALWAYS_LOCK_FREE(int);
+CHECK_ALWAYS_LOCK_FREE(unsigned int);
+CHECK_ALWAYS_LOCK_FREE(long);
+CHECK_ALWAYS_LOCK_FREE(unsigned long);
+CHECK_ALWAYS_LOCK_FREE(long long);
+CHECK_ALWAYS_LOCK_FREE(unsigned long long);
+CHECK_ALWAYS_LOCK_FREE(std::nullptr_t);
+CHECK_ALWAYS_LOCK_FREE(void*);
+CHECK_ALWAYS_LOCK_FREE(float);
+CHECK_ALWAYS_LOCK_FREE(double);
+CHECK_ALWAYS_LOCK_FREE(long double);
+CHECK_ALWAYS_LOCK_FREE(int __attribute__((vector_size(1 * sizeof(int);
+CHECK_ALWAYS_LOCK_FREE(int __attribute__((vector_size(2 * sizeof(int);
+CHECK_ALWAYS_LOCK_FREE(int __attribute__((vector_size(4 * sizeof(int);
+CHECK_ALWAYS_LOCK_FREE(int __attribute__((vector_size(16 * sizeof(int);
+CHECK_ALWAYS_LOCK_FREE(int __attribute__((vector_size(32 * sizeof(int);
+CHECK_ALWAYS_LOCK_FREE(float __attribute__((vector_size(1 * sizeof(float);
+CHECK_ALWAYS_LOCK_FREE(float __attribute__((vector_size(2 * sizeof(float);
+CHECK_ALWAYS_LOCK_FREE(float __attribute__((vector_size(4 * sizeof(float);
+CHECK_ALWAYS_LOCK_FREE(float __attribute__((vector_size(16 * sizeof(float);
+CHECK_ALWAYS_LOCK_FREE(float __attribute__((vector_size(32 * sizeof(float);
+CHECK_ALWAYS_LOCK_FREE(double __attribute__((vector_size(1 * sizeof(double);
+CHECK_ALWAYS_LOCK_FREE(double __attribute__((vector_size(2 * sizeof(double);
+CHECK_ALWAYS_LOCK_FREE(double __attribute__((vector_size(4 * sizeof(double);
+CHECK_ALWAYS_LOCK_FREE(double __attribute__((vector_size(16 * sizeof(double);
+CHECK_ALWAYS_LOCK_FREE(double __attribute__((vector_size(32 * sizeof(double);
+CHECK_ALWAYS_LOCK_FREE(struct{});
+CHECK_ALWAYS_LOCK_FREE(struct{ int i; });
+CHECK_ALWAYS_LOCK_FREE(struct{ int i[2]; });
+CHECK_ALWAYS_LOCK_FREE(struct{ long long int i[2]; });
+CHECK_ALWAYS_LOCK_FREE(struct{ long long int i[4]; });
+CHECK_ALWAYS_LOCK_FREE(struct{ long long int i[8]; });
+CHECK_ALWAYS_LOCK_FREE(struct{ long long int i[16]; });
+CHECK_ALWAYS_LOCK_FREE(struct{ char c; /* padding */ long long int i; });
+CHECK_ALWAYS_LOCK_FREE(union{ int i; float f; });
 }
Inde

Re: [PATCH] D17950: Implement is_always_lock_free

2016-03-07 Thread JF Bastien via cfe-commits
jfb added a comment.

I'll check with GCC folks whether they want to share macros the same way we're 
already sharing `__GCC_ATOMIC_*_LOCK_FREE`. The new macros I propose are 
`__LLVM__ATOMIC_*_BYTES_LOCK_FREE` and `__LLVM_LOCK_FREE_IS_SIZE_BASED`.

Let's do a first sanity-check round of code reviews to make sure I have the 
LLVM-isms down right, then I'll add GCC folks.


http://reviews.llvm.org/D17950



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17950: Implement is_always_lock_free

2016-03-07 Thread JF Bastien via cfe-commits
jfb added inline comments.


Comment at: lib/Frontend/InitPreprocessor.cpp:480
@@ +479,3 @@
+  if (LangOpts.CPlusPlus1z) {
+Builder.defineMacro("__cpp_lib_atomic_is_always_lock_free", "201603");
+  }

How do you pick these numbers before the standard is actually out? 201603 is 
the Jacksonville meeting, seems fine to me :)


Comment at: lib/Frontend/InitPreprocessor.cpp:853
@@ -830,1 +852,3 @@
+DEFINE_LOCK_FREE_MACRO(DOUBLE, Double);
+DEFINE_LOCK_FREE_MACRO(LDOUBLE, LongDouble);
 Builder.defineMacro("__GCC_ATOMIC_POINTER_LOCK_FREE",

Adding these which aren't in the C standard, but which `is_always_lock_free` 
would use. We're proposing that floating-point atomics be added so it's not 
crazy:
  http://open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0020r1.html


Comment at: test/Lexer/cxx-features.cpp:6
@@ -5,1 +5,3 @@
+// RUN: %clang_cc1 -std=c++1z -fsized-deallocation -verify %s
+// RUN: %clang_cc1 -std=c++1z -fsized-deallocation -fconcepts-ts 
-DCONCEPTS_TS=1 -verify %s
 // RUN: %clang_cc1 -fcoroutines -DCOROUTINES -verify %s

This was out of date, I'm updating the test to C++1z, testing C++14, and 
keeping c++1y for compatibility.


http://reviews.llvm.org/D17950



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17951: Implement is_always_lock_free

2016-03-07 Thread JF Bastien via cfe-commits
jfb added inline comments.


Comment at: include/atomic:840
@@ +839,3 @@
+#define ATOMIC_LLONG_LOCK_FREE __GCC_ATOMIC_LLONG_LOCK_FREE
+#define ATOMIC_POINTER_LOCK_FREE   __GCC_ATOMIC_POINTER_LOCK_FREE
+

Moving these from the bottom of the file since I need them.


Comment at: include/atomic:887
@@ +886,3 @@
+false;
+#   endif
+# endif

This is slightly ugly, but I don't see a better way to go about without 
breaking libc++ when it's not exactly in sync with clang, or when it's used 
with GCC (until GCC picks up these macros).


Comment at: test/std/atomics/atomics.lockfree/lockfree.pass.cpp:23
@@ -21,2 +22,3 @@
 // #define ATOMIC_LLONG_LOCK_FREE unspecified
+// #define ATOMIC_POINTER_LOCK_FREE unspecified
 

BOOL and POINTER weren't tested, I'm adding them while I'm here.


http://reviews.llvm.org/D17951



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D17952: [Clang] Accept absolute paths in the -fuse-ld option

2016-03-07 Thread whitequark via cfe-commits
whitequark created this revision.
whitequark added a reviewer: majnemer.
whitequark added a subscriber: cfe-commits.
whitequark set the repository for this revision to rL LLVM.
Herald added a subscriber: aemerson.

This patch extends the -fuse-ld option to accept a full path to an executable
and use it verbatim to invoke the linker. There are generally two reasons
to desire this.

The first reason relates to the sad truth is that Clang is retargetable,
Binutils are not.

While any Clang from a binary distribution is sufficient to compile code 
for a wide range of architectures and prefixed BFD linkers (e.g.
installed as /usr/bin/arm-none-linux-gnueabi-ld) as well as cross-compiled
libc's (for non-bare-metal targets) are widely available, including on all
Debian derivatives, it is impossible to use them together because
the -fuse-ld= option allows to specify neither a linker prefix nor 
a full path to one.

The second reason is linker development, both when porting existing linkers
to new architectures and when working on a new linker such as LLD.

Repository:
  rL LLVM

http://reviews.llvm.org/D17952

Files:
  cfe/trunk/lib/Driver/ToolChain.cpp

Index: cfe/trunk/lib/Driver/ToolChain.cpp
===
--- cfe/trunk/lib/Driver/ToolChain.cpp
+++ cfe/trunk/lib/Driver/ToolChain.cpp
@@ -342,19 +342,26 @@
 
 std::string ToolChain::GetLinkerPath() const {
   if (Arg *A = Args.getLastArg(options::OPT_fuse_ld_EQ)) {
-StringRef Suffix = A->getValue();
-
-// If we're passed -fuse-ld= with no argument, or with the argument ld,
-// then use whatever the default system linker is.
-if (Suffix.empty() || Suffix == "ld")
-  return GetProgramPath("ld");
-
-llvm::SmallString<8> LinkerName("ld.");
-LinkerName.append(Suffix);
-
-std::string LinkerPath(GetProgramPath(LinkerName.c_str()));
-if (llvm::sys::fs::exists(LinkerPath))
-  return LinkerPath;
+StringRef UseLinker = A->getValue();
+
+if (UseLinker[0] == '/') {
+  // If we're passed -fuse-ld= with what looks like an absolute path,
+  // don't attempt to second-guess that.
+  if (llvm::sys::fs::exists(UseLinker))
+return UseLinker;
+} else {
+  // If we're passed -fuse-ld= with no argument, or with the argument ld,
+  // then use whatever the default system linker is.
+  if (UseLinker.empty() || UseLinker == "ld")
+return GetProgramPath("ld");
+
+  llvm::SmallString<8> LinkerName("ld.");
+  LinkerName.append(UseLinker);
+
+  std::string LinkerPath(GetProgramPath(LinkerName.c_str()));
+  if (llvm::sys::fs::exists(LinkerPath))
+return LinkerPath;
+}
 
 getDriver().Diag(diag::err_drv_invalid_linker_name) << 
A->getAsString(Args);
 return "";


Index: cfe/trunk/lib/Driver/ToolChain.cpp
===
--- cfe/trunk/lib/Driver/ToolChain.cpp
+++ cfe/trunk/lib/Driver/ToolChain.cpp
@@ -342,19 +342,26 @@
 
 std::string ToolChain::GetLinkerPath() const {
   if (Arg *A = Args.getLastArg(options::OPT_fuse_ld_EQ)) {
-StringRef Suffix = A->getValue();
-
-// If we're passed -fuse-ld= with no argument, or with the argument ld,
-// then use whatever the default system linker is.
-if (Suffix.empty() || Suffix == "ld")
-  return GetProgramPath("ld");
-
-llvm::SmallString<8> LinkerName("ld.");
-LinkerName.append(Suffix);
-
-std::string LinkerPath(GetProgramPath(LinkerName.c_str()));
-if (llvm::sys::fs::exists(LinkerPath))
-  return LinkerPath;
+StringRef UseLinker = A->getValue();
+
+if (UseLinker[0] == '/') {
+  // If we're passed -fuse-ld= with what looks like an absolute path,
+  // don't attempt to second-guess that.
+  if (llvm::sys::fs::exists(UseLinker))
+return UseLinker;
+} else {
+  // If we're passed -fuse-ld= with no argument, or with the argument ld,
+  // then use whatever the default system linker is.
+  if (UseLinker.empty() || UseLinker == "ld")
+return GetProgramPath("ld");
+
+  llvm::SmallString<8> LinkerName("ld.");
+  LinkerName.append(UseLinker);
+
+  std::string LinkerPath(GetProgramPath(LinkerName.c_str()));
+  if (llvm::sys::fs::exists(LinkerPath))
+return LinkerPath;
+}
 
 getDriver().Diag(diag::err_drv_invalid_linker_name) << A->getAsString(Args);
 return "";
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17952: [Clang] Accept absolute paths in the -fuse-ld option

2016-03-07 Thread Sean Silva via cfe-commits
silvas added a subscriber: silvas.
silvas added a comment.

Some nits but this looks fine to me. I've been wanting this for a while now.



Comment at: cfe/trunk/lib/Driver/ToolChain.cpp:347
@@ +346,3 @@
+
+if (UseLinker[0] == '/') {
+  // If we're passed -fuse-ld= with what looks like an absolute path,

Use llvm::sys::path::is_absolute so that this works on windows.


Comment at: cfe/trunk/lib/Driver/ToolChain.cpp:352
@@ +351,3 @@
+return UseLinker;
+} else {
+  // If we're passed -fuse-ld= with no argument, or with the argument ld,

No need for else after return.


Repository:
  rL LLVM

http://reviews.llvm.org/D17952



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17952: [Clang] Accept absolute paths in the -fuse-ld option

2016-03-07 Thread whitequark via cfe-commits
whitequark marked an inline comment as done.


Comment at: cfe/trunk/lib/Driver/ToolChain.cpp:352
@@ +351,3 @@
+return UseLinker;
+} else {
+  // If we're passed -fuse-ld= with no argument, or with the argument ld,

silvas wrote:
> No need for else after return.
This would change behavior when an absolute path is passed but doesn't exist; 
clang will try to append it to "ld." and display some silly error message.


Repository:
  rL LLVM

http://reviews.llvm.org/D17952



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17952: [Clang] Accept absolute paths in the -fuse-ld option

2016-03-07 Thread whitequark via cfe-commits
whitequark updated this revision to Diff 50021.
whitequark added a comment.

Windows compatibility


Repository:
  rL LLVM

http://reviews.llvm.org/D17952

Files:
  cfe/trunk/lib/Driver/ToolChain.cpp

Index: cfe/trunk/lib/Driver/ToolChain.cpp
===
--- cfe/trunk/lib/Driver/ToolChain.cpp
+++ cfe/trunk/lib/Driver/ToolChain.cpp
@@ -342,19 +342,26 @@
 
 std::string ToolChain::GetLinkerPath() const {
   if (Arg *A = Args.getLastArg(options::OPT_fuse_ld_EQ)) {
-StringRef Suffix = A->getValue();
-
-// If we're passed -fuse-ld= with no argument, or with the argument ld,
-// then use whatever the default system linker is.
-if (Suffix.empty() || Suffix == "ld")
-  return GetProgramPath("ld");
-
-llvm::SmallString<8> LinkerName("ld.");
-LinkerName.append(Suffix);
-
-std::string LinkerPath(GetProgramPath(LinkerName.c_str()));
-if (llvm::sys::fs::exists(LinkerPath))
-  return LinkerPath;
+StringRef UseLinker = A->getValue();
+
+if (llvm::sys::path::is_absolute(UseLinker)) {
+  // If we're passed -fuse-ld= with what looks like an absolute path,
+  // don't attempt to second-guess that.
+  if (llvm::sys::fs::exists(UseLinker))
+return UseLinker;
+} else {
+  // If we're passed -fuse-ld= with no argument, or with the argument ld,
+  // then use whatever the default system linker is.
+  if (UseLinker.empty() || UseLinker == "ld")
+return GetProgramPath("ld");
+
+  llvm::SmallString<8> LinkerName("ld.");
+  LinkerName.append(UseLinker);
+
+  std::string LinkerPath(GetProgramPath(LinkerName.c_str()));
+  if (llvm::sys::fs::exists(LinkerPath))
+return LinkerPath;
+}
 
 getDriver().Diag(diag::err_drv_invalid_linker_name) << 
A->getAsString(Args);
 return "";


Index: cfe/trunk/lib/Driver/ToolChain.cpp
===
--- cfe/trunk/lib/Driver/ToolChain.cpp
+++ cfe/trunk/lib/Driver/ToolChain.cpp
@@ -342,19 +342,26 @@
 
 std::string ToolChain::GetLinkerPath() const {
   if (Arg *A = Args.getLastArg(options::OPT_fuse_ld_EQ)) {
-StringRef Suffix = A->getValue();
-
-// If we're passed -fuse-ld= with no argument, or with the argument ld,
-// then use whatever the default system linker is.
-if (Suffix.empty() || Suffix == "ld")
-  return GetProgramPath("ld");
-
-llvm::SmallString<8> LinkerName("ld.");
-LinkerName.append(Suffix);
-
-std::string LinkerPath(GetProgramPath(LinkerName.c_str()));
-if (llvm::sys::fs::exists(LinkerPath))
-  return LinkerPath;
+StringRef UseLinker = A->getValue();
+
+if (llvm::sys::path::is_absolute(UseLinker)) {
+  // If we're passed -fuse-ld= with what looks like an absolute path,
+  // don't attempt to second-guess that.
+  if (llvm::sys::fs::exists(UseLinker))
+return UseLinker;
+} else {
+  // If we're passed -fuse-ld= with no argument, or with the argument ld,
+  // then use whatever the default system linker is.
+  if (UseLinker.empty() || UseLinker == "ld")
+return GetProgramPath("ld");
+
+  llvm::SmallString<8> LinkerName("ld.");
+  LinkerName.append(UseLinker);
+
+  std::string LinkerPath(GetProgramPath(LinkerName.c_str()));
+  if (llvm::sys::fs::exists(LinkerPath))
+return LinkerPath;
+}
 
 getDriver().Diag(diag::err_drv_invalid_linker_name) << A->getAsString(Args);
 return "";
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17952: [Clang] Accept absolute paths in the -fuse-ld option

2016-03-07 Thread Sean Silva via cfe-commits
silvas added inline comments.


Comment at: cfe/trunk/lib/Driver/ToolChain.cpp:352
@@ +351,3 @@
+return UseLinker;
+} else {
+  // If we're passed -fuse-ld= with no argument, or with the argument ld,

Makes sense.


Repository:
  rL LLVM

http://reviews.llvm.org/D17952



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17908: Add Visual Studio Visualizers for more Clang types

2016-03-07 Thread Mike Spertus via cfe-commits
mspertus updated this revision to Diff 50022.
mspertus added a comment.

Based on Eric Feiveson's comment that I can suppress the numeric value of an 
enum visualization with ", en" I have uploaded a new diff. By suppressing the 
numeric values, instead of the verbose TemplateArgumentLoc visualization (much 
of which probably won't fit in the window)

  Type (0x0001), SubstTemplateTypeParm (0x001e): {Identifier (("T"))} 
=> Record (0x0019), {Identifier (("A"))}

I get the much more readable

  Type template parameter: SubstTemplateTypeParm: {Identifier (("T"))} => 
Record, {Identifier (("A"))}


http://reviews.llvm.org/D17908

Files:
  clang.natvis

Index: clang.natvis
===
--- clang.natvis
+++ clang.natvis
@@ -1,18 +1,81 @@
 
 
 http://schemas.microsoft.com/vstudio/debugger/natvis/2010";>
   
-Builtin Type={(clang::BuiltinType::Kind)BuiltinTypeBits.Kind}
-Modified Type={((clang::AttributedType*)this)->ModifiedType} Attribute={(clang::AttributedType::Kind)AttributedTypeBits.AttrKind}
-Type Class={(clang::Type::TypeClass)TypeBits.TC}
+{(clang::Type::TypeClass)TypeBits.TC, en}
+Builtin Type={*(clang::BuiltinType *)this}
+Modified Type={((clang::AttributedType*)this)->ModifiedType} Attribute={(clang::AttributedType::Kind)AttributedTypeBits.AttrKind}
+{*(clang::SubstTemplateTypeParmType *)this}
+{*(clang::RecordType *)this}
+{(clang::Type::TypeClass)TypeBits.TC, en}
+
+  (clang::Type::TypeClass)TypeBits.TC
+  TypeBits
+  CanonicalType
+  *(clang::BuiltinType *)this
+  (clang::SubstTemplateTypeParmType *)this
+  (clang::RecordType *)this
+
+  
+  
+{*decl}
+
+  decl
+
+  
+  
+{*(clang::Type *)this, view(BaseOnly)}, {*(clang::TagType *)this}
+
+  *(clang::TagType *)this
+
+  
+  
+{*(clang::Type *)this, view(BaseOnly)}: {*Replaced} => {CanonicalType}
+
+  *(clang::Type *)this, view(BaseOnly)
+  *Replaced
+
+  
+  
+{*TTPDecl}
   
   
-{((clang::ExtQualsTypeCommonBase *)(((uintptr_t)Value.Value) & ~(uintptr_t)((1 << clang::TypeAlignmentInBits) - 1)))->BaseType}
+
+{*((clang::ExtQualsTypeCommonBase *)(((uintptr_t)Value.Value) & ~(uintptr_t)((1 << 4) - 1)))->BaseType}
+
+  *((clang::ExtQualsTypeCommonBase *)(((uintptr_t)Value.Value) & ~(uintptr_t)((1 << 4) - 1)))->BaseType
+
+  
+  
+{Argument}
+
+  Argument
+
+  
+  
+{(clang::TemplateArgument::ArgKind)TypeOrValue.Kind,en} template parameter: {*(clang::QualType *)&TypeOrValue.V}
+
+  *(clang::QualType *)&TypeOrValue.V
+  
+
+  
+  
+{(clang::BuiltinType::Kind)BuiltinTypeBits.Kind, en}
+
+  (clang::BuiltinType::Kind)BuiltinTypeBits.Kind
+
+  
+  
+{Name}
+  
+  
+{(clang::TemplateDecl *)((Template.Storage.Val.Val.Value >> 2) << 2)}
+{Template.Storage}
   
   
 ({((llvm::StringMapEntry*)Entry)+1,s})
@@ -35,7 +98,7 @@
 
   
   
-{(clang::tok::TokenKind)Kind}
+{(clang::tok::TokenKind)Kind,en}
 {{Identifier ({*(clang::IdentifierInfo *)(PtrData)})}}
   
   
@@ -65,4 +128,10 @@
   ParmVarDeclBits
 
   
+  
+{($T1 *)Ptr
+
+  ($T1 *)Ptr
+
+  
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15944: [OpenMP] Parsing and sema support for target update directive

2016-03-07 Thread Kelvin Li via cfe-commits
kkwli0 marked 3 inline comments as done.


Comment at: include/clang/AST/OpenMPClause.h:3196
@@ -3195,1 +3195,3 @@
 
+/// \brief This represents clause 'from' in the '#pragma omp ...'
+/// directives.

ABataev wrote:
> New clauses must be added in separate patches after commit of the new 
> directive.
Will do


Comment at: lib/Parse/ParseOpenMP.cpp:71-74
@@ -69,3 +70,6 @@
  !P.getPreprocessor().getSpelling(Tok).compare("point")) ||
-((i == 1) && 
!P.getPreprocessor().getSpelling(Tok).compare("data"));
+((i == 1) &&
+ !P.getPreprocessor().getSpelling(Tok).compare("data")) ||
+((i == 2) &&
+ !P.getPreprocessor().getSpelling(Tok).compare("update"));
   } else {

ABataev wrote:
> Probably, we need to add local enumeric for these constants (0, 1, 2 etc.) 
Will use the latest infrastructure.


http://reviews.llvm.org/D15944



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15944: [OpenMP] Parsing and sema support for target update directive

2016-03-07 Thread Kelvin Li via cfe-commits
kkwli0 updated this revision to Diff 50024.
kkwli0 marked 2 inline comments as done.
kkwli0 added a comment.

I rebase the patch to the latest trunk and make use of the infrastructure form 
parsing and sema.


http://reviews.llvm.org/D15944

Files:
  include/clang-c/Index.h
  include/clang/AST/OpenMPClause.h
  include/clang/AST/RecursiveASTVisitor.h
  include/clang/AST/StmtOpenMP.h
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/OpenMPKinds.def
  include/clang/Basic/StmtNodes.td
  include/clang/Sema/Sema.h
  include/clang/Serialization/ASTBitCodes.h
  lib/AST/OpenMPClause.cpp
  lib/AST/StmtOpenMP.cpp
  lib/AST/StmtPrinter.cpp
  lib/AST/StmtProfile.cpp
  lib/Basic/OpenMPKinds.cpp
  lib/CodeGen/CGStmt.cpp
  lib/CodeGen/CGStmtOpenMP.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/Parse/ParseOpenMP.cpp
  lib/Sema/SemaOpenMP.cpp
  lib/Sema/TreeTransform.h
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp
  lib/StaticAnalyzer/Core/ExprEngine.cpp
  test/OpenMP/nesting_of_regions.cpp
  test/OpenMP/target_map_messages.cpp
  test/OpenMP/target_parallel_for_map_messages.cpp
  test/OpenMP/target_parallel_map_messages.cpp
  test/OpenMP/target_update_ast_print.cpp
  test/OpenMP/target_update_device_messages.cpp
  test/OpenMP/target_update_from_messages.cpp
  test/OpenMP/target_update_if_messages.cpp
  test/OpenMP/target_update_messages.cpp
  test/OpenMP/target_update_to_messages.cpp
  tools/libclang/CIndex.cpp
  tools/libclang/CXCursor.cpp

Index: tools/libclang/CXCursor.cpp
===
--- tools/libclang/CXCursor.cpp
+++ tools/libclang/CXCursor.cpp
@@ -612,6 +612,9 @@
   case Stmt::OMPTargetParallelForDirectiveClass:
 K = CXCursor_OMPTargetParallelForDirective;
 break;
+  case Stmt::OMPTargetUpdateDirectiveClass:
+K = CXCursor_OMPTargetUpdateDirective;
+break;
   case Stmt::OMPTeamsDirectiveClass:
 K = CXCursor_OMPTeamsDirective;
 break;
Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -2254,6 +2254,12 @@
 }
 void OMPClauseEnqueue::VisitOMPDefaultmapClause(
 const OMPDefaultmapClause * /*C*/) {}
+void OMPClauseEnqueue::VisitOMPFromClause(const OMPFromClause *C) {
+  VisitOMPClauseList(C);
+}
+void OMPClauseEnqueue::VisitOMPToClause(const OMPToClause *C) {
+  VisitOMPClauseList(C);
+}
 }
 
 void EnqueueVisitor::EnqueueChildren(const OMPClause *S) {
@@ -4824,6 +4830,8 @@
 return cxstring::createRef("OMPTargetParallelDirective");
   case CXCursor_OMPTargetParallelForDirective:
 return cxstring::createRef("OMPTargetParallelForDirective");
+  case CXCursor_OMPTargetUpdateDirective:
+return cxstring::createRef("OMPTargetUpdateDirective");
   case CXCursor_OMPTeamsDirective:
 return cxstring::createRef("OMPTeamsDirective");
   case CXCursor_OMPCancellationPointDirective:
Index: test/OpenMP/target_update_to_messages.cpp
===
--- /dev/null
+++ test/OpenMP/target_update_to_messages.cpp
@@ -0,0 +1,175 @@
+// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s
+
+void foo() {
+}
+
+bool foobool(int argc) {
+  return argc;
+}
+
+struct S1; // expected-note 2 {{declared here}}
+extern S1 a;
+class S2 {
+  mutable int a;
+public:
+  S2():a(0) { }
+  S2(S2 &s2):a(s2.a) { }
+  static float S2s; // expected-note 4 {{mappable type cannot contain static members}}
+  static const float S2sc; // expected-note 4 {{mappable type cannot contain static members}}
+};
+const float S2::S2sc = 0;
+const S2 b;
+const S2 ba[5];
+class S3 {
+  int a;
+public:
+  S3():a(0) { }
+  S3(S3 &s3):a(s3.a) { }
+};
+const S3 c;
+const S3 ca[5];
+extern const int f;
+class S4 {
+  int a;
+  S4();
+  S4(const S4 &s4);
+public:
+  S4(int v):a(v) { }
+};
+class S5 {
+  int a;
+  S5():a(0) {}
+  S5(const S5 &s5):a(s5.a) { }
+public:
+  S5(int v):a(v) { }
+};
+struct S6 {
+  int ii;
+  int aa[30];
+  float xx;
+  double *pp;
+};
+struct S7 {
+  int i;
+  int a[50];
+  float x;
+  S6 s6[5];
+  double *p;
+  unsigned bfa : 4;
+};
+
+S3 h;
+#pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
+
+typedef int from;
+
+template  // expected-note {{declared here}}
+T tmain(T argc) {
+  const T d = 5;
+  const T da[5] = { 0 };
+  S4 e(4);
+  S5 g(5);
+  T *m;
+  T i, t[20];
+  T &j = i;
+  T *k = &j;
+  T x;
+  T y;
+  T to;
+  const T (&l)[5] = da;
+  S7 s7;
+
+#pragma omp target update to // expected-error {{expected '(' after 'to'}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+#pragma omp target update to( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected expression}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+#pragma omp target update to()

r262915 - Sema: Treat 'strict' availability flag like unavailable

2016-03-07 Thread Duncan P. N. Exon Smith via cfe-commits
Author: dexonsmith
Date: Tue Mar  8 00:12:54 2016
New Revision: 262915

URL: http://llvm.org/viewvc/llvm-project?rev=262915&view=rev
Log:
Sema: Treat 'strict' availability flag like unavailable

This is a follow-up to r261512, which made the 'strict' availability
attribute flag behave like 'unavailable'.  However, that fix was
insufficient.  The following case would (erroneously) error when the
deployment target was older than 10.9:

struct __attribute__((availability(macosx,strict,introduced=10.9))) A;
__attribute__((availability(macosx,strict,introduced=10.9))) void f(A*);

The use of A* in the argument list for f is valid here, since f and A
have the same availability.

The fix is to return AR_Unavailable from DeclBase::getAvailability
instead of AR_NotYetIntroduced.  This also reverts the special handling
added in r261163, instead relying on the well-tested logic for
AR_Unavailable.

rdar://problem/23791325

Modified:
cfe/trunk/lib/AST/DeclBase.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/Sema/attr-availability-macosx.c

Modified: cfe/trunk/lib/AST/DeclBase.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclBase.cpp?rev=262915&r1=262914&r2=262915&view=diff
==
--- cfe/trunk/lib/AST/DeclBase.cpp (original)
+++ cfe/trunk/lib/AST/DeclBase.cpp Tue Mar  8 00:12:54 2016
@@ -432,7 +432,7 @@ static AvailabilityResult CheckAvailabil
   << VTI << HintMessage;
 }
 
-return AR_NotYetIntroduced;
+return A->getStrict() ? AR_Unavailable : AR_NotYetIntroduced;
   }
 
   // Make sure that this declaration hasn't been obsoleted.

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=262915&r1=262914&r2=262915&view=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Tue Mar  8 00:12:54 2016
@@ -159,19 +159,11 @@ DiagnoseAvailabilityOfDecl(Sema &S, Name
   break;
 
 case AR_NotYetIntroduced: {
-  // With strict, the compiler will emit unavailable error.
-  AvailabilityAttr *AA = D->getAttr();
-  if (AA && AA->getStrict() &&
-  S.getCurContextAvailability() != AR_NotYetIntroduced)
-S.EmitAvailabilityWarning(Sema::AD_Unavailable,
-  D, Message, Loc, UnknownObjCClass, ObjCPDecl,
-  ObjCPropertyAccess);
-
   // Don't do this for enums, they can't be redeclared.
   if (isa(D) || isa(D))
 break;
  
-  bool Warn = !AA->isInherited();
+  bool Warn = !D->getAttr()->isInherited();
   // Objective-C method declarations in categories are not modelled as
   // redeclarations, so manually look for a redeclaration in a category
   // if necessary.

Modified: cfe/trunk/test/Sema/attr-availability-macosx.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/attr-availability-macosx.c?rev=262915&r1=262914&r2=262915&view=diff
==
--- cfe/trunk/test/Sema/attr-availability-macosx.c (original)
+++ cfe/trunk/test/Sema/attr-availability-macosx.c Tue Mar  8 00:12:54 2016
@@ -22,6 +22,16 @@ void test() {
   f6(0); // expected-error{{'f6' is unavailable: introduced in OS X 10.6}}
 }
 
+struct __attribute__((availability(macosx,strict,introduced=10.6)))
+  not_yet_introduced_struct; // \
+expected-note{{'not_yet_introduced_struct' has been explicitly marked 
unavailable here}}
+
+void uses_not_introduced_struct(struct not_yet_introduced_struct *); // \
+expected-error{{'not_yet_introduced_struct' is unavailable: introduced in 
OS X 10.6}}
+
+__attribute__((availability(macosx,strict,introduced=10.6)))
+void uses_not_introduced_struct_same_availability(struct 
not_yet_introduced_struct *);
+
 // rdar://10535640
 
 enum {


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits