[PATCH] D23765: Fix for clang PR 29087

2016-11-02 Thread Taewook Oh via cfe-commits
twoh updated this revision to Diff 76817.
twoh added a comment.

Addressing comments from @rsmith. Thanks!


https://reviews.llvm.org/D23765

Files:
  lib/Sema/SemaExprCXX.cpp
  test/SemaCXX/cxx11-crashes.cpp


Index: test/SemaCXX/cxx11-crashes.cpp
===
--- test/SemaCXX/cxx11-crashes.cpp
+++ test/SemaCXX/cxx11-crashes.cpp
@@ -91,3 +91,15 @@
   Foo(lambda);
 }
 }
+
+namespace pr29091 {
+  struct X{ X(const X &x); };
+  struct Y: X { using X::X; };
+  bool foo() { return __has_nothrow_constructor(Y); }
+  bool bar() { return __has_nothrow_copy(Y); }
+
+  struct A { template  A(); };
+  struct B : A { using A::A; };
+  bool baz() { return __has_nothrow_constructor(B); }
+  bool qux() { return __has_nothrow_copy(B); }
+}
Index: lib/Sema/SemaExprCXX.cpp
===
--- lib/Sema/SemaExprCXX.cpp
+++ lib/Sema/SemaExprCXX.cpp
@@ -4398,9 +4398,12 @@
 // A template constructor is never a copy constructor.
 // FIXME: However, it may actually be selected at the actual overload
 // resolution point.
-if (isa(ND))
+if (isa(ND->getUnderlyingDecl()))
   continue;
-const CXXConstructorDecl *Constructor = cast(ND);
+// UsingDecl itself is not a constructor
+if (isa(ND))
+  continue;
+auto *Constructor = cast(ND->getUnderlyingDecl());
 if (Constructor->isCopyConstructor(FoundTQs)) {
   FoundConstructor = true;
   const FunctionProtoType *CPT
@@ -4434,9 +4437,12 @@
   bool FoundConstructor = false;
   for (const auto *ND : Self.LookupConstructors(RD)) {
 // FIXME: In C++0x, a constructor template can be a default 
constructor.
-if (isa(ND))
+if (isa(ND->getUnderlyingDecl()))
+  continue;
+// UsingDecl itself is not a constructor
+if (isa(ND))
   continue;
-const CXXConstructorDecl *Constructor = cast(ND);
+auto *Constructor = cast(ND->getUnderlyingDecl());
 if (Constructor->isDefaultConstructor()) {
   FoundConstructor = true;
   const FunctionProtoType *CPT


Index: test/SemaCXX/cxx11-crashes.cpp
===
--- test/SemaCXX/cxx11-crashes.cpp
+++ test/SemaCXX/cxx11-crashes.cpp
@@ -91,3 +91,15 @@
   Foo(lambda);
 }
 }
+
+namespace pr29091 {
+  struct X{ X(const X &x); };
+  struct Y: X { using X::X; };
+  bool foo() { return __has_nothrow_constructor(Y); }
+  bool bar() { return __has_nothrow_copy(Y); }
+
+  struct A { template  A(); };
+  struct B : A { using A::A; };
+  bool baz() { return __has_nothrow_constructor(B); }
+  bool qux() { return __has_nothrow_copy(B); }
+}
Index: lib/Sema/SemaExprCXX.cpp
===
--- lib/Sema/SemaExprCXX.cpp
+++ lib/Sema/SemaExprCXX.cpp
@@ -4398,9 +4398,12 @@
 // A template constructor is never a copy constructor.
 // FIXME: However, it may actually be selected at the actual overload
 // resolution point.
-if (isa(ND))
+if (isa(ND->getUnderlyingDecl()))
   continue;
-const CXXConstructorDecl *Constructor = cast(ND);
+// UsingDecl itself is not a constructor
+if (isa(ND))
+  continue;
+auto *Constructor = cast(ND->getUnderlyingDecl());
 if (Constructor->isCopyConstructor(FoundTQs)) {
   FoundConstructor = true;
   const FunctionProtoType *CPT
@@ -4434,9 +4437,12 @@
   bool FoundConstructor = false;
   for (const auto *ND : Self.LookupConstructors(RD)) {
 // FIXME: In C++0x, a constructor template can be a default constructor.
-if (isa(ND))
+if (isa(ND->getUnderlyingDecl()))
+  continue;
+// UsingDecl itself is not a constructor
+if (isa(ND))
   continue;
-const CXXConstructorDecl *Constructor = cast(ND);
+auto *Constructor = cast(ND->getUnderlyingDecl());
 if (Constructor->isDefaultConstructor()) {
   FoundConstructor = true;
   const FunctionProtoType *CPT
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r285879 - [Sema] Remove a dead assignment, NFC.

2016-11-02 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Thu Nov  3 01:35:16 2016
New Revision: 285879

URL: http://llvm.org/viewvc/llvm-project?rev=285879&view=rev
Log:
[Sema] Remove a dead assignment, NFC.

The assignment to NextIsDereference is either followed by (1) another,
unrelated assignment to NextIsDereference or by (2) an early loop exit.

Found by clang's static analyzer: http://llvm.org/reports/scan-build

(While we're at it fix a typo.)

Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=285879&r1=285878&r2=285879&view=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Thu Nov  3 01:35:16 2016
@@ -9880,15 +9880,14 @@ static void DiagnoseConstAssignment(Sema
   // a note to the error.
   bool DiagnosticEmitted = false;
 
-  // Track if the current expression is the result of a derefence, and if the
-  // next checked expression is the result of a derefence.
+  // Track if the current expression is the result of a dereference, and if the
+  // next checked expression is the result of a dereference.
   bool IsDereference = false;
   bool NextIsDereference = false;
 
   // Loop to process MemberExpr chains.
   while (true) {
 IsDereference = NextIsDereference;
-NextIsDereference = false;
 
 E = E->IgnoreParenImpCasts();
 if (const MemberExpr *ME = dyn_cast(E)) {


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


[PATCH] D26271: [PPC} add extract significand/ extract exponent/test data class for vector float and vector double -- clang portion

2016-11-02 Thread Sean Fertile via cfe-commits
sfertile created this revision.
sfertile added reviewers: kbarton, nemanjai, amehsan, syzaara, jtony, lei.
sfertile added subscribers: cfe-commits, echristo.
sfertile set the repository for this revision to rL LLVM.

Add support in altivec.h for the following functions, as well as matching 
builtins:
vector unsigned long long vec_extract_exp (vector double);
vector unsigned int vec_extract_exp (vector float);
vector unsigned long long vec_extract_sig (vector double)
vector unsigned int vec_extract_sig (vector float)

Add builtins mapping to the vector float/vector double 'test data class' 
instructions, as well as a function like macro that will expand to the 
equivalent of either:
vector bool int vec_test_data_class (vector float, const int);
vector bool long long vec_test_data_class (vector double, const int);

as well as defines for all the masks used as the second argument to 
vec_test_data_class.


Repository:
  rL LLVM

https://reviews.llvm.org/D26271

Files:
  include/clang/Basic/BuiltinsPPC.def
  lib/Headers/altivec.h
  test/CodeGen/builtins-ppc-p9vector.c

Index: test/CodeGen/builtins-ppc-p9vector.c
===
--- test/CodeGen/builtins-ppc-p9vector.c
+++ test/CodeGen/builtins-ppc-p9vector.c
@@ -827,4 +827,46 @@
 // CHECK-NEXT: ret <16 x i8>
   return vec_srv (vuca, vucb);
 }
+vector unsigned int test74(void) {
+// CHECK-BE: @llvm.ppc.vsx.xvxexpsp(<4 x float> {{.+}})
+// CHECK-BE-NEXT: ret <4 x i32>
+// CHECK: @llvm.ppc.vsx.xvxexpsp(<4 x float> {{.+}})
+// CHECK-NEXT: ret <4 x i32>
+  return vec_extract_exp(vfa);
+}
+vector unsigned long long test75(void) {
+// CHECK-BE: @llvm.ppc.vsx.xvxexpdp(<2 x double> {{.+}})
+// CHECK-BE-NEXT: ret <2 x i64>
+// CHECK: @llvm.ppc.vsx.xvxexpdp(<2 x double> {{.+}})
+// CHECK-NEXT: ret <2 x i64>
+  return vec_extract_exp(vda);
+}
+vector unsigned int test76(void) {
+// CHECK-BE: @llvm.ppc.vsx.xvxsigsp(<4 x float> {{.+}})
+// CHECK-BE-NEXT: ret <4 x i32>
+// CHECK: @llvm.ppc.vsx.xvxsigsp(<4 x float> {{.+}})
+// CHECK-NEXT: ret <4 x i32>
+  return vec_extract_sig(vfa);
+}
+vector unsigned long long test77(void) {
+// CHECK-BE: @llvm.ppc.vsx.xvxsigdp(<2 x double> {{.+}})
+// CHECK-BE-NEXT: ret <2 x i64>
+// CHECK: @llvm.ppc.vsx.xvxsigdp(<2 x double> {{.+}})
+// CHECK-NEXT: ret <2 x i64>
+  return vec_extract_sig(vda);
+}
+vector bool int test78(void) {
+// CHECK-BE: @llvm.ppc.vsx.xvtstdcsp(<4 x float> {{.+}}, i32 127)
+// CHECK-BE-NEXT: ret <4 x i32>
+// CHECK: @llvm.ppc.vsx.xvtstdcsp(<4 x float> {{.+}}, i32 127)
+// CHECK-NEXT: ret <4 x i32>
+   return vec_test_data_class(vfa, __VEC_CLASS_FP_NOT_NORMAL);
+}
+vector bool long long test79(void) {
+// CHECK-BE: @llvm.ppc.vsx.xvtstdcdp(<2 x double> {{.+}}, i32 127)
+// CHECK-BE_NEXT: ret <2 x i64
+// CHECK: @llvm.ppc.vsx.xvtstdcdp(<2 x double> {{.+}}, i32 127)
+// CHECK-NEXT: ret <2 x i64>
+  return vec_test_data_class(vda, __VEC_CLASS_FP_NOT_NORMAL);
+}
 
Index: lib/Headers/altivec.h
===
--- lib/Headers/altivec.h
+++ lib/Headers/altivec.h
@@ -34,6 +34,25 @@
 #define __CR6_LT 2
 #define __CR6_LT_REV 3
 
+/* Constants for vec_test_data_class */
+#define __VEC_CLASS_FP_SUBNORMAL_N (1 << 0)
+#define __VEC_CLASS_FP_SUBNORMAL_P (1 << 1)
+#define __VEC_CLASS_FP_SUBNORMAL (__VEC_CLASS_FP_SUBNORMAL_P | \
+  __VEC_CLASS_FP_SUBNORMAL_N)
+#define __VEC_CLASS_FP_ZERO_N (1<<2)
+#define __VEC_CLASS_FP_ZERO_P (1<<3)
+#define __VEC_CLASS_FP_ZERO (__VEC_CLASS_FP_ZERO_P   | \
+ __VEC_CLASS_FP_ZERO_N)
+#define __VEC_CLASS_FP_INFINITY_N (1<<4)
+#define __VEC_CLASS_FP_INFINITY_P (1<<5)
+#define __VEC_CLASS_FP_INFINITY (__VEC_CLASS_FP_INFINITY_P   | \
+ __VEC_CLASS_FP_INFINITY_N)
+#define __VEC_CLASS_FP_NAN (1<<6)
+#define __VEC_CLASS_FP_NOT_NORMAL (__VEC_CLASS_FP_NAN| \
+   __VEC_CLASS_FP_SUBNORMAL  | \
+   __VEC_CLASS_FP_ZERO   | \
+   __VEC_CLASS_FP_INFINITY)
+
 #define __ATTRS_o_ai __attribute__((__overloadable__, __always_inline__))
 
 static __inline__ vector signed char __ATTRS_o_ai vec_perm(
@@ -11873,6 +11892,34 @@
   return __a[__b];
 }
 
+#ifdef __POWER9_VECTOR__
+
+/* vec_extract_exp */
+
+static __inline__ vector unsigned int __ATTRS_o_ai
+vec_extract_exp(vector float __a) {
+  return __builtin_vsx_xvxexpsp(__a);
+}
+
+static __inline__ vector unsigned long long __ATTRS_o_ai
+vec_extract_exp(vector double __a) {
+  return __builtin_vsx_xvxexpdp(__a);
+}
+
+/* vec_extract_sig */
+
+static __inline__ vector unsigned int __ATTRS_o_ai
+vec_extract_sig(vector float __a) {
+  return __builtin_vsx_xvxsigsp(__a);
+}
+
+static __inline__ vector unsigned long long __ATTRS_o_ai
+vec_extract_sig (vector double __a) {
+  return __builtin_vsx_xvxsigdp(__a);
+}
+
+#endif /* __POWER9_VECTOR__ */
+
 /* vec_insert */
 
 sta

r285873 - [CodeGen] Use StringRef. NFC.

2016-11-02 Thread George Burgess IV via cfe-commits
Author: gbiv
Date: Wed Nov  2 21:21:43 2016
New Revision: 285873

URL: http://llvm.org/viewvc/llvm-project?rev=285873&view=rev
Log:
[CodeGen] Use StringRef. NFC.

Looks like CurFn's name outlives FunctionName, so we can just pass
StringRefs around rather than going from a StringRef to a std::string
to a const char* to a StringRef.

Modified:
cfe/trunk/lib/CodeGen/CGBlocks.cpp
cfe/trunk/lib/CodeGen/CGExprConstant.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.h

Modified: cfe/trunk/lib/CodeGen/CGBlocks.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBlocks.cpp?rev=285873&r1=285872&r2=285873&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBlocks.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBlocks.cpp Wed Nov  2 21:21:43 2016
@@ -1052,10 +1052,10 @@ Address CodeGenFunction::GetAddrOfBlockD
 }
 
 llvm::Constant *
-CodeGenModule::GetAddrOfGlobalBlock(const BlockExpr *blockExpr,
-const char *name) {
-  CGBlockInfo blockInfo(blockExpr->getBlockDecl(), name);
-  blockInfo.BlockExpression = blockExpr;
+CodeGenModule::GetAddrOfGlobalBlock(const BlockExpr *BE,
+StringRef Name) {
+  CGBlockInfo blockInfo(BE->getBlockDecl(), Name);
+  blockInfo.BlockExpression = BE;
 
   // Compute information about the layout, etc., of this block.
   computeBlockInfo(*this, nullptr, blockInfo);

Modified: cfe/trunk/lib/CodeGen/CGExprConstant.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprConstant.cpp?rev=285873&r1=285872&r2=285873&view=diff
==
--- cfe/trunk/lib/CodeGen/CGExprConstant.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprConstant.cpp Wed Nov  2 21:21:43 2016
@@ -1086,7 +1086,7 @@ public:
   return CGM.GetAddrOfConstantCFString(Literal);
 }
 case Expr::BlockExprClass: {
-  std::string FunctionName;
+  StringRef FunctionName;
   if (CGF)
 FunctionName = CGF->CurFn->getName();
   else
@@ -1094,7 +1094,7 @@ public:
 
   // This is not really an l-value.
   llvm::Constant *Ptr =
-CGM.GetAddrOfGlobalBlock(cast(E), FunctionName.c_str());
+CGM.GetAddrOfGlobalBlock(cast(E), FunctionName);
   return ConstantAddress(Ptr, CGM.getPointerAlign());
 }
 case Expr::CXXTypeidExprClass: {

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.h?rev=285873&r1=285872&r2=285873&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.h Wed Nov  2 21:21:43 2016
@@ -773,7 +773,7 @@ public:
   llvm::Type *getGenericBlockLiteralType();
 
   /// Gets the address of a block which requires no captures.
-  llvm::Constant *GetAddrOfGlobalBlock(const BlockExpr *BE, const char *);
+  llvm::Constant *GetAddrOfGlobalBlock(const BlockExpr *BE, StringRef Name);
   
   /// Return a pointer to a constant CFString object for the given string.
   ConstantAddress GetAddrOfConstantCFString(const StringLiteral *Literal);


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


r285872 - [Sema] Allow static_cast(e) to check explicit conversions for non-reference-related types.

2016-11-02 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed Nov  2 21:13:17 2016
New Revision: 285872

URL: http://llvm.org/viewvc/llvm-project?rev=285872&view=rev
Log:
[Sema] Allow static_cast(e) to check explicit conversions for 
non-reference-related types.

Summary:
[expr.cast.static] states:
> 3. A glvalue of type “cv1 T1” can be cast to type “rvalue reference to cv2 
> T2” if “cv2 T2” is reference-compatible
> with “cv1 T1”. The result refers to the object or the specified base class 
> subobject thereof. If T2 is
> an inaccessible or ambiguous base class of T1, a program that necessitates 
> such a cast is
> ill-formed.
> 
> 4. Otherwise, an expression e can be explicitly converted to a type T using a 
> static_cast of the form static_-
> cast(e) if the declaration T t(e); is well-formed, for some invented 
> temporary variable t. [...]

Currently when checking p3 Clang will diagnose `static_cast(e)` as invalid 
if the argument is not reference compatible with `T`. However I believe the 
correct behavior is to also check p4 in those cases.  For example:

```
double y = 42;
static_cast(y); // this should be OK.  'int&& t(y)' is well formed
```

Note that we still don't check p4 for non-reference-compatible types which are 
reference-related since  `T&& t(e);` should never be well formed in those cases.


Reviewers: rsmith

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D26231

Added:
cfe/trunk/test/CXX/expr/expr.post/expr.static.cast/p3-p4-0x.cpp
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaCast.cpp
cfe/trunk/test/SemaCXX/rval-references.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=285872&r1=285871&r2=285872&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed Nov  2 21:13:17 
2016
@@ -5944,6 +5944,9 @@ def err_bad_cxx_cast_vector_to_vector_di
 def err_bad_lvalue_to_rvalue_cast : Error<
   "cannot cast from lvalue of type %1 to rvalue reference type %2; types are "
   "not compatible">;
+def err_bad_rvalue_to_rvalue_cast : Error<
+  "cannot cast from rvalue of type %1 to rvalue reference type %2; types are "
+  "not compatible">;
 def err_bad_static_cast_pointer_nonpointer : Error<
   "cannot cast from type %1 to pointer type %2">;
 def err_bad_static_cast_member_pointer_nonmp : Error<

Modified: cfe/trunk/lib/Sema/SemaCast.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCast.cpp?rev=285872&r1=285871&r2=285872&view=diff
==
--- cfe/trunk/lib/Sema/SemaCast.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCast.cpp Wed Nov  2 21:13:17 2016
@@ -983,7 +983,7 @@ static TryCastResult TryStaticCast(Sema
   // C++11 [expr.static.cast]p3: 
   //   A glvalue of type "cv1 T1" can be cast to type "rvalue reference to cv2
   //   T2" if "cv2 T2" is reference-compatible with "cv1 T1".
-  tcr = TryLValueToRValueCast(Self, SrcExpr.get(), DestType, CStyle, Kind, 
+  tcr = TryLValueToRValueCast(Self, SrcExpr.get(), DestType, CStyle, Kind,
   BasePath, msg);
   if (tcr != TC_NotApplicable)
 return tcr;
@@ -1134,12 +1134,12 @@ static TryCastResult TryStaticCast(Sema
 }
 
 /// Tests whether a conversion according to N2844 is valid.
-TryCastResult
-TryLValueToRValueCast(Sema &Self, Expr *SrcExpr, QualType DestType,
-  bool CStyle, CastKind &Kind, CXXCastPath &BasePath, 
-  unsigned &msg) {
+TryCastResult TryLValueToRValueCast(Sema &Self, Expr *SrcExpr,
+QualType DestType, bool CStyle,
+CastKind &Kind, CXXCastPath &BasePath,
+unsigned &msg) {
   // C++11 [expr.static.cast]p3:
-  //   A glvalue of type "cv1 T1" can be cast to type "rvalue reference to 
+  //   A glvalue of type "cv1 T1" can be cast to type "rvalue reference to
   //   cv2 T2" if "cv2 T2" is reference-compatible with "cv1 T1".
   const RValueReferenceType *R = DestType->getAs();
   if (!R)
@@ -1160,15 +1160,18 @@ TryLValueToRValueCast(Sema &Self, Expr *
 FromType = FromType.getUnqualifiedType();
 ToType = ToType.getUnqualifiedType();
   }
-  
-  if (Self.CompareReferenceRelationship(SrcExpr->getLocStart(),
-ToType, FromType,
-DerivedToBase, ObjCConversion,
-ObjCLifetimeConversion) 
-!= Sema::Ref_Compatible) {
-if (CStyle)
+
+  Sema::ReferenceCompareResult RefResult = Self.CompareReferenceRelationship(
+  SrcExpr->getLocStart(), ToType, FromType, DerivedToBase, ObjCConversion,
+  ObjCLifetimeConversion);
+  if (RefResult 

[PATCH] D26231: [Sema] Allow static_cast(e) to check explicit conversions for non-reference-related types.

2016-11-02 Thread Eric Fiselier via cfe-commits
EricWF marked 2 inline comments as done.
EricWF added inline comments.



Comment at: lib/Sema/SemaCast.cpp:1148
 
+  // FIXME C++1z doesn't allow this conversions for xvalues.
   if (!SrcExpr->isGLValue())

rsmith wrote:
> Actually, it does, but it's covered by p4. (p3 now only covers the special 
> lvalue->xvalue case for `static_cast`, which is not permitted by p4.) It's 
> fine for us to still handle this here, or to allow the p4 case to deal with 
> it instead. It's probably better to keep handling it here, since we produce 
> better diagnostics this way.
Cool sounds good. I knew p4 would end up handling it, but I wasn't sure if 
forwarding to p4 would allow previously ill-formed conversions. I tried to 
construct such a case but couldn't.



Comment at: lib/Sema/SemaCast.cpp:1171-1173
+msg = SrcExpr->isLValue() ? diag::err_bad_lvalue_to_rvalue_cast
+  : diag::err_bad_rvalue_to_rvalue_cast;
 return TC_Failed;

rsmith wrote:
> OK, so the idea here is that p4 will never apply in a case where the 
> reference is reference-related to the source but not reference-compatible, 
> and no other rules would let us static_cast to reference type? It would be 
> good to add a comment explaining that, since it's not immediately obvious.
That's my understanding. I'll add a comment.  


https://reviews.llvm.org/D26231



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


[PATCH] D26166: [Sema] Don't issue analysis-based warnings when a fatal error has occurred

2016-11-02 Thread Richard Smith via cfe-commits
rsmith accepted this revision.
rsmith added inline comments.
This revision is now accepted and ready to land.



Comment at: lib/Sema/SemaTemplateInstantiate.cpp:213-214
+  // Don't allow further instantiation if a fatal error and an uncompilable
+  // error have occcured. Any diagnostics we might have raised will not be
+  // visible.
+  if (SemaRef.Diags.hasFatalErrorOccurred() &&

Maybe "Any diagnostics we might have raised will not be visible, and we do not 
need to construct a correct AST." to justify the two checks?


https://reviews.llvm.org/D26166



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


[PATCH] D21298: [Clang-tidy] delete null check

2016-11-02 Thread Gergely Angeli via cfe-commits
SilverGeri removed rL LLVM as the repository for this revision.
SilverGeri updated this revision to Diff 76803.
Herald added a subscriber: mgorny.

https://reviews.llvm.org/D21298

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/DeleteNullPointerCheck.cpp
  clang-tidy/misc/DeleteNullPointerCheck.h
  clang-tidy/misc/MiscTidyModule.cpp
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-delete-null-pointer.rst
  test/clang-tidy/misc-delete-null-pointer.cpp

Index: test/clang-tidy/misc-delete-null-pointer.cpp
===
--- /dev/null
+++ test/clang-tidy/misc-delete-null-pointer.cpp
@@ -0,0 +1,29 @@
+// RUN: %check_clang_tidy %s misc-delete-null-pointer %t
+
+void f() {
+  int *p = 0;
+  if (p) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: if statement is unnecessary (deleting null pointer has no effect) [misc-delete-null-pointer]
+delete p;
+  }
+  // CHECK-FIXES: delete p;
+  int *p3 = new int[3];
+  if (p3)
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: if statement is unnecessary (deleting null pointer has no effect) [misc-delete-null-pointer]
+delete[] p3;
+  // CHECK-FIXES: delete[] p3;
+}
+
+void g() {
+  int *p, *p2;
+  if (p)
+delete p2;
+
+  if (p && p2)
+delete p;
+
+  if (p2) {
+int x = 5;
+delete p2;
+  }
+}
Index: docs/clang-tidy/checks/misc-delete-null-pointer.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/misc-delete-null-pointer.rst
@@ -0,0 +1,12 @@
+.. title:: clang-tidy - misc-delete-null-pointer
+
+misc-delete-null-pointer
+
+
+Checks the if statements where a pointer's existence is checked and then deletes the pointer.
+The check is unnecessary as deleting a nullpointer has no effect.
+
+.. code:: c++
+int *p;
+  if (p)
+delete p;
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -58,6 +58,7 @@
misc-bool-pointer-implicit-conversion
misc-dangling-handle
misc-definitions-in-headers
+   misc-delete-null-pointer
misc-fold-init-type
misc-forward-declaration-namespace
misc-inaccurate-erase
Index: clang-tidy/misc/MiscTidyModule.cpp
===
--- clang-tidy/misc/MiscTidyModule.cpp
+++ clang-tidy/misc/MiscTidyModule.cpp
@@ -12,6 +12,7 @@
 #include "../ClangTidyModuleRegistry.h"
 #include "ArgumentCommentCheck.h"
 #include "AssertSideEffectCheck.h"
+#include "DeleteNullPointerCheck.h"
 #include "MisplacedConstCheck.h"
 #include "UnconventionalAssignOperatorCheck.h"
 #include "BoolPointerImplicitConversionCheck.h"
@@ -63,6 +64,8 @@
 CheckFactories.registerCheck("misc-argument-comment");
 CheckFactories.registerCheck(
 "misc-assert-side-effect");
+CheckFactories.registerCheck(
+"misc-delete-null-pointer");
 CheckFactories.registerCheck(
 "misc-misplaced-const");
 CheckFactories.registerCheck(
Index: clang-tidy/misc/DeleteNullPointerCheck.h
===
--- /dev/null
+++ clang-tidy/misc/DeleteNullPointerCheck.h
@@ -0,0 +1,35 @@
+//===--- DeleteNullPointerCheck.h - clang-tidy---*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_DELETE_NULL_POINTER_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_DELETE_NULL_POINTER_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+namespace misc {
+
+/// FIXME: Write a short description.
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/misc-delete-null-pointer.html
+class DeleteNullPointerCheck : public ClangTidyCheck {
+public:
+  DeleteNullPointerCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+};
+
+} // namespace misc
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_DELETE_NULL_POINTER_H
Index: clang-tidy/misc/DeleteNullPointerCheck.cpp
===
--- /dev/null
+++ clang-tidy/misc/DeleteNullPointerCheck.cpp
@@ -0,0 +1,58 @@
+//===--- DeleteNullPointerCheck.cpp - clang-tidy---===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===---

[PATCH] D26268: [CUDA] Use only the GVALinkage on function definitions.

2016-11-02 Thread Justin Lebar via cfe-commits
jlebar created this revision.
jlebar added a reviewer: tra.
jlebar added subscribers: rsmith, cfe-commits.

Previously we'd look at the GVALinkage of whatever FunctionDecl you
happened to be calling.

This is not right.  In the absence of the gnu_inline attribute, to be
handled separately, the function definition determines the function's
linkage.  So we need to wait until we get a def before we can know
whether something is known-emitted.


https://reviews.llvm.org/D26268

Files:
  clang/lib/Sema/SemaCUDA.cpp
  clang/test/SemaCUDA/add-inline-in-definition.cu


Index: clang/test/SemaCUDA/add-inline-in-definition.cu
===
--- /dev/null
+++ clang/test/SemaCUDA/add-inline-in-definition.cu
@@ -0,0 +1,51 @@
+// RUN: %clang_cc1 -std=c++11 -fcuda-is-device -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+#include "Inputs/cuda.h"
+
+#ifndef __CUDA_ARCH__
+// expected-no-diagnostics
+#endif
+
+// When compiling for device, foo()'s call to host_fn() is an error, because
+// foo() is known-emitted.
+//
+// The trickiness here comes from the fact that the FunctionDecl bar() sees for
+// foo() does not have the "inline" keyword, so we might incorrectly think that
+// foo() is a priori known-emitted.  This would prevent us from marking foo()
+// as known-emitted, which would prevent us from emitting an error for foo()'s
+// call to host_fn() when we eventually see it.
+
+void host_fn() {}
+#ifdef __CUDA_ARCH__
+  // expected-note@-2 {{declared here}}
+#endif
+
+__host__ __device__ void foo();
+__device__ void bar() {
+  foo();
+#ifdef __CUDA_ARCH__
+  // expected-note@-2 {{called by 'bar'}}
+#endif
+}
+inline __host__ __device__ void foo() {
+  host_fn();
+#ifdef __CUDA_ARCH__
+  // expected-error@-2 {{reference to __host__ function}}
+#endif
+}
+
+// This is similar to the above, except there's no error here.  This code used
+// to trip an assertion due to us noticing, when emitting the definition of
+// boom(), that T::operator S() was (incorrectly) considered a priori
+// known-emitted.
+struct S {};
+struct T {
+  __device__ operator S() const;
+};
+__device__ inline T::operator S() const { return S(); }
+
+__device__ T t;
+__device__ void boom() {
+  S s = t;
+}
Index: clang/lib/Sema/SemaCUDA.cpp
===
--- clang/lib/Sema/SemaCUDA.cpp
+++ clang/lib/Sema/SemaCUDA.cpp
@@ -577,8 +577,22 @@
   (T == Sema::CFT_Device || T == Sema::CFT_Global))
 return false;
 
-  // Externally-visible and similar functions are always emitted.
-  if (!isDiscardableGVALinkage(S.getASTContext().GetGVALinkageForFunction(FD)))
+  // Check whether this function is externally visible -- if so, it's
+  // known-emitted.
+  //
+  // We have to check the GVA linkage of the function's *definition* -- if we
+  // only have a declaration, we don't know whether or not the function will be
+  // emitted, because (say) the definition could include "inline".
+  FunctionDecl *Def = FD->getDefinition();
+
+  // We may currently be parsing the body of FD, in which case
+  // FD->getDefinition() will be null, but we still want to treat FD as though
+  // it's a definition.
+  if (!Def && FD->willHaveBody())
+Def = FD;
+
+  if (Def &&
+  
!isDiscardableGVALinkage(S.getASTContext().GetGVALinkageForFunction(Def)))
 return true;
 
   // Otherwise, the function is known-emitted if it's in our set of


Index: clang/test/SemaCUDA/add-inline-in-definition.cu
===
--- /dev/null
+++ clang/test/SemaCUDA/add-inline-in-definition.cu
@@ -0,0 +1,51 @@
+// RUN: %clang_cc1 -std=c++11 -fcuda-is-device -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+#include "Inputs/cuda.h"
+
+#ifndef __CUDA_ARCH__
+// expected-no-diagnostics
+#endif
+
+// When compiling for device, foo()'s call to host_fn() is an error, because
+// foo() is known-emitted.
+//
+// The trickiness here comes from the fact that the FunctionDecl bar() sees for
+// foo() does not have the "inline" keyword, so we might incorrectly think that
+// foo() is a priori known-emitted.  This would prevent us from marking foo()
+// as known-emitted, which would prevent us from emitting an error for foo()'s
+// call to host_fn() when we eventually see it.
+
+void host_fn() {}
+#ifdef __CUDA_ARCH__
+  // expected-note@-2 {{declared here}}
+#endif
+
+__host__ __device__ void foo();
+__device__ void bar() {
+  foo();
+#ifdef __CUDA_ARCH__
+  // expected-note@-2 {{called by 'bar'}}
+#endif
+}
+inline __host__ __device__ void foo() {
+  host_fn();
+#ifdef __CUDA_ARCH__
+  // expected-error@-2 {{reference to __host__ function}}
+#endif
+}
+
+// This is similar to the above, except there's no error here.  This code used
+// to trip an assertion due to us noticing, when emitting the definition of
+// boom(), that T::operator S() was (incorrectly) considered a p

[PATCH] D26267: [Modules] Include builtins with #include instead of #import for ObjC

2016-11-02 Thread Bruno Cardoso Lopes via cfe-commits
bruno created this revision.
bruno added a reviewer: rsmith.
bruno added subscribers: cfe-commits, manmanren.

After r284797 builins are treated like textual includes. When compiling for 
ObjC++, the in-memory header file generated for the modules is composed only of 
#import's instead of includes. That could block some textual includes to happen 
because #import's will not re-enter headers already handled by other #import's.

Use #include when the header in question is a built-in.


https://reviews.llvm.org/D26267

Files:
  include/clang/Lex/ModuleMap.h
  lib/Frontend/FrontendActions.cpp
  lib/Lex/ModuleMap.cpp
  test/Modules/Inputs/libc-libcxx/sysroot/usr/include/c++/v1/cstddef
  test/Modules/Inputs/libc-libcxx/sysroot/usr/include/c++/v1/math.h
  test/Modules/Inputs/libc-libcxx/sysroot/usr/include/c++/v1/module.modulemap
  test/Modules/Inputs/libc-libcxx/sysroot/usr/include/c++/v1/stddef.h
  test/Modules/Inputs/libc-libcxx/sysroot/usr/include/c++/v1/type_traits
  test/Modules/Inputs/libc-libcxx/sysroot/usr/include/module.modulemap
  test/Modules/Inputs/libc-libcxx/sysroot/usr/include/stddef.h
  test/Modules/Inputs/libc-libcxx/sysroot/usr/include/sys/_types/_ptrdiff_t.h
  test/Modules/Inputs/libc-libcxx/sysroot/usr/include/sys/_types/_types.h
  test/Modules/builtin-import.mm

Index: test/Modules/builtin-import.mm
===
--- /dev/null
+++ test/Modules/builtin-import.mm
@@ -0,0 +1,6 @@
+// REQUIRES: system-darwin
+
+// RUN: rm -rf %t
+// RUN: %clang -cc1 -fsyntax-only -nostdinc++ -isysroot %S/Inputs/libc-libcxx/sysroot -isystem %S/Inputs/libc-libcxx/sysroot/usr/include/c++/v1 -F%S/Inputs/libc-libcxx/sysroot/Frameworks -std=c++11 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -x objective-c++ -fmodules-local-submodule-visibility %s
+
+#include 
Index: test/Modules/Inputs/libc-libcxx/sysroot/usr/include/sys/_types/_types.h
===
--- /dev/null
+++ test/Modules/Inputs/libc-libcxx/sysroot/usr/include/sys/_types/_types.h
@@ -0,0 +1,6 @@
+#ifndef _SYS_TYPES_UMBRELLA
+#define _SYS_TYPES_UMBRELLA
+
+#include "_ptrdiff_t.h"
+
+#endif
Index: test/Modules/Inputs/libc-libcxx/sysroot/usr/include/sys/_types/_ptrdiff_t.h
===
--- /dev/null
+++ test/Modules/Inputs/libc-libcxx/sysroot/usr/include/sys/_types/_ptrdiff_t.h
@@ -0,0 +1,4 @@
+#ifndef _PTRDIFF_T
+#define _PTRDIFF_T
+typedef int * ptrdiff_t;
+#endif /* _PTRDIFF_T */
Index: test/Modules/Inputs/libc-libcxx/sysroot/usr/include/stddef.h
===
--- test/Modules/Inputs/libc-libcxx/sysroot/usr/include/stddef.h
+++ test/Modules/Inputs/libc-libcxx/sysroot/usr/include/stddef.h
@@ -1 +1,6 @@
-// stddef.h
+#ifndef __STDDEF_H__
+#define __STDDEF_H__
+
+#include "sys/_types/_ptrdiff_t.h"
+
+#endif
Index: test/Modules/Inputs/libc-libcxx/sysroot/usr/include/module.modulemap
===
--- test/Modules/Inputs/libc-libcxx/sysroot/usr/include/module.modulemap
+++ test/Modules/Inputs/libc-libcxx/sysroot/usr/include/module.modulemap
@@ -5,4 +5,12 @@
   module stdint { header "stdint.h" export * }
   module stdio { header "stdio.h" export * }
   module util { header "util.h" export * }
+  module POSIX {
+module sys {
+  module types {
+umbrella header "sys/_types/_types.h"
+export *
+  }
+}
+  }
 }
Index: test/Modules/Inputs/libc-libcxx/sysroot/usr/include/c++/v1/type_traits
===
--- /dev/null
+++ test/Modules/Inputs/libc-libcxx/sysroot/usr/include/c++/v1/type_traits
@@ -0,0 +1,6 @@
+#ifndef _LIBCPP_TYPE_TRAITS
+#define _LIBCPP_TYPE_TRAITS
+
+#include 
+
+#endif
Index: test/Modules/Inputs/libc-libcxx/sysroot/usr/include/c++/v1/stddef.h
===
--- test/Modules/Inputs/libc-libcxx/sysroot/usr/include/c++/v1/stddef.h
+++ test/Modules/Inputs/libc-libcxx/sysroot/usr/include/c++/v1/stddef.h
@@ -2,5 +2,6 @@
 #define LIBCXX_STDDEF_H
 
 #include <__config>
+#include_next 
 
 #endif
Index: test/Modules/Inputs/libc-libcxx/sysroot/usr/include/c++/v1/module.modulemap
===
--- test/Modules/Inputs/libc-libcxx/sysroot/usr/include/c++/v1/module.modulemap
+++ test/Modules/Inputs/libc-libcxx/sysroot/usr/include/c++/v1/module.modulemap
@@ -6,5 +6,7 @@
   // FIXME: remove "textual" from stdint module below once the issue
   // between umbrella headers and builtins is resolved.
   module stdint { textual header "stdint.h" export * }
+  module type_traits { header "type_traits" export * }
+  module cstddef { header "cstddef" export * }
   module __config { header "__config" export * }
 }
Index: test/Modules/Inputs/libc-libcxx/sysroot/usr/include/c++/v1/math.h
=

r285870 - Update manglings for C++17 noexcept function types to match Jason Merrill's

2016-11-02 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Wed Nov  2 19:27:54 2016
New Revision: 285870

URL: http://llvm.org/viewvc/llvm-project?rev=285870&view=rev
Log:
Update manglings for C++17 noexcept function types to match Jason Merrill's
proposal on cxx-abi-dev earlier today.

Modified:
cfe/trunk/lib/AST/ItaniumMangle.cpp
cfe/trunk/test/CodeGenCXX/mangle-exception-spec.cpp
cfe/trunk/test/CodeGenCXX/rtti-qualfn.cpp

Modified: cfe/trunk/lib/AST/ItaniumMangle.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ItaniumMangle.cpp?rev=285870&r1=285869&r2=285870&view=diff
==
--- cfe/trunk/lib/AST/ItaniumMangle.cpp (original)
+++ cfe/trunk/lib/AST/ItaniumMangle.cpp Wed Nov  2 19:27:54 2016
@@ -2585,18 +2585,18 @@ void CXXNameMangler::mangleType(const Fu
   // per cxx-abi-dev proposal on 2016-10-11.
   if (T->hasInstantiationDependentExceptionSpec()) {
 if (T->getExceptionSpecType() == EST_ComputedNoexcept) {
-  Out << "nX";
+  Out << "DO";
   mangleExpression(T->getNoexceptExpr());
   Out << "E";
 } else {
   assert(T->getExceptionSpecType() == EST_Dynamic);
-  Out << "tw";
+  Out << "Dw";
   for (auto ExceptTy : T->exceptions())
 mangleType(ExceptTy);
   Out << "E";
 }
   } else if (T->isNothrow(getASTContext())) {
-Out << "nx";
+Out << "Do";
   }
 
   Out << 'F';

Modified: cfe/trunk/test/CodeGenCXX/mangle-exception-spec.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/mangle-exception-spec.cpp?rev=285870&r1=285869&r2=285870&view=diff
==
--- cfe/trunk/test/CodeGenCXX/mangle-exception-spec.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/mangle-exception-spec.cpp Wed Nov  2 19:27:54 2016
@@ -4,35 +4,35 @@
 // CHECK: define {{.*}} @_Z1aPFivE(
 void a(int() throw(int, float)) {}
 // CHECK-CXX11: define {{.*}} @_Z1bPFivE(
-// CHECK-CXX17: define {{.*}} @_Z1bPnxFivE(
+// CHECK-CXX17: define {{.*}} @_Z1bPDoFivE(
 void b(int() noexcept) {}
 // CHECK-CXX11: define {{.*}} @_Z1cPFivE(
-// CHECK-CXX17: define {{.*}} @_Z1cPnxFivE(
+// CHECK-CXX17: define {{.*}} @_Z1cPDoFivE(
 void c(int() throw()) {}
 // CHECK: define {{.*}} @_Z1dPFivE(
 void d(int() noexcept(false)) {}
 // CHECK-CXX11: define {{.*}} @_Z1ePFivE(
-// CHECK-CXX17: define {{.*}} @_Z1ePnxFivE(
+// CHECK-CXX17: define {{.*}} @_Z1ePDoFivE(
 void e(int() noexcept(true)) {}
 
 template void f(int() noexcept(B)) {}
-// CHECK: define {{.*}} @_Z1fILb0EEvPnXT_EFivE(
+// CHECK: define {{.*}} @_Z1fILb0EEvPDOT_EFivE(
 template void f(int());
-// CHECK: define {{.*}} @_Z1fILb1EEvPnXT_EFivE(
+// CHECK: define {{.*}} @_Z1fILb1EEvPDOT_EFivE(
 template void f(int() noexcept);
 
 template void g(int() throw(T...)) {}
-// CHECK: define {{.*}} @_Z1gIJEEvPtwDpT_EFivE(
+// CHECK: define {{.*}} @_Z1gIJEEvPDwDpT_EFivE(
 template void g<>(int() noexcept);
-// CHECK: define {{.*}} @_Z1gIJfEEvPtwDpT_EFivE(
+// CHECK: define {{.*}} @_Z1gIJfEEvPDwDpT_EFivE(
 template void g(int());
 
 // We consider the exception specifications in parameter and return type here
 // to be different.
 template auto h(int() throw(int, T...)) -> int (*)() throw(T..., 
int) { return nullptr; }
-// CHECK: define {{.*}} @_Z1hIJEEPtwDpT_iEFivEPtwiS1_EFivE(
+// CHECK: define {{.*}} @_Z1hIJEEPDwDpT_iEFivEPDwiS1_EFivE(
 template auto h<>(int()) -> int (*)();
-// CHECK: define {{.*}} @_Z1hIJfEEPtwDpT_iEFivEPtwiS1_EFivE(
+// CHECK: define {{.*}} @_Z1hIJfEEPDwDpT_iEFivEPDwiS1_EFivE(
 template auto h(int()) -> int (*)();
 
 // FIXME: The C++11 manglings here are wrong; they should be the same as the
@@ -41,9 +41,9 @@ template auto h(int()) -> int (*)
 // differ only in type sugar that is not relevant for mangling. (In this case,
 // the types differ in presence/absence of ParenType nodes under the pointer.)
 template auto i(int() throw(int, T...)) -> int (*)() throw(int, 
T...) { return nullptr; }
-// CHECK-CXX11: define {{.*}} @_Z1iIJEEPtwiDpT_EFivEPS2_(
-// CHECK-CXX17: define {{.*}} @_Z1iIJEEPtwiDpT_EFivES3_(
+// CHECK-CXX11: define {{.*}} @_Z1iIJEEPDwiDpT_EFivEPS2_(
+// CHECK-CXX17: define {{.*}} @_Z1iIJEEPDwiDpT_EFivES3_(
 template auto i<>(int()) -> int (*)();
-// CHECK-CXX11: define {{.*}} @_Z1iIJfEEPtwiDpT_EFivEPS2_(
-// CHECK-CXX17: define {{.*}} @_Z1iIJfEEPtwiDpT_EFivES3_(
+// CHECK-CXX11: define {{.*}} @_Z1iIJfEEPDwiDpT_EFivEPS2_(
+// CHECK-CXX17: define {{.*}} @_Z1iIJfEEPDwiDpT_EFivES3_(
 template auto i(int()) -> int (*)();

Modified: cfe/trunk/test/CodeGenCXX/rtti-qualfn.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/rtti-qualfn.cpp?rev=285870&r1=285869&r2=285870&view=diff
==
--- cfe/trunk/test/CodeGenCXX/rtti-qualfn.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/rtti-qualfn.cpp Wed Nov  2 19:27:54 2016
@@ -24,8 +24,8 @@ auto &ti_lref = typeid(void (A::*)() &);
 // CHECK-DAG: @_ZTIM

r285869 - Teach clang-query to dump types. I couldn't find any existing tests for clang-query's dumping functionality. =(

2016-11-02 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Wed Nov  2 18:57:18 2016
New Revision: 285869

URL: http://llvm.org/viewvc/llvm-project?rev=285869&view=rev
Log:
Teach clang-query to dump types. I couldn't find any existing tests for 
clang-query's dumping functionality. =(

Modified:
cfe/trunk/include/clang/AST/Type.h
cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
cfe/trunk/lib/AST/ASTDumper.cpp
cfe/trunk/lib/AST/ASTTypeTraits.cpp

Modified: cfe/trunk/include/clang/AST/Type.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=285869&r1=285868&r2=285869&view=diff
==
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Wed Nov  2 18:57:18 2016
@@ -985,6 +985,7 @@ public:
 
   void dump(const char *s) const;
   void dump() const;
+  void dump(llvm::raw_ostream &OS) const;
 
   void Profile(llvm::FoldingSetNodeID &ID) const {
 ID.AddPointer(getAsOpaquePtr());
@@ -2005,6 +2006,7 @@ public:
   }
   CanQualType getCanonicalTypeUnqualified() const; // in CanonicalType.h
   void dump() const;
+  void dump(llvm::raw_ostream &OS) const;
 
   friend class ASTReader;
   friend class ASTWriter;

Modified: cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td?rev=285869&r1=285868&r2=285869&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td Wed Nov  2 18:57:18 2016
@@ -183,7 +183,7 @@ def ext_hex_constant_invalid : Extension
 def ext_hex_literal_invalid : Extension<
   "hexadecimal floating literals are a C++1z feature">, InGroup;
 def warn_cxx1z_hex_literal : Warning<
-  "hexidecimal floating literals are incompatible with "
+  "hexadecimal floating literals are incompatible with "
   "C++ standards before C++1z">,
   InGroup, DefaultIgnore;
 def ext_binary_literal : Extension<

Modified: cfe/trunk/lib/AST/ASTDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDumper.cpp?rev=285869&r1=285868&r2=285869&view=diff
==
--- cfe/trunk/lib/AST/ASTDumper.cpp (original)
+++ cfe/trunk/lib/AST/ASTDumper.cpp Wed Nov  2 18:57:18 2016
@@ -2466,12 +2466,18 @@ void QualType::dump(const char *msg) con
   dump();
 }
 
-LLVM_DUMP_METHOD void QualType::dump() const {
-  ASTDumper Dumper(llvm::errs(), nullptr, nullptr);
+LLVM_DUMP_METHOD void QualType::dump() const { dump(llvm::errs()); }
+
+LLVM_DUMP_METHOD void QualType::dump(llvm::raw_ostream &OS) const {
+  ASTDumper Dumper(OS, nullptr, nullptr);
   Dumper.dumpTypeAsChild(*this);
 }
 
-LLVM_DUMP_METHOD void Type::dump() const { QualType(this, 0).dump(); }
+LLVM_DUMP_METHOD void Type::dump() const { dump(llvm::errs()); }
+
+LLVM_DUMP_METHOD void Type::dump(llvm::raw_ostream &OS) const {
+  QualType(this, 0).dump(OS);
+}
 
 
//===--===//
 // Decl method implementations

Modified: cfe/trunk/lib/AST/ASTTypeTraits.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTTypeTraits.cpp?rev=285869&r1=285868&r2=285869&view=diff
==
--- cfe/trunk/lib/AST/ASTTypeTraits.cpp (original)
+++ cfe/trunk/lib/AST/ASTTypeTraits.cpp Wed Nov  2 18:57:18 2016
@@ -135,6 +135,8 @@ void DynTypedNode::dump(llvm::raw_ostrea
 D->dump(OS);
   else if (const Stmt *S = get())
 S->dump(OS, SM);
+  else if (const Type *T = get())
+T->dump(OS);
   else
 OS << "Unable to dump values of type " << NodeKind.asStringRef() << "\n";
 }


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


r285868 - [index] Fix assertion hit when handling a declaration of C++'s 'operator new' function.

2016-11-02 Thread Argyrios Kyrtzidis via cfe-commits
Author: akirtzidis
Date: Wed Nov  2 18:42:33 2016
New Revision: 285868

URL: http://llvm.org/viewvc/llvm-project?rev=285868&view=rev
Log:
[index] Fix assertion hit when handling a declaration of C++'s 'operator new' 
function.

Part of this is to allow creating a USR for the canonical decl of that which is 
implicit and does
not have a source location.

rdar://28978992

Modified:
cfe/trunk/lib/Index/IndexingContext.cpp
cfe/trunk/lib/Index/USRGeneration.cpp
cfe/trunk/test/Index/Core/index-source.cpp

Modified: cfe/trunk/lib/Index/IndexingContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/IndexingContext.cpp?rev=285868&r1=285867&r2=285868&view=diff
==
--- cfe/trunk/lib/Index/IndexingContext.cpp (original)
+++ cfe/trunk/lib/Index/IndexingContext.cpp Wed Nov  2 18:42:33 2016
@@ -290,19 +290,9 @@ bool IndexingContext::handleDeclOccurren
 Roles |= (unsigned)SymbolRole::Declaration;
 
   D = getCanonicalDecl(D);
-  if (D->isImplicit() && !isa(D) &&
-  !(isa(D) && cast(D)->getBuiltinID())) {
-// operator new declarations will link to the implicit one as canonical.
-return true;
-  }
   Parent = adjustParent(Parent);
   if (Parent)
 Parent = getCanonicalDecl(Parent);
-  assert((!Parent || !Parent->isImplicit() ||
-  (isa(Parent) &&
-   cast(Parent)->getBuiltinID()) ||
-  isa(Parent) || isa(Parent)) &&
- "unexpected implicit parent!");
 
   SmallVector FinalRelations;
   FinalRelations.reserve(Relations.size()+1);

Modified: cfe/trunk/lib/Index/USRGeneration.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/USRGeneration.cpp?rev=285868&r1=285867&r2=285868&view=diff
==
--- cfe/trunk/lib/Index/USRGeneration.cpp (original)
+++ cfe/trunk/lib/Index/USRGeneration.cpp Wed Nov  2 18:42:33 2016
@@ -173,8 +173,11 @@ bool USRGenerator::ShouldGenerateLocatio
 return false;
   if (D->getParentFunctionOrMethod())
 return true;
+  SourceLocation Loc = D->getLocation();
+  if (Loc.isInvalid())
+return false;
   const SourceManager &SM = Context->getSourceManager();
-  return !SM.isInSystemHeader(D->getLocation());
+  return !SM.isInSystemHeader(Loc);
 }
 
 void USRGenerator::VisitDeclContext(const DeclContext *DC) {
@@ -874,9 +877,11 @@ void clang::index::generateUSRForObjCPro
 
 bool clang::index::generateUSRForDecl(const Decl *D,
   SmallVectorImpl &Buf) {
-  // Don't generate USRs for things with invalid locations.
-  if (!D || D->getLocStart().isInvalid())
+  if (!D)
 return true;
+  // We don't ignore decls with invalid source locations. Implicit decls, like
+  // C++'s operator new function, can have invalid locations but it is fine to
+  // create USRs that can identify them.
 
   USRGenerator UG(&D->getASTContext(), Buf);
   UG.Visit(D);

Modified: cfe/trunk/test/Index/Core/index-source.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/Core/index-source.cpp?rev=285868&r1=285867&r2=285868&view=diff
==
--- cfe/trunk/test/Index/Core/index-source.cpp (original)
+++ cfe/trunk/test/Index/Core/index-source.cpp Wed Nov  2 18:42:33 2016
@@ -19,3 +19,9 @@ class BT {
 return { .idx = 0 }; // Make sure this doesn't trigger a crash.
   }
 };
+
+// CHECK: [[@LINE+1]]:23 | type-alias/C | size_t |
+typedef unsigned long size_t;
+// CHECK: [[@LINE+2]]:7 | function/C | operator new | c:@F@operator new#l# | 
__Znwm |
+// CHECK: [[@LINE+1]]:20 | type-alias/C | size_t | {{.*}} | Ref |
+void* operator new(size_t sz);


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


[libcxxabi] r285867 - [p0012] Implement ABI support for throwing a noexcept function pointer and

2016-11-02 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Wed Nov  2 18:41:51 2016
New Revision: 285867

URL: http://llvm.org/viewvc/llvm-project?rev=285867&view=rev
Log:
[p0012] Implement ABI support for throwing a noexcept function pointer and
catching as non-noexcept

This implements the following proposal from cxx-abi-dev:

http://sourcerytools.com/pipermail/cxx-abi-dev/2016-October/002988.html

... which is necessary for complete support of http://wg21.link/p0012,
specifically throwing noexcept function and member function pointers and
catching them as non-noexcept pointers.

Differential Review: https://reviews.llvm.org/D26178

Added:
libcxxabi/trunk/test/catch_function_03.pass.cpp
libcxxabi/trunk/test/catch_member_function_pointer_02.pass.cpp
Modified:
libcxxabi/trunk/src/private_typeinfo.cpp
libcxxabi/trunk/src/private_typeinfo.h
libcxxabi/trunk/test/libcxxabi/test/config.py

Modified: libcxxabi/trunk/src/private_typeinfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/private_typeinfo.cpp?rev=285867&r1=285866&r2=285867&view=diff
==
--- libcxxabi/trunk/src/private_typeinfo.cpp (original)
+++ libcxxabi/trunk/src/private_typeinfo.cpp Wed Nov  2 18:41:51 2016
@@ -105,6 +105,45 @@ __function_type_info::~__function_type_i
 {
 }
 
+// __qualified_function_type_info
+
+__qualified_function_type_info::~__qualified_function_type_info()
+{
+}
+
+// Determine if a function pointer conversion can convert a pointer (or pointer
+// to member) to type x into a pointer (or pointer to member) to type y.
+static bool is_function_pointer_conversion(const std::type_info* x,
+   const std::type_info* y)
+{
+const unsigned int discardable_quals =
+__qualified_function_type_info::__noexcept_mask |
+__qualified_function_type_info::__transaction_safe_mask |
+__qualified_function_type_info::__noreturn_mask;
+
+// If x has only discardable qualifiers and y is unqualified, then
+// conversion is permitted.
+const __qualified_function_type_info* qual_x =
+dynamic_cast(x);
+if (!qual_x)
+return false;
+if ((qual_x->__qualifiers & ~discardable_quals) == 0 &&
+is_equal(qual_x->__base_type, y, false))
+return true;
+
+// Otherwise, x's qualifiers must be the same as y's, plus some discardable
+// ones.
+const __qualified_function_type_info* qual_y =
+dynamic_cast(y);
+if (!qual_y)
+return false;
+if (qual_y->__qualifiers & ~qual_x->__qualifiers)
+return false;
+if (qual_x->__qualifiers & ~qual_y->__qualifiers & ~discardable_quals)
+return false;
+return is_equal(qual_x->__base_type, qual_y->__base_type, false);
+}
+
 // __enum_type_info
 
 __enum_type_info::~__enum_type_info()
@@ -395,6 +434,10 @@ __pointer_type_info::can_catch(const __s
 return false;
 if (is_equal(__pointee, thrown_pointer_type->__pointee, false))
 return true;
+// bullet 3C
+if (is_function_pointer_conversion(thrown_pointer_type->__pointee,
+   __pointee))
+  return true;
 // bullet 3A
 if (is_equal(__pointee, &typeid(void), false)) {
 // pointers to functions cannot be converted to void*.
@@ -502,7 +545,9 @@ bool __pointer_to_member_type_info::can_
 return false;
 if (thrown_pointer_type->__flags & ~__flags)
 return false;
-if (!is_equal(__pointee, thrown_pointer_type->__pointee, false))
+if (!is_equal(__pointee, thrown_pointer_type->__pointee, false) &&
+!is_function_pointer_conversion(thrown_pointer_type->__pointee,
+__pointee))
 return false;
 if (is_equal(__context, thrown_pointer_type->__context, false))
 return true;

Modified: libcxxabi/trunk/src/private_typeinfo.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/private_typeinfo.h?rev=285867&r1=285866&r2=285867&view=diff
==
--- libcxxabi/trunk/src/private_typeinfo.h (original)
+++ libcxxabi/trunk/src/private_typeinfo.h Wed Nov  2 18:41:51 2016
@@ -49,6 +49,33 @@ public:
void *&) const;
 };
 
+// This implements the following proposal from cxx-abi-dev (not yet part of the
+// ABI document):
+//
+//   http://sourcerytools.com/pipermail/cxx-abi-dev/2016-October/002988.html
+//
+// This is necessary for support of http://wg21.link/p0012, which permits 
throwing
+// noexcept function and member function pointers and catching them as 
non-noexcept
+// pointers.
+class _LIBCXXABI_TYPE_VIS __qualified_function_type_info : public 
__shim_type_info {
+public:
+  const __function_type_info* __base_type;
+  unsigned int __qualifiers;
+
+  enum __qualifiers_mask {
+__const_mask = 0x01,
+__volatile_mask = 0x02,
+__restrict_mask = 0x04,
+__lv

[PATCH] D26196: AMDGPU: Translate null pointers in private and local addr space

2016-11-02 Thread John McCall via cfe-commits
rjmccall added a comment.

I think there are a number of conceptual questions here, chiefly among them 
whether an llvm::ConstantPointerNull in an address-space type should have the 
correct representation for the target.  If the decision for that is "no", then 
ok, we can produce an explicit representation in IRGen; however, we will need 
to update quite a bit of code in order to do so correctly.

In general, frontend address spaces don't necessarily correspond to IR address 
spaces.  All of your address-space operations need to be parameterized with a 
frontend address space (or both a source and dest address space for 
conversions).  The question you should be keeping in mind when designing these 
APIs is "what if there were an address space defined to be exactly the generic 
address space, only with a different null value?"

IRGen has primitive knowledge about null pointer representations that are 
encoded in a bunch of places.  Among them are:

- Emitting zero-initialization.  Fortunately, we already have this 
well-abstracted because of C++; search for isZeroInitializable.
- Converting from a literal 0, nullptr_t etc. to a given pointer type; this is 
CK_NullToPointer.
- Source-level conversions of a pointer type to boolean; this is 
CK_PointerToBoolean.
- Inherent null-checks of pointer values; you'll need to search for 
CK_DerivedToBase and CK_BaseToDerived.

You will also need to verify that the AST-level constant evaluator correctly 
distinguishes between CK_NullToPointer and CK_IntegerToPointer.

I think you need to provide three basic operations on CodeGenTargetInfo:

- Get a null pointer value in a given address space as an llvm::Constant.
- Test whether a value in a given address space is a null value.
- Convert a value from one address space to another.  You'll need to make sure 
that everything in IRGen that does an address space conversion goes through 
this, and the default implementation should be the only thing that ever creates 
an LLVM addrspace cast.


https://reviews.llvm.org/D26196



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


[PATCH] D21298: [Clang-tidy] delete null check

2016-11-02 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: docs/clang-tidy/checks/misc-delete-null-pointer.rst:10
+.. code:: c++
+int *p;
+  if (p)

Please indent variable declaration.


https://reviews.llvm.org/D21298



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


Re: r285856 - Don't require nullability on template parameters in typedefs.

2016-11-02 Thread Jordan Rose via cfe-commits

> On Nov 2, 2016, at 16:20, Richard Smith  wrote:
> 
> On Wed, Nov 2, 2016 at 3:51 PM, Jordan Rose via cfe-commits 
> mailto:cfe-commits@lists.llvm.org>> wrote:
> 
>> On Nov 2, 2016, at 15:48, Richard Smith > > wrote:
>> 
>> On Wed, Nov 2, 2016 at 2:34 PM, Jordan Rose via cfe-commits 
>> mailto:cfe-commits@lists.llvm.org>> wrote:
>> 
>>> On Nov 2, 2016, at 14:31, Richard Smith >> > wrote:
>>> 
>>> On 2 Nov 2016 1:53 pm, "Jordan Rose via cfe-commits" 
>>> mailto:cfe-commits@lists.llvm.org>> wrote:
>>> Author: jrose
>>> Date: Wed Nov  2 15:44:07 2016
>>> New Revision: 285856
>>> 
>>> URL: http://llvm.org/viewvc/llvm-project?rev=285856&view=rev 
>>> 
>>> Log:
>>> Don't require nullability on template parameters in typedefs.
>>> 
>>> Previously the following code would warn on the use of "T":
>>> 
>>>   template 
>>>   struct X {
>>> typedef T *type;
>>>   };
>>> 
>>> ...because nullability is /allowed/ on template parameters (because
>>> they could be pointers). (Actually putting nullability on this use of
>>> 'T' will of course break if the argument is a non-pointer type.)
>>> 
>>> This doesn't make any sense to me. Why would T need to be a pointer type 
>>> for a nullability qualifier to be valid on a T*?
>> 
>> Sorry, this is referring to the following change to the example:
>> 
>> template 
>> struct X {
>>   typedef T _Nullable *type;
>> };
>> 
>> This is legal, but of course `X` then produces an error. So we want to 
>> accept nullability in this position (in case T is implicitly required to be 
>> a pointer type by the definition of X) but not warn when it’s missing (in 
>> case it isn’t).
>> 
>> Oh, I see. Your testcase is very confusing, though, since it wraps the 
>> problematic use of T in a completely-unrelated pointer type. The actual 
>> problem being fixed is much more obvious in a case like this:
>> 
>> int *_Nullable p;
>> template struct X {
>>   T t; // warns without your fix
>> };
>> 
>> It'd be easier on future readers of this code to use the more obvious test 
>> case here.
> 
> Ah, that case doesn’t actually trigger the issue, because a typedef doesn’t 
> require nullability on its outermost pointer type. (It’s assumed that the use 
> site may need to make some uses of the typedef nullable and some 
> non-nullable.)
> 
> The testcase I gave above definitely produces a bogus warning before your 
> patch. I've not actually checked whether the patch fixes it, though.
>  

Oops, sorry, I misread it thinking it still said ‘typedef’. Yes, that does 
warn, and no, this patch does not fix it.

Jordan

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


Re: r285856 - Don't require nullability on template parameters in typedefs.

2016-11-02 Thread Richard Smith via cfe-commits
On Wed, Nov 2, 2016 at 3:51 PM, Jordan Rose via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

>
> On Nov 2, 2016, at 15:48, Richard Smith  wrote:
>
> On Wed, Nov 2, 2016 at 2:34 PM, Jordan Rose via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>>
>> On Nov 2, 2016, at 14:31, Richard Smith  wrote:
>>
>> On 2 Nov 2016 1:53 pm, "Jordan Rose via cfe-commits" <
>> cfe-commits@lists.llvm.org> wrote:
>>
>> Author: jrose
>> Date: Wed Nov  2 15:44:07 2016
>> New Revision: 285856
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=285856&view=rev
>> Log:
>> Don't require nullability on template parameters in typedefs.
>>
>> Previously the following code would warn on the use of "T":
>>
>>   template 
>>   struct X {
>> typedef T *type;
>>   };
>>
>> ...because nullability is /allowed/ on template parameters (because
>> they could be pointers). (Actually putting nullability on this use of
>> 'T' will of course break if the argument is a non-pointer type.)
>>
>>
>> This doesn't make any sense to me. Why would T need to be a pointer type
>> for a nullability qualifier to be valid on a T*?
>>
>>
>> Sorry, this is referring to the following change to the example:
>>
>> template 
>> struct X {
>>   typedef T _Nullable *type;
>> };
>>
>>
>> This is legal, but of course `X` then produces an error. So we want
>> to accept nullability in this position (in case T is implicitly required to
>> be a pointer type by the definition of X) but not warn when it’s missing
>> (in case it isn’t).
>>
>
> Oh, I see. Your testcase is very confusing, though, since it wraps the
> problematic use of T in a completely-unrelated pointer type. The actual
> problem being fixed is much more obvious in a case like this:
>
> int *_Nullable p;
> template struct X {
>   T t; // warns without your fix
> };
>
> It'd be easier on future readers of this code to use the more obvious test
> case here.
>
>
> Ah, that case doesn’t actually trigger the issue, because a typedef
> doesn’t require nullability on its outermost pointer type. (It’s assumed
> that the use site may need to make some uses of the typedef nullable and
> some non-nullable.)
>

The testcase I gave above definitely produces a bogus warning before your
patch. I've not actually checked whether the patch fixes it, though.


> We *do* still see this issue for *fields* of type ’T’, but that seemed
> trickier to deal with. I might have been overthinking it, though.
>
> Jordan
>
>
> ___
> 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


[PATCH] D26231: [Sema] Allow static_cast(e) to check explicit conversions for non-reference-related types.

2016-11-02 Thread Richard Smith via cfe-commits
rsmith accepted this revision.
rsmith added inline comments.
This revision is now accepted and ready to land.



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:5946
+def err_bad_rvalue_to_rvalue_cast : Error<
+  "cannot cast from rvalue reference of type %1 to rvalue reference type %2; 
types are "
+  "not compatible">;

Delete the first "reference" here. We're never casting from a reference (there 
are no expressions of reference type).



Comment at: lib/Sema/SemaCast.cpp:1148
 
+  // FIXME C++1z doesn't allow this conversions for xvalues.
   if (!SrcExpr->isGLValue())

Actually, it does, but it's covered by p4. (p3 now only covers the special 
lvalue->xvalue case for `static_cast`, which is not permitted by p4.) It's fine 
for us to still handle this here, or to allow the p4 case to deal with it 
instead. It's probably better to keep handling it here, since we produce better 
diagnostics this way.



Comment at: lib/Sema/SemaCast.cpp:1171-1173
+msg = SrcExpr->isLValue() ? diag::err_bad_lvalue_to_rvalue_cast
+  : diag::err_bad_rvalue_to_rvalue_cast;
 return TC_Failed;

OK, so the idea here is that p4 will never apply in a case where the reference 
is reference-related to the source but not reference-compatible, and no other 
rules would let us static_cast to reference type? It would be good to add a 
comment explaining that, since it's not immediately obvious.



Comment at: test/CXX/expr/expr.post/expr.static.cast/p3-p4-0x.cpp:29
+  A &&ar6 = static_cast(xvalue());
+  A &&ar7 = static_cast(prvalue());
+

It'd be good to also have some negative tests here, for cases like 
```
A &&ar8 = static_cast(prvalue());
```


https://reviews.llvm.org/D26231



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


Re: r285856 - Don't require nullability on template parameters in typedefs.

2016-11-02 Thread Jordan Rose via cfe-commits

> On Nov 2, 2016, at 15:48, Richard Smith  wrote:
> 
> On Wed, Nov 2, 2016 at 2:34 PM, Jordan Rose via cfe-commits 
> mailto:cfe-commits@lists.llvm.org>> wrote:
> 
>> On Nov 2, 2016, at 14:31, Richard Smith > > wrote:
>> 
>> On 2 Nov 2016 1:53 pm, "Jordan Rose via cfe-commits" 
>> mailto:cfe-commits@lists.llvm.org>> wrote:
>> Author: jrose
>> Date: Wed Nov  2 15:44:07 2016
>> New Revision: 285856
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=285856&view=rev 
>> 
>> Log:
>> Don't require nullability on template parameters in typedefs.
>> 
>> Previously the following code would warn on the use of "T":
>> 
>>   template 
>>   struct X {
>> typedef T *type;
>>   };
>> 
>> ...because nullability is /allowed/ on template parameters (because
>> they could be pointers). (Actually putting nullability on this use of
>> 'T' will of course break if the argument is a non-pointer type.)
>> 
>> This doesn't make any sense to me. Why would T need to be a pointer type for 
>> a nullability qualifier to be valid on a T*?
> 
> Sorry, this is referring to the following change to the example:
> 
> template 
> struct X {
>   typedef T _Nullable *type;
> };
> 
> This is legal, but of course `X` then produces an error. So we want to 
> accept nullability in this position (in case T is implicitly required to be a 
> pointer type by the definition of X) but not warn when it’s missing (in case 
> it isn’t).
> 
> Oh, I see. Your testcase is very confusing, though, since it wraps the 
> problematic use of T in a completely-unrelated pointer type. The actual 
> problem being fixed is much more obvious in a case like this:
> 
> int *_Nullable p;
> template struct X {
>   T t; // warns without your fix
> };
> 
> It'd be easier on future readers of this code to use the more obvious test 
> case here.

Ah, that case doesn’t actually trigger the issue, because a typedef doesn’t 
require nullability on its outermost pointer type. (It’s assumed that the use 
site may need to make some uses of the typedef nullable and some non-nullable.)

We do still see this issue for fields of type ’T’, but that seemed trickier to 
deal with. I might have been overthinking it, though.

Jordan

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


Re: r285856 - Don't require nullability on template parameters in typedefs.

2016-11-02 Thread Richard Smith via cfe-commits
On Wed, Nov 2, 2016 at 2:34 PM, Jordan Rose via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

>
> On Nov 2, 2016, at 14:31, Richard Smith  wrote:
>
> On 2 Nov 2016 1:53 pm, "Jordan Rose via cfe-commits" <
> cfe-commits@lists.llvm.org> wrote:
>
> Author: jrose
> Date: Wed Nov  2 15:44:07 2016
> New Revision: 285856
>
> URL: http://llvm.org/viewvc/llvm-project?rev=285856&view=rev
> Log:
> Don't require nullability on template parameters in typedefs.
>
> Previously the following code would warn on the use of "T":
>
>   template 
>   struct X {
> typedef T *type;
>   };
>
> ...because nullability is /allowed/ on template parameters (because
> they could be pointers). (Actually putting nullability on this use of
> 'T' will of course break if the argument is a non-pointer type.)
>
>
> This doesn't make any sense to me. Why would T need to be a pointer type
> for a nullability qualifier to be valid on a T*?
>
>
> Sorry, this is referring to the following change to the example:
>
> template 
> struct X {
>   typedef T _Nullable *type;
> };
>
>
> This is legal, but of course `X` then produces an error. So we want
> to accept nullability in this position (in case T is implicitly required to
> be a pointer type by the definition of X) but not warn when it’s missing
> (in case it isn’t).
>

Oh, I see. Your testcase is very confusing, though, since it wraps the
problematic use of T in a completely-unrelated pointer type. The actual
problem being fixed is much more obvious in a case like this:

int *_Nullable p;
template struct X {
  T t; // warns without your fix
};

It'd be easier on future readers of this code to use the more obvious test
case here.

Jordan
>
>
> This fix doesn't handle the case where a template parameter is used
> /outside/ of a typedef. That seems trickier, especially in parameter
> position.
>
> Modified:
> cfe/trunk/lib/Sema/SemaType.cpp
> cfe/trunk/test/SemaObjCXX/Inputs/nullability-consistency-1.h
>
> Modified: cfe/trunk/lib/Sema/SemaType.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaT
> ype.cpp?rev=285856&r1=285855&r2=285856&view=diff
> 
> ==
> --- cfe/trunk/lib/Sema/SemaType.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaType.cpp Wed Nov  2 15:44:07 2016
> @@ -3600,7 +3600,17 @@ static TypeSourceInfo *GetFullTypeForDec
>  // inner pointers.
>  complainAboutMissingNullability = CAMN_InnerPointers;
>
> -if (T->canHaveNullability() && !T->getNullability(S.Context)) {
> +auto isDependentNonPointerType = [](QualType T) -> bool {
> +  // Note: This is intended to be the same check as
> Type::canHaveNullability
> +  // except with all of the ambiguous cases being treated as 'false'
> rather
> +  // than 'true'.
> +  return T->isDependentType() && !T->isAnyPointerType() &&
> +!T->isBlockPointerType() && !T->isMemberPointerType();
> +};
> +
> +if (T->canHaveNullability() && !T->getNullability(S.Context) &&
> +!isDependentNonPointerType(T)) {
> +  // Note that we allow but don't require nullability on dependent
> types.
>++NumPointersRemaining;
>  }
>
>
> Modified: cfe/trunk/test/SemaObjCXX/Inputs/nullability-consistency-1.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjCX
> X/Inputs/nullability-consistency-1.h?rev=285856&r1=285855&
> r2=285856&view=diff
> 
> ==
> --- cfe/trunk/test/SemaObjCXX/Inputs/nullability-consistency-1.h
> (original)
> +++ cfe/trunk/test/SemaObjCXX/Inputs/nullability-consistency-1.h Wed Nov
> 2 15:44:07 2016
> @@ -13,5 +13,13 @@ class X {
>int X:: *memptr; // expected-warning{{member pointer is missing a
> nullability type specifier}}
>  };
>
> +template 
> +struct Typedefs {
> +  typedef T *Base; // no-warning
> +  typedef Base *type; // expected-warning{{pointer is missing a
> nullability type specifier}}
> +};
> +
> +Typedefs xx;
> +Typedefs yy;
>
>
>
>
> ___
> 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
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26118: [clang-tidy] Change readability-redundant-member-init to get base type from constructor

2016-11-02 Thread Malcolm Parsons via cfe-commits
malcolm.parsons updated this revision to Diff 76797.
malcolm.parsons added a comment.

Add test.


https://reviews.llvm.org/D26118

Files:
  clang-tidy/readability/RedundantMemberInitCheck.cpp
  test/clang-tidy/readability-redundant-member-init.cpp


Index: test/clang-tidy/readability-redundant-member-init.cpp
===
--- test/clang-tidy/readability-redundant-member-init.cpp
+++ test/clang-tidy/readability-redundant-member-init.cpp
@@ -87,6 +87,24 @@
   // CHECK-FIXES: F7()  {}
 };
 
+namespace Foo {
+inline namespace Bar {
+template 
+struct Template {
+  Template() = default;
+  int i = N;
+};
+}
+}
+
+enum { N_THINGS = 5 };
+
+struct F8 : Foo::Template {
+  F8() : Template() {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: initializer for base class 
'Foo::Template' is redundant
+  // CHECK-FIXES: F8()  {}
+};
+
 // Initializer not written
 struct NF1 {
   NF1() {}
Index: clang-tidy/readability/RedundantMemberInitCheck.cpp
===
--- clang-tidy/readability/RedundantMemberInitCheck.cpp
+++ clang-tidy/readability/RedundantMemberInitCheck.cpp
@@ -54,7 +54,7 @@
 } else {
   diag(Init->getSourceLocation(),
"initializer for base class %0 is redundant")
-  << Init->getTypeSourceInfo()->getType()
+  << Construct->getType()
   << FixItHint::CreateRemoval(Init->getSourceRange());
 }
   }


Index: test/clang-tidy/readability-redundant-member-init.cpp
===
--- test/clang-tidy/readability-redundant-member-init.cpp
+++ test/clang-tidy/readability-redundant-member-init.cpp
@@ -87,6 +87,24 @@
   // CHECK-FIXES: F7()  {}
 };
 
+namespace Foo {
+inline namespace Bar {
+template 
+struct Template {
+  Template() = default;
+  int i = N;
+};
+}
+}
+
+enum { N_THINGS = 5 };
+
+struct F8 : Foo::Template {
+  F8() : Template() {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: initializer for base class 'Foo::Template' is redundant
+  // CHECK-FIXES: F8()  {}
+};
+
 // Initializer not written
 struct NF1 {
   NF1() {}
Index: clang-tidy/readability/RedundantMemberInitCheck.cpp
===
--- clang-tidy/readability/RedundantMemberInitCheck.cpp
+++ clang-tidy/readability/RedundantMemberInitCheck.cpp
@@ -54,7 +54,7 @@
 } else {
   diag(Init->getSourceLocation(),
"initializer for base class %0 is redundant")
-  << Init->getTypeSourceInfo()->getType()
+  << Construct->getType()
   << FixItHint::CreateRemoval(Init->getSourceRange());
 }
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26207: [ClangTidy - performance-unnecessary-value-param] Only add "const" when current parameter is not already const qualified

2016-11-02 Thread Felix Berger via cfe-commits
flx added inline comments.



Comment at: test/clang-tidy/performance-unnecessary-value-param.cpp:242
+// Case where parameter in declaration is already const-qualified but not in
+// implementation. Make sure a second 'const' is not added to the declaration.
+void PositiveConstDeclaration(const ExpensiveToCopyType A);

aaron.ballman wrote:
> flx wrote:
> > aaron.ballman wrote:
> > > This comment doesn't really match the test cases. The original code has 
> > > two *different* declarations (only one of which is a definition), not one 
> > > declaration and one redeclaration with the definition.
> > > 
> > > I think what is really happening is that it is adding the `&` qualifier 
> > > to the first declaration, and adding the `const` and `&` qualifiers to 
> > > the second declaration, and the result is that you get harmonization. But 
> > > it brings up a question to me; what happens with:
> > > ```
> > > void f1(ExpensiveToCopyType A) {
> > > }
> > > 
> > > void f1(const ExpensiveToCopyType A) {
> > > 
> > > }
> > > ```
> > > Does the fix-it try to create two definitions of the same function?
> > Good catch. I added the reverse case as well and modified the check 
> > slightly to make that case work as well.
> Can you add a test like this as well?
> ```
> void f1(ExpensiveToCopyType A); // Declared, not defined
> 
> void f1(const ExpensiveToCopyType A) {}
> void f1(const ExpensiveToCopyType &A) {}
> ```
> I'm trying to make sure this check does not suggest a fixit that breaks 
> existing code because of overload sets. I would expect a diagnostic for the 
> first two declarations, but no fixit suggestion for `void f1(const 
> ExpensiveToCopyType A)` because that would result in an ambiguous function 
> definition.
The current code suggests the following fixes:

-void f1(ExpensiveToCopyType A); // Declared, not defined
+void f1(const ExpensiveToCopyType& A); // Declared, not defined
 
-void f1(const ExpensiveToCopyType A) {}
+void f1(const ExpensiveToCopyType& A) {}
 void f1(const ExpensiveToCopyType &A) {}

and we get a warning message for the void f1(const ExpensiveToCopyType A) {}

I think the compiler sees "void f1(const ExpensiveToCopyType A) {}" as 
definition of "void f1(ExpensiveToCopyType A); // Declared, not defined" and 
thus both places get fixed.

Since the check is catching cases where the value argument is either modified 
or could be moved it and this is not the case here it is worth raising this 
issue of what looks like a very subtle difference in overrides.

My inclination is to leave this as is. What do you suggest we do?



Repository:
  rL LLVM

https://reviews.llvm.org/D26207



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


[PATCH] D26196: AMDGPU: Translate null pointers in private and local addr space

2016-11-02 Thread Yaxun Liu via cfe-commits
yaxunl added inline comments.



Comment at: lib/CodeGen/TargetInfo.cpp:7039
+  if (CGM.getTarget().getTriple().getArch() != llvm::Triple::amdgcn ||
+(AS != Ctx.getTargetAddressSpace(LangAS::opencl_local) && AS != 0))
+return C;

arsenm wrote:
> Shouldn't the 0 be checking lang as::opencl_private? 
clang does not define enum for opencl_private.


https://reviews.llvm.org/D26196



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


[PATCH] D26196: AMDGPU: Translate null pointers in private and local addr space

2016-11-02 Thread Yaxun Liu via cfe-commits
yaxunl updated the summary for this revision.
yaxunl updated this revision to Diff 76792.
yaxunl added a comment.

Fixed translation of a pointer to bool. Added more tests.


https://reviews.llvm.org/D26196

Files:
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/CGExprConstant.cpp
  lib/CodeGen/CGExprScalar.cpp
  lib/CodeGen/CodeGenModule.h
  lib/CodeGen/TargetInfo.cpp
  lib/CodeGen/TargetInfo.h
  test/CodeGenOpenCL/amdgpu-nullptr.cl

Index: test/CodeGenOpenCL/amdgpu-nullptr.cl
===
--- /dev/null
+++ test/CodeGenOpenCL/amdgpu-nullptr.cl
@@ -0,0 +1,325 @@
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -include opencl-c.h -triple amdgcn -emit-llvm -o - | FileCheck %s
+
+// Test 0 as initializer.
+
+// CHECK: @private_p = local_unnamed_addr addrspace(1) global i8* addrspacecast (i8 addrspace(4)* null to i8*), align 4
+private char *private_p = 0;
+
+// CHECK: @local_p = local_unnamed_addr addrspace(1) global i8 addrspace(3)* addrspacecast (i8 addrspace(4)* null to i8 addrspace(3)*), align 4
+local char *local_p = 0;
+
+// CHECK: @global_p = local_unnamed_addr addrspace(1) global i8 addrspace(1)* null, align 4
+global char *global_p = 0;
+
+// CHECK: @constant_p = local_unnamed_addr addrspace(1) global i8 addrspace(2)* null, align 4
+constant char *constant_p = 0;
+
+// CHECK: @generic_p = local_unnamed_addr addrspace(1) global i8 addrspace(4)* null, align 4
+generic char *generic_p = 0;
+
+// Test NULL as initializer.
+
+// CHECK: @private_p_NULL = local_unnamed_addr addrspace(1) global i8* addrspacecast (i8 addrspace(4)* null to i8*), align 4
+private char *private_p_NULL = NULL;
+
+// CHECK: @local_p_NULL = local_unnamed_addr addrspace(1) global i8 addrspace(3)* addrspacecast (i8 addrspace(4)* null to i8 addrspace(3)*), align 4
+local char *local_p_NULL = NULL;
+
+// CHECK: @global_p_NULL = local_unnamed_addr addrspace(1) global i8 addrspace(1)* null, align 4
+global char *global_p_NULL = NULL;
+
+// CHECK: @constant_p_NULL = local_unnamed_addr addrspace(1) global i8 addrspace(2)* null, align 4
+constant char *constant_p_NULL = NULL;
+
+// CHECK: @generic_p_NULL = local_unnamed_addr addrspace(1) global i8 addrspace(4)* null, align 4
+generic char *generic_p_NULL = NULL;
+
+// Test comparison with 0.
+
+// CHECK-LABEL: cmp_private
+// CHECK: icmp eq i8* %p, addrspacecast (i8 addrspace(4)* null to i8*)
+void cmp_private(private char* p) {
+  if (p != 0)
+*p = 0;
+}
+
+// CHECK-LABEL: cmp_local
+// CHECK: icmp eq i8 addrspace(3)* %p, addrspacecast (i8 addrspace(4)* null to i8 addrspace(3)*)
+void cmp_local(local char* p) {
+  if (p != 0)
+*p = 0;
+}
+
+// CHECK-LABEL: cmp_global
+// CHECK: icmp eq i8 addrspace(1)* %p, null
+void cmp_global(global char* p) {
+  if (p != 0)
+*p = 0;
+}
+
+// CHECK-LABEL: cmp_constant
+// CHECK: icmp eq i8 addrspace(2)* %p, null
+char cmp_constant(constant char* p) {
+  if (p != 0)
+return *p;
+  else
+return 0;
+}
+
+// CHECK-LABEL: cmp_generic
+// CHECK: icmp eq i8 addrspace(4)* %p, null
+void cmp_generic(generic char* p) {
+  if (p != 0)
+*p = 0;
+}
+
+// Test comparison with NULL.
+
+// CHECK-LABEL: cmp_NULL_private
+// CHECK: icmp eq i8* %p, addrspacecast (i8 addrspace(4)* null to i8*)
+void cmp_NULL_private(private char* p) {
+  if (p != NULL)
+*p = 0;
+}
+
+// CHECK-LABEL: cmp_NULL_local
+// CHECK: icmp eq i8 addrspace(3)* %p, addrspacecast (i8 addrspace(4)* null to i8 addrspace(3)*)
+void cmp_NULL_local(local char* p) {
+  if (p != NULL)
+*p = 0;
+}
+
+// CHECK-LABEL: cmp_NULL_global
+// CHECK: icmp eq i8 addrspace(1)* %p, addrspacecast (i8 addrspace(4)* null to i8 addrspace(1)*)
+void cmp_NULL_global(global char* p) {
+  if (p != NULL)
+*p = 0;
+}
+
+// CHECK-LABEL: cmp_NULL_constant
+// CHECK: icmp eq i8 addrspace(2)* %p, addrspacecast (i8 addrspace(4)* null to i8 addrspace(2)*)
+char cmp_NULL_constant(constant char* p) {
+  if (p != NULL)
+return *p;
+  else
+return 0;
+}
+
+// CHECK-LABEL: cmp_NULL_generic
+// CHECK: icmp eq i8 addrspace(4)* %p, null
+void cmp_NULL_generic(generic char* p) {
+  if (p != NULL)
+*p = 0;
+}
+
+// Test storage 0 as null pointer.
+// CHECK-LABEL: test_storage_null_pointer
+// CHECK: store i8* addrspacecast (i8 addrspace(4)* null to i8*), i8* addrspace(4)* %arg_private
+// CHECK: store i8 addrspace(3)* addrspacecast (i8 addrspace(4)* null to i8 addrspace(3)*), i8 addrspace(3)* addrspace(4)* %arg_local
+// CHECK: store i8 addrspace(1)* null, i8 addrspace(1)* addrspace(4)* %arg_global
+// CHECK: store i8 addrspace(2)* null, i8 addrspace(2)* addrspace(4)* %arg_constant
+// CHECK: store i8 addrspace(4)* null, i8 addrspace(4)* addrspace(4)* %arg_generic
+void test_storage_null_pointer(private char** arg_private,
+   local char** arg_local,
+   global char** arg_global,
+   constant char** arg_constant,
+   generic char** arg_generic) {
+   *arg_

[PATCH] D26218: [clang-tidy] Ignore notes along with a warning when processing NOLINT

2016-11-02 Thread Malcolm Parsons via cfe-commits
malcolm.parsons closed this revision.
malcolm.parsons added a comment.

Committed as r285861.
Thanks!


https://reviews.llvm.org/D26218



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


Re: r285856 - Don't require nullability on template parameters in typedefs.

2016-11-02 Thread Jordan Rose via cfe-commits

> On Nov 2, 2016, at 14:31, Richard Smith  wrote:
> 
> On 2 Nov 2016 1:53 pm, "Jordan Rose via cfe-commits" 
> mailto:cfe-commits@lists.llvm.org>> wrote:
> Author: jrose
> Date: Wed Nov  2 15:44:07 2016
> New Revision: 285856
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=285856&view=rev 
> 
> Log:
> Don't require nullability on template parameters in typedefs.
> 
> Previously the following code would warn on the use of "T":
> 
>   template 
>   struct X {
> typedef T *type;
>   };
> 
> ...because nullability is /allowed/ on template parameters (because
> they could be pointers). (Actually putting nullability on this use of
> 'T' will of course break if the argument is a non-pointer type.)
> 
> This doesn't make any sense to me. Why would T need to be a pointer type for 
> a nullability qualifier to be valid on a T*?

Sorry, this is referring to the following change to the example:

template 
struct X {
  typedef T _Nullable *type;
};

This is legal, but of course `X` then produces an error. So we want to 
accept nullability in this position (in case T is implicitly required to be a 
pointer type by the definition of X) but not warn when it’s missing (in case it 
isn’t).

Jordan

> 
> This fix doesn't handle the case where a template parameter is used
> /outside/ of a typedef. That seems trickier, especially in parameter
> position.
> 
> Modified:
> cfe/trunk/lib/Sema/SemaType.cpp
> cfe/trunk/test/SemaObjCXX/Inputs/nullability-consistency-1.h
> 
> Modified: cfe/trunk/lib/Sema/SemaType.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=285856&r1=285855&r2=285856&view=diff
>  
> 
> ==
> --- cfe/trunk/lib/Sema/SemaType.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaType.cpp Wed Nov  2 15:44:07 2016
> @@ -3600,7 +3600,17 @@ static TypeSourceInfo *GetFullTypeForDec
>  // inner pointers.
>  complainAboutMissingNullability = CAMN_InnerPointers;
> 
> -if (T->canHaveNullability() && !T->getNullability(S.Context)) {
> +auto isDependentNonPointerType = [](QualType T) -> bool {
> +  // Note: This is intended to be the same check as 
> Type::canHaveNullability
> +  // except with all of the ambiguous cases being treated as 'false' 
> rather
> +  // than 'true'.
> +  return T->isDependentType() && !T->isAnyPointerType() &&
> +!T->isBlockPointerType() && !T->isMemberPointerType();
> +};
> +
> +if (T->canHaveNullability() && !T->getNullability(S.Context) &&
> +!isDependentNonPointerType(T)) {
> +  // Note that we allow but don't require nullability on dependent types.
>++NumPointersRemaining;
>  }
> 
> 
> Modified: cfe/trunk/test/SemaObjCXX/Inputs/nullability-consistency-1.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjCXX/Inputs/nullability-consistency-1.h?rev=285856&r1=285855&r2=285856&view=diff
>  
> 
> ==
> --- cfe/trunk/test/SemaObjCXX/Inputs/nullability-consistency-1.h (original)
> +++ cfe/trunk/test/SemaObjCXX/Inputs/nullability-consistency-1.h Wed Nov  2 
> 15:44:07 2016
> @@ -13,5 +13,13 @@ class X {
>int X:: *memptr; // expected-warning{{member pointer is missing a 
> nullability type specifier}}
>  };
> 
> +template 
> +struct Typedefs {
> +  typedef T *Base; // no-warning
> +  typedef Base *type; // expected-warning{{pointer is missing a nullability 
> type specifier}}
> +};
> +
> +Typedefs xx;
> +Typedefs yy;
> 
> 
> 
> 
> ___
> 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: r285856 - Don't require nullability on template parameters in typedefs.

2016-11-02 Thread Richard Smith via cfe-commits
On 2 Nov 2016 1:53 pm, "Jordan Rose via cfe-commits" <
cfe-commits@lists.llvm.org> wrote:

Author: jrose
Date: Wed Nov  2 15:44:07 2016
New Revision: 285856

URL: http://llvm.org/viewvc/llvm-project?rev=285856&view=rev
Log:
Don't require nullability on template parameters in typedefs.

Previously the following code would warn on the use of "T":

  template 
  struct X {
typedef T *type;
  };

...because nullability is /allowed/ on template parameters (because
they could be pointers). (Actually putting nullability on this use of
'T' will of course break if the argument is a non-pointer type.)


This doesn't make any sense to me. Why would T need to be a pointer type
for a nullability qualifier to be valid on a T*?

This fix doesn't handle the case where a template parameter is used
/outside/ of a typedef. That seems trickier, especially in parameter
position.

Modified:
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/test/SemaObjCXX/Inputs/nullability-consistency-1.h

Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/
SemaType.cpp?rev=285856&r1=285855&r2=285856&view=diff

==
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Wed Nov  2 15:44:07 2016
@@ -3600,7 +3600,17 @@ static TypeSourceInfo *GetFullTypeForDec
 // inner pointers.
 complainAboutMissingNullability = CAMN_InnerPointers;

-if (T->canHaveNullability() && !T->getNullability(S.Context)) {
+auto isDependentNonPointerType = [](QualType T) -> bool {
+  // Note: This is intended to be the same check as
Type::canHaveNullability
+  // except with all of the ambiguous cases being treated as 'false'
rather
+  // than 'true'.
+  return T->isDependentType() && !T->isAnyPointerType() &&
+!T->isBlockPointerType() && !T->isMemberPointerType();
+};
+
+if (T->canHaveNullability() && !T->getNullability(S.Context) &&
+!isDependentNonPointerType(T)) {
+  // Note that we allow but don't require nullability on dependent
types.
   ++NumPointersRemaining;
 }


Modified: cfe/trunk/test/SemaObjCXX/Inputs/nullability-consistency-1.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/
SemaObjCXX/Inputs/nullability-consistency-1.h?rev=285856&r1=
285855&r2=285856&view=diff

==
--- cfe/trunk/test/SemaObjCXX/Inputs/nullability-consistency-1.h (original)
+++ cfe/trunk/test/SemaObjCXX/Inputs/nullability-consistency-1.h Wed Nov  2
15:44:07 2016
@@ -13,5 +13,13 @@ class X {
   int X:: *memptr; // expected-warning{{member pointer is missing a
nullability type specifier}}
 };

+template 
+struct Typedefs {
+  typedef T *Base; // no-warning
+  typedef Base *type; // expected-warning{{pointer is missing a
nullability type specifier}}
+};
+
+Typedefs xx;
+Typedefs yy;




___
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


[clang-tools-extra] r285861 - [clang-tidy] Suppress notes for warnings that were ignored

2016-11-02 Thread Malcolm Parsons via cfe-commits
Author: malcolm.parsons
Date: Wed Nov  2 16:14:22 2016
New Revision: 285861

URL: http://llvm.org/viewvc/llvm-project?rev=285861&view=rev
Log:
[clang-tidy] Suppress notes for warnings that were ignored

Fixes PR30565.

Patch by Nikita Kakuev

Added:
clang-tools-extra/trunk/test/clang-tidy/Inputs/nolint/
clang-tools-extra/trunk/test/clang-tidy/Inputs/nolint/trigger_warning.h
Modified:
clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp
clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h
clang-tools-extra/trunk/test/clang-tidy/nolint.cpp

Modified: clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp?rev=285861&r1=285860&r2=285861&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp Wed Nov  
2 16:14:22 2016
@@ -250,7 +250,7 @@ StringRef ClangTidyContext::getCheckName
 
 ClangTidyDiagnosticConsumer::ClangTidyDiagnosticConsumer(ClangTidyContext &Ctx)
 : Context(Ctx), LastErrorRelatesToUserCode(false),
-  LastErrorPassesLineFilter(false) {
+  LastErrorPassesLineFilter(false), LastErrorWasIgnored(false) {
   IntrusiveRefCntPtr DiagOpts = new DiagnosticOptions();
   Diags.reset(new DiagnosticsEngine(
   IntrusiveRefCntPtr(new DiagnosticIDs), &*DiagOpts, this,
@@ -309,13 +309,20 @@ static bool LineIsMarkedWithNOLINTinMacr
 
 void ClangTidyDiagnosticConsumer::HandleDiagnostic(
 DiagnosticsEngine::Level DiagLevel, const Diagnostic &Info) {
+  if (LastErrorWasIgnored && DiagLevel == DiagnosticsEngine::Note)
+return;
+
   if (Info.getLocation().isValid() &&
   DiagLevel != DiagnosticsEngine::Error &&
   DiagLevel != DiagnosticsEngine::Fatal &&
   LineIsMarkedWithNOLINTinMacro(Diags->getSourceManager(), 
Info.getLocation())) {
 ++Context.Stats.ErrorsIgnoredNOLINT;
+// Ignored a warning, should ignore related notes as well
+LastErrorWasIgnored = true;
 return;
   }
+
+  LastErrorWasIgnored = false;
   // Count warnings/errors.
   DiagnosticConsumer::HandleDiagnostic(DiagLevel, Info);
 

Modified: clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h?rev=285861&r1=285860&r2=285861&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h (original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h Wed Nov  2 
16:14:22 2016
@@ -286,6 +286,7 @@ private:
   std::unique_ptr HeaderFilter;
   bool LastErrorRelatesToUserCode;
   bool LastErrorPassesLineFilter;
+  bool LastErrorWasIgnored;
 };
 
 } // end namespace tidy

Added: clang-tools-extra/trunk/test/clang-tidy/Inputs/nolint/trigger_warning.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/Inputs/nolint/trigger_warning.h?rev=285861&view=auto
==
--- clang-tools-extra/trunk/test/clang-tidy/Inputs/nolint/trigger_warning.h 
(added)
+++ clang-tools-extra/trunk/test/clang-tidy/Inputs/nolint/trigger_warning.h Wed 
Nov  2 16:14:22 2016
@@ -0,0 +1,5 @@
+void A1(const int &In, int &Out) {
+  if (In > 123) // NOLINT
+Out = 123;
+}
+

Modified: clang-tools-extra/trunk/test/clang-tidy/nolint.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/nolint.cpp?rev=285861&r1=285860&r2=285861&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/nolint.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/nolint.cpp Wed Nov  2 16:14:22 2016
@@ -1,4 +1,5 @@
-// RUN: %check_clang_tidy %s 
google-explicit-constructor,clang-diagnostic-unused-variable %t -- 
-extra-arg=-Wunused-variable --
+// RUN: %check_clang_tidy %s 
google-explicit-constructor,clang-diagnostic-unused-variable,clang-analyzer-core.UndefinedBinaryOperatorResult
 %t -- -extra-arg=-Wunused-variable -- -I%S/Inputs/nolint
+
 
 class A { A(int i); };
 // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: single-argument constructors must 
be marked explicit
@@ -27,4 +28,12 @@ MACRO_NOLINT
 #define DOUBLE_MACRO MACRO(H) // NOLINT
 DOUBLE_MACRO
 
-// CHECK-MESSAGES: Suppressed 7 warnings (7 NOLINT)
+#include "trigger_warning.h"
+void I(int& Out) {
+  int In;
+  A1(In, Out);
+}
+// CHECK-NOT: trigger_warning.h:{{.*}} warning: The left operand of '>' is a 
garbage value
+// CHECK-NOT: :[[@LINE-4]]:{{.*}} note
+
+// CHECK-MESSAGES: Suppressed 8 warnings (8 NOLINT)


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.or

[PATCH] D26226: Don't require nullability on template parameters in typedefs.

2016-11-02 Thread Jordan Rose via cfe-commits
jordan_rose closed this revision.
jordan_rose added a comment.

Committed in r285856.


Repository:
  rL LLVM

https://reviews.llvm.org/D26226



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


r285856 - Don't require nullability on template parameters in typedefs.

2016-11-02 Thread Jordan Rose via cfe-commits
Author: jrose
Date: Wed Nov  2 15:44:07 2016
New Revision: 285856

URL: http://llvm.org/viewvc/llvm-project?rev=285856&view=rev
Log:
Don't require nullability on template parameters in typedefs.

Previously the following code would warn on the use of "T":

  template 
  struct X {
typedef T *type;
  };

...because nullability is /allowed/ on template parameters (because
they could be pointers). (Actually putting nullability on this use of
'T' will of course break if the argument is a non-pointer type.)

This fix doesn't handle the case where a template parameter is used
/outside/ of a typedef. That seems trickier, especially in parameter
position.

Modified:
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/test/SemaObjCXX/Inputs/nullability-consistency-1.h

Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=285856&r1=285855&r2=285856&view=diff
==
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Wed Nov  2 15:44:07 2016
@@ -3600,7 +3600,17 @@ static TypeSourceInfo *GetFullTypeForDec
 // inner pointers.
 complainAboutMissingNullability = CAMN_InnerPointers;
 
-if (T->canHaveNullability() && !T->getNullability(S.Context)) {
+auto isDependentNonPointerType = [](QualType T) -> bool {
+  // Note: This is intended to be the same check as 
Type::canHaveNullability
+  // except with all of the ambiguous cases being treated as 'false' rather
+  // than 'true'.
+  return T->isDependentType() && !T->isAnyPointerType() &&
+!T->isBlockPointerType() && !T->isMemberPointerType();
+};
+
+if (T->canHaveNullability() && !T->getNullability(S.Context) &&
+!isDependentNonPointerType(T)) {
+  // Note that we allow but don't require nullability on dependent types.
   ++NumPointersRemaining;
 }
 

Modified: cfe/trunk/test/SemaObjCXX/Inputs/nullability-consistency-1.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjCXX/Inputs/nullability-consistency-1.h?rev=285856&r1=285855&r2=285856&view=diff
==
--- cfe/trunk/test/SemaObjCXX/Inputs/nullability-consistency-1.h (original)
+++ cfe/trunk/test/SemaObjCXX/Inputs/nullability-consistency-1.h Wed Nov  2 
15:44:07 2016
@@ -13,5 +13,13 @@ class X {
   int X:: *memptr; // expected-warning{{member pointer is missing a 
nullability type specifier}}
 };
 
+template 
+struct Typedefs {
+  typedef T *Base; // no-warning
+  typedef Base *type; // expected-warning{{pointer is missing a nullability 
type specifier}}
+};
+
+Typedefs xx;
+Typedefs yy;
 
 


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


[PATCH] D24991: Inline hot functions in libcxx shared_ptr implementation.

2016-11-02 Thread Kuba Brecka via cfe-commits
kubabrecka added a comment.

In https://reviews.llvm.org/D24991#586219, @sebpop wrote:

> I just ran ninja check-all with and without this patch and there are no 
> regressions in compiler-rt on an x86_64-linux machine.


The TSan interceptors (and testcases) are Darwin-only at this point.  I'll run 
the tests on my machine.


https://reviews.llvm.org/D24991



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


[PATCH] D26231: [Sema] Allow static_cast(e) to check explicit conversions for non-reference-related types.

2016-11-02 Thread Eric Fiselier via cfe-commits
EricWF updated this revision to Diff 76775.
EricWF added a comment.

- Add tests under `test/CXX`
- Add FIXME regarding the C++1z change from glvalue to lvalue in p3.


https://reviews.llvm.org/D26231

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaCast.cpp
  test/CXX/expr/expr.post/expr.static.cast/p3-p4-0x.cpp
  test/SemaCXX/rval-references.cpp

Index: test/SemaCXX/rval-references.cpp
===
--- test/SemaCXX/rval-references.cpp
+++ test/SemaCXX/rval-references.cpp
@@ -30,11 +30,15 @@
   int &&virr2 = 0;
   int &&virr3 = virr2; // expected-error {{rvalue reference to type 'int' cannot bind to lvalue of type 'int'}}
   int i1 = 0;
+  const double d1 = 0;
+  const int ci1 = 1;
   int &&virr4 = i1; // expected-error {{rvalue reference to type 'int' cannot bind to lvalue of type 'int'}}
   int &&virr5 = ret_irr();
   int &&virr6 = static_cast(i1);
-  (void)static_cast(i1); // expected-error {{types are not compatible}}
-
+  (void)static_cast(i1); // expected-error {{reference to type 'not_int' could not bind to an lvalue of type 'int'}}
+  (void)static_cast(static_cast(i1)); // expected-error {{cannot cast from rvalue reference of type 'const int' to rvalue reference type 'int &&'}}
+  (void)static_cast(ci1);// expected-error {{types are not compatible}}
+  (void)static_cast(d1);
   int i2 = over(i1);
   not_int ni1 = over(0);
   int i3 = over(virr2);
Index: test/CXX/expr/expr.post/expr.static.cast/p3-p4-0x.cpp
===
--- /dev/null
+++ test/CXX/expr/expr.post/expr.static.cast/p3-p4-0x.cpp
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+// expected-no-diagnostics
+
+// p3
+// A glvalue of type "cv1 T1" can be cast to type "rvalue reference to
+// cv2 T2" if "cv2 T2" is reference-compatible with "cv1 T1" (8.5.3).
+// p4
+// Otherwise, an expression e can be explicitly converted to a type T using a
+// static_cast of the form static_cast(e) if the declaration T t(e); is
+// well-formed, for some invented temporary variable t (8.5). [...]
+struct A { };
+struct B : A { };
+
+struct C { explicit operator A&&(); };
+struct D { operator B(); };
+
+template T& lvalue();
+template T&& xvalue();
+template  T prvalue();
+
+void test(A &a, B &b) {
+  A &&ar0 = static_cast(prvalue());
+  A &&ar1 = static_cast(prvalue());
+  A &&ar2 = static_cast(lvalue());
+  A &&ar3 = static_cast(xvalue());
+  A &&ar4 = static_cast(prvalue());
+  A &&ar5 = static_cast(lvalue());
+  A &&ar6 = static_cast(xvalue());
+  A &&ar7 = static_cast(prvalue());
+
+  const A &&ar8 = static_cast(prvalue());
+  const A &&ar9 = static_cast(prvalue());
+  const A &&ar10 = static_cast(lvalue());
+  const A &&ar11 = static_cast(xvalue());
+  const A &&ar12 = static_cast(prvalue());
+  const A &&ar13 = static_cast(lvalue());
+}
Index: lib/Sema/SemaCast.cpp
===
--- lib/Sema/SemaCast.cpp
+++ lib/Sema/SemaCast.cpp
@@ -1134,17 +1134,18 @@
 }
 
 /// Tests whether a conversion according to N2844 is valid.
-TryCastResult
-TryLValueToRValueCast(Sema &Self, Expr *SrcExpr, QualType DestType,
-  bool CStyle, CastKind &Kind, CXXCastPath &BasePath, 
+TryCastResult TryLValueToRValueCast(Sema &Self, Expr *SrcExpr,
+QualType DestType, bool CStyle,
+CastKind &Kind, CXXCastPath &BasePath,
 unsigned &msg) {
   // C++11 [expr.static.cast]p3:
   //   A glvalue of type "cv1 T1" can be cast to type "rvalue reference to
   //   cv2 T2" if "cv2 T2" is reference-compatible with "cv1 T1".
   const RValueReferenceType *R = DestType->getAs();
   if (!R)
 return TC_NotApplicable;
 
+  // FIXME C++1z doesn't allow this conversions for xvalues.
   if (!SrcExpr->isGLValue())
 return TC_NotApplicable;
 
@@ -1161,14 +1162,14 @@
 ToType = ToType.getUnqualifiedType();
   }
 
-  if (Self.CompareReferenceRelationship(SrcExpr->getLocStart(),
-ToType, FromType,
-DerivedToBase, ObjCConversion,
-ObjCLifetimeConversion) 
-!= Sema::Ref_Compatible) {
-if (CStyle)
+  Sema::ReferenceCompareResult RefResult = Self.CompareReferenceRelationship(
+  SrcExpr->getLocStart(), ToType, FromType, DerivedToBase, ObjCConversion,
+  ObjCLifetimeConversion);
+  if (RefResult != Sema::Ref_Compatible) {
+if (CStyle || RefResult == Sema::Ref_Incompatible)
   return TC_NotApplicable;
-msg = diag::err_bad_lvalue_to_rvalue_cast;
+msg = SrcExpr->isLValue() ? diag::err_bad_lvalue_to_rvalue_cast
+  : diag::err_bad_rvalue_to_rvalue_cast;
 return TC_Failed;
   }
 
Index: include/clang/Basic/DiagnosticSemaKinds.td
==

[PATCH] D26082: Support for Python 3 in libclang python bindings

2016-11-02 Thread Jonathan B Coe via cfe-commits
jbcoe added inline comments.



Comment at: bindings/python/clang/cindex.py:77
+# Python 3 strings are unicode, translate them to/from utf8 for C-interop
+if type(u"") == str:
+class c_string_p(c_char_p):

mgorny wrote:
> What is the Python3 version you're aiming to support? If I recall correctly, 
> `u""` is allowed (again) since 3.4. And even then, the condition looks weird 
> and makes me think a while before I figure out what it's supposed to mean.
Replaced with a simple version check



Comment at: bindings/python/clang/cindex.py:518
 
-for i in xrange(0, count):
+for i in range(0, count):
 token = Token()

mgorny wrote:
> compnerd wrote:
> > IIRC, `range` and `xrange` did have some performance difference.  This 
> > would slow down the bindings on python 2.  The difference is obviously not 
> > immediately visible unless count is very high.  I wonder if we can do 
> > anything here to detect the python version and dispatch to `xrange` in 
> > python 2.
> The difference is that `range()` used to construct a complete list in Python 
> 2. In Python 3, `xrange()` (that uses iterator) got renamed to `range()`.
> 
> If you want to avoid performance impact (not sure if it's really measurable 
> here), you can do something alike C for loop:
> 
> i = 0
> while i < count:
> #...
> i += 1
> 
> It's not really idiomatic Python though. OTOH, it won't take more lines than 
> the conditional.
I've defined `xrange` to be `range` for python3. A bit confusing but then we 
can use `xrange` uniformly.



Comment at: bindings/python/clang/cindex.py:623
 """Return all CursorKind enumeration instances."""
-return filter(None, CursorKind._kinds)
+return [x for x in CursorKind._kinds if x]
 

mgorny wrote:
> Why are you changing this? The old version seems to be correct for Python3.
`filter` has changed in Python 3 and the replaced code does not behave the same 
as this simple list comprehension. I've not delved deeper into why but see test 
failures without this change.



Comment at: bindings/python/clang/cindex.py:2573
 if len(args) > 0:
-args_array = (c_char_p * len(args))(* args)
+args_array = (c_string_p * len(args))()
+for i,a in enumerate(args):

mgorny wrote:
> I may be wrong but I think you could use a list comprehension here.
> 
> args_array = (c_string_p * len(args))([c_string_p(x) for x in args])
> 
> You can also try without `[]` to avoid the overhead of constructing list, if 
> the function can take an iterator.
I can't get this to work with a comprension or generator, I agree either would 
be an improvement.



Comment at: bindings/python/tests/cindex/test_translation_unit.py:62
 def test_unsaved_files_2():
-import StringIO
+try:
+from StringIO import StringIO

mgorny wrote:
> Could you try inverting this? Python 2.7 already has `io.StringIO`, so that 
> branch is much more likely to work.
Python 2.7's `io.StringIO` needs a unicode string.


https://reviews.llvm.org/D26082



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


[PATCH] D26082: Support for Python 3 in libclang python bindings

2016-11-02 Thread Jonathan B Coe via cfe-commits
jbcoe updated this revision to Diff 76774.
jbcoe marked an inline comment as done.
jbcoe added a comment.

Respond to review comments.


https://reviews.llvm.org/D26082

Files:
  bindings/python/clang/cindex.py
  bindings/python/tests/cindex/test_translation_unit.py

Index: bindings/python/tests/cindex/test_translation_unit.py
===
--- bindings/python/tests/cindex/test_translation_unit.py
+++ bindings/python/tests/cindex/test_translation_unit.py
@@ -59,9 +59,13 @@
 assert spellings[-1] == 'y'
 
 def test_unsaved_files_2():
-import StringIO
+try:
+from StringIO import StringIO
+except:
+from io import StringIO
+
 tu = TranslationUnit.from_source('fake.c', unsaved_files = [
-('fake.c', StringIO.StringIO('int x;'))])
+('fake.c', StringIO('int x;'))])
 spellings = [c.spelling for c in tu.cursor.get_children()]
 assert spellings[-1] == 'x'
 
Index: bindings/python/clang/cindex.py
===
--- bindings/python/clang/cindex.py
+++ bindings/python/clang/cindex.py
@@ -64,6 +64,7 @@
 
 from ctypes import *
 import collections
+import sys
 
 import clang.enumerations
 
@@ -73,6 +74,33 @@
 # this by marshalling object arguments as void**.
 c_object_p = POINTER(c_void_p)
 
+if sys.version_info[0] > 2:
+# Python 3 strings are unicode, translate them to/from utf8 for C-interop
+# Python 3 replaces xrange with range, we want xrange behaviour
+xrange = range
+
+class c_string_p(c_char_p):
+def __init__(self, p=None):
+if type(p) == str:
+p = p.encode("utf8")
+super(c_char_p, self).__init__(p)
+
+def __str__(self):
+return str(self.value)
+
+@property
+def value(self):
+if super(c_char_p, self).value is None:
+return None
+return super(c_char_p, self).value.decode("utf8")
+
+@classmethod
+def from_param(cls, param):
+return cls(param)
+else:
+c_string_p = c_char_p
+
+
 callbacks = {}
 
 ### Exception Classes ###
@@ -147,7 +175,7 @@
 class _CXString(Structure):
 """Helper for transforming CXString results."""
 
-_fields_ = [("spelling", c_char_p), ("free", c_int)]
+_fields_ = [("spelling", c_string_p), ("free", c_int)]
 
 def __del__(self):
 conf.lib.clang_disposeString(self)
@@ -329,7 +357,7 @@
 
 @property
 def spelling(self):
-return conf.lib.clang_getDiagnosticSpelling(self)
+return str(conf.lib.clang_getDiagnosticSpelling(self))
 
 @property
 def ranges(self):
@@ -358,8 +386,8 @@
 
 def __getitem__(self, key):
 range = SourceRange()
-value = conf.lib.clang_getDiagnosticFixIt(self.diag, key,
-byref(range))
+value = str(conf.lib.clang_getDiagnosticFixIt(self.diag, key,
+byref(range)))
 if len(value) == 0:
 raise IndexError
 
@@ -392,20 +420,20 @@
 @property
 def category_name(self):
 """The string name of the category for this diagnostic."""
-return conf.lib.clang_getDiagnosticCategoryText(self)
+return str(conf.lib.clang_getDiagnosticCategoryText(self))
 
 @property
 def option(self):
 """The command-line option that enables this diagnostic."""
-return conf.lib.clang_getDiagnosticOption(self, None)
+return str(conf.lib.clang_getDiagnosticOption(self, None))
 
 @property
 def disable_option(self):
 """The command-line option that disables this diagnostic."""
 disable = _CXString()
 conf.lib.clang_getDiagnosticOption(self, byref(disable))
 
-return conf.lib.clang_getCString(disable)
+return str(conf.lib.clang_getCString(disable))
 
 def format(self, options=None):
 """
@@ -554,8 +582,8 @@
 if value >= len(self.__class__._kinds):
 self.__class__._kinds += [None] * (value - len(self.__class__._kinds) + 1)
 if self.__class__._kinds[value] is not None:
-raise ValueError,'{0} value {1} already loaded'.format(
-str(self.__class__), value)
+raise ValueError('{0} value {1} already loaded'.format(
+str(self.__class__), value))
 self.value = value
 self.__class__._kinds[value] = self
 self.__class__._name_map = None
@@ -572,12 +600,12 @@
 for key, value in self.__class__.__dict__.items():
 if isinstance(value, self.__class__):
 self._name_map[value] = key
-return self._name_map[self]
+return str(self._name_map[self])
 
 @classmethod
 def from_id(cls, id):
 if id >= len(cls._kinds) or cls._kinds[id] is None:
-raise ValueError,'Unknown template argument kind %d' % id
+  

[PATCH] D25760: [AVX512][Clang] Adding missing instructions' variations

2016-11-02 Thread coby via cfe-commits
coby abandoned this revision.
coby added a comment.

Amending vpmultishiftqb is currently being maintained at the following patches:
https://reviews.llvm.org/D26258
https://reviews.llvm.org/D26257
All other changes are discarded


Repository:
  rL LLVM

https://reviews.llvm.org/D25760



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


[PATCH] D24991: Inline hot functions in libcxx shared_ptr implementation.

2016-11-02 Thread Sebastian Pop via cfe-commits
sebpop added a comment.

In https://reviews.llvm.org/D24991#583877, @kubabrecka wrote:

> Just a question:  TSan intercepts on the dylib functions, namely 
> `__release_shared`, to track the atomic accesses.  Can you make sure this 
> doesn't break?  There's a few testcases for this in compiler-rt.


I just ran ninja check-all with and without this patch and there are no 
regressions in compiler-rt on an x86_64-linux machine.


https://reviews.llvm.org/D24991



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


[PATCH] D26218: [clang-tidy] Ignore notes along with a warning when processing NOLINT

2016-11-02 Thread Nikita Kakuev via cfe-commits
nkakuev added a comment.

@malcolm.parsons, can you please commit this patch? I don't have commit rights.


https://reviews.llvm.org/D26218



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


[PATCH] D26258: [AVX512][llvm] Amending vpmultishiftqb

2016-11-02 Thread coby via cfe-commits
coby created this revision.
coby added reviewers: craig.topper, m_zuckerman, igorb, delena, AsafBadouh.
coby added a subscriber: cfe-commits.
coby set the repository for this revision to rL LLVM.

The 'vpmultishiftqb' instruction was implemented falsely, this patch amend it.
This is the clang part, llvm side is accessible here:
https://reviews.llvm.org/D26257


Repository:
  rL LLVM

https://reviews.llvm.org/D26258

Files:
  include/clang/Basic/BuiltinsX86.def
  lib/Headers/avx512vbmiintrin.h
  lib/Headers/avx512vbmivlintrin.h

Index: lib/Headers/avx512vbmiintrin.h
===
--- lib/Headers/avx512vbmiintrin.h
+++ lib/Headers/avx512vbmiintrin.h
@@ -107,27 +107,27 @@
 static __inline__ __m512i __DEFAULT_FN_ATTRS
 _mm512_mask_multishift_epi64_epi8 (__m512i __W, __mmask64 __M, __m512i __X, __m512i __Y)
 {
-  return (__m512i) __builtin_ia32_vpmultishiftqb512_mask ((__v64qi) __X,
-(__v64qi) __Y,
-(__v64qi) __W,
+  return (__m512i) __builtin_ia32_vpmultishiftqb512_mask ((__v8di) __X,
+(__v8di) __Y,
+(__v8di) __W,
 (__mmask64) __M);
 }
 
 static __inline__ __m512i __DEFAULT_FN_ATTRS
 _mm512_maskz_multishift_epi64_epi8 (__mmask64 __M, __m512i __X, __m512i __Y)
 {
-  return (__m512i) __builtin_ia32_vpmultishiftqb512_mask ((__v64qi) __X,
-(__v64qi) __Y,
-(__v64qi) _mm512_setzero_si512 (),
+  return (__m512i) __builtin_ia32_vpmultishiftqb512_mask ((__v8di) __X,
+(__v8di) __Y,
+(__v8di) _mm512_setzero_si512 (),
 (__mmask64) __M);
 }
 
 static __inline__ __m512i __DEFAULT_FN_ATTRS
 _mm512_multishift_epi64_epi8 (__m512i __X, __m512i __Y)
 {
-  return (__m512i) __builtin_ia32_vpmultishiftqb512_mask ((__v64qi) __X,
-(__v64qi) __Y,
-(__v64qi) _mm512_undefined_epi32 (),
+  return (__m512i) __builtin_ia32_vpmultishiftqb512_mask ((__v8di) __X,
+(__v8di) __Y,
+(__v8di) _mm512_undefined_epi32 (),
 (__mmask64) -1);
 }
 
Index: lib/Headers/avx512vbmivlintrin.h
===
--- lib/Headers/avx512vbmivlintrin.h
+++ lib/Headers/avx512vbmivlintrin.h
@@ -186,57 +186,57 @@
 static __inline__ __m128i __DEFAULT_FN_ATTRS
 _mm_mask_multishift_epi64_epi8 (__m128i __W, __mmask16 __M, __m128i __X, __m128i __Y)
 {
-  return (__m128i) __builtin_ia32_vpmultishiftqb128_mask ((__v16qi) __X,
-(__v16qi) __Y,
-(__v16qi) __W,
+  return (__m128i) __builtin_ia32_vpmultishiftqb128_mask ((__v2di) __X,
+(__v2di) __Y,
+(__v2di) __W,
 (__mmask16) __M);
 }
 
 static __inline__ __m128i __DEFAULT_FN_ATTRS
 _mm_maskz_multishift_epi64_epi8 (__mmask16 __M, __m128i __X, __m128i __Y)
 {
-  return (__m128i) __builtin_ia32_vpmultishiftqb128_mask ((__v16qi) __X,
-(__v16qi) __Y,
-(__v16qi)
+  return (__m128i) __builtin_ia32_vpmultishiftqb128_mask ((__v2di) __X,
+(__v2di) __Y,
+(__v2di)
 _mm_setzero_si128 (),
 (__mmask16) __M);
 }
 
 static __inline__ __m128i __DEFAULT_FN_ATTRS
 _mm_multishift_epi64_epi8 (__m128i __X, __m128i __Y)
 {
-  return (__m128i) __builtin_ia32_vpmultishiftqb128_mask ((__v16qi) __X,
-(__v16qi) __Y,
-(__v16qi)
+  return (__m128i) __builtin_ia32_vpmultishiftqb128_mask ((__v2di) __X,
+(__v2di) __Y,
+(__v2di)
 _mm_undefined_si128 (),
 (__mmask16) -1);
 }
 
 static __inline__ __m256i __DEFAULT_FN_ATTRS
 _mm256_mask_multishift_epi64_epi8 (__m256i __W, __mmask32 __M, __m256i __X, __m256i __Y)
 {
-  return (__m256i) __builtin_ia32_vpmultishiftqb256_mask ((__v32qi) __X,
-(__v32qi) __Y,
-(__v32qi) __W,
+  return (__m256i) __builtin_ia32_vpmultishiftqb256_mask ((__v4di) __X,
+(__v4di) __Y,
+(__v4di) __W,
 (__mmask32) __M);
 }
 
 static __inline__ __m256i __DEFAULT_FN_ATTRS
 _mm256_maskz_multishift_epi64_epi8 (__mmask32 __M, __m256i __X, __m256i __Y)
 {
-  return (__m256i) __builtin_ia32_vpmultishiftqb256_mask ((__v32qi) __X,
-(__v32qi) __Y,
-(__v32qi)
+  return (__m256i) __builtin_ia32_vpmultishiftqb256_mask ((__v4di) __X,
+(__v4di) __Y,
+(__v4di)
 _mm256_setzero_si256 (),
 (__mmask32) __M);
 }
 
 static __inline__ __m256i __DEFAULT_FN_ATTRS
 _mm256_multishift_epi64_epi8 (__m256i __X, __m256i __Y)
 {
-  return (__m256i) __builtin_ia32_vpmultishiftqb256_mask ((__v32qi) __X,
-(__v32qi) __Y,
-(__v32qi)
+  return (__m256i) __builtin_ia32_vpmultishiftqb256_mask ((__v4di) __X,
+(__v4di) __Y,
+(__v4di)
   

r285852 - [analyzer] StdLibraryFunctions: provide platform-specific function summaries.

2016-11-02 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Wed Nov  2 14:35:20 2016
New Revision: 285852

URL: http://llvm.org/viewvc/llvm-project?rev=285852&view=rev
Log:
[analyzer] StdLibraryFunctions: provide platform-specific function summaries.

Because standard functions can be defined differently on different platforms,
this commit introduces a method for constructing summaries with multiple
variants, whichever matches better. It is also useful for supporting overloads.

Differential Revision: https://reviews.llvm.org/D25940

Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
cfe/trunk/test/Analysis/std-c-library-functions.c

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp?rev=285852&r1=285851&r2=285852&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp 
(original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp Wed 
Nov  2 14:35:20 2016
@@ -79,11 +79,15 @@ class StdLibraryFunctionsChecker : publi
   /// impose a constraint that involves other argument or return value symbols.
   enum ValueRangeKindTy { OutOfRange, WithinRange, ComparesToArgument };
 
+  // The universal integral type to use in value range descriptions.
+  // Unsigned to make sure overflows are well-defined.
+  typedef uint64_t RangeIntTy;
+
   /// Normally, describes a single range constraint, eg. {{0, 1}, {3, 4}} is
   /// a non-negative integer, which less than 5 and not equal to 2. For
   /// `ComparesToArgument', holds information about how exactly to compare to
   /// the argument.
-  typedef std::vector> IntRangeVectorTy;
+  typedef std::vector> IntRangeVectorTy;
 
   /// A reference to an argument or return value by its number.
   /// ArgNo in CallExpr and CallEvent is defined as Unsigned, but
@@ -190,9 +194,16 @@ class StdLibraryFunctionsChecker : publi
 bool matchesCall(const CallExpr *CE) const;
   };
 
+  // The same function (as in, function identifier) may have different
+  // summaries assigned to it, with different argument and return value types.
+  // We call these "variants" of the function. This can be useful for handling
+  // C++ function overloads, and also it can be used when the same function
+  // may have different definitions on different platforms.
+  typedef std::vector FunctionVariantsTy;
+
   // The map of all functions supported by the checker. It is initialized
   // lazily, and it doesn't change after initialization.
-  typedef llvm::StringMap FunctionSummaryMapTy;
+  typedef llvm::StringMap FunctionSummaryMapTy;
   mutable FunctionSummaryMapTy FunctionSummaryMap;
 
   // Auxiliary functions to support ArgNoTy within all structures
@@ -442,11 +453,12 @@ StdLibraryFunctionsChecker::findFunction
   // Strict checking is important because we will be conducting
   // very integral-type-sensitive operations on arguments and
   // return values.
-  const FunctionSummaryTy &Spec = FSMI->second;
-  if (!Spec.matchesCall(CE))
-return None;
+  const FunctionVariantsTy &SpecVariants = FSMI->second;
+  for (const FunctionSummaryTy &Spec : SpecVariants)
+if (Spec.matchesCall(CE))
+  return Spec;
 
-  return Spec;
+  return None;
 }
 
 void StdLibraryFunctionsChecker::initFunctionSummaries(
@@ -458,17 +470,20 @@ void StdLibraryFunctionsChecker::initFun
 
   // These types are useful for writing specifications quickly,
   // New specifications should probably introduce more types.
+  // Some types are hard to obtain from the AST, eg. "ssize_t".
+  // In such cases it should be possible to provide multiple variants
+  // of function summary for common cases (eg. ssize_t could be int or long
+  // or long long, so three summary variants would be enough).
+  // Of course, function variants are also useful for C++ overloads.
   QualType Irrelevant; // A placeholder, whenever we do not care about the 
type.
   QualType IntTy = ACtx.IntTy;
+  QualType LongTy = ACtx.LongTy;
+  QualType LongLongTy = ACtx.LongLongTy;
   QualType SizeTy = ACtx.getSizeType();
-  QualType SSizeTy = ACtx.getIntTypeForBitwidth(ACtx.getTypeSize(SizeTy), 
true);
 
-  // Don't worry about truncation here, it'd be cast back to SIZE_MAX when 
used.
-  int64_t SizeMax =
-  BVF.getMaxValue(SizeTy).getLimitedValue();
-  int64_t SSizeMax =
-BVF.getMaxValue(SSizeTy).getLimitedValue();
-  (void)SizeMax;
+  RangeIntTy IntMax = BVF.getMaxValue(IntTy).getLimitedValue();
+  RangeIntTy LongMax = BVF.getMaxValue(LongTy).getLimitedValue();
+  RangeIntTy LongLongMax = BVF.getMaxValue(LongLongTy).getLimitedValue();
 
   // We are finally ready to define specifications for all supported functions.
   //
@@ -511,17 +526,22 @@ void StdLibraryFunctionsChecker::initFun
   //  }
   //}
 
+#define SUMMARY_WITH_VARIANTS(identifier) {#identifier, {
+#define END_SUMMARY_WITH_

[PATCH] D25940: [analyzer] LibraryFunctions: Fix errors due to different integral types and typedefs on different architectures.

2016-11-02 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL285852: [analyzer] StdLibraryFunctions: provide 
platform-specific function summaries. (authored by dergachev).

Changed prior to commit:
  https://reviews.llvm.org/D25940?vs=76731&id=76771#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25940

Files:
  cfe/trunk/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
  cfe/trunk/test/Analysis/std-c-library-functions.c

Index: cfe/trunk/test/Analysis/std-c-library-functions.c
===
--- cfe/trunk/test/Analysis/std-c-library-functions.c
+++ cfe/trunk/test/Analysis/std-c-library-functions.c
@@ -1,4 +1,8 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=unix.StdCLibraryFunctions,debug.ExprInspection -verify %s
+// RUN: %clang_cc1 -triple i686-unknown-linux -analyze -analyzer-checker=unix.StdCLibraryFunctions,debug.ExprInspection -verify %s
 // RUN: %clang_cc1 -triple x86_64-unknown-linux -analyze -analyzer-checker=unix.StdCLibraryFunctions,debug.ExprInspection -verify %s
+// RUN: %clang_cc1 -triple armv7-a15-linux -analyze -analyzer-checker=unix.StdCLibraryFunctions,debug.ExprInspection -verify %s
+// RUN: %clang_cc1 -triple thumbv7-a15-linux -analyze -analyzer-checker=unix.StdCLibraryFunctions,debug.ExprInspection -verify %s
 
 void clang_analyzer_eval(int);
 
@@ -23,7 +27,7 @@
 }
 
 
-typedef unsigned long size_t;
+typedef typeof(sizeof(int)) size_t;
 typedef signed long ssize_t;
 ssize_t read(int, void *, size_t);
 ssize_t write(int, const void *, size_t);
Index: cfe/trunk/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
@@ -79,11 +79,15 @@
   /// impose a constraint that involves other argument or return value symbols.
   enum ValueRangeKindTy { OutOfRange, WithinRange, ComparesToArgument };
 
+  // The universal integral type to use in value range descriptions.
+  // Unsigned to make sure overflows are well-defined.
+  typedef uint64_t RangeIntTy;
+
   /// Normally, describes a single range constraint, eg. {{0, 1}, {3, 4}} is
   /// a non-negative integer, which less than 5 and not equal to 2. For
   /// `ComparesToArgument', holds information about how exactly to compare to
   /// the argument.
-  typedef std::vector> IntRangeVectorTy;
+  typedef std::vector> IntRangeVectorTy;
 
   /// A reference to an argument or return value by its number.
   /// ArgNo in CallExpr and CallEvent is defined as Unsigned, but
@@ -190,9 +194,16 @@
 bool matchesCall(const CallExpr *CE) const;
   };
 
+  // The same function (as in, function identifier) may have different
+  // summaries assigned to it, with different argument and return value types.
+  // We call these "variants" of the function. This can be useful for handling
+  // C++ function overloads, and also it can be used when the same function
+  // may have different definitions on different platforms.
+  typedef std::vector FunctionVariantsTy;
+
   // The map of all functions supported by the checker. It is initialized
   // lazily, and it doesn't change after initialization.
-  typedef llvm::StringMap FunctionSummaryMapTy;
+  typedef llvm::StringMap FunctionSummaryMapTy;
   mutable FunctionSummaryMapTy FunctionSummaryMap;
 
   // Auxiliary functions to support ArgNoTy within all structures
@@ -442,11 +453,12 @@
   // Strict checking is important because we will be conducting
   // very integral-type-sensitive operations on arguments and
   // return values.
-  const FunctionSummaryTy &Spec = FSMI->second;
-  if (!Spec.matchesCall(CE))
-return None;
+  const FunctionVariantsTy &SpecVariants = FSMI->second;
+  for (const FunctionSummaryTy &Spec : SpecVariants)
+if (Spec.matchesCall(CE))
+  return Spec;
 
-  return Spec;
+  return None;
 }
 
 void StdLibraryFunctionsChecker::initFunctionSummaries(
@@ -458,17 +470,20 @@
 
   // These types are useful for writing specifications quickly,
   // New specifications should probably introduce more types.
+  // Some types are hard to obtain from the AST, eg. "ssize_t".
+  // In such cases it should be possible to provide multiple variants
+  // of function summary for common cases (eg. ssize_t could be int or long
+  // or long long, so three summary variants would be enough).
+  // Of course, function variants are also useful for C++ overloads.
   QualType Irrelevant; // A placeholder, whenever we do not care about the type.
   QualType IntTy = ACtx.IntTy;
+  QualType LongTy = ACtx.LongTy;
+  QualType LongLongTy = ACtx.LongLongTy;
   QualType SizeTy = ACtx.getSizeType();
-  QualType SSizeTy = ACtx.getIntTypeForBitwidth(ACtx.getTypeSize(SizeTy), true);
 
-  // Don't worry about truncation here, it'd be cast back to SIZE_MAX when used.
-  int64_t SizeMax =
-  BVF.getMaxValu

[PATCH] D26218: [clang-tidy] Ignore notes along with a warning when processing NOLINT

2016-11-02 Thread Nikita Kakuev via cfe-commits
nkakuev updated this revision to Diff 76769.
nkakuev marked an inline comment as done.
nkakuev added a comment.

Fix a typo.


https://reviews.llvm.org/D26218

Files:
  clang-tidy/ClangTidyDiagnosticConsumer.cpp
  clang-tidy/ClangTidyDiagnosticConsumer.h
  test/clang-tidy/Inputs/nolint/trigger_warning.h
  test/clang-tidy/nolint.cpp


Index: test/clang-tidy/nolint.cpp
===
--- test/clang-tidy/nolint.cpp
+++ test/clang-tidy/nolint.cpp
@@ -1,4 +1,5 @@
-// RUN: %check_clang_tidy %s 
google-explicit-constructor,clang-diagnostic-unused-variable %t -- 
-extra-arg=-Wunused-variable --
+// RUN: %check_clang_tidy %s 
google-explicit-constructor,clang-diagnostic-unused-variable,clang-analyzer-core.UndefinedBinaryOperatorResult
 %t -- -extra-arg=-Wunused-variable -- -I%S/Inputs/nolint
+
 
 class A { A(int i); };
 // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: single-argument constructors must 
be marked explicit
@@ -27,4 +28,12 @@
 #define DOUBLE_MACRO MACRO(H) // NOLINT
 DOUBLE_MACRO
 
-// CHECK-MESSAGES: Suppressed 7 warnings (7 NOLINT)
+#include "trigger_warning.h"
+void I(int& Out) {
+  int In;
+  A1(In, Out);
+}
+// CHECK-NOT: trigger_warning.h:{{.*}} warning: The left operand of '>' is a 
garbage value
+// CHECK-NOT: :[[@LINE-4]]:{{.*}} note
+
+// CHECK-MESSAGES: Suppressed 8 warnings (8 NOLINT)
Index: test/clang-tidy/Inputs/nolint/trigger_warning.h
===
--- test/clang-tidy/Inputs/nolint/trigger_warning.h
+++ test/clang-tidy/Inputs/nolint/trigger_warning.h
@@ -0,0 +1,5 @@
+void A1(const int &In, int &Out) {
+  if (In > 123) // NOLINT
+Out = 123;
+}
+
Index: clang-tidy/ClangTidyDiagnosticConsumer.h
===
--- clang-tidy/ClangTidyDiagnosticConsumer.h
+++ clang-tidy/ClangTidyDiagnosticConsumer.h
@@ -286,6 +286,7 @@
   std::unique_ptr HeaderFilter;
   bool LastErrorRelatesToUserCode;
   bool LastErrorPassesLineFilter;
+  bool LastErrorWasIgnored;
 };
 
 } // end namespace tidy
Index: clang-tidy/ClangTidyDiagnosticConsumer.cpp
===
--- clang-tidy/ClangTidyDiagnosticConsumer.cpp
+++ clang-tidy/ClangTidyDiagnosticConsumer.cpp
@@ -250,7 +250,7 @@
 
 ClangTidyDiagnosticConsumer::ClangTidyDiagnosticConsumer(ClangTidyContext &Ctx)
 : Context(Ctx), LastErrorRelatesToUserCode(false),
-  LastErrorPassesLineFilter(false) {
+  LastErrorPassesLineFilter(false), LastErrorWasIgnored(false) {
   IntrusiveRefCntPtr DiagOpts = new DiagnosticOptions();
   Diags.reset(new DiagnosticsEngine(
   IntrusiveRefCntPtr(new DiagnosticIDs), &*DiagOpts, this,
@@ -309,13 +309,20 @@
 
 void ClangTidyDiagnosticConsumer::HandleDiagnostic(
 DiagnosticsEngine::Level DiagLevel, const Diagnostic &Info) {
+  if (LastErrorWasIgnored && DiagLevel == DiagnosticsEngine::Note)
+return;
+
   if (Info.getLocation().isValid() &&
   DiagLevel != DiagnosticsEngine::Error &&
   DiagLevel != DiagnosticsEngine::Fatal &&
   LineIsMarkedWithNOLINTinMacro(Diags->getSourceManager(), 
Info.getLocation())) {
 ++Context.Stats.ErrorsIgnoredNOLINT;
+// Ignored a warning, should ignore related notes as well
+LastErrorWasIgnored = true;
 return;
   }
+
+  LastErrorWasIgnored = false;
   // Count warnings/errors.
   DiagnosticConsumer::HandleDiagnostic(DiagLevel, Info);
 


Index: test/clang-tidy/nolint.cpp
===
--- test/clang-tidy/nolint.cpp
+++ test/clang-tidy/nolint.cpp
@@ -1,4 +1,5 @@
-// RUN: %check_clang_tidy %s google-explicit-constructor,clang-diagnostic-unused-variable %t -- -extra-arg=-Wunused-variable --
+// RUN: %check_clang_tidy %s google-explicit-constructor,clang-diagnostic-unused-variable,clang-analyzer-core.UndefinedBinaryOperatorResult %t -- -extra-arg=-Wunused-variable -- -I%S/Inputs/nolint
+
 
 class A { A(int i); };
 // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: single-argument constructors must be marked explicit
@@ -27,4 +28,12 @@
 #define DOUBLE_MACRO MACRO(H) // NOLINT
 DOUBLE_MACRO
 
-// CHECK-MESSAGES: Suppressed 7 warnings (7 NOLINT)
+#include "trigger_warning.h"
+void I(int& Out) {
+  int In;
+  A1(In, Out);
+}
+// CHECK-NOT: trigger_warning.h:{{.*}} warning: The left operand of '>' is a garbage value
+// CHECK-NOT: :[[@LINE-4]]:{{.*}} note
+
+// CHECK-MESSAGES: Suppressed 8 warnings (8 NOLINT)
Index: test/clang-tidy/Inputs/nolint/trigger_warning.h
===
--- test/clang-tidy/Inputs/nolint/trigger_warning.h
+++ test/clang-tidy/Inputs/nolint/trigger_warning.h
@@ -0,0 +1,5 @@
+void A1(const int &In, int &Out) {
+  if (In > 123) // NOLINT
+Out = 123;
+}
+
Index: clang-tidy/ClangTidyDiagnosticConsumer.h
===
--- clang-tidy/ClangTidyDiagnosticConsumer.h
+++ clang-tidy/Cla

[PATCH] D25204: Register Calling Convention, Clang changes

2016-11-02 Thread Erich Keane via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL285849: regcall: Implement regcall Calling Conv in clang 
(authored by erichkeane).

Changed prior to commit:
  https://reviews.llvm.org/D25204?vs=76717&id=76755#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25204

Files:
  cfe/trunk/include/clang-c/Index.h
  cfe/trunk/include/clang/AST/Type.h
  cfe/trunk/include/clang/Basic/Attr.td
  cfe/trunk/include/clang/Basic/AttrDocs.td
  cfe/trunk/include/clang/Basic/Specifiers.h
  cfe/trunk/include/clang/Basic/TokenKinds.def
  cfe/trunk/lib/AST/Expr.cpp
  cfe/trunk/lib/AST/ItaniumMangle.cpp
  cfe/trunk/lib/AST/Mangle.cpp
  cfe/trunk/lib/AST/MicrosoftMangle.cpp
  cfe/trunk/lib/AST/Type.cpp
  cfe/trunk/lib/AST/TypePrinter.cpp
  cfe/trunk/lib/Basic/Targets.cpp
  cfe/trunk/lib/CodeGen/CGCall.cpp
  cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
  cfe/trunk/lib/CodeGen/CodeGenModule.cpp
  cfe/trunk/lib/CodeGen/TargetInfo.cpp
  cfe/trunk/lib/Parse/ParseDecl.cpp
  cfe/trunk/lib/Parse/ParseTentative.cpp
  cfe/trunk/lib/Sema/SemaDeclAttr.cpp
  cfe/trunk/lib/Sema/SemaType.cpp
  cfe/trunk/test/CodeGen/regcall.c
  cfe/trunk/test/CodeGenCXX/regcall.cpp
  cfe/trunk/tools/libclang/CXType.cpp

Index: cfe/trunk/lib/Parse/ParseDecl.cpp
===
--- cfe/trunk/lib/Parse/ParseDecl.cpp
+++ cfe/trunk/lib/Parse/ParseDecl.cpp
@@ -605,6 +605,7 @@
 case tok::kw___fastcall:
 case tok::kw___stdcall:
 case tok::kw___thiscall:
+case tok::kw___regcall:
 case tok::kw___cdecl:
 case tok::kw___vectorcall:
 case tok::kw___ptr64:
@@ -3137,6 +3138,7 @@
 case tok::kw___stdcall:
 case tok::kw___fastcall:
 case tok::kw___thiscall:
+case tok::kw___regcall:
 case tok::kw___vectorcall:
   ParseMicrosoftTypeAttributes(DS.getAttributes());
   continue;
@@ -4454,6 +4456,7 @@
   case tok::kw___stdcall:
   case tok::kw___fastcall:
   case tok::kw___thiscall:
+  case tok::kw___regcall:
   case tok::kw___vectorcall:
   case tok::kw___w64:
   case tok::kw___ptr64:
@@ -4638,6 +4641,7 @@
   case tok::kw___stdcall:
   case tok::kw___fastcall:
   case tok::kw___thiscall:
+  case tok::kw___regcall:
   case tok::kw___vectorcall:
   case tok::kw___w64:
   case tok::kw___sptr:
@@ -4876,6 +4880,7 @@
 case tok::kw___stdcall:
 case tok::kw___fastcall:
 case tok::kw___thiscall:
+case tok::kw___regcall:
 case tok::kw___vectorcall:
   if (AttrReqs & AR_DeclspecAttributesParsed) {
 ParseMicrosoftTypeAttributes(DS.getAttributes());
Index: cfe/trunk/lib/Parse/ParseTentative.cpp
===
--- cfe/trunk/lib/Parse/ParseTentative.cpp
+++ cfe/trunk/lib/Parse/ParseTentative.cpp
@@ -909,7 +909,7 @@
   // '(' abstract-declarator ')'
   if (Tok.isOneOf(tok::kw___attribute, tok::kw___declspec, tok::kw___cdecl,
   tok::kw___stdcall, tok::kw___fastcall, tok::kw___thiscall,
-  tok::kw___vectorcall))
+  tok::kw___regcall, tok::kw___vectorcall))
 return TPResult::True; // attributes indicate declaration
   TPResult TPR = TryParseDeclarator(mayBeAbstract, mayHaveIdentifier);
   if (TPR != TPResult::Ambiguous)
@@ -1058,6 +1058,7 @@
   case tok::kw___stdcall:
   case tok::kw___fastcall:
   case tok::kw___thiscall:
+  case tok::kw___regcall:
   case tok::kw___vectorcall:
   case tok::kw___unaligned:
   case tok::kw___vector:
@@ -1351,6 +1352,7 @@
   case tok::kw___stdcall:
   case tok::kw___fastcall:
   case tok::kw___thiscall:
+  case tok::kw___regcall:
   case tok::kw___vectorcall:
   case tok::kw___w64:
   case tok::kw___sptr:
Index: cfe/trunk/lib/CodeGen/CGCall.cpp
===
--- cfe/trunk/lib/CodeGen/CGCall.cpp
+++ cfe/trunk/lib/CodeGen/CGCall.cpp
@@ -48,6 +48,7 @@
   default: return llvm::CallingConv::C;
   case CC_X86StdCall: return llvm::CallingConv::X86_StdCall;
   case CC_X86FastCall: return llvm::CallingConv::X86_FastCall;
+  case CC_X86RegCall: return llvm::CallingConv::X86_RegCall;
   case CC_X86ThisCall: return llvm::CallingConv::X86_ThisCall;
   case CC_X86_64Win64: return llvm::CallingConv::X86_64_Win64;
   case CC_X86_64SysV: return llvm::CallingConv::X86_64_SysV;
@@ -173,6 +174,9 @@
   if (D->hasAttr())
 return CC_X86FastCall;
 
+  if (D->hasAttr())
+return CC_X86RegCall;
+
   if (D->hasAttr())
 return CC_X86ThisCall;
 
Index: cfe/trunk/lib/CodeGen/TargetInfo.cpp
===
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp
@@ -1229,7 +1229,8 @@
 
   const Type *Base = nullptr;
   uint64_t NumElts = 0;
-  if (State.CC == llvm::CallingConv::X86_VectorCall &&
+  if ((State.CC == llvm::CallingConv::X86_VectorCall ||
+   State.CC == llvm::CallingConv::X86_RegCall) &&
   isHomogeneousAggregate(RetTy, Bas

[clang-tools-extra] r285848 - [Documentation] Fix Clang-tidy misc-use-after-move and cert-msc50-cpp style and misspelling.

2016-11-02 Thread Eugene Zelenko via cfe-commits
Author: eugenezelenko
Date: Wed Nov  2 13:23:52 2016
New Revision: 285848

URL: http://llvm.org/viewvc/llvm-project?rev=285848&view=rev
Log:
[Documentation] Fix Clang-tidy misc-use-after-move and cert-msc50-cpp style and 
misspelling.

Modified:
clang-tools-extra/trunk/docs/clang-tidy/checks/cert-msc50-cpp.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/misc-use-after-move.rst

Modified: clang-tools-extra/trunk/docs/clang-tidy/checks/cert-msc50-cpp.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/cert-msc50-cpp.rst?rev=285848&r1=285847&r2=285848&view=diff
==
--- clang-tools-extra/trunk/docs/clang-tidy/checks/cert-msc50-cpp.rst (original)
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/cert-msc50-cpp.rst Wed Nov  
2 13:23:52 2016
@@ -3,4 +3,9 @@
 cert-msc50-cpp
 ==
 
-Pseudorandom number generators use mathematical algorithms to produce a 
sequence of numbers with good statistical properties, but the numbers produced 
are not genuinely random. The ``std::rand()`` function takes a seed (number), 
runs a mathematical operation on it and returns the result. By manipulating the 
seed the result can be predictible. This check warns for the usage of 
``std::rand()``.
+Pseudorandom number generators use mathematical algorithms to produce a 
sequence
+of numbers with good statistical properties, but the numbers produced are not
+genuinely random. The ``std::rand()`` function takes a seed (number), runs a
+mathematical operation on it and returns the result. By manipulating the seed
+the result can be predictable. This check warns for the usage of
+``std::rand()``.

Modified: clang-tools-extra/trunk/docs/clang-tidy/checks/misc-use-after-move.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/misc-use-after-move.rst?rev=285848&r1=285847&r2=285848&view=diff
==
--- clang-tools-extra/trunk/docs/clang-tidy/checks/misc-use-after-move.rst 
(original)
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/misc-use-after-move.rst Wed 
Nov  2 13:23:52 2016
@@ -152,9 +152,9 @@ is considered to be a use.
 An exception to this are objects of type ``std::unique_ptr``,
 ``std::shared_ptr`` and ``std::weak_ptr``, which have defined move behavior
 (objects of these classes are guaranteed to be empty after they have been moved
-from). Therefore, an object of these classes `` will only be considered to be
-used if it is dereferenced, i.e. if ``operator*``, ``operator->`` or
-``operator[]`` (in the case of ``std::unique_ptr``) is called on it.
+from). Therefore, an object of these classes will only be considered to be used
+if it is dereferenced, i.e. if ``operator*``, ``operator->`` or ``operator[]``
+(in the case of ``std::unique_ptr``) is called on it.
 
 If multiple uses occur after a move, only the first of these is flagged.
 


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


r285849 - regcall: Implement regcall Calling Conv in clang

2016-11-02 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Wed Nov  2 13:29:35 2016
New Revision: 285849

URL: http://llvm.org/viewvc/llvm-project?rev=285849&view=rev
Log:
regcall: Implement regcall Calling Conv in clang

This patch implements the register call calling convention, which ensures
as many values as possible are passed in registers. CodeGen changes
were committed in https://reviews.llvm.org/rL284108.

Differential Revision: https://reviews.llvm.org/D25204

Added:
cfe/trunk/test/CodeGen/regcall.c   (with props)
cfe/trunk/test/CodeGenCXX/regcall.cpp   (with props)
Modified:
cfe/trunk/include/clang-c/Index.h
cfe/trunk/include/clang/AST/Type.h
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/include/clang/Basic/AttrDocs.td
cfe/trunk/include/clang/Basic/Specifiers.h
cfe/trunk/include/clang/Basic/TokenKinds.def
cfe/trunk/lib/AST/Expr.cpp
cfe/trunk/lib/AST/ItaniumMangle.cpp
cfe/trunk/lib/AST/Mangle.cpp
cfe/trunk/lib/AST/MicrosoftMangle.cpp
cfe/trunk/lib/AST/Type.cpp
cfe/trunk/lib/AST/TypePrinter.cpp
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/TargetInfo.cpp
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/lib/Parse/ParseTentative.cpp
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/tools/libclang/CXType.cpp

Modified: cfe/trunk/include/clang-c/Index.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=285849&r1=285848&r2=285849&view=diff
==
--- cfe/trunk/include/clang-c/Index.h (original)
+++ cfe/trunk/include/clang-c/Index.h Wed Nov  2 13:29:35 2016
@@ -3022,7 +3022,7 @@ enum CXCallingConv {
   CXCallingConv_X86Pascal = 5,
   CXCallingConv_AAPCS = 6,
   CXCallingConv_AAPCS_VFP = 7,
-  /* Value 8 was PnaclCall, but it was never used, so it could safely be 
re-used. */
+  CXCallingConv_X86RegCall = 8,
   CXCallingConv_IntelOclBicc = 9,
   CXCallingConv_X86_64Win64 = 10,
   CXCallingConv_X86_64SysV = 11,

Modified: cfe/trunk/include/clang/AST/Type.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=285849&r1=285848&r2=285849&view=diff
==
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Wed Nov  2 13:29:35 2016
@@ -1378,7 +1378,7 @@ protected:
 
 /// Extra information which affects how the function is called, like
 /// regparm and the calling convention.
-unsigned ExtInfo : 9;
+unsigned ExtInfo : 10;
 
 /// Used only by FunctionProtoType, put here to pack with the
 /// other bitfields.
@@ -2907,19 +2907,19 @@ class FunctionType : public Type {
   // * AST read and write
   // * Codegen
   class ExtInfo {
-// Feel free to rearrange or add bits, but if you go over 9,
+// Feel free to rearrange or add bits, but if you go over 10,
 // you'll need to adjust both the Bits field below and
 // Type::FunctionTypeBitfields.
 
 //   |  CC  |noreturn|produces|regparm|
-//   |0 .. 3|   4|5   | 6 .. 8|
+//   |0 .. 4|   5|6   | 7 .. 9|
 //
 // regparm is either 0 (no regparm attribute) or the regparm value+1.
-enum { CallConvMask = 0xF };
-enum { NoReturnMask = 0x10 };
-enum { ProducesResultMask = 0x20 };
+enum { CallConvMask = 0x1F };
+enum { NoReturnMask = 0x20 };
+enum { ProducesResultMask = 0x40 };
 enum { RegParmMask = ~(CallConvMask | NoReturnMask | ProducesResultMask),
-   RegParmOffset = 6 }; // Assumed to be the last field
+   RegParmOffset = 7 }; // Assumed to be the last field
 
 uint16_t Bits;
 
@@ -3803,6 +3803,7 @@ public:
 attr_fastcall,
 attr_stdcall,
 attr_thiscall,
+attr_regcall,
 attr_pascal,
 attr_swiftcall,
 attr_vectorcall,

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=285849&r1=285848&r2=285849&view=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Wed Nov  2 13:29:35 2016
@@ -810,6 +810,11 @@ def FastCall : InheritableAttr {
   let Documentation = [FastCallDocs];
 }
 
+def RegCall : InheritableAttr {
+  let Spellings = [GCC<"regcall">, Keyword<"__regcall">];
+  let Documentation = [RegCallDocs];
+}
+
 def Final : InheritableAttr {
   let Spellings = [Keyword<"final">, Keyword<"sealed">];
   let Accessors = [Accessor<"isSpelledAsSealed", [Keyword<"sealed">]>];

Modified: cfe/trunk/include/clang/Basic/AttrDocs.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrDocs.td?rev=285849&r1=285848&r2=285849&view=diff
===

[libunwind] r285845 - Add support for old versions of MacOS to libunwind. Fixes PR22203. Thanks to Jeremy for the bug report and the patch.

2016-11-02 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Wed Nov  2 12:56:05 2016
New Revision: 285845

URL: http://llvm.org/viewvc/llvm-project?rev=285845&view=rev
Log:
Add support for old versions of MacOS to libunwind. Fixes PR22203. Thanks to 
Jeremy for the bug report and the patch.

Modified:
libunwind/trunk/include/libunwind.h

Modified: libunwind/trunk/include/libunwind.h
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/include/libunwind.h?rev=285845&r1=285844&r2=285845&view=diff
==
--- libunwind/trunk/include/libunwind.h (original)
+++ libunwind/trunk/include/libunwind.h Wed Nov  2 12:56:05 2016
@@ -20,12 +20,26 @@
 #include 
 
 #ifdef __APPLE__
-  #include 
-#ifdef __arm__
-   #define LIBUNWIND_AVAIL __attribute__((unavailable))
+  #if __clang__
+#if __has_include()
+  #include 
+#endif
+  #elif __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1050
+#include 
+  #endif
+
+  #ifdef __arm__
+ #define LIBUNWIND_AVAIL __attribute__((unavailable))
+  #elif defined(__OSX_AVAILABLE_STARTING)
+#define LIBUNWIND_AVAIL __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_5_0)
+  #else
+#include 
+#ifdef AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER
+  #define LIBUNWIND_AVAIL AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER
 #else
-  #define LIBUNWIND_AVAIL __OSX_AVAILABLE_STARTING(__MAC_10_6, 
__IPHONE_5_0)
+  #define LIBUNWIND_AVAIL __attribute__((unavailable))
 #endif
+  #endif
 #else
   #define LIBUNWIND_AVAIL
 #endif


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


[PATCH] D25811: [libcxx] Fix toupper/tolower tests for UTF-8 locale

2016-11-02 Thread Alex Lorenz via cfe-commits
arphaman added a comment.

In https://reviews.llvm.org/D25811#586053, @kparzysz wrote:

> In https://reviews.llvm.org/D25811#586000, @arphaman wrote:
>
> > I've tested this patch on OS X and these 4 tests that you've changed now 
> > fail.
> >
> > The `XFAIL: with_system_cxx_lib` lines don't have any effect on my system - 
> > these tests get invoked as expected by lit. Let me know if there's anything 
> > else I can do to help you.
>
>
> That's surprising.  Seems like something is different on OS X.
>  Could you try compiling/running this small program?
>
>   #include 
>   #include 
>  
>   int main() {
> std::locale x("en_US.UTF-8");
> std::cout << x.name() << std::endl;
>   }
>
>
> If it prints "en_US.UTF-8", then I'm out of ideas... :)


Just tried it, I get "en_US.UTF-8"


Repository:
  rL LLVM

https://reviews.llvm.org/D25811



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


[PATCH] D25811: [libcxx] Fix toupper/tolower tests for UTF-8 locale

2016-11-02 Thread Krzysztof Parzyszek via cfe-commits
kparzysz added a comment.

And thanks for help.  :)


Repository:
  rL LLVM

https://reviews.llvm.org/D25811



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


[clang-tools-extra] r285842 - [clang-tidy] Extend misc-use-after-move to support unique_ptr and shared_ptr.

2016-11-02 Thread Martin Bohme via cfe-commits
Author: mboehme
Date: Wed Nov  2 12:34:47 2016
New Revision: 285842

URL: http://llvm.org/viewvc/llvm-project?rev=285842&view=rev
Log:
[clang-tidy] Extend misc-use-after-move to support unique_ptr and shared_ptr.

Summary:
As a unique_ptr or shared_ptr that has been moved from is guaranteed to be null,
we only warn if the pointer is dereferenced.

Reviewers: hokein, alexfh, aaron.ballman

Subscribers: Prazek, cfe-commits

Differential Revision: https://reviews.llvm.org/D26041

Modified:
clang-tools-extra/trunk/clang-tidy/misc/UseAfterMoveCheck.cpp
clang-tools-extra/trunk/docs/clang-tidy/checks/misc-use-after-move.rst
clang-tools-extra/trunk/test/clang-tidy/misc-use-after-move.cpp

Modified: clang-tools-extra/trunk/clang-tidy/misc/UseAfterMoveCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/UseAfterMoveCheck.cpp?rev=285842&r1=285841&r2=285842&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/UseAfterMoveCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/UseAfterMoveCheck.cpp Wed Nov  2 
12:34:47 2016
@@ -463,6 +463,26 @@ void UseAfterMoveFinder::getUsesAndReini
 });
 }
 
+bool isStandardSmartPointer(const ValueDecl *VD) {
+  const Type *TheType = VD->getType().getTypePtrOrNull();
+  if (!TheType)
+return false;
+
+  const CXXRecordDecl *RecordDecl = TheType->getAsCXXRecordDecl();
+  if (!RecordDecl)
+return false;
+
+  const IdentifierInfo *ID = RecordDecl->getIdentifier();
+  if (!ID)
+return false;
+
+  StringRef Name = ID->getName();
+  if (Name != "unique_ptr" && Name != "shared_ptr" && Name != "weak_ptr")
+return false;
+
+  return RecordDecl->getDeclContext()->isStdNamespace();
+}
+
 void UseAfterMoveFinder::getDeclRefs(
 const CFGBlock *Block, const Decl *MovedVariable,
 llvm::SmallPtrSetImpl *DeclRefs) {
@@ -472,17 +492,33 @@ void UseAfterMoveFinder::getDeclRefs(
 if (!S)
   continue;
 
-SmallVector Matches =
-match(findAll(declRefExpr(hasDeclaration(equalsNode(MovedVariable)),
-  unless(inDecltypeOrTemplateArg()))
-  .bind("declref")),
-  *S->getStmt(), *Context);
+auto addDeclRefs = [this, Block,
+DeclRefs](const ArrayRef Matches) {
+  for (const auto &Match : Matches) {
+const auto *DeclRef = Match.getNodeAs("declref");
+const auto *Operator = 
Match.getNodeAs("operator");
+if (DeclRef && BlockMap->blockContainingStmt(DeclRef) == Block) {
+  // Ignore uses of a standard smart pointer that don't dereference the
+  // pointer.
+  if (Operator || !isStandardSmartPointer(DeclRef->getDecl())) {
+DeclRefs->insert(DeclRef);
+  }
+}
+  }
+};
 
-for (const auto &Match : Matches) {
-  const auto *DeclRef = Match.getNodeAs("declref");
-  if (DeclRef && BlockMap->blockContainingStmt(DeclRef) == Block)
-DeclRefs->insert(DeclRef);
-}
+auto DeclRefMatcher = 
declRefExpr(hasDeclaration(equalsNode(MovedVariable)),
+  unless(inDecltypeOrTemplateArg()))
+  .bind("declref");
+
+addDeclRefs(match(findAll(DeclRefMatcher), *S->getStmt(), *Context));
+addDeclRefs(match(
+findAll(cxxOperatorCallExpr(anyOf(hasOverloadedOperatorName("*"),
+  hasOverloadedOperatorName("->"),
+  hasOverloadedOperatorName("[]")),
+hasArgument(0, DeclRefMatcher))
+.bind("operator")),
+*S->getStmt(), *Context));
   }
 }
 
@@ -500,6 +536,9 @@ void UseAfterMoveFinder::getReinits(
  "::std::unordered_set", "::std::unordered_map",
  "::std::unordered_multiset", "::std::unordered_multimap")));
 
+  auto StandardSmartPointerTypeMatcher = hasType(cxxRecordDecl(
+  hasAnyName("::std::unique_ptr", "::std::shared_ptr", 
"::std::weak_ptr")));
+
   // Matches different types of reinitialization.
   auto ReinitMatcher =
   stmt(anyOf(
@@ -521,6 +560,10 @@ void UseAfterMoveFinder::getReinits(
// is called on any of the other containers, this will be
// flagged by a compile error anyway.
callee(cxxMethodDecl(hasAnyName("clear", "assign",
+   // reset() on standard smart pointers.
+   cxxMemberCallExpr(
+   on(allOf(DeclRefMatcher, StandardSmartPointerTypeMatcher)),
+   callee(cxxMethodDecl(hasName("reset",
// Passing variable to a function as a non-const pointer.
callExpr(forEachArgumentWithParam(
unaryOperator(hasOperatorName("&"),
@@ -587,15 +630,10 @@ void UseAfterMoveCheck::registerMatchers
   if (!getLangOpts()

[PATCH] D26041: [clang-tidy] Extend misc-use-after-move to support unique_ptr and shared_ptr.

2016-11-02 Thread Martin Böhme via cfe-commits
This revision was automatically updated to reflect the committed changes.
mboehme marked 2 inline comments as done.
Closed by commit rL285842: [clang-tidy] Extend misc-use-after-move to support 
unique_ptr and shared_ptr. (authored by mboehme).

Changed prior to commit:
  https://reviews.llvm.org/D26041?vs=76655&id=76740#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D26041

Files:
  clang-tools-extra/trunk/clang-tidy/misc/UseAfterMoveCheck.cpp
  clang-tools-extra/trunk/docs/clang-tidy/checks/misc-use-after-move.rst
  clang-tools-extra/trunk/test/clang-tidy/misc-use-after-move.cpp

Index: clang-tools-extra/trunk/clang-tidy/misc/UseAfterMoveCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/misc/UseAfterMoveCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/misc/UseAfterMoveCheck.cpp
@@ -463,6 +463,26 @@
 });
 }
 
+bool isStandardSmartPointer(const ValueDecl *VD) {
+  const Type *TheType = VD->getType().getTypePtrOrNull();
+  if (!TheType)
+return false;
+
+  const CXXRecordDecl *RecordDecl = TheType->getAsCXXRecordDecl();
+  if (!RecordDecl)
+return false;
+
+  const IdentifierInfo *ID = RecordDecl->getIdentifier();
+  if (!ID)
+return false;
+
+  StringRef Name = ID->getName();
+  if (Name != "unique_ptr" && Name != "shared_ptr" && Name != "weak_ptr")
+return false;
+
+  return RecordDecl->getDeclContext()->isStdNamespace();
+}
+
 void UseAfterMoveFinder::getDeclRefs(
 const CFGBlock *Block, const Decl *MovedVariable,
 llvm::SmallPtrSetImpl *DeclRefs) {
@@ -472,17 +492,33 @@
 if (!S)
   continue;
 
-SmallVector Matches =
-match(findAll(declRefExpr(hasDeclaration(equalsNode(MovedVariable)),
-  unless(inDecltypeOrTemplateArg()))
-  .bind("declref")),
-  *S->getStmt(), *Context);
+auto addDeclRefs = [this, Block,
+DeclRefs](const ArrayRef Matches) {
+  for (const auto &Match : Matches) {
+const auto *DeclRef = Match.getNodeAs("declref");
+const auto *Operator = Match.getNodeAs("operator");
+if (DeclRef && BlockMap->blockContainingStmt(DeclRef) == Block) {
+  // Ignore uses of a standard smart pointer that don't dereference the
+  // pointer.
+  if (Operator || !isStandardSmartPointer(DeclRef->getDecl())) {
+DeclRefs->insert(DeclRef);
+  }
+}
+  }
+};
 
-for (const auto &Match : Matches) {
-  const auto *DeclRef = Match.getNodeAs("declref");
-  if (DeclRef && BlockMap->blockContainingStmt(DeclRef) == Block)
-DeclRefs->insert(DeclRef);
-}
+auto DeclRefMatcher = declRefExpr(hasDeclaration(equalsNode(MovedVariable)),
+  unless(inDecltypeOrTemplateArg()))
+  .bind("declref");
+
+addDeclRefs(match(findAll(DeclRefMatcher), *S->getStmt(), *Context));
+addDeclRefs(match(
+findAll(cxxOperatorCallExpr(anyOf(hasOverloadedOperatorName("*"),
+  hasOverloadedOperatorName("->"),
+  hasOverloadedOperatorName("[]")),
+hasArgument(0, DeclRefMatcher))
+.bind("operator")),
+*S->getStmt(), *Context));
   }
 }
 
@@ -500,6 +536,9 @@
  "::std::unordered_set", "::std::unordered_map",
  "::std::unordered_multiset", "::std::unordered_multimap")));
 
+  auto StandardSmartPointerTypeMatcher = hasType(cxxRecordDecl(
+  hasAnyName("::std::unique_ptr", "::std::shared_ptr", "::std::weak_ptr")));
+
   // Matches different types of reinitialization.
   auto ReinitMatcher =
   stmt(anyOf(
@@ -521,6 +560,10 @@
// is called on any of the other containers, this will be
// flagged by a compile error anyway.
callee(cxxMethodDecl(hasAnyName("clear", "assign",
+   // reset() on standard smart pointers.
+   cxxMemberCallExpr(
+   on(allOf(DeclRefMatcher, StandardSmartPointerTypeMatcher)),
+   callee(cxxMethodDecl(hasName("reset",
// Passing variable to a function as a non-const pointer.
callExpr(forEachArgumentWithParam(
unaryOperator(hasOperatorName("&"),
@@ -587,15 +630,10 @@
   if (!getLangOpts().CPlusPlus11)
 return;
 
-  auto StandardSmartPointerTypeMatcher = hasType(
-  cxxRecordDecl(hasAnyName("::std::unique_ptr", "::std::shared_ptr")));
-
   auto CallMoveMatcher =
   callExpr(
   callee(functionDecl(hasName("::std::move"))), argumentCountIs(1),
-  hasArgument(
-  0,
-  declRefExpr(unless(StandardSmartPointerTypeMatcher)).bind("arg")),
+  hasArgument(0, declRefExpr().bind("arg")),
   anyOf(hasAncestor(lambdaExpr().b

[PATCH] D25811: [libcxx] Fix toupper/tolower tests for UTF-8 locale

2016-11-02 Thread Krzysztof Parzyszek via cfe-commits
kparzysz added a comment.

In https://reviews.llvm.org/D25811#586000, @arphaman wrote:

> I've tested this patch on OS X and these 4 tests that you've changed now fail.
>
> The `XFAIL: with_system_cxx_lib` lines don't have any effect on my system - 
> these tests get invoked as expected by lit. Let me know if there's anything 
> else I can do to help you.


That's surprising.  Seems like something is different on OS X.
Could you try compiling/running this small program?

  #include 
  #include 
  
  int main() {
std::locale x("en_US.UTF-8");
std::cout << x.name() << std::endl;
  }

If it prints "en_US.UTF-8", then I'm out of ideas... :)


Repository:
  rL LLVM

https://reviews.llvm.org/D25811



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


[PATCH] D26218: [clang-tidy] Ignore notes along with a warning when processing NOLINT

2016-11-02 Thread Malcolm Parsons via cfe-commits
malcolm.parsons accepted this revision.
malcolm.parsons added a comment.
This revision is now accepted and ready to land.

LGTM, with typo below fixed.




Comment at: test/clang-tidy/nolint.cpp:36
+}
+// CHECK-NOT: header.h:{{.*}} warning: The left operand of '>' is a garbage 
value
+// CHECK-NOT: :[[@LINE-4]]:{{.*}} note

Is header.h supposed to be trigger_warning.h?


https://reviews.llvm.org/D26218



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


[PATCH] D25204: Register Calling Convention, Clang changes

2016-11-02 Thread Reid Kleckner via cfe-commits
rnk accepted this revision.
rnk added a reviewer: rnk.
rnk added a comment.
This revision is now accepted and ready to land.

Looks good to me.


https://reviews.llvm.org/D25204



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


[PATCH] D26082: Support for Python 3 in libclang python bindings

2016-11-02 Thread Michał Górny via cfe-commits
mgorny added a comment.

A few comments/questions. However, please note that those are generic Python 
comments and I haven't used or tested the clang Python API yet.




Comment at: bindings/python/clang/cindex.py:77
+# Python 3 strings are unicode, translate them to/from utf8 for C-interop
+if type(u"") == str:
+class c_string_p(c_char_p):

What is the Python3 version you're aiming to support? If I recall correctly, 
`u""` is allowed (again) since 3.4. And even then, the condition looks weird 
and makes me think a while before I figure out what it's supposed to mean.



Comment at: bindings/python/clang/cindex.py:518
 
-for i in xrange(0, count):
+for i in range(0, count):
 token = Token()

compnerd wrote:
> IIRC, `range` and `xrange` did have some performance difference.  This would 
> slow down the bindings on python 2.  The difference is obviously not 
> immediately visible unless count is very high.  I wonder if we can do 
> anything here to detect the python version and dispatch to `xrange` in python 
> 2.
The difference is that `range()` used to construct a complete list in Python 2. 
In Python 3, `xrange()` (that uses iterator) got renamed to `range()`.

If you want to avoid performance impact (not sure if it's really measurable 
here), you can do something alike C for loop:

i = 0
while i < count:
#...
i += 1

It's not really idiomatic Python though. OTOH, it won't take more lines than 
the conditional.



Comment at: bindings/python/clang/cindex.py:623
 """Return all CursorKind enumeration instances."""
-return filter(None, CursorKind._kinds)
+return [x for x in CursorKind._kinds if x]
 

Why are you changing this? The old version seems to be correct for Python3.



Comment at: bindings/python/clang/cindex.py:2371
 
+
 def __repr__(self):

Seems to be mistakenly added.



Comment at: bindings/python/clang/cindex.py:2573
 if len(args) > 0:
-args_array = (c_char_p * len(args))(* args)
+args_array = (c_string_p * len(args))()
+for i,a in enumerate(args):

I may be wrong but I think you could use a list comprehension here.

args_array = (c_string_p * len(args))([c_string_p(x) for x in args])

You can also try without `[]` to avoid the overhead of constructing list, if 
the function can take an iterator.



Comment at: bindings/python/tests/cindex/test_translation_unit.py:62
 def test_unsaved_files_2():
-import StringIO
+try:
+from StringIO import StringIO

Could you try inverting this? Python 2.7 already has `io.StringIO`, so that 
branch is much more likely to work.


https://reviews.llvm.org/D26082



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


[PATCH] D14274: Add alloc_size attribute to clang

2016-11-02 Thread George Burgess IV via cfe-commits
george.burgess.iv added a comment.

With any luck, this'll be on the top of my to-do list next week. :)


https://reviews.llvm.org/D14274



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


[PATCH] D25811: [libcxx] Fix toupper/tolower tests for UTF-8 locale

2016-11-02 Thread Alex Lorenz via cfe-commits
arphaman added a comment.

I've tested this patch on OS X and these 4 tests that you've changed now fail.

The `XFAIL: with_system_cxx_lib` lines don't have any effect on my system - 
these tests get invoked as expected by lit. Let me know if there's anything 
else I can do to help you.


Repository:
  rL LLVM

https://reviews.llvm.org/D25811



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


[PATCH] D26118: [clang-tidy] Change readability-redundant-member-init to get base type from constructor

2016-11-02 Thread Malcolm Parsons via cfe-commits
malcolm.parsons added inline comments.



Comment at: clang-tidy/readability/RedundantMemberInitCheck.cpp:57
"initializer for base class %0 is redundant")
-  << Init->getTypeSourceInfo()->getType()
+  << Construct->getType()
   << FixItHint::CreateRemoval(Init->getSourceRange());

aaron.ballman wrote:
> malcolm.parsons wrote:
> > aaron.ballman wrote:
> > > Why is it more correct to use the CXXConstructExpr type information 
> > > rather than the CXXCtorInitializer?
> > Something to do with templates and namespaces.
> > 
> > In the bug report, `CXXCtorInitializer` had type `std::__1::bitset<128>` 
> > and `CXXConstructExpr` had type `std::bitset`.
> > 
> > I don't know why.
> I believe it's because `__1` is an inline namespace, and the printing policy 
> matters. IIRC, there's the `SuppressUnwrittenScope` policy data member, that 
> if you set it to true, it won't print the inline or anonymous namespace when 
> printing types.
> 
> We should understand why there's a difference before applying this change. I 
> think using the CXXCtorInitializer's type is more correct than using the 
> CXXConstructExpr's type (due to implicit type conversions). Given that the 
> printing policy controls whether inline namespaces are printed, I would have 
> expected these both to print without the inline namespace (the type changed, 
> but not the printing policy) -- the fact that the behavior differs makes me 
> worried there's a bug somewhere else and this fix is masking it.
The difference isn't just the scope; `MAX_SUBTARGET_FEATURES` became `128` too.

Looking at `Sema::BuildMemInitializer()` didn't help me.


Repository:
  rL LLVM

https://reviews.llvm.org/D26118



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


[PATCH] D26138: [clang-tidy] Add modernize-use-equals-delete check

2016-11-02 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tidy/modernize/UseEqualsDeleteCheck.cpp:58
+  << FixItHint::CreateInsertion(StartLoc, "public: ")
+  << FixItHint::CreateInsertion(AfterLoc, " private:");
+}

malcolm.parsons wrote:
> aaron.ballman wrote:
> > I am on the fence about this fixit. On the one hand, the fix is a technical 
> > improvement because it means that implementations will consistently find 
> > the declaration and bark about it being explicitly deleted. On the other 
> > hand, the fixit suggests code that should never pass a reasonable code 
> > review.
> > 
> > I'm wondering if it would make more sense to leave the access specifiers 
> > alone and just put a FIXME in the code to point the situation out. I am 
> > guessing that at some point we will have a refactoring tool that can help 
> > without resorting to making declarations like `public: C() = delete; 
> > private:`.
> > 
> > What do you think?
> I'm wondering whether no fixit would be better than a not-good-enough fixit.
Generally, no. Incremental improvements are almost always fine. However, the 
user is asking to have their code modernized, and the fixit results in code 
that looks more foreign than modern (at least, to me).

I won't block the patch moving forward regardless of whether the fixit is in or 
out, but I am curious if @alexfh has an opinion, or if you have a strong 
preference one way or the other.


https://reviews.llvm.org/D26138



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


[PATCH] D25940: [analyzer] LibraryFunctions: Fix errors due to different integral types and typedefs on different architectures.

2016-11-02 Thread Artem Dergachev via cfe-commits
NoQ updated this revision to Diff 76731.
NoQ added a comment.

Comment up on variants.


https://reviews.llvm.org/D25940

Files:
  lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
  test/Analysis/std-c-library-functions.c

Index: test/Analysis/std-c-library-functions.c
===
--- test/Analysis/std-c-library-functions.c
+++ test/Analysis/std-c-library-functions.c
@@ -27,7 +27,7 @@
 }
 
 
-typedef unsigned long size_t;
+typedef typeof(sizeof(int)) size_t;
 typedef signed long ssize_t;
 ssize_t read(int, void *, size_t);
 ssize_t write(int, const void *, size_t);
Index: lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
+++ lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
@@ -194,9 +194,16 @@
 bool matchesCall(const CallExpr *CE) const;
   };
 
+  // The same function (as in, function identifier) may have different
+  // summaries assigned to it, with different argument and return value types.
+  // We call these "variants" of the function. This can be useful for handling
+  // C++ function overloads, and also it can be used when the same function
+  // may have different definitions on different platforms.
+  typedef std::vector FunctionVariantsTy;
+
   // The map of all functions supported by the checker. It is initialized
   // lazily, and it doesn't change after initialization.
-  typedef llvm::StringMap FunctionSummaryMapTy;
+  typedef llvm::StringMap FunctionSummaryMapTy;
   mutable FunctionSummaryMapTy FunctionSummaryMap;
 
   // Auxiliary functions to support ArgNoTy within all structures
@@ -446,11 +453,12 @@
   // Strict checking is important because we will be conducting
   // very integral-type-sensitive operations on arguments and
   // return values.
-  const FunctionSummaryTy &Spec = FSMI->second;
-  if (!Spec.matchesCall(CE))
-return None;
+  const FunctionVariantsTy &SpecVariants = FSMI->second;
+  for (const FunctionSummaryTy &Spec : SpecVariants)
+if (Spec.matchesCall(CE))
+  return Spec;
 
-  return Spec;
+  return None;
 }
 
 void StdLibraryFunctionsChecker::initFunctionSummaries(
@@ -462,17 +470,20 @@
 
   // These types are useful for writing specifications quickly,
   // New specifications should probably introduce more types.
+  // Some types are hard to obtain from the AST, eg. "ssize_t".
+  // In such cases it should be possible to provide multiple variants
+  // of function summary for common cases (eg. ssize_t could be int or long
+  // or long long, so three summary variants would be enough).
+  // Of course, function variants are also useful for C++ overloads.
   QualType Irrelevant; // A placeholder, whenever we do not care about the type.
   QualType IntTy = ACtx.IntTy;
+  QualType LongTy = ACtx.LongTy;
+  QualType LongLongTy = ACtx.LongLongTy;
   QualType SizeTy = ACtx.getSizeType();
-  QualType SSizeTy = ACtx.getIntTypeForBitwidth(ACtx.getTypeSize(SizeTy), true);
 
-  // Don't worry about truncation here, it'd be cast back to SIZE_MAX when used.
-  RangeIntTy SizeMax =
-  BVF.getMaxValue(SizeTy).getLimitedValue();
-  RangeIntTy SSizeMax =
-BVF.getMaxValue(SSizeTy).getLimitedValue();
-  (void)SizeMax; // Unused.
+  RangeIntTy IntMax = BVF.getMaxValue(IntTy).getLimitedValue();
+  RangeIntTy LongMax = BVF.getMaxValue(LongTy).getLimitedValue();
+  RangeIntTy LongLongMax = BVF.getMaxValue(LongLongTy).getLimitedValue();
 
   // We are finally ready to define specifications for all supported functions.
   //
@@ -515,17 +526,22 @@
   //  }
   //}
 
+#define SUMMARY_WITH_VARIANTS(identifier) {#identifier, {
+#define END_SUMMARY_WITH_VARIANTS }},
+#define VARIANT(argument_types, return_type, invalidation_approach)\
+  { argument_types, return_type, invalidation_approach, {
+#define END_VARIANT } },
 #define SUMMARY(identifier, argument_types, return_type,   \
 invalidation_approach) \
-  {#identifier, {argument_types, return_type, invalidation_approach, {
-#define END_SUMMARY }}},
+  { #identifier, { { argument_types, return_type, invalidation_approach, {
+#define END_SUMMARY } } } },
 #define ARGUMENT_TYPES(...) { __VA_ARGS__ }
 #define RETURN_TYPE(x) x
 #define INVALIDATION_APPROACH(x) x
 #define CASE {
 #define END_CASE },
 #define ARGUMENT_CONDITION(argument_number, condition_kind)\
-  {argument_number, condition_kind, {
+  { argument_number, condition_kind, {
 #define END_ARGUMENT_CONDITION }},
 #define RETURN_VALUE_CONDITION(condition_kind) \
   { Ret, condition_kind, {
@@ -875,28 +891,80 @@
 END_SUMMARY
 
 // read()-like functions that never return more than buffer size.
-SUMMARY(read, ARGUMENT_TYPES(Irrelevant, Irrelevant, SizeTy),
-RETURN_TYPE(SSizeTy), INVALIDATION_APPROACH(

[PATCH] D26138: [clang-tidy] Add modernize-use-equals-delete check

2016-11-02 Thread Malcolm Parsons via cfe-commits
malcolm.parsons added inline comments.



Comment at: clang-tidy/modernize/UseEqualsDeleteCheck.cpp:58
+  << FixItHint::CreateInsertion(StartLoc, "public: ")
+  << FixItHint::CreateInsertion(AfterLoc, " private:");
+}

aaron.ballman wrote:
> I am on the fence about this fixit. On the one hand, the fix is a technical 
> improvement because it means that implementations will consistently find the 
> declaration and bark about it being explicitly deleted. On the other hand, 
> the fixit suggests code that should never pass a reasonable code review.
> 
> I'm wondering if it would make more sense to leave the access specifiers 
> alone and just put a FIXME in the code to point the situation out. I am 
> guessing that at some point we will have a refactoring tool that can help 
> without resorting to making declarations like `public: C() = delete; 
> private:`.
> 
> What do you think?
I'm wondering whether no fixit would be better than a not-good-enough fixit.


https://reviews.llvm.org/D26138



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


[PATCH] D26118: [clang-tidy] Change readability-redundant-member-init to get base type from constructor

2016-11-02 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tidy/readability/RedundantMemberInitCheck.cpp:57
"initializer for base class %0 is redundant")
-  << Init->getTypeSourceInfo()->getType()
+  << Construct->getType()
   << FixItHint::CreateRemoval(Init->getSourceRange());

malcolm.parsons wrote:
> aaron.ballman wrote:
> > Why is it more correct to use the CXXConstructExpr type information rather 
> > than the CXXCtorInitializer?
> Something to do with templates and namespaces.
> 
> In the bug report, `CXXCtorInitializer` had type `std::__1::bitset<128>` and 
> `CXXConstructExpr` had type `std::bitset`.
> 
> I don't know why.
I believe it's because `__1` is an inline namespace, and the printing policy 
matters. IIRC, there's the `SuppressUnwrittenScope` policy data member, that if 
you set it to true, it won't print the inline or anonymous namespace when 
printing types.

We should understand why there's a difference before applying this change. I 
think using the CXXCtorInitializer's type is more correct than using the 
CXXConstructExpr's type (due to implicit type conversions). Given that the 
printing policy controls whether inline namespaces are printed, I would have 
expected these both to print without the inline namespace (the type changed, 
but not the printing policy) -- the fact that the behavior differs makes me 
worried there's a bug somewhere else and this fix is masking it.


Repository:
  rL LLVM

https://reviews.llvm.org/D26118



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


[PATCH] D26082: Support for Python 3 in libclang python bindings

2016-11-02 Thread Saleem Abdulrasool via cfe-commits
compnerd accepted this revision.
compnerd added a comment.
This revision is now accepted and ready to land.

It would be nice if there is a simple way to handle the possible performance 
impact for python 2.  Worst case, we can deal with it when it becomes an issue.




Comment at: bindings/python/clang/cindex.py:518
 
-for i in xrange(0, count):
+for i in range(0, count):
 token = Token()

IIRC, `range` and `xrange` did have some performance difference.  This would 
slow down the bindings on python 2.  The difference is obviously not 
immediately visible unless count is very high.  I wonder if we can do anything 
here to detect the python version and dispatch to `xrange` in python 2.


https://reviews.llvm.org/D26082



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


[PATCH] D26138: [clang-tidy] Add modernize-use-equals-delete check

2016-11-02 Thread Malcolm Parsons via cfe-commits
malcolm.parsons updated this revision to Diff 76729.
malcolm.parsons added a comment.

Take out renaming of modernize-use-default.


https://reviews.llvm.org/D26138

Files:
  clang-tidy/modernize/CMakeLists.txt
  clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tidy/modernize/UseEqualsDeleteCheck.cpp
  clang-tidy/modernize/UseEqualsDeleteCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/modernize-use-default.rst
  docs/clang-tidy/checks/modernize-use-equals-delete.rst
  test/clang-tidy/modernize-use-equals-delete.cpp

Index: test/clang-tidy/modernize-use-equals-delete.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-use-equals-delete.cpp
@@ -0,0 +1,122 @@
+// RUN: %check_clang_tidy %s modernize-use-equals-delete %t
+
+struct PositivePrivate {
+private:
+  PositivePrivate();
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= delete' to prohibit calling of a special member function [modernize-use-equals-delete]
+  // CHECK-FIXES: public: PositivePrivate() = delete; private:
+  PositivePrivate(const PositivePrivate &);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= delete' to prohibit calling of a special member function [modernize-use-equals-delete]
+  // CHECK-FIXES: public: PositivePrivate(const PositivePrivate &) = delete; private:
+  PositivePrivate &operator=(const PositivePrivate &);
+  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: use '= delete' to prohibit calling of a special member function [modernize-use-equals-delete]
+  // CHECK-FIXES: public: PositivePrivate &operator=(const PositivePrivate &) = delete; private:
+  PositivePrivate(PositivePrivate &&);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= delete' to prohibit calling of a special member function [modernize-use-equals-delete]
+  // CHECK-FIXES: public: PositivePrivate(PositivePrivate &&) = delete; private:
+  PositivePrivate &operator=(PositivePrivate &&);
+  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: use '= delete' to prohibit calling of a special member function [modernize-use-equals-delete]
+  // CHECK-FIXES: public: PositivePrivate &operator=(PositivePrivate &&) = delete; private:
+  ~PositivePrivate();
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= delete' to prohibit calling of a special member function [modernize-use-equals-delete]
+  // CHECK-FIXES: public: ~PositivePrivate() = delete; private:
+};
+
+struct NegativePublic {
+  NegativePublic(const NegativePublic &);
+};
+
+struct NegativeProtected {
+protected:
+  NegativeProtected(const NegativeProtected &);
+};
+
+struct PositiveInlineMember {
+  int foo() { return 0; }
+
+private:
+  PositiveInlineMember(const PositiveInlineMember &);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= delete' to prohibit calling of a special member function [modernize-use-equals-delete]
+  // CHECK-FIXES: public: PositiveInlineMember(const PositiveInlineMember &) = delete; private:
+};
+
+struct PositiveOutOfLineMember {
+  int foo();
+
+private:
+  PositiveOutOfLineMember(const PositiveOutOfLineMember &);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= delete' to prohibit calling of a special member function [modernize-use-equals-delete]
+  // CHECK-FIXES: public: PositiveOutOfLineMember(const PositiveOutOfLineMember &) = delete; private:
+};
+
+int PositiveOutOfLineMember::foo() { return 0; }
+
+struct PositiveAbstractMember {
+  virtual int foo() = 0;
+
+private:
+  PositiveAbstractMember(const PositiveAbstractMember &);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= delete' to prohibit calling of a special member function [modernize-use-equals-delete]
+  // CHECK-FIXES: public: PositiveAbstractMember(const PositiveAbstractMember &) = delete; private:
+};
+
+struct NegativeMemberNotImpl {
+  int foo();
+
+private:
+  NegativeMemberNotImpl(const NegativeMemberNotImpl &);
+};
+
+struct NegativeStaticMemberNotImpl {
+  static int foo();
+
+private:
+  NegativeStaticMemberNotImpl(const NegativeStaticMemberNotImpl &);
+};
+
+struct NegativeInline {
+private:
+  NegativeInline(const NegativeInline &) {}
+};
+
+struct NegativeOutOfLine {
+private:
+  NegativeOutOfLine(const NegativeOutOfLine &);
+};
+
+NegativeOutOfLine::NegativeOutOfLine(const NegativeOutOfLine &) {}
+
+struct NegativeConstructNotImpl {
+  NegativeConstructNotImpl();
+
+private:
+  NegativeConstructNotImpl(const NegativeConstructNotImpl &);
+};
+
+struct PositiveDefaultedConstruct {
+  PositiveDefaultedConstruct() = default;
+
+private:
+  PositiveDefaultedConstruct(const PositiveDefaultedConstruct &);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= delete' to prohibit calling of a special member function [modernize-use-equals-delete]
+  // CHECK-FIXES: public: PositiveDefaultedConstruct(const PositiveDefaultedConstruct &) = delete; private:
+};
+
+struct PositiveDeletedConstruct {
+  PositiveDeletedConstruct() = delete;
+
+private:
+  PositiveDeletedConstruct(const Positi

[PATCH] D26041: [clang-tidy] Extend misc-use-after-move to support unique_ptr and shared_ptr.

2016-11-02 Thread Aaron Ballman via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.

LGTM, thank you!


https://reviews.llvm.org/D26041



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


[libunwind] r285831 - Add conditions for PPC to libunwind. Fixes PR22200. Thanks to Jeremy for the bug report and the patch.

2016-11-02 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Wed Nov  2 11:39:55 2016
New Revision: 285831

URL: http://llvm.org/viewvc/llvm-project?rev=285831&view=rev
Log:
Add conditions for PPC to libunwind. Fixes PR22200. Thanks to Jeremy for the 
bug report and the patch.

Modified:
libunwind/trunk/src/config.h

Modified: libunwind/trunk/src/config.h
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/config.h?rev=285831&r1=285830&r2=285831&view=diff
==
--- libunwind/trunk/src/config.h (original)
+++ libunwind/trunk/src/config.h Wed Nov  2 11:39:55 2016
@@ -62,13 +62,14 @@
 #define _LIBUNWIND_BUILD_SJLJ_APIS 0
 #endif
 
-#if defined(__i386__) || defined(__x86_64__)
+#if defined(__i386__) || defined(__x86_64__) || defined(__ppc__) || 
defined(__ppc64__)
 #define _LIBUNWIND_SUPPORT_FRAME_APIS 1
 #else
 #define _LIBUNWIND_SUPPORT_FRAME_APIS 0
 #endif
 
 #if defined(__i386__) || defined(__x86_64__) ||
\
+defined(__ppc__) || defined(__ppc64__) ||  
\
 (!defined(__APPLE__) && defined(__arm__)) ||   
\
 (defined(__arm64__) || defined(__aarch64__)) ||
\
 (defined(__APPLE__) && defined(__mips__))


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


[PATCH] D26195: Ignore incomplete types when determining whether they are expensive to copy

2016-11-02 Thread Aaron Ballman via cfe-commits
aaron.ballman added a comment.

In https://reviews.llvm.org/D26195#585198, @flx wrote:

> In https://reviews.llvm.org/D26195#585091, @aaron.ballman wrote:
>
> > In https://reviews.llvm.org/D26195#584958, @flx wrote:
> >
> > > In https://reviews.llvm.org/D26195#584730, @aaron.ballman wrote:
> > >
> > > > In https://reviews.llvm.org/D26195#584724, @flx wrote:
> > > >
> > > > > In https://reviews.llvm.org/D26195#584712, @aaron.ballman wrote:
> > > > >
> > > > > > Please add a test case with an incomplete type that would exercise 
> > > > > > this code path, otherwise, LGTM.
> > > > >
> > > > >
> > > > > Hi Aaron,
> > > > >
> > > > > do you have any advise on how to add an incomplete type? When 
> > > > > debugging this I had a compilation unit that failed to compile 
> > > > > causing it, but I'm not sure this is a good way to add a test case.
> > > >
> > > >
> > > > A type like `class C;` is an incomplete type, as is `void`, so perhaps 
> > > > you can find a check that would let such a construct call through to 
> > > > `isExpensiveToCopy()`.
> > >
> > >
> > > Great, this works and I was able to see the check produce a false 
> > > positive without the proposed change here, but the test code introduces a 
> > > compile error now due to the incomplete type used in the function 
> > > definition. Is there a way to suppress that?
> >
> >
> > Unlikely -- fixing the compile error likely makes the type not expensive to 
> > copy by using a pointer (or reference). This may be tricky to test because 
> > the times when you would call `isExpensiveToCopy()` is with types that are 
> > going to be logically required to be complete. I am not certain the compile 
> > error is actually a problem though -- I would imagine your existing 
> > false-positives (that you mentioned in the patch summary) are cases where 
> > there is a compile error *and* a clang-tidy diagnostic, so the test may 
> > simply be "check that there's only a compile error and no clang-tidy 
> > diagnostic where there used to be a false-positive one."
>
>
> That's exactly the case, my question here is how can I make the test succeed 
> in the face of a compile error, i.e. by expecting the error as well?


Doesn't `// CHECK-MESSAGES: :[[@LINE-1]]:3: error: blah blah blah` work?


Repository:
  rL LLVM

https://reviews.llvm.org/D26195



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


[PATCH] D26207: [ClangTidy - performance-unnecessary-value-param] Only add "const" when current parameter is not already const qualified

2016-11-02 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tidy/performance/UnnecessaryValueParamCheck.cpp:131
*Result.Context);
-if (!IsConstQualified)
+if (!CurrentParam.getType().getCanonicalType().isConstQualified())
   Diag << utils::fixit::changeVarDeclToConst(CurrentParam);

You should add a comment here explaining why you need something more complex 
than `IsConstQualified`.



Comment at: test/clang-tidy/performance-unnecessary-value-param.cpp:242
+// Case where parameter in declaration is already const-qualified but not in
+// implementation. Make sure a second 'const' is not added to the declaration.
+void PositiveConstDeclaration(const ExpensiveToCopyType A);

flx wrote:
> aaron.ballman wrote:
> > This comment doesn't really match the test cases. The original code has two 
> > *different* declarations (only one of which is a definition), not one 
> > declaration and one redeclaration with the definition.
> > 
> > I think what is really happening is that it is adding the `&` qualifier to 
> > the first declaration, and adding the `const` and `&` qualifiers to the 
> > second declaration, and the result is that you get harmonization. But it 
> > brings up a question to me; what happens with:
> > ```
> > void f1(ExpensiveToCopyType A) {
> > }
> > 
> > void f1(const ExpensiveToCopyType A) {
> > 
> > }
> > ```
> > Does the fix-it try to create two definitions of the same function?
> Good catch. I added the reverse case as well and modified the check slightly 
> to make that case work as well.
Can you add a test like this as well?
```
void f1(ExpensiveToCopyType A); // Declared, not defined

void f1(const ExpensiveToCopyType A) {}
void f1(const ExpensiveToCopyType &A) {}
```
I'm trying to make sure this check does not suggest a fixit that breaks 
existing code because of overload sets. I would expect a diagnostic for the 
first two declarations, but no fixit suggestion for `void f1(const 
ExpensiveToCopyType A)` because that would result in an ambiguous function 
definition.


Repository:
  rL LLVM

https://reviews.llvm.org/D26207



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


Re: r285543 - Make output of ast-print closer to C++ code

2016-11-02 Thread Richard Smith via cfe-commits
Test?

On 30 Oct 2016 10:20 pm, "Serge Pavlov via cfe-commits" <
cfe-commits@lists.llvm.org> wrote:

> Author: sepavloff
> Date: Mon Oct 31 00:11:12 2016
> New Revision: 285543
>
> URL: http://llvm.org/viewvc/llvm-project?rev=285543&view=rev
> Log:
> Make output of ast-print closer to C++ code
>
> Put semicolon after non-defining method declaration and a class
> specialization body.
>
> Modified:
> cfe/trunk/lib/AST/DeclPrinter.cpp
>
> Modified: cfe/trunk/lib/AST/DeclPrinter.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/
> DeclPrinter.cpp?rev=285543&r1=285542&r2=285543&view=diff
> 
> ==
> --- cfe/trunk/lib/AST/DeclPrinter.cpp (original)
> +++ cfe/trunk/lib/AST/DeclPrinter.cpp Mon Oct 31 00:11:12 2016
> @@ -337,10 +337,9 @@ void DeclPrinter::VisitDeclContext(DeclC
>  const char *Terminator = nullptr;
>  if (isa(*D) || isa(*
> D))
>Terminator = nullptr;
> -else if (isa(*D) &&
> - cast(*D)->isThisDeclarationADefinition())
> +else if (isa(*D) && cast(*D)->hasBody())
>Terminator = nullptr;
> -else if (isa(*D) && cast(*D)->
> getBody())
> +else if (isa(*D) && cast(*D)->
> hasBody())
>Terminator = nullptr;
>  else if (isa(*D) || isa(*D) ||
>   isa(*D) ||
> @@ -984,7 +983,7 @@ void DeclPrinter::VisitClassTemplateDecl
>  for (auto *I : D->specializations()) {
>PrintTemplateParameters(Params, &I->getTemplateArgs());
>Visit(I);
> -  Out << '\n';
> +  Out << ";\n";
>  }
>}
>
>
>
> ___
> 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


[PATCH] D26138: [clang-tidy] Add modernize-use-equals-delete check

2016-11-02 Thread Aaron Ballman via cfe-commits
aaron.ballman added a comment.

Can you split the modernize-use-default changes into a separate patch? I think 
that change requires additional discussion, because renaming the check may 
break users relying on the old name. The changes aren't really related (aside 
from naming consistency), and I'd rather not let modernize-use-default 
discussion delay accepting this patch.




Comment at: clang-tidy/modernize/UseEqualsDeleteCheck.cpp:58
+  << FixItHint::CreateInsertion(StartLoc, "public: ")
+  << FixItHint::CreateInsertion(AfterLoc, " private:");
+}

I am on the fence about this fixit. On the one hand, the fix is a technical 
improvement because it means that implementations will consistently find the 
declaration and bark about it being explicitly deleted. On the other hand, the 
fixit suggests code that should never pass a reasonable code review.

I'm wondering if it would make more sense to leave the access specifiers alone 
and just put a FIXME in the code to point the situation out. I am guessing that 
at some point we will have a refactoring tool that can help without resorting 
to making declarations like `public: C() = delete; private:`.

What do you think?


https://reviews.llvm.org/D26138



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


[PATCH] D14274: Add alloc_size attribute to clang

2016-11-02 Thread Hal Finkel via cfe-commits
hfinkel added a comment.

What's the status of this?


https://reviews.llvm.org/D14274



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


Re: r285289 - [Sema] -Wunused-variable warning for array variables should behave

2016-11-02 Thread Alex L via cfe-commits
On 1 November 2016 at 14:22, David Blaikie  wrote:

>
>
> On Tue, Nov 1, 2016 at 3:13 AM Alex L  wrote:
>
>> On 31 October 2016 at 15:34, David Blaikie  wrote:
>>
>>
>>
>> On Thu, Oct 27, 2016 at 6:40 AM Alex Lorenz via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>> Author: arphaman
>> Date: Thu Oct 27 08:30:51 2016
>> New Revision: 285289
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=285289&view=rev
>> Log:
>> [Sema] -Wunused-variable warning for array variables should behave
>> similarly to scalar variables.
>>
>> This commit makes the -Wunused-variable warning behaviour more consistent:
>> Now clang won't warn for array variables where it doesn't warn for scalar
>> variables.
>>
>> rdar://24158862
>>
>> Differential Revision: https://reviews.llvm.org/D25937
>>
>> Modified:
>> cfe/trunk/lib/Sema/SemaDecl.cpp
>> cfe/trunk/test/SemaCXX/warn-everthing.cpp
>> cfe/trunk/test/SemaCXX/warn-unused-variables.cpp
>>
>> Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaD
>> ecl.cpp?rev=285289&r1=285288&r2=285289&view=diff
>> 
>> ==
>> --- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
>> +++ cfe/trunk/lib/Sema/SemaDecl.cpp Thu Oct 27 08:30:51 2016
>> @@ -1522,7 +1522,7 @@ static bool ShouldDiagnoseUnusedDecl(con
>>if (const VarDecl *VD = dyn_cast(D)) {
>>
>>  // White-list anything with an __attribute__((unused)) type.
>> -QualType Ty = VD->getType();
>> +const auto *Ty = VD->getType().getTypePtr();
>>
>>  // Only look at the outermost level of typedef.
>>  if (const TypedefType *TT = Ty->getAs()) {
>> @@ -1535,6 +1535,10 @@ static bool ShouldDiagnoseUnusedDecl(con
>>  if (Ty->isIncompleteType() || Ty->isDependentType())
>>return false;
>>
>> +// Look at the element type to ensure that the warning behaviour is
>> +// consistent for both scalars and arrays.
>> +Ty = Ty->getBaseElementTypeUnsafe();
>> +
>>  if (const TagType *TT = Ty->getAs()) {
>>const TagDecl *Tag = TT->getDecl();
>>if (Tag->hasAttr())
>>
>> Modified: cfe/trunk/test/SemaCXX/warn-everthing.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/
>> warn-everthing.cpp?rev=285289&r1=285288&r2=285289&view=diff
>> 
>> ==
>> --- cfe/trunk/test/SemaCXX/warn-everthing.cpp (original)
>> +++ cfe/trunk/test/SemaCXX/warn-everthing.cpp Thu Oct 27 08:30:51 2016
>> @@ -9,5 +9,5 @@ public:
>>  };
>>
>>  void testPR12271() { // expected-warning {{no previous prototype for
>> function 'testPR12271'}}
>> -  PR12271 a[1][1]; // expected-warning {{unused variable 'a'}}
>> +  PR12271 a[1][1];
>>  }
>>
>> Modified: cfe/trunk/test/SemaCXX/warn-unused-variables.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/
>> warn-unused-variables.cpp?rev=285289&r1=285288&r2=285289&view=diff
>> 
>> ==
>> --- cfe/trunk/test/SemaCXX/warn-unused-variables.cpp (original)
>> +++ cfe/trunk/test/SemaCXX/warn-unused-variables.cpp Thu Oct 27 08:30:51
>> 2016
>> @@ -150,3 +150,54 @@ namespace ctor_with_cleanups {
>>  }
>>
>>  #include "Inputs/warn-unused-variables.h"
>> +
>> +namespace arrayRecords {
>> +
>> +int total = 0;
>> +
>> +class Adder {
>>
>>
>> Presumably this class could be a bit simpler - is it just about having a
>> non-trivial ctor? or non-trivial dtor?
>>
>> It'd be helpful to make the test as simple as possible to show what
>> features are important to the diagnostic - rather than making the test look
>> like real code by having functionality that's not required for testing.
>>
>> (eg: you don't have to implement functions here - the code will not be
>> linked or executed, just compiled for warnings in the test suite)
>>
>> Potentially name the class by its purpose:
>>
>> struct NonTriviallyDestructible {
>>   ~NonTriviallyDestructible();
>> };
>>
>> and similar.
>>
>>
>> Thanks for looking at this commit!
>> You're right about this particular class, it can be simpler, since it's
>> testing a non-trivial door. When I started working on this patch I used the
>> code from the bug report to reproduce this issue in the test case, and
>> didn't simplify it further when I found out the cause.
>>
>
> *nod* no worries - it's certainly not uncommon
>
>
>>
>>
>>
>> (is it important that Adder and Foo are constructed with arguments/have
>> ctor parameters? It's not clear to me from the test or code whether that's
>> the case)
>>
>>
>> No. Do you think I should simplify this test case in a separate commit?
>>
>
> That'd be great if you could simplify it down to what seems to be the
> essentials!
>

Thanks, I simplified it in r285825.

Alex


> - Dave
>
>
>>
>> Cheers,
>> Alex
>>
>>
>>
>>
>> +public:
>> +  Adder(int x); // out of line below
>> +  ~Adder() {}
>> +};
>> +
>> +Adder::Ad

r285825 - Simplify the test case from r285289.

2016-11-02 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Wed Nov  2 11:11:30 2016
New Revision: 285825

URL: http://llvm.org/viewvc/llvm-project?rev=285825&view=rev
Log:
Simplify the test case from r285289.

This commit simplifies and clarifies the test code
that was added in r285289. 

Suggested by David Blaikie.

Modified:
cfe/trunk/test/SemaCXX/warn-unused-variables.cpp

Modified: cfe/trunk/test/SemaCXX/warn-unused-variables.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-unused-variables.cpp?rev=285825&r1=285824&r2=285825&view=diff
==
--- cfe/trunk/test/SemaCXX/warn-unused-variables.cpp (original)
+++ cfe/trunk/test/SemaCXX/warn-unused-variables.cpp Wed Nov  2 11:11:30 2016
@@ -153,36 +153,29 @@ namespace ctor_with_cleanups {
 
 namespace arrayRecords {
 
-int total = 0;
-
-class Adder {
+class NonTriviallyDestructible {
 public:
-  Adder(int x); // out of line below
-  ~Adder() {}
+  ~NonTriviallyDestructible() {}
 };
 
-Adder::Adder(int x) {
-  total += x;
-}
-
 struct Foo {
   int x;
   Foo(int x) : x(x) {}
 };
 
-struct S1 {
-  S1();
+struct Elidable {
+  Elidable();
 };
 
 void foo(int size) {
-  S1 y; // no warning
-  S1 yarray[2]; // no warning
-  S1 dynArray[size]; // no warning
-  S1 nestedArray[1][2][3]; // no warning
-
-  Adder scalerInFuncScope = 134; // no warning
-  Adder arrayInFuncScope[] = { 135, 136 };  // no warning
-  Adder nestedArrayInFuncScope[2][2] = { {1,2}, {3,4} }; // no warning
+  Elidable elidable; // no warning
+  Elidable elidableArray[2]; // no warning
+  Elidable elidableDynArray[size]; // no warning
+  Elidable elidableNestedArray[1][2][3]; // no warning
+
+  NonTriviallyDestructible scalar; // no warning
+  NonTriviallyDestructible array[2];  // no warning
+  NonTriviallyDestructible nestedArray[2][2]; // no warning
 
   Foo fooScalar = 1; // expected-warning {{unused variable 'fooScalar'}}
   Foo fooArray[] = {1,2}; // expected-warning {{unused variable 'fooArray'}}
@@ -191,8 +184,8 @@ void foo(int size) {
 
 template
 void bar() {
-  Adder scaler = 123; // no warning
-  Adder array[N] = {1,2}; // no warning
+  NonTriviallyDestructible scaler; // no warning
+  NonTriviallyDestructible array[N]; // no warning
 }
 
 void test() {


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


[PATCH] D25263: [Driver] Allow setting the default linker during build

2016-11-02 Thread Petr Hosek via cfe-commits
phosek updated this revision to Diff 76720.
phosek marked 3 inline comments as done.

Repository:
  rL LLVM

https://reviews.llvm.org/D25263

Files:
  CMakeLists.txt
  include/clang/Config/config.h.cmake
  include/clang/Driver/ToolChain.h
  lib/Driver/ToolChain.cpp
  lib/Driver/ToolChains.cpp
  lib/Driver/ToolChains.h

Index: lib/Driver/ToolChains.h
===
--- lib/Driver/ToolChains.h
+++ lib/Driver/ToolChains.h
@@ -926,6 +926,10 @@
  : RuntimeLibType::RLT_CompilerRT;
   }
 
+  const char *getDefaultLinker() const override {
+return "lld";
+  }
+
 private:
   Multilib SelectedMultilib;
   std::string LibSuffix;
@@ -1055,6 +1059,10 @@
   void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args,
llvm::opt::ArgStringList &CmdArgs) const override;
 
+  const char *getDefaultLinker() const override {
+return "lld";
+  }
+
 protected:
   Tool *buildAssembler() const override;
   Tool *buildLinker() const override;
@@ -1241,6 +1249,10 @@
   const llvm::opt::ArgList &DriverArgs,
   llvm::opt::ArgStringList &CC1Args) const override;
 
+  const char *getDefaultLinker() const override {
+return "lld";
+  }
+
   Tool *buildLinker() const override;
 };
 
Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -2976,9 +2976,6 @@
   LibSuffix = tools::mips::getMipsABILibSuffix(Args, Triple);
   getFilePaths().clear();
   getFilePaths().push_back(computeSysRoot() + "/usr/lib" + LibSuffix);
-
-  // Use LLD by default.
-  DefaultLinker = "lld";
 }
 
 void MipsLLVMToolChain::AddClangSystemIncludeArgs(
@@ -4842,9 +4839,6 @@
 
   getFilePaths().push_back(D.SysRoot + "/lib");
   getFilePaths().push_back(D.ResourceDir + "/lib/fuchsia");
-
-  // Use LLD by default.
-  DefaultLinker = "lld";
 }
 
 Tool *Fuchsia::buildAssembler() const {
@@ -5222,9 +5216,6 @@
   assert(Triple.isArch32Bit() != Triple.isArch64Bit());
   getFilePaths().push_back(
   getDriver().SysRoot + "/lib" + (Triple.isArch32Bit() ? "32" : "64"));
-
-  // Use LLD by default.
-  DefaultLinker = "lld";
 }
 
 bool WebAssembly::IsMathErrnoDefault() const { return false; }
Index: lib/Driver/ToolChain.cpp
===
--- lib/Driver/ToolChain.cpp
+++ lib/Driver/ToolChain.cpp
@@ -374,10 +374,9 @@
 }
 
 getDriver().Diag(diag::err_drv_invalid_linker_name) << A->getAsString(Args);
-return "";
   }
 
-  return GetProgramPath(DefaultLinker);
+  return GetProgramPath(getDefaultLinker());
 }
 
 types::ID ToolChain::LookupTypeForExtension(StringRef Ext) const {
@@ -719,3 +718,7 @@
 
 void ToolChain::AddIAMCUIncludeArgs(const ArgList &DriverArgs,
 ArgStringList &CC1Args) const {}
+
+const char *ToolChain::getDefaultLinker() const {
+  return CLANG_DEFAULT_LINKER;
+}
Index: include/clang/Driver/ToolChain.h
===
--- include/clang/Driver/ToolChain.h
+++ include/clang/Driver/ToolChain.h
@@ -104,7 +104,6 @@
 
 protected:
   MultilibSet Multilibs;
-  const char *DefaultLinker = "ld";
 
   ToolChain(const Driver &D, const llvm::Triple &T,
 const llvm::opt::ArgList &Args);
@@ -450,6 +449,8 @@
   /// \brief On Windows, returns the version of cl.exe.  On other platforms,
   /// returns an empty VersionTuple.
   virtual VersionTuple getMSVCVersionFromExe() const { return VersionTuple(); }
+
+  virtual const char *getDefaultLinker() const;
 };
 
 /// Set a ToolChain's effective triple. Reset it when the registration object
Index: include/clang/Config/config.h.cmake
===
--- include/clang/Config/config.h.cmake
+++ include/clang/Config/config.h.cmake
@@ -8,6 +8,9 @@
 /* Bug report URL. */
 #define BUG_REPORT_URL "${BUG_REPORT_URL}"
 
+/* Default linker to use. */
+#define CLANG_DEFAULT_LINKER "${CLANG_DEFAULT_LINKER}"
+
 /* Default C++ stdlib to use. */
 #define CLANG_DEFAULT_CXX_STDLIB "${CLANG_DEFAULT_CXX_STDLIB}"
 
Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -198,6 +198,9 @@
 set(ENABLE_X86_RELAX_RELOCATIONS OFF CACHE BOOL
 "enable x86 relax relocations by default")
 
+set(CLANG_DEFAULT_LINKER "" CACHE STRING
+  "Default linker to use (linker name or absolute path, empty for platform default)")
+
 set(CLANG_DEFAULT_CXX_STDLIB "" CACHE STRING
   "Default C++ stdlib to use (\"libstdc++\" or \"libc++\", empty for platform default")
 if (NOT(CLANG_DEFAULT_CXX_STDLIB STREQUAL "" OR
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r285625 - DebugInfo: support for DW_TAG_atomic_type

2016-11-02 Thread Adrian Prantl via cfe-commits
Ping?

> On Oct 31, 2016, at 12:41 PM, Adrian Prantl via cfe-commits 
>  wrote:
> 
>> 
>> On Oct 31, 2016, at 12:09 PM, Victor Leschuk via cfe-commits 
>>  wrote:
>> 
>> Author: vleschuk
>> Date: Mon Oct 31 14:09:47 2016
>> New Revision: 285625
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=285625&view=rev
>> Log:
>> DebugInfo: support for DW_TAG_atomic_type
>> 
>> Mark C11 _Atomic variables with DW_TAG_atomic_type tag.
>> 
>> Differential Revision: https://reviews.llvm.org/D26145
>> 
>> Added:
>>   cfe/trunk/test/CodeGen/debug-info-atomic.c
>> Modified:
>>   cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
>> 
>> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=285625&r1=285624&r2=285625&view=diff
>> ==
>> --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
>> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Mon Oct 31 14:09:47 2016
>> @@ -2287,9 +2287,8 @@ llvm::DIType *CGDebugInfo::CreateType(co
>> }
>> 
>> llvm::DIType *CGDebugInfo::CreateType(const AtomicType *Ty, llvm::DIFile *U) 
>> {
>> -  // Ignore the atomic wrapping
>> -  // FIXME: What is the correct representation?
>> -  return getOrCreateType(Ty->getValueType(), U);
>> +  auto *FromTy = getOrCreateType(Ty->getValueType(), U);
>> +  return DBuilder.createQualifiedType(llvm::dwarf::DW_TAG_atomic_type, 
>> FromTy);
>> }
>> 
>> llvm::DIType* CGDebugInfo::CreateType(const PipeType *Ty,
>> 
>> Added: cfe/trunk/test/CodeGen/debug-info-atomic.c
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/debug-info-atomic.c?rev=285625&view=auto
>> ==
>> --- cfe/trunk/test/CodeGen/debug-info-atomic.c (added)
>> +++ cfe/trunk/test/CodeGen/debug-info-atomic.c Mon Oct 31 14:09:47 2016
>> @@ -0,0 +1,7 @@
>> +// RUN: %clang -g -c -std=c11 -S -emit-llvm -o - %s | FileCheck %s
>> +
>> +// CHECK: !DIGlobalVariable(name: "i"{{.*}}type: !5, isLocal: false, 
>> isDefinition: true)
>> +// CHECK: !5 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !6)
>> +// CHECK: !6 = !DIDerivedType(tag: DW_TAG_atomic_type, baseType: !7)
>> +// CHECK: !7 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
> 
> Please use FileCheck variables like ![[TYPE:[0-9]+]] instead of hardcoding 
> the numbers. This is bound to break soon otherwise.
> 
> -- adrian
> 
>> +_Atomic const int i;
>> 
>> 
>> ___
>> 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 
> 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26218: [clang-tidy] Ignore notes along with a warning when processing NOLINT

2016-11-02 Thread Nikita Kakuev via cfe-commits
nkakuev added a reviewer: malcolm.parsons.
nkakuev updated this revision to Diff 76718.
nkakuev added a comment.

Fixed review comments: replaced a static variable with a class member.


https://reviews.llvm.org/D26218

Files:
  clang-tidy/ClangTidyDiagnosticConsumer.cpp
  clang-tidy/ClangTidyDiagnosticConsumer.h
  test/clang-tidy/Inputs/nolint/trigger_warning.h
  test/clang-tidy/nolint.cpp


Index: test/clang-tidy/nolint.cpp
===
--- test/clang-tidy/nolint.cpp
+++ test/clang-tidy/nolint.cpp
@@ -1,4 +1,5 @@
-// RUN: %check_clang_tidy %s 
google-explicit-constructor,clang-diagnostic-unused-variable %t -- 
-extra-arg=-Wunused-variable --
+// RUN: %check_clang_tidy %s 
google-explicit-constructor,clang-diagnostic-unused-variable,clang-analyzer-core.UndefinedBinaryOperatorResult
 %t -- -extra-arg=-Wunused-variable -- -I%S/Inputs/nolint
+
 
 class A { A(int i); };
 // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: single-argument constructors must 
be marked explicit
@@ -27,4 +28,12 @@
 #define DOUBLE_MACRO MACRO(H) // NOLINT
 DOUBLE_MACRO
 
-// CHECK-MESSAGES: Suppressed 7 warnings (7 NOLINT)
+#include "trigger_warning.h"
+void I(int& Out) {
+  int In;
+  A1(In, Out);
+}
+// CHECK-NOT: header.h:{{.*}} warning: The left operand of '>' is a garbage 
value
+// CHECK-NOT: :[[@LINE-4]]:{{.*}} note
+
+// CHECK-MESSAGES: Suppressed 8 warnings (8 NOLINT)
Index: test/clang-tidy/Inputs/nolint/trigger_warning.h
===
--- test/clang-tidy/Inputs/nolint/trigger_warning.h
+++ test/clang-tidy/Inputs/nolint/trigger_warning.h
@@ -0,0 +1,5 @@
+void A1(const int &In, int &Out) {
+  if (In > 123) // NOLINT
+Out = 123;
+}
+
Index: clang-tidy/ClangTidyDiagnosticConsumer.h
===
--- clang-tidy/ClangTidyDiagnosticConsumer.h
+++ clang-tidy/ClangTidyDiagnosticConsumer.h
@@ -286,6 +286,7 @@
   std::unique_ptr HeaderFilter;
   bool LastErrorRelatesToUserCode;
   bool LastErrorPassesLineFilter;
+  bool LastErrorWasIgnored;
 };
 
 } // end namespace tidy
Index: clang-tidy/ClangTidyDiagnosticConsumer.cpp
===
--- clang-tidy/ClangTidyDiagnosticConsumer.cpp
+++ clang-tidy/ClangTidyDiagnosticConsumer.cpp
@@ -250,7 +250,7 @@
 
 ClangTidyDiagnosticConsumer::ClangTidyDiagnosticConsumer(ClangTidyContext &Ctx)
 : Context(Ctx), LastErrorRelatesToUserCode(false),
-  LastErrorPassesLineFilter(false) {
+  LastErrorPassesLineFilter(false), LastErrorWasIgnored(false) {
   IntrusiveRefCntPtr DiagOpts = new DiagnosticOptions();
   Diags.reset(new DiagnosticsEngine(
   IntrusiveRefCntPtr(new DiagnosticIDs), &*DiagOpts, this,
@@ -309,13 +309,20 @@
 
 void ClangTidyDiagnosticConsumer::HandleDiagnostic(
 DiagnosticsEngine::Level DiagLevel, const Diagnostic &Info) {
+  if (LastErrorWasIgnored && DiagLevel == DiagnosticsEngine::Note)
+return;
+
   if (Info.getLocation().isValid() &&
   DiagLevel != DiagnosticsEngine::Error &&
   DiagLevel != DiagnosticsEngine::Fatal &&
   LineIsMarkedWithNOLINTinMacro(Diags->getSourceManager(), 
Info.getLocation())) {
 ++Context.Stats.ErrorsIgnoredNOLINT;
+// Ignored a warning, should ignore related notes as well
+LastErrorWasIgnored = true;
 return;
   }
+
+  LastErrorWasIgnored = false;
   // Count warnings/errors.
   DiagnosticConsumer::HandleDiagnostic(DiagLevel, Info);
 


Index: test/clang-tidy/nolint.cpp
===
--- test/clang-tidy/nolint.cpp
+++ test/clang-tidy/nolint.cpp
@@ -1,4 +1,5 @@
-// RUN: %check_clang_tidy %s google-explicit-constructor,clang-diagnostic-unused-variable %t -- -extra-arg=-Wunused-variable --
+// RUN: %check_clang_tidy %s google-explicit-constructor,clang-diagnostic-unused-variable,clang-analyzer-core.UndefinedBinaryOperatorResult %t -- -extra-arg=-Wunused-variable -- -I%S/Inputs/nolint
+
 
 class A { A(int i); };
 // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: single-argument constructors must be marked explicit
@@ -27,4 +28,12 @@
 #define DOUBLE_MACRO MACRO(H) // NOLINT
 DOUBLE_MACRO
 
-// CHECK-MESSAGES: Suppressed 7 warnings (7 NOLINT)
+#include "trigger_warning.h"
+void I(int& Out) {
+  int In;
+  A1(In, Out);
+}
+// CHECK-NOT: header.h:{{.*}} warning: The left operand of '>' is a garbage value
+// CHECK-NOT: :[[@LINE-4]]:{{.*}} note
+
+// CHECK-MESSAGES: Suppressed 8 warnings (8 NOLINT)
Index: test/clang-tidy/Inputs/nolint/trigger_warning.h
===
--- test/clang-tidy/Inputs/nolint/trigger_warning.h
+++ test/clang-tidy/Inputs/nolint/trigger_warning.h
@@ -0,0 +1,5 @@
+void A1(const int &In, int &Out) {
+  if (In > 123) // NOLINT
+Out = 123;
+}
+
Index: clang-tidy/ClangTidyDiagnosticConsumer.h
===
--- clang-tidy/ClangT

[PATCH] D25204: Register Calling Convention, Clang changes

2016-11-02 Thread Erich Keane via cfe-commits
erichkeane updated this revision to Diff 76717.
erichkeane added a comment.

It was brought to my attention that regcall isn't a calling convention that 
should cause MSVC to switch to C++ mangling.  Switched that and updated the 
tests.


https://reviews.llvm.org/D25204

Files:
  include/clang-c/Index.h
  include/clang/AST/Type.h
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Basic/Specifiers.h
  include/clang/Basic/TokenKinds.def
  lib/AST/Expr.cpp
  lib/AST/ItaniumMangle.cpp
  lib/AST/Mangle.cpp
  lib/AST/MicrosoftMangle.cpp
  lib/AST/Type.cpp
  lib/AST/TypePrinter.cpp
  lib/Basic/Targets.cpp
  lib/CodeGen/CGCall.cpp
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/TargetInfo.cpp
  lib/Parse/ParseDecl.cpp
  lib/Parse/ParseTentative.cpp
  lib/Sema/SemaDeclAttr.cpp
  lib/Sema/SemaType.cpp
  test/CodeGen/regcall.c
  test/CodeGenCXX/regcall.cpp
  tools/libclang/CXType.cpp

Index: lib/Parse/ParseDecl.cpp
===
--- lib/Parse/ParseDecl.cpp
+++ lib/Parse/ParseDecl.cpp
@@ -605,6 +605,7 @@
 case tok::kw___fastcall:
 case tok::kw___stdcall:
 case tok::kw___thiscall:
+case tok::kw___regcall:
 case tok::kw___cdecl:
 case tok::kw___vectorcall:
 case tok::kw___ptr64:
@@ -3137,6 +3138,7 @@
 case tok::kw___stdcall:
 case tok::kw___fastcall:
 case tok::kw___thiscall:
+case tok::kw___regcall:
 case tok::kw___vectorcall:
   ParseMicrosoftTypeAttributes(DS.getAttributes());
   continue;
@@ -4454,6 +4456,7 @@
   case tok::kw___stdcall:
   case tok::kw___fastcall:
   case tok::kw___thiscall:
+  case tok::kw___regcall:
   case tok::kw___vectorcall:
   case tok::kw___w64:
   case tok::kw___ptr64:
@@ -4638,6 +4641,7 @@
   case tok::kw___stdcall:
   case tok::kw___fastcall:
   case tok::kw___thiscall:
+  case tok::kw___regcall:
   case tok::kw___vectorcall:
   case tok::kw___w64:
   case tok::kw___sptr:
@@ -4876,6 +4880,7 @@
 case tok::kw___stdcall:
 case tok::kw___fastcall:
 case tok::kw___thiscall:
+case tok::kw___regcall:
 case tok::kw___vectorcall:
   if (AttrReqs & AR_DeclspecAttributesParsed) {
 ParseMicrosoftTypeAttributes(DS.getAttributes());
Index: lib/Parse/ParseTentative.cpp
===
--- lib/Parse/ParseTentative.cpp
+++ lib/Parse/ParseTentative.cpp
@@ -909,7 +909,7 @@
   // '(' abstract-declarator ')'
   if (Tok.isOneOf(tok::kw___attribute, tok::kw___declspec, tok::kw___cdecl,
   tok::kw___stdcall, tok::kw___fastcall, tok::kw___thiscall,
-  tok::kw___vectorcall))
+  tok::kw___regcall, tok::kw___vectorcall))
 return TPResult::True; // attributes indicate declaration
   TPResult TPR = TryParseDeclarator(mayBeAbstract, mayHaveIdentifier);
   if (TPR != TPResult::Ambiguous)
@@ -1058,6 +1058,7 @@
   case tok::kw___stdcall:
   case tok::kw___fastcall:
   case tok::kw___thiscall:
+  case tok::kw___regcall:
   case tok::kw___vectorcall:
   case tok::kw___unaligned:
   case tok::kw___vector:
@@ -1351,6 +1352,7 @@
   case tok::kw___stdcall:
   case tok::kw___fastcall:
   case tok::kw___thiscall:
+  case tok::kw___regcall:
   case tok::kw___vectorcall:
   case tok::kw___w64:
   case tok::kw___sptr:
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -673,7 +673,16 @@
   } else {
 IdentifierInfo *II = ND->getIdentifier();
 assert(II && "Attempt to mangle unnamed decl.");
-Str = II->getName();
+const auto *FD = dyn_cast(ND);
+
+if (FD &&
+FD->getType()->castAs()->getCallConv() == CC_X86RegCall) {
+  llvm::raw_svector_ostream Out(Buffer);
+  Out << "__regcall3__" << II->getName();
+  Str = Out.str();
+} else {
+  Str = II->getName();
+}
   }
 
   // Keep the first result in the case of a mangling collision.
Index: lib/CodeGen/CGCall.cpp
===
--- lib/CodeGen/CGCall.cpp
+++ lib/CodeGen/CGCall.cpp
@@ -48,6 +48,7 @@
   default: return llvm::CallingConv::C;
   case CC_X86StdCall: return llvm::CallingConv::X86_StdCall;
   case CC_X86FastCall: return llvm::CallingConv::X86_FastCall;
+  case CC_X86RegCall: return llvm::CallingConv::X86_RegCall;
   case CC_X86ThisCall: return llvm::CallingConv::X86_ThisCall;
   case CC_X86_64Win64: return llvm::CallingConv::X86_64_Win64;
   case CC_X86_64SysV: return llvm::CallingConv::X86_64_SysV;
@@ -173,6 +174,9 @@
   if (D->hasAttr())
 return CC_X86FastCall;
 
+  if (D->hasAttr())
+return CC_X86RegCall;
+
   if (D->hasAttr())
 return CC_X86ThisCall;
 
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.

[PATCH] D22955: [MSVC] Improved late parsing of template functions.

2016-11-02 Thread Alexey Bataev via cfe-commits
ABataev added a comment.

Ping!


https://reviews.llvm.org/D22955



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


[PATCH] D26189: Add a note that points to the linkage specifier for the "must have C++ linkage" errors

2016-11-02 Thread Alex Lorenz via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL285823: Add a note that points to the linkage specifier for 
the C++ linkage errors (authored by arphaman).

Changed prior to commit:
  https://reviews.llvm.org/D26189?vs=76577&id=76716#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D26189

Files:
  cfe/trunk/include/clang/AST/DeclBase.h
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/lib/AST/DeclBase.cpp
  cfe/trunk/lib/Sema/SemaDecl.cpp
  cfe/trunk/lib/Sema/SemaDeclCXX.cpp
  cfe/trunk/lib/Sema/SemaTemplate.cpp
  cfe/trunk/test/CXX/over/over.oper/over.literal/p6.cpp
  cfe/trunk/test/SemaCXX/cxx0x-defaulted-functions.cpp
  cfe/trunk/test/SemaTemplate/class-template-decl.cpp

Index: cfe/trunk/include/clang/AST/DeclBase.h
===
--- cfe/trunk/include/clang/AST/DeclBase.h
+++ cfe/trunk/include/clang/AST/DeclBase.h
@@ -1334,6 +1334,9 @@
   /// linkage specification context that specifies C linkage.
   bool isExternCContext() const;
 
+  /// \brief Retrieve the nearest enclosing C linkage specification context.
+  const LinkageSpecDecl *getExternCContext() const;
+
   /// \brief Determines whether this context or some of its ancestors is a
   /// linkage specification context that specifies C++ linkage.
   bool isExternCXXContext() const;
Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
@@ -4502,6 +4502,8 @@
   "conflicts with declaration %select{in global scope|with C language linkage}0">;
 def note_extern_c_global_conflict : Note<
   "declared %select{in global scope|with C language linkage}0 here">;
+def note_extern_c_begins_here : Note<
+  "extern \"C\" language linkage specification begins here">;
 def warn_weak_import : Warning <
   "an already-declared variable is made a weak_import declaration %0">;
 def ext_static_non_static : Extension<
@@ -8605,8 +8607,6 @@
   "import of C++ module '%0' appears within extern \"C\" language linkage "
   "specification">, DefaultError,
   InGroup>;
-def note_module_import_in_extern_c : Note<
-  "extern \"C\" language linkage specification begins here">;
 def err_module_import_not_at_top_level_fatal : Error<
   "import of module '%0' appears within %1">, DefaultFatal;
 def ext_module_import_not_at_top_level_noop : ExtWarn<
Index: cfe/trunk/test/SemaCXX/cxx0x-defaulted-functions.cpp
===
--- cfe/trunk/test/SemaCXX/cxx0x-defaulted-functions.cpp
+++ cfe/trunk/test/SemaCXX/cxx0x-defaulted-functions.cpp
@@ -180,7 +180,7 @@
   Outer::Inner2::~Inner2() = default; // expected-error {{nested name specifier 'Outer::Inner2::' for declaration does not refer into a class, class template or class template partial specialization}}  expected-error {{only special member functions may be defaulted}}
 }
 
-extern "C" {
+extern "C" { // expected-note {{extern "C" language linkage specification begins here}}
  template // expected-error {{templates must have C++ linkage}}
  void PR13573(const _Tp&) = delete;
 }
Index: cfe/trunk/test/CXX/over/over.oper/over.literal/p6.cpp
===
--- cfe/trunk/test/CXX/over/over.oper/over.literal/p6.cpp
+++ cfe/trunk/test/CXX/over/over.oper/over.literal/p6.cpp
@@ -1,9 +1,11 @@
 // RUN: %clang_cc1 -std=c++11 %s -verify
 
+// expected-note@+1 {{extern "C" language linkage specification begins here}}
 extern "C" void operator "" _a(const char *); // expected-error {{must have C++ linkage}}
 extern "C" template void operator "" _b(); // expected-error {{must have C++ linkage}}
+// expected-note@-1 {{extern "C" language linkage specification begins here}}
 
-extern "C" {
+extern "C" { // expected-note 4 {{extern "C" language linkage specification begins here}}
   void operator "" _c(const char *); // expected-error {{must have C++ linkage}}
   template void operator "" _d(); // expected-error {{must have C++ linkage}}
   namespace N {
Index: cfe/trunk/test/SemaTemplate/class-template-decl.cpp
===
--- cfe/trunk/test/SemaTemplate/class-template-decl.cpp
+++ cfe/trunk/test/SemaTemplate/class-template-decl.cpp
@@ -10,11 +10,11 @@
   template class C;
 }
 
-extern "C" {
+extern "C" { // expected-note {{extern "C" language linkage specification begins here}}
   template class D; // expected-error{{templates must have C++ linkage}}
 }
 
-extern "C" {
+extern "C" { // expected-note 2 {{extern "C" language linkage specification begins here}}
   class PR17968 {
 template class D; // expected-error{{templates must have C++ linkage}}
 template void f(); // expected-error{{templates must have C++ linkage}}
@@ -148,7 +148,7 @@
 }
 
 extern "C" template  // expected-error

[PATCH] D25940: [analyzer] LibraryFunctions: Fix errors due to different integral types and typedefs on different architectures.

2016-11-02 Thread Anna Zaks via cfe-commits
zaks.anna accepted this revision.
zaks.anna added a comment.
This revision is now accepted and ready to land.

LGTM other than the missing explanation in comments.


https://reviews.llvm.org/D25940



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


r285823 - Add a note that points to the linkage specifier for the C++ linkage errors

2016-11-02 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Wed Nov  2 10:46:34 2016
New Revision: 285823

URL: http://llvm.org/viewvc/llvm-project?rev=285823&view=rev
Log:
Add a note that points to the linkage specifier for the C++ linkage errors

This commit improves the "must have C++ linkage" error diagnostics that are
emitted for C++ declarations like templates and literal operators by adding an
additional note that points to the appropriate extern "C" linkage specifier.

rdar://19021120

Differential Revision: https://reviews.llvm.org/D26189

Modified:
cfe/trunk/include/clang/AST/DeclBase.h
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/AST/DeclBase.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/test/CXX/over/over.oper/over.literal/p6.cpp
cfe/trunk/test/SemaCXX/cxx0x-defaulted-functions.cpp
cfe/trunk/test/SemaTemplate/class-template-decl.cpp

Modified: cfe/trunk/include/clang/AST/DeclBase.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclBase.h?rev=285823&r1=285822&r2=285823&view=diff
==
--- cfe/trunk/include/clang/AST/DeclBase.h (original)
+++ cfe/trunk/include/clang/AST/DeclBase.h Wed Nov  2 10:46:34 2016
@@ -1334,6 +1334,9 @@ public:
   /// linkage specification context that specifies C linkage.
   bool isExternCContext() const;
 
+  /// \brief Retrieve the nearest enclosing C linkage specification context.
+  const LinkageSpecDecl *getExternCContext() const;
+
   /// \brief Determines whether this context or some of its ancestors is a
   /// linkage specification context that specifies C++ linkage.
   bool isExternCXXContext() const;

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=285823&r1=285822&r2=285823&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed Nov  2 10:46:34 
2016
@@ -4502,6 +4502,8 @@ def err_extern_c_global_conflict : Error
   "conflicts with declaration %select{in global scope|with C language 
linkage}0">;
 def note_extern_c_global_conflict : Note<
   "declared %select{in global scope|with C language linkage}0 here">;
+def note_extern_c_begins_here : Note<
+  "extern \"C\" language linkage specification begins here">;
 def warn_weak_import : Warning <
   "an already-declared variable is made a weak_import declaration %0">;
 def ext_static_non_static : Extension<
@@ -8605,8 +8607,6 @@ def ext_module_import_in_extern_c : ExtW
   "import of C++ module '%0' appears within extern \"C\" language linkage "
   "specification">, DefaultError,
   InGroup>;
-def note_module_import_in_extern_c : Note<
-  "extern \"C\" language linkage specification begins here">;
 def err_module_import_not_at_top_level_fatal : Error<
   "import of module '%0' appears within %1">, DefaultFatal;
 def ext_module_import_not_at_top_level_noop : ExtWarn<

Modified: cfe/trunk/lib/AST/DeclBase.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclBase.cpp?rev=285823&r1=285822&r2=285823&view=diff
==
--- cfe/trunk/lib/AST/DeclBase.cpp (original)
+++ cfe/trunk/lib/AST/DeclBase.cpp Wed Nov  2 10:46:34 2016
@@ -992,6 +992,18 @@ bool DeclContext::isExternCContext() con
   return isLinkageSpecContext(this, clang::LinkageSpecDecl::lang_c);
 }
 
+const LinkageSpecDecl *DeclContext::getExternCContext() const {
+  const DeclContext *DC = this;
+  while (DC->getDeclKind() != Decl::TranslationUnit) {
+if (DC->getDeclKind() == Decl::LinkageSpec &&
+cast(DC)->getLanguage() ==
+clang::LinkageSpecDecl::lang_c)
+  return cast(DC);
+DC = DC->getLexicalParent();
+  }
+  return nullptr;
+}
+
 bool DeclContext::isExternCXXContext() const {
   return isLinkageSpecContext(this, clang::LinkageSpecDecl::lang_cxx);
 }

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=285823&r1=285822&r2=285823&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed Nov  2 10:46:34 2016
@@ -15341,7 +15341,7 @@ static void checkModuleImportContext(Sem
   } else if (!M->IsExternC && ExternCLoc.isValid()) {
 S.Diag(ImportLoc, diag::ext_module_import_in_extern_c)
   << M->getFullModuleName();
-S.Diag(ExternCLoc, diag::note_module_import_in_extern_c);
+S.Diag(ExternCLoc, diag::note_extern_c_begins_here);
   }
 }
 

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=285823&r1=285822&r2=285823&view=diff
==

r285820 - [asan] Use the dynamic ASan runtime if -shared-libasan is passed

2016-11-02 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Wed Nov  2 10:38:51 2016
New Revision: 285820

URL: http://llvm.org/viewvc/llvm-project?rev=285820&view=rev
Log:
[asan] Use the dynamic ASan runtime if -shared-libasan is passed

-shared-libasan is likely to be used as a link flag if the user is using
the GCC-style clang driver.

This logic is already tested in clang-cl tests, and the new flag to
exercise it will be covered by asan tests.

Modified:
cfe/trunk/lib/Driver/Tools.cpp

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=285820&r1=285819&r2=285820&view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Wed Nov  2 10:38:51 2016
@@ -10786,7 +10786,8 @@ void visualstudio::Linker::ConstructJob(
   if (TC.getSanitizerArgs().needsAsanRt()) {
 CmdArgs.push_back(Args.MakeArgString("-debug"));
 CmdArgs.push_back(Args.MakeArgString("-incremental:no"));
-if (Args.hasArg(options::OPT__SLASH_MD, options::OPT__SLASH_MDd)) {
+if (TC.getSanitizerArgs().needsSharedAsanRt() ||
+Args.hasArg(options::OPT__SLASH_MD, options::OPT__SLASH_MDd)) {
   for (const auto &Lib : {"asan_dynamic", "asan_dynamic_runtime_thunk"})
 CmdArgs.push_back(TC.getCompilerRTArgString(Args, Lib));
   // Make sure the dynamic runtime thunk is not optimized out at link time


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


[libcxx] r285818 - Implement another part of P0031; adding constexpr to move_iterator

2016-11-02 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Wed Nov  2 10:30:26 2016
New Revision: 285818

URL: http://llvm.org/viewvc/llvm-project?rev=285818&view=rev
Log:
Implement another part of P0031; adding constexpr to move_iterator

Modified:
libcxx/trunk/include/iterator

libcxx/trunk/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.nonmember/make_move_iterator.pass.cpp

libcxx/trunk/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.nonmember/minus.pass.cpp

libcxx/trunk/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.nonmember/plus.pass.cpp

libcxx/trunk/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.+/difference_type.pass.cpp

libcxx/trunk/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.+=/difference_type.pass.cpp

libcxx/trunk/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.-/difference_type.pass.cpp

libcxx/trunk/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.-=/difference_type.pass.cpp

libcxx/trunk/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_eq.pass.cpp

libcxx/trunk/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_gt.pass.cpp

libcxx/trunk/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_gte.pass.cpp

libcxx/trunk/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_lt.pass.cpp

libcxx/trunk/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_lte.pass.cpp

libcxx/trunk/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_neq.pass.cpp

libcxx/trunk/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.const/convert.pass.cpp

libcxx/trunk/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.const/default.pass.cpp

libcxx/trunk/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.const/iter.pass.cpp

libcxx/trunk/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.decr/post.pass.cpp

libcxx/trunk/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.decr/pre.pass.cpp

libcxx/trunk/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.incr/post.pass.cpp

libcxx/trunk/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.incr/pre.pass.cpp

libcxx/trunk/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.index/difference_type.pass.cpp

libcxx/trunk/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.ref/op_arrow.pass.cpp

libcxx/trunk/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.star/op_star.pass.cpp

libcxx/trunk/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op=/move_iterator.pass.cpp

Modified: libcxx/trunk/include/iterator
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/iterator?rev=285818&r1=285817&r2=285818&view=diff
==
--- libcxx/trunk/include/iterator (original)
+++ libcxx/trunk/include/iterator Wed Nov  2 10:30:26 2016
@@ -219,61 +219,64 @@ public:
 typedef typename iterator_traits::iterator_category 
iterator_category;
 typedef value_type&&  reference;
  
-move_iterator();
-explicit move_iterator(Iterator i);
-template  move_iterator(const move_iterator& u);
-template  move_iterator& operator=(const move_iterator& u);
-iterator_type base() const;
-reference operator*() const;
-pointer operator->() const;
-move_iterator& operator++();
-move_iterator operator++(int);
-move_iterator& operator--();
-move_iterator operator--(int);
-move_iterator operator+(difference_type n) const; 
-move_iterator& operator+=(difference_type n); 
-move_iterator operator-(difference_type n) const; 
-move_iterator& operator-=(difference_type n); 
-unspecified operator[](difference_type n) const;
+constexpr move_iterator();  // all the constexprs are in C++17
+constexpr explicit move_iterator(Iterator i);
+template 
+  constexpr move_iterator(const move_iterator& u);
+template 
+  constexpr move_iterator& operator=(const move_iterator& u);
+constexpr iterator_type base() const;
+constexpr reference operator*() const;
+constexpr pointer operator->() const;
+constexpr move_iterator& operator++();
+constexpr move_iterator operator++(int);
+constexpr move_iterator& operator--();
+constexpr move_iterator operator--(int);
+constexpr move_iterator operator+(difference_type n) const; 
+constexpr move_iterator& op

[PATCH] D25828: Implement part of P0031; adding `constexpr` to `move_iterator`

2016-11-02 Thread Marshall Clow via cfe-commits
mclow.lists accepted this revision.
mclow.lists added a reviewer: mclow.lists.
mclow.lists added a comment.
This revision is now accepted and ready to land.

Committed as revision 285818


https://reviews.llvm.org/D25828



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


[PATCH] D19979: [analyzer] ScopeContext - initial implementation

2016-11-02 Thread Artem Dergachev via cfe-commits
NoQ added a comment.

https://llvm.org/bugs/show_bug.cgi?id=28450
^Another impressing test case for variable scopes, which should ideally be 
fixed by scope contexts, even though i doubt this patch (or the CFG patch) 
addresses this issue. Variable-length arrays might actually mess up things 
quite a bit.

Long story short, every time a goto jumps to before VLA was declared, it gets 
re-allocated. And we need to represent it as a different VarRegion for the same 
declaration. We could extend the region hierarchy to treat VLAs specially, but 
ideally it seems saner to me to make a VarRegion on top of a different scope 
memspace every time VLA is re-allocated.


https://reviews.llvm.org/D19979



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


r285810 - Turn on the /bigobj switch for RecursiveASTVisitorTest.cpp; we are now bumping up against that limit with MSVC 2015 in Win64 debug build mode.

2016-11-02 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Wed Nov  2 09:31:36 2016
New Revision: 285810

URL: http://llvm.org/viewvc/llvm-project?rev=285810&view=rev
Log:
Turn on the /bigobj switch for RecursiveASTVisitorTest.cpp; we are now bumping 
up against that limit with MSVC 2015 in Win64 debug build mode.

Modified:
cfe/trunk/unittests/Tooling/CMakeLists.txt

Modified: cfe/trunk/unittests/Tooling/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Tooling/CMakeLists.txt?rev=285810&r1=285809&r2=285810&view=diff
==
--- cfe/trunk/unittests/Tooling/CMakeLists.txt (original)
+++ cfe/trunk/unittests/Tooling/CMakeLists.txt Wed Nov  2 09:31:36 2016
@@ -6,6 +6,7 @@ set(LLVM_LINK_COMPONENTS
 # By default MSVC has a 2^16 limit on the number of sections in an object file,
 # and this needs more than that.
 if (MSVC)
+  set_source_files_properties(RecursiveASTVisitorTest.cpp PROPERTIES 
COMPILE_FLAGS /bigobj)
   set_source_files_properties(RecursiveASTVisitorTestExprVisitor.cpp 
PROPERTIES COMPILE_FLAGS /bigobj)
 endif()
 


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


[PATCH] D22346: [Clang-tidy] CERT-MSC50-CPP (std:rand() )

2016-11-02 Thread Benedek Kiss via cfe-commits
falho added a comment.

Thanks !


https://reviews.llvm.org/D22346



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


[clang-tools-extra] r285809 - Add a new clang-tidy check for cert-msc50-cpp (and cert-msc30-c) that corresponds to the CERT C++ secure coding rule: https://www.securecoding.cert.org/confluence/display

2016-11-02 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Wed Nov  2 09:16:36 2016
New Revision: 285809

URL: http://llvm.org/viewvc/llvm-project?rev=285809&view=rev
Log:
Add a new clang-tidy check for cert-msc50-cpp (and cert-msc30-c) that 
corresponds to the CERT C++ secure coding rule: 
https://www.securecoding.cert.org/confluence/display/cplusplus/MSC50-CPP.+Do+not+use+std%3A%3Arand%28%29+for+generating+pseudorandom+numbers

Patch by Benedek Kiss

Added:
clang-tools-extra/trunk/clang-tidy/cert/LimitedRandomnessCheck.cpp
clang-tools-extra/trunk/clang-tidy/cert/LimitedRandomnessCheck.h
clang-tools-extra/trunk/docs/clang-tidy/checks/cert-msc30-c.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/cert-msc50-cpp.rst
clang-tools-extra/trunk/test/clang-tidy/cert-limited-randomness.c
clang-tools-extra/trunk/test/clang-tidy/cert-limited-randomness.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/cert/CERTTidyModule.cpp
clang-tools-extra/trunk/clang-tidy/cert/CMakeLists.txt
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst

Modified: clang-tools-extra/trunk/clang-tidy/cert/CERTTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cert/CERTTidyModule.cpp?rev=285809&r1=285808&r2=285809&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/cert/CERTTidyModule.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/cert/CERTTidyModule.cpp Wed Nov  2 
09:16:36 2016
@@ -18,6 +18,7 @@
 #include "../misc/ThrowByValueCatchByReferenceCheck.h"
 #include "CommandProcessorCheck.h"
 #include "FloatLoopCounter.h"
+#include "LimitedRandomnessCheck.h"
 #include "SetLongJmpCheck.h"
 #include "StaticObjectExceptionCheck.h"
 #include "StrToNumCheck.h"
@@ -53,6 +54,9 @@ public:
 "cert-err60-cpp");
 CheckFactories.registerCheck(
 "cert-err61-cpp");
+// MSC
+CheckFactories.registerCheck(
+"cert-msc50-cpp");
 
 // C checkers
 // DCL
@@ -70,6 +74,9 @@ public:
 // ERR
 CheckFactories.registerCheck(
 "cert-err34-c");
+// MSC
+CheckFactories.registerCheck(
+"cert-msc30-c");
   }
   ClangTidyOptions getModuleOptions() override {
 ClangTidyOptions Options;

Modified: clang-tools-extra/trunk/clang-tidy/cert/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cert/CMakeLists.txt?rev=285809&r1=285808&r2=285809&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/cert/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/cert/CMakeLists.txt Wed Nov  2 09:16:36 
2016
@@ -4,6 +4,7 @@ add_clang_library(clangTidyCERTModule
   CERTTidyModule.cpp
   CommandProcessorCheck.cpp
   FloatLoopCounter.cpp
+  LimitedRandomnessCheck.cpp
   SetLongJmpCheck.cpp
   StaticObjectExceptionCheck.cpp
   StrToNumCheck.cpp

Added: clang-tools-extra/trunk/clang-tidy/cert/LimitedRandomnessCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cert/LimitedRandomnessCheck.cpp?rev=285809&view=auto
==
--- clang-tools-extra/trunk/clang-tidy/cert/LimitedRandomnessCheck.cpp (added)
+++ clang-tools-extra/trunk/clang-tidy/cert/LimitedRandomnessCheck.cpp Wed Nov  
2 09:16:36 2016
@@ -0,0 +1,40 @@
+//===--- LimitedRandomnessCheck.cpp - 
clang-tidy---===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "LimitedRandomnessCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace cert {
+
+void LimitedRandomnessCheck::registerMatchers(MatchFinder *Finder) {
+  Finder->addMatcher(callExpr(callee(functionDecl(namedDecl(hasName("::rand")),
+  parameterCountIs(0
+ .bind("randomGenerator"),
+ this);
+}
+
+void LimitedRandomnessCheck::check(const MatchFinder::MatchResult &Result) {
+  std::string msg = "";
+  if (getLangOpts().CPlusPlus)
+msg = "; use C++11 random library instead";
+
+  const auto *MatchedDecl = 
Result.Nodes.getNodeAs("randomGenerator");
+  diag(MatchedDecl->getLocStart(),
+   "rand() has limited randomness" + msg);
+}
+
+} // namespace cert
+} // namespace tidy
+} // namespace clang
+

Added: clang-tools-extra/trunk/clang-tidy/cert/LimitedRandomnessCheck.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cert/LimitedRandomnessCheck.h?rev=285809&view=auto
==
--- clang-tool

[PATCH] D22346: [Clang-tidy] CERT-MSC50-CPP (std:rand() )

2016-11-02 Thread Aaron Ballman via cfe-commits
aaron.ballman closed this revision.
aaron.ballman added a comment.

Thanks! I've commit in r285809


https://reviews.llvm.org/D22346



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


[PATCH] D26244: [Driver] Prefer libraries installed next to Clang over those from GCC

2016-11-02 Thread Jonas Hahnfeld via cfe-commits
Hahnfeld created this revision.
Hahnfeld added reviewers: mgorny, rsmith, EricWF.
Hahnfeld added a subscriber: cfe-commits.

This is for example needed to make sure we get LLVM's `libunwind.so.1` and 
don't end up with the system default non-GNU `libunwind.so.8` as reported in 
https://reviews.llvm.org/D25008.


https://reviews.llvm.org/D26244

Files:
  lib/Driver/ToolChains.cpp


Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -4222,6 +4222,17 @@
   const std::string OSLibDir = getOSLibDir(Triple, Args);
   const std::string MultiarchTriple = getMultiarchTriple(D, Triple, SysRoot);
 
+  // Similar to the logic for GCC below, if we currently running Clang inside
+  // of the requested system root, add its parent library paths to those
+  // searched.
+  // FIXME: It's not clear whether we should use the driver's installed
+  // directory ('Dir' below) or the ResourceDir.
+  if (StringRef(D.Dir).startswith(SysRoot)) {
+addPathIfExists(D, D.Dir + "/../lib/" + MultiarchTriple, Paths);
+addPathIfExists(D, D.Dir + "/../" + OSLibDir, Paths);
+addPathIfExists(D, D.Dir + "/../lib", Paths);
+  }
+
   // Add the multilib suffixed paths where they are available.
   if (GCCInstallation.isValid()) {
 const llvm::Triple &GCCTriple = GCCInstallation.getTriple();
@@ -4275,16 +4286,6 @@
 }
   }
 
-  // Similar to the logic for GCC above, if we currently running Clang inside
-  // of the requested system root, add its parent library paths to
-  // those searched.
-  // FIXME: It's not clear whether we should use the driver's installed
-  // directory ('Dir' below) or the ResourceDir.
-  if (StringRef(D.Dir).startswith(SysRoot)) {
-addPathIfExists(D, D.Dir + "/../lib/" + MultiarchTriple, Paths);
-addPathIfExists(D, D.Dir + "/../" + OSLibDir, Paths);
-  }
-
   addPathIfExists(D, SysRoot + "/lib/" + MultiarchTriple, Paths);
   addPathIfExists(D, SysRoot + "/lib/../" + OSLibDir, Paths);
   addPathIfExists(D, SysRoot + "/usr/lib/" + MultiarchTriple, Paths);
@@ -4321,14 +4322,6 @@
   addPathIfExists(D, LibPath, Paths);
   }
 
-  // Similar to the logic for GCC above, if we are currently running Clang
-  // inside of the requested system root, add its parent library path to those
-  // searched.
-  // FIXME: It's not clear whether we should use the driver's installed
-  // directory ('Dir' below) or the ResourceDir.
-  if (StringRef(D.Dir).startswith(SysRoot))
-addPathIfExists(D, D.Dir + "/../lib", Paths);
-
   addPathIfExists(D, SysRoot + "/lib", Paths);
   addPathIfExists(D, SysRoot + "/usr/lib", Paths);
 }


Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -4222,6 +4222,17 @@
   const std::string OSLibDir = getOSLibDir(Triple, Args);
   const std::string MultiarchTriple = getMultiarchTriple(D, Triple, SysRoot);
 
+  // Similar to the logic for GCC below, if we currently running Clang inside
+  // of the requested system root, add its parent library paths to those
+  // searched.
+  // FIXME: It's not clear whether we should use the driver's installed
+  // directory ('Dir' below) or the ResourceDir.
+  if (StringRef(D.Dir).startswith(SysRoot)) {
+addPathIfExists(D, D.Dir + "/../lib/" + MultiarchTriple, Paths);
+addPathIfExists(D, D.Dir + "/../" + OSLibDir, Paths);
+addPathIfExists(D, D.Dir + "/../lib", Paths);
+  }
+
   // Add the multilib suffixed paths where they are available.
   if (GCCInstallation.isValid()) {
 const llvm::Triple &GCCTriple = GCCInstallation.getTriple();
@@ -4275,16 +4286,6 @@
 }
   }
 
-  // Similar to the logic for GCC above, if we currently running Clang inside
-  // of the requested system root, add its parent library paths to
-  // those searched.
-  // FIXME: It's not clear whether we should use the driver's installed
-  // directory ('Dir' below) or the ResourceDir.
-  if (StringRef(D.Dir).startswith(SysRoot)) {
-addPathIfExists(D, D.Dir + "/../lib/" + MultiarchTriple, Paths);
-addPathIfExists(D, D.Dir + "/../" + OSLibDir, Paths);
-  }
-
   addPathIfExists(D, SysRoot + "/lib/" + MultiarchTriple, Paths);
   addPathIfExists(D, SysRoot + "/lib/../" + OSLibDir, Paths);
   addPathIfExists(D, SysRoot + "/usr/lib/" + MultiarchTriple, Paths);
@@ -4321,14 +4322,6 @@
   addPathIfExists(D, LibPath, Paths);
   }
 
-  // Similar to the logic for GCC above, if we are currently running Clang
-  // inside of the requested system root, add its parent library path to those
-  // searched.
-  // FIXME: It's not clear whether we should use the driver's installed
-  // directory ('Dir' below) or the ResourceDir.
-  if (StringRef(D.Dir).startswith(SysRoot))
-addPathIfExists(D, D.Dir + "/../lib", Paths);
-
   addPathIfExists(D, SysRoot + "/lib", Paths);
   addPathIfExists(D, SysRoot + "/usr/lib", Paths);
 }
_

[PATCH] D22346: [Clang-tidy] CERT-MSC50-CPP (std:rand() )

2016-11-02 Thread Benedek Kiss via cfe-commits
falho added a comment.

I just figured out that I don't have right to commit to llvm so I would 
appreciate if you could commit this check for me. Do you need any info about 
me? Thank you!


https://reviews.llvm.org/D22346



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


[PATCH] D26157: [OpenCL] always use SPIR address spaces for kernel_arg_addr_space MD

2016-11-02 Thread Pekka Jääskeläinen via cfe-commits
pekka.jaaskelainen added a comment.

In https://reviews.llvm.org/D26157#585688, @bader wrote:

> @pekka.jaaskelainen, I have related question: what is the problem with 
> retaining OpenCL address space information in LLVM IR?
>  My understanding is that target CodeGen can ignore this information for the 
> machines with 'flat' address space model.
>  On the other hand I would expect this information be useful for the 
> Optimizer to resolve pointer aliasing.
>  Does it make any sense to keep OpenCL address space information in LLVM IR 
> generated for the machines with 'flat' address space (e.g. CPU)?


Is there nowadays such a thing as "standard OpenCL logical AS IDs" which could 
be retained down to code gen? I must say I haven't checked the current 
situation here. It used to be that the logical ids are assumed to be converted 
to the target ones already in Clang and I'm afraid changing this requires a 
major rework.

pocl has used the fake-address-space ids until now for exactly this -- 
retaining the logical AS info in the IR which can be exploited for disjoint 
address space AA, but is also required for handling the different AS kernel 
arguments as local arguments must be treated differently memory allocation wise.

However, as all backends are not expected to support mapping the fake address 
spaces to their internal ones (in single AS it's trivial to simply ignore the 
AS ids, but for multi-AS machines there has to be explicit mapping) we have had 
an IR pass that converts the address spaces to the target's before code gen. 
This pass we call TargetAddressSpaces has grown way too complex and is a major 
source of bugs all the time.

Also, another source of bugs is the fact that many passes simply ignore address 
spaces as they have been developed for single AS machines and only tested on 
them. This leads to bugs where the AS ID info is silently dropped (converted to 
0) which makes them hard to catch.  If the pointer creation APIs of LLVM were 
forced to include the AS ID in the construction, it might yield out majority of 
these issues -- as long as the coders respect the fact that there can be 
multiple ASs and not simply use 0 there all the time.

Also, some optimizations such as vectorization might get confused in case it 
sees non-0 address spaces for CPU targets (e.g. there might not be vectorized 
intrinsics available for non-0 ASs).

Etc. Thus, due to the limited time our group has available for hunting the bugs 
that stem from this, I decided it might be best to avoid the use of the 
"logical IDs" inside IR for now and think about how to implement the disjoint 
AA without them later on.


Repository:
  rL LLVM

https://reviews.llvm.org/D26157



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


[PATCH] D26157: [OpenCL] always use SPIR address spaces for kernel_arg_addr_space MD

2016-11-02 Thread Alexey Bader via cfe-commits
bader added a comment.

@pekka.jaaskelainen, I have related question: what is the problem with 
retaining OpenCL address space information in LLVM IR?
My understanding is that target CodeGen can ignore this information for the 
machines with 'flat' address space model.
On the other hand I would expect this information be useful for the Optimizer 
to resolve pointer aliasing.
Does it make any sense to keep OpenCL address space information in LLVM IR 
generated for the machines with 'flat' address space (e.g. CPU)?


Repository:
  rL LLVM

https://reviews.llvm.org/D26157



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


[PATCH] D26206: Fix Clang-tidy readability-redundant-string-cstr warnings

2016-11-02 Thread Malcolm Parsons via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL285799: Fix Clang-tidy readability-redundant-string-cstr 
warnings (authored by malcolm.parsons).

Changed prior to commit:
  https://reviews.llvm.org/D26206?vs=76642&id=76685#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D26206

Files:
  cfe/trunk/lib/ARCMigrate/FileRemapper.cpp
  cfe/trunk/lib/CodeGen/CGObjCGNU.cpp
  cfe/trunk/lib/CodeGen/TargetInfo.cpp
  cfe/trunk/lib/Driver/Driver.cpp
  cfe/trunk/lib/Driver/Job.cpp
  cfe/trunk/lib/Driver/Tools.cpp
  cfe/trunk/lib/Frontend/CompilerInvocation.cpp
  cfe/trunk/lib/Frontend/Rewrite/RewriteModernObjC.cpp
  cfe/trunk/lib/Frontend/Rewrite/RewriteObjC.cpp
  cfe/trunk/lib/Parse/ParseDeclCXX.cpp
  cfe/trunk/lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp
  cfe/trunk/unittests/AST/ASTImporterTest.cpp

Index: cfe/trunk/unittests/AST/ASTImporterTest.cpp
===
--- cfe/trunk/unittests/AST/ASTImporterTest.cpp
+++ cfe/trunk/unittests/AST/ASTImporterTest.cpp
@@ -71,8 +71,7 @@
 ToCtx.getSourceManager().getFileManager().getVirtualFileSystem().get());
   vfs::InMemoryFileSystem *MFS = static_cast(
 OFS->overlays_begin()->get());
-  MFS->addFile(InputFileName, 0,
-   llvm::MemoryBuffer::getMemBuffer(FromCode.c_str()));
+  MFS->addFile(InputFileName, 0, llvm::MemoryBuffer::getMemBuffer(FromCode));
 
   ASTImporter Importer(ToCtx, ToAST->getFileManager(),
FromCtx, FromAST->getFileManager(), false);
Index: cfe/trunk/lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp
@@ -106,7 +106,7 @@
   SmallVector checkerOpts;
   for (unsigned i = 0, e = opts.CheckersControlList.size(); i != e; ++i) {
 const std::pair &opt = opts.CheckersControlList[i];
-checkerOpts.push_back(CheckerOptInfo(opt.first.c_str(), opt.second));
+checkerOpts.push_back(CheckerOptInfo(opt.first, opt.second));
   }
   return checkerOpts;
 }
Index: cfe/trunk/lib/Driver/Driver.cpp
===
--- cfe/trunk/lib/Driver/Driver.cpp
+++ cfe/trunk/lib/Driver/Driver.cpp
@@ -874,8 +874,7 @@
 return;
 
   std::string TmpName = GetTemporaryPath("response", "txt");
-  Cmd.setResponseFile(
-  C.addTempFile(C.getArgs().MakeArgString(TmpName.c_str(;
+  Cmd.setResponseFile(C.addTempFile(C.getArgs().MakeArgString(TmpName)));
 }
 
 int Driver::ExecuteCompilation(
@@ -3295,7 +3294,7 @@
 std::pair Split = Name.split('.');
 std::string TmpName = GetTemporaryPath(
 Split.first, types::getTypeTempSuffix(JA.getType(), IsCLMode()));
-return C.addTempFile(C.getArgs().MakeArgString(TmpName.c_str()));
+return C.addTempFile(C.getArgs().MakeArgString(TmpName));
   }
 
   SmallString<128> BasePath(BaseInput);
@@ -3344,7 +3343,7 @@
   NamedOutput = C.getArgs().MakeArgString(Output.c_str());
 }
   } else if (JA.getType() == types::TY_PCH && IsCLMode()) {
-NamedOutput = C.getArgs().MakeArgString(GetClPchPath(C, BaseName).c_str());
+NamedOutput = C.getArgs().MakeArgString(GetClPchPath(C, BaseName));
   } else {
 const char *Suffix = types::getTypeTempSuffix(JA.getType(), IsCLMode());
 assert(Suffix && "All types used for output should have a suffix.");
@@ -3394,7 +3393,7 @@
   std::pair Split = Name.split('.');
   std::string TmpName = GetTemporaryPath(
   Split.first, types::getTypeTempSuffix(JA.getType(), IsCLMode()));
-  return C.addTempFile(C.getArgs().MakeArgString(TmpName.c_str()));
+  return C.addTempFile(C.getArgs().MakeArgString(TmpName));
 }
   }
 
Index: cfe/trunk/lib/Driver/Job.cpp
===
--- cfe/trunk/lib/Driver/Job.cpp
+++ cfe/trunk/lib/Driver/Job.cpp
@@ -182,7 +182,7 @@
 // Replace the input file name with the crashinfo's file name.
 OS << ' ';
 StringRef ShortName = llvm::sys::path::filename(CrashInfo->Filename);
-printArg(OS, ShortName.str().c_str(), Quote);
+printArg(OS, ShortName.str(), Quote);
 continue;
   }
 }
@@ -195,7 +195,7 @@
 OS << ' ';
 printArg(OS, "-ivfsoverlay", Quote);
 OS << ' ';
-printArg(OS, CrashInfo->VFSPath.str().c_str(), Quote);
+printArg(OS, CrashInfo->VFSPath.str(), Quote);
 
 // Insert -fmodules-cache-path and use the relative module directory
 // .cache/vfs/modules where we already dumped the modules.
@@ -207,7 +207,7 @@
 ModCachePath.append(RelModCacheDir.c_str());
 
 OS << ' ';
-printArg(OS, ModCachePath.c_str(), Quote);
+printArg(OS, ModCachePath, Quote);
   }
 
   if (ResponseFile != nullptr) {
Index: cfe/trunk/lib/Driver/Tools.cpp
=

[PATCH] D26218: [clang-tidy] Ignore notes along with a warning when processing NOLINT

2016-11-02 Thread Malcolm Parsons via cfe-commits
malcolm.parsons added inline comments.



Comment at: clang-tidy/ClangTidyDiagnosticConsumer.cpp:312
 DiagnosticsEngine::Level DiagLevel, const Diagnostic &Info) {
+  static bool ShouldIgnoreNotes = false;
+  if (ShouldIgnoreNotes && DiagLevel == DiagnosticsEngine::Note)

Change `ShouldIgnoreNotes` to a class member and rename to 
`LastErrorWasIgnored` or similar.


https://reviews.llvm.org/D26218



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


r285799 - Fix Clang-tidy readability-redundant-string-cstr warnings

2016-11-02 Thread Malcolm Parsons via cfe-commits
Author: malcolm.parsons
Date: Wed Nov  2 05:39:27 2016
New Revision: 285799

URL: http://llvm.org/viewvc/llvm-project?rev=285799&view=rev
Log:
Fix Clang-tidy readability-redundant-string-cstr warnings

Reviewers: aaron.ballman, mehdi_amini, dblaikie

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D26206

Modified:
cfe/trunk/lib/ARCMigrate/FileRemapper.cpp
cfe/trunk/lib/CodeGen/CGObjCGNU.cpp
cfe/trunk/lib/CodeGen/TargetInfo.cpp
cfe/trunk/lib/Driver/Driver.cpp
cfe/trunk/lib/Driver/Job.cpp
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/Frontend/Rewrite/RewriteModernObjC.cpp
cfe/trunk/lib/Frontend/Rewrite/RewriteObjC.cpp
cfe/trunk/lib/Parse/ParseDeclCXX.cpp
cfe/trunk/lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp
cfe/trunk/unittests/AST/ASTImporterTest.cpp

Modified: cfe/trunk/lib/ARCMigrate/FileRemapper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ARCMigrate/FileRemapper.cpp?rev=285799&r1=285798&r2=285799&view=diff
==
--- cfe/trunk/lib/ARCMigrate/FileRemapper.cpp (original)
+++ cfe/trunk/lib/ARCMigrate/FileRemapper.cpp Wed Nov  2 05:39:27 2016
@@ -64,7 +64,7 @@ bool FileRemapper::initFromFile(StringRe
   std::vector > pairs;
 
   llvm::ErrorOr> fileBuf =
-  llvm::MemoryBuffer::getFile(infoFile.c_str());
+  llvm::MemoryBuffer::getFile(infoFile);
   if (!fileBuf)
 return report("Error opening file: " + infoFile, Diag);
   

Modified: cfe/trunk/lib/CodeGen/CGObjCGNU.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCGNU.cpp?rev=285799&r1=285798&r2=285799&view=diff
==
--- cfe/trunk/lib/CodeGen/CGObjCGNU.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCGNU.cpp Wed Nov  2 05:39:27 2016
@@ -2647,8 +2647,7 @@ llvm::Function *CGObjCGNU::ModuleInitFun
 for (std::vector::iterator iter = ClassAliases.begin();
iter != ClassAliases.end(); ++iter) {
llvm::Constant *TheClass =
- TheModule.getGlobalVariable(("_OBJC_CLASS_" + iter->first).c_str(),
-true);
+  TheModule.getGlobalVariable("_OBJC_CLASS_" + iter->first, true);
if (TheClass) {
  TheClass = llvm::ConstantExpr::getBitCast(TheClass, PtrTy);
  Builder.CreateCall(RegisterAlias,

Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=285799&r1=285798&r2=285799&view=diff
==
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Wed Nov  2 05:39:27 2016
@@ -7457,7 +7457,7 @@ class FieldEncoding {
   std::string Enc;
 public:
   FieldEncoding(bool b, SmallStringEnc &e) : HasName(b), Enc(e.c_str()) {}
-  StringRef str() {return Enc.c_str();}
+  StringRef str() { return Enc; }
   bool operator<(const FieldEncoding &rhs) const {
 if (HasName != rhs.HasName) return HasName;
 return Enc < rhs.Enc;
@@ -7623,7 +7623,7 @@ StringRef TypeStringCache::lookupStr(con
 E.State = IncompleteUsed;
 ++IncompleteUsedCount;
   }
-  return E.Str.c_str();
+  return E.Str;
 }
 
 /// The XCore ABI includes a type information section that communicates symbol

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=285799&r1=285798&r2=285799&view=diff
==
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Wed Nov  2 05:39:27 2016
@@ -874,8 +874,7 @@ void Driver::setUpResponseFiles(Compilat
 return;
 
   std::string TmpName = GetTemporaryPath("response", "txt");
-  Cmd.setResponseFile(
-  C.addTempFile(C.getArgs().MakeArgString(TmpName.c_str(;
+  Cmd.setResponseFile(C.addTempFile(C.getArgs().MakeArgString(TmpName)));
 }
 
 int Driver::ExecuteCompilation(
@@ -3295,7 +3294,7 @@ const char *Driver::GetNamedOutputPath(C
 std::pair Split = Name.split('.');
 std::string TmpName = GetTemporaryPath(
 Split.first, types::getTypeTempSuffix(JA.getType(), IsCLMode()));
-return C.addTempFile(C.getArgs().MakeArgString(TmpName.c_str()));
+return C.addTempFile(C.getArgs().MakeArgString(TmpName));
   }
 
   SmallString<128> BasePath(BaseInput);
@@ -3344,7 +3343,7 @@ const char *Driver::GetNamedOutputPath(C
   NamedOutput = C.getArgs().MakeArgString(Output.c_str());
 }
   } else if (JA.getType() == types::TY_PCH && IsCLMode()) {
-NamedOutput = C.getArgs().MakeArgString(GetClPchPath(C, BaseName).c_str());
+NamedOutput = C.getArgs().MakeArgString(GetClPchPath(C, BaseName));
   } else {
 const char *Suffix = types::getTypeTempSuffix(JA.getType(), IsCLMode());
 assert(Suffix && "All types used for output sh

[PATCH] D26234: [Frontend] Add a predefined macro that describes the Objective-C bool type

2016-11-02 Thread Alex Lorenz via cfe-commits
arphaman created this revision.
arphaman added reviewers: bob.wilson, steven_wu.
arphaman added a subscriber: cfe-commits.
arphaman set the repository for this revision to rL LLVM.

This patch adds a new predefined macro named `__OBJC_BOOL_IS_BOOL` that 
describes the Objective-C boolean type: its value is zero if the Objective-C 
boolean uses the signed character type, otherwise its value is one as the 
Objective-C boolean uses the builtin boolean type.


Repository:
  rL LLVM

https://reviews.llvm.org/D26234

Files:
  lib/Frontend/InitPreprocessor.cpp
  test/Frontend/objc-bool-is-bool.m


Index: test/Frontend/objc-bool-is-bool.m
===
--- /dev/null
+++ test/Frontend/objc-bool-is-bool.m
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fsyntax-only -E -dM -triple=armv7k-apple-watchos %s | 
FileCheck --check-prefix=BOOL %s
+// RUN: %clang_cc1 -fsyntax-only -E -dM -triple=x86_64-apple-darwin16 %s | 
FileCheck --check-prefix=CHAR %s
+// RUN: %clang_cc1 -x c -fsyntax-only -E -dM -triple=x86_64-apple-darwin16 %s 
| FileCheck --check-prefix=NONE %s
+
+// rdar://21170440
+
+// BOOL: #define __OBJC_BOOL_IS_BOOL 1
+// BOOL-NOT: #define __OBJC_BOOL_IS_BOOL 0
+
+// CHAR: #define __OBJC_BOOL_IS_BOOL 0
+// CHAR-NOT: #define __OBJC_BOOL_IS_BOOL 1
+
+// NONE-NOT: __OBJC_BOOL_IS_BOOL
Index: lib/Frontend/InitPreprocessor.cpp
===
--- lib/Frontend/InitPreprocessor.cpp
+++ lib/Frontend/InitPreprocessor.cpp
@@ -591,6 +591,9 @@
 Builder.defineMacro("OBJC_ZEROCOST_EXCEPTIONS");
 }
 
+Builder.defineMacro("__OBJC_BOOL_IS_BOOL",
+Twine(TI.useSignedCharForObjCBool() ? "0" : "1"));
+
 if (LangOpts.getGC() != LangOptions::NonGC)
   Builder.defineMacro("__OBJC_GC__");
 


Index: test/Frontend/objc-bool-is-bool.m
===
--- /dev/null
+++ test/Frontend/objc-bool-is-bool.m
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fsyntax-only -E -dM -triple=armv7k-apple-watchos %s | FileCheck --check-prefix=BOOL %s
+// RUN: %clang_cc1 -fsyntax-only -E -dM -triple=x86_64-apple-darwin16 %s | FileCheck --check-prefix=CHAR %s
+// RUN: %clang_cc1 -x c -fsyntax-only -E -dM -triple=x86_64-apple-darwin16 %s | FileCheck --check-prefix=NONE %s
+
+// rdar://21170440
+
+// BOOL: #define __OBJC_BOOL_IS_BOOL 1
+// BOOL-NOT: #define __OBJC_BOOL_IS_BOOL 0
+
+// CHAR: #define __OBJC_BOOL_IS_BOOL 0
+// CHAR-NOT: #define __OBJC_BOOL_IS_BOOL 1
+
+// NONE-NOT: __OBJC_BOOL_IS_BOOL
Index: lib/Frontend/InitPreprocessor.cpp
===
--- lib/Frontend/InitPreprocessor.cpp
+++ lib/Frontend/InitPreprocessor.cpp
@@ -591,6 +591,9 @@
 Builder.defineMacro("OBJC_ZEROCOST_EXCEPTIONS");
 }
 
+Builder.defineMacro("__OBJC_BOOL_IS_BOOL",
+Twine(TI.useSignedCharForObjCBool() ? "0" : "1"));
+
 if (LangOpts.getGC() != LangOptions::NonGC)
   Builder.defineMacro("__OBJC_GC__");
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26139: Tests for strings conversions under libcpp-no-exceptions

2016-11-02 Thread Asiri Rathnayake via cfe-commits
rmaprath added a comment.

Would it be more cleaner to separate out the exceptions-related tests into 
their own functions? So, we'd have the two functions `test_withexceptions()` 
and `test_noexceptions()`; the former will only be invoked when testing the 
normal library variant, the latter will be invoked for all the library variants.

WDYT?

/ Asiri


https://reviews.llvm.org/D26139



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


[libcxx] r285792 - Remove spurious token from #endif

2016-11-02 Thread Roger Ferrer Ibanez via cfe-commits
Author: rogfer01
Date: Wed Nov  2 03:36:43 2016
New Revision: 285792

URL: http://llvm.org/viewvc/llvm-project?rev=285792&view=rev
Log:
Remove spurious token from #endif


Modified:

libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow.pass.cpp

Modified: 
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow.pass.cpp?rev=285792&r1=285791&r2=285792&view=diff
==
--- 
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow.pass.cpp
 Wed Nov  2 03:36:43 2016
@@ -40,7 +40,7 @@ int main()
 std::set_new_handler(new_handler);
 #ifndef TEST_HAS_NO_EXCEPTIONS
 try
-#endif TEST_HAS_NO_EXCEPTIONS
+#endif
 {
 void*volatile vp = operator new [] 
(std::numeric_limits::max(), std::nothrow);
 assert(new_handler_called == 1);


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


[PATCH] D26197: Protect tests for new/delete under libcpp-no-exceptions

2016-11-02 Thread Roger Ferrer Ibanez via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL285791: Protect tests for new/delete under 
libcpp-no-exceptions (authored by rogfer01).

Changed prior to commit:
  https://reviews.llvm.org/D26197?vs=76575&id=76675#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D26197

Files:
  
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array.pass.cpp
  
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow.pass.cpp
  
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new.pass.cpp
  
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_nothrow.pass.cpp

Index: libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_nothrow.pass.cpp
===
--- libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_nothrow.pass.cpp
+++ libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_nothrow.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 
-// XFAIL: libcpp-no-exceptions
 // test operator new (nothrow)
 
 // asan and msan will not call the new handler.
@@ -18,6 +17,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 int new_handler_called = 0;
 
 void new_handler()
@@ -37,16 +38,20 @@
 int main()
 {
 std::set_new_handler(new_handler);
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
+#endif
 {
 void* vp = operator new (std::numeric_limits::max(), std::nothrow);
 assert(new_handler_called == 1);
 assert(vp == 0);
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 catch (...)
 {
 assert(false);
 }
+#endif
 A* ap = new(std::nothrow) A;
 assert(ap);
 assert(A_constructed);
Index: libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new.pass.cpp
===
--- libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new.pass.cpp
+++ libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new.pass.cpp
@@ -7,8 +7,6 @@
 //
 //===--===//
 
-// XFAIL: libcpp-no-exceptions
-
 // test operator new
 
 // asan and msan will not call the new handler.
@@ -19,6 +17,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 int new_handler_called = 0;
 
 void new_handler()
@@ -37,6 +37,7 @@
 
 int main()
 {
+#ifndef TEST_HAS_NO_EXCEPTIONS
 std::set_new_handler(new_handler);
 try
 {
@@ -52,6 +53,7 @@
 {
 assert(false);
 }
+#endif
 A* ap = new A;
 assert(ap);
 assert(A_constructed);
Index: libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow.pass.cpp
===
--- libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow.pass.cpp
+++ libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 
-// XFAIL: libcpp-no-exceptions
 // test operator new [] (nothrow)
 // NOTE: asan and msan will not call the new handler.
 // UNSUPPORTED: sanitizer-new-delete
@@ -18,6 +17,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 int new_handler_called = 0;
 
 void new_handler()
@@ -37,16 +38,20 @@
 int main()
 {
 std::set_new_handler(new_handler);
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
+#endif TEST_HAS_NO_EXCEPTIONS
 {
 void*volatile vp = operator new [] (std::numeric_limits::max(), std::nothrow);
 assert(new_handler_called == 1);
 assert(vp == 0);
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 catch (...)
 {
 assert(false);
 }
+#endif
 A* ap = new(std::nothrow) A[3];
 assert(ap);
 assert(A_constructed == 3);
Index: libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array.pass.cpp
===
--- libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array.pass.cpp
+++ libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 
-// XFAIL: libcpp-no-exceptions
 // test operator new[]
 // NOTE: asan and msan will not call the new handler.
 // UNSUPPORTED: sanitizer-new-delete
@@ -18,6 +17,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 int new_handler_called = 0;
 
 void new_handler()
@@ -36,6 +37,7 @@
 
 int main()

[PATCH] D25008: [cmake] Split linked libraries into private & public, for linker script

2016-11-02 Thread Jonas Hahnfeld via cfe-commits
Hahnfeld added a comment.

Please disregard the noise, I think the error lays in the testing of 
`compiler-rt` which clears `LIBRARY_PATH` and therefore doesn't find the right 
`libunwind`!


Repository:
  rL LLVM

https://reviews.llvm.org/D25008



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


  1   2   >