[PATCH] D56112: [clang-offload-bundler] Added install component

2019-01-21 Thread Vyacheslav Zakharin via Phabricator via cfe-commits
vzakhari added a comment.

ping


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56112/new/

https://reviews.llvm.org/D56112



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


[PATCH] D56411: [CUDA][HIP][Sema] Fix template kernel with function as template parameter

2019-01-21 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In D56411#1365745 , @rjmccall wrote:

> In D56411#1365727 , @yaxunl wrote:
>
> > In D56411#1360010 , @rjmccall 
> > wrote:
> >
> > > I think the diagnostic should come during instantiation when you find an 
> > > evaluated use of a host function within a device function.
> >
> >
> > It seems the body of function template is checked only during parsing of 
> > the definition of the template itself. When a function
> >  template is instantiated, the body of the instantiated function is not 
> > checked again.
>
>
> No, that's not correct.  However, it's checked somewhat differently, and it's 
> possible that the existing diagnostic is not set up to fire along all common 
> paths.  Try moving the diagnostic to `MarkFunctionReferenced`, and note that 
> `OdrUse` will be `false` in all the unevaluated contexts.


You are right. After I disable current diagnostic, I saw 
PerformPendingInstantiations at the end of parsing the TU, where the AST of the 
instantiated function is iterated and MarkFunctionReferenced is called. I will 
try to fix my patch as suggested. Thanks.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56411/new/

https://reviews.llvm.org/D56411



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


Re: [libcxx] r294553 - [libcxx][CMake] Support in-tree libunwind when building as part of runtimes

2019-01-21 Thread Leslie Zhai via cfe-commits


在 2019/1/21 下午5:36, Leslie Zhai 写道:

Hi Asiri,

Did you fix the issue when building libcxx and libcxxabi use LLVM's 
libunwind?


Fixed :)

Just put libcxx, libcxxabi, libunwind and compiler-rt under `runtimes` 
directory.


Leslie Zhai




http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20170206/184841.html 



I experienced the similar issue:

CMake Error at projects/libcxxabi/src/CMakeLists.txt:163 
(target_link_libraries):
  Target "unwind" of type UTILITY may not be linked into another 
target.  One

  may link only to INTERFACE, OBJECT, STATIC or SHARED libraries, or to
  executables with the ENABLE_EXPORTS property set.


CMake Error at projects/libcxxabi/src/CMakeLists.txt:197 
(target_link_libraries):
  Target "unwind" of type UTILITY may not be linked into another 
target.  One

  may link only to INTERFACE, OBJECT, STATIC or SHARED libraries, or to
  executables with the ENABLE_EXPORTS property set.

...

CMake Error at projects/libcxx/lib/CMakeLists.txt:244 
(target_link_libraries):
  Target "unwind" of type UTILITY may not be linked into another 
target.  One

  may link only to INTERFACE, OBJECT, STATIC or SHARED libraries, or to
  executables with the ENABLE_EXPORTS property set.


CMake Error at projects/libcxx/lib/CMakeLists.txt:268 
(target_link_libraries):
  Target "unwind" of type UTILITY may not be linked into another 
target.  One

  may link only to INTERFACE, OBJECT, STATIC or SHARED libraries, or to
  executables with the ENABLE_EXPORTS property set.

- 8<  8<  8<  8<  8<  8< ---

My cmake option:

$ cmake .. -DCMAKE_INSTALL_PREFIX=/opt/loong-llvm \
    -DCMAKE_BUILD_TYPE=Release \
    -DLLVM_ENABLE_ASSERTIONS=ON \
    -DCMAKE_C_COMPILER=/opt/loong-llvm/bin/clang \
    -DCMAKE_CXX_COMPILER=/opt/loong-llvm/bin/clang++ \
    -DCMAKE_C_FLAGS="-fPIC" \
    -DCMAKE_CXX_FLAGS="-std=c++11 -fPIC" \
    -DLLVM_BUILD_LLVM_DYLIB=ON \
    -DLLVM_LINK_LLVM_DYLIB=ON \
    -DLLVM_INSTALL_UTILS=ON \
    -DLLVM_ENABLE_RTTI=ON \
    -DLLVM_ENABLE_FFI=ON \
    -DLLVM_ENABLE_EH=ON \
    -DLLVM_BUILD_TESTS=OFF \
    -DLLVM_BUILD_DOCS=OFF \
    -DLLVM_ENABLE_SPHINX=OFF \
    -DLLVM_ENABLE_DOXYGEN=OFF \
    -DLLDB_DISABLE_LIBEDIT=1 \
    -DSPHINX_WARNINGS_AS_ERRORS=OFF \
    -DFFI_INCLUDE_DIR=$(pkg-config --variable=includedir libffi) \
    -DFFI_LIBRARY_DIR:PATH="$(pkg-config --variable=libdir libffi)" \
    -DLLVM_BINUTILS_INCDIR=/usr/include \
    -DLIBCXX_ENABLE_ABI_LINKER_SCRIPT=ON \
    -DLIBUNWIND_ENABLE_SHARED=OFF \
    -DLIBCXXABI_USE_LLVM_UNWINDER=ON \
    -DLLVM_DEFAULT_TARGET_TRIPLE="mips64el-redhat-linux" \
    -DCLANG_VENDOR="Loongson"

Regards,

Leslie Zhai



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


[PATCH] D45045: [DebugInfo] Generate debug information for labels.

2019-01-21 Thread Hsiangkai Wang via Phabricator via cfe-commits
HsiangKai added a comment.

D54199  and D54465 
 have been accepted and landed. I have tested 
the revision with LLVM test and Clang test. They are all passed. Chromium build 
is also successful in my local environment. I think it is ready to reland the 
revision.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D45045/new/

https://reviews.llvm.org/D45045



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


Re: r351603 - [ASTDump] NFC: Remove non-needed braces

2019-01-21 Thread Nico Weber via cfe-commits
(To be clear, your 3 others around the same time are all fine! I mean just
bracing tweaks.)

On Mon, Jan 21, 2019 at 9:03 PM Nico Weber  wrote:

> Please don't do changes like this. They have marginal utility and make
> blame output more annoying to work with.
>
> On Fri, Jan 18, 2019 at 5:18 PM Stephen Kelly via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: steveire
>> Date: Fri Jan 18 14:14:59 2019
>> New Revision: 351603
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=351603=rev
>> Log:
>> [ASTDump] NFC: Remove non-needed braces
>>
>> Modified:
>> cfe/trunk/lib/AST/ASTDumper.cpp
>>
>> Modified: cfe/trunk/lib/AST/ASTDumper.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDumper.cpp?rev=351603=351602=351603=diff
>>
>> ==
>> --- cfe/trunk/lib/AST/ASTDumper.cpp (original)
>> +++ cfe/trunk/lib/AST/ASTDumper.cpp Fri Jan 18 14:14:59 2019
>> @@ -1242,12 +1242,11 @@ void ASTDumper::VisitObjCMethodDecl(cons
>>if (D->isVariadic())
>>  OS << " variadic";
>>
>> -  if (D->isThisDeclarationADefinition()) {
>> +  if (D->isThisDeclarationADefinition())
>>  dumpDeclContext(D);
>> -  } else {
>> +  else
>>  for (const ParmVarDecl *Parameter : D->parameters())
>>dumpDecl(Parameter);
>> -  }
>>
>>if (D->hasBody())
>>  dumpStmt(D->getBody());
>>
>>
>> ___
>> 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: r351603 - [ASTDump] NFC: Remove non-needed braces

2019-01-21 Thread Nico Weber via cfe-commits
Please don't do changes like this. They have marginal utility and make
blame output more annoying to work with.

On Fri, Jan 18, 2019 at 5:18 PM Stephen Kelly via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: steveire
> Date: Fri Jan 18 14:14:59 2019
> New Revision: 351603
>
> URL: http://llvm.org/viewvc/llvm-project?rev=351603=rev
> Log:
> [ASTDump] NFC: Remove non-needed braces
>
> Modified:
> cfe/trunk/lib/AST/ASTDumper.cpp
>
> Modified: cfe/trunk/lib/AST/ASTDumper.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDumper.cpp?rev=351603=351602=351603=diff
>
> ==
> --- cfe/trunk/lib/AST/ASTDumper.cpp (original)
> +++ cfe/trunk/lib/AST/ASTDumper.cpp Fri Jan 18 14:14:59 2019
> @@ -1242,12 +1242,11 @@ void ASTDumper::VisitObjCMethodDecl(cons
>if (D->isVariadic())
>  OS << " variadic";
>
> -  if (D->isThisDeclarationADefinition()) {
> +  if (D->isThisDeclarationADefinition())
>  dumpDeclContext(D);
> -  } else {
> +  else
>  for (const ParmVarDecl *Parameter : D->parameters())
>dumpDecl(Parameter);
> -  }
>
>if (D->hasBody())
>  dumpStmt(D->getBody());
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D56998: [X86] Custom codegen 512-bit cvt(u)qq2tops, cvt(u)qqtopd, and cvt(u)dqtops intrinsics.

2019-01-21 Thread Craig Topper via Phabricator via cfe-commits
craig.topper updated this revision to Diff 182837.
craig.topper added a comment.

Rename the intrinics to include avx512 prefix


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56998/new/

https://reviews.llvm.org/D56998

Files:
  lib/CodeGen/CGBuiltin.cpp
  test/CodeGen/avx512dq-builtins.c
  test/CodeGen/avx512f-builtins.c

Index: test/CodeGen/avx512f-builtins.c
===
--- test/CodeGen/avx512f-builtins.c
+++ test/CodeGen/avx512f-builtins.c
@@ -5022,42 +5022,46 @@
 __m512 test_mm512_cvt_roundepi32_ps( __m512i __A)
 {
   // CHECK-LABEL: @test_mm512_cvt_roundepi32_ps
-  // CHECK: @llvm.x86.avx512.mask.cvtdq2ps.512
+  // CHECK: @llvm.x86.avx512.sitofp.round.v16f32.v16i32
   return _mm512_cvt_roundepi32_ps(__A, _MM_FROUND_TO_NEAREST_INT | _MM_FROUND_NO_EXC);
 }
 
 __m512 test_mm512_mask_cvt_roundepi32_ps(__m512 __W, __mmask16 __U, __m512i __A)
 {
   // CHECK-LABEL: @test_mm512_mask_cvt_roundepi32_ps
-  // CHECK: @llvm.x86.avx512.mask.cvtdq2ps.512
+  // CHECK: @llvm.x86.avx512.sitofp.round.v16f32.v16i32
+  // CHECK: select <16 x i1> %{{.*}}, <16 x float> %{{.*}}, <16 x float> %{{.*}}
   return _mm512_mask_cvt_roundepi32_ps(__W,__U,__A, _MM_FROUND_TO_NEAREST_INT | _MM_FROUND_NO_EXC);
 }
 
 __m512 test_mm512_maskz_cvt_roundepi32_ps(__mmask16 __U, __m512i __A)
 {
   // CHECK-LABEL: @test_mm512_maskz_cvt_roundepi32_ps
-  // CHECK: @llvm.x86.avx512.mask.cvtdq2ps.512
+  // CHECK: @llvm.x86.avx512.sitofp.round.v16f32.v16i32
+  // CHECK: select <16 x i1> %{{.*}}, <16 x float> %{{.*}}, <16 x float> %{{.*}}
   return _mm512_maskz_cvt_roundepi32_ps(__U,__A, _MM_FROUND_TO_NEAREST_INT | _MM_FROUND_NO_EXC);
 }
 
 __m512 test_mm512_cvt_roundepu32_ps(__m512i __A)
 {
   // CHECK-LABEL: @test_mm512_cvt_roundepu32_ps
-  // CHECK: @llvm.x86.avx512.mask.cvtudq2ps.512
+  // CHECK: @llvm.x86.avx512.uitofp.round.v16f32.v16i32
   return _mm512_cvt_roundepu32_ps(__A, _MM_FROUND_TO_NEAREST_INT | _MM_FROUND_NO_EXC);
 }
 
 __m512 test_mm512_mask_cvt_roundepu32_ps(__m512 __W, __mmask16 __U,__m512i __A)
 {
   // CHECK-LABEL: @test_mm512_mask_cvt_roundepu32_ps
-  // CHECK: @llvm.x86.avx512.mask.cvtudq2ps.512
+  // CHECK: @llvm.x86.avx512.uitofp.round.v16f32.v16i32
+  // CHECK: select <16 x i1> %{{.*}}, <16 x float> %{{.*}}, <16 x float> %{{.*}}
   return _mm512_mask_cvt_roundepu32_ps(__W,__U,__A, _MM_FROUND_TO_NEAREST_INT | _MM_FROUND_NO_EXC);
 }
 
 __m512 test_mm512_maskz_cvt_roundepu32_ps(__mmask16 __U,__m512i __A)
 {
   // CHECK-LABEL: @test_mm512_maskz_cvt_roundepu32_ps
-  // CHECK: @llvm.x86.avx512.mask.cvtudq2ps.512
+  // CHECK: @llvm.x86.avx512.uitofp.round.v16f32.v16i32
+  // CHECK: select <16 x i1> %{{.*}}, <16 x float> %{{.*}}, <16 x float> %{{.*}}
   return _mm512_maskz_cvt_roundepu32_ps(__U,__A, _MM_FROUND_TO_NEAREST_INT | _MM_FROUND_NO_EXC);
 }
 
Index: test/CodeGen/avx512dq-builtins.c
===
--- test/CodeGen/avx512dq-builtins.c
+++ test/CodeGen/avx512dq-builtins.c
@@ -613,55 +613,61 @@
 
 __m512d test_mm512_cvt_roundepi64_pd(__m512i __A) {
   // CHECK-LABEL: @test_mm512_cvt_roundepi64_pd
-  // CHECK: @llvm.x86.avx512.mask.cvtqq2pd.512
+  // CHECK: @llvm.x86.avx512.sitofp.round.v8f64.v8i64
   return _mm512_cvt_roundepi64_pd(__A, _MM_FROUND_TO_NEAREST_INT | _MM_FROUND_NO_EXC); 
 }
 
 __m512d test_mm512_mask_cvt_roundepi64_pd(__m512d __W, __mmask8 __U, __m512i __A) {
   // CHECK-LABEL: @test_mm512_mask_cvt_roundepi64_pd
-  // CHECK: @llvm.x86.avx512.mask.cvtqq2pd.512
+  // CHECK: @llvm.x86.avx512.sitofp.round.v8f64.v8i64
+  // CHECK: select <8 x i1> %{{.*}}, <8 x double> %{{.*}}, <8 x double> %{{.*}}
   return _mm512_mask_cvt_roundepi64_pd(__W, __U, __A, _MM_FROUND_TO_NEAREST_INT | _MM_FROUND_NO_EXC); 
 }
 
 __m512d test_mm512_maskz_cvt_roundepi64_pd(__mmask8 __U, __m512i __A) {
   // CHECK-LABEL: @test_mm512_maskz_cvt_roundepi64_pd
-  // CHECK: @llvm.x86.avx512.mask.cvtqq2pd.512
+  // CHECK: @llvm.x86.avx512.sitofp.round.v8f64.v8i64
+  // CHECK: select <8 x i1> %{{.*}}, <8 x double> %{{.*}}, <8 x double> %{{.*}}
   return _mm512_maskz_cvt_roundepi64_pd(__U, __A, _MM_FROUND_TO_NEAREST_INT | _MM_FROUND_NO_EXC); 
 }
 
 __m256 test_mm512_cvtepi64_ps(__m512i __A) {
   // CHECK-LABEL: @test_mm512_cvtepi64_ps
-  // CHECK: @llvm.x86.avx512.mask.cvtqq2ps.512
+  // CHECK: sitofp <8 x i64> %{{.*}} to <8 x float>
   return _mm512_cvtepi64_ps(__A); 
 }
 
 __m256 test_mm512_mask_cvtepi64_ps(__m256 __W, __mmask8 __U, __m512i __A) {
   // CHECK-LABEL: @test_mm512_mask_cvtepi64_ps
-  // CHECK: @llvm.x86.avx512.mask.cvtqq2ps.512
+  // CHECK: sitofp <8 x i64> %{{.*}} to <8 x float>
+  // CHECK: select <8 x i1> %{{.*}}, <8 x float> %{{.*}}, <8 x float> %{{.*}}
   return _mm512_mask_cvtepi64_ps(__W, __U, __A); 
 }
 
 __m256 test_mm512_maskz_cvtepi64_ps(__mmask8 __U, __m512i __A) {
   // CHECK-LABEL: @test_mm512_maskz_cvtepi64_ps
-  // CHECK: @llvm.x86.avx512.mask.cvtqq2ps.512
+  // CHECK: sitofp <8 x 

[PATCH] D56821: [CodeGen] Always use string computed in Sema for PredefinedExpr

2019-01-21 Thread Eli Friedman via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL351766: [CodeGen] Always use string computed in Sema for 
PredefinedExpr (authored by efriedma, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D56821?vs=182196=182834#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56821/new/

https://reviews.llvm.org/D56821

Files:
  cfe/trunk/lib/CodeGen/CGExprConstant.cpp
  cfe/trunk/test/CodeGen/const-init.c
  cfe/trunk/test/CodeGenCXX/predefined-expr-cxx14.cpp


Index: cfe/trunk/test/CodeGenCXX/predefined-expr-cxx14.cpp
===
--- cfe/trunk/test/CodeGenCXX/predefined-expr-cxx14.cpp
+++ cfe/trunk/test/CodeGenCXX/predefined-expr-cxx14.cpp
@@ -20,6 +20,8 @@
 // CHECK-DAG: @__func__.___ZN16ClassBlockConstrD2Ev_block_invoke = private 
unnamed_addr constant [31 x i8] c"~ClassBlockConstr_block_invoke\00"
 // CHECK-DAG: @__func__.___ZN16ClassBlockConstrC2Ev_block_invoke = private 
unnamed_addr constant [30 x i8] c"ClassBlockConstr_block_invoke\00"
 
+// CHECK-DAG: private unnamed_addr constant [32 x i8] c"const char 
*ConstexprPrettyFn()\00"
+
 int printf(const char * _Format, ...);
 
 class ClassInTopLevelNamespace {
@@ -83,6 +85,11 @@
   const char *getFunc() const { return Func; }
 };
 
+constexpr const char* ConstexprPrettyFn() {
+  return __PRETTY_FUNCTION__;
+}
+const char* ConstexprPrettyVar = ConstexprPrettyFn();
+
 int
 main() {
   int a;
Index: cfe/trunk/test/CodeGen/const-init.c
===
--- cfe/trunk/test/CodeGen/const-init.c
+++ cfe/trunk/test/CodeGen/const-init.c
@@ -121,8 +121,8 @@
 struct g23 {char a; short b; char c; struct g22 d;};
 struct g23 g24 = {1,2,3,4};
 
-// CHECK: @g25.g26 = internal global i8* getelementptr inbounds ([4 x i8], [4 
x i8]* @__func__.g25, i32 0, i32 0)
-// CHECK: @__func__.g25 = private unnamed_addr constant [4 x i8] c"g25\00"
+// CHECK: @g25.g26 = internal global i8* getelementptr inbounds ([4 x i8], [4 
x i8]* @[[FUNC:.*]], i32 0, i32 0)
+// CHECK: @[[FUNC]] = private unnamed_addr constant [4 x i8] c"g25\00"
 int g25() {
   static const char *g26 = __func__;
   return *g26;
@@ -153,7 +153,7 @@
   DCC_PASSWD passwd;
   } DCC_SRVR_NM;
   // CHECK: @g29.a = internal global %struct.DCC_SRVR_NM { [2 x i8] c"@\00" }, 
align 1
-  // CHECK: @g29.b = internal global [1 x i32] [i32 ptrtoint ([5 x i8]* @.str 
to i32)], align 4
+  // CHECK: @g29.b = internal global [1 x i32] [i32 ptrtoint ([5 x i8]* 
@.str.1 to i32)], align 4
   // CHECK: @g29.c = internal global [1 x i32] [i32 97], align 4
   static DCC_SRVR_NM a = { {"@"} };
   static int b[1] = { "asdf" }; // expected-warning {{incompatible pointer to 
integer conversion initializing 'int' with an expression of type 'char [5]'}}
Index: cfe/trunk/lib/CodeGen/CGExprConstant.cpp
===
--- cfe/trunk/lib/CodeGen/CGExprConstant.cpp
+++ cfe/trunk/lib/CodeGen/CGExprConstant.cpp
@@ -1788,17 +1788,7 @@
 
 ConstantLValue
 ConstantLValueEmitter::VisitPredefinedExpr(const PredefinedExpr *E) {
-  if (auto CGF = Emitter.CGF) {
-LValue Res = CGF->EmitPredefinedLValue(E);
-return cast(Res.getAddress());
-  }
-
-  auto kind = E->getIdentKind();
-  if (kind == PredefinedExpr::PrettyFunction) {
-return CGM.GetAddrOfConstantCString("top level", ".tmp");
-  }
-
-  return CGM.GetAddrOfConstantCString("", ".tmp");
+  return CGM.GetAddrOfConstantStringFromLiteral(E->getFunctionName());
 }
 
 ConstantLValue


Index: cfe/trunk/test/CodeGenCXX/predefined-expr-cxx14.cpp
===
--- cfe/trunk/test/CodeGenCXX/predefined-expr-cxx14.cpp
+++ cfe/trunk/test/CodeGenCXX/predefined-expr-cxx14.cpp
@@ -20,6 +20,8 @@
 // CHECK-DAG: @__func__.___ZN16ClassBlockConstrD2Ev_block_invoke = private unnamed_addr constant [31 x i8] c"~ClassBlockConstr_block_invoke\00"
 // CHECK-DAG: @__func__.___ZN16ClassBlockConstrC2Ev_block_invoke = private unnamed_addr constant [30 x i8] c"ClassBlockConstr_block_invoke\00"
 
+// CHECK-DAG: private unnamed_addr constant [32 x i8] c"const char *ConstexprPrettyFn()\00"
+
 int printf(const char * _Format, ...);
 
 class ClassInTopLevelNamespace {
@@ -83,6 +85,11 @@
   const char *getFunc() const { return Func; }
 };
 
+constexpr const char* ConstexprPrettyFn() {
+  return __PRETTY_FUNCTION__;
+}
+const char* ConstexprPrettyVar = ConstexprPrettyFn();
+
 int
 main() {
   int a;
Index: cfe/trunk/test/CodeGen/const-init.c
===
--- cfe/trunk/test/CodeGen/const-init.c
+++ cfe/trunk/test/CodeGen/const-init.c
@@ -121,8 +121,8 @@
 struct g23 {char a; short b; char c; struct g22 d;};
 struct g23 g24 = {1,2,3,4};
 
-// CHECK: @g25.g26 = internal global i8* getelementptr inbounds ([4 x i8], [4 x i8]* @__func__.g25, 

r351766 - [CodeGen] Always use string computed in Sema for PredefinedExpr

2019-01-21 Thread Eli Friedman via cfe-commits
Author: efriedma
Date: Mon Jan 21 16:11:17 2019
New Revision: 351766

URL: http://llvm.org/viewvc/llvm-project?rev=351766=rev
Log:
[CodeGen] Always use string computed in Sema for PredefinedExpr

We can't use any other string, anyway, because its type wouldn't
match the type of the PredefinedExpr.

With this change, we don't compute a "nice" name for the __func__ global
when it's used in the initializer for a constant. This doesn't seem like
a great loss, and I'm not sure how to fix it without either storing more
information in the AST, or somehow threading through the information
from ExprConstant.cpp.

This could break some situations involving BlockDecl; currently,
CodeGenFunction::EmitPredefinedLValue has some logic to intentionally
emit a string different from what Sema computed.  This code skips that
logic... but that logic can't work correctly in general anyway.  (For
example, sizeof(__func__) returns the wrong result.) Hopefully this
doesn't affect practical code.

Fixes https://bugs.llvm.org/show_bug.cgi?id=40313 .

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


Modified:
cfe/trunk/lib/CodeGen/CGExprConstant.cpp
cfe/trunk/test/CodeGen/const-init.c
cfe/trunk/test/CodeGenCXX/predefined-expr-cxx14.cpp

Modified: cfe/trunk/lib/CodeGen/CGExprConstant.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprConstant.cpp?rev=351766=351765=351766=diff
==
--- cfe/trunk/lib/CodeGen/CGExprConstant.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprConstant.cpp Mon Jan 21 16:11:17 2019
@@ -1788,17 +1788,7 @@ ConstantLValueEmitter::VisitObjCStringLi
 
 ConstantLValue
 ConstantLValueEmitter::VisitPredefinedExpr(const PredefinedExpr *E) {
-  if (auto CGF = Emitter.CGF) {
-LValue Res = CGF->EmitPredefinedLValue(E);
-return cast(Res.getAddress());
-  }
-
-  auto kind = E->getIdentKind();
-  if (kind == PredefinedExpr::PrettyFunction) {
-return CGM.GetAddrOfConstantCString("top level", ".tmp");
-  }
-
-  return CGM.GetAddrOfConstantCString("", ".tmp");
+  return CGM.GetAddrOfConstantStringFromLiteral(E->getFunctionName());
 }
 
 ConstantLValue

Modified: cfe/trunk/test/CodeGen/const-init.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/const-init.c?rev=351766=351765=351766=diff
==
--- cfe/trunk/test/CodeGen/const-init.c (original)
+++ cfe/trunk/test/CodeGen/const-init.c Mon Jan 21 16:11:17 2019
@@ -121,8 +121,8 @@ struct g22 {int x;} __attribute((packed)
 struct g23 {char a; short b; char c; struct g22 d;};
 struct g23 g24 = {1,2,3,4};
 
-// CHECK: @g25.g26 = internal global i8* getelementptr inbounds ([4 x i8], [4 
x i8]* @__func__.g25, i32 0, i32 0)
-// CHECK: @__func__.g25 = private unnamed_addr constant [4 x i8] c"g25\00"
+// CHECK: @g25.g26 = internal global i8* getelementptr inbounds ([4 x i8], [4 
x i8]* @[[FUNC:.*]], i32 0, i32 0)
+// CHECK: @[[FUNC]] = private unnamed_addr constant [4 x i8] c"g25\00"
 int g25() {
   static const char *g26 = __func__;
   return *g26;
@@ -153,7 +153,7 @@ void g29() {
   DCC_PASSWD passwd;
   } DCC_SRVR_NM;
   // CHECK: @g29.a = internal global %struct.DCC_SRVR_NM { [2 x i8] c"@\00" }, 
align 1
-  // CHECK: @g29.b = internal global [1 x i32] [i32 ptrtoint ([5 x i8]* @.str 
to i32)], align 4
+  // CHECK: @g29.b = internal global [1 x i32] [i32 ptrtoint ([5 x i8]* 
@.str.1 to i32)], align 4
   // CHECK: @g29.c = internal global [1 x i32] [i32 97], align 4
   static DCC_SRVR_NM a = { {"@"} };
   static int b[1] = { "asdf" }; // expected-warning {{incompatible pointer to 
integer conversion initializing 'int' with an expression of type 'char [5]'}}

Modified: cfe/trunk/test/CodeGenCXX/predefined-expr-cxx14.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/predefined-expr-cxx14.cpp?rev=351766=351765=351766=diff
==
--- cfe/trunk/test/CodeGenCXX/predefined-expr-cxx14.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/predefined-expr-cxx14.cpp Mon Jan 21 16:11:17 2019
@@ -20,6 +20,8 @@
 // CHECK-DAG: @__func__.___ZN16ClassBlockConstrD2Ev_block_invoke = private 
unnamed_addr constant [31 x i8] c"~ClassBlockConstr_block_invoke\00"
 // CHECK-DAG: @__func__.___ZN16ClassBlockConstrC2Ev_block_invoke = private 
unnamed_addr constant [30 x i8] c"ClassBlockConstr_block_invoke\00"
 
+// CHECK-DAG: private unnamed_addr constant [32 x i8] c"const char 
*ConstexprPrettyFn()\00"
+
 int printf(const char * _Format, ...);
 
 class ClassInTopLevelNamespace {
@@ -83,6 +85,11 @@ public:
   const char *getFunc() const { return Func; }
 };
 
+constexpr const char* ConstexprPrettyFn() {
+  return __PRETTY_FUNCTION__;
+}
+const char* ConstexprPrettyVar = ConstexprPrettyFn();
+
 int
 main() {
   int a;


___
cfe-commits mailing list

[PATCH] D50403: [clang-format]AlignConsecutiveAssignments

2019-01-21 Thread Roland Schulz via Phabricator via cfe-commits
rolandschulz added a comment.

Is anyone still working on this or is a new author needed?

For what's it worth it, I'm in favor of the first version (right hand aligned) 
for different sized operators.

A matching bug exists at: https://bugs.llvm.org/show_bug.cgi?id=31681


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D50403/new/

https://reviews.llvm.org/D50403



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


[PATCH] D56723: [CodeComplete] Propagate preferred types through parser in more cases

2019-01-21 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

This seems to be introducing a requirement that `enterUnknown` is called on all 
paths through the parser where we recurse to parse a subexpression and don't 
have specific type information. That seems like an unfortunate requirement to 
me from a maintenance perspective; have you considered alternative approaches? 
For example, we could store the preferred type alongside the `SourceLocation` 
of the corresponding token (and propagate the information when we parse 
parentheses and any other completion-type-preserving construct), and only apply 
the information when the code completion token is at that location. That way, 
we only need to annotate cases where we know the preferred type, not when we 
don't.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56723/new/

https://reviews.llvm.org/D56723



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


[PATCH] D56651: [ASTImporter] Fix importing OperatorDelete from CXXConstructorDecl

2019-01-21 Thread Aleksei Sidorin via Phabricator via cfe-commits
a_sidorin accepted this revision.
a_sidorin added a comment.
This revision is now accepted and ready to land.

LGTM, thank you!
I'm sorry if the change I requested doesn't look good, but I think the 
correctness is our priority.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56651/new/

https://reviews.llvm.org/D56651



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


[PATCH] D56411: [CUDA][HIP][Sema] Fix template kernel with function as template parameter

2019-01-21 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

In D56411#1365727 , @yaxunl wrote:

> In D56411#1360010 , @rjmccall wrote:
>
> > I think the diagnostic should come during instantiation when you find an 
> > evaluated use of a host function within a device function.
>
>
> It seems the body of function template is checked only during parsing of the 
> definition of the template itself. When a function
>  template is instantiated, the body of the instantiated function is not 
> checked again.


No, that's not correct.  However, it's checked somewhat differently, and it's 
possible that the existing diagnostic is not set up to fire along all common 
paths.  Try moving the diagnostic to `MarkFunctionReferenced`, and note that 
`OdrUse` will be `false` in all the unevaluated contexts.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56411/new/

https://reviews.llvm.org/D56411



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


[PATCH] D56967: Thread safety analysis: Improve diagnostics for double locking

2019-01-21 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert marked 2 inline comments as done.
aaronpuchert added a comment.

Thanks for the review! I'll commit this when I have commit access again, which 
is waiting for my employer's approval to the relicensing.




Comment at: lib/Sema/AnalysisBasedWarnings.cpp:1693
+ << Kind << LockName);
+OptionalNotes notes =
+LocLocked.isValid()

I'll assume it's also `Notes` then. I tend to subconsciously forget these 
things.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56967/new/

https://reviews.llvm.org/D56967



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


[PATCH] D56411: [CUDA][HIP][Sema] Fix template kernel with function as template parameter

2019-01-21 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In D56411#1360010 , @rjmccall wrote:

> I think the diagnostic should come during instantiation when you find an 
> evaluated use of a host function within a device function.


It seems the body of function template is checked only during parsing of the 
definition of the template itself. When a function
template is instantiated, the body of the instantiated function is not checked 
again.

I could push an evaluated context, then iterate the AST of the instantiated 
template function to check function call expressions.
However, this will increase the compilation time. Can I do the check in codegen 
stage where the function call instruction is emitted?
That will add extra AST iteration.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56411/new/

https://reviews.llvm.org/D56411



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


[PATCH] D57032: [SemaCXX] Param diagnostic matches overload logic

2019-01-21 Thread Brian Gesiak via Phabricator via cfe-commits
modocache created this revision.
modocache added a reviewer: rsmith.

Given the following test program:

  class C {
  public:
int A(int a, int& b);
  };
  
  int C::A(const int a, int b) {
return a * b;
  }

Clang would produce an error message that correctly diagnosed the
redeclaration of `C::A` to not match the original declaration (the
parameters to the two declarations do not match -- the original takes an
`int &` as its 2nd parameter, but the redeclaration takes an `int`). However,
it also produced a note diagnostic that inaccurately pointed to the
first parameter, claiming that `const int` in the redeclaration did not
match the unqualified `int` in the original. The diagnostic is
misleading because it has nothing to do with why the program does not
compile.

The logic for checking for a function overload, in
`Sema::FunctionParamTypesAreEqual`, discards cv-qualifiers before
checking whether the types are equal. Do the same when producing the
overload diagnostic.


Repository:
  rC Clang

https://reviews.llvm.org/D57032

Files:
  lib/Sema/SemaDecl.cpp
  test/SemaCXX/function-redecl.cpp


Index: test/SemaCXX/function-redecl.cpp
===
--- test/SemaCXX/function-redecl.cpp
+++ test/SemaCXX/function-redecl.cpp
@@ -125,3 +125,9 @@
 }
 void Foo::beEvil() {} // expected-error {{out-of-line definition of 'beEvil' 
does not match any declaration in namespace 'redecl_typo::Foo'; did you mean 
'BeEvil'?}}
 }
+
+struct CVQualFun {
+  void func(int a, int ); // expected-note {{type of 2nd parameter of member 
declaration does not match definition ('int &' vs 'int')}}
+};
+
+void CVQualFun::func(const int a, int b) {} // expected-error {{out-of-line 
definition of 'func' does not match any declaration in 'CVQualFun'}}
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -5089,7 +5089,8 @@
 QualType DefParamTy = Definition->getParamDecl(Idx)->getType();
 
 // The parameter types are identical
-if (Context.hasSameType(DefParamTy, DeclParamTy))
+if (Context.hasSameType(DefParamTy.getUnqualifiedType(),
+DeclParamTy.getUnqualifiedType()))
   continue;
 
 QualType DeclParamBaseTy = getCoreType(DeclParamTy);


Index: test/SemaCXX/function-redecl.cpp
===
--- test/SemaCXX/function-redecl.cpp
+++ test/SemaCXX/function-redecl.cpp
@@ -125,3 +125,9 @@
 }
 void Foo::beEvil() {} // expected-error {{out-of-line definition of 'beEvil' does not match any declaration in namespace 'redecl_typo::Foo'; did you mean 'BeEvil'?}}
 }
+
+struct CVQualFun {
+  void func(int a, int ); // expected-note {{type of 2nd parameter of member declaration does not match definition ('int &' vs 'int')}}
+};
+
+void CVQualFun::func(const int a, int b) {} // expected-error {{out-of-line definition of 'func' does not match any declaration in 'CVQualFun'}}
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -5089,7 +5089,8 @@
 QualType DefParamTy = Definition->getParamDecl(Idx)->getType();
 
 // The parameter types are identical
-if (Context.hasSameType(DefParamTy, DeclParamTy))
+if (Context.hasSameType(DefParamTy.getUnqualifiedType(),
+DeclParamTy.getUnqualifiedType()))
   continue;
 
 QualType DeclParamBaseTy = getCoreType(DeclParamTy);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D56318: [HIP] Fix size_t for MSVC environment

2019-01-21 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In D56318#1355705 , @rjmccall wrote:

> It's pretty unfortunate that all these fields have to be individually called 
> out like this.  Can you move all these basic layout fields into a separate 
> `struct` (which can be a secondary base class of `TargetInfo`) which can then 
> just be normally copied?  Anything that needs special copy semantics, like 
> the LLVM `DataLayout` (do you need to copy this?) doesn't need to go into 
> that struct, just the basic POD things that determine fundamental type 
> layouts and semantics.


LLVM DataLayout contains target specific stuff and cannot be simply copied. So 
far we did not see necessity to adjust device data layout for host.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56318/new/

https://reviews.llvm.org/D56318



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


[PATCH] D56318: [HIP] Fix size_t for MSVC environment

2019-01-21 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 182815.
yaxunl added a comment.

separate layout controlling flags to a base class for TargetInfo.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56318/new/

https://reviews.llvm.org/D56318

Files:
  include/clang/Basic/TargetInfo.h
  lib/Basic/TargetInfo.cpp
  lib/Basic/Targets/AMDGPU.cpp
  lib/Frontend/CompilerInstance.cpp
  test/SemaCUDA/amdgpu-size_t.cu

Index: test/SemaCUDA/amdgpu-size_t.cu
===
--- /dev/null
+++ test/SemaCUDA/amdgpu-size_t.cu
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -aux-triple x86_64-pc-windows-msvc -fms-compatibility -fcuda-is-device -fsyntax-only -verify %s
+
+// expected-no-diagnostics
+typedef unsigned __int64 size_t;
+typedef __int64 intptr_t;
+typedef unsigned __int64 uintptr_t;
+
Index: lib/Frontend/CompilerInstance.cpp
===
--- lib/Frontend/CompilerInstance.cpp
+++ lib/Frontend/CompilerInstance.cpp
@@ -929,6 +929,9 @@
   // Adjust target options based on codegen options.
   getTarget().adjustTargetOptions(getCodeGenOpts(), getTargetOpts());
 
+  if (auto *Aux = getAuxTarget())
+getTarget().copyAuxTarget(Aux);
+
   // rewriter project will change target built-in bool type from its default.
   if (getFrontendOpts().ProgramAction == frontend::RewriteObjC)
 getTarget().noSignedCharForObjCBool();
Index: lib/Basic/Targets/AMDGPU.cpp
===
--- lib/Basic/Targets/AMDGPU.cpp
+++ lib/Basic/Targets/AMDGPU.cpp
@@ -261,6 +261,7 @@
   }
 
   MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;
+  ShouldCopyAuxTarget = true;
 }
 
 void AMDGPUTargetInfo::adjust(LangOptions ) {
Index: lib/Basic/TargetInfo.cpp
===
--- lib/Basic/TargetInfo.cpp
+++ lib/Basic/TargetInfo.cpp
@@ -130,6 +130,7 @@
   // Default to an unknown platform name.
   PlatformName = "unknown";
   PlatformMinVersion = VersionTuple();
+  ShouldCopyAuxTarget = false;
 }
 
 // Out of line virtual dtor for TargetInfo.
@@ -796,3 +797,12 @@
   assert(getAccumIBits() >= getUnsignedAccumIBits());
   assert(getLongAccumIBits() >= getUnsignedLongAccumIBits());
 }
+
+void TargetInfo::copyAuxTarget(TargetInfo *Aux) {
+  if (!ShouldCopyAuxTarget)
+return;
+
+  auto *Target = static_cast(this);
+  auto *Src = static_cast(Aux);
+  *Target = *Src;
+}
Index: include/clang/Basic/TargetInfo.h
===
--- include/clang/Basic/TargetInfo.h
+++ include/clang/Basic/TargetInfo.h
@@ -49,21 +49,8 @@
 
 namespace Builtin { struct Info; }
 
-/// Exposes information about the current target.
-///
-class TargetInfo : public RefCountedBase {
-  std::shared_ptr TargetOpts;
-  llvm::Triple Triple;
-protected:
-  // Target values set by the ctor of the actual target implementation.  Default
-  // values are specified by the TargetInfo constructor.
-  bool BigEndian;
-  bool TLSSupported;
-  bool VLASupported;
-  bool NoAsmVariants;  // True if {|} are normal characters.
-  bool HasLegalHalfType; // True if the backend supports operations on the half
- // LLVM IR type.
-  bool HasFloat128;
+/// Flags controlling how a type is layed out in memory.
+struct TransferrableTargetInfo {
   unsigned char PointerWidth, PointerAlign;
   unsigned char BoolWidth, BoolAlign;
   unsigned char IntWidth, IntAlign;
@@ -104,15 +91,91 @@
   unsigned char SuitableAlign;
   unsigned char DefaultAlignForAttributeAligned;
   unsigned char MinGlobalAlign;
-  unsigned char MaxAtomicPromoteWidth, MaxAtomicInlineWidth;
+
+  unsigned short NewAlign;
   unsigned short MaxVectorAlign;
   unsigned short MaxTLSAlign;
+
+  const llvm::fltSemantics *HalfFormat, *FloatFormat, *DoubleFormat,
+*LongDoubleFormat, *Float128Format;
+
+  ///=== Target Data Type Query Methods ---===//
+  enum IntType {
+NoInt = 0,
+SignedChar,
+UnsignedChar,
+SignedShort,
+UnsignedShort,
+SignedInt,
+UnsignedInt,
+SignedLong,
+UnsignedLong,
+SignedLongLong,
+UnsignedLongLong
+  };
+
+  enum RealType {
+NoFloat = 255,
+Float = 0,
+Double,
+LongDouble,
+Float128
+  };
+protected:
+  IntType SizeType, IntMaxType, PtrDiffType, IntPtrType, WCharType,
+  WIntType, Char16Type, Char32Type, Int64Type, SigAtomicType,
+  ProcessIDType;
+
+  /// Whether Objective-C's built-in boolean type should be signed char.
+  ///
+  /// Otherwise, when this flag is not set, the normal built-in boolean type is
+  /// used.
+  unsigned UseSignedCharForObjCBool : 1;
+
+  /// Control whether the alignment of bit-field types is respected when laying
+  /// out structures. If true, then the alignment of the bit-field type will be
+  /// used to (a) impact the alignment of the containing structure, and (b)
+  /// ensure that the 

[PATCH] D56967: Thread safety analysis: Improve diagnostics for double locking

2019-01-21 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM aside from a naming convention nit.




Comment at: lib/Analysis/ThreadSafety.cpp:984
 StringRef DiagKind) const {
-if (!FSet.findLock(FactMan, Cp)) {
+if (const FactEntry *fact = FSet.findLock(FactMan, Cp)) {
+  if (Handler)

fact -> Fact


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56967/new/

https://reviews.llvm.org/D56967



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


LLVM buildmaster will restart tonight

2019-01-21 Thread Galina Kistanova via cfe-commits
 Hello everyone,

LLVM buildmaster will be updated and restarted after 6PM Pacific time today.

Thanks

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


[PATCH] D56903: [clangd] Suggest adding missing includes for incomplete type diagnostics.

2019-01-21 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

This looks pretty good! My main concern is latency (and variability of latency) 
in practice.
Particularly:

- we should avoid paying for fuzzyfind and fetching hundreds of results when we 
want exact-match
- limit the damage in degenerate cases: should we limit to e.g. 5 index queries 
per TU?

Actually, now that I think about it - if we can see a forward declaration, 
can't we do a lookup() instead of a fuzzyFind?
Is the problem that this doesn't generalize to the no-declaration case (where 
it looks like a typo)?

If we had an operation that looked like lookup() but worked by qname, would we 
design the feature the same way?
In particular, would we want to batch the requests to the index (lookup takes a 
set of IDs)? This would affect the code structure a bit. But it would make the 
feature cost basically O(1) instead of O(errs)...




Comment at: clangd/ClangdUnit.cpp:295
 
+  llvm::Optional FixIncludes;
+  auto BuildDir = VFS->getCurrentWorkingDirectory();

Probably worth a two-line comment explaining at a high level what this is doing.
Somewhat redundant with `IncludeFixer.h` but probably worth it anyway since 
this containing function is a complicated mess.



Comment at: clangd/ClangdUnit.h:65
 struct ParseInputs {
+  ParseInputs(tooling::CompileCommand CompileCommand,
+  IntrusiveRefCntPtr FS,

(nit: can we keep this as a plain struct? Once the number of members get large, 
initializing them one-by-one probably reads better anyway...)



Comment at: clangd/ClangdUnit.h:91
+IntrusiveRefCntPtr VFS,
+const SymbolIndex *Index);
 

Index is a reasonable (if surprising) param here, but I think we need to 
explicitly enable the include-fixing behavior. Even the very minimal hard-coded 
list of clang-tidy checks caused issues :-( And this is going to result in new 
network RPCs in some configs.

I'd suggest keeping the Index param, and wrapping the "use include fixer?" 
policy along with the clang-tidy options in D55256 as some sort of "diagnostic 
options" struct. (Though be wary of name clash with the one in Diagnostics.h, 
sigh).



Comment at: clangd/Diagnostics.h:105
+  /// If set, possibly adds fixes for diagnostics using \p Fixer.
+  void setIncludeFixer(const IncludeFixer ) { FixIncludes =  }
+

This seems like a suspicious dependency.
Can we indirect here e.g. `void contributeFixes(std::function(const 
clang::Diagnostic&)>)`



Comment at: clangd/IncludeFixer.cpp:1
+//===--- IncludeFixer.cpp *- 
C++-*-===//
+//

new copyright notice



Comment at: clangd/IncludeFixer.cpp:39
+   const clang::Diagnostic ) const {
+  if (isIncompleteTypeDiag(Info.getID())) {
+// Incomplete type diagnostics should have a QualType argument for the

can you add a trace to this function so we know what the impact on latency is?



Comment at: clangd/IncludeFixer.cpp:66
+  vlog("Trying to fix include for incomplete type {0}", IncompleteType);
+  FuzzyFindRequest Req;
+  Req.AnyScope = false;

limit?



Comment at: clangd/IncludeFixer.cpp:74
+  llvm::Optional Matched;
+  Index.fuzzyFind(Req, [&](const Symbol ) {
+// FIXME: support multiple matched symbols.

so issuing a bunch of fuzzy finds in sequence is clearly not ideal from a 
performance standpoint.
Any ideas on what we might do better, or how we can limit the worst case?
(not sure we need to do any better in this patch, but might be worth comments)



Comment at: clangd/IncludeFixer.cpp:112
+  vlog("Failed to calculate include insertion for {0} into {1}: {2}", File,
+   Inc, llvm::toString(ToInclude.takeError()));
+}

should be no need for toString here



Comment at: clangd/IncludeFixer.h:1
+//===- IncludeFixer.h - Add missing includes *- C++ 
-*-===//
+//

new copyright notice



Comment at: clangd/IncludeFixer.h:39
+  /// Attempts to recover diagnostic caused by an incomplete type \p T.
+  std::vector fixInCompleteType(const Type ) const;
+

nit: incomplete is one word



Comment at: unittests/clangd/IncludeFixerTests.cpp:1
+//===-- ClangdUnitTests.cpp - ClangdUnit tests --*- C++ 
-*-===//
+//

new copyright notice; wrong filename



Comment at: unittests/clangd/IncludeFixerTests.cpp:26
+
+testing::Matcher WithFix(testing::Matcher FixMatcher) {
+  return Field(::Fixes, ElementsAre(FixMatcher));

because the helpers and public APIs tested are common, I wonder if we'd be 
better off creating DiagnosticsTests.cpp and moving the relevant tests from 
both ClangdUnit and here 

[PATCH] D56976: [clang] [test] Pass -ccc-install-dir in mac compilation db test

2019-01-21 Thread Michał Górny via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL351752: [test] Pass -ccc-install-dir in mac compilation db 
test (authored by mgorny, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D56976?vs=182785=182803#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56976/new/

https://reviews.llvm.org/D56976

Files:
  cfe/trunk/test/Tooling/clang-check-mac-libcxx-fixed-compilation-db.cpp


Index: cfe/trunk/test/Tooling/clang-check-mac-libcxx-fixed-compilation-db.cpp
===
--- cfe/trunk/test/Tooling/clang-check-mac-libcxx-fixed-compilation-db.cpp
+++ cfe/trunk/test/Tooling/clang-check-mac-libcxx-fixed-compilation-db.cpp
@@ -10,6 +10,11 @@
 //
 // RUN: cp clang-check %t/mock-libcxx/bin/
 // RUN: cp %s %t/test.cpp
-// RUN: "%t/mock-libcxx/bin/clang-check" -p %t %t/test.cpp -- -stdlib=libc++ 
-target x86_64-apple-darwin
+// RUN: "%t/mock-libcxx/bin/clang-check" -p %t %t/test.cpp -- \
+// RUN: -stdlib=libc++ -target x86_64-apple-darwin \
+// RUN: -ccc-install-dir %t/mock-libcxx/bin
+//
+// ^ -ccc-install-dir passed to unbreak tests on *BSD where
+//   getMainExecutable() relies on real argv[0] being passed
 #include 
 vector v;


Index: cfe/trunk/test/Tooling/clang-check-mac-libcxx-fixed-compilation-db.cpp
===
--- cfe/trunk/test/Tooling/clang-check-mac-libcxx-fixed-compilation-db.cpp
+++ cfe/trunk/test/Tooling/clang-check-mac-libcxx-fixed-compilation-db.cpp
@@ -10,6 +10,11 @@
 //
 // RUN: cp clang-check %t/mock-libcxx/bin/
 // RUN: cp %s %t/test.cpp
-// RUN: "%t/mock-libcxx/bin/clang-check" -p %t %t/test.cpp -- -stdlib=libc++ -target x86_64-apple-darwin
+// RUN: "%t/mock-libcxx/bin/clang-check" -p %t %t/test.cpp -- \
+// RUN: -stdlib=libc++ -target x86_64-apple-darwin \
+// RUN: -ccc-install-dir %t/mock-libcxx/bin
+//
+// ^ -ccc-install-dir passed to unbreak tests on *BSD where
+//   getMainExecutable() relies on real argv[0] being passed
 #include 
 vector v;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r351752 - [test] Pass -ccc-install-dir in mac compilation db test

2019-01-21 Thread Michal Gorny via cfe-commits
Author: mgorny
Date: Mon Jan 21 09:05:43 2019
New Revision: 351752

URL: http://llvm.org/viewvc/llvm-project?rev=351752=rev
Log:
[test] Pass -ccc-install-dir in mac compilation db test

Pass -ccc-install-dir explicitly as the compilation database code does
not pass argv[0] to getMainExecutable(), while some systems require it
to return the correct path.  Since the relevant code is apparently only
applicable to Darwin, just pass correct -ccc-install-dir to make
the tests pass on *BSD systems.

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

Modified:
cfe/trunk/test/Tooling/clang-check-mac-libcxx-fixed-compilation-db.cpp

Modified: cfe/trunk/test/Tooling/clang-check-mac-libcxx-fixed-compilation-db.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Tooling/clang-check-mac-libcxx-fixed-compilation-db.cpp?rev=351752=351751=351752=diff
==
--- cfe/trunk/test/Tooling/clang-check-mac-libcxx-fixed-compilation-db.cpp 
(original)
+++ cfe/trunk/test/Tooling/clang-check-mac-libcxx-fixed-compilation-db.cpp Mon 
Jan 21 09:05:43 2019
@@ -10,6 +10,11 @@
 //
 // RUN: cp clang-check %t/mock-libcxx/bin/
 // RUN: cp %s %t/test.cpp
-// RUN: "%t/mock-libcxx/bin/clang-check" -p %t %t/test.cpp -- -stdlib=libc++ 
-target x86_64-apple-darwin
+// RUN: "%t/mock-libcxx/bin/clang-check" -p %t %t/test.cpp -- \
+// RUN: -stdlib=libc++ -target x86_64-apple-darwin \
+// RUN: -ccc-install-dir %t/mock-libcxx/bin
+//
+// ^ -ccc-install-dir passed to unbreak tests on *BSD where
+//   getMainExecutable() relies on real argv[0] being passed
 #include 
 vector v;


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


[PATCH] D56976: [clang] [test] Pass -ccc-install-dir in mac compilation db test

2019-01-21 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov accepted this revision.
ilya-biryukov added a comment.

LGTM


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56976/new/

https://reviews.llvm.org/D56976



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


[PATCH] D56959: [AST] NFC: Introduce new class GenericSelectionExpr::Association

2019-01-21 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno added a comment.

Some small additional remarks if you are already modifying this class.




Comment at: include/clang/AST/Expr.h:5021
   unsigned NumAssocs, ResultIndex;
   SourceLocation GenericLoc, DefaultLoc, RParenLoc;
 

It is possible to stuff one `SourceLocation` in the bit-fields of `Stmt` to 
save one more pointer.



Comment at: include/clang/AST/Expr.h:5113
   SourceLocation getBeginLoc() const LLVM_READONLY { return GenericLoc; }
   SourceLocation getEndLoc() const LLVM_READONLY { return RParenLoc; }
 

I believe these `LLVM_READONLY` are pointless here.



Comment at: include/clang/AST/Expr.h:5125
   }
   friend class ASTStmtReader;
 };

Move this friend decl to the top ?


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56959/new/

https://reviews.llvm.org/D56959



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


[PATCH] D56860: [clangd] NFC: Use buildCompilerInvocation in CodeComplete

2019-01-21 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

In D56860#1365432 , @ilya-biryukov 
wrote:

> Adding Sam as a reviewer, IIRC we used to have `buildCompilerInvocation` here 
> and he was the one who inlined it.
>  I would personally LGTM this change (with the two comments fixed), but Sam 
> might have a different opinion on whether this should be outlined again.


I inlined it because `buildCompilerInvocation` was private, and I was moving 
CodeComplete out of ClangdUnit.cpp in rL319655 
.
The function was made public in rL333737  as 
part of a larger change.
I don't really object to the patch as it is, but if you're open to 
suggestions...

I'd **prefer** to have fewer dependencies between CodeComplete and ClangdUnit, 
as the latter has historically been a hairball.
Can we move `buildCompilerInvocation` and `ParseInputs` into `Compiler.h`, 
which is simplified APIs for invoking the compiler?
Both ClangdUnit and CodeComplete can certainly use Compiler, no question.


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56860/new/

https://reviews.llvm.org/D56860



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


[PATCH] D56959: [AST] NFC: Introduce new class GenericSelectionExpr::Association

2019-01-21 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno added inline comments.



Comment at: include/clang/AST/Expr.h:5068
 
+  Association getAssociation(unsigned I) const {
+return Association(cast(SubExprs[END_EXPR + I]), AssocTypes[I],

aaron.ballman wrote:
> steveire wrote:
> > aaron.ballman wrote:
> > > steveire wrote:
> > > > aaron.ballman wrote:
> > > > > Rather than gin these objects up on demand every time they're needed, 
> > > > > I'd prefer to see the class store `Association` objects directly. I 
> > > > > don't think it will be easy to do that and still support 
> > > > > `getAssocExprs()` and `getAssocTypeSourceInfos()`, so I think those 
> > > > > APIs should be removed in favor of this one. There's currently not 
> > > > > many uses of `getAssocExprs()` or `getAssocTypeSourceInfos()` (I spot 
> > > > > one each in Clang) so migration to the new API should not be onerous.
> > > > > 
> > > > > This should also have a range-based accessor version so that users 
> > > > > aren't required to use iterative loops to access the information (a 
> > > > > lot of the places you're already touching could use that range-based 
> > > > > interface).
> > > > I would prefer that too, but it doesn't seem to be possible. This is a 
> > > > sub-range of the `SubExprs` returned from `children()`. 
> > > > 
> > > > In theory, that could be split into two members, but then you would 
> > > > need a range library to recombine them and implement `children()`: 
> > > > https://godbolt.org/z/ZVamdC
> > > > 
> > > > This seems to be the best approach for now, and AFAIK it excludes a 
> > > > range-accessor.
> > > > I would prefer that too, but it doesn't seem to be possible. This is a 
> > > > sub-range of the SubExprs returned from children().
> > > 
> > > Ugh, you're right. :-(
> > > 
> > > > In theory, that could be split into two members, but then you would 
> > > > need a range library to recombine them and implement children(): 
> > > > https://godbolt.org/z/ZVamdC
> > > 
> > > We have zip iterators that could be used to implement this, I believe. 
> > > (see STLExtras.h)
> > > 
> > > Alternatively, we could tail-allocate the Association objects with 
> > > (perhaps references to) pointers back into the Expr tail-allocated array. 
> > > Not ideal, but does provide a clean interface.
> > > 
> > > @riccibruno may have other ideas on how to pack the arrays, as he's done 
> > > a lot of this work recently.
> > > We have zip iterators that could be used to implement this, I believe.
> > 
> > You're right, there is a `concat` there, but on second thought - because 
> > Association and Stmt don't share a base, I don't think it can work.
> > 
> > > Alternatively, we could tail-allocate the Association objects with 
> > > (perhaps references to) pointers back into the Expr tail-allocated array. 
> > > Not ideal, but does provide a clean interface.
> > 
> > Perhaps this can work, but I don't know how to do it. If you have scope for 
> > it in your part of the efforts, it would be a good way to get this 
> > unblocked.
> > Perhaps this can work, but I don't know how to do it. If you have scope for 
> > it in your part of the efforts, it would be a good way to get this 
> > unblocked.
> 
> I'll put some time into it today and see where it goes. You may be right that 
> this is more work than it's worth, so we'll see.
I don't see what would prevent tail-allocating the array of sub-expression and 
the array of `TypeSourceInfo`, and removing the `getAssocExpr`, 
`getAssocTypeSourceInfo`, `getAssocType` interface in favor of a single 
`getAssociation`. Then create a range version of `getAssociation` using the 
fact that if you know where you are in the sub-expression array, you know where 
is the corresponding `TypeSourceInfo`. To know which index correspond to the 
selected sub-expression you could use one of the low bits in the 
`TypeSourceInfo` pointers.

This means that `children` is still simple to implement, and users can use a 
single unified
interface via `getAssociation` and the range version `associations()`. From the 
point of view of the users it would be like if the `Association` objects were 
stored contiguously.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56959/new/

https://reviews.llvm.org/D56959



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


[PATCH] D57012: Merge similar target diagnostics for interrupt attribute into one. NFC

2019-01-21 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM aside from a commenting nit, thank you for the cleanup!




Comment at: lib/Sema/SemaDeclAttr.cpp:5620
+S.Diag(D->getLocation(), diag::warn_interrupt_attribute_invalid)
+<< /*Mips*/ 0 << 0;
 return;

Comment should probably be `MIPS` instead (same below).


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57012/new/

https://reviews.llvm.org/D57012



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


[clang-tools-extra] r351751 - [clang-tidy] Work around http://llvm.org/PR40392

2019-01-21 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Mon Jan 21 08:26:54 2019
New Revision: 351751

URL: http://llvm.org/viewvc/llvm-project?rev=351751=rev
Log:
[clang-tidy] Work around http://llvm.org/PR40392

The readability-else-after-return check should be smarter about cases where the
variable defined in the condition is used in the `else` branch. This patch makes
it just ignore such cases, but alternative solutions may be better (added a
FIXME).

Modified:
clang-tools-extra/trunk/clang-tidy/readability/ElseAfterReturnCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/readability-else-after-return.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/readability/ElseAfterReturnCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/ElseAfterReturnCheck.cpp?rev=351751=351750=351751=diff
==
--- clang-tools-extra/trunk/clang-tidy/readability/ElseAfterReturnCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/readability/ElseAfterReturnCheck.cpp Mon 
Jan 21 08:26:54 2019
@@ -18,16 +18,22 @@ namespace tidy {
 namespace readability {
 
 void ElseAfterReturnCheck::registerMatchers(MatchFinder *Finder) {
-  const auto ControlFlowInterruptorMatcher =
+  const auto InterruptsControlFlow =
   stmt(anyOf(returnStmt().bind("return"), continueStmt().bind("continue"),
  breakStmt().bind("break"),
  expr(ignoringImplicit(cxxThrowExpr().bind("throw");
   Finder->addMatcher(
   compoundStmt(forEach(
   ifStmt(unless(isConstexpr()),
- hasThen(stmt(
- anyOf(ControlFlowInterruptorMatcher,
-   compoundStmt(has(ControlFlowInterruptorMatcher),
+ // FIXME: Explore alternatives for the
+ // `if (T x = ...) {... return; } else {  }`
+ // pattern:
+ //   * warn, but don't fix;
+ //   * fix by pulling out the variable declaration out of
+ // the condition.
+ unless(hasConditionVariableStatement(anything())),
+ hasThen(stmt(anyOf(InterruptsControlFlow,
+
compoundStmt(has(InterruptsControlFlow),
  hasElse(stmt().bind("else")))
   .bind("if"))),
   this);

Modified: 
clang-tools-extra/trunk/test/clang-tidy/readability-else-after-return.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/readability-else-after-return.cpp?rev=351751=351750=351751=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/readability-else-after-return.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/readability-else-after-return.cpp 
Mon Jan 21 08:26:54 2019
@@ -105,3 +105,15 @@ void foo() {
 }
   }
 }
+
+extern int *g();
+extern void h(int **x);
+
+int *decl_in_condition() {
+  if (int *x = g()) {
+return x;
+  } else {
+h();
+return x;
+  }
+}


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


[PATCH] D56992: [clang] Mark lambda-to-function-pointer conversion as noexcept

2019-01-21 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman closed this revision.
aaron.ballman added a comment.

I needed to make some minor alterations to your patch. The CXX DR status page 
is automatically generated and I didn't remember that. I went and added an 
additional test case and did the automated DR regeneration. I've commit in 
r351750, thank you for the patch!


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56992/new/

https://reviews.llvm.org/D56992



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


[PATCH] D55850: [OpenCL] Allow address spaces as method qualifiers

2019-01-21 Thread Bevin Hansson via Phabricator via cfe-commits
ebevhan added a comment.

I'm a bit late to the party here, it was an older patch so I wasn't watching 
this one.

I get a bit miffed when address space related features get locked behind 
langoptions that aren't strictly address spaces. I know that there are 
currently a couple code snippets which are behind LangOptions.OpenCL, that are 
needed for address spaces to work reasonably even when you aren't using OpenCL.

I guess I do understand that the only address spaces that are interesting to 
parse here are the named qualifier ones, but it would be convenient if the 
parsing would accept other ones as well (such as the `__attribute__` based 
ones) and not necessarily assume that the user is using OpenCL++.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55850/new/

https://reviews.llvm.org/D55850



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


r351750 - Mark the lambda function pointer conversion operator as noexcept.

2019-01-21 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Mon Jan 21 08:25:08 2019
New Revision: 351750

URL: http://llvm.org/viewvc/llvm-project?rev=351750=rev
Log:
Mark the lambda function pointer conversion operator as noexcept.

This implements CWG DR 1722 and fixes PR40309. Patch by Ignat Loskutov.

Added:
cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/p9.cpp
Modified:
cfe/trunk/lib/Sema/SemaLambda.cpp
cfe/trunk/test/AST/ast-dump-expr.cpp
cfe/trunk/test/CXX/drs/dr17xx.cpp
cfe/trunk/www/cxx_dr_status.html

Modified: cfe/trunk/lib/Sema/SemaLambda.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLambda.cpp?rev=351750=351749=351750=diff
==
--- cfe/trunk/lib/Sema/SemaLambda.cpp (original)
+++ cfe/trunk/lib/Sema/SemaLambda.cpp Mon Jan 21 08:25:08 2019
@@ -1227,9 +1227,10 @@ static void addFunctionPointerConversion
   FunctionProtoType::ExtProtoInfo ConvExtInfo(
   S.Context.getDefaultCallingConvention(
   /*IsVariadic=*/false, /*IsCXXMethod=*/true));
-  // The conversion function is always const.
+  // The conversion function is always const and noexcept.
   ConvExtInfo.TypeQuals = Qualifiers();
   ConvExtInfo.TypeQuals.addConst();
+  ConvExtInfo.ExceptionSpec.Type = EST_BasicNoexcept;
   QualType ConvTy =
   S.Context.getFunctionType(PtrToFunctionTy, None, ConvExtInfo);
 

Modified: cfe/trunk/test/AST/ast-dump-expr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/AST/ast-dump-expr.cpp?rev=351750=351749=351750=diff
==
--- cfe/trunk/test/AST/ast-dump-expr.cpp (original)
+++ cfe/trunk/test/AST/ast-dump-expr.cpp Mon Jan 21 08:25:08 2019
@@ -290,7 +290,7 @@ void PrimaryExpressions(Ts... a) {
   // CHECK-NEXT: Destructor
   // CHECK-NEXT: CXXMethodDecl 0x{{[^ ]*}}  col:3 operator() 
'auto () const' inline
   // CHECK-NEXT: CompoundStmt
-  // CHECK-NEXT: CXXConversionDecl 0x{{[^ ]*}}  col:3 implicit 
constexpr operator auto (*)() 'auto (*() const)()' inline
+  // CHECK-NEXT: CXXConversionDecl 0x{{[^ ]*}}  col:3 implicit 
constexpr operator auto (*)() 'auto (*() const noexcept)()' inline
   // CHECK-NEXT: CXXMethodDecl 0x{{[^ ]*}}  col:3 implicit 
__invoke 'auto ()' static inline
   // CHECK-NEXT: CompoundStmt 0x{{[^ ]*}} 
 
@@ -307,7 +307,7 @@ void PrimaryExpressions(Ts... a) {
   // CHECK-NEXT: CXXMethodDecl 0x{{[^ ]*}}  col:3 operator() 
'auto (int, ...) const' inline
   // CHECK-NEXT: ParmVarDecl 0x{{[^ ]*}}  col:10 a 'int'
   // CHECK-NEXT: CompoundStmt
-  // CHECK-NEXT: CXXConversionDecl 0x{{[^ ]*}}  col:3 implicit 
constexpr operator auto (*)(int, ...) 'auto (*() const)(int, ...)' inline
+  // CHECK-NEXT: CXXConversionDecl 0x{{[^ ]*}}  col:3 implicit 
constexpr operator auto (*)(int, ...) 'auto (*() const noexcept)(int, ...)' 
inline
   // CHECK-NEXT: CXXMethodDecl 0x{{[^ ]*}}  col:3 implicit 
__invoke 'auto (int, ...)' static inline
   // CHECK-NEXT: ParmVarDecl 0x{{[^ ]*}}  col:10 a 'int'
   // CHECK-NEXT: CompoundStmt 0x{{[^ ]*}} 
@@ -455,7 +455,7 @@ void PrimaryExpressions(Ts... a) {
   // CHECK-NEXT: Destructor
   // CHECK-NEXT: CXXMethodDecl 0x{{[^ ]*}}  col:3 constexpr 
operator() 'auto () const' inline
   // CHECK-NEXT: CompoundStmt
-  // CHECK-NEXT: CXXConversionDecl 0x{{[^ ]*}}  col:3 implicit 
constexpr operator auto (*)() 'auto (*() const)()' inline
+  // CHECK-NEXT: CXXConversionDecl 0x{{[^ ]*}}  col:3 implicit 
constexpr operator auto (*)() 'auto (*() const noexcept)()' inline
   // CHECK-NEXT: CXXMethodDecl 0x{{[^ ]*}}  col:3 implicit 
__invoke 'auto ()' static inline
   // CHECK-NEXT: CompoundStmt 0x{{[^ ]*}} 
 
@@ -471,7 +471,7 @@ void PrimaryExpressions(Ts... a) {
   // CHECK-NEXT: Destructor
   // CHECK-NEXT: CXXMethodDecl 0x{{[^ ]*}}  col:3 operator() 
'auto ()' inline
   // CHECK-NEXT: CompoundStmt
-  // CHECK-NEXT: CXXConversionDecl 0x{{[^ ]*}}  col:3 implicit 
constexpr operator auto (*)() 'auto (*() const)()' inline
+  // CHECK-NEXT: CXXConversionDecl 0x{{[^ ]*}}  col:3 implicit 
constexpr operator auto (*)() 'auto (*() const noexcept)()' inline
   // CHECK-NEXT: CXXMethodDecl 0x{{[^ ]*}}  col:3 implicit 
__invoke 'auto ()' static inline
   // CHECK-NEXT: CompoundStmt 0x{{[^ ]*}} 
 
@@ -487,7 +487,7 @@ void PrimaryExpressions(Ts... a) {
   // CHECK-NEXT: Destructor
   // CHECK-NEXT: CXXMethodDecl 0x{{[^ ]*}}  col:3 operator() 
'auto () const noexcept' inline
   // CHECK-NEXT: CompoundStmt
-  // CHECK-NEXT: CXXConversionDecl 0x{{[^ ]*}}  col:3 implicit 
constexpr operator auto (*)() noexcept 'auto (*() const)() noexcept' inline
+  // CHECK-NEXT: CXXConversionDecl 0x{{[^ ]*}}  col:3 implicit 
constexpr operator auto (*)() noexcept 'auto (*() const noexcept)() noexcept' 
inline
   // CHECK-NEXT: CXXMethodDecl 0x{{[^ ]*}}  col:3 implicit 
__invoke 'auto () noexcept' static inline
   // CHECK-NEXT: CompoundStmt 0x{{[^ ]*}} 
 
@@ -505,7 +505,7 @@ void PrimaryExpressions(Ts... a) {
   // CHECK-NEXT: 

[PATCH] D56860: [clangd] NFC: Use buildCompilerInvocation in CodeComplete

2019-01-21 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a reviewer: sammccall.
ilya-biryukov added a comment.

Adding Sam as a reviewer, IIRC we used to have `buildCompilerInvocation` here 
and he was the one who inlined it.
I would personally LGTM this change (with the two comments fixed), but Sam 
might have a different opinion on whether this should be outlined again.


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56860/new/

https://reviews.llvm.org/D56860



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


r351749 - Regenerating the C++ DR status page from the latest Core issues list.

2019-01-21 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Mon Jan 21 08:21:14 2019
New Revision: 351749

URL: http://llvm.org/viewvc/llvm-project?rev=351749=rev
Log:
Regenerating the C++ DR status page from the latest Core issues list.

Modified:
cfe/trunk/www/cxx_dr_status.html

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


[PATCH] D56936: Fix handling of overriden methods during ASTImport

2019-01-21 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

> @martong the only issue is that I am seeing a regression on 
> Analysis/ctu-main.cpp when I run check-clang. I am going to look into it but 
> if you have any insights that would be helpful.

I am looking into it and will come back with what I have found.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56936/new/

https://reviews.llvm.org/D56936



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


[PATCH] D56936: Fix handling of overriden methods during ASTImport

2019-01-21 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

Hi Shafik, thank you for this patch! Generally it looks quite okay to me, but I 
have a few minor comments.




Comment at: lib/AST/ASTImporter.cpp:3049
+  // Import the body of D and attach that to FoundByLookup.
+  // This should probably be refactored into a function since we do the
+  // same below too.

Could you please do this refactor and remove this sentence from the comment? 
(At line 3208 we repeat the same logic.)



Comment at: unittests/AST/ASTImporterTest.cpp:2243
+  auto BP = cxxMethodDecl(hasName("f"), 
hasParent(cxxRecordDecl(hasName("B";
+  auto DP = cxxMethodDecl(hasName("f"), 
hasParent(cxxRecordDecl(hasName("D";
+

balazske wrote:
> I think names like `BP` and `BFP ` could be better (`P` should stand for 
> "Pattern" and always the last part of the name, so use `BFP` and `BFIsDefP`). 
> And for storing `B::F` a `BF` can be better name than `B`.
I agree. I think the contractions we use in 
`ImportOverriddenMethodTwiceOutOfClassDef` are more consistent.



Comment at: unittests/AST/ASTImporterTest.cpp:2325
+  EXPECT_EQ(DeclCounter().match(ToTU, BFP), 1u);
+  EXPECT_EQ(DeclCounter().match(ToTU, BFPIsDef), 0u);
+

balazske wrote:
> For the out-of-class definition the `hasParent(cxxRecordDecl(hasName("B")))` 
> does not match? (Otherwise this count should be 1.)
That does not match, because `hasParent` matches based on the lexical decl 
context. In the case of the out-of-class definition, the lexical decl context 
is the global namespace (the TranslationUnitDecl). 

However, the semantical decl context of the out-of-class definition is the 
CXXRecordDecl with the name "B". But this relation is not symmetric. The 
definition is not the child (i.e. DeclContext::containsDecl is false) of the 
CXXRecordDecl rather the child of the TranslataionUnitDecl.



Comment at: unittests/AST/ASTImporterTest.cpp:2385
+  EXPECT_EQ(DeclCounter().match(ToTU, BFP), 1u);
+  EXPECT_EQ(DeclCounter().match(ToTU, BFPIsDef), 0u);
+

Perhaps it would make sense to have expectations on `DFP` and on `DFPIsDef` too.



Comment at: unittests/AST/ASTImporterTest.cpp:2393
+
+  // The definition should be out-of-class.
+  EXPECT_NE(ToBFInClass, ToBFOutOfClass);

Perhaps it would make sense to have expectations on `D::f() {}` too. Even 
better could be to have a lambda which takes a few Decls as parameters and does 
the expectations on those.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56936/new/

https://reviews.llvm.org/D56936



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


[PATCH] D57021: [clangd] Suggest adding missing includes for typos (like include-fixer).

2019-01-21 Thread Eric Liu via Phabricator via cfe-commits
ioeric updated this revision to Diff 182800.
ioeric added a comment.

- Rebase on D56903 .


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57021/new/

https://reviews.llvm.org/D57021

Files:
  clangd/ClangdUnit.cpp
  clangd/IncludeFixer.cpp
  clangd/IncludeFixer.h
  unittests/clangd/IncludeFixerTests.cpp

Index: unittests/clangd/IncludeFixerTests.cpp
===
--- unittests/clangd/IncludeFixerTests.cpp
+++ unittests/clangd/IncludeFixerTests.cpp
@@ -13,6 +13,8 @@
 #include "TestIndex.h"
 #include "TestTU.h"
 #include "index/MemIndex.h"
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/StringRef.h"
 #include "llvm/Support/ScopedPrinter.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
@@ -24,7 +26,12 @@
 using testing::UnorderedElementsAre;
 
 testing::Matcher WithFix(testing::Matcher FixMatcher) {
-  return Field(::Fixes, ElementsAre(FixMatcher));
+  return Field(::Fixes, UnorderedElementsAre(FixMatcher));
+}
+
+testing::Matcher WithFix(testing::Matcher FixMatcher1,
+   testing::Matcher FixMatcher2) {
+  return Field(::Fixes, UnorderedElementsAre(FixMatcher1, FixMatcher2));
 }
 
 MATCHER_P2(Diag, Range, Message,
@@ -39,6 +46,24 @@
  arg.Edits[0].range == Range && arg.Edits[0].newText == Replacement;
 }
 
+struct SymbolWithHeader {
+  std::string QName;
+  std::string DeclaringFile;
+  std::string IncludeHeader;
+};
+
+std::unique_ptr buildIndexWithSymbol(llvm::ArrayRef Syms) {
+  SymbolSlab::Builder Slab;
+  for (const auto  : Syms) {
+Symbol Sym = symbol(S.QName);
+Sym.Flags |= Symbol::IndexedForCodeCompletion;
+Sym.CanonicalDeclaration.FileURI = S.DeclaringFile.c_str();
+Sym.IncludeHeaders.emplace_back(S.IncludeHeader, 1);
+Slab.insert(Sym);
+  }
+  return MemIndex::build(std::move(Slab).build(), RefSlab());
+}
+
 TEST(IncludeFixerTest, IncompleteType) {
   Annotations Test(R"cpp(
 $insert[[]]namespace ns {
@@ -51,14 +76,8 @@
 }
   )cpp");
   auto TU = TestTU::withCode(Test.code());
-  Symbol Sym = symbol("ns::X");
-  Sym.Flags |= Symbol::IndexedForCodeCompletion;
-  Sym.CanonicalDeclaration.FileURI = "unittest:///x.h";
-  Sym.IncludeHeaders.emplace_back("\"x.h\"", 1);
-
-  SymbolSlab::Builder Slab;
-  Slab.insert(Sym);
-  auto Index = MemIndex::build(std::move(Slab).build(), RefSlab());
+  auto Index = buildIndexWithSymbol(
+  {SymbolWithHeader{"ns::X", "unittest:///x.h", "\"x.h\""}});
   TU.ExternalIndex = Index.get();
 
   EXPECT_THAT(
@@ -73,6 +92,65 @@
 "Add include \"x.h\" for symbol ns::X");
 }
 
+TEST(IncludeFixerTest, Typo) {
+  Annotations Test(R"cpp(
+$insert[[]]namespace ns {
+void foo() {
+  $unqualified[[X]] x;
+}
+}
+void bar() {
+  ns::$qualified[[X]] x; // ns:: is valid.
+  ::$global[[Global]] glob;
+}
+  )cpp");
+  auto TU = TestTU::withCode(Test.code());
+  auto Index = buildIndexWithSymbol(
+  {SymbolWithHeader{"ns::X", "unittest:///x.h", "\"x.h\""},
+   SymbolWithHeader{"Global", "unittest:///global.h", "\"global.h\""}});
+  TU.ExternalIndex = Index.get();
+
+  EXPECT_THAT(
+  TU.build().getDiagnostics(),
+  UnorderedElementsAre(
+  AllOf(Diag(Test.range("unqualified"), "unknown type name 'X'"),
+WithFix(Fix(Test.range("insert"), "#include \"x.h\"\n",
+"Add include \"x.h\" for symbol ns::X"))),
+  AllOf(Diag(Test.range("qualified"),
+ "no type named 'X' in namespace 'ns'"),
+WithFix(Fix(Test.range("insert"), "#include \"x.h\"\n",
+"Add include \"x.h\" for symbol ns::X"))),
+  AllOf(Diag(Test.range("global"),
+ "no type named 'Global' in the global namespace"),
+WithFix(Fix(Test.range("insert"), "#include \"global.h\"\n",
+"Add include \"global.h\" for symbol Global");
+}
+
+TEST(IncludeFixerTest, MultipleMatchedSymbols) {
+  Annotations Test(R"cpp(
+$insert[[]]namespace na {
+namespace nb {
+void foo() {
+  $unqualified[[X]] x;
+}
+}
+}
+  )cpp");
+  auto TU = TestTU::withCode(Test.code());
+  auto Index = buildIndexWithSymbol(
+  {SymbolWithHeader{"na::X", "unittest:///a.h", "\"a.h\""},
+   SymbolWithHeader{"na::nb::X", "unittest:///b.h", "\"b.h\""}});
+  TU.ExternalIndex = Index.get();
+
+  EXPECT_THAT(TU.build().getDiagnostics(),
+  UnorderedElementsAre(AllOf(
+  Diag(Test.range("unqualified"), "unknown type name 'X'"),
+  WithFix(Fix(Test.range("insert"), "#include \"a.h\"\n",
+  "Add include \"a.h\" for symbol na::X"),
+  Fix(Test.range("insert"), "#include \"b.h\"\n",
+  "Add include \"b.h\" for symbol na::nb::X");
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: 

[PATCH] D57021: [clangd] Suggest adding missing includes for typos (like include-fixer).

2019-01-21 Thread Eric Liu via Phabricator via cfe-commits
ioeric updated this revision to Diff 182799.
ioeric added a comment.

- revert unintended change


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57021/new/

https://reviews.llvm.org/D57021

Files:
  clangd/CMakeLists.txt
  clangd/ClangdServer.cpp
  clangd/ClangdUnit.cpp
  clangd/ClangdUnit.h
  clangd/CodeComplete.cpp
  clangd/Diagnostics.cpp
  clangd/Diagnostics.h
  clangd/Headers.cpp
  clangd/Headers.h
  clangd/IncludeFixer.cpp
  clangd/IncludeFixer.h
  clangd/SourceCode.cpp
  clangd/SourceCode.h
  unittests/clangd/CMakeLists.txt
  unittests/clangd/FileIndexTests.cpp
  unittests/clangd/IncludeFixerTests.cpp
  unittests/clangd/TUSchedulerTests.cpp
  unittests/clangd/TestTU.cpp
  unittests/clangd/TestTU.h

Index: unittests/clangd/TestTU.h
===
--- unittests/clangd/TestTU.h
+++ unittests/clangd/TestTU.h
@@ -48,6 +48,9 @@
   // Extra arguments for the compiler invocation.
   std::vector ExtraArgs;
 
+  // Index to use when building AST.
+  const SymbolIndex *ExternalIndex = nullptr;
+
   ParsedAST build() const;
   SymbolSlab headerSymbols() const;
   std::unique_ptr index() const;
Index: unittests/clangd/TestTU.cpp
===
--- unittests/clangd/TestTU.cpp
+++ unittests/clangd/TestTU.cpp
@@ -35,6 +35,7 @@
   Inputs.CompileCommand.Directory = testRoot();
   Inputs.Contents = Code;
   Inputs.FS = buildTestFS({{FullFilename, Code}, {FullHeaderName, HeaderCode}});
+  Inputs.Index = ExternalIndex;
   auto PCHs = std::make_shared();
   auto CI = buildCompilerInvocation(Inputs);
   assert(CI && "Failed to build compilation invocation.");
Index: unittests/clangd/TUSchedulerTests.cpp
===
--- unittests/clangd/TUSchedulerTests.cpp
+++ unittests/clangd/TUSchedulerTests.cpp
@@ -37,8 +37,9 @@
 class TUSchedulerTests : public ::testing::Test {
 protected:
   ParseInputs getInputs(PathRef File, std::string Contents) {
-return ParseInputs{*CDB.getCompileCommand(File),
-   buildTestFS(Files, Timestamps), std::move(Contents)};
+return ParseInputs(*CDB.getCompileCommand(File),
+   buildTestFS(Files, Timestamps), std::move(Contents),
+   /*Index=*/nullptr);
   }
 
   void updateWithCallback(TUScheduler , PathRef File,
Index: unittests/clangd/IncludeFixerTests.cpp
===
--- /dev/null
+++ unittests/clangd/IncludeFixerTests.cpp
@@ -0,0 +1,156 @@
+//===-- ClangdUnitTests.cpp - ClangdUnit tests --*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "Annotations.h"
+#include "ClangdUnit.h"
+#include "IncludeFixer.h"
+#include "TestIndex.h"
+#include "TestTU.h"
+#include "index/MemIndex.h"
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/ScopedPrinter.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace clangd {
+namespace {
+
+using testing::UnorderedElementsAre;
+
+testing::Matcher WithFix(testing::Matcher FixMatcher) {
+  return Field(::Fixes, UnorderedElementsAre(FixMatcher));
+}
+
+testing::Matcher WithFix(testing::Matcher FixMatcher1,
+   testing::Matcher FixMatcher2) {
+  return Field(::Fixes, UnorderedElementsAre(FixMatcher1, FixMatcher2));
+}
+
+MATCHER_P2(Diag, Range, Message,
+   "Diag at " + llvm::to_string(Range) + " = [" + Message + "]") {
+  return arg.Range == Range && arg.Message == Message;
+}
+
+MATCHER_P3(Fix, Range, Replacement, Message,
+   "Fix " + llvm::to_string(Range) + " => " +
+   testing::PrintToString(Replacement) + " = [" + Message + "]") {
+  return arg.Message == Message && arg.Edits.size() == 1 &&
+ arg.Edits[0].range == Range && arg.Edits[0].newText == Replacement;
+}
+
+struct SymbolWithHeader {
+  std::string QName;
+  std::string DeclaringFile;
+  std::string IncludeHeader;
+};
+
+std::unique_ptr buildIndexWithSymbol(llvm::ArrayRef Syms) {
+  SymbolSlab::Builder Slab;
+  for (const auto  : Syms) {
+Symbol Sym = symbol(S.QName);
+Sym.Flags |= Symbol::IndexedForCodeCompletion;
+Sym.CanonicalDeclaration.FileURI = S.DeclaringFile.c_str();
+Sym.IncludeHeaders.emplace_back(S.IncludeHeader, 1);
+Slab.insert(Sym);
+  }
+  return MemIndex::build(std::move(Slab).build(), RefSlab());
+}
+
+TEST(IncludeFixerTest, IncompleteType) {
+  Annotations Test(R"cpp(
+$insert[[]]namespace ns {
+  class X;
+}
+class Y : $base[[public ns::X]] {};
+int main() {
+  ns::X *x;
+  x$access[[->]]f();
+}
+  )cpp");
+  auto TU = TestTU::withCode(Test.code());

[PATCH] D57021: [clangd] Suggest adding missing includes for typos (like include-fixer).

2019-01-21 Thread Eric Liu via Phabricator via cfe-commits
ioeric created this revision.
ioeric added a reviewer: sammccall.

This adds include-fixer feature into clangd based on D56903 
. Clangd now captures
diagnostics caused by typos and attach include insertion fixes to potentially
fix the typo.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D57021

Files:
  change-namespace/ChangeNamespace.cpp
  clangd/ClangdUnit.cpp
  clangd/IncludeFixer.cpp
  clangd/IncludeFixer.h
  unittests/clangd/IncludeFixerTests.cpp

Index: unittests/clangd/IncludeFixerTests.cpp
===
--- unittests/clangd/IncludeFixerTests.cpp
+++ unittests/clangd/IncludeFixerTests.cpp
@@ -13,6 +13,8 @@
 #include "TestIndex.h"
 #include "TestTU.h"
 #include "index/MemIndex.h"
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/StringRef.h"
 #include "llvm/Support/ScopedPrinter.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
@@ -24,7 +26,12 @@
 using testing::UnorderedElementsAre;
 
 testing::Matcher WithFix(testing::Matcher FixMatcher) {
-  return Field(::Fixes, ElementsAre(FixMatcher));
+  return Field(::Fixes, UnorderedElementsAre(FixMatcher));
+}
+
+testing::Matcher WithFix(testing::Matcher FixMatcher1,
+   testing::Matcher FixMatcher2) {
+  return Field(::Fixes, UnorderedElementsAre(FixMatcher1, FixMatcher2));
 }
 
 MATCHER_P2(Diag, Range, Message,
@@ -39,6 +46,24 @@
  arg.Edits[0].range == Range && arg.Edits[0].newText == Replacement;
 }
 
+struct SymbolWithHeader {
+  std::string QName;
+  std::string DeclaringFile;
+  std::string IncludeHeader;
+};
+
+std::unique_ptr buildIndexWithSymbol(llvm::ArrayRef Syms) {
+  SymbolSlab::Builder Slab;
+  for (const auto  : Syms) {
+Symbol Sym = symbol(S.QName);
+Sym.Flags |= Symbol::IndexedForCodeCompletion;
+Sym.CanonicalDeclaration.FileURI = S.DeclaringFile.c_str();
+Sym.IncludeHeaders.emplace_back(S.IncludeHeader, 1);
+Slab.insert(Sym);
+  }
+  return MemIndex::build(std::move(Slab).build(), RefSlab());
+}
+
 TEST(IncludeFixerTest, IncompleteType) {
   Annotations Test(R"cpp(
 $insert[[]]namespace ns {
@@ -51,14 +76,8 @@
 }
   )cpp");
   auto TU = TestTU::withCode(Test.code());
-  Symbol Sym = symbol("ns::X");
-  Sym.Flags |= Symbol::IndexedForCodeCompletion;
-  Sym.CanonicalDeclaration.FileURI = "unittest:///x.h";
-  Sym.IncludeHeaders.emplace_back("\"x.h\"", 1);
-
-  SymbolSlab::Builder Slab;
-  Slab.insert(Sym);
-  auto Index = MemIndex::build(std::move(Slab).build(), RefSlab());
+  auto Index = buildIndexWithSymbol(
+  {SymbolWithHeader{"ns::X", "unittest:///x.h", "\"x.h\""}});
   TU.ExternalIndex = Index.get();
 
   EXPECT_THAT(
@@ -73,6 +92,65 @@
 "Add include \"x.h\" for symbol ns::X");
 }
 
+TEST(IncludeFixerTest, Typo) {
+  Annotations Test(R"cpp(
+$insert[[]]namespace ns {
+void foo() {
+  $unqualified[[X]] x;
+}
+}
+void bar() {
+  ns::$qualified[[X]] x; // ns:: is valid.
+  ::$global[[Global]] glob;
+}
+  )cpp");
+  auto TU = TestTU::withCode(Test.code());
+  auto Index = buildIndexWithSymbol(
+  {SymbolWithHeader{"ns::X", "unittest:///x.h", "\"x.h\""},
+   SymbolWithHeader{"Global", "unittest:///global.h", "\"global.h\""}});
+  TU.ExternalIndex = Index.get();
+
+  EXPECT_THAT(
+  TU.build().getDiagnostics(),
+  UnorderedElementsAre(
+  AllOf(Diag(Test.range("unqualified"), "unknown type name 'X'"),
+WithFix(Fix(Test.range("insert"), "#include \"x.h\"\n",
+"Add include \"x.h\" for symbol ns::X"))),
+  AllOf(Diag(Test.range("qualified"),
+ "no type named 'X' in namespace 'ns'"),
+WithFix(Fix(Test.range("insert"), "#include \"x.h\"\n",
+"Add include \"x.h\" for symbol ns::X"))),
+  AllOf(Diag(Test.range("global"),
+ "no type named 'Global' in the global namespace"),
+WithFix(Fix(Test.range("insert"), "#include \"global.h\"\n",
+"Add include \"global.h\" for symbol Global");
+}
+
+TEST(IncludeFixerTest, MultipleMatchedSymbols) {
+  Annotations Test(R"cpp(
+$insert[[]]namespace na {
+namespace nb {
+void foo() {
+  $unqualified[[X]] x;
+}
+}
+}
+  )cpp");
+  auto TU = TestTU::withCode(Test.code());
+  auto Index = buildIndexWithSymbol(
+  {SymbolWithHeader{"na::X", "unittest:///a.h", "\"a.h\""},
+   SymbolWithHeader{"na::nb::X", "unittest:///b.h", "\"b.h\""}});
+  TU.ExternalIndex = Index.get();
+
+  EXPECT_THAT(TU.build().getDiagnostics(),
+  UnorderedElementsAre(AllOf(
+  Diag(Test.range("unqualified"), "unknown type name 'X'"),
+  WithFix(Fix(Test.range("insert"), "#include \"a.h\"\n",
+  "Add include \"a.h\" for symbol na::X"),
+  Fix(Test.range("insert"), "#include \"b.h\"\n",
+  "Add 

[PATCH] D56903: [clangd] Suggest adding missing includes for incomplete type diagnostics.

2019-01-21 Thread Eric Liu via Phabricator via cfe-commits
ioeric updated this revision to Diff 182796.
ioeric added a comment.

- add comments


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56903/new/

https://reviews.llvm.org/D56903

Files:
  clangd/CMakeLists.txt
  clangd/ClangdServer.cpp
  clangd/ClangdUnit.cpp
  clangd/ClangdUnit.h
  clangd/CodeComplete.cpp
  clangd/Diagnostics.cpp
  clangd/Diagnostics.h
  clangd/Headers.cpp
  clangd/Headers.h
  clangd/IncludeFixer.cpp
  clangd/IncludeFixer.h
  clangd/SourceCode.cpp
  clangd/SourceCode.h
  unittests/clangd/CMakeLists.txt
  unittests/clangd/FileIndexTests.cpp
  unittests/clangd/IncludeFixerTests.cpp
  unittests/clangd/TUSchedulerTests.cpp
  unittests/clangd/TestTU.cpp
  unittests/clangd/TestTU.h

Index: unittests/clangd/TestTU.h
===
--- unittests/clangd/TestTU.h
+++ unittests/clangd/TestTU.h
@@ -48,6 +48,9 @@
   // Extra arguments for the compiler invocation.
   std::vector ExtraArgs;
 
+  // Index to use when building AST.
+  const SymbolIndex *ExternalIndex = nullptr;
+
   ParsedAST build() const;
   SymbolSlab headerSymbols() const;
   std::unique_ptr index() const;
Index: unittests/clangd/TestTU.cpp
===
--- unittests/clangd/TestTU.cpp
+++ unittests/clangd/TestTU.cpp
@@ -35,6 +35,7 @@
   Inputs.CompileCommand.Directory = testRoot();
   Inputs.Contents = Code;
   Inputs.FS = buildTestFS({{FullFilename, Code}, {FullHeaderName, HeaderCode}});
+  Inputs.Index = ExternalIndex;
   auto PCHs = std::make_shared();
   auto CI = buildCompilerInvocation(Inputs);
   assert(CI && "Failed to build compilation invocation.");
Index: unittests/clangd/TUSchedulerTests.cpp
===
--- unittests/clangd/TUSchedulerTests.cpp
+++ unittests/clangd/TUSchedulerTests.cpp
@@ -37,8 +37,9 @@
 class TUSchedulerTests : public ::testing::Test {
 protected:
   ParseInputs getInputs(PathRef File, std::string Contents) {
-return ParseInputs{*CDB.getCompileCommand(File),
-   buildTestFS(Files, Timestamps), std::move(Contents)};
+return ParseInputs(*CDB.getCompileCommand(File),
+   buildTestFS(Files, Timestamps), std::move(Contents),
+   /*Index=*/nullptr);
   }
 
   void updateWithCallback(TUScheduler , PathRef File,
Index: unittests/clangd/IncludeFixerTests.cpp
===
--- /dev/null
+++ unittests/clangd/IncludeFixerTests.cpp
@@ -0,0 +1,78 @@
+//===-- ClangdUnitTests.cpp - ClangdUnit tests --*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "Annotations.h"
+#include "ClangdUnit.h"
+#include "IncludeFixer.h"
+#include "TestIndex.h"
+#include "TestTU.h"
+#include "index/MemIndex.h"
+#include "llvm/Support/ScopedPrinter.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace clangd {
+namespace {
+
+using testing::UnorderedElementsAre;
+
+testing::Matcher WithFix(testing::Matcher FixMatcher) {
+  return Field(::Fixes, ElementsAre(FixMatcher));
+}
+
+MATCHER_P2(Diag, Range, Message,
+   "Diag at " + llvm::to_string(Range) + " = [" + Message + "]") {
+  return arg.Range == Range && arg.Message == Message;
+}
+
+MATCHER_P3(Fix, Range, Replacement, Message,
+   "Fix " + llvm::to_string(Range) + " => " +
+   testing::PrintToString(Replacement) + " = [" + Message + "]") {
+  return arg.Message == Message && arg.Edits.size() == 1 &&
+ arg.Edits[0].range == Range && arg.Edits[0].newText == Replacement;
+}
+
+TEST(IncludeFixerTest, IncompleteType) {
+  Annotations Test(R"cpp(
+$insert[[]]namespace ns {
+  class X;
+}
+class Y : $base[[public ns::X]] {};
+int main() {
+  ns::X *x;
+  x$access[[->]]f();
+}
+  )cpp");
+  auto TU = TestTU::withCode(Test.code());
+  Symbol Sym = symbol("ns::X");
+  Sym.Flags |= Symbol::IndexedForCodeCompletion;
+  Sym.CanonicalDeclaration.FileURI = "unittest:///x.h";
+  Sym.IncludeHeaders.emplace_back("\"x.h\"", 1);
+
+  SymbolSlab::Builder Slab;
+  Slab.insert(Sym);
+  auto Index = MemIndex::build(std::move(Slab).build(), RefSlab());
+  TU.ExternalIndex = Index.get();
+
+  EXPECT_THAT(
+  TU.build().getDiagnostics(),
+  UnorderedElementsAre(
+  AllOf(Diag(Test.range("base"), "base class has incomplete type"),
+WithFix(Fix(Test.range("insert"), "#include \"x.h\"\n",
+"Add include \"x.h\" for symbol ns::X"))),
+  AllOf(Diag(Test.range("access"),
+ "member access into incomplete type 'ns::X'"),
+WithFix(Fix(Test.range("insert"), "#include 

[PATCH] D55850: [OpenCL] Allow address spaces as method qualifiers

2019-01-21 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

After rebase I had to modify the following test:

  Index: test/SemaOpenCLCXX/address_space_overloading.cl
  ===
  --- test/SemaOpenCLCXX/address_space_overloading.cl   (revision 351746)
  +++ test/SemaOpenCLCXX/address_space_overloading.cl   (working copy)
  @@ -1,12 +1,12 @@
   // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=c++
   
  -// expected-no-diagnostics
  +// FIXME: This test shouldn't trigger any errors.
   
   struct RetGlob {
 int dummy;
   };
   
  -struct RetGen {
  +struct RetGen { //expected-error{{binding value of type '__generic RetGen' 
to reference to type 'RetGen' drops <> qualifiers}}
 char dummy;
   };
   
  @@ -19,5 +19,5 @@
 __local int *ArgLoc;
 RetGlob TestGlob = foo(ArgGlob);
 RetGen TestGen = foo(ArgGen);
  -  TestGen = foo(ArgLoc);
  +  TestGen = foo(ArgLoc); //expected-note{{in implicit copy assignment 
operator for 'RetGen' first required here}}
   }

After looking at it, I realized that there is another un-handled path for 
address spaces in the initialization sequence. That gets hit during the 
creation of a return statement when we define implicit copy assignment. 
assignment. As a result I end up with the following incorrect AST:

  UnaryOperator 0x75a910 '__generic struct RetGen' lvalue prefix '*' cannot 
overflow
  `-CXXThisExpr 0x75a900 '__generic struct RetGen *' this

As I wasn't sure whether I should fix the initialization sequence again by 
splitting the address space conversion to move it to a later step or just fix 
the type of *this expr, I will upload a separate fix for this instead of 
reopening this review.

The overloading resolution seems to work fine at least which is what this test 
is supposed to check.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55850/new/

https://reviews.llvm.org/D55850



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


[PATCH] D55850: [OpenCL] Allow address spaces as method qualifiers

2019-01-21 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC351747: [OpenCL] Allow address spaces as method qualifiers. 
(authored by stulova, committed by ).
Herald added a subscriber: ebevhan.

Changed prior to commit:
  https://reviews.llvm.org/D55850?vs=182496=182795#toc

Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55850/new/

https://reviews.llvm.org/D55850

Files:
  include/clang/AST/Type.h
  include/clang/Sema/ParsedAttr.h
  lib/Parse/ParseDecl.cpp
  lib/Sema/SemaOverload.cpp
  lib/Sema/SemaType.cpp
  test/CodeGenOpenCLCXX/method-overload-address-space.cl
  test/SemaOpenCLCXX/address-space-of-this-class-scope.cl
  test/SemaOpenCLCXX/address_space_overloading.cl
  test/SemaOpenCLCXX/method-overload-address-space.cl

Index: include/clang/AST/Type.h
===
--- include/clang/AST/Type.h
+++ include/clang/AST/Type.h
@@ -1982,7 +1982,7 @@
   bool isObjCQualifiedClassType() const;// Class
   bool isObjCObjectOrInterfaceType() const;
   bool isObjCIdType() const;// id
-
+  bool isDecltypeType() const;
   /// Was this type written with the special inert-in-ARC __unsafe_unretained
   /// qualifier?
   ///
@@ -6440,6 +6440,10 @@
   return isObjCIdType() || isObjCClassType() || isObjCSelType();
 }
 
+inline bool Type::isDecltypeType() const {
+  return isa(this);
+}
+
 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
   inline bool Type::is##Id##Type() const { \
 return isSpecificBuiltinType(BuiltinType::Id); \
Index: include/clang/Sema/ParsedAttr.h
===
--- include/clang/Sema/ParsedAttr.h
+++ include/clang/Sema/ParsedAttr.h
@@ -567,6 +567,25 @@
   /// parsed attribute does not have a semantic equivalent, or would not have
   /// a Spelling enumeration, the value UINT_MAX is returned.
   unsigned getSemanticSpelling() const;
+
+  /// If this is an OpenCL addr space attribute returns its representation
+  /// in LangAS, otherwise returns default addr space.
+  LangAS asOpenCLLangAS() const {
+switch (getKind()) {
+case ParsedAttr::AT_OpenCLConstantAddressSpace:
+  return LangAS::opencl_constant;
+case ParsedAttr::AT_OpenCLGlobalAddressSpace:
+  return LangAS::opencl_global;
+case ParsedAttr::AT_OpenCLLocalAddressSpace:
+  return LangAS::opencl_local;
+case ParsedAttr::AT_OpenCLPrivateAddressSpace:
+  return LangAS::opencl_private;
+case ParsedAttr::AT_OpenCLGenericAddressSpace:
+  return LangAS::opencl_generic;
+default:
+  return LangAS::Default;
+}
+  }
 };
 
 class AttributePool;
Index: test/CodeGenOpenCLCXX/method-overload-address-space.cl
===
--- test/CodeGenOpenCLCXX/method-overload-address-space.cl
+++ test/CodeGenOpenCLCXX/method-overload-address-space.cl
@@ -0,0 +1,35 @@
+//RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=c++ -emit-llvm -O0 -o - | FileCheck %s
+
+struct C {
+  void foo() __local;
+  void foo() __global;
+  void foo();
+  void bar();
+};
+
+__global C c1;
+
+__kernel void k() {
+  __local C c2;
+  C c3;
+  __global C _ref = c1;
+  __global C *c_ptr;
+
+  // CHECK: call void @_ZNU3AS11C3fooEv(%struct.C addrspace(1)*
+  c1.foo();
+  // CHECK: call void @_ZNU3AS31C3fooEv(%struct.C addrspace(3)*
+  c2.foo();
+  // CHECK: call void @_ZNU3AS41C3fooEv(%struct.C addrspace(4)*
+  c3.foo();
+  // CHECK: call void @_ZNU3AS11C3fooEv(%struct.C addrspace(1)*
+  c_ptr->foo();
+  // CHECK: void @_ZNU3AS11C3fooEv(%struct.C addrspace(1)*
+  c_ref.foo();
+
+  // CHECK: call void @_ZNU3AS41C3barEv(%struct.C addrspace(4)* addrspacecast (%struct.C addrspace(1)* @c1 to %struct.C addrspace(4)*))
+  c1.bar();
+  //FIXME: Doesn't compile yet
+  //c_ptr->bar();
+  // CHECK: call void @_ZNU3AS41C3barEv(%struct.C addrspace(4)* addrspacecast (%struct.C addrspace(1)* @c1 to %struct.C addrspace(4)*))
+  c_ref.bar();
+}
Index: test/SemaOpenCLCXX/address-space-of-this-class-scope.cl
===
--- test/SemaOpenCLCXX/address-space-of-this-class-scope.cl
+++ test/SemaOpenCLCXX/address-space-of-this-class-scope.cl
@@ -0,0 +1,18 @@
+//RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=c++ -pedantic -verify
+
+struct C {
+  auto fGlob() __global -> decltype(this);
+  auto fGen() -> decltype(this);
+  auto fErr() __global __local -> decltype(this); //expected-error{{multiple address spaces specified for type}}
+};
+
+void bar(__local C*);
+// expected-note@-1{{candidate function not viable: address space mismatch in 1st argument ('decltype(this)' (aka '__global C *')), parameter type must be '__local C *'}}
+// expected-note@-2{{candidate function not viable: address space mismatch in 1st argument ('decltype(this)' (aka 'C *')), parameter type must be '__local C *'}}
+
+__global C Glob;
+void foo(){

[PATCH] D56860: [clangd] NFC: Use buildCompilerInvocation in CodeComplete

2019-01-21 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clangd/CodeComplete.cpp:1030
   auto  = CI->getFrontendOpts();
   FrontendOpts.DisableFree = false;
   FrontendOpts.SkipFunctionBodies = true;

remove this line, `buildCompilerInvocation` handles this for us



Comment at: clangd/CodeComplete.cpp:1032
   FrontendOpts.SkipFunctionBodies = true;
   CI->getLangOpts()->CommentOpts.ParseAllComments = true;
   // Disable typo correction in Sema.

remove this line, buildCompilerInvocation handles this for us




Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56860/new/

https://reviews.llvm.org/D56860



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


r351747 - [OpenCL] Allow address spaces as method qualifiers.

2019-01-21 Thread Anastasia Stulova via cfe-commits
Author: stulova
Date: Mon Jan 21 08:01:38 2019
New Revision: 351747

URL: http://llvm.org/viewvc/llvm-project?rev=351747=rev
Log:
[OpenCL] Allow address spaces as method qualifiers.

Methods can now be qualified with address spaces to prevent
undesirable conversions to generic or to provide custom 
implementation to be used if the object is located in certain
memory segments.

This commit extends parsing and standard C++ overloading to
work for an address space of a method (i.e. implicit 'this'
parameter).

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


Added:
cfe/trunk/test/CodeGenOpenCLCXX/method-overload-address-space.cl
cfe/trunk/test/SemaOpenCLCXX/address-space-of-this-class-scope.cl
cfe/trunk/test/SemaOpenCLCXX/method-overload-address-space.cl
Modified:
cfe/trunk/include/clang/AST/Type.h
cfe/trunk/include/clang/Sema/ParsedAttr.h
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/test/SemaOpenCLCXX/address_space_overloading.cl

Modified: cfe/trunk/include/clang/AST/Type.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=351747=351746=351747=diff
==
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Mon Jan 21 08:01:38 2019
@@ -1982,7 +1982,7 @@ public:
   bool isObjCQualifiedClassType() const;// Class
   bool isObjCObjectOrInterfaceType() const;
   bool isObjCIdType() const;// id
-
+  bool isDecltypeType() const;
   /// Was this type written with the special inert-in-ARC __unsafe_unretained
   /// qualifier?
   ///
@@ -6440,6 +6440,10 @@ inline bool Type::isObjCBuiltinType() co
   return isObjCIdType() || isObjCClassType() || isObjCSelType();
 }
 
+inline bool Type::isDecltypeType() const {
+  return isa(this);
+}
+
 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
   inline bool Type::is##Id##Type() const { \
 return isSpecificBuiltinType(BuiltinType::Id); \

Modified: cfe/trunk/include/clang/Sema/ParsedAttr.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/ParsedAttr.h?rev=351747=351746=351747=diff
==
--- cfe/trunk/include/clang/Sema/ParsedAttr.h (original)
+++ cfe/trunk/include/clang/Sema/ParsedAttr.h Mon Jan 21 08:01:38 2019
@@ -567,6 +567,25 @@ public:
   /// parsed attribute does not have a semantic equivalent, or would not have
   /// a Spelling enumeration, the value UINT_MAX is returned.
   unsigned getSemanticSpelling() const;
+
+  /// If this is an OpenCL addr space attribute returns its representation
+  /// in LangAS, otherwise returns default addr space.
+  LangAS asOpenCLLangAS() const {
+switch (getKind()) {
+case ParsedAttr::AT_OpenCLConstantAddressSpace:
+  return LangAS::opencl_constant;
+case ParsedAttr::AT_OpenCLGlobalAddressSpace:
+  return LangAS::opencl_global;
+case ParsedAttr::AT_OpenCLLocalAddressSpace:
+  return LangAS::opencl_local;
+case ParsedAttr::AT_OpenCLPrivateAddressSpace:
+  return LangAS::opencl_private;
+case ParsedAttr::AT_OpenCLGenericAddressSpace:
+  return LangAS::opencl_generic;
+default:
+  return LangAS::Default;
+}
+  }
 };
 
 class AttributePool;

Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=351747=351746=351747=diff
==
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Mon Jan 21 08:01:38 2019
@@ -6177,6 +6177,20 @@ void Parser::ParseFunctionDeclarator(Dec
   Qualifiers Q = Qualifiers::fromCVRUMask(DS.getTypeQualifiers());
   if (D.getDeclSpec().isConstexprSpecified() && !getLangOpts().CPlusPlus14)
 Q.addConst();
+  // FIXME: Collect C++ address spaces.
+  // If there are multiple different address spaces, the source is invalid.
+  // Carry on using the first addr space for the qualifiers of 'this'.
+  // The diagnostic will be given later while creating the function
+  // prototype for the method.
+  if (getLangOpts().OpenCLCPlusPlus) {
+for (ParsedAttr  : DS.getAttributes()) {
+  LangAS ASIdx = attr.asOpenCLLangAS();
+  if (ASIdx != LangAS::Default) {
+Q.addAddressSpace(ASIdx);
+break;
+  }
+}
+  }
 
   Sema::CXXThisScopeRAII ThisScope(
   Actions, dyn_cast(Actions.CurContext), Q,

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=351747=351746=351747=diff
==
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp 

[PATCH] D56841: [clangd] Filter out plugin related flags and move all commandline manipulations into OverlayCDB.

2019-01-21 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov accepted this revision.
ilya-biryukov added a comment.
This revision is now accepted and ready to land.

LGTM




Comment at: clangd/GlobalCompilationDatabase.cpp:24
+void AdjustArguments(tooling::CompileCommand ,
+ const std::string ) {
+  // Strip plugin related command line arguments. Clangd does

kadircet wrote:
> ilya-biryukov wrote:
> > kadircet wrote:
> > > ilya-biryukov wrote:
> > > > NIT: use `StringRef`
> > > Need a string for the concatenation below, when pushing to vector. 
> > > Otherwise we get a Twine
> > Why not call `.str()` on a Twine?
> Sure it is also an option but didn't think it would look any better, but 
> there you go.
Looks kinda ugly, but **so** efficient... (Not that we care much here)


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56841/new/

https://reviews.llvm.org/D56841



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


[PATCH] D56959: [AST] NFC: Introduce new class GenericSelectionExpr::Association

2019-01-21 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: include/clang/AST/Expr.h:5068
 
+  Association getAssociation(unsigned I) const {
+return Association(cast(SubExprs[END_EXPR + I]), AssocTypes[I],

steveire wrote:
> aaron.ballman wrote:
> > steveire wrote:
> > > aaron.ballman wrote:
> > > > Rather than gin these objects up on demand every time they're needed, 
> > > > I'd prefer to see the class store `Association` objects directly. I 
> > > > don't think it will be easy to do that and still support 
> > > > `getAssocExprs()` and `getAssocTypeSourceInfos()`, so I think those 
> > > > APIs should be removed in favor of this one. There's currently not many 
> > > > uses of `getAssocExprs()` or `getAssocTypeSourceInfos()` (I spot one 
> > > > each in Clang) so migration to the new API should not be onerous.
> > > > 
> > > > This should also have a range-based accessor version so that users 
> > > > aren't required to use iterative loops to access the information (a lot 
> > > > of the places you're already touching could use that range-based 
> > > > interface).
> > > I would prefer that too, but it doesn't seem to be possible. This is a 
> > > sub-range of the `SubExprs` returned from `children()`. 
> > > 
> > > In theory, that could be split into two members, but then you would need 
> > > a range library to recombine them and implement `children()`: 
> > > https://godbolt.org/z/ZVamdC
> > > 
> > > This seems to be the best approach for now, and AFAIK it excludes a 
> > > range-accessor.
> > > I would prefer that too, but it doesn't seem to be possible. This is a 
> > > sub-range of the SubExprs returned from children().
> > 
> > Ugh, you're right. :-(
> > 
> > > In theory, that could be split into two members, but then you would need 
> > > a range library to recombine them and implement children(): 
> > > https://godbolt.org/z/ZVamdC
> > 
> > We have zip iterators that could be used to implement this, I believe. (see 
> > STLExtras.h)
> > 
> > Alternatively, we could tail-allocate the Association objects with (perhaps 
> > references to) pointers back into the Expr tail-allocated array. Not ideal, 
> > but does provide a clean interface.
> > 
> > @riccibruno may have other ideas on how to pack the arrays, as he's done a 
> > lot of this work recently.
> > We have zip iterators that could be used to implement this, I believe.
> 
> You're right, there is a `concat` there, but on second thought - because 
> Association and Stmt don't share a base, I don't think it can work.
> 
> > Alternatively, we could tail-allocate the Association objects with (perhaps 
> > references to) pointers back into the Expr tail-allocated array. Not ideal, 
> > but does provide a clean interface.
> 
> Perhaps this can work, but I don't know how to do it. If you have scope for 
> it in your part of the efforts, it would be a good way to get this unblocked.
> Perhaps this can work, but I don't know how to do it. If you have scope for 
> it in your part of the efforts, it would be a good way to get this unblocked.

I'll put some time into it today and see where it goes. You may be right that 
this is more work than it's worth, so we'll see.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56959/new/

https://reviews.llvm.org/D56959



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


[PATCH] D56945: [clang-tidy] Delete obsolete objc-property-declaration options ✂️

2019-01-21 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56945/new/

https://reviews.llvm.org/D56945



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


[PATCH] D56992: [clang] Mark lambda-to-function-pointer conversion as noexcept

2019-01-21 Thread Ignat Loskutov via Phabricator via cfe-commits
loskutov marked an inline comment as done.
loskutov added a comment.

Yes, I'm not able to commit by myself, so it would be nice if you did that. 
Apache 2.0 with LLVM Exceptions is fine.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56992/new/

https://reviews.llvm.org/D56992



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


[PATCH] D56892: Add a priority field to availability attributes to prioritize explicit attributes from declaration over attributes from '#pragma clang attribute'

2019-01-21 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.

LGTM with a suggested edit for the docs (which look great, btw!).




Comment at: include/clang/Basic/AttrDocs.td:1252
+  
+For platforms like ``watchOS`` and ``tvOS`` whose availability attributes can
+be implicitly inferred from an ``iOS`` availability attribute the logic is

tvOS whose -> tvOS, whose



Comment at: include/clang/Basic/AttrDocs.td:1253
+For platforms like ``watchOS`` and ``tvOS`` whose availability attributes can
+be implicitly inferred from an ``iOS`` availability attribute the logic is
+slightly more complex. The explicit and the pragma-applied availability

attribute the logic -> attribute, the logic


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56892/new/

https://reviews.llvm.org/D56892



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


[PATCH] D56992: [clang] Mark lambda-to-function-pointer conversion as noexcept

2019-01-21 Thread Ignat Loskutov via Phabricator via cfe-commits
loskutov updated this revision to Diff 182792.
loskutov edited the summary of this revision.
loskutov added a comment.

Reflected the change in cxx_dr_status.html and specified `-std=c++17` for the 
test.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56992/new/

https://reviews.llvm.org/D56992

Files:
  clang/lib/Sema/SemaLambda.cpp
  clang/test/AST/ast-dump-expr.cpp
  clang/test/CXX/expr/expr.prim/expr.prim.lambda/p9.cpp
  clang/www/cxx_dr_status.html

Index: clang/www/cxx_dr_status.html
===
--- clang/www/cxx_dr_status.html
+++ clang/www/cxx_dr_status.html
@@ -10147,7 +10147,7 @@
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1722;>1722
 CD4
 Should lambda to function pointer conversion function be noexcept?
-Unknown
+Yes
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1723;>1723
Index: clang/test/CXX/expr/expr.prim/expr.prim.lambda/p9.cpp
===
--- /dev/null
+++ clang/test/CXX/expr/expr.prim/expr.prim.lambda/p9.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++17 %s -verify
+// expected-no-diagnostics
+
+void test_noexcept() {
+  const auto lambda = [](int x) { return x + 1; };
+  static_assert(noexcept((int (*)(int))(lambda)),
+"Lambda-to-function-pointer conversion is expected to be noexcept");
+}
Index: clang/test/AST/ast-dump-expr.cpp
===
--- clang/test/AST/ast-dump-expr.cpp
+++ clang/test/AST/ast-dump-expr.cpp
@@ -290,7 +290,7 @@
   // CHECK-NEXT: Destructor
   // CHECK-NEXT: CXXMethodDecl 0x{{[^ ]*}}  col:3 operator() 'auto () const' inline
   // CHECK-NEXT: CompoundStmt
-  // CHECK-NEXT: CXXConversionDecl 0x{{[^ ]*}}  col:3 implicit constexpr operator auto (*)() 'auto (*() const)()' inline
+  // CHECK-NEXT: CXXConversionDecl 0x{{[^ ]*}}  col:3 implicit constexpr operator auto (*)() 'auto (*() const noexcept)()' inline
   // CHECK-NEXT: CXXMethodDecl 0x{{[^ ]*}}  col:3 implicit __invoke 'auto ()' static inline
   // CHECK-NEXT: CompoundStmt 0x{{[^ ]*}} 
 
@@ -307,7 +307,7 @@
   // CHECK-NEXT: CXXMethodDecl 0x{{[^ ]*}}  col:3 operator() 'auto (int, ...) const' inline
   // CHECK-NEXT: ParmVarDecl 0x{{[^ ]*}}  col:10 a 'int'
   // CHECK-NEXT: CompoundStmt
-  // CHECK-NEXT: CXXConversionDecl 0x{{[^ ]*}}  col:3 implicit constexpr operator auto (*)(int, ...) 'auto (*() const)(int, ...)' inline
+  // CHECK-NEXT: CXXConversionDecl 0x{{[^ ]*}}  col:3 implicit constexpr operator auto (*)(int, ...) 'auto (*() const noexcept)(int, ...)' inline
   // CHECK-NEXT: CXXMethodDecl 0x{{[^ ]*}}  col:3 implicit __invoke 'auto (int, ...)' static inline
   // CHECK-NEXT: ParmVarDecl 0x{{[^ ]*}}  col:10 a 'int'
   // CHECK-NEXT: CompoundStmt 0x{{[^ ]*}} 
@@ -455,7 +455,7 @@
   // CHECK-NEXT: Destructor
   // CHECK-NEXT: CXXMethodDecl 0x{{[^ ]*}}  col:3 constexpr operator() 'auto () const' inline
   // CHECK-NEXT: CompoundStmt
-  // CHECK-NEXT: CXXConversionDecl 0x{{[^ ]*}}  col:3 implicit constexpr operator auto (*)() 'auto (*() const)()' inline
+  // CHECK-NEXT: CXXConversionDecl 0x{{[^ ]*}}  col:3 implicit constexpr operator auto (*)() 'auto (*() const noexcept)()' inline
   // CHECK-NEXT: CXXMethodDecl 0x{{[^ ]*}}  col:3 implicit __invoke 'auto ()' static inline
   // CHECK-NEXT: CompoundStmt 0x{{[^ ]*}} 
 
@@ -471,7 +471,7 @@
   // CHECK-NEXT: Destructor
   // CHECK-NEXT: CXXMethodDecl 0x{{[^ ]*}}  col:3 operator() 'auto ()' inline
   // CHECK-NEXT: CompoundStmt
-  // CHECK-NEXT: CXXConversionDecl 0x{{[^ ]*}}  col:3 implicit constexpr operator auto (*)() 'auto (*() const)()' inline
+  // CHECK-NEXT: CXXConversionDecl 0x{{[^ ]*}}  col:3 implicit constexpr operator auto (*)() 'auto (*() const noexcept)()' inline
   // CHECK-NEXT: CXXMethodDecl 0x{{[^ ]*}}  col:3 implicit __invoke 'auto ()' static inline
   // CHECK-NEXT: CompoundStmt 0x{{[^ ]*}} 
 
@@ -487,7 +487,7 @@
   // CHECK-NEXT: Destructor
   // CHECK-NEXT: CXXMethodDecl 0x{{[^ ]*}}  col:3 operator() 'auto () const noexcept' inline
   // CHECK-NEXT: CompoundStmt
-  // CHECK-NEXT: CXXConversionDecl 0x{{[^ ]*}}  col:3 implicit constexpr operator auto (*)() noexcept 'auto (*() const)() noexcept' inline
+  // CHECK-NEXT: CXXConversionDecl 0x{{[^ ]*}}  col:3 implicit constexpr operator auto (*)() noexcept 'auto (*() const noexcept)() noexcept' inline
   // CHECK-NEXT: CXXMethodDecl 0x{{[^ ]*}}  col:3 implicit __invoke 'auto () noexcept' static inline
   // CHECK-NEXT: CompoundStmt 0x{{[^ ]*}} 
 
@@ -505,7 +505,7 @@
   // CHECK-NEXT: CompoundStmt
   // CHECK-NEXT: ReturnStmt 0x{{[^ ]*}} 
   // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}}  'int' 0
-  // CHECK-NEXT: CXXConversionDecl 0x{{[^ ]*}}  col:3 implicit constexpr operator int (*)() 'auto (*() const)() -> int' inline
+  // CHECK-NEXT: CXXConversionDecl 0x{{[^ ]*}}  col:3 implicit constexpr operator int (*)() 'auto (*() const 

[PATCH] D56959: [AST] NFC: Introduce new class GenericSelectionExpr::Association

2019-01-21 Thread Stephen Kelly via Phabricator via cfe-commits
steveire marked an inline comment as done.
steveire added inline comments.



Comment at: include/clang/AST/Expr.h:5068
 
+  Association getAssociation(unsigned I) const {
+return Association(cast(SubExprs[END_EXPR + I]), AssocTypes[I],

aaron.ballman wrote:
> steveire wrote:
> > aaron.ballman wrote:
> > > Rather than gin these objects up on demand every time they're needed, I'd 
> > > prefer to see the class store `Association` objects directly. I don't 
> > > think it will be easy to do that and still support `getAssocExprs()` and 
> > > `getAssocTypeSourceInfos()`, so I think those APIs should be removed in 
> > > favor of this one. There's currently not many uses of `getAssocExprs()` 
> > > or `getAssocTypeSourceInfos()` (I spot one each in Clang) so migration to 
> > > the new API should not be onerous.
> > > 
> > > This should also have a range-based accessor version so that users aren't 
> > > required to use iterative loops to access the information (a lot of the 
> > > places you're already touching could use that range-based interface).
> > I would prefer that too, but it doesn't seem to be possible. This is a 
> > sub-range of the `SubExprs` returned from `children()`. 
> > 
> > In theory, that could be split into two members, but then you would need a 
> > range library to recombine them and implement `children()`: 
> > https://godbolt.org/z/ZVamdC
> > 
> > This seems to be the best approach for now, and AFAIK it excludes a 
> > range-accessor.
> > I would prefer that too, but it doesn't seem to be possible. This is a 
> > sub-range of the SubExprs returned from children().
> 
> Ugh, you're right. :-(
> 
> > In theory, that could be split into two members, but then you would need a 
> > range library to recombine them and implement children(): 
> > https://godbolt.org/z/ZVamdC
> 
> We have zip iterators that could be used to implement this, I believe. (see 
> STLExtras.h)
> 
> Alternatively, we could tail-allocate the Association objects with (perhaps 
> references to) pointers back into the Expr tail-allocated array. Not ideal, 
> but does provide a clean interface.
> 
> @riccibruno may have other ideas on how to pack the arrays, as he's done a 
> lot of this work recently.
> We have zip iterators that could be used to implement this, I believe.

You're right, there is a `concat` there, but on second thought - because 
Association and Stmt don't share a base, I don't think it can work.

> Alternatively, we could tail-allocate the Association objects with (perhaps 
> references to) pointers back into the Expr tail-allocated array. Not ideal, 
> but does provide a clean interface.

Perhaps this can work, but I don't know how to do it. If you have scope for it 
in your part of the efforts, it would be a good way to get this unblocked.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56959/new/

https://reviews.llvm.org/D56959



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


[PATCH] D56916: Fix crash due to ObjCPropertyDecl

2019-01-21 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

Good point, @aaron.ballman! @dgoldman, could you please add a test case?


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56916/new/

https://reviews.llvm.org/D56916



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


r351746 - [Analyzer] Remove extra blank line from Iterator Checker (test commit)

2019-01-21 Thread Adam Balogh via cfe-commits
Author: baloghadamsoftware
Date: Mon Jan 21 07:31:23 2019
New Revision: 351746

URL: http://llvm.org/viewvc/llvm-project?rev=351746=rev
Log:
[Analyzer] Remove extra blank line from Iterator Checker (test commit)


Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp?rev=351746=351745=351746=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp Mon Jan 21 
07:31:23 2019
@@ -2378,7 +2378,6 @@ bool compare(ProgramStateRef State, Symb
   return compare(State, nonloc::SymbolVal(Sym1), nonloc::SymbolVal(Sym2), Opc);
 }
 
-
 bool compare(ProgramStateRef State, NonLoc NL1, NonLoc NL2,
  BinaryOperator::Opcode Opc) {
   auto  = State->getStateManager().getSValBuilder();


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


[PATCH] D56900: [Fixed Point Arithmetic] Fixed Point and Integer Conversions

2019-01-21 Thread Bevin Hansson via Phabricator via cfe-commits
ebevhan added inline comments.



Comment at: clang/lib/AST/ExprConstant.cpp:9825
+if (Result.isSigned() && !DstSigned) {
+  Overflow = Result < 0 || Result.ugt(DstMax);
+} else if (Result.isUnsigned() && DstSigned) {

leonardchan wrote:
> ebevhan wrote:
> > The `Result < 0` is more clearly expressed as `Result.isNegative()` I think.
> Ah, so I ran into something similar with the patch preceding this in 
> `APFixedPoint::convert()`. `isNegative()` is a method of `APInt` which 
> doesn't care about signage. It just checks if the last bit is set. `Result < 
> 0` calls `APSInt::operator<()` which cares about the sign and checks if this 
> signed int is less than zero. 
> 
>  have no big problem with this, but if `Result.isNegative()` is more 
> readable, I could also add `Result.isSigned()` which together effectively 
> does the same thing as `Result < 0`.
This makes sense, but you're already checking if the value is signed in the 
line above, so it shouldn't be an issue.



Comment at: clang/test/Frontend/fixed_point_conversions.c:426
+  _Sat short _Accum sat_sa;
+  _Sat unsigned short _Accum sat_usa;
+

There are no tests here for what you get if you convert an integer to a 
fixed-point type with a larger integral part than the integer has.



Comment at: clang/test/Frontend/fixed_point_conversions.c:437
+  // DEFAULT-NEXT: [[RES:%[a-z0-9]+]] = trunc i39 [[SATMIN]] to i16
+  // DEFAULT-NEXT: store i16 [[RES]], i16* %sat_sa, align 2
+

Conversions like this are a bit odd. There shouldn't be a need to 
upsize/upscale the container before the saturation, should there?


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56900/new/

https://reviews.llvm.org/D56900



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


[PATCH] D56992: [clang] Mark lambda-to-function-pointer conversion as noexcept

2019-01-21 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

Aside from the DR status page and a nit with the test's RUN line, this LGTM. 
Thank you for working on this -- do you need me to commit on your behalf? If 
so, are you aware of the recent relicensing of the project and intending to 
contribute under the new license?




Comment at: clang/test/CXX/expr/expr.prim/expr.prim.lambda/p9.cpp:1
+// RUN: %clang_cc1 -fsyntax-only -std=c++1z %s -verify
+// expected-no-diagnostics

The test can use -std=c++17


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56992/new/

https://reviews.llvm.org/D56992



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


[PATCH] D56959: [AST] NFC: Introduce new class GenericSelectionExpr::Association

2019-01-21 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: include/clang/AST/Expr.h:5068
 
+  Association getAssociation(unsigned I) const {
+return Association(cast(SubExprs[END_EXPR + I]), AssocTypes[I],

steveire wrote:
> aaron.ballman wrote:
> > Rather than gin these objects up on demand every time they're needed, I'd 
> > prefer to see the class store `Association` objects directly. I don't think 
> > it will be easy to do that and still support `getAssocExprs()` and 
> > `getAssocTypeSourceInfos()`, so I think those APIs should be removed in 
> > favor of this one. There's currently not many uses of `getAssocExprs()` or 
> > `getAssocTypeSourceInfos()` (I spot one each in Clang) so migration to the 
> > new API should not be onerous.
> > 
> > This should also have a range-based accessor version so that users aren't 
> > required to use iterative loops to access the information (a lot of the 
> > places you're already touching could use that range-based interface).
> I would prefer that too, but it doesn't seem to be possible. This is a 
> sub-range of the `SubExprs` returned from `children()`. 
> 
> In theory, that could be split into two members, but then you would need a 
> range library to recombine them and implement `children()`: 
> https://godbolt.org/z/ZVamdC
> 
> This seems to be the best approach for now, and AFAIK it excludes a 
> range-accessor.
> I would prefer that too, but it doesn't seem to be possible. This is a 
> sub-range of the SubExprs returned from children().

Ugh, you're right. :-(

> In theory, that could be split into two members, but then you would need a 
> range library to recombine them and implement children(): 
> https://godbolt.org/z/ZVamdC

We have zip iterators that could be used to implement this, I believe. (see 
STLExtras.h)

Alternatively, we could tail-allocate the Association objects with (perhaps 
references to) pointers back into the Expr tail-allocated array. Not ideal, but 
does provide a clean interface.

@riccibruno may have other ideas on how to pack the arrays, as he's done a lot 
of this work recently.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56959/new/

https://reviews.llvm.org/D56959



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


[PATCH] D56946: [Documentation] Use HTTPS whenever possible in Clang

2019-01-21 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment.

Yes, I tested all URLs, but I think independent testing will not be excessive.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56946/new/

https://reviews.llvm.org/D56946



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


[PATCH] D56976: [clang] [test] Pass -ccc-install-dir in mac compilation db test

2019-01-21 Thread Michał Górny via Phabricator via cfe-commits
mgorny updated this revision to Diff 182785.
mgorny added a comment.

Added a comment as requested.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56976/new/

https://reviews.llvm.org/D56976

Files:
  test/Tooling/clang-check-mac-libcxx-fixed-compilation-db.cpp


Index: test/Tooling/clang-check-mac-libcxx-fixed-compilation-db.cpp
===
--- test/Tooling/clang-check-mac-libcxx-fixed-compilation-db.cpp
+++ test/Tooling/clang-check-mac-libcxx-fixed-compilation-db.cpp
@@ -10,6 +10,11 @@
 //
 // RUN: cp clang-check %t/mock-libcxx/bin/
 // RUN: cp %s %t/test.cpp
-// RUN: "%t/mock-libcxx/bin/clang-check" -p %t %t/test.cpp -- -stdlib=libc++ 
-target x86_64-apple-darwin
+// RUN: "%t/mock-libcxx/bin/clang-check" -p %t %t/test.cpp -- \
+// RUN: -stdlib=libc++ -target x86_64-apple-darwin \
+// RUN: -ccc-install-dir %t/mock-libcxx/bin
+//
+// ^ -ccc-install-dir passed to unbreak tests on *BSD where
+//   getMainExecutable() relies on real argv[0] being passed
 #include 
 vector v;


Index: test/Tooling/clang-check-mac-libcxx-fixed-compilation-db.cpp
===
--- test/Tooling/clang-check-mac-libcxx-fixed-compilation-db.cpp
+++ test/Tooling/clang-check-mac-libcxx-fixed-compilation-db.cpp
@@ -10,6 +10,11 @@
 //
 // RUN: cp clang-check %t/mock-libcxx/bin/
 // RUN: cp %s %t/test.cpp
-// RUN: "%t/mock-libcxx/bin/clang-check" -p %t %t/test.cpp -- -stdlib=libc++ -target x86_64-apple-darwin
+// RUN: "%t/mock-libcxx/bin/clang-check" -p %t %t/test.cpp -- \
+// RUN: -stdlib=libc++ -target x86_64-apple-darwin \
+// RUN: -ccc-install-dir %t/mock-libcxx/bin
+//
+// ^ -ccc-install-dir passed to unbreak tests on *BSD where
+//   getMainExecutable() relies on real argv[0] being passed
 #include 
 vector v;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D56976: [clang] [test] Pass -ccc-install-dir in mac compilation db test

2019-01-21 Thread Michał Górny via Phabricator via cfe-commits
mgorny marked an inline comment as done.
mgorny added a comment.

In D56976#1365190 , @ilya-biryukov 
wrote:

> Was confused about your comment, so it works on other systems because they 
> don't rely on `argv[0]` to get the path to main executable. Got you.


Exactly.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56976/new/

https://reviews.llvm.org/D56976



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


r351744 - [NFC] Fix comparison warning issues by MSVC

2019-01-21 Thread Johannes Doerfert via cfe-commits
Author: jdoerfert
Date: Mon Jan 21 06:23:46 2019
New Revision: 351744

URL: http://llvm.org/viewvc/llvm-project?rev=351744=rev
Log:
[NFC] Fix comparison warning issues by MSVC

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

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=351744=351743=351744=diff
==
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Mon Jan 21 06:23:46 2019
@@ -3560,7 +3560,9 @@ static void handleCallbackAttr(Sema ,
 
   int CalleeIdx = EncodingIndices.front();
   // Check if the callee index is proper, thus not "this" and not "unknown".
-  if (CalleeIdx < HasImplicitThisParam) {
+  // This means the "CalleeIdx" has to be non-negative if 
"HasImplicitThisParam"
+  // is false and positive if "HasImplicitThisParam" is true.
+  if (CalleeIdx < (int)HasImplicitThisParam) {
 S.Diag(AL.getLoc(), diag::err_callback_attribute_invalid_callee)
 << AL.getRange();
 return;


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


[PATCH] D57015: [MSP430] Ajust f32/f64 alignment according to MSP430 EABI

2019-01-21 Thread Kristina Bessonova via Phabricator via cfe-commits
krisb created this revision.
krisb added a reviewer: asl.
Herald added a subscriber: cfe-commits.

Repository:
  rC Clang

https://reviews.llvm.org/D57015

Files:
  lib/Basic/Targets/MSP430.h
  test/CodeGen/msp430-align.c
  test/Preprocessor/init.c


Index: test/Preprocessor/init.c
===
--- test/Preprocessor/init.c
+++ test/Preprocessor/init.c
@@ -5158,7 +5158,7 @@
 // MSP430:#define __SIZE_MAX__ 65535U
 // MSP430:#define __SIZE_TYPE__ unsigned int
 // MSP430:#define __SIZE_WIDTH__ 16
-// MSP430-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 8U
+// MSP430-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 2U
 // MSP430:#define __UINT16_C_SUFFIX__ U
 // MSP430:#define __UINT16_MAX__ 65535U
 // MSP430:#define __UINT16_TYPE__ unsigned short
Index: test/CodeGen/msp430-align.c
===
--- /dev/null
+++ test/CodeGen/msp430-align.c
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -triple msp430-elf -emit-llvm %s -o - | FileCheck %s
+
+// MSP430 target prefers chars to be aligned to 8 bit and other types to 16 
bit.
+
+// CHECK: @c ={{.*}}global i8 1, align 1
+// CHECK: @s ={{.*}}global i16 266, align 2
+// CHECK: @i ={{.*}}global i16 266, align 2
+// CHECK: @l ={{.*}}global i32 16909060, align 2
+// CHECK: @ll ={{.*}}global i64 283686952306183, align 2
+// CHECK: @f ={{.*}}global float 1.00e+00, align 2
+// CHECK: @d ={{.*}}global double 1.00e+00, align 2
+// CHECK: @ld ={{.*}}global double 1.00e+00, align 2
+// CHECK: @p ={{.*}}global i8* @c, align 2
+
+char c = 1;
+short s = 266;
+int i = 266;
+long l = 16909060;
+long long ll = 283686952306183;
+float f = 1.0f;
+double d = 1.0;
+long double ld = 1.0;
+char *p = 
Index: lib/Basic/Targets/MSP430.h
===
--- lib/Basic/Targets/MSP430.h
+++ lib/Basic/Targets/MSP430.h
@@ -33,6 +33,10 @@
 LongWidth = 32;
 LongLongWidth = 64;
 LongAlign = LongLongAlign = 16;
+FloatWidth = 32;
+FloatAlign = 16;
+DoubleWidth = LongDoubleWidth = 64;
+DoubleAlign = LongDoubleAlign = 16;
 PointerWidth = 16;
 PointerAlign = 16;
 SuitableAlign = 16;
@@ -51,6 +55,8 @@
 return None;
   }
 
+  bool allowsLargerPreferedTypeAlignment() const override { return false; }
+
   bool hasFeature(StringRef Feature) const override {
 return Feature == "msp430";
   }


Index: test/Preprocessor/init.c
===
--- test/Preprocessor/init.c
+++ test/Preprocessor/init.c
@@ -5158,7 +5158,7 @@
 // MSP430:#define __SIZE_MAX__ 65535U
 // MSP430:#define __SIZE_TYPE__ unsigned int
 // MSP430:#define __SIZE_WIDTH__ 16
-// MSP430-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 8U
+// MSP430-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 2U
 // MSP430:#define __UINT16_C_SUFFIX__ U
 // MSP430:#define __UINT16_MAX__ 65535U
 // MSP430:#define __UINT16_TYPE__ unsigned short
Index: test/CodeGen/msp430-align.c
===
--- /dev/null
+++ test/CodeGen/msp430-align.c
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -triple msp430-elf -emit-llvm %s -o - | FileCheck %s
+
+// MSP430 target prefers chars to be aligned to 8 bit and other types to 16 bit.
+
+// CHECK: @c ={{.*}}global i8 1, align 1
+// CHECK: @s ={{.*}}global i16 266, align 2
+// CHECK: @i ={{.*}}global i16 266, align 2
+// CHECK: @l ={{.*}}global i32 16909060, align 2
+// CHECK: @ll ={{.*}}global i64 283686952306183, align 2
+// CHECK: @f ={{.*}}global float 1.00e+00, align 2
+// CHECK: @d ={{.*}}global double 1.00e+00, align 2
+// CHECK: @ld ={{.*}}global double 1.00e+00, align 2
+// CHECK: @p ={{.*}}global i8* @c, align 2
+
+char c = 1;
+short s = 266;
+int i = 266;
+long l = 16909060;
+long long ll = 283686952306183;
+float f = 1.0f;
+double d = 1.0;
+long double ld = 1.0;
+char *p = 
Index: lib/Basic/Targets/MSP430.h
===
--- lib/Basic/Targets/MSP430.h
+++ lib/Basic/Targets/MSP430.h
@@ -33,6 +33,10 @@
 LongWidth = 32;
 LongLongWidth = 64;
 LongAlign = LongLongAlign = 16;
+FloatWidth = 32;
+FloatAlign = 16;
+DoubleWidth = LongDoubleWidth = 64;
+DoubleAlign = LongDoubleAlign = 16;
 PointerWidth = 16;
 PointerAlign = 16;
 SuitableAlign = 16;
@@ -51,6 +55,8 @@
 return None;
   }
 
+  bool allowsLargerPreferedTypeAlignment() const override { return false; }
+
   bool hasFeature(StringRef Feature) const override {
 return Feature == "msp430";
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D56959: [AST] NFC: Introduce new class GenericSelectionExpr::Association

2019-01-21 Thread Stephen Kelly via Phabricator via cfe-commits
steveire marked 2 inline comments as done.
steveire added inline comments.



Comment at: include/clang/AST/Expr.h:5068
 
+  Association getAssociation(unsigned I) const {
+return Association(cast(SubExprs[END_EXPR + I]), AssocTypes[I],

aaron.ballman wrote:
> Rather than gin these objects up on demand every time they're needed, I'd 
> prefer to see the class store `Association` objects directly. I don't think 
> it will be easy to do that and still support `getAssocExprs()` and 
> `getAssocTypeSourceInfos()`, so I think those APIs should be removed in favor 
> of this one. There's currently not many uses of `getAssocExprs()` or 
> `getAssocTypeSourceInfos()` (I spot one each in Clang) so migration to the 
> new API should not be onerous.
> 
> This should also have a range-based accessor version so that users aren't 
> required to use iterative loops to access the information (a lot of the 
> places you're already touching could use that range-based interface).
I would prefer that too, but it doesn't seem to be possible. This is a 
sub-range of the `SubExprs` returned from `children()`. 

In theory, that could be split into two members, but then you would need a 
range library to recombine them and implement `children()`: 
https://godbolt.org/z/ZVamdC

This seems to be the best approach for now, and AFAIK it excludes a 
range-accessor.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56959/new/

https://reviews.llvm.org/D56959



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


[PATCH] D56946: [Documentation] Use HTTPS whenever possible in Clang

2019-01-21 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru added a comment.

Did you test all url?


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56946/new/

https://reviews.llvm.org/D56946



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


[PATCH] D56916: Fix crash due to ObjCPropertyDecl

2019-01-21 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Test case? Or does one already cover this crash?


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56916/new/

https://reviews.llvm.org/D56916



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


[PATCH] D56992: [clang] Mark lambda-to-function-pointer conversion as noexcept

2019-01-21 Thread Ignat Loskutov via Phabricator via cfe-commits
loskutov updated this revision to Diff 182783.

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56992/new/

https://reviews.llvm.org/D56992

Files:
  clang/lib/Sema/SemaLambda.cpp
  clang/test/AST/ast-dump-expr.cpp
  clang/test/CXX/expr/expr.prim/expr.prim.lambda/p9.cpp


Index: clang/test/CXX/expr/expr.prim/expr.prim.lambda/p9.cpp
===
--- /dev/null
+++ clang/test/CXX/expr/expr.prim/expr.prim.lambda/p9.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++1z %s -verify
+// expected-no-diagnostics
+
+void test_noexcept() {
+  const auto lambda = [](int x) { return x + 1; };
+  static_assert(noexcept((int (*)(int))(lambda)),
+"Lambda-to-function-pointer conversion is expected to be 
noexcept");
+}
Index: clang/test/AST/ast-dump-expr.cpp
===
--- clang/test/AST/ast-dump-expr.cpp
+++ clang/test/AST/ast-dump-expr.cpp
@@ -290,7 +290,7 @@
   // CHECK-NEXT: Destructor
   // CHECK-NEXT: CXXMethodDecl 0x{{[^ ]*}}  col:3 operator() 
'auto () const' inline
   // CHECK-NEXT: CompoundStmt
-  // CHECK-NEXT: CXXConversionDecl 0x{{[^ ]*}}  col:3 implicit 
constexpr operator auto (*)() 'auto (*() const)()' inline
+  // CHECK-NEXT: CXXConversionDecl 0x{{[^ ]*}}  col:3 implicit 
constexpr operator auto (*)() 'auto (*() const noexcept)()' inline
   // CHECK-NEXT: CXXMethodDecl 0x{{[^ ]*}}  col:3 implicit 
__invoke 'auto ()' static inline
   // CHECK-NEXT: CompoundStmt 0x{{[^ ]*}} 
 
@@ -307,7 +307,7 @@
   // CHECK-NEXT: CXXMethodDecl 0x{{[^ ]*}}  col:3 operator() 
'auto (int, ...) const' inline
   // CHECK-NEXT: ParmVarDecl 0x{{[^ ]*}}  col:10 a 'int'
   // CHECK-NEXT: CompoundStmt
-  // CHECK-NEXT: CXXConversionDecl 0x{{[^ ]*}}  col:3 implicit 
constexpr operator auto (*)(int, ...) 'auto (*() const)(int, ...)' inline
+  // CHECK-NEXT: CXXConversionDecl 0x{{[^ ]*}}  col:3 implicit 
constexpr operator auto (*)(int, ...) 'auto (*() const noexcept)(int, ...)' 
inline
   // CHECK-NEXT: CXXMethodDecl 0x{{[^ ]*}}  col:3 implicit 
__invoke 'auto (int, ...)' static inline
   // CHECK-NEXT: ParmVarDecl 0x{{[^ ]*}}  col:10 a 'int'
   // CHECK-NEXT: CompoundStmt 0x{{[^ ]*}} 
@@ -455,7 +455,7 @@
   // CHECK-NEXT: Destructor
   // CHECK-NEXT: CXXMethodDecl 0x{{[^ ]*}}  col:3 constexpr 
operator() 'auto () const' inline
   // CHECK-NEXT: CompoundStmt
-  // CHECK-NEXT: CXXConversionDecl 0x{{[^ ]*}}  col:3 implicit 
constexpr operator auto (*)() 'auto (*() const)()' inline
+  // CHECK-NEXT: CXXConversionDecl 0x{{[^ ]*}}  col:3 implicit 
constexpr operator auto (*)() 'auto (*() const noexcept)()' inline
   // CHECK-NEXT: CXXMethodDecl 0x{{[^ ]*}}  col:3 implicit 
__invoke 'auto ()' static inline
   // CHECK-NEXT: CompoundStmt 0x{{[^ ]*}} 
 
@@ -471,7 +471,7 @@
   // CHECK-NEXT: Destructor
   // CHECK-NEXT: CXXMethodDecl 0x{{[^ ]*}}  col:3 operator() 
'auto ()' inline
   // CHECK-NEXT: CompoundStmt
-  // CHECK-NEXT: CXXConversionDecl 0x{{[^ ]*}}  col:3 implicit 
constexpr operator auto (*)() 'auto (*() const)()' inline
+  // CHECK-NEXT: CXXConversionDecl 0x{{[^ ]*}}  col:3 implicit 
constexpr operator auto (*)() 'auto (*() const noexcept)()' inline
   // CHECK-NEXT: CXXMethodDecl 0x{{[^ ]*}}  col:3 implicit 
__invoke 'auto ()' static inline
   // CHECK-NEXT: CompoundStmt 0x{{[^ ]*}} 
 
@@ -487,7 +487,7 @@
   // CHECK-NEXT: Destructor
   // CHECK-NEXT: CXXMethodDecl 0x{{[^ ]*}}  col:3 operator() 
'auto () const noexcept' inline
   // CHECK-NEXT: CompoundStmt
-  // CHECK-NEXT: CXXConversionDecl 0x{{[^ ]*}}  col:3 implicit 
constexpr operator auto (*)() noexcept 'auto (*() const)() noexcept' inline
+  // CHECK-NEXT: CXXConversionDecl 0x{{[^ ]*}}  col:3 implicit 
constexpr operator auto (*)() noexcept 'auto (*() const noexcept)() noexcept' 
inline
   // CHECK-NEXT: CXXMethodDecl 0x{{[^ ]*}}  col:3 implicit 
__invoke 'auto () noexcept' static inline
   // CHECK-NEXT: CompoundStmt 0x{{[^ ]*}} 
 
@@ -505,7 +505,7 @@
   // CHECK-NEXT: CompoundStmt
   // CHECK-NEXT: ReturnStmt 0x{{[^ ]*}} 
   // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}}  'int' 0
-  // CHECK-NEXT: CXXConversionDecl 0x{{[^ ]*}}  col:3 implicit 
constexpr operator int (*)() 'auto (*() const)() -> int' inline
+  // CHECK-NEXT: CXXConversionDecl 0x{{[^ ]*}}  col:3 implicit 
constexpr operator int (*)() 'auto (*() const noexcept)() -> int' inline
   // CHECK-NEXT: CXXMethodDecl 0x{{[^ ]*}}  col:3 implicit 
__invoke 'auto () -> int' static inline
   // CHECK-NEXT: CompoundStmt 0x{{[^ ]*}} 
   // CHECK-NEXT: ReturnStmt 0x{{[^ ]*}} 
@@ -568,4 +568,4 @@
   // CHECK: CallExpr 0x{{[^ ]*}} ]+}}> 'void'{{$}}
   f(x);
 }
-} // namespace test_adl_call_three
\ No newline at end of file
+} // namespace test_adl_call_three
Index: clang/lib/Sema/SemaLambda.cpp
===
--- clang/lib/Sema/SemaLambda.cpp
+++ clang/lib/Sema/SemaLambda.cpp
@@ -1227,9 +1227,10 @@
   FunctionProtoType::ExtProtoInfo 

[PATCH] D56992: [clang] Mark lambda-to-function-pointer conversion as noexcept

2019-01-21 Thread Ignat Loskutov via Phabricator via cfe-commits
loskutov updated this revision to Diff 182782.
loskutov marked an inline comment as done.
loskutov added a comment.

Uploaded an updated diff instead of a diff-from-previous-diff


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56992/new/

https://reviews.llvm.org/D56992

Files:
  clang/lib/Sema/SemaLambda.cpp
  clang/test/AST/ast-dump-expr.cpp
  clang/test/CXX/expr/expr.prim/expr.prim.lambda/p9.cpp


Index: clang/test/CXX/expr/expr.prim/expr.prim.lambda/p9.cpp
===
--- /dev/null
+++ clang/test/CXX/expr/expr.prim/expr.prim.lambda/p9.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++1z %s -verify
+// expected-no-diagnostics
+
+void test_noexcept() {
+  const auto lambda = [](int x) { return x + 1; };
+  static_assert(noexcept((int (*)(int))(lambda)),
+"Lambda-to-function pointer conversion is expected to be 
noexcept");
+}
Index: clang/test/AST/ast-dump-expr.cpp
===
--- clang/test/AST/ast-dump-expr.cpp
+++ clang/test/AST/ast-dump-expr.cpp
@@ -290,7 +290,7 @@
   // CHECK-NEXT: Destructor
   // CHECK-NEXT: CXXMethodDecl 0x{{[^ ]*}}  col:3 operator() 
'auto () const' inline
   // CHECK-NEXT: CompoundStmt
-  // CHECK-NEXT: CXXConversionDecl 0x{{[^ ]*}}  col:3 implicit 
constexpr operator auto (*)() 'auto (*() const)()' inline
+  // CHECK-NEXT: CXXConversionDecl 0x{{[^ ]*}}  col:3 implicit 
constexpr operator auto (*)() 'auto (*() const noexcept)()' inline
   // CHECK-NEXT: CXXMethodDecl 0x{{[^ ]*}}  col:3 implicit 
__invoke 'auto ()' static inline
   // CHECK-NEXT: CompoundStmt 0x{{[^ ]*}} 
 
@@ -307,7 +307,7 @@
   // CHECK-NEXT: CXXMethodDecl 0x{{[^ ]*}}  col:3 operator() 
'auto (int, ...) const' inline
   // CHECK-NEXT: ParmVarDecl 0x{{[^ ]*}}  col:10 a 'int'
   // CHECK-NEXT: CompoundStmt
-  // CHECK-NEXT: CXXConversionDecl 0x{{[^ ]*}}  col:3 implicit 
constexpr operator auto (*)(int, ...) 'auto (*() const)(int, ...)' inline
+  // CHECK-NEXT: CXXConversionDecl 0x{{[^ ]*}}  col:3 implicit 
constexpr operator auto (*)(int, ...) 'auto (*() const noexcept)(int, ...)' 
inline
   // CHECK-NEXT: CXXMethodDecl 0x{{[^ ]*}}  col:3 implicit 
__invoke 'auto (int, ...)' static inline
   // CHECK-NEXT: ParmVarDecl 0x{{[^ ]*}}  col:10 a 'int'
   // CHECK-NEXT: CompoundStmt 0x{{[^ ]*}} 
@@ -455,7 +455,7 @@
   // CHECK-NEXT: Destructor
   // CHECK-NEXT: CXXMethodDecl 0x{{[^ ]*}}  col:3 constexpr 
operator() 'auto () const' inline
   // CHECK-NEXT: CompoundStmt
-  // CHECK-NEXT: CXXConversionDecl 0x{{[^ ]*}}  col:3 implicit 
constexpr operator auto (*)() 'auto (*() const)()' inline
+  // CHECK-NEXT: CXXConversionDecl 0x{{[^ ]*}}  col:3 implicit 
constexpr operator auto (*)() 'auto (*() const noexcept)()' inline
   // CHECK-NEXT: CXXMethodDecl 0x{{[^ ]*}}  col:3 implicit 
__invoke 'auto ()' static inline
   // CHECK-NEXT: CompoundStmt 0x{{[^ ]*}} 
 
@@ -471,7 +471,7 @@
   // CHECK-NEXT: Destructor
   // CHECK-NEXT: CXXMethodDecl 0x{{[^ ]*}}  col:3 operator() 
'auto ()' inline
   // CHECK-NEXT: CompoundStmt
-  // CHECK-NEXT: CXXConversionDecl 0x{{[^ ]*}}  col:3 implicit 
constexpr operator auto (*)() 'auto (*() const)()' inline
+  // CHECK-NEXT: CXXConversionDecl 0x{{[^ ]*}}  col:3 implicit 
constexpr operator auto (*)() 'auto (*() const noexcept)()' inline
   // CHECK-NEXT: CXXMethodDecl 0x{{[^ ]*}}  col:3 implicit 
__invoke 'auto ()' static inline
   // CHECK-NEXT: CompoundStmt 0x{{[^ ]*}} 
 
@@ -487,7 +487,7 @@
   // CHECK-NEXT: Destructor
   // CHECK-NEXT: CXXMethodDecl 0x{{[^ ]*}}  col:3 operator() 
'auto () const noexcept' inline
   // CHECK-NEXT: CompoundStmt
-  // CHECK-NEXT: CXXConversionDecl 0x{{[^ ]*}}  col:3 implicit 
constexpr operator auto (*)() noexcept 'auto (*() const)() noexcept' inline
+  // CHECK-NEXT: CXXConversionDecl 0x{{[^ ]*}}  col:3 implicit 
constexpr operator auto (*)() noexcept 'auto (*() const noexcept)() noexcept' 
inline
   // CHECK-NEXT: CXXMethodDecl 0x{{[^ ]*}}  col:3 implicit 
__invoke 'auto () noexcept' static inline
   // CHECK-NEXT: CompoundStmt 0x{{[^ ]*}} 
 
@@ -505,7 +505,7 @@
   // CHECK-NEXT: CompoundStmt
   // CHECK-NEXT: ReturnStmt 0x{{[^ ]*}} 
   // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}}  'int' 0
-  // CHECK-NEXT: CXXConversionDecl 0x{{[^ ]*}}  col:3 implicit 
constexpr operator int (*)() 'auto (*() const)() -> int' inline
+  // CHECK-NEXT: CXXConversionDecl 0x{{[^ ]*}}  col:3 implicit 
constexpr operator int (*)() 'auto (*() const noexcept)() -> int' inline
   // CHECK-NEXT: CXXMethodDecl 0x{{[^ ]*}}  col:3 implicit 
__invoke 'auto () -> int' static inline
   // CHECK-NEXT: CompoundStmt 0x{{[^ ]*}} 
   // CHECK-NEXT: ReturnStmt 0x{{[^ ]*}} 
@@ -568,4 +568,4 @@
   // CHECK: CallExpr 0x{{[^ ]*}} ]+}}> 'void'{{$}}
   f(x);
 }
-} // namespace test_adl_call_three
\ No newline at end of file
+} // namespace test_adl_call_three
Index: clang/lib/Sema/SemaLambda.cpp

[PATCH] D56916: Fix crash due to ObjCPropertyDecl

2019-01-21 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

@dgoldman, do you have commit access or should I land this for you?




Comment at: clangd/index/SymbolCollector.cpp:375
+  // not a NamedDecl.
+  const NamedDecl *OriginalDecl = dyn_cast(ASTNode.OrigD);
+  if (!OriginalDecl)

NIT: use `auto*`, the type name is spelled in the RHS anyway.


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56916/new/

https://reviews.llvm.org/D56916



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


[PATCH] D55256: [clangd] Support clang-tidy configuration in clangd.

2019-01-21 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clangd/ClangdLSPServer.h:132
 
-  RealFileSystemProvider FSProvider;
   /// Options used for code completion

hokein wrote:
> sammccall wrote:
> > ilya-biryukov wrote:
> > > Could we instead call `getRealFS()` when we try to initialize a 
> > > clang-tidy options provider in `main()` and avoid changing this?
> > > To avoid adding extra non-real-fs "modes of operation" to 
> > > `ClangdLSPServer`. Unless you see other uses for this.
> > We already have out-of-tree modifications to ClangdLSPServer to use 
> > non-real FSes.
> > Given that, I think this change is OK... though better still might be to 
> > move it into `ClangdServer::Options`
> Yes, this is the main reason I did this change.
It still feels that `ClangdLSPServcer` is closely tied to real fs, so I don't 
see how that makes things simpler. I wouldn't call the presence of out-of-tree 
modifications a good reason to do this change, at least not without tests and 
comments explaining why this needs to be configurable.

WRT to `ClangdServer::Options`, I believe this goes back to the previous 
discussion we had about putting the non-data configuration parameters 
(Index+FSProvider+CompilationsDB). I'd say put `CompilationsDB` into `Options` 
as well if you plan to put FSProvider, they should really live together (i.e. 
the reason we have out-of-tree modifications is closely tied to our custom CDB, 
so it makes sense for both to stay together). 

FWIW, I still think they're FSProvider+CDB+Index should be separate parameters, 
but that goes back to the earlier conversation we had with @sammccall when the 
`Options` were added in the first place.

Not a big deal, just wanted to convey the intention of my original comment.


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55256/new/

https://reviews.llvm.org/D55256



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


[PATCH] D56959: [AST] NFC: Introduce new class GenericSelectionExpr::Association

2019-01-21 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: include/clang/AST/Expr.h:5068
 
+  Association getAssociation(unsigned I) const {
+return Association(cast(SubExprs[END_EXPR + I]), AssocTypes[I],

Rather than gin these objects up on demand every time they're needed, I'd 
prefer to see the class store `Association` objects directly. I don't think it 
will be easy to do that and still support `getAssocExprs()` and 
`getAssocTypeSourceInfos()`, so I think those APIs should be removed in favor 
of this one. There's currently not many uses of `getAssocExprs()` or 
`getAssocTypeSourceInfos()` (I spot one each in Clang) so migration to the new 
API should not be onerous.

This should also have a range-based accessor version so that users aren't 
required to use iterative loops to access the information (a lot of the places 
you're already touching could use that range-based interface).



Comment at: lib/AST/ASTDumper.cpp:1467
 dumpChild([=] {
-  if (const TypeSourceInfo *TSI = E->getAssocTypeSourceInfo(I)) {
+  const auto Assoc = E->getAssociation(I);
+  const TypeSourceInfo *TSI = Assoc.getTypeSourceInfo();

Don't use `auto` here.



Comment at: lib/AST/StmtPrinter.cpp:1266
 OS << ", ";
-QualType T = Node->getAssocType(i);
+auto Assoc = Node->getAssociation(i);
+QualType T = Assoc.getType();

Don't use `auto`.



Comment at: lib/AST/StmtProfile.cpp:1263
   for (unsigned i = 0; i != S->getNumAssocs(); ++i) {
-QualType T = S->getAssocType(i);
+auto Assoc = S->getAssociation(i);
+QualType T = Assoc.getType();

Or here (or anywhere similar in this patch; I'll stop commenting on them).


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56959/new/

https://reviews.llvm.org/D56959



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


[PATCH] D56917: [clang] add tests to ExprMutAnalyzer that reproduced a crash in ASTMatchers

2019-01-21 Thread Jonas Toth via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL351743: [clang] add tests to ExprMutAnalyzer that reproduced 
a crash in ASTMatchers (authored by JonasToth, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56917/new/

https://reviews.llvm.org/D56917

Files:
  cfe/trunk/unittests/Analysis/ExprMutationAnalyzerTest.cpp


Index: cfe/trunk/unittests/Analysis/ExprMutationAnalyzerTest.cpp
===
--- cfe/trunk/unittests/Analysis/ExprMutationAnalyzerTest.cpp
+++ cfe/trunk/unittests/Analysis/ExprMutationAnalyzerTest.cpp
@@ -1108,4 +1108,23 @@
   EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("x->mf()"));
 }
 
+TEST(ExprMutationAnalyzerTest, ReproduceFailureMinimal) {
+  const std::string Reproducer =
+  "namespace std {"
+  "template  T forward(T & A) { return static_cast(A); }"
+  "template  struct __bind {"
+  "  T f;"
+  "  template  __bind(T v, V &&) : f(forward(v)) {}"
+  "};"
+  "}"
+  "void f() {"
+  "  int x = 42;"
+  "  auto Lambda = [] {};"
+  "  std::__bind(Lambda, x);"
+  "}";
+  auto AST11 = buildASTFromCodeWithArgs(Reproducer, {"-std=c++11"});
+  auto Results11 =
+  match(withEnclosingCompound(declRefTo("x")), AST11->getASTContext());
+  EXPECT_FALSE(isMutated(Results11, AST11.get()));
+}
 } // namespace clang


Index: cfe/trunk/unittests/Analysis/ExprMutationAnalyzerTest.cpp
===
--- cfe/trunk/unittests/Analysis/ExprMutationAnalyzerTest.cpp
+++ cfe/trunk/unittests/Analysis/ExprMutationAnalyzerTest.cpp
@@ -1108,4 +1108,23 @@
   EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("x->mf()"));
 }
 
+TEST(ExprMutationAnalyzerTest, ReproduceFailureMinimal) {
+  const std::string Reproducer =
+  "namespace std {"
+  "template  T forward(T & A) { return static_cast(A); }"
+  "template  struct __bind {"
+  "  T f;"
+  "  template  __bind(T v, V &&) : f(forward(v)) {}"
+  "};"
+  "}"
+  "void f() {"
+  "  int x = 42;"
+  "  auto Lambda = [] {};"
+  "  std::__bind(Lambda, x);"
+  "}";
+  auto AST11 = buildASTFromCodeWithArgs(Reproducer, {"-std=c++11"});
+  auto Results11 =
+  match(withEnclosingCompound(declRefTo("x")), AST11->getASTContext());
+  EXPECT_FALSE(isMutated(Results11, AST11.get()));
+}
 } // namespace clang
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D56960: NFC: Implement GenericSelectionExpr::Association dump with Visitor

2019-01-21 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: lib/AST/ASTDumper.cpp:1476-1477
 
   for (unsigned I = 0, N = E->getNumAssocs(); I != N; ++I) {
-dumpChild([=] {
-  const auto Assoc = E->getAssociation(I);
-  const TypeSourceInfo *TSI = Assoc.getTypeSourceInfo();
-  if (TSI) {
-OS << "case ";
-NodeDumper.dumpType(TSI->getType());
-  } else {
-OS << "default";
-  }
-
-  if (Assoc.IsSelected())
-OS << " selected";
-
-  if (TSI)
-dumpTypeAsChild(TSI->getType());
-  dumpStmt(Assoc.getExpr());
-});
+Visit(E->getAssociation(I));
   }

aaron.ballman wrote:
> You can change this to be a range-based for loop over the associations to 
> clean it up even further. `for (const auto *A = E->getAssocExprs())`
Ah, I see now that this is over the new `Association` objects, not the old 
`Expr *` objects. I'll add comments on the other review, but same guideline 
here.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56960/new/

https://reviews.llvm.org/D56960



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


r351743 - [clang] add tests to ExprMutAnalyzer that reproduced a crash in ASTMatchers

2019-01-21 Thread Jonas Toth via cfe-commits
Author: jonastoth
Date: Mon Jan 21 05:26:18 2019
New Revision: 351743

URL: http://llvm.org/viewvc/llvm-project?rev=351743=rev
Log:
[clang] add tests to ExprMutAnalyzer that reproduced a crash in ASTMatchers

Summary:
This patch adds two unit-tests that are the result of reducing a crashing TU
when running ExprMutAnalyzer over it. They are added only to ensure the 
regression
that has been fixed with https://reviews.llvm.org/D56444 don't creep back.

Reviewers: aaron.ballman, sammccall, rsmith, george.karpenkov

Reviewed By: sammccall

Subscribers: baloghadamsoftware, a.sidorin, Szelethus, donat.nagy, dkrupp, 
cfe-commits

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

Modified:
cfe/trunk/unittests/Analysis/ExprMutationAnalyzerTest.cpp

Modified: cfe/trunk/unittests/Analysis/ExprMutationAnalyzerTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Analysis/ExprMutationAnalyzerTest.cpp?rev=351743=351742=351743=diff
==
--- cfe/trunk/unittests/Analysis/ExprMutationAnalyzerTest.cpp (original)
+++ cfe/trunk/unittests/Analysis/ExprMutationAnalyzerTest.cpp Mon Jan 21 
05:26:18 2019
@@ -1108,4 +1108,23 @@ TEST(ExprMutationAnalyzerTest, UniquePtr
   EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("x->mf()"));
 }
 
+TEST(ExprMutationAnalyzerTest, ReproduceFailureMinimal) {
+  const std::string Reproducer =
+  "namespace std {"
+  "template  T forward(T & A) { return static_cast(A); }"
+  "template  struct __bind {"
+  "  T f;"
+  "  template  __bind(T v, V &&) : f(forward(v)) {}"
+  "};"
+  "}"
+  "void f() {"
+  "  int x = 42;"
+  "  auto Lambda = [] {};"
+  "  std::__bind(Lambda, x);"
+  "}";
+  auto AST11 = buildASTFromCodeWithArgs(Reproducer, {"-std=c++11"});
+  auto Results11 =
+  match(withEnclosingCompound(declRefTo("x")), AST11->getASTContext());
+  EXPECT_FALSE(isMutated(Results11, AST11.get()));
+}
 } // namespace clang


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


[PATCH] D56960: NFC: Implement GenericSelectionExpr::Association dump with Visitor

2019-01-21 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM with a few small cosmetic changes.




Comment at: lib/AST/ASTDumper.cpp:1463-1464
+NodeDumper.Visit(A);
+const TypeSourceInfo *TSI = A.getTypeSourceInfo();
+if (TSI)
+  dumpTypeAsChild(TSI->getType());

These can be combined into a single `if` statement.



Comment at: lib/AST/ASTDumper.cpp:1476-1477
 
   for (unsigned I = 0, N = E->getNumAssocs(); I != N; ++I) {
-dumpChild([=] {
-  const auto Assoc = E->getAssociation(I);
-  const TypeSourceInfo *TSI = Assoc.getTypeSourceInfo();
-  if (TSI) {
-OS << "case ";
-NodeDumper.dumpType(TSI->getType());
-  } else {
-OS << "default";
-  }
-
-  if (Assoc.IsSelected())
-OS << " selected";
-
-  if (TSI)
-dumpTypeAsChild(TSI->getType());
-  dumpStmt(Assoc.getExpr());
-});
+Visit(E->getAssociation(I));
   }

You can change this to be a range-based for loop over the associations to clean 
it up even further. `for (const auto *A = E->getAssocExprs())`


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56960/new/

https://reviews.llvm.org/D56960



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


[PATCH] D56917: [clang] add tests to ExprMutAnalyzer that reproduced a crash in ASTMatchers

2019-01-21 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth updated this revision to Diff 182780.
JonasToth added a comment.

- use only the small reproducer


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56917/new/

https://reviews.llvm.org/D56917

Files:
  unittests/Analysis/ExprMutationAnalyzerTest.cpp


Index: unittests/Analysis/ExprMutationAnalyzerTest.cpp
===
--- unittests/Analysis/ExprMutationAnalyzerTest.cpp
+++ unittests/Analysis/ExprMutationAnalyzerTest.cpp
@@ -1109,4 +1109,23 @@
   EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("x->mf()"));
 }
 
+TEST(ExprMutationAnalyzerTest, ReproduceFailureMinimal) {
+  const std::string Reproducer =
+  "namespace std {"
+  "template  T forward(T & A) { return static_cast(A); }"
+  "template  struct __bind {"
+  "  T f;"
+  "  template  __bind(T v, V &&) : f(forward(v)) {}"
+  "};"
+  "}"
+  "void f() {"
+  "  int x = 42;"
+  "  auto Lambda = [] {};"
+  "  std::__bind(Lambda, x);"
+  "}";
+  auto AST11 = buildASTFromCodeWithArgs(Reproducer, {"-std=c++11"});
+  auto Results11 =
+  match(withEnclosingCompound(declRefTo("x")), AST11->getASTContext());
+  EXPECT_FALSE(isMutated(Results11, AST11.get()));
+}
 } // namespace clang


Index: unittests/Analysis/ExprMutationAnalyzerTest.cpp
===
--- unittests/Analysis/ExprMutationAnalyzerTest.cpp
+++ unittests/Analysis/ExprMutationAnalyzerTest.cpp
@@ -1109,4 +1109,23 @@
   EXPECT_THAT(mutatedBy(Results, AST.get()), ElementsAre("x->mf()"));
 }
 
+TEST(ExprMutationAnalyzerTest, ReproduceFailureMinimal) {
+  const std::string Reproducer =
+  "namespace std {"
+  "template  T forward(T & A) { return static_cast(A); }"
+  "template  struct __bind {"
+  "  T f;"
+  "  template  __bind(T v, V &&) : f(forward(v)) {}"
+  "};"
+  "}"
+  "void f() {"
+  "  int x = 42;"
+  "  auto Lambda = [] {};"
+  "  std::__bind(Lambda, x);"
+  "}";
+  auto AST11 = buildASTFromCodeWithArgs(Reproducer, {"-std=c++11"});
+  auto Results11 =
+  match(withEnclosingCompound(declRefTo("x")), AST11->getASTContext());
+  EXPECT_FALSE(isMutated(Results11, AST11.get()));
+}
 } // namespace clang
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D56961: NFC: Move GenericSelectionExpr dump to NodeDumper

2019-01-21 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM!


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56961/new/

https://reviews.llvm.org/D56961



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


[PATCH] D56992: [clang] Mark lambda-to-function-pointer conversion as noexcept

2019-01-21 Thread Ignat Loskutov via Phabricator via cfe-commits
loskutov updated this revision to Diff 182779.
loskutov added a comment.

Fixed the comment.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56992/new/

https://reviews.llvm.org/D56992

Files:
  clang/lib/Sema/SemaLambda.cpp


Index: clang/lib/Sema/SemaLambda.cpp
===
--- clang/lib/Sema/SemaLambda.cpp
+++ clang/lib/Sema/SemaLambda.cpp
@@ -1227,9 +1227,7 @@
   FunctionProtoType::ExtProtoInfo ConvExtInfo(
   S.Context.getDefaultCallingConvention(
   /*IsVariadic=*/false, /*IsCXXMethod=*/true));
-  // The conversion function is always const.
-  // C++17 also obliges it to be noexcept (which it in fact is),
-  // and previous standards don't forbid that either.
+  // The conversion function is always const and noexcept.
   ConvExtInfo.TypeQuals = Qualifiers();
   ConvExtInfo.TypeQuals.addConst();
   ConvExtInfo.ExceptionSpec.Type = EST_BasicNoexcept;


Index: clang/lib/Sema/SemaLambda.cpp
===
--- clang/lib/Sema/SemaLambda.cpp
+++ clang/lib/Sema/SemaLambda.cpp
@@ -1227,9 +1227,7 @@
   FunctionProtoType::ExtProtoInfo ConvExtInfo(
   S.Context.getDefaultCallingConvention(
   /*IsVariadic=*/false, /*IsCXXMethod=*/true));
-  // The conversion function is always const.
-  // C++17 also obliges it to be noexcept (which it in fact is),
-  // and previous standards don't forbid that either.
+  // The conversion function is always const and noexcept.
   ConvExtInfo.TypeQuals = Qualifiers();
   ConvExtInfo.TypeQuals.addConst();
   ConvExtInfo.ExceptionSpec.Type = EST_BasicNoexcept;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D55256: [clangd] Support clang-tidy configuration in clangd.

2019-01-21 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clangd/tool/ClangdMain.cpp:438
+  auto OverrideClangTidyOptions = tidy::ClangTidyOptions::getDefaults();
+  if (!ClangTidyChecks.empty())
+OverrideClangTidyOptions.Checks = ClangTidyChecks;

sammccall wrote:
> This prevents `-clang-tidy-checks=` from disabling all checks.
> use ClangTidyChecks.getNumOccurrences() instead?
To disable all checks, the `-clang-tidy-checks` should be `-*`. clang-tidy 
merges all configurations.

Actually we don't need this `if`, removed.


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55256/new/

https://reviews.llvm.org/D55256



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


[PATCH] D55256: [clangd] Support clang-tidy configuration in clangd.

2019-01-21 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 182778.
hokein marked 5 inline comments as done.
hokein added a comment.

Address comments.


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55256/new/

https://reviews.llvm.org/D55256

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdLSPServer.h
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/ClangdUnit.cpp
  clangd/ClangdUnit.h
  clangd/tool/ClangdMain.cpp
  unittests/clangd/ClangdUnitTests.cpp
  unittests/clangd/FileIndexTests.cpp
  unittests/clangd/TUSchedulerTests.cpp
  unittests/clangd/TestTU.cpp
  unittests/clangd/TestTU.h

Index: unittests/clangd/TestTU.h
===
--- unittests/clangd/TestTU.h
+++ unittests/clangd/TestTU.h
@@ -48,6 +48,8 @@
   // Extra arguments for the compiler invocation.
   std::vector ExtraArgs;
 
+  llvm::Optional ClangTidyChecks;
+
   ParsedAST build() const;
   SymbolSlab headerSymbols() const;
   std::unique_ptr index() const;
Index: unittests/clangd/TestTU.cpp
===
--- unittests/clangd/TestTU.cpp
+++ unittests/clangd/TestTU.cpp
@@ -35,6 +35,8 @@
   Inputs.CompileCommand.Directory = testRoot();
   Inputs.Contents = Code;
   Inputs.FS = buildTestFS({{FullFilename, Code}, {FullHeaderName, HeaderCode}});
+  Inputs.ClangTidyOpts = tidy::ClangTidyOptions::getDefaults();
+  Inputs.ClangTidyOpts.Checks = ClangTidyChecks;
   auto PCHs = std::make_shared();
   auto CI = buildCompilerInvocation(Inputs);
   assert(CI && "Failed to build compilation invocation.");
Index: unittests/clangd/TUSchedulerTests.cpp
===
--- unittests/clangd/TUSchedulerTests.cpp
+++ unittests/clangd/TUSchedulerTests.cpp
@@ -38,7 +38,8 @@
 protected:
   ParseInputs getInputs(PathRef File, std::string Contents) {
 return ParseInputs{*CDB.getCompileCommand(File),
-   buildTestFS(Files, Timestamps), std::move(Contents)};
+   buildTestFS(Files, Timestamps), std::move(Contents),
+   tidy::ClangTidyOptions::getDefaults()};
   }
 
   void updateWithCallback(TUScheduler , PathRef File,
Index: unittests/clangd/FileIndexTests.cpp
===
--- unittests/clangd/FileIndexTests.cpp
+++ unittests/clangd/FileIndexTests.cpp
@@ -363,7 +363,8 @@
   auto AST =
   ParsedAST::build(createInvocationFromCommandLine(Cmd), PreambleData,
llvm::MemoryBuffer::getMemBufferCopy(Main.code()),
-   std::make_shared(), PI.FS);
+   std::make_shared(), PI.FS,
+   tidy::ClangTidyOptions::getDefaults());
   ASSERT_TRUE(AST);
   FileIndex Index;
   Index.updateMain(MainFile, *AST);
Index: unittests/clangd/ClangdUnitTests.cpp
===
--- unittests/clangd/ClangdUnitTests.cpp
+++ unittests/clangd/ClangdUnitTests.cpp
@@ -141,6 +141,9 @@
   )cpp");
   auto TU = TestTU::withCode(Test.code());
   TU.HeaderFilename = "assert.h"; // Suppress "not found" error.
+  TU.ClangTidyChecks =
+  "-*, bugprone-sizeof-expression, bugprone-macro-repeated-side-effects, "
+  "modernize-deprecated-headers";
   EXPECT_THAT(
   TU.build().getDiagnostics(),
   UnorderedElementsAre(
Index: clangd/tool/ClangdMain.cpp
===
--- clangd/tool/ClangdMain.cpp
+++ clangd/tool/ClangdMain.cpp
@@ -201,6 +201,12 @@
"placeholders for method parameters."),
 llvm::cl::init(CodeCompleteOptions().EnableFunctionArgSnippets));
 
+static llvm::cl::opt ClangTidyChecks(
+"clang-tidy-checks",
+llvm::cl::desc("List of clang-tidy checks to run (this will overrides "
+   ".clang-tidy files)"),
+llvm::cl::init(""), llvm::cl::Hidden);
+
 namespace {
 
 /// \brief Supports a test URI scheme with relaxed constraints for lit tests.
@@ -408,6 +414,7 @@
   CCOpts.EnableFunctionArgSnippets = EnableFunctionArgSnippets;
   CCOpts.AllScopes = AllScopesCompletion;
 
+  RealFileSystemProvider FSProvider;
   // Initialize and run ClangdLSPServer.
   // Change stdin to binary to not lose \r\n on windows.
   llvm::sys::ChangeStdinToBinary();
@@ -427,8 +434,16 @@
 PrettyPrint, InputStyle);
   }
 
+  // Create an empty clang-tidy option.
+  auto OverrideClangTidyOptions = tidy::ClangTidyOptions::getDefaults();
+  OverrideClangTidyOptions.Checks = ClangTidyChecks;
+  tidy::FileOptionsProvider ClangTidyOptProvider(
+  tidy::ClangTidyGlobalOptions(),
+  /* Default */ tidy::ClangTidyOptions::getDefaults(),
+  /* Override */ OverrideClangTidyOptions, FSProvider.getFileSystem());
+  Opts.ClangTidyOptProvider = 
   ClangdLSPServer LSPServer(
-  *TransportLayer, CCOpts, CompileCommandsDirPath,
+  *TransportLayer, FSProvider, CCOpts, 

[PATCH] D56992: [clang] Mark lambda-to-function-pointer conversion as noexcept

2019-01-21 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman edited reviewers, added: rsmith; removed: llvm-commits, 
doug.gregor.
aaron.ballman added a comment.

> Pre-C++17 standards don't have this requirement; however, they don't forbid 
> the conversion functions to have this specification either.

This change happened as a result of DR 1722 
(http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1722), so the 
correct behavior is to treat this as a requirement since the feature was 
introduced (aka, what you're doing here is correct). You should also update 
clang/www/cxx_dr_status.html with the change for the DR.




Comment at: clang/lib/Sema/SemaLambda.cpp:1231-1232
   // The conversion function is always const.
+  // C++17 also obliges it to be noexcept (which it in fact is),
+  // and previous standards don't forbid that either.
   ConvExtInfo.TypeQuals = Qualifiers();

I would update the previous comment rather than add this one. `The conversion 
function is always const with a non-throwing exception specification." or some 
such.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56992/new/

https://reviews.llvm.org/D56992



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


[PATCH] D56976: [clang] [test] Pass -ccc-install-dir in mac compilation db test

2019-01-21 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

Was confused about your comment, so it works on other systems because they 
don't rely on `argv[0]` to get the path to main executable. Got you.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56976/new/

https://reviews.llvm.org/D56976



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


[PATCH] D56976: [clang] [test] Pass -ccc-install-dir in mac compilation db test

2019-01-21 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

In D56976#1365087 , @mgorny wrote:

> Actually, it works on other systems because they don't use `argv[0]`. The 
> problem is in compilation db code using getMainExecutable() in ctor without 
> passing the real argv to it.


But it does so in all OSes and still manages find libc++, right? What's 
different for *BSD?

One possible fix is to start passing proper `argv[0]` into `getMainExecutable`, 
but my expectation is that using `clang` there was intentional: the tooling 
library tries to fallback to the system clang in that case.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56976/new/

https://reviews.llvm.org/D56976



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


[PATCH] D57012: Merge similar target diagnostics for interrupt attribute into one. NFC

2019-01-21 Thread Kristina Bessonova via Phabricator via cfe-commits
krisb created this revision.
krisb added reviewers: asl, aaron.ballman.
Herald added a subscriber: cfe-commits.

Repository:
  rC Clang

https://reviews.llvm.org/D57012

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaDeclAttr.cpp


Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -5541,14 +5541,14 @@
   }
 
   if (hasFunctionProto(D) && getFunctionOrMethodNumParams(D) != 0) {
-S.Diag(D->getLocation(), diag::warn_msp430_interrupt_attribute)
-<< 0;
+S.Diag(D->getLocation(), diag::warn_interrupt_attribute_invalid)
+<< /*MSP430*/ 1 << 0;
 return;
   }
 
   if (!getFunctionOrMethodResultType(D)->isVoidType()) {
-S.Diag(D->getLocation(), diag::warn_msp430_interrupt_attribute)
-<< 1;
+S.Diag(D->getLocation(), diag::warn_interrupt_attribute_invalid)
+<< /*MSP430*/ 1 << 1;
 return;
   }
 
@@ -5616,14 +5616,14 @@
   }
 
   if (hasFunctionProto(D) && getFunctionOrMethodNumParams(D) != 0) {
-S.Diag(D->getLocation(), diag::warn_mips_interrupt_attribute)
-<< 0;
+S.Diag(D->getLocation(), diag::warn_interrupt_attribute_invalid)
+<< /*Mips*/ 0 << 0;
 return;
   }
 
   if (!getFunctionOrMethodResultType(D)->isVoidType()) {
-S.Diag(D->getLocation(), diag::warn_mips_interrupt_attribute)
-<< 1;
+S.Diag(D->getLocation(), diag::warn_interrupt_attribute_invalid)
+<< /*Mips*/ 0 << 1;
 return;
   }
 
@@ -5770,12 +5770,14 @@
   }
 
   if (hasFunctionProto(D) && getFunctionOrMethodNumParams(D) != 0) {
-S.Diag(D->getLocation(), diag::warn_riscv_interrupt_attribute) << 0;
+S.Diag(D->getLocation(), diag::warn_interrupt_attribute_invalid)
+  << /*RISC-V*/ 2 << 0;
 return;
   }
 
   if (!getFunctionOrMethodResultType(D)->isVoidType()) {
-S.Diag(D->getLocation(), diag::warn_riscv_interrupt_attribute) << 1;
+S.Diag(D->getLocation(), diag::warn_interrupt_attribute_invalid)
+  << /*RISC-V*/ 2 << 1;
 return;
   }
 
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -261,22 +261,14 @@
 def warn_arm_interrupt_calling_convention : Warning<
"call to function without interrupt attribute could clobber interruptee's 
VFP registers">,
InGroup;
-def warn_mips_interrupt_attribute : Warning<
-   "MIPS 'interrupt' attribute only applies to functions that have "
-   "%select{no parameters|a 'void' return type}0">,
+def warn_interrupt_attribute_invalid : Warning<
+   "%select{MIPS|MSP430|RISC-V}0 'interrupt' attribute only applies to "
+   "functions that have %select{no parameters|a 'void' return type}1">,
InGroup;
 def warn_riscv_repeated_interrupt_attribute : Warning<
   "repeated RISC-V 'interrupt' attribute">, InGroup;
 def note_riscv_repeated_interrupt_attribute : Note<
   "repeated RISC-V 'interrupt' attribute is here">;
-def warn_riscv_interrupt_attribute : Warning<
-   "RISC-V 'interrupt' attribute only applies to functions that have "
-   "%select{no parameters|a 'void' return type}0">,
-   InGroup;
-def warn_msp430_interrupt_attribute : Warning<
-   "MSP430 'interrupt' attribute only applies to functions that have "
-   "%select{no parameters|a 'void' return type}0">,
-   InGroup;
 def warn_unused_parameter : Warning<"unused parameter %0">,
   InGroup, DefaultIgnore;
 def warn_unused_variable : Warning<"unused variable %0">,


Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -5541,14 +5541,14 @@
   }
 
   if (hasFunctionProto(D) && getFunctionOrMethodNumParams(D) != 0) {
-S.Diag(D->getLocation(), diag::warn_msp430_interrupt_attribute)
-<< 0;
+S.Diag(D->getLocation(), diag::warn_interrupt_attribute_invalid)
+<< /*MSP430*/ 1 << 0;
 return;
   }
 
   if (!getFunctionOrMethodResultType(D)->isVoidType()) {
-S.Diag(D->getLocation(), diag::warn_msp430_interrupt_attribute)
-<< 1;
+S.Diag(D->getLocation(), diag::warn_interrupt_attribute_invalid)
+<< /*MSP430*/ 1 << 1;
 return;
   }
 
@@ -5616,14 +5616,14 @@
   }
 
   if (hasFunctionProto(D) && getFunctionOrMethodNumParams(D) != 0) {
-S.Diag(D->getLocation(), diag::warn_mips_interrupt_attribute)
-<< 0;
+S.Diag(D->getLocation(), diag::warn_interrupt_attribute_invalid)
+<< /*Mips*/ 0 << 0;
 return;
   }
 
   if (!getFunctionOrMethodResultType(D)->isVoidType()) {
-S.Diag(D->getLocation(), diag::warn_mips_interrupt_attribute)
-<< 1;
+S.Diag(D->getLocation(), diag::warn_interrupt_attribute_invalid)
+<< /*Mips*/ 0 << 1;
 return;
   }
 
@@ -5770,12 +5770,14 @@
   }
 
   if (hasFunctionProto(D) && getFunctionOrMethodNumParams(D) != 0) {
-

[PATCH] D56267: [clangd] Interfaces for writing code actions

2019-01-21 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Can live with `applyTweak` etc, though it makes me sad.




Comment at: clangd/refactor/Tweak.h:40
+  struct Selection {
+static llvm::Optional create(llvm::StringRef File,
+llvm::StringRef Code,

ilya-biryukov wrote:
> sammccall wrote:
> > sammccall wrote:
> > > Not convinced about this helper function.
> > >  - much of it is just a passthrough to struct initialization. I think the 
> > > code calling it would be clearer if it was initialising the fields one-by 
> > > one
> > >  - the only part that's not passthrough is already a function call with a 
> > > clear name, calling it seems reasonable
> > >  - I'm not sure it makes sense to have the Range -> SourceLocation 
> > > conversion in this file, but the Tweak -> CodeAction conversion outside 
> > > this file (and not unit-testable). There's an argument to be make to keep 
> > > this file independent of LSP protocol structs, but I think that argument 
> > > applies equally to this function.
> > Expected? Passing an invalid range is always an error I guess.
> The reason I added it is to avoid duplication between in the test code and 
> `ClangdServer`, which are the only two clients we have.
> I expect this to be more useful when we add a way to traverse the subset of 
> the AST in the checks
I understand. I think as things stand both callers would be clearer (if a 
couple of lines longer) without this helper.

What the API should be in the future - happy to talk about that then.



Comment at: clangd/refactor/Tweak.h:59
+  /// A unique id of the action. The convention is to
+  /// lower-case-with-dashes for the identifier.
+  virtual TweakID id() const = 0;

ilya-biryukov wrote:
> sammccall wrote:
> > nit: one of my lessons from clang-tidy is that mapping between IDs and 
> > implementations is annoying.
> > Since IDs are 1:1 with classes, can we just require this to be the class 
> > name?
> > 
> > (If you wanted, I think you could adapt REGISTER_TWEAK so that it goes 
> > inside the class defn, and then it could provide the override of id() 
> > itself)
> That would mean no two tweaks are allowed to have the same class name. This 
> is probably fine, but somewhat contradicts C++, which would solve it with 
> namespaces.
> To be fair, there's a simple trick to grep for the id to find its class, so 
> I'd keep as is.
> 
> If we choose to adapt `REGISTER_TWEAK`, that would mean we force everyone to 
> put their tweaks **only** in `.cpp` files. That creates arbitrary 
> restrictions on how one should write a check and I'm somewhat opposed to 
> this. But happy to reconsider if you feel strongly about this.
I don't care about the details (e.g. whether `REGISTER_TWEAK` sets the name, 
asserts the name, or none of the above).

I do care that we don't add a second ID for a class that's not equal to the 
class name. This is both a bad idea from first principles and from experience 
with clang-tidy.
If this were ever to become a real problem, I'm happy to include the namespace 
name in the ID.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56267/new/

https://reviews.llvm.org/D56267



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


[PATCH] D56917: [clang] add tests to ExprMutAnalyzer that reproduced a crash in ASTMatchers

2019-01-21 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added inline comments.
This revision is now accepted and ready to land.



Comment at: unittests/Analysis/ExprMutationAnalyzerTest.cpp:1112
 
+TEST(ExprMutationAnalyzerTest, ReproduceFailure11) {
+  const std::string Reproducer =

As I understand, the tests are for the same bug - can we just keep the smaller 
one?


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56917/new/

https://reviews.llvm.org/D56917



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


[PATCH] D55256: [clangd] Support clang-tidy configuration in clangd.

2019-01-21 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added inline comments.



Comment at: clangd/tool/ClangdMain.cpp:204
 
+static llvm::cl::opt ClangTidyChecks(
+"clang-tidy-checks",

hokein wrote:
> sammccall wrote:
> > Maybe add a TODO or FIXME to respect .clang-tidy files?
> didn't get the point of the comment -- in this patch, clangd will read 
> configurations from `.clang-tidy` files (`FileOptionsProvider` provides this 
> functionality). This command-line flag is used to overwrite the `.clang-tidy` 
> configurations,.
Ah, I missed that FileOptionsProvider was actually used. Can you update the 
desc to something like "List of clang-tidy checks to run (overrides .clang-tidy 
files)"?



Comment at: clangd/tool/ClangdMain.cpp:435
 
+  RealFileSystemProvider FSProvider;
+  // Create an empty option.

please move this up to a section near the other feature configuration stuff. 
e.g. below where CCOpts is initialized.

The Transport/ClangdLSPServer initialization is more closely related.



Comment at: clangd/tool/ClangdMain.cpp:438
+  auto OverrideClangTidyOptions = tidy::ClangTidyOptions::getDefaults();
+  if (!ClangTidyChecks.empty())
+OverrideClangTidyOptions.Checks = ClangTidyChecks;

This prevents `-clang-tidy-checks=` from disabling all checks.
use ClangTidyChecks.getNumOccurrences() instead?



Comment at: unittests/clangd/TestTU.cpp:39
+  Inputs.ClangTidyOpts = tidy::ClangTidyOptions::getDefaults();
+  Inputs.ClangTidyOpts.Checks =
+  "-*, bugprone-sizeof-expression, bugprone-macro-repeated-side-effects, "

Make this list an optional attribute to TestTU instead of hard-coding?


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55256/new/

https://reviews.llvm.org/D55256



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


[PATCH] D55256: [clangd] Support clang-tidy configuration in clangd.

2019-01-21 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clangd/ClangdLSPServer.h:132
 
-  RealFileSystemProvider FSProvider;
   /// Options used for code completion

sammccall wrote:
> ilya-biryukov wrote:
> > Could we instead call `getRealFS()` when we try to initialize a clang-tidy 
> > options provider in `main()` and avoid changing this?
> > To avoid adding extra non-real-fs "modes of operation" to 
> > `ClangdLSPServer`. Unless you see other uses for this.
> We already have out-of-tree modifications to ClangdLSPServer to use non-real 
> FSes.
> Given that, I think this change is OK... though better still might be to move 
> it into `ClangdServer::Options`
Yes, this is the main reason I did this change.



Comment at: clangd/ClangdUnit.h:83
+IntrusiveRefCntPtr VFS,
+tidy::ClangTidyOptions ClangTidyOpts);
 

sammccall wrote:
> Passing by value is OK here if deliberate, but let's try to avoid too many 
> random copies below.
changed to `const &`



Comment at: clangd/tool/ClangdMain.cpp:204
 
+static llvm::cl::opt ClangTidyChecks(
+"clang-tidy-checks",

sammccall wrote:
> Maybe add a TODO or FIXME to respect .clang-tidy files?
didn't get the point of the comment -- in this patch, clangd will read 
configurations from `.clang-tidy` files (`FileOptionsProvider` provides this 
functionality). This command-line flag is used to overwrite the `.clang-tidy` 
configurations,.


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55256/new/

https://reviews.llvm.org/D55256



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


[PATCH] D55256: [clangd] Support clang-tidy configuration in clangd.

2019-01-21 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 182768.
hokein marked 7 inline comments as done.
hokein added a comment.

Address review comments.


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55256/new/

https://reviews.llvm.org/D55256

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdLSPServer.h
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/ClangdUnit.cpp
  clangd/ClangdUnit.h
  clangd/tool/ClangdMain.cpp
  unittests/clangd/FileIndexTests.cpp
  unittests/clangd/TUSchedulerTests.cpp
  unittests/clangd/TestTU.cpp

Index: unittests/clangd/TestTU.cpp
===
--- unittests/clangd/TestTU.cpp
+++ unittests/clangd/TestTU.cpp
@@ -35,6 +35,10 @@
   Inputs.CompileCommand.Directory = testRoot();
   Inputs.Contents = Code;
   Inputs.FS = buildTestFS({{FullFilename, Code}, {FullHeaderName, HeaderCode}});
+  Inputs.ClangTidyOpts = tidy::ClangTidyOptions::getDefaults();
+  Inputs.ClangTidyOpts.Checks =
+  "-*, bugprone-sizeof-expression, bugprone-macro-repeated-side-effects, "
+  "modernize-deprecated-headers";
   auto PCHs = std::make_shared();
   auto CI = buildCompilerInvocation(Inputs);
   assert(CI && "Failed to build compilation invocation.");
Index: unittests/clangd/TUSchedulerTests.cpp
===
--- unittests/clangd/TUSchedulerTests.cpp
+++ unittests/clangd/TUSchedulerTests.cpp
@@ -38,7 +38,8 @@
 protected:
   ParseInputs getInputs(PathRef File, std::string Contents) {
 return ParseInputs{*CDB.getCompileCommand(File),
-   buildTestFS(Files, Timestamps), std::move(Contents)};
+   buildTestFS(Files, Timestamps), std::move(Contents),
+   tidy::ClangTidyOptions::getDefaults()};
   }
 
   void updateWithCallback(TUScheduler , PathRef File,
Index: unittests/clangd/FileIndexTests.cpp
===
--- unittests/clangd/FileIndexTests.cpp
+++ unittests/clangd/FileIndexTests.cpp
@@ -363,7 +363,8 @@
   auto AST =
   ParsedAST::build(createInvocationFromCommandLine(Cmd), PreambleData,
llvm::MemoryBuffer::getMemBufferCopy(Main.code()),
-   std::make_shared(), PI.FS);
+   std::make_shared(), PI.FS,
+   tidy::ClangTidyOptions::getDefaults());
   ASSERT_TRUE(AST);
   FileIndex Index;
   Index.updateMain(MainFile, *AST);
Index: clangd/tool/ClangdMain.cpp
===
--- clangd/tool/ClangdMain.cpp
+++ clangd/tool/ClangdMain.cpp
@@ -201,6 +201,11 @@
"placeholders for method parameters."),
 llvm::cl::init(CodeCompleteOptions().EnableFunctionArgSnippets));
 
+static llvm::cl::opt ClangTidyChecks(
+"clang-tidy-checks",
+llvm::cl::desc("A list of clang-tidy checks running in clangd"),
+llvm::cl::init(""), llvm::cl::Hidden);
+
 namespace {
 
 /// \brief Supports a test URI scheme with relaxed constraints for lit tests.
@@ -427,8 +432,18 @@
 PrettyPrint, InputStyle);
   }
 
+  RealFileSystemProvider FSProvider;
+  // Create an empty option.
+  auto OverrideClangTidyOptions = tidy::ClangTidyOptions::getDefaults();
+  if (!ClangTidyChecks.empty())
+OverrideClangTidyOptions.Checks = ClangTidyChecks;
+  tidy::FileOptionsProvider ClangTidyOptProvider(
+  tidy::ClangTidyGlobalOptions(),
+  /* Default */ tidy::ClangTidyOptions::getDefaults(),
+  /* Override */ OverrideClangTidyOptions, FSProvider.getFileSystem());
+  Opts.ClangTidyOptProvider = 
   ClangdLSPServer LSPServer(
-  *TransportLayer, CCOpts, CompileCommandsDirPath,
+  *TransportLayer, FSProvider, CCOpts, CompileCommandsDirPath,
   /*UseDirBasedCDB=*/CompileArgsFrom == FilesystemCompileArgs, Opts);
   llvm::set_thread_name("clangd.main");
   return LSPServer.run() ? 0
Index: clangd/ClangdUnit.h
===
--- clangd/ClangdUnit.h
+++ clangd/ClangdUnit.h
@@ -9,6 +9,7 @@
 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_CLANGDUNIT_H
 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_CLANGDUNIT_H
 
+#include "../clang-tidy/ClangTidyOptions.h"
 #include "Diagnostics.h"
 #include "FS.h"
 #include "Function.h"
@@ -64,6 +65,7 @@
   tooling::CompileCommand CompileCommand;
   IntrusiveRefCntPtr FS;
   std::string Contents;
+  tidy::ClangTidyOptions ClangTidyOpts;
 };
 
 /// Stores and provides access to parsed AST.
@@ -76,7 +78,8 @@
 std::shared_ptr Preamble,
 std::unique_ptr Buffer,
 std::shared_ptr PCHs,
-IntrusiveRefCntPtr VFS);
+IntrusiveRefCntPtr VFS,
+const tidy::ClangTidyOptions );
 
   ParsedAST(ParsedAST &);
   ParsedAST =(ParsedAST &);
Index: clangd/ClangdUnit.cpp
===
--- clangd/ClangdUnit.cpp
+++ clangd/ClangdUnit.cpp
@@ -132,6 +132,9 

[PATCH] D56976: [clang] [test] Pass -ccc-install-dir in mac compilation db test

2019-01-21 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

In D56976#1365001 , @ilya-biryukov 
wrote:

> LGTM to unbreak the tests on *BSD, but could you please leave a comment?
>  It would probably be best to take `argv[0]` into account on *BSD systems as 
> well (possibly only if `clang` could not be found).
>
> At least if that's the behaviour on **all** other systems.


Actually, it works on other systems because they don't use `argv[0]`. The 
problem is in compilation db code using getMainExecutable() in ctor without 
passing the real argv to it.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56976/new/

https://reviews.llvm.org/D56976



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


[PATCH] D56852: [AArch64] Use LL for 64-bit arguments

2019-01-21 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL351740: [AArch64] Use LL for 64-bit intrinsic arguments 
(authored by sam_parker, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D56852?vs=182481=182766#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56852/new/

https://reviews.llvm.org/D56852

Files:
  cfe/trunk/include/clang/Basic/BuiltinsAArch64.def
  cfe/trunk/test/CodeGen/arm64-crc32.c
  cfe/trunk/test/CodeGen/builtins-arm64.c

Index: cfe/trunk/test/CodeGen/arm64-crc32.c
===
--- cfe/trunk/test/CodeGen/arm64-crc32.c
+++ cfe/trunk/test/CodeGen/arm64-crc32.c
@@ -1,54 +1,57 @@
 // REQUIRES: aarch64-registered-target
 // RUN: %clang_cc1 -triple arm64-none-linux-gnu \
 // RUN:  -disable-O0-optnone -S -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s
+// RUN: %clang_cc1 -triple aarch64-windows \
+// RUN:  -disable-O0-optnone -S -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s
+#include 
 
-int crc32b(int a, char b)
+uint32_t crc32b(uint32_t a, uint8_t b)
 {
 return __builtin_arm_crc32b(a,b);
 // CHECK: [[T0:%[0-9]+]] = zext i8 %b to i32
 // CHECK: call i32 @llvm.aarch64.crc32b(i32 %a, i32 [[T0]])
 }
 
-int crc32cb(int a, char b)
+uint32_t crc32cb(uint32_t a, uint8_t b)
 {
 return __builtin_arm_crc32cb(a,b);
 // CHECK: [[T0:%[0-9]+]] = zext i8 %b to i32
 // CHECK: call i32 @llvm.aarch64.crc32cb(i32 %a, i32 [[T0]])
 }
 
-int crc32h(int a, short b)
+uint32_t crc32h(uint32_t a, uint16_t b)
 {
 return __builtin_arm_crc32h(a,b);
 // CHECK: [[T0:%[0-9]+]] = zext i16 %b to i32
 // CHECK: call i32 @llvm.aarch64.crc32h(i32 %a, i32 [[T0]])
 }
 
-int crc32ch(int a, short b)
+uint32_t crc32ch(uint32_t a, uint16_t b)
 {
 return __builtin_arm_crc32ch(a,b);
 // CHECK: [[T0:%[0-9]+]] = zext i16 %b to i32
 // CHECK: call i32 @llvm.aarch64.crc32ch(i32 %a, i32 [[T0]])
 }
 
-int crc32w(int a, int b)
+uint32_t crc32w(uint32_t a, uint32_t b)
 {
 return __builtin_arm_crc32w(a,b);
 // CHECK: call i32 @llvm.aarch64.crc32w(i32 %a, i32 %b)
 }
 
-int crc32cw(int a, int b)
+uint32_t crc32cw(uint32_t a, uint32_t b)
 {
 return __builtin_arm_crc32cw(a,b);
 // CHECK: call i32 @llvm.aarch64.crc32cw(i32 %a, i32 %b)
 }
 
-int crc32d(int a, long b)
+uint32_t crc32d(uint32_t a, uint64_t b)
 {
 return __builtin_arm_crc32d(a,b);
 // CHECK: call i32 @llvm.aarch64.crc32x(i32 %a, i64 %b)
 }
 
-int crc32cd(int a, long b)
+uint32_t crc32cd(uint32_t a, uint64_t b)
 {
 return __builtin_arm_crc32cd(a,b);
 // CHECK: call i32 @llvm.aarch64.crc32cx(i32 %a, i64 %b)
Index: cfe/trunk/test/CodeGen/builtins-arm64.c
===
--- cfe/trunk/test/CodeGen/builtins-arm64.c
+++ cfe/trunk/test/CodeGen/builtins-arm64.c
@@ -1,4 +1,6 @@
 // RUN: %clang_cc1 -triple arm64-unknown-linux -disable-O0-optnone -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s
+// RUN: %clang_cc1 -triple aarch64-windows -disable-O0-optnone -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s
+#include 
 
 void f0(void *a, void *b) {
 	__clear_cache(a,b);
@@ -55,7 +57,7 @@
   return __builtin_arm_rsr("1:2:3:4:5");
 }
 
-unsigned long rsr64() {
+uint64_t rsr64() {
   // CHECK: call i64 @llvm.read_register.i64(metadata ![[M0:[0-9]]])
   return __builtin_arm_rsr64("1:2:3:4:5");
 }
@@ -72,7 +74,7 @@
   __builtin_arm_wsr("1:2:3:4:5", v);
 }
 
-void wsr64(unsigned long v) {
+void wsr64(uint64_t v) {
   // CHECK: call void @llvm.write_register.i64(metadata ![[M0:[0-9]]], i64 %v)
   __builtin_arm_wsr64("1:2:3:4:5", v);
 }
Index: cfe/trunk/include/clang/Basic/BuiltinsAArch64.def
===
--- cfe/trunk/include/clang/Basic/BuiltinsAArch64.def
+++ cfe/trunk/include/clang/Basic/BuiltinsAArch64.def
@@ -32,7 +32,7 @@
 
 // Bit manipulation
 BUILTIN(__builtin_arm_rbit, "UiUi", "nc")
-BUILTIN(__builtin_arm_rbit64, "LUiLUi", "nc")
+BUILTIN(__builtin_arm_rbit64, "LLUiLLUi", "nc")
 
 // HINT
 BUILTIN(__builtin_arm_nop, "v", "")
@@ -49,8 +49,8 @@
 BUILTIN(__builtin_arm_crc32ch, "UiUiUs", "nc")
 BUILTIN(__builtin_arm_crc32w, "UiUiUi", "nc")
 BUILTIN(__builtin_arm_crc32cw, "UiUiUi", "nc")
-BUILTIN(__builtin_arm_crc32d, "UiUiLUi", "nc")
-BUILTIN(__builtin_arm_crc32cd, "UiUiLUi", "nc")
+BUILTIN(__builtin_arm_crc32d, "UiUiLLUi", "nc")
+BUILTIN(__builtin_arm_crc32cd, "UiUiLLUi", "nc")
 
 // Memory barrier
 BUILTIN(__builtin_arm_dmb, "vUi", "nc")
@@ -62,10 +62,10 @@
 
 // System Registers
 BUILTIN(__builtin_arm_rsr, "UicC*", "nc")
-BUILTIN(__builtin_arm_rsr64, "LUicC*", "nc")
+BUILTIN(__builtin_arm_rsr64, "LLUicC*", "nc")
 BUILTIN(__builtin_arm_rsrp, "v*cC*", "nc")
 BUILTIN(__builtin_arm_wsr, "vcC*Ui", "nc")
-BUILTIN(__builtin_arm_wsr64, "vcC*LUi", "nc")
+BUILTIN(__builtin_arm_wsr64, "vcC*LLUi", "nc")
 BUILTIN(__builtin_arm_wsrp, "vcC*vC*", 

r351740 - [AArch64] Use LL for 64-bit intrinsic arguments

2019-01-21 Thread Sam Parker via cfe-commits
Author: sam_parker
Date: Mon Jan 21 03:01:05 2019
New Revision: 351740

URL: http://llvm.org/viewvc/llvm-project?rev=351740=rev
Log:
[AArch64] Use LL for 64-bit intrinsic arguments

The ACLE states that 64-bit crc32, wsr, rsr and rbit operands are
uint64_t so we should have the clang builtin match this description
- which is what we already do for AArch32.

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

Modified:
cfe/trunk/include/clang/Basic/BuiltinsAArch64.def
cfe/trunk/test/CodeGen/arm64-crc32.c
cfe/trunk/test/CodeGen/builtins-arm64.c

Modified: cfe/trunk/include/clang/Basic/BuiltinsAArch64.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsAArch64.def?rev=351740=351739=351740=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsAArch64.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsAArch64.def Mon Jan 21 03:01:05 2019
@@ -32,7 +32,7 @@ BUILTIN(__builtin_arm_clrex, "v", "")
 
 // Bit manipulation
 BUILTIN(__builtin_arm_rbit, "UiUi", "nc")
-BUILTIN(__builtin_arm_rbit64, "LUiLUi", "nc")
+BUILTIN(__builtin_arm_rbit64, "LLUiLLUi", "nc")
 
 // HINT
 BUILTIN(__builtin_arm_nop, "v", "")
@@ -49,8 +49,8 @@ BUILTIN(__builtin_arm_crc32h, "UiUiUs",
 BUILTIN(__builtin_arm_crc32ch, "UiUiUs", "nc")
 BUILTIN(__builtin_arm_crc32w, "UiUiUi", "nc")
 BUILTIN(__builtin_arm_crc32cw, "UiUiUi", "nc")
-BUILTIN(__builtin_arm_crc32d, "UiUiLUi", "nc")
-BUILTIN(__builtin_arm_crc32cd, "UiUiLUi", "nc")
+BUILTIN(__builtin_arm_crc32d, "UiUiLLUi", "nc")
+BUILTIN(__builtin_arm_crc32cd, "UiUiLLUi", "nc")
 
 // Memory barrier
 BUILTIN(__builtin_arm_dmb, "vUi", "nc")
@@ -62,10 +62,10 @@ BUILTIN(__builtin_arm_prefetch, "vvC*UiU
 
 // System Registers
 BUILTIN(__builtin_arm_rsr, "UicC*", "nc")
-BUILTIN(__builtin_arm_rsr64, "LUicC*", "nc")
+BUILTIN(__builtin_arm_rsr64, "LLUicC*", "nc")
 BUILTIN(__builtin_arm_rsrp, "v*cC*", "nc")
 BUILTIN(__builtin_arm_wsr, "vcC*Ui", "nc")
-BUILTIN(__builtin_arm_wsr64, "vcC*LUi", "nc")
+BUILTIN(__builtin_arm_wsr64, "vcC*LLUi", "nc")
 BUILTIN(__builtin_arm_wsrp, "vcC*vC*", "nc")
 
 // MSVC

Modified: cfe/trunk/test/CodeGen/arm64-crc32.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/arm64-crc32.c?rev=351740=351739=351740=diff
==
--- cfe/trunk/test/CodeGen/arm64-crc32.c (original)
+++ cfe/trunk/test/CodeGen/arm64-crc32.c Mon Jan 21 03:01:05 2019
@@ -1,54 +1,57 @@
 // REQUIRES: aarch64-registered-target
 // RUN: %clang_cc1 -triple arm64-none-linux-gnu \
 // RUN:  -disable-O0-optnone -S -emit-llvm -o - %s | opt -S -mem2reg | 
FileCheck %s
+// RUN: %clang_cc1 -triple aarch64-windows \
+// RUN:  -disable-O0-optnone -S -emit-llvm -o - %s | opt -S -mem2reg | 
FileCheck %s
+#include 
 
-int crc32b(int a, char b)
+uint32_t crc32b(uint32_t a, uint8_t b)
 {
 return __builtin_arm_crc32b(a,b);
 // CHECK: [[T0:%[0-9]+]] = zext i8 %b to i32
 // CHECK: call i32 @llvm.aarch64.crc32b(i32 %a, i32 [[T0]])
 }
 
-int crc32cb(int a, char b)
+uint32_t crc32cb(uint32_t a, uint8_t b)
 {
 return __builtin_arm_crc32cb(a,b);
 // CHECK: [[T0:%[0-9]+]] = zext i8 %b to i32
 // CHECK: call i32 @llvm.aarch64.crc32cb(i32 %a, i32 [[T0]])
 }
 
-int crc32h(int a, short b)
+uint32_t crc32h(uint32_t a, uint16_t b)
 {
 return __builtin_arm_crc32h(a,b);
 // CHECK: [[T0:%[0-9]+]] = zext i16 %b to i32
 // CHECK: call i32 @llvm.aarch64.crc32h(i32 %a, i32 [[T0]])
 }
 
-int crc32ch(int a, short b)
+uint32_t crc32ch(uint32_t a, uint16_t b)
 {
 return __builtin_arm_crc32ch(a,b);
 // CHECK: [[T0:%[0-9]+]] = zext i16 %b to i32
 // CHECK: call i32 @llvm.aarch64.crc32ch(i32 %a, i32 [[T0]])
 }
 
-int crc32w(int a, int b)
+uint32_t crc32w(uint32_t a, uint32_t b)
 {
 return __builtin_arm_crc32w(a,b);
 // CHECK: call i32 @llvm.aarch64.crc32w(i32 %a, i32 %b)
 }
 
-int crc32cw(int a, int b)
+uint32_t crc32cw(uint32_t a, uint32_t b)
 {
 return __builtin_arm_crc32cw(a,b);
 // CHECK: call i32 @llvm.aarch64.crc32cw(i32 %a, i32 %b)
 }
 
-int crc32d(int a, long b)
+uint32_t crc32d(uint32_t a, uint64_t b)
 {
 return __builtin_arm_crc32d(a,b);
 // CHECK: call i32 @llvm.aarch64.crc32x(i32 %a, i64 %b)
 }
 
-int crc32cd(int a, long b)
+uint32_t crc32cd(uint32_t a, uint64_t b)
 {
 return __builtin_arm_crc32cd(a,b);
 // CHECK: call i32 @llvm.aarch64.crc32cx(i32 %a, i64 %b)

Modified: cfe/trunk/test/CodeGen/builtins-arm64.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins-arm64.c?rev=351740=351739=351740=diff
==
--- cfe/trunk/test/CodeGen/builtins-arm64.c (original)
+++ cfe/trunk/test/CodeGen/builtins-arm64.c Mon Jan 21 03:01:05 2019
@@ -1,4 +1,6 @@
 // RUN: %clang_cc1 -triple arm64-unknown-linux -disable-O0-optnone -emit-llvm 
-o - %s | opt -S -mem2reg | FileCheck %s
+// RUN: %clang_cc1 

[PATCH] D56841: [clangd] Filter out plugin related flags and move all commandline manipulations into OverlayCDB.

2019-01-21 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 182765.
kadircet marked 3 inline comments as done.
kadircet added a comment.

Address comments


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56841/new/

https://reviews.llvm.org/D56841

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdServer.cpp
  clangd/GlobalCompilationDatabase.cpp
  clangd/GlobalCompilationDatabase.h
  clangd/index/Background.cpp
  clangd/index/Background.h
  unittests/clangd/BackgroundIndexTests.cpp
  unittests/clangd/ClangdTests.cpp
  unittests/clangd/GlobalCompilationDatabaseTests.cpp

Index: unittests/clangd/GlobalCompilationDatabaseTests.cpp
===
--- unittests/clangd/GlobalCompilationDatabaseTests.cpp
+++ unittests/clangd/GlobalCompilationDatabaseTests.cpp
@@ -65,7 +65,7 @@
 };
 
 TEST_F(OverlayCDBTest, GetCompileCommand) {
-  OverlayCDB CDB(Base.get());
+  OverlayCDB CDB(Base.get(), {}, std::string(""));
   EXPECT_EQ(CDB.getCompileCommand(testPath("foo.cc")),
 Base->getCompileCommand(testPath("foo.cc")));
   EXPECT_EQ(CDB.getCompileCommand(testPath("missing.cc")), llvm::None);
@@ -85,7 +85,7 @@
 }
 
 TEST_F(OverlayCDBTest, NoBase) {
-  OverlayCDB CDB(nullptr, {"-DA=6"});
+  OverlayCDB CDB(nullptr, {"-DA=6"}, std::string(""));
   EXPECT_EQ(CDB.getCompileCommand(testPath("bar.cc")), None);
   auto Override = cmd(testPath("bar.cc"), "-DA=5");
   CDB.setCompileCommand(testPath("bar.cc"), Override);
Index: unittests/clangd/ClangdTests.cpp
===
--- unittests/clangd/ClangdTests.cpp
+++ unittests/clangd/ClangdTests.cpp
@@ -10,6 +10,7 @@
 #include "Annotations.h"
 #include "ClangdLSPServer.h"
 #include "ClangdServer.h"
+#include "GlobalCompilationDatabase.h"
 #include "Matchers.h"
 #include "SyncAPI.h"
 #include "TestFS.h"
@@ -1037,6 +1038,28 @@
 }
 #endif
 
+TEST_F(ClangdVFSTest, FlagsWithPlugins) {
+  MockFSProvider FS;
+  ErrorCheckingDiagConsumer DiagConsumer;
+  MockCompilationDatabase CDB;
+  CDB.ExtraClangFlags = {
+  "-Xclang",
+  "-add-plugin",
+  "-Xclang",
+  "random-plugin",
+  };
+  OverlayCDB OCDB();
+  ClangdServer Server(OCDB, FS, DiagConsumer, ClangdServer::optsForTest());
+
+  auto FooCpp = testPath("foo.cpp");
+  const auto SourceContents = "int main() { return 0; }";
+  FS.Files[FooCpp] = FooCpp;
+  Server.addDocument(FooCpp, SourceContents);
+  auto Result = dumpASTWithoutMemoryLocs(Server, FooCpp);
+  EXPECT_TRUE(Server.blockUntilIdleForTest()) << "Waiting for diagnostics";
+  EXPECT_NE(Result, "");
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: unittests/clangd/BackgroundIndexTests.cpp
===
--- unittests/clangd/BackgroundIndexTests.cpp
+++ unittests/clangd/BackgroundIndexTests.cpp
@@ -76,7 +76,7 @@
   size_t CacheHits = 0;
   MemoryShardStorage MSS(Storage, CacheHits);
   OverlayCDB CDB(/*Base=*/nullptr);
-  BackgroundIndex Idx(Context::empty(), "", FS, CDB,
+  BackgroundIndex Idx(Context::empty(), FS, CDB,
   [&](llvm::StringRef) { return  });
 
   tooling::CompileCommand Cmd;
@@ -113,7 +113,7 @@
   size_t CacheHits = 0;
   MemoryShardStorage MSS(Storage, CacheHits);
   OverlayCDB CDB(/*Base=*/nullptr);
-  BackgroundIndex Idx(Context::empty(), "", FS, CDB,
+  BackgroundIndex Idx(Context::empty(), FS, CDB,
   [&](llvm::StringRef) { return  });
 
   tooling::CompileCommand Cmd;
@@ -168,7 +168,7 @@
   // Check nothing is loaded from Storage, but A.cc and A.h has been stored.
   {
 OverlayCDB CDB(/*Base=*/nullptr);
-BackgroundIndex Idx(Context::empty(), "", FS, CDB,
+BackgroundIndex Idx(Context::empty(), FS, CDB,
 [&](llvm::StringRef) { return  });
 CDB.setCompileCommand(testPath("root/A.cc"), Cmd);
 ASSERT_TRUE(Idx.blockUntilIdleForTest());
@@ -178,7 +178,7 @@
 
   {
 OverlayCDB CDB(/*Base=*/nullptr);
-BackgroundIndex Idx(Context::empty(), "", FS, CDB,
+BackgroundIndex Idx(Context::empty(), FS, CDB,
 [&](llvm::StringRef) { return  });
 CDB.setCompileCommand(testPath("root"), Cmd);
 ASSERT_TRUE(Idx.blockUntilIdleForTest());
@@ -224,7 +224,7 @@
   Cmd.CommandLine = {"clang++", testPath("root/A.cc")};
   {
 OverlayCDB CDB(/*Base=*/nullptr);
-BackgroundIndex Idx(Context::empty(), "", FS, CDB,
+BackgroundIndex Idx(Context::empty(), FS, CDB,
 [&](llvm::StringRef) { return  });
 CDB.setCompileCommand(testPath("root/A.cc"), Cmd);
 ASSERT_TRUE(Idx.blockUntilIdleForTest());
@@ -262,7 +262,7 @@
   MemoryShardStorage MSS(Storage, CacheHits);
   OverlayCDB CDB(/*Base=*/nullptr);
   BackgroundIndex Idx(
-  Context::empty(), "", FS, CDB, [&](llvm::StringRef) { return  },
+  Context::empty(), FS, CDB, [&](llvm::StringRef) { return  },
   /*BuildIndexPeriodMs=*/500);
 
   

[PATCH] D56841: [clangd] Filter out plugin related flags and move all commandline manipulations into OverlayCDB.

2019-01-21 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clangd/GlobalCompilationDatabase.cpp:24
+void AdjustArguments(tooling::CompileCommand ,
+ const std::string ) {
+  // Strip plugin related command line arguments. Clangd does

ilya-biryukov wrote:
> kadircet wrote:
> > ilya-biryukov wrote:
> > > NIT: use `StringRef`
> > Need a string for the concatenation below, when pushing to vector. 
> > Otherwise we get a Twine
> Why not call `.str()` on a Twine?
Sure it is also an option but didn't think it would look any better, but there 
you go.


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56841/new/

https://reviews.llvm.org/D56841



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


[PATCH] D51178: [ASTImporter] Add test for importing anonymous namespaces.

2019-01-21 Thread Raphael Isemann via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC351739: [ASTImporter] Add test for importing anonymous 
namespaces. (authored by teemperor, committed by ).

Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D51178/new/

https://reviews.llvm.org/D51178

Files:
  test/Import/cxx-anon-namespace/Inputs/F.cpp
  test/Import/cxx-anon-namespace/test.cpp


Index: test/Import/cxx-anon-namespace/Inputs/F.cpp
===
--- test/Import/cxx-anon-namespace/Inputs/F.cpp
+++ test/Import/cxx-anon-namespace/Inputs/F.cpp
@@ -0,0 +1,25 @@
+namespace {
+void func1() {
+}
+} // namespace
+
+namespace test_namespace1 {
+namespace {
+void func2() {}
+} // namespace
+} // namespace test_namespace1
+
+namespace test_namespace2 {
+namespace {
+namespace test_namespace3 {
+void func3() {}
+} // namespace test_namespace3
+} // namespace
+} // namespace test_namespace2
+
+namespace {
+namespace {
+void func4() {
+}
+} // namespace
+} // namespace
Index: test/Import/cxx-anon-namespace/test.cpp
===
--- test/Import/cxx-anon-namespace/test.cpp
+++ test/Import/cxx-anon-namespace/test.cpp
@@ -0,0 +1,45 @@
+// RUN: clang-import-test -dump-ast -import %S/Inputs/F.cpp -expression %s | 
FileCheck %s
+
+// The implicit UsingDirectiveDecls for the anonymous namespaces are created 
by the Sema.
+
+// CHECK: NamespaceDecl
+// The nested anonymous namespace.
+// CHECK-NEXT: NamespaceDecl
+// CHECK: FunctionDecl
+// CHECK-SAME: func4
+// CHECK-NEXT: CompoundStmt
+// This is for the nested anonymous namespace.
+// CHECK-NEXT: UsingDirectiveDecl
+// CHECK-SAME: ''
+// CHECK: FunctionDecl
+// CHECK-SAME: func1
+// CHECK-NEXT: CompoundStmt
+// CHECK-NEXT: UsingDirectiveDecl
+// CHECK-SAME: ''
+
+// CHECK: NamespaceDecl
+// CHECK-SAME: test_namespace1
+// CHECK-NEXT: NamespaceDecl
+// CHECK: FunctionDecl
+// CHECK-SAME: func2
+// CHECK-NEXT: CompoundStmt
+// CHECK-NEXT: UsingDirectiveDecl
+// CHECK-SAME: ''
+
+// CHECK-NEXT: NamespaceDecl
+// CHECK-SAME: test_namespace2
+// CHECK-NEXT: NamespaceDecl
+// CHECK-NEXT: NamespaceDecl
+// CHECK-SAME: test_namespace3
+// CHECK: FunctionDecl
+// CHECK-SAME: func3
+// CHECK-NEXT: CompoundStmt
+// CHECK-NEXT: UsingDirectiveDecl
+// CHECK-SAME: ''
+
+void expr() {
+  func1();
+  test_namespace1::func2();
+  test_namespace2::test_namespace3::func3();
+  func4();
+}


Index: test/Import/cxx-anon-namespace/Inputs/F.cpp
===
--- test/Import/cxx-anon-namespace/Inputs/F.cpp
+++ test/Import/cxx-anon-namespace/Inputs/F.cpp
@@ -0,0 +1,25 @@
+namespace {
+void func1() {
+}
+} // namespace
+
+namespace test_namespace1 {
+namespace {
+void func2() {}
+} // namespace
+} // namespace test_namespace1
+
+namespace test_namespace2 {
+namespace {
+namespace test_namespace3 {
+void func3() {}
+} // namespace test_namespace3
+} // namespace
+} // namespace test_namespace2
+
+namespace {
+namespace {
+void func4() {
+}
+} // namespace
+} // namespace
Index: test/Import/cxx-anon-namespace/test.cpp
===
--- test/Import/cxx-anon-namespace/test.cpp
+++ test/Import/cxx-anon-namespace/test.cpp
@@ -0,0 +1,45 @@
+// RUN: clang-import-test -dump-ast -import %S/Inputs/F.cpp -expression %s | FileCheck %s
+
+// The implicit UsingDirectiveDecls for the anonymous namespaces are created by the Sema.
+
+// CHECK: NamespaceDecl
+// The nested anonymous namespace.
+// CHECK-NEXT: NamespaceDecl
+// CHECK: FunctionDecl
+// CHECK-SAME: func4
+// CHECK-NEXT: CompoundStmt
+// This is for the nested anonymous namespace.
+// CHECK-NEXT: UsingDirectiveDecl
+// CHECK-SAME: ''
+// CHECK: FunctionDecl
+// CHECK-SAME: func1
+// CHECK-NEXT: CompoundStmt
+// CHECK-NEXT: UsingDirectiveDecl
+// CHECK-SAME: ''
+
+// CHECK: NamespaceDecl
+// CHECK-SAME: test_namespace1
+// CHECK-NEXT: NamespaceDecl
+// CHECK: FunctionDecl
+// CHECK-SAME: func2
+// CHECK-NEXT: CompoundStmt
+// CHECK-NEXT: UsingDirectiveDecl
+// CHECK-SAME: ''
+
+// CHECK-NEXT: NamespaceDecl
+// CHECK-SAME: test_namespace2
+// CHECK-NEXT: NamespaceDecl
+// CHECK-NEXT: NamespaceDecl
+// CHECK-SAME: test_namespace3
+// CHECK: FunctionDecl
+// CHECK-SAME: func3
+// CHECK-NEXT: CompoundStmt
+// CHECK-NEXT: UsingDirectiveDecl
+// CHECK-SAME: ''
+
+void expr() {
+  func1();
+  test_namespace1::func2();
+  test_namespace2::test_namespace3::func3();
+  func4();
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r351739 - [ASTImporter] Add test for importing anonymous namespaces.

2019-01-21 Thread Raphael Isemann via cfe-commits
Author: teemperor
Date: Mon Jan 21 02:14:31 2019
New Revision: 351739

URL: http://llvm.org/viewvc/llvm-project?rev=351739=rev
Log:
[ASTImporter] Add test for importing anonymous namespaces.

Reviewers: a.sidorin, a_sidorin

Reviewed By: a_sidorin

Subscribers: a_sidorin, martong, cfe-commits

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

Added:
cfe/trunk/test/Import/cxx-anon-namespace/
cfe/trunk/test/Import/cxx-anon-namespace/Inputs/
cfe/trunk/test/Import/cxx-anon-namespace/Inputs/F.cpp
cfe/trunk/test/Import/cxx-anon-namespace/test.cpp

Added: cfe/trunk/test/Import/cxx-anon-namespace/Inputs/F.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/cxx-anon-namespace/Inputs/F.cpp?rev=351739=auto
==
--- cfe/trunk/test/Import/cxx-anon-namespace/Inputs/F.cpp (added)
+++ cfe/trunk/test/Import/cxx-anon-namespace/Inputs/F.cpp Mon Jan 21 02:14:31 
2019
@@ -0,0 +1,25 @@
+namespace {
+void func1() {
+}
+} // namespace
+
+namespace test_namespace1 {
+namespace {
+void func2() {}
+} // namespace
+} // namespace test_namespace1
+
+namespace test_namespace2 {
+namespace {
+namespace test_namespace3 {
+void func3() {}
+} // namespace test_namespace3
+} // namespace
+} // namespace test_namespace2
+
+namespace {
+namespace {
+void func4() {
+}
+} // namespace
+} // namespace

Added: cfe/trunk/test/Import/cxx-anon-namespace/test.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/cxx-anon-namespace/test.cpp?rev=351739=auto
==
--- cfe/trunk/test/Import/cxx-anon-namespace/test.cpp (added)
+++ cfe/trunk/test/Import/cxx-anon-namespace/test.cpp Mon Jan 21 02:14:31 2019
@@ -0,0 +1,45 @@
+// RUN: clang-import-test -dump-ast -import %S/Inputs/F.cpp -expression %s | 
FileCheck %s
+
+// The implicit UsingDirectiveDecls for the anonymous namespaces are created 
by the Sema.
+
+// CHECK: NamespaceDecl
+// The nested anonymous namespace.
+// CHECK-NEXT: NamespaceDecl
+// CHECK: FunctionDecl
+// CHECK-SAME: func4
+// CHECK-NEXT: CompoundStmt
+// This is for the nested anonymous namespace.
+// CHECK-NEXT: UsingDirectiveDecl
+// CHECK-SAME: ''
+// CHECK: FunctionDecl
+// CHECK-SAME: func1
+// CHECK-NEXT: CompoundStmt
+// CHECK-NEXT: UsingDirectiveDecl
+// CHECK-SAME: ''
+
+// CHECK: NamespaceDecl
+// CHECK-SAME: test_namespace1
+// CHECK-NEXT: NamespaceDecl
+// CHECK: FunctionDecl
+// CHECK-SAME: func2
+// CHECK-NEXT: CompoundStmt
+// CHECK-NEXT: UsingDirectiveDecl
+// CHECK-SAME: ''
+
+// CHECK-NEXT: NamespaceDecl
+// CHECK-SAME: test_namespace2
+// CHECK-NEXT: NamespaceDecl
+// CHECK-NEXT: NamespaceDecl
+// CHECK-SAME: test_namespace3
+// CHECK: FunctionDecl
+// CHECK-SAME: func3
+// CHECK-NEXT: CompoundStmt
+// CHECK-NEXT: UsingDirectiveDecl
+// CHECK-SAME: ''
+
+void expr() {
+  func1();
+  test_namespace1::func2();
+  test_namespace2::test_namespace3::func3();
+  func4();
+}


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


[clang-tools-extra] r351738 - [clang-tidy] Use getStripPluginsAdjuster

2019-01-21 Thread Kadir Cetinkaya via cfe-commits
Author: kadircet
Date: Mon Jan 21 02:10:18 2019
New Revision: 351738

URL: http://llvm.org/viewvc/llvm-project?rev=351738=rev
Log:
[clang-tidy] Use getStripPluginsAdjuster

Summary: See rC351531 for the introduction of getStripPluginsAdjuster.

Reviewers: alexfh

Subscribers: xazax.hun, cfe-commits

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

Modified:
clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp

Modified: clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp?rev=351738=351737=351738=diff
==
--- clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp Mon Jan 21 02:10:18 2019
@@ -528,24 +528,8 @@ runClangTidy(clang::tidy::ClangTidyConte
 return AdjustedArgs;
   };
 
-  // Remove plugins arguments.
-  ArgumentsAdjuster PluginArgumentsRemover =
-  [](const CommandLineArguments , StringRef Filename) {
-CommandLineArguments AdjustedArgs;
-for (size_t I = 0, E = Args.size(); I < E; ++I) {
-  if (I + 4 < Args.size() && Args[I] == "-Xclang" &&
-  (Args[I + 1] == "-load" || Args[I + 1] == "-add-plugin" ||
-   StringRef(Args[I + 1]).startswith("-plugin-arg-")) &&
-  Args[I + 2] == "-Xclang") {
-I += 3;
-  } else
-AdjustedArgs.push_back(Args[I]);
-}
-return AdjustedArgs;
-  };
-
   Tool.appendArgumentsAdjuster(PerFileExtraArgumentsInserter);
-  Tool.appendArgumentsAdjuster(PluginArgumentsRemover);
+  Tool.appendArgumentsAdjuster(getStripPluginsAdjuster());
   Context.setEnableProfiling(EnableCheckProfile);
   Context.setProfileStoragePrefix(StoreCheckProfile);
 


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


[PATCH] D51178: [ASTImporter] Add test for importing anonymous namespaces.

2019-01-21 Thread Raphael Isemann via Phabricator via cfe-commits
teemperor updated this revision to Diff 182761.
teemperor added a comment.

- Added a comment that the using directives are created by Sema.

Also sorry for the late update :)


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D51178/new/

https://reviews.llvm.org/D51178

Files:
  test/Import/cxx-anon-namespace/Inputs/F.cpp
  test/Import/cxx-anon-namespace/test.cpp


Index: test/Import/cxx-anon-namespace/test.cpp
===
--- /dev/null
+++ test/Import/cxx-anon-namespace/test.cpp
@@ -0,0 +1,45 @@
+// RUN: clang-import-test -dump-ast -import %S/Inputs/F.cpp -expression %s | 
FileCheck %s
+
+// The implicit UsingDirectiveDecls for the anonymous namespaces are created 
by the Sema.
+
+// CHECK: NamespaceDecl
+// The nested anonymous namespace.
+// CHECK-NEXT: NamespaceDecl
+// CHECK: FunctionDecl
+// CHECK-SAME: func4
+// CHECK-NEXT: CompoundStmt
+// This is for the nested anonymous namespace.
+// CHECK-NEXT: UsingDirectiveDecl
+// CHECK-SAME: ''
+// CHECK: FunctionDecl
+// CHECK-SAME: func1
+// CHECK-NEXT: CompoundStmt
+// CHECK-NEXT: UsingDirectiveDecl
+// CHECK-SAME: ''
+
+// CHECK: NamespaceDecl
+// CHECK-SAME: test_namespace1
+// CHECK-NEXT: NamespaceDecl
+// CHECK: FunctionDecl
+// CHECK-SAME: func2
+// CHECK-NEXT: CompoundStmt
+// CHECK-NEXT: UsingDirectiveDecl
+// CHECK-SAME: ''
+
+// CHECK-NEXT: NamespaceDecl
+// CHECK-SAME: test_namespace2
+// CHECK-NEXT: NamespaceDecl
+// CHECK-NEXT: NamespaceDecl
+// CHECK-SAME: test_namespace3
+// CHECK: FunctionDecl
+// CHECK-SAME: func3
+// CHECK-NEXT: CompoundStmt
+// CHECK-NEXT: UsingDirectiveDecl
+// CHECK-SAME: ''
+
+void expr() {
+  func1();
+  test_namespace1::func2();
+  test_namespace2::test_namespace3::func3();
+  func4();
+}
Index: test/Import/cxx-anon-namespace/Inputs/F.cpp
===
--- /dev/null
+++ test/Import/cxx-anon-namespace/Inputs/F.cpp
@@ -0,0 +1,25 @@
+namespace {
+void func1() {
+}
+} // namespace
+
+namespace test_namespace1 {
+namespace {
+void func2() {}
+} // namespace
+} // namespace test_namespace1
+
+namespace test_namespace2 {
+namespace {
+namespace test_namespace3 {
+void func3() {}
+} // namespace test_namespace3
+} // namespace
+} // namespace test_namespace2
+
+namespace {
+namespace {
+void func4() {
+}
+} // namespace
+} // namespace


Index: test/Import/cxx-anon-namespace/test.cpp
===
--- /dev/null
+++ test/Import/cxx-anon-namespace/test.cpp
@@ -0,0 +1,45 @@
+// RUN: clang-import-test -dump-ast -import %S/Inputs/F.cpp -expression %s | FileCheck %s
+
+// The implicit UsingDirectiveDecls for the anonymous namespaces are created by the Sema.
+
+// CHECK: NamespaceDecl
+// The nested anonymous namespace.
+// CHECK-NEXT: NamespaceDecl
+// CHECK: FunctionDecl
+// CHECK-SAME: func4
+// CHECK-NEXT: CompoundStmt
+// This is for the nested anonymous namespace.
+// CHECK-NEXT: UsingDirectiveDecl
+// CHECK-SAME: ''
+// CHECK: FunctionDecl
+// CHECK-SAME: func1
+// CHECK-NEXT: CompoundStmt
+// CHECK-NEXT: UsingDirectiveDecl
+// CHECK-SAME: ''
+
+// CHECK: NamespaceDecl
+// CHECK-SAME: test_namespace1
+// CHECK-NEXT: NamespaceDecl
+// CHECK: FunctionDecl
+// CHECK-SAME: func2
+// CHECK-NEXT: CompoundStmt
+// CHECK-NEXT: UsingDirectiveDecl
+// CHECK-SAME: ''
+
+// CHECK-NEXT: NamespaceDecl
+// CHECK-SAME: test_namespace2
+// CHECK-NEXT: NamespaceDecl
+// CHECK-NEXT: NamespaceDecl
+// CHECK-SAME: test_namespace3
+// CHECK: FunctionDecl
+// CHECK-SAME: func3
+// CHECK-NEXT: CompoundStmt
+// CHECK-NEXT: UsingDirectiveDecl
+// CHECK-SAME: ''
+
+void expr() {
+  func1();
+  test_namespace1::func2();
+  test_namespace2::test_namespace3::func3();
+  func4();
+}
Index: test/Import/cxx-anon-namespace/Inputs/F.cpp
===
--- /dev/null
+++ test/Import/cxx-anon-namespace/Inputs/F.cpp
@@ -0,0 +1,25 @@
+namespace {
+void func1() {
+}
+} // namespace
+
+namespace test_namespace1 {
+namespace {
+void func2() {}
+} // namespace
+} // namespace test_namespace1
+
+namespace test_namespace2 {
+namespace {
+namespace test_namespace3 {
+void func3() {}
+} // namespace test_namespace3
+} // namespace
+} // namespace test_namespace2
+
+namespace {
+namespace {
+void func4() {
+}
+} // namespace
+} // namespace
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D56902: [clang-tidy] Use getStripPluginsAdjuster

2019-01-21 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL351738: [clang-tidy] Use getStripPluginsAdjuster (authored 
by kadircet, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56902/new/

https://reviews.llvm.org/D56902

Files:
  clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp


Index: clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
===
--- clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
+++ clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
@@ -528,24 +528,8 @@
 return AdjustedArgs;
   };
 
-  // Remove plugins arguments.
-  ArgumentsAdjuster PluginArgumentsRemover =
-  [](const CommandLineArguments , StringRef Filename) {
-CommandLineArguments AdjustedArgs;
-for (size_t I = 0, E = Args.size(); I < E; ++I) {
-  if (I + 4 < Args.size() && Args[I] == "-Xclang" &&
-  (Args[I + 1] == "-load" || Args[I + 1] == "-add-plugin" ||
-   StringRef(Args[I + 1]).startswith("-plugin-arg-")) &&
-  Args[I + 2] == "-Xclang") {
-I += 3;
-  } else
-AdjustedArgs.push_back(Args[I]);
-}
-return AdjustedArgs;
-  };
-
   Tool.appendArgumentsAdjuster(PerFileExtraArgumentsInserter);
-  Tool.appendArgumentsAdjuster(PluginArgumentsRemover);
+  Tool.appendArgumentsAdjuster(getStripPluginsAdjuster());
   Context.setEnableProfiling(EnableCheckProfile);
   Context.setProfileStoragePrefix(StoreCheckProfile);
 


Index: clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
===
--- clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
+++ clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
@@ -528,24 +528,8 @@
 return AdjustedArgs;
   };
 
-  // Remove plugins arguments.
-  ArgumentsAdjuster PluginArgumentsRemover =
-  [](const CommandLineArguments , StringRef Filename) {
-CommandLineArguments AdjustedArgs;
-for (size_t I = 0, E = Args.size(); I < E; ++I) {
-  if (I + 4 < Args.size() && Args[I] == "-Xclang" &&
-  (Args[I + 1] == "-load" || Args[I + 1] == "-add-plugin" ||
-   StringRef(Args[I + 1]).startswith("-plugin-arg-")) &&
-  Args[I + 2] == "-Xclang") {
-I += 3;
-  } else
-AdjustedArgs.push_back(Args[I]);
-}
-return AdjustedArgs;
-  };
-
   Tool.appendArgumentsAdjuster(PerFileExtraArgumentsInserter);
-  Tool.appendArgumentsAdjuster(PluginArgumentsRemover);
+  Tool.appendArgumentsAdjuster(getStripPluginsAdjuster());
   Context.setEnableProfiling(EnableCheckProfile);
   Context.setProfileStoragePrefix(StoreCheckProfile);
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D56976: [clang] [test] Pass -ccc-install-dir in mac compilation db test

2019-01-21 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

LGTM to unbreak the tests on *BSD, but could you please leave a comment?
It would probably be best to take `argv[0]` into account on *BSD systems as 
well (possibly only if `clang` could not be found).

At least if that's the behaviour on **all** other systems.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56976/new/

https://reviews.llvm.org/D56976



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


[PATCH] D56976: [clang] [test] Pass -ccc-install-dir in mac compilation db test

2019-01-21 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: test/Tooling/clang-check-mac-libcxx-fixed-compilation-db.cpp:15
+// RUN: -stdlib=libc++ -target x86_64-apple-darwin \
+// RUN: -ccc-install-dir %t/mock-libcxx/bin
 #include 

Could you leave a comment this is passed to unbreak *BSD tests?


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56976/new/

https://reviews.llvm.org/D56976



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


[libunwind] r351731 - Fix typos throughout the license files that somehow I and my reviewers

2019-01-21 Thread Chandler Carruth via cfe-commits
Author: chandlerc
Date: Mon Jan 21 01:52:34 2019
New Revision: 351731

URL: http://llvm.org/viewvc/llvm-project?rev=351731=rev
Log:
Fix typos throughout the license files that somehow I and my reviewers
all missed!

Thanks to Alex Bradbury for pointing this out, and the fact that I never
added the intended `legacy` anchor to the developer policy. Add that
anchor too. With hope, this will cause the links to all resolve
successfully.

Modified:
libunwind/trunk/LICENSE.TXT

Modified: libunwind/trunk/LICENSE.TXT
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/LICENSE.TXT?rev=351731=351730=351731=diff
==
--- libunwind/trunk/LICENSE.TXT (original)
+++ libunwind/trunk/LICENSE.TXT Mon Jan 21 01:52:34 2019
@@ -234,7 +234,7 @@ mechanisms:
file.
 
 ==
-Legacy LLVM License (ttps://llvm.org/docs/DeveloperPolicy.html#legacy):
+Legacy LLVM License (https://llvm.org/docs/DeveloperPolicy.html#legacy):
 ==
 
 The libunwind library is dual licensed under both the University of Illinois


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


  1   2   >