Re: [PATCH] D17761: Added applyAllReplacementsAndFormat that works for multiple files.

2016-03-02 Thread Manuel Klimek via cfe-commits
klimek added a comment.

Ok, after thinking about it a bit, here is a new plan:

- get rid of applyAllReplacementsAndFormat (in all its forms)
- implement a formatRewrittenCode(Rewriter&, ...); as Daniel wants libFormat to 
stay file focused, we can put that into non-core libTooling; it'll figure out 
what to reformat from the rewriter state

That should leave us with a set of single purpose functions we can nicely 
combine.


http://reviews.llvm.org/D17761



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


[clang-tools-extra] r262470 - [clang-tidy] Make 'modernize-pass-by-value' fix work on header files.

2016-03-02 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Wed Mar  2 03:01:25 2016
New Revision: 262470

URL: http://llvm.org/viewvc/llvm-project?rev=262470&view=rev
Log:
[clang-tidy] Make 'modernize-pass-by-value' fix work on header files.

Reviewers: alexfh

Subscribers: jbcoe, cfe-commits

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

Added:
clang-tools-extra/trunk/test/clang-tidy/Inputs/modernize-pass-by-value/

clang-tools-extra/trunk/test/clang-tidy/Inputs/modernize-pass-by-value/header.h
clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value-header.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/modernize/PassByValueCheck.cpp

Modified: clang-tools-extra/trunk/clang-tidy/modernize/PassByValueCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/PassByValueCheck.cpp?rev=262470&r1=262469&r2=262470&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/PassByValueCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/PassByValueCheck.cpp Wed Mar  
2 03:01:25 2016
@@ -208,11 +208,12 @@ void PassByValueCheck::check(const Match
<< FixItHint::CreateInsertion(
   Initializer->getLParenLoc().getLocWithOffset(1), "std::move(");
 
-  auto Insertion =
-  Inserter->CreateIncludeInsertion(SM.getMainFileID(), "utility",
-   /*IsAngled=*/true);
-  if (Insertion.hasValue())
-Diag << Insertion.getValue();
+  if (auto IncludeFixit = Inserter->CreateIncludeInsertion(
+  Result.SourceManager->getFileID(Initializer->getSourceLocation()),
+  "utility",
+  /*IsAngled=*/true)) {
+Diag << *IncludeFixit;
+  }
 }
 
 } // namespace modernize

Added: 
clang-tools-extra/trunk/test/clang-tidy/Inputs/modernize-pass-by-value/header.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/Inputs/modernize-pass-by-value/header.h?rev=262470&view=auto
==
--- 
clang-tools-extra/trunk/test/clang-tidy/Inputs/modernize-pass-by-value/header.h 
(added)
+++ 
clang-tools-extra/trunk/test/clang-tidy/Inputs/modernize-pass-by-value/header.h 
Wed Mar  2 03:01:25 2016
@@ -0,0 +1,7 @@
+class ThreadId {
+};
+
+struct A {
+  A(const ThreadId &tid) : threadid(tid) {}
+  ThreadId threadid;
+};

Added: 
clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value-header.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value-header.cpp?rev=262470&view=auto
==
--- clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value-header.cpp 
(added)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value-header.cpp 
Wed Mar  2 03:01:25 2016
@@ -0,0 +1,8 @@
+// RUN: cp %S/Inputs/modernize-pass-by-value/header.h %T/pass-by-value-header.h
+// RUN: clang-tidy %s -checks='-*,modernize-pass-by-value' -header-filter='.*' 
-fix -- -std=c++11 -I %T | FileCheck %s -check-prefix=CHECK-MESSAGES 
-implicit-check-not="{{warning|error}}:"
+// RUN: FileCheck -input-file=%T/pass-by-value-header.h %s 
-check-prefix=CHECK-FIXES
+
+#include "pass-by-value-header.h"
+// CHECK-MESSAGES: :5:5: warning: pass by value and use std::move 
[modernize-pass-by-value]
+// CHECK-FIXES: #include 
+// CHECK-FIXES: A(ThreadId tid) : threadid(std::move(tid)) {}


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


Re: [PATCH] D17756: [clang-tidy] Make 'modernize-pass-by-value' fix work on header files.

2016-03-02 Thread Haojian Wu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL262470: [clang-tidy] Make 'modernize-pass-by-value' fix work 
on header files. (authored by hokein).

Changed prior to commit:
  http://reviews.llvm.org/D17756?vs=49463&id=49588#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D17756

Files:
  clang-tools-extra/trunk/clang-tidy/modernize/PassByValueCheck.cpp
  
clang-tools-extra/trunk/test/clang-tidy/Inputs/modernize-pass-by-value/header.h
  clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value-header.cpp

Index: clang-tools-extra/trunk/clang-tidy/modernize/PassByValueCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/modernize/PassByValueCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/modernize/PassByValueCheck.cpp
@@ -208,11 +208,12 @@
<< FixItHint::CreateInsertion(
   Initializer->getLParenLoc().getLocWithOffset(1), "std::move(");
 
-  auto Insertion =
-  Inserter->CreateIncludeInsertion(SM.getMainFileID(), "utility",
-   /*IsAngled=*/true);
-  if (Insertion.hasValue())
-Diag << Insertion.getValue();
+  if (auto IncludeFixit = Inserter->CreateIncludeInsertion(
+  Result.SourceManager->getFileID(Initializer->getSourceLocation()),
+  "utility",
+  /*IsAngled=*/true)) {
+Diag << *IncludeFixit;
+  }
 }
 
 } // namespace modernize
Index: 
clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value-header.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value-header.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value-header.cpp
@@ -0,0 +1,8 @@
+// RUN: cp %S/Inputs/modernize-pass-by-value/header.h %T/pass-by-value-header.h
+// RUN: clang-tidy %s -checks='-*,modernize-pass-by-value' -header-filter='.*' 
-fix -- -std=c++11 -I %T | FileCheck %s -check-prefix=CHECK-MESSAGES 
-implicit-check-not="{{warning|error}}:"
+// RUN: FileCheck -input-file=%T/pass-by-value-header.h %s 
-check-prefix=CHECK-FIXES
+
+#include "pass-by-value-header.h"
+// CHECK-MESSAGES: :5:5: warning: pass by value and use std::move 
[modernize-pass-by-value]
+// CHECK-FIXES: #include 
+// CHECK-FIXES: A(ThreadId tid) : threadid(std::move(tid)) {}
Index: 
clang-tools-extra/trunk/test/clang-tidy/Inputs/modernize-pass-by-value/header.h
===
--- 
clang-tools-extra/trunk/test/clang-tidy/Inputs/modernize-pass-by-value/header.h
+++ 
clang-tools-extra/trunk/test/clang-tidy/Inputs/modernize-pass-by-value/header.h
@@ -0,0 +1,7 @@
+class ThreadId {
+};
+
+struct A {
+  A(const ThreadId &tid) : threadid(tid) {}
+  ThreadId threadid;
+};


Index: clang-tools-extra/trunk/clang-tidy/modernize/PassByValueCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/modernize/PassByValueCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/modernize/PassByValueCheck.cpp
@@ -208,11 +208,12 @@
<< FixItHint::CreateInsertion(
   Initializer->getLParenLoc().getLocWithOffset(1), "std::move(");
 
-  auto Insertion =
-  Inserter->CreateIncludeInsertion(SM.getMainFileID(), "utility",
-   /*IsAngled=*/true);
-  if (Insertion.hasValue())
-Diag << Insertion.getValue();
+  if (auto IncludeFixit = Inserter->CreateIncludeInsertion(
+  Result.SourceManager->getFileID(Initializer->getSourceLocation()),
+  "utility",
+  /*IsAngled=*/true)) {
+Diag << *IncludeFixit;
+  }
 }
 
 } // namespace modernize
Index: clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value-header.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value-header.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value-header.cpp
@@ -0,0 +1,8 @@
+// RUN: cp %S/Inputs/modernize-pass-by-value/header.h %T/pass-by-value-header.h
+// RUN: clang-tidy %s -checks='-*,modernize-pass-by-value' -header-filter='.*' -fix -- -std=c++11 -I %T | FileCheck %s -check-prefix=CHECK-MESSAGES -implicit-check-not="{{warning|error}}:"
+// RUN: FileCheck -input-file=%T/pass-by-value-header.h %s -check-prefix=CHECK-FIXES
+
+#include "pass-by-value-header.h"
+// CHECK-MESSAGES: :5:5: warning: pass by value and use std::move [modernize-pass-by-value]
+// CHECK-FIXES: #include 
+// CHECK-FIXES: A(ThreadId tid) : threadid(std::move(tid)) {}
Index: clang-tools-extra/trunk/test/clang-tidy/Inputs/modernize-pass-by-value/header.h
===
--- clang-tools-extra/trunk/test/clang-tidy/Inputs/modernize-pass-by-value/header.h
+++ clang-tools-extra/trunk/test/clang-tidy/Inputs/modernize-pass-by-value/header.h
@@ -0,0 +1,7 @@
+class ThreadId {
+};
+
+struct A {
+  A(co

r262471 - [CLANG] [AVX512] [BUILTIN] Adding PSRAV

2016-03-02 Thread Michael Zuckerman via cfe-commits
Author: mzuckerm
Date: Wed Mar  2 03:05:46 2016
New Revision: 262471

URL: http://llvm.org/viewvc/llvm-project?rev=262471&view=rev
Log:
[CLANG] [AVX512] [BUILTIN] Adding PSRAV

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


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

Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=262471&r1=262470&r2=262471&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Wed Mar  2 03:05:46 2016
@@ -1678,6 +1678,13 @@ TARGET_BUILTIN(__builtin_ia32_psrlq128_m
 TARGET_BUILTIN(__builtin_ia32_psrlq256_mask, 
"V4LLiV4LLiV2LLiV4LLiUc","","avx512vl")
 TARGET_BUILTIN(__builtin_ia32_psrlqi128_mask, 
"V2LLiV2LLiIiV2LLiUc","","avx512vl")
 TARGET_BUILTIN(__builtin_ia32_psrlqi256_mask, 
"V4LLiV4LLiIiV4LLiUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_psrav32hi_mask, 
"V32sV32sV32sV32sUi","","avx512bw")
+TARGET_BUILTIN(__builtin_ia32_psrav16hi_mask, 
"V16sV16sV16sV16sUs","","avx512bw,avx512vl")
+TARGET_BUILTIN(__builtin_ia32_psrav8hi_mask, 
"V8sV8sV8sV8sUc","","avx512bw,avx512vl")
+TARGET_BUILTIN(__builtin_ia32_psrav4si_mask, "V4iV4iV4iV4iUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_psrav8si_mask, "V8iV8iV8iV8iUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_psravq128_mask, 
"V2LLiV2LLiV2LLiV2LLiUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_psravq256_mask, 
"V4LLiV4LLiV4LLiV4LLiUc","","avx512vl")
 
 #undef BUILTIN
 #undef TARGET_BUILTIN

Modified: cfe/trunk/lib/Headers/avx512bwintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512bwintrin.h?rev=262471&r1=262470&r2=262471&view=diff
==
--- cfe/trunk/lib/Headers/avx512bwintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512bwintrin.h Wed Mar  2 03:05:46 2016
@@ -1749,6 +1749,35 @@ _mm512_maskz_srlv_epi16 (__mmask32 __U,
   (__mmask32) __U);
 }
 
+static __inline__ __m512i __DEFAULT_FN_ATTRS
+_mm512_srav_epi16 (__m512i __A, __m512i __B)
+{
+  return (__m512i) __builtin_ia32_psrav32hi_mask ((__v32hi) __A,
+  (__v32hi) __B,
+  (__v32hi)
+  _mm512_setzero_hi (),
+  (__mmask32) -1);
+}
+
+static __inline__ __m512i __DEFAULT_FN_ATTRS
+_mm512_mask_srav_epi16 (__m512i __W, __mmask32 __U, __m512i __A,
+  __m512i __B)
+{
+  return (__m512i) __builtin_ia32_psrav32hi_mask ((__v32hi) __A,
+  (__v32hi) __B,
+  (__v32hi) __W,
+  (__mmask32) __U);
+}
+
+static __inline__ __m512i __DEFAULT_FN_ATTRS
+_mm512_maskz_srav_epi16 (__mmask32 __U, __m512i __A, __m512i __B)
+{
+  return (__m512i) __builtin_ia32_psrav32hi_mask ((__v32hi) __A,
+  (__v32hi) __B,
+  (__v32hi)
+  _mm512_setzero_hi (),
+  (__mmask32) __U);
+}
 #undef __DEFAULT_FN_ATTRS
 
 #endif

Modified: cfe/trunk/lib/Headers/avx512vlbwintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512vlbwintrin.h?rev=262471&r1=262470&r2=262471&view=diff
==
--- cfe/trunk/lib/Headers/avx512vlbwintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512vlbwintrin.h Wed Mar  2 03:05:46 2016
@@ -2655,6 +2655,66 @@ _mm_maskz_srlv_epi16 (__mmask8 __U, __m1
  (__mmask8) __U);
 }
 
+static __inline__ __m256i __DEFAULT_FN_ATTRS
+_mm256_srav_epi16 (__m256i __A, __m256i __B)
+{
+  return (__m256i) __builtin_ia32_psrav16hi_mask ((__v16hi) __A,
+  (__v16hi) __B,
+  (__v16hi)
+  _mm256_setzero_si256 (),
+  (__mmask16) -1);
+}
+
+static __inline__ __m256i __DEFAULT_FN_ATTRS
+_mm256_mask_srav_epi16 (__m256i __W, __mmask16 __U, __m256i __A,
+  __m256i __B)
+{
+  return (__m256i) __builtin_ia32_psrav16hi_mask ((__v16hi) __A,
+  (__v16hi) __B,
+  (__v16hi) __W,
+  (__mmask16) __U);
+}
+
+static __inline__ __m256i __DEFAULT_FN_ATTRS
+_mm256_maskz_srav_epi16 (__mmask16 __U, __m256i __A, __m256i __B)
+{
+  return (__m256i) __builtin_ia32_psrav16hi_mask ((__v16hi) __A,
+  (__v16hi) __B,
+  (__v16hi)
+  _mm256_setzero_si256 (),
+  (__mmask16) __U);
+}
+
+static __inline__ __m128i __DEFAULT_FN_ATTRS
+_mm_srav_epi16 (__m128i __A, __m128i __B)
+{
+  return (__m128i) __builtin_ia32_psrav8hi_mask ((__v8hi) __A,
+ (__v8hi) __B,
+ (__v8hi)
+ _mm_setzero_hi (),
+ (__mmask8) -1);
+}
+
+static __inline__ __m128i __DEFAULT_FN_ATTRS
+_

Re: [PATCH] D17547: [OpenMP] Add support for multidimensional array sections in map clause SEMA.

2016-03-02 Thread Alexey Bataev via cfe-commits
ABataev added inline comments.


Comment at: include/clang/Basic/DiagnosticSemaKinds.td:7787-7789
@@ -7786,5 +7786,5 @@
   "bit fields cannot be used to specify storage in a map clause">;
-def err_omp_array_section_in_rightmost_expression : Error<
-  "array section can only be associated with the rightmost variable in a map 
clause expression">;
+def err_cannot_prove_omp_array_section_specifies_contiguous_storage : Error<
+  "can't prove employed array section specifies contiguous storage">;
 def err_omp_union_type_not_allowed : Error<
   "mapped storage cannot be derived from a union">;

'can't prove' again is not good for an error. Still think this must be a 
warning or you don't need to diagnose anything if you can't make a decision. In 
this case, you must consider specified array section as a contiguous.


Comment at: lib/Sema/SemaOpenMP.cpp:9016-9023
@@ +9015,10 @@
+
+  // If this is an array subscript, it refers to the whole size if the size of
+  // the dimension is constant and equals 1. Also, an array section assumes the
+  // format of an array subscript if no colon is used.
+  if (isa(E) || (OASE && OASE->getColonLoc().isInvalid())) 
{
+if (auto *ATy = dyn_cast(BaseQTy.getTypePtr()))
+  return ATy->getSize().getSExtValue() == 1;
+return false;
+  }
+

I agree with all your examples except for this one
```
#pragma omp target map(a[:][arg:])
```
For me, this is valid if you can't prove it is non-contiguous. You should 
consider this as a possibly contiguous. If it is not contiguous, it is user's 
problem. But if he needs to use such form of expression, I don't see why we 
should not allow him to do this.


http://reviews.llvm.org/D17547



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


Re: [PATCH] D17547: [OpenMP] Add support for multidimensional array sections in map clause SEMA.

2016-03-02 Thread Alexey Bataev via cfe-commits
ABataev added inline comments.


Comment at: lib/Sema/SemaOpenMP.cpp:9016-9023
@@ +9015,10 @@
+
+  // If this is an array subscript, it refers to the whole size if the size of
+  // the dimension is constant and equals 1. Also, an array section assumes the
+  // format of an array subscript if no colon is used.
+  if (isa(E) || (OASE && OASE->getColonLoc().isInvalid())) 
{
+if (auto *ATy = dyn_cast(BaseQTy.getTypePtr()))
+  return ATy->getSize().getSExtValue() == 1;
+return false;
+  }
+

ABataev wrote:
> I agree with all your examples except for this one
> ```
> #pragma omp target map(a[:][arg:])
> ```
> For me, this is valid if you can't prove it is non-contiguous. You should 
> consider this as a possibly contiguous. If it is not contiguous, it is user's 
> problem. But if he needs to use such form of expression, I don't see why we 
> should not allow him to do this.
I don't think this code
```
const int n = 0;
arr[n:]
```
will work in C. Try to add a test for C, not C++. In C 'const' does not mean 
you can evaluate the value of the variable during compilation.


http://reviews.llvm.org/D17547



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


[PATCH] D17799: Serialize `#pragma comment`.

2016-03-02 Thread Nico Weber via cfe-commits
thakis created this revision.
thakis added a reviewer: rnk.
thakis added a subscriber: cfe-commits.

`#pragma comment` was handled by Sema calling a function on ASTConsumer, and 
CodeGen then implementing this function and writing things to its output.

Instead, introduce a PragmaCommentDecl AST node and hang one off the 
TranslationUnitDecl for every `#pragma comment` line, and then use the regular 
serialization machinery. (Since PragmaCommentDecl has codegen relevance, it's 
eagerly deserialized.)

http://reviews.llvm.org/D17799

Files:
  include/clang/AST/ASTConsumer.h
  include/clang/AST/Decl.h
  include/clang/AST/RecursiveASTVisitor.h
  include/clang/Basic/DeclNodes.td
  include/clang/Basic/PragmaKinds.h
  include/clang/Frontend/MultiplexConsumer.h
  include/clang/Sema/Sema.h
  include/clang/Serialization/ASTBitCodes.h
  lib/AST/ASTContext.cpp
  lib/AST/ASTDumper.cpp
  lib/AST/Decl.cpp
  lib/AST/DeclBase.cpp
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/CodeGenAction.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/ModuleBuilder.cpp
  lib/Frontend/MultiplexConsumer.cpp
  lib/Parse/ParsePragma.cpp
  lib/Sema/SemaAttr.cpp
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  lib/Serialization/ASTCommon.cpp
  lib/Serialization/ASTReaderDecl.cpp
  lib/Serialization/ASTWriterDecl.cpp
  test/PCH/pragma-comment.c
  tools/libclang/CIndex.cpp

Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -5584,6 +5584,7 @@
   case Decl::OMPThreadPrivate:
   case Decl::ObjCTypeParam:
   case Decl::BuiltinTemplate:
+  case Decl::PragmaComment:
 return C;
 
   // Declaration kinds that don't make any sense here, but are
Index: test/PCH/pragma-comment.c
===
--- test/PCH/pragma-comment.c
+++ test/PCH/pragma-comment.c
@@ -0,0 +1,24 @@
+// Test this without pch.
+// RUN: %clang_cc1 %s -Wunknown-pragmas -Werror -triple x86_64-pc-win32 -fms-extensions -emit-llvm -include %s -o - | FileCheck %s
+
+// Test with pch.
+// RUN: %clang_cc1 %s -Wunknown-pragmas -Werror -triple x86_64-pc-win32 -fms-extensions -emit-pch -o %t
+// RUN: %clang_cc1 %s -Wunknown-pragmas -Werror -triple x86_64-pc-win32 -fms-extensions -emit-llvm -include-pch %t -o - | FileCheck %s
+
+// The first run line creates a pch, and since at that point HEADER is not
+// defined, the only thing contained in the pch is the pragma. The second line
+// then includes that pch, so HEADER is defined and the actual code is compiled.
+// The check then makes sure that the pragma is in effect in the file that
+// includes the pch.
+
+// expected-no-diagnostics
+
+#ifndef HEADER
+#define HEADER
+#pragma comment(lib, "foo.lib")
+
+#else
+
+// CHECK: "/DEFAULTLIB:foo.lib"
+
+#endif
Index: lib/Serialization/ASTWriterDecl.cpp
===
--- lib/Serialization/ASTWriterDecl.cpp
+++ lib/Serialization/ASTWriterDecl.cpp
@@ -49,6 +49,7 @@
 void Visit(Decl *D);
 
 void VisitDecl(Decl *D);
+void VisitPragmaCommentDecl(PragmaCommentDecl *D);
 void VisitTranslationUnitDecl(TranslationUnitDecl *D);
 void VisitNamedDecl(NamedDecl *D);
 void VisitLabelDecl(LabelDecl *LD);
@@ -315,6 +316,16 @@
   }
 }
 
+void ASTDeclWriter::VisitPragmaCommentDecl(PragmaCommentDecl *D) {
+  StringRef Arg = D->getArg();
+  Record.push_back(Arg.size());
+  VisitDecl(D);
+  Writer.AddSourceLocation(D->getLocStart(), Record);
+  Record.push_back(D->getCommentKind());
+  Writer.AddString(Arg, Record);
+  Code = serialization::DECL_PRAGMA_COMMENT;
+}
+
 void ASTDeclWriter::VisitTranslationUnitDecl(TranslationUnitDecl *D) {
   llvm_unreachable("Translation units aren't directly serialized");
 }
Index: lib/Serialization/ASTReaderDecl.cpp
===
--- lib/Serialization/ASTReaderDecl.cpp
+++ lib/Serialization/ASTReaderDecl.cpp
@@ -68,6 +68,10 @@
   return Reader.ReadDeclID(F, R, I);
 }
 
+std::string ReadString(const RecordData &R, unsigned &I) {
+  return Reader.ReadString(R, I);
+}
+
 void ReadDeclIDList(SmallVectorImpl &IDs) {
   for (unsigned I = 0, Size = Record[Idx++]; I != Size; ++I)
 IDs.push_back(ReadDeclID(Record, Idx));
@@ -238,6 +242,7 @@
 }
 
 void VisitDecl(Decl *D);
+void VisitPragmaCommentDecl(PragmaCommentDecl *D);
 void VisitTranslationUnitDecl(TranslationUnitDecl *TU);
 void VisitNamedDecl(NamedDecl *ND);
 void VisitLabelDecl(LabelDecl *LD);
@@ -538,6 +543,15 @@
   }
 }
 
+void ASTDeclReader::VisitPragmaCommentDecl(PragmaCommentDecl *D) {
+  VisitDecl(D);
+  D->setLocation(ReadSourceLocation(Record, Idx));
+  D->CommentKind = (PragmaMSCommentKind)Record[Idx++];
+  std::string Arg = ReadString(Record, Idx);
+  memcpy(D->getTrailingObjects(), Arg.data(), Arg.size());
+  D->getTrailingObjects()[Arg.size()] = '\0';
+}
+
 void ASTDeclReader::VisitTran

Re: [PATCH] D17019: [OpenMP] Code generation for teams - kernel launching

2016-03-02 Thread Alexey Bataev via cfe-commits
ABataev added inline comments.


Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:256-296
@@ -255,26 +255,43 @@
 /// \brief RAII for emitting code of OpenMP constructs.
 class InlinedOpenMPRegionRAII {
   CodeGenFunction &CGF;
+  /// \brief Saves the varaibles that were forced to be local in the current
+  /// inlined region.
+  SmallVector ForcedLocalVars;
 
 public:
-  /// \brief Constructs region for combined constructs.
+  /// \brief Constructs inlined region. Mostly used for combined constructs. If
+  /// a captured statement is provided it also ensures the captured variables
+  /// are all defined in the scope of the enclosing function. This is typical
+  /// used for regions that make local instances of global variables, e.g.
+  /// target regions.
   /// \param CodeGen Code generation sequence for combined directives. Includes
   /// a list of functions used for code generation of implicitly inlined
   /// regions.
   InlinedOpenMPRegionRAII(CodeGenFunction &CGF, const RegionCodeGenTy &CodeGen,
-  OpenMPDirectiveKind Kind, bool HasCancel)
+  OpenMPDirectiveKind Kind, bool HasCancel,
+  const CapturedStmt *CS)
   : CGF(CGF) {
 // Start emission for the construct.
 CGF.CapturedStmtInfo = new CGOpenMPInlinedRegionInfo(
 CGF.CapturedStmtInfo, CodeGen, Kind, HasCancel);
+
+// Ensures that all the captures are local in the current inlined region.
+if (CS)
+  CGF.StartOpenMPInlinedCapturedRegion(*CS, ForcedLocalVars);
   }
 
   ~InlinedOpenMPRegionRAII() {
+// Restore the local variable information if we have anything forced in 
this
+// inlined region.
+if (!ForcedLocalVars.empty())
+  CGF.CloseOpenMPInlinedCapturedRegion(ForcedLocalVars);
+
 // Restore original CapturedStmtInfo only if we're done with code emission.
 auto *OldCSI =
 cast(CGF.CapturedStmtInfo)->getOldCSI();
 delete CGF.CapturedStmtInfo;
 CGF.CapturedStmtInfo = OldCSI;
   }
 };
 

Do not modify this one, add a new one like this:
```
static void EmptyCodeGen(CodeGenFunction &) {
  llvm_unreachable("No codegen for expressions");
}
/// \brief API for generation of expressions captured in OpenMP region in outer
/// scope.
class CGOpenMPOuterExprInfo : public CGOpenMPInlinedRegionInfo {
public:
  CGOpenMPOuterExprInfo(CodeGenFunction &CGF)
  : CGOpenMPInlinedRegionInfo(CGF.CapturedStmtInfo, CodeGen, OMPD_unknown,
  /*HasCancel=*/false),
CGF(CGF) {}

  /// \brief Lookup the captured field decl for a variable.
  const FieldDecl *lookup(const VarDecl *VD) const override {
if (auto *FD = CGOpenMPInlinedRegionInfo::lookup(VD))
  return FD;
if (!VD->isLocalVarDeclOrParm() && Mapped.count(VD) == 0) {
  auto It =
  PrivateGlobals.insert(new CodeGenFunction::OMPPrivateScope(CGF));
  DeclRefExpr DRE(const_cast(VD),
  /*RefersToEnclosingVariableOrCapture=*/false,
  VD->getType().getNonReferenceType(), VK_LValue,
  SourceLocation());
  It.first->addPrivate(
  VD, [&]() -> Address { return CGF.EmitLValue(&DRE).getAddress(); });
  (void)It.first->Privatize();
  Mapped.insert(VD);
}
return nullptr;
  }

  /// \brief Emit the captured statement body.
  void EmitBody(CodeGenFunction &CGF, const Stmt *S) override {
llvm_unreachable("No body for expressions");
  }

  /// \brief Get a variable or parameter for storing global thread id
  /// inside OpenMP construct.
  const VarDecl *getThreadIDVariable() const override {
llvm_unreachable("No thread id for expressions");
  }

  /// \brief Get the name of the capture helper.
  StringRef getHelperName() const override {
llvm_unreachable("No helper name for expressions");
  }

  static bool classof(const CGCapturedStmtInfo *Info) {
llvm_unreachable("No helper name for expressions");
  }

  virtual ~CGOpenMPOuterExprInfo() {
for (auto *Scope : PrivateGlobals)
  delete Scope;
PrivateGlobals.clear();
  }

private:
  CodeGenFunction &CGF;
  /// Private scopes for each captured global variables.
  llvm::SmallPtrSet PrivateGlobals;
  SmallSet Mapped;
};
```


http://reviews.llvm.org/D17019



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


r262481 - [CLANG] [AVX512] [BUILTIN] Adding PSRA{W|WI}{128|256|512}.

2016-03-02 Thread Michael Zuckerman via cfe-commits
Author: mzuckerm
Date: Wed Mar  2 06:06:06 2016
New Revision: 262481

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

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


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

Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=262481&r1=262480&r2=262481&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Wed Mar  2 06:06:06 2016
@@ -1685,6 +1685,12 @@ TARGET_BUILTIN(__builtin_ia32_psrav4si_m
 TARGET_BUILTIN(__builtin_ia32_psrav8si_mask, "V8iV8iV8iV8iUc","","avx512vl")
 TARGET_BUILTIN(__builtin_ia32_psravq128_mask, 
"V2LLiV2LLiV2LLiV2LLiUc","","avx512vl")
 TARGET_BUILTIN(__builtin_ia32_psravq256_mask, 
"V4LLiV4LLiV4LLiV4LLiUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_psraw512_mask, "V32sV32sV8sV32sUi","","avx512bw")
+TARGET_BUILTIN(__builtin_ia32_psrawi512_mask, "V32sV32sIiV32sUi","","avx512bw")
+TARGET_BUILTIN(__builtin_ia32_psraw128_mask, 
"V8sV8sV8sV8sUc","","avx512bw,avx512vl")
+TARGET_BUILTIN(__builtin_ia32_psraw256_mask, 
"V16sV16sV8sV16sUs","","avx512bw,avx512vl")
+TARGET_BUILTIN(__builtin_ia32_psrawi128_mask, 
"V8sV8sIiV8sUc","","avx512bw,avx512vl")
+TARGET_BUILTIN(__builtin_ia32_psrawi256_mask, 
"V16sV16sIiV16sUs","","avx512bw,avx512vl")
 
 #undef BUILTIN
 #undef TARGET_BUILTIN

Modified: cfe/trunk/lib/Headers/avx512bwintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512bwintrin.h?rev=262481&r1=262480&r2=262481&view=diff
==
--- cfe/trunk/lib/Headers/avx512bwintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512bwintrin.h Wed Mar  2 06:06:06 2016
@@ -1778,6 +1778,57 @@ _mm512_maskz_srav_epi16 (__mmask32 __U,
   _mm512_setzero_hi (),
   (__mmask32) __U);
 }
+
+static __inline__ __m512i __DEFAULT_FN_ATTRS
+_mm512_sra_epi16 (__m512i __A, __m128i __B)
+{
+ return (__m512i) __builtin_ia32_psraw512_mask ((__v32hi) __A,
+ (__v8hi) __B,
+ (__v32hi)
+ _mm512_setzero_hi (),
+ (__mmask32) -1);
+}
+
+static __inline__ __m512i __DEFAULT_FN_ATTRS
+_mm512_mask_sra_epi16 (__m512i __W, __mmask32 __U, __m512i __A,
+   __m128i __B)
+{
+  return (__m512i) __builtin_ia32_psraw512_mask ((__v32hi) __A,
+ (__v8hi) __B,
+ (__v32hi) __W,
+(__mmask32) __U);
+}
+
+static __inline__ __m512i __DEFAULT_FN_ATTRS
+_mm512_maskz_sra_epi16 (__mmask32 __U, __m512i __A, __m128i __B)
+{
+  return (__m512i) __builtin_ia32_psraw512_mask ((__v32hi) __A,
+ (__v8hi) __B,
+ (__v32hi)
+ _mm512_setzero_hi (),
+(__mmask32) __U);
+}
+
+#define _mm512_srai_epi16( __A, __B) __extension__ ({ \
+__builtin_ia32_psrawi512_mask ((__v32hi)( __A),( __B),\
+  (__v32hi)\
+  _mm512_setzero_hi (),\
+  (__mmask32) -2);\
+})
+
+#define _mm512_mask_srai_epi16( __W, __U, __A, __B) __extension__ ({ \
+__builtin_ia32_psrawi512_mask ((__v32hi)( __A),( __B),\
+  (__v32hi)( __W),\
+  (__mmask32)( __U));\
+})
+
+#define _mm512_maskz_srai_epi16( __U, __A, __B) __extension__ ({ \
+__builtin_ia32_psrawi512_mask ((__v32hi)( __A),( __B),\
+  (__v32hi)\
+  _mm512_setzero_hi (),\
+  (__mmask32)( __U));\
+})
+
 #undef __DEFAULT_FN_ATTRS
 
 #endif

Modified: cfe/trunk/lib/Headers/avx512vlbwintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512vlbwintrin.h?rev=262481&r1=262480&r2=262481&view=diff
==
--- cfe/trunk/lib/Headers/avx512vlbwintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512vlbwintrin.h Wed Mar  2 06:06:06 2016
@@ -2715,6 +2715,72 @@ _mm_maskz_srav_epi16 (__mmask8 __U, __m1
  (__mmask8) __U);
 }
 
+static __inline__ __m128i __DEFAULT_FN_ATTRS
+_mm_mask_sra_epi16 (__m128i __W, __mmask8 __U, __m128i __A,
+__m128i __B)
+{
+  return (__m128i) __builtin_ia32_psraw128_mask ((__v8hi) __A,
+ (__v8hi) __B,
+ (__v8hi) __W,
+ (__mmask8) __U);
+}
+
+static __inline__ __m128i __DEFAULT_FN_ATTRS
+_mm_maskz_sra_epi16 (__mmask8 __U, __m128i __A, __m128i __B)
+{
+  return (__m128i) __builtin_ia32_psraw128_mask ((__v8hi) __A,
+ (__v8hi) __B,
+ (__v8hi)
+ _mm_setzero_si128 (),
+ (__mmask8) __U);
+}
+
+static __inline__ __m256i __DEFAULT_FN_ATTRS
+_mm256_mask_sra_epi16 (__m256i __W, __mmask16 __U, __m256i __A,
+  

Re: [PATCH] D15120: Add support for __float128 type to be used by targets that support it

2016-03-02 Thread Nemanja Ivanovic via cfe-commits
nemanjai added inline comments.


Comment at: lib/Sema/SemaOverload.cpp:1658
@@ -1657,1 +1657,3 @@
   } else if (FromType->isRealFloatingType() && ToType->isRealFloatingType()) {
+// FIXME: disable conversions between long double and __float128 if
+// their representation is different until there is back end support

hubert.reinterpretcast wrote:
> The update to check the case where the representation of `long double` is the 
> same as that of `double` is missing.
Yes, I missed this. Thanks for noticing. I'll update the comment and change the 
body of the if to:

if (&S.Context.getFloatTypeSemantics(FromType) !=
&S.Context.getFloatTypeSemantics(ToType)) {
  bool Float128AndLongDouble = ((FromType == S.Context.Float128Ty &&
ToType == S.Context.LongDoubleTy) ||
   (FromType == S.Context.LongDoubleTy &&
ToType == S.Context.Float128Ty));
  if (Float128AndLongDouble &&
  (&S.Context.getFloatTypeSemantics(S.Context.LongDoubleTy) !=
   &llvm::APFloat::IEEEdouble))
return false;
}


Comment at: lib/Sema/SemaOverload.cpp:1966-1967
@@ -1955,4 +1965,4 @@
   // C99 6.3.1.5p1:
   //   When a float is promoted to double or long double, or a
   //   double is promoted to long double [...].
   if (!getLangOpts().CPlusPlus &&

hubert.reinterpretcast wrote:
> @rsmith; this is the discussion on floating-point "promotions" in "C" that I 
> was asking you about.
I can certainly remove this if the agreement is that I should do so.


Repository:
  rL LLVM

http://reviews.llvm.org/D15120



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


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

2016-03-02 Thread Dmitry Polukhin via cfe-commits
DmitryPolukhin added a comment.

Aaron, friendly ping, please take a look!


http://reviews.llvm.org/D17567



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


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

2016-03-02 Thread Aaron Ballman via cfe-commits
I'll definitely take a look as I have the chance. In WG21 meetings all
week, so it may likely be sometime next week.

~Aaron

On Wed, Mar 2, 2016 at 7:51 AM, Dmitry Polukhin
 wrote:
> DmitryPolukhin added a comment.
>
> Aaron, friendly ping, please take a look!
>
>
> http://reviews.llvm.org/D17567
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D16628: clang-cl: support __cdecl-on-struct anachronism

2016-03-02 Thread Stephan Bergmann via cfe-commits
sberg added a comment.

friendly ping


http://reviews.llvm.org/D16628



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


Re: [PATCH] D15267: For MS ABI, emit dllexport friend functions defined inline in class

2016-03-02 Thread Stephan Bergmann via cfe-commits
sberg added a comment.

friendly ping


http://reviews.llvm.org/D15267



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


Re: [PATCH] D17722: Make sure SLocEntry is an expansion before using getExpansion() method in SourceManager.

2016-03-02 Thread Haojian Wu via cfe-commits
hokein abandoned this revision.
hokein added a comment.

In http://reviews.llvm.org/D17722#365267, @bkramer wrote:

> This doesn't have a test case. Also I don't understand why this is the 
> correct fix. If someone is calling one of those method with a file 
> SourceLocation (as opposed to a macro SourceLocation) they should stop doing 
> that.


After a more deep investigation, I think the bug isn't related to SourceManger 
now. I'm closing this as in favor of http://reviews.llvm.org/D17805 .


Repository:
  rL LLVM

http://reviews.llvm.org/D17722



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


Re: [PATCH] D17805: [clang-tidy] Fix an assertion failure of "SLocEntry::getExpansion()" when IncludeInserter handles macro header file.

2016-03-02 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! Thank you for finding and fixing this!



Comment at: clang-tidy/utils/IncludeInserter.cpp:23
@@ -21,3 +22,3 @@
   void InclusionDirective(SourceLocation HashLocation,
-  const Token & /*include_token*/,
+  const Token & IncludeToken,
   StringRef FileNameRef, bool IsAngled,

clang-format, please.


Repository:
  rL LLVM

http://reviews.llvm.org/D17805



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


[clang-tools-extra] r262484 - [clang-tidy] Fix an assertion failure of "SLocEntry::getExpansion()" when IncludeInserter handles macro header file.

2016-03-02 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Wed Mar  2 08:12:17 2016
New Revision: 262484

URL: http://llvm.org/viewvc/llvm-project?rev=262484&view=rev
Log:
[clang-tidy] Fix an assertion failure of "SLocEntry::getExpansion()" when 
IncludeInserter handles macro header file.

Summary: Also Fixes PR24749.

Reviewers: alexfh

Subscribers: cfe-commits

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

Added:

clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value-marco-header.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/utils/IncludeInserter.cpp

Modified: clang-tools-extra/trunk/clang-tidy/utils/IncludeInserter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/utils/IncludeInserter.cpp?rev=262484&r1=262483&r2=262484&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/utils/IncludeInserter.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/utils/IncludeInserter.cpp Wed Mar  2 
08:12:17 2016
@@ -8,6 +8,7 @@
 
//===--===//
 
 #include "IncludeInserter.h"
+#include "clang/Lex/Token.h"
 
 namespace clang {
 namespace tidy {
@@ -19,14 +20,14 @@ public:
   // Implements PPCallbacks::InclusionDerective(). Records the names and source
   // locations of the inclusions in the main source file being processed.
   void InclusionDirective(SourceLocation HashLocation,
-  const Token & /*include_token*/,
+  const Token & IncludeToken,
   StringRef FileNameRef, bool IsAngled,
   CharSourceRange FileNameRange,
   const FileEntry * /*IncludedFile*/,
   StringRef /*SearchPath*/, StringRef /*RelativePath*/,
   const Module * /*ImportedModule*/) override {
 Inserter->AddInclude(FileNameRef, IsAngled, HashLocation,
- FileNameRange.getEnd());
+ IncludeToken.getEndLoc());
   }
 
 private:

Added: 
clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value-marco-header.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value-marco-header.cpp?rev=262484&view=auto
==
--- 
clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value-marco-header.cpp
 (added)
+++ 
clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value-marco-header.cpp
 Wed Mar  2 08:12:17 2016
@@ -0,0 +1,16 @@
+// RUN: %check_clang_tidy %s modernize-pass-by-value %t -- -- -std=c++11 
-isystem %S/Inputs/Headers
+
+// CHECK-FIXES: #include 
+
+#define HEADER <./a.h>
+#include HEADER
+
+struct A {
+};
+
+struct B {
+  B(const A &a) : a(a) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: pass by value and use std::move 
[modernize-pass-by-value]
+// CHECK-FIXES: B(A a) : a(std::move(a)) {}
+  A a;
+};


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


Re: [PATCH] D17805: [clang-tidy] Fix an assertion failure of "SLocEntry::getExpansion()" when IncludeInserter handles macro header file.

2016-03-02 Thread Haojian Wu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL262484: [clang-tidy] Fix an assertion failure of 
"SLocEntry::getExpansion()" when… (authored by hokein).

Changed prior to commit:
  http://reviews.llvm.org/D17805?vs=49611&id=49613#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D17805

Files:
  clang-tools-extra/trunk/clang-tidy/utils/IncludeInserter.cpp
  
clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value-marco-header.cpp

Index: clang-tools-extra/trunk/clang-tidy/utils/IncludeInserter.cpp
===
--- clang-tools-extra/trunk/clang-tidy/utils/IncludeInserter.cpp
+++ clang-tools-extra/trunk/clang-tidy/utils/IncludeInserter.cpp
@@ -8,6 +8,7 @@
 
//===--===//
 
 #include "IncludeInserter.h"
+#include "clang/Lex/Token.h"
 
 namespace clang {
 namespace tidy {
@@ -19,14 +20,14 @@
   // Implements PPCallbacks::InclusionDerective(). Records the names and source
   // locations of the inclusions in the main source file being processed.
   void InclusionDirective(SourceLocation HashLocation,
-  const Token & /*include_token*/,
+  const Token & IncludeToken,
   StringRef FileNameRef, bool IsAngled,
   CharSourceRange FileNameRange,
   const FileEntry * /*IncludedFile*/,
   StringRef /*SearchPath*/, StringRef /*RelativePath*/,
   const Module * /*ImportedModule*/) override {
 Inserter->AddInclude(FileNameRef, IsAngled, HashLocation,
- FileNameRange.getEnd());
+ IncludeToken.getEndLoc());
   }
 
 private:
Index: 
clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value-marco-header.cpp
===
--- 
clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value-marco-header.cpp
+++ 
clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value-marco-header.cpp
@@ -0,0 +1,16 @@
+// RUN: %check_clang_tidy %s modernize-pass-by-value %t -- -- -std=c++11 
-isystem %S/Inputs/Headers
+
+// CHECK-FIXES: #include 
+
+#define HEADER <./a.h>
+#include HEADER
+
+struct A {
+};
+
+struct B {
+  B(const A &a) : a(a) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: pass by value and use std::move 
[modernize-pass-by-value]
+// CHECK-FIXES: B(A a) : a(std::move(a)) {}
+  A a;
+};


Index: clang-tools-extra/trunk/clang-tidy/utils/IncludeInserter.cpp
===
--- clang-tools-extra/trunk/clang-tidy/utils/IncludeInserter.cpp
+++ clang-tools-extra/trunk/clang-tidy/utils/IncludeInserter.cpp
@@ -8,6 +8,7 @@
 //===--===//
 
 #include "IncludeInserter.h"
+#include "clang/Lex/Token.h"
 
 namespace clang {
 namespace tidy {
@@ -19,14 +20,14 @@
   // Implements PPCallbacks::InclusionDerective(). Records the names and source
   // locations of the inclusions in the main source file being processed.
   void InclusionDirective(SourceLocation HashLocation,
-  const Token & /*include_token*/,
+  const Token & IncludeToken,
   StringRef FileNameRef, bool IsAngled,
   CharSourceRange FileNameRange,
   const FileEntry * /*IncludedFile*/,
   StringRef /*SearchPath*/, StringRef /*RelativePath*/,
   const Module * /*ImportedModule*/) override {
 Inserter->AddInclude(FileNameRef, IsAngled, HashLocation,
- FileNameRange.getEnd());
+ IncludeToken.getEndLoc());
   }
 
 private:
Index: clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value-marco-header.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value-marco-header.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value-marco-header.cpp
@@ -0,0 +1,16 @@
+// RUN: %check_clang_tidy %s modernize-pass-by-value %t -- -- -std=c++11 -isystem %S/Inputs/Headers
+
+// CHECK-FIXES: #include 
+
+#define HEADER <./a.h>
+#include HEADER
+
+struct A {
+};
+
+struct B {
+  B(const A &a) : a(a) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: pass by value and use std::move [modernize-pass-by-value]
+// CHECK-FIXES: B(A a) : a(std::move(a)) {}
+  A a;
+};
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r262487 - test/Driver/cl-pch-errorhandling.cpp: Copy input file to a temporary

2016-03-02 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Wed Mar  2 08:26:59 2016
New Revision: 262487

URL: http://llvm.org/viewvc/llvm-project?rev=262487&view=rev
Log:
test/Driver/cl-pch-errorhandling.cpp: Copy input file to a temporary
location as we cannot assume the location of the input file to be
writable.

Modified:
cfe/trunk/test/Driver/cl-pch-errorhandling.cpp

Modified: cfe/trunk/test/Driver/cl-pch-errorhandling.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-pch-errorhandling.cpp?rev=262487&r1=262486&r2=262487&view=diff
==
--- cfe/trunk/test/Driver/cl-pch-errorhandling.cpp (original)
+++ cfe/trunk/test/Driver/cl-pch-errorhandling.cpp Wed Mar  2 08:26:59 2016
@@ -6,7 +6,8 @@
 // code generation, which makes this test require an x86 backend.
 // REQUIRES: x86-registered-target
 
-// RUN: not %clang_cl -internal-enable-pch -Werror /Yc%S/Inputs/pchfile.h 
/FI%S/Inputs/pchfile.h /c -DERR_HEADER -- %s 2>&1 \
+// RUN: cp %S/Inputs/pchfile.h %t.h
+// RUN: not %clang_cl -internal-enable-pch -Werror /Yc%t.h /FI%t.h /c 
-DERR_HEADER -- %s 2>&1 \
 // RUN:   | FileCheck %s
 
 // CHECK: nope1


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


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

2016-03-02 Thread Stephan Bergmann via cfe-commits
sberg added a subscriber: sberg.


Comment at: lib/Sema/SemaDeclAttr.cpp:4497
@@ +4496,3 @@
+static void handleAbiTagAttr(Sema &S, Decl *D, const AttributeList &Attr) {
+  SmallVector Tags;
+  for (unsigned I = 0, E = Attr.getNumArgs(); I != E; ++I) {

needs to be SmallVector with current trunk


http://reviews.llvm.org/D17567



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


[PATCH] D17808: [libclang] Link clang-tidy plugin into libclang if present.

2016-03-02 Thread Benjamin Kramer via cfe-commits
bkramer created this revision.
bkramer added a reviewer: klimek.
bkramer added a subscriber: cfe-commits.

This is a sad workaround for the lack of plugin support in libclang. Depends
on D17807, a tools-extra change that also contains the test case.

This is designed to be easy to remove again if libclang ever grows proper
plugin support.

http://reviews.llvm.org/D17808

Files:
  tools/libclang/CIndex.cpp
  tools/libclang/CMakeLists.txt

Index: tools/libclang/CMakeLists.txt
===
--- tools/libclang/CMakeLists.txt
+++ tools/libclang/CMakeLists.txt
@@ -47,6 +47,11 @@
   list(APPEND LIBS clangARCMigrate)
 endif ()
 
+if (CLANG_TOOL_EXTRA_BUILD)
+  add_definitions(-DCLANG_TOOL_EXTRA_BUILD)
+  list(APPEND LIBS clangTidyPlugin)
+endif ()
+
 find_library(DL_LIBRARY_PATH dl)
 if (DL_LIBRARY_PATH)
   list(APPEND LIBS dl)
Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -7930,3 +7930,10 @@
 OS << "--\n";
   }
 }
+
+#ifdef CLANG_TOOL_EXTRA_BUILD
+// This anchor is used to force the linker to link the clang-tidy plugin.
+extern volatile int ClangTidyPluginAnchorSource;
+static int LLVM_ATTRIBUTE_UNUSED ClangTidyPluginAnchorDestination =
+ClangTidyPluginAnchorSource;
+#endif


Index: tools/libclang/CMakeLists.txt
===
--- tools/libclang/CMakeLists.txt
+++ tools/libclang/CMakeLists.txt
@@ -47,6 +47,11 @@
   list(APPEND LIBS clangARCMigrate)
 endif ()
 
+if (CLANG_TOOL_EXTRA_BUILD)
+  add_definitions(-DCLANG_TOOL_EXTRA_BUILD)
+  list(APPEND LIBS clangTidyPlugin)
+endif ()
+
 find_library(DL_LIBRARY_PATH dl)
 if (DL_LIBRARY_PATH)
   list(APPEND LIBS dl)
Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -7930,3 +7930,10 @@
 OS << "--\n";
   }
 }
+
+#ifdef CLANG_TOOL_EXTRA_BUILD
+// This anchor is used to force the linker to link the clang-tidy plugin.
+extern volatile int ClangTidyPluginAnchorSource;
+static int LLVM_ATTRIBUTE_UNUSED ClangTidyPluginAnchorDestination =
+ClangTidyPluginAnchorSource;
+#endif
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D17807: [clang-tidy] Add "clang-tidy as a clang plugin" skeleton.

2016-03-02 Thread Benjamin Kramer via cfe-commits
bkramer created this revision.
bkramer added a reviewer: klimek.
bkramer added a subscriber: cfe-commits.

This doesn't really do much at the moment. You can load it via libclang
and set the -checks via an extra command line argument as illustrated in
the test case. Support for other options (including headers check) is
currently missing. Also when using this with libclang some checks may
not work with the precompiled preamble in place.

This can be used to easily show clang-tidy warnings in an editor
integration as all that's needed is adding command line flags that are
passed into libclang. Warnings and FixIts are exposed via the existing
CXDiagnostic machinery.

http://reviews.llvm.org/D17807

Files:
  clang-tidy/CMakeLists.txt
  clang-tidy/ClangTidyDiagnosticConsumer.h
  clang-tidy/plugin/CMakeLists.txt
  clang-tidy/plugin/ClangTidyPlugin.cpp
  test/clang-tidy/basic.cpp

Index: test/clang-tidy/basic.cpp
===
--- test/clang-tidy/basic.cpp
+++ test/clang-tidy/basic.cpp
@@ -1,4 +1,5 @@
 // RUN: clang-tidy %s -checks='-*,llvm-namespace-comment' -- | FileCheck %s
+// RUN: c-index-test -test-load-source-reparse 2 all %s -Xclang -add-plugin -Xclang clang-tidy -Xclang -plugin-arg-clang-tidy -Xclang -checks='-*,llvm-namespace-comment' 2>&1 | FileCheck %s
 
 namespace i {
 }
Index: clang-tidy/plugin/ClangTidyPlugin.cpp
===
--- /dev/null
+++ clang-tidy/plugin/ClangTidyPlugin.cpp
@@ -0,0 +1,122 @@
+//===- ClangTidyPlugin.cpp - clang-tidy as a clang plugin -===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "../ClangTidy.h"
+#include "../ClangTidyModule.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Frontend/FrontendPluginRegistry.h"
+#include "clang/Frontend/MultiplexConsumer.h"
+
+namespace clang {
+namespace tidy {
+
+/// The core clang tidy plugin action. This just provides the AST consumer and
+/// command line flag parsing for using clang-tidy as a clang plugin.
+class ClangTidyPluginAction : public PluginASTAction {
+  /// Wrapper to grant the context the same lifetime as the action. We use
+  /// MultiplexConsumer to avoid writing out all the forwarding methods.
+  class WrapConsumer : public MultiplexConsumer {
+std::unique_ptr Context;
+
+  public:
+WrapConsumer(std::unique_ptr Context,
+ std::vector> Consumer)
+: MultiplexConsumer(std::move(Consumer)), Context(std::move(Context)) {}
+  };
+
+public:
+  std::unique_ptr CreateASTConsumer(CompilerInstance &Compiler,
+ StringRef File) override {
+// Insert the current diagnostics engine.
+Context->setDiagnosticsEngine(&Compiler.getDiagnostics());
+
+// Create the AST consumer.
+ClangTidyASTConsumerFactory Factory(*Context);
+std::vector> Vec;
+Vec.push_back(Factory.CreateASTConsumer(Compiler, File));
+
+return llvm::make_unique(std::move(Context), std::move(Vec));
+  }
+
+  bool ParseArgs(const CompilerInstance &,
+ const std::vector &Args) override {
+ClangTidyGlobalOptions GlobalOptions;
+ClangTidyOptions DefaultOptions;
+ClangTidyOptions OverrideOptions;
+
+// Parse the extra command line args.
+// FIXME: This is very limited at the moment.
+for (StringRef Arg : Args)
+  if (Arg.startswith("-checks="))
+OverrideOptions.Checks = Arg.substr(strlen("-checks="));
+
+auto Options = llvm::make_unique(
+GlobalOptions, DefaultOptions, OverrideOptions);
+Context = llvm::make_unique(std::move(Options));
+return true;
+  }
+
+private:
+  std::unique_ptr Context;
+};
+} // namespace tidy
+} // namespace clang
+
+// This anchor is used to force the linker to link in the generated object file
+// and thus register the clang-tidy plugin.
+volatile int ClangTidyPluginAnchorSource = 0;
+
+static clang::FrontendPluginRegistry::Add
+X("clang-tidy", "clang-tidy");
+
+namespace clang {
+namespace tidy {
+
+// This anchor is used to force the linker to link the CERTModule.
+extern volatile int CERTModuleAnchorSource;
+static int LLVM_ATTRIBUTE_UNUSED CERTModuleAnchorDestination =
+CERTModuleAnchorSource;
+
+// This anchor is used to force the linker to link the LLVMModule.
+extern volatile int LLVMModuleAnchorSource;
+static int LLVM_ATTRIBUTE_UNUSED LLVMModuleAnchorDestination =
+LLVMModuleAnchorSource;
+
+// This anchor is used to force the linker to link the CppCoreGuidelinesModule.
+extern volatile int CppCoreGuidelinesModuleAnchorSource;
+static int LLVM_ATTRIBUTE_UNUSED CppCoreGuidelinesModuleAnchorDestination =
+CppCoreGuidelinesModuleAnchorSource;
+
+// This anchor is used to force the li

Re: [PATCH] D17807: [clang-tidy] Add "clang-tidy as a clang plugin" skeleton.

2016-03-02 Thread Manuel Klimek via cfe-commits
klimek accepted this revision.
klimek added a comment.
This revision is now accepted and ready to land.

LG. For now I don't see a better path forward.


http://reviews.llvm.org/D17807



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


Re: [PATCH] D17808: [libclang] Link clang-tidy plugin into libclang if present.

2016-03-02 Thread Manuel Klimek via cfe-commits
klimek accepted this revision.
klimek added a comment.
This revision is now accepted and ready to land.

lg


http://reviews.llvm.org/D17808



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


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

2016-03-02 Thread Dmitry Polukhin via cfe-commits
DmitryPolukhin updated this revision to Diff 49617.
DmitryPolukhin marked an inline comment as done.
DmitryPolukhin added a comment.

Rebase


http://reviews.llvm.org/D17567

Files:
  docs/ItaniumMangleAbiTags.rst
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/AttributeList.h
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/SemaCXX/attr-abi-tag-syntax.cpp

Index: test/SemaCXX/attr-abi-tag-syntax.cpp
===
--- /dev/null
+++ test/SemaCXX/attr-abi-tag-syntax.cpp
@@ -0,0 +1,43 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+namespace N1 {
+
+namespace __attribute__((__abi_tag__)) {}
+// expected-warning@-1 {{'abi_tag' attribute on non-inline namespace ignored}}
+
+namespace N __attribute__((__abi_tag__)) {}
+// expected-warning@-1 {{'abi_tag' attribute on non-inline namespace ignored}}
+
+} // namespace N1
+
+namespace N2 {
+
+inline namespace __attribute__((__abi_tag__)) {}
+// expected-warning@-1 {{'abi_tag' attribute on anonymous namespace ignored}}
+
+inline namespace N __attribute__((__abi_tag__)) {}
+// FIXME: remove this warning as soon as attribute fully supported.
+// expected-warning@-2 {{'__abi_tag__' attribute ignored}}
+
+} // namespcace N2
+
+__attribute__((abi_tag("B", "A"))) extern int a1;
+// FIXME: remove this warning as soon as attribute fully supported.
+// expected-warning@-2 {{'abi_tag' attribute ignored}}
+
+__attribute__((abi_tag("A", "B"))) extern int a1;
+// expected-note@-1 {{previous declaration is here}}
+// FIXME: remove this warning as soon as attribute fully supported.
+// expected-warning@-3 {{'abi_tag' attribute ignored}}
+
+__attribute__((abi_tag("A", "C"))) extern int a1;
+// expected-error@-1 {{'abi_tag' C missing in original declaration}}
+// FIXME: remove this warning as soon as attribute fully supported.
+// expected-warning@-3 {{'abi_tag' attribute ignored}}
+
+extern int a2;
+// expected-note@-1 {{previous declaration is here}}
+__attribute__((abi_tag("A")))extern int a2;
+// expected-error@-1 {{cannot add 'abi_tag' attribute in redeclaration}}
+// FIXME: remove this warning as soon as attribute fully supported.
+// expected-warning@-3 {{'abi_tag' attribute ignored}}
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -4493,6 +4493,42 @@
   Attr.getRange(), S.Context, Attr.getAttributeSpellingListIndex()));
 }
 
+static void handleAbiTagAttr(Sema &S, Decl *D, const AttributeList &Attr) {
+  SmallVector Tags;
+  for (unsigned I = 0, E = Attr.getNumArgs(); I != E; ++I) {
+StringRef Tag;
+if (!S.checkStringLiteralArgumentAttr(Attr, I, Tag))
+  return;
+Tags.push_back(Tag);
+  }
+
+  if (const auto *NS = dyn_cast(D)) {
+if (!NS->isInline()) {
+  S.Diag(Attr.getLoc(), diag::warn_attr_abi_tag_namespace) << 0;
+  return;
+}
+if (NS->isAnonymousNamespace()) {
+  S.Diag(Attr.getLoc(), diag::warn_attr_abi_tag_namespace) << 1;
+  return;
+}
+if (Attr.getNumArgs() == 0)
+  Tags.push_back(NS->getName());
+  } else if (!checkAttributeAtLeastNumArgs(S, Attr, 1))
+return;
+
+  // Store tags sorted and without duplicates.
+  std::sort(Tags.begin(), Tags.end());
+  Tags.erase(std::unique(Tags.begin(), Tags.end()), Tags.end());
+
+  D->addAttr(::new (S.Context)
+ AbiTagAttr(Attr.getRange(), S.Context, Tags.data(), Tags.size(),
+Attr.getAttributeSpellingListIndex()));
+
+  // FIXME: remove this warning as soon as mangled part is ready.
+  S.Diag(Attr.getRange().getBegin(), diag::warn_attribute_ignored)
+<< Attr.getName();
+}
+
 static void handleARMInterruptAttr(Sema &S, Decl *D,
const AttributeList &Attr) {
   // Check the attribute arguments.
@@ -5500,6 +5536,9 @@
   case AttributeList::AT_Thread:
 handleDeclspecThreadAttr(S, D, Attr);
 break;
+  case AttributeList::AT_AbiTag:
+handleAbiTagAttr(S, D, Attr);
+break;
 
   // Thread safety attributes:
   case AttributeList::AT_AssertExclusiveLock:
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -2398,6 +2398,24 @@
 }
   }
 
+  // Re-declaration cannot add abi_tag's.
+  if (const auto *NewAbiTagAttr = New->getAttr()) {
+if (const auto *OldAbiTagAttr = Old->getAttr()) {
+  for (const auto &NewTag : NewAbiTagAttr->tags()) {
+if (std::find(OldAbiTagAttr->tags_begin(), OldAbiTagAttr->tags_end(),
+  NewTag) == OldAbiTagAttr->tags_end()) {
+  Diag(NewAbiTagAttr->getLocation(),
+   diag::err_new_abi_tag_on_redeclaration)
+  << NewTag;
+  Diag(OldAbiTagAttr->getLocation(), diag::note_previous_declaration);
+}
+  }
+} el

Re: [PATCH] D17761: Added applyAllReplacementsAndFormat that works for multiple files.

2016-03-02 Thread Eric Liu via cfe-commits
ioeric updated this revision to Diff 49619.
ioeric added a comment.

- Removed all applyAllReplacementsAndFormat(*); added formatRewrittenCode in 
clangTooling.


http://reviews.llvm.org/D17761

Files:
  include/clang/Basic/SourceManager.h
  include/clang/Format/Format.h
  include/clang/Tooling/Core/Replacement.h
  include/clang/Tooling/ReplacementsFormat.h
  lib/Format/CMakeLists.txt
  lib/Format/Format.cpp
  lib/Tooling/CMakeLists.txt
  lib/Tooling/Core/Replacement.cpp
  lib/Tooling/ReplacementsFormat.cpp
  unittests/Format/FormatTest.cpp
  unittests/Tooling/CMakeLists.txt
  unittests/Tooling/RefactoringTest.cpp

Index: unittests/Tooling/RefactoringTest.cpp
===
--- unittests/Tooling/RefactoringTest.cpp
+++ unittests/Tooling/RefactoringTest.cpp
@@ -18,11 +18,13 @@
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/LangOptions.h"
 #include "clang/Basic/SourceManager.h"
+#include "clang/Format/Format.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/FrontendAction.h"
 #include "clang/Frontend/TextDiagnosticPrinter.h"
 #include "clang/Rewrite/Core/Rewriter.h"
 #include "clang/Tooling/Refactoring.h"
+#include "clang/Tooling/ReplacementsFormat.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/Support/Path.h"
@@ -166,6 +168,42 @@
   EXPECT_EQ("z", Context.getRewrittenText(IDz));
 }
 
+TEST_F(ReplacementTest, MultipleFilesReplaceAndFormat) {
+  // Column limit is 20.
+  std::string Code1 = "Long *a =\n"
+  "new Long();\n"
+  "long x = 1;";
+  std::string Expected1 = "auto a = new Long();\n"
+  "long x =\n"
+  "12345678901;";
+  std::string Code2 = "int x = 123;\n"
+  "int y = 0;";
+  std::string Expected2 = "int x =\n"
+  "1234567890123;\n"
+  "int y = 10;";
+  FileID ID1 = Context.createInMemoryFile("format_1.cpp", Code1);
+  FileID ID2 = Context.createInMemoryFile("format_2.cpp", Code2);
+
+  tooling::Replacements Replaces;
+  // Scrambled the order of replacements.
+  Replaces.insert(tooling::Replacement(
+  Context.Sources, Context.getLocation(ID2, 1, 12), 0, "4567890123"));
+  Replaces.insert(tooling::Replacement(
+  Context.Sources, Context.getLocation(ID1, 1, 1), 6, "auto "));
+  Replaces.insert(tooling::Replacement(
+  Context.Sources, Context.getLocation(ID2, 2, 9), 1, "10"));
+  Replaces.insert(tooling::Replacement(
+  Context.Sources, Context.getLocation(ID1, 3, 10), 1, "12345678901"));
+
+  format::FormatStyle Style = format::getLLVMStyle();
+  Style.ColumnLimit = 20; // Set column limit to 20 to increase readibility.
+
+  EXPECT_TRUE(applyAllReplacements(Replaces, Context.Rewrite));
+  EXPECT_TRUE(formatRewrittenCode(Context.Rewrite, Replaces, Style));
+  EXPECT_EQ(Expected1, Context.getRewrittenText(ID1));
+  EXPECT_EQ(Expected2, Context.getRewrittenText(ID2));
+}
+
 TEST(ShiftedCodePositionTest, FindsNewCodePosition) {
   Replacements Replaces;
   Replaces.insert(Replacement("", 0, 1, ""));
Index: unittests/Tooling/CMakeLists.txt
===
--- unittests/Tooling/CMakeLists.txt
+++ unittests/Tooling/CMakeLists.txt
@@ -24,6 +24,7 @@
   clangAST
   clangASTMatchers
   clangBasic
+  clangFormat
   clangFrontend
   clangLex
   clangRewrite
Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -11212,7 +11212,8 @@
 
   format::FormatStyle Style = format::getLLVMStyle();
   Style.ColumnLimit = 20; // Set column limit to 20 to increase readibility.
-  EXPECT_EQ(Expected, applyAllReplacementsAndFormat(Code, Replaces, Style));
+  EXPECT_EQ(Expected, applyAllReplacements(
+  Code, formatReplacements(Code, Replaces, Style)));
 }
 
 } // end namespace
Index: lib/Tooling/ReplacementsFormat.cpp
===
--- /dev/null
+++ lib/Tooling/ReplacementsFormat.cpp
@@ -0,0 +1,75 @@
+//===--- ReplacementFormat.cpp - Format code changed by replacemnts ---===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// \file
+// \brief This file implements functions that reformat code changed by
+// replacements.
+//
+//===--===//
+
+#include "clang/Tooling/ReplacementsFormat.h"
+
+#include "clang/Basic/SourceManager.h"
+#include "clang/Rewrite/Core/Rewriter.h"
+#include "clang/Tooling/Core/Replacement.h"
+
+namespace clang {
+namespace tooling {
+
+/// \brief Re

Re: [PATCH] D17761: Added applyAllReplacementsAndFormat that works for multiple files.

2016-03-02 Thread Eric Liu via cfe-commits
ioeric updated this revision to Diff 49620.
ioeric added a comment.

- Removed definitions that were forgotten.


http://reviews.llvm.org/D17761

Files:
  include/clang/Basic/SourceManager.h
  include/clang/Format/Format.h
  include/clang/Tooling/Core/Replacement.h
  include/clang/Tooling/ReplacementsFormat.h
  lib/Format/CMakeLists.txt
  lib/Format/Format.cpp
  lib/Tooling/CMakeLists.txt
  lib/Tooling/Core/Replacement.cpp
  lib/Tooling/ReplacementsFormat.cpp
  unittests/Format/FormatTest.cpp
  unittests/Tooling/CMakeLists.txt
  unittests/Tooling/RefactoringTest.cpp

Index: unittests/Tooling/RefactoringTest.cpp
===
--- unittests/Tooling/RefactoringTest.cpp
+++ unittests/Tooling/RefactoringTest.cpp
@@ -18,11 +18,13 @@
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/LangOptions.h"
 #include "clang/Basic/SourceManager.h"
+#include "clang/Format/Format.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/FrontendAction.h"
 #include "clang/Frontend/TextDiagnosticPrinter.h"
 #include "clang/Rewrite/Core/Rewriter.h"
 #include "clang/Tooling/Refactoring.h"
+#include "clang/Tooling/ReplacementsFormat.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/Support/Path.h"
@@ -166,6 +168,42 @@
   EXPECT_EQ("z", Context.getRewrittenText(IDz));
 }
 
+TEST_F(ReplacementTest, MultipleFilesReplaceAndFormat) {
+  // Column limit is 20.
+  std::string Code1 = "Long *a =\n"
+  "new Long();\n"
+  "long x = 1;";
+  std::string Expected1 = "auto a = new Long();\n"
+  "long x =\n"
+  "12345678901;";
+  std::string Code2 = "int x = 123;\n"
+  "int y = 0;";
+  std::string Expected2 = "int x =\n"
+  "1234567890123;\n"
+  "int y = 10;";
+  FileID ID1 = Context.createInMemoryFile("format_1.cpp", Code1);
+  FileID ID2 = Context.createInMemoryFile("format_2.cpp", Code2);
+
+  tooling::Replacements Replaces;
+  // Scrambled the order of replacements.
+  Replaces.insert(tooling::Replacement(
+  Context.Sources, Context.getLocation(ID2, 1, 12), 0, "4567890123"));
+  Replaces.insert(tooling::Replacement(
+  Context.Sources, Context.getLocation(ID1, 1, 1), 6, "auto "));
+  Replaces.insert(tooling::Replacement(
+  Context.Sources, Context.getLocation(ID2, 2, 9), 1, "10"));
+  Replaces.insert(tooling::Replacement(
+  Context.Sources, Context.getLocation(ID1, 3, 10), 1, "12345678901"));
+
+  format::FormatStyle Style = format::getLLVMStyle();
+  Style.ColumnLimit = 20; // Set column limit to 20 to increase readibility.
+
+  EXPECT_TRUE(applyAllReplacements(Replaces, Context.Rewrite));
+  EXPECT_TRUE(formatRewrittenCode(Context.Rewrite, Replaces, Style));
+  EXPECT_EQ(Expected1, Context.getRewrittenText(ID1));
+  EXPECT_EQ(Expected2, Context.getRewrittenText(ID2));
+}
+
 TEST(ShiftedCodePositionTest, FindsNewCodePosition) {
   Replacements Replaces;
   Replaces.insert(Replacement("", 0, 1, ""));
Index: unittests/Tooling/CMakeLists.txt
===
--- unittests/Tooling/CMakeLists.txt
+++ unittests/Tooling/CMakeLists.txt
@@ -24,6 +24,7 @@
   clangAST
   clangASTMatchers
   clangBasic
+  clangFormat
   clangFrontend
   clangLex
   clangRewrite
Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -11212,7 +11212,8 @@
 
   format::FormatStyle Style = format::getLLVMStyle();
   Style.ColumnLimit = 20; // Set column limit to 20 to increase readibility.
-  EXPECT_EQ(Expected, applyAllReplacementsAndFormat(Code, Replaces, Style));
+  EXPECT_EQ(Expected, applyAllReplacements(
+  Code, formatReplacements(Code, Replaces, Style)));
 }
 
 } // end namespace
Index: lib/Tooling/ReplacementsFormat.cpp
===
--- /dev/null
+++ lib/Tooling/ReplacementsFormat.cpp
@@ -0,0 +1,75 @@
+//===--- ReplacementFormat.cpp - Format code changed by replacemnts ---===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// \file
+// \brief This file implements functions that reformat code changed by
+// replacements.
+//
+//===--===//
+
+#include "clang/Tooling/ReplacementsFormat.h"
+
+#include "clang/Basic/SourceManager.h"
+#include "clang/Rewrite/Core/Rewriter.h"
+#include "clang/Tooling/Core/Replacement.h"
+
+namespace clang {
+namespace tooling {
+
+/// \brief Reformat code changed by \p Replaces in \p Rewrite.

Re: [PATCH] D17799: Serialize `#pragma comment`.

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

lgtm


http://reviews.llvm.org/D17799



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


Re: [PATCH] D16628: clang-cl: support __cdecl-on-struct anachronism

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

Thanks, lgtm.


http://reviews.llvm.org/D16628



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


Re: [PATCH] D15267: For MS ABI, emit dllexport friend functions defined inline in class

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

lgtm


http://reviews.llvm.org/D15267



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


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

2016-03-02 Thread Samuel Benzaquen via cfe-commits
sbenza created this revision.
sbenza added a reviewer: alexfh.
sbenza added a subscriber: cfe-commits.

Add check misc-dangling-handle to detect dangling references in value
handlers like std::experimental::string_view.
It provides a configuration option to specify other handle types that
should also be checked.

Right now it detects:
 - Construction from temporaries.
 - Assignment from temporaries.
 - Return statements from temporaries or locals.
 - Insertion into containers from temporaries.

http://reviews.llvm.org/D17811

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

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

Re: [PATCH] D15120: Add support for __float128 type to be used by targets that support it

2016-03-02 Thread Hubert Tong via cfe-commits
hubert.reinterpretcast added inline comments.


Comment at: lib/Sema/SemaOverload.cpp:1658
@@ -1657,1 +1657,3 @@
   } else if (FromType->isRealFloatingType() && ToType->isRealFloatingType()) {
+// FIXME: disable conversions between long double and __float128 if
+// their representation is different until there is back end support

nemanjai wrote:
> hubert.reinterpretcast wrote:
> > The update to check the case where the representation of `long double` is 
> > the same as that of `double` is missing.
> Yes, I missed this. Thanks for noticing. I'll update the comment and change 
> the body of the if to:
> 
> if (&S.Context.getFloatTypeSemantics(FromType) !=
> &S.Context.getFloatTypeSemantics(ToType)) {
>   bool Float128AndLongDouble = ((FromType == S.Context.Float128Ty &&
> ToType == S.Context.LongDoubleTy) ||
>(FromType == S.Context.LongDoubleTy &&
> ToType == S.Context.Float128Ty));
>   if (Float128AndLongDouble &&
>   (&S.Context.getFloatTypeSemantics(S.Context.LongDoubleTy) !=
>&llvm::APFloat::IEEEdouble))
> return false;
> }
I'm not a fan of redundant parentheses, but that looks okay.


Comment at: lib/Sema/SemaOverload.cpp:1966-1967
@@ -1955,4 +1965,4 @@
   // C99 6.3.1.5p1:
   //   When a float is promoted to double or long double, or a
   //   double is promoted to long double [...].
   if (!getLangOpts().CPlusPlus &&

nemanjai wrote:
> hubert.reinterpretcast wrote:
> > @rsmith; this is the discussion on floating-point "promotions" in "C" that 
> > I was asking you about.
> I can certainly remove this if the agreement is that I should do so.
Richard had requested to allow "promoting" `long double` to `__float128`, and 
at the time, implicitly converting from `long double` to `__float128` was 
something I was not convinced we should do at the time. At this time, I believe 
that adding this "promotion" is consistent with the rest of the patch; however, 
I am still not sure what this code is meant to implement (again, C11 does not 
have floating-point promotions).


Repository:
  rL LLVM

http://reviews.llvm.org/D15120



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


[PATCH] D17815: [libc++abi] Use fallback_malloc to allocate __cxa_eh_globals in case of dynamic memory exhaustion.

2016-03-02 Thread Igor Kudrin via cfe-commits
ikudrin created this revision.
ikudrin added reviewers: mclow.lists, howard.hinnant, EricWF.
ikudrin added a subscriber: cfe-commits.

Throwing an exception for the first time may lead to calling calloc to allocate 
memory for __cxa_eh_globals. If the memory pool at that moment is exhausted, it 
results in abnormal termination of the program.

This patch addresses the issue by using fallback_malloc in that case.

http://reviews.llvm.org/D17815

Files:
  libcxxabi/trunk/src/cxa_exception_storage.cpp
  libcxxabi/trunk/test/test_exception_storage_nodynmem.pass.cpp

Index: libcxxabi/trunk/test/test_exception_storage_nodynmem.pass.cpp
===
--- /dev/null
+++ libcxxabi/trunk/test/test_exception_storage_nodynmem.pass.cpp
@@ -0,0 +1,21 @@
+//===--- test_exception_storage_nodynmem.cpp 
--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include 
+
+// Override calloc to simulate exhaustion of dynamic memory
+void *calloc(size_t, size_t) { return 0; }
+
+int main(int argc, char *argv[]) {
+  try {
+throw 42;
+  } catch (...) {
+  }
+  return 0;
+}
Index: libcxxabi/trunk/src/cxa_exception_storage.cpp
===
--- libcxxabi/trunk/src/cxa_exception_storage.cpp
+++ libcxxabi/trunk/src/cxa_exception_storage.cpp
@@ -46,19 +46,38 @@
 
 #include 
 #include   // for calloc, free
+#include   // for memset
 #include "abort_message.h"
 
 //  In general, we treat all pthread errors as fatal.
 //  We cannot call std::terminate() because that will in turn
 //  call __cxa_get_globals() and cause infinite recursion.
 
 namespace __cxxabiv1 {
+
+#include "fallback_malloc.ipp"
+
+//  Allocate some memory from _somewhere_
+static void *do_calloc(size_t count, size_t size) {
+void *ptr = std::calloc(count, size);
+if (NULL == ptr) { // if calloc fails, fall back to emergency stash
+ptr = fallback_malloc(size * count);
+if (NULL != ptr)
+std::memset(ptr, 0, size * count);
+}
+return ptr;
+}
+
+static void do_free(void *ptr) {
+is_fallback_ptr(ptr) ? fallback_free(ptr) : std::free(ptr);
+}
+
 namespace {
 pthread_key_t  key_;
 pthread_once_t flag_ = PTHREAD_ONCE_INIT;
 
 void destruct_ (void *p) {
-std::free ( p );
+do_free ( p );
 if ( 0 != ::pthread_setspecific ( key_, NULL ) ) 
 abort_message("cannot zero out thread value for 
__cxa_get_globals()");
 }
@@ -77,7 +96,7 @@
 //  If this is the first time we've been asked for these globals, create 
them
 if ( NULL == retVal ) {
 retVal = static_cast<__cxa_eh_globals*>
-(std::calloc (1, sizeof (__cxa_eh_globals)));
+(do_calloc (1, sizeof (__cxa_eh_globals)));
 if ( NULL == retVal )
 abort_message("cannot allocate __cxa_eh_globals");
 if ( 0 != pthread_setspecific ( key_, retVal ) )


Index: libcxxabi/trunk/test/test_exception_storage_nodynmem.pass.cpp
===
--- /dev/null
+++ libcxxabi/trunk/test/test_exception_storage_nodynmem.pass.cpp
@@ -0,0 +1,21 @@
+//===--- test_exception_storage_nodynmem.cpp --===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include 
+
+// Override calloc to simulate exhaustion of dynamic memory
+void *calloc(size_t, size_t) { return 0; }
+
+int main(int argc, char *argv[]) {
+  try {
+throw 42;
+  } catch (...) {
+  }
+  return 0;
+}
Index: libcxxabi/trunk/src/cxa_exception_storage.cpp
===
--- libcxxabi/trunk/src/cxa_exception_storage.cpp
+++ libcxxabi/trunk/src/cxa_exception_storage.cpp
@@ -46,19 +46,38 @@
 
 #include 
 #include   // for calloc, free
+#include   // for memset
 #include "abort_message.h"
 
 //  In general, we treat all pthread errors as fatal.
 //  We cannot call std::terminate() because that will in turn
 //  call __cxa_get_globals() and cause infinite recursion.
 
 namespace __cxxabiv1 {
+
+#include "fallback_malloc.ipp"
+
+//  Allocate some memory from _somewhere_
+static void *do_calloc(size_t count, size_t size) {
+void *ptr = std::calloc(count, size);
+if (NULL == ptr) { // if calloc fails, fall back to emergency stash
+ptr = fallback_malloc(size * count);
+if (NULL != ptr)
+std::memset

Re: [PATCH] D17807: [clang-tidy] Add "clang-tidy as a clang plugin" skeleton.

2016-03-02 Thread David Blaikie via cfe-commits
Would this also be usable as a way to run clang-tidy checks as part of
normal compilation? (some things in clang-tidy aren't there because the FP
is too high to be a hard error on old codebases (but might be viable once a
codebase is able to be cleaned up (like several have been with LLVM)) or
because they're project specific (either stylistically, or because they're
about some project specific API))

On Wed, Mar 2, 2016 at 6:47 AM, Benjamin Kramer via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> bkramer created this revision.
> bkramer added a reviewer: klimek.
> bkramer added a subscriber: cfe-commits.
>
> This doesn't really do much at the moment. You can load it via libclang
> and set the -checks via an extra command line argument as illustrated in
> the test case. Support for other options (including headers check) is
> currently missing. Also when using this with libclang some checks may
> not work with the precompiled preamble in place.
>
> This can be used to easily show clang-tidy warnings in an editor
> integration as all that's needed is adding command line flags that are
> passed into libclang. Warnings and FixIts are exposed via the existing
> CXDiagnostic machinery.
>
> http://reviews.llvm.org/D17807
>
> Files:
>   clang-tidy/CMakeLists.txt
>   clang-tidy/ClangTidyDiagnosticConsumer.h
>   clang-tidy/plugin/CMakeLists.txt
>   clang-tidy/plugin/ClangTidyPlugin.cpp
>   test/clang-tidy/basic.cpp
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r262493 - Serialize `#pragma comment`.

2016-03-02 Thread Nico Weber via cfe-commits
Author: nico
Date: Wed Mar  2 11:28:48 2016
New Revision: 262493

URL: http://llvm.org/viewvc/llvm-project?rev=262493&view=rev
Log:
Serialize `#pragma comment`.

`#pragma comment` was handled by Sema calling a function on ASTConsumer, and
CodeGen then implementing this function and writing things to its output.

Instead, introduce a PragmaCommentDecl AST node and hang one off the
TranslationUnitDecl for every `#pragma comment` line, and then use the regular
serialization machinery. (Since PragmaCommentDecl has codegen relevance, it's
eagerly deserialized.)

http://reviews.llvm.org/D17799

Added:
cfe/trunk/include/clang/Basic/PragmaKinds.h
cfe/trunk/test/PCH/pragma-comment.c
Modified:
cfe/trunk/include/clang/AST/ASTConsumer.h
cfe/trunk/include/clang/AST/Decl.h
cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
cfe/trunk/include/clang/Basic/DeclNodes.td
cfe/trunk/include/clang/Frontend/MultiplexConsumer.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/include/clang/Serialization/ASTBitCodes.h
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/AST/ASTDumper.cpp
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/lib/AST/DeclBase.cpp
cfe/trunk/lib/CodeGen/CGDecl.cpp
cfe/trunk/lib/CodeGen/CodeGenAction.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/ModuleBuilder.cpp
cfe/trunk/lib/Frontend/MultiplexConsumer.cpp
cfe/trunk/lib/Parse/ParsePragma.cpp
cfe/trunk/lib/Sema/SemaAttr.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/lib/Serialization/ASTCommon.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
cfe/trunk/tools/libclang/CIndex.cpp

Modified: cfe/trunk/include/clang/AST/ASTConsumer.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTConsumer.h?rev=262493&r1=262492&r2=262493&view=diff
==
--- cfe/trunk/include/clang/AST/ASTConsumer.h (original)
+++ cfe/trunk/include/clang/AST/ASTConsumer.h Wed Mar  2 11:28:48 2016
@@ -94,22 +94,12 @@ public:
   /// The default implementation passes it to HandleTopLevelDecl.
   virtual void HandleImplicitImportDecl(ImportDecl *D);
 
-  /// \brief Handle a pragma or command line flag that appends to Linker
-  /// Options.  This exists to support Microsoft's
-  /// #pragma comment(linker, "/foo") and the frontend flag --linker-option=.
-  virtual void HandleLinkerOption(llvm::StringRef Opts) {}
-
   /// \brief Handle a pragma that emits a mismatch identifier and value to the
   /// object file for the linker to work with.  Currently, this only exists to
   /// support Microsoft's #pragma detect_mismatch.
   virtual void HandleDetectMismatch(llvm::StringRef Name,
 llvm::StringRef Value) {}
 
-  /// \brief Handle a dependent library created by a pragma in the source.
-  /// Currently this only exists to support Microsoft's
-  /// #pragma comment(lib, "/foo").
-  virtual void HandleDependentLibrary(llvm::StringRef Lib) {}
-
   /// CompleteTentativeDefinition - Callback invoked at the end of a 
translation
   /// unit to notify the consumer that the given tentative definition should be
   /// completed.

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=262493&r1=262492&r2=262493&view=diff
==
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Wed Mar  2 11:28:48 2016
@@ -23,6 +23,7 @@
 #include "clang/Basic/Linkage.h"
 #include "clang/Basic/Module.h"
 #include "clang/Basic/OperatorKinds.h"
+#include "clang/Basic/PragmaKinds.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/Support/Compiler.h"
@@ -103,6 +104,40 @@ public:
   }
 };
 
+/// \brief Represents a `#pragma comment` line. Always a child of
+/// TranslationUnitDecl.
+class PragmaCommentDecl final
+: public Decl,
+  private llvm::TrailingObjects {
+  virtual void anchor();
+
+  PragmaMSCommentKind CommentKind;
+
+  friend TrailingObjects;
+  friend class ASTDeclReader;
+  friend class ASTDeclWriter;
+
+  PragmaCommentDecl(TranslationUnitDecl *TU, SourceLocation CommentLoc,
+PragmaMSCommentKind CommentKind)
+  : Decl(PragmaComment, TU, CommentLoc), CommentKind(CommentKind) {}
+
+public:
+  static PragmaCommentDecl *Create(const ASTContext &C, TranslationUnitDecl 
*DC,
+   SourceLocation CommentLoc,
+   PragmaMSCommentKind CommentKind,
+   StringRef Arg);
+  static PragmaCommentDecl *CreateDeserialized(ASTContext &C, unsigned ID,
+   unsigned ArgSize);
+
+  PragmaMSCommentKind getCommentKind() const { return CommentKind; }
+
+  StringRef getArg() const { 

Re: [PATCH] D17799: Serialize `#pragma comment`.

2016-03-02 Thread Nico Weber via cfe-commits
thakis closed this revision.
thakis added a comment.

r262493, thanks!


http://reviews.llvm.org/D17799



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


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

2016-03-02 Thread Richard via cfe-commits
LegalizeAdulthood added a comment.

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


http://reviews.llvm.org/D16529



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


Re: [PATCH] D10013: Refactor: Simplify boolean conditional return statements in lib/Driver

2016-03-02 Thread Richard via cfe-commits
LegalizeAdulthood abandoned this revision.
LegalizeAdulthood added a comment.

Discarding due to inaction by reviewers.


http://reviews.llvm.org/D10013



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


[PATCH] D17820: Clang Code Completion Filtering

2016-03-02 Thread Bianca-Cristina Cristescu via cfe-commits
CrisCristescu created this revision.
CrisCristescu added reviewers: clang-c, benlangmuir, akyrtzi.
CrisCristescu added a subscriber: cfe-commits.
CrisCristescu set the repository for this revision to rL LLVM.
CrisCristescu changed the visibility of this Differential Revision from "Public 
(No Login Required)" to "All Users".

The patch is enabling filtering for code completion.

The stem upon which the filtering is to be done is known at the moment of 
parsing.
A get/set function for the completion stem has been added to the Token class in 
order to save the stem as the identifier of the code_complete token type. Once 
the token has been set, it has to be passed through to the SemaCodeCompleteX 
functions, which subsequently passes it to the HandleCodeCompletionResults and 
which passes it to the PrintingCodeCompleteConsumer::ProcessCodeCompleteResults 
where the actual filtering is happening.


Repository:
  rL LLVM

http://reviews.llvm.org/D17820

Files:
  include/clang/Lex/Token.h
  include/clang/Sema/CodeCompleteConsumer.h
  include/clang/Sema/Sema.h
  lib/Lex/Lexer.cpp
  lib/Parse/ParseDecl.cpp
  lib/Parse/ParseDeclCXX.cpp
  lib/Parse/ParseExpr.cpp
  lib/Parse/ParseExprCXX.cpp
  lib/Parse/ParseObjc.cpp
  lib/Parse/ParseStmt.cpp
  lib/Parse/Parser.cpp
  lib/Sema/CodeCompleteConsumer.cpp
  lib/Sema/SemaCodeComplete.cpp
  test/CodeCompletion/Filtering/filter-function-name.cpp
  test/CodeCompletion/Filtering/filter-member-access.cpp
  test/CodeCompletion/Filtering/filter-namespace.cpp
  test/CodeCompletion/Filtering/filter-ordinary-name.cpp

Index: test/CodeCompletion/Filtering/filter-ordinary-name.cpp
===
--- /dev/null
+++ test/CodeCompletion/Filtering/filter-ordinary-name.cpp
@@ -0,0 +1,8 @@
+int main() {
+	int myVariableOne;
+	int myVariableTwo;
+	myVar
+	// RUN: %clang_cc1 -code-completion-at=%s:4:10 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
+	// CHECK-CC1: COMPLETION: myVariableOne : [#int#]myVariableOne
+	// CHECK-CC1-NEXT: COMPLETION: myVariableTwo : [#int#]myVariableTwo
+}
\ No newline at end of file
Index: test/CodeCompletion/Filtering/filter-namespace.cpp
===
--- /dev/null
+++ test/CodeCompletion/Filtering/filter-namespace.cpp
@@ -0,0 +1,7 @@
+namespace outerspace {
+  namespace innerspace { }
+}
+
+using namespace outerspace::inner
+// RUN: %clang_cc1 -code-completion-at=%s:5:34 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
+// CHECK-CC1: COMPLETION: innerspace : innerspace
Index: test/CodeCompletion/Filtering/filter-member-access.cpp
===
--- /dev/null
+++ test/CodeCompletion/Filtering/filter-member-access.cpp
@@ -0,0 +1,24 @@
+class MyClass {
+private:
+  int anInteger;
+  double aDouble;
+
+public:
+  MyClass(int i, double d) {
+	anInteger = i;
+	aDouble = d;
+  }	
+  int getInt() { return anInteger; }
+  double getDouble() { return aDouble; }
+  void setInt(int value) { anInteger = value; }
+  void setDouble(double value) { aDouble = value; }
+};
+
+int main() {
+	MyClass* objectMyClass = new MyClass(5, 1.0);
+	objectMyClass->set
+	// RUN: %clang_cc1 -code-completion-at=%s:19:23 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
+	// CHECK-CC1: COMPLETION: setDouble : [#void#]setDouble(<#double value#>)
+	// CHECK-CC1-NEXT: COMPLETION: setInt : [#void#]setInt(<#int value#>)
+	return 0;
+}
\ No newline at end of file
Index: test/CodeCompletion/Filtering/filter-function-name.cpp
===
--- /dev/null
+++ test/CodeCompletion/Filtering/filter-function-name.cpp
@@ -0,0 +1,8 @@
+void myFunction();
+
+int main() {
+	myFunc
+	// RUN: %clang_cc1 -code-completion-at=%s:4:11 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
+	// CHECK-CC1: COMPLETION: myFunction : [#void#]myFunction()
+}
+
Index: lib/Sema/SemaCodeComplete.cpp
===
--- lib/Sema/SemaCodeComplete.cpp
+++ lib/Sema/SemaCodeComplete.cpp
@@ -3065,13 +3065,14 @@
   Results.ExitScope();
 }
 
-static void HandleCodeCompleteResults(Sema *S,
+static void HandleCodeCompleteResults(Token Tok, Sema *S,
   CodeCompleteConsumer *CodeCompleter,
   CodeCompletionContext Context,
   CodeCompletionResult *Results,
   unsigned NumResults) {
-  if (CodeCompleter)
-CodeCompleter->ProcessCodeCompleteResults(*S, Context, Results, NumResults);
+  if (CodeCompleter) {
+CodeCompleter->ProcessCodeCompleteResults(Tok, *S, Context, Results, NumResults);
+  }
 }
 
 static enum CodeCompletionContext::Kind mapCodeCompletionContext(Sema &S, 
@@ -3203,7 +3204,7 @@
   }
 }
 
-void Sema::CodeCompleteModuleImport(SourceLocation ImportLoc, 
+void Sema::CodeCompleteModuleImport(Token Tok, SourceLocation ImportLoc,
 

[PATCH] D17821: [OpenCL] Complete image types support

2016-03-02 Thread Anastasia Stulova via cfe-commits
Anastasia created this revision.
Anastasia added a reviewer: bader.
Anastasia added subscribers: cfe-commits, pekka.jaaskelainen, yaxunl.

Follow up from the earlier discussion via cfe-dev regarding incomplete images 
support in Clang:
http://lists.llvm.org/pipermail/cfe-dev/2016-February/047187.html
 
This review is based on older code base (around Clang version 3.5) and is 
uploaded for quick preview and possible discussions aiming to correct 
functionality of OpenCL images.

I. Current implementation of images is not conformant to spec in the following 
points:

1. It makes no distinction with respect to access qualifiers and therefore 
allows to use images with different access type interchangeably. The following 
code would compile just fine:

  void write_image(write_only image2d_t img);

  kernel void foo(read_only image2d_t img) {
write_image(img); // Accepted code
  }

which is disallowed according to s6.13.14.

2. It discards access qualifier on generated code, which leads to generated 
code for the above example:

  call void @write_image(%opencl.image2d_t* %img);

In OpenCL2.0 however we can have different calls into write_image with 
read_only and wite_only images.
Also generally following compiler steps have no easy way to take different path 
depending on the image access: linking to the right implementation of image 
types, performing IR opts and backend codegen differently.

3. Image types are language keywords and can't be redeclared s6.1.9, which can 
happen currently as they are just typedef names.

4. Default access qualifier read_only is to be added if not provided explicitly.

II. This patch corrects the above points as follows:

1.  All images are encapsulated into a separate .def file that is inserted in 
different points where image handling is required. This avoid a lot of code 
repetition as all images are handled the same way in the code with no 
distinction of their exact type.

2. The Cartesian product of image types and image access qualifiers is added to 
the builtin types. This simplifies a lot handling of access type mismatch as no 
operations are allowed by default on distinct Builtin types. Also spec intended 
access qualifier as special type qualifier that are combined with an image type 
to form a distinct type (see statement above - images can't be created w/o 
access qualifiers). 

3. Improves testing of images in Clang.

This patch would require rebasing, fixing formatting, and also addition of 
OpenCL2.0 images and pipes, to be committed. 

http://reviews.llvm.org/D17821

Files:
  include/clang/AST/ASTContext.h
  include/clang/AST/BuiltinTypes.def
  include/clang/AST/OpenCLImageTypes.def
  include/clang/AST/Type.h
  include/clang/Basic/Specifiers.h
  include/clang/Basic/TokenKinds.def
  include/clang/Sema/DeclSpec.h
  include/clang/Serialization/ASTBitCodes.h
  lib/AST/ASTContext.cpp
  lib/AST/ASTImporter.cpp
  lib/AST/ItaniumMangle.cpp
  lib/AST/MicrosoftMangle.cpp
  lib/AST/NSAPI.cpp
  lib/AST/Type.cpp
  lib/AST/TypeLoc.cpp
  lib/Analysis/PrintfFormatString.cpp
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CGDebugInfo.h
  lib/CodeGen/CGOpenCLRuntime.cpp
  lib/CodeGen/CodeGenTypes.cpp
  lib/CodeGen/ItaniumCXXABI.cpp
  lib/Index/USRGeneration.cpp
  lib/Parse/ParseDecl.cpp
  lib/Parse/ParseExpr.cpp
  lib/Parse/ParseTentative.cpp
  lib/Sema/DeclSpec.cpp
  lib/Sema/Sema.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaTemplateVariadic.cpp
  lib/Sema/SemaType.cpp
  lib/Serialization/ASTCommon.cpp
  lib/Serialization/ASTReader.cpp
  test/CodeGenOpenCL/images.cl
  test/CodeGenOpenCL/opencl_types.cl
  test/SemaOpenCL/images.cl
  test/SemaOpenCL/invalid-kernel-parameters.cl
  tools/libclang/CIndex.cpp

Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -1419,12 +1419,9 @@
   case BuiltinType::Void:
   case BuiltinType::NullPtr:
   case BuiltinType::Dependent:
-  case BuiltinType::OCLImage1d:
-  case BuiltinType::OCLImage1dArray:
-  case BuiltinType::OCLImage1dBuffer:
-  case BuiltinType::OCLImage2d:
-  case BuiltinType::OCLImage2dArray:
-  case BuiltinType::OCLImage3d:
+#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
+  case BuiltinType::Id:
+#include "clang/AST/OpenCLImageTypes.def"
   case BuiltinType::OCLSampler:
   case BuiltinType::OCLEvent:
 #define BUILTIN_TYPE(Id, SingletonId)
Index: test/SemaOpenCL/invalid-kernel-parameters.cl
===
--- test/SemaOpenCL/invalid-kernel-parameters.cl
+++ test/SemaOpenCL/invalid-kernel-parameters.cl
@@ -24,7 +24,7 @@
 
 typedef struct FooImage2D // expected-note{{within field of type 'FooImage2D' declared here}}
 {
-  image2d_t imageField; // expected-note{{field of illegal type 'image2d_t' declared here}}
+  image2d_t imageField; // expected-note{{field of illegal type '__read_only image2d_t' declared here}}
 } FooImage2D;
 
 kernel void image_in_str

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

2016-03-02 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko added a subscriber: Eugene.Zelenko.
Eugene.Zelenko added a comment.

Does it make http://reviews.llvm.org/D17772 obsolete?


http://reviews.llvm.org/D17811



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


r262499 - [CUDA] Do not generate unnecessary runtime init code.

2016-03-02 Thread Artem Belevich via cfe-commits
Author: tra
Date: Wed Mar  2 12:28:53 2016
New Revision: 262499

URL: http://llvm.org/viewvc/llvm-project?rev=262499&view=rev
Log:
[CUDA] Do not generate unnecessary runtime init code.

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

Modified:
cfe/trunk/lib/CodeGen/CGCUDANV.cpp
cfe/trunk/test/CodeGenCUDA/device-stub.cu

Modified: cfe/trunk/lib/CodeGen/CGCUDANV.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCUDANV.cpp?rev=262499&r1=262498&r2=262499&view=diff
==
--- cfe/trunk/lib/CodeGen/CGCUDANV.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCUDANV.cpp Wed Mar  2 12:28:53 2016
@@ -178,6 +178,10 @@ void CGNVCUDARuntime::emitDeviceStubBody
 /// }
 /// \endcode
 llvm::Function *CGNVCUDARuntime::makeRegisterGlobalsFn() {
+  // No need to register anything
+  if (EmittedKernels.empty() && DeviceVars.empty())
+return nullptr;
+
   llvm::Function *RegisterKernelsFunc = llvm::Function::Create(
   llvm::FunctionType::get(VoidTy, VoidPtrPtrTy, false),
   llvm::GlobalValue::InternalLinkage, "__cuda_register_globals", 
&TheModule);
@@ -251,6 +255,10 @@ llvm::Function *CGNVCUDARuntime::makeReg
 /// }
 /// \endcode
 llvm::Function *CGNVCUDARuntime::makeModuleCtorFunction() {
+  // No need to generate ctors/dtors if there are no GPU binaries.
+  if (CGM.getCodeGenOpts().CudaGpuBinaryFileNames.empty())
+return nullptr;
+
   // void __cuda_register_globals(void* handle);
   llvm::Function *RegisterGlobalsFunc = makeRegisterGlobalsFn();
   // void ** __cudaRegisterFatBinary(void *);
@@ -309,7 +317,8 @@ llvm::Function *CGNVCUDARuntime::makeMod
CGM.getPointerAlign());
 
 // Call __cuda_register_globals(GpuBinaryHandle);
-CtorBuilder.CreateCall(RegisterGlobalsFunc, RegisterFatbinCall);
+if (RegisterGlobalsFunc)
+  CtorBuilder.CreateCall(RegisterGlobalsFunc, RegisterFatbinCall);
 
 // Save GpuBinaryHandle so we can unregister it in destructor.
 GpuBinaryHandles.push_back(GpuBinaryHandle);
@@ -329,6 +338,10 @@ llvm::Function *CGNVCUDARuntime::makeMod
 /// }
 /// \endcode
 llvm::Function *CGNVCUDARuntime::makeModuleDtorFunction() {
+  // No need for destructor if we don't have handles to unregister.
+  if (GpuBinaryHandles.empty())
+return nullptr;
+
   // void __cudaUnregisterFatBinary(void ** handle);
   llvm::Constant *UnregisterFatbinFunc = CGM.CreateRuntimeFunction(
   llvm::FunctionType::get(VoidTy, VoidPtrPtrTy, false),

Modified: cfe/trunk/test/CodeGenCUDA/device-stub.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCUDA/device-stub.cu?rev=262499&r1=262498&r2=262499&view=diff
==
--- cfe/trunk/test/CodeGenCUDA/device-stub.cu (original)
+++ cfe/trunk/test/CodeGenCUDA/device-stub.cu Wed Mar  2 12:28:53 2016
@@ -1,7 +1,11 @@
 // RUN: %clang_cc1 -emit-llvm %s -fcuda-include-gpubinary %s -o - | FileCheck 
%s
+// RUN: %clang_cc1 -emit-llvm %s -fcuda-include-gpubinary %s -o -  -DNOGLOBALS 
\
+// RUN:   | FileCheck %s -check-prefix=NOGLOBALS
+// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s -check-prefix=NOGPUBIN
 
 #include "Inputs/cuda.h"
 
+#ifndef NOGLOBALS
 // CHECK-DAG: @device_var = internal global i32
 __device__ int device_var;
 
@@ -65,6 +69,7 @@ __global__ void kernelfunc(int i, int j,
 // CHECK: call{{.*}}cudaConfigureCall
 // CHECK: call{{.*}}kernelfunc
 void hostfunc(void) { kernelfunc<<<1, 1>>>(1, 1, 1); }
+#endif
 
 // Test that we've built a function to register kernels and global vars.
 // CHECK: define internal void @__cuda_register_globals
@@ -89,3 +94,18 @@ void hostfunc(void) { kernelfunc<<<1, 1>
 // CHECK: load{{.*}}__cuda_gpubin_handle
 // CHECK-NEXT: call void @__cudaUnregisterFatBinary
 
+// There should be no __cuda_register_globals if we have no
+// device-side globals, but we still need to register GPU binary.
+// Skip GPU binary string first.
+// NOGLOBALS: @0 = private unnamed_addr constant{{.*}}
+// NOGLOBALS-NOT: define internal void @__cuda_register_globals
+// NOGLOBALS: define internal void @__cuda_module_ctor
+// NOGLOBALS: call{{.*}}cudaRegisterFatBinary{{.*}}__cuda_fatbin_wrapper
+// NOGLOBALS-NOT: call void @__cuda_register_globals
+// NOGLOBALS: define internal void @__cuda_module_dtor
+// NOGLOBALS: call void @__cudaUnregisterFatBinary
+
+// There should be no constructors/destructors if we have no GPU binary.
+// NOGPUBIN-NOT: define internal void @__cuda_register_globals
+// NOGPUBIN-NOT: define internal void @__cuda_module_ctor
+// NOGPUBIN-NOT: define internal void @__cuda_module_dtor


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


r262498 - [CUDA] Emit host-side 'shadows' for device-side global variables

2016-03-02 Thread Artem Belevich via cfe-commits
Author: tra
Date: Wed Mar  2 12:28:50 2016
New Revision: 262498

URL: http://llvm.org/viewvc/llvm-project?rev=262498&view=rev
Log:
[CUDA] Emit host-side 'shadows' for device-side global variables

... and register them with CUDA runtime.

This is needed for commonly used cudaMemcpy*() APIs that use address of
host-side shadow to access their counterparts on device side.

Fixes PR26340

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

Modified:
cfe/trunk/lib/CodeGen/CGCUDANV.cpp
cfe/trunk/lib/CodeGen/CGCUDARuntime.h
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/test/CodeGenCUDA/device-stub.cu
cfe/trunk/test/CodeGenCUDA/filter-decl.cu

Modified: cfe/trunk/lib/CodeGen/CGCUDANV.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCUDANV.cpp?rev=262498&r1=262497&r2=262498&view=diff
==
--- cfe/trunk/lib/CodeGen/CGCUDANV.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCUDANV.cpp Wed Mar  2 12:28:50 2016
@@ -38,6 +38,7 @@ private:
   llvm::Module &TheModule;
   /// Keeps track of kernel launch stubs emitted in this module
   llvm::SmallVector EmittedKernels;
+  llvm::SmallVector, 16> 
DeviceVars;
   /// Keeps track of variables containing handles of GPU binaries. Populated by
   /// ModuleCtorFunction() and used to create corresponding cleanup calls in
   /// ModuleDtorFunction()
@@ -47,7 +48,7 @@ private:
   llvm::Constant *getLaunchFn() const;
 
   /// Creates a function to register all kernel stubs generated in this module.
-  llvm::Function *makeRegisterKernelsFn();
+  llvm::Function *makeRegisterGlobalsFn();
 
   /// Helper function that generates a constant string and returns a pointer to
   /// the start of the string.  The result of this function can be used 
anywhere
@@ -68,6 +69,10 @@ public:
   CGNVCUDARuntime(CodeGenModule &CGM);
 
   void emitDeviceStub(CodeGenFunction &CGF, FunctionArgList &Args) override;
+  void registerDeviceVar(llvm::GlobalVariable &Var, unsigned Flags) override {
+DeviceVars.push_back(std::make_pair(&Var, Flags));
+  }
+
   /// Creates module constructor function
   llvm::Function *makeModuleCtorFunction() override;
   /// Creates module destructor function
@@ -158,19 +163,24 @@ void CGNVCUDARuntime::emitDeviceStubBody
   CGF.EmitBlock(EndBlock);
 }
 
-/// Creates internal function to register all kernel stubs generated in this
-/// module with the CUDA runtime.
+/// Creates a function that sets up state on the host side for CUDA objects 
that
+/// have a presence on both the host and device sides. Specifically, registers
+/// the host side of kernel functions and device global variables with the CUDA
+/// runtime.
 /// \code
-/// void __cuda_register_kernels(void** GpuBinaryHandle) {
+/// void __cuda_register_globals(void** GpuBinaryHandle) {
 ///__cudaRegisterFunction(GpuBinaryHandle,Kernel0,...);
 ///...
 ///__cudaRegisterFunction(GpuBinaryHandle,KernelM,...);
+///__cudaRegisterVar(GpuBinaryHandle, GlobalVar0, ...);
+///...
+///__cudaRegisterVar(GpuBinaryHandle, GlobalVarN, ...);
 /// }
 /// \endcode
-llvm::Function *CGNVCUDARuntime::makeRegisterKernelsFn() {
+llvm::Function *CGNVCUDARuntime::makeRegisterGlobalsFn() {
   llvm::Function *RegisterKernelsFunc = llvm::Function::Create(
   llvm::FunctionType::get(VoidTy, VoidPtrPtrTy, false),
-  llvm::GlobalValue::InternalLinkage, "__cuda_register_kernels", 
&TheModule);
+  llvm::GlobalValue::InternalLinkage, "__cuda_register_globals", 
&TheModule);
   llvm::BasicBlock *EntryBB =
   llvm::BasicBlock::Create(Context, "entry", RegisterKernelsFunc);
   CGBuilderTy Builder(CGM, Context);
@@ -186,18 +196,44 @@ llvm::Function *CGNVCUDARuntime::makeReg
   "__cudaRegisterFunction");
 
   // Extract GpuBinaryHandle passed as the first argument passed to
-  // __cuda_register_kernels() and generate __cudaRegisterFunction() call for
+  // __cuda_register_globals() and generate __cudaRegisterFunction() call for
   // each emitted kernel.
   llvm::Argument &GpuBinaryHandlePtr = *RegisterKernelsFunc->arg_begin();
   for (llvm::Function *Kernel : EmittedKernels) {
 llvm::Constant *KernelName = makeConstantString(Kernel->getName());
 llvm::Constant *NullPtr = llvm::ConstantPointerNull::get(VoidPtrTy);
-llvm::Value *args[] = {
+llvm::Value *Args[] = {
 &GpuBinaryHandlePtr, Builder.CreateBitCast(Kernel, VoidPtrTy),
 KernelName, KernelName, llvm::ConstantInt::get(IntTy, -1), NullPtr,
 NullPtr, NullPtr, NullPtr,
 llvm::ConstantPointerNull::get(IntTy->getPointerTo())};
-Builder.CreateCall(RegisterFunc, args);
+Builder.CreateCall(RegisterFunc, Args);
+  }
+
+  // void __cudaRegisterVar(void **, char *, char *, const char *,
+  //int, int, int, int)
+  std::vector RegisterVarParams = {
+  VoidPtrPtrTy, CharPtrTy, CharPtrTy, CharPtrTy,
+  IntTy,IntTy, IntTy, IntTy};
+  llvm::Constant *Regi

Re: [PATCH] D17779: [CUDA] Emit host-side 'shadows' for device-side global variables

2016-03-02 Thread Artem Belevich via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL262498: [CUDA] Emit host-side 'shadows' for device-side 
global variables (authored by tra).

Changed prior to commit:
  http://reviews.llvm.org/D17779?vs=49561&id=49645#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D17779

Files:
  cfe/trunk/lib/CodeGen/CGCUDANV.cpp
  cfe/trunk/lib/CodeGen/CGCUDARuntime.h
  cfe/trunk/lib/CodeGen/CodeGenModule.cpp
  cfe/trunk/test/CodeGenCUDA/device-stub.cu
  cfe/trunk/test/CodeGenCUDA/filter-decl.cu

Index: cfe/trunk/lib/CodeGen/CGCUDARuntime.h
===
--- cfe/trunk/lib/CodeGen/CGCUDARuntime.h
+++ cfe/trunk/lib/CodeGen/CGCUDARuntime.h
@@ -18,6 +18,7 @@
 
 namespace llvm {
 class Function;
+class GlobalVariable;
 }
 
 namespace clang {
@@ -37,6 +38,12 @@
   CodeGenModule &CGM;
 
 public:
+  // Global variable properties that must be passed to CUDA runtime.
+  enum DeviceVarFlags {
+ExternDeviceVar = 0x01,   // extern
+ConstantDeviceVar = 0x02, // __constant__
+  };
+
   CGCUDARuntime(CodeGenModule &CGM) : CGM(CGM) {}
   virtual ~CGCUDARuntime();
 
@@ -46,6 +53,7 @@
 
   /// Emits a kernel launch stub.
   virtual void emitDeviceStub(CodeGenFunction &CGF, FunctionArgList &Args) = 0;
+  virtual void registerDeviceVar(llvm::GlobalVariable &Var, unsigned Flags) = 0;
 
   /// Constructs and returns a module initialization function or nullptr if it's
   /// not needed. Must be called after all kernels have been emitted.
Index: cfe/trunk/lib/CodeGen/CGCUDANV.cpp
===
--- cfe/trunk/lib/CodeGen/CGCUDANV.cpp
+++ cfe/trunk/lib/CodeGen/CGCUDANV.cpp
@@ -38,6 +38,7 @@
   llvm::Module &TheModule;
   /// Keeps track of kernel launch stubs emitted in this module
   llvm::SmallVector EmittedKernels;
+  llvm::SmallVector, 16> DeviceVars;
   /// Keeps track of variables containing handles of GPU binaries. Populated by
   /// ModuleCtorFunction() and used to create corresponding cleanup calls in
   /// ModuleDtorFunction()
@@ -47,7 +48,7 @@
   llvm::Constant *getLaunchFn() const;
 
   /// Creates a function to register all kernel stubs generated in this module.
-  llvm::Function *makeRegisterKernelsFn();
+  llvm::Function *makeRegisterGlobalsFn();
 
   /// Helper function that generates a constant string and returns a pointer to
   /// the start of the string.  The result of this function can be used anywhere
@@ -68,6 +69,10 @@
   CGNVCUDARuntime(CodeGenModule &CGM);
 
   void emitDeviceStub(CodeGenFunction &CGF, FunctionArgList &Args) override;
+  void registerDeviceVar(llvm::GlobalVariable &Var, unsigned Flags) override {
+DeviceVars.push_back(std::make_pair(&Var, Flags));
+  }
+
   /// Creates module constructor function
   llvm::Function *makeModuleCtorFunction() override;
   /// Creates module destructor function
@@ -158,19 +163,24 @@
   CGF.EmitBlock(EndBlock);
 }
 
-/// Creates internal function to register all kernel stubs generated in this
-/// module with the CUDA runtime.
+/// Creates a function that sets up state on the host side for CUDA objects that
+/// have a presence on both the host and device sides. Specifically, registers
+/// the host side of kernel functions and device global variables with the CUDA
+/// runtime.
 /// \code
-/// void __cuda_register_kernels(void** GpuBinaryHandle) {
+/// void __cuda_register_globals(void** GpuBinaryHandle) {
 ///__cudaRegisterFunction(GpuBinaryHandle,Kernel0,...);
 ///...
 ///__cudaRegisterFunction(GpuBinaryHandle,KernelM,...);
+///__cudaRegisterVar(GpuBinaryHandle, GlobalVar0, ...);
+///...
+///__cudaRegisterVar(GpuBinaryHandle, GlobalVarN, ...);
 /// }
 /// \endcode
-llvm::Function *CGNVCUDARuntime::makeRegisterKernelsFn() {
+llvm::Function *CGNVCUDARuntime::makeRegisterGlobalsFn() {
   llvm::Function *RegisterKernelsFunc = llvm::Function::Create(
   llvm::FunctionType::get(VoidTy, VoidPtrPtrTy, false),
-  llvm::GlobalValue::InternalLinkage, "__cuda_register_kernels", &TheModule);
+  llvm::GlobalValue::InternalLinkage, "__cuda_register_globals", &TheModule);
   llvm::BasicBlock *EntryBB =
   llvm::BasicBlock::Create(Context, "entry", RegisterKernelsFunc);
   CGBuilderTy Builder(CGM, Context);
@@ -186,18 +196,44 @@
   "__cudaRegisterFunction");
 
   // Extract GpuBinaryHandle passed as the first argument passed to
-  // __cuda_register_kernels() and generate __cudaRegisterFunction() call for
+  // __cuda_register_globals() and generate __cudaRegisterFunction() call for
   // each emitted kernel.
   llvm::Argument &GpuBinaryHandlePtr = *RegisterKernelsFunc->arg_begin();
   for (llvm::Function *Kernel : EmittedKernels) {
 llvm::Constant *KernelName = makeConstantString(Kernel->getName());
 llvm::Constant *NullPtr = llvm::ConstantPointerNull::get(VoidPtrTy);
-llvm::Value *args[] = {
+llvm::Value *Args[] = {
 &GpuBinaryHandlePtr, Builder.CreateBi

Re: [PATCH] D17299: [ASTReader] Report error when accessing corrupt record data

2016-03-02 Thread Vedant Kumar via cfe-commits
vsk added a comment.

Gentle ping.

For context, we've had a few situations where corrupt pch files trigger 
surprising assertion failures in our world builds.


http://reviews.llvm.org/D17299



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


Re: [PATCH] D17807: [clang-tidy] Add "clang-tidy as a clang plugin" skeleton.

2016-03-02 Thread Benjamin Kramer via cfe-commits
In theory yes, in practice that needs a bit of build system tweaking
to either build clang-tidy into clang or as a shared library. Then it
can be used like any regular Clang plugin.

It will also slow down clang significantly, but I consider that a bug ;)

On Wed, Mar 2, 2016 at 6:21 PM, David Blaikie  wrote:
> Would this also be usable as a way to run clang-tidy checks as part of
> normal compilation? (some things in clang-tidy aren't there because the FP
> is too high to be a hard error on old codebases (but might be viable once a
> codebase is able to be cleaned up (like several have been with LLVM)) or
> because they're project specific (either stylistically, or because they're
> about some project specific API))
>
> On Wed, Mar 2, 2016 at 6:47 AM, Benjamin Kramer via cfe-commits
>  wrote:
>>
>> bkramer created this revision.
>> bkramer added a reviewer: klimek.
>> bkramer added a subscriber: cfe-commits.
>>
>> This doesn't really do much at the moment. You can load it via libclang
>> and set the -checks via an extra command line argument as illustrated in
>> the test case. Support for other options (including headers check) is
>> currently missing. Also when using this with libclang some checks may
>> not work with the precompiled preamble in place.
>>
>> This can be used to easily show clang-tidy warnings in an editor
>> integration as all that's needed is adding command line flags that are
>> passed into libclang. Warnings and FixIts are exposed via the existing
>> CXDiagnostic machinery.
>>
>> http://reviews.llvm.org/D17807
>>
>> Files:
>>   clang-tidy/CMakeLists.txt
>>   clang-tidy/ClangTidyDiagnosticConsumer.h
>>   clang-tidy/plugin/CMakeLists.txt
>>   clang-tidy/plugin/ClangTidyPlugin.cpp
>>   test/clang-tidy/basic.cpp
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17780: [CUDA] Do not generate unnecessary runtime init code.

2016-03-02 Thread Artem Belevich via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL262499: [CUDA] Do not generate unnecessary runtime init 
code. (authored by tra).

Changed prior to commit:
  http://reviews.llvm.org/D17780?vs=49539&id=49646#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D17780

Files:
  cfe/trunk/lib/CodeGen/CGCUDANV.cpp
  cfe/trunk/test/CodeGenCUDA/device-stub.cu

Index: cfe/trunk/lib/CodeGen/CGCUDANV.cpp
===
--- cfe/trunk/lib/CodeGen/CGCUDANV.cpp
+++ cfe/trunk/lib/CodeGen/CGCUDANV.cpp
@@ -178,6 +178,10 @@
 /// }
 /// \endcode
 llvm::Function *CGNVCUDARuntime::makeRegisterGlobalsFn() {
+  // No need to register anything
+  if (EmittedKernels.empty() && DeviceVars.empty())
+return nullptr;
+
   llvm::Function *RegisterKernelsFunc = llvm::Function::Create(
   llvm::FunctionType::get(VoidTy, VoidPtrPtrTy, false),
   llvm::GlobalValue::InternalLinkage, "__cuda_register_globals", 
&TheModule);
@@ -251,6 +255,10 @@
 /// }
 /// \endcode
 llvm::Function *CGNVCUDARuntime::makeModuleCtorFunction() {
+  // No need to generate ctors/dtors if there are no GPU binaries.
+  if (CGM.getCodeGenOpts().CudaGpuBinaryFileNames.empty())
+return nullptr;
+
   // void __cuda_register_globals(void* handle);
   llvm::Function *RegisterGlobalsFunc = makeRegisterGlobalsFn();
   // void ** __cudaRegisterFatBinary(void *);
@@ -309,7 +317,8 @@
CGM.getPointerAlign());
 
 // Call __cuda_register_globals(GpuBinaryHandle);
-CtorBuilder.CreateCall(RegisterGlobalsFunc, RegisterFatbinCall);
+if (RegisterGlobalsFunc)
+  CtorBuilder.CreateCall(RegisterGlobalsFunc, RegisterFatbinCall);
 
 // Save GpuBinaryHandle so we can unregister it in destructor.
 GpuBinaryHandles.push_back(GpuBinaryHandle);
@@ -329,6 +338,10 @@
 /// }
 /// \endcode
 llvm::Function *CGNVCUDARuntime::makeModuleDtorFunction() {
+  // No need for destructor if we don't have handles to unregister.
+  if (GpuBinaryHandles.empty())
+return nullptr;
+
   // void __cudaUnregisterFatBinary(void ** handle);
   llvm::Constant *UnregisterFatbinFunc = CGM.CreateRuntimeFunction(
   llvm::FunctionType::get(VoidTy, VoidPtrPtrTy, false),
Index: cfe/trunk/test/CodeGenCUDA/device-stub.cu
===
--- cfe/trunk/test/CodeGenCUDA/device-stub.cu
+++ cfe/trunk/test/CodeGenCUDA/device-stub.cu
@@ -1,7 +1,11 @@
 // RUN: %clang_cc1 -emit-llvm %s -fcuda-include-gpubinary %s -o - | FileCheck 
%s
+// RUN: %clang_cc1 -emit-llvm %s -fcuda-include-gpubinary %s -o -  -DNOGLOBALS 
\
+// RUN:   | FileCheck %s -check-prefix=NOGLOBALS
+// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s -check-prefix=NOGPUBIN
 
 #include "Inputs/cuda.h"
 
+#ifndef NOGLOBALS
 // CHECK-DAG: @device_var = internal global i32
 __device__ int device_var;
 
@@ -65,6 +69,7 @@
 // CHECK: call{{.*}}cudaConfigureCall
 // CHECK: call{{.*}}kernelfunc
 void hostfunc(void) { kernelfunc<<<1, 1>>>(1, 1, 1); }
+#endif
 
 // Test that we've built a function to register kernels and global vars.
 // CHECK: define internal void @__cuda_register_globals
@@ -89,3 +94,18 @@
 // CHECK: load{{.*}}__cuda_gpubin_handle
 // CHECK-NEXT: call void @__cudaUnregisterFatBinary
 
+// There should be no __cuda_register_globals if we have no
+// device-side globals, but we still need to register GPU binary.
+// Skip GPU binary string first.
+// NOGLOBALS: @0 = private unnamed_addr constant{{.*}}
+// NOGLOBALS-NOT: define internal void @__cuda_register_globals
+// NOGLOBALS: define internal void @__cuda_module_ctor
+// NOGLOBALS: call{{.*}}cudaRegisterFatBinary{{.*}}__cuda_fatbin_wrapper
+// NOGLOBALS-NOT: call void @__cuda_register_globals
+// NOGLOBALS: define internal void @__cuda_module_dtor
+// NOGLOBALS: call void @__cudaUnregisterFatBinary
+
+// There should be no constructors/destructors if we have no GPU binary.
+// NOGPUBIN-NOT: define internal void @__cuda_register_globals
+// NOGPUBIN-NOT: define internal void @__cuda_module_ctor
+// NOGPUBIN-NOT: define internal void @__cuda_module_dtor


Index: cfe/trunk/lib/CodeGen/CGCUDANV.cpp
===
--- cfe/trunk/lib/CodeGen/CGCUDANV.cpp
+++ cfe/trunk/lib/CodeGen/CGCUDANV.cpp
@@ -178,6 +178,10 @@
 /// }
 /// \endcode
 llvm::Function *CGNVCUDARuntime::makeRegisterGlobalsFn() {
+  // No need to register anything
+  if (EmittedKernels.empty() && DeviceVars.empty())
+return nullptr;
+
   llvm::Function *RegisterKernelsFunc = llvm::Function::Create(
   llvm::FunctionType::get(VoidTy, VoidPtrPtrTy, false),
   llvm::GlobalValue::InternalLinkage, "__cuda_register_globals", &TheModule);
@@ -251,6 +255,10 @@
 /// }
 /// \endcode
 llvm::Function *CGNVCUDARuntime::makeModuleCtorFunction() {
+  // No need to generate ctors/dtors if there are no GPU binaries.
+  if (CGM.getCodeGenOpts().CudaGpuBinaryFileNames.empty())
+   

Re: [PATCH] D17737: [PGO] change profile use cc1 option

2016-03-02 Thread Rong Xu via cfe-commits
xur updated this revision to Diff 49647.
xur marked an inline comment as done.
xur added a comment.

I think David's suggestion to use one cc1 option -fprofile-instrument-use-path 
is a very good idea.
I update the patch to get rid of -fprofille-instrument-use.

The profile kind is now set by checking the profile header. I use a separated 
function (instead of using the overloaded name of setPGOInstrumentor()).

The assertion in lib/CodeGen/CodeGenModule.cpp:153 might not be needed. As 
Profilekind CodeGenOpts is getting from CodeGenOpts.ProfileInstrumentUsePath, 
so it should not be empty. But I keep it just in case.


http://reviews.llvm.org/D17737

Files:
  include/clang/Driver/CC1Options.td
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.def
  include/clang/Frontend/CodeGenOptions.h
  lib/CodeGen/BackendUtil.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/Driver/Tools.cpp
  lib/Frontend/CMakeLists.txt
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/Inputs/pgotestclang.profraw
  test/CodeGen/Inputs/pgotestir.profraw
  test/CodeGen/pgo-instrumentation.c
  test/Driver/clang_f_opts.c
  test/Profile/c-captured.c
  test/Profile/c-counter-overflows.c
  test/Profile/c-general.c
  test/Profile/c-outdated-data.c
  test/Profile/c-unprofiled-blocks.c
  test/Profile/c-unprofiled.c
  test/Profile/cxx-lambda.cpp
  test/Profile/cxx-rangefor.cpp
  test/Profile/cxx-templates.cpp
  test/Profile/objc-general.m
  test/Profile/profile-does-not-exist.c

Index: test/Profile/profile-does-not-exist.c
===
--- test/Profile/profile-does-not-exist.c
+++ test/Profile/profile-does-not-exist.c
@@ -1,4 +1,4 @@
-// RUN: not %clang_cc1 -emit-llvm %s -o - -fprofile-instr-use=%t.nonexistent.profdata 2>&1 | FileCheck %s
+// RUN: not %clang_cc1 -emit-llvm %s -o - -fprofile-instrument-use-path=%t.nonexistent.profdata 2>&1 | FileCheck %s
 
 // CHECK: error: Could not read profile {{.*}}.nonexistent.profdata:
 // CHECK-NOT: Assertion failed
Index: test/Profile/objc-general.m
===
--- test/Profile/objc-general.m
+++ test/Profile/objc-general.m
@@ -3,7 +3,7 @@
 // RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name objc-general.m %s -o - -emit-llvm -fblocks -fprofile-instrument=clang | FileCheck -check-prefix=PGOGEN %s
 
 // RUN: llvm-profdata merge %S/Inputs/objc-general.proftext -o %t.profdata
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name objc-general.m %s -o - -emit-llvm -fblocks -fprofile-instr-use=%t.profdata | FileCheck -check-prefix=PGOUSE %s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name objc-general.m %s -o - -emit-llvm -fblocks -fprofile-instrument-use-path=%t.profdata | FileCheck -check-prefix=PGOUSE %s
 
 #ifdef HAVE_FOUNDATION
 
Index: test/Profile/cxx-templates.cpp
===
--- test/Profile/cxx-templates.cpp
+++ test/Profile/cxx-templates.cpp
@@ -6,7 +6,7 @@
 // RUN: FileCheck --input-file=%tgen -check-prefix=T100GEN -check-prefix=ALL %s
 
 // RUN: llvm-profdata merge %S/Inputs/cxx-templates.proftext -o %t.profdata
-// RUN: %clang_cc1 -x c++ %s -triple %itanium_abi_triple -main-file-name cxx-templates.cpp -std=c++11 -o - -emit-llvm -fprofile-instr-use=%t.profdata > %tuse
+// RUN: %clang_cc1 -x c++ %s -triple %itanium_abi_triple -main-file-name cxx-templates.cpp -std=c++11 -o - -emit-llvm -fprofile-instrument-use-path=%t.profdata > %tuse
 // RUN: FileCheck --input-file=%tuse -check-prefix=T0USE -check-prefix=ALL %s
 // RUN: FileCheck --input-file=%tuse -check-prefix=T100USE -check-prefix=ALL %s
 
Index: test/Profile/cxx-rangefor.cpp
===
--- test/Profile/cxx-rangefor.cpp
+++ test/Profile/cxx-rangefor.cpp
@@ -4,7 +4,7 @@
 // RUN: FileCheck --input-file=%tgen -check-prefix=CHECK -check-prefix=PGOGEN %s
 
 // RUN: llvm-profdata merge %S/Inputs/cxx-rangefor.proftext -o %t.profdata
-// RUN: %clang_cc1 -x c++ %s -triple %itanium_abi_triple -main-file-name cxx-rangefor.cpp -std=c++11 -o - -emit-llvm -fprofile-instr-use=%t.profdata > %tuse
+// RUN: %clang_cc1 -x c++ %s -triple %itanium_abi_triple -main-file-name cxx-rangefor.cpp -std=c++11 -o - -emit-llvm -fprofile-instrument-use-path=%t.profdata > %tuse
 // RUN: FileCheck --input-file=%tuse -check-prefix=CHECK -check-prefix=PGOUSE %s
 
 // PGOGEN: @[[RFC:__profc__Z9range_forv]] = private global [5 x i64] zeroinitializer
Index: test/Profile/cxx-lambda.cpp
===
--- test/Profile/cxx-lambda.cpp
+++ test/Profile/cxx-lambda.cpp
@@ -5,7 +5,7 @@
 // RUN: FileCheck --input-file=%tgen -check-prefix=LMBGEN %s
 
 // RUN: llvm-profdata merge %S/Inputs/cxx-lambda.proftext -o %t.profdata
-// RUN: %clang_cc1 -x c++ %s -triple %itanium_abi_triple -main-file-name cxx-lambda.cpp -std=c++11 -o - -emit-llvm -fprofile-instr-use

Re: [PATCH] D17807: [clang-tidy] Add "clang-tidy as a clang plugin" skeleton.

2016-03-02 Thread David Blaikie via cfe-commits
On Wed, Mar 2, 2016 at 10:36 AM, Benjamin Kramer 
wrote:

> In theory yes, in practice that needs a bit of build system tweaking
> to either build clang-tidy into clang or as a shared library. Then it
> can be used like any regular Clang plugin.
>

I haven't looked at this patch in detail - soundds like you're saying here
^ that this patch doesn't make a "regular Clang plugin" for clang-tidy, but
something irregular?


> It will also slow down clang significantly, but I consider that a bug ;)
>

Yeah, that's something I'm a tad concerned about. It seems like the
matchers are convenient for writing but may be sub-optimal
performance-wise. (I don't expect them to ever be as quick as checks built
into Clang - doing the check as we parse the code is hard to beat
performance-wise, but a burden for code maintenance, but hopefully there's
something acceptable on both fronts)


>
> On Wed, Mar 2, 2016 at 6:21 PM, David Blaikie  wrote:
> > Would this also be usable as a way to run clang-tidy checks as part of
> > normal compilation? (some things in clang-tidy aren't there because the
> FP
> > is too high to be a hard error on old codebases (but might be viable
> once a
> > codebase is able to be cleaned up (like several have been with LLVM)) or
> > because they're project specific (either stylistically, or because
> they're
> > about some project specific API))
> >
> > On Wed, Mar 2, 2016 at 6:47 AM, Benjamin Kramer via cfe-commits
> >  wrote:
> >>
> >> bkramer created this revision.
> >> bkramer added a reviewer: klimek.
> >> bkramer added a subscriber: cfe-commits.
> >>
> >> This doesn't really do much at the moment. You can load it via libclang
> >> and set the -checks via an extra command line argument as illustrated in
> >> the test case. Support for other options (including headers check) is
> >> currently missing. Also when using this with libclang some checks may
> >> not work with the precompiled preamble in place.
> >>
> >> This can be used to easily show clang-tidy warnings in an editor
> >> integration as all that's needed is adding command line flags that are
> >> passed into libclang. Warnings and FixIts are exposed via the existing
> >> CXDiagnostic machinery.
> >>
> >> http://reviews.llvm.org/D17807
> >>
> >> Files:
> >>   clang-tidy/CMakeLists.txt
> >>   clang-tidy/ClangTidyDiagnosticConsumer.h
> >>   clang-tidy/plugin/CMakeLists.txt
> >>   clang-tidy/plugin/ClangTidyPlugin.cpp
> >>   test/clang-tidy/basic.cpp
> >>
> >>
> >> ___
> >> cfe-commits mailing list
> >> cfe-commits@lists.llvm.org
> >> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
> >>
> >
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17772: [clang-tidy]: string_view of temporary string

2016-03-02 Thread Jonathan B Coe via cfe-commits
jbcoe abandoned this revision.
jbcoe added a comment.

rendered obsolete by http://reviews.llvm.org/D17811


Repository:
  rL LLVM

http://reviews.llvm.org/D17772



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


Re: [PATCH] D17299: [ASTReader] Report error when accessing corrupt record data

2016-03-02 Thread Ben Langmuir via cfe-commits
benlangmuir added a comment.

This LGTM, but I would like Richard to take a look too.


http://reviews.llvm.org/D17299



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


Re: [PATCH] D17737: [PGO] change profile use cc1 option

2016-03-02 Thread Sean Silva via cfe-commits
silvas added a comment.

I agree, David's suggestion has simplified things. This LGTM (with a couple 
nits) but I'll let David give the final approval.



Comment at: lib/CodeGen/CodeGenModule.cpp:153
@@ +152,3 @@
+  if (CodeGenOpts.hasProfileClangUse()) {
+assert(!CodeGenOpts.ProfileInstrumentUsePath.empty() &&
+   "Need to explicitly specify the profile name.");

This assertion is not needed anymore. Or at least should be reworded as 
"hasProfileClangUse but no ProfileInstrumentPath" or similar to clearly 
indicate the expected state that should be guaranteed by the rest of the 
program.


Comment at: lib/Driver/Tools.cpp:3318
@@ -3316,1 +3317,3 @@
+// The default is to use Clang instrumentation profile.
+//CmdArgs.push_back("-fprofile-instrument-use=clang");
   }

This is not needed anymore after David's suggestion.


Comment at: lib/Frontend/CompilerInvocation.cpp:404
@@ +403,3 @@
+  const std::string ProfileName) {
+  assert(!ProfileName.empty());
+  auto ReaderOrErr = llvm::IndexedInstrProfReader::create(ProfileName);

I think this assertion is not needed since we are already handling errors below 
(by deferring to clang).


Comment at: lib/Frontend/CompilerInvocation.cpp:406
@@ +405,3 @@
+  auto ReaderOrErr = llvm::IndexedInstrProfReader::create(ProfileName);
+  // In error, reutrn silently and let Clang PGO use report the error message.
+  if (ReaderOrErr.getError()) {

typo: reutrn


http://reviews.llvm.org/D17737



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


Re: [PATCH] D17345: [OpenCL] Improve diagnostics of address spaces for variables inside function

2016-03-02 Thread Anastasia Stulova via cfe-commits
Anastasia updated this revision to Diff 49651.
Anastasia added a comment.

Improved message text!


http://reviews.llvm.org/D17345

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaDecl.cpp
  test/Parser/opencl-storage-class.cl
  test/SemaOpenCL/storageclass-cl20.cl
  test/SemaOpenCL/storageclass.cl

Index: test/SemaOpenCL/storageclass.cl
===
--- test/SemaOpenCL/storageclass.cl
+++ test/SemaOpenCL/storageclass.cl
@@ -14,6 +14,7 @@
   local int L2;
 
   auto int L3 = 7; // expected-error{{OpenCL does not support the 'auto' storage class specifier}}
+  global int L4;   // expected-error{{function scope variable cannot be declared in global address space}}
 }
 
 static void kernel bar() { // expected-error{{kernel functions cannot be declared static}}
@@ -26,4 +27,6 @@
 constant int L1 = 0; // expected-error{{non-kernel function variable cannot be declared in constant address space}}
 local int L2;// expected-error{{non-kernel function variable cannot be declared in local address space}}
   }
+  global int L3; // expected-error{{function scope variable cannot be declared in global address space}}
+  extern constant float L4;
 }
Index: test/SemaOpenCL/storageclass-cl20.cl
===
--- test/SemaOpenCL/storageclass-cl20.cl
+++ test/SemaOpenCL/storageclass-cl20.cl
@@ -1,15 +1,19 @@
-// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -DCL20 -cl-std=CL2.0
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0
 
 static constant int G1 = 0;
 int G2 = 0;
 global int G3 = 0;
-local int G4 = 0;// expected-error{{program scope variable must reside in global or constant address space}}
+local int G4 = 0;  // expected-error{{program scope variable must reside in global or constant address space}}
 
 void kernel foo() {
   static int S1 = 5;
   static global int S2 = 5;
-  static private int S3 = 5;// expected-error{{program scope variable must reside in global or constant address space}}
+  static private int S3 = 5;   // expected-error{{static local variable must reside in global or constant address space}}
 
   constant int L1 = 0;
   local int L2;
+  global int L3; // expected-error{{function scope variable cannot be declared in global address space}}
+
+  extern global int G5;
+  extern int G6; // expected-error{{extern variable must reside in global or constant address space}}
 }
Index: test/Parser/opencl-storage-class.cl
===
--- test/Parser/opencl-storage-class.cl
+++ test/Parser/opencl-storage-class.cl
@@ -8,8 +8,8 @@
   auto int d;  // expected-error {{OpenCL does not support the 'auto' storage class specifier}}
 
 #pragma OPENCL EXTENSION cl_clang_storage_class_specifiers : enable
-  static int e; // expected-error {{program scope variable must reside in constant address space}}
+  static int e; // expected-error {{static local variable must reside in constant address space}}
   register int f;
-  extern int g;
+  extern int g; // expected-error {{extern variable must reside in constant address space}}
   auto int h;
 }
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -6594,34 +6594,26 @@
 // OpenCL v2.0 s6.5.1 - Variables defined at program scope and static
 // variables inside a function can also be declared in the global
 // address space.
-if (NewVD->isFileVarDecl()) {
+if (NewVD->isFileVarDecl() || NewVD->isStaticLocal() ||
+NewVD->hasExternalStorage()) {
   if (!T->isSamplerT() &&
   !(T.getAddressSpace() == LangAS::opencl_constant ||
 (T.getAddressSpace() == LangAS::opencl_global &&
  getLangOpts().OpenCLVersion == 200))) {
+int VarScope = NewVD->isStaticLocal() | (NewVD->hasExternalStorage() << 1);
 if (getLangOpts().OpenCLVersion == 200)
   Diag(NewVD->getLocation(), diag::err_opencl_global_invalid_addr_space)
-  << "global or constant";
+  << VarScope << "global or constant";
 else
   Diag(NewVD->getLocation(), diag::err_opencl_global_invalid_addr_space)
-  << "constant";
+  << VarScope << "constant";
 NewVD->setInvalidDecl();
 return;
   }
 } else {
-  // OpenCL v2.0 s6.5.1 - Variables defined at program scope and static
-  // variables inside a function can also be declared in the global
-  // address space.
-  if (NewVD->isStaticLocal() &&
-  !(T.getAddressSpace() == LangAS::opencl_constant ||
-(T.getAddressSpace() == LangAS::opencl_global &&
- getLangOpts().OpenCLVersion == 200))) {
-if (getLangOpts().OpenCLVersion == 200)
-  Diag(NewVD->getLocation(), diag::err_opencl_global_invalid_addr_space)
-  << 

Re: [PATCH] D17019: [OpenMP] Code generation for teams - kernel launching

2016-03-02 Thread Samuel Antao via cfe-commits
sfantao updated this revision to Diff 49653.
sfantao added a comment.

Use new innermost scope API for the emission of the num_teams and thread_limit 
expressions.


http://reviews.llvm.org/D17019

Files:
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CGStmtOpenMP.cpp
  test/OpenMP/teams_codegen.cpp

Index: test/OpenMP/teams_codegen.cpp
===
--- /dev/null
+++ test/OpenMP/teams_codegen.cpp
@@ -0,0 +1,210 @@
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+// Test host codegen.
+// RUN: %clang_cc1 -DCK1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -omptargets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix CK1 --check-prefix CK1-64
+// RUN: %clang_cc1 -DCK1 -fopenmp -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -omptargets=powerpc64le-ibm-linux-gnu -emit-pch -o %t %s
+// RUN: %clang_cc1 -DCK1 -fopenmp -x c++ -triple powerpc64le-unknown-unknown -omptargets=powerpc64le-ibm-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CK1 --check-prefix CK1-64
+// RUN: %clang_cc1 -DCK1 -verify -fopenmp -x c++ -triple i386-unknown-unknown -omptargets=i386-pc-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix CK1 --check-prefix CK1-32
+// RUN: %clang_cc1 -DCK1 -fopenmp -x c++ -std=c++11 -triple i386-unknown-unknown -omptargets=i386-pc-linux-gnu -emit-pch -o %t %s
+// RUN: %clang_cc1 -DCK1 -fopenmp -x c++ -triple i386-unknown-unknown -omptargets=i386-pc-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CK1 --check-prefix CK1-32
+#ifdef CK1
+
+int Gbla;
+long long Gblb;
+int &Gblc = Gbla;
+
+// CK1-LABEL: teams_argument_global_local
+int teams_argument_global_local(int a){
+  int comp = 1;
+
+  int la = 23;
+  float lc = 25.0;
+
+  // CK1: call i32 @__tgt_target_teams(i32 -1, i8* @{{[^,]+}}, i32 1, i8** %{{[^,]+}}, i8** %{{[^,]+}}, i{{64|32}}* {{.+}}@{{[^,]+}}, i32 0, i32 0), i32* {{.+}}@{{[^,]+}}, i32 0, i32 0), i32 0, i32 0)
+  // CK1: call void @{{.+}}(i{{64|32}} %{{.+}})
+  #pragma omp target
+  #pragma omp teams
+  {
+++comp;
+  }
+
+  // CK1-DAG: call i32 @__tgt_target_teams(i32 -1, i8* @{{[^,]+}}, i32 2, i8** %{{[^,]+}}, i8** %{{[^,]+}}, i{{64|32}}* {{.+}}@{{[^,]+}}, i32 0, i32 0), i32* {{.+}}@{{[^,]+}}, i32 0, i32 0), i32 [[NT:%[^,]+]], i32 0)
+  // CK1-DAG: [[NT]] = load i32, i32* [[NTA:%[^,]+]],
+
+  // CK1: call void @{{.+}}(i{{64|32}} %{{.+}})
+  #pragma omp target
+  #pragma omp teams num_teams(la)
+  {
+++comp;
+  }
+
+  // CK1-DAG: call i32 @__tgt_target_teams(i32 -1, i8* @{{[^,]+}}, i32 2, i8** %{{[^,]+}}, i8** %{{[^,]+}}, i{{64|32}}* {{.+}}@{{[^,]+}}, i32 0, i32 0), i32* {{.+}}@{{[^,]+}}, i32 0, i32 0), i32 0, i32 [[NT:%[^,]+]])
+  // CK1-DAG: [[NT]] = load i32, i32* [[NTA:%[^,]+]],
+
+  // CK1: call void @{{.+}}(i{{64|32}} %{{.+}})
+  #pragma omp target
+  #pragma omp teams thread_limit(la)
+  {
+++comp;
+  }
+
+  // CK1-DAG: call i32 @__tgt_target_teams(i32 -1, i8* @{{[^,]+}}, i32 5, i8** %{{[^,]+}}, i8** %{{[^,]+}}, i{{64|32}}* {{.+}}@{{[^,]+}}, i32 0, i32 0), i32* {{.+}}@{{[^,]+}}, i32 0, i32 0), i32 [[NT:%[^,]+]], i32 [[TL:%[^,]+]])
+
+  // CK1-DAG: [[NT]] = add nsw i32 [[NTA:%[^,]+]], [[NTB:%[^,]+]]
+  // CK1-DAG: [[NTA]] = load i32, i32* @Gbla,
+  // CK1-DAG: [[NTB]] = load i32, i32* %{{.+}},
+
+  // CK1-DAG: [[TL]] = trunc i64 [[TLA:%[^,]+]] to i32
+  // CK1-DAG: [[TLA]] = add nsw i64 [[TLB:%[^,]+]], [[TLC:%[^,]+]]
+  // CK1-DAG: [[TLC]] = fptosi float [[TLD:%[^,]+]] to i64
+  // CK1-DAG: [[TLD]] = load float, float* %{{.+}},
+  // CK1-DAG: [[TLB]] = load i64, i64* @Gblb,
+
+  // CK1: call void @{{.+}}(i{{.+}} {{.+}}, i{{.+}} {{.+}}, i{{.+}} {{.+}}, i{{.+}} {{.+}}, i{{.+}} {{.+}})
+  #pragma omp target
+  #pragma omp teams num_teams(Gbla+a) thread_limit(Gblb+(long long)lc)
+  {
+++comp;
+  }
+
+  // CK1-DAG: call i32 @__tgt_target_teams(i32 -1, i8* @{{[^,]+}}, i32 {{.+}}, i8** %{{[^,]+}}, i8** %{{[^,]+}}, i{{64|32}}* {{.+}}@{{[^,]+}}, i32 0, i32 0), i32* {{.+}}@{{[^,]+}}, i32 0, i32 0), i32 [[NT:%[^,]+]], i32 [[TL:%[^,]+]])
+
+  // CK1-DAG: [[NT]] = add nsw i32 [[NTA:%[^,]+]], 1
+  // CK1-DAG: [[NTA]] = load i32, i32* @Gbla,
+
+  // CK1-DAG: [[TL]] = add nsw i32 [[TLA:%[^,]+]], 2
+  // CK1-DAG: [[TLA]] = load i32, i32* @Gbla,
+
+  // CK1: call void @{{.+}}(i{{.+}} {{.+}}
+  #pragma omp target
+  #pragma omp teams num_teams(Gblc+1) thread_limit(Gblc+2)
+  {
+comp += Gblc;
+  }
+
+  return comp;
+}
+
+#endif // CK1
+
+// Test host codegen.
+// RUN: %clang_cc1 -DCK2 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -omptargets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix CK2 --check-prefix CK2-64
+// RUN: %clang_cc1 -DCK2 -fopenmp -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -omptargets=powerpc64le-ibm-linux-gnu -emit-pch -o %t %s
+// RUN: %clang_cc1 -DCK2 -fopenmp -x c++ -triple powerpc64le-unknown-unknown -omptargets=

Re: [PATCH] D17019: [OpenMP] Code generation for teams - kernel launching

2016-03-02 Thread Samuel Antao via cfe-commits
sfantao added inline comments.


Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:256-296
@@ -255,26 +255,43 @@
 /// \brief RAII for emitting code of OpenMP constructs.
 class InlinedOpenMPRegionRAII {
   CodeGenFunction &CGF;
+  /// \brief Saves the varaibles that were forced to be local in the current
+  /// inlined region.
+  SmallVector ForcedLocalVars;
 
 public:
-  /// \brief Constructs region for combined constructs.
+  /// \brief Constructs inlined region. Mostly used for combined constructs. If
+  /// a captured statement is provided it also ensures the captured variables
+  /// are all defined in the scope of the enclosing function. This is typical
+  /// used for regions that make local instances of global variables, e.g.
+  /// target regions.
   /// \param CodeGen Code generation sequence for combined directives. Includes
   /// a list of functions used for code generation of implicitly inlined
   /// regions.
   InlinedOpenMPRegionRAII(CodeGenFunction &CGF, const RegionCodeGenTy &CodeGen,
-  OpenMPDirectiveKind Kind, bool HasCancel)
+  OpenMPDirectiveKind Kind, bool HasCancel,
+  const CapturedStmt *CS)
   : CGF(CGF) {
 // Start emission for the construct.
 CGF.CapturedStmtInfo = new CGOpenMPInlinedRegionInfo(
 CGF.CapturedStmtInfo, CodeGen, Kind, HasCancel);
+
+// Ensures that all the captures are local in the current inlined region.
+if (CS)
+  CGF.StartOpenMPInlinedCapturedRegion(*CS, ForcedLocalVars);
   }
 
   ~InlinedOpenMPRegionRAII() {
+// Restore the local variable information if we have anything forced in 
this
+// inlined region.
+if (!ForcedLocalVars.empty())
+  CGF.CloseOpenMPInlinedCapturedRegion(ForcedLocalVars);
+
 // Restore original CapturedStmtInfo only if we're done with code emission.
 auto *OldCSI =
 cast(CGF.CapturedStmtInfo)->getOldCSI();
 delete CGF.CapturedStmtInfo;
 CGF.CapturedStmtInfo = OldCSI;
   }
 };
 

ABataev wrote:
> Do not modify this one, add a new one like this:
> ```
> static void EmptyCodeGen(CodeGenFunction &) {
>   llvm_unreachable("No codegen for expressions");
> }
> /// \brief API for generation of expressions captured in OpenMP region in 
> outer
> /// scope.
> class CGOpenMPOuterExprInfo : public CGOpenMPInlinedRegionInfo {
> public:
>   CGOpenMPOuterExprInfo(CodeGenFunction &CGF)
>   : CGOpenMPInlinedRegionInfo(CGF.CapturedStmtInfo, CodeGen, OMPD_unknown,
>   /*HasCancel=*/false),
> CGF(CGF) {}
> 
>   /// \brief Lookup the captured field decl for a variable.
>   const FieldDecl *lookup(const VarDecl *VD) const override {
> if (auto *FD = CGOpenMPInlinedRegionInfo::lookup(VD))
>   return FD;
> if (!VD->isLocalVarDeclOrParm() && Mapped.count(VD) == 0) {
>   auto It =
>   PrivateGlobals.insert(new CodeGenFunction::OMPPrivateScope(CGF));
>   DeclRefExpr DRE(const_cast(VD),
>   /*RefersToEnclosingVariableOrCapture=*/false,
>   VD->getType().getNonReferenceType(), VK_LValue,
>   SourceLocation());
>   It.first->addPrivate(
>   VD, [&]() -> Address { return CGF.EmitLValue(&DRE).getAddress(); });
>   (void)It.first->Privatize();
>   Mapped.insert(VD);
> }
> return nullptr;
>   }
> 
>   /// \brief Emit the captured statement body.
>   void EmitBody(CodeGenFunction &CGF, const Stmt *S) override {
> llvm_unreachable("No body for expressions");
>   }
> 
>   /// \brief Get a variable or parameter for storing global thread id
>   /// inside OpenMP construct.
>   const VarDecl *getThreadIDVariable() const override {
> llvm_unreachable("No thread id for expressions");
>   }
> 
>   /// \brief Get the name of the capture helper.
>   StringRef getHelperName() const override {
> llvm_unreachable("No helper name for expressions");
>   }
> 
>   static bool classof(const CGCapturedStmtInfo *Info) {
> llvm_unreachable("No helper name for expressions");
>   }
> 
>   virtual ~CGOpenMPOuterExprInfo() {
> for (auto *Scope : PrivateGlobals)
>   delete Scope;
> PrivateGlobals.clear();
>   }
> 
> private:
>   CodeGenFunction &CGF;
>   /// Private scopes for each captured global variables.
>   llvm::SmallPtrSet PrivateGlobals;
>   SmallSet Mapped;
> };
> ```
Ok, I adapted the code you pasted above and I am now creating a new inline 
region API. I am naming it `CGOpenMPInnerExprInfo` given that it relates to the 
emission of expression defined in the inner scope. Also, I am doing the 
privatization in the constructor given that the globals have to be local 
already by the time the expression is emitted. 


http://reviews.llvm.org/D17019



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


r262503 - [libFuzzer] allow -fsanitize-coverage=0 (disables all coverage)

2016-03-02 Thread Kostya Serebryany via cfe-commits
Author: kcc
Date: Wed Mar  2 13:16:54 2016
New Revision: 262503

URL: http://llvm.org/viewvc/llvm-project?rev=262503&view=rev
Log:
[libFuzzer] allow -fsanitize-coverage=0 (disables all coverage)

Modified:
cfe/trunk/lib/Driver/SanitizerArgs.cpp
cfe/trunk/test/Driver/fsanitize-coverage.c

Modified: cfe/trunk/lib/Driver/SanitizerArgs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/SanitizerArgs.cpp?rev=262503&r1=262502&r2=262503&view=diff
==
--- cfe/trunk/lib/Driver/SanitizerArgs.cpp (original)
+++ cfe/trunk/lib/Driver/SanitizerArgs.cpp Wed Mar  2 13:16:54 2016
@@ -446,9 +446,8 @@ SanitizerArgs::SanitizerArgs(const ToolC
   LegacySanitizeCoverage >= 0 && LegacySanitizeCoverage <= 4) {
 switch (LegacySanitizeCoverage) {
 case 0:
-  D.Diag(diag::warn_drv_deprecated_arg) << Arg->getAsString(Args)
-<< "-fsanitize-coverage=";
   CoverageFeatures = 0;
+  Arg->claim();
   break;
 case 1:
   D.Diag(diag::warn_drv_deprecated_arg) << Arg->getAsString(Args)

Modified: cfe/trunk/test/Driver/fsanitize-coverage.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/fsanitize-coverage.c?rev=262503&r1=262502&r2=262503&view=diff
==
--- cfe/trunk/test/Driver/fsanitize-coverage.c (original)
+++ cfe/trunk/test/Driver/fsanitize-coverage.c Wed Mar  2 13:16:54 2016
@@ -2,6 +2,7 @@
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=address 
-fsanitize-coverage=edge -fsanitize-coverage=0 %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-SANITIZE-COVERAGE-0
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=address %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-SANITIZE-COVERAGE-0
 // CHECK-SANITIZE-COVERAGE-0-NOT: fsanitize-coverage-type
+// CHECK-SANITIZE-COVERAGE-0: -fsanitize=address
 
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=address 
-fsanitize-coverage=func %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-SANITIZE-COVERAGE-FUNC
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=memory 
-fsanitize-coverage=func %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-SANITIZE-COVERAGE-FUNC
@@ -21,6 +22,10 @@
 // CHECK-SANITIZE-COVERAGE-FUNC_INDIR: fsanitize-coverage-type=3
 // CHECK-SANITIZE-COVERAGE-FUNC_INDIR: fsanitize-coverage-indirect-calls
 
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=address 
-fsanitize-coverage=1 %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-SANITIZE-COVERAGE-1
+// CHECK-SANITIZE-COVERAGE-1: warning: argument '-fsanitize-coverage=1' is 
deprecated, use '-fsanitize-coverage=func' instead
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=address 
-fsanitize-coverage=2 %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-SANITIZE-COVERAGE-2
+// CHECK-SANITIZE-COVERAGE-2: warning: argument '-fsanitize-coverage=2' is 
deprecated, use '-fsanitize-coverage=bb' instead
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=address 
-fsanitize-coverage=3 %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-SANITIZE-COVERAGE-3
 // CHECK-SANITIZE-COVERAGE-3: warning: argument '-fsanitize-coverage=3' is 
deprecated, use '-fsanitize-coverage=edge' instead
 //


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


r262506 - Serialize `#pragma detect_mismatch`.

2016-03-02 Thread Nico Weber via cfe-commits
Author: nico
Date: Wed Mar  2 13:28:54 2016
New Revision: 262506

URL: http://llvm.org/viewvc/llvm-project?rev=262506&view=rev
Log:
Serialize `#pragma detect_mismatch`.

This is like r262493, but for pragma detect_mismatch instead of pragma comment.
The two pragmas have similar behavior, so use the same approach for both.

Added:
cfe/trunk/test/PCH/pragma-detect_mismatch.c
Modified:
cfe/trunk/include/clang/AST/ASTConsumer.h
cfe/trunk/include/clang/AST/Decl.h
cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
cfe/trunk/include/clang/Basic/DeclNodes.td
cfe/trunk/include/clang/Frontend/MultiplexConsumer.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/include/clang/Serialization/ASTBitCodes.h
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/AST/ASTDumper.cpp
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/lib/AST/DeclBase.cpp
cfe/trunk/lib/CodeGen/CGDecl.cpp
cfe/trunk/lib/CodeGen/CodeGenAction.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/ModuleBuilder.cpp
cfe/trunk/lib/Frontend/MultiplexConsumer.cpp
cfe/trunk/lib/Parse/ParsePragma.cpp
cfe/trunk/lib/Sema/SemaAttr.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/lib/Serialization/ASTCommon.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
cfe/trunk/tools/libclang/CIndex.cpp

Modified: cfe/trunk/include/clang/AST/ASTConsumer.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTConsumer.h?rev=262506&r1=262505&r2=262506&view=diff
==
--- cfe/trunk/include/clang/AST/ASTConsumer.h (original)
+++ cfe/trunk/include/clang/AST/ASTConsumer.h Wed Mar  2 13:28:54 2016
@@ -94,12 +94,6 @@ public:
   /// The default implementation passes it to HandleTopLevelDecl.
   virtual void HandleImplicitImportDecl(ImportDecl *D);
 
-  /// \brief Handle a pragma that emits a mismatch identifier and value to the
-  /// object file for the linker to work with.  Currently, this only exists to
-  /// support Microsoft's #pragma detect_mismatch.
-  virtual void HandleDetectMismatch(llvm::StringRef Name,
-llvm::StringRef Value) {}
-
   /// CompleteTentativeDefinition - Callback invoked at the end of a 
translation
   /// unit to notify the consumer that the given tentative definition should be
   /// completed.

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=262506&r1=262505&r2=262506&view=diff
==
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Wed Mar  2 13:28:54 2016
@@ -138,6 +138,39 @@ public:
   static bool classofKind(Kind K) { return K == PragmaComment; }
 };
 
+/// \brief Represents a `#pragma detect_mismatch` line. Always a child of
+/// TranslationUnitDecl.
+class PragmaDetectMismatchDecl final
+: public Decl,
+  private llvm::TrailingObjects {
+  virtual void anchor();
+
+  size_t ValueStart;
+
+  friend TrailingObjects;
+  friend class ASTDeclReader;
+  friend class ASTDeclWriter;
+
+  PragmaDetectMismatchDecl(TranslationUnitDecl *TU, SourceLocation Loc,
+   size_t ValueStart)
+  : Decl(PragmaDetectMismatch, TU, Loc), ValueStart(ValueStart) {}
+
+public:
+  static PragmaDetectMismatchDecl *Create(const ASTContext &C,
+  TranslationUnitDecl *DC,
+  SourceLocation Loc, StringRef Name,
+  StringRef Value);
+  static PragmaDetectMismatchDecl *
+  CreateDeserialized(ASTContext &C, unsigned ID, unsigned NameValueSize);
+
+  StringRef getName() const { return getTrailingObjects(); }
+  StringRef getValue() const { return getTrailingObjects() + ValueStart; 
}
+
+  // Implement isa/cast/dyncast/etc.
+  static bool classof(const Decl *D) { return classofKind(D->getKind()); }
+  static bool classofKind(Kind K) { return K == PragmaDetectMismatch; }
+};
+
 /// \brief Declaration context for names declared as extern "C" in C++. This
 /// is neither the semantic nor lexical context for such declarations, but is
 /// used to check for conflicts with other extern "C" declarations. Example:

Modified: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecursiveASTVisitor.h?rev=262506&r1=262505&r2=262506&view=diff
==
--- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h (original)
+++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h Wed Mar  2 13:28:54 2016
@@ -1361,6 +1361,8 @@ DEF_TRAVERSE_DECL(
 
 DEF_TRAVERSE_DECL(PragmaCommentDecl, {})
 
+DEF_TRAVERSE_DECL(PragmaDetectMismatchDecl, {})
+
 DEF_TRAVERSE_DECL(ExternCCo

Re: [PATCH] D17799: Serialize `#pragma comment`.

2016-03-02 Thread Nico Weber via cfe-commits
thakis added a comment.

Also landed a very similar change for the very similar detect_mismatch pragma 
in r262506. (The other missing serialized pragmas will use a different 
approach.)


http://reviews.llvm.org/D17799



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


Re: [PATCH] D17183: Make TargetInfo store an actual DataLayout instead of a string.

2016-03-02 Thread Eric Christopher via cfe-commits
echristo accepted this revision.
echristo added a comment.
This revision is now accepted and ready to land.

Sorry, I've been waffling on this, but I think this is fine.

Thanks!

-eric


http://reviews.llvm.org/D17183



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


Re: [PATCH] D17737: [PGO] change profile use cc1 option

2016-03-02 Thread Rong Xu via cfe-commits
xur updated this revision to Diff 49655.
xur added a comment.

Integrated with Sean's review comments.

-Rong


http://reviews.llvm.org/D17737

Files:
  include/clang/Driver/CC1Options.td
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.def
  include/clang/Frontend/CodeGenOptions.h
  lib/CodeGen/BackendUtil.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/Driver/Tools.cpp
  lib/Frontend/CMakeLists.txt
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/Inputs/pgotestclang.profraw
  test/CodeGen/Inputs/pgotestir.profraw
  test/CodeGen/pgo-instrumentation.c
  test/Driver/clang_f_opts.c
  test/Profile/c-captured.c
  test/Profile/c-counter-overflows.c
  test/Profile/c-general.c
  test/Profile/c-outdated-data.c
  test/Profile/c-unprofiled-blocks.c
  test/Profile/c-unprofiled.c
  test/Profile/cxx-lambda.cpp
  test/Profile/cxx-rangefor.cpp
  test/Profile/cxx-templates.cpp
  test/Profile/objc-general.m
  test/Profile/profile-does-not-exist.c

Index: test/Profile/profile-does-not-exist.c
===
--- test/Profile/profile-does-not-exist.c
+++ test/Profile/profile-does-not-exist.c
@@ -1,4 +1,4 @@
-// RUN: not %clang_cc1 -emit-llvm %s -o - -fprofile-instr-use=%t.nonexistent.profdata 2>&1 | FileCheck %s
+// RUN: not %clang_cc1 -emit-llvm %s -o - -fprofile-instrument-use-path=%t.nonexistent.profdata 2>&1 | FileCheck %s
 
 // CHECK: error: Could not read profile {{.*}}.nonexistent.profdata:
 // CHECK-NOT: Assertion failed
Index: test/Profile/objc-general.m
===
--- test/Profile/objc-general.m
+++ test/Profile/objc-general.m
@@ -3,7 +3,7 @@
 // RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name objc-general.m %s -o - -emit-llvm -fblocks -fprofile-instrument=clang | FileCheck -check-prefix=PGOGEN %s
 
 // RUN: llvm-profdata merge %S/Inputs/objc-general.proftext -o %t.profdata
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name objc-general.m %s -o - -emit-llvm -fblocks -fprofile-instr-use=%t.profdata | FileCheck -check-prefix=PGOUSE %s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name objc-general.m %s -o - -emit-llvm -fblocks -fprofile-instrument-use-path=%t.profdata | FileCheck -check-prefix=PGOUSE %s
 
 #ifdef HAVE_FOUNDATION
 
Index: test/Profile/cxx-templates.cpp
===
--- test/Profile/cxx-templates.cpp
+++ test/Profile/cxx-templates.cpp
@@ -6,7 +6,7 @@
 // RUN: FileCheck --input-file=%tgen -check-prefix=T100GEN -check-prefix=ALL %s
 
 // RUN: llvm-profdata merge %S/Inputs/cxx-templates.proftext -o %t.profdata
-// RUN: %clang_cc1 -x c++ %s -triple %itanium_abi_triple -main-file-name cxx-templates.cpp -std=c++11 -o - -emit-llvm -fprofile-instr-use=%t.profdata > %tuse
+// RUN: %clang_cc1 -x c++ %s -triple %itanium_abi_triple -main-file-name cxx-templates.cpp -std=c++11 -o - -emit-llvm -fprofile-instrument-use-path=%t.profdata > %tuse
 // RUN: FileCheck --input-file=%tuse -check-prefix=T0USE -check-prefix=ALL %s
 // RUN: FileCheck --input-file=%tuse -check-prefix=T100USE -check-prefix=ALL %s
 
Index: test/Profile/cxx-rangefor.cpp
===
--- test/Profile/cxx-rangefor.cpp
+++ test/Profile/cxx-rangefor.cpp
@@ -4,7 +4,7 @@
 // RUN: FileCheck --input-file=%tgen -check-prefix=CHECK -check-prefix=PGOGEN %s
 
 // RUN: llvm-profdata merge %S/Inputs/cxx-rangefor.proftext -o %t.profdata
-// RUN: %clang_cc1 -x c++ %s -triple %itanium_abi_triple -main-file-name cxx-rangefor.cpp -std=c++11 -o - -emit-llvm -fprofile-instr-use=%t.profdata > %tuse
+// RUN: %clang_cc1 -x c++ %s -triple %itanium_abi_triple -main-file-name cxx-rangefor.cpp -std=c++11 -o - -emit-llvm -fprofile-instrument-use-path=%t.profdata > %tuse
 // RUN: FileCheck --input-file=%tuse -check-prefix=CHECK -check-prefix=PGOUSE %s
 
 // PGOGEN: @[[RFC:__profc__Z9range_forv]] = private global [5 x i64] zeroinitializer
Index: test/Profile/cxx-lambda.cpp
===
--- test/Profile/cxx-lambda.cpp
+++ test/Profile/cxx-lambda.cpp
@@ -5,7 +5,7 @@
 // RUN: FileCheck --input-file=%tgen -check-prefix=LMBGEN %s
 
 // RUN: llvm-profdata merge %S/Inputs/cxx-lambda.proftext -o %t.profdata
-// RUN: %clang_cc1 -x c++ %s -triple %itanium_abi_triple -main-file-name cxx-lambda.cpp -std=c++11 -o - -emit-llvm -fprofile-instr-use=%t.profdata > %tuse
+// RUN: %clang_cc1 -x c++ %s -triple %itanium_abi_triple -main-file-name cxx-lambda.cpp -std=c++11 -o - -emit-llvm -fprofile-instrument-use-path=%t.profdata > %tuse
 // RUN: FileCheck --input-file=%tuse -check-prefix=PGOUSE %s
 // RUN: FileCheck --input-file=%tuse -check-prefix=LMBUSE %s
 
Index: test/Profile/c-unprofiled.c
===
--- test/Profile/c-unprofiled.c
+++ test/Profile/c-unprofiled.c
@@ -7,7 +7,7 @@
 // doesn't play wel

r262508 - fix test from r262506

2016-03-02 Thread Nico Weber via cfe-commits
Author: nico
Date: Wed Mar  2 13:38:24 2016
New Revision: 262508

URL: http://llvm.org/viewvc/llvm-project?rev=262508&view=rev
Log:
fix test from r262506

Modified:
cfe/trunk/test/PCH/pragma-detect_mismatch.c

Modified: cfe/trunk/test/PCH/pragma-detect_mismatch.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/pragma-detect_mismatch.c?rev=262508&r1=262507&r2=262508&view=diff
==
--- cfe/trunk/test/PCH/pragma-detect_mismatch.c (original)
+++ cfe/trunk/test/PCH/pragma-detect_mismatch.c Wed Mar  2 13:38:24 2016
@@ -17,7 +17,6 @@
 
 #else
 
-// CHECK: "/DEFAULTLIB:foo.lib"
 // CHECK: "/FAILIFMISMATCH:\22FruitKind=Jaboticaba\22"
 
 #endif


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


Re: [PATCH] D17737: [PGO] change profile use cc1 option

2016-03-02 Thread David Li via cfe-commits
davidxl accepted this revision.
davidxl added a comment.

lgtm


http://reviews.llvm.org/D17737



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


Re: [PATCH] D17820: Clang Code Completion Filtering

2016-03-02 Thread Argyrios Kyrtzidis via cfe-commits
akyrtzi added a comment.

We should not bake-in filtering into the clang CodeComplete API. What kind of 
filtering to use should be on a higher level, different clients may want 
different filtering, e.g. prefix filtering, fuzzy filtering, etc.


Repository:
  rL LLVM

http://reviews.llvm.org/D17820



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


Add hasInClassInitializer matcher

2016-03-02 Thread Julian Bangert via cfe-commits
This adds a matcher for C++ in Class initializers.

---
 include/clang/ASTMatchers/ASTMatchers.h   | 14 ++
 unittests/ASTMatchers/ASTMatchersTest.cpp |  7 +++
 2 files changed, 21 insertions(+)

diff --git a/include/clang/ASTMatchers/ASTMatchers.h
b/include/clang/ASTMatchers/ASTMatchers.h
index 21a4969..6b0a5d6 100644
--- a/include/clang/ASTMatchers/ASTMatchers.h
+++ b/include/clang/ASTMatchers/ASTMatchers.h
@@ -2848,6 +2848,20 @@ AST_MATCHER(CXXCtorInitializer, isMemberInitializer)
{
   return Node.isMemberInitializer();
 }

+/// \brief Matches a C++ inClassInitializer matching the given matcher
+///
+/// Given:
+/// \code
+///   class A { int x = 1; };
+/// \endcode
+///
+/// \c hasInClassInitializer(integerLiteral()) matches int x = 1
+AST_MATCHER_P(FieldDecl, hasInClassInitializer,
+  internal::Matcher, InnerMatcher) {
+  return Node.hasInClassInitializer()
+  && InnerMatcher.matches(*Node.getInClassInitializer(), Finder,
Builder);
+}
+
 /// \brief Matches any argument of a call expression or a constructor call
 /// expression.
 ///
diff --git a/unittests/ASTMatchers/ASTMatchersTest.cpp
b/unittests/ASTMatchers/ASTMatchersTest.cpp
index 133dc70..15776d7 100644
--- a/unittests/ASTMatchers/ASTMatchersTest.cpp
+++ b/unittests/ASTMatchers/ASTMatchersTest.cpp
@@ -2402,6 +2402,13 @@ TEST(HasAnyConstructorInitializer,
IsBaseInitializer) {
 hasName("E");
 }

+TEST(Matcher, inClassInitializer) {
+  EXPECT_TRUE(matches("class A{ int x = 1; };",
+  fieldDecl(hasInClassInitializer(integerLiteral();
+  EXPECT_FALSE(matches("class A{ int x; void b() { x = 1; } };",
+
fieldDecl(hasInClassInitializer(integerLiteral();
+}
+
 TEST(Matcher, NewExpression) {
   StatementMatcher New = cxxNewExpr();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17820: Clang Code Completion Filtering

2016-03-02 Thread Milian Wolff via cfe-commits
milianw added a subscriber: milianw.
milianw added a comment.

I'm not yet acquainted enough with the code at hand, but I wonder whether I'm 
understanding the code correctly:

Could it be that you only filter before printing to the output stream? The 
other consumers, e.g. the one used by the clang-c API function 
clang_codeCompleteAt is thus not affected? That would be a shame, imo. This 
functionality should also be applied there, don't you think?


Repository:
  rL LLVM

http://reviews.llvm.org/D17820



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


Re: [PATCH] D17820: Clang Code Completion Filtering

2016-03-02 Thread Milian Wolff via cfe-commits
milianw added a comment.

@akyrtzi raises a very valid point - I did not think about that. KDevelop uses 
the clang-c API and does fuzzy matching on top of the results, e.g. for 
camel-case matching. But, we currently always request code completion at a word 
start boundary so nothing would change for us. That said, I see how this patch 
could be seen as a breaking behavior change, and thus should probably only get 
enabled by an explicit option - if at all.


Repository:
  rL LLVM

http://reviews.llvm.org/D17820



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


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

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

Review Feedback



Comment at: include/clang/Basic/Attr.td:993-998
@@ +992,8 @@
+
+def AMDGPUToolsInsertNops : InheritableAttr {
+  let Spellings = [GNU<"amdgpu_tools_insert_nops">];
+  let Documentation = [AMDGPUToolsInsertNopsDocs];
+  let Subjects = SubjectList<[Function], ErrorDiag,
+ "ExpectedKernelFunction">;
+}
+

arsenm wrote:
> I didn't envision these as being user code facing attributes, and only the 
> function emission would add them. Is there a use for these being used 
> manually?
Tools team expressed a desire to have the ability to specify them manually as 
well.


Comment at: include/clang/Driver/Options.td:355-365
@@ -354,2 +354,13 @@
 def allowable__client : Separate<["-"], "allowable_client">;
+def amdgpu_tools_insert_nops :
+  Flag<["--"], "amdgpu-tools-insert-nops">, Flags<[CC1Option, HelpHidden]>,
+  HelpText<"Insert two nop instructions for each high level source statement">;
+def amdgpu_tools_num_reserved_vgpr :
+  Joined<["--"], "amdgpu-tools-num-reserved-vgpr=">,
+  Flags<[CC1Option, HelpHidden]>,
+  HelpText<"Reserve  vector registers">, MetaVarName<"">;
+def amdgpu_tools_num_reserved_sgpr :
+  Joined<["--"], "amdgpu-tools-num-reserved-sgpr=">,
+  Flags<[CC1Option, HelpHidden]>,
+  HelpText<"Reserve  scalar registers">, MetaVarName<"">;
 def ansi : Flag<["-", "--"], "ansi">;

arsenm wrote:
> These are user facing options, not cc1 flags? I wouldn't expect these to be 
> exposed to users, and they would just be implied by -g. Is there a need for 
> this? Even if there is some need for these, I don't see anything testing for 
> these with only -g
These should be independent of -g, user facing options. One of the use cases is 
profiler, where debug information is needed (-g), but no registers need to be 
reserved, no nops inserted.


Comment at: lib/CodeGen/CGCall.cpp:1601
@@ +1600,3 @@
+if (CodeGenOpts.AMDGPUToolsInsertNopsOpt)
+  FuncAttrs.addAttribute("amdgpu_tools_insert_nops");
+if (CodeGenOpts.AMDGPUToolsNumReservedVGPROpt)

arsenm wrote:
> I've been trying to switch to consistently using the '-' separates words 
> conventions most function attributes use.
Do you mean use '-' instead of '_' in attribute spellings?


http://reviews.llvm.org/D17764



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


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

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

Review Feedback - Updated diff


http://reviews.llvm.org/D17764

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

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

Re: [PATCH] D17820: Clang Code Completion Filtering

2016-03-02 Thread Argyrios Kyrtzidis via cfe-commits
akyrtzi added a comment.

In http://reviews.llvm.org/D17820#366638, @milianw wrote:

> But, we currently always request code completion at a word start boundary so 
> nothing would change for us. That said, I see how this patch could be seen as 
> a breaking behavior change, and thus should probably only get enabled by an 
> explicit option - if at all.


I actually think it is fine changing it so clang code-completion automatically 
adjusts to word boundary, I cannot think of a case where it is useful to not do 
that, or being aware of a client that does not already adjusts anyway.


Repository:
  rL LLVM

http://reviews.llvm.org/D17820



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


Re: [PATCH] D7982: Add readability-duplicate-include check to clang-tidy

2016-03-02 Thread Richard via cfe-commits
LegalizeAdulthood added a comment.

I need to update from review comments and upload a new diff.


http://reviews.llvm.org/D7982



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


Re: Add hasInClassInitializer matcher

2016-03-02 Thread Aaron Ballman via cfe-commits
On Wed, Mar 2, 2016 at 2:01 PM, Julian Bangert via cfe-commits
 wrote:
> This adds a matcher for C++ in Class initializers.
>
> ---
>  include/clang/ASTMatchers/ASTMatchers.h   | 14 ++
>  unittests/ASTMatchers/ASTMatchersTest.cpp |  7 +++
>  2 files changed, 21 insertions(+)
>
> diff --git a/include/clang/ASTMatchers/ASTMatchers.h
> b/include/clang/ASTMatchers/ASTMatchers.h

Please also generate the AST matcher documentation by running
dump-ast-matchers.py and register the function in Registry.cpp. Also,
if you can provide an svn patch instead of a git patch, it would be
appreciated (especially if you need someone to commit on your behalf).

> index 21a4969..6b0a5d6 100644
> --- a/include/clang/ASTMatchers/ASTMatchers.h
> +++ b/include/clang/ASTMatchers/ASTMatchers.h
> @@ -2848,6 +2848,20 @@ AST_MATCHER(CXXCtorInitializer, isMemberInitializer)
> {
>return Node.isMemberInitializer();
>  }
>
> +/// \brief Matches a C++ inClassInitializer matching the given matcher
> +///
> +/// Given:
> +/// \code
> +///   class A { int x = 1; };
> +/// \endcode
> +///
> +/// \c hasInClassInitializer(integerLiteral()) matches int x = 1
> +AST_MATCHER_P(FieldDecl, hasInClassInitializer,
> +  internal::Matcher, InnerMatcher) {
> +  return Node.hasInClassInitializer()
> +  && InnerMatcher.matches(*Node.getInClassInitializer(), Finder,
> Builder);
> +}
> +
>  /// \brief Matches any argument of a call expression or a constructor call
>  /// expression.
>  ///
> diff --git a/unittests/ASTMatchers/ASTMatchersTest.cpp
> b/unittests/ASTMatchers/ASTMatchersTest.cpp
> index 133dc70..15776d7 100644
> --- a/unittests/ASTMatchers/ASTMatchersTest.cpp
> +++ b/unittests/ASTMatchers/ASTMatchersTest.cpp
> @@ -2402,6 +2402,13 @@ TEST(HasAnyConstructorInitializer, IsBaseInitializer)
> {
>  hasName("E");
>  }
>
> +TEST(Matcher, inClassInitializer) {
> +  EXPECT_TRUE(matches("class A{ int x = 1; };",
> +  fieldDecl(hasInClassInitializer(integerLiteral();
> +  EXPECT_FALSE(matches("class A{ int x; void b() { x = 1; } };",

This should use EXPECT_TRUE and notMatches.

~Aaron

> +
> fieldDecl(hasInClassInitializer(integerLiteral();
> +}
> +
>  TEST(Matcher, NewExpression) {
>StatementMatcher New = cxxNewExpr();
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: Add hasInClassInitializer matcher

2016-03-02 Thread Richard Smith via cfe-commits
On Wed, Mar 2, 2016 at 12:06 PM, Aaron Ballman via cfe-commits
 wrote:
> On Wed, Mar 2, 2016 at 2:01 PM, Julian Bangert via cfe-commits
>  wrote:
>> This adds a matcher for C++ in Class initializers.
>>
>> ---
>>  include/clang/ASTMatchers/ASTMatchers.h   | 14 ++
>>  unittests/ASTMatchers/ASTMatchersTest.cpp |  7 +++
>>  2 files changed, 21 insertions(+)
>>
>> diff --git a/include/clang/ASTMatchers/ASTMatchers.h
>> b/include/clang/ASTMatchers/ASTMatchers.h
>
> Please also generate the AST matcher documentation by running
> dump-ast-matchers.py and register the function in Registry.cpp. Also,
> if you can provide an svn patch instead of a git patch, it would be
> appreciated (especially if you need someone to commit on your behalf).

Please also name this "hasDefaultMemberInitializer" to match the C++
standard's (fairly new) name for this feature. We'll rename Clang's
internals to match at some point soon.

>> index 21a4969..6b0a5d6 100644
>> --- a/include/clang/ASTMatchers/ASTMatchers.h
>> +++ b/include/clang/ASTMatchers/ASTMatchers.h
>> @@ -2848,6 +2848,20 @@ AST_MATCHER(CXXCtorInitializer, isMemberInitializer)
>> {
>>return Node.isMemberInitializer();
>>  }
>>
>> +/// \brief Matches a C++ inClassInitializer matching the given matcher
>> +///
>> +/// Given:
>> +/// \code
>> +///   class A { int x = 1; };
>> +/// \endcode
>> +///
>> +/// \c hasInClassInitializer(integerLiteral()) matches int x = 1
>> +AST_MATCHER_P(FieldDecl, hasInClassInitializer,
>> +  internal::Matcher, InnerMatcher) {
>> +  return Node.hasInClassInitializer()
>> +  && InnerMatcher.matches(*Node.getInClassInitializer(), Finder,
>> Builder);
>> +}
>> +
>>  /// \brief Matches any argument of a call expression or a constructor call
>>  /// expression.
>>  ///
>> diff --git a/unittests/ASTMatchers/ASTMatchersTest.cpp
>> b/unittests/ASTMatchers/ASTMatchersTest.cpp
>> index 133dc70..15776d7 100644
>> --- a/unittests/ASTMatchers/ASTMatchersTest.cpp
>> +++ b/unittests/ASTMatchers/ASTMatchersTest.cpp
>> @@ -2402,6 +2402,13 @@ TEST(HasAnyConstructorInitializer, IsBaseInitializer)
>> {
>>  hasName("E");
>>  }
>>
>> +TEST(Matcher, inClassInitializer) {
>> +  EXPECT_TRUE(matches("class A{ int x = 1; };",
>> +  fieldDecl(hasInClassInitializer(integerLiteral();
>> +  EXPECT_FALSE(matches("class A{ int x; void b() { x = 1; } };",
>
> This should use EXPECT_TRUE and notMatches.
>
> ~Aaron
>
>> +
>> fieldDecl(hasInClassInitializer(integerLiteral();
>> +}
>> +
>>  TEST(Matcher, NewExpression) {
>>StatementMatcher New = cxxNewExpr();
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17451: PR26448: [Sema] Fix determined type of ternary operator acting on two xvalue class types

2016-03-02 Thread Erik Pilkington via cfe-commits
erik.pilkington added a comment.

Ping!


http://reviews.llvm.org/D17451



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


Re: r262487 - test/Driver/cl-pch-errorhandling.cpp: Copy input file to a temporary

2016-03-02 Thread Nico Weber via cfe-commits
(A different fix would've been to just add /Fp%.pch to set the output path
to be not next to the inputs.)

On Wed, Mar 2, 2016 at 6:27 AM, Daniel Jasper via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: djasper
> Date: Wed Mar  2 08:26:59 2016
> New Revision: 262487
>
> URL: http://llvm.org/viewvc/llvm-project?rev=262487&view=rev
> Log:
> test/Driver/cl-pch-errorhandling.cpp: Copy input file to a temporary
> location as we cannot assume the location of the input file to be
> writable.
>
> Modified:
> cfe/trunk/test/Driver/cl-pch-errorhandling.cpp
>
> Modified: cfe/trunk/test/Driver/cl-pch-errorhandling.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-pch-errorhandling.cpp?rev=262487&r1=262486&r2=262487&view=diff
>
> ==
> --- cfe/trunk/test/Driver/cl-pch-errorhandling.cpp (original)
> +++ cfe/trunk/test/Driver/cl-pch-errorhandling.cpp Wed Mar  2 08:26:59 2016
> @@ -6,7 +6,8 @@
>  // code generation, which makes this test require an x86 backend.
>  // REQUIRES: x86-registered-target
>
> -// RUN: not %clang_cl -internal-enable-pch -Werror /Yc%S/Inputs/pchfile.h
> /FI%S/Inputs/pchfile.h /c -DERR_HEADER -- %s 2>&1 \
> +// RUN: cp %S/Inputs/pchfile.h %t.h
> +// RUN: not %clang_cl -internal-enable-pch -Werror /Yc%t.h /FI%t.h /c
> -DERR_HEADER -- %s 2>&1 \
>  // RUN:   | FileCheck %s
>
>  // CHECK: nope1
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r262487 - test/Driver/cl-pch-errorhandling.cpp: Copy input file to a temporary

2016-03-02 Thread Nico Weber via cfe-commits
Thanks!

On Wed, Mar 2, 2016 at 6:27 AM, Daniel Jasper via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: djasper
> Date: Wed Mar  2 08:26:59 2016
> New Revision: 262487
>
> URL: http://llvm.org/viewvc/llvm-project?rev=262487&view=rev
> Log:
> test/Driver/cl-pch-errorhandling.cpp: Copy input file to a temporary
> location as we cannot assume the location of the input file to be
> writable.
>
> Modified:
> cfe/trunk/test/Driver/cl-pch-errorhandling.cpp
>
> Modified: cfe/trunk/test/Driver/cl-pch-errorhandling.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-pch-errorhandling.cpp?rev=262487&r1=262486&r2=262487&view=diff
>
> ==
> --- cfe/trunk/test/Driver/cl-pch-errorhandling.cpp (original)
> +++ cfe/trunk/test/Driver/cl-pch-errorhandling.cpp Wed Mar  2 08:26:59 2016
> @@ -6,7 +6,8 @@
>  // code generation, which makes this test require an x86 backend.
>  // REQUIRES: x86-registered-target
>
> -// RUN: not %clang_cl -internal-enable-pch -Werror /Yc%S/Inputs/pchfile.h
> /FI%S/Inputs/pchfile.h /c -DERR_HEADER -- %s 2>&1 \
> +// RUN: cp %S/Inputs/pchfile.h %t.h
> +// RUN: not %clang_cl -internal-enable-pch -Werror /Yc%t.h /FI%t.h /c
> -DERR_HEADER -- %s 2>&1 \
>  // RUN:   | FileCheck %s
>
>  // CHECK: nope1
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r262515 - [PGO] Change profile use cc1 option to handle IR level profiles

2016-03-02 Thread Rong Xu via cfe-commits
Author: xur
Date: Wed Mar  2 14:59:36 2016
New Revision: 262515

URL: http://llvm.org/viewvc/llvm-project?rev=262515&view=rev
Log:
[PGO] Change profile use cc1 option to handle IR level profiles

This patch changes cc1 option for PGO profile use from
-fprofile-instr-use= to -fprofile-instrument-use-path=.
-fprofile-instr-use= is now a driver only option.

In addition to decouple the cc1 option from the driver level option, this patch
also enables IR level profile use. cc1 option handling now reads the profile
header and sets CodeGenOpt ProfileUse (valid values are {None, Clang, LLVM}
-- this is a common enum for -fprofile-instrument={}, for the profile
instrumentation), and invoke the pipeline to enable the respective PGO use pass.

Reviewers: silvas, davidxl

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

Added:
cfe/trunk/test/CodeGen/Inputs/pgotestclang.profraw
cfe/trunk/test/CodeGen/Inputs/pgotestir.profraw
Modified:
cfe/trunk/include/clang/Driver/CC1Options.td
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/include/clang/Frontend/CodeGenOptions.def
cfe/trunk/include/clang/Frontend/CodeGenOptions.h
cfe/trunk/lib/CodeGen/BackendUtil.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/lib/Frontend/CMakeLists.txt
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/test/CodeGen/pgo-instrumentation.c
cfe/trunk/test/Driver/clang_f_opts.c
cfe/trunk/test/Profile/c-captured.c
cfe/trunk/test/Profile/c-counter-overflows.c
cfe/trunk/test/Profile/c-general.c
cfe/trunk/test/Profile/c-outdated-data.c
cfe/trunk/test/Profile/c-unprofiled-blocks.c
cfe/trunk/test/Profile/c-unprofiled.c
cfe/trunk/test/Profile/cxx-lambda.cpp
cfe/trunk/test/Profile/cxx-rangefor.cpp
cfe/trunk/test/Profile/cxx-templates.cpp
cfe/trunk/test/Profile/objc-general.m
cfe/trunk/test/Profile/profile-does-not-exist.c

Modified: cfe/trunk/include/clang/Driver/CC1Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=262515&r1=262514&r2=262515&view=diff
==
--- cfe/trunk/include/clang/Driver/CC1Options.td (original)
+++ cfe/trunk/include/clang/Driver/CC1Options.td Wed Mar  2 14:59:36 2016
@@ -279,6 +279,9 @@ def fprofile_instrument_EQ : Joined<["-"
 def fprofile_instrument_path_EQ : Joined<["-"], "fprofile-instrument-path=">,
 HelpText<"Generate instrumented code to collect execution counts into "
  " (overridden by LLVM_PROFILE_FILE env var)">;
+def fprofile_instrument_use_path_EQ :
+Joined<["-"], "fprofile-instrument-use-path=">,
+HelpText<"Specify the profile path in PGO use compilation">;
 
 
//===--===//
 // Dependency Output Options

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=262515&r1=262514&r2=262515&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Wed Mar  2 14:59:36 2016
@@ -462,7 +462,7 @@ def fprofile_instr_generate_EQ : Joined<
 def fprofile_instr_use : Flag<["-"], "fprofile-instr-use">, Group,
 Flags<[DriverOption]>;
 def fprofile_instr_use_EQ : Joined<["-"], "fprofile-instr-use=">,
-Group, Flags<[CC1Option]>,
+Group, Flags<[DriverOption]>,
 HelpText<"Use instrumentation data for profile-guided optimization">;
 def fcoverage_mapping : Flag<["-"], "fcoverage-mapping">,
 Group, Flags<[CC1Option]>,

Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.def?rev=262515&r1=262514&r2=262515&view=diff
==
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.def (original)
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def Wed Mar  2 14:59:36 2016
@@ -105,6 +105,8 @@ VALUE_CODEGENOPT(OptimizeSize, 2, 0) ///
 
 /// \brief Choose profile instrumenation kind or no instrumentation.
 ENUM_CODEGENOPT(ProfileInstr, ProfileInstrKind, 2, ProfileNone)
+/// \brief Choose profile kind for PGO use compilation.
+ENUM_CODEGENOPT(ProfileUse, ProfileInstrKind, 2, ProfileNone)
 CODEGENOPT(CoverageMapping , 1, 0) ///< Generate coverage mapping regions to
///< enable code coverage analysis.
 CODEGENOPT(DumpCoverageMapping , 1, 0) ///< Dump the generated coverage mapping

Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.h?rev=262515&r1=262514&r2=262515&view=diff
==
--- cfe/trunk/i

Re: [PATCH] D17737: [PGO] change profile use cc1 option

2016-03-02 Thread Rong Xu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL262515: [PGO] Change profile use cc1 option to handle IR 
level profiles (authored by xur).

Changed prior to commit:
  http://reviews.llvm.org/D17737?vs=49655&id=49664#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D17737

Files:
  cfe/trunk/include/clang/Driver/CC1Options.td
  cfe/trunk/include/clang/Driver/Options.td
  cfe/trunk/include/clang/Frontend/CodeGenOptions.def
  cfe/trunk/include/clang/Frontend/CodeGenOptions.h
  cfe/trunk/lib/CodeGen/BackendUtil.cpp
  cfe/trunk/lib/CodeGen/CodeGenModule.cpp
  cfe/trunk/lib/Driver/Tools.cpp
  cfe/trunk/lib/Frontend/CMakeLists.txt
  cfe/trunk/lib/Frontend/CompilerInvocation.cpp
  cfe/trunk/test/CodeGen/Inputs/pgotestclang.profraw
  cfe/trunk/test/CodeGen/Inputs/pgotestir.profraw
  cfe/trunk/test/CodeGen/pgo-instrumentation.c
  cfe/trunk/test/Driver/clang_f_opts.c
  cfe/trunk/test/Profile/c-captured.c
  cfe/trunk/test/Profile/c-counter-overflows.c
  cfe/trunk/test/Profile/c-general.c
  cfe/trunk/test/Profile/c-outdated-data.c
  cfe/trunk/test/Profile/c-unprofiled-blocks.c
  cfe/trunk/test/Profile/c-unprofiled.c
  cfe/trunk/test/Profile/cxx-lambda.cpp
  cfe/trunk/test/Profile/cxx-rangefor.cpp
  cfe/trunk/test/Profile/cxx-templates.cpp
  cfe/trunk/test/Profile/objc-general.m
  cfe/trunk/test/Profile/profile-does-not-exist.c

Index: cfe/trunk/include/clang/Frontend/CodeGenOptions.def
===
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.def
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def
@@ -105,6 +105,8 @@
 
 /// \brief Choose profile instrumenation kind or no instrumentation.
 ENUM_CODEGENOPT(ProfileInstr, ProfileInstrKind, 2, ProfileNone)
+/// \brief Choose profile kind for PGO use compilation.
+ENUM_CODEGENOPT(ProfileUse, ProfileInstrKind, 2, ProfileNone)
 CODEGENOPT(CoverageMapping , 1, 0) ///< Generate coverage mapping regions to
///< enable code coverage analysis.
 CODEGENOPT(DumpCoverageMapping , 1, 0) ///< Dump the generated coverage mapping
Index: cfe/trunk/include/clang/Frontend/CodeGenOptions.h
===
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.h
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.h
@@ -153,7 +153,7 @@
   std::string SampleProfileFile;
 
   /// Name of the profile file to use as input for -fprofile-instr-use
-  std::string InstrProfileInput;
+  std::string ProfileInstrumentUsePath;
 
   /// Name of the function summary index file to use for ThinLTO function
   /// importing.
@@ -232,6 +232,16 @@
   bool hasProfileIRInstr() const {
 return getProfileInstr() == ProfileIRInstr;
   }
+
+  /// \brief Check if Clang profile use is on.
+  bool hasProfileClangUse() const {
+return getProfileUse() == ProfileClangInstr;
+  }
+
+  /// \brief Check if IR level profile use is on.
+  bool hasProfileIRUse() const {
+return getProfileUse() == ProfileIRInstr;
+  }
 };
 
 }  // end namespace clang
Index: cfe/trunk/include/clang/Driver/Options.td
===
--- cfe/trunk/include/clang/Driver/Options.td
+++ cfe/trunk/include/clang/Driver/Options.td
@@ -462,7 +462,7 @@
 def fprofile_instr_use : Flag<["-"], "fprofile-instr-use">, Group,
 Flags<[DriverOption]>;
 def fprofile_instr_use_EQ : Joined<["-"], "fprofile-instr-use=">,
-Group, Flags<[CC1Option]>,
+Group, Flags<[DriverOption]>,
 HelpText<"Use instrumentation data for profile-guided optimization">;
 def fcoverage_mapping : Flag<["-"], "fcoverage-mapping">,
 Group, Flags<[CC1Option]>,
Index: cfe/trunk/include/clang/Driver/CC1Options.td
===
--- cfe/trunk/include/clang/Driver/CC1Options.td
+++ cfe/trunk/include/clang/Driver/CC1Options.td
@@ -279,6 +279,9 @@
 def fprofile_instrument_path_EQ : Joined<["-"], "fprofile-instrument-path=">,
 HelpText<"Generate instrumented code to collect execution counts into "
  " (overridden by LLVM_PROFILE_FILE env var)">;
+def fprofile_instrument_use_path_EQ :
+Joined<["-"], "fprofile-instrument-use-path=">,
+HelpText<"Specify the profile path in PGO use compilation">;
 
 //===--===//
 // Dependency Output Options
Index: cfe/trunk/test/Profile/cxx-rangefor.cpp
===
--- cfe/trunk/test/Profile/cxx-rangefor.cpp
+++ cfe/trunk/test/Profile/cxx-rangefor.cpp
@@ -4,7 +4,7 @@
 // RUN: FileCheck --input-file=%tgen -check-prefix=CHECK -check-prefix=PGOGEN %s
 
 // RUN: llvm-profdata merge %S/Inputs/cxx-rangefor.proftext -o %t.profdata
-// RUN: %clang_cc1 -x c++ %s -triple %itanium_abi_triple -main-file-name cxx-rangefor.cpp -std=c++11 -o - -emit-llvm -fprofile-instr-use=%t.profdata > %tuse
+// RUN: %clang_cc1 -

r262516 - Fixed test failure platforms with name mangling different from Linux.

2016-03-02 Thread Artem Belevich via cfe-commits
Author: tra
Date: Wed Mar  2 15:03:20 2016
New Revision: 262516

URL: http://llvm.org/viewvc/llvm-project?rev=262516&view=rev
Log:
Fixed test failure platforms with name mangling different from Linux.
* Run cc with -triple x86_64-linux-gnu to make symbol mangling predictable.
* Use temporary file as a fake GPU input so its content
  does not interfere with pattern matching.

Modified:
cfe/trunk/test/CodeGenCUDA/device-stub.cu

Modified: cfe/trunk/test/CodeGenCUDA/device-stub.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCUDA/device-stub.cu?rev=262516&r1=262515&r2=262516&view=diff
==
--- cfe/trunk/test/CodeGenCUDA/device-stub.cu (original)
+++ cfe/trunk/test/CodeGenCUDA/device-stub.cu Wed Mar  2 15:03:20 2016
@@ -1,7 +1,8 @@
-// RUN: %clang_cc1 -emit-llvm %s -fcuda-include-gpubinary %s -o - | FileCheck 
%s
-// RUN: %clang_cc1 -emit-llvm %s -fcuda-include-gpubinary %s -o -  -DNOGLOBALS 
\
+// RUN: echo "GPU binary would be here" > %t
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s 
-fcuda-include-gpubinary %t -o - | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s 
-fcuda-include-gpubinary %t -o -  -DNOGLOBALS \
 // RUN:   | FileCheck %s -check-prefix=NOGLOBALS
-// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s -check-prefix=NOGPUBIN
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s -o - | FileCheck %s 
-check-prefix=NOGPUBIN
 
 #include "Inputs/cuda.h"
 


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


Re: r262487 - test/Driver/cl-pch-errorhandling.cpp: Copy input file to a temporary

2016-03-02 Thread Daniel Jasper via cfe-commits
Feel free to change. I have no idea what I am doing here.

On Wed, Mar 2, 2016 at 12:55 PM, Nico Weber  wrote:

> (A different fix would've been to just add /Fp%.pch to set the output path
> to be not next to the inputs.)
>
> On Wed, Mar 2, 2016 at 6:27 AM, Daniel Jasper via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: djasper
>> Date: Wed Mar  2 08:26:59 2016
>> New Revision: 262487
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=262487&view=rev
>> Log:
>> test/Driver/cl-pch-errorhandling.cpp: Copy input file to a temporary
>> location as we cannot assume the location of the input file to be
>> writable.
>>
>> Modified:
>> cfe/trunk/test/Driver/cl-pch-errorhandling.cpp
>>
>> Modified: cfe/trunk/test/Driver/cl-pch-errorhandling.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-pch-errorhandling.cpp?rev=262487&r1=262486&r2=262487&view=diff
>>
>> ==
>> --- cfe/trunk/test/Driver/cl-pch-errorhandling.cpp (original)
>> +++ cfe/trunk/test/Driver/cl-pch-errorhandling.cpp Wed Mar  2 08:26:59
>> 2016
>> @@ -6,7 +6,8 @@
>>  // code generation, which makes this test require an x86 backend.
>>  // REQUIRES: x86-registered-target
>>
>> -// RUN: not %clang_cl -internal-enable-pch -Werror
>> /Yc%S/Inputs/pchfile.h /FI%S/Inputs/pchfile.h /c -DERR_HEADER -- %s 2>&1 \
>> +// RUN: cp %S/Inputs/pchfile.h %t.h
>> +// RUN: not %clang_cl -internal-enable-pch -Werror /Yc%t.h /FI%t.h /c
>> -DERR_HEADER -- %s 2>&1 \
>>  // RUN:   | FileCheck %s
>>
>>  // CHECK: nope1
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: Add hasInClassInitializer matcher

2016-03-02 Thread Julian Bangert via cfe-commits
In case my MUA messed up the formatting, see the attached

On Wed, Mar 2, 2016 at 1:14 PM Julian Bangert  wrote:

> Here is a patch to SVN with the requested changes (documentation, renamed
> and added to registry):
>
> Index: docs/LibASTMatchersReference.html
> ===
> --- docs/LibASTMatchersReference.html (revision 262512)
> +++ docs/LibASTMatchersReference.html (working copy)
> @@ -2412,7 +2412,7 @@
>  
>
>
> -MatcherNamedDecl> class="name" onclick="toggle('hasName0')"> name="hasName0Anchor">hasNamestd::string Name
> +MatcherNamedDecl> class="name" onclick="toggle('hasName0')"> name="hasName0Anchor">hasNamestd::string  Name
>  Matches NamedDecl
> nodes that have the specified name.
>
>  Supports specifying enclosing namespaces or classes by prefixing the name
> @@ -3107,7 +3107,7 @@
>
>  This matcher is only provided as a performance optimization of hasName.
>  hasAnyName(a, b, c)
> - is equivalent but faster than
> + is equivalent to, but faster than
>  anyOf(hasName(a), hasName(b), hasName(c))
>  
>
> @@ -4180,6 +4180,16 @@
>  
>
>
> +MatcherFieldDecl> class="name" onclick="toggle('hasDefaultMemberInitializer0')"> name="hasDefaultMemberInitializer0Anchor">hasDefaultMemberInitializerMatcher< href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html";>Expr>
> InnerMatcher
> + id="hasDefaultMemberInitializer0">Matches a C++ default member
> initializer matching the given matcher
> +
> +Given:
> +  class A { int x = 1; };
> +
> +hasDefaultMemberInitializer(integerLiteral()) matches int x = 1
> +
> +
> +
>  MatcherForStmt> class="name" onclick="toggle('hasBody1')"> name="hasBody1Anchor">hasBodyMatcherStmt>
> InnerMatcher
>  Matches a 'for',
> 'while', 'do while' statement or a function
>  definition that has a given body.
> Index: include/clang/ASTMatchers/ASTMatchers.h
> ===
> --- include/clang/ASTMatchers/ASTMatchers.h (revision 262512)
> +++ include/clang/ASTMatchers/ASTMatchers.h (working copy)
> @@ -2848,6 +2848,20 @@
>return Node.isMemberInitializer();
>  }
>
> +/// \brief Matches a C++ default member initializer matching the given
> matcher
> +///
> +/// Given:
> +/// \code
> +///   class A { int x = 1; };
> +/// \endcode
> +///
> +/// \c hasDefaultMemberInitializer(integerLiteral()) matches int x = 1
> +AST_MATCHER_P(FieldDecl, hasDefaultMemberInitializer,
> +  internal::Matcher, InnerMatcher) {
> +  return Node.hasInClassInitializer()
> +  && InnerMatcher.matches(*Node.getInClassInitializer(), Finder,
> Builder);
> +}
> +
>  /// \brief Matches any argument of a call expression or a constructor call
>  /// expression.
>  ///
> Index: lib/ASTMatchers/Dynamic/Registry.cpp
> ===
> --- lib/ASTMatchers/Dynamic/Registry.cpp (revision 262512)
> +++ lib/ASTMatchers/Dynamic/Registry.cpp (working copy)
> @@ -210,6 +210,7 @@
>REGISTER_MATCHER(hasDeclaration);
>REGISTER_MATCHER(hasDeclContext);
>REGISTER_MATCHER(hasDeducedType);
> +  REGISTER_MATCHER(hasDefaultMemberInitializer);
>REGISTER_MATCHER(hasDescendant);
>REGISTER_MATCHER(hasDestinationType);
>REGISTER_MATCHER(hasEitherOperand);
> Index: unittests/ASTMatchers/ASTMatchersTest.cpp
> ===
> --- unittests/ASTMatchers/ASTMatchersTest.cpp (revision 262512)
> +++ unittests/ASTMatchers/ASTMatchersTest.cpp (working copy)
> @@ -2402,6 +2402,13 @@
>  hasName("E");
>  }
>
> +TEST(Matcher, inDefaultMemberInitializer) {
> +  EXPECT_TRUE(matches("class A{ int x = 1; };",
> +
>  fieldDecl(hasDefaultMemberInitializer(integerLiteral();
> +  EXPECT_TRUE(notMatches("class A{ int x; void b() { x = 1; } };",
> +
> fieldDecl(hasDefaultMemberInitializer(integerLiteral();
> +}
> +
>  TEST(Matcher, NewExpression) {
>StatementMatcher New = cxxNewExpr();
>
>
>
> On Wed, Mar 2, 2016 at 12:23 PM Richard Smith 
> wrote:
>
>> On Wed, Mar 2, 2016 at 12:06 PM, Aaron Ballman via cfe-commits
>>  wrote:
>> > On Wed, Mar 2, 2016 at 2:01 PM, Julian Bangert via cfe-commits
>> >  wrote:
>> >> This adds a matcher for C++ in Class initializers.
>> >>
>> >> ---
>> >>  include/clang/ASTMatchers/ASTMatchers.h   | 14 ++
>> >>  unittests/ASTMatchers/ASTMatchersTest.cpp |  7 +++
>> >>  2 files changed, 21 insertions(+)
>> >>
>> >> diff --git a/include/clang/ASTMatchers/ASTMatchers.h
>> >> b/include/clang/ASTMatchers/ASTMatchers.h
>> >
>> > Please also generate the AST matcher documentation by running
>> > dump-ast-matchers.py and register the function in Registry.cp

Re: Add hasInClassInitializer matcher

2016-03-02 Thread Julian Bangert via cfe-commits
Here is a patch to SVN with the requested changes (documentation, renamed
and added to registry):

Index: docs/LibASTMatchersReference.html
===
--- docs/LibASTMatchersReference.html (revision 262512)
+++ docs/LibASTMatchersReference.html (working copy)
@@ -2412,7 +2412,7 @@
 


-MatcherNamedDecl>hasNamestd::string Name
+MatcherNamedDecl>hasNamestd::string  Name
 Matches NamedDecl nodes
that have the specified name.

 Supports specifying enclosing namespaces or classes by prefixing the name
@@ -3107,7 +3107,7 @@

 This matcher is only provided as a performance optimization of hasName.
 hasAnyName(a, b, c)
- is equivalent but faster than
+ is equivalent to, but faster than
 anyOf(hasName(a), hasName(b), hasName(c))
 

@@ -4180,6 +4180,16 @@
 


+MatcherFieldDecl>hasDefaultMemberInitializerMatcherExpr>
InnerMatcher
+Matches a C++ default member
initializer matching the given matcher
+
+Given:
+  class A { int x = 1; };
+
+hasDefaultMemberInitializer(integerLiteral()) matches int x = 1
+
+
+
 MatcherForStmt>hasBodyMatcherStmt>
InnerMatcher
 Matches a 'for',
'while', 'do while' statement or a function
 definition that has a given body.
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h (revision 262512)
+++ include/clang/ASTMatchers/ASTMatchers.h (working copy)
@@ -2848,6 +2848,20 @@
   return Node.isMemberInitializer();
 }

+/// \brief Matches a C++ default member initializer matching the given
matcher
+///
+/// Given:
+/// \code
+///   class A { int x = 1; };
+/// \endcode
+///
+/// \c hasDefaultMemberInitializer(integerLiteral()) matches int x = 1
+AST_MATCHER_P(FieldDecl, hasDefaultMemberInitializer,
+  internal::Matcher, InnerMatcher) {
+  return Node.hasInClassInitializer()
+  && InnerMatcher.matches(*Node.getInClassInitializer(), Finder,
Builder);
+}
+
 /// \brief Matches any argument of a call expression or a constructor call
 /// expression.
 ///
Index: lib/ASTMatchers/Dynamic/Registry.cpp
===
--- lib/ASTMatchers/Dynamic/Registry.cpp (revision 262512)
+++ lib/ASTMatchers/Dynamic/Registry.cpp (working copy)
@@ -210,6 +210,7 @@
   REGISTER_MATCHER(hasDeclaration);
   REGISTER_MATCHER(hasDeclContext);
   REGISTER_MATCHER(hasDeducedType);
+  REGISTER_MATCHER(hasDefaultMemberInitializer);
   REGISTER_MATCHER(hasDescendant);
   REGISTER_MATCHER(hasDestinationType);
   REGISTER_MATCHER(hasEitherOperand);
Index: unittests/ASTMatchers/ASTMatchersTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersTest.cpp (revision 262512)
+++ unittests/ASTMatchers/ASTMatchersTest.cpp (working copy)
@@ -2402,6 +2402,13 @@
 hasName("E");
 }

+TEST(Matcher, inDefaultMemberInitializer) {
+  EXPECT_TRUE(matches("class A{ int x = 1; };",
+
 fieldDecl(hasDefaultMemberInitializer(integerLiteral();
+  EXPECT_TRUE(notMatches("class A{ int x; void b() { x = 1; } };",
+
fieldDecl(hasDefaultMemberInitializer(integerLiteral();
+}
+
 TEST(Matcher, NewExpression) {
   StatementMatcher New = cxxNewExpr();



On Wed, Mar 2, 2016 at 12:23 PM Richard Smith  wrote:

> On Wed, Mar 2, 2016 at 12:06 PM, Aaron Ballman via cfe-commits
>  wrote:
> > On Wed, Mar 2, 2016 at 2:01 PM, Julian Bangert via cfe-commits
> >  wrote:
> >> This adds a matcher for C++ in Class initializers.
> >>
> >> ---
> >>  include/clang/ASTMatchers/ASTMatchers.h   | 14 ++
> >>  unittests/ASTMatchers/ASTMatchersTest.cpp |  7 +++
> >>  2 files changed, 21 insertions(+)
> >>
> >> diff --git a/include/clang/ASTMatchers/ASTMatchers.h
> >> b/include/clang/ASTMatchers/ASTMatchers.h
> >
> > Please also generate the AST matcher documentation by running
> > dump-ast-matchers.py and register the function in Registry.cpp. Also,
> > if you can provide an svn patch instead of a git patch, it would be
> > appreciated (especially if you need someone to commit on your behalf).
>
> Please also name this "hasDefaultMemberInitializer" to match the C++
> standard's (fairly new) name for this feature. We'll rename Clang's
> internals to match at some point soon.
>
> >> index 21a4969..6b0a5d6 100644
> >> --- a/include/clang/ASTMatchers/ASTMatchers.h
> >> +++ b/include/clang/ASTMatchers/ASTMatchers.h
> >> @@ -2848,6 +2848,20 @@ AST_MATCHER(CXXCtorInitializer,
> isMemberInitializer)
> >> {
> >>return Node.isMemberInitializer();
> >>  }
> >>
> >> +/// \brief Matches a C++ inClassInitializer matching 

Re: Add hasInClassInitializer matcher

2016-03-02 Thread Aaron Ballman via cfe-commits
On Wed, Mar 2, 2016 at 4:14 PM, Julian Bangert  wrote:
> Here is a patch to SVN with the requested changes (documentation, renamed
> and added to registry):

LGTM!

~Aaron

>
> Index: docs/LibASTMatchersReference.html
> ===
> --- docs/LibASTMatchersReference.html (revision 262512)
> +++ docs/LibASTMatchersReference.html (working copy)
> @@ -2412,7 +2412,7 @@
>  
>
>
> -Matcher< href="http://clang.llvm.org/doxygen/classclang_1_1NamedDecl.html";>NamedDecl> class="name" onclick="toggle('hasName0')"> name="hasName0Anchor">hasNamestd::string Name
> +Matcher< href="http://clang.llvm.org/doxygen/classclang_1_1NamedDecl.html";>NamedDecl> class="name" onclick="toggle('hasName0')"> name="hasName0Anchor">hasNamestd::string  Name
>  Matches NamedDecl nodes
> that have the specified name.
>
>  Supports specifying enclosing namespaces or classes by prefixing the name
> @@ -3107,7 +3107,7 @@
>
>  This matcher is only provided as a performance optimization of hasName.
>  hasAnyName(a, b, c)
> - is equivalent but faster than
> + is equivalent to, but faster than
>  anyOf(hasName(a), hasName(b), hasName(c))
>  
>
> @@ -4180,6 +4180,16 @@
>  
>
>
> +Matcher< href="http://clang.llvm.org/doxygen/classclang_1_1FieldDecl.html";>FieldDecl> class="name" onclick="toggle('hasDefaultMemberInitializer0')"> name="hasDefaultMemberInitializer0Anchor">hasDefaultMemberInitializerMatcher< href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html";>Expr>
> InnerMatcher
> + id="hasDefaultMemberInitializer0">Matches a C++ default member
> initializer matching the given matcher
> +
> +Given:
> +  class A { int x = 1; };
> +
> +hasDefaultMemberInitializer(integerLiteral()) matches int x = 1
> +
> +
> +
>  Matcher< href="http://clang.llvm.org/doxygen/classclang_1_1ForStmt.html";>ForStmt> class="name" onclick="toggle('hasBody1')"> name="hasBody1Anchor">hasBodyMatcher< href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html";>Stmt>
> InnerMatcher
>  Matches a 'for',
> 'while', 'do while' statement or a function
>  definition that has a given body.
> Index: include/clang/ASTMatchers/ASTMatchers.h
> ===
> --- include/clang/ASTMatchers/ASTMatchers.h (revision 262512)
> +++ include/clang/ASTMatchers/ASTMatchers.h (working copy)
> @@ -2848,6 +2848,20 @@
>return Node.isMemberInitializer();
>  }
>
> +/// \brief Matches a C++ default member initializer matching the given
> matcher
> +///
> +/// Given:
> +/// \code
> +///   class A { int x = 1; };
> +/// \endcode
> +///
> +/// \c hasDefaultMemberInitializer(integerLiteral()) matches int x = 1
> +AST_MATCHER_P(FieldDecl, hasDefaultMemberInitializer,
> +  internal::Matcher, InnerMatcher) {
> +  return Node.hasInClassInitializer()
> +  && InnerMatcher.matches(*Node.getInClassInitializer(), Finder,
> Builder);
> +}
> +
>  /// \brief Matches any argument of a call expression or a constructor call
>  /// expression.
>  ///
> Index: lib/ASTMatchers/Dynamic/Registry.cpp
> ===
> --- lib/ASTMatchers/Dynamic/Registry.cpp (revision 262512)
> +++ lib/ASTMatchers/Dynamic/Registry.cpp (working copy)
> @@ -210,6 +210,7 @@
>REGISTER_MATCHER(hasDeclaration);
>REGISTER_MATCHER(hasDeclContext);
>REGISTER_MATCHER(hasDeducedType);
> +  REGISTER_MATCHER(hasDefaultMemberInitializer);
>REGISTER_MATCHER(hasDescendant);
>REGISTER_MATCHER(hasDestinationType);
>REGISTER_MATCHER(hasEitherOperand);
> Index: unittests/ASTMatchers/ASTMatchersTest.cpp
> ===
> --- unittests/ASTMatchers/ASTMatchersTest.cpp (revision 262512)
> +++ unittests/ASTMatchers/ASTMatchersTest.cpp (working copy)
> @@ -2402,6 +2402,13 @@
>  hasName("E");
>  }
>
> +TEST(Matcher, inDefaultMemberInitializer) {
> +  EXPECT_TRUE(matches("class A{ int x = 1; };",
> +
> fieldDecl(hasDefaultMemberInitializer(integerLiteral();
> +  EXPECT_TRUE(notMatches("class A{ int x; void b() { x = 1; } };",
> +
> fieldDecl(hasDefaultMemberInitializer(integerLiteral();
> +}
> +
>  TEST(Matcher, NewExpression) {
>StatementMatcher New = cxxNewExpr();
>
>
>
> On Wed, Mar 2, 2016 at 12:23 PM Richard Smith  wrote:
>>
>> On Wed, Mar 2, 2016 at 12:06 PM, Aaron Ballman via cfe-commits
>>  wrote:
>> > On Wed, Mar 2, 2016 at 2:01 PM, Julian Bangert via cfe-commits
>> >  wrote:
>> >> This adds a matcher for C++ in Class initializers.
>> >>
>> >> ---
>> >>  include/clang/ASTMatchers/ASTMatchers.h   | 14 ++
>> >>  unittests/ASTMatchers/ASTMatchersTest.cpp |  7 +++
>> >>  2 files changed, 21 insertions(+)
>> >>
>> >> diff --git a/include/clang/ASTMatchers/ASTMatchers.h
>> >> b/include/clang/ASTMatchers/ASTMatchers.h
>> >
>> > Please also generate the AST matcher documentation by running
>> > dump-ast-matchers.py and register the function in Registry.cpp. Also,
>

r262520 - [analyzer] Fix capitalization in ObjCSuperDeallocChecker diagnostic.

2016-03-02 Thread Devin Coughlin via cfe-commits
Author: dcoughlin
Date: Wed Mar  2 15:22:48 2016
New Revision: 262520

URL: http://llvm.org/viewvc/llvm-project?rev=262520&view=rev
Log:
[analyzer] Fix capitalization in ObjCSuperDeallocChecker diagnostic.

Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCSuperDeallocChecker.cpp
cfe/trunk/test/Analysis/DeallocUseAfterFreeErrors.m

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCSuperDeallocChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCSuperDeallocChecker.cpp?rev=262520&r1=262519&r2=262520&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCSuperDeallocChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCSuperDeallocChecker.cpp Wed Mar  
2 15:22:48 2016
@@ -165,7 +165,7 @@ void ObjCSuperDeallocChecker::checkLocat
   std::string Buf;
   llvm::raw_string_ostream OS(Buf);
   if (IvarRegion) {
-OS << "use of instance variable '" << *IvarRegion->getDecl() <<
+OS << "Use of instance variable '" << *IvarRegion->getDecl() <<
   "' after 'self' has been deallocated";
 Desc = OS.str();
   }

Modified: cfe/trunk/test/Analysis/DeallocUseAfterFreeErrors.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/DeallocUseAfterFreeErrors.m?rev=262520&r1=262519&r2=262520&view=diff
==
--- cfe/trunk/test/Analysis/DeallocUseAfterFreeErrors.m (original)
+++ cfe/trunk/test/Analysis/DeallocUseAfterFreeErrors.m Wed Mar  2 15:22:48 2016
@@ -36,8 +36,8 @@ typedef struct objc_selector *SEL;
 }
 - (void)dealloc {
   [super dealloc]; // expected-note {{[super dealloc] called here}}
-  [_ivar release]; // expected-warning {{use of instance variable '_ivar' 
after 'self' has been deallocated}}
-  // expected-note@-1 {{use of instance variable '_ivar' after 'self' has been 
deallocated}}
+  [_ivar release]; // expected-warning {{Use of instance variable '_ivar' 
after 'self' has been deallocated}}
+  // expected-note@-1 {{Use of instance variable '_ivar' after 'self' has been 
deallocated}}
 }
 @end
 
@@ -56,8 +56,8 @@ typedef struct objc_selector *SEL;
 }
 - (void)dealloc {
   [super dealloc]; // expected-note {{[super dealloc] called here}}
-  _delegate = nil; // expected-warning {{use of instance variable '_delegate' 
after 'self' has been deallocated}}
-  // expected-note@-1 {{use of instance variable '_delegate' after 'self' 
has been deallocated}}
+  _delegate = nil; // expected-warning {{Use of instance variable '_delegate' 
after 'self' has been deallocated}}
+  // expected-note@-1 {{Use of instance variable '_delegate' after 'self' 
has been deallocated}}
 }
 @end
 
@@ -74,8 +74,8 @@ struct SomeStruct {
 @implementation SuperDeallocThenAssignIvarField
 - (void)dealloc {
   [super dealloc]; // expected-note {{[super dealloc] called here}}
-  _s.f = 7; // expected-warning {{use of instance variable '_s' after 'self' 
has been deallocated}}
-  // expected-note@-1 {{use of instance variable '_s' after 'self' has 
been deallocated}}
+  _s.f = 7; // expected-warning {{Use of instance variable '_s' after 'self' 
has been deallocated}}
+  // expected-note@-1 {{Use of instance variable '_s' after 'self' has 
been deallocated}}
 }
 @end
 
@@ -93,8 +93,8 @@ struct SomeStruct {
 @implementation SuperDeallocThenAssignIvarIvar
 - (void)dealloc {
   [super dealloc]; // expected-note {{[super dealloc] called here}}
-  _ivar->_otherIvar = 7; // expected-warning {{use of instance variable 
'_ivar' after 'self' has been deallocated}}
-  // expected-note@-1 {{use of instance variable '_ivar' after 'self' has 
been deallocated}}
+  _ivar->_otherIvar = 7; // expected-warning {{Use of instance variable 
'_ivar' after 'self' has been deallocated}}
+  // expected-note@-1 {{Use of instance variable '_ivar' after 'self' has 
been deallocated}}
 }
 @end
 
@@ -106,8 +106,8 @@ struct SomeStruct {
 @implementation SuperDeallocThenAssignSelfIvar
 - (void)dealloc {
   [super dealloc]; // expected-note {{[super dealloc] called here}}
-  self->_ivar = nil; // expected-warning {{use of instance variable '_ivar' 
after 'self' has been deallocated}}
-  // expected-note@-1 {{use of instance variable '_ivar' after 'self' has 
been deallocated}}
+  self->_ivar = nil; // expected-warning {{Use of instance variable '_ivar' 
after 'self' has been deallocated}}
+  // expected-note@-1 {{Use of instance variable '_ivar' after 'self' has 
been deallocated}}
 }
 @end
 


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


r262524 - [analyzer] Move ObjCDeallocChecker out of the alpha package.

2016-03-02 Thread Devin Coughlin via cfe-commits
Author: dcoughlin
Date: Wed Mar  2 15:50:54 2016
New Revision: 262524

URL: http://llvm.org/viewvc/llvm-project?rev=262524&view=rev
Log:
[analyzer] Move ObjCDeallocChecker out of the alpha package.

It will now be on by default on Darwin.

rdar://problem/6927496

Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/Checkers.td
cfe/trunk/test/Analysis/DeallocMissingRelease.m
cfe/trunk/test/Analysis/MissingDealloc.m
cfe/trunk/test/Analysis/PR2978.m
cfe/trunk/test/Analysis/properties.m

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/Checkers.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/Checkers.td?rev=262524&r1=262523&r2=262524&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/Checkers.td (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/Checkers.td Wed Mar  2 15:50:54 2016
@@ -505,14 +505,14 @@ def ObjCGenericsChecker : Checker<"ObjCG
   HelpText<"Check for type errors when using Objective-C generics">,
   DescFile<"DynamicTypePropagation.cpp">;
 
-} // end "osx.cocoa"
-
-let ParentPackage = CocoaAlpha in {
-
 def ObjCDeallocChecker : Checker<"Dealloc">,
   HelpText<"Warn about Objective-C classes that lack a correct implementation 
of -dealloc">,
   DescFile<"CheckObjCDealloc.cpp">;
 
+} // end "osx.cocoa"
+
+let ParentPackage = CocoaAlpha in {
+
 def ObjCSuperDeallocChecker : Checker<"SuperDealloc">,
   HelpText<"Warn about improper use of '[super dealloc]' in Objective-C">,
   DescFile<"ObjCSuperDeallocChecker.cpp">;

Modified: cfe/trunk/test/Analysis/DeallocMissingRelease.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/DeallocMissingRelease.m?rev=262524&r1=262523&r2=262524&view=diff
==
--- cfe/trunk/test/Analysis/DeallocMissingRelease.m (original)
+++ cfe/trunk/test/Analysis/DeallocMissingRelease.m Wed Mar  2 15:50:54 2016
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=alpha.osx.cocoa.Dealloc -fblocks 
-verify %s
-// RUN: %clang_cc1 -analyze -analyzer-checker=alpha.osx.cocoa.Dealloc -fblocks 
-triple x86_64-apple-darwin10 -fobjc-arc -fobjc-runtime-has-weak -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=osx.cocoa.Dealloc -fblocks 
-verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=osx.cocoa.Dealloc -fblocks 
-triple x86_64-apple-darwin10 -fobjc-arc -fobjc-runtime-has-weak -verify %s
 
 #include "Inputs/system-header-simulator-for-objc-dealloc.h"
 

Modified: cfe/trunk/test/Analysis/MissingDealloc.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/MissingDealloc.m?rev=262524&r1=262523&r2=262524&view=diff
==
--- cfe/trunk/test/Analysis/MissingDealloc.m (original)
+++ cfe/trunk/test/Analysis/MissingDealloc.m Wed Mar  2 15:50:54 2016
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=alpha.osx.cocoa.Dealloc -fblocks 
-verify %s
-// RUN: %clang_cc1 -analyze -analyzer-checker=alpha.osx.cocoa.Dealloc -fblocks 
-verify -triple x86_64-apple-darwin10 -fobjc-arc %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=osx.cocoa.Dealloc -fblocks 
-verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=osx.cocoa.Dealloc -fblocks 
-verify -triple x86_64-apple-darwin10 -fobjc-arc %s
 
 #define NON_ARC !__has_feature(objc_arc)
 

Modified: cfe/trunk/test/Analysis/PR2978.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/PR2978.m?rev=262524&r1=262523&r2=262524&view=diff
==
--- cfe/trunk/test/Analysis/PR2978.m (original)
+++ cfe/trunk/test/Analysis/PR2978.m Wed Mar  2 15:50:54 2016
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.core 
-analyzer-checker=alpha.osx.cocoa.Dealloc %s -verify
+// RUN: %clang_cc1 -analyze 
-analyzer-checker=core,alpha.core,osx.cocoa.Dealloc %s -verify
 
 // Tests for the checker which checks missing/extra ivar 'release' calls 
 // in dealloc.

Modified: cfe/trunk/test/Analysis/properties.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/properties.m?rev=262524&r1=262523&r2=262524&view=diff
==
--- cfe/trunk/test/Analysis/properties.m (original)
+++ cfe/trunk/test/Analysis/properties.m Wed Mar  2 15:50:54 2016
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -analyze 
-analyzer-checker=core,osx.cocoa.RetainCount,alpha.osx.cocoa.Dealloc,debug.ExprInspection
 -analyzer-store=region -verify -Wno-objc-root-class %s
-// RUN: %clang_cc1 -analyze 
-analyzer-checker=core,osx.cocoa.RetainCount,alpha.osx.cocoa.Dealloc,debug.ExprInspection
 -analyzer-store=region -verify -Wno-objc-root-class -fobjc-arc %s
+// RUN: %clang_cc1 -analyze 
-analyzer-checker=core,osx.cocoa.RetainCount,osx.cocoa.Dealloc,debug.ExprInspection
 -analyzer-store=region -verify -Wn

r262526 - [analyzer] Move ObjCSuperDeallocChecker out of the alpha package.

2016-03-02 Thread Devin Coughlin via cfe-commits
Author: dcoughlin
Date: Wed Mar  2 16:01:03 2016
New Revision: 262526

URL: http://llvm.org/viewvc/llvm-project?rev=262526&view=rev
Log:
[analyzer] Move ObjCSuperDeallocChecker out of the alpha package.

It will now be on by default on Darwin.

rdar://problem/6953275

Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/Checkers.td
cfe/trunk/test/Analysis/DeallocUseAfterFreeErrors.m

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/Checkers.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/Checkers.td?rev=262526&r1=262525&r2=262526&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/Checkers.td (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/Checkers.td Wed Mar  2 16:01:03 2016
@@ -509,14 +509,14 @@ def ObjCDeallocChecker : Checker<"Deallo
   HelpText<"Warn about Objective-C classes that lack a correct implementation 
of -dealloc">,
   DescFile<"CheckObjCDealloc.cpp">;
 
-} // end "osx.cocoa"
-
-let ParentPackage = CocoaAlpha in {
-
 def ObjCSuperDeallocChecker : Checker<"SuperDealloc">,
   HelpText<"Warn about improper use of '[super dealloc]' in Objective-C">,
   DescFile<"ObjCSuperDeallocChecker.cpp">;
 
+} // end "osx.cocoa"
+
+let ParentPackage = CocoaAlpha in {
+
 def InstanceVariableInvalidation : Checker<"InstanceVariableInvalidation">,
   HelpText<"Check that the invalidatable instance variables are invalidated in 
the methods annotated with objc_instance_variable_invalidator">,
   DescFile<"IvarInvalidationChecker.cpp">;

Modified: cfe/trunk/test/Analysis/DeallocUseAfterFreeErrors.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/DeallocUseAfterFreeErrors.m?rev=262526&r1=262525&r2=262526&view=diff
==
--- cfe/trunk/test/Analysis/DeallocUseAfterFreeErrors.m (original)
+++ cfe/trunk/test/Analysis/DeallocUseAfterFreeErrors.m Wed Mar  2 16:01:03 2016
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -analyze 
-analyzer-checker=core,alpha.osx.cocoa.SuperDealloc,debug.ExprInspection 
-analyzer-output=text -verify %s
+// RUN: %clang_cc1 -analyze 
-analyzer-checker=core,osx.cocoa.SuperDealloc,debug.ExprInspection 
-analyzer-output=text -verify %s
 
 void clang_analyzer_warnIfReached();
 


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


Re: [PATCH] D17385: clang-format: [JS] re-quote single or double quoted strings.

2016-03-02 Thread Daniel Jasper via cfe-commits
djasper accepted this revision.
djasper added a comment.
This revision is now accepted and ready to land.

Looks good.



Comment at: lib/Format/Format.cpp:1140
@@ +1139,3 @@
+
+  void insertReplacement(SourceLocation Start, unsigned Length,
+ StringRef ReplacementText) {

I think this function doesn't carry its own weight.


http://reviews.llvm.org/D17385



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


r262534 - clang-format: [JS] Optionally re-quote string literals.

2016-03-02 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Wed Mar  2 16:44:03 2016
New Revision: 262534

URL: http://llvm.org/viewvc/llvm-project?rev=262534&view=rev
Log:
clang-format: [JS] Optionally re-quote string literals.

Turns "foo" into 'foo' (or vice versa, depending on configuration).
This makes it more convenient to follow the Google JavaScript style
guide:
https://google.github.io/styleguide/javascriptguide.xml?showone=Strings#Strings

This functionality is behind the option "JavaScriptQuotes", which can be:

  * "leave" (no re-quoting)
  * "single" (change to single quotes)
  * "double" (change to double quotes)

This also changes single quoted JavaScript string literals to be treated
as tok::string_literal, not tok::char_literal, which fixes two unrelated
tests.

Patch by Martin Probst. Thank you.

Modified:
cfe/trunk/include/clang/Format/Format.h
cfe/trunk/lib/Format/Format.cpp
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTest.cpp
cfe/trunk/unittests/Format/FormatTestJS.cpp

Modified: cfe/trunk/include/clang/Format/Format.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Format/Format.h?rev=262534&r1=262533&r2=262534&view=diff
==
--- cfe/trunk/include/clang/Format/Format.h (original)
+++ cfe/trunk/include/clang/Format/Format.h Wed Mar  2 16:44:03 2016
@@ -594,6 +594,20 @@ struct FormatStyle {
   /// \brief The way to use tab characters in the resulting file.
   UseTabStyle UseTab;
 
+  /// \brief Quotation styles for JavaScript strings. Does not affect template
+  /// strings.
+  enum JavaScriptQuoteStyle {
+/// Leave string quotes as they are.
+JSQS_Leave,
+/// Always use single quotes.
+JSQS_Single,
+/// Always use double quotes.
+JSQS_Double
+  };
+
+  /// \brief The JavaScriptQuoteStyle to use for JavaScript strings.
+  JavaScriptQuoteStyle JavaScriptQuotes;
+
   bool operator==(const FormatStyle &R) const {
 return AccessModifierOffset == R.AccessModifierOffset &&
AlignAfterOpenBracket == R.AlignAfterOpenBracket &&
@@ -670,7 +684,8 @@ struct FormatStyle {
SpacesInParentheses == R.SpacesInParentheses &&
SpacesInSquareBrackets == R.SpacesInSquareBrackets &&
Standard == R.Standard && TabWidth == R.TabWidth &&
-   UseTab == R.UseTab;
+   UseTab == R.UseTab &&
+   JavaScriptQuotes == R.JavaScriptQuotes;
   }
 };
 

Modified: cfe/trunk/lib/Format/Format.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=262534&r1=262533&r2=262534&view=diff
==
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Wed Mar  2 16:44:03 2016
@@ -71,6 +71,14 @@ template <> struct ScalarEnumerationTrai
   }
 };
 
+template <> struct ScalarEnumerationTraits {
+  static void enumeration(IO &IO, FormatStyle::JavaScriptQuoteStyle &Value) {
+IO.enumCase(Value, "Leave", FormatStyle::JSQS_Leave);
+IO.enumCase(Value, "Single", FormatStyle::JSQS_Single);
+IO.enumCase(Value, "Double", FormatStyle::JSQS_Double);
+  }
+};
+
 template <> struct ScalarEnumerationTraits {
   static void enumeration(IO &IO, FormatStyle::ShortFunctionStyle &Value) {
 IO.enumCase(Value, "None", FormatStyle::SFS_None);
@@ -335,6 +343,7 @@ template <> struct MappingTraitsNewlinesBefore > 0 || Tokens.back()->IsMultiline)
 FirstInLineIndex = Tokens.size() - 1;
 } while (Tokens.back()->Tok.isNot(tok::eof));
@@ -1061,6 +1074,75 @@ private:
 return false;
   }
 
+  // If the last token is a double/single-quoted string literal, generates a
+  // replacement with a single/double quoted string literal, re-escaping the
+  // contents in the process.
+  void tryRequoteJSStringLiteral() {
+if (Style.JavaScriptQuotes == FormatStyle::JSQS_Leave)
+  return;
+
+FormatToken *FormatTok = Tokens.back();
+StringRef Input = FormatTok->TokenText;
+if (!FormatTok->isStringLiteral() ||
+// NB: testing for not starting with a double quote to avoid breaking
+// `template strings`.
+(Style.JavaScriptQuotes == FormatStyle::JSQS_Single &&
+ !Input.startswith("\"")) ||
+(Style.JavaScriptQuotes == FormatStyle::JSQS_Double &&
+ !Input.startswith("\'")))
+  return;
+
+// Change start and end quote.
+bool IsSingle = Style.JavaScriptQuotes == FormatStyle::JSQS_Single;
+SourceLocation Start = FormatTok->Tok.getLocation();
+auto Replace = [&](SourceLocation Start, unsigned Length,
+   StringRef ReplacementText) {
+  Replaces.insert(
+  tooling::Replacement(SourceMgr, Start, Length, ReplacementText));
+};
+Replace(Start, 1, IsSingle ? "'" : "\"");
+Replace(FormatTok->Tok.getEndLoc().getLocWithOffset(-1), 1,
+IsSingle ? "'" : "\"");
+
+// Escape internal quotes.
+size_t Col

Re: [PATCH] D17385: clang-format: [JS] re-quote single or double quoted strings.

2016-03-02 Thread Daniel Jasper via cfe-commits
djasper closed this revision.
djasper added a comment.

Submitted as r262534.


http://reviews.llvm.org/D17385



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


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

2016-03-02 Thread Alexander Riccio via cfe-commits
ariccio added a comment.

In http://reviews.llvm.org/D17688#366011, @ariccio wrote:

> In http://reviews.llvm.org/D17688#365951, @zaks.anna wrote:
>
> > ls ./clang/test/Analysis/malloc*
>
>
> Ah, ok. Would it be ok if (for _strdup & _alloca) I just do this at the 
> beginning:
>
>   #if defined(_WIN32)
>  
>   #define strdup _strdup
>   #define alloca _alloca
>  
>   #endif //defined(_WIN32)
>


Nevermind. I'm uploading a proper patch in the next few minutes.


http://reviews.llvm.org/D17688



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


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

2016-03-02 Thread Alexander Riccio via cfe-commits
ariccio updated this revision to Diff 49674.
ariccio added a comment.

Added newly checked variants to the malloc checks.

(Running the check-all suite now, will update with results)


http://reviews.llvm.org/D17688

Files:
  llvm/tools/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
  llvm/tools/clang/test/Analysis/malloc.c

Index: llvm/tools/clang/test/Analysis/malloc.c
===
--- llvm/tools/clang/test/Analysis/malloc.c
+++ llvm/tools/clang/test/Analysis/malloc.c
@@ -13,9 +13,15 @@
 void *reallocf(void *ptr, size_t size);
 void *calloc(size_t nmemb, size_t size);
 char *strdup(const char *s);
+wchar_t *wcsdup(const wchar_t *s);
 char *strndup(const char *s, size_t n);
 int memcmp(const void *s1, const void *s2, size_t n);
 
+// Windows variants
+char *_strdup(const char *strSource);
+wchar_t *_wcsdup(const wchar_t *strSource);
+void *_alloca(size_t size);
+
 void myfoo(int *p);
 void myfooint(int p);
 char *fooRetPtr();
@@ -55,6 +61,10 @@
   int *p = alloca(sizeof(int));
 } // no warn
 
+void winAllocaTest() {
+  int *p = _alloca(sizeof(int));
+} // no warn
+
 void allocaBuiltinTest() {
   int *p = __builtin_alloca(sizeof(int));
 } // no warn
@@ -210,6 +220,11 @@
   int *p = alloca(0); // no warning
 }
 
+void CheckUseZeroWinAllocatedNoWarn2() {
+  int *p = _alloca(0); // no warning
+}
+
+
 void CheckUseZeroAllocatedNoWarn3() {
   int *p = malloc(0);
   int *q = realloc(p, 8); // no warning
@@ -233,6 +248,11 @@
   return *p; // expected-warning {{Use of zero-allocated memory}}
 }
 
+char CheckUseZeroWinAllocated2() {
+  char *p = _alloca(0);
+  return *p; // expected-warning {{Use of zero-allocated memory}}
+}
+
 void UseZeroAllocated(int *p) {
   if (p)
 *p = 7; // expected-warning {{Use of zero-allocated memory}}
@@ -1076,6 +1096,21 @@
   s2[validIndex + 1] = 'b';
 } // expected-warning {{Potential leak of memory pointed to by}}
 
+void testWinStrdup(const char *s, unsigned validIndex) {
+  char *s2 = _strdup(s);
+  s2[validIndex + 1] = 'b';
+} // expected-warning {{Potential leak of memory pointed to by}}
+
+void testWcsdup(const wchar_t *s, unsigned validIndex) {
+  wchar_t *s2 = wcsdup(s);
+  s2[validIndex + 1] = 'b';
+} // expected-warning {{Potential leak of memory pointed to by}}
+
+void testWinWcsdup(const wchar_t *s, unsigned validIndex) {
+  wchar_t *s2 = _wcsdup(s);
+  s2[validIndex + 1] = 'b';
+} // expected-warning {{Potential leak of memory pointed to by}}
+
 int testStrndup(const char *s, unsigned validIndex, unsigned size) {
   char *s2 = strndup(s, size);
   s2 [validIndex + 1] = 'b';
@@ -1091,6 +1126,24 @@
   free(s2);
 }
 
+void testWinStrdupContentIsDefined(const char *s, unsigned validIndex) {
+  char *s2 = _strdup(s);
+  char result = s2[1];// no warning
+  free(s2);
+}
+
+void testWcsdupContentIsDefined(const wchar_t *s, unsigned validIndex) {
+  wchar_t *s2 = wcsdup(s);
+  wchar_t result = s2[1];// no warning
+  free(s2);
+}
+
+void testWinWcsdupContentIsDefined(const wchar_t *s, unsigned validIndex) {
+  wchar_t *s2 = _wcsdup(s);
+  wchar_t result = s2[1];// no warning
+  free(s2);
+}
+
 // 
 // Test the system library functions to which the pointer can escape.
 // This tests false positive suppression.
@@ -1444,6 +1497,10 @@
   return strdup(strdup(str)); // expected-warning{{leak}}
 }
 
+char *testWinLeakWithinReturn(wchar_t *str) {
+  return _strdup(_strdup(str)); // expected-warning{{leak}}
+}
+
 void passConstPtr(const char * ptr);
 
 void testPassConstPointer() {
Index: llvm/tools/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
===
--- llvm/tools/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
+++ llvm/tools/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
@@ -169,11 +169,12 @@
 {
 public:
   MallocChecker()
-  : II_alloca(nullptr), II_malloc(nullptr), II_free(nullptr),
-II_realloc(nullptr), II_calloc(nullptr), II_valloc(nullptr),
-II_reallocf(nullptr), II_strndup(nullptr), II_strdup(nullptr),
-II_kmalloc(nullptr), II_if_nameindex(nullptr),
-II_if_freenameindex(nullptr) {}
+  : II_alloca(nullptr), II_win_alloca(nullptr), II_malloc(nullptr),
+II_free(nullptr), II_realloc(nullptr), II_calloc(nullptr),
+II_valloc(nullptr), II_reallocf(nullptr), II_strndup(nullptr),
+II_strdup(nullptr), II_win_strdup(nullptr), II_kmalloc(nullptr),
+II_if_nameindex(nullptr), II_if_freenameindex(nullptr),
+II_wcsdup(nullptr), II_win_wcsdup(nullptr) {}
 
   /// In pessimistic mode, the checker assumes that it does not know which
   /// functions might free the memory.
@@ -231,10 +232,11 @@
   mutable std::unique_ptr BT_MismatchedDealloc;
   mutable std::unique_ptr BT_OffsetFree[CK_NumCheckKinds];
   mutable std::unique_ptr BT_UseZerroAllocated[CK_NumCheckKinds];
-  mutable IdentifierInfo *II_alloca, *I

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

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

LGTM. Thanks!

I can commit this in your behalf.


http://reviews.llvm.org/D17688



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


r262539 - Serialize `pragma ms_struct` state.

2016-03-02 Thread Nico Weber via cfe-commits
Author: nico
Date: Wed Mar  2 17:22:00 2016
New Revision: 262539

URL: http://llvm.org/viewvc/llvm-project?rev=262539&view=rev
Log:
Serialize `pragma ms_struct` state.

pragma ms_struct has an effect on struct decls, and the effect is serialized
correctly already.  But the "is ms_struct currently on" state wasn't before
this change.

This uses the same approach as `pragma clang optimize`: When writing a module,
the state isn't serialized, only when writing a pch file.

Added:
cfe/trunk/test/PCH/pragma-ms_struct.cpp
Modified:
cfe/trunk/include/clang/Basic/PragmaKinds.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/include/clang/Serialization/ASTBitCodes.h
cfe/trunk/include/clang/Serialization/ASTReader.h
cfe/trunk/include/clang/Serialization/ASTWriter.h
cfe/trunk/lib/Parse/ParsePragma.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp

Modified: cfe/trunk/include/clang/Basic/PragmaKinds.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/PragmaKinds.h?rev=262539&r1=262538&r2=262539&view=diff
==
--- cfe/trunk/include/clang/Basic/PragmaKinds.h (original)
+++ cfe/trunk/include/clang/Basic/PragmaKinds.h Wed Mar  2 17:22:00 2016
@@ -21,6 +21,11 @@ enum PragmaMSCommentKind {
   PCK_User  // #pragma comment(user, ...)
 };
 
+enum PragmaMSStructKind {
+  PMSST_OFF, // #pragms ms_struct off
+  PMSST_ON   // #pragms ms_struct on
+};
+
 }
 
 #endif

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=262539&r1=262538&r2=262539&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Wed Mar  2 17:22:00 2016
@@ -7611,11 +7611,6 @@ public:
 PPK_Pop  // #pragma pack(pop, [identifier], [n])
   };
 
-  enum PragmaMSStructKind {
-PMSST_OFF,  // #pragms ms_struct off
-PMSST_ON// #pragms ms_struct on
-  };
-
   /// ActOnPragmaPack - Called on well formed \#pragma pack(...).
   void ActOnPragmaPack(PragmaPackKind Kind,
IdentifierInfo *Name,

Modified: cfe/trunk/include/clang/Serialization/ASTBitCodes.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTBitCodes.h?rev=262539&r1=262538&r2=262539&view=diff
==
--- cfe/trunk/include/clang/Serialization/ASTBitCodes.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTBitCodes.h Wed Mar  2 17:22:00 2016
@@ -575,7 +575,10 @@ namespace clang {
   CXX_CTOR_INITIALIZERS_OFFSETS = 53,
 
   /// \brief Delete expressions that will be analyzed later.
-  DELETE_EXPRS_TO_ANALYZE = 54
+  DELETE_EXPRS_TO_ANALYZE = 54,
+
+  /// \brief Record code for \#pragma ms_struct options.
+  MSSTRUCT_PRAGMA_OPTIONS = 55
 };
 
 /// \brief Record types used within a source manager block.

Modified: cfe/trunk/include/clang/Serialization/ASTReader.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTReader.h?rev=262539&r1=262538&r2=262539&view=diff
==
--- cfe/trunk/include/clang/Serialization/ASTReader.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTReader.h Wed Mar  2 17:22:00 2016
@@ -785,6 +785,9 @@ private:
   /// \brief The pragma clang optimize location (if the pragma state is "off").
   SourceLocation OptimizeOffPragmaLocation;
 
+  /// \brief The PragmaMSStructKind pragma ms_struct state if set, or -1.
+  int PragmaMSStructState;
+
   /// \brief The OpenCL extension settings.
   SmallVector OpenCLExtensions;
 

Modified: cfe/trunk/include/clang/Serialization/ASTWriter.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTWriter.h?rev=262539&r1=262538&r2=262539&view=diff
==
--- cfe/trunk/include/clang/Serialization/ASTWriter.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTWriter.h Wed Mar  2 17:22:00 2016
@@ -551,6 +551,7 @@ private:
   void WriteObjCCategories();
   void WriteLateParsedTemplates(Sema &SemaRef);
   void WriteOptimizePragmaOptions(Sema &SemaRef);
+  void WriteMSStructPragmaOptions(Sema &SemaRef);
   void WriteModuleFileExtension(Sema &SemaRef,
 ModuleFileExtensionWriter &Writer);
 

Modified: cfe/trunk/lib/Parse/ParsePragma.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParsePragma.cpp?rev=262539&r1=262538&r2=262539&view=diff
==
--- cfe/trunk/lib/Parse/ParsePragma.cpp (original)
+++ cfe/trunk/lib/Parse/ParsePragma.cpp Wed Mar  2 17:22:00 2016
@@ -362,9 +362,8 @@ void Parser::Handle

r262541 - clang-cl pch test: Instead of copying the input, use /Fp to not write into the test directory.

2016-03-02 Thread Nico Weber via cfe-commits
Author: nico
Date: Wed Mar  2 17:29:29 2016
New Revision: 262541

URL: http://llvm.org/viewvc/llvm-project?rev=262541&view=rev
Log:
clang-cl pch test: Instead of copying the input, use /Fp to not write into the 
test directory.

Also fix a bug with /Fp and absolute paths uncovered by this.
Follow-up to r262487.

Modified:
cfe/trunk/lib/Driver/Driver.cpp
cfe/trunk/test/Driver/cl-pch-errorhandling.cpp

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=262541&r1=262540&r2=262541&view=diff
==
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Wed Mar  2 17:29:29 2016
@@ -2246,7 +2246,7 @@ const char *Driver::GetNamedOutputPath(C
   }
 
   // As an annoying special case, PCH generation doesn't strip the pathname.
-  if (JA.getType() == types::TY_PCH) {
+  if (JA.getType() == types::TY_PCH && !IsCLMode()) {
 llvm::sys::path::remove_filename(BasePath);
 if (BasePath.empty())
   BasePath = NamedOutput;

Modified: cfe/trunk/test/Driver/cl-pch-errorhandling.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-pch-errorhandling.cpp?rev=262541&r1=262540&r2=262541&view=diff
==
--- cfe/trunk/test/Driver/cl-pch-errorhandling.cpp (original)
+++ cfe/trunk/test/Driver/cl-pch-errorhandling.cpp Wed Mar  2 17:29:29 2016
@@ -6,8 +6,7 @@
 // code generation, which makes this test require an x86 backend.
 // REQUIRES: x86-registered-target
 
-// RUN: cp %S/Inputs/pchfile.h %t.h
-// RUN: not %clang_cl -internal-enable-pch -Werror /Yc%t.h /FI%t.h /c 
-DERR_HEADER -- %s 2>&1 \
+// RUN: not %clang_cl -internal-enable-pch -Werror /Yc%S/Inputs/pchfile.h 
/FI%S/Inputs/pchfile.h /Fp%t.pch /c -DERR_HEADER -- %s 2>&1 \
 // RUN:   | FileCheck %s
 
 // CHECK: nope1


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


Re: r262487 - test/Driver/cl-pch-errorhandling.cpp: Copy input file to a temporary

2016-03-02 Thread Nico Weber via cfe-commits
Ok, gave that a try in r262541.

On Wed, Mar 2, 2016 at 1:20 PM, Daniel Jasper  wrote:

> Feel free to change. I have no idea what I am doing here.
>
> On Wed, Mar 2, 2016 at 12:55 PM, Nico Weber  wrote:
>
>> (A different fix would've been to just add /Fp%.pch to set the output
>> path to be not next to the inputs.)
>>
>> On Wed, Mar 2, 2016 at 6:27 AM, Daniel Jasper via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Author: djasper
>>> Date: Wed Mar  2 08:26:59 2016
>>> New Revision: 262487
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=262487&view=rev
>>> Log:
>>> test/Driver/cl-pch-errorhandling.cpp: Copy input file to a temporary
>>> location as we cannot assume the location of the input file to be
>>> writable.
>>>
>>> Modified:
>>> cfe/trunk/test/Driver/cl-pch-errorhandling.cpp
>>>
>>> Modified: cfe/trunk/test/Driver/cl-pch-errorhandling.cpp
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-pch-errorhandling.cpp?rev=262487&r1=262486&r2=262487&view=diff
>>>
>>> ==
>>> --- cfe/trunk/test/Driver/cl-pch-errorhandling.cpp (original)
>>> +++ cfe/trunk/test/Driver/cl-pch-errorhandling.cpp Wed Mar  2 08:26:59
>>> 2016
>>> @@ -6,7 +6,8 @@
>>>  // code generation, which makes this test require an x86 backend.
>>>  // REQUIRES: x86-registered-target
>>>
>>> -// RUN: not %clang_cl -internal-enable-pch -Werror
>>> /Yc%S/Inputs/pchfile.h /FI%S/Inputs/pchfile.h /c -DERR_HEADER -- %s 2>&1 \
>>> +// RUN: cp %S/Inputs/pchfile.h %t.h
>>> +// RUN: not %clang_cl -internal-enable-pch -Werror /Yc%t.h /FI%t.h /c
>>> -DERR_HEADER -- %s 2>&1 \
>>>  // RUN:   | FileCheck %s
>>>
>>>  // CHECK: nope1
>>>
>>>
>>> ___
>>> cfe-commits mailing list
>>> cfe-commits@lists.llvm.org
>>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>>
>>
>>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2016-03-02 Thread Alexander Riccio via cfe-commits
ariccio added a comment.

Hmm, check-all produced a number of issues, which I think stem from the 
following warning:

  File C:\LLVM\llvm\tools\clang\test\Analysis\malloc.c Line 16: unknown type 
name 'wchar_t'

(with a bunch of instances of that)

...so how do I declare/define `wchar_t` properly?


http://reviews.llvm.org/D17688



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


r262551 - Improve some infrastructure for extended parameter infos and

2016-03-02 Thread John McCall via cfe-commits
Author: rjmccall
Date: Wed Mar  2 18:10:03 2016
New Revision: 262551

URL: http://llvm.org/viewvc/llvm-project?rev=262551&view=rev
Log:
Improve some infrastructure for extended parameter infos and
fix a bug with the instantiation of ns_consumed parameter
attributes in ARC.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Sema/AttributeList.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/AST/TypePrinter.cpp
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/test/SemaCXX/cxx11-gnu-attrs.cpp
cfe/trunk/test/SemaObjCXX/arc-nsconsumed-errors.mm
cfe/trunk/test/SemaObjCXX/arc-templates.mm

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=262551&r1=262550&r2=262551&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed Mar  2 18:10:03 
2016
@@ -2934,6 +2934,9 @@ def warn_ns_attribute_wrong_return_type
   "%0 attribute only applies to %select{functions|methods|properties}1 that "
   "return %select{an Objective-C object|a pointer|a non-retainable pointer}2">,
   InGroup;
+def err_ns_attribute_wrong_parameter_type : Error<
+  "%0 attribute only applies to "
+  "%select{Objective-C object|pointer|pointer-to-CF-pointer}1 parameters">;
 def warn_ns_attribute_wrong_parameter_type : Warning<
   "%0 attribute only applies to "
   "%select{Objective-C object|pointer|pointer-to-CF-pointer}1 parameters">,

Modified: cfe/trunk/include/clang/Sema/AttributeList.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/AttributeList.h?rev=262551&r1=262550&r2=262551&view=diff
==
--- cfe/trunk/include/clang/Sema/AttributeList.h (original)
+++ cfe/trunk/include/clang/Sema/AttributeList.h Wed Mar  2 18:10:03 2016
@@ -94,9 +94,11 @@ private:
   SourceLocation ScopeLoc;
   SourceLocation EllipsisLoc;
 
+  unsigned AttrKind : 16;
+
   /// The number of expression arguments this attribute has.
   /// The expressions themselves are stored after the object.
-  unsigned NumArgs : 15;
+  unsigned NumArgs : 16;
 
   /// Corresponds to the Syntax enum.
   unsigned SyntaxUsed : 3;
@@ -122,7 +124,11 @@ private:
   /// True if this has a ParsedType
   unsigned HasParsedType : 1;
 
-  unsigned AttrKind : 8;
+  /// True if the processing cache is valid.
+  mutable unsigned HasProcessingCache : 1;
+
+  /// A cached value.
+  mutable unsigned ProcessingCache : 8;
 
   /// \brief The location of the 'unavailable' keyword in an
   /// availability attribute.
@@ -231,7 +237,8 @@ private:
   ScopeLoc(scopeLoc), EllipsisLoc(ellipsisLoc), NumArgs(numArgs),
   SyntaxUsed(syntaxUsed), Invalid(false), UsedAsTypeAttr(false),
   IsAvailability(false), IsTypeTagForDatatype(false), IsProperty(false),
-  HasParsedType(false), NextInPosition(nullptr), NextInPool(nullptr) {
+  HasParsedType(false), HasProcessingCache(false),
+  NextInPosition(nullptr), NextInPool(nullptr) {
 if (numArgs) memcpy(getArgsBuffer(), args, numArgs * sizeof(ArgsUnion));
 AttrKind = getKind(getName(), getScopeName(), syntaxUsed);
   }
@@ -249,8 +256,8 @@ private:
   ScopeLoc(scopeLoc), EllipsisLoc(), NumArgs(1), SyntaxUsed(syntaxUsed),
   Invalid(false), UsedAsTypeAttr(false), IsAvailability(true),
   IsTypeTagForDatatype(false), IsProperty(false), HasParsedType(false),
-  UnavailableLoc(unavailable), MessageExpr(messageExpr),
-  NextInPosition(nullptr), NextInPool(nullptr) {
+  HasProcessingCache(false), UnavailableLoc(unavailable),
+  MessageExpr(messageExpr), NextInPosition(nullptr), NextInPool(nullptr) {
 ArgsUnion PVal(Parm);
 memcpy(getArgsBuffer(), &PVal, sizeof(ArgsUnion));
 new (&getAvailabilitySlot(IntroducedSlot)) AvailabilityChange(introduced);
@@ -271,7 +278,7 @@ private:
 ScopeLoc(scopeLoc), EllipsisLoc(), NumArgs(3), SyntaxUsed(syntaxUsed),
 Invalid(false), UsedAsTypeAttr(false), IsAvailability(false),
 IsTypeTagForDatatype(false), IsProperty(false), HasParsedType(false),
-NextInPosition(nullptr), NextInPool(nullptr) {
+HasProcessingCache(false), NextInPosition(nullptr), NextInPool(nullptr) {
 ArgsVector Args;
 Args.push_back(Parm1);
 Args.push_back(Parm2);
@@ -289,7 +296,7 @@ private:
   ScopeLoc(scopeLoc), EllipsisLoc(), NumArgs(1), SyntaxUsed(syntaxUsed),
   Invalid(false), UsedAsTypeAttr(false), IsAvailability(false),
   IsTypeTagForDatatype(true), IsProperty(false), HasParsedType(false),
-  NextInPosition(nullptr), NextInPool(nullptr) {
+  HasProcessingCache(false), NextInPosition(nullptr), NextInPool(nullptr) {
 ArgsUnion PVal

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

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

Generate a preprocessed file and keep copying the definitions from there until 
you reach the types compiler knows about.


http://reviews.llvm.org/D17688



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


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

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

Please, do not submit patches for review before they pass all tests.


http://reviews.llvm.org/D17688



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


r262552 - Serialize `pragma pointers_to_members` state.

2016-03-02 Thread Nico Weber via cfe-commits
Author: nico
Date: Wed Mar  2 18:17:35 2016
New Revision: 262552

URL: http://llvm.org/viewvc/llvm-project?rev=262552&view=rev
Log:
Serialize `pragma pointers_to_members` state.

Like r262539, but for pointers_to_members.

Added:
cfe/trunk/test/PCH/pragma-pointers_to_members.cpp
Modified:
cfe/trunk/include/clang/Serialization/ASTBitCodes.h
cfe/trunk/include/clang/Serialization/ASTReader.h
cfe/trunk/include/clang/Serialization/ASTWriter.h
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp

Modified: cfe/trunk/include/clang/Serialization/ASTBitCodes.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTBitCodes.h?rev=262552&r1=262551&r2=262552&view=diff
==
--- cfe/trunk/include/clang/Serialization/ASTBitCodes.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTBitCodes.h Wed Mar  2 18:17:35 2016
@@ -578,7 +578,10 @@ namespace clang {
   DELETE_EXPRS_TO_ANALYZE = 54,
 
   /// \brief Record code for \#pragma ms_struct options.
-  MSSTRUCT_PRAGMA_OPTIONS = 55
+  MSSTRUCT_PRAGMA_OPTIONS = 55,
+
+  /// \brief Record code for \#pragma ms_struct options.
+  POINTERS_TO_MEMBERS_PRAGMA_OPTIONS = 56
 };
 
 /// \brief Record types used within a source manager block.

Modified: cfe/trunk/include/clang/Serialization/ASTReader.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTReader.h?rev=262552&r1=262551&r2=262552&view=diff
==
--- cfe/trunk/include/clang/Serialization/ASTReader.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTReader.h Wed Mar  2 18:17:35 2016
@@ -788,6 +788,10 @@ private:
   /// \brief The PragmaMSStructKind pragma ms_struct state if set, or -1.
   int PragmaMSStructState;
 
+  /// \brief The PragmaMSPointersToMembersKind pragma pointers_to_members 
state.
+  int PragmaMSPointersToMembersState;
+  SourceLocation PointersToMembersPragmaLocation;
+
   /// \brief The OpenCL extension settings.
   SmallVector OpenCLExtensions;
 

Modified: cfe/trunk/include/clang/Serialization/ASTWriter.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTWriter.h?rev=262552&r1=262551&r2=262552&view=diff
==
--- cfe/trunk/include/clang/Serialization/ASTWriter.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTWriter.h Wed Mar  2 18:17:35 2016
@@ -552,6 +552,7 @@ private:
   void WriteLateParsedTemplates(Sema &SemaRef);
   void WriteOptimizePragmaOptions(Sema &SemaRef);
   void WriteMSStructPragmaOptions(Sema &SemaRef);
+  void WriteMSPointersToMembersPragmaOptions(Sema &SemaRef);
   void WriteModuleFileExtension(Sema &SemaRef,
 ModuleFileExtensionWriter &Writer);
 

Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=262552&r1=262551&r2=262552&view=diff
==
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Wed Mar  2 18:17:35 2016
@@ -3225,6 +3225,15 @@ ASTReader::ReadASTBlock(ModuleFile &F, u
   PragmaMSStructState = Record[0];
   break;
 
+case POINTERS_TO_MEMBERS_PRAGMA_OPTIONS:
+  if (Record.size() != 2) {
+Error("invalid pragma ms_struct record");
+return Failure;
+  }
+  PragmaMSPointersToMembersState = Record[0];
+  PointersToMembersPragmaLocation = ReadSourceLocation(F, Record[1]);
+  break;
+
 case UNUSED_LOCAL_TYPEDEF_NAME_CANDIDATES:
   for (unsigned I = 0, N = Record.size(); I != N; ++I)
 UnusedLocalTypedefNameCandidates.push_back(
@@ -7012,6 +7021,12 @@ void ASTReader::UpdateSema() {
 SemaObj->ActOnPragmaOptimize(/* IsOn = */ false, 
OptimizeOffPragmaLocation);
   if (PragmaMSStructState != -1)
 SemaObj->ActOnPragmaMSStruct((PragmaMSStructKind)PragmaMSStructState);
+  if (PointersToMembersPragmaLocation.isValid()) {
+SemaObj->ActOnPragmaMSPointersToMembers(
+(LangOptions::PragmaMSPointersToMembersKind)
+PragmaMSPointersToMembersState,
+PointersToMembersPragmaLocation);
+  }
 }
 
 IdentifierInfo *ASTReader::get(StringRef Name) {
@@ -8707,6 +8722,7 @@ ASTReader::ASTReader(
   Consumer(nullptr), ModuleMgr(PP.getFileManager(), PCHContainerRdr),
   ReadTimer(std::move(ReadTimer)),
   PragmaMSStructState(-1),
+  PragmaMSPointersToMembersState(-1),
   isysroot(isysroot), DisableValidation(DisableValidation),
   AllowASTWithCompilerErrors(AllowASTWithCompilerErrors),
   AllowConfigurationMismatch(AllowConfigurationMismatch),

Modified: cfe/trunk/lib/Serialization/ASTWriter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/c

[libcxx] r262557 - Creating release candidate final from release_380 branch

2016-03-02 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Wed Mar  2 18:19:14 2016
New Revision: 262557

URL: http://llvm.org/viewvc/llvm-project?rev=262557&view=rev
Log:
Creating release candidate final from release_380 branch

Added:
libcxx/tags/RELEASE_380/final/   (props changed)
  - copied from r262556, libcxx/branches/release_38/

Propchange: libcxx/tags/RELEASE_380/final/
--
--- svn:mergeinfo (added)
+++ svn:mergeinfo Wed Mar  2 18:19:14 2016
@@ -0,0 +1,2 @@
+/libcxx/branches/apple:136569-137939
+/libcxx/trunk:257682,257696,257702,258107,258403,259682


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


  1   2   >