Re: [PATCH] D19524: [OpenCL] Fix pipe type dump.

2016-04-26 Thread Xiuli PAN via cfe-commits
pxli168 updated this revision to Diff 55161.
pxli168 added a comment.

Add test and fix some old test.


http://reviews.llvm.org/D19524

Files:
  lib/AST/ASTDumper.cpp
  lib/AST/TypePrinter.cpp
  test/Misc/ast-dump-pipe.cl
  test/SemaOpenCL/invalid-access-qualifier.cl
  test/SemaOpenCL/invalid-pipes-cl2.0.cl

Index: test/SemaOpenCL/invalid-pipes-cl2.0.cl
===
--- test/SemaOpenCL/invalid-pipes-cl2.0.cl
+++ test/SemaOpenCL/invalid-pipes-cl2.0.cl
@@ -7,5 +7,5 @@
 void test3(int pipe p){// expected-error {{cannot combine with previous 'int' 
declaration specifier}}
 }
 void test4() {
-  pipe int p; // expected-error {{type 'pipe' can only be used as a function 
parameter}}
+  pipe int p; // expected-error {{type 'pipe int' can only be used as a 
function parameter}}
 }
Index: test/SemaOpenCL/invalid-access-qualifier.cl
===
--- test/SemaOpenCL/invalid-access-qualifier.cl
+++ test/SemaOpenCL/invalid-access-qualifier.cl
@@ -8,7 +8,7 @@
 void test3(read_only read_only image1d_t i){} // expected-error{{multiple 
access qualifiers}}
 
 #ifdef CL20
-void test4(read_write pipe int i){} // expected-error{{access qualifier 
'read_write' can not be used for 'pipe'}}
+void test4(read_write pipe int i){} // expected-error{{access qualifier 
'read_write' can not be used for 'pipe int'}}
 #else
 void test4(__read_write image1d_t i) {} // expected-error{{access qualifier 
'__read_write' can not be used for '__read_write image1d_t' earlier than 
OpenCL2.0 version}}
 #endif
Index: test/Misc/ast-dump-pipe.cl
===
--- /dev/null
+++ test/Misc/ast-dump-pipe.cl
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -triple spir64 -cl-std=CL2.0 -ast-dump -ast-dump-filter 
pipetype %s | FileCheck -strict-whitespace %s
+typedef pipe int pipetype;
+// CHECK:  PipeType {{.*}} 'pipe int'
+// CHECK-NEXT:   BuiltinType {{.*}} 'int'
Index: lib/AST/TypePrinter.cpp
===
--- lib/AST/TypePrinter.cpp
+++ lib/AST/TypePrinter.cpp
@@ -895,7 +895,8 @@
 void TypePrinter::printPipeBefore(const PipeType *T, raw_ostream ) {
   IncludeStrongLifetimeRAII Strong(Policy);
 
-  OS << "pipe";
+  OS << "pipe ";
+  print(T->getElementType(), OS, StringRef());
   spaceBeforePlaceHolder(OS);
 }
 
Index: lib/AST/ASTDumper.cpp
===
--- lib/AST/ASTDumper.cpp
+++ lib/AST/ASTDumper.cpp
@@ -404,6 +404,9 @@
 void VisitAtomicType(const AtomicType *T) {
   dumpTypeAsChild(T->getValueType());
 }
+void VisitPipeType(const PipeType *T) {
+  dumpTypeAsChild(T->getElementType());
+}
 void VisitAdjustedType(const AdjustedType *T) {
   dumpTypeAsChild(T->getOriginalType());
 }


Index: test/SemaOpenCL/invalid-pipes-cl2.0.cl
===
--- test/SemaOpenCL/invalid-pipes-cl2.0.cl
+++ test/SemaOpenCL/invalid-pipes-cl2.0.cl
@@ -7,5 +7,5 @@
 void test3(int pipe p){// expected-error {{cannot combine with previous 'int' declaration specifier}}
 }
 void test4() {
-  pipe int p; // expected-error {{type 'pipe' can only be used as a function parameter}}
+  pipe int p; // expected-error {{type 'pipe int' can only be used as a function parameter}}
 }
Index: test/SemaOpenCL/invalid-access-qualifier.cl
===
--- test/SemaOpenCL/invalid-access-qualifier.cl
+++ test/SemaOpenCL/invalid-access-qualifier.cl
@@ -8,7 +8,7 @@
 void test3(read_only read_only image1d_t i){} // expected-error{{multiple access qualifiers}}
 
 #ifdef CL20
-void test4(read_write pipe int i){} // expected-error{{access qualifier 'read_write' can not be used for 'pipe'}}
+void test4(read_write pipe int i){} // expected-error{{access qualifier 'read_write' can not be used for 'pipe int'}}
 #else
 void test4(__read_write image1d_t i) {} // expected-error{{access qualifier '__read_write' can not be used for '__read_write image1d_t' earlier than OpenCL2.0 version}}
 #endif
Index: test/Misc/ast-dump-pipe.cl
===
--- /dev/null
+++ test/Misc/ast-dump-pipe.cl
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -triple spir64 -cl-std=CL2.0 -ast-dump -ast-dump-filter pipetype %s | FileCheck -strict-whitespace %s
+typedef pipe int pipetype;
+// CHECK:  PipeType {{.*}} 'pipe int'
+// CHECK-NEXT:   BuiltinType {{.*}} 'int'
Index: lib/AST/TypePrinter.cpp
===
--- lib/AST/TypePrinter.cpp
+++ lib/AST/TypePrinter.cpp
@@ -895,7 +895,8 @@
 void TypePrinter::printPipeBefore(const PipeType *T, raw_ostream ) {
   IncludeStrongLifetimeRAII Strong(Policy);
 
-  OS << "pipe";
+  OS << "pipe ";
+  print(T->getElementType(), OS, StringRef());
   spaceBeforePlaceHolder(OS);
 }
 
Index: 

[PATCH] D19577: [clang-tidy] Enhance misc-suspicious-string-compare by matching string.compare

2016-04-26 Thread Etienne Bergeron via cfe-commits
etienneb created this revision.
etienneb added a reviewer: alexfh.
etienneb added a subscriber: cfe-commits.

This patch added the support for method "compare" on string-like classes.

The LLVM stringRef is supported. The checker assume that StringRef is returning 
-1, 0 or 1.
Which is not the case for other functions returning <0, 0 or >0.

http://reviews.llvm.org/D19577

Files:
  clang-tidy/misc/SuspiciousStringCompareCheck.cpp
  test/clang-tidy/misc-suspicious-string-compare.cpp

Index: test/clang-tidy/misc-suspicious-string-compare.cpp
===
--- test/clang-tidy/misc-suspicious-string-compare.cpp
+++ test/clang-tidy/misc-suspicious-string-compare.cpp
@@ -6,6 +6,34 @@
 
 typedef __SIZE_TYPE__ size;
 
+namespace std {
+template 
+class allocator {};
+template 
+class char_traits {};
+template 
+struct basic_string {
+  typedef basic_string _Type;
+  basic_string();
+  basic_string(const C *p, const A  = A());
+
+  int compare(const C* s) const;
+};
+
+typedef basic_string string;
+typedef basic_string wstring;
+}
+
+namespace llvm {
+struct StringRef {
+  StringRef();
+  StringRef(const char*);
+  int compare(StringRef RHS);
+  int compare_lower(StringRef RHS);
+  int compare_numeric(StringRef RHS);
+};
+}
+
 struct locale_t {
   void* dummy;
 } locale;
@@ -335,3 +363,56 @@
 
   return 1;
 }
+
+int test_string_patterns() {
+  std::string str;
+  if (str.compare("a"))
+return 0;
+  // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'compare' is called without explicitly comparing result
+  // CHECK-FIXES: if (str.compare("a") != 0)
+
+  if (str.compare("a") == 0 ||
+  str.compare("b"))
+return 0;
+  // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'compare' is called without explicitly comparing result
+  // CHECK-FIXES: str.compare("b") != 0)
+
+  if (str.compare("a") == 1)
+return 0;
+  // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'compare' is compared to a suspicious constant
+
+  if (str.compare("a") == 2)
+return 0;
+  // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'compare' is compared to a suspicious constant
+}
+
+int test_llvm_patterns() {
+  llvm::StringRef str;
+  if (str.compare("a"))
+return 0;
+  // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'compare' is called without explicitly comparing result
+  // CHECK-FIXES: if (str.compare("a") != 0)
+
+  if (str.compare_lower("a"))
+return 0;
+  // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'compare_lower' is called without explicitly comparing result
+  // CHECK-FIXES: if (str.compare_lower("a") != 0)   
+
+  if (str.compare("a") == 0 ||
+  str.compare("b"))
+return 0;
+  // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'compare' is called without explicitly comparing result
+  // CHECK-FIXES: str.compare("b") != 0)
+ 
+  if (str.compare("a") == 2)
+return 0;
+  // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'compare' is compared to a suspicious constant
+
+  // The following calls are valid.
+  if (str.compare("a") == 1) return 0;
+  if (str.compare("a") != 1) return 0;
+  if (str.compare("a") == 0) return 0;
+  if (str.compare("a") != 0) return 0;
+  if (str.compare("a") == -1) return 0;
+  if (str.compare("a") != -1) return 0;
+}
Index: clang-tidy/misc/SuspiciousStringCompareCheck.cpp
===
--- clang-tidy/misc/SuspiciousStringCompareCheck.cpp
+++ clang-tidy/misc/SuspiciousStringCompareCheck.cpp
@@ -8,10 +8,10 @@
 //===--===//
 
 #include "SuspiciousStringCompareCheck.h"
+#include "../utils/Matchers.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/Lex/Lexer.h"
-#include "../utils/Matchers.h"
 
 using namespace clang::ast_matchers;
 
@@ -106,20 +106,37 @@
   ParseFunctionNames(KnownStringCompareFunctions, );
   ParseFunctionNames(StringCompareLikeFunctions, );
 
-  // Match a call to a string compare functions.
+  // Match a std::string::compare call.
+  const auto StdStringCompareCallExpr =
+  cxxMemberCallExpr(callee(cxxMethodDecl(ofClass(hasName("basic_string")),
+ hasName("compare"))
+   .bind("decl")))
+  .bind("call");
+
+  // Match llvm strings variants.
+  const auto LLVMStringCompareCallExpr =
+  cxxMemberCallExpr(
+  callee(cxxMethodDecl(hasAnyName("::llvm::StringRef::compare",
+  "::llvm::StringRef::compare_lower",
+  "::llvm::StringRef::compare_numeric"))
+ .bind("decl")))
+  .bind("call");
+
+  // Match a call to a string compare functions (i.e. strcmp).
   const auto FunctionCompareDecl =
   

Re: [PATCH] D19524: [OpenCL] Fix pipe type dump.

2016-04-26 Thread Xiuli PAN via cfe-commits
pxli168 added a comment.

I will add a test and send a new version.


http://reviews.llvm.org/D19524



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


Re: r267534 - [MSVC] PR27337: allow static_cast from private base to derived for WTL

2016-04-26 Thread Richard Smith via cfe-commits
On Tue, Apr 26, 2016 at 7:04 PM, David Majnemer via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Visual Studio 2015 (19.00.23720.0) reports:
>
> error C2243: 'static_cast': conversion from 'B *' to 'A *' exists, but is
> inaccessible
>

Right, it's the other direction ('A *' to 'B *') that this patch is
permitting.


> On Tue, Apr 26, 2016 at 6:33 PM, Richard Smith via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> As noted in PR27337, this only occurs in one WTL sample, and we have no
>> evidence that it actually occurs in real code. Have you seen uses of this
>> in the wild? We generally don't want to add compatibility for MSVC bugs
>> unless there's some real-world motivation.
>>
>>
>> On Tue, Apr 26, 2016 at 2:21 AM, Dmitry Polukhin via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Author: dpolukhin
>>> Date: Tue Apr 26 04:21:17 2016
>>> New Revision: 267534
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=267534=rev
>>> Log:
>>> [MSVC] PR27337: allow static_cast from private base to derived for WTL
>>>
>>> MSVC doesn't report even warning for cast from private base class to
>>> derived.
>>>
>>> Differential Revision: http://reviews.llvm.org/D19477
>>>
>>> Added:
>>> cfe/trunk/test/SemaCXX/ext_ms_downcast.cpp   (with props)
>>> Modified:
>>> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>>> cfe/trunk/lib/Sema/SemaCast.cpp
>>>
>>> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=267534=267533=267534=diff
>>>
>>> ==
>>> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
>>> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Apr 26
>>> 04:21:17 2016
>>> @@ -5764,6 +5764,9 @@ def err_static_downcast_via_virtual : Er
>>>"cannot cast %0 to %1 via virtual base %2">;
>>>  def err_downcast_from_inaccessible_base : Error<
>>>"cannot cast %select{private|protected}2 base class %1 to %0">;
>>> +def ext_ms_downcast_from_inaccessible_base : ExtWarn<
>>> +  "casting from %select{private|protected}2 base class %1 to derived
>>> class %0 is a Microsoft extension">,
>>> +  InGroup;
>>>  def err_upcast_to_inaccessible_base : Error<
>>>"cannot cast %0 to its %select{private|protected}2 base class %1">;
>>>  def err_bad_dynamic_cast_not_ref_or_ptr : Error<
>>>
>>> Modified: cfe/trunk/lib/Sema/SemaCast.cpp
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCast.cpp?rev=267534=267533=267534=diff
>>>
>>> ==
>>> --- cfe/trunk/lib/Sema/SemaCast.cpp (original)
>>> +++ cfe/trunk/lib/Sema/SemaCast.cpp Tue Apr 26 04:21:17 2016
>>> @@ -1344,10 +1344,11 @@ TryStaticDowncast(Sema , CanQualTyp
>>>}
>>>
>>>if (!CStyle) {
>>> -switch (Self.CheckBaseClassAccess(OpRange.getBegin(),
>>> -  SrcType, DestType,
>>> -  Paths.front(),
>>> -
>>> diag::err_downcast_from_inaccessible_base)) {
>>> +unsigned Diag = Self.getLangOpts().MSVCCompat
>>> +? diag::ext_ms_downcast_from_inaccessible_base
>>> +: diag::err_downcast_from_inaccessible_base;
>>> +switch (Self.CheckBaseClassAccess(OpRange.getBegin(), SrcType,
>>> DestType,
>>> +  Paths.front(), Diag)) {
>>>  case Sema::AR_accessible:
>>>  case Sema::AR_delayed: // be optimistic
>>>  case Sema::AR_dependent:   // be optimistic
>>>
>>> Added: cfe/trunk/test/SemaCXX/ext_ms_downcast.cpp
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/ext_ms_downcast.cpp?rev=267534=auto
>>>
>>> ==
>>> --- cfe/trunk/test/SemaCXX/ext_ms_downcast.cpp (added)
>>> +++ cfe/trunk/test/SemaCXX/ext_ms_downcast.cpp Tue Apr 26 04:21:17 2016
>>> @@ -0,0 +1,40 @@
>>> +// RUN: %clang_cc1 -fsyntax-only -fms-compatibility -verify %s
>>> +// RUN: %clang_cc1 -fsyntax-only -DNO_MS_COMPATIBILITY -verify %s
>>> +
>>> +// Minimal reproducer.
>>> +class A {};
>>> +class B : A {}; // expected-note 2 {{implicitly declared private here}}
>>> +
>>> +B* foo(A* p) {
>>> +  return static_cast(p);
>>> +#ifdef NO_MS_COMPATIBILITY
>>> +  // expected-error@-2 {{cannot cast private base class 'A' to 'B'}}
>>> +#else
>>> +  // expected-warning@-4 {{casting from private base class 'A' to
>>> derived class 'B' is a Microsoft extension}}
>>> +#endif
>>> +}
>>> +
>>> +A* bar(B* p) {
>>> +  return static_cast(p); // expected-error {{cannot cast 'B' to its
>>> private base class 'A'}}
>>> +}
>>> +
>>> +// from atlframe.h
>>> +template 
>>> +class CUpdateUI {
>>> +public:
>>> +  CUpdateUI() {
>>> +T* pT = static_cast(this);
>>> +#ifdef NO_MS_COMPATIBILITY
>>> +// 

Re: r267534 - [MSVC] PR27337: allow static_cast from private base to derived for WTL

2016-04-26 Thread David Majnemer via cfe-commits
Visual Studio 2015 (19.00.23720.0) reports:

error C2243: 'static_cast': conversion from 'B *' to 'A *' exists, but is
inaccessible

On Tue, Apr 26, 2016 at 6:33 PM, Richard Smith via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> As noted in PR27337, this only occurs in one WTL sample, and we have no
> evidence that it actually occurs in real code. Have you seen uses of this
> in the wild? We generally don't want to add compatibility for MSVC bugs
> unless there's some real-world motivation.
>
>
> On Tue, Apr 26, 2016 at 2:21 AM, Dmitry Polukhin via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: dpolukhin
>> Date: Tue Apr 26 04:21:17 2016
>> New Revision: 267534
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=267534=rev
>> Log:
>> [MSVC] PR27337: allow static_cast from private base to derived for WTL
>>
>> MSVC doesn't report even warning for cast from private base class to
>> derived.
>>
>> Differential Revision: http://reviews.llvm.org/D19477
>>
>> Added:
>> cfe/trunk/test/SemaCXX/ext_ms_downcast.cpp   (with props)
>> Modified:
>> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>> cfe/trunk/lib/Sema/SemaCast.cpp
>>
>> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=267534=267533=267534=diff
>>
>> ==
>> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
>> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Apr 26
>> 04:21:17 2016
>> @@ -5764,6 +5764,9 @@ def err_static_downcast_via_virtual : Er
>>"cannot cast %0 to %1 via virtual base %2">;
>>  def err_downcast_from_inaccessible_base : Error<
>>"cannot cast %select{private|protected}2 base class %1 to %0">;
>> +def ext_ms_downcast_from_inaccessible_base : ExtWarn<
>> +  "casting from %select{private|protected}2 base class %1 to derived
>> class %0 is a Microsoft extension">,
>> +  InGroup;
>>  def err_upcast_to_inaccessible_base : Error<
>>"cannot cast %0 to its %select{private|protected}2 base class %1">;
>>  def err_bad_dynamic_cast_not_ref_or_ptr : Error<
>>
>> Modified: cfe/trunk/lib/Sema/SemaCast.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCast.cpp?rev=267534=267533=267534=diff
>>
>> ==
>> --- cfe/trunk/lib/Sema/SemaCast.cpp (original)
>> +++ cfe/trunk/lib/Sema/SemaCast.cpp Tue Apr 26 04:21:17 2016
>> @@ -1344,10 +1344,11 @@ TryStaticDowncast(Sema , CanQualTyp
>>}
>>
>>if (!CStyle) {
>> -switch (Self.CheckBaseClassAccess(OpRange.getBegin(),
>> -  SrcType, DestType,
>> -  Paths.front(),
>> -
>> diag::err_downcast_from_inaccessible_base)) {
>> +unsigned Diag = Self.getLangOpts().MSVCCompat
>> +? diag::ext_ms_downcast_from_inaccessible_base
>> +: diag::err_downcast_from_inaccessible_base;
>> +switch (Self.CheckBaseClassAccess(OpRange.getBegin(), SrcType,
>> DestType,
>> +  Paths.front(), Diag)) {
>>  case Sema::AR_accessible:
>>  case Sema::AR_delayed: // be optimistic
>>  case Sema::AR_dependent:   // be optimistic
>>
>> Added: cfe/trunk/test/SemaCXX/ext_ms_downcast.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/ext_ms_downcast.cpp?rev=267534=auto
>>
>> ==
>> --- cfe/trunk/test/SemaCXX/ext_ms_downcast.cpp (added)
>> +++ cfe/trunk/test/SemaCXX/ext_ms_downcast.cpp Tue Apr 26 04:21:17 2016
>> @@ -0,0 +1,40 @@
>> +// RUN: %clang_cc1 -fsyntax-only -fms-compatibility -verify %s
>> +// RUN: %clang_cc1 -fsyntax-only -DNO_MS_COMPATIBILITY -verify %s
>> +
>> +// Minimal reproducer.
>> +class A {};
>> +class B : A {}; // expected-note 2 {{implicitly declared private here}}
>> +
>> +B* foo(A* p) {
>> +  return static_cast(p);
>> +#ifdef NO_MS_COMPATIBILITY
>> +  // expected-error@-2 {{cannot cast private base class 'A' to 'B'}}
>> +#else
>> +  // expected-warning@-4 {{casting from private base class 'A' to
>> derived class 'B' is a Microsoft extension}}
>> +#endif
>> +}
>> +
>> +A* bar(B* p) {
>> +  return static_cast(p); // expected-error {{cannot cast 'B' to its
>> private base class 'A'}}
>> +}
>> +
>> +// from atlframe.h
>> +template 
>> +class CUpdateUI {
>> +public:
>> +  CUpdateUI() {
>> +T* pT = static_cast(this);
>> +#ifdef NO_MS_COMPATIBILITY
>> +// expected-error@-2 {{cannot cast private base class}}
>> +#else
>> +// expected-warning@-4 {{casting from private base class
>> 'CUpdateUI' to derived class 'CMDIFrame' is a Microsoft
>> extension}}
>> +#endif
>> +  }
>> +};
>> +
>> +// from sample WTL/MDIDocVw (mainfrm.h
>> +class CMDIFrame : CUpdateUI {};
>> +// 

[libcxx] r267654 - Fix = that should have been == in test. Thanks to STL@microsoft for the catch

2016-04-26 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Tue Apr 26 20:46:43 2016
New Revision: 267654

URL: http://llvm.org/viewvc/llvm-project?rev=267654=rev
Log:
Fix = that should have been == in test. Thanks to STL@microsoft for the catch

Modified:
libcxx/trunk/test/std/containers/associative/map/compare.pass.cpp

Modified: libcxx/trunk/test/std/containers/associative/map/compare.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/associative/map/compare.pass.cpp?rev=267654=267653=267654=diff
==
--- libcxx/trunk/test/std/containers/associative/map/compare.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/associative/map/compare.pass.cpp Tue Apr 
26 20:46:43 2016
@@ -44,7 +44,7 @@ int main()
 MapT map;
 IterBool result = map.insert(std::make_pair(Key(0), 42));
 assert(result.second);
-assert(result.first->second = 42);
+assert(result.first->second == 42);
 IterBool result2 = map.insert(std::make_pair(Key(0), 43));
 assert(!result2.second);
 assert(map[Key(0)] == 42);


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


Re: [PATCH] D19565: [libc++] Fix an accidental assignment within assert() that should have been equality.

2016-04-26 Thread Marshall Clow via cfe-commits
mclow.lists closed this revision.
mclow.lists added a comment.

Committed as revision 267654.


http://reviews.llvm.org/D19565



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


Re: [PATCH] D18641: [PP] Handle #include_next after include found relative to current one same as GCC

2016-04-26 Thread Richard Smith via cfe-commits
rsmith added a comment.

I'm a little concerned about the possibility of this breaking uses of this 
feature on platforms where Clang is the system compiler. For instance, this 
pattern would be broken by your change:

  // stddef.h
  #include "stddef-helper.h"
  
  // stddef-helper.h
  #include_next 

Conversely, I don't think any important library is likely to be relying on the 
GCC behavior, because compilations with "gcc -I-" would get the current Clang 
behavior (because relative-looking paths would be found in the relevant include 
search path rather than as relative paths).

Is there some way we can gain confidence we're not breaking things here?



Comment at: include/clang/Basic/DiagnosticLexKinds.td:268-269
@@ -267,4 +267,4 @@
   "the #__include_macros directive is only for internal use by -imacros">;
-def pp_include_next_absolute_path : Warning<
-  "#include_next with absolute path">,
+def pp_include_next_without_state : Warning<
+  "#include_next without previous state, searching from the beginning of the 
include directories list">,
   InGroup>;

Can you distinguish between the two cases here and give better diagnostics for 
both?

  "#include_next in file found by relative path, searching from [...]"
  "#include_next with absolute path, searching from [...]"

would be an improvement on this.


http://reviews.llvm.org/D18641



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


Re: [PATCH] D19565: [libc++] Fix an accidental assignment within assert() that should have been equality.

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

Whoops!  LGTM.


http://reviews.llvm.org/D19565



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


Re: r267534 - [MSVC] PR27337: allow static_cast from private base to derived for WTL

2016-04-26 Thread Richard Smith via cfe-commits
As noted in PR27337, this only occurs in one WTL sample, and we have no
evidence that it actually occurs in real code. Have you seen uses of this
in the wild? We generally don't want to add compatibility for MSVC bugs
unless there's some real-world motivation.

On Tue, Apr 26, 2016 at 2:21 AM, Dmitry Polukhin via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: dpolukhin
> Date: Tue Apr 26 04:21:17 2016
> New Revision: 267534
>
> URL: http://llvm.org/viewvc/llvm-project?rev=267534=rev
> Log:
> [MSVC] PR27337: allow static_cast from private base to derived for WTL
>
> MSVC doesn't report even warning for cast from private base class to
> derived.
>
> Differential Revision: http://reviews.llvm.org/D19477
>
> Added:
> cfe/trunk/test/SemaCXX/ext_ms_downcast.cpp   (with props)
> Modified:
> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> cfe/trunk/lib/Sema/SemaCast.cpp
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=267534=267533=267534=diff
>
> ==
> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Apr 26
> 04:21:17 2016
> @@ -5764,6 +5764,9 @@ def err_static_downcast_via_virtual : Er
>"cannot cast %0 to %1 via virtual base %2">;
>  def err_downcast_from_inaccessible_base : Error<
>"cannot cast %select{private|protected}2 base class %1 to %0">;
> +def ext_ms_downcast_from_inaccessible_base : ExtWarn<
> +  "casting from %select{private|protected}2 base class %1 to derived
> class %0 is a Microsoft extension">,
> +  InGroup;
>  def err_upcast_to_inaccessible_base : Error<
>"cannot cast %0 to its %select{private|protected}2 base class %1">;
>  def err_bad_dynamic_cast_not_ref_or_ptr : Error<
>
> Modified: cfe/trunk/lib/Sema/SemaCast.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCast.cpp?rev=267534=267533=267534=diff
>
> ==
> --- cfe/trunk/lib/Sema/SemaCast.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaCast.cpp Tue Apr 26 04:21:17 2016
> @@ -1344,10 +1344,11 @@ TryStaticDowncast(Sema , CanQualTyp
>}
>
>if (!CStyle) {
> -switch (Self.CheckBaseClassAccess(OpRange.getBegin(),
> -  SrcType, DestType,
> -  Paths.front(),
> -
> diag::err_downcast_from_inaccessible_base)) {
> +unsigned Diag = Self.getLangOpts().MSVCCompat
> +? diag::ext_ms_downcast_from_inaccessible_base
> +: diag::err_downcast_from_inaccessible_base;
> +switch (Self.CheckBaseClassAccess(OpRange.getBegin(), SrcType,
> DestType,
> +  Paths.front(), Diag)) {
>  case Sema::AR_accessible:
>  case Sema::AR_delayed: // be optimistic
>  case Sema::AR_dependent:   // be optimistic
>
> Added: cfe/trunk/test/SemaCXX/ext_ms_downcast.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/ext_ms_downcast.cpp?rev=267534=auto
>
> ==
> --- cfe/trunk/test/SemaCXX/ext_ms_downcast.cpp (added)
> +++ cfe/trunk/test/SemaCXX/ext_ms_downcast.cpp Tue Apr 26 04:21:17 2016
> @@ -0,0 +1,40 @@
> +// RUN: %clang_cc1 -fsyntax-only -fms-compatibility -verify %s
> +// RUN: %clang_cc1 -fsyntax-only -DNO_MS_COMPATIBILITY -verify %s
> +
> +// Minimal reproducer.
> +class A {};
> +class B : A {}; // expected-note 2 {{implicitly declared private here}}
> +
> +B* foo(A* p) {
> +  return static_cast(p);
> +#ifdef NO_MS_COMPATIBILITY
> +  // expected-error@-2 {{cannot cast private base class 'A' to 'B'}}
> +#else
> +  // expected-warning@-4 {{casting from private base class 'A' to
> derived class 'B' is a Microsoft extension}}
> +#endif
> +}
> +
> +A* bar(B* p) {
> +  return static_cast(p); // expected-error {{cannot cast 'B' to its
> private base class 'A'}}
> +}
> +
> +// from atlframe.h
> +template 
> +class CUpdateUI {
> +public:
> +  CUpdateUI() {
> +T* pT = static_cast(this);
> +#ifdef NO_MS_COMPATIBILITY
> +// expected-error@-2 {{cannot cast private base class}}
> +#else
> +// expected-warning@-4 {{casting from private base class
> 'CUpdateUI' to derived class 'CMDIFrame' is a Microsoft
> extension}}
> +#endif
> +  }
> +};
> +
> +// from sample WTL/MDIDocVw (mainfrm.h
> +class CMDIFrame : CUpdateUI {};
> +// expected-note@-1 {{implicitly declared private here}}
> +// expected-note@-2 {{in instantiation of member function}}
> +
> +CMDIFrame wndMain;
>
> Propchange: cfe/trunk/test/SemaCXX/ext_ms_downcast.cpp
>
> --
> svn:eol-style = native
>
> Propchange: 

Re: [PATCH] D19003: Set C99 as default C Standard for PS4 target

2016-04-26 Thread Paul Robinson via cfe-commits
probinson accepted this revision.
probinson added a reviewer: probinson.
probinson added a comment.
This revision is now accepted and ready to land.

LGTM.


http://reviews.llvm.org/D19003



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


Re: [PATCH] D19327: Keep invalid function body as part of the AST

2016-04-26 Thread Richard Smith via cfe-commits
rsmith added inline comments.


Comment at: lib/Sema/SemaDecl.cpp:5044-5045
@@ -5043,4 +5043,4 @@
   // function template specialization, add it to the scope stack.
-  if (New->getDeclName() && AddToScope &&
-   !(D.isRedeclaration() && New->isInvalidDecl())) {
+  if (New->getDeclName() && AddToScope && !(D.isRedeclaration()
+  && New->isInvalidDecl() && !D.isFunctionDefinition())) {
 // Only make a locally-scoped extern declaration visible if it is the first

Can we delete the invalid-decl check entirely here? If it's doing something 
important, we need to figure out what and make sure we preserve that intent if 
it's important, but either way it doesn't make a lot of sense to me for this to 
depend on whether the declaration has a definition.


http://reviews.llvm.org/D19327



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


Re: [PATCH] D19552: Check 'r' and 'y specifiers of freebsd_kernel_printf format strings on PS4

2016-04-26 Thread Sunil Srivastava via cfe-commits
Sunil_Srivastava closed this revision.
Sunil_Srivastava added a comment.

Submitted as r267625.


http://reviews.llvm.org/D19552



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


Re: [PATCH] D19567: PR21823: 'nodebug' attribute on global/static variables

2016-04-26 Thread Aaron Ballman via cfe-commits
aaron.ballman added a subscriber: aaron.ballman.
aaron.ballman accepted this revision.
aaron.ballman added a reviewer: aaron.ballman.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM on the attribute part. Someone else should pipe up if the debug info part 
looks incorrect, but it looks reasonable to me.



Comment at: include/clang/Basic/Attr.td:976
@@ -975,3 +975,3 @@
   let Spellings = [GCC<"nodebug">];
-  let Documentation = [Undocumented];
+  let Documentation = [NoDebugDocs];
 }

This isn't your problem to fix (though I would not complain if you did fix 
it!), but the lack of a Subjects line should be fixed at some point.


http://reviews.llvm.org/D19567



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


[PATCH] D19567: PR21823: 'nodebug' attribute on global/static variables

2016-04-26 Thread Paul Robinson via cfe-commits
probinson created this revision.
probinson added reviewers: dblaikie, aprantl.
probinson added a subscriber: cfe-commits.

'nodebug' on a function will currently suppress all debug info for the function 
and its contents.
'nodebug on a static-duration variable will currently suppress debug info for 
the associated static initializer function (if any).
This patch suppresses all debug info for the variable, as requested in PR21823.

As a follow-up I'd like to expand applicability of 'nodebug' to any variable, 
and non-static data members.


http://reviews.llvm.org/D19567

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  lib/CodeGen/CGDebugInfo.cpp
  test/CodeGenCXX/debug-info-nodebug.cpp

Index: test/CodeGenCXX/debug-info-nodebug.cpp
===
--- test/CodeGenCXX/debug-info-nodebug.cpp
+++ test/CodeGenCXX/debug-info-nodebug.cpp
@@ -0,0 +1,55 @@
+// RUN: %clang_cc1 -DSETNODEBUG=0 -emit-llvm -debug-info-kind=limited %s -o - | FileCheck %s --check-prefix=YESINFO
+// RUN: %clang_cc1 -DSETNODEBUG=1 -emit-llvm -debug-info-kind=limited %s -o - | FileCheck %s --check-prefix=NOINFO
+
+#if SETNODEBUG
+#define NODEBUG __attribute__((nodebug))
+#else
+#define NODEBUG
+#endif
+
+// Simple global variable declaration and definition.
+// Use the declaration so it gets emitted.
+NODEBUG int global_int_decl;
+NODEBUG int global_int_def = global_int_decl;
+// YESINFO-DAG: !DIGlobalVariable(name: "global_int_decl"
+// NOINFO-NOT:  !DIGlobalVariable(name: "global_int_decl"
+// YESINFO-DAG: !DIGlobalVariable(name: "global_int_def"
+// NOINFO-NOT:  !DIGlobalVariable(name: "global_int_def"
+
+// Const global variable. Use it so it gets emitted.
+NODEBUG static const int const_global_int_def = 1;
+void func1(int);
+void func2() { func1(const_global_int_def); }
+// YESINFO-DAG: !DIGlobalVariable(name: "const_global_int_def"
+// NOINFO-NOT:  !DIGlobalVariable(name: "const_global_int_def"
+
+// Global variable with a more involved type.
+// If the variable has no debug info, the type should not appear either.
+struct S1 {
+  int a;
+  int b;
+};
+NODEBUG S1 global_struct = { 2, 3 };
+// YESINFO-DAG: !DICompositeType({{.*}} name: "S1"
+// NOINFO-NOT:  !DICompositeType({{.*}} name: "S1"
+// YESINFO-DAG: !DIGlobalVariable(name: "global_struct"
+// NOINFO-NOT:  !DIGlobalVariable(name: "global_struct"
+
+// Static data members. Const member needs a use.
+struct S2 {
+  NODEBUG static int static_member;
+  NODEBUG static const int static_const_member = 4;
+};
+int S2::static_member = 5;
+int junk = S2::static_const_member;
+// YESINFO-DAG: !DIGlobalVariable(name: "static_member"
+// NOINFO-NOT:  !DIGlobalVariable(name: "static_member"
+// YESINFO-DAG: !DIDerivedType({{.*}} name: "static_const_member"
+// NOINFO-NOT:  !DIDerivedType({{.*}} name: "static_const_member"
+
+// Function-local static variable.
+void func3() {
+  NODEBUG static int func_local = 6;
+}
+// YESINFO-DAG: !DIGlobalVariable(name: "func_local"
+// NOINFO-NOT:  !DIGlobalVariable(name: "func_local"
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -1014,6 +1014,8 @@
 // the corresponding declarations in the source program.
 for (const auto *I : record->decls())
   if (const auto *V = dyn_cast(I)) {
+if (V->hasAttr())
+  continue;
 // Reuse the existing static member declaration if one exists
 auto MI = StaticDataMemberCache.find(V->getCanonicalDecl());
 if (MI != StaticDataMemberCache.end()) {
@@ -3391,6 +3393,8 @@
 void CGDebugInfo::EmitGlobalVariable(llvm::GlobalVariable *Var,
  const VarDecl *D) {
   assert(DebugKind >= codegenoptions::LimitedDebugInfo);
+  if (D->hasAttr())
+return;
   // Create global variable debug descriptor.
   llvm::DIFile *Unit = nullptr;
   llvm::DIScope *DContext = nullptr;
@@ -3423,6 +3427,8 @@
 void CGDebugInfo::EmitGlobalVariable(const ValueDecl *VD,
  llvm::Constant *Init) {
   assert(DebugKind >= codegenoptions::LimitedDebugInfo);
+  if (VD->hasAttr())
+return;
   // Create the descriptor for the variable.
   llvm::DIFile *Unit = getOrCreateFile(VD->getLocation());
   StringRef Name = VD->getName();
Index: include/clang/Basic/AttrDocs.td
===
--- include/clang/Basic/AttrDocs.td
+++ include/clang/Basic/AttrDocs.td
@@ -494,6 +494,15 @@
   }];
 }
 
+def NoDebugDocs : Documentation {
+  let Category = DocCatVariable;
+  let Content = [{
+The ``nodebug`` attribute allows you to suppress debugging information for a
+function, or for a variable declared with static storage duration, such as
+globals, class static data members, and static locals.
+  }];
+}
+
 def NoDuplicateDocs : Documentation {
   let Category = DocCatFunction;
   let Content = [{
Index: 

Re: r267464 - Module Debugging: Fix the condition for determining whether a template

2016-04-26 Thread Adrian Prantl via cfe-commits

> On Apr 26, 2016, at 4:11 PM, Richard Smith  wrote:
> 
> On Tue, Apr 26, 2016 at 3:10 PM, Adrian Prantl via cfe-commits 
> > wrote:
> 
>> On Apr 25, 2016, at 5:34 PM, Richard Smith > > wrote:
>> 
>> On Mon, Apr 25, 2016 at 1:52 PM, Adrian Prantl via cfe-commits 
>> > wrote:
>> Author: adrian
>> Date: Mon Apr 25 15:52:40 2016
>> New Revision: 267464
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=267464=rev 
>> 
>> Log:
>> Module Debugging: Fix the condition for determining whether a template
>> instantiation is in a module.
>> 
>> This patch fixes the condition for determining whether the debug info for a
>> template instantiation will exist in an imported clang module by:
>> 
>> - checking whether the ClassTemplateSpecializationDecl is complete and
>> - checking that the instantiation was in a module by looking at the first 
>> field.
>> 
>> I also added a negative check to make sure that a typedef to a 
>> forward-declared
>> template (with the definition outside of the module) is handled correctly.
>> 
>> http://reviews.llvm.org/D19443 
>> rdar://problem/25553724 <>
>> 
>> Modified:
>> cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
>> cfe/trunk/test/Modules/ExtDebugInfo.cpp
>> cfe/trunk/test/Modules/Inputs/DebugCXX.h
>> cfe/trunk/test/Modules/ModuleDebugInfo.cpp
>> 
>> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=267464=267463=267464=diff
>>  
>> 
>> ==
>> --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
>> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Mon Apr 25 15:52:40 2016
>> @@ -1514,12 +1514,28 @@ static bool hasExplicitMemberDefinition(
>>return false;
>>  }
>> 
>> +/// Does a type definition exist in an imported clang module?
>> +static bool isDefinedInClangModule(const RecordDecl *RD) {
>> +  if (!RD->isFromASTFile())
>> +return false;
>> +  if (!RD->getDefinition())
>> +return false;
>> +  if (!RD->isExternallyVisible() && RD->getName().empty())
>> +return false;
>> +  if (auto *CTSD = dyn_cast(RD)) {
>> 
>> The same issue also affects member classes of class template specializations 
>> (you can detect them with RD->getInstantiatedFromMemberClass(), or detect 
>> all the relevant cases at once with RD->getTemplateSpecializationKind()).
> 
> I added a testcase for this r267612, but I couldn’t reproduce the situation 
> that you were describing here. Do you have an example of what you had in mind?
> 
> Something just like your testcase for class template specializations should 
> work:
> 
> // DebugCXX.h
> template  class FwdDeclTemplateMember { class Member; };
> typedef FwdDeclTemplateMember::Member TypedefFwdDeclTemplateMember;
> 
> // ExtDebugInfo.cpp
> template  class FwdDeclTemplateMember::Member { T t; };
> TypedefFwdDeclTemplateMember tdfdtm;

Thanks, that does the trick! Fixed in r267630.

>> +if (!CTSD->isCompleteDefinition())
>> +  return false;
>> 
>> You already checked this a few lines above. Actually, the two checks do 
>> different things depending on whether RD or some other declaration is the 
>> definition; did you really mean to treat a (non-template) class that's 
>> defined locally but forward-declared within a module as being defined in 
>> that module? (It might make more sense to map to the definition upfront and 
>> do all your queries on that if that's what you intend to check.)
> 
> Thanks! I changed this in r267611 to always pass RD->getDefinition() into 
> isDefinedInClangModule. Does this make the check for isCompleteDefinition() 
> redundant?
> 
> Yes. The only other possibility here is that the class is currently being 
> defined (we're between the open and close braces), but as far as I know you 
> shouldn't ever see such a class from here, and you should certainly never see 
> one where the partial definition is imported from an AST file. You could 
> assert isCompleteDefinition() if you're worried that we might give you a bad 
> AST.

I added the assertion in r267633.

-- adrian
> 
>>  
>> +// Make sure the instantiation is actually in a module.
>> +if (CTSD->field_begin() != CTSD->field_end())
>> +  return CTSD->field_begin()->isFromASTFile();
>> +  }
>> +  return true;
>> +}
>> +
>>  static bool shouldOmitDefinition(codegenoptions::DebugInfoKind DebugKind,
>>   bool DebugTypeExtRefs, const RecordDecl 
>> *RD,
>>   const LangOptions ) {
>> -  // Does the type exist in an imported clang module?

Re: [PATCH] D19415: [libcxx][rfc] Externalized threading support

2016-04-26 Thread Asiri Rathnayake via cfe-commits
rmaprath updated this revision to Diff 55127.
rmaprath added a comment.

Addressing review comments from @bcraig:

Adjusted according to the changes of http://reviews.llvm.org/D19412. This patch 
is now mostly trivial.

There is a small catch in that, this version of the API takes 
pointer-to-pointer type arguments for most `__os_xxx` functions. This is partly 
because we need to use opaque pointer types to hide the underlying 
implementation details from libcxx internals. This can be worked-around by 
using some template hackery (along the lines of `is_pointer`), but I thought to 
leave it as it is to avoid cluttering up the sources for the normal use case.


http://reviews.llvm.org/D19415

Files:
  include/__os_support

Index: include/__os_support
===
--- include/__os_support
+++ include/__os_support
@@ -186,7 +186,71 @@
 pthread_setspecific(__key, __p);
 }
 
-#else // !_LIBCPP_THREAD_API_PTHREAD
+#elif defined(_LIBCPP_THREAD_API_EXTERNAL)
+
+// Mutex
+#define __OS_MUTEX_INITIALIZER 0
+struct __libcpp_mutex_external;
+typedef __libcpp_mutex_external* __libcpp_mutex;
+
+int __os_mutex_init(__libcpp_mutex* __m, bool is_recursive);
+
+int __os_mutex_lock(__libcpp_mutex* __m);
+
+int __os_mutex_trylock(__libcpp_mutex* __m);
+
+int __os_mutex_unlock(__libcpp_mutex* __m);
+
+int __os_mutex_destroy(__libcpp_mutex* __m);
+
+// Condition variable
+#define __OS_COND_INITIALIZER 0
+struct __libcpp_condvar_external;
+typedef __libcpp_condvar_external* __libcpp_condvar;
+
+int __os_condvar_signal(__libcpp_condvar* __cv);
+
+int __os_condvar_broadcast(__libcpp_condvar* __cv);
+
+int __os_condvar_wait(__libcpp_condvar* __cv, __libcpp_mutex* __m);
+
+int __os_condvar_timedwait(__libcpp_condvar* __cv, __libcpp_mutex* __m, 
timespec* __ts);
+
+int __os_condvar_destroy(__libcpp_condvar* __cv);
+
+// Thread id
+typedef unsigned long __libcpp_thread_id;
+
+int __os_thread_id_compare(__libcpp_thread_id t1, __libcpp_thread_id t2);
+
+// Thread
+struct __libcpp_thread_external;
+typedef __libcpp_thread_external* __libcpp_thread;
+
+template
+int __os_thread_create(__libcpp_thread* __t, _Func&& __f, _Arg&& __arg);
+
+__libcpp_thread_id __os_thread_get_current_id();
+
+__libcpp_thread_id __os_thread_get_id(const __libcpp_thread* __t);
+
+int __os_thread_join(__libcpp_thread* __t);
+
+int __os_thread_detach(__libcpp_thread* __t);
+
+void __os_thread_yield();
+
+// Thread local storage
+typedef unsigned long __libcpp_tl_key;
+
+template
+int __os_tl_create(__libcpp_tl_key* __key, _Func&& __at_exit);
+
+void* __os_tl_get(__libcpp_tl_key __key);
+
+void __os_tl_set(__libcpp_tl_key __key, void* __p);
+
+#else
   #error "No thread API selected."
 #endif
 


Index: include/__os_support
===
--- include/__os_support
+++ include/__os_support
@@ -186,7 +186,71 @@
 pthread_setspecific(__key, __p);
 }
 
-#else // !_LIBCPP_THREAD_API_PTHREAD
+#elif defined(_LIBCPP_THREAD_API_EXTERNAL)
+
+// Mutex
+#define __OS_MUTEX_INITIALIZER 0
+struct __libcpp_mutex_external;
+typedef __libcpp_mutex_external* __libcpp_mutex;
+
+int __os_mutex_init(__libcpp_mutex* __m, bool is_recursive);
+
+int __os_mutex_lock(__libcpp_mutex* __m);
+
+int __os_mutex_trylock(__libcpp_mutex* __m);
+
+int __os_mutex_unlock(__libcpp_mutex* __m);
+
+int __os_mutex_destroy(__libcpp_mutex* __m);
+
+// Condition variable
+#define __OS_COND_INITIALIZER 0
+struct __libcpp_condvar_external;
+typedef __libcpp_condvar_external* __libcpp_condvar;
+
+int __os_condvar_signal(__libcpp_condvar* __cv);
+
+int __os_condvar_broadcast(__libcpp_condvar* __cv);
+
+int __os_condvar_wait(__libcpp_condvar* __cv, __libcpp_mutex* __m);
+
+int __os_condvar_timedwait(__libcpp_condvar* __cv, __libcpp_mutex* __m, timespec* __ts);
+
+int __os_condvar_destroy(__libcpp_condvar* __cv);
+
+// Thread id
+typedef unsigned long __libcpp_thread_id;
+
+int __os_thread_id_compare(__libcpp_thread_id t1, __libcpp_thread_id t2);
+
+// Thread
+struct __libcpp_thread_external;
+typedef __libcpp_thread_external* __libcpp_thread;
+
+template
+int __os_thread_create(__libcpp_thread* __t, _Func&& __f, _Arg&& __arg);
+
+__libcpp_thread_id __os_thread_get_current_id();
+
+__libcpp_thread_id __os_thread_get_id(const __libcpp_thread* __t);
+
+int __os_thread_join(__libcpp_thread* __t);
+
+int __os_thread_detach(__libcpp_thread* __t);
+
+void __os_thread_yield();
+
+// Thread local storage
+typedef unsigned long __libcpp_tl_key;
+
+template
+int __os_tl_create(__libcpp_tl_key* __key, _Func&& __at_exit);
+
+void* __os_tl_get(__libcpp_tl_key __key);
+
+void __os_tl_set(__libcpp_tl_key __key, void* __p);
+
+#else
   #error "No thread API selected."
 #endif
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r267633 - Module debugging: Add an assertion.

2016-04-26 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Tue Apr 26 18:42:43 2016
New Revision: 267633

URL: http://llvm.org/viewvc/llvm-project?rev=267633=rev
Log:
Module debugging: Add an assertion.

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=267633=267632=267633=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Tue Apr 26 18:42:43 2016
@@ -1520,11 +1520,13 @@ static bool isDefinedInClangModule(const
 return false;
   if (!RD->isExternallyVisible() && RD->getName().empty())
 return false;
-  if (auto *CXXDecl = dyn_cast(RD))
+  if (auto *CXXDecl = dyn_cast(RD)) {
+assert(CXXDecl->isCompleteDefinition() && "incomplete record definition");
 if (CXXDecl->getTemplateSpecializationKind() != TSK_Undeclared)
   // Make sure the instantiation is actually in a module.
   if (CXXDecl->field_begin() != CXXDecl->field_end())
 return CXXDecl->field_begin()->isFromASTFile();
+  }
 
   return true;
 }


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


r267632 - PR27513: When determining which declaration to put into an exported lookup

2016-04-26 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Apr 26 18:40:43 2016
New Revision: 267632

URL: http://llvm.org/viewvc/llvm-project?rev=267632=rev
Log:
PR27513: When determining which declaration to put into an exported lookup
table for a module / PCH, never map from a normal declaration of a class to an
injected-class-name declaration (or vice versa). Those declarations live in
distinct lookup tables and should not be confused.

We really shouldn't be using a CXXRecordDecl to represent an
injected-class-name in the first place; I've filed PR27532 so we don't forget.

Added:
cfe/trunk/test/Modules/Inputs/PR27513/
cfe/trunk/test/Modules/Inputs/PR27513/a.h
cfe/trunk/test/Modules/Inputs/PR27513/b.h
cfe/trunk/test/Modules/Inputs/PR27513/b1.h
cfe/trunk/test/Modules/Inputs/PR27513/b11.h
cfe/trunk/test/Modules/Inputs/PR27513/b111.h
cfe/trunk/test/Modules/Inputs/PR27513/b.h
cfe/trunk/test/Modules/Inputs/PR27513/b1112.h
cfe/trunk/test/Modules/Inputs/PR27513/b2.h
cfe/trunk/test/Modules/Inputs/PR27513/c.h
cfe/trunk/test/Modules/Inputs/PR27513/module.modulemap
cfe/trunk/test/Modules/Inputs/PR27513/mystring.h
cfe/trunk/test/Modules/pr27513.cpp
Modified:
cfe/trunk/lib/Serialization/ASTWriter.cpp

Modified: cfe/trunk/lib/Serialization/ASTWriter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=267632=267631=267632=diff
==
--- cfe/trunk/lib/Serialization/ASTWriter.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriter.cpp Tue Apr 26 18:40:43 2016
@@ -3107,11 +3107,20 @@ static NamedDecl *getDeclForLocalLookup(
   if (Decl *Redecl = D->getPreviousDecl()) {
 // For Redeclarable decls, a prior declaration might be local.
 for (; Redecl; Redecl = Redecl->getPreviousDecl()) {
-  if (!Redecl->isFromASTFile())
+  // If we find a local decl, we're done.
+  if (!Redecl->isFromASTFile()) {
+// Exception: in very rare cases (for injected-class-names), not all
+// redeclarations are in the same semantic context. Skip ones in a
+// different context. They don't go in this lookup table at all.
+if (!Redecl->getDeclContext()->getRedeclContext()->Equals(
+D->getDeclContext()->getRedeclContext()))
+  continue;
 return cast(Redecl);
+  }
+
   // If we find a decl from a (chained-)PCH stop since we won't find a
   // local one.
-  if (D->getOwningModuleID() == 0)
+  if (Redecl->getOwningModuleID() == 0)
 break;
 }
   } else if (Decl *First = D->getCanonicalDecl()) {

Added: cfe/trunk/test/Modules/Inputs/PR27513/a.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/PR27513/a.h?rev=267632=auto
==
--- cfe/trunk/test/Modules/Inputs/PR27513/a.h (added)
+++ cfe/trunk/test/Modules/Inputs/PR27513/a.h Tue Apr 26 18:40:43 2016
@@ -0,0 +1,5 @@
+#include "b.h"
+
+inline void f() { basic_string s; }
+
+#include "c.h"

Added: cfe/trunk/test/Modules/Inputs/PR27513/b.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/PR27513/b.h?rev=267632=auto
==
--- cfe/trunk/test/Modules/Inputs/PR27513/b.h (added)
+++ cfe/trunk/test/Modules/Inputs/PR27513/b.h Tue Apr 26 18:40:43 2016
@@ -0,0 +1,3 @@
+#include "mystring.h"
+#include "b1.h"
+#include "b2.h"

Added: cfe/trunk/test/Modules/Inputs/PR27513/b1.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/PR27513/b1.h?rev=267632=auto
==
--- cfe/trunk/test/Modules/Inputs/PR27513/b1.h (added)
+++ cfe/trunk/test/Modules/Inputs/PR27513/b1.h Tue Apr 26 18:40:43 2016
@@ -0,0 +1 @@
+#include "b11.h"

Added: cfe/trunk/test/Modules/Inputs/PR27513/b11.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/PR27513/b11.h?rev=267632=auto
==
--- cfe/trunk/test/Modules/Inputs/PR27513/b11.h (added)
+++ cfe/trunk/test/Modules/Inputs/PR27513/b11.h Tue Apr 26 18:40:43 2016
@@ -0,0 +1,2 @@
+#include "mystring.h"
+#include "b111.h"

Added: cfe/trunk/test/Modules/Inputs/PR27513/b111.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/PR27513/b111.h?rev=267632=auto
==
--- cfe/trunk/test/Modules/Inputs/PR27513/b111.h (added)
+++ cfe/trunk/test/Modules/Inputs/PR27513/b111.h Tue Apr 26 18:40:43 2016
@@ -0,0 +1,3 @@
+#include "mystring.h"
+#include "b.h"
+#include "b1112.h"

Added: cfe/trunk/test/Modules/Inputs/PR27513/b.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/PR27513/b.h?rev=267632=auto

r267630 - Module debugging: Also correctly handle typedef'd foward-declared members.

2016-04-26 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Tue Apr 26 18:37:38 2016
New Revision: 267630

URL: http://llvm.org/viewvc/llvm-project?rev=267630=rev
Log:
Module debugging: Also correctly handle typedef'd foward-declared members.
Thanks again to Richard Smith for pointing this out.

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

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=267630=267629=267630=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Tue Apr 26 18:37:38 2016
@@ -1520,13 +1520,12 @@ static bool isDefinedInClangModule(const
 return false;
   if (!RD->isExternallyVisible() && RD->getName().empty())
 return false;
-  if (auto *CTSD = dyn_cast(RD)) {
-if (!CTSD->isCompleteDefinition())
-  return false;
-// Make sure the instantiation is actually in a module.
-if (CTSD->field_begin() != CTSD->field_end())
-  return CTSD->field_begin()->isFromASTFile();
-  }
+  if (auto *CXXDecl = dyn_cast(RD))
+if (CXXDecl->getTemplateSpecializationKind() != TSK_Undeclared)
+  // Make sure the instantiation is actually in a module.
+  if (CXXDecl->field_begin() != CXXDecl->field_end())
+return CXXDecl->field_begin()->isFromASTFile();
+
   return true;
 }
 

Modified: cfe/trunk/test/Modules/ExtDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/ExtDebugInfo.cpp?rev=267630=267629=267630=diff
==
--- cfe/trunk/test/Modules/ExtDebugInfo.cpp (original)
+++ cfe/trunk/test/Modules/ExtDebugInfo.cpp Tue Apr 26 18:37:38 2016
@@ -28,6 +28,8 @@ using DebugCXX::Struct;
 
 Struct s;
 DebugCXX::Enum e;
+
+// Template instantiations.
 DebugCXX::Template implicitTemplate;
 DebugCXX::Template explicitTemplate;
 DebugCXX::FloatInstantiation typedefTemplate;
@@ -51,13 +53,16 @@ TypedefFwdDeclTemplate tdfdt;
 
 InAnonymousNamespace anon;
 
-// Forward-declared in the module.
+// Types that are forward-declared in the module and defined here.
 struct PureFwdDecl { int i; };
 PureFwdDecl definedLocally;
 
 struct Specialized::Member { int i; };
 struct Specialized::Member definedLocally2;
 
+template  struct FwdDeclTemplateMember::Member { T t; };
+TypedefFwdDeclTemplateMember tdfdtm;
+
 void foo() {
   anon.i = GlobalStruct.i = GlobalUnion.i = GlobalEnum;
 }
@@ -150,6 +155,12 @@ void foo() {
 // CHECK-SAME: elements:
 // CHECK-SAME: identifier: "_ZTSN11SpecializedIiE6MemberE")
 
+// This type is defined locally and forward-declared in the module.
+// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "Member",
+// CHECK-SAME: elements:
+// CHECK-SAME: identifier: 
"_ZTSN21FwdDeclTemplateMemberIiE6MemberE")
+
+
 // CHECK: !DIGlobalVariable(name: "anon_enum", {{.*}}, type: 
![[ANON_ENUM:[0-9]+]]
 // CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, scope: ![[NS]],
 // CHECK-SAME: line: 16

Modified: cfe/trunk/test/Modules/Inputs/DebugCXX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/DebugCXX.h?rev=267630=267629=267630=diff
==
--- cfe/trunk/test/Modules/Inputs/DebugCXX.h (original)
+++ cfe/trunk/test/Modules/Inputs/DebugCXX.h Tue Apr 26 18:37:38 2016
@@ -97,10 +97,11 @@ template  class FwdDeclTemplate
 typedef FwdDeclTemplate TypedefFwdDeclTemplate;
 
 // Member classes of class template specializations.
-template  struct Specialized {
-};
+template  struct Specialized {};
 
-template <> struct Specialized { 
-struct Member;// { int i; };
+template <> struct Specialized {
+  struct Member;
 };
 
+template  struct FwdDeclTemplateMember { struct Member; };
+typedef FwdDeclTemplateMember::Member TypedefFwdDeclTemplateMember;

Modified: cfe/trunk/test/Modules/ModuleDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/ModuleDebugInfo.cpp?rev=267630=267629=267630=diff
==
--- cfe/trunk/test/Modules/ModuleDebugInfo.cpp (original)
+++ cfe/trunk/test/Modules/ModuleDebugInfo.cpp Tue Apr 26 18:37:38 2016
@@ -130,5 +130,9 @@
 // CHECK-SAME: flags: DIFlagFwdDecl
 // CHECK-SAME: identifier: "_ZTS15FwdDeclTemplateIiE")
 
+// Forward-declared member of a template.
+// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "Member",
+// CHECK-SAME: flags: DIFlagFwdDecl
+// CHECK-SAME: identifier: 
"_ZTSN21FwdDeclTemplateMemberIiE6MemberE")
 
 // CHECK-NEG-NOT: !DICompositeType(tag: DW_TAG_structure_type, name: 
"PureForwardDecl"



Re: [PATCH] D19412: [libcxx] Refactor pthread usage - II

2016-04-26 Thread Asiri Rathnayake via cfe-commits
rmaprath updated this revision to Diff 55119.
rmaprath added a comment.

Addressing review comments from @bcraig:

In the earlier patch, I tried to keep the `__os_support` header to a minimum by 
not exposing the internal pthread dependencies (in library sources) in this 
header. This however blew up on me when externalizing the threading support in 
http://reviews.llvm.org/D19415, where I ended up sprinkling a lot of:

  #if defined(_LIBCPP_THREAD_API_PTHREAD)
// Do pthread thing
  #elif defined(_LIBCPP_THREAD_API_EXTERNAL)
// Do other thing
  #else
// Fault
  #endif

Perhaps the mistake was to view these two threading APIs as unrelated. After 
hiding all pthread dependencies behind the corresponding `__os_` functions 
(as suggested), everything falls into place (http://reviews.llvm.org/D19415 
trivially becomes the list of `__os_` function declarations).

I have addressed the remaining review comments along the way. Will update 
http://reviews.llvm.org/D19415 soon.

@bcraig: Hope this is much better?


http://reviews.llvm.org/D19412

Files:
  include/__config
  include/__mutex_base
  include/__os_support
  include/mutex
  include/thread
  src/algorithm.cpp
  src/condition_variable.cpp
  src/memory.cpp
  src/mutex.cpp
  src/thread.cpp

Index: src/thread.cpp
===
--- src/thread.cpp
+++ src/thread.cpp
@@ -37,6 +37,8 @@
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
+using namespace __libcpp_os_support;
+
 thread::~thread()
 {
 if (__t_ != 0)
@@ -46,7 +48,7 @@
 void
 thread::join()
 {
-int ec = pthread_join(__t_, 0);
+int ec = __os_thread_join(&__t_);
 #ifndef _LIBCPP_NO_EXCEPTIONS
 if (ec)
 throw system_error(error_code(ec, system_category()), "thread::join failed");
@@ -62,7 +64,7 @@
 int ec = EINVAL;
 if (__t_ != 0)
 {
-ec = pthread_detach(__t_);
+ec = __os_thread_detach(&__t_);
 if (ec == 0)
 __t_ = 0;
 }
Index: src/mutex.cpp
===
--- src/mutex.cpp
+++ src/mutex.cpp
@@ -21,15 +21,17 @@
 const try_to_lock_t try_to_lock = {};
 const adopt_lock_t  adopt_lock = {};
 
+using namespace __libcpp_os_support;
+
 mutex::~mutex()
 {
-pthread_mutex_destroy(&__m_);
+__os_mutex_destroy(&__m_);
 }
 
 void
 mutex::lock()
 {
-int ec = pthread_mutex_lock(&__m_);
+int ec = __os_mutex_lock(&__m_);
 if (ec)
 __throw_system_error(ec, "mutex lock failed");
 }
@@ -37,13 +39,13 @@
 bool
 mutex::try_lock() _NOEXCEPT
 {
-return pthread_mutex_trylock(&__m_) == 0;
+return __os_mutex_trylock(&__m_) == 0;
 }
 
 void
 mutex::unlock() _NOEXCEPT
 {
-int ec = pthread_mutex_unlock(&__m_);
+int ec = __os_mutex_unlock(&__m_);
 (void)ec;
 assert(ec == 0);
 }
@@ -52,36 +54,14 @@
 
 recursive_mutex::recursive_mutex()
 {
-pthread_mutexattr_t attr;
-int ec = pthread_mutexattr_init();
-if (ec)
-goto fail;
-ec = pthread_mutexattr_settype(, PTHREAD_MUTEX_RECURSIVE);
-if (ec)
-{
-pthread_mutexattr_destroy();
-goto fail;
-}
-ec = pthread_mutex_init(&__m_, );
+int ec = __os_mutex_init(&__m_, true);
 if (ec)
-{
-pthread_mutexattr_destroy();
-goto fail;
-}
-ec = pthread_mutexattr_destroy();
-if (ec)
-{
-pthread_mutex_destroy(&__m_);
-goto fail;
-}
-return;
-fail:
-__throw_system_error(ec, "recursive_mutex constructor failed");
+__throw_system_error(ec, "recursive_mutex constructor failed");
 }
 
 recursive_mutex::~recursive_mutex()
 {
-int e = pthread_mutex_destroy(&__m_);
+int e = __os_mutex_destroy(&__m_);
 (void)e;
 assert(e == 0);
 }
@@ -89,7 +69,7 @@
 void
 recursive_mutex::lock()
 {
-int ec = pthread_mutex_lock(&__m_);
+int ec = __os_mutex_lock(&__m_);
 if (ec)
 __throw_system_error(ec, "recursive_mutex lock failed");
 }
@@ -97,7 +77,7 @@
 void
 recursive_mutex::unlock() _NOEXCEPT
 {
-int e = pthread_mutex_unlock(&__m_);
+int e = __os_mutex_unlock(&__m_);
 (void)e;
 assert(e == 0);
 }
@@ -105,7 +85,7 @@
 bool
 recursive_mutex::try_lock() _NOEXCEPT
 {
-return pthread_mutex_trylock(&__m_) == 0;
+return __os_mutex_trylock(&__m_) == 0;
 }
 
 // timed_mutex
@@ -165,9 +145,9 @@
 void
 recursive_timed_mutex::lock()
 {
-pthread_t id = pthread_self();
+__libcpp_thread_id id = __os_thread_get_current_id();
 unique_lock lk(__m_);
-if (pthread_equal(id, __id_))
+if (__os_thread_id_compare(id, __id_) == 0)
 {
 if (__count_ == numeric_limits::max())
 __throw_system_error(EAGAIN, "recursive_timed_mutex lock limit reached");
@@ -183,9 +163,9 @@
 bool
 recursive_timed_mutex::try_lock() _NOEXCEPT
 {
-pthread_t id = pthread_self();
+__libcpp_thread_id id = __os_thread_get_current_id();
 unique_lock lk(__m_, try_to_lock);
-if (lk.owns_lock() && (__count_ == 0 

r267625 - Check 'r' and 'y specifiers of freebsd_kernel_printf format strings on PS4

2016-04-26 Thread Sunil Srivastava via cfe-commits
Author: ssrivastava
Date: Tue Apr 26 18:19:00 2016
New Revision: 267625

URL: http://llvm.org/viewvc/llvm-project?rev=267625=rev
Log:
Check 'r' and 'y specifiers of freebsd_kernel_printf format strings on PS4

This is an addendum to r229921.

Modified:
cfe/trunk/lib/Analysis/FormatString.cpp
cfe/trunk/test/Sema/format-strings-freebsd.c

Modified: cfe/trunk/lib/Analysis/FormatString.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/FormatString.cpp?rev=267625=267624=267625=diff
==
--- cfe/trunk/lib/Analysis/FormatString.cpp (original)
+++ cfe/trunk/lib/Analysis/FormatString.cpp Tue Apr 26 18:19:00 2016
@@ -694,7 +694,7 @@ bool FormatSpecifier::hasValidLengthModi
   return true;
 case ConversionSpecifier::FreeBSDrArg:
 case ConversionSpecifier::FreeBSDyArg:
-  return Target.getTriple().isOSFreeBSD();
+  return Target.getTriple().isOSFreeBSD() || 
Target.getTriple().isPS4();
 default:
   return false;
   }
@@ -727,7 +727,7 @@ bool FormatSpecifier::hasValidLengthModi
   return true;
 case ConversionSpecifier::FreeBSDrArg:
 case ConversionSpecifier::FreeBSDyArg:
-  return Target.getTriple().isOSFreeBSD();
+  return Target.getTriple().isOSFreeBSD() || 
Target.getTriple().isPS4();
 default:
   return false;
   }

Modified: cfe/trunk/test/Sema/format-strings-freebsd.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/format-strings-freebsd.c?rev=267625=267624=267625=diff
==
--- cfe/trunk/test/Sema/format-strings-freebsd.c (original)
+++ cfe/trunk/test/Sema/format-strings-freebsd.c Tue Apr 26 18:19:00 2016
@@ -1,10 +1,11 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -triple i386-unknown-freebsd %s
 // RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-unknown-freebsd %s
+// RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-scei-ps4 %s
 
 // Test FreeBSD kernel printf extensions.
 int freebsd_kernel_printf(const char *, ...) 
__attribute__((__format__(__freebsd_kprintf__, 1, 2)));
 
-void check_freebsd_kernel_extensions(int i, long l, char *s)
+void check_freebsd_kernel_extensions(int i, long l, char *s, short h)
 {
   // %b expects an int and a char *
   freebsd_kernel_printf("reg=%b\n", i, "\10\2BITTWO\1BITONE\n"); // no-warning
@@ -32,6 +33,12 @@ void check_freebsd_kernel_extensions(int
   freebsd_kernel_printf("%lr", i); // expected-warning{{format specifies type 
'long' but the argument has type 'int'}}
   freebsd_kernel_printf("%lr", l); // no-warning
 
+  // h modifier expects a short
+  freebsd_kernel_printf("%hr", i); // expected-warning{{format specifies type 
'short' but the argument has type 'int'}}
+  freebsd_kernel_printf("%hr", h); // no-warning
+  freebsd_kernel_printf("%hy", i); // expected-warning{{format specifies type 
'short' but the argument has type 'int'}}
+  freebsd_kernel_printf("%hy", h); // no-warning
+
   // %y expects an int
   freebsd_kernel_printf("%y", i); // no-warning
   freebsd_kernel_printf("%y", l); // expected-warning{{format specifies type 
'int' but the argument has type 'long'}}


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


Re: r267464 - Module Debugging: Fix the condition for determining whether a template

2016-04-26 Thread Richard Smith via cfe-commits
On Tue, Apr 26, 2016 at 3:10 PM, Adrian Prantl via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

>
> On Apr 25, 2016, at 5:34 PM, Richard Smith  wrote:
>
> On Mon, Apr 25, 2016 at 1:52 PM, Adrian Prantl via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: adrian
>> Date: Mon Apr 25 15:52:40 2016
>> New Revision: 267464
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=267464=rev
>> Log:
>> Module Debugging: Fix the condition for determining whether a template
>> instantiation is in a module.
>>
>> This patch fixes the condition for determining whether the debug info for
>> a
>> template instantiation will exist in an imported clang module by:
>>
>> - checking whether the ClassTemplateSpecializationDecl is complete and
>> - checking that the instantiation was in a module by looking at the first
>> field.
>>
>> I also added a negative check to make sure that a typedef to a
>> forward-declared
>> template (with the definition outside of the module) is handled correctly.
>>
>> http://reviews.llvm.org/D19443
>> rdar://problem/25553724
>>
>> Modified:
>> cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
>> cfe/trunk/test/Modules/ExtDebugInfo.cpp
>> cfe/trunk/test/Modules/Inputs/DebugCXX.h
>> cfe/trunk/test/Modules/ModuleDebugInfo.cpp
>>
>> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=267464=267463=267464=diff
>>
>> ==
>> --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
>> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Mon Apr 25 15:52:40 2016
>> @@ -1514,12 +1514,28 @@ static bool hasExplicitMemberDefinition(
>>return false;
>>  }
>>
>> +/// Does a type definition exist in an imported clang module?
>> +static bool isDefinedInClangModule(const RecordDecl *RD) {
>> +  if (!RD->isFromASTFile())
>> +return false;
>> +  if (!RD->getDefinition())
>> +return false;
>> +  if (!RD->isExternallyVisible() && RD->getName().empty())
>> +return false;
>> +  if (auto *CTSD = dyn_cast(RD)) {
>>
>
> The same issue also affects member classes of class template
> specializations (you can detect them with
> RD->getInstantiatedFromMemberClass(), or detect all the relevant cases at
> once with RD->getTemplateSpecializationKind()).
>
>
> I added a testcase for this r267612, but I couldn’t reproduce the
> situation that you were describing here. Do you have an example of what you
> had in mind?
>

Something just like your testcase for class template specializations should
work:

// DebugCXX.h
template  class FwdDeclTemplateMember { class Member; };
typedef FwdDeclTemplateMember::Member TypedefFwdDeclTemplateMember;

// ExtDebugInfo.cpp
template  class FwdDeclTemplateMember::Member { T t; };
TypedefFwdDeclTemplateMember tdfdtm;

> +if (!CTSD->isCompleteDefinition())
>> +  return false;
>>
>
> You already checked this a few lines above. Actually, the two checks do
> different things depending on whether RD or some other declaration is the
> definition; did you really mean to treat a (non-template) class that's
> defined locally but forward-declared within a module as being defined in
> that module? (It might make more sense to map to the definition upfront and
> do all your queries on that if that's what you intend to check.)
>
>
> Thanks! I changed this in r267611 to always pass RD->getDefinition() into
> isDefinedInClangModule. Does this make the check for isCompleteDefinition()
> redundant?
>

Yes. The only other possibility here is that the class is currently being
defined (we're between the open and close braces), but as far as I know you
shouldn't ever see such a class from here, and you should certainly never
see one where the partial definition is imported from an AST file. You
could assert isCompleteDefinition() if you're worried that we might give
you a bad AST.

-- adrian
>
>
>
>> +// Make sure the instantiation is actually in a module.
>> +if (CTSD->field_begin() != CTSD->field_end())
>> +  return CTSD->field_begin()->isFromASTFile();
>> +  }
>> +  return true;
>> +}
>> +
>>  static bool shouldOmitDefinition(codegenoptions::DebugInfoKind DebugKind,
>>   bool DebugTypeExtRefs, const
>> RecordDecl *RD,
>>   const LangOptions ) {
>> -  // Does the type exist in an imported clang module?
>> -  if (DebugTypeExtRefs && RD->isFromASTFile() && RD->getDefinition() &&
>> -  (RD->isExternallyVisible() || !RD->getName().empty()))
>> +  if (DebugTypeExtRefs && isDefinedInClangModule(RD))
>>  return true;
>>
>>if (DebugKind > codegenoptions::LimitedDebugInfo)
>>
>> Modified: cfe/trunk/test/Modules/ExtDebugInfo.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/ExtDebugInfo.cpp?rev=267464=267463=267464=diff
>>
>> ==
>> --- 

[PATCH] D19565: [libc++] Fix an accidental assignment within assert() that should have been equality.

2016-04-26 Thread Stephan T. Lavavej via cfe-commits
STL_MSFT created this revision.
STL_MSFT added reviewers: EricWF, mclow.lists.
STL_MSFT added a subscriber: cfe-commits.

[libc++] Fix an accidental assignment within assert() that should have been 
equality.

Fixes MSVC "warning C4706: assignment within conditional expression".

http://reviews.llvm.org/D19565

Files:
  test/std/containers/associative/map/compare.pass.cpp

Index: test/std/containers/associative/map/compare.pass.cpp
===
--- test/std/containers/associative/map/compare.pass.cpp
+++ test/std/containers/associative/map/compare.pass.cpp
@@ -44,7 +44,7 @@
 MapT map;
 IterBool result = map.insert(std::make_pair(Key(0), 42));
 assert(result.second);
-assert(result.first->second = 42);
+assert(result.first->second == 42);
 IterBool result2 = map.insert(std::make_pair(Key(0), 43));
 assert(!result2.second);
 assert(map[Key(0)] == 42);


Index: test/std/containers/associative/map/compare.pass.cpp
===
--- test/std/containers/associative/map/compare.pass.cpp
+++ test/std/containers/associative/map/compare.pass.cpp
@@ -44,7 +44,7 @@
 MapT map;
 IterBool result = map.insert(std::make_pair(Key(0), 42));
 assert(result.second);
-assert(result.first->second = 42);
+assert(result.first->second == 42);
 IterBool result2 = map.insert(std::make_pair(Key(0), 43));
 assert(!result2.second);
 assert(map[Key(0)] == 42);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D19552: Check 'r' and 'y specifiers of freebsd_kernel_printf format strings on PS4

2016-04-26 Thread Sunil Srivastava via cfe-commits
Sunil_Srivastava added a comment.

I had put these 'h' test lines to test the first of my changes, and this 
sufficed, but you are correct. I should add %y too. I am going to add '%hr' and 
'%hy'.



Comment at: test/Sema/format-strings-freebsd.c:39
@@ -35,1 +38,3 @@
+  freebsd_kernel_printf("%hr", h); // no-warning
+
   // %y expects an int

dim wrote:
> It's nice to add these for %r, but is there any reason you didn't add similar 
> ones for %y? (This is just a minor nit.)
I had put these lines to test the first of my changes, and this sufficed, but 
you are correct. I should  add %y too.  I am going to add '%hr' and '%hy'.


http://reviews.llvm.org/D19552



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


Re: r267464 - Module Debugging: Fix the condition for determining whether a template

2016-04-26 Thread Adrian Prantl via cfe-commits

> On Apr 25, 2016, at 5:34 PM, Richard Smith  wrote:
> 
> On Mon, Apr 25, 2016 at 1:52 PM, Adrian Prantl via cfe-commits 
> > wrote:
> Author: adrian
> Date: Mon Apr 25 15:52:40 2016
> New Revision: 267464
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=267464=rev 
> 
> Log:
> Module Debugging: Fix the condition for determining whether a template
> instantiation is in a module.
> 
> This patch fixes the condition for determining whether the debug info for a
> template instantiation will exist in an imported clang module by:
> 
> - checking whether the ClassTemplateSpecializationDecl is complete and
> - checking that the instantiation was in a module by looking at the first 
> field.
> 
> I also added a negative check to make sure that a typedef to a 
> forward-declared
> template (with the definition outside of the module) is handled correctly.
> 
> http://reviews.llvm.org/D19443 
> rdar://problem/25553724
> 
> Modified:
> cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> cfe/trunk/test/Modules/ExtDebugInfo.cpp
> cfe/trunk/test/Modules/Inputs/DebugCXX.h
> cfe/trunk/test/Modules/ModuleDebugInfo.cpp
> 
> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=267464=267463=267464=diff
>  
> 
> ==
> --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Mon Apr 25 15:52:40 2016
> @@ -1514,12 +1514,28 @@ static bool hasExplicitMemberDefinition(
>return false;
>  }
> 
> +/// Does a type definition exist in an imported clang module?
> +static bool isDefinedInClangModule(const RecordDecl *RD) {
> +  if (!RD->isFromASTFile())
> +return false;
> +  if (!RD->getDefinition())
> +return false;
> +  if (!RD->isExternallyVisible() && RD->getName().empty())
> +return false;
> +  if (auto *CTSD = dyn_cast(RD)) {
> 
> The same issue also affects member classes of class template specializations 
> (you can detect them with RD->getInstantiatedFromMemberClass(), or detect all 
> the relevant cases at once with RD->getTemplateSpecializationKind()).

I added a testcase for this r267612, but I couldn’t reproduce the situation 
that you were describing here. Do you have an example of what you had in mind?
> 
> +if (!CTSD->isCompleteDefinition())
> +  return false;
> 
> You already checked this a few lines above. Actually, the two checks do 
> different things depending on whether RD or some other declaration is the 
> definition; did you really mean to treat a (non-template) class that's 
> defined locally but forward-declared within a module as being defined in that 
> module? (It might make more sense to map to the definition upfront and do all 
> your queries on that if that's what you intend to check.)

Thanks! I changed this in r267611 to always pass RD->getDefinition() into 
isDefinedInClangModule. Does this make the check for isCompleteDefinition() 
redundant? Looking at the source for TagDecl::getDefinition() I’m not sure.

-- adrian

>  
> +// Make sure the instantiation is actually in a module.
> +if (CTSD->field_begin() != CTSD->field_end())
> +  return CTSD->field_begin()->isFromASTFile();
> +  }
> +  return true;
> +}
> +
>  static bool shouldOmitDefinition(codegenoptions::DebugInfoKind DebugKind,
>   bool DebugTypeExtRefs, const RecordDecl *RD,
>   const LangOptions ) {
> -  // Does the type exist in an imported clang module?
> -  if (DebugTypeExtRefs && RD->isFromASTFile() && RD->getDefinition() &&
> -  (RD->isExternallyVisible() || !RD->getName().empty()))
> +  if (DebugTypeExtRefs && isDefinedInClangModule(RD))
>  return true;
> 
>if (DebugKind > codegenoptions::LimitedDebugInfo)
> 
> Modified: cfe/trunk/test/Modules/ExtDebugInfo.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/ExtDebugInfo.cpp?rev=267464=267463=267464=diff
>  
> 
> ==
> --- cfe/trunk/test/Modules/ExtDebugInfo.cpp (original)
> +++ cfe/trunk/test/Modules/ExtDebugInfo.cpp Mon Apr 25 15:52:40 2016
> @@ -2,7 +2,7 @@
>  // Test that only forward declarations are emitted for types dfined in 
> modules.
> 
>  // Modules:
> -// RUN: %clang_cc1 -x objective-c++ -std=c++11 -debug-info-kind=limited \
> +// RUN: %clang_cc1 -x objective-c++ -std=c++11 -debug-info-kind=standalone \
>  // RUN: -dwarf-ext-refs -fmodules   \
>  // RUN: 

r267612 - Module debugging: Add testcase for member classes of class template specializations.

2016-04-26 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Tue Apr 26 16:58:23 2016
New Revision: 267612

URL: http://llvm.org/viewvc/llvm-project?rev=267612=rev
Log:
Module debugging: Add testcase for member classes of class template 
specializations.

Modified:
cfe/trunk/test/Modules/ExtDebugInfo.cpp
cfe/trunk/test/Modules/Inputs/DebugCXX.h

Modified: cfe/trunk/test/Modules/ExtDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/ExtDebugInfo.cpp?rev=267612=267611=267612=diff
==
--- cfe/trunk/test/Modules/ExtDebugInfo.cpp (original)
+++ cfe/trunk/test/Modules/ExtDebugInfo.cpp Tue Apr 26 16:58:23 2016
@@ -55,6 +55,9 @@ InAnonymousNamespace anon;
 struct PureFwdDecl { int i; };
 PureFwdDecl definedLocally;
 
+struct Specialized::Member { int i; };
+struct Specialized::Member definedLocally2;
+
 void foo() {
   anon.i = GlobalStruct.i = GlobalUnion.i = GlobalEnum;
 }
@@ -137,11 +140,16 @@ void foo() {
 // CHECK-SAME: templateParams:
 // CHECK-SAME: identifier: "_ZTS15FwdDeclTemplateIiE")
 
-// This type is defined locally and forward-declare in the module.
+// This type is defined locally and forward-declared in the module.
 // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "PureFwdDecl",
 // CHECK-SAME: elements:
 // CHECK-SAME: identifier: "_ZTS11PureFwdDecl")
 
+// This type is defined locally and forward-declared in the module.
+// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "Member",
+// CHECK-SAME: elements:
+// CHECK-SAME: identifier: "_ZTSN11SpecializedIiE6MemberE")
+
 // CHECK: !DIGlobalVariable(name: "anon_enum", {{.*}}, type: 
![[ANON_ENUM:[0-9]+]]
 // CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, scope: ![[NS]],
 // CHECK-SAME: line: 16

Modified: cfe/trunk/test/Modules/Inputs/DebugCXX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/DebugCXX.h?rev=267612=267611=267612=diff
==
--- cfe/trunk/test/Modules/Inputs/DebugCXX.h (original)
+++ cfe/trunk/test/Modules/Inputs/DebugCXX.h Tue Apr 26 16:58:23 2016
@@ -95,3 +95,12 @@ extern template class Template1;
 
 template  class FwdDeclTemplate;
 typedef FwdDeclTemplate TypedefFwdDeclTemplate;
+
+// Member classes of class template specializations.
+template  struct Specialized {
+};
+
+template <> struct Specialized { 
+struct Member;// { int i; };
+};
+


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


r267611 - Module debugging: Use the definition to determine module-defined types.

2016-04-26 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Tue Apr 26 16:58:18 2016
New Revision: 267611

URL: http://llvm.org/viewvc/llvm-project?rev=267611=rev
Log:
Module debugging: Use the definition to determine module-defined types.

Follow-up to r267464. Thanks to Richard Smith for pointing this out!

Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/test/Modules/ExtDebugInfo.cpp

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=267611=267610=267611=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Tue Apr 26 16:58:18 2016
@@ -1516,9 +1516,7 @@ static bool hasExplicitMemberDefinition(
 
 /// Does a type definition exist in an imported clang module?
 static bool isDefinedInClangModule(const RecordDecl *RD) {
-  if (!RD->isFromASTFile())
-return false;
-  if (!RD->getDefinition())
+  if (!RD || !RD->isFromASTFile())
 return false;
   if (!RD->isExternallyVisible() && RD->getName().empty())
 return false;
@@ -1535,7 +1533,7 @@ static bool isDefinedInClangModule(const
 static bool shouldOmitDefinition(codegenoptions::DebugInfoKind DebugKind,
  bool DebugTypeExtRefs, const RecordDecl *RD,
  const LangOptions ) {
-  if (DebugTypeExtRefs && isDefinedInClangModule(RD))
+  if (DebugTypeExtRefs && isDefinedInClangModule(RD->getDefinition()))
 return true;
 
   if (DebugKind > codegenoptions::LimitedDebugInfo)

Modified: cfe/trunk/test/Modules/ExtDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/ExtDebugInfo.cpp?rev=267611=267610=267611=diff
==
--- cfe/trunk/test/Modules/ExtDebugInfo.cpp (original)
+++ cfe/trunk/test/Modules/ExtDebugInfo.cpp Tue Apr 26 16:58:18 2016
@@ -51,6 +51,10 @@ TypedefFwdDeclTemplate tdfdt;
 
 InAnonymousNamespace anon;
 
+// Forward-declared in the module.
+struct PureFwdDecl { int i; };
+PureFwdDecl definedLocally;
+
 void foo() {
   anon.i = GlobalStruct.i = GlobalUnion.i = GlobalEnum;
 }
@@ -133,6 +137,11 @@ void foo() {
 // CHECK-SAME: templateParams:
 // CHECK-SAME: identifier: "_ZTS15FwdDeclTemplateIiE")
 
+// This type is defined locally and forward-declare in the module.
+// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "PureFwdDecl",
+// CHECK-SAME: elements:
+// CHECK-SAME: identifier: "_ZTS11PureFwdDecl")
+
 // CHECK: !DIGlobalVariable(name: "anon_enum", {{.*}}, type: 
![[ANON_ENUM:[0-9]+]]
 // CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, scope: ![[NS]],
 // CHECK-SAME: line: 16


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


Re: [PATCH] D19385: [scan-build] fix logic error warnings emitted on clang code base

2016-04-26 Thread Apelete Seketeli via cfe-commits
apelete updated this revision to Diff 55103.
apelete added a comment.

[scan-build] fix logic error warnings emitted on clang code base

Chnages since last revision:

- lib/Format/Format.cpp: removed all changes, redenderd obsolete by upstream.


http://reviews.llvm.org/D19385

Files:
  lib/AST/DeclObjC.cpp
  lib/Frontend/CompilerInstance.cpp
  lib/Sema/SemaExprCXX.cpp
  lib/Sema/SemaLookup.cpp
  lib/StaticAnalyzer/Core/PlistDiagnostics.cpp

Index: lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
===
--- lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
+++ lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
@@ -297,6 +297,7 @@
   if (!Diags.empty())
 SM = ()->path.front()->getLocation().getManager();
 
+  assert(SM && "SourceManager is NULL, cannot iterate through the 
diagnostics");
 
   for (std::vector::iterator DI = Diags.begin(),
DE = Diags.end(); DI != DE; ++DI) {
Index: lib/Sema/SemaLookup.cpp
===
--- lib/Sema/SemaLookup.cpp
+++ lib/Sema/SemaLookup.cpp
@@ -3744,6 +3744,7 @@
   bool AnyVisibleDecls = !NewDecls.empty();
 
   for (/**/; DI != DE; ++DI) {
+assert(*DI && "TypoCorrection iterator cannot be NULL");
 NamedDecl *VisibleDecl = *DI;
 if (!LookupResult::isVisible(SemaRef, *DI))
   VisibleDecl = findAcceptableDecl(SemaRef, *DI);
Index: lib/Sema/SemaExprCXX.cpp
===
--- lib/Sema/SemaExprCXX.cpp
+++ lib/Sema/SemaExprCXX.cpp
@@ -398,8 +398,10 @@
 SourceLocation TypeidLoc,
 Expr *E,
 SourceLocation RParenLoc) {
+  assert(E && "expression operand is NULL, cannot build C++ typeid 
expression");
+
   bool WasEvaluated = false;
-  if (E && !E->isTypeDependent()) {
+  if (!E->isTypeDependent()) {
 if (E->getType()->isPlaceholderType()) {
   ExprResult result = CheckPlaceholderExpr(E);
   if (result.isInvalid()) return ExprError();
Index: lib/Frontend/CompilerInstance.cpp
===
--- lib/Frontend/CompilerInstance.cpp
+++ lib/Frontend/CompilerInstance.cpp
@@ -742,7 +742,7 @@
 
   // Figure out where to get and map in the main file.
   if (InputFile != "-") {
-const FileEntry *File;
+const FileEntry *File = nullptr;
 if (Opts.FindPchSource.empty()) {
   File = FileMgr.getFile(InputFile, /*OpenFile=*/true);
 } else {
@@ -760,13 +760,14 @@
   SmallVector
   Includers;
   Includers.push_back(std::make_pair(FindFile, FindFile->getDir()));
-  File = HS->LookupFile(InputFile, SourceLocation(), /*isAngled=*/false,
-/*FromDir=*/nullptr,
-/*CurDir=*/UnusedCurDir, Includers,
-/*SearchPath=*/nullptr,
-/*RelativePath=*/nullptr,
-/*RequestingModule=*/nullptr,
-/*SuggestedModule=*/nullptr, /*SkipCache=*/true);
+  if (HS)
+File = HS->LookupFile(InputFile, SourceLocation(), /*isAngled=*/false,
+  /*FromDir=*/nullptr,
+  /*CurDir=*/UnusedCurDir, Includers,
+  /*SearchPath=*/nullptr,
+  /*RelativePath=*/nullptr,
+  /*RequestingModule=*/nullptr,
+  /*SuggestedModule=*/nullptr, /*SkipCache=*/true);
   // Also add the header to /showIncludes output.
   if (File)
 DepOpts.ShowIncludesPretendHeader = File->getName();
Index: lib/AST/DeclObjC.cpp
===
--- lib/AST/DeclObjC.cpp
+++ lib/AST/DeclObjC.cpp
@@ -1577,8 +1577,10 @@
   data().IvarList = layout[0].Ivar; Ix++;
   curIvar = data().IvarList;
 }
-for ( ; Ix != EIx; curIvar = layout[Ix].Ivar, Ix++)
+for ( ; Ix != EIx; curIvar = layout[Ix].Ivar, Ix++) {
+  assert(curIvar && "instance variable is NULL, stop iterating through 
layout");
   curIvar->setNextIvar(layout[Ix].Ivar);
+}
   }
 }
   }


Index: lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
===
--- lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
+++ lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
@@ -297,6 +297,7 @@
   if (!Diags.empty())
 SM = ()->path.front()->getLocation().getManager();
 
+  assert(SM && "SourceManager is NULL, cannot iterate through the diagnostics");
 
   for (std::vector::iterator DI = Diags.begin(),
DE = Diags.end(); DI != DE; ++DI) {
Index: lib/Sema/SemaLookup.cpp
===
--- lib/Sema/SemaLookup.cpp
+++ lib/Sema/SemaLookup.cpp
@@ -3744,6 +3744,7 @@
   bool 

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

2016-04-26 Thread James Y Knight via cfe-commits
jyknight added a comment.

ping again.


http://reviews.llvm.org/D17933



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


Re: [PATCH] D19175: Fix for PR27015 (variable template initialized with a generic lambda expression)

2016-04-26 Thread Richard Smith via cfe-commits
On Tue, Apr 26, 2016 at 1:55 PM, Akira Hatanaka via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> ahatanak added a comment.
>
> I'm looking for a way to avoid the assert in
> Sema::PerformDependentDiagnostics that is fired when a template parameter
> doesn't have a name.
>
> In order to avoid the assert, CXXRecordDecl::isDependentLambda() should
> return true for the old lambda class, and in order to do that, somehow I
> have to set KnownDependent to true in Sema::ActOnStartOfLambdaDefinition
> when the lambda is used to initialize a variable template.
>
> I can think of two ways to fix this:
>
> 1. Make changes in Sema::ActOnTypeParameter to call S->AddDecl(Param)
> regardless of whether Param has a name. This looks harmless to me because
> the list of Scope's decls is used just to see if a declaration belongs to a
> certain scope.
>
> 2. Add a field to Scope that indicates whether a variable template is
> being parsed.
>

I would expect this to go wrong in other contexts too. For instance:
"template void f(int a = []{ return 0; }()) {}"

Does this sound like a good idea or are there other ways to do what I'm
> trying to do?


This is going wrong in SemaLambda.cpp:818 -- it's trying to figure out
whether the lambda appears within a template, but gets the computation
wrong if no template parameters are in scope. (The decls_empty() check is
trying to distinguish between an explicit specialization scope and a "real"
template parameter scope.)

Ultimately, I think this is a bug in the parser -- it's using a single
template parameter scope for a multi-level template parameter list, and
also for the case of an explicit specialization. In the former case, there
should be multiple template parameter scopes, and in the latter case there
should be no scope. I don't think the reuse of the template parameter scope
for a multi-level list matters, but we shouldn't have a template parameter
scope at all if the only template headers are explicit specialization
headers.

You could change Parser::ParseTemplateDeclarationOrSpecialization to track
whether it's only seen explicit specialization 'template<>' headers, and
call 'TemplateParmScope.setFlags(0)' if so. Then remove the decls_empty()
check from SemaLambda.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r267604 - Test commit

2016-04-26 Thread Erik Pilkington via cfe-commits
Author: epilk
Date: Tue Apr 26 15:55:48 2016
New Revision: 267604

URL: http://llvm.org/viewvc/llvm-project?rev=267604=rev
Log:
Test commit

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

Modified: cfe/trunk/lib/Sema/SemaStmt.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmt.cpp?rev=267604=267603=267604=diff
==
--- cfe/trunk/lib/Sema/SemaStmt.cpp (original)
+++ cfe/trunk/lib/Sema/SemaStmt.cpp Tue Apr 26 15:55:48 2016
@@ -37,6 +37,7 @@
 #include "llvm/ADT/SmallPtrSet.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/SmallVector.h"
+
 using namespace clang;
 using namespace sema;
 


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


Re: [PATCH] D19175: Fix for PR27015 (variable template initialized with a generic lambda expression)

2016-04-26 Thread Akira Hatanaka via cfe-commits
ahatanak added a comment.

I'm looking for a way to avoid the assert in Sema::PerformDependentDiagnostics 
that is fired when a template parameter doesn't have a name.

In order to avoid the assert, CXXRecordDecl::isDependentLambda() should return 
true for the old lambda class, and in order to do that, somehow I have to set 
KnownDependent to true in Sema::ActOnStartOfLambdaDefinition when the lambda is 
used to initialize a variable template.

I can think of two ways to fix this:

1. Make changes in Sema::ActOnTypeParameter to call S->AddDecl(Param) 
regardless of whether Param has a name. This looks harmless to me because the 
list of Scope's decls is used just to see if a declaration belongs to a certain 
scope.

2. Add a field to Scope that indicates whether a variable template is being 
parsed.

Does this sound like a good idea or are there other ways to do what I'm trying 
to do?


http://reviews.llvm.org/D19175



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


r267601 - Try to get at_file_missing.c passing after LLVM r267556.

2016-04-26 Thread Nico Weber via cfe-commits
Author: nico
Date: Tue Apr 26 15:40:23 2016
New Revision: 267601

URL: http://llvm.org/viewvc/llvm-project?rev=267601=rev
Log:
Try to get at_file_missing.c passing after LLVM r267556.

r267556 made backslashes escape the next character
unconditionally in rsp files.  This test echos a path into
a rsp file, and paths contain backslashes on Windows. Since
it's not important for this test to get the filename from
the rsp file, just pass it regularly.

Modified:
cfe/trunk/test/Driver/at_file_missing.c

Modified: cfe/trunk/test/Driver/at_file_missing.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/at_file_missing.c?rev=267601=267600=267601=diff
==
--- cfe/trunk/test/Driver/at_file_missing.c (original)
+++ cfe/trunk/test/Driver/at_file_missing.c Tue Apr 26 15:40:23 2016
@@ -1,7 +1,7 @@
 // Make sure that arguments that begin with @ are left as is in the argument
 // stream, and also that @file arguments continue to be processed.
 
-// RUN: echo "%s -D FOO" > %t.args
-// RUN: %clang -rpath @executable_path/../lib @%t.args -### 2>&1 | FileCheck %s
+// RUN: echo "-D FOO" > %t.args
+// RUN: %clang -rpath @executable_path/../lib @%t.args %s -### 2>&1 | 
FileCheck %s
 // CHECK: "-D" "FOO"
 // CHECK: "-rpath" "@executable_path/../lib"


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


Re: [PATCH] D18136: boost-use-to-string check

2016-04-26 Thread Piotr Padlewski via cfe-commits
Prazek added a comment.

Alex, if you accept this revision, please accept this also
http://reviews.llvm.org/D18274


http://reviews.llvm.org/D18136



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


Re: [PATCH] D18136: boost-use-to-string check

2016-04-26 Thread Piotr Padlewski via cfe-commits
Prazek updated this revision to Diff 55077.
Prazek marked an inline comment as done.
Prazek added a comment.

I hope it is final


http://reviews.llvm.org/D18136

Files:
  clang-tidy/boost/BoostTidyModule.cpp
  clang-tidy/boost/CMakeLists.txt
  clang-tidy/boost/UseToStringCheck.cpp
  clang-tidy/boost/UseToStringCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/boost-use-to-string.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/boost-use-to-string.cpp

Index: test/clang-tidy/boost-use-to-string.cpp
===
--- /dev/null
+++ test/clang-tidy/boost-use-to-string.cpp
@@ -0,0 +1,149 @@
+// RUN: %check_clang_tidy %s boost-use-to-string %t
+
+namespace std {
+
+template 
+class basic_string {};
+
+using string = basic_string;
+using wstring = basic_string;
+}
+
+namespace boost {
+template 
+T lexical_cast(const V &) {
+  return T();
+};
+}
+
+struct my_weird_type {};
+
+std::string fun(const std::string &) {}
+
+void test_to_string1() {
+
+  auto xa = boost::lexical_cast(5);
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use std::to_string instead of boost::lexical_cast [boost-use-to-string]
+  // CHECK-FIXES: auto xa = std::to_string(5);
+
+  auto z = boost::lexical_cast(42LL);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use std::to_string {{..}}
+  // CHECK-FIXES: auto z = std::to_string(42LL);
+
+  // this should not trigger
+  fun(boost::lexical_cast(42.0));
+  auto non = boost::lexical_cast(42);
+  boost::lexical_cast("12");
+}
+
+void test_to_string2() {
+  int a;
+  long b;
+  long long c;
+  unsigned d;
+  unsigned long e;
+  unsigned long long f;
+  float g;
+  double h;
+  long double i;
+  bool j;
+
+  fun(boost::lexical_cast(a));
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::to_string {{..}}
+  // CHECK-FIXES: fun(std::to_string(a));
+  fun(boost::lexical_cast(b));
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::to_string {{..}}
+  // CHECK-FIXES: fun(std::to_string(b));
+  fun(boost::lexical_cast(c));
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::to_string {{..}}
+  // CHECK-FIXES: fun(std::to_string(c));
+  fun(boost::lexical_cast(d));
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::to_string {{..}}
+  // CHECK-FIXES: fun(std::to_string(d));
+  fun(boost::lexical_cast(e));
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::to_string {{..}}
+  // CHECK-FIXES: fun(std::to_string(e));
+  fun(boost::lexical_cast(f));
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::to_string {{..}}
+  // CHECK-FIXES: fun(std::to_string(f));
+
+  // No change for floating numbers.
+  fun(boost::lexical_cast(g));
+  fun(boost::lexical_cast(h));
+  fun(boost::lexical_cast(i));
+  // And bool.
+  fun(boost::lexical_cast(j));
+}
+
+std::string fun(const std::wstring &) {}
+
+void test_to_wstring() {
+  int a;
+  long b;
+  long long c;
+  unsigned d;
+  unsigned long e;
+  unsigned long long f;
+  float g;
+  double h;
+  long double i;
+  bool j;
+
+  fun(boost::lexical_cast(a));
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::to_wstring instead of boost::lexical_cast [boost-use-to-string]
+  // CHECK-FIXES: fun(std::to_wstring(a));
+  fun(boost::lexical_cast(b));
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::to_wstring {{..}}
+  // CHECK-FIXES: fun(std::to_wstring(b));
+  fun(boost::lexical_cast(c));
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::to_wstring {{..}}
+  // CHECK-FIXES: fun(std::to_wstring(c));
+  fun(boost::lexical_cast(d));
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::to_wstring {{..}}
+  // CHECK-FIXES: fun(std::to_wstring(d));
+  fun(boost::lexical_cast(e));
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::to_wstring {{..}}
+  // CHECK-FIXES: fun(std::to_wstring(e));
+  fun(boost::lexical_cast(f));
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::to_wstring {{..}}
+  // CHECK-FIXES: fun(std::to_wstring(f));
+
+  // No change for floating numbers
+  fun(boost::lexical_cast(g));
+  fun(boost::lexical_cast(h));
+  fun(boost::lexical_cast(i));
+  // and bool.
+  fun(boost::lexical_cast(j));
+}
+
+const auto glob = boost::lexical_cast(42);
+// CHECK-MESSAGES: :[[@LINE-1]]:19: warning: use std::to_string{{..}}
+// CHECK-FIXES: const auto glob = std::to_string(42);
+
+template 
+void string_as_T(T t = T()) {
+  boost::lexical_cast(42);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use std::to_string{{..}}
+  // CHECK-FIXES: std::to_string(42);
+
+  boost::lexical_cast(42);
+  string_as_T(boost::lexical_cast(42));
+  auto p = boost::lexical_cast(42);
+  auto p2 = (T)boost::lexical_cast(42);
+  auto p3 = static_cast(boost::lexical_cast(42));
+}
+
+#define my_to_string boost::lexical_cast
+
+void no_fixup_inside_macro() {
+  my_to_string(12);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use std::to_string{{..}}
+}
+
+void no_warnings() {
+  fun(boost::lexical_cast("abc"));
+  fun(boost::lexical_cast("abc"));
+  

Re: [PATCH] D18136: boost-use-to-string check

2016-04-26 Thread Piotr Padlewski via cfe-commits
Prazek marked 5 inline comments as done.


Comment at: clang-tidy/boost/UseToStringCheck.cpp:60
@@ +59,3 @@
+  else
+return;
+

alexfh wrote:
> Please add a reduced test case for this.
I don't see it crashing right now on the same test when it was crashing before, 
so I guess it won't be needed


http://reviews.llvm.org/D18136



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


[PATCH] D19552: Check 'r' and 'y specifiers of freebsd_kernel_printf format strings on PS4

2016-04-26 Thread Sunil Srivastava via cfe-commits
Sunil_Srivastava created this revision.
Sunil_Srivastava added a reviewer: dim.
Sunil_Srivastava added a subscriber: cfe-commits.
Herald added a subscriber: emaste.

This is an addendum to r229921.


http://reviews.llvm.org/D19552

Files:
  lib/Analysis/FormatString.cpp
  test/Sema/format-strings-freebsd.c

Index: test/Sema/format-strings-freebsd.c
===
--- test/Sema/format-strings-freebsd.c
+++ test/Sema/format-strings-freebsd.c
@@ -1,10 +1,11 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -triple i386-unknown-freebsd %s
 // RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-unknown-freebsd %s
+// RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-scei-ps4 %s
 
 // Test FreeBSD kernel printf extensions.
 int freebsd_kernel_printf(const char *, ...) 
__attribute__((__format__(__freebsd_kprintf__, 1, 2)));
 
-void check_freebsd_kernel_extensions(int i, long l, char *s)
+void check_freebsd_kernel_extensions(int i, long l, char *s, short h)
 {
   // %b expects an int and a char *
   freebsd_kernel_printf("reg=%b\n", i, "\10\2BITTWO\1BITONE\n"); // no-warning
@@ -32,6 +33,10 @@
   freebsd_kernel_printf("%lr", i); // expected-warning{{format specifies type 
'long' but the argument has type 'int'}}
   freebsd_kernel_printf("%lr", l); // no-warning
 
+  // h modifier expects a short
+  freebsd_kernel_printf("%hr", i); // expected-warning{{format specifies type 
'short' but the argument has type 'int'}}
+  freebsd_kernel_printf("%hr", h); // no-warning
+
   // %y expects an int
   freebsd_kernel_printf("%y", i); // no-warning
   freebsd_kernel_printf("%y", l); // expected-warning{{format specifies type 
'int' but the argument has type 'long'}}
Index: lib/Analysis/FormatString.cpp
===
--- lib/Analysis/FormatString.cpp
+++ lib/Analysis/FormatString.cpp
@@ -694,7 +694,7 @@
   return true;
 case ConversionSpecifier::FreeBSDrArg:
 case ConversionSpecifier::FreeBSDyArg:
-  return Target.getTriple().isOSFreeBSD();
+  return Target.getTriple().isOSFreeBSD() || 
Target.getTriple().isPS4();
 default:
   return false;
   }
@@ -727,7 +727,7 @@
   return true;
 case ConversionSpecifier::FreeBSDrArg:
 case ConversionSpecifier::FreeBSDyArg:
-  return Target.getTriple().isOSFreeBSD();
+  return Target.getTriple().isOSFreeBSD() || 
Target.getTriple().isPS4();
 default:
   return false;
   }


Index: test/Sema/format-strings-freebsd.c
===
--- test/Sema/format-strings-freebsd.c
+++ test/Sema/format-strings-freebsd.c
@@ -1,10 +1,11 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -triple i386-unknown-freebsd %s
 // RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-unknown-freebsd %s
+// RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-scei-ps4 %s
 
 // Test FreeBSD kernel printf extensions.
 int freebsd_kernel_printf(const char *, ...) __attribute__((__format__(__freebsd_kprintf__, 1, 2)));
 
-void check_freebsd_kernel_extensions(int i, long l, char *s)
+void check_freebsd_kernel_extensions(int i, long l, char *s, short h)
 {
   // %b expects an int and a char *
   freebsd_kernel_printf("reg=%b\n", i, "\10\2BITTWO\1BITONE\n"); // no-warning
@@ -32,6 +33,10 @@
   freebsd_kernel_printf("%lr", i); // expected-warning{{format specifies type 'long' but the argument has type 'int'}}
   freebsd_kernel_printf("%lr", l); // no-warning
 
+  // h modifier expects a short
+  freebsd_kernel_printf("%hr", i); // expected-warning{{format specifies type 'short' but the argument has type 'int'}}
+  freebsd_kernel_printf("%hr", h); // no-warning
+
   // %y expects an int
   freebsd_kernel_printf("%y", i); // no-warning
   freebsd_kernel_printf("%y", l); // expected-warning{{format specifies type 'int' but the argument has type 'long'}}
Index: lib/Analysis/FormatString.cpp
===
--- lib/Analysis/FormatString.cpp
+++ lib/Analysis/FormatString.cpp
@@ -694,7 +694,7 @@
   return true;
 case ConversionSpecifier::FreeBSDrArg:
 case ConversionSpecifier::FreeBSDyArg:
-  return Target.getTriple().isOSFreeBSD();
+  return Target.getTriple().isOSFreeBSD() || Target.getTriple().isPS4();
 default:
   return false;
   }
@@ -727,7 +727,7 @@
   return true;
 case ConversionSpecifier::FreeBSDrArg:
 case ConversionSpecifier::FreeBSDyArg:
-  return Target.getTriple().isOSFreeBSD();
+  return Target.getTriple().isOSFreeBSD() || Target.getTriple().isPS4();
 default:
   return false;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r267591 - Apparently XFAIL tests that are supposed to fail to compile can be problematic. They still get compiled, and if the compile succeeds, the buildbots complain. Replace the XFAIL with

2016-04-26 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Tue Apr 26 14:29:35 2016
New Revision: 267591

URL: http://llvm.org/viewvc/llvm-project?rev=267591=rev
Log:
Apparently XFAIL tests that are supposed to fail to compile can be problematic. 
They still get compiled, and if the compile succeeds, the buildbots complain. 
Replace the XFAIL with #error.

Modified:
libcxx/trunk/test/std/re/re.alg/re.alg.match/basic.fail.cpp
libcxx/trunk/test/std/re/re.alg/re.alg.search/basic.fail.cpp
libcxx/trunk/test/std/re/re.iter/re.regiter/re.regiter.cnstr/cnstr.fail.cpp
libcxx/trunk/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/array.fail.cpp
libcxx/trunk/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/init.fail.cpp
libcxx/trunk/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/int.fail.cpp
libcxx/trunk/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/vector.fail.cpp

Modified: libcxx/trunk/test/std/re/re.alg/re.alg.match/basic.fail.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.alg/re.alg.match/basic.fail.cpp?rev=267591=267590=267591=diff
==
--- libcxx/trunk/test/std/re/re.alg/re.alg.match/basic.fail.cpp (original)
+++ libcxx/trunk/test/std/re/re.alg/re.alg.match/basic.fail.cpp Tue Apr 26 
14:29:35 2016
@@ -18,12 +18,14 @@
 //regex_constants::match_flag_type = 
 //  regex_constants::match_default) = delete;
 
-// XFAIL: C++98, c++03, c++11
-
 #include 
 #include 
 #include "test_macros.h"
 
+#if TEST_STD_VER < 14
+#error
+#endif
+
 int main()
 {
 {

Modified: libcxx/trunk/test/std/re/re.alg/re.alg.search/basic.fail.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.alg/re.alg.search/basic.fail.cpp?rev=267591=267590=267591=diff
==
--- libcxx/trunk/test/std/re/re.alg/re.alg.search/basic.fail.cpp (original)
+++ libcxx/trunk/test/std/re/re.alg/re.alg.search/basic.fail.cpp Tue Apr 26 
14:29:35 2016
@@ -18,12 +18,14 @@
 // regex_constants::match_flag_type = 
 //   regex_constants::match_default) = delete;
 
-// XFAIL: C++98, c++03, c++11
-
 #include 
 #include 
 #include "test_macros.h"
 
+#if TEST_STD_VER < 14
+#error
+#endif
+
 int main()
 {
 {

Modified: 
libcxx/trunk/test/std/re/re.iter/re.regiter/re.regiter.cnstr/cnstr.fail.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.iter/re.regiter/re.regiter.cnstr/cnstr.fail.cpp?rev=267591=267590=267591=diff
==
--- libcxx/trunk/test/std/re/re.iter/re.regiter/re.regiter.cnstr/cnstr.fail.cpp 
(original)
+++ libcxx/trunk/test/std/re/re.iter/re.regiter/re.regiter.cnstr/cnstr.fail.cpp 
Tue Apr 26 14:29:35 2016
@@ -17,12 +17,14 @@
 //  regex_constants::match_flag_type m =
 //regex_constants::match_default) = delete;
 
-// XFAIL: C++98, c++03, c++11
-
 #include 
 #include 
 #include "test_macros.h"
 
+#if TEST_STD_VER < 14
+#error
+#endif
+
 int main()
 {
 {

Modified: 
libcxx/trunk/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/array.fail.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/array.fail.cpp?rev=267591=267590=267591=diff
==
--- libcxx/trunk/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/array.fail.cpp 
(original)
+++ libcxx/trunk/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/array.fail.cpp 
Tue Apr 26 14:29:35 2016
@@ -18,13 +18,15 @@
 //  regex_constants::match_flag_type m =
 //  
regex_constants::match_default);
 
-// XFAIL: C++98, c++03, c++11
-
 #include 
 #include 
 #include 
 #include "test_macros.h"
 
+#if TEST_STD_VER < 14
+#error
+#endif
+
 int main()
 {
 {

Modified: 
libcxx/trunk/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/init.fail.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/init.fail.cpp?rev=267591=267590=267591=diff
==
--- libcxx/trunk/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/init.fail.cpp 
(original)
+++ libcxx/trunk/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/init.fail.cpp 
Tue Apr 26 14:29:35 2016
@@ -17,12 +17,14 @@
 //  regex_constants::match_flag_type m =
 //  
regex_constants::match_default);
 
-// XFAIL: C++98, c++03, c++11
-
 #include 
 #include 
 #include "test_macros.h"
 
+#if TEST_STD_VER < 14
+#error
+#endif
+
 int main()
 {
 {

Modified: 
libcxx/trunk/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/int.fail.cpp
URL: 

Re: [PATCH] D19071: [OpenCL] Add predefined macros.

2016-04-26 Thread Yaxun Liu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL267590: [OpenCL] Add predefined macros. (authored by yaxunl).

Changed prior to commit:
  http://reviews.llvm.org/D19071?vs=55016=55066#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D19071

Files:
  cfe/trunk/lib/Frontend/CompilerInvocation.cpp
  cfe/trunk/lib/Frontend/InitPreprocessor.cpp
  cfe/trunk/test/Frontend/std.cl
  cfe/trunk/test/Frontend/stdlang.c
  cfe/trunk/test/Preprocessor/predefined-macros.c

Index: cfe/trunk/test/Preprocessor/predefined-macros.c
===
--- cfe/trunk/test/Preprocessor/predefined-macros.c
+++ cfe/trunk/test/Preprocessor/predefined-macros.c
@@ -146,3 +146,40 @@
 // CHECK-SYNC_CAS_MIPS: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1
 // CHECK-SYNC_CAS_MIPS32-NOT: __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8
 // CHECK-SYNC_CAS_MIPS64: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 1
+
+// RUN: %clang_cc1 %s -E -dM -o - -x cl \
+// RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-CL10
+// RUN: %clang_cc1 %s -E -dM -o - -x cl -cl-std=CL1.1 \
+// RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-CL11
+// RUN: %clang_cc1 %s -E -dM -o - -x cl -cl-std=CL1.2 \
+// RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-CL12
+// RUN: %clang_cc1 %s -E -dM -o - -x cl -cl-std=CL2.0 \
+// RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-CL20
+// RUN: %clang_cc1 %s -E -dM -o - -x cl -cl-fast-relaxed-math \
+// RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-FRM
+// CHECK-CL10: #define CL_VERSION_1_0 100
+// CHECK-CL10: #define CL_VERSION_1_1 110
+// CHECK-CL10: #define CL_VERSION_1_2 120
+// CHECK-CL10: #define CL_VERSION_2_0 200
+// CHECK-CL10: #define __OPENCL_C_VERSION__ 100
+// CHECK-CL10-NOT: #define __FAST_RELAXED_MATH__ 1
+// CHECK-CL11: #define CL_VERSION_1_0 100
+// CHECK-CL11: #define CL_VERSION_1_1 110
+// CHECK-CL11: #define CL_VERSION_1_2 120
+// CHECK-CL11: #define CL_VERSION_2_0 200
+// CHECK-CL11: #define __OPENCL_C_VERSION__ 110
+// CHECK-CL11-NOT: #define __FAST_RELAXED_MATH__ 1
+// CHECK-CL12: #define CL_VERSION_1_0 100
+// CHECK-CL12: #define CL_VERSION_1_1 110
+// CHECK-CL12: #define CL_VERSION_1_2 120
+// CHECK-CL12: #define CL_VERSION_2_0 200
+// CHECK-CL12: #define __OPENCL_C_VERSION__ 120
+// CHECK-CL12-NOT: #define __FAST_RELAXED_MATH__ 1
+// CHECK-CL20: #define CL_VERSION_1_0 100
+// CHECK-CL20: #define CL_VERSION_1_1 110
+// CHECK-CL20: #define CL_VERSION_1_2 120
+// CHECK-CL20: #define CL_VERSION_2_0 200
+// CHECK-CL20: #define __OPENCL_C_VERSION__ 200
+// CHECK-CL20-NOT: #define __FAST_RELAXED_MATH__ 1
+// CHECK-FRM: #define __FAST_RELAXED_MATH__ 1
+
Index: cfe/trunk/test/Frontend/stdlang.c
===
--- cfe/trunk/test/Frontend/stdlang.c
+++ cfe/trunk/test/Frontend/stdlang.c
@@ -1,6 +1,13 @@
 // RUN: %clang_cc1 -x cuda -std=c++11 -DCUDA %s
-// RUN: %clang_cc1 -x cl -std=c99 -DOPENCL %s
-// expected-no-diagnostics
+// RUN: %clang_cc1 -x cl -DOPENCL %s
+// RUN: %clang_cc1 -x cl -cl-std=CL -DOPENCL %s
+// RUN: %clang_cc1 -x cl -cl-std=CL1.1 -DOPENCL %s
+// RUN: %clang_cc1 -x cl -cl-std=CL1.2 -DOPENCL %s
+// RUN: %clang_cc1 -x cl -cl-std=CL2.0 -DOPENCL %s
+// RUN: not %clang_cc1 -x cl -std=c99 -DOPENCL %s 2>&1 | FileCheck --check-prefix=CHECK-C99 %s
+// RUN: not %clang_cc1 -x cl -cl-std=invalid -DOPENCL %s 2>&1 | FileCheck --check-prefix=CHECK-INVALID %s
+// CHECK-C99: error: invalid argument '-std=c99' not allowed with 'OpenCL'
+// CHECK-INVALID: error: invalid value 'invalid' in '-cl-std=invalid'
 
 #if defined(CUDA)
   __attribute__((device)) void f_device();
Index: cfe/trunk/test/Frontend/std.cl
===
--- cfe/trunk/test/Frontend/std.cl
+++ cfe/trunk/test/Frontend/std.cl
@@ -1,9 +0,0 @@
-// RUN: %clang_cc1 %s -fsyntax-only -cl-std=CL
-// RUN: %clang_cc1 %s -fsyntax-only -cl-std=CL1.1
-// RUN: %clang_cc1 %s -fsyntax-only -cl-std=CL1.2
-// RUN: %clang_cc1 %s -fsyntax-only -cl-std=CL2.0
-// RUN: not %clang_cc1 %s -fsyntax-only -cl-std=invalid -DINVALID 2>&1 | FileCheck %s
-
-#ifdef INVALID 
-// CHECK: invalid value 'invalid' in '-cl-std=invalid'
-#endif
Index: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
===
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp
@@ -1495,9 +1495,8 @@
 << A->getAsString(Args) << "C++/ObjC++";
 break;
   case IK_OpenCL:
-if (!Std.isC99())
-  Diags.Report(diag::err_drv_argument_not_allowed_with)
-<< A->getAsString(Args) << "OpenCL";
+Diags.Report(diag::err_drv_argument_not_allowed_with)
+  << A->getAsString(Args) << "OpenCL";
 break;
   case IK_CUDA:
   case IK_PreprocessedCuda:
Index: cfe/trunk/lib/Frontend/InitPreprocessor.cpp

r267590 - [OpenCL] Add predefined macros.

2016-04-26 Thread Yaxun Liu via cfe-commits
Author: yaxunl
Date: Tue Apr 26 14:25:46 2016
New Revision: 267590

URL: http://llvm.org/viewvc/llvm-project?rev=267590=rev
Log:
[OpenCL] Add predefined macros.

OpenCL spec requires __OPENCL_C_VERSION__ to be defined based on -cl-std 
option. This patch implements that.

The patch also defines __FAST_RELAXED_MATH__ based on -cl-fast-relaxed-math 
option.

Also fixed a test using -std=c99 for OpenCL program. Limit allowed language 
standard of OpenCL to be OpenCL standards.

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

Removed:
cfe/trunk/test/Frontend/std.cl
Modified:
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/Frontend/InitPreprocessor.cpp
cfe/trunk/test/Frontend/stdlang.c
cfe/trunk/test/Preprocessor/predefined-macros.c

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=267590=267589=267590=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Tue Apr 26 14:25:46 2016
@@ -1495,9 +1495,8 @@ static void ParseLangArgs(LangOptions 
 << A->getAsString(Args) << "C++/ObjC++";
 break;
   case IK_OpenCL:
-if (!Std.isC99())
-  Diags.Report(diag::err_drv_argument_not_allowed_with)
-<< A->getAsString(Args) << "OpenCL";
+Diags.Report(diag::err_drv_argument_not_allowed_with)
+  << A->getAsString(Args) << "OpenCL";
 break;
   case IK_CUDA:
   case IK_PreprocessedCuda:

Modified: cfe/trunk/lib/Frontend/InitPreprocessor.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitPreprocessor.cpp?rev=267590=267589=267590=diff
==
--- cfe/trunk/lib/Frontend/InitPreprocessor.cpp (original)
+++ cfe/trunk/lib/Frontend/InitPreprocessor.cpp Tue Apr 26 14:25:46 2016
@@ -408,6 +408,39 @@ static void InitializeStandardPredefined
   if (LangOpts.ObjC1)
 Builder.defineMacro("__OBJC__");
 
+  // OpenCL v1.0/1.1 s6.9, v1.2/2.0 s6.10: Preprocessor Directives and Macros.
+  if (LangOpts.OpenCL) {
+// OpenCL v1.0 and v1.1 do not have a predefined macro to indicate the
+// language standard with which the program is compiled. __OPENCL_VERSION__
+// is for the OpenCL version supported by the OpenCL device, which is not
+// necessarily the language standard with which the program is compiled.
+// A shared OpenCL header file requires a macro to indicate the language
+// standard. As a workaround, __OPENCL_C_VERSION__ is defined for
+// OpenCL v1.0 and v1.1.
+switch (LangOpts.OpenCLVersion) {
+case 100:
+  Builder.defineMacro("__OPENCL_C_VERSION__", "100");
+  break;
+case 110:
+  Builder.defineMacro("__OPENCL_C_VERSION__", "110");
+  break;
+case 120:
+  Builder.defineMacro("__OPENCL_C_VERSION__", "120");
+  break;
+case 200:
+  Builder.defineMacro("__OPENCL_C_VERSION__", "200");
+  break;
+default:
+  llvm_unreachable("Unsupported OpenCL version");
+}
+Builder.defineMacro("CL_VERSION_1_0", "100");
+Builder.defineMacro("CL_VERSION_1_1", "110");
+Builder.defineMacro("CL_VERSION_1_2", "120");
+Builder.defineMacro("CL_VERSION_2_0", "200");
+
+if (LangOpts.FastRelaxedMath)
+  Builder.defineMacro("__FAST_RELAXED_MATH__");
+  }
   // Not "standard" per se, but available even with the -undef flag.
   if (LangOpts.AsmPreprocessor)
 Builder.defineMacro("__ASSEMBLER__");

Removed: cfe/trunk/test/Frontend/std.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/std.cl?rev=267589=auto
==
--- cfe/trunk/test/Frontend/std.cl (original)
+++ cfe/trunk/test/Frontend/std.cl (removed)
@@ -1,9 +0,0 @@
-// RUN: %clang_cc1 %s -fsyntax-only -cl-std=CL
-// RUN: %clang_cc1 %s -fsyntax-only -cl-std=CL1.1
-// RUN: %clang_cc1 %s -fsyntax-only -cl-std=CL1.2
-// RUN: %clang_cc1 %s -fsyntax-only -cl-std=CL2.0
-// RUN: not %clang_cc1 %s -fsyntax-only -cl-std=invalid -DINVALID 2>&1 | 
FileCheck %s
-
-#ifdef INVALID 
-// CHECK: invalid value 'invalid' in '-cl-std=invalid'
-#endif

Modified: cfe/trunk/test/Frontend/stdlang.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/stdlang.c?rev=267590=267589=267590=diff
==
--- cfe/trunk/test/Frontend/stdlang.c (original)
+++ cfe/trunk/test/Frontend/stdlang.c Tue Apr 26 14:25:46 2016
@@ -1,6 +1,13 @@
 // RUN: %clang_cc1 -x cuda -std=c++11 -DCUDA %s
-// RUN: %clang_cc1 -x cl -std=c99 -DOPENCL %s
-// expected-no-diagnostics
+// RUN: %clang_cc1 -x cl -DOPENCL %s
+// RUN: %clang_cc1 -x cl -cl-std=CL -DOPENCL %s
+// RUN: %clang_cc1 -x cl -cl-std=CL1.1 -DOPENCL %s
+// RUN: %clang_cc1 -x cl 

[clang-tools-extra] r267587 - [clang-tidy] Added misc-move-const-arg docs.

2016-04-26 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Tue Apr 26 13:48:59 2016
New Revision: 267587

URL: http://llvm.org/viewvc/llvm-project?rev=267587=rev
Log:
[clang-tidy] Added misc-move-const-arg docs.

Added:
clang-tools-extra/trunk/docs/clang-tidy/checks/misc-move-const-arg.rst
Modified:
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst

Modified: clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst?rev=267587=267586=267587=diff
==
--- clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst (original)
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst Tue Apr 26 13:48:59 
2016
@@ -61,6 +61,7 @@ Clang-Tidy Checks
misc-macro-parentheses
misc-macro-repeated-side-effects
misc-misplaced-widening-cast
+   misc-move-const-arg
misc-move-constructor-init
misc-multiple-statement-macro
misc-new-delete-overloads
@@ -76,7 +77,7 @@ Clang-Tidy Checks
misc-string-literal-with-embedded-nul
misc-suspicious-missing-comma
misc-suspicious-semicolon
-   misc-suspicious-string-compare   
+   misc-suspicious-string-compare
misc-swapped-arguments
misc-throw-by-value-catch-by-reference
misc-undelegated-constructor

Added: clang-tools-extra/trunk/docs/clang-tidy/checks/misc-move-const-arg.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/misc-move-const-arg.rst?rev=267587=auto
==
--- clang-tools-extra/trunk/docs/clang-tidy/checks/misc-move-const-arg.rst 
(added)
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/misc-move-const-arg.rst Tue 
Apr 26 13:48:59 2016
@@ -0,0 +1,15 @@
+.. title:: clang-tidy - misc-move-const-arg
+
+misc-move-const-arg
+===
+
+The check warns if the result of ``std::move(x)`` is bound to a constant
+reference argument, e.g.:
+
+.. code:: c++
+
+  void f(const string&);
+  void g() {
+string s;
+F(std::move(s));  // Warning here. std::move() is not moving anything.
+  }


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


Re: r267496 - [lanai] Update handling of structs in arguments to be passed in registers.

2016-04-26 Thread Kostya Serebryany via cfe-commits
On Tue, Apr 26, 2016 at 6:49 AM, Jacques Pienaar 
wrote:

> Thanks for fixing this. My apologies for breaking this and not noticing &
> fixing it earlier.
>

no problem.


> Is there any way to test the Windows build without a Windows machine at my
> disposal?
>

Not that I know of. My workflow for windows is the same -- commit, watch
the bots, make a guess-based fix if bots got broken.
That's unfortunate, I would rather prefer trybots, but we don't have them
for any platform...

--kcc


>
> On Mon, Apr 25, 2016 at 6:59 PM, Kostya Serebryany  wrote:
>
>> Hopefully fixed by r267513.
>>
>> On Mon, Apr 25, 2016 at 6:46 PM, Kostya Serebryany 
>> wrote:
>>
>>> +rnk
>>>
>>> On Mon, Apr 25, 2016 at 5:09 PM, Jacques Pienaar via cfe-commits <
>>> cfe-commits@lists.llvm.org> wrote:
>>>
 Author: jpienaar
 Date: Mon Apr 25 19:09:29 2016
 New Revision: 267496

 URL: http://llvm.org/viewvc/llvm-project?rev=267496=rev
 Log:
 [lanai] Update handling of structs in arguments to be passed in
 registers.

 Previously aggregate types were passed byval, change the ABI to pass
 these in registers instead.


 Modified:
 cfe/trunk/lib/CodeGen/TargetInfo.cpp
 cfe/trunk/test/CodeGen/lanai-arguments.c

 Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
 URL:
 http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=267496=267495=267496=diff

 ==
 --- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
 +++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Mon Apr 25 19:09:29 2016
 @@ -6691,6 +6691,7 @@ public:
I.info = classifyArgumentType(I.type, State);
}

 +  ABIArgInfo getIndirectResult(QualType Ty, bool ByVal, CCState
 ) const;
ABIArgInfo classifyArgumentType(QualType RetTy, CCState )
 const;
  };
  } // end anonymous namespace
 @@ -6712,21 +6713,72 @@ bool LanaiABIInfo::shouldUseInReg(QualTy
return true;
  }

 +ABIArgInfo LanaiABIInfo::getIndirectResult(QualType Ty, bool ByVal,
 +   CCState ) const {
 +  if (!ByVal) {
 +if (State.FreeRegs) {
 +  --State.FreeRegs; // Non-byval indirects just use one pointer.
 +  return getNaturalAlignIndirectInReg(Ty);
 +}
 +return getNaturalAlignIndirect(Ty, false);
 +  }
 +
 +  // Compute the byval alignment.
 +  constexpr unsigned MinABIStackAlignInBytes = 4;

>>>
>>> This broke the build on Windows;
>>>
>>> C:\b\slave\sanitizer-windows\llvm\tools\clang\lib\CodeGen\TargetInfo.cpp(6727)
>>>  : error C2065: 'constexpr' : undeclared identifier
>>>
>>>
>>>
>>>
>>>
 +  unsigned TypeAlign = getContext().getTypeAlign(Ty) / 8;
 +  return ABIArgInfo::getIndirect(CharUnits::fromQuantity(4),
 /*ByVal=*/true,
 + /*Realign=*/TypeAlign >
 + MinABIStackAlignInBytes);
 +}
 +
  ABIArgInfo LanaiABIInfo::classifyArgumentType(QualType Ty,
CCState ) const {
 -  if (isAggregateTypeForABI(Ty))
 -return getNaturalAlignIndirect(Ty);
 +  // Check with the C++ ABI first.
 +  const RecordType *RT = Ty->getAs();
 +  if (RT) {
 +CGCXXABI::RecordArgABI RAA = getRecordArgABI(RT, getCXXABI());
 +if (RAA == CGCXXABI::RAA_Indirect) {
 +  return getIndirectResult(Ty, /*ByVal=*/false, State);
 +} else if (RAA == CGCXXABI::RAA_DirectInMemory) {
 +  return getNaturalAlignIndirect(Ty, /*ByRef=*/true);
 +}
 +  }
 +
 +  if (isAggregateTypeForABI(Ty)) {
 +// Structures with flexible arrays are always indirect.
 +if (RT && RT->getDecl()->hasFlexibleArrayMember())
 +  return getIndirectResult(Ty, /*ByVal=*/true, State);
 +
 +// Ignore empty structs/unions.
 +if (isEmptyRecord(getContext(), Ty, true))
 +  return ABIArgInfo::getIgnore();
 +
 +llvm::LLVMContext  = getVMContext();
 +unsigned SizeInRegs = (getContext().getTypeSize(Ty) + 31) / 32;
 +if (SizeInRegs <= State.FreeRegs) {
 +  llvm::IntegerType *Int32 = llvm::Type::getInt32Ty(LLVMContext);
 +  SmallVector Elements(SizeInRegs, Int32);
 +  llvm::Type *Result = llvm::StructType::get(LLVMContext,
 Elements);
 +  State.FreeRegs -= SizeInRegs;
 +  return ABIArgInfo::getDirectInReg(Result);
 +} else {
 +  State.FreeRegs = 0;
 +}
 +return getIndirectResult(Ty, true, State);
 +  }

// Treat an enum type as its underlying type.
if (const auto *EnumTy = Ty->getAs())
  Ty = EnumTy->getDecl()->getIntegerType();

 -  if (shouldUseInReg(Ty, State))
 -  

[PATCH] D19547: [clang-tidy] Add FixIt for swapping arguments in string-constructor-checker.

2016-04-26 Thread Etienne Bergeron via cfe-commits
etienneb created this revision.
etienneb added a reviewer: alexfh.
etienneb added a subscriber: cfe-commits.

Arguments can be swapped using fixit when they are not in macros.
This is the same implementation than SwappedArguments. Some code 
got lifted to be reused.

Others checks are not safe to be fixed as they tend to be bugs or errors.
It is better to let the user manually review them.

http://reviews.llvm.org/D19547

Files:
  clang-tidy/misc/StringConstructorCheck.cpp
  clang-tidy/misc/SwappedArgumentsCheck.cpp
  clang-tidy/utils/FixItHintUtils.cpp
  clang-tidy/utils/FixItHintUtils.h
  test/clang-tidy/misc-string-constructor.cpp

Index: test/clang-tidy/misc-string-constructor.cpp
===
--- test/clang-tidy/misc-string-constructor.cpp
+++ test/clang-tidy/misc-string-constructor.cpp
@@ -22,8 +22,10 @@
 void Test() {
   std::string str('x', 4);
   // CHECK-MESSAGES: [[@LINE-1]]:15: warning: constructor parameters are probably swapped [misc-string-constructor]
+  // CHECK-FIXES: std::string str(4, 'x');  
   std::wstring wstr(L'x', 4);
   // CHECK-MESSAGES: [[@LINE-1]]:16: warning: constructor parameters are probably swapped
+  // CHECK-FIXES: std::wstring wstr(4, L'x');
   std::string s0(0, 'x');
   // CHECK-MESSAGES: [[@LINE-1]]:15: warning: constructor creating an empty string
   std::string s1(-4, 'x');
Index: clang-tidy/utils/FixItHintUtils.h
===
--- clang-tidy/utils/FixItHintUtils.h
+++ clang-tidy/utils/FixItHintUtils.h
@@ -24,6 +24,9 @@
 /// \brief Creates fix to make VarDecl const qualified.
 FixItHint changeVarDeclToConst(const VarDecl );
 
+/// \brief Get a StringRef representing a SourceRange.
+StringRef getSourceRangeAsString(const ASTContext , SourceRange R);
+
 } // namespace create_fix_it
 } // utils
 } // namespace tidy
Index: clang-tidy/utils/FixItHintUtils.cpp
===
--- clang-tidy/utils/FixItHintUtils.cpp
+++ clang-tidy/utils/FixItHintUtils.cpp
@@ -30,6 +30,21 @@
   return FixItHint::CreateInsertion(Var.getTypeSpecStartLoc(), "const ");
 }
 
+StringRef getSourceRangeAsString(const ASTContext , SourceRange R) {
+  const SourceManager  = Context.getSourceManager();
+  // Don't even try to resolve macro or include contraptions. Not worth emitting
+  // a fixit for.
+  if (R.getBegin().isMacroID() ||
+  !SM.isWrittenInSameFile(R.getBegin(), R.getEnd()))
+return StringRef();
+
+  const char *Begin = SM.getCharacterData(R.getBegin());
+  const char *End = SM.getCharacterData(
+  Lexer::getLocForEndOfToken(R.getEnd(), 0, SM, Context.getLangOpts()));
+
+  return StringRef(Begin, End - Begin);
+}
+
 } // namespace create_fix_it
 } // namespace utils
 } // namespace tidy
Index: clang-tidy/misc/SwappedArgumentsCheck.cpp
===
--- clang-tidy/misc/SwappedArgumentsCheck.cpp
+++ clang-tidy/misc/SwappedArgumentsCheck.cpp
@@ -8,6 +8,7 @@
 //===--===//
 
 #include "SwappedArgumentsCheck.h"
+#include "../utils/FixItHintUtils.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/Lex/Lexer.h"
 #include "llvm/ADT/SmallPtrSet.h"
@@ -46,24 +47,8 @@
  Cast->getCastKind() == CK_PointerToBoolean;
 }
 
-/// \brief Get a StringRef representing a SourceRange.
-static StringRef getAsString(const MatchFinder::MatchResult ,
- SourceRange R) {
-  const SourceManager  = *Result.SourceManager;
-  // Don't even try to resolve macro or include contraptions. Not worth emitting
-  // a fixit for.
-  if (R.getBegin().isMacroID() ||
-  !SM.isWrittenInSameFile(R.getBegin(), R.getEnd()))
-return StringRef();
-
-  const char *Begin = SM.getCharacterData(R.getBegin());
-  const char *End = SM.getCharacterData(Lexer::getLocForEndOfToken(
-  R.getEnd(), 0, SM, Result.Context->getLangOpts()));
-
-  return StringRef(Begin, End - Begin);
-}
-
 void SwappedArgumentsCheck::check(const MatchFinder::MatchResult ) {
+  const ASTContext  = *Result.Context;
   auto *Call = Result.Nodes.getStmtAs("call");
 
   llvm::SmallPtrSet UsedArgs;
@@ -108,8 +93,10 @@
 << LHS->getType() << LHSFrom->getType() << RHS->getType()
 << RHSFrom->getType() << LHSRange << RHSRange;
 
-StringRef RHSString = getAsString(Result, RHSRange);
-StringRef LHSString = getAsString(Result, LHSRange);
+StringRef RHSString =
+utils::create_fix_it::getSourceRangeAsString(Ctx, RHSRange);
+StringRef LHSString =
+utils::create_fix_it::getSourceRangeAsString(Ctx, LHSRange);
 if (!LHSString.empty() && !RHSString.empty()) {
   D << FixItHint::CreateReplacement(
CharSourceRange::getTokenRange(LHSRange), RHSString)
Index: clang-tidy/misc/StringConstructorCheck.cpp
===
--- 

Re: [PATCH] D19299: lower __builtin_expect() directly to prof metadata instead of LLVM intrinsic

2016-04-26 Thread Sanjay Patel via cfe-commits
spatel abandoned this revision.
spatel added a comment.

Abandoning.

The feedback on the dev list was that handling the builtin_expect() in clang is 
ugly, so it's better to pay a small cost in LLVM to do it.

Note that the current llvm.expect lowering pass doesn't actually work for 
anything but the simplest cases. The pass needs to be enhanced to handle 
patterns like:

  int foo(int x, int y) {
if (__builtin_expect(x, 20) > 10) return 234;  // expected value is not 1
return 2;
  }

or:

  int foo(int n) {
int b = __builtin_expect(n, 1);  // expect is not directly used in 
comparison
if (b) return 24;
return 234;
  }

Currently, the llvm.expect is discarded in these cases without generating any 
metadata.


http://reviews.llvm.org/D19299



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


Re: [PATCH] D18271: Avoid -Wshadow warnings about constructor parameters named after fields

2016-04-26 Thread Reid Kleckner via cfe-commits
rnk updated this revision to Diff 55044.
rnk added a comment.

- Implement suggestions to avoid warning twice


http://reviews.llvm.org/D18271

Files:
  include/clang/Basic/Diagnostic.h
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/Sema.h
  lib/Sema/AnalysisBasedWarnings.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaExpr.cpp
  test/SemaCXX/warn-shadow.cpp

Index: test/SemaCXX/warn-shadow.cpp
===
--- test/SemaCXX/warn-shadow.cpp
+++ test/SemaCXX/warn-shadow.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -verify -fsyntax-only -Wshadow %s
+// RUN: %clang_cc1 -verify -fsyntax-only -Wshadow-all %s
 
 namespace {
   int i; // expected-note {{previous declaration is here}}
@@ -29,7 +29,23 @@
 
 class A {
   static int data; // expected-note {{previous declaration}}
-  int field; // expected-note {{previous declaration}}
+  // expected-note@+1 {{previous declaration}}
+  int field;
+  int f1, f2, f3, f4; // expected-note 8 {{previous declaration is here}}
+
+  // The initialization is safe, but the modifications are not.
+  A(int f1, int f2, int f3, int f4) // expected-note-re 4 {{variable 'f{{[0-4]}}' is declared here}}
+	  : f1(f1) {
+f1 = 3; // expected-warning {{modifying constructor parameter 'f1' that shadows a field of 'A'}}
+f1 = 4; // one warning per shadow
+f2++; // expected-warning {{modifying constructor parameter 'f2' that shadows a field of 'A'}}
+--f3; // expected-warning {{modifying constructor parameter 'f3' that shadows a field of 'A'}}
+f4 += 2; // expected-warning {{modifying constructor parameter 'f4' that shadows a field of 'A'}}
+  }
+
+  // The initialization is safe, but the modifications are not.
+  // expected-warning-re@+1 4 {{constructor parameter 'f{{[0-4]}}' shadows the field 'f{{[0-9]}}' of 'A'}}
+  A(int f1, int f2, int f3, int f4, double overload_dummy) {}
 
   void test() {
 char *field; // expected-warning {{declaration shadows a field of 'A'}}
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -9733,6 +9733,9 @@
 /// emit an error and return true.  If so, return false.
 static bool CheckForModifiableLvalue(Expr *E, SourceLocation Loc, Sema ) {
   assert(!E->hasPlaceholderType(BuiltinType::PseudoObject));
+
+  S.CheckShadowingDeclModification(E, Loc);
+
   SourceLocation OrigLoc = Loc;
   Expr::isModifiableLvalueResult IsLV = E->isModifiableLvalue(S.Context,
   );
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -1609,9 +1609,19 @@
 // If this was a forward reference to a label, verify it was defined.
 if (LabelDecl *LD = dyn_cast(D))
   CheckPoppedLabel(LD, *this);
-
-// Remove this name from our lexical scope.
+
+// Remove this name from our lexical scope, and warn on it if we haven't
+// already.
 IdResolver.RemoveDecl(D);
+auto ShadowI = ShadowingDecls.find(D);
+if (ShadowI != ShadowingDecls.end()) {
+  if (const auto *FD = dyn_cast(ShadowI->second)) {
+Diag(D->getLocation(), diag::warn_ctor_parm_shadows_field)
+<< D << FD << FD->getParent();
+Diag(FD->getLocation(), diag::note_previous_declaration);
+  }
+  ShadowingDecls.erase(ShadowI);
+}
   }
 }
 
@@ -6382,6 +6392,17 @@
   return NewVD;
 }
 
+/// Enum describing the %select options in diag::warn_decl_shadow.
+enum ShadowedDeclKind { SDK_Local, SDK_Global, SDK_StaticMember, SDK_Field };
+
+/// Determine what kind of declaration we're shadowing.
+static ShadowedDeclKind computeShadowedDeclKind(const NamedDecl *ShadowedDecl,
+const DeclContext *OldDC) {
+  if (isa(OldDC))
+return isa(ShadowedDecl) ? SDK_Field : SDK_StaticMember;
+  return OldDC->isFileContext() ? SDK_Global : SDK_Local;
+}
+
 /// \brief Diagnose variable or built-in function shadowing.  Implements
 /// -Wshadow.
 ///
@@ -6410,12 +6431,23 @@
   if (!isa(ShadowedDecl) && !isa(ShadowedDecl))
 return;
 
-  // Fields are not shadowed by variables in C++ static methods.
-  if (isa(ShadowedDecl))
+  if (FieldDecl *FD = dyn_cast(ShadowedDecl)) {
+// Fields are not shadowed by variables in C++ static methods.
 if (CXXMethodDecl *MD = dyn_cast(NewDC))
   if (MD->isStatic())
 return;
 
+// Fields shadowed by constructor parameters are a special case. Usually
+// the constructor initializes the field with the parameter.
+if (isa(NewDC) && isa(D)) {
+  // Remember that this was shadowed so we can either warn about its
+  // modification or its existance depending on warning settings.
+  D = D->getCanonicalDecl();
+  ShadowingDecls.insert({D, FD});
+  return;
+}
+  }
+
   if 

[clang-tools-extra] r267576 - [Release notes] Mention Clang-tidy misc-fold-init-type check.

2016-04-26 Thread Eugene Zelenko via cfe-commits
Author: eugenezelenko
Date: Tue Apr 26 12:54:00 2016
New Revision: 267576

URL: http://llvm.org/viewvc/llvm-project?rev=267576=rev
Log:
[Release notes] Mention Clang-tidy misc-fold-init-type check.

Highlighting consistency in Clang-tidy misc-fold-init-type check documentation.

Modified:
clang-tools-extra/trunk/docs/ReleaseNotes.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/misc-fold-init-type.rst

Modified: clang-tools-extra/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/ReleaseNotes.rst?rev=267576=267575=267576=diff
==
--- clang-tools-extra/trunk/docs/ReleaseNotes.rst (original)
+++ clang-tools-extra/trunk/docs/ReleaseNotes.rst Tue Apr 26 12:54:00 2016
@@ -92,6 +92,12 @@ identified.  The improvements since the
   Detects dangling references in value handlers like
   ``std::experimental::string_view``.
 
+- New `misc-fold-init-type
+  `_ 
check
+
+  The check flags type mismatches in `folds` like ``std::accumulate`` that 
might
+  result in loss of precision.
+
 - New `misc-forward-declaration-namespace
   
`_
 check
 

Modified: clang-tools-extra/trunk/docs/clang-tidy/checks/misc-fold-init-type.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/misc-fold-init-type.rst?rev=267576=267575=267576=diff
==
--- clang-tools-extra/trunk/docs/clang-tidy/checks/misc-fold-init-type.rst 
(original)
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/misc-fold-init-type.rst Tue 
Apr 26 12:54:00 2016
@@ -5,13 +5,13 @@ misc-fold-init-type
 
 The check flags type mismatches in
 `folds `_
-like `std::accumulate` that might result in loss of precision.
-`std::accumulate` folds an input range into an initial value using the type of
-the latter, with `operator+` by default. This can cause loss of precision
+like ``std::accumulate`` that might result in loss of precision.
+``std::accumulate`` folds an input range into an initial value using the type 
of
+the latter, with ``operator+`` by default. This can cause loss of precision
 through:
 
 - Truncation: The following code uses a floating point range and an int
-  initial value, so trucation wil happen at every application of `operator+`
+  initial value, so trucation wil happen at every application of ``operator+``
   and the result will be `0`, which might not be what the user expected.
 
 .. code:: c++


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


[clang-tools-extra] r267574 - [clang-tidy] New checker for redundant expressions.

2016-04-26 Thread Etienne Bergeron via cfe-commits
Author: etienneb
Date: Tue Apr 26 12:30:30 2016
New Revision: 267574

URL: http://llvm.org/viewvc/llvm-project?rev=267574=rev
Log:
[clang-tidy] New checker for redundant expressions.

Summary:
This checker finds redundant expression on both side of a binary operator.

The current implementation provide a function to check whether expressions
are equivalent. This implementation is able to recognize the common
subset encounter in C++ program. Side-effects like "x++" are not considered
to be equivalent.

There are many False Positives related to macros and to floating point
computations (detecting NaN). The checker is ignoring these cases.

Example:
```
if( !dst || dst->depth != desired_depth ||
dst->nChannels != desired_num_channels ||
dst_size.width != src_size.width ||
dst_size.height != dst_size.height )<<--- bug
{
```

Reviewers: alexfh

Subscribers: danielmarjamaki, fahlgren, jordan_rose, zaks.anna, Eugene.Zelenko, 
cfe-commits

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

Added:
clang-tools-extra/trunk/clang-tidy/misc/RedundantExpressionCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/RedundantExpressionCheck.h
clang-tools-extra/trunk/docs/clang-tidy/checks/misc-redundant-expression.rst
clang-tools-extra/trunk/test/clang-tidy/misc-redundant-expression.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp
clang-tools-extra/trunk/docs/ReleaseNotes.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst

Modified: clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt?rev=267574=267573=267574=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt Tue Apr 26 12:30:30 
2016
@@ -23,6 +23,7 @@ add_clang_library(clangTidyMiscModule
   NoexceptMoveConstructorCheck.cpp
   NonCopyableObjects.cpp
   PointerAndIntegralOperationCheck.cpp
+  RedundantExpressionCheck.cpp
   SizeofContainerCheck.cpp
   SizeofExpressionCheck.cpp
   StaticAssertCheck.cpp

Modified: clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp?rev=267574=267573=267574=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp Tue Apr 26 
12:30:30 2016
@@ -31,6 +31,7 @@
 #include "NoexceptMoveConstructorCheck.h"
 #include "NonCopyableObjects.h"
 #include "PointerAndIntegralOperationCheck.h"
+#include "RedundantExpressionCheck.h"
 #include "SizeofContainerCheck.h"
 #include "SizeofExpressionCheck.h"
 #include "StaticAssertCheck.h"
@@ -98,6 +99,8 @@ public:
 "misc-non-copyable-objects");
 CheckFactories.registerCheck(
 "misc-pointer-and-integral-operation");
+CheckFactories.registerCheck(
+"misc-redundant-expression");
 
CheckFactories.registerCheck("misc-sizeof-container");
 CheckFactories.registerCheck(
 "misc-sizeof-expression");

Added: clang-tools-extra/trunk/clang-tidy/misc/RedundantExpressionCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/RedundantExpressionCheck.cpp?rev=267574=auto
==
--- clang-tools-extra/trunk/clang-tidy/misc/RedundantExpressionCheck.cpp (added)
+++ clang-tools-extra/trunk/clang-tidy/misc/RedundantExpressionCheck.cpp Tue 
Apr 26 12:30:30 2016
@@ -0,0 +1,133 @@
+//===--- RedundantExpressionCheck.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 "RedundantExpressionCheck.h"
+#include "../utils/Matchers.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace misc {
+
+static bool AreIdenticalExpr(const Expr *Left, const Expr *Right) {
+  if (!Left || !Right)
+return !Left && !Right;
+
+  Left = Left->IgnoreParens();
+  Right = Right->IgnoreParens();
+
+  // Compare classes.
+  if (Left->getStmtClass() != Right->getStmtClass())
+return false;
+
+  // Compare children.
+  Expr::const_child_iterator LeftIter = Left->child_begin();
+  Expr::const_child_iterator RightIter = Right->child_begin();
+  while (LeftIter != Left->child_end() && RightIter != Right->child_end()) {
+if 

Re: [PATCH] D19541: Fix generation of documentation for UndefinedBehaviorSanitizer.

2016-04-26 Thread Etienne Bergeron via cfe-commits
etienneb added a comment.

This got fixed.
Abandoning this change.


http://reviews.llvm.org/D19541



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


[PATCH] D19541: Fix generation of documentation for UndefinedBehaviorSanitizer.

2016-04-26 Thread Etienne Bergeron via cfe-commits
etienneb created this revision.
etienneb added a reviewer: alexfh.
etienneb added a subscriber: cfe-commits.

The text is mis-aligned.

http://reviews.llvm.org/D19541

Files:
  docs/UndefinedBehaviorSanitizer.rst

Index: docs/UndefinedBehaviorSanitizer.rst
===
--- docs/UndefinedBehaviorSanitizer.rst
+++ docs/UndefinedBehaviorSanitizer.rst
@@ -93,13 +93,13 @@
   -  ``-fsanitize=null``: Use of a null pointer or creation of a null
  reference.
   -  ``-fsanitize=object-size``: An attempt to potentially use bytes which
-the optimizer can determine are not part of the object being accessed.
-This will also detect some types of undefined behavior that may not
-directly access memory, but are provably incorrect given the size of
-the objects involved, such as invalid downcasts and calling methods on
-invalid pointers. These checks are made in terms of
-``__builtin_object_size``, and consequently may be able to detect more
-problems at higher optimization levels.
+ the optimizer can determine are not part of the object being accessed.
+ This will also detect some types of undefined behavior that may not
+ directly access memory, but are provably incorrect given the size of
+ the objects involved, such as invalid downcasts and calling methods on
+ invalid pointers. These checks are made in terms of
+ ``__builtin_object_size``, and consequently may be able to detect more
+ problems at higher optimization levels.
   -  ``-fsanitize=return``: In C++, reaching the end of a
  value-returning function without returning a value.
   -  ``-fsanitize=returns-nonnull-attribute``: Returning null pointer


Index: docs/UndefinedBehaviorSanitizer.rst
===
--- docs/UndefinedBehaviorSanitizer.rst
+++ docs/UndefinedBehaviorSanitizer.rst
@@ -93,13 +93,13 @@
   -  ``-fsanitize=null``: Use of a null pointer or creation of a null
  reference.
   -  ``-fsanitize=object-size``: An attempt to potentially use bytes which
-the optimizer can determine are not part of the object being accessed.
-This will also detect some types of undefined behavior that may not
-directly access memory, but are provably incorrect given the size of
-the objects involved, such as invalid downcasts and calling methods on
-invalid pointers. These checks are made in terms of
-``__builtin_object_size``, and consequently may be able to detect more
-problems at higher optimization levels.
+ the optimizer can determine are not part of the object being accessed.
+ This will also detect some types of undefined behavior that may not
+ directly access memory, but are provably incorrect given the size of
+ the objects involved, such as invalid downcasts and calling methods on
+ invalid pointers. These checks are made in terms of
+ ``__builtin_object_size``, and consequently may be able to detect more
+ problems at higher optimization levels.
   -  ``-fsanitize=return``: In C++, reaching the end of a
  value-returning function without returning a value.
   -  ``-fsanitize=returns-nonnull-attribute``: Returning null pointer
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D19539: Fix a crash in cppcoreguidelines-pro-type-member-init when checking a type with a template parameter as a base class.

2016-04-26 Thread Michael Miller via cfe-commits
michael_miller created this revision.
michael_miller added reviewers: hokein, aaron.ballman, alexfh.
michael_miller added a subscriber: cfe-commits.

Fixed a crash in cppcoreguidelines-pro-type-member-init when encountering a 
type that uses one of its template parameters as a base when compiling for 
C++98.

http://reviews.llvm.org/D19539

Files:
  clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
  test/clang-tidy/cppcoreguidelines-pro-type-member-init-cxx98.cpp

Index: test/clang-tidy/cppcoreguidelines-pro-type-member-init-cxx98.cpp
===
--- test/clang-tidy/cppcoreguidelines-pro-type-member-init-cxx98.cpp
+++ test/clang-tidy/cppcoreguidelines-pro-type-member-init-cxx98.cpp
@@ -70,26 +70,36 @@
   int Z;
 };
 
-struct NonTrivialType {
+struct TrivialType {
   int X;
   int Y;
 };
 
 struct PositiveUninitializedBaseOrdering : public NegativeAggregateType,
-   public NonTrivialType {
-  PositiveUninitializedBaseOrdering() : NegativeAggregateType(), 
NonTrivialType(), B() {}
+   public TrivialType {
+  PositiveUninitializedBaseOrdering() : NegativeAggregateType(), 
TrivialType(), B() {}
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor does not initialize 
these fields: A
-  // CHECK-FIXES: PositiveUninitializedBaseOrdering() : 
NegativeAggregateType(), NonTrivialType(), A(), B() {}
+  // CHECK-FIXES: PositiveUninitializedBaseOrdering() : 
NegativeAggregateType(), TrivialType(), A(), B() {}
 
   // This is somewhat pathological with the base class initializer at the 
end...
-  PositiveUninitializedBaseOrdering(int) : B(), NonTrivialType(), A() {}
+  PositiveUninitializedBaseOrdering(int) : B(), TrivialType(), A() {}
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor does not initialize 
these bases: NegativeAggregateType
-  // CHECK-FIXES: PositiveUninitializedBaseOrdering(int) : B(), 
NegativeAggregateType(), NonTrivialType(), A() {}
+  // CHECK-FIXES: PositiveUninitializedBaseOrdering(int) : B(), 
NegativeAggregateType(), TrivialType(), A() {}
 
   PositiveUninitializedBaseOrdering(float) : NegativeAggregateType(), A() {}
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor does not initialize 
these bases: NonTrivialType
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor does not initialize 
these bases: TrivialType
   // CHECK-MESSAGES: :[[@LINE-2]]:3: warning: constructor does not initialize 
these fields: B
-  // CHECK-FIXES: PositiveUninitializedBaseOrdering(float) : 
NegativeAggregateType(), NonTrivialType(), A(), B() {}
+  // CHECK-FIXES: PositiveUninitializedBaseOrdering(float) : 
NegativeAggregateType(), TrivialType(), A(), B() {}
 
   int A, B;
 };
+
+template 
+class PositiveTemplateBase : T {
+public:
+  PositiveTemplateBase() {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor does not initialize 
these fields: X
+  // CHECK-FIXES: PositiveTemplateBase() : X() {}
+
+  int X;
+};
Index: clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
===
--- clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
+++ clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
@@ -208,8 +208,12 @@
 void getInitializationsInOrder(const CXXRecordDecl *ClassDecl,
SmallVectorImpl ) {
   Decls.clear();
-  for (const auto  : ClassDecl->bases())
-Decls.emplace_back(getCanonicalRecordDecl(Base.getType()));
+  for (const auto  : ClassDecl->bases()) {
+// Decl may be null if the base class is a template parameter.
+if (const NamedDecl *Decl = getCanonicalRecordDecl(Base.getType())) {
+  Decls.emplace_back(Decl);
+}
+  }
   Decls.append(ClassDecl->fields().begin(), ClassDecl->fields().end());
 }
 


Index: test/clang-tidy/cppcoreguidelines-pro-type-member-init-cxx98.cpp
===
--- test/clang-tidy/cppcoreguidelines-pro-type-member-init-cxx98.cpp
+++ test/clang-tidy/cppcoreguidelines-pro-type-member-init-cxx98.cpp
@@ -70,26 +70,36 @@
   int Z;
 };
 
-struct NonTrivialType {
+struct TrivialType {
   int X;
   int Y;
 };
 
 struct PositiveUninitializedBaseOrdering : public NegativeAggregateType,
-   public NonTrivialType {
-  PositiveUninitializedBaseOrdering() : NegativeAggregateType(), NonTrivialType(), B() {}
+   public TrivialType {
+  PositiveUninitializedBaseOrdering() : NegativeAggregateType(), TrivialType(), B() {}
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor does not initialize these fields: A
-  // CHECK-FIXES: PositiveUninitializedBaseOrdering() : NegativeAggregateType(), NonTrivialType(), A(), B() {}
+  // CHECK-FIXES: PositiveUninitializedBaseOrdering() : NegativeAggregateType(), TrivialType(), A(), B() {}
 
   // This is somewhat pathological with the base 

Re: [PATCH] D19451: [clang-tidy] New checker for redundant expressions.

2016-04-26 Thread Etienne Bergeron via cfe-commits
etienneb added inline comments.


Comment at: clang-tidy/misc/RedundantExpressionCheck.cpp:21
@@ +20,3 @@
+
+static bool AreIdenticalExpr(const Expr *Left, const Expr *Right) {
+  if (!Left || !Right)

alexfh wrote:
> This is to some degree similar to comparing `llvm::FoldingSetNodeIDs` created 
> using `Stmt::Profile`. However it's only useful to check for identical 
> expressions and won't work, if you're going to extend this to equivalent 
> expressions.
Exact. There is plan to extend the notion of "equivalent".
I think we should lift this to "utils", and maybe we can also provide a 
"isIdenticalExpression" based on FoldingSet.


http://reviews.llvm.org/D19451



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


[clang-tools-extra] r267570 - [clang-tidy] Enhance misc-suspicious-string-compare to move down false-positives.

2016-04-26 Thread Etienne Bergeron via cfe-commits
Author: etienneb
Date: Tue Apr 26 11:53:21 2016
New Revision: 267570

URL: http://llvm.org/viewvc/llvm-project?rev=267570=rev
Log:
[clang-tidy] Enhance misc-suspicious-string-compare to move down 
false-positives.

Summary:
The checker was noisy when running over llvm code base.
This patch is impriving the way string-compare functions are matched.

1) By default, do not report !strcmp(...) unless it's activate by the user,
2) Only match suspicious expression over a subset of expression (binary 
operator),
3) Added matching of macro wrapper used with clang on linux.

See bug: 27465.

Reviewers: alexfh

Subscribers: cfe-commits

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

Modified:
clang-tools-extra/trunk/clang-tidy/misc/SuspiciousStringCompareCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/misc-suspicious-string-compare.c
clang-tools-extra/trunk/test/clang-tidy/misc-suspicious-string-compare.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/misc/SuspiciousStringCompareCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/SuspiciousStringCompareCheck.cpp?rev=267570=267569=267570=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/SuspiciousStringCompareCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/misc/SuspiciousStringCompareCheck.cpp 
Tue Apr 26 11:53:21 2016
@@ -11,6 +11,7 @@
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/Lex/Lexer.h"
+#include "../utils/Matchers.h"
 
 using namespace clang::ast_matchers;
 
@@ -18,10 +19,6 @@ namespace clang {
 namespace tidy {
 namespace misc {
 
-AST_MATCHER(BinaryOperator, isComparisonOperator) {
-  return Node.isComparisonOp();
-}
-
 static const char KnownStringCompareFunctions[] = "__builtin_memcmp;"
   "__builtin_strcasecmp;"
   "__builtin_strcmp;"
@@ -84,7 +81,7 @@ SuspiciousStringCompareCheck::Suspicious
 StringRef Name, ClangTidyContext *Context)
 : ClangTidyCheck(Name, Context),
   WarnOnImplicitComparison(Options.get("WarnOnImplicitComparison", 1)),
-  WarnOnLogicalNotComparison(Options.get("WarnOnLogicalNotComparison", 1)),
+  WarnOnLogicalNotComparison(Options.get("WarnOnLogicalNotComparison", 0)),
   StringCompareLikeFunctions(
   Options.get("StringCompareLikeFunctions", "")) {}
 
@@ -98,7 +95,8 @@ void SuspiciousStringCompareCheck::store
 void SuspiciousStringCompareCheck::registerMatchers(MatchFinder *Finder) {
   // Match relational operators.
   const auto ComparisonUnaryOperator = unaryOperator(hasOperatorName("!"));
-  const auto ComparisonBinaryOperator = binaryOperator(isComparisonOperator());
+  const auto ComparisonBinaryOperator =
+  binaryOperator(matchers::isComparisonOperator());
   const auto ComparisonOperator =
   expr(anyOf(ComparisonUnaryOperator, ComparisonBinaryOperator));
 
@@ -107,48 +105,35 @@ void SuspiciousStringCompareCheck::regis
   std::vector FunctionNames;
   ParseFunctionNames(KnownStringCompareFunctions, );
   ParseFunctionNames(StringCompareLikeFunctions, );
+
+  // Match a call to a string compare functions.
   const auto FunctionCompareDecl =
   functionDecl(hasAnyName(std::vector(FunctionNames.begin(),
  FunctionNames.end(
   .bind("decl");
-
-  // Match a call to a string compare functions.
-  const auto StringCompareCallExpr =
+  const auto DirectStringCompareCallExpr =
   callExpr(hasDeclaration(FunctionCompareDecl)).bind("call");
+  const auto MacroStringCompareCallExpr =
+  conditionalOperator(
+
anyOf(hasTrueExpression(ignoringParenImpCasts(DirectStringCompareCallExpr)),
+  
hasFalseExpression(ignoringParenImpCasts(DirectStringCompareCallExpr;
+  // The implicit cast is not present in C.
+  const auto StringCompareCallExpr = ignoringParenImpCasts(
+anyOf(DirectStringCompareCallExpr, MacroStringCompareCallExpr));
 
   if (WarnOnImplicitComparison) {
-// Detect suspicious calls to string compare (missing comparator) [only C]:
+// Detect suspicious calls to string compare:
 // 'if (strcmp())'  ->  'if (strcmp() != 0)'
 Finder->addMatcher(
 stmt(anyOf(ifStmt(hasCondition(StringCompareCallExpr)),
whileStmt(hasCondition(StringCompareCallExpr)),
doStmt(hasCondition(StringCompareCallExpr)),
-   forStmt(hasCondition(StringCompareCallExpr
+   forStmt(hasCondition(StringCompareCallExpr)),
+   binaryOperator(
+   anyOf(hasOperatorName("&&"), hasOperatorName("||")),
+   hasEitherOperand(StringCompareCallExpr
 .bind("missing-comparison"),
 this);
-
-Finder->addMatcher(expr(StringCompareCallExpr,
- 

Re: [PATCH] D19497: [clang-tidy] Enhance misc-suspicious-string-compare to move down false-positives.

2016-04-26 Thread Etienne Bergeron via cfe-commits
etienneb updated this revision to Diff 55025.
etienneb marked an inline comment as done.
etienneb added a comment.

address alexfh comments.


http://reviews.llvm.org/D19497

Files:
  clang-tidy/misc/SuspiciousStringCompareCheck.cpp
  test/clang-tidy/misc-suspicious-string-compare.c
  test/clang-tidy/misc-suspicious-string-compare.cpp

Index: test/clang-tidy/misc-suspicious-string-compare.cpp
===
--- test/clang-tidy/misc-suspicious-string-compare.cpp
+++ test/clang-tidy/misc-suspicious-string-compare.cpp
@@ -15,6 +15,8 @@
 static const unsigned char V[] = "xyz";
 static const wchar_t W[] = L"abc";
 
+int strlen(const char *);
+
 int memcmp(const void *, const void *, size);
 int wmemcmp(const wchar_t *, const wchar_t *, size);
 int memicmp(const void *, const void *, size);
@@ -297,3 +299,39 @@
 
   return 1;
 }
+
+int strcmp_wrapper1(const char* a, const char* b) {
+  return strcmp(a, b);
+}
+
+int strcmp_wrapper2(const char* a, const char* b) {
+  return (a && b) ? strcmp(a, b) : 0;
+}
+
+#define macro_strncmp(s1, s2, n)  \
+  (__extension__ (__builtin_constant_p (n)\
+  && ((__builtin_constant_p (s1)  \
+   && strlen (s1) < ((size) (n))) \
+  || (__builtin_constant_p (s2)   \
+  && strlen (s2) < ((size) (n \
+  ? strcmp (s1, s2) : strncmp (s1, s2, n)))
+
+int strncmp_macro(const char* a, const char* b) {
+  if (macro_strncmp(a, b, 4))
+return 0;
+  // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'strcmp' is called without explicitly comparing result
+
+  if (macro_strncmp(a, b, 4) == 2)
+return 0;
+  // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'strcmp' is compared to a suspicious constant
+
+  if (macro_strncmp(a, b, 4) <= .0)
+return 0;
+  // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'strcmp' has suspicious implicit cast
+
+  if (macro_strncmp(a, b, 4) + 0)
+return 0;
+  // CHECK-MESSAGES: [[@LINE-2]]:7: warning: results of function 'strcmp' used by operator '+'
+
+  return 1;
+}
Index: test/clang-tidy/misc-suspicious-string-compare.c
===
--- test/clang-tidy/misc-suspicious-string-compare.c
+++ test/clang-tidy/misc-suspicious-string-compare.c
@@ -64,3 +64,16 @@
   if (strcmp(A, "a") == strcmp(A, "b")) return 0;
   return 1;
 }
+
+int wrapper(const char* a, const char* b) {
+  return strcmp(a, b);
+}
+
+int assignment_wrapper(const char* a, const char* b) {
+  int cmp = strcmp(a, b);
+  return cmp;
+}
+
+int condexpr_wrapper(const char* a, const char* b) {
+  return (a < b) ? strcmp(a, b) : strcmp(b, a);
+}
Index: clang-tidy/misc/SuspiciousStringCompareCheck.cpp
===
--- clang-tidy/misc/SuspiciousStringCompareCheck.cpp
+++ clang-tidy/misc/SuspiciousStringCompareCheck.cpp
@@ -11,17 +11,14 @@
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/Lex/Lexer.h"
+#include "../utils/Matchers.h"
 
 using namespace clang::ast_matchers;
 
 namespace clang {
 namespace tidy {
 namespace misc {
 
-AST_MATCHER(BinaryOperator, isComparisonOperator) {
-  return Node.isComparisonOp();
-}
-
 static const char KnownStringCompareFunctions[] = "__builtin_memcmp;"
   "__builtin_strcasecmp;"
   "__builtin_strcmp;"
@@ -84,7 +81,7 @@
 StringRef Name, ClangTidyContext *Context)
 : ClangTidyCheck(Name, Context),
   WarnOnImplicitComparison(Options.get("WarnOnImplicitComparison", 1)),
-  WarnOnLogicalNotComparison(Options.get("WarnOnLogicalNotComparison", 1)),
+  WarnOnLogicalNotComparison(Options.get("WarnOnLogicalNotComparison", 0)),
   StringCompareLikeFunctions(
   Options.get("StringCompareLikeFunctions", "")) {}
 
@@ -98,57 +95,45 @@
 void SuspiciousStringCompareCheck::registerMatchers(MatchFinder *Finder) {
   // Match relational operators.
   const auto ComparisonUnaryOperator = unaryOperator(hasOperatorName("!"));
-  const auto ComparisonBinaryOperator = binaryOperator(isComparisonOperator());
+  const auto ComparisonBinaryOperator =
+  binaryOperator(matchers::isComparisonOperator());
   const auto ComparisonOperator =
   expr(anyOf(ComparisonUnaryOperator, ComparisonBinaryOperator));
 
   // Add the list of known string compare-like functions and add user-defined
   // functions.
   std::vector FunctionNames;
   ParseFunctionNames(KnownStringCompareFunctions, );
   ParseFunctionNames(StringCompareLikeFunctions, );
+
+  // Match a call to a string compare functions.
   const auto FunctionCompareDecl =
   

Re: [PATCH] D19324: [ASTMatchers] new forEachOverriden matcher

2016-04-26 Thread Samuel Benzaquen via cfe-commits
sbenza added inline comments.


Comment at: include/clang/AST/DeclCXX.h:1830
@@ -1829,2 +1829,3 @@
   unsigned size_overridden_methods() const;
+  const ArrayRef overridden_methods() const;
 

Return type should have have toplevel `const`.


Comment at: lib/AST/ASTContext.cpp:1262
@@ -1261,2 +1261,3 @@
 ASTContext::overridden_methods_begin(const CXXMethodDecl *Method) const {
   llvm::DenseMap::const_iterator Pos
+  = OverriddenMethods.find(Method->getCanonicalDecl());

I would invert the calls here.
That is, make overridden_methods_begin/_end call overridden_methods() instead, 
and have overridden_methods() be the one that does the lookup.
This way we have a single place where the lookup happens. It would also make 
overridden_methods() faster.


http://reviews.llvm.org/D19324



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


[PATCH] D19536: [CodeGenObjCXX] Fix handling of blocks in lambda

2016-04-26 Thread Akira Hatanaka via cfe-commits
ahatanak created this revision.
ahatanak added a reviewer: rjmccall.
ahatanak added a subscriber: cfe-commits.

This fixes a crash that occurs when a block nested in a c++ lambda captures a 
reference that is captured by the enclosing lambda.

rdar://problem/18586651

http://reviews.llvm.org/D19536

Files:
  lib/CodeGen/CGBlocks.cpp
  test/CodeGenObjCXX/block-nested-in-lambda.cpp

Index: test/CodeGenObjCXX/block-nested-in-lambda.cpp
===
--- /dev/null
+++ test/CodeGenObjCXX/block-nested-in-lambda.cpp
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -triple=x86_64-apple-darwin10 -emit-llvm -std=c++11 
-fblocks -o - %s | FileCheck %s
+
+// CHECK: %[[BLOCK_CAPTURED0:.*]] = getelementptr inbounds <{ i8*, i32, i32, 
i8*, %struct.__block_descriptor*, i32*, i32* }>, <{ i8*, i32, i32, i8*, 
%struct.__block_descriptor*, i32*, i32* }>* %[[BLOCK:.*]], i32 0, i32 5
+// CHECK: %[[V0:.*]] = getelementptr inbounds %[[LAMBDA_CLASS:.*]], 
%[[LAMBDA_CLASS]]* %[[THIS:.*]], i32 0, i32 0
+// CHECK: %[[V1:.*]] = load i32*, i32** %[[V0]], align 8
+// CHECK: store i32* %[[V1]], i32** %[[BLOCK_CAPTURED0]], align 8
+// CHECK: %[[BLOCK_CAPTURED1:.*]] = getelementptr inbounds <{ i8*, i32, i32, 
i8*, %struct.__block_descriptor*, i32*, i32* }>, <{ i8*, i32, i32, i8*, 
%struct.__block_descriptor*, i32*, i32* }>* %[[BLOCK]], i32 0, i32 6
+// CHECK: %[[V2:.*]] = getelementptr inbounds %[[LAMBDA_CLASS]], 
%[[LAMBDA_CLASS]]* %[[THIS]], i32 0, i32 1
+// CHECK: %[[V3:.*]] = load i32*, i32** %[[V2]], align 8
+// CHECK: store i32* %[[V3]], i32** %[[BLOCK_CAPTURED1]], align 8
+
+void foo1(int &, int &);
+
+void block_in_lambda(int , int ) {
+  auto lambda = [, ]() {
+auto block = ^{
+  foo1(s1, s2);
+};
+block();
+  };
+
+  lambda();
+}
Index: lib/CodeGen/CGBlocks.cpp
===
--- lib/CodeGen/CGBlocks.cpp
+++ lib/CodeGen/CGBlocks.cpp
@@ -14,6 +14,7 @@
 #include "CGBlocks.h"
 #include "CGDebugInfo.h"
 #include "CGObjCRuntime.h"
+#include "CGRecordLayout.h"
 #include "CodeGenFunction.h"
 #include "CodeGenModule.h"
 #include "clang/AST/DeclObjC.h"
@@ -789,6 +790,20 @@
   // The lambda capture in a lambda's conversion-to-block-pointer is
   // special; we'll simply emit it directly.
   src = Address::invalid();
+} else if (FieldDecl *FD = LambdaCaptureFields.lookup(variable)) {
+  const RecordDecl *Rec = FD->getParent();
+  QualType TagType = getContext().getTagDeclType(Rec);
+  LValue LV = MakeNaturalAlignAddrLValue(CXXABIThisValue, TagType);
+  Address Addr = LV.getAddress();
+  unsigned Idx =
+  CGM.getTypes().getCGRecordLayout(Rec).getLLVMFieldNo(FD);
+  CharUnits Offset;
+  if (Idx != 0) {
+auto  = getContext().getASTRecordLayout(Rec);
+auto OffsetInBits = RecLayout.getFieldOffset(FD->getFieldIndex());
+Offset = getContext().toCharUnitsFromBits(OffsetInBits);
+  }
+  src = Builder.CreateStructGEP(Addr, Idx, Offset, FD->getName());
 } else {
   // Just look it up in the locals map, which will give us back a
   // [[type]]*.  If that doesn't work, do the more elaborate DRE


Index: test/CodeGenObjCXX/block-nested-in-lambda.cpp
===
--- /dev/null
+++ test/CodeGenObjCXX/block-nested-in-lambda.cpp
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -triple=x86_64-apple-darwin10 -emit-llvm -std=c++11 -fblocks -o - %s | FileCheck %s
+
+// CHECK: %[[BLOCK_CAPTURED0:.*]] = getelementptr inbounds <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, i32*, i32* }>, <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, i32*, i32* }>* %[[BLOCK:.*]], i32 0, i32 5
+// CHECK: %[[V0:.*]] = getelementptr inbounds %[[LAMBDA_CLASS:.*]], %[[LAMBDA_CLASS]]* %[[THIS:.*]], i32 0, i32 0
+// CHECK: %[[V1:.*]] = load i32*, i32** %[[V0]], align 8
+// CHECK: store i32* %[[V1]], i32** %[[BLOCK_CAPTURED0]], align 8
+// CHECK: %[[BLOCK_CAPTURED1:.*]] = getelementptr inbounds <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, i32*, i32* }>, <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, i32*, i32* }>* %[[BLOCK]], i32 0, i32 6
+// CHECK: %[[V2:.*]] = getelementptr inbounds %[[LAMBDA_CLASS]], %[[LAMBDA_CLASS]]* %[[THIS]], i32 0, i32 1
+// CHECK: %[[V3:.*]] = load i32*, i32** %[[V2]], align 8
+// CHECK: store i32* %[[V3]], i32** %[[BLOCK_CAPTURED1]], align 8
+
+void foo1(int &, int &);
+
+void block_in_lambda(int , int ) {
+  auto lambda = [, ]() {
+auto block = ^{
+  foo1(s1, s2);
+};
+block();
+  };
+
+  lambda();
+}
Index: lib/CodeGen/CGBlocks.cpp
===
--- lib/CodeGen/CGBlocks.cpp
+++ lib/CodeGen/CGBlocks.cpp
@@ -14,6 +14,7 @@
 #include "CGBlocks.h"
 #include "CGDebugInfo.h"
 #include "CGObjCRuntime.h"
+#include "CGRecordLayout.h"
 #include "CodeGenFunction.h"
 #include "CodeGenModule.h"
 #include "clang/AST/DeclObjC.h"
@@ -789,6 

[libcxx] r267567 - #include in all the regex tests, and remove all mentions of __cpluplus (use TEST_STD_VERS and/or XFAIL instead). No functional change

2016-04-26 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Tue Apr 26 11:24:44 2016
New Revision: 267567

URL: http://llvm.org/viewvc/llvm-project?rev=267567=rev
Log:
#include  in all the regex tests, and remove all mentions of 
__cpluplus (use TEST_STD_VERS and/or XFAIL instead). No functional change

Modified:
libcxx/trunk/test/std/re/re.alg/re.alg.match/awk.pass.cpp
libcxx/trunk/test/std/re/re.alg/re.alg.match/basic.fail.cpp
libcxx/trunk/test/std/re/re.alg/re.alg.match/basic.pass.cpp
libcxx/trunk/test/std/re/re.alg/re.alg.match/ecma.pass.cpp
libcxx/trunk/test/std/re/re.alg/re.alg.match/egrep.pass.cpp
libcxx/trunk/test/std/re/re.alg/re.alg.match/extended.pass.cpp
libcxx/trunk/test/std/re/re.alg/re.alg.match/grep.pass.cpp
libcxx/trunk/test/std/re/re.alg/re.alg.match/lookahead_capture.pass.cpp
libcxx/trunk/test/std/re/re.alg/re.alg.match/parse_curly_brackets.pass.cpp
libcxx/trunk/test/std/re/re.alg/re.alg.replace/test1.pass.cpp
libcxx/trunk/test/std/re/re.alg/re.alg.replace/test2.pass.cpp
libcxx/trunk/test/std/re/re.alg/re.alg.replace/test3.pass.cpp
libcxx/trunk/test/std/re/re.alg/re.alg.replace/test4.pass.cpp
libcxx/trunk/test/std/re/re.alg/re.alg.replace/test5.pass.cpp
libcxx/trunk/test/std/re/re.alg/re.alg.replace/test6.pass.cpp
libcxx/trunk/test/std/re/re.alg/re.alg.search/awk.pass.cpp
libcxx/trunk/test/std/re/re.alg/re.alg.search/backup.pass.cpp
libcxx/trunk/test/std/re/re.alg/re.alg.search/basic.fail.cpp
libcxx/trunk/test/std/re/re.alg/re.alg.search/basic.pass.cpp
libcxx/trunk/test/std/re/re.alg/re.alg.search/ecma.pass.cpp
libcxx/trunk/test/std/re/re.alg/re.alg.search/egrep.pass.cpp
libcxx/trunk/test/std/re/re.alg/re.alg.search/extended.pass.cpp
libcxx/trunk/test/std/re/re.alg/re.alg.search/lookahead.pass.cpp
libcxx/trunk/test/std/re/re.alg/re.alg.search/no_update_pos.pass.cpp
libcxx/trunk/test/std/re/re.badexp/regex_error.pass.cpp
libcxx/trunk/test/std/re/re.const/re.err/error_type.pass.cpp
libcxx/trunk/test/std/re/re.const/re.matchflag/match_flag_type.pass.cpp
libcxx/trunk/test/std/re/re.const/re.matchflag/match_not_bol.pass.cpp
libcxx/trunk/test/std/re/re.const/re.matchflag/match_not_eol.pass.cpp
libcxx/trunk/test/std/re/re.const/re.synopt/syntax_option_type.pass.cpp
libcxx/trunk/test/std/re/re.iter/re.regiter/re.regiter.cnstr/cnstr.fail.cpp
libcxx/trunk/test/std/re/re.iter/re.regiter/re.regiter.cnstr/cnstr.pass.cpp

libcxx/trunk/test/std/re/re.iter/re.regiter/re.regiter.cnstr/default.pass.cpp
libcxx/trunk/test/std/re/re.iter/re.regiter/re.regiter.deref/deref.pass.cpp
libcxx/trunk/test/std/re/re.iter/re.regiter/re.regiter.incr/post.pass.cpp
libcxx/trunk/test/std/re/re.iter/re.regiter/types.pass.cpp
libcxx/trunk/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/array.fail.cpp
libcxx/trunk/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/array.pass.cpp

libcxx/trunk/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/default.pass.cpp
libcxx/trunk/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/init.fail.cpp
libcxx/trunk/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/init.pass.cpp
libcxx/trunk/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/int.fail.cpp
libcxx/trunk/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/int.pass.cpp
libcxx/trunk/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/vector.fail.cpp
libcxx/trunk/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/vector.pass.cpp
libcxx/trunk/test/std/re/re.iter/re.tokiter/re.tokiter.comp/equal.pass.cpp
libcxx/trunk/test/std/re/re.iter/re.tokiter/re.tokiter.deref/deref.pass.cpp
libcxx/trunk/test/std/re/re.iter/re.tokiter/re.tokiter.incr/post.pass.cpp
libcxx/trunk/test/std/re/re.iter/re.tokiter/types.pass.cpp
libcxx/trunk/test/std/re/re.regex/re.regex.assign/assign.il.pass.cpp
libcxx/trunk/test/std/re/re.regex/re.regex.assign/assign.pass.cpp

libcxx/trunk/test/std/re/re.regex/re.regex.assign/assign_iter_iter_flag.pass.cpp
libcxx/trunk/test/std/re/re.regex/re.regex.assign/assign_ptr_flag.pass.cpp

libcxx/trunk/test/std/re/re.regex/re.regex.assign/assign_ptr_size_flag.pass.cpp

libcxx/trunk/test/std/re/re.regex/re.regex.assign/assign_string_flag.pass.cpp
libcxx/trunk/test/std/re/re.regex/re.regex.assign/copy.pass.cpp
libcxx/trunk/test/std/re/re.regex/re.regex.assign/il.pass.cpp
libcxx/trunk/test/std/re/re.regex/re.regex.assign/ptr.pass.cpp
libcxx/trunk/test/std/re/re.regex/re.regex.assign/string.pass.cpp
libcxx/trunk/test/std/re/re.regex/re.regex.const/constants.pass.cpp
libcxx/trunk/test/std/re/re.regex/re.regex.construct/awk_oct.pass.cpp
libcxx/trunk/test/std/re/re.regex/re.regex.construct/bad_escape.pass.cpp
libcxx/trunk/test/std/re/re.regex/re.regex.construct/bad_repeat.pass.cpp
libcxx/trunk/test/std/re/re.regex/re.regex.construct/copy.pass.cpp
libcxx/trunk/test/std/re/re.regex/re.regex.construct/default.pass.cpp

Re: [PATCH] D18957: clang-rename: add missing newline at the end of 'found name:'

2016-04-26 Thread Miklos Vajna via cfe-commits
vmiklos added a comment.

Thanks! Is there anything I have to do to get this actually committed or I just 
have to be patient?


http://reviews.llvm.org/D18957



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


Re: [PATCH] D19071: [OpenCL] Add predefined macros.

2016-04-26 Thread Anastasia Stulova via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.
This revision is now accepted and ready to land.

LGTM! Thanks!


http://reviews.llvm.org/D19071



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


Re: [PATCH] D18265: [clang-tidy] New: checker misc-unconventional-assign-operator replacing misc-assign-operator-signature

2016-04-26 Thread Samuel Benzaquen via cfe-commits
sbenza added inline comments.


Comment at: clang-tidy/misc/UnconventionalAssignOperatorCheck.cpp:69
@@ +68,3 @@
+void UnconventionalAssignOperatorCheck::check(const MatchFinder::MatchResult 
) {
+  if (const auto *RetStmt = Result.Nodes.getNodeAs("returnStmt")) {
+diag(RetStmt->getLocStart(), "operator=() should always return '*this'");

couldn't this be folded into the Messages array below?


http://reviews.llvm.org/D18265



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


Re: [PATCH] D18963: PR27216: Only define __ARM_FEATURE_FMA when the target has VFPv4

2016-04-26 Thread silviu.bara...@arm.com via cfe-commits
sbaranga added inline comments.


Comment at: test/Sema/arm_vfma.c:1
@@ -1,2 +1,2 @@
-// RUN: %clang_cc1 -triple thumbv7s-apple-ios7.0 -target-feature +neon 
-fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple thumbv7-none-eabi -target-feature +neon 
-target-feature +vfp4 -fsyntax-only -verify %s
 #include 

I updated this test, but used thumbv7-none-eabi here, since VFPv4 requires at 
least v7.


http://reviews.llvm.org/D18963



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


Re: [PATCH] D18963: PR27216: Only define __ARM_FEATURE_FMA when the target has VFPv4

2016-04-26 Thread silviu.bara...@arm.com via cfe-commits
sbaranga updated this revision to Diff 55018.
sbaranga added a comment.

Address the latest review comments (which means rolling back to the last 
change).


http://reviews.llvm.org/D18963

Files:
  lib/Basic/Targets.cpp
  test/CodeGen/arm-neon-fma.c
  test/Preprocessor/arm-acle-6.5.c
  test/Sema/arm_vfma.c

Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -4931,7 +4931,7 @@
 Builder.defineMacro("__ARM_FP16_ARGS", "1");
 
 // ACLE 6.5.3 Fused multiply-accumulate (FMA)
-if (ArchVersion >= 7 && (CPUProfile != "M" || CPUAttr == "7EM"))
+if (ArchVersion >= 7 && (FPU & VFP4FPU))
   Builder.defineMacro("__ARM_FEATURE_FMA", "1");
 
 // Subtarget options.
Index: test/CodeGen/arm-neon-fma.c
===
--- test/CodeGen/arm-neon-fma.c
+++ test/CodeGen/arm-neon-fma.c
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -triple thumbv7-none-linux-gnueabihf \
 // RUN:   -target-abi aapcs \
-// RUN:   -target-cpu cortex-a8 \
+// RUN:   -target-cpu cortex-a7 \
 // RUN:   -mfloat-abi hard \
 // RUN:   -ffreestanding \
 // RUN:   -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s
Index: test/Preprocessor/arm-acle-6.5.c
===
--- test/Preprocessor/arm-acle-6.5.c
+++ test/Preprocessor/arm-acle-6.5.c
@@ -49,10 +49,13 @@
 
 // CHECK-NO-FMA-NOT: __ARM_FEATURE_FMA
 
-// RUN: %clang -target armv7a-eabi -x c -E -dM %s -o - | FileCheck %s 
-check-prefix CHECK-FMA
-// RUN: %clang -target armv7r-eabi -x c -E -dM %s -o - | FileCheck %s 
-check-prefix CHECK-FMA
+// RUN: %clang -target armv7a-eabi -x c -E -dM %s -o - | FileCheck %s 
-check-prefix CHECK-NO-FMA
+// RUN: %clang -target armv7a-eabi -mfpu=vfpv4 -x c -E -dM %s -o - | FileCheck 
%s -check-prefix CHECK-FMA
+// RUN: %clang -target armv7r-eabi -x c -E -dM %s -o - | FileCheck %s 
-check-prefix CHECK-NO-FMA
+// RUN: %clang -target armv7r-eabi -mfpu=vfpv4 -x c -E -dM %s -o - | FileCheck 
%s -check-prefix CHECK-FMA
 // RUN: %clang -target armv7em-eabi -x c -E -dM %s -o - | FileCheck %s 
-check-prefix CHECK-FMA
-// RUN: %clang -target armv8-eabi -x c -E -dM %s -o - | FileCheck %s 
-check-prefix CHECK-FMA
+// RUN: %clang -target armv8-eabi -x c -E -dM %s -o - | FileCheck %s 
-check-prefix CHECK-NO-FMA
+// RUN: %clang -target armv8-eabi -mfpu=vfpv4 -x c -E -dM %s -o - | FileCheck 
%s -check-prefix CHECK-FMA
 
 // CHECK-FMA: __ARM_FEATURE_FMA 1
 
Index: test/Sema/arm_vfma.c
===
--- test/Sema/arm_vfma.c
+++ test/Sema/arm_vfma.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple thumbv7s-apple-ios7.0 -target-feature +neon 
-fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple thumbv7-none-eabi -target-feature +neon 
-target-feature +vfp4 -fsyntax-only -verify %s
 #include 
 
 // expected-no-diagnostics


Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -4931,7 +4931,7 @@
 Builder.defineMacro("__ARM_FP16_ARGS", "1");
 
 // ACLE 6.5.3 Fused multiply-accumulate (FMA)
-if (ArchVersion >= 7 && (CPUProfile != "M" || CPUAttr == "7EM"))
+if (ArchVersion >= 7 && (FPU & VFP4FPU))
   Builder.defineMacro("__ARM_FEATURE_FMA", "1");
 
 // Subtarget options.
Index: test/CodeGen/arm-neon-fma.c
===
--- test/CodeGen/arm-neon-fma.c
+++ test/CodeGen/arm-neon-fma.c
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -triple thumbv7-none-linux-gnueabihf \
 // RUN:   -target-abi aapcs \
-// RUN:   -target-cpu cortex-a8 \
+// RUN:   -target-cpu cortex-a7 \
 // RUN:   -mfloat-abi hard \
 // RUN:   -ffreestanding \
 // RUN:   -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s
Index: test/Preprocessor/arm-acle-6.5.c
===
--- test/Preprocessor/arm-acle-6.5.c
+++ test/Preprocessor/arm-acle-6.5.c
@@ -49,10 +49,13 @@
 
 // CHECK-NO-FMA-NOT: __ARM_FEATURE_FMA
 
-// RUN: %clang -target armv7a-eabi -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-FMA
-// RUN: %clang -target armv7r-eabi -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-FMA
+// RUN: %clang -target armv7a-eabi -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-NO-FMA
+// RUN: %clang -target armv7a-eabi -mfpu=vfpv4 -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-FMA
+// RUN: %clang -target armv7r-eabi -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-NO-FMA
+// RUN: %clang -target armv7r-eabi -mfpu=vfpv4 -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-FMA
 // RUN: %clang -target armv7em-eabi -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-FMA
-// RUN: %clang -target armv8-eabi -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-FMA
+// RUN: %clang -target armv8-eabi -x c -E -dM %s -o - | FileCheck %s 

Re: [PATCH] D18953: [ms][dll] #26935 Defining a dllimport function should cause it to be exported

2016-04-26 Thread David Majnemer via cfe-commits
majnemer added a subscriber: majnemer.


Comment at: test/SemaCXX/dllimport.cpp:179
@@ -140,1 +178,3 @@
+template 
+int ExternVarTmplDeclInit = 1;
 

avt77 wrote:
> rnk wrote:
> > Can you check with MSVC 2015 update 2 actually does with definitions of 
> > dllimport variable templates? I bet it doesn't export them.
> They don't support variable templates at all:
> 
> error C2399: variable templates are not supported in this release
Your compiler is too old, they are definitely supported.

> Previously a template declaration was only allowed to be a function, class, 
> or alias. Now, in the MSVC compiler it can be a variable as well.

https://blogs.msdn.microsoft.com/vcblog/2016/02/11/compiler-improvements-in-vs-2015-update-2/


http://reviews.llvm.org/D18953



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


Re: [PATCH] D19451: [clang-tidy] New checker for redundant expressions.

2016-04-26 Thread Etienne Bergeron via cfe-commits
etienneb added a comment.

In http://reviews.llvm.org/D19451#412017, @alexfh wrote:

> In http://reviews.llvm.org/D19451#411990, @alexfh wrote:
>
> > BTW, have you seen the `alpha.core.IdenticalExpr` static analyzer checker?
>
>
> Anna, Jordan, and whoever else is interested in the 
> `alpha.core.IdenticalExpr` checker 
> (lib/StaticAnalyzer/Checkers/IdenticalExprChecker.cpp), it looks like Etienne 
> has reinvented a large part of this checker as a clang-tidy check. I'm not 
> sure which of these supports more cases and has more false positives (given 
> that the `alpha.core.IdenticalExpr` checker was there for quite a while, but 
> IIUC, this clang-tidy check has been tested on a huge code base with pretty 
> good results).
>
> BTW, have you seen the alpha.core.IdenticalExpr static analyzer checker?


Yes, I looked at it. The AreEquivalentExpression is pretty much a variant of 
that code (a simplification).

> A few questions to all of you:

> 

> 1. is the `alpha.core.IdenticalExpr` checker going to be released in the near 
> future?

> 2. is anyone actively working on it?

> 3. given that Etienne seems to be planning to continue actively working on 
> the clang-tidy analog of that static analyzer checker, are you fine to move 
> all of this checker's (`alpha.core.IdenticalExpr`) functionality to 
> clang-tidy?

> 4. more generally, should we officially recommend to use clang-tidy (instead 
> of the static analyzer) for writing AST-based checks that don't require any 
> path-based analysis?


For now, there are overlap between both checkers. I think 
'alpha.core.IdenticalExpr' is in "alpha"-mode because there are too many 
false-positives related to cases like macro/floating-points (detecting 
NaN,...). The current checker has a pretty-low false-positive ratio. But, some 
redundant expressions won't be reported.

  i.e.   A[(3) - (3)]  which is frequent in bison-generated files won't be 
reported.

On a long term, I'm planning rules to enhance matching redundant expressions 
like:

  x == 10 && x < 12   (x < 12 is useless)


http://reviews.llvm.org/D19451



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


Re: [PATCH] D19071: [OpenCL] Add predefined macros.

2016-04-26 Thread Yaxun Liu via cfe-commits
yaxunl updated this revision to Diff 55016.
yaxunl marked 4 inline comments as done.
yaxunl added a comment.

Add CHECK-NOT for `__FAST_RELAXED_MATH__`.


http://reviews.llvm.org/D19071

Files:
  lib/Frontend/CompilerInvocation.cpp
  lib/Frontend/InitPreprocessor.cpp
  test/Frontend/std.cl
  test/Frontend/stdlang.c
  test/Preprocessor/predefined-macros.c

Index: test/Preprocessor/predefined-macros.c
===
--- test/Preprocessor/predefined-macros.c
+++ test/Preprocessor/predefined-macros.c
@@ -146,3 +146,40 @@
 // CHECK-SYNC_CAS_MIPS: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1
 // CHECK-SYNC_CAS_MIPS32-NOT: __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8
 // CHECK-SYNC_CAS_MIPS64: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 1
+
+// RUN: %clang_cc1 %s -E -dM -o - -x cl \
+// RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-CL10
+// RUN: %clang_cc1 %s -E -dM -o - -x cl -cl-std=CL1.1 \
+// RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-CL11
+// RUN: %clang_cc1 %s -E -dM -o - -x cl -cl-std=CL1.2 \
+// RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-CL12
+// RUN: %clang_cc1 %s -E -dM -o - -x cl -cl-std=CL2.0 \
+// RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-CL20
+// RUN: %clang_cc1 %s -E -dM -o - -x cl -cl-fast-relaxed-math \
+// RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-FRM
+// CHECK-CL10: #define CL_VERSION_1_0 100
+// CHECK-CL10: #define CL_VERSION_1_1 110
+// CHECK-CL10: #define CL_VERSION_1_2 120
+// CHECK-CL10: #define CL_VERSION_2_0 200
+// CHECK-CL10: #define __OPENCL_C_VERSION__ 100
+// CHECK-CL10-NOT: #define __FAST_RELAXED_MATH__ 1
+// CHECK-CL11: #define CL_VERSION_1_0 100
+// CHECK-CL11: #define CL_VERSION_1_1 110
+// CHECK-CL11: #define CL_VERSION_1_2 120
+// CHECK-CL11: #define CL_VERSION_2_0 200
+// CHECK-CL11: #define __OPENCL_C_VERSION__ 110
+// CHECK-CL11-NOT: #define __FAST_RELAXED_MATH__ 1
+// CHECK-CL12: #define CL_VERSION_1_0 100
+// CHECK-CL12: #define CL_VERSION_1_1 110
+// CHECK-CL12: #define CL_VERSION_1_2 120
+// CHECK-CL12: #define CL_VERSION_2_0 200
+// CHECK-CL12: #define __OPENCL_C_VERSION__ 120
+// CHECK-CL12-NOT: #define __FAST_RELAXED_MATH__ 1
+// CHECK-CL20: #define CL_VERSION_1_0 100
+// CHECK-CL20: #define CL_VERSION_1_1 110
+// CHECK-CL20: #define CL_VERSION_1_2 120
+// CHECK-CL20: #define CL_VERSION_2_0 200
+// CHECK-CL20: #define __OPENCL_C_VERSION__ 200
+// CHECK-CL20-NOT: #define __FAST_RELAXED_MATH__ 1
+// CHECK-FRM: #define __FAST_RELAXED_MATH__ 1
+
Index: test/Frontend/stdlang.c
===
--- test/Frontend/stdlang.c
+++ test/Frontend/stdlang.c
@@ -1,6 +1,13 @@
 // RUN: %clang_cc1 -x cuda -std=c++11 -DCUDA %s
-// RUN: %clang_cc1 -x cl -std=c99 -DOPENCL %s
-// expected-no-diagnostics
+// RUN: %clang_cc1 -x cl -DOPENCL %s
+// RUN: %clang_cc1 -x cl -cl-std=CL -DOPENCL %s
+// RUN: %clang_cc1 -x cl -cl-std=CL1.1 -DOPENCL %s
+// RUN: %clang_cc1 -x cl -cl-std=CL1.2 -DOPENCL %s
+// RUN: %clang_cc1 -x cl -cl-std=CL2.0 -DOPENCL %s
+// RUN: not %clang_cc1 -x cl -std=c99 -DOPENCL %s 2>&1 | FileCheck --check-prefix=CHECK-C99 %s
+// RUN: not %clang_cc1 -x cl -cl-std=invalid -DOPENCL %s 2>&1 | FileCheck --check-prefix=CHECK-INVALID %s
+// CHECK-C99: error: invalid argument '-std=c99' not allowed with 'OpenCL'
+// CHECK-INVALID: error: invalid value 'invalid' in '-cl-std=invalid'
 
 #if defined(CUDA)
   __attribute__((device)) void f_device();
Index: test/Frontend/std.cl
===
--- test/Frontend/std.cl
+++ /dev/null
@@ -1,9 +0,0 @@
-// RUN: %clang_cc1 %s -fsyntax-only -cl-std=CL
-// RUN: %clang_cc1 %s -fsyntax-only -cl-std=CL1.1
-// RUN: %clang_cc1 %s -fsyntax-only -cl-std=CL1.2
-// RUN: %clang_cc1 %s -fsyntax-only -cl-std=CL2.0
-// RUN: not %clang_cc1 %s -fsyntax-only -cl-std=invalid -DINVALID 2>&1 | FileCheck %s
-
-#ifdef INVALID 
-// CHECK: invalid value 'invalid' in '-cl-std=invalid'
-#endif
Index: lib/Frontend/InitPreprocessor.cpp
===
--- lib/Frontend/InitPreprocessor.cpp
+++ lib/Frontend/InitPreprocessor.cpp
@@ -408,6 +408,39 @@
   if (LangOpts.ObjC1)
 Builder.defineMacro("__OBJC__");
 
+  // OpenCL v1.0/1.1 s6.9, v1.2/2.0 s6.10: Preprocessor Directives and Macros.
+  if (LangOpts.OpenCL) {
+// OpenCL v1.0 and v1.1 do not have a predefined macro to indicate the
+// language standard with which the program is compiled. __OPENCL_VERSION__
+// is for the OpenCL version supported by the OpenCL device, which is not
+// necessarily the language standard with which the program is compiled.
+// A shared OpenCL header file requires a macro to indicate the language
+// standard. As a workaround, __OPENCL_C_VERSION__ is defined for
+// OpenCL v1.0 and v1.1.
+switch (LangOpts.OpenCLVersion) {
+case 100:
+  

[PATCH] D19534: [clang-tidy] new google-default-arguments check

2016-04-26 Thread Clement Courbet via cfe-commits
courbet created this revision.
courbet added a reviewer: alexfh.
courbet added a subscriber: cfe-commits.

To check the google style guide rule here:
https://google.github.io/styleguide/cppguide.html#Default_Arguments

http://reviews.llvm.org/D19534

Files:
  clang-tidy/google/CMakeLists.txt
  clang-tidy/google/DefaultArgumentsCheck.cpp
  clang-tidy/google/DefaultArgumentsCheck.h
  clang-tidy/google/GoogleTidyModule.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/google-default-arguments.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/google-default-arguments.cpp

Index: test/clang-tidy/google-default-arguments.cpp
===
--- /dev/null
+++ test/clang-tidy/google-default-arguments.cpp
@@ -0,0 +1,29 @@
+// RUN: %check_clang_tidy %s google-default-arguments %t
+
+struct A {
+  virtual void f(int I, int J = 3);
+  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: default argument given for virtual or override method
+};
+
+struct B : public A {
+  void f(int I, int J = 5);
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: default argument given for virtual or override method
+};
+
+struct C : public B {
+  void f(int I, int J = 5) override;
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: default argument given for virtual or override method
+};
+
+// Negatives.
+struct D : public B {
+  void f(int I, int J) override;
+};
+
+struct X {
+  void f(int I, int J = 3);
+};
+
+struct Y : public X {
+  void f(int I, int J = 5);
+};
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -30,6 +30,7 @@
google-build-explicit-make-pair
google-build-namespaces
google-build-using-namespace
+   google-default-arguments
google-explicit-constructor
google-global-names-in-headers
google-readability-braces-around-statements (redirects to readability-braces-around-statements) 
@@ -75,7 +76,7 @@
misc-string-literal-with-embedded-nul
misc-suspicious-missing-comma
misc-suspicious-semicolon
-   misc-suspicious-string-compare   
+   misc-suspicious-string-compare
misc-swapped-arguments
misc-throw-by-value-catch-by-reference
misc-undelegated-constructor
Index: docs/clang-tidy/checks/google-default-arguments.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/google-default-arguments.rst
@@ -0,0 +1,8 @@
+.. title:: clang-tidy - google-default-arguments
+
+google-default-arguments
+
+
+Checks that default parameters are not given for virtual methods.
+
+See https://google.github.io/styleguide/cppguide.html#Default_Arguments
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -86,6 +86,11 @@
   Flags user-defined constructor definitions that do not initialize all builtin
   and pointer fields which leaves their memory in an undefined state.
 
+- New `google-default-arguments
+  `_ check
+
+  Flags default arguments in vitual methods.
+
 - New `misc-dangling-handle
   `_ check
 
Index: clang-tidy/google/GoogleTidyModule.cpp
===
--- clang-tidy/google/GoogleTidyModule.cpp
+++ clang-tidy/google/GoogleTidyModule.cpp
@@ -15,6 +15,7 @@
 #include "../readability/NamespaceCommentCheck.h"
 #include "../readability/RedundantSmartptrGetCheck.h"
 #include "AvoidCStyleCastsCheck.h"
+#include "DefaultArgumentsCheck.h"
 #include "ExplicitConstructorCheck.h"
 #include "ExplicitMakePairCheck.h"
 #include "GlobalNamesInHeadersCheck.h"
@@ -36,6 +37,8 @@
 class GoogleModule : public ClangTidyModule {
 public:
   void addCheckFactories(ClangTidyCheckFactories ) override {
+CheckFactories.registerCheck(
+"google-default-arguments");
 CheckFactories.registerCheck(
 "google-build-explicit-make-pair");
 CheckFactories.registerCheck(
Index: clang-tidy/google/DefaultArgumentsCheck.h
===
--- /dev/null
+++ clang-tidy/google/DefaultArgumentsCheck.h
@@ -0,0 +1,34 @@
+//===--- DefaultArgumentsCheck.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_GOOGLE_DEFAULT_ARGUMENTS_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_GOOGLE_DEFAULT_ARGUMENTS_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+namespace google {
+
+/// Checks that 

Re: [PATCH] D18953: [ms][dll] #26935 Defining a dllimport function should cause it to be exported

2016-04-26 Thread Andrew V. Tischenko via cfe-commits
avt77 added a comment.

It seems the latest MSVC changed the support of several features covering in 
this patch: more investigations needed.



Comment at: test/SemaCXX/dllimport.cpp:179
@@ -140,1 +178,3 @@
+template 
+int ExternVarTmplDeclInit = 1;
 

rnk wrote:
> Can you check with MSVC 2015 update 2 actually does with definitions of 
> dllimport variable templates? I bet it doesn't export them.
They don't support variable templates at all:

error C2399: variable templates are not supported in this release


Comment at: test/SemaCXX/dllimport.cpp:1137
@@ -1017,1 +1136,3 @@
+template 
+void ImportClassTmplMembers::normalDef() {}
 #ifdef GNU

rnk wrote:
> I'm pretty sure MSVC considers all free function templates to be 'inline', 
> i.e. they put them in comdats. I doubt MSVC exports these. Can you verify 
> what it does?
They prohibit such a definition in the latest MSVC: 

error C2491: 'ImportClassTmplMembers::normalDef': definition of dllimport 
function not allowed

The same error I see for other definitions as well


http://reviews.llvm.org/D18953



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


Re: [PATCH] D19478: Remove assert mandating you can only use SPIR target with OpenCL

2016-04-26 Thread Anastasia Stulova via cfe-commits
Anastasia added a comment.

Committed in r267561!


http://reviews.llvm.org/D19478



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


Re: [PATCH] D19220: [Concepts] Pass requires-clause to ActOnTemplateParameterList; NFC

2016-04-26 Thread Hubert Tong via cfe-commits
hubert.reinterpretcast added a comment.

Ping.


http://reviews.llvm.org/D19220



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


r267560 - [OpenMP] Improve mappable expressions Sema.

2016-04-26 Thread Samuel Antao via cfe-commits
Author: sfantao
Date: Tue Apr 26 09:54:23 2016
New Revision: 267560

URL: http://llvm.org/viewvc/llvm-project?rev=267560=rev
Log:
[OpenMP] Improve mappable expressions Sema.

Summary:
This patch adds logic to save the components of mappable expressions in the 
clause that uses it, so that they don't have to be recomputed during codegen. 
Given that the mappable components are (will be) used in several clauses a new 
geneneric implementation `OMPMappableExprListClause` is used that extends the 
existing `OMPVarListClause`.

This patch does not add new tests. The goal is to preserve the existing 
functionality while storing more info in the clauses.

Reviewers: hfinkel, carlo.bertolli, arpith-jacob, kkwli0, ABataev

Subscribers: cfe-commits, caomhin

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

Modified:
cfe/trunk/include/clang/AST/OpenMPClause.h
cfe/trunk/lib/AST/OpenMPClause.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
cfe/trunk/lib/Serialization/ASTWriterStmt.cpp

Modified: cfe/trunk/include/clang/AST/OpenMPClause.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/OpenMPClause.h?rev=267560=267559=267560=diff
==
--- cfe/trunk/include/clang/AST/OpenMPClause.h (original)
+++ cfe/trunk/include/clang/AST/OpenMPClause.h Tue Apr 26 09:54:23 2016
@@ -2774,6 +2774,495 @@ public:
   }
 };
 
+/// \brief Struct that defines common infrastructure to handle mappable
+/// expressions used in OpenMP clauses.
+class OMPClauseMappableExprCommon {
+public:
+  // \brief Class that represents a component of a mappable expression. E.g.
+  // for an expression S.a, the first component is a declaration reference
+  // expression associated with 'S' and the second is a member expression
+  // associated with the field declaration 'a'. If the expression is an array
+  // subscript it may not have any associated declaration. In that case the
+  // associated declaration is set to nullptr.
+  class MappableComponent {
+// \brief Expression associated with the component.
+Expr *AssociatedExpression = nullptr;
+// \brief Declaration associated with the declaration. If the component 
does
+// not have a declaration (e.g. array subscripts or section), this is set 
to
+// nullptr.
+ValueDecl *AssociatedDeclaration = nullptr;
+
+  public:
+explicit MappableComponent() {}
+explicit MappableComponent(Expr *AssociatedExpression,
+   ValueDecl *AssociatedDeclaration)
+: AssociatedExpression(AssociatedExpression),
+  AssociatedDeclaration(
+  AssociatedDeclaration
+  ? cast(AssociatedDeclaration->getCanonicalDecl())
+  : nullptr) {}
+
+Expr *getAssociatedExpression() const { return AssociatedExpression; }
+ValueDecl *getAssociatedDeclaration() const {
+  return AssociatedDeclaration;
+}
+  };
+
+  // \brief List of components of an expression. This first one is the whole
+  // expression and the last one is the base expression.
+  typedef SmallVector MappableExprComponentList;
+  typedef ArrayRef MappableExprComponentListRef;
+
+  // \brief List of all component lists associated to the same base 
declaration.
+  // E.g. if both 'S.a' and 'S.b' are a mappable expressions, each will have
+  // their component list but the same base declaration 'S'.
+  typedef SmallVector MappableExprComponentLists;
+  typedef ArrayRef MappableExprComponentListsRef;
+
+protected:
+  // \brief Return the total number of elements in a list of component lists.
+  static unsigned
+  getComponentsTotalNumber(MappableExprComponentListsRef ComponentLists);
+
+  // \brief Return the total number of elements in a list of declarations. All
+  // declarations are expected to be canonical.
+  static unsigned
+  getUniqueDeclarationsTotalNumber(ArrayRef Declarations);
+};
+
+/// \brief This represents clauses with a list of expressions that are 
mappable.
+/// Examples of these clauses are 'map' in
+/// '#pragma omp target [enter|exit] [data]...' directives, and  'to' and 'from
+/// in '#pragma omp target update...' directives.
+template 
+class OMPMappableExprListClause : public OMPVarListClause,
+  public OMPClauseMappableExprCommon {
+  friend class OMPClauseReader;
+
+  /// \brief Number of unique declarations in this clause.
+  unsigned NumUniqueDeclarations;
+
+  /// \brief Number of component lists in this clause.
+  unsigned NumComponentLists;
+
+  /// \brief Total number of components in this clause.
+  unsigned NumComponents;
+
+protected:
+  /// \brief Get the unique declarations that are in the trailing objects of 
the
+  /// class.
+  MutableArrayRef getUniqueDeclsRef() {
+return MutableArrayRef(
+static_cast(this)->template getTrailingObjects(),
+

Re: [PATCH] D19482: [include-fixer] Add a find-all-symbols tool for include-fixer.

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

http://reviews.llvm.org/D19482



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


Re: [PATCH] D19524: [OpenCL] Fix pipe type dump.

2016-04-26 Thread Anastasia Stulova via cfe-commits
Anastasia added a comment.

Do you think we could add a test? For example similar to 
test/Misc/ast-dump-decl.c. We could have it for now in test/SemaOpenCL folder.


http://reviews.llvm.org/D19524



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


Re: [PATCH] D19482: [include-fixer] Add a find-all-symbols tool for include-fixer.

2016-04-26 Thread Haojian Wu via cfe-commits
hokein updated this revision to Diff 55003.
hokein marked 3 inline comments as done.
hokein added a comment.

Address review comments.


http://reviews.llvm.org/D19482

Files:
  include-fixer/CMakeLists.txt
  include-fixer/find-all-symbols/CMakeLists.txt
  include-fixer/find-all-symbols/FindAllSymbols.cpp
  include-fixer/find-all-symbols/FindAllSymbols.h
  include-fixer/find-all-symbols/SymbolInfo.cpp
  include-fixer/find-all-symbols/SymbolInfo.h
  include-fixer/find-all-symbols/tool/CMakeLists.txt
  include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
  include-fixer/find-all-symbols/tool/run-find-all-symbols.py
  unittests/include-fixer/CMakeLists.txt
  unittests/include-fixer/find-all-symbols/CMakeLists.txt
  unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp

Index: unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
===
--- /dev/null
+++ unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
@@ -0,0 +1,364 @@
+//===-- FindAllSymbolsTests.cpp - find all symbols unit tests -===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "FindAllSymbols.h"
+#include "clang/Tooling/Tooling.h"
+#include "llvm/Support/YAMLTraits.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace find_all_symbols {
+
+static const char HeaderName[] = "symbols.h";
+
+class MockReporter
+: public clang::find_all_symbols::FindAllSymbols::ResultReporter {
+public:
+  ~MockReporter() {}
+
+  void reportResult(llvm::StringRef FileName,
+const SymbolInfo ) override {
+Symbols.push_back(Symbol);
+  }
+
+  bool hasSymbol(const SymbolInfo ) {
+for (const auto  : Symbols) {
+  if (S == Symbol)
+return true;
+}
+return false;
+  }
+
+  bool getSymbolExtraInfo(SymbolInfo *Symbol) {
+for (const auto  : Symbols) {
+  if (S == *Symbol) {
+Symbol->FunctionInfos = S.FunctionInfos;
+Symbol->TypedefNameInfos = S.TypedefNameInfos;
+Symbol->VariableInfos = S.VariableInfos;
+return true;
+  }
+}
+return false;
+  }
+
+private:
+  std::vector Symbols;
+};
+
+class FindAllSymbolsTest : public ::testing::Test {
+public:
+  bool hasSymbol(const SymbolInfo ) {
+return Reporter.hasSymbol(Symbol);
+  }
+
+  bool getSymbolExtraInfo(SymbolInfo ) {
+return Reporter.getSymbolExtraInfo();
+  }
+
+  bool runFindAllSymbols(StringRef Code) {
+FindAllSymbols matcher();
+clang::ast_matchers::MatchFinder MatchFinder;
+matcher.RegisterSearcher();
+
+llvm::IntrusiveRefCntPtr InMemoryFileSystem(
+new vfs::InMemoryFileSystem);
+llvm::IntrusiveRefCntPtr Files(
+new FileManager(FileSystemOptions(), InMemoryFileSystem));
+
+std::string FileName = "symbol.cc";
+std::unique_ptr Factory =
+clang::tooling::newFrontendActionFactory();
+tooling::ToolInvocation Invocation(
+{std::string("find_all_symbols"), std::string("-fsyntax-only"),
+ FileName},
+Factory->create(), Files.get(),
+std::make_shared());
+
+InMemoryFileSystem->addFile(HeaderName, 0,
+llvm::MemoryBuffer::getMemBuffer(Code));
+
+std::string Content = "#include\"" + std::string(HeaderName) + "\"";
+InMemoryFileSystem->addFile(FileName, 0,
+llvm::MemoryBuffer::getMemBuffer(Content));
+Invocation.run();
+return true;
+  }
+
+private:
+  MockReporter Reporter;
+};
+
+SymbolInfo
+CreateSymbolInfo(StringRef Identifier, SymbolInfo::SymbolType Type,
+ const std::string FilePath, int LineNumber,
+ const std::vector ) {
+  SymbolInfo Symbol;
+  Symbol.Identifier = Identifier;
+  Symbol.Type = Type;
+  Symbol.FilePath = FilePath;
+  Symbol.LineNumber = LineNumber;
+  Symbol.Contexts = Contexts;
+  return Symbol;
+}
+
+TEST_F(FindAllSymbolsTest, VariableSymbols) {
+  static const char Code[] = R"(
+  extern int xargc;
+  namespace na {
+  static bool  = false;
+  namespace nb { const long long *; }
+  })";
+  runFindAllSymbols(Code);
+
+  {
+SymbolInfo Symbol =
+CreateSymbolInfo("xargc", SymbolInfo::Variable, HeaderName, 2, {});
+EXPECT_TRUE(hasSymbol(Symbol));
+getSymbolExtraInfo(Symbol);
+EXPECT_EQ("int", Symbol.VariableInfos.getValue().Type);
+  }
+  {
+SymbolInfo Symbol =
+CreateSymbolInfo("", SymbolInfo::Variable, HeaderName, 4,
+ {{SymbolInfo::Namespace, "na"}});
+EXPECT_TRUE(hasSymbol(Symbol));
+getSymbolExtraInfo(Symbol);
+EXPECT_EQ("_Bool", Symbol.VariableInfos.getValue().Type);
+  }
+  {
+SymbolInfo Symbol = CreateSymbolInfo(
+"", 

Re: [PATCH] D19071: [OpenCL] Add predefined macros.

2016-04-26 Thread Anastasia Stulova via cfe-commits
Anastasia added inline comments.


Comment at: test/Preprocessor/predefined-macros.c:180
@@ +179,3 @@
+// CHECK-CL20: #define __OPENCL_C_VERSION__ 200
+// CHECK-FRM: #define __FAST_RELAXED_MATH__ 1
+

Could we also add CHECK-NOT for all the above cases to make sure 
FAST_RELAXED_MATH doesn't appear there.


http://reviews.llvm.org/D19071



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


Re: [PATCH] D17981: [clang-tidy] Fix clang-tidy to support parsing of assembly statements.

2016-04-26 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

Manuel, can you take a look at this? We need your input.


http://reviews.llvm.org/D17981



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


Re: [PATCH] D19382: [OpenMP] Improve mappable expressions Sema.

2016-04-26 Thread Samuel Antao via cfe-commits
sfantao updated this revision to Diff 55002.
sfantao marked an inline comment as done.
sfantao added a comment.

- Explicitelly store canonical declaration when looking for unique declarations.


http://reviews.llvm.org/D19382

Files:
  include/clang/AST/OpenMPClause.h
  lib/AST/OpenMPClause.cpp
  lib/Sema/SemaOpenMP.cpp
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp

Index: lib/Serialization/ASTWriterStmt.cpp
===
--- lib/Serialization/ASTWriterStmt.cpp
+++ lib/Serialization/ASTWriterStmt.cpp
@@ -2021,13 +2021,26 @@
 
 void OMPClauseWriter::VisitOMPMapClause(OMPMapClause *C) {
   Record.push_back(C->varlist_size());
+  Record.push_back(C->getUniqueDeclarationsNum());
+  Record.push_back(C->getTotalComponentListNum());
+  Record.push_back(C->getTotalComponentsNum());
   Record.AddSourceLocation(C->getLParenLoc());
   Record.push_back(C->getMapTypeModifier());
   Record.push_back(C->getMapType());
   Record.AddSourceLocation(C->getMapLoc());
   Record.AddSourceLocation(C->getColonLoc());
-  for (auto *VE : C->varlists())
-Record.AddStmt(VE);
+  for (auto *E : C->varlists())
+Record.AddStmt(E);
+  for (auto *D : C->all_decls())
+Record.AddDeclRef(D);
+  for (auto N : C->all_num_lists())
+Record.push_back(N);
+  for (auto N : C->all_lists_sizes())
+Record.push_back(N);
+  for (auto  : C->all_components()) {
+Record.AddStmt(M.getAssociatedExpression());
+Record.AddDeclRef(M.getAssociatedDeclaration());
+  }
 }
 
 void OMPClauseWriter::VisitOMPNumTeamsClause(OMPNumTeamsClause *C) {
Index: lib/Serialization/ASTReaderStmt.cpp
===
--- lib/Serialization/ASTReaderStmt.cpp
+++ lib/Serialization/ASTReaderStmt.cpp
@@ -1861,9 +1861,15 @@
   case OMPC_device:
 C = new (Context) OMPDeviceClause();
 break;
-  case OMPC_map:
-C = OMPMapClause::CreateEmpty(Context, Record[Idx++]);
+  case OMPC_map: {
+unsigned NumVars = Record[Idx++];
+unsigned NumDeclarations = Record[Idx++];
+unsigned NumLists = Record[Idx++];
+unsigned NumComponents = Record[Idx++];
+C = OMPMapClause::CreateEmpty(Context, NumVars, NumDeclarations, NumLists,
+  NumComponents);
 break;
+  }
   case OMPC_num_teams:
 C = new (Context) OMPNumTeamsClause();
 break;
@@ -2225,12 +2231,45 @@
   C->setMapLoc(Reader->ReadSourceLocation(Record, Idx));
   C->setColonLoc(Reader->ReadSourceLocation(Record, Idx));
   auto NumVars = C->varlist_size();
+  auto UniqueDecls = C->getUniqueDeclarationsNum();
+  auto TotalLists = C->getTotalComponentListNum();
+  auto TotalComponents = C->getTotalComponentsNum();
+
   SmallVector Vars;
   Vars.reserve(NumVars);
-  for (unsigned i = 0; i != NumVars; ++i) {
+  for (unsigned i = 0; i != NumVars; ++i)
 Vars.push_back(Reader->Reader.ReadSubExpr());
-  }
   C->setVarRefs(Vars);
+
+  SmallVector Decls;
+  Decls.reserve(UniqueDecls);
+  for (unsigned i = 0; i < UniqueDecls; ++i)
+Decls.push_back(
+Reader->Reader.ReadDeclAs(Reader->F, Record, Idx));
+  C->setUniqueDecls(Decls);
+
+  SmallVector ListsPerDecl;
+  ListsPerDecl.reserve(UniqueDecls);
+  for (unsigned i = 0; i < UniqueDecls; ++i)
+ListsPerDecl.push_back(Record[Idx++]);
+  C->setDeclNumLists(ListsPerDecl);
+
+  SmallVector ListSizes;
+  ListSizes.reserve(TotalLists);
+  for (unsigned i = 0; i < TotalLists; ++i)
+ListSizes.push_back(Record[Idx++]);
+  C->setComponentListSizes(ListSizes);
+
+  SmallVector Components;
+  Components.reserve(TotalComponents);
+  for (unsigned i = 0; i < TotalComponents; ++i) {
+Expr *AssociatedExpr = Reader->Reader.ReadSubExpr();
+ValueDecl *AssociatedDecl =
+Reader->Reader.ReadDeclAs(Reader->F, Record, Idx);
+Components.push_back(OMPClauseMappableExprCommon::MappableComponent(
+AssociatedExpr, AssociatedDecl));
+  }
+  C->setComponents(Components, ListSizes);
 }
 
 void OMPClauseReader::VisitOMPNumTeamsClause(OMPNumTeamsClause *C) {
Index: lib/Sema/SemaOpenMP.cpp
===
--- lib/Sema/SemaOpenMP.cpp
+++ lib/Sema/SemaOpenMP.cpp
@@ -81,8 +81,6 @@
   };
 
 private:
-  typedef SmallVector MapInfo;
-
   struct DSAInfo {
 OpenMPClauseKind Attributes;
 Expr *RefExpr;
@@ -92,14 +90,16 @@
   typedef llvm::DenseMap AlignedMapTy;
   typedef std::pair LCDeclInfo;
   typedef llvm::DenseMap LoopControlVariablesMapTy;
-  typedef llvm::DenseMap MappedDeclsTy;
+  typedef llvm::DenseMap<
+  ValueDecl *, OMPClauseMappableExprCommon::MappableExprComponentLists>
+  MappedExprComponentsTy;
   typedef llvm::StringMap
   CriticalsWithHintsTy;
 
   struct SharingMapTy {
 DeclSAMapTy SharingMap;
 AlignedMapTy AlignedMap;
-MappedDeclsTy MappedDecls;
+

Re: [PATCH] D19382: [OpenMP] Improve mappable expressions Sema.

2016-04-26 Thread Samuel Antao via cfe-commits
sfantao marked 2 inline comments as done.
sfantao added a comment.

Hi Alexey,

Thanks for the review.



Comment at: lib/AST/OpenMPClause.cpp:546
@@ +545,3 @@
+  for (auto *D : Declarations) {
+assert(
+(!D || D->isCanonicalDecl()) &&

ABataev wrote:
> sfantao wrote:
> > Ok, using canonical declarations now. 
> > 
> No, I mean you'd better to check and store canonical decls in Cache, like:
> ```
> if (Cache.count(D->getCaonicalDecl())
> ```
> ```
> Cache.insert(D->getCanonicalDecl());
> ```
> 
Oh, okay, I am doing as you say.


http://reviews.llvm.org/D19382



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


Re: [PATCH] D18300: [clang-tidy] ProTypeMemberInitCheck - check that field decls do not have in-class initializer

2016-04-26 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

In http://reviews.llvm.org/D18300#412003, @flx wrote:

> I should free up again soon, just caught the flu though. Maybe next week?
>  Feel free to commit before then.


Just tried it, and the patch doesn't apply cleanly. Leaving this to you.


Repository:
  rL LLVM

http://reviews.llvm.org/D18300



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


Re: [PATCH] D19412: [libcxx] Refactor pthread usage - II

2016-04-26 Thread Ben Craig via cfe-commits
bcraig added a subscriber: bcraig.


Comment at: src/mutex.cpp:31
@@ +30,3 @@
+#else
+#error "Not implemented for the selected thread API."
+#endif

Can't we just check for _LIBCPP_THREAD_API_PTHREAD once at the top of the file 
and #error as necessary there?  I don't get the value of multiple #errors for 
the same condition, but sprinkled throughout the implementation.  I do see the 
cost in the strategy, in that there are now lots of places that can bit-rot.


http://reviews.llvm.org/D19412



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


Re: [PATCH] D18821: Add modernize-bool-to-integer-conversion

2016-04-26 Thread Alexander Kornienko via cfe-commits
alexfh requested changes to this revision.
alexfh added a comment.
This revision now requires changes to proceed.

In http://reviews.llvm.org/D18821#403117, @Prazek wrote:

> In http://reviews.llvm.org/D18821#402686, @Prazek wrote:
>
> > In http://reviews.llvm.org/D18821#398843, @alexfh wrote:
> >
> > > BTW, why is the check in the 'modernize' module? It doesn't seem to make 
> > > anything more modern. I would guess, the pattern it detects is most 
> > > likely to result from a programming error. Also, the fix, though it 
> > > retains the behavior, has a high chance to be incorrect. Can you share 
> > > the results of running this check on LLVM? At least, how many problems it 
> > > found and how many times the suggested fix was correct.
> > >
> > > I'd suggest to move the check to `misc` or maybe it's time to create a 
> > > separate directory for checks targeting various bug-prone patterns.
> >
> >
> > Do you have any thought about the name for such a module? I belive that 
> > misc is overloaded.
> >
> > So for this we are looking for something that is probably not a bug, but it 
> > makes code a little bit inaccurate
> >  Maybe something like:
> >
> > - accuracy,
> > - correctness,
> > - certainity,
> > - safety,
> > - maybebugmaybenothardtosay
>
>
> after a long though I think that "accuracy" is the best name here - we want 
> to look for a code that is valid, but not accurate


There are many possible reasons this pattern can appear in the code. Sometimes 
it's a bug, sometimes, it's an attempt to make the code look better than it is 
;) It seems to me though, that having a type mismatch of this kind is a 
bug-prone pattern, so I would start a more generic "bugprone" category of 
checks (and move some misc- checks there later on).

Also, please re-upload http://reviews.llvm.org/D19105 after disabling matches 
on 1-bit bitfields in the check.


http://reviews.llvm.org/D18821



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


Re: [PATCH] D19415: [libcxx][rfc] Externalized threading support

2016-04-26 Thread Ben Craig via cfe-commits
bcraig added a subscriber: bcraig.
bcraig added a comment.

Note:  My opinion doesn't count for much as far as community acceptance goes.

I'm fine with the idea.  I think there is at least one significant conformance 
hurdle that you will need to address though.  I also have some commentary on 
the implementation details.



Comment at: include/__mutex_base:43
@@ +42,3 @@
+#if defined(_LIBCPP_THREAD_API_EXTERNAL)
+mutex() _NOEXCEPT {__libcpp_os_support::__os_mutex_init(&__m_);}
+#elif !defined(_LIBCPP_HAS_NO_CONSTEXPR)

This is not C++14 conformant.  The default constructor for mutex() needs to be 
constexpr.

I'm not sure if there is a good way around this issue given the problem you are 
trying to solve.  There have been similar constexpr issues with this 
constructor with regards to musl libc.


Comment at: include/__os_support:23
@@ +22,3 @@
+// Mutexes
+struct __mutex_t;
+typedef struct __mutex_t* __os_mutex;

I would prefer that the internal types use an under-under-libcpp __libcpp 
prefix.  I've had issues in the past with my under-under symbol names colliding 
with those from the underlying C library, especially for obvious names like 
under-under-mutex_t.


Comment at: src/algorithm.cpp:65
@@ +64,3 @@
+# elif defined(_LIBCPP_THREAD_API_EXTERNAL)
+__rs_mut.lock();
+# else

I would rather the new branch be used across the board.  I don't like littering 
the generic implementation files with preprocessor blocks everywhere.

Stated differently, get rid of 
```
__libcpp_os_support::__os_mutex __rs_mut
```
and just use 
```
mutex __rs_mut
```
everywhere instead.


Comment at: src/mutex.cpp:31
@@ -30,1 +30,3 @@
+#elif defined(_LIBCPP_THREAD_API_EXTERNAL)
+__os_mutex_destroy(__m_);
 #else

My preference is for all of this to hide behind the __os_mutex_destroy call, 
instead of having the preprocessor block here.  It looks like that has already 
been discussed in a prior review though ( http://reviews.llvm.org/D11781 ).


http://reviews.llvm.org/D19415



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


r267557 - Update test after LLVM r267556.

2016-04-26 Thread Nico Weber via cfe-commits
Author: nico
Date: Tue Apr 26 08:54:29 2016
New Revision: 267557

URL: http://llvm.org/viewvc/llvm-project?rev=267557=rev
Log:
Update test after LLVM r267556.

Modified:
cfe/trunk/test/Driver/at_file.c
cfe/trunk/test/Driver/at_file.c.args

Modified: cfe/trunk/test/Driver/at_file.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/at_file.c?rev=267557=267556=267557=diff
==
--- cfe/trunk/test/Driver/at_file.c (original)
+++ cfe/trunk/test/Driver/at_file.c Tue Apr 26 08:54:29 2016
@@ -14,9 +14,9 @@
 // CHECK-NEXT: foo9'bar9'zed9
 // CHECK-NEXT: foo10"bar10"zed10
 // CHECK: bar
-// CHECK: zed12
+// CHECK: zed1
 // CHECK: one\two
-// CHECK: c:\foo\bar.c
+// CHECK: c:foobar.c
 
 foo1
 foo2

Modified: cfe/trunk/test/Driver/at_file.c.args
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/at_file.c.args?rev=267557=267556=267557=diff
==
--- cfe/trunk/test/Driver/at_file.c.args (original)
+++ cfe/trunk/test/Driver/at_file.c.args Tue Apr 26 08:54:29 2016
@@ -8,6 +8,7 @@
 -Dfoo9=foo9\'bar9\'zed9
 -Dfoo10=foo10\"bar10\"zed10
 -D foo11
--Dfoo12=zed12\
+-Dfoo12=zed1\
+2
 -Dfoo13='one\\two'
 -Dfoo14='c:\foo\bar.c'


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


Re: [PATCH] D18694: [ClangTidy] Add an 'explain-checks' option to diagnose where each checks comes from.

2016-04-26 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

One more nit.



Comment at: clang-tidy/ClangTidyOptions.h:233
@@ -200,2 +232,3 @@
 
-  ClangTidyOptions getOptions(llvm::StringRef FileName) override;
+  std::vector getRawOptions(
+  llvm::StringRef FileName) override;

clang-format?

Consider making `git clang-format` handle it for you ;)


http://reviews.llvm.org/D18694



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


Re: [PATCH] D18694: [ClangTidy] Add an 'explain-checks' option to diagnose where each checks comes from.

2016-04-26 Thread Alexander Kornienko via cfe-commits
alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.

Looks good with one nit.

Thank you for implementing this!



Comment at: clang-tidy/tool/ClangTidyMain.cpp:320
@@ +319,3 @@
+  if (ExplainConfig) {
+std::vector
+RawOptions = OptionsProvider->getRawOptions(FileName);

Sorry for being not clear. We still need to find a way to display the source of 
other components of the configuration. So the FIXME was fine, just the wording 
was confusing. Please add the FIXME back, but just remove the "more elegant" 
part.


http://reviews.llvm.org/D18694



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


Re: [PATCH] D18694: [ClangTidy] Add an 'explain-checks' option to diagnose where each checks comes from.

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

http://reviews.llvm.org/D18694



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


Re: r267496 - [lanai] Update handling of structs in arguments to be passed in registers.

2016-04-26 Thread Jacques Pienaar via cfe-commits
Thanks for fixing this. My apologies for breaking this and not noticing &
fixing it earlier. Is there any way to test the Windows build without a
Windows machine at my disposal?

On Mon, Apr 25, 2016 at 6:59 PM, Kostya Serebryany  wrote:

> Hopefully fixed by r267513.
>
> On Mon, Apr 25, 2016 at 6:46 PM, Kostya Serebryany  wrote:
>
>> +rnk
>>
>> On Mon, Apr 25, 2016 at 5:09 PM, Jacques Pienaar via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Author: jpienaar
>>> Date: Mon Apr 25 19:09:29 2016
>>> New Revision: 267496
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=267496=rev
>>> Log:
>>> [lanai] Update handling of structs in arguments to be passed in
>>> registers.
>>>
>>> Previously aggregate types were passed byval, change the ABI to pass
>>> these in registers instead.
>>>
>>>
>>> Modified:
>>> cfe/trunk/lib/CodeGen/TargetInfo.cpp
>>> cfe/trunk/test/CodeGen/lanai-arguments.c
>>>
>>> Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
>>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/
>>> TargetInfo.cpp?rev=267496=267495=267496=diff
>>> 
>>> ==
>>> --- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
>>> +++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Mon Apr 25 19:09:29 2016
>>> @@ -6691,6 +6691,7 @@ public:
>>>I.info = classifyArgumentType(I.type, State);
>>>}
>>>
>>> +  ABIArgInfo getIndirectResult(QualType Ty, bool ByVal, CCState )
>>> const;
>>>ABIArgInfo classifyArgumentType(QualType RetTy, CCState ) const;
>>>  };
>>>  } // end anonymous namespace
>>> @@ -6712,21 +6713,72 @@ bool LanaiABIInfo::shouldUseInReg(QualTy
>>>return true;
>>>  }
>>>
>>> +ABIArgInfo LanaiABIInfo::getIndirectResult(QualType Ty, bool ByVal,
>>> +   CCState ) const {
>>> +  if (!ByVal) {
>>> +if (State.FreeRegs) {
>>> +  --State.FreeRegs; // Non-byval indirects just use one pointer.
>>> +  return getNaturalAlignIndirectInReg(Ty);
>>> +}
>>> +return getNaturalAlignIndirect(Ty, false);
>>> +  }
>>> +
>>> +  // Compute the byval alignment.
>>> +  constexpr unsigned MinABIStackAlignInBytes = 4;
>>>
>>
>> This broke the build on Windows;
>>
>> C:\b\slave\sanitizer-windows\llvm\tools\clang\lib\CodeGen\TargetInfo.cpp(6727)
>>  : error C2065: 'constexpr' : undeclared identifier
>>
>>
>>
>>
>>
>>> +  unsigned TypeAlign = getContext().getTypeAlign(Ty) / 8;
>>> +  return ABIArgInfo::getIndirect(CharUnits::fromQuantity(4),
>>> /*ByVal=*/true,
>>> + /*Realign=*/TypeAlign >
>>> + MinABIStackAlignInBytes);
>>> +}
>>> +
>>>  ABIArgInfo LanaiABIInfo::classifyArgumentType(QualType Ty,
>>>CCState ) const {
>>> -  if (isAggregateTypeForABI(Ty))
>>> -return getNaturalAlignIndirect(Ty);
>>> +  // Check with the C++ ABI first.
>>> +  const RecordType *RT = Ty->getAs();
>>> +  if (RT) {
>>> +CGCXXABI::RecordArgABI RAA = getRecordArgABI(RT, getCXXABI());
>>> +if (RAA == CGCXXABI::RAA_Indirect) {
>>> +  return getIndirectResult(Ty, /*ByVal=*/false, State);
>>> +} else if (RAA == CGCXXABI::RAA_DirectInMemory) {
>>> +  return getNaturalAlignIndirect(Ty, /*ByRef=*/true);
>>> +}
>>> +  }
>>> +
>>> +  if (isAggregateTypeForABI(Ty)) {
>>> +// Structures with flexible arrays are always indirect.
>>> +if (RT && RT->getDecl()->hasFlexibleArrayMember())
>>> +  return getIndirectResult(Ty, /*ByVal=*/true, State);
>>> +
>>> +// Ignore empty structs/unions.
>>> +if (isEmptyRecord(getContext(), Ty, true))
>>> +  return ABIArgInfo::getIgnore();
>>> +
>>> +llvm::LLVMContext  = getVMContext();
>>> +unsigned SizeInRegs = (getContext().getTypeSize(Ty) + 31) / 32;
>>> +if (SizeInRegs <= State.FreeRegs) {
>>> +  llvm::IntegerType *Int32 = llvm::Type::getInt32Ty(LLVMContext);
>>> +  SmallVector Elements(SizeInRegs, Int32);
>>> +  llvm::Type *Result = llvm::StructType::get(LLVMContext,
>>> Elements);
>>> +  State.FreeRegs -= SizeInRegs;
>>> +  return ABIArgInfo::getDirectInReg(Result);
>>> +} else {
>>> +  State.FreeRegs = 0;
>>> +}
>>> +return getIndirectResult(Ty, true, State);
>>> +  }
>>>
>>>// Treat an enum type as its underlying type.
>>>if (const auto *EnumTy = Ty->getAs())
>>>  Ty = EnumTy->getDecl()->getIntegerType();
>>>
>>> -  if (shouldUseInReg(Ty, State))
>>> -return ABIArgInfo::getDirectInReg();
>>> -
>>> -  if (Ty->isPromotableIntegerType())
>>> +  bool InReg = shouldUseInReg(Ty, State);
>>> +  if (Ty->isPromotableIntegerType()) {
>>> +if (InReg)
>>> +  return ABIArgInfo::getDirectInReg();
>>>  return ABIArgInfo::getExtend();
>>> -
>>> +  }
>>> +  if (InReg)
>>> +return ABIArgInfo::getDirectInReg();
>>>return ABIArgInfo::getDirect();
>>>  }
>>>
>>>
>>> Modified: 

Re: [PATCH] D18694: [ClangTidy] Add an 'explain-checks' option to diagnose where each checks comes from.

2016-04-26 Thread Haojian Wu via cfe-commits
hokein added inline comments.


Comment at: clang-tidy/ClangTidyOptions.cpp:235
@@ +234,3 @@
+if (Iter != CachedOptions.end()) {
+  RawOptions.push_back(Iter->second);
+  break;

alexfh wrote:
> This seems to be changing the caching logic. Consider this directory 
> structure:
> 
>   a/
>  .clang-tidy
>  b/
> c/
> 
> And consequtive `getRawOptions` calls with:
>   1. "a/some_file"
>   2. "a/b/c/some_file"
>   3. "a/b/some_file".
> 
> What would happen previously:
>   1. after call 1 `CachedOptions` would contain an entry for "a"
>   2. call 2 would find an entry for "a" and copy it for "a/b" and "a/b/c"
>   3. call 3 would just use the cache entry for "a/b"
> 
> Now step 2 doesn't copy the cache entry to "a/b" and "a/b/c".
> 
> Is there any specific reason to change this? This is benign given that the 
> lookups happen in memory, but then the code needs to be consistent and avoid 
> replicating cache entries to intermediate directories in all cases.
Oh, I add a `break` statement here accidently. Remove it, and keep the caching 
logic here now. 


Comment at: clang-tidy/ClangTidyOptions.h:115
@@ +114,3 @@
+  ///* clang-tidy binary
+  ///* '-config' commandline option or a specific configuration file
+  ///* '-checks' commandline option

Explaining the priority of `config` option and config file is't reasonable here 
since clang-tidy only takes one of them. If the config option is specified, 
clang-tidy just ignores the config file.


http://reviews.llvm.org/D18694



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


Re: [PATCH] D19249: Fix include path in ClangTidy.cpp.

2016-04-26 Thread Alexander Kornienko via cfe-commits
alexfh requested changes to this revision.
alexfh added a comment.
This revision now requires changes to proceed.

In http://reviews.llvm.org/D19249#408437, @chh wrote:

> This change depends on http://reviews.llvm.org/D19393.


I'm personally fine with the solution in http://reviews.llvm.org/D19393. 
Removing this from my dashboard until that patch lands.


http://reviews.llvm.org/D19249



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


Re: [PATCH] D19451: [clang-tidy] New checker for redundant expressions.

2016-04-26 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

In http://reviews.llvm.org/D19451#411990, @alexfh wrote:

> BTW, have you seen the `alpha.core.IdenticalExpr` static analyzer checker?


Anna, Jordan, and whoever else is interested in the `alpha.core.IdenticalExpr` 
checker (lib/StaticAnalyzer/Checkers/IdenticalExprChecker.cpp), it looks like 
Etienne has reinvented a large part of this checker as a clang-tidy check. I'm 
not sure which of these supports more cases and has more false positives (given 
that the `alpha.core.IdenticalExpr` checker was there for quite a while, but 
IIUC, this clang-tidy check has been tested on a huge code base with pretty 
good results).

A few questions to all of you:

1. is the `alpha.core.IdenticalExpr` checker going to be released in the near 
future?
2. is anyone actively working on it?
3. given that Etienne seems to be planning to continue actively working on the 
clang-tidy analog of that static analyzer checker, are you fine to move all of 
this checker's (`alpha.core.IdenticalExpr`) functionality to clang-tidy?
4. more generally, should we officially recommend to use clang-tidy (instead of 
the static analyzer) for writing AST-based checks that don't require any 
path-based analysis?


http://reviews.llvm.org/D19451



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


Re: [PATCH] D18963: PR27216: Only define __ARM_FEATURE_FMA when the target has VFPv4

2016-04-26 Thread silviu.bara...@arm.com via cfe-commits
sbaranga added inline comments.


Comment at: lib/Basic/Targets.cpp:4710
@@ -4709,1 +4709,3 @@
  const std::vector ) const override {
+if (CPU == "")
+  CPU = "generic";

rengolin wrote:
> This change is unrelated and may bring side effects into clang. I'd keep this 
> out and investigate it in another patch with the appropriate tests. If you 
> just force the target-feature in the test, this corner case won't be relevant 
> in this patch.
Ok, that makes sense. I'll revert to the previous revision of this patch.


http://reviews.llvm.org/D18963



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


Re: [PATCH] D19412: [libcxx] Refactor pthread usage - II

2016-04-26 Thread Asiri Rathnayake via cfe-commits
rmaprath updated this revision to Diff 54999.
rmaprath added a comment.

Minor cleanup + Gentle ping.


http://reviews.llvm.org/D19412

Files:
  include/__config
  include/__mutex_base
  include/__os_support
  include/mutex
  include/thread
  src/algorithm.cpp
  src/condition_variable.cpp
  src/memory.cpp
  src/mutex.cpp
  src/thread.cpp

Index: src/thread.cpp
===
--- src/thread.cpp
+++ src/thread.cpp
@@ -37,6 +37,8 @@
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
+using namespace __libcpp_os_support;
+
 thread::~thread()
 {
 if (__t_ != 0)
@@ -46,7 +48,11 @@
 void
 thread::join()
 {
+#if defined(_LIBCPP_THREAD_API_PTHREAD)
 int ec = pthread_join(__t_, 0);
+#else
+#error "Not implemented for the selected thread API."
+#endif
 #ifndef _LIBCPP_NO_EXCEPTIONS
 if (ec)
 throw system_error(error_code(ec, system_category()), "thread::join failed");
@@ -62,7 +68,11 @@
 int ec = EINVAL;
 if (__t_ != 0)
 {
+#if defined(_LIBCPP_THREAD_API_PTHREAD)
 ec = pthread_detach(__t_);
+#else
+#error "Not implemented for the selected thread API."
+#endif
 if (ec == 0)
 __t_ = 0;
 }
Index: src/mutex.cpp
===
--- src/mutex.cpp
+++ src/mutex.cpp
@@ -21,37 +21,56 @@
 const try_to_lock_t try_to_lock = {};
 const adopt_lock_t  adopt_lock = {};
 
+using namespace __libcpp_os_support;
+
 mutex::~mutex()
 {
+#if defined(_LIBCPP_THREAD_API_PTHREAD)
 pthread_mutex_destroy(&__m_);
+#else
+#error "Not implemented for the selected thread API."
+#endif
 }
 
 void
 mutex::lock()
 {
+#if defined(_LIBCPP_THREAD_API_PTHREAD)
 int ec = pthread_mutex_lock(&__m_);
+#else
+#error "Not implemented for the selected thread API."
+#endif
 if (ec)
 __throw_system_error(ec, "mutex lock failed");
 }
 
 bool
 mutex::try_lock() _NOEXCEPT
 {
+#if defined(_LIBCPP_THREAD_API_PTHREAD)
 return pthread_mutex_trylock(&__m_) == 0;
+#else
+#error "Not implemented for the selected thread API."
+#endif
 }
 
 void
 mutex::unlock() _NOEXCEPT
 {
+#if defined(_LIBCPP_THREAD_API_PTHREAD)
 int ec = pthread_mutex_unlock(&__m_);
+#else
+#error "Not implemented for the selected thread API."
+#endif
 (void)ec;
 assert(ec == 0);
 }
 
 // recursive_mutex
 
 recursive_mutex::recursive_mutex()
 {
+#if defined(_LIBCPP_THREAD_API_PTHREAD)
 pthread_mutexattr_t attr;
 int ec = pthread_mutexattr_init();
 if (ec)
@@ -77,35 +96,54 @@
 return;
 fail:
 __throw_system_error(ec, "recursive_mutex constructor failed");
+#else
+#error "Not implemented for the selected thread API."
+#endif
 }
 
 recursive_mutex::~recursive_mutex()
 {
+#if defined(_LIBCPP_THREAD_API_PTHREAD)
 int e = pthread_mutex_destroy(&__m_);
+#else
+#error "Not implemented for the selected thread API."
+#endif
 (void)e;
 assert(e == 0);
 }
 
 void
 recursive_mutex::lock()
 {
+#if defined(_LIBCPP_THREAD_API_PTHREAD)
 int ec = pthread_mutex_lock(&__m_);
+#else
+#error "Not implemented for the selected thread API."
+#endif
 if (ec)
 __throw_system_error(ec, "recursive_mutex lock failed");
 }
 
 void
 recursive_mutex::unlock() _NOEXCEPT
 {
+#if defined(_LIBCPP_THREAD_API_PTHREAD)
 int e = pthread_mutex_unlock(&__m_);
+#else
+#error "Not implemented for the selected thread API."
+#endif
 (void)e;
 assert(e == 0);
 }
 
 bool
 recursive_mutex::try_lock() _NOEXCEPT
 {
+#if defined(_LIBCPP_THREAD_API_PTHREAD)
 return pthread_mutex_trylock(&__m_) == 0;
+#else
+#error "Not implemented for the selected thread API."
+#endif
 }
 
 // timed_mutex
@@ -165,9 +203,9 @@
 void
 recursive_timed_mutex::lock()
 {
-pthread_t id = pthread_self();
+__os_thread_id id = __os_thread_get_current_id();
 unique_lock lk(__m_);
-if (pthread_equal(id, __id_))
+if (__os_thread_id_compare(id, __id_) == 0)
 {
 if (__count_ == numeric_limits::max())
 __throw_system_error(EAGAIN, "recursive_timed_mutex lock limit reached");
@@ -183,9 +221,9 @@
 bool
 recursive_timed_mutex::try_lock() _NOEXCEPT
 {
-pthread_t id = pthread_self();
+__os_thread_id id = __os_thread_get_current_id();
 unique_lock lk(__m_, try_to_lock);
-if (lk.owns_lock() && (__count_ == 0 || pthread_equal(id, __id_)))
+if (lk.owns_lock() && (__count_ == 0 || __os_thread_id_compare(id, __id_) == 0))
 {
 if (__count_ == numeric_limits::max())
 return false;
@@ -210,13 +248,12 @@
 
 #endif // !_LIBCPP_HAS_NO_THREADS
 
+#if !defined(_LIBCPP_HAS_NO_THREADS) && defined(_LIBCPP_THREAD_API_PTHREAD)
 // If dispatch_once_f ever handles C++ exceptions, and if one can get to it
 // without illegal macros (unexpected macros not beginning with _UpperCase or
 // __lowercase), and if it stops spinning waiting threads, then call_once should
 // call into dispatch_once_f instead of here. Relevant radar this code 

Re: [PATCH] D18963: PR27216: Only define __ARM_FEATURE_FMA when the target has VFPv4

2016-04-26 Thread Renato Golin via cfe-commits
rengolin added inline comments.


Comment at: lib/Basic/Targets.cpp:4710
@@ -4709,1 +4709,3 @@
  const std::vector ) const override {
+if (CPU == "")
+  CPU = "generic";

This change is unrelated and may bring side effects into clang. I'd keep this 
out and investigate it in another patch with the appropriate tests. If you just 
force the target-feature in the test, this corner case won't be relevant in 
this patch.


Comment at: test/Sema/arm_vfma.c:1
@@ -1,2 +1,2 @@
-// RUN: %clang_cc1 -triple thumbv7s-apple-ios7.0 -target-feature +neon 
-fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple thumbv7s-apple-ios7.0 -fsyntax-only -verify %s
 #include 

This test should not be relying on the front-end getting the feature right, it 
should be forcing the vfpv4 target feature on a base arch like "arm-none-eabi".


Comment at: test/Sema/neon-vector-types-support.c:1
@@ -1,2 +1,2 @@
-// RUN: %clang_cc1 %s -triple armv7 -fsyntax-only -verify
+// RUN: %clang_cc1 %s -triple armv7 -target-feature -neon -fsyntax-only -verify
 

This change seems unrelated?


http://reviews.llvm.org/D18963



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


Re: [PATCH] D18300: [clang-tidy] ProTypeMemberInitCheck - check that field decls do not have in-class initializer

2016-04-26 Thread Felix Berger via cfe-commits
I should free up again soon, just caught the flu though. Maybe next week?
Feel free to commit before then.

On Tue, Apr 26, 2016 at 5:52 AM, Alexander Kornienko 
wrote:

> alexfh added a comment.
>
> Felix, do you have time to commit the patch or should I do this for you?
>
>
> Repository:
>   rL LLVM
>
> http://reviews.llvm.org/D18300
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D19327: Keep invalid function body as part of the AST

2016-04-26 Thread Olivier Goffart via cfe-commits
ogoffart added a comment.

Ping?


http://reviews.llvm.org/D19327



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


Re: [PATCH] D19451: [clang-tidy] New checker for redundant expressions.

2016-04-26 Thread Alexander Kornienko via cfe-commits
alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.

Awesome idea!

LG with a couple of nits.

In http://reviews.llvm.org/D19451#410064, @etienneb wrote:

> Tested over LLVM code, no false positives.
>
> Two catches:
>  http://reviews.llvm.org/D19460
>  http://reviews.llvm.org/D19451


The second link refers to this revision ;)



Comment at: clang-tidy/misc/RedundantExpressionCheck.cpp:21
@@ +20,3 @@
+
+static bool AreIdenticalExpr(const Expr *Left, const Expr *Right) {
+  if (!Left || !Right)

This is to some degree similar to comparing `llvm::FoldingSetNodeIDs` created 
using `Stmt::Profile`. However it's only useful to check for identical 
expressions and won't work, if you're going to extend this to equivalent 
expressions.


Comment at: docs/clang-tidy/checks/misc-redundant-expression.rst:10
@@ +9,3 @@
+  * redundant,
+  * always be true,
+  * always be false,

Please enclose `true` and `false` in backquotes.


http://reviews.llvm.org/D19451



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


Re: [PATCH] D19451: [clang-tidy] New checker for redundant expressions.

2016-04-26 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

BTW, have you seen the `alpha.core.IdenticalExpr` static analyzer checker?


http://reviews.llvm.org/D19451



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


Re: [PATCH] D17416: [libcxx] Reorganize locale extension fallbacks. NFCI

2016-04-26 Thread Ben Craig via cfe-commits
bcraig added a comment.

ping @danalbert, @mclow.lists


http://reviews.llvm.org/D17416



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


Re: [PATCH] D19497: [clang-tidy] Enhance misc-suspicious-string-compare to move down false-positives.

2016-04-26 Thread Alexander Kornienko via cfe-commits
alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.

LG with one nit.



Comment at: clang-tidy/misc/SuspiciousStringCompareCheck.cpp:215
@@ +214,3 @@
+  if (Result.Nodes.getNodeAs("suspicious-operator")) {
+diag(Call->getLocStart(), "suspicious usage of function %0") << Decl;
+  }

Can you make the message more specific? It should make it clear, what exactly 
is "suspicious" in this usage.


http://reviews.llvm.org/D19497



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


Re: [PATCH] D18694: [ClangTidy] Add an 'explain-checks' option to diagnose where each checks comes from.

2016-04-26 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

Sorry for the long delay. This is getting closer. A few more comments though.



Comment at: clang-tidy/ClangTidyOptions.cpp:224
@@ +223,3 @@
+  DefaultOptionsProvider::getRawOptions(FileName);
+  OptionsSource CommandLineOptions =
+  OptionsSource(OverrideOptions, OptionsSourceTypeCheckCommandLineOption);

s/ = \s*OptionsSource//


Comment at: clang-tidy/ClangTidyOptions.cpp:235
@@ +234,3 @@
+if (Iter != CachedOptions.end()) {
+  RawOptions.push_back(Iter->second);
+  break;

This seems to be changing the caching logic. Consider this directory structure:

  a/
 .clang-tidy
 b/
c/

And consequtive `getRawOptions` calls with:
  1. "a/some_file"
  2. "a/b/c/some_file"
  3. "a/b/some_file".

What would happen previously:
  1. after call 1 `CachedOptions` would contain an entry for "a"
  2. call 2 would find an entry for "a" and copy it for "a/b" and "a/b/c"
  3. call 3 would just use the cache entry for "a/b"

Now step 2 doesn't copy the cache entry to "a/b" and "a/b/c".

Is there any specific reason to change this? This is benign given that the 
lookups happen in memory, but then the code needs to be consistent and avoid 
replicating cache entries to intermediate directories in all cases.


Comment at: clang-tidy/ClangTidyOptions.h:102
@@ -101,1 +101,3 @@
 public:
+  static constexpr char OptionsSourceTypeDefaultBinary[] = "clang-tidy binary";
+  static constexpr char OptionsSourceTypeCheckCommandLineOption[] =

As we figured out with another patch, `constexpr` is not supported by VS2013. 
Sorry for pushing you in a wrong direction.


Comment at: clang-tidy/ClangTidyOptions.h:115
@@ +114,3 @@
+  //
+  /// clang-tidy has 3 types of the sources (from low to top):
+  ///* clang-tidy binary

s/from low to top/in order of increasing priority/


Comment at: clang-tidy/ClangTidyOptions.h:117
@@ +116,3 @@
+  ///* clang-tidy binary
+  ///* '-config' commandline option or a specific configuration file
+  ///* '-checks' commandline option

This item should make it clear how a config file relates to the '-config' 
option in terms of priority. The easiest way to make the order clear is 
probably to split the item in two (and update the "3 types of the sources" 
above).


Comment at: clang-tidy/ClangTidyOptions.h:127
@@ -108,2 +126,3 @@
   /// specified \p FileName.
-  virtual ClangTidyOptions getOptions(llvm::StringRef FileName) = 0;
+  ClangTidyOptions getOptions(llvm::StringRef FileName) {
+ClangTidyOptions Result;

Let's move the implementation to the .cpp file. It's only used by a small 
fraction of translation units including this header, and it doesn't seem to be 
performance-critical to make this method inline.


Comment at: clang-tidy/ClangTidyOptions.h:145
@@ -121,4 +144,3 @@
   }
-  ClangTidyOptions getOptions(llvm::StringRef /*FileName*/) override {
-return DefaultOptions;
-  }
+  std::vector getRawOptions(
+  llvm::StringRef FileName) override;

clang-format?

A few more instances below.


Comment at: clang-tidy/ClangTidyOptions.h:161
@@ +160,3 @@
+const ClangTidyOptions );
+  std::vector getRawOptions(
+  llvm::StringRef FileName) override;

clang-format?


Comment at: clang-tidy/tool/ClangTidyMain.cpp:320
@@ +319,3 @@
+  if (ExplainConfig) {
+// FIXME: Figure out a more elegant way to show other ClangTidyOptions'
+// fields like ExtraArg.

"a more elegant way" seems to suggest that currently this already happens, but 
in a not elegant fashion. As far as I understand, we're not doing this at all ;)


http://reviews.llvm.org/D18694



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


Re: [PATCH] D18694: [ClangTidy] Add an 'explain-checks' option to diagnose where each checks comes from.

2016-04-26 Thread Haojian Wu via cfe-commits
hokein updated this revision to Diff 54996.
hokein marked an inline comment as done.
hokein added a comment.

- VS2013 doesn't support constexpr.
- Don't make test read external .clang-tidy file.


http://reviews.llvm.org/D18694

Files:
  clang-tidy/ClangTidyOptions.cpp
  clang-tidy/ClangTidyOptions.h
  clang-tidy/tool/ClangTidyMain.cpp
  test/clang-tidy/Inputs/explain-config/.clang-tidy
  test/clang-tidy/explain-checks.cpp

Index: test/clang-tidy/explain-checks.cpp
===
--- /dev/null
+++ test/clang-tidy/explain-checks.cpp
@@ -0,0 +1,14 @@
+// RUN: clang-tidy -checks=-*,modernize-use-nullptr -explain-config | FileCheck --check-prefix=CHECK-MESSAGE1 %s
+// RUN: clang-tidy -config="{Checks: '-*,modernize-use-nullptr'}" -explain-config | FileCheck --check-prefix=CHECK-MESSAGE2 %s
+// RUN: clang-tidy -checks=modernize-use-nullptr -config="{Checks: '-*,modernize-use-nullptr'}" -explain-config | FileCheck --check-prefix=CHECK-MESSAGE3 %s
+// RUN: clang-tidy -checks=modernize-use-nullptr -config="{Checks: '-*,-modernize-use-nullptr'}" %S/Inputs/explain-config/a.cc -explain-config | FileCheck --check-prefix=CHECK-MESSAGE4 %s
+// RUN: clang-tidy -checks=modernize-use-nullptr -config="{Checks: '-*,modernize-*'}" -explain-config | FileCheck --check-prefix=CHECK-MESSAGE5 %s
+// RUN: clang-tidy -config="{Checks: 'modernize-use-nullptr'}" -explain-config | FileCheck --check-prefix=CHECK-MESSAGE6 %s
+// RUN: clang-tidy -explain-config %S/Inputs/explain-config/a.cc | grep "'modernize-use-nullptr' is enabled in the %S/Inputs/explain-config/.clang-tidy."
+
+// CHECK-MESSAGE1: 'modernize-use-nullptr' is enabled in the command-line option '-checks'.
+// CHECK-MESSAGE2: 'modernize-use-nullptr' is enabled in the command-line option '-config'.
+// CHECK-MESSAGE3: 'modernize-use-nullptr' is enabled in the command-line option '-checks'.
+// CHECK-MESSAGE4: 'modernize-use-nullptr' is enabled in the command-line option '-checks'.
+// CHECK-MESSAGE5: 'modernize-use-nullptr' is enabled in the command-line option '-checks'.
+// CHECK-MESSAGE6: 'clang-analyzer-unix.API' is enabled in the clang-tidy binary.
Index: test/clang-tidy/Inputs/explain-config/.clang-tidy
===
--- /dev/null
+++ test/clang-tidy/Inputs/explain-config/.clang-tidy
@@ -0,0 +1 @@
+Checks: '-*,modernize-use-nullptr'
Index: clang-tidy/tool/ClangTidyMain.cpp
===
--- clang-tidy/tool/ClangTidyMain.cpp
+++ clang-tidy/tool/ClangTidyMain.cpp
@@ -128,6 +128,12 @@
 )"),
 cl::init(false), cl::cat(ClangTidyCategory));
 
+static cl::opt ExplainConfig("explain-config", cl::desc(R"(
+for each enabled check explains, where it is enabled, i.e. in clang-tidy binary,
+command line or a specific configuration file.
+)"),
+   cl::init(false), cl::cat(ClangTidyCategory));
+
 static cl::opt Config("config", cl::desc(R"(
 Specifies a configuration in YAML/JSON format:
   -config="{Checks: '*',
@@ -280,11 +286,10 @@
   if (!Config.empty()) {
 if (llvm::ErrorOr ParsedConfig =
 parseConfiguration(Config)) {
-  return llvm::make_unique(
-  GlobalOptions, ClangTidyOptions::getDefaults()
- .mergeWith(DefaultOptions)
- .mergeWith(*ParsedConfig)
- .mergeWith(OverrideOptions));
+  return llvm::make_unique(
+  GlobalOptions,
+  ClangTidyOptions::getDefaults().mergeWith(DefaultOptions),
+  *ParsedConfig, OverrideOptions);
 } else {
   llvm::errs() << "Error: invalid configuration specified.\n"
<< ParsedConfig.getError().message() << "\n";
@@ -311,6 +316,23 @@
   ClangTidyOptions EffectiveOptions = OptionsProvider->getOptions(FileName);
   std::vector EnabledChecks = getCheckNames(EffectiveOptions);
 
+  if (ExplainConfig) {
+// FIXME: Figure out a more elegant way to show other ClangTidyOptions'
+// fields like ExtraArg.
+std::vector
+RawOptions = OptionsProvider->getRawOptions(FileName);
+for (const std::string  : EnabledChecks) {
+  for (auto It = RawOptions.rbegin(); It != RawOptions.rend(); ++It) {
+if (It->first.Checks && GlobList(*It->first.Checks).contains(Check)) {
+  llvm::outs() << "'" << Check << "' is enabled in the " << It->second
+   << ".\n";
+  break;
+}
+  }
+}
+return 0;
+  }
+
   if (ListChecks) {
 llvm::outs() << "Enabled checks:";
 for (auto CheckName : EnabledChecks)
Index: clang-tidy/ClangTidyOptions.h
===
--- clang-tidy/ClangTidyOptions.h
+++ clang-tidy/ClangTidyOptions.h
@@ -99,14 +99,35 @@
 /// \brief Abstract interface for retrieving various ClangTidy options.
 class ClangTidyOptionsProvider {
 

  1   2   >