[PATCH] D49223: [AST] Check described template at structural equivalence check.

2018-08-07 Thread Balázs Kéri via Phabricator via cfe-commits
balazske updated this revision to Diff 159458.
balazske marked an inline comment as done.
balazske added a comment.

- Renamed methods, simplified code, comments updated.


Repository:
  rC Clang

https://reviews.llvm.org/D49223

Files:
  include/clang/AST/ASTStructuralEquivalence.h
  lib/AST/ASTStructuralEquivalence.cpp
  unittests/AST/StructuralEquivalenceTest.cpp

Index: unittests/AST/StructuralEquivalenceTest.cpp
===
--- unittests/AST/StructuralEquivalenceTest.cpp
+++ unittests/AST/StructuralEquivalenceTest.cpp
@@ -78,11 +78,18 @@
   }
 
   bool testStructuralMatch(Decl *D0, Decl *D1) {
-llvm::DenseSet> NonEquivalentDecls;
-StructuralEquivalenceContext Ctx(
-D0->getASTContext(), D1->getASTContext(), NonEquivalentDecls,
-StructuralEquivalenceKind::Default, false, false);
-return Ctx.IsEquivalent(D0, D1);
+llvm::DenseSet> NonEquivalentDecls01;
+llvm::DenseSet> NonEquivalentDecls10;
+StructuralEquivalenceContext Ctx01(
+D0->getASTContext(), D1->getASTContext(),
+NonEquivalentDecls01, StructuralEquivalenceKind::Default, false, false);
+StructuralEquivalenceContext Ctx10(
+D1->getASTContext(), D0->getASTContext(),
+NonEquivalentDecls10, StructuralEquivalenceKind::Default, false, false);
+bool Eq01 = Ctx01.IsEquivalent(D0, D1);
+bool Eq10 = Ctx10.IsEquivalent(D1, D0);
+EXPECT_EQ(Eq01, Eq10);
+return Eq01;
   }
 
   bool testStructuralMatch(std::tuple t) {
@@ -215,6 +222,14 @@
 struct StructuralEquivalenceFunctionTest : StructuralEquivalenceTest {
 };
 
+TEST_F(StructuralEquivalenceFunctionTest, TemplateVsNonTemplate) {
+  auto t = makeNamedDecls(
+  "void foo();",
+  "template void foo();",
+  Lang_CXX);
+  EXPECT_FALSE(testStructuralMatch(t));
+}
+
 TEST_F(StructuralEquivalenceFunctionTest, ParamConstWithRef) {
   auto t = makeNamedDecls("void foo(int&);",
   "void foo(const int&);", Lang_CXX);
@@ -618,6 +633,14 @@
   EXPECT_FALSE(testStructuralMatch(R0, R1));
 }
 
+TEST_F(StructuralEquivalenceRecordTest, TemplateVsNonTemplate) {
+  auto t = makeDecls(
+  "struct A { };",
+  "template struct A { };",
+  Lang_CXX,
+  cxxRecordDecl(hasName("A")));
+  EXPECT_FALSE(testStructuralMatch(t));
+}
 
 TEST_F(StructuralEquivalenceTest, CompareSameDeclWithMultiple) {
   auto t = makeNamedDecls(
Index: lib/AST/ASTStructuralEquivalence.cpp
===
--- lib/AST/ASTStructuralEquivalence.cpp
+++ lib/AST/ASTStructuralEquivalence.cpp
@@ -1023,7 +1023,7 @@
 return true;
 
   // If any of the records has external storage and we do a minimal check (or
-  // AST import) we assmue they are equivalent. (If we didn't have this
+  // AST import) we assume they are equivalent. (If we didn't have this
   // assumption then `RecordDecl::LoadFieldsFromExternalStorage` could trigger
   // another AST import which in turn would call the structural equivalency
   // check again and finally we'd have an improper result.)
@@ -1497,6 +1497,141 @@
   return !Finish();
 }
 
+bool StructuralEquivalenceContext::CheckCommonEquivalence(Decl *D1, Decl *D2) {
+  // Check for equivalent described template.
+  TemplateDecl *Template1 = D1->getDescribedTemplate();
+  TemplateDecl *Template2 = D2->getDescribedTemplate();
+  if ((Template1 != nullptr) != (Template2 != nullptr))
+return false;
+  if (Template1 && !IsStructurallyEquivalent(*this, Template1, Template2))
+return false;
+
+  // FIXME: Move check for identifier names into this function.
+
+  return true;
+}
+
+bool StructuralEquivalenceContext::CheckKindSpecificEquivalence(
+Decl *D1, Decl *D2) {
+  // FIXME: Switch on all declaration kinds. For now, we're just going to
+  // check the obvious ones.
+  if (auto *Record1 = dyn_cast(D1)) {
+if (auto *Record2 = dyn_cast(D2)) {
+  // Check for equivalent structure names.
+  IdentifierInfo *Name1 = Record1->getIdentifier();
+  if (!Name1 && Record1->getTypedefNameForAnonDecl())
+Name1 = Record1->getTypedefNameForAnonDecl()->getIdentifier();
+  IdentifierInfo *Name2 = Record2->getIdentifier();
+  if (!Name2 && Record2->getTypedefNameForAnonDecl())
+Name2 = Record2->getTypedefNameForAnonDecl()->getIdentifier();
+  if (!::IsStructurallyEquivalent(Name1, Name2) ||
+  !::IsStructurallyEquivalent(*this, Record1, Record2))
+return false;
+} else {
+  // Record/non-record mismatch.
+  return false;
+}
+  } else if (auto *Enum1 = dyn_cast(D1)) {
+if (auto *Enum2 = dyn_cast(D2)) {
+  // Check for equivalent enum names.
+  IdentifierInfo *Name1 = Enum1->getIdentifier();
+  if (!Name1 && Enum1->getTypedefNameForAnonDecl())
+Name1 = Enum1->getTypedefNameForAnonDecl()->getIdentifier();
+  IdentifierInfo *Name2 = Enum2->getIdentifier();
+  if (!Name2 && Enum2->getTypedefNameForAnon

[PATCH] D50278: [Sema] Fix for crash on conditional operation with address_space pointer

2018-08-07 Thread Bevin Hansson via Phabricator via cfe-commits
ebevhan added a comment.

I think the solution to a lot of diagnostic and behavior issues with address 
spaces is to remove predication on OpenCL. It's a bit odd to have a language 
feature that is enabled out of the box regardless of langoptions (address 
spaces) but won't actually work properly unless you're building OpenCL.




Comment at: include/clang/Basic/DiagnosticSemaKinds.td:6943
+def err_typecheck_incompatible_conditional_pointer_operands : Error<
+  "unable to find common type between %0 and %1 for conditional operation">;
 

This error is very similar to the one in my first comment, `conditional 
operator with the second and third operands of type 
('__attribute__((address_space(1))) char *' and 
'__attribute__((address_space(2))) char *') which are pointers to 
non-overlapping address spaces`. It would normally be emitted at 6472, but 
won't be since OpenCL isn't enabled.



Comment at: test/Sema/conditional-expr.c:78
+   // expected-error@-1{{converting 
'__attribute__((address_space(2))) int *' to type 'void *' changes address 
space of pointer}}
+   // expected-error@-2{{converting 
'__attribute__((address_space(3))) int *' to type 'void *' changes address 
space of pointer}}
 

rjmccall wrote:
> leonardchan wrote:
> > rjmccall wrote:
> > > Also, these diagnostics seem wrong.  Where is `void *` coming from?
> > When dumping the AST this is what the resulting type is for the conditional 
> > expression already is if the operands are 2 pointers with different address 
> > spaces.
> > 
> > According to this comment, the reason seems to be because this is what GCC 
> > does:
> > 
> > ```
> >  6512 // In this situation, we assume void* type. No especially good
> >  6513 // reason, but this is what gcc does, and we do have to pick
> >  6514 // to get a consistent AST.
> > ```
> That makes sense in general, but in this case it's not a great diagnostic; we 
> should just emit an error when trying to pick a common type.
Is it possible that you are getting `void *` because we aren't running the 
qualifier removal at 6495? I don't think I've ever seen spurious `void *`'s 
show up in our downstream diagnostics.


Repository:
  rC Clang

https://reviews.llvm.org/D50278



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


[PATCH] D46892: [X86] Lowering adds/addus/subs/subus intrinsics to native IR (Clang part)

2018-08-07 Thread Tomasz Krupa via Phabricator via cfe-commits
tkrupa updated this revision to Diff 159461.
tkrupa added a comment.

Removed signed intrinsics lowering due to the pattern being too complicated - 
instead some minor optimizations were introduced on LLVM side.


Repository:
  rC Clang

https://reviews.llvm.org/D46892

Files:
  lib/CodeGen/CGBuiltin.cpp
  test/CodeGen/avx2-builtins.c
  test/CodeGen/avx512bw-builtins.c
  test/CodeGen/avx512vlbw-builtins.c
  test/CodeGen/sse2-builtins.c

Index: test/CodeGen/sse2-builtins.c
===
--- test/CodeGen/sse2-builtins.c
+++ test/CodeGen/sse2-builtins.c
@@ -59,13 +59,19 @@
 
 __m128i test_mm_adds_epu8(__m128i A, __m128i B) {
   // CHECK-LABEL: test_mm_adds_epu8
-  // CHECK: call <16 x i8> @llvm.x86.sse2.paddus.b(<16 x i8> %{{.*}}, <16 x i8> %{{.*}})
+  // CHECK-NOT: call <16 x i8> @llvm.x86.sse2.paddus.b(<16 x i8> %{{.*}}, <16 x i8> %{{.*}})
+  // CHECK: add <16 x i8> %{{.*}}, %{{.*}}
+  // CHECK: icmp ugt <16 x i8> %{{.*}}, %{{.*}}
+  // CHECK: select <16 x i1> %{{.*}}, <16 x i8> , <16 x i8> {{.*}}
   return _mm_adds_epu8(A, B);
 }
 
 __m128i test_mm_adds_epu16(__m128i A, __m128i B) {
   // CHECK-LABEL: test_mm_adds_epu16
-  // CHECK: call <8 x i16> @llvm.x86.sse2.paddus.w(<8 x i16> %{{.*}}, <8 x i16> %{{.*}})
+  // CHECK-NOT: call <8 x i16> @llvm.x86.sse2.paddus.w(<8 x i16> %{{.*}}, <8 x i16> %{{.*}})
+  // CHECK: add <8 x i16> %{{.*}}, %{{.*}}
+  // CHECK: icmp ugt <8 x i16> %{{.*}}, %{{.*}}
+  // CHECK: select <8 x i1> %{{.*}}, <8 x i16> , <8 x i16> {{.*}}
   return _mm_adds_epu16(A, B);
 }
 
@@ -1422,13 +1428,19 @@
 
 __m128i test_mm_subs_epu8(__m128i A, __m128i B) {
   // CHECK-LABEL: test_mm_subs_epu8
-  // CHECK: call <16 x i8> @llvm.x86.sse2.psubus.b(<16 x i8> %{{.*}}, <16 x i8> %{{.*}})
+  // CHECK-NOT: call <16 x i8> @llvm.x86.sse2.psubus.b(<16 x i8> %{{.*}}, <16 x i8> %{{.*}})
+  // CHECK: icmp ugt <16 x i8> {{.*}}, {{.*}}
+  // CHECK: select <16 x i1> {{.*}}, <16 x i8> {{.*}}, <16 x i8> {{.*}}
+  // CHECK: sub <16 x i8> {{.*}}, {{.*}}
   return _mm_subs_epu8(A, B);
 }
 
 __m128i test_mm_subs_epu16(__m128i A, __m128i B) {
   // CHECK-LABEL: test_mm_subs_epu16
-  // CHECK: call <8 x i16> @llvm.x86.sse2.psubus.w(<8 x i16> %{{.*}}, <8 x i16> %{{.*}})
+  // CHECK-NOT: call <8 x i16> @llvm.x86.sse2.psubus.w(<8 x i16> %{{.*}}, <8 x i16> %{{.*}})
+  // CHECK: icmp ugt <8 x i16> {{.*}}, {{.*}}
+  // CHECK: select <8 x i1> {{.*}}, <8 x i16> {{.*}}, <8 x i16> {{.*}}
+  // CHECK: sub <8 x i16> {{.*}}, {{.*}}
   return _mm_subs_epu16(A, B);
 }
 
Index: test/CodeGen/avx512vlbw-builtins.c
===
--- test/CodeGen/avx512vlbw-builtins.c
+++ test/CodeGen/avx512vlbw-builtins.c
@@ -1123,49 +1123,73 @@
 }
 __m128i test_mm_mask_adds_epu8(__m128i __W, __mmask16 __U, __m128i __A, __m128i __B) {
   // CHECK-LABEL: @test_mm_mask_adds_epu8
-  // CHECK: @llvm.x86.sse2.paddus.b
+  // CHECK-NOT: @llvm.x86.sse2.paddus.b
+  // CHECK: add <16 x i8> %{{.*}}, %{{.*}}
+  // CHECK: icmp ugt <16 x i8> %{{.*}}, %{{.*}}
+  // CHECK: select <16 x i1> %{{.*}}, <16 x i8> , <16 x i8> {{.*}}
   // CHECK: select <16 x i1> %{{.*}}, <16 x i8> %{{.*}}, <16 x i8> %{{.*}}
   return _mm_mask_adds_epu8(__W,__U,__A,__B); 
 }
 __m128i test_mm_maskz_adds_epu8(__mmask16 __U, __m128i __A, __m128i __B) {
   // CHECK-LABEL: @test_mm_maskz_adds_epu8
-  // CHECK: @llvm.x86.sse2.paddus.b
+  // CHECK-NOT: @llvm.x86.sse2.paddus.b
+  // CHECK: add <16 x i8> %{{.*}}, %{{.*}}
+  // CHECK: icmp ugt <16 x i8> %{{.*}}, %{{.*}}
+  // CHECK: select <16 x i1> %{{.*}}, <16 x i8> , <16 x i8> {{.*}}
   // CHECK: select <16 x i1> %{{.*}}, <16 x i8> %{{.*}}, <16 x i8> %{{.*}}
   return _mm_maskz_adds_epu8(__U,__A,__B); 
 }
 __m256i test_mm256_mask_adds_epu8(__m256i __W, __mmask32 __U, __m256i __A, __m256i __B) {
   // CHECK-LABEL: @test_mm256_mask_adds_epu8
-  // CHECK: @llvm.x86.avx2.paddus.b
+  // CHECK-NOT: @llvm.x86.avx2.paddus.b
+  // CHECK: add <32 x i8> %{{.*}}, %{{.*}}
+  // CHECK: icmp ugt <32 x i8> %{{.*}}, %{{.*}}
+  // CHECK: select <32 x i1> %{{.*}}, <32 x i8> , <32 x i8> {{.*}}
   // CHECK: select <32 x i1> %{{.*}}, <32 x i8> %{{.*}}, <32 x i8> %{{.*}}
   return _mm256_mask_adds_epu8(__W,__U,__A,__B); 
 }
 __m256i test_mm256_maskz_adds_epu8(__mmask32 __U, __m256i __A, __m256i __B) {
   // CHECK-LABEL: @test_mm256_maskz_adds_epu8
-  // CHECK: @llvm.x86.avx2.paddus.b
+  // CHECK-NOT: @llvm.x86.avx2.paddus.b
+  // CHECK: add <32 x i8> %{{.*}}, %{{.*}}
+  // CHECK: icmp ugt <32 x i8> %{{.*}}, %{{.*}}
+  // CHECK: select <32 x i1> %{{.*}}, <32 x i8> , <32 x i8> {{.*}}
   // CHECK: select <32 x i1> %{{.*}}, <32 x i8> %{{.*}}, <32 x i8> %{{.*}}
   return _mm256_maskz_adds_epu8(__U,__A,__B); 
 }
 __m128i test_mm_mask_adds_epu16(__m128i __W, __mmask8 __U, __m128i __A, __m128i __B) {
   // CHECK-LABEL: @test_mm_mask_adds_epu16
-  // CHECK: @llvm.x86.sse2.paddus.w
+  // CHECK-NOT: @llvm.x86.sse2.paddus.w
+  // CHECK: add <8 x i16> %{{.*}}, %{{.*}}
+  // CHECK

r339109 - AMDGPU: Add builtin for s_dcache_inv_vol

2018-08-07 Thread Matt Arsenault via cfe-commits
Author: arsenm
Date: Tue Aug  7 00:49:04 2018
New Revision: 339109

URL: http://llvm.org/viewvc/llvm-project?rev=339109&view=rev
Log:
AMDGPU: Add builtin for s_dcache_inv_vol

Added:
cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn-ci.cl
cfe/trunk/test/SemaOpenCL/builtins-amdgcn-error-ci.cl
Modified:
cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def
cfe/trunk/lib/Basic/Targets/AMDGPU.cpp
cfe/trunk/test/CodeGenOpenCL/amdgpu-features.cl

Modified: cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def?rev=339109&r1=339108&r2=339109&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def Tue Aug  7 00:49:04 2018
@@ -101,6 +101,11 @@ BUILTIN(__builtin_amdgcn_ds_fminf, "ff*3
 BUILTIN(__builtin_amdgcn_ds_fmaxf, "ff*3fIiIiIb", "n")
 
 
//===--===//
+// CI+ only builtins.
+//===--===//
+TARGET_BUILTIN(__builtin_amdgcn_s_dcache_inv_vol, "v", "n", "ci-insts")
+
+//===--===//
 // VI+ only builtins.
 
//===--===//
 

Modified: cfe/trunk/lib/Basic/Targets/AMDGPU.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/AMDGPU.cpp?rev=339109&r1=339108&r2=339109&view=diff
==
--- cfe/trunk/lib/Basic/Targets/AMDGPU.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/AMDGPU.cpp Tue Aug  7 00:49:04 2018
@@ -148,12 +148,14 @@ bool AMDGPUTargetInfo::initFeatureMap(
   Features["16-bit-insts"] = true;
   Features["dpp"] = true;
   Features["s-memrealtime"] = true;
-  break;
+  LLVM_FALLTHROUGH;
 case GK_GFX704:
 case GK_GFX703:
 case GK_GFX702:
 case GK_GFX701:
 case GK_GFX700:
+  Features["ci-insts"] = true;
+  LLVM_FALLTHROUGH;
 case GK_GFX601:
 case GK_GFX600:
   break;

Modified: cfe/trunk/test/CodeGenOpenCL/amdgpu-features.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/amdgpu-features.cl?rev=339109&r1=339108&r2=339109&view=diff
==
--- cfe/trunk/test/CodeGenOpenCL/amdgpu-features.cl (original)
+++ cfe/trunk/test/CodeGenOpenCL/amdgpu-features.cl Tue Aug  7 00:49:04 2018
@@ -5,8 +5,16 @@
 
 // RUN: %clang_cc1 -triple amdgcn -target-cpu gfx904 -S -emit-llvm -o - %s | 
FileCheck --check-prefix=GFX904 %s
 // RUN: %clang_cc1 -triple amdgcn -target-cpu gfx906 -S -emit-llvm -o - %s | 
FileCheck --check-prefix=GFX906 %s
+// RUN: %clang_cc1 -triple amdgcn -target-cpu gfx801 -S -emit-llvm -o - %s | 
FileCheck --check-prefix=GFX801 %s
+// RUN: %clang_cc1 -triple amdgcn -target-cpu gfx700 -S -emit-llvm -o - %s | 
FileCheck --check-prefix=GFX700 %s
+// RUN: %clang_cc1 -triple amdgcn -target-cpu gfx600 -S -emit-llvm -o - %s | 
FileCheck --check-prefix=GFX600 %s
+// RUN: %clang_cc1 -triple amdgcn -target-cpu gfx601 -S -emit-llvm -o - %s | 
FileCheck --check-prefix=GFX601 %s
 
-// GFX904: 
"target-features"="+16-bit-insts,+dpp,+fp32-denormals,+fp64-fp16-denormals,+gfx9-insts,+s-memrealtime"
-// GFX906: 
"target-features"="+16-bit-insts,+dl-insts,+dpp,+fp32-denormals,+fp64-fp16-denormals,+gfx9-insts,+s-memrealtime"
+// GFX904: 
"target-features"="+16-bit-insts,+ci-insts,+dpp,+fp32-denormals,+fp64-fp16-denormals,+gfx9-insts,+s-memrealtime"
+// GFX906: 
"target-features"="+16-bit-insts,+ci-insts,+dl-insts,+dpp,+fp32-denormals,+fp64-fp16-denormals,+gfx9-insts,+s-memrealtime"
+// GFX801: 
"target-features"="+16-bit-insts,+ci-insts,+dpp,+fp32-denormals,+fp64-fp16-denormals,+s-memrealtime"
+// GFX700: "target-features"="+ci-insts,+fp64-fp16-denormals,-fp32-denormals"
+// GFX600: "target-features"="+fp32-denormals,+fp64-fp16-denormals"
+// GFX601: "target-features"="+fp64-fp16-denormals,-fp32-denormals"
 
 kernel void test() {}

Added: cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn-ci.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn-ci.cl?rev=339109&view=auto
==
--- cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn-ci.cl (added)
+++ cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn-ci.cl Tue Aug  7 00:49:04 2018
@@ -0,0 +1,12 @@
+// REQUIRES: amdgpu-registered-target
+// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu hawaii -S 
-emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu fiji -S 
-emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu gfx906 -S 
-emit-llvm -o - %s | FileCheck %s
+
+//

r339110 - AMDGPU: Add builtin for s_dcache_wb

2018-08-07 Thread Matt Arsenault via cfe-commits
Author: arsenm
Date: Tue Aug  7 00:49:13 2018
New Revision: 339110

URL: http://llvm.org/viewvc/llvm-project?rev=339110&view=rev
Log:
AMDGPU: Add builtin for s_dcache_wb

Added:
cfe/trunk/test/SemaOpenCL/builtins-amdgcn-error-vi.cl
Modified:
cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def
cfe/trunk/lib/Basic/Targets/AMDGPU.cpp
cfe/trunk/test/CodeGenOpenCL/amdgpu-features.cl
cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn-vi.cl

Modified: cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def?rev=339110&r1=339109&r2=339110&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def Tue Aug  7 00:49:13 2018
@@ -121,6 +121,7 @@ TARGET_BUILTIN(__builtin_amdgcn_fracth,
 TARGET_BUILTIN(__builtin_amdgcn_classh, "bhi", "nc", "16-bit-insts")
 TARGET_BUILTIN(__builtin_amdgcn_s_memrealtime, "LUi", "n", "s-memrealtime")
 TARGET_BUILTIN(__builtin_amdgcn_mov_dpp, "iiIiIiIiIb", "nc", "dpp")
+TARGET_BUILTIN(__builtin_amdgcn_s_dcache_wb, "v", "n", "vi-insts")
 
 
//===--===//
 // GFX9+ only builtins.

Modified: cfe/trunk/lib/Basic/Targets/AMDGPU.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/AMDGPU.cpp?rev=339110&r1=339109&r2=339110&view=diff
==
--- cfe/trunk/lib/Basic/Targets/AMDGPU.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/AMDGPU.cpp Tue Aug  7 00:49:13 2018
@@ -145,6 +145,7 @@ bool AMDGPUTargetInfo::initFeatureMap(
 case GK_GFX803:
 case GK_GFX802:
 case GK_GFX801:
+  Features["vi-insts"] = true;
   Features["16-bit-insts"] = true;
   Features["dpp"] = true;
   Features["s-memrealtime"] = true;

Modified: cfe/trunk/test/CodeGenOpenCL/amdgpu-features.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/amdgpu-features.cl?rev=339110&r1=339109&r2=339110&view=diff
==
--- cfe/trunk/test/CodeGenOpenCL/amdgpu-features.cl (original)
+++ cfe/trunk/test/CodeGenOpenCL/amdgpu-features.cl Tue Aug  7 00:49:13 2018
@@ -10,9 +10,9 @@
 // RUN: %clang_cc1 -triple amdgcn -target-cpu gfx600 -S -emit-llvm -o - %s | 
FileCheck --check-prefix=GFX600 %s
 // RUN: %clang_cc1 -triple amdgcn -target-cpu gfx601 -S -emit-llvm -o - %s | 
FileCheck --check-prefix=GFX601 %s
 
-// GFX904: 
"target-features"="+16-bit-insts,+ci-insts,+dpp,+fp32-denormals,+fp64-fp16-denormals,+gfx9-insts,+s-memrealtime"
-// GFX906: 
"target-features"="+16-bit-insts,+ci-insts,+dl-insts,+dpp,+fp32-denormals,+fp64-fp16-denormals,+gfx9-insts,+s-memrealtime"
-// GFX801: 
"target-features"="+16-bit-insts,+ci-insts,+dpp,+fp32-denormals,+fp64-fp16-denormals,+s-memrealtime"
+// GFX904: 
"target-features"="+16-bit-insts,+ci-insts,+dpp,+fp32-denormals,+fp64-fp16-denormals,+gfx9-insts,+s-memrealtime,+vi-insts"
+// GFX906: 
"target-features"="+16-bit-insts,+ci-insts,+dl-insts,+dpp,+fp32-denormals,+fp64-fp16-denormals,+gfx9-insts,+s-memrealtime,+vi-insts"
+// GFX801: 
"target-features"="+16-bit-insts,+ci-insts,+dpp,+fp32-denormals,+fp64-fp16-denormals,+s-memrealtime,+vi-insts"
 // GFX700: "target-features"="+ci-insts,+fp64-fp16-denormals,-fp32-denormals"
 // GFX600: "target-features"="+fp32-denormals,+fp64-fp16-denormals"
 // GFX601: "target-features"="+fp64-fp16-denormals,-fp32-denormals"

Modified: cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn-vi.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn-vi.cl?rev=339110&r1=339109&r2=339110&view=diff
==
--- cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn-vi.cl (original)
+++ cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn-vi.cl Tue Aug  7 00:49:13 2018
@@ -82,6 +82,13 @@ void test_s_memrealtime(global ulong* ou
   *out = __builtin_amdgcn_s_memrealtime();
 }
 
+// CHECK-LABEL: @test_s_dcache_wb()
+// CHECK: call void @llvm.amdgcn.s.dcache.wb()
+void test_s_dcache_wb()
+{
+  __builtin_amdgcn_s_dcache_wb();
+}
+
 // CHECK-LABEL: @test_mov_dpp
 // CHECK: call i32 @llvm.amdgcn.mov.dpp.i32(i32 %src, i32 0, i32 0, i32 0, i1 
false)
 void test_mov_dpp(global int* out, int src)

Added: cfe/trunk/test/SemaOpenCL/builtins-amdgcn-error-vi.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/builtins-amdgcn-error-vi.cl?rev=339110&view=auto
==
--- cfe/trunk/test/SemaOpenCL/builtins-amdgcn-error-vi.cl (added)
+++ cfe/trunk/test/SemaOpenCL/builtins-amdgcn-error-vi.cl Tue Aug  7 00:49:13 
2018
@@ -0,0 +1,8 @@
+// REQUIRES: amdgpu-registered-target
+// RUN: %clang_cc1 -triple amdgcn-- -target-cpu tahiti -verify -S -o - %s

[PATCH] D50321: AMDGPU: Add builtin for s_dcache_wb

2018-08-07 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm closed this revision.
arsenm added a comment.

r339110


https://reviews.llvm.org/D50321



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


[PATCH] D50320: AMDGPU: Add builtin for s_dcache_inv_vol

2018-08-07 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm closed this revision.
arsenm added a comment.

r339109


https://reviews.llvm.org/D50320



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


[PATCH] D50144: Add Windows support for the GNUstep Objective-C ABI V2.

2018-08-07 Thread David Chisnall via Phabricator via cfe-commits
theraven added a comment.

I'd like to commit this, unless @rjmccall has any objections.


Repository:
  rC Clang

https://reviews.llvm.org/D50144



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


r339112 - Fix clash of gcc toolchains in driver regression tests

2018-08-07 Thread Karl-Johan Karlsson via cfe-commits
Author: karka
Date: Tue Aug  7 01:10:33 2018
New Revision: 339112

URL: http://llvm.org/viewvc/llvm-project?rev=339112&view=rev
Log:
Fix clash of gcc toolchains in driver regression tests

For some regression tests the path to the right toolchain is specified
using the -sysroot switch. However, if clang was configured with a
custom gcc toolchain (either by using GCC_INSTALL_PREFIX in cmake or the
equivalent configure command), the path to the custom gcc toolchain path
takes precedence to the one specified by sysroot. This causes several
regression tests to fail as they will be using an unexpected path. This
patch fixes this issue by adding --gcc-toolchain='' to all tests that
rely on that. The empty string causes the driver to pick the path from
sysroot instead.

This patch contain the same kind of fixes as done in rC225182

Modified:
cfe/trunk/test/Driver/linux-header-search.cpp
cfe/trunk/test/Driver/linux-ld.c

Modified: cfe/trunk/test/Driver/linux-header-search.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/linux-header-search.cpp?rev=339112&r1=339111&r2=339112&view=diff
==
--- cfe/trunk/test/Driver/linux-header-search.cpp (original)
+++ cfe/trunk/test/Driver/linux-header-search.cpp Tue Aug  7 01:10:33 2018
@@ -498,6 +498,7 @@
 // RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
 // RUN: -target arm-oe-linux-gnueabi -stdlib=libstdc++ \
 // RUN: --sysroot=%S/Inputs/openembedded_arm_linux_tree \
+// RUN: --gcc-toolchain="" \
 // RUN:   | FileCheck --check-prefix=CHECK-OE-ARM %s
 
 // CHECK-OE-ARM: "{{[^"]*}}clang{{[^"]*}}" "-cc1"
@@ -509,6 +510,7 @@
 // RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
 // RUN: -target aarch64-oe-linux -stdlib=libstdc++ \
 // RUN: --sysroot=%S/Inputs/openembedded_aarch64_linux_tree \
+// RUN: --gcc-toolchain="" \
 // RUN:   | FileCheck --check-prefix=CHECK-OE-AARCH64 %s
 
 // CHECK-OE-AARCH64: "{{[^"]*}}clang{{[^"]*}}" "-cc1"

Modified: cfe/trunk/test/Driver/linux-ld.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/linux-ld.c?rev=339112&r1=339111&r2=339112&view=diff
==
--- cfe/trunk/test/Driver/linux-ld.c (original)
+++ cfe/trunk/test/Driver/linux-ld.c Tue Aug  7 01:10:33 2018
@@ -1817,6 +1817,7 @@
 // Check whether the OpenEmbedded ARM libs are added correctly.
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: --target=arm-oe-linux-gnueabi -rtlib=libgcc \
+// RUN: --gcc-toolchain="" \
 // RUN: --sysroot=%S/Inputs/openembedded_arm_linux_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-OE-ARM %s
 
@@ -1836,6 +1837,7 @@
 // Check whether the OpenEmbedded AArch64 libs are added correctly.
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: --target=aarch64-oe-linux -rtlib=libgcc \
+// RUN: --gcc-toolchain="" \
 // RUN: --sysroot=%S/Inputs/openembedded_aarch64_linux_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-OE-AARCH64 %s
 


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


[PATCH] D50170: [libcxxabi] Fix test_exception_address_alignment test for ARM

2018-08-07 Thread Yvan Roux via Phabricator via cfe-commits
yroux added a comment.

I dug a bit and can give more context.  The usage of _LIBUNWIND_ARM_EHABI was 
introduced by https://reviews.llvm.org/D31178 but from what we are seeing with 
the release builds, libunwind headers are not picked up (at least in these 
configs) and since r309226 
 was 
committed, clang and libunwind unwind.h versions are close enough (and are the 
same w/r to alignment) to rely on libcxxabi macro _LIBCXXABI_ARM_EHABI to 
choose the alignment no matter which unwind header is used.


Repository:
  rCXXA libc++abi

https://reviews.llvm.org/D50170



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


[PATCH] D50337: [clangd] DexIndex implementation prototype

2018-08-07 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 159463.
kbobyrev added a comment.

Don't resize retrieved symbols vector, simply let callback process at most 
`MaxCandidateCount` items.


https://reviews.llvm.org/D50337

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/index/MemIndex.h
  clang-tools-extra/clangd/index/dex/DexIndex.cpp
  clang-tools-extra/clangd/index/dex/DexIndex.h
  clang-tools-extra/clangd/index/dex/Token.cpp
  clang-tools-extra/clangd/index/dex/Token.h
  clang-tools-extra/unittests/clangd/CMakeLists.txt
  clang-tools-extra/unittests/clangd/DexIndexTests.cpp
  clang-tools-extra/unittests/clangd/IndexHelpers.cpp
  clang-tools-extra/unittests/clangd/IndexHelpers.h
  clang-tools-extra/unittests/clangd/IndexTests.cpp

Index: clang-tools-extra/unittests/clangd/IndexTests.cpp
===
--- clang-tools-extra/unittests/clangd/IndexTests.cpp
+++ clang-tools-extra/unittests/clangd/IndexTests.cpp
@@ -7,33 +7,20 @@
 //
 //===--===//
 
+#include "IndexHelpers.h"
 #include "index/Index.h"
 #include "index/MemIndex.h"
 #include "index/Merge.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 
-using testing::UnorderedElementsAre;
 using testing::Pointee;
+using testing::UnorderedElementsAre;
 
 namespace clang {
 namespace clangd {
 namespace {
 
-Symbol symbol(llvm::StringRef QName) {
-  Symbol Sym;
-  Sym.ID = SymbolID(QName.str());
-  size_t Pos = QName.rfind("::");
-  if (Pos == llvm::StringRef::npos) {
-Sym.Name = QName;
-Sym.Scope = "";
-  } else {
-Sym.Name = QName.substr(Pos + 2);
-Sym.Scope = QName.substr(0, Pos + 2);
-  }
-  return Sym;
-}
-
 MATCHER_P(Named, N, "") { return arg.Name == N; }
 
 TEST(SymbolSlab, FindAndIterate) {
@@ -52,59 +39,6 @@
 EXPECT_THAT(*S.find(SymbolID(Sym)), Named(Sym));
 }
 
-struct SlabAndPointers {
-  SymbolSlab Slab;
-  std::vector Pointers;
-};
-
-// Create a slab of symbols with the given qualified names as both IDs and
-// names. The life time of the slab is managed by the returned shared pointer.
-// If \p WeakSymbols is provided, it will be pointed to the managed object in
-// the returned shared pointer.
-std::shared_ptr>
-generateSymbols(std::vector QualifiedNames,
-std::weak_ptr *WeakSymbols = nullptr) {
-  SymbolSlab::Builder Slab;
-  for (llvm::StringRef QName : QualifiedNames)
-Slab.insert(symbol(QName));
-
-  auto Storage = std::make_shared();
-  Storage->Slab = std::move(Slab).build();
-  for (const auto &Sym : Storage->Slab)
-Storage->Pointers.push_back(&Sym);
-  if (WeakSymbols)
-*WeakSymbols = Storage;
-  auto *Pointers = &Storage->Pointers;
-  return {std::move(Storage), Pointers};
-}
-
-// Create a slab of symbols with IDs and names [Begin, End], otherwise identical
-// to the `generateSymbols` above.
-std::shared_ptr>
-generateNumSymbols(int Begin, int End,
-   std::weak_ptr *WeakSymbols = nullptr) {
-  std::vector Names;
-  for (int i = Begin; i <= End; i++)
-Names.push_back(std::to_string(i));
-  return generateSymbols(Names, WeakSymbols);
-}
-
-std::string getQualifiedName(const Symbol &Sym) {
-  return (Sym.Scope + Sym.Name).str();
-}
-
-std::vector match(const SymbolIndex &I,
-   const FuzzyFindRequest &Req,
-   bool *Incomplete = nullptr) {
-  std::vector Matches;
-  bool IsIncomplete = I.fuzzyFind(Req, [&](const Symbol &Sym) {
-Matches.push_back(getQualifiedName(Sym));
-  });
-  if (Incomplete)
-*Incomplete = IsIncomplete;
-  return Matches;
-}
-
 TEST(MemIndexTest, MemIndexSymbolsRecycled) {
   MemIndex I;
   std::weak_ptr Symbols;
@@ -212,18 +146,6 @@
   EXPECT_THAT(match(I, Req), UnorderedElementsAre("ns::ABC", "ns::abc"));
 }
 
-// Returns qualified names of symbols with any of IDs in the index.
-std::vector lookup(const SymbolIndex &I,
-llvm::ArrayRef IDs) {
-  LookupRequest Req;
-  Req.IDs.insert(IDs.begin(), IDs.end());
-  std::vector Results;
-  I.lookup(Req, [&](const Symbol &Sym) {
-Results.push_back(getQualifiedName(Sym));
-  });
-  return Results;
-}
-
 TEST(MemIndexTest, Lookup) {
   MemIndex I;
   I.build(generateSymbols({"ns::abc", "ns::xyz"}));
@@ -269,7 +191,7 @@
 TEST(MergeTest, Merge) {
   Symbol L, R;
   L.ID = R.ID = SymbolID("hello");
-  L.Name = R.Name = "Foo";// same in both
+  L.Name = R.Name = "Foo";   // same in both
   L.CanonicalDeclaration.FileURI = "file:///left.h"; // differs
   R.CanonicalDeclaration.FileURI = "file:///right.h";
   L.References = 1;
Index: clang-tools-extra/unittests/clangd/IndexHelpers.h
===
--- /dev/null
+++ clang-tools-extra/unittests/clangd/IndexHelpers.h
@@ -0,0 +1,57 @@
+//===-- IndexHelpers.h --*- C++ -*-===//
+//
+// 

[PATCH] D50375: [clangd] Share getSymbolID implementation.

2018-08-07 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: ioeric.
Herald added subscribers: arphaman, jkorous, MaskRay, ilya-biryukov.

And remove all duplicated implementation.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D50375

Files:
  clangd/AST.cpp
  clangd/AST.h
  clangd/CodeComplete.cpp
  clangd/XRefs.cpp
  clangd/index/SymbolCollector.cpp

Index: clangd/index/SymbolCollector.cpp
===
--- clangd/index/SymbolCollector.cpp
+++ clangd/index/SymbolCollector.cpp
@@ -320,21 +320,20 @@
   if (!shouldCollectSymbol(*ND, *ASTCtx, Opts))
 return true;
 
-  llvm::SmallString<128> USR;
-  if (index::generateUSRForDecl(ND, USR))
+  auto ID = getSymbolID(ND);
+  if (!ID)
 return true;
-  SymbolID ID(USR);
 
   const NamedDecl &OriginalDecl = *cast(ASTNode.OrigD);
-  const Symbol *BasicSymbol = Symbols.find(ID);
+  const Symbol *BasicSymbol = Symbols.find(*ID);
   if (!BasicSymbol) // Regardless of role, ND is the canonical declaration.
-BasicSymbol = addDeclaration(*ND, std::move(ID));
+BasicSymbol = addDeclaration(*ND, std::move(*ID));
   else if (isPreferredDeclaration(OriginalDecl, Roles))
 // If OriginalDecl is preferred, replace the existing canonical
 // declaration (e.g. a class forward declaration). There should be at most
 // one duplicate as we expect to see only one preferred declaration per
 // TU, because in practice they are definitions.
-BasicSymbol = addDeclaration(OriginalDecl, std::move(ID));
+BasicSymbol = addDeclaration(OriginalDecl, std::move(*ID));
 
   if (Roles & static_cast(index::SymbolRole::Definition))
 addDefinition(OriginalDecl, *BasicSymbol);
@@ -423,9 +422,9 @@
 }
   };
   for (const NamedDecl *ND : ReferencedDecls) {
-llvm::SmallString<128> USR;
-if (!index::generateUSRForDecl(ND, USR))
-  IncRef(SymbolID(USR));
+if (auto ID = getSymbolID(ND)) {
+  IncRef(*ID);
+}
   }
   if (Opts.CollectMacro) {
 assert(PP);
Index: clangd/XRefs.cpp
===
--- clangd/XRefs.cpp
+++ clangd/XRefs.cpp
@@ -202,15 +202,6 @@
   return L;
 }
 
-// Get the symbol ID for a declaration, if possible.
-llvm::Optional getSymbolID(const Decl *D) {
-  llvm::SmallString<128> USR;
-  if (index::generateUSRForDecl(D, USR)) {
-return None;
-  }
-  return SymbolID(USR);
-}
-
 } // namespace
 
 std::vector findDefinitions(ParsedAST &AST, Position Pos,
Index: clangd/CodeComplete.cpp
===
--- clangd/CodeComplete.cpp
+++ clangd/CodeComplete.cpp
@@ -396,10 +396,7 @@
   switch (R.Kind) {
   case CodeCompletionResult::RK_Declaration:
   case CodeCompletionResult::RK_Pattern: {
-llvm::SmallString<128> USR;
-if (/*Ignore=*/clang::index::generateUSRForDecl(R.Declaration, USR))
-  return None;
-return SymbolID(USR);
+return clang::clangd::getSymbolID(R.Declaration);
   }
   case CodeCompletionResult::RK_Macro:
 // FIXME: Macros do have USRs, but the CCR doesn't contain enough info.
Index: clangd/AST.h
===
--- clangd/AST.h
+++ clangd/AST.h
@@ -16,6 +16,7 @@
 
 #include "clang/AST/Decl.h"
 #include "clang/Basic/SourceLocation.h"
+#include "index/Index.h"
 
 namespace clang {
 class SourceManager;
@@ -33,6 +34,10 @@
 /// like inline namespaces.
 std::string printQualifiedName(const NamedDecl &ND);
 
+/// Gets the symbol ID for a declaration.
+/// Returns None if fails.
+llvm::Optional getSymbolID(const Decl *D);
+
 } // namespace clangd
 } // namespace clang
 
Index: clangd/AST.cpp
===
--- clangd/AST.cpp
+++ clangd/AST.cpp
@@ -12,6 +12,7 @@
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/Decl.h"
 #include "clang/Basic/SourceManager.h"
+#include "clang/Index/USRGeneration.h"
 
 namespace clang {
 namespace clangd {
@@ -53,5 +54,13 @@
   return QName;
 }
 
+llvm::Optional getSymbolID(const Decl *D) {
+  llvm::SmallString<128> USR;
+  if (index::generateUSRForDecl(D, USR)) {
+return None;
+  }
+  return SymbolID(USR);
+}
+
 } // namespace clangd
 } // namespace clang
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D50375: [clangd] Share getSymbolID implementation.

2018-08-07 Thread Eric Liu via Phabricator via cfe-commits
ioeric accepted this revision.
ioeric added inline comments.
This revision is now accepted and ready to land.



Comment at: clangd/AST.cpp:59
+  llvm::SmallString<128> USR;
+  if (index::generateUSRForDecl(D, USR)) {
+return None;

nit: no braces



Comment at: clangd/AST.h:38
+/// Gets the symbol ID for a declaration.
+/// Returns None if fails.
+llvm::Optional getSymbolID(const Decl *D);

nit: this isn't necessary a failure. `D` might not have USR. Maybe `..., if 
possible.` like the original wording?



Comment at: clangd/CodeComplete.cpp:399
   case CodeCompletionResult::RK_Pattern: {
-llvm::SmallString<128> USR;
-if (/*Ignore=*/clang::index::generateUSRForDecl(R.Declaration, USR))
-  return None;
-return SymbolID(USR);
+return clang::clangd::getSymbolID(R.Declaration);
   }

No need for namespace qualifiers?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D50375



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


[PATCH] D50375: [clangd] Share getSymbolID implementation.

2018-08-07 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clangd/CodeComplete.cpp:399
   case CodeCompletionResult::RK_Pattern: {
-llvm::SmallString<128> USR;
-if (/*Ignore=*/clang::index::generateUSRForDecl(R.Declaration, USR))
-  return None;
-return SymbolID(USR);
+return clang::clangd::getSymbolID(R.Declaration);
   }

ioeric wrote:
> No need for namespace qualifiers?
We need the qualifiers to disambiguate the function name, because this function 
name is also `getSymbolID`.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D50375



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


[PATCH] D50375: [clangd] Share getSymbolID implementation.

2018-08-07 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 159466.
hokein marked 3 inline comments as done.
hokein added a comment.

Address comments.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D50375

Files:
  clangd/AST.cpp
  clangd/AST.h
  clangd/CodeComplete.cpp
  clangd/XRefs.cpp
  clangd/index/SymbolCollector.cpp

Index: clangd/index/SymbolCollector.cpp
===
--- clangd/index/SymbolCollector.cpp
+++ clangd/index/SymbolCollector.cpp
@@ -320,21 +320,20 @@
   if (!shouldCollectSymbol(*ND, *ASTCtx, Opts))
 return true;
 
-  llvm::SmallString<128> USR;
-  if (index::generateUSRForDecl(ND, USR))
+  auto ID = getSymbolID(ND);
+  if (!ID)
 return true;
-  SymbolID ID(USR);
 
   const NamedDecl &OriginalDecl = *cast(ASTNode.OrigD);
-  const Symbol *BasicSymbol = Symbols.find(ID);
+  const Symbol *BasicSymbol = Symbols.find(*ID);
   if (!BasicSymbol) // Regardless of role, ND is the canonical declaration.
-BasicSymbol = addDeclaration(*ND, std::move(ID));
+BasicSymbol = addDeclaration(*ND, std::move(*ID));
   else if (isPreferredDeclaration(OriginalDecl, Roles))
 // If OriginalDecl is preferred, replace the existing canonical
 // declaration (e.g. a class forward declaration). There should be at most
 // one duplicate as we expect to see only one preferred declaration per
 // TU, because in practice they are definitions.
-BasicSymbol = addDeclaration(OriginalDecl, std::move(ID));
+BasicSymbol = addDeclaration(OriginalDecl, std::move(*ID));
 
   if (Roles & static_cast(index::SymbolRole::Definition))
 addDefinition(OriginalDecl, *BasicSymbol);
@@ -423,9 +422,9 @@
 }
   };
   for (const NamedDecl *ND : ReferencedDecls) {
-llvm::SmallString<128> USR;
-if (!index::generateUSRForDecl(ND, USR))
-  IncRef(SymbolID(USR));
+if (auto ID = getSymbolID(ND)) {
+  IncRef(*ID);
+}
   }
   if (Opts.CollectMacro) {
 assert(PP);
Index: clangd/XRefs.cpp
===
--- clangd/XRefs.cpp
+++ clangd/XRefs.cpp
@@ -202,15 +202,6 @@
   return L;
 }
 
-// Get the symbol ID for a declaration, if possible.
-llvm::Optional getSymbolID(const Decl *D) {
-  llvm::SmallString<128> USR;
-  if (index::generateUSRForDecl(D, USR)) {
-return None;
-  }
-  return SymbolID(USR);
-}
-
 } // namespace
 
 std::vector findDefinitions(ParsedAST &AST, Position Pos,
Index: clangd/CodeComplete.cpp
===
--- clangd/CodeComplete.cpp
+++ clangd/CodeComplete.cpp
@@ -396,10 +396,7 @@
   switch (R.Kind) {
   case CodeCompletionResult::RK_Declaration:
   case CodeCompletionResult::RK_Pattern: {
-llvm::SmallString<128> USR;
-if (/*Ignore=*/clang::index::generateUSRForDecl(R.Declaration, USR))
-  return None;
-return SymbolID(USR);
+return clang::clangd::getSymbolID(R.Declaration);
   }
   case CodeCompletionResult::RK_Macro:
 // FIXME: Macros do have USRs, but the CCR doesn't contain enough info.
Index: clangd/AST.h
===
--- clangd/AST.h
+++ clangd/AST.h
@@ -16,6 +16,7 @@
 
 #include "clang/AST/Decl.h"
 #include "clang/Basic/SourceLocation.h"
+#include "index/Index.h"
 
 namespace clang {
 class SourceManager;
@@ -33,6 +34,9 @@
 /// like inline namespaces.
 std::string printQualifiedName(const NamedDecl &ND);
 
+/// Gets the symbol ID for a declaration, if possible.
+llvm::Optional getSymbolID(const Decl *D);
+
 } // namespace clangd
 } // namespace clang
 
Index: clangd/AST.cpp
===
--- clangd/AST.cpp
+++ clangd/AST.cpp
@@ -12,6 +12,7 @@
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/Decl.h"
 #include "clang/Basic/SourceManager.h"
+#include "clang/Index/USRGeneration.h"
 
 namespace clang {
 namespace clangd {
@@ -53,5 +54,12 @@
   return QName;
 }
 
+llvm::Optional getSymbolID(const Decl *D) {
+  llvm::SmallString<128> USR;
+  if (index::generateUSRForDecl(D, USR))
+return None;
+  return SymbolID(USR);
+}
+
 } // namespace clangd
 } // namespace clang
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D49796: [ASTImporter] Load external Decls when getting field index.

2018-08-07 Thread Balázs Kéri via Phabricator via cfe-commits
balazske updated this revision to Diff 159467.
balazske added a comment.

- Added common getFieldIndex.


Repository:
  rC Clang

https://reviews.llvm.org/D49796

Files:
  include/clang/AST/ASTImporter.h
  lib/AST/ASTImporter.cpp
  test/ASTMerge/unnamed_fields/Inputs/il.cpp
  test/ASTMerge/unnamed_fields/test.cpp
  unittests/AST/ASTImporterTest.cpp

Index: unittests/AST/ASTImporterTest.cpp
===
--- unittests/AST/ASTImporterTest.cpp
+++ unittests/AST/ASTImporterTest.cpp
@@ -2612,6 +2612,40 @@
   R1, recordDecl(has(fieldDecl(hasName("next"));
 }
 
+TEST_P(ASTImporterTestBase, ImportUnnamedFieldsInCorrectOrder) {
+  Decl *FromTU = getTuDecl(
+  R"(
+  void f(int X, int Y, bool Z) {
+(void)[X, Y, Z] { (void)Z; };
+  }
+  )",
+  Lang_CXX11, "input0.cc");
+  auto *FromF = FirstDeclMatcher().match(
+  FromTU, functionDecl(hasName("f")));
+  auto *ToF = cast_or_null(Import(FromF, Lang_CXX11));
+  EXPECT_TRUE(ToF);
+
+  CXXRecordDecl *FromLambda =
+  cast(cast(cast(
+  FromF->getBody())->body_front())->getSubExpr())->getLambdaClass();
+
+  auto *ToLambda = cast_or_null(Import(FromLambda, Lang_CXX11));
+  EXPECT_TRUE(ToLambda);
+
+  // Check if the fields of the lambda class are imported in correct order.
+  unsigned FromIndex = 0u;
+  for (auto *FromField : FromLambda->fields()) {
+ASSERT_FALSE(FromField->getDeclName());
+auto *ToField = cast_or_null(Import(FromField, Lang_CXX11));
+EXPECT_TRUE(ToField);
+unsigned ToIndex = ASTImporter::getFieldIndex(ToField);
+EXPECT_EQ(ToIndex, FromIndex);
+++FromIndex;
+  }
+
+  EXPECT_EQ(FromIndex, 3u);
+}
+
 struct DeclContextTest : ASTImporterTestBase {};
 
 TEST_P(DeclContextTest, removeDeclOfClassTemplateSpecialization) {
Index: test/ASTMerge/unnamed_fields/test.cpp
===
--- /dev/null
+++ test/ASTMerge/unnamed_fields/test.cpp
@@ -0,0 +1,3 @@
+// RUN: %clang_cc1 -emit-pch -o %t.1.ast %S/Inputs/il.cpp
+// RUN: %clang_cc1 -ast-merge %t.1.ast -fsyntax-only %s 2>&1 | FileCheck --allow-empty %s
+// CHECK-NOT: warning: field '' declared with incompatible types in different translation units ('bool' vs. 'int')
Index: test/ASTMerge/unnamed_fields/Inputs/il.cpp
===
--- /dev/null
+++ test/ASTMerge/unnamed_fields/Inputs/il.cpp
@@ -0,0 +1,3 @@
+void f(int X, int Y, bool Z) {
+  auto x = [X, Y, Z] { (void)Z; };
+}
Index: lib/AST/ASTImporter.cpp
===
--- lib/AST/ASTImporter.cpp
+++ lib/AST/ASTImporter.cpp
@@ -71,6 +71,28 @@
 
 namespace clang {
 
+  unsigned ASTImporter::getFieldIndex(Decl *F) {
+assert(F && (isa(*F) || isa(*F)) &&
+"Try to get field index for non-field.");
+
+auto *Owner = dyn_cast(F->getDeclContext());
+if (!Owner)
+  return 0;
+
+unsigned Index = 1;
+for (const auto *D : Owner->decls()) {
+  if (D == F)
+return Index;
+
+  if (isa(*D) || isa(*D))
+++Index;
+}
+
+llvm_unreachable("Field was not found in its parent context.");
+
+return 0;
+  }
+
   template 
   SmallVector
   getCanonicalForwardRedeclChain(Redeclarable* D) {
@@ -2823,23 +2845,6 @@
   return VisitCXXMethodDecl(D);
 }
 
-static unsigned getFieldIndex(Decl *F) {
-  auto *Owner = dyn_cast(F->getDeclContext());
-  if (!Owner)
-return 0;
-
-  unsigned Index = 1;
-  for (const auto *D : Owner->noload_decls()) {
-if (D == F)
-  return Index;
-
-if (isa(*D) || isa(*D))
-  ++Index;
-  }
-
-  return Index;
-}
-
 Decl *ASTNodeImporter::VisitFieldDecl(FieldDecl *D) {
   // Import the major distinguishing characteristics of a variable.
   DeclContext *DC, *LexicalDC;
@@ -2857,7 +2862,9 @@
   for (auto *FoundDecl : FoundDecls) {
 if (auto *FoundField = dyn_cast(FoundDecl)) {
   // For anonymous fields, match up by index.
-  if (!Name && getFieldIndex(D) != getFieldIndex(FoundField))
+  if (!Name &&
+  ASTImporter::getFieldIndex(D) !=
+  ASTImporter::getFieldIndex(FoundField))
 continue;
 
   if (Importer.IsStructurallyEquivalent(D->getType(),
@@ -2922,7 +2929,9 @@
   for (unsigned I = 0, N = FoundDecls.size(); I != N; ++I) {
 if (auto *FoundField = dyn_cast(FoundDecls[I])) {
   // For anonymous indirect fields, match up by index.
-  if (!Name && getFieldIndex(D) != getFieldIndex(FoundField))
+  if (!Name &&
+  ASTImporter::getFieldIndex(D) !=
+  ASTImporter::getFieldIndex(FoundField))
 continue;
 
   if (Importer.IsStructurallyEquivalent(D->getType(),
Index: include/clang/AST/ASTImporter.h
===
--- include/clang/AST/ASTImporter.h
+++ include/clang/AST/ASTImporter.h
@@ -333,6 +333,13 @@
 /// equivalent.
 bool IsStructurallyEquivalent(QualType From, QualT

[clang-tools-extra] r339116 - [clangd] Share getSymbolID implementation.

2018-08-07 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Tue Aug  7 01:57:52 2018
New Revision: 339116

URL: http://llvm.org/viewvc/llvm-project?rev=339116&view=rev
Log:
[clangd] Share getSymbolID implementation.

Summary: And remove all duplicated implementation.

Reviewers: ioeric

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits

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

Modified:
clang-tools-extra/trunk/clangd/AST.cpp
clang-tools-extra/trunk/clangd/AST.h
clang-tools-extra/trunk/clangd/CodeComplete.cpp
clang-tools-extra/trunk/clangd/XRefs.cpp
clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp

Modified: clang-tools-extra/trunk/clangd/AST.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/AST.cpp?rev=339116&r1=339115&r2=339116&view=diff
==
--- clang-tools-extra/trunk/clangd/AST.cpp (original)
+++ clang-tools-extra/trunk/clangd/AST.cpp Tue Aug  7 01:57:52 2018
@@ -12,6 +12,7 @@
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/Decl.h"
 #include "clang/Basic/SourceManager.h"
+#include "clang/Index/USRGeneration.h"
 
 namespace clang {
 namespace clangd {
@@ -53,5 +54,12 @@ std::string printQualifiedName(const Nam
   return QName;
 }
 
+llvm::Optional getSymbolID(const Decl *D) {
+  llvm::SmallString<128> USR;
+  if (index::generateUSRForDecl(D, USR))
+return None;
+  return SymbolID(USR);
+}
+
 } // namespace clangd
 } // namespace clang

Modified: clang-tools-extra/trunk/clangd/AST.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/AST.h?rev=339116&r1=339115&r2=339116&view=diff
==
--- clang-tools-extra/trunk/clangd/AST.h (original)
+++ clang-tools-extra/trunk/clangd/AST.h Tue Aug  7 01:57:52 2018
@@ -16,6 +16,7 @@
 
 #include "clang/AST/Decl.h"
 #include "clang/Basic/SourceLocation.h"
+#include "index/Index.h"
 
 namespace clang {
 class SourceManager;
@@ -33,6 +34,9 @@ SourceLocation findNameLoc(const clang::
 /// like inline namespaces.
 std::string printQualifiedName(const NamedDecl &ND);
 
+/// Gets the symbol ID for a declaration, if possible.
+llvm::Optional getSymbolID(const Decl *D);
+
 } // namespace clangd
 } // namespace clang
 

Modified: clang-tools-extra/trunk/clangd/CodeComplete.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/CodeComplete.cpp?rev=339116&r1=339115&r2=339116&view=diff
==
--- clang-tools-extra/trunk/clangd/CodeComplete.cpp (original)
+++ clang-tools-extra/trunk/clangd/CodeComplete.cpp Tue Aug  7 01:57:52 2018
@@ -396,10 +396,7 @@ llvm::Optional getSymbolID(con
   switch (R.Kind) {
   case CodeCompletionResult::RK_Declaration:
   case CodeCompletionResult::RK_Pattern: {
-llvm::SmallString<128> USR;
-if (/*Ignore=*/clang::index::generateUSRForDecl(R.Declaration, USR))
-  return None;
-return SymbolID(USR);
+return clang::clangd::getSymbolID(R.Declaration);
   }
   case CodeCompletionResult::RK_Macro:
 // FIXME: Macros do have USRs, but the CCR doesn't contain enough info.

Modified: clang-tools-extra/trunk/clangd/XRefs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/XRefs.cpp?rev=339116&r1=339115&r2=339116&view=diff
==
--- clang-tools-extra/trunk/clangd/XRefs.cpp (original)
+++ clang-tools-extra/trunk/clangd/XRefs.cpp Tue Aug  7 01:57:52 2018
@@ -202,15 +202,6 @@ makeLocation(ParsedAST &AST, const Sourc
   return L;
 }
 
-// Get the symbol ID for a declaration, if possible.
-llvm::Optional getSymbolID(const Decl *D) {
-  llvm::SmallString<128> USR;
-  if (index::generateUSRForDecl(D, USR)) {
-return None;
-  }
-  return SymbolID(USR);
-}
-
 } // namespace
 
 std::vector findDefinitions(ParsedAST &AST, Position Pos,

Modified: clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp?rev=339116&r1=339115&r2=339116&view=diff
==
--- clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp Tue Aug  7 
01:57:52 2018
@@ -320,21 +320,20 @@ bool SymbolCollector::handleDeclOccurenc
   if (!shouldCollectSymbol(*ND, *ASTCtx, Opts))
 return true;
 
-  llvm::SmallString<128> USR;
-  if (index::generateUSRForDecl(ND, USR))
+  auto ID = getSymbolID(ND);
+  if (!ID)
 return true;
-  SymbolID ID(USR);
 
   const NamedDecl &OriginalDecl = *cast(ASTNode.OrigD);
-  const Symbol *BasicSymbol = Symbols.find(ID);
+  const Symbol *BasicSymbol = Symbols.find(*ID);
   if (!BasicSymbol) // Regardless of role, ND is the canonical declaration.
-BasicSymbol = addDeclaration(*ND, std::move(ID

[PATCH] D50375: [clangd] Share getSymbolID implementation.

2018-08-07 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL339116: [clangd] Share getSymbolID implementation. (authored 
by hokein, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D50375

Files:
  clang-tools-extra/trunk/clangd/AST.cpp
  clang-tools-extra/trunk/clangd/AST.h
  clang-tools-extra/trunk/clangd/CodeComplete.cpp
  clang-tools-extra/trunk/clangd/XRefs.cpp
  clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp

Index: clang-tools-extra/trunk/clangd/AST.cpp
===
--- clang-tools-extra/trunk/clangd/AST.cpp
+++ clang-tools-extra/trunk/clangd/AST.cpp
@@ -12,6 +12,7 @@
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/Decl.h"
 #include "clang/Basic/SourceManager.h"
+#include "clang/Index/USRGeneration.h"
 
 namespace clang {
 namespace clangd {
@@ -53,5 +54,12 @@
   return QName;
 }
 
+llvm::Optional getSymbolID(const Decl *D) {
+  llvm::SmallString<128> USR;
+  if (index::generateUSRForDecl(D, USR))
+return None;
+  return SymbolID(USR);
+}
+
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp
===
--- clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp
+++ clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp
@@ -320,21 +320,20 @@
   if (!shouldCollectSymbol(*ND, *ASTCtx, Opts))
 return true;
 
-  llvm::SmallString<128> USR;
-  if (index::generateUSRForDecl(ND, USR))
+  auto ID = getSymbolID(ND);
+  if (!ID)
 return true;
-  SymbolID ID(USR);
 
   const NamedDecl &OriginalDecl = *cast(ASTNode.OrigD);
-  const Symbol *BasicSymbol = Symbols.find(ID);
+  const Symbol *BasicSymbol = Symbols.find(*ID);
   if (!BasicSymbol) // Regardless of role, ND is the canonical declaration.
-BasicSymbol = addDeclaration(*ND, std::move(ID));
+BasicSymbol = addDeclaration(*ND, std::move(*ID));
   else if (isPreferredDeclaration(OriginalDecl, Roles))
 // If OriginalDecl is preferred, replace the existing canonical
 // declaration (e.g. a class forward declaration). There should be at most
 // one duplicate as we expect to see only one preferred declaration per
 // TU, because in practice they are definitions.
-BasicSymbol = addDeclaration(OriginalDecl, std::move(ID));
+BasicSymbol = addDeclaration(OriginalDecl, std::move(*ID));
 
   if (Roles & static_cast(index::SymbolRole::Definition))
 addDefinition(OriginalDecl, *BasicSymbol);
@@ -423,9 +422,9 @@
 }
   };
   for (const NamedDecl *ND : ReferencedDecls) {
-llvm::SmallString<128> USR;
-if (!index::generateUSRForDecl(ND, USR))
-  IncRef(SymbolID(USR));
+if (auto ID = getSymbolID(ND)) {
+  IncRef(*ID);
+}
   }
   if (Opts.CollectMacro) {
 assert(PP);
Index: clang-tools-extra/trunk/clangd/AST.h
===
--- clang-tools-extra/trunk/clangd/AST.h
+++ clang-tools-extra/trunk/clangd/AST.h
@@ -16,6 +16,7 @@
 
 #include "clang/AST/Decl.h"
 #include "clang/Basic/SourceLocation.h"
+#include "index/Index.h"
 
 namespace clang {
 class SourceManager;
@@ -33,6 +34,9 @@
 /// like inline namespaces.
 std::string printQualifiedName(const NamedDecl &ND);
 
+/// Gets the symbol ID for a declaration, if possible.
+llvm::Optional getSymbolID(const Decl *D);
+
 } // namespace clangd
 } // namespace clang
 
Index: clang-tools-extra/trunk/clangd/XRefs.cpp
===
--- clang-tools-extra/trunk/clangd/XRefs.cpp
+++ clang-tools-extra/trunk/clangd/XRefs.cpp
@@ -202,15 +202,6 @@
   return L;
 }
 
-// Get the symbol ID for a declaration, if possible.
-llvm::Optional getSymbolID(const Decl *D) {
-  llvm::SmallString<128> USR;
-  if (index::generateUSRForDecl(D, USR)) {
-return None;
-  }
-  return SymbolID(USR);
-}
-
 } // namespace
 
 std::vector findDefinitions(ParsedAST &AST, Position Pos,
Index: clang-tools-extra/trunk/clangd/CodeComplete.cpp
===
--- clang-tools-extra/trunk/clangd/CodeComplete.cpp
+++ clang-tools-extra/trunk/clangd/CodeComplete.cpp
@@ -396,10 +396,7 @@
   switch (R.Kind) {
   case CodeCompletionResult::RK_Declaration:
   case CodeCompletionResult::RK_Pattern: {
-llvm::SmallString<128> USR;
-if (/*Ignore=*/clang::index::generateUSRForDecl(R.Declaration, USR))
-  return None;
-return SymbolID(USR);
+return clang::clangd::getSymbolID(R.Declaration);
   }
   case CodeCompletionResult::RK_Macro:
 // FIXME: Macros do have USRs, but the CCR doesn't contain enough info.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D50376: AMDGPU: Fix enabling denormals by default on pre-VI targets

2018-08-07 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm created this revision.
arsenm added reviewers: b-sumner, kzhuravl.
Herald added subscribers: t-tye, tpr, dstuttard, yaxunl, nhaehnle, wdng.

Fast FMAF is not a sufficient condition to enable denormals.
Before VI, enabling denormals caused https://reviews.llvm.org/F32 instructions 
to
run at https://reviews.llvm.org/F64 speeds.


https://reviews.llvm.org/D50376

Files:
  lib/Basic/Targets/AMDGPU.cpp
  lib/Basic/Targets/AMDGPU.h
  test/CodeGenOpenCL/denorms-are-zero.cl

Index: test/CodeGenOpenCL/denorms-are-zero.cl
===
--- test/CodeGenOpenCL/denorms-are-zero.cl
+++ test/CodeGenOpenCL/denorms-are-zero.cl
@@ -1,8 +1,26 @@
 // RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s
-// RUN: %clang_cc1 -emit-llvm -cl-denorms-are-zero -o - %s | FileCheck %s --check-prefix=DENORM-ZERO
-// RUN: %clang_cc1 -emit-llvm -cl-denorms-are-zero -o - -triple amdgcn--amdhsa -target-cpu fiji %s | FileCheck %s --check-prefix=AMDGCN
-// RUN: %clang_cc1 -emit-llvm -o - -triple amdgcn--amdhsa -target-cpu fiji %s | FileCheck %s --check-prefix=AMDGCN-DENORM
-// RUN: %clang_cc1 -emit-llvm -target-feature +fp32-denormals -target-feature -fp64-fp16-denormals -cl-denorms-are-zero -o - -triple amdgcn--amdhsa -target-cpu fiji %s | FileCheck --check-prefix=AMDGCN-FEATURE %s
+// RUN: %clang_cc1 -emit-llvm -cl-denorms-are-zero -o - %s | FileCheck -check-prefix=DENORM-ZERO %s
+
+// Slow FMAF and slow f32 denormals
+// RUN: %clang_cc1 -emit-llvm -o - -triple amdgcn--amdhsa -target-cpu pitcairn %s | FileCheck -check-prefixes=AMDGCN,AMDGCN-FLUSH %s
+// RUN: %clang_cc1 -emit-llvm -cl-denorms-are-zero -o - -triple amdgcn--amdhsa -target-cpu pitcairn %s | FileCheck -check-prefixes=AMDGCN,AMDGCN-FLUSH-OPT %s
+
+// Fast FMAF, but slow f32 denormals
+// RUN: %clang_cc1 -emit-llvm -o - -triple amdgcn--amdhsa -target-cpu tahiti %s | FileCheck -check-prefixes=AMDGCN,AMDGCN-FLUSH %s
+// RUN: %clang_cc1 -emit-llvm -cl-denorms-are-zero -o - -triple amdgcn--amdhsa -target-cpu tahiti %s | FileCheck -check-prefixes=AMDGCN,AMDGCN-FLUSH-OPT %s
+
+// Fast F32 denormals, but slow FMAF
+// RUN: %clang_cc1 -emit-llvm -o - -triple amdgcn--amdhsa -target-cpu fiji %s | FileCheck -check-prefixes=AMDGCN,AMDGCN-FLUSH %s
+// RUN: %clang_cc1 -emit-llvm -cl-denorms-are-zero -o - -triple amdgcn--amdhsa -target-cpu fiji %s | FileCheck -check-prefixes=AMDGCN,AMDGCN-FLUSH-OPT %s
+
+// Fast F32 denormals and fast FMAF
+// RUN: %clang_cc1 -emit-llvm -o - -triple amdgcn--amdhsa -target-cpu gfx900 %s | FileCheck -check-prefixes=AMDGCN,AMDGCN-DENORM %s
+// RUN: %clang_cc1 -emit-llvm -cl-denorms-are-zero -o - -triple amdgcn--amdhsa -target-cpu gfx900 %s | FileCheck -check-prefixes=AMDGCN,AMDGCN-FLUSH-OPT %s
+
+// RUN: %clang_cc1 -emit-llvm -target-feature +fp32-denormals -target-feature -fp64-fp16-denormals -cl-denorms-are-zero -o - -triple amdgcn--amdhsa -target-cpu fiji %s | FileCheck -check-prefixes=AMDGCN,AMDGCN-FEATURE %s
+// RUN: %clang_cc1 -emit-llvm -target-feature +fp32-denormals -target-feature -fp64-fp16-denormals -cl-denorms-are-zero -o - -triple amdgcn--amdhsa -target-cpu pitcairn %s | FileCheck -check-prefixes=AMDGCN,AMDGCN-FEATURE %s
+
+
 
 // For all targets 'denorms-are-zero' attribute is set to 'true'
 // if '-cl-denorms-are-zero' was specified and  to 'false' otherwise.
@@ -17,9 +35,11 @@
 // explicitly set. amdgcn target always do not flush fp64 denormals. The control for fp64 and fp16 denormals is the same.
 
 // AMDGCN-LABEL: define void @f()
-// AMDGCN: attributes #{{[0-9]*}} = {{{[^}]*}} "denorms-are-zero"="true" {{.*}} "target-features"="{{[^"]*}}+fp64-fp16-denormals,{{[^"]*}}-fp32-denormals{{[^"]*}}"
-// AMDGCN-DENORM-LABEL: define void @f()
-// AMDGCN-DENORM: attributes #{{[0-9]*}} = {{{[^}]*}} "denorms-are-zero"="false" {{.*}} "target-features"="{{[^"]*}}+fp64-fp16-denormals,{{[^"]*}}-fp32-denormals{{[^"]*}}"
-// AMDGCN-FEATURE-LABEL: define void @f()
+
+// AMDGCN-FLUSH: attributes #{{[0-9]*}} = {{{[^}]*}} "denorms-are-zero"="false" {{.*}} "target-features"="{{[^"]*}}+fp64-fp16-denormals,{{[^"]*}}-fp32-denormals{{[^"]*}}"
+// AMDGCN-FLUSH-OPT: attributes #{{[0-9]*}} = {{{[^}]*}} "denorms-are-zero"="true" {{.*}} "target-features"="{{[^"]*}}+fp64-fp16-denormals,{{[^"]*}}-fp32-denormals{{[^"]*}}"
+
+// AMDGCN-DENORM: attributes #{{[0-9]*}} = {{{[^}]*}} "denorms-are-zero"="false" {{.*}} "target-features"="{{[^"]*}}+fp32-denormals,{{[^"]*}}+fp64-fp16-denormals{{[^"]*}}"
+
 // AMDGCN-FEATURE: attributes #{{[0-9]*}} = {{{[^}]*}} "denorms-are-zero"="true" {{.*}} "target-features"="{{[^"]*}}+fp32-denormals,{{[^"]*}}-fp64-fp16-denormals{{[^"]*}}"
 void f() {}
Index: lib/Basic/Targets/AMDGPU.h
===
--- lib/Basic/Targets/AMDGPU.h
+++ lib/Basic/Targets/AMDGPU.h
@@ -94,77 +94,78 @@
 bool HasLDEXPF;
 bool HasFP64;
 bool HasFastFMA;
+bool HasFullRateF32Denorms;
   };
 
   static constexpr GPUInfo InvalidGPU =
-{{""}, {""}, GK_

[PATCH] D50337: [clangd] DexIndex implementation prototype

2018-08-07 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev added a comment.

As discussed offline, incomplete trigrams (unigrams and bigrams generation) 
should be a blocker for this patch, because otherwise it isn't functional. Once 
incomplete trigrams are in, `MemIndex` tests can be reused for `DexIndex` to 
ensure stability.


https://reviews.llvm.org/D50337



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


[PATCH] D50378: [clang-format] comment reflow: add last line's penalty when ending broken

2018-08-07 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir created this revision.
Herald added a subscriber: cfe-commits.

This fixes a bug in clang-format where the last line's penalty is not
taken into account when its ending is broken. Usually the last line's penalty
is handled by addNextStateToQueue, but in cases where the trailing `*/` is put
on a newline, the contents of the last line have to be considered for 
penalizing.


Repository:
  rC Clang

https://reviews.llvm.org/D50378

Files:
  lib/Format/ContinuationIndenter.cpp
  unittests/Format/FormatTestJS.cpp


Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -2284,5 +2284,25 @@
"formatMe( );\n");
 }
 
+TEST_F(FormatTestJS, AddsLastLinePenaltyIfEndingIsBroken) {
+  EXPECT_EQ(
+  "a = function() {\n"
+  "  b = function() {\n"
+  "this.aaa[aaa] = .aa ?\n"
+  ".aa : /** @type "
+  "{..a.aaa} */\n"
+  "(..a.a.a);\n"
+  "  };\n"
+  "};",
+  format("a = function() {\n"
+ "  b = function() {\n"
+ "this.aaa[aaa] = .aa ? "
+ ".aa : /** @type "
+ "{..a.aaa} */\n"
+ "(..a.a.a);\n"
+ "  };\n"
+ "};"));
+}
+
 } // end namespace tooling
 } // end namespace clang
Index: lib/Format/ContinuationIndenter.cpp
===
--- lib/Format/ContinuationIndenter.cpp
+++ lib/Format/ContinuationIndenter.cpp
@@ -1840,7 +1840,8 @@
 // No break opportunity - update the penalty and continue with the next
 // logical line.
 if (LineIndex < EndIndex - 1)
-  // The last line's penalty is handled in addNextStateToQueue().
+  // The last line's penalty is handled in addNextStateToQueue() or 
when
+  // calling replaceWhitespaceAfterLastLine below.
   Penalty += Style.PenaltyExcessCharacter *
  (ContentStartColumn + RemainingTokenColumns - 
ColumnLimit);
 LLVM_DEBUG(llvm::dbgs() << "No break opportunity.\n");
@@ -2095,6 +2096,12 @@
   Token->getSplitAfterLastLine(TailOffset);
   if (SplitAfterLastLine.first != StringRef::npos) {
 LLVM_DEBUG(llvm::dbgs() << "Replacing whitespace after last line.\n");
+
+// We add the last line's penalty here, since that line is going to be 
split
+// now.
+Penalty += Style.PenaltyExcessCharacter *
+   (ContentStartColumn + RemainingTokenColumns - ColumnLimit);
+
 if (!DryRun)
   Token->replaceWhitespaceAfterLastLine(TailOffset, SplitAfterLastLine,
 Whitespaces);


Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -2284,5 +2284,25 @@
"formatMe( );\n");
 }
 
+TEST_F(FormatTestJS, AddsLastLinePenaltyIfEndingIsBroken) {
+  EXPECT_EQ(
+  "a = function() {\n"
+  "  b = function() {\n"
+  "this.aaa[aaa] = .aa ?\n"
+  ".aa : /** @type "
+  "{..a.aaa} */\n"
+  "(..a.a.a);\n"
+  "  };\n"
+  "};",
+  format("a = function() {\n"
+ "  b = function() {\n"
+ "this.aaa[aaa] = .aa ? "
+ ".aa : /** @type "
+ "{..a.aaa} */\n"
+ "(..a.a.a);\n"
+ "  };\n"
+ "};"));
+}
+
 } // end namespace tooling
 } // end namespace clang
Index: lib/Format/ContinuationIndenter.cpp
===
--- lib/Format/ContinuationIndenter.cpp
+++ lib/Format/ContinuationIndenter.cpp
@@ -1840,7 +1840,8 @@
 // No break opportunity - update the penalty and continue with the next
 // logical line.
 if (LineIndex < EndIndex - 1)
-  // The last line's penalty is handled in addNextStateToQueue().
+  // The last line's penalty is handled in addNextStateToQueue() or when
+  // calling replaceWhitespaceAfterLastLine below.
   Penalty += Style.PenaltyExcessCharacter *
  (ContentStartColumn + RemainingTokenColumns - ColumnLimit);
 LLVM_DEBUG(llvm::dbgs() << "No break opportunity.\n");
@@ -2095,6 +2096,12 @@
   Token->getSplitAfterLastLine(TailOffset);
   if (SplitAfterLastLine.first != StringRef::npos) {
 LLVM_DEBUG(llvm::dbgs() << "

r339123 - [clang-format] comment reflow: add last line's penalty when ending broken

2018-08-07 Thread Krasimir Georgiev via cfe-commits
Author: krasimir
Date: Tue Aug  7 03:23:24 2018
New Revision: 339123

URL: http://llvm.org/viewvc/llvm-project?rev=339123&view=rev
Log:
[clang-format] comment reflow: add last line's penalty when ending broken

Summary:
This fixes a bug in clang-format where the last line's penalty is not
taken into account when its ending is broken. Usually the last line's penalty
is handled by addNextStateToQueue, but in cases where the trailing `*/` is put
on a newline, the contents of the last line have to be considered for 
penalizing.

Reviewers: mprobst

Reviewed By: mprobst

Subscribers: cfe-commits

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

Modified:
cfe/trunk/lib/Format/ContinuationIndenter.cpp
cfe/trunk/unittests/Format/FormatTestJS.cpp

Modified: cfe/trunk/lib/Format/ContinuationIndenter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/ContinuationIndenter.cpp?rev=339123&r1=339122&r2=339123&view=diff
==
--- cfe/trunk/lib/Format/ContinuationIndenter.cpp (original)
+++ cfe/trunk/lib/Format/ContinuationIndenter.cpp Tue Aug  7 03:23:24 2018
@@ -1840,7 +1840,8 @@ ContinuationIndenter::breakProtrudingTok
 // No break opportunity - update the penalty and continue with the next
 // logical line.
 if (LineIndex < EndIndex - 1)
-  // The last line's penalty is handled in addNextStateToQueue().
+  // The last line's penalty is handled in addNextStateToQueue() or 
when
+  // calling replaceWhitespaceAfterLastLine below.
   Penalty += Style.PenaltyExcessCharacter *
  (ContentStartColumn + RemainingTokenColumns - 
ColumnLimit);
 LLVM_DEBUG(llvm::dbgs() << "No break opportunity.\n");
@@ -2095,6 +2096,12 @@ ContinuationIndenter::breakProtrudingTok
   Token->getSplitAfterLastLine(TailOffset);
   if (SplitAfterLastLine.first != StringRef::npos) {
 LLVM_DEBUG(llvm::dbgs() << "Replacing whitespace after last line.\n");
+
+// We add the last line's penalty here, since that line is going to be 
split
+// now.
+Penalty += Style.PenaltyExcessCharacter *
+   (ContentStartColumn + RemainingTokenColumns - ColumnLimit);
+
 if (!DryRun)
   Token->replaceWhitespaceAfterLastLine(TailOffset, SplitAfterLastLine,
 Whitespaces);

Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=339123&r1=339122&r2=339123&view=diff
==
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Tue Aug  7 03:23:24 2018
@@ -2284,5 +2284,25 @@ TEST_F(FormatTestJS, BackslashesInCommen
"formatMe( );\n");
 }
 
+TEST_F(FormatTestJS, AddsLastLinePenaltyIfEndingIsBroken) {
+  EXPECT_EQ(
+  "a = function() {\n"
+  "  b = function() {\n"
+  "this.aaa[aaa] = .aa ?\n"
+  ".aa : /** @type "
+  "{..a.aaa} */\n"
+  "(..a.a.a);\n"
+  "  };\n"
+  "};",
+  format("a = function() {\n"
+ "  b = function() {\n"
+ "this.aaa[aaa] = .aa ? "
+ ".aa : /** @type "
+ "{..a.aaa} */\n"
+ "(..a.a.a);\n"
+ "  };\n"
+ "};"));
+}
+
 } // end namespace tooling
 } // end namespace clang


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


[PATCH] D50378: [clang-format] comment reflow: add last line's penalty when ending broken

2018-08-07 Thread Krasimir Georgiev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC339123: [clang-format] comment reflow: add last line's 
penalty when ending broken (authored by krasimir, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D50378?vs=159474&id=159476#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D50378

Files:
  lib/Format/ContinuationIndenter.cpp
  unittests/Format/FormatTestJS.cpp


Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -2284,5 +2284,25 @@
"formatMe( );\n");
 }
 
+TEST_F(FormatTestJS, AddsLastLinePenaltyIfEndingIsBroken) {
+  EXPECT_EQ(
+  "a = function() {\n"
+  "  b = function() {\n"
+  "this.aaa[aaa] = .aa ?\n"
+  ".aa : /** @type "
+  "{..a.aaa} */\n"
+  "(..a.a.a);\n"
+  "  };\n"
+  "};",
+  format("a = function() {\n"
+ "  b = function() {\n"
+ "this.aaa[aaa] = .aa ? "
+ ".aa : /** @type "
+ "{..a.aaa} */\n"
+ "(..a.a.a);\n"
+ "  };\n"
+ "};"));
+}
+
 } // end namespace tooling
 } // end namespace clang
Index: lib/Format/ContinuationIndenter.cpp
===
--- lib/Format/ContinuationIndenter.cpp
+++ lib/Format/ContinuationIndenter.cpp
@@ -1840,7 +1840,8 @@
 // No break opportunity - update the penalty and continue with the next
 // logical line.
 if (LineIndex < EndIndex - 1)
-  // The last line's penalty is handled in addNextStateToQueue().
+  // The last line's penalty is handled in addNextStateToQueue() or 
when
+  // calling replaceWhitespaceAfterLastLine below.
   Penalty += Style.PenaltyExcessCharacter *
  (ContentStartColumn + RemainingTokenColumns - 
ColumnLimit);
 LLVM_DEBUG(llvm::dbgs() << "No break opportunity.\n");
@@ -2095,6 +2096,12 @@
   Token->getSplitAfterLastLine(TailOffset);
   if (SplitAfterLastLine.first != StringRef::npos) {
 LLVM_DEBUG(llvm::dbgs() << "Replacing whitespace after last line.\n");
+
+// We add the last line's penalty here, since that line is going to be 
split
+// now.
+Penalty += Style.PenaltyExcessCharacter *
+   (ContentStartColumn + RemainingTokenColumns - ColumnLimit);
+
 if (!DryRun)
   Token->replaceWhitespaceAfterLastLine(TailOffset, SplitAfterLastLine,
 Whitespaces);


Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -2284,5 +2284,25 @@
"formatMe( );\n");
 }
 
+TEST_F(FormatTestJS, AddsLastLinePenaltyIfEndingIsBroken) {
+  EXPECT_EQ(
+  "a = function() {\n"
+  "  b = function() {\n"
+  "this.aaa[aaa] = .aa ?\n"
+  ".aa : /** @type "
+  "{..a.aaa} */\n"
+  "(..a.a.a);\n"
+  "  };\n"
+  "};",
+  format("a = function() {\n"
+ "  b = function() {\n"
+ "this.aaa[aaa] = .aa ? "
+ ".aa : /** @type "
+ "{..a.aaa} */\n"
+ "(..a.a.a);\n"
+ "  };\n"
+ "};"));
+}
+
 } // end namespace tooling
 } // end namespace clang
Index: lib/Format/ContinuationIndenter.cpp
===
--- lib/Format/ContinuationIndenter.cpp
+++ lib/Format/ContinuationIndenter.cpp
@@ -1840,7 +1840,8 @@
 // No break opportunity - update the penalty and continue with the next
 // logical line.
 if (LineIndex < EndIndex - 1)
-  // The last line's penalty is handled in addNextStateToQueue().
+  // The last line's penalty is handled in addNextStateToQueue() or when
+  // calling replaceWhitespaceAfterLastLine below.
   Penalty += Style.PenaltyExcessCharacter *
  (ContentStartColumn + RemainingTokenColumns - ColumnLimit);
 LLVM_DEBUG(llvm::dbgs() << "No break opportunity.\n");
@@ -2095,6 +2096,12 @@
   Token->getSplitAfterLastLine(TailOffset);
   if (SplitAfterLastLine.first != StringRef::npos) {
 LLVM_DEBUG(llvm::dbgs() << "Replacing whitespace after last line.\n");
+
+// We add the last line's penalty he

[PATCH] D50378: [clang-format] comment reflow: add last line's penalty when ending broken

2018-08-07 Thread Krasimir Georgiev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL339123: [clang-format] comment reflow: add last line's 
penalty when ending broken (authored by krasimir, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D50378

Files:
  cfe/trunk/lib/Format/ContinuationIndenter.cpp
  cfe/trunk/unittests/Format/FormatTestJS.cpp


Index: cfe/trunk/lib/Format/ContinuationIndenter.cpp
===
--- cfe/trunk/lib/Format/ContinuationIndenter.cpp
+++ cfe/trunk/lib/Format/ContinuationIndenter.cpp
@@ -1840,7 +1840,8 @@
 // No break opportunity - update the penalty and continue with the next
 // logical line.
 if (LineIndex < EndIndex - 1)
-  // The last line's penalty is handled in addNextStateToQueue().
+  // The last line's penalty is handled in addNextStateToQueue() or 
when
+  // calling replaceWhitespaceAfterLastLine below.
   Penalty += Style.PenaltyExcessCharacter *
  (ContentStartColumn + RemainingTokenColumns - 
ColumnLimit);
 LLVM_DEBUG(llvm::dbgs() << "No break opportunity.\n");
@@ -2095,6 +2096,12 @@
   Token->getSplitAfterLastLine(TailOffset);
   if (SplitAfterLastLine.first != StringRef::npos) {
 LLVM_DEBUG(llvm::dbgs() << "Replacing whitespace after last line.\n");
+
+// We add the last line's penalty here, since that line is going to be 
split
+// now.
+Penalty += Style.PenaltyExcessCharacter *
+   (ContentStartColumn + RemainingTokenColumns - ColumnLimit);
+
 if (!DryRun)
   Token->replaceWhitespaceAfterLastLine(TailOffset, SplitAfterLastLine,
 Whitespaces);
Index: cfe/trunk/unittests/Format/FormatTestJS.cpp
===
--- cfe/trunk/unittests/Format/FormatTestJS.cpp
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp
@@ -2284,5 +2284,25 @@
"formatMe( );\n");
 }
 
+TEST_F(FormatTestJS, AddsLastLinePenaltyIfEndingIsBroken) {
+  EXPECT_EQ(
+  "a = function() {\n"
+  "  b = function() {\n"
+  "this.aaa[aaa] = .aa ?\n"
+  ".aa : /** @type "
+  "{..a.aaa} */\n"
+  "(..a.a.a);\n"
+  "  };\n"
+  "};",
+  format("a = function() {\n"
+ "  b = function() {\n"
+ "this.aaa[aaa] = .aa ? "
+ ".aa : /** @type "
+ "{..a.aaa} */\n"
+ "(..a.a.a);\n"
+ "  };\n"
+ "};"));
+}
+
 } // end namespace tooling
 } // end namespace clang


Index: cfe/trunk/lib/Format/ContinuationIndenter.cpp
===
--- cfe/trunk/lib/Format/ContinuationIndenter.cpp
+++ cfe/trunk/lib/Format/ContinuationIndenter.cpp
@@ -1840,7 +1840,8 @@
 // No break opportunity - update the penalty and continue with the next
 // logical line.
 if (LineIndex < EndIndex - 1)
-  // The last line's penalty is handled in addNextStateToQueue().
+  // The last line's penalty is handled in addNextStateToQueue() or when
+  // calling replaceWhitespaceAfterLastLine below.
   Penalty += Style.PenaltyExcessCharacter *
  (ContentStartColumn + RemainingTokenColumns - ColumnLimit);
 LLVM_DEBUG(llvm::dbgs() << "No break opportunity.\n");
@@ -2095,6 +2096,12 @@
   Token->getSplitAfterLastLine(TailOffset);
   if (SplitAfterLastLine.first != StringRef::npos) {
 LLVM_DEBUG(llvm::dbgs() << "Replacing whitespace after last line.\n");
+
+// We add the last line's penalty here, since that line is going to be split
+// now.
+Penalty += Style.PenaltyExcessCharacter *
+   (ContentStartColumn + RemainingTokenColumns - ColumnLimit);
+
 if (!DryRun)
   Token->replaceWhitespaceAfterLastLine(TailOffset, SplitAfterLastLine,
 Whitespaces);
Index: cfe/trunk/unittests/Format/FormatTestJS.cpp
===
--- cfe/trunk/unittests/Format/FormatTestJS.cpp
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp
@@ -2284,5 +2284,25 @@
"formatMe( );\n");
 }
 
+TEST_F(FormatTestJS, AddsLastLinePenaltyIfEndingIsBroken) {
+  EXPECT_EQ(
+  "a = function() {\n"
+  "  b = function() {\n"
+  "this.aaa[aaa] = .aa ?\n"
+  ".aa : /** @type "
+  "{..a.aaa} */\n"
+  "(..a.a.a);\n"
+  "  };\n"
+  "};",
+ 

[PATCH] D50380: [Headers] Expand _Unwind_Exception for SEH on MinGW/x86_64

2018-08-07 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo created this revision.
mstorsjo added reviewers: rnk, compnerd, hans.
Herald added a subscriber: chrib.

This matches how GCC defines this struct.


Repository:
  rC Clang

https://reviews.llvm.org/D50380

Files:
  lib/Headers/unwind.h


Index: lib/Headers/unwind.h
===
--- lib/Headers/unwind.h
+++ lib/Headers/unwind.h
@@ -154,8 +154,12 @@
 struct _Unwind_Exception {
   _Unwind_Exception_Class exception_class;
   _Unwind_Exception_Cleanup_Fn exception_cleanup;
+#if !defined (__USING_SJLJ_EXCEPTIONS__) && defined (__SEH__)
+  _Unwind_Word private_[6];
+#else
   _Unwind_Word private_1;
   _Unwind_Word private_2;
+#endif
   /* The Itanium ABI requires that _Unwind_Exception objects are "double-word
* aligned".  GCC has interpreted this to mean "use the maximum useful
* alignment for the target"; so do we. */


Index: lib/Headers/unwind.h
===
--- lib/Headers/unwind.h
+++ lib/Headers/unwind.h
@@ -154,8 +154,12 @@
 struct _Unwind_Exception {
   _Unwind_Exception_Class exception_class;
   _Unwind_Exception_Cleanup_Fn exception_cleanup;
+#if !defined (__USING_SJLJ_EXCEPTIONS__) && defined (__SEH__)
+  _Unwind_Word private_[6];
+#else
   _Unwind_Word private_1;
   _Unwind_Word private_2;
+#endif
   /* The Itanium ABI requires that _Unwind_Exception objects are "double-word
* aligned".  GCC has interpreted this to mean "use the maximum useful
* alignment for the target"; so do we. */
___
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.

2018-08-07 Thread Edd Barrett via Phabricator via cfe-commits
vext01 added a comment.

Hi,

I'm generating these labels from the Rust compiler, which is far from a minimal 
example.

I'm actually conflicted about what should happen if code containing a label is 
removed, but the label is marked to be "retained". Maybe it does make sense for 
those to stay with some kind of a special offset or flag to indicate so. What 
do you think?

FWIW, my working assumption is that the `-unreachableblockelim` pass is 
removing code that contains labels, resulting in 0x0 offsets.

I'll try to get a simple example that gives a label with an 0x0 offset.


Repository:
  rL LLVM

https://reviews.llvm.org/D45045



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


r339128 - [objc-gnustep] Don't emit .guess ivar offset vars.

2018-08-07 Thread David Chisnall via cfe-commits
Author: theraven
Date: Tue Aug  7 05:02:46 2018
New Revision: 339128

URL: http://llvm.org/viewvc/llvm-project?rev=339128&view=rev
Log:
[objc-gnustep] Don't emit .guess ivar offset vars.

These were intended to allow non-fragile and fragile ABI code to be
mixed, as long as the fragile classes were higher up the hierarchy than
the non-fragile ones.  Unfortunately:

 - No one actually wants to do this.
 - Recent versions of Linux's run-time linker break it.

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

Modified: cfe/trunk/lib/CodeGen/CGObjCGNU.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCGNU.cpp?rev=339128&r1=339127&r2=339128&view=diff
==
--- cfe/trunk/lib/CodeGen/CGObjCGNU.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCGNU.cpp Tue Aug  7 05:02:46 2018
@@ -3812,40 +3812,10 @@ llvm::GlobalVariable *CGObjCGNU::ObjCIva
   // is.  This allows code compiled with non-fragile ivars to work correctly
   // when linked against code which isn't (most of the time).
   llvm::GlobalVariable *IvarOffsetPointer = TheModule.getNamedGlobal(Name);
-  if (!IvarOffsetPointer) {
-// This will cause a run-time crash if we accidentally use it.  A value of
-// 0 would seem more sensible, but will silently overwrite the isa pointer
-// causing a great deal of confusion.
-uint64_t Offset = -1;
-// We can't call ComputeIvarBaseOffset() here if we have the
-// implementation, because it will create an invalid ASTRecordLayout object
-// that we are then stuck with forever, so we only initialize the ivar
-// offset variable with a guess if we only have the interface.  The
-// initializer will be reset later anyway, when we are generating the class
-// description.
-if (!CGM.getContext().getObjCImplementation(
-  const_cast(ID)))
-  Offset = ComputeIvarBaseOffset(CGM, ID, Ivar);
-
-llvm::ConstantInt *OffsetGuess = llvm::ConstantInt::get(Int32Ty, Offset,
- /*isSigned*/true);
-// Don't emit the guess in non-PIC code because the linker will not be able
-// to replace it with the real version for a library.  In non-PIC code you
-// must compile with the fragile ABI if you want to use ivars from a
-// GCC-compiled class.
-if (CGM.getLangOpts().PICLevel) {
-  llvm::GlobalVariable *IvarOffsetGV = new llvm::GlobalVariable(TheModule,
-Int32Ty, false,
-llvm::GlobalValue::PrivateLinkage, OffsetGuess, Name+".guess");
-  IvarOffsetPointer = new llvm::GlobalVariable(TheModule,
-IvarOffsetGV->getType(), false, 
llvm::GlobalValue::LinkOnceAnyLinkage,
-IvarOffsetGV, Name);
-} else {
-  IvarOffsetPointer = new llvm::GlobalVariable(TheModule,
-  llvm::Type::getInt32PtrTy(VMContext), false,
-  llvm::GlobalValue::ExternalLinkage, nullptr, Name);
-}
-  }
+  if (!IvarOffsetPointer)
+IvarOffsetPointer = new llvm::GlobalVariable(TheModule,
+llvm::Type::getInt32PtrTy(VMContext), false,
+llvm::GlobalValue::ExternalLinkage, nullptr, Name);
   return IvarOffsetPointer;
 }
 


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


[PATCH] D49438: [analyzer][UninitializedObjectChecker] New flag to turn off dereferencing

2018-08-07 Thread Umann Kristóf via Phabricator via cfe-commits
Szelethus updated this revision to Diff 159486.
Szelethus added a comment.

Added the TODO we were discussing.


https://reviews.llvm.org/D49438

Files:
  lib/StaticAnalyzer/Checkers/UninitializedObjectChecker.cpp
  test/Analysis/cxx-uninitialized-object-inheritance.cpp
  test/Analysis/cxx-uninitialized-object-no-dereference.cpp
  test/Analysis/cxx-uninitialized-object-notes-as-warnings.cpp
  test/Analysis/cxx-uninitialized-object-ptr-ref.cpp
  test/Analysis/cxx-uninitialized-object.cpp

Index: test/Analysis/cxx-uninitialized-object.cpp
===
--- test/Analysis/cxx-uninitialized-object.cpp
+++ test/Analysis/cxx-uninitialized-object.cpp
@@ -1,6 +1,11 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.cplusplus.UninitializedObject -analyzer-config alpha.cplusplus.UninitializedObject:Pedantic=true -std=c++11 -DPEDANTIC -verify %s
-
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.cplusplus.UninitializedObject -std=c++11 -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.cplusplus.UninitializedObject \
+// RUN:   -analyzer-config alpha.cplusplus.UninitializedObject:Pedantic=true -DPEDANTIC \
+// RUN:   -analyzer-config alpha.cplusplus.UninitializedObject:CheckPointeeInitialization=true \
+// RUN:   -std=c++11 -verify  %s
+
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.cplusplus.UninitializedObject \
+// RUN:   -analyzer-config alpha.cplusplus.UninitializedObject:CheckPointeeInitialization=true \
+// RUN:   -std=c++11 -verify  %s
 
 //===--===//
 // Default constructor test.
Index: test/Analysis/cxx-uninitialized-object-ptr-ref.cpp
===
--- test/Analysis/cxx-uninitialized-object-ptr-ref.cpp
+++ test/Analysis/cxx-uninitialized-object-ptr-ref.cpp
@@ -1,6 +1,11 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.cplusplus.UninitializedObject -analyzer-config alpha.cplusplus.UninitializedObject:Pedantic=true -std=c++11 -DPEDANTIC -verify %s
-
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.cplusplus.UninitializedObject -std=c++11 -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.cplusplus.UninitializedObject \
+// RUN:   -analyzer-config alpha.cplusplus.UninitializedObject:Pedantic=true -DPEDANTIC \
+// RUN:   -analyzer-config alpha.cplusplus.UninitializedObject:CheckPointeeInitialization=true \
+// RUN:   -std=c++11 -verify  %s
+
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.cplusplus.UninitializedObject \
+// RUN:   -analyzer-config alpha.cplusplus.UninitializedObject:CheckPointeeInitialization=true \
+// RUN:   -std=c++11 -verify  %s
 
 //===--===//
 // Concrete location tests.
Index: test/Analysis/cxx-uninitialized-object-notes-as-warnings.cpp
===
--- test/Analysis/cxx-uninitialized-object-notes-as-warnings.cpp
+++ test/Analysis/cxx-uninitialized-object-notes-as-warnings.cpp
@@ -1,4 +1,7 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.cplusplus.UninitializedObject -analyzer-config alpha.cplusplus.UninitializedObject:NotesAsWarnings=true -std=c++11 -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.cplusplus.UninitializedObject \
+// RUN:   -analyzer-config alpha.cplusplus.UninitializedObject:NotesAsWarnings=true \
+// RUN:   -analyzer-config alpha.cplusplus.UninitializedObject:CheckPointeeInitialization=true \
+// RUN:   -std=c++11 -verify %s
 
 class NotesAsWarningsTest {
   int a;
Index: test/Analysis/cxx-uninitialized-object-no-dereference.cpp
===
--- /dev/null
+++ test/Analysis/cxx-uninitialized-object-no-dereference.cpp
@@ -0,0 +1,27 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.cplusplus.UninitializedObject \
+// RUN:   -std=c++11 -DPEDANTIC -verify %s
+
+class UninitPointerTest {
+  int *ptr; // expected-note{{uninitialized pointer 'this->ptr'}}
+  int dontGetFilteredByNonPedanticMode = 0;
+
+public:
+  UninitPointerTest() {} // expected-warning{{1 uninitialized field}}
+};
+
+void fUninitPointerTest() {
+  UninitPointerTest();
+}
+
+class UninitPointeeTest {
+  int *ptr; // no-note
+  int dontGetFilteredByNonPedanticMode = 0;
+
+public:
+  UninitPointeeTest(int *ptr) : ptr(ptr) {} // no-warning
+};
+
+void fUninitPointeeTest() {
+  int a;
+  UninitPointeeTest t(&a);
+}
Index: test/Analysis/cxx-uninitialized-object-inheritance.cpp
===
--- test/Analysis/cxx-uninitialized-object-inheritance.cpp
+++ test/Analysis/cxx-uninitialized-object-inheritance.cpp
@@ -1,4 +1,7 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.cplusplus.UninitializedObject -analyzer-config alpha.cplusplus.UninitializedObject:Pedantic=true -std=c++11 -

r339132 - [AST][NFC] Use unsigned in the bit-fields of PrintingPolicy

2018-08-07 Thread Bruno Ricci via cfe-commits
Author: brunoricci
Date: Tue Aug  7 05:23:41 2018
New Revision: 339132

URL: http://llvm.org/viewvc/llvm-project?rev=339132&view=rev
Log:
[AST][NFC] Use unsigned in the bit-fields of PrintingPolicy

Avoid the mix between bools and unsigned since MSVC pack
this poorly.


Modified:
cfe/trunk/include/clang/AST/PrettyPrinter.h

Modified: cfe/trunk/include/clang/AST/PrettyPrinter.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/PrettyPrinter.h?rev=339132&r1=339131&r2=339132&view=diff
==
--- cfe/trunk/include/clang/AST/PrettyPrinter.h (original)
+++ cfe/trunk/include/clang/AST/PrettyPrinter.h Tue Aug  7 05:23:41 2018
@@ -81,7 +81,7 @@ struct PrintingPolicy {
   /// declaration for "x", so that we will print "int *x"; it will be
   /// \c true when we print "y", so that we suppress printing the
   /// "const int" type specifier and instead only print the "*y".
-  bool SuppressSpecifiers : 1;
+  unsigned SuppressSpecifiers : 1;
 
   /// Whether type printing should skip printing the tag keyword.
   ///
@@ -91,7 +91,7 @@ struct PrintingPolicy {
   /// \code
   /// struct Geometry::Point;
   /// \endcode
-  bool SuppressTagKeyword : 1;
+  unsigned SuppressTagKeyword : 1;
 
   /// When true, include the body of a tag definition.
   ///
@@ -101,14 +101,14 @@ struct PrintingPolicy {
   /// \code
   /// typedef struct { int x, y; } Point;
   /// \endcode
-  bool IncludeTagDefinition : 1;
+  unsigned IncludeTagDefinition : 1;
 
   /// Suppresses printing of scope specifiers.
-  bool SuppressScope : 1;
+  unsigned SuppressScope : 1;
 
   /// Suppress printing parts of scope specifiers that don't need
   /// to be written, e.g., for inline or anonymous namespaces.
-  bool SuppressUnwrittenScope : 1;
+  unsigned SuppressUnwrittenScope : 1;
 
   /// Suppress printing of variable initializers.
   ///
@@ -121,7 +121,7 @@ struct PrintingPolicy {
   ///
   /// SuppressInitializers will be true when printing "auto x", so that the
   /// internal initializer constructed for x will not be printed.
-  bool SuppressInitializers : 1;
+  unsigned SuppressInitializers : 1;
 
   /// Whether we should print the sizes of constant array expressions as 
written
   /// in the sources.
@@ -139,12 +139,12 @@ struct PrintingPolicy {
   /// int a[104];
   /// char a[9] = "A string";
   /// \endcode
-  bool ConstantArraySizeAsWritten : 1;
+  unsigned ConstantArraySizeAsWritten : 1;
 
   /// When printing an anonymous tag name, also print the location of that
   /// entity (e.g., "enum "). Otherwise, just prints
   /// "(anonymous)" for the name.
-  bool AnonymousTagLocations : 1;
+  unsigned AnonymousTagLocations : 1;
 
   /// When true, suppress printing of the __strong lifetime qualifier in ARC.
   unsigned SuppressStrongLifetime : 1;
@@ -199,7 +199,7 @@ struct PrintingPolicy {
   /// Use whitespace and punctuation like MSVC does. In particular, this prints
   /// anonymous namespaces as `anonymous namespace' and does not insert spaces
   /// after template arguments.
-  bool MSVCFormatting : 1;
+  unsigned MSVCFormatting : 1;
 
   /// Whether we should print the constant expressions as written in the
   /// sources.
@@ -217,14 +217,14 @@ struct PrintingPolicy {
   /// 0x10
   /// 2.5e3
   /// \endcode
-  bool ConstantsAsWritten : 1;
+  unsigned ConstantsAsWritten : 1;
 
   /// When true, don't print the implicit 'self' or 'this' expressions.
-  bool SuppressImplicitBase : 1;
+  unsigned SuppressImplicitBase : 1;
 
   /// When true, print the fully qualified name of function declarations.
   /// This is the opposite of SuppressScope and thus overrules it.
-  bool FullyQualifiedName : 1;
+  unsigned FullyQualifiedName : 1;
 };
 
 } // end namespace clang


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


[PATCH] D50382: [analyzer] Fix a typo in `RegionStore.txt`.

2018-08-07 Thread Henry Wong via Phabricator via cfe-commits
MTC created this revision.
MTC added reviewers: NoQ, george.karpenkov.
Herald added subscribers: mikhail.ramalho, a.sidorin, szepet, xazax.hun.

The typo of the description for default bindings can be confusing.


Repository:
  rC Clang

https://reviews.llvm.org/D50382

Files:
  docs/analyzer/RegionStore.txt


Index: docs/analyzer/RegionStore.txt
===
--- docs/analyzer/RegionStore.txt
+++ docs/analyzer/RegionStore.txt
@@ -118,7 +118,7 @@
   int manyInts[10];
   manyInts[1] = 42;   // Creates a Direct binding for manyInts[1].
   print(manyInts[1]); // Retrieves the Direct binding for manyInts[1];
-  print(manyInts[0]); // There is no Direct binding for manyInts[1].
+  print(manyInts[0]); // There is no Direct binding for manyInts[0].
   // Is there a Default binding for the entire array?
   // There is not, but it is a stack variable, so we use
   // "uninitialized" as the default value (and emit a
@@ -166,6 +166,6 @@
 return p2.x;// The binding for FieldRegion 'p2.x' is requested.
 // There is no Direct binding, so we look for a Default
 // binding to 'p2' and find the LCV.
-// Because it's an LCV, we look at our requested region
+// Because it's a LCV, we look at our requested region
 // and see that it's the '.x' field. We ask for the value
 // of 'p.x' within the snapshot, and get back 42.


Index: docs/analyzer/RegionStore.txt
===
--- docs/analyzer/RegionStore.txt
+++ docs/analyzer/RegionStore.txt
@@ -118,7 +118,7 @@
   int manyInts[10];
   manyInts[1] = 42;   // Creates a Direct binding for manyInts[1].
   print(manyInts[1]); // Retrieves the Direct binding for manyInts[1];
-  print(manyInts[0]); // There is no Direct binding for manyInts[1].
+  print(manyInts[0]); // There is no Direct binding for manyInts[0].
   // Is there a Default binding for the entire array?
   // There is not, but it is a stack variable, so we use
   // "uninitialized" as the default value (and emit a
@@ -166,6 +166,6 @@
 return p2.x;// The binding for FieldRegion 'p2.x' is requested.
 // There is no Direct binding, so we look for a Default
 // binding to 'p2' and find the LCV.
-// Because it's an LCV, we look at our requested region
+// Because it's a LCV, we look at our requested region
 // and see that it's the '.x' field. We ask for the value
 // of 'p.x' within the snapshot, and get back 42.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D50055: Update the coding standard about NFC changes and whitespace

2018-08-07 Thread Jonas Devlieghere via Phabricator via cfe-commits
JDevlieghere added inline comments.



Comment at: docs/CodingStandards.rst:514-516
+line of code. Some common editors will automatically remove trailing whitespace
+when saving a file which causes unrelated changes to appear in diffs and
+commits.

chandlerc wrote:
> Meinersbur wrote:
> > Just to note that this policy will prohibit the use of remove 
> > trailing-whitespace feature in editors since it makes it impossible to edit 
> > the file without also 'editing' any unrelated whitespace. At the same time, 
> > since not being able to use the feature, I risk committing trailing 
> > whitespace myself (that is, some additional steps are necessary: I use 'git 
> > clang-format' which should remove traling whitespace only on edited lines 
> > and 'git diff' shows trailing whitespace in red; these are still additional 
> > steps that are easy to miss)
> I also have editor settings that risk violating this, but I just reduce my 
> patdh before submitting. This is a touch annoying with svn, but with got it 
> is pretty simple to use `git add -p` and ignore the unnecessary removals if 
> trailing whitespace 
I had the same workflow as Chandler but that became rather tedious for the LLDB 
repo where there's a lot of trailing whitespace. I ended up adding an alias to 
my git config that only stages non-whitespace changes: `anw = !sh -c 'git diff 
-U0 -w --no-color "$@" | git apply --cached --ignore-whitespace --unidiff-zero 
-'`. It's far from optimal but it works pretty well. 


https://reviews.llvm.org/D50055



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


r339134 - [AST][NFC] Use unsigned in the bit-fields of IdentifierInfo

2018-08-07 Thread Bruno Ricci via cfe-commits
Author: brunoricci
Date: Tue Aug  7 05:40:41 2018
New Revision: 339134

URL: http://llvm.org/viewvc/llvm-project?rev=339134&view=rev
Log:
[AST][NFC] Use unsigned in the bit-fields of IdentifierInfo

Avoid mixing bool and unsigned in the bit-fields of IdentifierInfo
since MSVC packs this poorly. Also clang-format the changes.

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

Modified: cfe/trunk/include/clang/Basic/IdentifierTable.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/IdentifierTable.h?rev=339134&r1=339133&r2=339134&view=diff
==
--- cfe/trunk/include/clang/Basic/IdentifierTable.h (original)
+++ cfe/trunk/include/clang/Basic/IdentifierTable.h Tue Aug  7 05:40:41 2018
@@ -50,36 +50,60 @@ using IdentifierLocPair = std::pair *Entry = nullptr;


___
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.

2018-08-07 Thread Edd Barrett via Phabricator via cfe-commits
vext01 added a comment.

Got one!

Here's a dumb program which simply adds 3 to 1 using a function. There is one 
label in the `add_3` function, named `XXXYYYZZZ`:

  ; ModuleID = 'mymod'
  source_filename = "mymod"
  
  define i32 @add_3(i32 %x) !dbg !3 {
  entry:
%res = add i32 %x, 3, !dbg !9
call void @llvm.dbg.label(metadata !8), !dbg !9
ret i32 %res, !dbg !9
  }
  
  ; Function Attrs: nounwind readnone speculatable
  declare void @llvm.dbg.label(metadata) #0
  
  define i32 @main() {
  entry:
%0 = call i32 @add_3(i32 1)
ret i32 %0
  }
  
  attributes #0 = { nounwind readnone speculatable }
  
  !llvm.module.flags = !{!0}
  !llvm.dbg.cu = !{!1}
  
  !0 = !{i32 2, !"Debug Info Version", i32 3}
  !1 = distinct !DICompileUnit(language: DW_LANG_C, file: !2, producer: "API 
Example", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
  !2 = !DIFile(filename: "main.xxx", directory: ".")
  !3 = distinct !DISubprogram(name: "add_3", scope: null, file: !2, type: !4, 
isLocal: false, isDefinition: true, flags: DIFlagPrototyped, isOptimized: 
false, unit: !1, retainedNodes: !7)
  !4 = !DISubroutineType(types: !5)
  !5 = !{!6, !6}
  !6 = !DIBasicType(name: "u32", size: 32, encoding: DW_ATE_unsigned)
  !7 = !{!8}
  !8 = !DILabel(scope: !3, name: "XXXYYYZZZ", file: !2, line: 1)
  !9 = !DILocation(line: 0, column: 1, scope: !3)

If we compile this (using LLVM just before your change was backed out), and 
inspect the debuginfo:

  $ clang -g -c -O0 -o example.o example.ll
  warning: overriding the module target triple with x86_64-unknown-linux-gnu 
[-Woverride-module]
  1 warning generated.
  $ dwarfdump example.o
  ...
  < 2><0x0041>  DW_TAG_label
  DW_AT_name  XXXYYYZZZ
  DW_AT_decl_file 0x0001 ./main.xxx
  DW_AT_decl_line 0x0001
  DW_AT_low_pc0x
  ...

Here we can see that `DW_AT_low_pc` is 0. What does this mean? Perhaps a bug? 
The code is clearly not dead, although I would understand if `add_3` were 
inlined. Either way, I'd expect a non-zero `low_pc`, right?


Repository:
  rL LLVM

https://reviews.llvm.org/D45045



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


r339135 - [analyzer][UninitializedObjectChecker] New flag to turn off dereferencing

2018-08-07 Thread Kristof Umann via cfe-commits
Author: szelethus
Date: Tue Aug  7 05:55:26 2018
New Revision: 339135

URL: http://llvm.org/viewvc/llvm-project?rev=339135&view=rev
Log:
[analyzer][UninitializedObjectChecker] New flag to turn off dereferencing

Even for a checker being in alpha, some reports about pointees held so little
value to the user that it's safer to disable pointer/reference chasing for now.
It can be enabled with a new flag, in which case checker should function as it
has always been. This can be set with `CheckPointeeInitialization`.

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

Added:
cfe/trunk/test/Analysis/cxx-uninitialized-object-no-dereference.cpp
Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObjectChecker.cpp
cfe/trunk/test/Analysis/cxx-uninitialized-object-inheritance.cpp
cfe/trunk/test/Analysis/cxx-uninitialized-object-notes-as-warnings.cpp
cfe/trunk/test/Analysis/cxx-uninitialized-object-ptr-ref.cpp
cfe/trunk/test/Analysis/cxx-uninitialized-object.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObjectChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObjectChecker.cpp?rev=339135&r1=339134&r2=339135&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObjectChecker.cpp 
(original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObjectChecker.cpp Tue 
Aug  7 05:55:26 2018
@@ -10,19 +10,33 @@
 // This file defines a checker that reports uninitialized fields in objects
 // created after a constructor call.
 //
-// This checker has two options:
+// This checker has several options:
 //   - "Pedantic" (boolean). If its not set or is set to false, the checker
 // won't emit warnings for objects that don't have at least one initialized
 // field. This may be set with
 //
-//  `-analyzer-config alpha.cplusplus.UninitializedObject:Pedantic=true`.
+// `-analyzer-config alpha.cplusplus.UninitializedObject:Pedantic=true`.
 //
 //   - "NotesAsWarnings" (boolean). If set to true, the checker will emit a
 // warning for each uninitalized field, as opposed to emitting one warning
 // per constructor call, and listing the uninitialized fields that belongs
 // to it in notes. Defaults to false.
 //
-//  `-analyzer-config 
alpha.cplusplus.UninitializedObject:NotesAsWarnings=true`.
+// `-analyzer-config \
+// alpha.cplusplus.UninitializedObject:NotesAsWarnings=true`.
+//
+//   - "CheckPointeeInitialization" (boolean). If set to false, the checker 
will
+// not analyze the pointee of pointer/reference fields, and will only check
+// whether the object itself is initialized. Defaults to false.
+//
+// `-analyzer-config \
+// 
alpha.cplusplus.UninitializedObject:CheckPointeeInitialization=true`.
+//
+// TODO: With some clever heuristics, some pointers should be dereferenced
+// by default. For example, if the pointee is constructed within the
+// constructor call, it's reasonable to say that no external object
+// references it, and we wouldn't generate multiple report on the same
+// pointee.
 //
 
//===--===//
 
@@ -44,6 +58,7 @@ public:
   // These fields will be initialized when registering the checker.
   bool IsPedantic;
   bool ShouldConvertNotesToWarnings;
+  bool CheckPointeeInitialization;
 
   UninitializedObjectChecker()
   : BT_uninitField(new BuiltinBug(this, "Uninitialized fields")) {}
@@ -109,13 +124,16 @@ class FindUninitializedFields {
   const TypedValueRegion *const ObjectR;
 
   const bool IsPedantic;
+  const bool CheckPointeeInitialization;
+
   bool IsAnyFieldInitialized = false;
 
   UninitFieldSet UninitFields;
 
 public:
   FindUninitializedFields(ProgramStateRef State,
-  const TypedValueRegion *const R, bool IsPedantic);
+  const TypedValueRegion *const R, bool IsPedantic,
+  bool CheckPointeeInitialization);
   const UninitFieldSet &getUninitFields();
 
 private:
@@ -262,8 +280,8 @@ void UninitializedObjectChecker::checkEn
   if (!Object)
 return;
 
-  FindUninitializedFields F(Context.getState(), Object->getRegion(),
-IsPedantic);
+  FindUninitializedFields F(Context.getState(), Object->getRegion(), 
IsPedantic,
+CheckPointeeInitialization);
 
   const UninitFieldSet &UninitFields = F.getUninitFields();
 
@@ -327,8 +345,10 @@ void UninitializedObjectChecker::checkEn
 
//===--===//
 
 FindUninitializedFields::FindUninitializedFields(
-ProgramStateRef State, const TypedValueRegion *const R, bool IsPedantic)
-: State(State), ObjectR(R), IsPedantic(IsPedantic) {}
+ProgramStateRef State, const TypedValueRegion *const R, bool IsPedantic,
+bool Ch

[PATCH] D49438: [analyzer][UninitializedObjectChecker] New flag to turn off dereferencing

2018-08-07 Thread Umann Kristóf via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC339135: [analyzer][UninitializedObjectChecker] New flag to 
turn off dereferencing (authored by Szelethus, committed by ).

Repository:
  rC Clang

https://reviews.llvm.org/D49438

Files:
  lib/StaticAnalyzer/Checkers/UninitializedObjectChecker.cpp
  test/Analysis/cxx-uninitialized-object-inheritance.cpp
  test/Analysis/cxx-uninitialized-object-no-dereference.cpp
  test/Analysis/cxx-uninitialized-object-notes-as-warnings.cpp
  test/Analysis/cxx-uninitialized-object-ptr-ref.cpp
  test/Analysis/cxx-uninitialized-object.cpp

Index: test/Analysis/cxx-uninitialized-object-ptr-ref.cpp
===
--- test/Analysis/cxx-uninitialized-object-ptr-ref.cpp
+++ test/Analysis/cxx-uninitialized-object-ptr-ref.cpp
@@ -1,6 +1,11 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.cplusplus.UninitializedObject -analyzer-config alpha.cplusplus.UninitializedObject:Pedantic=true -std=c++11 -DPEDANTIC -verify %s
-
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.cplusplus.UninitializedObject -std=c++11 -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.cplusplus.UninitializedObject \
+// RUN:   -analyzer-config alpha.cplusplus.UninitializedObject:Pedantic=true -DPEDANTIC \
+// RUN:   -analyzer-config alpha.cplusplus.UninitializedObject:CheckPointeeInitialization=true \
+// RUN:   -std=c++11 -verify  %s
+
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.cplusplus.UninitializedObject \
+// RUN:   -analyzer-config alpha.cplusplus.UninitializedObject:CheckPointeeInitialization=true \
+// RUN:   -std=c++11 -verify  %s
 
 //===--===//
 // Concrete location tests.
Index: test/Analysis/cxx-uninitialized-object-no-dereference.cpp
===
--- test/Analysis/cxx-uninitialized-object-no-dereference.cpp
+++ test/Analysis/cxx-uninitialized-object-no-dereference.cpp
@@ -0,0 +1,27 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.cplusplus.UninitializedObject \
+// RUN:   -std=c++11 -DPEDANTIC -verify %s
+
+class UninitPointerTest {
+  int *ptr; // expected-note{{uninitialized pointer 'this->ptr'}}
+  int dontGetFilteredByNonPedanticMode = 0;
+
+public:
+  UninitPointerTest() {} // expected-warning{{1 uninitialized field}}
+};
+
+void fUninitPointerTest() {
+  UninitPointerTest();
+}
+
+class UninitPointeeTest {
+  int *ptr; // no-note
+  int dontGetFilteredByNonPedanticMode = 0;
+
+public:
+  UninitPointeeTest(int *ptr) : ptr(ptr) {} // no-warning
+};
+
+void fUninitPointeeTest() {
+  int a;
+  UninitPointeeTest t(&a);
+}
Index: test/Analysis/cxx-uninitialized-object.cpp
===
--- test/Analysis/cxx-uninitialized-object.cpp
+++ test/Analysis/cxx-uninitialized-object.cpp
@@ -1,6 +1,11 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.cplusplus.UninitializedObject -analyzer-config alpha.cplusplus.UninitializedObject:Pedantic=true -std=c++11 -DPEDANTIC -verify %s
-
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.cplusplus.UninitializedObject -std=c++11 -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.cplusplus.UninitializedObject \
+// RUN:   -analyzer-config alpha.cplusplus.UninitializedObject:Pedantic=true -DPEDANTIC \
+// RUN:   -analyzer-config alpha.cplusplus.UninitializedObject:CheckPointeeInitialization=true \
+// RUN:   -std=c++11 -verify  %s
+
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.cplusplus.UninitializedObject \
+// RUN:   -analyzer-config alpha.cplusplus.UninitializedObject:CheckPointeeInitialization=true \
+// RUN:   -std=c++11 -verify  %s
 
 //===--===//
 // Default constructor test.
Index: test/Analysis/cxx-uninitialized-object-inheritance.cpp
===
--- test/Analysis/cxx-uninitialized-object-inheritance.cpp
+++ test/Analysis/cxx-uninitialized-object-inheritance.cpp
@@ -1,4 +1,7 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.cplusplus.UninitializedObject -analyzer-config alpha.cplusplus.UninitializedObject:Pedantic=true -std=c++11 -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.cplusplus.UninitializedObject \
+// RUN: -analyzer-config alpha.cplusplus.UninitializedObject:Pedantic=true -DPEDANTIC \
+// RUN: -analyzer-config alpha.cplusplus.UninitializedObject:CheckPointeeInitialization=true \
+// RUN: -std=c++11 -verify  %s
 
 //===--===//
 // Non-polymorphic inheritance tests
Index: test/Analysis/cxx-uninitialized-object-notes-as-warnings.cpp
===
--- test/Analysis/cxx-uninitialized-object-notes-as-warnings.cp

[PATCH] D48436: [analyzer][UninitializedObjectChecker] Fixed a false negative by no longer filtering out certain constructor calls

2018-08-07 Thread Umann Kristóf via Phabricator via cfe-commits
Szelethus added a comment.

Polite ping :)


https://reviews.llvm.org/D48436



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


[PATCH] D50385: [clangd] Collect symbol occurrences from AST.

2018-08-07 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added reviewers: ilya-biryukov, ioeric.
Herald added subscribers: arphaman, mgrang, jkorous, MaskRay, mgorny.

This patch implements a SymbolOccurenceCollector, which will be used to:

- Find all occurrences in AST
- Find all occurrences in MemIndex


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D50385

Files:
  clangd/CMakeLists.txt
  clangd/index/Index.cpp
  clangd/index/Index.h
  clangd/index/SymbolOccurrenceCollector.cpp
  clangd/index/SymbolOccurrenceCollector.h
  unittests/clangd/CMakeLists.txt
  unittests/clangd/SymbolOccurrenceCollectorTests.cpp

Index: unittests/clangd/SymbolOccurrenceCollectorTests.cpp
===
--- /dev/null
+++ unittests/clangd/SymbolOccurrenceCollectorTests.cpp
@@ -0,0 +1,168 @@
+//===-- SymbolOccurrenceCollectorTests.cpp  -*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "index/SymbolOccurrenceCollector.h"
+#include "Annotations.h"
+#include "TestFS.h"
+#include "TestTU.h"
+#include "clang/Index/IndexingAction.h"
+#include "clang/Basic/FileManager.h"
+#include "clang/Basic/FileSystemOptions.h"
+#include "clang/Basic/VirtualFileSystem.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Index/IndexingAction.h"
+#include "clang/Tooling/Tooling.h"
+#include "llvm/ADT/IntrusiveRefCntPtr.h"
+#include "llvm/ADT/StringRef.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+#include 
+#include 
+
+MATCHER(OccurrenceRange, "") {
+  const clang::clangd::SymbolOccurrence& Pos = testing::get<0>(arg);
+  const clang::clangd::Range& Range = testing::get<1>(arg);
+  return std::tie(Pos.Location.Start.Line,
+  Pos.Location.Start.Column,
+  Pos.Location.End.Line,
+  Pos.Location.End.Column) ==
+ std::tie(Range.start.line, Range.start.character, Range.end.line,
+  Range.end.character);
+}
+
+namespace clang {
+namespace clangd {
+namespace {
+
+class SymbolIndexActionFactory : public tooling::FrontendActionFactory {
+public:
+  SymbolIndexActionFactory() = default;
+
+  clang::FrontendAction *create() override {
+index::IndexingOptions IndexOpts;
+IndexOpts.SystemSymbolFilter =
+index::IndexingOptions::SystemSymbolFilterKind::All;
+IndexOpts.IndexFunctionLocals = true;
+SymbolOccurrenceKind Filter = SymbolOccurrenceKind::Declaration |
+  SymbolOccurrenceKind::Definition |
+  SymbolOccurrenceKind::Reference;
+SymbolOccurrenceCollector::Options Opts;
+Opts.Filter = Filter;
+Opts.IDs = llvm::None;
+Collector = std::make_shared(Opts);
+return index::createIndexingAction(Collector, IndexOpts, nullptr).release();
+  }
+
+  std::shared_ptr Collector;
+};
+
+class OccurrenceCollectorTest : public ::testing::Test {
+public:
+  OccurrenceCollectorTest()
+  : InMemoryFileSystem(new vfs::InMemoryFileSystem),
+TestHeaderName(testPath("symbol.h")),
+TestFileName(testPath("symbol.cc")) {
+TestHeaderURI = URI::createFile(TestHeaderName).toString();
+TestFileURI = URI::createFile(TestFileName).toString();
+  }
+
+  bool collectOccurrences(StringRef HeaderCode, StringRef MainCode,
+  const std::vector &ExtraArgs = {}) {
+llvm::IntrusiveRefCntPtr Files(
+new FileManager(FileSystemOptions(), InMemoryFileSystem));
+
+auto Factory = llvm::make_unique();
+
+std::vector Args = {
+"symbol_occurrence_collector", "-fsyntax-only", "-xc++",
+"-std=c++11",   "-include",  TestHeaderName};
+Args.insert(Args.end(), ExtraArgs.begin(), ExtraArgs.end());
+// This allows to override the "-xc++" with something else, i.e.
+// -xobjective-c++.
+Args.push_back(TestFileName);
+
+tooling::ToolInvocation Invocation(
+Args,
+Factory->create(), Files.get(),
+std::make_shared());
+
+InMemoryFileSystem->addFile(TestHeaderName, 0,
+llvm::MemoryBuffer::getMemBuffer(HeaderCode));
+InMemoryFileSystem->addFile(TestFileName, 0,
+llvm::MemoryBuffer::getMemBuffer(MainCode));
+Invocation.run();
+Occurrences = Factory->Collector->takeOccurrences();
+return true;
+  }
+
+protected:
+  llvm::IntrusiveRefCntPtr InMemoryFileSystem;
+  std::string TestHeaderName;
+  std::string TestHeaderURI;
+  std::string TestFileName;
+  std::string TestFileURI;
+  std::unique_ptr Occurrences;
+};
+
+std::vector operator+(const std::vector &L,
+ const std::vector &R) {
+  std::vector Result = L;
+  Result.insert(Result.end(), R.begin(), R.end());
+  retur

[PATCH] D50193: Added functionality to suggest FixIts for conversion of '->' to '.' and vice versa.

2018-08-07 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

Thanks! The only major comment I have is about the `FixItsScore`, others are 
mostly NITs.




Comment at: clangd/Quality.cpp:298
+FixItCount += FixIt.CodeToInsert.size();
+  }
 }

NIT: remove braces around single-statement loop body



Comment at: clangd/Quality.h:80
   bool Forbidden = false; // Unavailable (e.g const) or inaccessible (private).
+  int FixItCount = 0; // Number of additional changes that needs to be 
performed
+  // for this change to take place.

The comment is a bit misleading, since it's actually the length of the inserted 
code.
I'd suggest keeping the comment and a name of this variable a bit more vague on 
the definition of this field, e.g. something like

`int FixItScore; // Measure of the total amount of edit needed by the fix-its. 
Higher is worse, i.e. more code needs to change`

And overall, it looks like the penalty might be too harsh for some potential 
fix-its. E.g. imagine a fix-it that adds a `using ns::some_class` directive 
somewhere to the file. The size of the inserted text will be proprotional to 
the size of the fully-qualfiied-name of the class, but it does not seem like 
the fix-its for items with larger names should be downranked more than others, 
after all it's the same type of fix-it.

```
// Hypothetical example, we don't have fix-its like that yet.
namespace ns {
  class SomeVeryLongName {};
  class ShortName {};
}


^ // <-- complete here, imagine the completion items for both classes are 
available and 
  // add `using ns::;`  to the global namespace.
```

In that case, we will penalize `SomeVeryLongName` more than `ShortName`, 
because it has a longer fix-it, but it does not look like a useful distinction.
I suggest we start with something simple, like having the same predefined 
penalty for all fix-its or penalize based on the number of fix-its in the list. 
We can generalize later when we see more fix-its and have a better 
understanding on penalties we want from them



Comment at: unittests/clangd/CodeCompleteTests.cpp:112
+
+CodeCompleteResult completions(ClangdServer &Server, Annotations Test,
+   std::vector IndexSymbols = {},

NIT: use `const Annotations&`?



Comment at: unittests/clangd/CodeCompleteTests.cpp:119
+
+CodeCompleteResult completions(ClangdServer &Server, StringRef Text,
+   std::vector IndexSymbols = {},

The number of `completions` overloads seems to be getting out of hand.
Any ideas on how we can reduce them?

Generally, I think we want the most general version:
```
CodeCompleteResult completionsImpl(ClangdServer&, Text, Point, Index, Opts)
```
And two conveniece wrappers that create `ClangdServer` for us:
```
// Parses Annotations(Text) and creates a ClangdServer instance.
CodeCompleteResult completions(Text, Index = ..., Opts = ...);
// Only creates a ClangdServer instance.
CodeCompleteResult completions(Text, Point, Index=..., Opts =...);
```

Can we make the rest of the code to use this API? (e.g. if function accepts a 
`ClangdServer`, the callers have to do quite a bit of setup anyway and I don't 
think adding the annotations parsing to get the completion point will hurt the 
readability  there). 



Comment at: unittests/clangd/CodeCompleteTests.cpp:1397
+EXPECT_TRUE(C.FixIts.size() == 1u || C.Name == "AuxFunction");
+if (!C.FixIts.empty()) {
+  EXPECT_THAT(C.FixIts, ElementsAre(ReplacementEdit));

NIT: remove braces around single-statement ifs, LLVM code generally tends to 
avoid adding braces around single-statement bodies of loops, conditionals, etc



Comment at: unittests/clangd/CodeCompleteTests.cpp:1439
+  CodeCompleteOptions Opts;
+  Opts.IncludeFixIts = true;
+  StringRef TestCode(

We tend to unit-test the scores separately from general completion tests.
Could we replace this test with a unit-test in `QualityTests.cpp`?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D50193



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


[PATCH] D49851: [clang-tidy] run-clang-tidy add synchronisation to the output

2018-08-07 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment.

I would like to have this patch in, because i currently have a 1MB output file, 
and the missing synchronization really destroys cleaning with grep and sed :(




Comment at: clang-tidy/tool/run-clang-tidy.py:167
+output, err = proc.communicate()
+if proc.returncode:
   failed_files.append(name)

Please do the comparison `!= 0` to be more clear about the expected success 
return value.



Comment at: clang-tidy/tool/run-clang-tidy.py:171
+  sys.stdout.write(' '.join(invocation) + '\n' + output + '\n')
+  if len(err):
+sys.stderr.write(err + '\n')

Please add a comparison you are looking for (`> 0` i guess)


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D49851



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


[PATCH] D49851: [clang-tidy] run-clang-tidy add synchronisation to the output

2018-08-07 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment.

I forgot: Did you measure how much of a time penalty this brings? Just out of 
curiosity, correct script is more important then fast script :)


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D49851



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


[PATCH] D50376: AMDGPU: Fix enabling denormals by default on pre-VI targets

2018-08-07 Thread Brian Sumner via Phabricator via cfe-commits
b-sumner added a comment.

This approach seems fine to me.


https://reviews.llvm.org/D50376



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


[PATCH] D50193: Added functionality to suggest FixIts for conversion of '->' to '.' and vice versa.

2018-08-07 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 159510.
kadircet marked 6 inline comments as done.
kadircet added a comment.

- Resolve discussions.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D50193

Files:
  clangd/CodeComplete.cpp
  clangd/CodeComplete.h
  clangd/Diagnostics.cpp
  clangd/Protocol.h
  clangd/Quality.cpp
  clangd/Quality.h
  clangd/SourceCode.cpp
  clangd/SourceCode.h
  unittests/clangd/CodeCompleteTests.cpp
  unittests/clangd/QualityTests.cpp

Index: unittests/clangd/QualityTests.cpp
===
--- unittests/clangd/QualityTests.cpp
+++ unittests/clangd/QualityTests.cpp
@@ -346,6 +346,28 @@
   EXPECT_EQ(Q.Category, SymbolQualitySignals::Constructor);
 }
 
+TEST(QualityTests, ItemWithFixItsRankedDown) {
+  CodeCompleteOptions Opts;
+  Opts.IncludeFixIts = true;
+
+  auto Header = TestTU::withHeaderCode(R"cpp(
+int x;
+  )cpp");
+  auto AST = Header.build();
+
+  SymbolRelevanceSignals RelevanceWithFixIt;
+  RelevanceWithFixIt.merge(
+  CodeCompletionResult(&findDecl(AST, "x"), 0, nullptr, false, true, {{}}));
+  EXPECT_TRUE(RelevanceWithFixIt.NeedsFixIts);
+
+  SymbolRelevanceSignals RelevanceWithoutFixIt;
+  RelevanceWithoutFixIt.merge(
+  CodeCompletionResult(&findDecl(AST, "x"), 0, nullptr, false, true, {}));
+  EXPECT_FALSE(RelevanceWithoutFixIt.NeedsFixIts);
+
+  EXPECT_LT(RelevanceWithFixIt.evaluate(), RelevanceWithoutFixIt.evaluate());
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: unittests/clangd/CodeCompleteTests.cpp
===
--- unittests/clangd/CodeCompleteTests.cpp
+++ unittests/clangd/CodeCompleteTests.cpp
@@ -79,6 +79,25 @@
   return MemIndex::build(std::move(Slab).build());
 }
 
+CodeCompleteResult completions(ClangdServer &Server, StringRef TestCode,
+   Position point,
+   std::vector IndexSymbols = {},
+   clangd::CodeCompleteOptions Opts = {}) {
+  std::unique_ptr OverrideIndex;
+  if (!IndexSymbols.empty()) {
+assert(!Opts.Index && "both Index and IndexSymbols given!");
+OverrideIndex = memIndex(std::move(IndexSymbols));
+Opts.Index = OverrideIndex.get();
+  }
+
+  auto File = testPath("foo.cpp");
+  runAddDocument(Server, File, TestCode);
+  auto CompletionList = cantFail(runCodeComplete(Server, File, point, Opts));
+  return CompletionList;
+}
+
+// Builds a server and runs code completion.
+// If IndexSymbols is non-empty, an index will be built and passed to opts.
 CodeCompleteResult completions(ClangdServer &Server, StringRef Text,
std::vector IndexSymbols = {},
clangd::CodeCompleteOptions Opts = {}) {
@@ -97,8 +116,6 @@
   return CompletionList;
 }
 
-// Builds a server and runs code completion.
-// If IndexSymbols is non-empty, an index will be built and passed to opts.
 CodeCompleteResult completions(StringRef Text,
std::vector IndexSymbols = {},
clangd::CodeCompleteOptions Opts = {}) {
@@ -1338,6 +1355,85 @@
   EXPECT_THAT(Results.Context, CodeCompletionContext::CCC_DotMemberAccess);
 }
 
+TEST(CompletionTest, FixItForArrowToDot) {
+  MockFSProvider FS;
+  MockCompilationDatabase CDB;
+  IgnoreDiagnostics DiagConsumer;
+  ClangdServer Server(CDB, FS, DiagConsumer, ClangdServer::optsForTest());
+
+  CodeCompleteOptions Opts;
+  Opts.IncludeFixIts = true;
+  Annotations TestCode(
+  R"cpp(
+class Auxilary {
+ public:
+  void AuxFunction();
+};
+class ClassWithPtr {
+ public:
+  void MemberFunction();
+  Auxilary* operator->() const;
+  Auxilary* Aux;
+};
+void f() {
+  ClassWithPtr x;
+  x[[->]]^;
+}
+  )cpp");
+  auto Results =
+  completions(Server, TestCode.code(), TestCode.point(), {}, Opts);
+  EXPECT_EQ(Results.Completions.size(), 3u);
+
+  TextEdit ReplacementEdit;
+  ReplacementEdit.range = TestCode.range();
+  ReplacementEdit.newText = ".";
+  for (const auto &C : Results.Completions) {
+EXPECT_TRUE(C.FixIts.size() == 1u || C.Name == "AuxFunction");
+if (!C.FixIts.empty())
+  EXPECT_THAT(C.FixIts, ElementsAre(ReplacementEdit));
+  }
+}
+
+TEST(CompletionTest, FixItForDotToArrow) {
+  MockFSProvider FS;
+  MockCompilationDatabase CDB;
+  IgnoreDiagnostics DiagConsumer;
+  ClangdServer Server(CDB, FS, DiagConsumer, ClangdServer::optsForTest());
+
+  CodeCompleteOptions Opts;
+  Opts.IncludeFixIts = true;
+  Annotations TestCode(
+  R"cpp(
+class Auxilary {
+ public:
+  void AuxFunction();
+};
+class ClassWithPtr {
+ public:
+  void MemberFunction();
+  Auxilary* operator->() const;
+  Auxilary* Aux;
+};
+void f() {
+  ClassWithPtr x;

[PATCH] D49851: [clang-tidy] run-clang-tidy add synchronisation to the output

2018-08-07 Thread Andi via Phabricator via cfe-commits
Abpostelnicu updated this revision to Diff 159511.

https://reviews.llvm.org/D49851

Files:
  clang-tidy/tool/run-clang-tidy.py


Index: clang-tidy/tool/run-clang-tidy.py
===
--- clang-tidy/tool/run-clang-tidy.py
+++ clang-tidy/tool/run-clang-tidy.py
@@ -153,7 +153,7 @@
   subprocess.call(invocation)
 
 
-def run_tidy(args, tmpdir, build_path, queue, failed_files):
+def run_tidy(args, tmpdir, build_path, queue, lock, failed_files):
   """Takes filenames out of queue and runs clang-tidy on them."""
   while True:
 name = queue.get()
@@ -161,10 +161,15 @@
  tmpdir, build_path, args.header_filter,
  args.extra_arg, args.extra_arg_before,
  args.quiet, args.config)
-sys.stdout.write(' '.join(invocation) + '\n')
-return_code = subprocess.call(invocation)
-if return_code != 0:
+
+proc = subprocess.Popen(invocation, stdout=subprocess.PIPE, 
stderr=subprocess.PIPE)
+output, err = proc.communicate()
+if proc.returncode != 0:
   failed_files.append(name)
+with lock:
+  sys.stdout.write(' '.join(invocation) + '\n' + output + '\n')
+  if err > 0:
+sys.stderr.write(err + '\n')
 queue.task_done()
 
 
@@ -263,9 +268,10 @@
 task_queue = queue.Queue(max_task)
 # List of files with a non-zero return code.
 failed_files = []
+lock = threading.Lock()
 for _ in range(max_task):
   t = threading.Thread(target=run_tidy,
-   args=(args, tmpdir, build_path, task_queue, 
failed_files))
+   args=(args, tmpdir, build_path, task_queue, lock, 
failed_files))
   t.daemon = True
   t.start()



Index: clang-tidy/tool/run-clang-tidy.py
===
--- clang-tidy/tool/run-clang-tidy.py
+++ clang-tidy/tool/run-clang-tidy.py
@@ -153,7 +153,7 @@
   subprocess.call(invocation)
 
 
-def run_tidy(args, tmpdir, build_path, queue, failed_files):
+def run_tidy(args, tmpdir, build_path, queue, lock, failed_files):
   """Takes filenames out of queue and runs clang-tidy on them."""
   while True:
 name = queue.get()
@@ -161,10 +161,15 @@
  tmpdir, build_path, args.header_filter,
  args.extra_arg, args.extra_arg_before,
  args.quiet, args.config)
-sys.stdout.write(' '.join(invocation) + '\n')
-return_code = subprocess.call(invocation)
-if return_code != 0:
+
+proc = subprocess.Popen(invocation, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+output, err = proc.communicate()
+if proc.returncode != 0:
   failed_files.append(name)
+with lock:
+  sys.stdout.write(' '.join(invocation) + '\n' + output + '\n')
+  if err > 0:
+sys.stderr.write(err + '\n')
 queue.task_done()
 
 
@@ -263,9 +268,10 @@
 task_queue = queue.Queue(max_task)
 # List of files with a non-zero return code.
 failed_files = []
+lock = threading.Lock()
 for _ in range(max_task):
   t = threading.Thread(target=run_tidy,
-   args=(args, tmpdir, build_path, task_queue, failed_files))
+   args=(args, tmpdir, build_path, task_queue, lock, failed_files))
   t.daemon = True
   t.start()

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


[PATCH] D49851: [clang-tidy] run-clang-tidy add synchronisation to the output

2018-08-07 Thread Andi via Phabricator via cfe-commits
Abpostelnicu marked 2 inline comments as done.
Abpostelnicu added a comment.

Regarding the time penalty it depends very much on how many files you have. But 
I would choose anytime to have this in the detriment of having "obfuscated" 
output.


https://reviews.llvm.org/D49851



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


[PATCH] D50099: [DebugInfo][OpenCL] Address post-commit review of D49930

2018-08-07 Thread Scott Linder via Phabricator via cfe-commits
scott.linder updated this revision to Diff 159512.
scott.linder added a comment.

Address feedback


https://reviews.llvm.org/D50099

Files:
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CGDebugInfo.h
  test/CodeGenOpenCL/blocks.cl

Index: test/CodeGenOpenCL/blocks.cl
===
--- test/CodeGenOpenCL/blocks.cl
+++ test/CodeGenOpenCL/blocks.cl
@@ -1,5 +1,7 @@
-// RUN: %clang_cc1 %s -cl-std=CL2.0 -emit-llvm -o - -O0 -debug-info-kind=limited -triple spir-unknown-unknown | FileCheck -check-prefixes=COMMON,SPIR %s
-// RUN: %clang_cc1 %s -cl-std=CL2.0 -emit-llvm -o - -O0 -debug-info-kind=limited -triple amdgcn-amd-amdhsa | FileCheck -check-prefixes=COMMON,AMDGCN %s
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -emit-llvm -o - -O0 -triple spir-unknown-unknown | FileCheck -check-prefixes=COMMON,SPIR %s
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -emit-llvm -o - -O0 -triple amdgcn-amd-amdhsa | FileCheck -check-prefixes=COMMON,AMDGCN %s
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -emit-llvm -o - -O0 -debug-info-kind=limited -triple spir-unknown-unknown | FileCheck -check-prefixes=CHECK-DEBUG %s
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -emit-llvm -o - -O0 -debug-info-kind=limited -triple amdgcn-amd-amdhsa | FileCheck -check-prefixes=CHECK-DEBUG %s
 
 // COMMON: @__block_literal_global = internal addrspace(1) constant { i32, i32 } { i32 8, i32 4 }
 // COMMON-NOT: .str
@@ -61,10 +63,10 @@
 
 // COMMON-NOT: define{{.*}}@__foo_block_invoke_kernel
 
-// COMMON: !DIDerivedType(tag: DW_TAG_member, name: "__size"
-// COMMON: !DIDerivedType(tag: DW_TAG_member, name: "__align"
+// CHECK-DEBUG: !DIDerivedType(tag: DW_TAG_member, name: "__size"
+// CHECK-DEBUG: !DIDerivedType(tag: DW_TAG_member, name: "__align"
 
-// COMMON-NOT: !DIDerivedType(tag: DW_TAG_member, name: "__isa"
-// COMMON-NOT: !DIDerivedType(tag: DW_TAG_member, name: "__flags"
-// COMMON-NOT: !DIDerivedType(tag: DW_TAG_member, name: "__reserved"
-// COMMON-NOT: !DIDerivedType(tag: DW_TAG_member, name: "__FuncPtr"
+// CHECK-DEBUG-NOT: !DIDerivedType(tag: DW_TAG_member, name: "__isa"
+// CHECK-DEBUG-NOT: !DIDerivedType(tag: DW_TAG_member, name: "__flags"
+// CHECK-DEBUG-NOT: !DIDerivedType(tag: DW_TAG_member, name: "__reserved"
+// CHECK-DEBUG-NOT: !DIDerivedType(tag: DW_TAG_member, name: "__FuncPtr"
Index: lib/CodeGen/CGDebugInfo.h
===
--- lib/CodeGen/CGDebugInfo.h
+++ lib/CodeGen/CGDebugInfo.h
@@ -311,6 +311,22 @@
   void AppendAddressSpaceXDeref(unsigned AddressSpace,
 SmallVectorImpl &Expr) const;
 
+  /// A helper function to collect debug info for the default elements of a
+  /// block.
+  ///
+  /// \returns The next available field offset after the default elements.
+  uint64_t collectDefaultElementTypesForBlockPointer(
+  const BlockPointerType *Ty, llvm::DIFile *Unit,
+  llvm::DIDerivedType *DescTy, unsigned LineNo,
+  SmallVectorImpl &EltTys);
+
+  /// A helper function to collect debug info for the default fields of a
+  /// block.
+  void collectDefaultFieldsForBlockLiteralDeclare(
+  const CGBlockInfo &Block, const ASTContext &Context, SourceLocation Loc,
+  const llvm::StructLayout &BlockLayout, llvm::DIFile *Unit,
+  SmallVectorImpl &Fields);
+
 public:
   CGDebugInfo(CodeGenModule &CGM);
   ~CGDebugInfo();
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -942,12 +942,47 @@
   return Cache;
 }
 
+uint64_t CGDebugInfo::collectDefaultElementTypesForBlockPointer(
+const BlockPointerType *Ty, llvm::DIFile *Unit, llvm::DIDerivedType *DescTy,
+unsigned LineNo, SmallVectorImpl &EltTys) {
+  QualType FType;
+
+  // Advanced by calls to CreateMemberType in increments of FType, then
+  // returned as the overall size of the default elements.
+  uint64_t FieldOffset = 0;
+
+  // Blocks in OpenCL have unique constraints which make the standard fields
+  // redundant while requiring size and align fields for enqueue_kernel. See
+  // initializeForBlockHeader in CGBlocks.cpp
+  if (CGM.getLangOpts().OpenCL) {
+FType = CGM.getContext().IntTy;
+EltTys.push_back(CreateMemberType(Unit, FType, "__size", &FieldOffset));
+EltTys.push_back(CreateMemberType(Unit, FType, "__align", &FieldOffset));
+  } else {
+FType = CGM.getContext().getPointerType(CGM.getContext().VoidTy);
+EltTys.push_back(CreateMemberType(Unit, FType, "__isa", &FieldOffset));
+FType = CGM.getContext().IntTy;
+EltTys.push_back(CreateMemberType(Unit, FType, "__flags", &FieldOffset));
+EltTys.push_back(CreateMemberType(Unit, FType, "__reserved", &FieldOffset));
+FType = CGM.getContext().getPointerType(Ty->getPointeeType());
+EltTys.push_back(CreateMemberType(Unit, FType, "__FuncPtr", &FieldOffset));
+FType = CGM.getContext().getPointerType(CGM.getContext().VoidTy);
+uint64_t FieldSize 

[PATCH] D49851: [clang-tidy] run-clang-tidy add synchronisation to the output

2018-08-07 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment.

Lets say running it over whole LLVM for one check? I will apply this path 
locally, because i have to analyze llvm right now anyway.

For me this looks good, but @alexfh or @aaron.ballman should accept it.


https://reviews.llvm.org/D49851



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


[PATCH] D50337: [clangd] DexIndex implementation prototype

2018-08-07 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 159515.
kbobyrev added a comment.

Continue implementing Proof of Concept Dex-based static index replacement.

This diff adds short query processing, the current solution does not utilize 
iterators framework (unlike the general queries) yet and is a subject to 
change. As discussed offline, this implementation should lean towards 
simplicity and usability rather then premature optimization.

The patch is still not ready for a comprehensive review yet, these are few 
points which should be addressed before the review is live:

- Code duplication should be reduced as much as possible. `DexIndex` is likely 
to become way more sophisticated than `MemIndex` in the future and hence it 
does not simply inherit or reuse `MemIndex`, this is also a reason why (as 
discussed offline) code duplication in unit tests is not that bad keeping in 
mind that the functionality and implementation of both types of index will 
diverge in the future. However, it's better to abstract out as much as possible 
if the implementation does not become less flexible and cross-dependencies are 
not introduced in the process.
- Slightly cleaning up unit tests (`IndexHelpers.(h|cpp)` is not a very good 
name for the new file used by both `MemIndex` and `DexIndex` testing framework, 
code duplication is also a slight concern)


https://reviews.llvm.org/D50337

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/index/MemIndex.h
  clang-tools-extra/clangd/index/dex/DexIndex.cpp
  clang-tools-extra/clangd/index/dex/DexIndex.h
  clang-tools-extra/clangd/index/dex/Token.cpp
  clang-tools-extra/clangd/index/dex/Token.h
  clang-tools-extra/unittests/clangd/CMakeLists.txt
  clang-tools-extra/unittests/clangd/DexIndexTests.cpp
  clang-tools-extra/unittests/clangd/IndexHelpers.cpp
  clang-tools-extra/unittests/clangd/IndexHelpers.h
  clang-tools-extra/unittests/clangd/IndexTests.cpp

Index: clang-tools-extra/unittests/clangd/IndexTests.cpp
===
--- clang-tools-extra/unittests/clangd/IndexTests.cpp
+++ clang-tools-extra/unittests/clangd/IndexTests.cpp
@@ -7,33 +7,20 @@
 //
 //===--===//
 
+#include "IndexHelpers.h"
 #include "index/Index.h"
 #include "index/MemIndex.h"
 #include "index/Merge.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 
-using testing::UnorderedElementsAre;
 using testing::Pointee;
+using testing::UnorderedElementsAre;
 
 namespace clang {
 namespace clangd {
 namespace {
 
-Symbol symbol(llvm::StringRef QName) {
-  Symbol Sym;
-  Sym.ID = SymbolID(QName.str());
-  size_t Pos = QName.rfind("::");
-  if (Pos == llvm::StringRef::npos) {
-Sym.Name = QName;
-Sym.Scope = "";
-  } else {
-Sym.Name = QName.substr(Pos + 2);
-Sym.Scope = QName.substr(0, Pos + 2);
-  }
-  return Sym;
-}
-
 MATCHER_P(Named, N, "") { return arg.Name == N; }
 
 TEST(SymbolSlab, FindAndIterate) {
@@ -52,59 +39,6 @@
 EXPECT_THAT(*S.find(SymbolID(Sym)), Named(Sym));
 }
 
-struct SlabAndPointers {
-  SymbolSlab Slab;
-  std::vector Pointers;
-};
-
-// Create a slab of symbols with the given qualified names as both IDs and
-// names. The life time of the slab is managed by the returned shared pointer.
-// If \p WeakSymbols is provided, it will be pointed to the managed object in
-// the returned shared pointer.
-std::shared_ptr>
-generateSymbols(std::vector QualifiedNames,
-std::weak_ptr *WeakSymbols = nullptr) {
-  SymbolSlab::Builder Slab;
-  for (llvm::StringRef QName : QualifiedNames)
-Slab.insert(symbol(QName));
-
-  auto Storage = std::make_shared();
-  Storage->Slab = std::move(Slab).build();
-  for (const auto &Sym : Storage->Slab)
-Storage->Pointers.push_back(&Sym);
-  if (WeakSymbols)
-*WeakSymbols = Storage;
-  auto *Pointers = &Storage->Pointers;
-  return {std::move(Storage), Pointers};
-}
-
-// Create a slab of symbols with IDs and names [Begin, End], otherwise identical
-// to the `generateSymbols` above.
-std::shared_ptr>
-generateNumSymbols(int Begin, int End,
-   std::weak_ptr *WeakSymbols = nullptr) {
-  std::vector Names;
-  for (int i = Begin; i <= End; i++)
-Names.push_back(std::to_string(i));
-  return generateSymbols(Names, WeakSymbols);
-}
-
-std::string getQualifiedName(const Symbol &Sym) {
-  return (Sym.Scope + Sym.Name).str();
-}
-
-std::vector match(const SymbolIndex &I,
-   const FuzzyFindRequest &Req,
-   bool *Incomplete = nullptr) {
-  std::vector Matches;
-  bool IsIncomplete = I.fuzzyFind(Req, [&](const Symbol &Sym) {
-Matches.push_back(getQualifiedName(Sym));
-  });
-  if (Incomplete)
-*Incomplete = IsIncomplete;
-  return Matches;
-}
-
 TEST(MemIndexTest, MemIndexSymbolsRecycled) {
   MemIndex I;
   std::weak_ptr Symbols;
@@ -212,18 +146,6 @@
   EXPECT_THAT(match(I, Req), UnorderedElementsAre("ns::A

[PATCH] D47849: [OpenMP][Clang][NVPTX] Enable math functions called in an OpenMP NVPTX target device region to be resolved as device-native function calls

2018-08-07 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld added a comment.

Do we still need this? I think what we really need to solve is the problem of 
(host) inline assembly in the header files...


Repository:
  rC Clang

https://reviews.llvm.org/D47849



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


[PATCH] D50055: Update the coding standard about NFC changes and whitespace

2018-08-07 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur added inline comments.



Comment at: docs/CodingStandards.rst:514-516
+line of code. Some common editors will automatically remove trailing whitespace
+when saving a file which causes unrelated changes to appear in diffs and
+commits.

JDevlieghere wrote:
> chandlerc wrote:
> > Meinersbur wrote:
> > > Just to note that this policy will prohibit the use of remove 
> > > trailing-whitespace feature in editors since it makes it impossible to 
> > > edit the file without also 'editing' any unrelated whitespace. At the 
> > > same time, since not being able to use the feature, I risk committing 
> > > trailing whitespace myself (that is, some additional steps are necessary: 
> > > I use 'git clang-format' which should remove traling whitespace only on 
> > > edited lines and 'git diff' shows trailing whitespace in red; these are 
> > > still additional steps that are easy to miss)
> > I also have editor settings that risk violating this, but I just reduce my 
> > patdh before submitting. This is a touch annoying with svn, but with got it 
> > is pretty simple to use `git add -p` and ignore the unnecessary removals if 
> > trailing whitespace 
> I had the same workflow as Chandler but that became rather tedious for the 
> LLDB repo where there's a lot of trailing whitespace. I ended up adding an 
> alias to my git config that only stages non-whitespace changes: `anw = !sh -c 
> 'git diff -U0 -w --no-color "$@" | git apply --cached --ignore-whitespace 
> --unidiff-zero -'`. It's far from optimal but it works pretty well. 
Thank you for sharing.


https://reviews.llvm.org/D50055



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


[PATCH] D48661: [Fixed Point Arithmetic] Fixed Point Constant

2018-08-07 Thread Bruno Ricci via Phabricator via cfe-commits
bricci added a comment.

Just to provide a bit of additional context:

My comment about fsyntax-only is not specific to fsyntax-only.
This is just an handy way to benchmark the frontend without noise
from LLVM. It is important to keep all frequently used structures small
(within reason) even if this result in a little bit of additional work to 
pack/unpack
(again, within reason) since the front-end is not doing a lot of computations
but is doing a lot of memory accesses.

On my machine when I do an fsyntax-only on all of Boost
~25% of the cycles are spent with execution stalled because of
a cache miss.

Now this basic fixed point type will potentially ends up in
the Type/Stmt/Decl hierarchy -> it *must* be small.

For another example of what not to do see APSInt which
stores a single bool, thus wasting 8 bytes on 64 bits archs
just for this single bit. I actually have a patch stuffing it into APInt
but have not bothered to upstream it since in this case it do not
really matter for clang.


Repository:
  rL LLVM

https://reviews.llvm.org/D48661



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


[PATCH] D50390: [SEMA]Uniform printing of Attributes

2018-08-07 Thread Erich Keane via Phabricator via cfe-commits
erichkeane created this revision.
erichkeane added reviewers: aaron.ballman, rjmccall.

The recent patch that reordered parsed attributes made it clear
that the diagnostics when printing attributes were incredibly 
inconsistent.  in the mutual-exclusion case, the order of the
attributes would change which was printed with leading/trailing
underscores.

This is because GNU attributes are permitted to be spelled with
leading/trailing underscores, but are quickly normalized after
parsing.  Therefore, any attribute that had been converted to a 
Attr type would only have the non-underscored type.

This patch adds a diagnostic category for a quoted-std-string,
as well as overloads for operator<< to permit ParsedAttr to be
sent to be emitted directly.

THEN, this patch changes everywhere that we were doing PA.getName()
in a diagnostic (which got the IdentifierInfo, which hadn't been
normalized) and replaces it with a call to the new operator<<.

The result is that ALL attributes are now uniformly printed with
the normalized name, rather than a mix of names.


https://reviews.llvm.org/D50390

Files:
  include/clang/Basic/Diagnostic.h
  include/clang/Basic/PartialDiagnostic.h
  include/clang/Sema/ParsedAttr.h
  include/clang/Sema/Sema.h
  lib/Basic/Diagnostic.cpp
  lib/Sema/ParsedAttr.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclAttr.cpp
  lib/Sema/SemaStmtAttr.cpp
  lib/Sema/SemaType.cpp
  test/Sema/attr-coldhot.c
  test/Sema/attr-min-vector-width.c
  test/Sema/attr-minsize.c
  test/Sema/attr-unavailable-message.c
  test/SemaObjC/attr-objc-exception.m
  test/SemaObjC/method-sentinel-attr.m
  utils/TableGen/ClangAttrEmitter.cpp

Index: lib/Sema/ParsedAttr.cpp
===
--- lib/Sema/ParsedAttr.cpp
+++ lib/Sema/ParsedAttr.cpp
@@ -114,6 +114,14 @@
   return AttrName;
 }
 
+StringRef ParsedAttr::getNormalizedName() const {
+  // Normalize the attribute name, __foo__ becomes foo. This is only allowable
+  // for GNU attributes.
+  return normalizeAttrName(AttrName->getName(),
+   ScopeName ? ScopeName->getName() : "",
+   static_cast(SyntaxUsed));
+}
+
 ParsedAttr::Kind ParsedAttr::getKind(const IdentifierInfo *Name,
  const IdentifierInfo *ScopeName,
  Syntax SyntaxUsed) {
@@ -138,8 +146,7 @@
   // Both variables will be used in tablegen generated
   // attribute spell list index matching code.
   StringRef Scope = ScopeName ? ScopeName->getName() : "";
-  StringRef Name = normalizeAttrName(AttrName->getName(), Scope,
- (ParsedAttr::Syntax)SyntaxUsed);
+  StringRef Name = getNormalizedName();
 
 #include "clang/Sema/AttrSpellingListIndex.inc"
 
Index: lib/Sema/SemaStmtAttr.cpp
===
--- lib/Sema/SemaStmtAttr.cpp
+++ lib/Sema/SemaStmtAttr.cpp
@@ -56,8 +56,7 @@
 static Attr *handleSuppressAttr(Sema &S, Stmt *St, const ParsedAttr &A,
 SourceRange Range) {
   if (A.getNumArgs() < 1) {
-S.Diag(A.getLoc(), diag::err_attribute_too_few_arguments)
-<< A.getName() << 1;
+S.Diag(A.getLoc(), diag::err_attribute_too_few_arguments) << A << 1;
 return nullptr;
   }
 
@@ -284,8 +283,7 @@
   unsigned NumArgs = A.getNumArgs();
 
   if (NumArgs > 1) {
-S.Diag(A.getLoc(), diag::err_attribute_too_many_arguments) << A.getName()
-   << 1;
+S.Diag(A.getLoc(), diag::err_attribute_too_many_arguments) << A << 1;
 return nullptr;
   }
 
@@ -297,16 +295,16 @@
 
 if (!E->isIntegerConstantExpr(ArgVal, S.Context)) {
   S.Diag(A.getLoc(), diag::err_attribute_argument_type)
-  << A.getName() << AANT_ArgumentIntegerConstant << E->getSourceRange();
+  << A << AANT_ArgumentIntegerConstant << E->getSourceRange();
   return nullptr;
 }
 
 int Val = ArgVal.getSExtValue();
 
 if (Val <= 0) {
   S.Diag(A.getRange().getBegin(),
  diag::err_attribute_requires_positive_integer)
-  << A.getName();
+  << A;
   return nullptr;
 }
 UnrollFactor = Val;
Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -5815,8 +5815,8 @@
 
 // Check the attribute arguments.
 if (Attr.getNumArgs() != 1) {
-  S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments)
-  << Attr.getName() << 1;
+  S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << Attr
+<< 1;
   Attr.setInvalid();
   return;
 }
@@ -5951,8 +5951,8 @@
 S.getSourceManager().getImmediateExpansionRange(AttrLoc).getBegin();
 
   if (!attr.isArgIdent(0)) {
-S.Diag(AttrLoc, diag::err_attribute_argument_type)
- 

[PATCH] D50390: [SEMA]Uniform printing of Attributes

2018-08-07 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: include/clang/Sema/ParsedAttr.h:956
+
+inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,
+   const ParsedAttr *At) {

Note that the pointer-overload is required since a couple of templates are used 
that switch between an Attr and a ParsedAttr, so we need to have the same form 
as the Attr.

Also note that we cannot do what Attr does (which is store an Attr Pointer in 
the diagnostic) without making Basic dependent on Sema, which seemed worse than 
the allocation in diagnostic situations.



Comment at: lib/Sema/SemaDeclAttr.cpp:3941
 
-CommonAttr *Sema::mergeCommonAttr(Decl *D, SourceRange Range,
-  IdentifierInfo *Ident,
-  unsigned AttrSpellingListIndex) {
-  if (checkAttrMutualExclusion(*this, D, Range, Ident))
+CommonAttr *Sema::mergeCommonAttr(Decl *D, const ParsedAttr &AL) {
+  if (checkAttrMutualExclusion(*this, D, AL))

It was tempting to template-these, but that would require moving them (or 
forcing instantiation) in the header file.  Additionally, since there is a 
difference between the spelling of how to get a location between the two types, 
this would become awkward.


https://reviews.llvm.org/D50390



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


r339150 - [OpenCL] Restore r338899 (reverted in r338904), fixing stack-use-after-return

2018-08-07 Thread Scott Linder via cfe-commits
Author: scott.linder
Date: Tue Aug  7 08:52:49 2018
New Revision: 339150

URL: http://llvm.org/viewvc/llvm-project?rev=339150&view=rev
Log:
[OpenCL] Restore r338899 (reverted in r338904), fixing stack-use-after-return

Always emit alloca in entry block for enqueue_kernel builtin.

Ensures the statically sized alloca is not converted to DYNAMIC_STACKALLOC
later because it is not in the entry block.

Added:
cfe/trunk/test/CodeGenOpenCL/enqueue-kernel-non-entry-block.cl
Modified:
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/test/CodeGenOpenCL/cl20-device-side-enqueue.cl

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=339150&r1=339149&r2=339150&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Tue Aug  7 08:52:49 2018
@@ -3337,24 +3337,31 @@ RValue CodeGenFunction::EmitBuiltinExpr(
 
 // Create a temporary array to hold the sizes of local pointer arguments
 // for the block. \p First is the position of the first size argument.
-auto CreateArrayForSizeVar = [=](unsigned First) {
-  auto *AT = llvm::ArrayType::get(SizeTy, NumArgs - First);
-  auto *Arr = Builder.CreateAlloca(AT);
-  llvm::Value *Ptr;
+auto CreateArrayForSizeVar = [=](unsigned First)
+-> std::tuple {
+  llvm::APInt ArraySize(32, NumArgs - First);
+  QualType SizeArrayTy = getContext().getConstantArrayType(
+  getContext().getSizeType(), ArraySize, ArrayType::Normal,
+  /*IndexTypeQuals=*/0);
+  auto Tmp = CreateMemTemp(SizeArrayTy, "block_sizes");
+  llvm::Value *TmpPtr = Tmp.getPointer();
+  llvm::Value *TmpSize = EmitLifetimeStart(
+  CGM.getDataLayout().getTypeAllocSize(Tmp.getElementType()), TmpPtr);
+  llvm::Value *ElemPtr;
   // Each of the following arguments specifies the size of the 
corresponding
   // argument passed to the enqueued block.
   auto *Zero = llvm::ConstantInt::get(IntTy, 0);
   for (unsigned I = First; I < NumArgs; ++I) {
 auto *Index = llvm::ConstantInt::get(IntTy, I - First);
-auto *GEP = Builder.CreateGEP(Arr, {Zero, Index});
+auto *GEP = Builder.CreateGEP(TmpPtr, {Zero, Index});
 if (I == First)
-  Ptr = GEP;
+  ElemPtr = GEP;
 auto *V =
 Builder.CreateZExtOrTrunc(EmitScalarExpr(E->getArg(I)), SizeTy);
 Builder.CreateAlignedStore(
 V, GEP, CGM.getDataLayout().getPrefTypeAlignment(SizeTy));
   }
-  return Ptr;
+  return std::tie(ElemPtr, TmpSize, TmpPtr);
 };
 
 // Could have events and/or varargs.
@@ -3366,24 +3373,27 @@ RValue CodeGenFunction::EmitBuiltinExpr(
   llvm::Value *Kernel =
   Builder.CreatePointerCast(Info.Kernel, GenericVoidPtrTy);
   auto *Block = Builder.CreatePointerCast(Info.BlockArg, GenericVoidPtrTy);
-  auto *PtrToSizeArray = CreateArrayForSizeVar(4);
+  llvm::Value *ElemPtr, *TmpSize, *TmpPtr;
+  std::tie(ElemPtr, TmpSize, TmpPtr) = CreateArrayForSizeVar(4);
 
   // Create a vector of the arguments, as well as a constant value to
   // express to the runtime the number of variadic arguments.
   std::vector Args = {
   Queue,  Flags, Range,
   Kernel, Block, ConstantInt::get(IntTy, NumArgs - 4),
-  PtrToSizeArray};
+  ElemPtr};
   std::vector ArgTys = {
-  QueueTy,  IntTy,RangeTy,
-  GenericVoidPtrTy, GenericVoidPtrTy, IntTy,
-  PtrToSizeArray->getType()};
+  QueueTy,  IntTy, RangeTy,   GenericVoidPtrTy,
+  GenericVoidPtrTy, IntTy, ElemPtr->getType()};
 
   llvm::FunctionType *FTy = llvm::FunctionType::get(
   Int32Ty, llvm::ArrayRef(ArgTys), false);
-  return RValue::get(
-  Builder.CreateCall(CGM.CreateRuntimeFunction(FTy, Name),
- llvm::ArrayRef(Args)));
+  auto Call =
+  RValue::get(Builder.CreateCall(CGM.CreateRuntimeFunction(FTy, Name),
+ llvm::ArrayRef(Args)));
+  if (TmpSize)
+EmitLifetimeEnd(TmpSize, TmpPtr);
+  return Call;
 }
 // Any calls now have event arguments passed.
 if (NumArgs >= 7) {
@@ -3430,15 +3440,19 @@ RValue CodeGenFunction::EmitBuiltinExpr(
   ArgTys.push_back(Int32Ty);
   Name = "__enqueue_kernel_events_varargs";
 
-  auto *PtrToSizeArray = CreateArrayForSizeVar(7);
-  Args.push_back(PtrToSizeArray);
-  ArgTys.push_back(PtrToSizeArray->getType());
+  llvm::Value *ElemPtr, *TmpSize, *TmpPtr;
+  std::tie(ElemPtr, TmpSize, TmpPtr) = CreateArrayForSizeVar(7);
+  Args.push_back(ElemPtr);
+  ArgTys.push_back(ElemPtr->getType());
 
   llvm::FunctionType *FTy = llvm::FunctionType::get(
   Int32Ty, llvm::ArrayRef(ArgTys), false);

r339152 - [OPENMP] Mark variables captured in declare target region as implicitly

2018-08-07 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Tue Aug  7 09:14:36 2018
New Revision: 339152

URL: http://llvm.org/viewvc/llvm-project?rev=339152&view=rev
Log:
[OPENMP] Mark variables captured in declare target region as implicitly
declare target.

According to OpenMP 5.0, variables captured in lambdas in declare target
regions must be considered as implicitly declare target.

Modified:
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/declare_target_ast_print.cpp
cfe/trunk/test/OpenMP/declare_target_codegen.cpp

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=339152&r1=339151&r2=339152&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Tue Aug  7 09:14:36 2018
@@ -8662,7 +8662,7 @@ public:
   /// Check if the specified variable is used in one of the private
   /// clauses (private, firstprivate, lastprivate, reduction etc.) in OpenMP
   /// constructs.
-  VarDecl *isOpenMPCapturedDecl(ValueDecl *D) const;
+  VarDecl *isOpenMPCapturedDecl(ValueDecl *D);
   ExprResult getOpenMPCapturedExpr(VarDecl *Capture, ExprValueKind VK,
ExprObjectKind OK, SourceLocation Loc);
 
@@ -8746,8 +8746,9 @@ public:
 OMPDeclareTargetDeclAttr::MapTypeTy MT,
 NamedDeclSetType &SameDirectiveDecls);
   /// Check declaration inside target region.
-  void checkDeclIsAllowedInOpenMPTarget(Expr *E, Decl *D,
-SourceLocation IdLoc = 
SourceLocation());
+  void
+  checkDeclIsAllowedInOpenMPTarget(Expr *E, Decl *D,
+   SourceLocation IdLoc = SourceLocation());
   /// Return true inside OpenMP declare target region.
   bool isInOpenMPDeclareTargetContext() const {
 return IsInOpenMPDeclareTargetContext;

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=339152&r1=339151&r2=339152&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Tue Aug  7 09:14:36 2018
@@ -8106,7 +8106,12 @@ bool CGOpenMPRuntime::emitTargetGlobalVa
   // Do not to emit variable if it is not marked as declare target.
   llvm::Optional Res =
   isDeclareTargetDeclaration(cast(GD.getDecl()));
-  return !Res || *Res == OMPDeclareTargetDeclAttr::MT_Link;
+  if (!Res || *Res == OMPDeclareTargetDeclAttr::MT_Link) {
+if (CGM.getContext().DeclMustBeEmitted(GD.getDecl()))
+  DeferredGlobalVariables.insert(cast(GD.getDecl()));
+return true;
+  }
+  return false;
 }
 
 void CGOpenMPRuntime::registerTargetGlobalVariable(const VarDecl *VD,
@@ -8163,6 +8168,18 @@ bool CGOpenMPRuntime::emitTargetGlobal(G
   return emitTargetGlobalVariable(GD);
 }
 
+void CGOpenMPRuntime::emitDeferredTargetDecls() const {
+  for (const VarDecl *VD : DeferredGlobalVariables) {
+llvm::Optional Res =
+isDeclareTargetDeclaration(VD);
+if (Res) {
+  assert(*Res != OMPDeclareTargetDeclAttr::MT_Link &&
+ "Implicit declare target variables must be only to().");
+  CGM.EmitGlobal(VD);
+}
+  }
+}
+
 CGOpenMPRuntime::DisableAutoDeclareTargetRAII::DisableAutoDeclareTargetRAII(
 CodeGenModule &CGM)
 : CGM(CGM) {

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h?rev=339152&r1=339151&r2=339152&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h Tue Aug  7 09:14:36 2018
@@ -602,6 +602,10 @@ private:
   bool ShouldMarkAsGlobal = true;
   llvm::SmallDenseSet AlreadyEmittedTargetFunctions;
 
+  /// List of variables that can become declare target implicitly and, thus,
+  /// must be emitted.
+  llvm::SmallDenseSet DeferredGlobalVariables;
+
   /// Creates and registers offloading binary descriptor for the current
   /// compilation unit. The function that does the registration is returned.
   llvm::Function *createOffloadingBinaryDescriptorRegistration();
@@ -1509,6 +1513,8 @@ public:
   /// true, if it was marked already, and false, otherwise.
   bool markAsGlobalTarget(GlobalDecl GD);
 
+  /// Emit deferred declare target variables marked for deferred emission.
+  void emitDeferredTargetDecls() const;
 };
 
 /// Class supports emissionof SIMD-only code.

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/Co

[PATCH] D47849: [OpenMP][Clang][NVPTX] Enable math functions called in an OpenMP NVPTX target device region to be resolved as device-native function calls

2018-08-07 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea added a comment.

In https://reviews.llvm.org/D47849#1190903, @Hahnfeld wrote:

> Do we still need this? I think what we really need to solve is the problem of 
> (host) inline assembly in the header files...


Don't we want to use device specific math functions?
It's not just about avoiding some the host specific assembly, it's also about 
getting an implementation tailored to the device.


Repository:
  rC Clang

https://reviews.llvm.org/D47849



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


Re: [PATCH] D50154: [clangd] capitalize diagnostic messages

2018-08-07 Thread David Blaikie via cfe-commits
What's the motivation for clangd to differ from clang here? (& if the first
letter is going to be capitalized, should there be a period at the end? But
also the phrasing of most/all diagnostic text isn't in the form of complete
sentences, so this might not make sense)

On Fri, Aug 3, 2018 at 1:44 PM Alex Lorenz via Phabricator via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> This revision was automatically updated to reflect the committed changes.
> Closed by commit rCTE338919: [clangd] capitalize diagnostic messages
> (authored by arphaman, committed by ).
>
> Changed prior to commit:
>   https://reviews.llvm.org/D50154?vs=159059&id=159080#toc
>
> Repository:
>   rCTE Clang Tools Extra
>
> https://reviews.llvm.org/D50154
>
> Files:
>   clangd/Diagnostics.cpp
>   test/clangd/diagnostics.test
>   test/clangd/did-change-configuration-params.test
>   test/clangd/execute-command.test
>   test/clangd/extra-flags.test
>   test/clangd/fixits.test
>   unittests/clangd/ClangdUnitTests.cpp
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D50154: [clangd] capitalize diagnostic messages

2018-08-07 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added subscribers: ilya-biryukov, dblaikie.
dblaikie added a comment.

What's the motivation for clangd to differ from clang here? (& if the first
letter is going to be capitalized, should there be a period at the end? But
also the phrasing of most/all diagnostic text isn't in the form of complete
sentences, so this might not make sense)


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D50154



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


Re: r338467 - Avoid exposing name for range-based for '__range' variables in lifetime warnings.

2018-08-07 Thread David Blaikie via cfe-commits
Reckon there's a chance of improved diagnostic text in cases like this?
Will users understand what the problem is/how to fix it when they read
"temporary
implicitly bound to local reference will be destroyed at the end of the
full-expression" - feels very standard-ese-y to me? & I appreciate teh
desire/need for precision, I wonder if there's better ways to communicate
it to the user... :/

On Tue, Jul 31, 2018 at 6:03 PM Richard Smith via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: rsmith
> Date: Tue Jul 31 18:03:33 2018
> New Revision: 338467
>
> URL: http://llvm.org/viewvc/llvm-project?rev=338467&view=rev
> Log:
> Avoid exposing name for range-based for '__range' variables in lifetime
> warnings.
>
> Modified:
> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> cfe/trunk/lib/Sema/SemaInit.cpp
> cfe/trunk/test/SemaCXX/attr-lifetimebound.cpp
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=338467&r1=338466&r2=338467&view=diff
>
> ==
> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Jul 31
> 18:03:33 2018
> @@ -7875,7 +7875,8 @@ def warn_ret_addr_label : Warning<
>  def err_ret_local_block : Error<
>"returning block that lives on the local stack">;
>  def note_local_var_initializer : Note<
> -  "%select{via initialization of|binding reference}0 variable %1 here">;
> +  "%select{via initialization of|binding reference}0 variable "
> +  "%select{%2 |}1here">;
>  def note_init_with_default_member_initalizer : Note<
>"initializing field %0 with default member initializer">;
>
> @@ -7907,13 +7908,14 @@ def note_lifetime_extending_member_decla
>"member with %select{reference|'std::initializer_list'}0 subobject}1 "
>"declared here">;
>  def warn_dangling_variable : Warning<
> -  "%select{temporary %select{whose address is used as value of|bound to}3
> "
> -  "%select{%select{|reference }3member of local variable|"
> -  "local %select{variable|reference}3}1|"
> +  "%select{temporary %select{whose address is used as value of|"
> +  "%select{|implicitly }2bound to}4 "
> +  "%select{%select{|reference }4member of local variable|"
> +  "local %select{variable|reference}4}1|"
>"array backing "
>"%select{initializer list subobject of local variable|"
>"local initializer list}1}0 "
> -  "%2 will be destroyed at the end of the full-expression">,
> +  "%select{%3 |}2will be destroyed at the end of the full-expression">,
>InGroup;
>  def warn_new_dangling_reference : Warning<
>"temporary bound to reference member of allocated object "
>
> Modified: cfe/trunk/lib/Sema/SemaInit.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=338467&r1=338466&r2=338467&view=diff
>
> ==
> --- cfe/trunk/lib/Sema/SemaInit.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaInit.cpp Tue Jul 31 18:03:33 2018
> @@ -6847,8 +6847,9 @@ void Sema::checkInitializerLifetime(cons
>return false;
>
>  Diag(DiagLoc, diag::warn_dangling_variable)
> -<< RK << !Entity.getParent() << ExtendingEntity->getDecl()
> -<< Init->isGLValue() << DiagRange;
> +<< RK << !Entity.getParent()
> +<< ExtendingEntity->getDecl()->isImplicit()
> +<< ExtendingEntity->getDecl() << Init->isGLValue() <<
> DiagRange;
>}
>break;
>  }
> @@ -6969,7 +6970,8 @@ void Sema::checkInitializerLifetime(cons
>case IndirectLocalPathEntry::VarInit:
>  const VarDecl *VD = cast(Elem.D);
>  Diag(VD->getLocation(), diag::note_local_var_initializer)
> -<< VD->getType()->isReferenceType() << VD->getDeclName()
> +<< VD->getType()->isReferenceType()
> +<< VD->isImplicit() << VD->getDeclName()
>  << nextPathEntryRange(Path, I + 1, L);
>  break;
>}
>
> Modified: cfe/trunk/test/SemaCXX/attr-lifetimebound.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/attr-lifetimebound.cpp?rev=338467&r1=338466&r2=338467&view=diff
>
> ==
> --- cfe/trunk/test/SemaCXX/attr-lifetimebound.cpp (original)
> +++ cfe/trunk/test/SemaCXX/attr-lifetimebound.cpp Tue Jul 31 18:03:33 2018
> @@ -101,7 +101,7 @@ namespace p0936r0_examples {
>std::vector make_vector();
>void use_reversed_range() {
>  // FIXME: Don't expose the name of the internal range variable.
> -for (auto x : reversed(make_vector())) {} // expected-warning
> {{temporary bound to local reference '__range1'}}
> +for (auto x : reversed(make_vector())) {} // expected-warning
> {{temporary implicitly bound to local reference will be 

Re: r338732 - [analyzer] Make RegionVector use const reference

2018-08-07 Thread David Blaikie via cfe-commits
Looks good! Though it may be useful in the future to describe, in the
commit message, the motivation for a change - how'd you find this? What
motivated you to make this particular fix just now, etc? ("identified using
clang-tidy" or "spotted during post-commit review of change r", etc...)

On Thu, Aug 2, 2018 at 9:29 AM Fangrui Song via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: maskray
> Date: Thu Aug  2 09:29:36 2018
> New Revision: 338732
>
> URL: http://llvm.org/viewvc/llvm-project?rev=338732&view=rev
> Log:
> [analyzer] Make RegionVector use const reference
>
> Modified:
> cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
>
> Modified: cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp?rev=338732&r1=338731&r2=338732&view=diff
>
> ==
> --- cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp (original)
> +++ cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp Thu Aug  2
> 09:29:36 2018
> @@ -395,7 +395,7 @@ private:
>const Optional
>findRegionOfInterestInRecord(const RecordDecl *RD, ProgramStateRef
> State,
> const MemRegion *R,
> -   RegionVector Vec = {},
> +   const RegionVector &Vec = {},
> int depth = 0) {
>
>  if (depth == DEREFERENCE_LIMIT) // Limit the recursion depth.
> @@ -548,14 +548,10 @@ private:
>
>/// \return Diagnostics piece for region not modified in the current
> function.
>std::shared_ptr
> -  notModifiedDiagnostics(const LocationContext *Ctx,
> - CallExitBegin &CallExitLoc,
> - CallEventRef<> Call,
> - RegionVector FieldChain,
> - const MemRegion *MatchedRegion,
> - StringRef FirstElement,
> - bool FirstIsReferenceType,
> - unsigned IndirectionLevel) {
> +  notModifiedDiagnostics(const LocationContext *Ctx, CallExitBegin
> &CallExitLoc,
> + CallEventRef<> Call, const RegionVector
> &FieldChain,
> + const MemRegion *MatchedRegion, StringRef
> FirstElement,
> + bool FirstIsReferenceType, unsigned
> IndirectionLevel) {
>
>  PathDiagnosticLocation L;
>  if (const ReturnStmt *RS = CallExitLoc.getReturnStmt()) {
> @@ -579,7 +575,8 @@ private:
>/// Pretty-print region \p MatchedRegion to \p os.
>void prettyPrintRegionName(StringRef FirstElement, bool
> FirstIsReferenceType,
>   const MemRegion *MatchedRegion,
> - RegionVector FieldChain, int
> IndirectionLevel,
> + const RegionVector &FieldChain,
> + int IndirectionLevel,
>   llvm::raw_svector_ostream &os) {
>
>  if (FirstIsReferenceType)
>
>
> ___
> 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] D49897: [WebAssembly] Force use of lld for test/Driver/wasm-toolchain.c(pp)

2018-08-07 Thread David Greene via Phabricator via cfe-commits
greened added a comment.

In https://reviews.llvm.org/D49897#1189688, @sbc100 wrote:

> But in the CL description you say "..when configuring clang to use a 
> different linker by default".  How is this possible?i.e. do you have a 
> config where these tests are currently failing?


Yes, I do.  I configured with -DCLANG_DEFAULT_LINKER=gold.


Repository:
  rC Clang

https://reviews.llvm.org/D49897



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


[PATCH] D49897: [WebAssembly] Force use of lld for test/Driver/wasm-toolchain.c(pp)

2018-08-07 Thread Sam Clegg via Phabricator via cfe-commits
sbc100 accepted this revision.
sbc100 added a comment.
This revision is now accepted and ready to land.

I see.  This seems a little strange to me.  I'm not sure it makes sense for 
CLANG_DEFAULT_LINKER to effect targets like WebAssembly that only have single 
supported linker.  I'm OK with landing this now but I think we might need to 
look into a better solution.


Repository:
  rC Clang

https://reviews.llvm.org/D49897



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


[PATCH] D50395: [WebAssembly] Remove use of lld -flavor flag

2018-08-07 Thread Sam Clegg via Phabricator via cfe-commits
sbc100 created this revision.
Herald added subscribers: cfe-commits, sunfish, aheejin, jgravelle-google, 
dschuff.

This flag is deprecated. The prefered way to select the lld
flavor is by calling it by one of its aliases.


Repository:
  rC Clang

https://reviews.llvm.org/D50395

Files:
  lib/Driver/ToolChains/WebAssembly.cpp
  lib/Driver/ToolChains/WebAssembly.h
  test/Driver/wasm-toolchain.cpp


Index: test/Driver/wasm-toolchain.cpp
===
--- test/Driver/wasm-toolchain.cpp
+++ test/Driver/wasm-toolchain.cpp
@@ -14,10 +14,10 @@
 
 // RUN: %clangxx -### -no-canonical-prefixes -target wasm32-unknown-unknown 
--sysroot=/foo --stdlib=c++ %s 2>&1 | FileCheck -check-prefix=LINK %s
 // LINK: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
-// LINK: lld{{.*}}" "-flavor" "wasm" "-L/foo/lib" "crt1.o" "[[temp]]" "-lc++" 
"-lc++abi" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
+// LINK: wasm-ld{{.*}}" "-L/foo/lib" "crt1.o" "[[temp]]" "-lc++" "-lc++abi" 
"-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
 
 // A basic C++ link command-line with optimization.
 
 // RUN: %clangxx -### -O2 -no-canonical-prefixes -target 
wasm32-unknown-unknown --sysroot=/foo %s --stdlib=c++ 2>&1 | FileCheck 
-check-prefix=LINK_OPT %s
 // LINK_OPT: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
-// LINK_OPT: lld{{.*}}" "-flavor" "wasm" "-L/foo/lib" "crt1.o" "[[temp]]" 
"-lc++" "-lc++abi" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
+// LINK_OPT: wasm-ld{{.*}}" "-L/foo/lib" "crt1.o" "[[temp]]" "-lc++" 
"-lc++abi" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
Index: lib/Driver/ToolChains/WebAssembly.h
===
--- lib/Driver/ToolChains/WebAssembly.h
+++ lib/Driver/ToolChains/WebAssembly.h
@@ -66,9 +66,7 @@
llvm::opt::ArgStringList &CmdArgs) const override;
   std::string getThreadModel() const override;
 
-  const char *getDefaultLinker() const override {
-return "lld";
-  }
+  const char *getDefaultLinker() const override { return "wasm-ld"; }
 
   Tool *buildLinker() const override;
 };
Index: lib/Driver/ToolChains/WebAssembly.cpp
===
--- lib/Driver/ToolChains/WebAssembly.cpp
+++ lib/Driver/ToolChains/WebAssembly.cpp
@@ -41,8 +41,6 @@
   const ToolChain &ToolChain = getToolChain();
   const char *Linker = Args.MakeArgString(ToolChain.GetLinkerPath());
   ArgStringList CmdArgs;
-  CmdArgs.push_back("-flavor");
-  CmdArgs.push_back("wasm");
 
   if (Args.hasArg(options::OPT_s))
 CmdArgs.push_back("--strip-all");


Index: test/Driver/wasm-toolchain.cpp
===
--- test/Driver/wasm-toolchain.cpp
+++ test/Driver/wasm-toolchain.cpp
@@ -14,10 +14,10 @@
 
 // RUN: %clangxx -### -no-canonical-prefixes -target wasm32-unknown-unknown --sysroot=/foo --stdlib=c++ %s 2>&1 | FileCheck -check-prefix=LINK %s
 // LINK: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
-// LINK: lld{{.*}}" "-flavor" "wasm" "-L/foo/lib" "crt1.o" "[[temp]]" "-lc++" "-lc++abi" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
+// LINK: wasm-ld{{.*}}" "-L/foo/lib" "crt1.o" "[[temp]]" "-lc++" "-lc++abi" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
 
 // A basic C++ link command-line with optimization.
 
 // RUN: %clangxx -### -O2 -no-canonical-prefixes -target wasm32-unknown-unknown --sysroot=/foo %s --stdlib=c++ 2>&1 | FileCheck -check-prefix=LINK_OPT %s
 // LINK_OPT: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
-// LINK_OPT: lld{{.*}}" "-flavor" "wasm" "-L/foo/lib" "crt1.o" "[[temp]]" "-lc++" "-lc++abi" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
+// LINK_OPT: wasm-ld{{.*}}" "-L/foo/lib" "crt1.o" "[[temp]]" "-lc++" "-lc++abi" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
Index: lib/Driver/ToolChains/WebAssembly.h
===
--- lib/Driver/ToolChains/WebAssembly.h
+++ lib/Driver/ToolChains/WebAssembly.h
@@ -66,9 +66,7 @@
llvm::opt::ArgStringList &CmdArgs) const override;
   std::string getThreadModel() const override;
 
-  const char *getDefaultLinker() const override {
-return "lld";
-  }
+  const char *getDefaultLinker() const override { return "wasm-ld"; }
 
   Tool *buildLinker() const override;
 };
Index: lib/Driver/ToolChains/WebAssembly.cpp
===
--- lib/Driver/ToolChains/WebAssembly.cpp
+++ lib/Driver/ToolChains/WebAssembly.cpp
@@ -41,8 +41,6 @@
   const ToolChain &ToolChain = getToolChain();
   const char *Linker = Args.MakeArgString(ToolChain.GetLinkerPath());
   ArgStringList CmdArgs;
-  CmdArgs.push_back("-flavor");
-  CmdArgs.push_back("wasm");
 
   if (Args.hasArg(options::OPT_s))
 CmdArgs.push_back("--strip

[PATCH] D50395: [WebAssembly] Remove use of lld -flavor flag

2018-08-07 Thread Sam Clegg via Phabricator via cfe-commits
sbc100 updated this revision to Diff 159533.
sbc100 added a comment.

- update test


Repository:
  rC Clang

https://reviews.llvm.org/D50395

Files:
  lib/Driver/ToolChains/WebAssembly.cpp
  lib/Driver/ToolChains/WebAssembly.h
  test/Driver/wasm-toolchain.c
  test/Driver/wasm-toolchain.cpp


Index: test/Driver/wasm-toolchain.cpp
===
--- test/Driver/wasm-toolchain.cpp
+++ test/Driver/wasm-toolchain.cpp
@@ -14,10 +14,10 @@
 
 // RUN: %clangxx -### -no-canonical-prefixes -target wasm32-unknown-unknown 
--sysroot=/foo --stdlib=c++ %s 2>&1 | FileCheck -check-prefix=LINK %s
 // LINK: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
-// LINK: lld{{.*}}" "-flavor" "wasm" "-L/foo/lib" "crt1.o" "[[temp]]" "-lc++" 
"-lc++abi" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
+// LINK: wasm-ld{{.*}}" "-L/foo/lib" "crt1.o" "[[temp]]" "-lc++" "-lc++abi" 
"-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
 
 // A basic C++ link command-line with optimization.
 
 // RUN: %clangxx -### -O2 -no-canonical-prefixes -target 
wasm32-unknown-unknown --sysroot=/foo %s --stdlib=c++ 2>&1 | FileCheck 
-check-prefix=LINK_OPT %s
 // LINK_OPT: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
-// LINK_OPT: lld{{.*}}" "-flavor" "wasm" "-L/foo/lib" "crt1.o" "[[temp]]" 
"-lc++" "-lc++abi" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
+// LINK_OPT: wasm-ld{{.*}}" "-L/foo/lib" "crt1.o" "[[temp]]" "-lc++" 
"-lc++abi" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
Index: test/Driver/wasm-toolchain.c
===
--- test/Driver/wasm-toolchain.c
+++ test/Driver/wasm-toolchain.c
@@ -14,10 +14,10 @@
 
 // RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown 
--sysroot=/foo %s 2>&1 | FileCheck -check-prefix=LINK %s
 // LINK: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
-// LINK: lld{{.*}}" "-flavor" "wasm" "-L/foo/lib" "crt1.o" "[[temp]]" "-lc" 
"{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
+// LINK: wasm-ld{{.*}}" "-L/foo/lib" "crt1.o" "[[temp]]" "-lc" 
"{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
 
 // A basic C link command-line with optimization.
 
 // RUN: %clang -### -O2 -no-canonical-prefixes -target wasm32-unknown-unknown 
--sysroot=/foo %s 2>&1 | FileCheck -check-prefix=LINK_OPT %s
 // LINK_OPT: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
-// LINK_OPT: lld{{.*}}" "-flavor" "wasm" "-L/foo/lib" "crt1.o" "[[temp]]" 
"-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
+// LINK_OPT: wasm-ld{{.*}}" "-L/foo/lib" "crt1.o" "[[temp]]" "-lc" 
"{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
Index: lib/Driver/ToolChains/WebAssembly.h
===
--- lib/Driver/ToolChains/WebAssembly.h
+++ lib/Driver/ToolChains/WebAssembly.h
@@ -66,9 +66,7 @@
llvm::opt::ArgStringList &CmdArgs) const override;
   std::string getThreadModel() const override;
 
-  const char *getDefaultLinker() const override {
-return "lld";
-  }
+  const char *getDefaultLinker() const override { return "wasm-ld"; }
 
   Tool *buildLinker() const override;
 };
Index: lib/Driver/ToolChains/WebAssembly.cpp
===
--- lib/Driver/ToolChains/WebAssembly.cpp
+++ lib/Driver/ToolChains/WebAssembly.cpp
@@ -41,8 +41,6 @@
   const ToolChain &ToolChain = getToolChain();
   const char *Linker = Args.MakeArgString(ToolChain.GetLinkerPath());
   ArgStringList CmdArgs;
-  CmdArgs.push_back("-flavor");
-  CmdArgs.push_back("wasm");
 
   if (Args.hasArg(options::OPT_s))
 CmdArgs.push_back("--strip-all");


Index: test/Driver/wasm-toolchain.cpp
===
--- test/Driver/wasm-toolchain.cpp
+++ test/Driver/wasm-toolchain.cpp
@@ -14,10 +14,10 @@
 
 // RUN: %clangxx -### -no-canonical-prefixes -target wasm32-unknown-unknown --sysroot=/foo --stdlib=c++ %s 2>&1 | FileCheck -check-prefix=LINK %s
 // LINK: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
-// LINK: lld{{.*}}" "-flavor" "wasm" "-L/foo/lib" "crt1.o" "[[temp]]" "-lc++" "-lc++abi" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
+// LINK: wasm-ld{{.*}}" "-L/foo/lib" "crt1.o" "[[temp]]" "-lc++" "-lc++abi" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
 
 // A basic C++ link command-line with optimization.
 
 // RUN: %clangxx -### -O2 -no-canonical-prefixes -target wasm32-unknown-unknown --sysroot=/foo %s --stdlib=c++ 2>&1 | FileCheck -check-prefix=LINK_OPT %s
 // LINK_OPT: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
-// LINK_OPT: lld{{.*}}" "-flavor" "wasm" "-L/foo/lib" "crt1.o" "[[temp]]" "-lc++" "-lc++abi" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
+// LINK_OPT: wasm-ld{{.*}}" "-L/foo/lib" "crt1.o" "[[temp]]" "-lc++" "-lc++abi" "-lc" "{{.*[/\\]}}libclang_rt.

[PATCH] D49851: [clang-tidy] run-clang-tidy add synchronisation to the output

2018-08-07 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment.

I do run it over llvm/lib, there is no visible effect. from my experience maybe 
1-5% of the lines are interleafed without the patch, too.


https://reviews.llvm.org/D49851



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


[PATCH] D47394: [OpenMP][Clang][NVPTX] Replace bundling with partial linking for the OpenMP NVPTX device offloading toolchain

2018-08-07 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea added inline comments.



Comment at: lib/Driver/ToolChains/Cuda.cpp:664
+  // Anything that's not a file name is potentially a static library
+  // so treat it as such.
+  if (C.canSkipOffloadBundler())

sfantao wrote:
> So, what if it is not a static library?
Can it be anything else at this point?


Repository:
  rC Clang

https://reviews.llvm.org/D47394



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


[PATCH] D47394: [OpenMP][Clang][NVPTX] Replace bundling with partial linking for the OpenMP NVPTX device offloading toolchain

2018-08-07 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 159536.
gtbercea marked 3 inline comments as done.
gtbercea added a comment.

- Address comments.


Repository:
  rC Clang

https://reviews.llvm.org/D47394

Files:
  include/clang/Driver/Action.h
  include/clang/Driver/Compilation.h
  include/clang/Driver/Options.td
  include/clang/Driver/ToolChain.h
  lib/Driver/Action.cpp
  lib/Driver/Compilation.cpp
  lib/Driver/Driver.cpp
  lib/Driver/ToolChain.cpp
  lib/Driver/ToolChains/Clang.cpp
  lib/Driver/ToolChains/Clang.h
  lib/Driver/ToolChains/Cuda.cpp
  test/Driver/openmp-offload-gpu-linux.c
  test/Driver/openmp-offload-gpu.c
  test/Driver/openmp-offload.c

Index: test/Driver/openmp-offload.c
===
--- test/Driver/openmp-offload.c
+++ test/Driver/openmp-offload.c
@@ -480,13 +480,13 @@
 // Create host object and bundle.
 // CHK-BUJOBS: clang{{.*}}" "-cc1" "-triple" "powerpc64le--linux" "-emit-obj" {{.*}}"-fopenmp" {{.*}}"-o" "
 // CHK-BUJOBS-SAME: [[HOSTOBJ:[^\\/]+\.o]]" "-x" "ir" "{{.*}}[[HOSTBC]]"
-// CHK-BUJOBS: clang-offload-bundler{{.*}}" "-type=o" "-targets=openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu,host-powerpc64le--linux" "-outputs=
+// CHK-BUJOBS: clang-offload-bundler{{.*}}" "-type=o"{{.*}}"-targets=openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu,host-powerpc64le--linux" "-outputs=
 // CHK-BUJOBS-SAME: [[RES:[^\\/]+\.o]]" "-inputs={{.*}}[[T1OBJ]],{{.*}}[[T2OBJ]],{{.*}}[[HOSTOBJ]]"
 // CHK-BUJOBS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le--linux" "-S" {{.*}}"-fopenmp" {{.*}}"-o" "
 // CHK-BUJOBS-ST-SAME: [[HOSTASM:[^\\/]+\.s]]" "-x" "ir" "{{.*}}[[HOSTBC]]"
 // CHK-BUJOBS-ST: clang{{.*}}" "-cc1as" "-triple" "powerpc64le--linux" "-filetype" "obj" {{.*}}"-o" "
 // CHK-BUJOBS-ST-SAME: [[HOSTOBJ:[^\\/]+\.o]]" "{{.*}}[[HOSTASM]]"
-// CHK-BUJOBS-ST: clang-offload-bundler{{.*}}" "-type=o" "-targets=openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu,host-powerpc64le--linux" "-outputs=
+// CHK-BUJOBS-ST: clang-offload-bundler{{.*}}" "-type=o"{{.*}}"-targets=openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu,host-powerpc64le--linux" "-outputs=
 // CHK-BUJOBS-ST-SAME: [[RES:[^\\/]+\.o]]" "-inputs={{.*}}[[T1OBJ]],{{.*}}[[T2OBJ]],{{.*}}[[HOSTOBJ]]"
 
 /// ###
Index: test/Driver/openmp-offload-gpu.c
===
--- test/Driver/openmp-offload-gpu.c
+++ test/Driver/openmp-offload-gpu.c
@@ -61,7 +61,7 @@
 
 /// Check cubin file generation and bundling
 // RUN:   %clang -### -target powerpc64le-unknown-linux-gnu -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda \
-// RUN:  -no-canonical-prefixes -save-temps %s -c 2>&1 \
+// RUN:  -no-canonical-prefixes -save-temps %s -c -fopenmp-use-target-bundling 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHK-PTXAS-CUBIN-BUNDLING %s
 
 // CHK-PTXAS-CUBIN-BUNDLING: clang{{.*}}" "-o" "[[PTX:.*\.s]]"
@@ -73,7 +73,7 @@
 /// Check cubin file unbundling and usage by nvlink
 // RUN:   touch %t.o
 // RUN:   %clang -### -target powerpc64le-unknown-linux-gnu -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda \
-// RUN:  -no-canonical-prefixes -save-temps %t.o 2>&1 \
+// RUN:  -no-canonical-prefixes -save-temps %t.o -fopenmp-use-target-bundling 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHK-CUBIN-UNBUNDLING-NVLINK %s
 
 /// Use DAG to ensure that cubin file has been unbundled.
@@ -87,11 +87,11 @@
 // RUN:   touch %t1.o
 // RUN:   touch %t2.o
 // RUN:   %clang -### -no-canonical-prefixes -target powerpc64le-unknown-linux-gnu -fopenmp=libomp \
-// RUN:  -fopenmp-targets=nvptx64-nvidia-cuda %t1.o %t2.o 2>&1 \
+// RUN:  -fopenmp-targets=nvptx64-nvidia-cuda %t1.o %t2.o -fopenmp-use-target-bundling 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHK-TWOCUBIN %s
 /// Check cubin file generation and usage by nvlink when toolchain has BindArchAction
 // RUN:   %clang -### -no-canonical-prefixes -target x86_64-apple-darwin17.0.0 -fopenmp=libomp \
-// RUN:  -fopenmp-targets=nvptx64-nvidia-cuda %t1.o %t2.o 2>&1 \
+// RUN:  -fopenmp-targets=nvptx64-nvidia-cuda %t1.o %t2.o -fopenmp-use-target-bundling 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHK-TWOCUBIN %s
 
 // CHK-TWOCUBIN: nvlink{{.*}}openmp-offload-{{.*}}.cubin" "{{.*}}openmp-offload-{{.*}}.cubin"
Index: test/Driver/openmp-offload-gpu-linux.c
===
--- /dev/null
+++ test/Driver/openmp-offload-gpu-linux.c
@@ -0,0 +1,52 @@
+///
+/// Perform driver tests for OpenMP offloading on Linux systems
+///
+
+// UNSUPPORTED: system-windows
+
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// REQUIRES: powerpc-registered-target
+// REQUIRES: nvptx-registered-target
+
+/// Check cubin file generation and partial linking with ld
+// RUN:   %clang -### -target powerpc64le-unknown-linux-gnu -fopenmp=

[PATCH] D48896: [libcxx][c++17] P0083R5: Splicing Maps and Sets Part 2: merge

2018-08-07 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington added a comment.

Ping!


https://reviews.llvm.org/D48896



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


[PATCH] D49851: [clang-tidy] run-clang-tidy add synchronisation to the output

2018-08-07 Thread Andi via Phabricator via cfe-commits
Abpostelnicu added a comment.

Did you notice any significant speed degradation?


https://reviews.llvm.org/D49851



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


[PATCH] D50193: Added functionality to suggest FixIts for conversion of '->' to '.' and vice versa.

2018-08-07 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, with a few NITs.
Thanks for the change!




Comment at: clangd/Quality.h:81
+  bool NeedsFixIts =
+  false; // Whether fixits needs to be applied for that completion or not.
 

NIT: put the comment at the previous line to keep `false` at the same line.
NIT2: use three slashes, to make it a doxygen comment (previous one should also 
be three slashes).



Comment at: unittests/clangd/CodeCompleteTests.cpp:99
+
+// Builds a server and runs code completion.
+// If IndexSymbols is non-empty, an index will be built and passed to opts.

It seems this comment got moved accidentally, move it back?



Comment at: unittests/clangd/QualityTests.cpp:360
+  RelevanceWithFixIt.merge(
+  CodeCompletionResult(&findDecl(AST, "x"), 0, nullptr, false, true, 
{{}}));
+  EXPECT_TRUE(RelevanceWithFixIt.NeedsFixIts);

NIT: took me some time to figure out the difference between this and the next 
one.
Maybe add the explicit type name to make more implicit that we're creating a 
fix-it here, i.e. `{FixItHint{}}`?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D50193



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


[PATCH] D49851: [clang-tidy] run-clang-tidy add synchronisation to the output

2018-08-07 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment.

No nothing. I think it is barely noticable in general. From prior long
runs i notices the scrambled messages, but it was only a small fraction.
So most of the time the threads dont seem to interfere, which makes the
lock kinda low-cost.

Am 07.08.2018 um 19:17 schrieb Andi via Phabricator:

> Abpostelnicu added a comment.
> 
> Did you notice any significant speed degradation?
> 
> https://reviews.llvm.org/D49851


https://reviews.llvm.org/D49851



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


[PATCH] D50389: [clang-tidy] new check for Abseil

2018-08-07 Thread Deanna Garcia via Phabricator via cfe-commits
deannagarcia updated this revision to Diff 159537.

https://reviews.llvm.org/D50389

Files:
  clang-tidy/abseil/AbseilTidyModule.cpp
  clang-tidy/abseil/DurationDivisionCheck.cpp
  clang-tidy/abseil/DurationDivisionCheck.h
  docs/clang-tidy/checks/abseil-duration-division.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/abseil-duration-division.cpp

Index: test/clang-tidy/abseil-duration-division.cpp
===
--- test/clang-tidy/abseil-duration-division.cpp
+++ test/clang-tidy/abseil-duration-division.cpp
@@ -0,0 +1,44 @@
+// RUN: %check_clang_tidy %s abseil-duration-division %t
+
+namespace absl {
+
+class Duration {};
+
+int operator/(Duration lhs, Duration rhs);
+
+double FDivDuration(Duration num, Duration den);
+
+}  // namespace absl
+
+void TakesInt(int);
+void TakesDouble(double);
+
+absl::Duration d;
+
+#define MACRO_EQ(x, y) (x == y)
+#define MACRO_DIVEQ(x,y,z) (x/y == z)
+#define CHECK(x) (x)
+
+void Positives() {
+  const double num = d/d;
+  // CHECK-MESSAGES: [[@LINE-1]]:23: warning: operator/ on Duration objects performs integer division; did you mean to use FDivDuration()? [abseil-duration-division]
+  // CHECK-FIXES: const double num = absl::FDivDuration(d, d);
+  if (MACRO_EQ(d/d, 0.0)) {}
+  // CHECK-MESSAGES: [[@LINE-1]]:17: warning: operator/ on Duration objects
+  // CHECK-FIXES: if (MACRO_EQ(absl::FDivDuration(d, d), 0.0)) {}
+  if (CHECK(MACRO_EQ(d/d, 0.0))) {}
+  // CHECK-MESSAGES: [[@LINE-1]]:23: warning: operator/ on Duration objects
+  // CHECK-FIXES: if (CHECK(MACRO_EQ(absl::FDivDuration(d, d), 0.0))) {}
+
+  // This one generates a message, but no fix.
+  if (MACRO_DIVEQ(d, d, 0.0)) {}
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: operator/ on Duration objects
+  // CHECK-FIXES: if (MACRO_DIVEQ(d, d, 0.0)) {}
+}
+
+void Negatives() {
+  const int num = d/d;
+
+  // Explicit cast should disable the warning.
+  const double num_d = static_cast(d/d);
+}
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -4,6 +4,7 @@
 =
 
 .. toctree::
+   abseil-duration-division
abseil-string-find-startswith
android-cloexec-accept
android-cloexec-accept4
Index: docs/clang-tidy/checks/abseil-duration-division.rst
===
--- docs/clang-tidy/checks/abseil-duration-division.rst
+++ docs/clang-tidy/checks/abseil-duration-division.rst
@@ -0,0 +1,36 @@
+.. title:: clang-tidy - abseil-duration-division
+  
+abseil-duration-division
+
+
+``absl::Duration`` arithmetic works like it does with integers. That means that
+division of two ``absl::Duration`` objects returns an ``int64`` with any fractional
+component truncated toward 0.
+
+For example:
+
+.. code-block:: c++
+
+ absl::Duration d = absl::Seconds(3.5);
+ int64 sec1 = d / absl::Seconds(1); // Truncates toward 0.
+ int64 sec2 = absl::ToInt64Seconds(d);  // Equivalent to division.
+ assert(sec1 == 3 && sec2 == 3);
+
+ double dsec = d / absl::Seconds(1);  // WRONG: Still truncates toward 0.
+ assert(dsec == 3.0);
+
+If you want floating-point division, you should use either the
+``absl::FDivDuration()`` function, or one of the unit conversion functions such
+as ``absl::ToDoubleSeconds()``. For example:
+
+.. code-block:: c++
+
+ absl::Duration d = absl::Seconds(3.5);
+ double dsec1 = absl::FDivDuration(d, absl::Seconds(1));  // GOOD: No truncation.
+ double dsec2 = absl::ToDoubleSeconds(d); // GOOD: No truncation.
+ assert(dsec1 == 3.5 && dsec2 == 3.5);
+
+
+This check looks for uses of ``absl::Duration`` division that is done in a
+floating-point context, and recommends the use of a function that returns a
+floating-point value.
Index: clang-tidy/abseil/DurationDivisionCheck.h
===
--- clang-tidy/abseil/DurationDivisionCheck.h
+++ clang-tidy/abseil/DurationDivisionCheck.h
@@ -0,0 +1,31 @@
+//===--- DurationDivisionCheck.h - clang-tidy*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ABSEIL_DURATIONDIVISIONCHECK_H_
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ABSEIL_DURATIONDIVISIONCHECK_H_
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+namespace abseil {
+
+// Find potential incorrect uses of integer division of absl::Duration objects.
+class DurationDivisionCheck : public ClangTidyCheck {
+public:
+  using ClangTidyCheck::ClangTidyCheck;
+  void registerMatchers(ast_matchers::MatchFinder *finder) override;
+  void check(const ast_matchers::MatchFi

[PATCH] D50154: [clangd] capitalize diagnostic messages

2018-08-07 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

In https://reviews.llvm.org/D50154#1191002, @dblaikie wrote:

> What's the motivation for clangd to differ from clang here? (& if the first
>  letter is going to be capitalized, should there be a period at the end? But
>  also the phrasing of most/all diagnostic text isn't in the form of complete
>  sentences, so this might not make sense)


It's mostly for the presentation purposes, to match the needs of our client. I 
first implemented it as an opt-in feature, but the consensus was to capitalize 
the messages all the time. 
I don't think it would make sense to insert the period at the end, because, as 
you said, not all diagnostics are complete sentences


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D50154



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


[PATCH] D50168: [Builtins] Implement __builtin_clrsb to be compatible with gcc

2018-08-07 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

Ping


https://reviews.llvm.org/D50168



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


r339158 - [WebAssembly] Force use of lld for test/Driver/wasm-toolchain.c(pp)

2018-08-07 Thread David Greene via cfe-commits
Author: greened
Date: Tue Aug  7 10:44:43 2018
New Revision: 339158

URL: http://llvm.org/viewvc/llvm-project?rev=339158&view=rev
Log:
[WebAssembly] Force use of lld for test/Driver/wasm-toolchain.c(pp)

lld is the only supported linker that works for WebAssembly, so ensure
clang is using it for this test. This gets the tests passing when
configuring clang to use a different linker by default.

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


Modified:
cfe/trunk/test/Driver/wasm-toolchain.c
cfe/trunk/test/Driver/wasm-toolchain.cpp

Modified: cfe/trunk/test/Driver/wasm-toolchain.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/wasm-toolchain.c?rev=339158&r1=339157&r2=339158&view=diff
==
--- cfe/trunk/test/Driver/wasm-toolchain.c (original)
+++ cfe/trunk/test/Driver/wasm-toolchain.c Tue Aug  7 10:44:43 2018
@@ -12,12 +12,12 @@
 
 // A basic C link command-line.
 
-// RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown 
--sysroot=/foo %s 2>&1 | FileCheck -check-prefix=LINK %s
+// RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown 
--sysroot=/foo -fuse-ld=lld %s 2>&1 | FileCheck -check-prefix=LINK %s
 // LINK: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
 // LINK: lld{{.*}}" "-flavor" "wasm" "-L/foo/lib" "crt1.o" "[[temp]]" "-lc" 
"{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
 
 // A basic C link command-line with optimization.
 
-// RUN: %clang -### -O2 -no-canonical-prefixes -target wasm32-unknown-unknown 
--sysroot=/foo %s 2>&1 | FileCheck -check-prefix=LINK_OPT %s
+// RUN: %clang -### -O2 -no-canonical-prefixes -target wasm32-unknown-unknown 
--sysroot=/foo -fuse-ld=lld %s 2>&1 | FileCheck -check-prefix=LINK_OPT %s
 // LINK_OPT: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
 // LINK_OPT: lld{{.*}}" "-flavor" "wasm" "-L/foo/lib" "crt1.o" "[[temp]]" 
"-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"

Modified: cfe/trunk/test/Driver/wasm-toolchain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/wasm-toolchain.cpp?rev=339158&r1=339157&r2=339158&view=diff
==
--- cfe/trunk/test/Driver/wasm-toolchain.cpp (original)
+++ cfe/trunk/test/Driver/wasm-toolchain.cpp Tue Aug  7 10:44:43 2018
@@ -12,12 +12,12 @@
 
 // A basic C++ link command-line.
 
-// RUN: %clangxx -### -no-canonical-prefixes -target wasm32-unknown-unknown 
--sysroot=/foo --stdlib=c++ %s 2>&1 | FileCheck -check-prefix=LINK %s
+// RUN: %clangxx -### -no-canonical-prefixes -target wasm32-unknown-unknown 
--sysroot=/foo --stdlib=c++ -fuse-ld=lld %s 2>&1 | FileCheck -check-prefix=LINK 
%s
 // LINK: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
 // LINK: lld{{.*}}" "-flavor" "wasm" "-L/foo/lib" "crt1.o" "[[temp]]" "-lc++" 
"-lc++abi" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
 
 // A basic C++ link command-line with optimization.
 
-// RUN: %clangxx -### -O2 -no-canonical-prefixes -target 
wasm32-unknown-unknown --sysroot=/foo %s --stdlib=c++ 2>&1 | FileCheck 
-check-prefix=LINK_OPT %s
+// RUN: %clangxx -### -O2 -no-canonical-prefixes -target 
wasm32-unknown-unknown --sysroot=/foo %s --stdlib=c++ -fuse-ld=lld 2>&1 | 
FileCheck -check-prefix=LINK_OPT %s
 // LINK_OPT: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
 // LINK_OPT: lld{{.*}}" "-flavor" "wasm" "-L/foo/lib" "crt1.o" "[[temp]]" 
"-lc++" "-lc++abi" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"


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


[PATCH] D49897: [WebAssembly] Force use of lld for test/Driver/wasm-toolchain.c(pp)

2018-08-07 Thread David Greene via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC339158: [WebAssembly] Force use of lld for 
test/Driver/wasm-toolchain.c(pp) (authored by greened, committed by ).

Repository:
  rC Clang

https://reviews.llvm.org/D49897

Files:
  test/Driver/wasm-toolchain.c
  test/Driver/wasm-toolchain.cpp


Index: test/Driver/wasm-toolchain.cpp
===
--- test/Driver/wasm-toolchain.cpp
+++ test/Driver/wasm-toolchain.cpp
@@ -12,12 +12,12 @@
 
 // A basic C++ link command-line.
 
-// RUN: %clangxx -### -no-canonical-prefixes -target wasm32-unknown-unknown 
--sysroot=/foo --stdlib=c++ %s 2>&1 | FileCheck -check-prefix=LINK %s
+// RUN: %clangxx -### -no-canonical-prefixes -target wasm32-unknown-unknown 
--sysroot=/foo --stdlib=c++ -fuse-ld=lld %s 2>&1 | FileCheck -check-prefix=LINK 
%s
 // LINK: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
 // LINK: lld{{.*}}" "-flavor" "wasm" "-L/foo/lib" "crt1.o" "[[temp]]" "-lc++" 
"-lc++abi" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
 
 // A basic C++ link command-line with optimization.
 
-// RUN: %clangxx -### -O2 -no-canonical-prefixes -target 
wasm32-unknown-unknown --sysroot=/foo %s --stdlib=c++ 2>&1 | FileCheck 
-check-prefix=LINK_OPT %s
+// RUN: %clangxx -### -O2 -no-canonical-prefixes -target 
wasm32-unknown-unknown --sysroot=/foo %s --stdlib=c++ -fuse-ld=lld 2>&1 | 
FileCheck -check-prefix=LINK_OPT %s
 // LINK_OPT: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
 // LINK_OPT: lld{{.*}}" "-flavor" "wasm" "-L/foo/lib" "crt1.o" "[[temp]]" 
"-lc++" "-lc++abi" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
Index: test/Driver/wasm-toolchain.c
===
--- test/Driver/wasm-toolchain.c
+++ test/Driver/wasm-toolchain.c
@@ -12,12 +12,12 @@
 
 // A basic C link command-line.
 
-// RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown 
--sysroot=/foo %s 2>&1 | FileCheck -check-prefix=LINK %s
+// RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown 
--sysroot=/foo -fuse-ld=lld %s 2>&1 | FileCheck -check-prefix=LINK %s
 // LINK: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
 // LINK: lld{{.*}}" "-flavor" "wasm" "-L/foo/lib" "crt1.o" "[[temp]]" "-lc" 
"{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
 
 // A basic C link command-line with optimization.
 
-// RUN: %clang -### -O2 -no-canonical-prefixes -target wasm32-unknown-unknown 
--sysroot=/foo %s 2>&1 | FileCheck -check-prefix=LINK_OPT %s
+// RUN: %clang -### -O2 -no-canonical-prefixes -target wasm32-unknown-unknown 
--sysroot=/foo -fuse-ld=lld %s 2>&1 | FileCheck -check-prefix=LINK_OPT %s
 // LINK_OPT: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
 // LINK_OPT: lld{{.*}}" "-flavor" "wasm" "-L/foo/lib" "crt1.o" "[[temp]]" 
"-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"


Index: test/Driver/wasm-toolchain.cpp
===
--- test/Driver/wasm-toolchain.cpp
+++ test/Driver/wasm-toolchain.cpp
@@ -12,12 +12,12 @@
 
 // A basic C++ link command-line.
 
-// RUN: %clangxx -### -no-canonical-prefixes -target wasm32-unknown-unknown --sysroot=/foo --stdlib=c++ %s 2>&1 | FileCheck -check-prefix=LINK %s
+// RUN: %clangxx -### -no-canonical-prefixes -target wasm32-unknown-unknown --sysroot=/foo --stdlib=c++ -fuse-ld=lld %s 2>&1 | FileCheck -check-prefix=LINK %s
 // LINK: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
 // LINK: lld{{.*}}" "-flavor" "wasm" "-L/foo/lib" "crt1.o" "[[temp]]" "-lc++" "-lc++abi" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
 
 // A basic C++ link command-line with optimization.
 
-// RUN: %clangxx -### -O2 -no-canonical-prefixes -target wasm32-unknown-unknown --sysroot=/foo %s --stdlib=c++ 2>&1 | FileCheck -check-prefix=LINK_OPT %s
+// RUN: %clangxx -### -O2 -no-canonical-prefixes -target wasm32-unknown-unknown --sysroot=/foo %s --stdlib=c++ -fuse-ld=lld 2>&1 | FileCheck -check-prefix=LINK_OPT %s
 // LINK_OPT: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
 // LINK_OPT: lld{{.*}}" "-flavor" "wasm" "-L/foo/lib" "crt1.o" "[[temp]]" "-lc++" "-lc++abi" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
Index: test/Driver/wasm-toolchain.c
===
--- test/Driver/wasm-toolchain.c
+++ test/Driver/wasm-toolchain.c
@@ -12,12 +12,12 @@
 
 // A basic C link command-line.
 
-// RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown --sysroot=/foo %s 2>&1 | FileCheck -check-prefix=LINK %s
+// RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown --sysroot=/foo -fuse-ld=lld %s 2>&1 | FileCheck -check-prefix=LINK %s
 // LINK: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
 // LINK: lld{{.*}}" "-flavor" "wasm" "-L/foo/lib" "crt1.o" "[[temp]]" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"

[PATCH] D50152: [CodeGen] Merge equivalent block copy/helper functions

2018-08-07 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 159546.
ahatanak marked an inline comment as done.
ahatanak added a reviewer: rsmith.
ahatanak added a comment.
Herald added a subscriber: jfb.

Address review comments.


Repository:
  rC Clang

https://reviews.llvm.org/D50152

Files:
  include/clang/AST/ComputeExceptionSpec.h
  lib/CodeGen/CGBlocks.cpp
  lib/CodeGen/CGBlocks.h
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/CGNonTrivialStruct.cpp
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaExceptionSpec.cpp
  test/CodeGen/blocks-1.c
  test/CodeGen/blocks.c
  test/CodeGen/sanitize-thread-no-checking-at-run-time.m
  test/CodeGenCXX/block-byref-cxx-objc.cpp
  test/CodeGenCXX/blocks.cpp
  test/CodeGenCXX/cxx-block-objects.cpp
  test/CodeGenObjC/arc-blocks.m
  test/CodeGenObjC/debug-info-block-helper.m
  test/CodeGenObjC/debug-info-blocks.m
  test/CodeGenObjC/mrc-weak.m
  test/CodeGenObjC/strong-in-c-struct.m
  test/CodeGenObjCXX/arc-blocks.mm
  test/CodeGenObjCXX/lambda-to-block.mm
  test/CodeGenObjCXX/mrc-weak.mm

Index: test/CodeGenObjCXX/mrc-weak.mm
===
--- test/CodeGenObjCXX/mrc-weak.mm
+++ test/CodeGenObjCXX/mrc-weak.mm
@@ -119,10 +119,10 @@
 // CHECK:   call void @use_block
 // CHECK:   call void @objc_destroyWeak
 
-// CHECK-LABEL: define internal void @__copy_helper_block
+// CHECK-LABEL: define linkonce_odr hidden void @__copy_helper_block
 // CHECK:   @objc_copyWeak
 
-// CHECK-LABEL: define internal void @__destroy_helper_block
+// CHECK-LABEL: define linkonce_odr hidden void @__destroy_helper_block
 // CHECK:   @objc_destroyWeak
 
 void test8(void) {
@@ -142,8 +142,8 @@
 // CHECK:   call void @objc_destroyWeak
 
 // CHECK-LABEL: define void @_Z14test9_baselinev()
-// CHECK:   define internal void @__copy_helper
-// CHECK:   define internal void @__destroy_helper
+// CHECK:   define linkonce_odr hidden void @__copy_helper
+// CHECK:   define linkonce_odr hidden void @__destroy_helper
 void test9_baseline(void) {
   Foo *p = get_object();
   use_block(^{ [p run]; });
Index: test/CodeGenObjCXX/lambda-to-block.mm
===
--- test/CodeGenObjCXX/lambda-to-block.mm
+++ test/CodeGenObjCXX/lambda-to-block.mm
@@ -12,7 +12,7 @@
 void hasLambda(Copyable x) {
   takesBlock([x] () { });
 }
-// CHECK-LABEL: define internal void @__copy_helper_block_
+// CHECK-LABEL: define internal void @"__copy_helper_block_
 // CHECK: call void @"_ZZ9hasLambda8CopyableEN3$_0C1ERKS0_"
 // CHECK-LABEL: define internal void @"_ZZ9hasLambda8CopyableEN3$_0C2ERKS0_"
 // CHECK: call void @_ZN8CopyableC1ERKS_
Index: test/CodeGenObjCXX/arc-blocks.mm
===
--- test/CodeGenObjCXX/arc-blocks.mm
+++ test/CodeGenObjCXX/arc-blocks.mm
@@ -1,8 +1,10 @@
 // RUN: %clang_cc1 -std=gnu++98 -triple x86_64-apple-darwin10 -emit-llvm -fobjc-runtime-has-weak -fblocks -fobjc-arc -fexceptions -fobjc-arc-exceptions -o - %s | FileCheck -check-prefix CHECK %s
 // RUN: %clang_cc1 -std=gnu++98 -triple x86_64-apple-darwin10 -emit-llvm -fobjc-runtime-has-weak -fblocks -fobjc-arc -fexceptions -fobjc-arc-exceptions -O1 -o - %s | FileCheck -check-prefix CHECK-O1 %s
+// RUN: %clang_cc1 -std=gnu++98 -triple x86_64-apple-darwin10 -emit-llvm -fobjc-runtime-has-weak -fblocks -fobjc-arc -o - %s | FileCheck -check-prefix CHECK-NOEXCP %s
 
 // CHECK: [[A:.*]] = type { i64, [10 x i8*] }
 // CHECK: %[[STRUCT_TEST1_S0:.*]] = type { i32 }
+// CHECK: %[[STRUCT_TRIVIAL_INTERNAL:.*]] = type { i32 }
 // CHECK: %[[STRUCT_BLOCK_DESCRIPTOR:.*]] = type { i64, i64 }
 
 // CHECK: [[LAYOUT0:@.*]] = private unnamed_addr constant [3 x i8] c" 9\00"
@@ -55,34 +57,34 @@
 
 // Check that copy/dispose helper functions are exception safe.
 
-// CHECK-LABEL: define internal void @__copy_helper_block_(
-// CHECK: %[[BLOCK_SOURCE:.*]] = bitcast i8* %{{.*}} to <{ i8*, i32, i32, i8*, %[[STRUCT_BLOCK_DESCRIPTOR]]*, i8*, i8*, i8*, %[[STRUCT_TEST1_S0]], %[[STRUCT_TEST1_S0]] }>*
-// CHECK: %[[BLOCK_DEST:.*]] = bitcast i8* %{{.*}} to <{ i8*, i32, i32, i8*, %[[STRUCT_BLOCK_DESCRIPTOR]]*, i8*, i8*, i8*, %[[STRUCT_TEST1_S0]], %[[STRUCT_TEST1_S0]] }>*
+// CHECK-LABEL: define linkonce_odr hidden void @__copy_helper_block_ea8_32s40b48w56c15_ZTSN5test12S0E60c15_ZTSN5test12S0E(
+// CHECK: %[[BLOCK_SOURCE:.*]] = bitcast i8* %{{.*}} to <{ i8*, i32, i32, i8*, %[[STRUCT_BLOCK_DESCRIPTOR]]*, i8*, i8*, i8*, %[[STRUCT_TEST1_S0]], %[[STRUCT_TEST1_S0]], %[[STRUCT_TRIVIAL_INTERNAL]] }>*
+// CHECK: %[[BLOCK_DEST:.*]] = bitcast i8* %{{.*}} to <{ i8*, i32, i32, i8*, %[[STRUCT_BLOCK_DESCRIPTOR]]*, i8*, i8*, i8*, %[[STRUCT_TEST1_S0]], %[[STRUCT_TEST1_S0]], %[[STRUCT_TRIVIAL_INTERNAL]] }>*
 
-// CHECK: %[[V4:.*]] = getelementptr inbounds <{ i8*, i32, i32, i8*, %[[STRUCT_BLOCK_DESCRIPTOR]]*, i8*, i8*, i8*, %[[STRUCT_TEST1_S0]], %[[STRUCT_TEST1_S0]] }>, <{ i8*, i32, i32, i

Re: [PATCH] D50154: [clangd] capitalize diagnostic messages

2018-08-07 Thread David Blaikie via cfe-commits
On Tue, Aug 7, 2018 at 10:33 AM Alex Lorenz via Phabricator <
revi...@reviews.llvm.org> wrote:

> arphaman added a comment.
>
> In https://reviews.llvm.org/D50154#1191002, @dblaikie wrote:
>
> > What's the motivation for clangd to differ from clang here? (& if the
> first
> >  letter is going to be capitalized, should there be a period at the end?
> But
> >  also the phrasing of most/all diagnostic text isn't in the form of
> complete
> >  sentences, so this might not make sense)
>
>
> It's mostly for the presentation purposes, to match the needs of our
> client. I first implemented it as an opt-in feature, but the consensus was
> to capitalize the messages all the time.
>

Doesn't seem like it'd be any more expensive (amount of code or
performance) to do that up in your client code, then, would it? I guess if
most users of this API in time ended up preferring capitalized values, it'd
make sense to share that implementation - but to me it seems like a strange
transformation to happen at this level. (since it depends on what kind of
client/how they want to render things - so it seems an odd choice to bake
in to the API (or even provide an option for, unless there are lots of
users/the code was especially complicated))

My 2c - I've no vested interest or authority here.


> I don't think it would make sense to insert the period at the end,
> because, as you said, not all diagnostics are complete sentences
>
>
> Repository:
>   rCTE Clang Tools Extra
>
> https://reviews.llvm.org/D50154
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D50152: [CodeGen] Merge equivalent block copy/helper functions

2018-08-07 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added inline comments.



Comment at: lib/CodeGen/CGBlocks.cpp:1643
+if (Ctx.getBlockVarCopyInits(VD))
+  return true;
+  return false;

rjmccall wrote:
> ahatanak wrote:
> > ahatanak wrote:
> > > rjmccall wrote:
> > > > Can you just ask Sema to check `canThrow` for the expression and pass 
> > > > it down?
> > > Since this changes the existing behavior, I made changes to 
> > > test/CodeGenCXX/block-byref-cxx-objc.cpp to test it. Previously, IRGen 
> > > would emit an invoke to call `_Block_object_assign` when the constructor 
> > > was marked as noexcept.
> > Perhaps I misunderstood your comment, should I have Sema set a flag or 
> > something in Expr when it calls a function that can throw?
> Sema has a `canThrow` predicate that it uses when checking things like the 
> `noexcept` expression.  I was thinking that you could pass that down with the 
> copy expression in the AST for the block capture.
> 
> Constructors can have default-argument expressions that can throw even if the 
> constructor itself can't, so it's important to do it that way.
I moved the code in lib/Sema/SemaExceptionSpec.cpp that  is needed to compute 
the exception specification to a template class in include/AST so that both 
Sema and IRGen can use it. Also, I added a call to ResolveExceptionSpec in 
Sema::CheckCompleteVariableDeclaration to resolve the destructor's exception 
specification and removed the isUnresolvedExceptionSpec check in 
CodeGenFunction::cxxDestructorCanThrow. Richard pointed out that the 
constructor's and destructor's exception specifications should have been 
resolved by the time IRGen is run.


Repository:
  rC Clang

https://reviews.llvm.org/D50152



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


[PATCH] D50389: [clang-tidy] new check for Abseil

2018-08-07 Thread Deanna Garcia via Phabricator via cfe-commits
deannagarcia updated this revision to Diff 159550.

https://reviews.llvm.org/D50389

Files:
  clang-tidy/abseil/AbseilTidyModule.cpp
  clang-tidy/abseil/DurationDivisionCheck.cpp
  clang-tidy/abseil/DurationDivisionCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/abseil-duration-division.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/abseil-duration-division.cpp

Index: test/clang-tidy/abseil-duration-division.cpp
===
--- test/clang-tidy/abseil-duration-division.cpp
+++ test/clang-tidy/abseil-duration-division.cpp
@@ -0,0 +1,44 @@
+// RUN: %check_clang_tidy %s abseil-duration-division %t
+
+namespace absl {
+
+class Duration {};
+
+int operator/(Duration lhs, Duration rhs);
+
+double FDivDuration(Duration num, Duration den);
+
+}  // namespace absl
+
+void TakesInt(int);
+void TakesDouble(double);
+
+absl::Duration d;
+
+#define MACRO_EQ(x, y) (x == y)
+#define MACRO_DIVEQ(x,y,z) (x/y == z)
+#define CHECK(x) (x)
+
+void Positives() {
+  const double num = d/d;
+  // CHECK-MESSAGES: [[@LINE-1]]:23: warning: operator/ on Duration objects performs integer division; did you mean to use FDivDuration()? [abseil-duration-division]
+  // CHECK-FIXES: const double num = absl::FDivDuration(d, d);
+  if (MACRO_EQ(d/d, 0.0)) {}
+  // CHECK-MESSAGES: [[@LINE-1]]:17: warning: operator/ on Duration objects
+  // CHECK-FIXES: if (MACRO_EQ(absl::FDivDuration(d, d), 0.0)) {}
+  if (CHECK(MACRO_EQ(d/d, 0.0))) {}
+  // CHECK-MESSAGES: [[@LINE-1]]:23: warning: operator/ on Duration objects
+  // CHECK-FIXES: if (CHECK(MACRO_EQ(absl::FDivDuration(d, d), 0.0))) {}
+
+  // This one generates a message, but no fix.
+  if (MACRO_DIVEQ(d, d, 0.0)) {}
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: operator/ on Duration objects
+  // CHECK-FIXES: if (MACRO_DIVEQ(d, d, 0.0)) {}
+}
+
+void Negatives() {
+  const int num = d/d;
+
+  // Explicit cast should disable the warning.
+  const double num_d = static_cast(d/d);
+}
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -4,6 +4,7 @@
 =
 
 .. toctree::
+   abseil-duration-division
abseil-string-find-startswith
android-cloexec-accept
android-cloexec-accept4
Index: docs/clang-tidy/checks/abseil-duration-division.rst
===
--- docs/clang-tidy/checks/abseil-duration-division.rst
+++ docs/clang-tidy/checks/abseil-duration-division.rst
@@ -0,0 +1,36 @@
+.. title:: clang-tidy - abseil-duration-division
+  
+abseil-duration-division
+
+
+``absl::Duration`` arithmetic works like it does with integers. That means that
+division of two ``absl::Duration`` objects returns an ``int64`` with any fractional
+component truncated toward 0.
+
+For example:
+
+.. code-block:: c++
+
+ absl::Duration d = absl::Seconds(3.5);
+ int64 sec1 = d / absl::Seconds(1); // Truncates toward 0.
+ int64 sec2 = absl::ToInt64Seconds(d);  // Equivalent to division.
+ assert(sec1 == 3 && sec2 == 3);
+
+ double dsec = d / absl::Seconds(1);  // WRONG: Still truncates toward 0.
+ assert(dsec == 3.0);
+
+If you want floating-point division, you should use either the
+``absl::FDivDuration()`` function, or one of the unit conversion functions such
+as ``absl::ToDoubleSeconds()``. For example:
+
+.. code-block:: c++
+
+ absl::Duration d = absl::Seconds(3.5);
+ double dsec1 = absl::FDivDuration(d, absl::Seconds(1));  // GOOD: No truncation.
+ double dsec2 = absl::ToDoubleSeconds(d); // GOOD: No truncation.
+ assert(dsec1 == 3.5 && dsec2 == 3.5);
+
+
+This check looks for uses of ``absl::Duration`` division that is done in a
+floating-point context, and recommends the use of a function that returns a
+floating-point value.
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -56,6 +56,12 @@
 
 Improvements to clang-tidy
 --
+- New :doc:``abseil-duration-division
+  `` check.
+
+  Checks for uses of ``absl::Duration`` division that is done in a
+  floating-point context, and recommends the use of a function that
+  returns a floating-point value.
 
 The improvements are...
 
Index: clang-tidy/abseil/DurationDivisionCheck.h
===
--- clang-tidy/abseil/DurationDivisionCheck.h
+++ clang-tidy/abseil/DurationDivisionCheck.h
@@ -0,0 +1,31 @@
+//===--- DurationDivisionCheck.h - clang-tidy*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_

[PATCH] D50361: [NFC] Test automatic variable initialization

2018-08-07 Thread JF Bastien via Phabricator via cfe-commits
jfb added a comment.

Further fixes in r339090 and r339093.


Repository:
  rC Clang

https://reviews.llvm.org/D50361



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


[PATCH] D50152: [CodeGen] Merge equivalent block copy/helper functions

2018-08-07 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 159553.
ahatanak added a comment.

Remove a stale comment and add an assertion to check the destructor's exception 
specification has been resolved.


Repository:
  rC Clang

https://reviews.llvm.org/D50152

Files:
  include/clang/AST/ComputeExceptionSpec.h
  lib/CodeGen/CGBlocks.cpp
  lib/CodeGen/CGBlocks.h
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/CGNonTrivialStruct.cpp
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaExceptionSpec.cpp
  test/CodeGen/blocks-1.c
  test/CodeGen/blocks.c
  test/CodeGen/sanitize-thread-no-checking-at-run-time.m
  test/CodeGenCXX/block-byref-cxx-objc.cpp
  test/CodeGenCXX/blocks.cpp
  test/CodeGenCXX/cxx-block-objects.cpp
  test/CodeGenObjC/arc-blocks.m
  test/CodeGenObjC/debug-info-block-helper.m
  test/CodeGenObjC/debug-info-blocks.m
  test/CodeGenObjC/mrc-weak.m
  test/CodeGenObjC/strong-in-c-struct.m
  test/CodeGenObjCXX/arc-blocks.mm
  test/CodeGenObjCXX/lambda-to-block.mm
  test/CodeGenObjCXX/mrc-weak.mm

Index: test/CodeGenObjCXX/mrc-weak.mm
===
--- test/CodeGenObjCXX/mrc-weak.mm
+++ test/CodeGenObjCXX/mrc-weak.mm
@@ -119,10 +119,10 @@
 // CHECK:   call void @use_block
 // CHECK:   call void @objc_destroyWeak
 
-// CHECK-LABEL: define internal void @__copy_helper_block
+// CHECK-LABEL: define linkonce_odr hidden void @__copy_helper_block
 // CHECK:   @objc_copyWeak
 
-// CHECK-LABEL: define internal void @__destroy_helper_block
+// CHECK-LABEL: define linkonce_odr hidden void @__destroy_helper_block
 // CHECK:   @objc_destroyWeak
 
 void test8(void) {
@@ -142,8 +142,8 @@
 // CHECK:   call void @objc_destroyWeak
 
 // CHECK-LABEL: define void @_Z14test9_baselinev()
-// CHECK:   define internal void @__copy_helper
-// CHECK:   define internal void @__destroy_helper
+// CHECK:   define linkonce_odr hidden void @__copy_helper
+// CHECK:   define linkonce_odr hidden void @__destroy_helper
 void test9_baseline(void) {
   Foo *p = get_object();
   use_block(^{ [p run]; });
Index: test/CodeGenObjCXX/lambda-to-block.mm
===
--- test/CodeGenObjCXX/lambda-to-block.mm
+++ test/CodeGenObjCXX/lambda-to-block.mm
@@ -12,7 +12,7 @@
 void hasLambda(Copyable x) {
   takesBlock([x] () { });
 }
-// CHECK-LABEL: define internal void @__copy_helper_block_
+// CHECK-LABEL: define internal void @"__copy_helper_block_
 // CHECK: call void @"_ZZ9hasLambda8CopyableEN3$_0C1ERKS0_"
 // CHECK-LABEL: define internal void @"_ZZ9hasLambda8CopyableEN3$_0C2ERKS0_"
 // CHECK: call void @_ZN8CopyableC1ERKS_
Index: test/CodeGenObjCXX/arc-blocks.mm
===
--- test/CodeGenObjCXX/arc-blocks.mm
+++ test/CodeGenObjCXX/arc-blocks.mm
@@ -1,8 +1,10 @@
 // RUN: %clang_cc1 -std=gnu++98 -triple x86_64-apple-darwin10 -emit-llvm -fobjc-runtime-has-weak -fblocks -fobjc-arc -fexceptions -fobjc-arc-exceptions -o - %s | FileCheck -check-prefix CHECK %s
 // RUN: %clang_cc1 -std=gnu++98 -triple x86_64-apple-darwin10 -emit-llvm -fobjc-runtime-has-weak -fblocks -fobjc-arc -fexceptions -fobjc-arc-exceptions -O1 -o - %s | FileCheck -check-prefix CHECK-O1 %s
+// RUN: %clang_cc1 -std=gnu++98 -triple x86_64-apple-darwin10 -emit-llvm -fobjc-runtime-has-weak -fblocks -fobjc-arc -o - %s | FileCheck -check-prefix CHECK-NOEXCP %s
 
 // CHECK: [[A:.*]] = type { i64, [10 x i8*] }
 // CHECK: %[[STRUCT_TEST1_S0:.*]] = type { i32 }
+// CHECK: %[[STRUCT_TRIVIAL_INTERNAL:.*]] = type { i32 }
 // CHECK: %[[STRUCT_BLOCK_DESCRIPTOR:.*]] = type { i64, i64 }
 
 // CHECK: [[LAYOUT0:@.*]] = private unnamed_addr constant [3 x i8] c" 9\00"
@@ -55,34 +57,34 @@
 
 // Check that copy/dispose helper functions are exception safe.
 
-// CHECK-LABEL: define internal void @__copy_helper_block_(
-// CHECK: %[[BLOCK_SOURCE:.*]] = bitcast i8* %{{.*}} to <{ i8*, i32, i32, i8*, %[[STRUCT_BLOCK_DESCRIPTOR]]*, i8*, i8*, i8*, %[[STRUCT_TEST1_S0]], %[[STRUCT_TEST1_S0]] }>*
-// CHECK: %[[BLOCK_DEST:.*]] = bitcast i8* %{{.*}} to <{ i8*, i32, i32, i8*, %[[STRUCT_BLOCK_DESCRIPTOR]]*, i8*, i8*, i8*, %[[STRUCT_TEST1_S0]], %[[STRUCT_TEST1_S0]] }>*
+// CHECK-LABEL: define linkonce_odr hidden void @__copy_helper_block_ea8_32s40b48w56c15_ZTSN5test12S0E60c15_ZTSN5test12S0E(
+// CHECK: %[[BLOCK_SOURCE:.*]] = bitcast i8* %{{.*}} to <{ i8*, i32, i32, i8*, %[[STRUCT_BLOCK_DESCRIPTOR]]*, i8*, i8*, i8*, %[[STRUCT_TEST1_S0]], %[[STRUCT_TEST1_S0]], %[[STRUCT_TRIVIAL_INTERNAL]] }>*
+// CHECK: %[[BLOCK_DEST:.*]] = bitcast i8* %{{.*}} to <{ i8*, i32, i32, i8*, %[[STRUCT_BLOCK_DESCRIPTOR]]*, i8*, i8*, i8*, %[[STRUCT_TEST1_S0]], %[[STRUCT_TEST1_S0]], %[[STRUCT_TRIVIAL_INTERNAL]] }>*
 
-// CHECK: %[[V4:.*]] = getelementptr inbounds <{ i8*, i32, i32, i8*, %[[STRUCT_BLOCK_DESCRIPTOR]]*, i8*, i8*, i8*, %[[STRUCT_TEST1_S0]], %[[STRUCT_TEST1_S0]] }>, <{ i8*, i32, i32, i8*, %[[STRUCT_BLOCK_D

[PATCH] D49518: [VFS] Emit an error when a file isn't located in any directory.

2018-08-07 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno accepted this revision.
bruno added a comment.
This revision is now accepted and ready to land.

LGTM




Comment at: clang/lib/Basic/VirtualFileSystem.cpp:1391
+  error(NameValueNode,
+"entry with relative path at the root level is not discoverable");
+  return nullptr;

Reads better :)


https://reviews.llvm.org/D49518



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


[PATCH] D50118: [VFS] Unify iteration code for VFSFromYamlDirIterImpl, NFC intended.

2018-08-07 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno accepted this revision.
bruno added a comment.
This revision is now accepted and ready to land.

Thanks for the clean up! LGTM


https://reviews.llvm.org/D50118



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


[PATCH] D50152: [CodeGen] Merge equivalent block copy/helper functions

2018-08-07 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

That is a change that Richard should definitely sign off on.  Also, I'm not 
sure this works — is it really okay to skip the work done by 
`ResolveExceptionSpec` in IRGen?  What does that mean, that we're just somewhat 
more conservative than we would otherwise be?  And why is this a better 
solution than just storing whether the copy-expression throws in 
`BlockDecl::Capture`?


Repository:
  rC Clang

https://reviews.llvm.org/D50152



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


Re: [PATCH] D50154: [clangd] capitalize diagnostic messages

2018-08-07 Thread Alex L via cfe-commits
On Tue, 7 Aug 2018 at 10:52, David Blaikie via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

>
>
> On Tue, Aug 7, 2018 at 10:33 AM Alex Lorenz via Phabricator <
> revi...@reviews.llvm.org> wrote:
>
>> arphaman added a comment.
>>
>> In https://reviews.llvm.org/D50154#1191002, @dblaikie wrote:
>>
>> > What's the motivation for clangd to differ from clang here? (& if the
>> first
>> >  letter is going to be capitalized, should there be a period at the
>> end? But
>> >  also the phrasing of most/all diagnostic text isn't in the form of
>> complete
>> >  sentences, so this might not make sense)
>>
>>
>> It's mostly for the presentation purposes, to match the needs of our
>> client. I first implemented it as an opt-in feature, but the consensus was
>> to capitalize the messages all the time.
>>
>
> Doesn't seem like it'd be any more expensive (amount of code or
> performance) to do that up in your client code, then, would it? I guess if
> most users of this API in time ended up preferring capitalized values, it'd
> make sense to share that implementation - but to me it seems like a strange
> transformation to happen at this level. (since it depends on what kind of
> client/how they want to render things - so it seems an odd choice to bake
> in to the API (or even provide an option for, unless there are lots of
> users/the code was especially complicated))
>
> My 2c - I've no vested interest or authority here.
>

I think it's more in spirit with Clangd to provide output that's as close
to the one presented by the client as possible.
I would argue there's already a precedence for this kind of
transformations, for example, Clangd merges the diagnostic messages of
notes and the main diagnostics into one, to make it a better presentation
experience in the client:

https://github.com/llvm-mirror/clang-tools-extra/blob/55bfabcc1bd75447d6338ffe6ff27c1624a8c15a/clangd/Diagnostics.cpp#L161




>
>
>> I don't think it would make sense to insert the period at the end,
>> because, as you said, not all diagnostics are complete sentences
>>
>>
>> Repository:
>>   rCTE Clang Tools Extra
>>
>> https://reviews.llvm.org/D50154
>>
>>
>>
>> ___
> 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] D50395: [WebAssembly] Remove use of lld -flavor flag

2018-08-07 Thread Rui Ueyama via Phabricator via cfe-commits
ruiu accepted this revision.
ruiu added a comment.
This revision is now accepted and ready to land.

LGTM!


Repository:
  rC Clang

https://reviews.llvm.org/D50395



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


[PATCH] D50278: [Sema] Fix for crash on conditional operation with address_space pointer

2018-08-07 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added inline comments.



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:6943
+def err_typecheck_incompatible_conditional_pointer_operands : Error<
+  "unable to find common type between %0 and %1 for conditional operation">;
 

ebevhan wrote:
> This error is very similar to the one in my first comment, `conditional 
> operator with the second and third operands of type 
> ('__attribute__((address_space(1))) char *' and 
> '__attribute__((address_space(2))) char *') which are pointers to 
> non-overlapping address spaces`. It would normally be emitted at 6472, but 
> won't be since OpenCL isn't enabled.
Done. Removing the check for OpenCL throws this instead of the warning.



Comment at: lib/Sema/SemaExpr.cpp:6522
+bool HasDifferingLAddrSpace = LAddrSpace != ResultAddrSpace;
+bool HasDifferingRAddrSpace = RAddrSpace != ResultAddrSpace;
+

rjmccall wrote:
> I was going to tell you to use the predicate 
> `Qualifiers::isAddressSpaceSupersetOf` here, but then I was looking at the 
> uses of that, and I think the real fix is to just go into the implementation 
> of `checkConditionalPointerCompatibility` and make the compatibility logic 
> not OpenCL-specific.  The fast-path should just be whether the address spaces 
> are different.
> 
> And it looks like this function has a bug where it always uses 
> `LangAS::Default` outside of OpenCL even if the pointers are in the same 
> address space.
I'm not sure how the `LangAS::Default`, but removing all checks for OpenCL does 
the trick and prints an existing error relating to different address_spaces on 
conditional operands to replace the warning. Only 2 tests needed the change 
from the expected warning to expected error without having to change any OpenCL 
tests.

I also think the address_space comparison is already done with the 
`lhQual.isAddressSpaceSupersetOf` and `rhQual.isAddressSpaceSupersetOf`.



Comment at: test/Sema/conditional-expr.c:78
+   // expected-error@-1{{converting 
'__attribute__((address_space(2))) int *' to type 'void *' changes address 
space of pointer}}
+   // expected-error@-2{{converting 
'__attribute__((address_space(3))) int *' to type 'void *' changes address 
space of pointer}}
 

ebevhan wrote:
> rjmccall wrote:
> > leonardchan wrote:
> > > rjmccall wrote:
> > > > Also, these diagnostics seem wrong.  Where is `void *` coming from?
> > > When dumping the AST this is what the resulting type is for the 
> > > conditional expression already is if the operands are 2 pointers with 
> > > different address spaces.
> > > 
> > > According to this comment, the reason seems to be because this is what 
> > > GCC does:
> > > 
> > > ```
> > >  6512 // In this situation, we assume void* type. No especially good
> > >  6513 // reason, but this is what gcc does, and we do have to pick
> > >  6514 // to get a consistent AST.
> > > ```
> > That makes sense in general, but in this case it's not a great diagnostic; 
> > we should just emit an error when trying to pick a common type.
> Is it possible that you are getting `void *` because we aren't running the 
> qualifier removal at 6495? I don't think I've ever seen spurious `void *`'s 
> show up in our downstream diagnostics.
So the `void *` is what get's dumped for me using the latest upstream version 
of clang and is the result of the `ConditionalOperator`.

An AST dump of 

```
  3   unsigned long test0 = 5;
  4   int __attribute__((address_space(2))) *adr2;
  5   int __attribute__((address_space(3))) *adr3;
  6   test0 ? adr2 : adr3;
```

 for me returns

```
`-ConditionalOperator 0xbdbcab0  'void *'
  |-ImplicitCastExpr 0xbdbc690  'unsigned long' 
  | `-DeclRefExpr 0xbdbc618  'unsigned long' lvalue Var 0xbdbc348 
'test0' 'unsigned long'
  |-ImplicitCastExpr 0xbdbc790  'void *' 
  | `-ImplicitCastExpr 0xbdbc6a8  
'__attribute__((address_space(2))) int *' 
  |   `-DeclRefExpr 0xbdbc640  '__attribute__((address_space(2))) 
int *' lvalue Var 0xbdbc490 'adr2' '__attribute__((address_space(2))) int *'
  `-ImplicitCastExpr 0xbdbc7a8  'void *' 
`-ImplicitCastExpr 0xbdbc6c0  
'__attribute__((address_space(3))) int *' 
  `-DeclRefExpr 0xbdbc668  '__attribute__((address_space(3))) 
int *' lvalue Var 0xbdbc5a0 'adr3' '__attribute__((address_space(3))) int *'
```


Repository:
  rC Clang

https://reviews.llvm.org/D50278



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


[PATCH] D50278: [Sema] Fix for crash on conditional operation with address_space pointer

2018-08-07 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 159559.
leonardchan marked an inline comment as done.
leonardchan added a comment.

- Removed checks for OpenCL in `checkConditionalPointerCompatibility`. This 
allows for the error 
`err_typecheck_op_on_nonoverlapping_address_space_pointers` to be dumped on 
getting pointers with different address spaces instead of the warning 
`ext_typecheck_cond_incompatible_pointers`.


Repository:
  rC Clang

https://reviews.llvm.org/D50278

Files:
  lib/Sema/SemaExpr.cpp
  test/Sema/address_spaces.c
  test/Sema/conditional-expr.c

Index: test/Sema/conditional-expr.c
===
--- test/Sema/conditional-expr.c
+++ test/Sema/conditional-expr.c
@@ -73,10 +73,10 @@
 
   int __attribute__((address_space(2))) *adr2;
   int __attribute__((address_space(3))) *adr3;
-  test0 ? adr2 : adr3; // expected-warning {{pointer type mismatch}} expected-warning {{expression result unused}}
+  test0 ? adr2 : adr3; // expected-error{{conditional operator with the second and third operands of type  ('__attribute__((address_space(2))) int *' and '__attribute__((address_space(3))) int *') which are pointers to non-overlapping address spaces}}
 
   // Make sure address-space mask ends up in the result type
-  (test0 ? (test0 ? adr2 : adr2) : nonconst_int); // expected-warning {{pointer type mismatch}} expected-warning {{expression result unused}}
+  (test0 ? (test0 ? adr2 : adr2) : nonconst_int); // expected-error{{conditional operator with the second and third operands of type  ('__attribute__((address_space(2))) int *' and 'int *') which are pointers to non-overlapping address spaces}}
 }
 
 int Postgresql() {
Index: test/Sema/address_spaces.c
===
--- test/Sema/address_spaces.c
+++ test/Sema/address_spaces.c
@@ -71,5 +71,5 @@
 
 // Clang extension doesn't forbid operations on pointers to different address spaces.
 char* cmp(_AS1 char *x,  _AS2 char *y) {
-  return x < y ? x : y; // expected-warning {{pointer type mismatch ('__attribute__((address_space(1))) char *' and '__attribute__((address_space(2))) char *')}}
+  return x < y ? x : y; // expected-error{{conditional operator with the second and third operands of type  ('__attribute__((address_space(1))) char *' and '__attribute__((address_space(2))) char *') which are pointers to non-overlapping address spaces}}
 }
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -6461,20 +6461,18 @@
   LangAS ResultAddrSpace = LangAS::Default;
   LangAS LAddrSpace = lhQual.getAddressSpace();
   LangAS RAddrSpace = rhQual.getAddressSpace();
-  if (S.getLangOpts().OpenCL) {
-// OpenCL v1.1 s6.5 - Conversion between pointers to distinct address
-// spaces is disallowed.
-if (lhQual.isAddressSpaceSupersetOf(rhQual))
-  ResultAddrSpace = LAddrSpace;
-else if (rhQual.isAddressSpaceSupersetOf(lhQual))
-  ResultAddrSpace = RAddrSpace;
-else {
-  S.Diag(Loc,
- diag::err_typecheck_op_on_nonoverlapping_address_space_pointers)
-  << LHSTy << RHSTy << 2 << LHS.get()->getSourceRange()
-  << RHS.get()->getSourceRange();
-  return QualType();
-}
+
+  // OpenCL v1.1 s6.5 - Conversion between pointers to distinct address
+  // spaces is disallowed.
+  if (lhQual.isAddressSpaceSupersetOf(rhQual))
+ResultAddrSpace = LAddrSpace;
+  else if (rhQual.isAddressSpaceSupersetOf(lhQual))
+ResultAddrSpace = RAddrSpace;
+  else {
+S.Diag(Loc, diag::err_typecheck_op_on_nonoverlapping_address_space_pointers)
+<< LHSTy << RHSTy << 2 << LHS.get()->getSourceRange()
+<< RHS.get()->getSourceRange();
+return QualType();
   }
 
   unsigned MergedCVRQual = lhQual.getCVRQualifiers() | rhQual.getCVRQualifiers();
@@ -6492,16 +6490,12 @@
   // Thus for conditional operator we merge CVR and address space unqualified
   // pointees and if there is a composite type we return a pointer to it with
   // merged qualifiers.
-  if (S.getLangOpts().OpenCL) {
-LHSCastKind = LAddrSpace == ResultAddrSpace
-  ? CK_BitCast
-  : CK_AddressSpaceConversion;
-RHSCastKind = RAddrSpace == ResultAddrSpace
-  ? CK_BitCast
-  : CK_AddressSpaceConversion;
-lhQual.removeAddressSpace();
-rhQual.removeAddressSpace();
-  }
+  LHSCastKind =
+  LAddrSpace == ResultAddrSpace ? CK_BitCast : CK_AddressSpaceConversion;
+  RHSCastKind =
+  RAddrSpace == ResultAddrSpace ? CK_BitCast : CK_AddressSpaceConversion;
+  lhQual.removeAddressSpace();
+  rhQual.removeAddressSpace();
 
   lhptee = S.Context.getQualifiedType(lhptee.getUnqualifiedType(), lhQual);
   rhptee = S.Context.getQualifiedType(rhptee.getUnqualifiedType(), rhQual);
@@ -6517,6 +6511,7 @@
 S.Context.getAddrSpaceQualType(S.Context.VoidTy, ResultAddrSpac

[PATCH] D50278: [Sema] Fix for crash on conditional operation with address_space pointer

2018-08-07 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

In https://reviews.llvm.org/D50278#1190544, @ebevhan wrote:

> I think the solution to a lot of diagnostic and behavior issues with address 
> spaces is to remove predication on OpenCL. It's a bit odd to have a language 
> feature that is enabled out of the box regardless of langoptions (address 
> spaces) but won't actually work properly unless you're building OpenCL.


I agree; almost all of the address-space-related restrictions predicated on 
OpenCL are actually general restrictions that apply across all address-space 
extensions.  OpenCL's rules only differ from what's laid out in TR 18037 in how 
certain declarations default to specific address spaces.  It's unfortunate that 
the code reviewers at the time (which probably included me at least a little) 
didn't try harder to push for the more general rule.  As it is, it would be a 
good project for someone who's working on address spaces a lot to just audit 
all the OpenCL-specific checks in Sema to see which of them should be 
generalized.


Repository:
  rC Clang

https://reviews.llvm.org/D50278



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


[PATCH] D50278: [Sema] Fix for crash on conditional operation with address_space pointer

2018-08-07 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

LGTM.




Comment at: lib/Sema/SemaExpr.cpp:6522
+bool HasDifferingLAddrSpace = LAddrSpace != ResultAddrSpace;
+bool HasDifferingRAddrSpace = RAddrSpace != ResultAddrSpace;
+

leonardchan wrote:
> rjmccall wrote:
> > I was going to tell you to use the predicate 
> > `Qualifiers::isAddressSpaceSupersetOf` here, but then I was looking at the 
> > uses of that, and I think the real fix is to just go into the 
> > implementation of `checkConditionalPointerCompatibility` and make the 
> > compatibility logic not OpenCL-specific.  The fast-path should just be 
> > whether the address spaces are different.
> > 
> > And it looks like this function has a bug where it always uses 
> > `LangAS::Default` outside of OpenCL even if the pointers are in the same 
> > address space.
> I'm not sure how the `LangAS::Default`, but removing all checks for OpenCL 
> does the trick and prints an existing error relating to different 
> address_spaces on conditional operands to replace the warning. Only 2 tests 
> needed the change from the expected warning to expected error without having 
> to change any OpenCL tests.
> 
> I also think the address_space comparison is already done with the 
> `lhQual.isAddressSpaceSupersetOf` and `rhQual.isAddressSpaceSupersetOf`.
Er, you're right, of course, since `isAddressSpaceSupersetOf` is a non-strict 
ordering.  If that operation ever gets big enough that we don't want to inline 
the whole thing, we can at least make sure the fast-path is inlinable and then 
outline the complicated stuff.  We can also worry about that later.


Repository:
  rC Clang

https://reviews.llvm.org/D50278



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


Re: [PATCH] D50154: [clangd] capitalize diagnostic messages

2018-08-07 Thread David Blaikie via cfe-commits
On Tue, Aug 7, 2018 at 11:22 AM Alex L  wrote:

> On Tue, 7 Aug 2018 at 10:52, David Blaikie via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>>
>>
>> On Tue, Aug 7, 2018 at 10:33 AM Alex Lorenz via Phabricator <
>> revi...@reviews.llvm.org> wrote:
>>
>>> arphaman added a comment.
>>>
>>> In https://reviews.llvm.org/D50154#1191002, @dblaikie wrote:
>>>
>>> > What's the motivation for clangd to differ from clang here? (& if the
>>> first
>>> >  letter is going to be capitalized, should there be a period at the
>>> end? But
>>> >  also the phrasing of most/all diagnostic text isn't in the form of
>>> complete
>>> >  sentences, so this might not make sense)
>>>
>>>
>>> It's mostly for the presentation purposes, to match the needs of our
>>> client. I first implemented it as an opt-in feature, but the consensus was
>>> to capitalize the messages all the time.
>>>
>>
>> Doesn't seem like it'd be any more expensive (amount of code or
>> performance) to do that up in your client code, then, would it? I guess if
>> most users of this API in time ended up preferring capitalized values, it'd
>> make sense to share that implementation - but to me it seems like a strange
>> transformation to happen at this level. (since it depends on what kind of
>> client/how they want to render things - so it seems an odd choice to bake
>> in to the API (or even provide an option for, unless there are lots of
>> users/the code was especially complicated))
>>
>> My 2c - I've no vested interest or authority here.
>>
>
> I think it's more in spirit with Clangd to provide output that's as close
> to the one presented by the client as possible.
>

That assumes there's one client though, right? Different clients might
reasonably have different needs for how they'd want the text rendered, I'd
imagine.


> I would argue there's already a precedence for this kind of
> transformations, for example, Clangd merges the diagnostic messages of
> notes and the main diagnostics into one, to make it a better presentation
> experience in the client:
>
>
> https://github.com/llvm-mirror/clang-tools-extra/blob/55bfabcc1bd75447d6338ffe6ff27c1624a8c15a/clangd/Diagnostics.cpp#L161
>

I'm assuming that's because the API/protocol only supports a single
message, so the multi-message/location nuance of LLVM's diagnostics are
necessarily lost when converting to that format?

If that's not the case, and the API/protocol does support a
multiple-message diagnostic & ClangD is collapsing them early - that also
seems like an unfortunate loss in fidelity.


>
>
>
>
>
>>
>>
>>> I don't think it would make sense to insert the period at the end,
>>> because, as you said, not all diagnostics are complete sentences
>>>
>>>
>>> Repository:
>>>   rCTE Clang Tools Extra
>>>
>>> https://reviews.llvm.org/D50154
>>>
>>>
>>>
>>> ___
>> 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] D50152: [CodeGen] Merge equivalent block copy/helper functions

2018-08-07 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added a comment.

I thought it was okay to skip the work done by `ResolveExceptionSpec` in IRGen 
as long as the exception specifications that are needed have already been 
resolved in Sema. But calling Sema::canThrow in 
Sema::CheckCompleteVariableDeclaration and storing the result in 
BlockDecl::Capture is clearly the better solution since it doesn't introduce 
the complexity introduced in the updated patch.


Repository:
  rC Clang

https://reviews.llvm.org/D50152



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


[PATCH] D50395: [WebAssembly] Remove use of lld -flavor flag

2018-08-07 Thread Sam Clegg via Phabricator via cfe-commits
sbc100 updated this revision to Diff 159562.
sbc100 added a comment.

- update tests


Repository:
  rC Clang

https://reviews.llvm.org/D50395

Files:
  lib/Driver/ToolChains/WebAssembly.cpp
  lib/Driver/ToolChains/WebAssembly.h
  test/Driver/wasm-toolchain.c
  test/Driver/wasm-toolchain.cpp


Index: test/Driver/wasm-toolchain.cpp
===
--- test/Driver/wasm-toolchain.cpp
+++ test/Driver/wasm-toolchain.cpp
@@ -12,12 +12,12 @@
 
 // A basic C++ link command-line.
 
-// RUN: %clangxx -### -no-canonical-prefixes -target wasm32-unknown-unknown 
--sysroot=/foo --stdlib=c++ -fuse-ld=lld %s 2>&1 | FileCheck -check-prefix=LINK 
%s
+// RUN: %clangxx -### -no-canonical-prefixes -target wasm32-unknown-unknown 
--sysroot=/foo --stdlib=c++ -fuse-ld=wasm-ld %s 2>&1 | FileCheck 
-check-prefix=LINK %s
 // LINK: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
-// LINK: lld{{.*}}" "-flavor" "wasm" "-L/foo/lib" "crt1.o" "[[temp]]" "-lc++" 
"-lc++abi" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
+// LINK: wasm-ld{{.*}}" "-L/foo/lib" "crt1.o" "[[temp]]" "-lc++" "-lc++abi" 
"-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
 
 // A basic C++ link command-line with optimization.
 
-// RUN: %clangxx -### -O2 -no-canonical-prefixes -target 
wasm32-unknown-unknown --sysroot=/foo %s --stdlib=c++ -fuse-ld=lld 2>&1 | 
FileCheck -check-prefix=LINK_OPT %s
+// RUN: %clangxx -### -O2 -no-canonical-prefixes -target 
wasm32-unknown-unknown --sysroot=/foo %s --stdlib=c++ -fuse-ld=wasm-ld 2>&1 | 
FileCheck -check-prefix=LINK_OPT %s
 // LINK_OPT: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
-// LINK_OPT: lld{{.*}}" "-flavor" "wasm" "-L/foo/lib" "crt1.o" "[[temp]]" 
"-lc++" "-lc++abi" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
+// LINK_OPT: wasm-ld{{.*}}" "-L/foo/lib" "crt1.o" "[[temp]]" "-lc++" 
"-lc++abi" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
Index: test/Driver/wasm-toolchain.c
===
--- test/Driver/wasm-toolchain.c
+++ test/Driver/wasm-toolchain.c
@@ -12,12 +12,12 @@
 
 // A basic C link command-line.
 
-// RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown 
--sysroot=/foo -fuse-ld=lld %s 2>&1 | FileCheck -check-prefix=LINK %s
+// RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown 
--sysroot=/foo -fuse-ld=wasm-ld %s 2>&1 | FileCheck -check-prefix=LINK %s
 // LINK: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
-// LINK: lld{{.*}}" "-flavor" "wasm" "-L/foo/lib" "crt1.o" "[[temp]]" "-lc" 
"{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
+// LINK: wasm-ld{{.*}}" "-L/foo/lib" "crt1.o" "[[temp]]" "-lc" 
"{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
 
 // A basic C link command-line with optimization.
 
-// RUN: %clang -### -O2 -no-canonical-prefixes -target wasm32-unknown-unknown 
--sysroot=/foo -fuse-ld=lld %s 2>&1 | FileCheck -check-prefix=LINK_OPT %s
+// RUN: %clang -### -O2 -no-canonical-prefixes -target wasm32-unknown-unknown 
--sysroot=/foo -fuse-ld=wasm-ld %s 2>&1 | FileCheck -check-prefix=LINK_OPT %s
 // LINK_OPT: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
-// LINK_OPT: lld{{.*}}" "-flavor" "wasm" "-L/foo/lib" "crt1.o" "[[temp]]" 
"-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
+// LINK_OPT: wasm-ld{{.*}}" "-L/foo/lib" "crt1.o" "[[temp]]" "-lc" 
"{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
Index: lib/Driver/ToolChains/WebAssembly.h
===
--- lib/Driver/ToolChains/WebAssembly.h
+++ lib/Driver/ToolChains/WebAssembly.h
@@ -66,9 +66,7 @@
llvm::opt::ArgStringList &CmdArgs) const override;
   std::string getThreadModel() const override;
 
-  const char *getDefaultLinker() const override {
-return "lld";
-  }
+  const char *getDefaultLinker() const override { return "wasm-ld"; }
 
   Tool *buildLinker() const override;
 };
Index: lib/Driver/ToolChains/WebAssembly.cpp
===
--- lib/Driver/ToolChains/WebAssembly.cpp
+++ lib/Driver/ToolChains/WebAssembly.cpp
@@ -41,8 +41,6 @@
   const ToolChain &ToolChain = getToolChain();
   const char *Linker = Args.MakeArgString(ToolChain.GetLinkerPath());
   ArgStringList CmdArgs;
-  CmdArgs.push_back("-flavor");
-  CmdArgs.push_back("wasm");
 
   if (Args.hasArg(options::OPT_s))
 CmdArgs.push_back("--strip-all");


Index: test/Driver/wasm-toolchain.cpp
===
--- test/Driver/wasm-toolchain.cpp
+++ test/Driver/wasm-toolchain.cpp
@@ -12,12 +12,12 @@
 
 // A basic C++ link command-line.
 
-// RUN: %clangxx -### -no-canonical-prefixes -target wasm32-unknown-unknown --sysroot=/foo --stdlib=c++ -fuse-ld=lld %s 2>&1 | FileCheck -check-prefix=LINK %s
+// RUN: %clangxx -### -no-canonical-prefixes -target wasm32-unknown

r339163 - [WebAssembly] Remove use of lld -flavor flag

2018-08-07 Thread Sam Clegg via cfe-commits
Author: sbc
Date: Tue Aug  7 11:55:41 2018
New Revision: 339163

URL: http://llvm.org/viewvc/llvm-project?rev=339163&view=rev
Log:
[WebAssembly] Remove use of lld -flavor flag

This flag is deprecated. The preferred way to select the lld
flavor is by calling it by one of its aliases.

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

Modified:
cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp
cfe/trunk/lib/Driver/ToolChains/WebAssembly.h
cfe/trunk/test/Driver/wasm-toolchain.c
cfe/trunk/test/Driver/wasm-toolchain.cpp

Modified: cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp?rev=339163&r1=339162&r2=339163&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp Tue Aug  7 11:55:41 2018
@@ -41,8 +41,6 @@ void wasm::Linker::ConstructJob(Compilat
   const ToolChain &ToolChain = getToolChain();
   const char *Linker = Args.MakeArgString(ToolChain.GetLinkerPath());
   ArgStringList CmdArgs;
-  CmdArgs.push_back("-flavor");
-  CmdArgs.push_back("wasm");
 
   if (Args.hasArg(options::OPT_s))
 CmdArgs.push_back("--strip-all");

Modified: cfe/trunk/lib/Driver/ToolChains/WebAssembly.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/WebAssembly.h?rev=339163&r1=339162&r2=339163&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/WebAssembly.h (original)
+++ cfe/trunk/lib/Driver/ToolChains/WebAssembly.h Tue Aug  7 11:55:41 2018
@@ -66,9 +66,7 @@ private:
llvm::opt::ArgStringList &CmdArgs) const override;
   std::string getThreadModel() const override;
 
-  const char *getDefaultLinker() const override {
-return "lld";
-  }
+  const char *getDefaultLinker() const override { return "wasm-ld"; }
 
   Tool *buildLinker() const override;
 };

Modified: cfe/trunk/test/Driver/wasm-toolchain.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/wasm-toolchain.c?rev=339163&r1=339162&r2=339163&view=diff
==
--- cfe/trunk/test/Driver/wasm-toolchain.c (original)
+++ cfe/trunk/test/Driver/wasm-toolchain.c Tue Aug  7 11:55:41 2018
@@ -12,12 +12,12 @@
 
 // A basic C link command-line.
 
-// RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown 
--sysroot=/foo -fuse-ld=lld %s 2>&1 | FileCheck -check-prefix=LINK %s
+// RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown 
--sysroot=/foo -fuse-ld=wasm-ld %s 2>&1 | FileCheck -check-prefix=LINK %s
 // LINK: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
-// LINK: lld{{.*}}" "-flavor" "wasm" "-L/foo/lib" "crt1.o" "[[temp]]" "-lc" 
"{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
+// LINK: wasm-ld{{.*}}" "-L/foo/lib" "crt1.o" "[[temp]]" "-lc" 
"{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
 
 // A basic C link command-line with optimization.
 
-// RUN: %clang -### -O2 -no-canonical-prefixes -target wasm32-unknown-unknown 
--sysroot=/foo -fuse-ld=lld %s 2>&1 | FileCheck -check-prefix=LINK_OPT %s
+// RUN: %clang -### -O2 -no-canonical-prefixes -target wasm32-unknown-unknown 
--sysroot=/foo -fuse-ld=wasm-ld %s 2>&1 | FileCheck -check-prefix=LINK_OPT %s
 // LINK_OPT: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
-// LINK_OPT: lld{{.*}}" "-flavor" "wasm" "-L/foo/lib" "crt1.o" "[[temp]]" 
"-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
+// LINK_OPT: wasm-ld{{.*}}" "-L/foo/lib" "crt1.o" "[[temp]]" "-lc" 
"{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"

Modified: cfe/trunk/test/Driver/wasm-toolchain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/wasm-toolchain.cpp?rev=339163&r1=339162&r2=339163&view=diff
==
--- cfe/trunk/test/Driver/wasm-toolchain.cpp (original)
+++ cfe/trunk/test/Driver/wasm-toolchain.cpp Tue Aug  7 11:55:41 2018
@@ -12,12 +12,12 @@
 
 // A basic C++ link command-line.
 
-// RUN: %clangxx -### -no-canonical-prefixes -target wasm32-unknown-unknown 
--sysroot=/foo --stdlib=c++ -fuse-ld=lld %s 2>&1 | FileCheck -check-prefix=LINK 
%s
+// RUN: %clangxx -### -no-canonical-prefixes -target wasm32-unknown-unknown 
--sysroot=/foo --stdlib=c++ -fuse-ld=wasm-ld %s 2>&1 | FileCheck 
-check-prefix=LINK %s
 // LINK: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
-// LINK: lld{{.*}}" "-flavor" "wasm" "-L/foo/lib" "crt1.o" "[[temp]]" "-lc++" 
"-lc++abi" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
+// LINK: wasm-ld{{.*}}" "-L/foo/lib" "crt1.o" "[[temp]]" "-lc++" "-lc++abi" 
"-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
 
 // A basic C++ link command-line with optimization.
 
-// RUN: %clangxx -### -O2 -no-canonical-prefi

[PATCH] D50395: [WebAssembly] Remove use of lld -flavor flag

2018-08-07 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL339163: [WebAssembly] Remove use of lld -flavor flag 
(authored by sbc, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D50395

Files:
  cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp
  cfe/trunk/lib/Driver/ToolChains/WebAssembly.h
  cfe/trunk/test/Driver/wasm-toolchain.c
  cfe/trunk/test/Driver/wasm-toolchain.cpp


Index: cfe/trunk/lib/Driver/ToolChains/WebAssembly.h
===
--- cfe/trunk/lib/Driver/ToolChains/WebAssembly.h
+++ cfe/trunk/lib/Driver/ToolChains/WebAssembly.h
@@ -66,9 +66,7 @@
llvm::opt::ArgStringList &CmdArgs) const override;
   std::string getThreadModel() const override;
 
-  const char *getDefaultLinker() const override {
-return "lld";
-  }
+  const char *getDefaultLinker() const override { return "wasm-ld"; }
 
   Tool *buildLinker() const override;
 };
Index: cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp
+++ cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp
@@ -41,8 +41,6 @@
   const ToolChain &ToolChain = getToolChain();
   const char *Linker = Args.MakeArgString(ToolChain.GetLinkerPath());
   ArgStringList CmdArgs;
-  CmdArgs.push_back("-flavor");
-  CmdArgs.push_back("wasm");
 
   if (Args.hasArg(options::OPT_s))
 CmdArgs.push_back("--strip-all");
Index: cfe/trunk/test/Driver/wasm-toolchain.c
===
--- cfe/trunk/test/Driver/wasm-toolchain.c
+++ cfe/trunk/test/Driver/wasm-toolchain.c
@@ -12,12 +12,12 @@
 
 // A basic C link command-line.
 
-// RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown 
--sysroot=/foo -fuse-ld=lld %s 2>&1 | FileCheck -check-prefix=LINK %s
+// RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown 
--sysroot=/foo -fuse-ld=wasm-ld %s 2>&1 | FileCheck -check-prefix=LINK %s
 // LINK: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
-// LINK: lld{{.*}}" "-flavor" "wasm" "-L/foo/lib" "crt1.o" "[[temp]]" "-lc" 
"{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
+// LINK: wasm-ld{{.*}}" "-L/foo/lib" "crt1.o" "[[temp]]" "-lc" 
"{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
 
 // A basic C link command-line with optimization.
 
-// RUN: %clang -### -O2 -no-canonical-prefixes -target wasm32-unknown-unknown 
--sysroot=/foo -fuse-ld=lld %s 2>&1 | FileCheck -check-prefix=LINK_OPT %s
+// RUN: %clang -### -O2 -no-canonical-prefixes -target wasm32-unknown-unknown 
--sysroot=/foo -fuse-ld=wasm-ld %s 2>&1 | FileCheck -check-prefix=LINK_OPT %s
 // LINK_OPT: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
-// LINK_OPT: lld{{.*}}" "-flavor" "wasm" "-L/foo/lib" "crt1.o" "[[temp]]" 
"-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
+// LINK_OPT: wasm-ld{{.*}}" "-L/foo/lib" "crt1.o" "[[temp]]" "-lc" 
"{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
Index: cfe/trunk/test/Driver/wasm-toolchain.cpp
===
--- cfe/trunk/test/Driver/wasm-toolchain.cpp
+++ cfe/trunk/test/Driver/wasm-toolchain.cpp
@@ -12,12 +12,12 @@
 
 // A basic C++ link command-line.
 
-// RUN: %clangxx -### -no-canonical-prefixes -target wasm32-unknown-unknown 
--sysroot=/foo --stdlib=c++ -fuse-ld=lld %s 2>&1 | FileCheck -check-prefix=LINK 
%s
+// RUN: %clangxx -### -no-canonical-prefixes -target wasm32-unknown-unknown 
--sysroot=/foo --stdlib=c++ -fuse-ld=wasm-ld %s 2>&1 | FileCheck 
-check-prefix=LINK %s
 // LINK: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
-// LINK: lld{{.*}}" "-flavor" "wasm" "-L/foo/lib" "crt1.o" "[[temp]]" "-lc++" 
"-lc++abi" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
+// LINK: wasm-ld{{.*}}" "-L/foo/lib" "crt1.o" "[[temp]]" "-lc++" "-lc++abi" 
"-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
 
 // A basic C++ link command-line with optimization.
 
-// RUN: %clangxx -### -O2 -no-canonical-prefixes -target 
wasm32-unknown-unknown --sysroot=/foo %s --stdlib=c++ -fuse-ld=lld 2>&1 | 
FileCheck -check-prefix=LINK_OPT %s
+// RUN: %clangxx -### -O2 -no-canonical-prefixes -target 
wasm32-unknown-unknown --sysroot=/foo %s --stdlib=c++ -fuse-ld=wasm-ld 2>&1 | 
FileCheck -check-prefix=LINK_OPT %s
 // LINK_OPT: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
-// LINK_OPT: lld{{.*}}" "-flavor" "wasm" "-L/foo/lib" "crt1.o" "[[temp]]" 
"-lc++" "-lc++abi" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
+// LINK_OPT: wasm-ld{{.*}}" "-L/foo/lib" "crt1.o" "[[temp]]" "-lc++" 
"-lc++abi" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"


Index: cfe/trunk/lib/Driver/ToolChains/WebAssembly.h
===
--- cfe/trunk/lib/Driver/ToolChains/WebAssembly

[PATCH] D15225: [Driver] Sanitizer support based on runtime library presence

2018-08-07 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov added a comment.

@rnk As discussed, would it be acceptable for you to just have empty sanitizer 
runtime files in the resource directory?


Repository:
  rL LLVM

https://reviews.llvm.org/D15225



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


r339164 - [VFS] Emit an error when entry at root level uses a relative path.

2018-08-07 Thread Volodymyr Sapsai via cfe-commits
Author: vsapsai
Date: Tue Aug  7 12:05:41 2018
New Revision: 339164

URL: http://llvm.org/viewvc/llvm-project?rev=339164&view=rev
Log:
[VFS] Emit an error when entry at root level uses a relative path.

Entries with only a filename prevent us from building a file system tree and
cause the assertion

> Assertion failed: (NewParentE && "Parent entry must exist"), function 
> uniqueOverlayTree, file clang/lib/Basic/VirtualFileSystem.cpp, line 1303.

Entries with a relative path are simply not discoverable during header search.

rdar://problem/28990865

Reviewers: bruno, benlangmuir

Reviewed By: bruno

Subscribers: dexonsmith, cfe-commits

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


Modified:
cfe/trunk/lib/Basic/VirtualFileSystem.cpp
cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp

Modified: cfe/trunk/lib/Basic/VirtualFileSystem.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/VirtualFileSystem.cpp?rev=339164&r1=339163&r2=339164&view=diff
==
--- cfe/trunk/lib/Basic/VirtualFileSystem.cpp (original)
+++ cfe/trunk/lib/Basic/VirtualFileSystem.cpp Tue Aug  7 12:05:41 2018
@@ -1281,7 +1281,8 @@ class RedirectingFileSystemParser {
 }
   }
 
-  std::unique_ptr parseEntry(yaml::Node *N, RedirectingFileSystem *FS) {
+  std::unique_ptr parseEntry(yaml::Node *N, RedirectingFileSystem *FS,
+bool IsRootEntry) {
 auto *M = dyn_cast(N);
 if (!M) {
   error(N, "expected mapping node for file or directory entry");
@@ -1302,6 +1303,7 @@ class RedirectingFileSystemParser {
 std::vector> EntryArrayContents;
 std::string ExternalContentsPath;
 std::string Name;
+yaml::Node *NameValueNode;
 auto UseExternalName = RedirectingFileEntry::NK_NotSet;
 EntryKind Kind;
 
@@ -1321,6 +1323,7 @@ class RedirectingFileSystemParser {
 if (!parseScalarString(I.getValue(), Value, Buffer))
   return nullptr;
 
+NameValueNode = I.getValue();
 if (FS->UseCanonicalizedPaths) {
   SmallString<256> Path(Value);
   // Guarantee that old YAML files containing paths with ".." and "."
@@ -1357,7 +1360,8 @@ class RedirectingFileSystemParser {
 }
 
 for (auto &I : *Contents) {
-  if (std::unique_ptr E = parseEntry(&I, FS))
+  if (std::unique_ptr E =
+  parseEntry(&I, FS, /*IsRootEntry*/ false))
 EntryArrayContents.push_back(std::move(E));
   else
 return nullptr;
@@ -1418,6 +1422,13 @@ class RedirectingFileSystemParser {
   return nullptr;
 }
 
+if (IsRootEntry && !sys::path::is_absolute(Name)) {
+  assert(NameValueNode && "Name presence should be checked earlier");
+  error(NameValueNode,
+"entry with relative path at the root level is not discoverable");
+  return nullptr;
+}
+
 // Remove trailing slash(es), being careful not to remove the root path
 StringRef Trimmed(Name);
 size_t RootPathLen = sys::path::root_path(Trimmed).size();
@@ -1500,7 +1511,8 @@ public:
 }
 
 for (auto &I : *Roots) {
-  if (std::unique_ptr E = parseEntry(&I, FS))
+  if (std::unique_ptr E =
+  parseEntry(&I, FS, /*IsRootEntry*/ true))
 RootEntries.push_back(std::move(E));
   else
 return false;

Modified: cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp?rev=339164&r1=339163&r2=339164&view=diff
==
--- cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp (original)
+++ cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp Tue Aug  7 12:05:41 2018
@@ -1468,3 +1468,35 @@ TEST_F(VFSFromYAMLTest, RecursiveDirecto
   }
   EXPECT_EQ(I, E);
 }
+
+TEST_F(VFSFromYAMLTest, RelativePaths) {
+  IntrusiveRefCntPtr Lower(new DummyFileSystem());
+  // Filename at root level without a parent directory.
+  IntrusiveRefCntPtr FS = getFromYAMLString(
+  "{ 'roots': [\n"
+  "  { 'type': 'file', 'name': 'file-not-in-directory.h',\n"
+  "'external-contents': '//root/external/file'\n"
+  "  }\n"
+  "] }", Lower);
+  EXPECT_EQ(nullptr, FS.get());
+
+  // Relative file path.
+  FS = getFromYAMLString(
+  "{ 'roots': [\n"
+  "  { 'type': 'file', 'name': 'relative/file/path.h',\n"
+  "'external-contents': '//root/external/file'\n"
+  "  }\n"
+  "] }", Lower);
+  EXPECT_EQ(nullptr, FS.get());
+
+  // Relative directory path.
+  FS = getFromYAMLString(
+   "{ 'roots': [\n"
+   "  { 'type': 'directory', 'name': 'relative/directory/path.h',\n"
+   "'contents': []\n"
+   "  }\n"
+   "] }", Lower);
+  EXPECT_EQ(nullptr, FS.get());
+
+  EXPECT_EQ(3, NumDiagnostics);
+}


___
cfe-commits mai

[PATCH] D49518: [VFS] Emit an error when a file isn't located in any directory.

2018-08-07 Thread Volodymyr Sapsai via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC339164: [VFS] Emit an error when entry at root level uses a 
relative path. (authored by vsapsai, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D49518?vs=157311&id=159567#toc

Repository:
  rC Clang

https://reviews.llvm.org/D49518

Files:
  lib/Basic/VirtualFileSystem.cpp
  unittests/Basic/VirtualFileSystemTest.cpp

Index: unittests/Basic/VirtualFileSystemTest.cpp
===
--- unittests/Basic/VirtualFileSystemTest.cpp
+++ unittests/Basic/VirtualFileSystemTest.cpp
@@ -1468,3 +1468,35 @@
   }
   EXPECT_EQ(I, E);
 }
+
+TEST_F(VFSFromYAMLTest, RelativePaths) {
+  IntrusiveRefCntPtr Lower(new DummyFileSystem());
+  // Filename at root level without a parent directory.
+  IntrusiveRefCntPtr FS = getFromYAMLString(
+  "{ 'roots': [\n"
+  "  { 'type': 'file', 'name': 'file-not-in-directory.h',\n"
+  "'external-contents': '//root/external/file'\n"
+  "  }\n"
+  "] }", Lower);
+  EXPECT_EQ(nullptr, FS.get());
+
+  // Relative file path.
+  FS = getFromYAMLString(
+  "{ 'roots': [\n"
+  "  { 'type': 'file', 'name': 'relative/file/path.h',\n"
+  "'external-contents': '//root/external/file'\n"
+  "  }\n"
+  "] }", Lower);
+  EXPECT_EQ(nullptr, FS.get());
+
+  // Relative directory path.
+  FS = getFromYAMLString(
+   "{ 'roots': [\n"
+   "  { 'type': 'directory', 'name': 'relative/directory/path.h',\n"
+   "'contents': []\n"
+   "  }\n"
+   "] }", Lower);
+  EXPECT_EQ(nullptr, FS.get());
+
+  EXPECT_EQ(3, NumDiagnostics);
+}
Index: lib/Basic/VirtualFileSystem.cpp
===
--- lib/Basic/VirtualFileSystem.cpp
+++ lib/Basic/VirtualFileSystem.cpp
@@ -1281,7 +1281,8 @@
 }
   }
 
-  std::unique_ptr parseEntry(yaml::Node *N, RedirectingFileSystem *FS) {
+  std::unique_ptr parseEntry(yaml::Node *N, RedirectingFileSystem *FS,
+bool IsRootEntry) {
 auto *M = dyn_cast(N);
 if (!M) {
   error(N, "expected mapping node for file or directory entry");
@@ -1302,6 +1303,7 @@
 std::vector> EntryArrayContents;
 std::string ExternalContentsPath;
 std::string Name;
+yaml::Node *NameValueNode;
 auto UseExternalName = RedirectingFileEntry::NK_NotSet;
 EntryKind Kind;
 
@@ -1321,6 +1323,7 @@
 if (!parseScalarString(I.getValue(), Value, Buffer))
   return nullptr;
 
+NameValueNode = I.getValue();
 if (FS->UseCanonicalizedPaths) {
   SmallString<256> Path(Value);
   // Guarantee that old YAML files containing paths with ".." and "."
@@ -1357,7 +1360,8 @@
 }
 
 for (auto &I : *Contents) {
-  if (std::unique_ptr E = parseEntry(&I, FS))
+  if (std::unique_ptr E =
+  parseEntry(&I, FS, /*IsRootEntry*/ false))
 EntryArrayContents.push_back(std::move(E));
   else
 return nullptr;
@@ -1418,6 +1422,13 @@
   return nullptr;
 }
 
+if (IsRootEntry && !sys::path::is_absolute(Name)) {
+  assert(NameValueNode && "Name presence should be checked earlier");
+  error(NameValueNode,
+"entry with relative path at the root level is not discoverable");
+  return nullptr;
+}
+
 // Remove trailing slash(es), being careful not to remove the root path
 StringRef Trimmed(Name);
 size_t RootPathLen = sys::path::root_path(Trimmed).size();
@@ -1500,7 +1511,8 @@
 }
 
 for (auto &I : *Roots) {
-  if (std::unique_ptr E = parseEntry(&I, FS))
+  if (std::unique_ptr E =
+  parseEntry(&I, FS, /*IsRootEntry*/ true))
 RootEntries.push_back(std::move(E));
   else
 return false;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D49518: [VFS] Emit an error when a file isn't located in any directory.

2018-08-07 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

Thanks for the review, Bruno.


Repository:
  rC Clang

https://reviews.llvm.org/D49518



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


[PATCH]Clang-format AlignConsecutiveAssignment

2018-08-07 Thread Doak, Peter W. via cfe-commits
In testing clang-format with our code base QMCPACK 
(https://github.com/QMCPACK/qmcpack) we realized we would like consecutive 
identical compound assignments to be aligned as tok::equal assignments were.  
The following patch accomplishes this. Not sure if this is the correct way to 
submit this, but this is my guess from reading the clang website.

Best,
Peter Doak

Index: include/clang/Format/Format.h
===
--- include/clang/Format/Format.h   (revision 339163)
+++ include/clang/Format/Format.h   (working copy)
@@ -80,12 +80,17 @@
 
   /// If ``true``, aligns consecutive assignments.
   ///
-  /// This will align the assignment operators of consecutive lines. This
-  /// will result in formattings like
+  /// This will align the declaration names of consecutive lines and
+  /// matching assignment operators. This includes consecutive |=, +=
+  /// -=, /=, *=. This will result in formattings like
   /// \code
   ///   int  = 12;
   ///   int b= 23;
   ///   int ccc  = 23;
+  ///
+  ///   int ddd += 12;
+  ///   int ee  += 22;
+  ///   int f   += 23;
   /// \endcode
   bool AlignConsecutiveAssignments;
 
Index: lib/Format/WhitespaceManager.cpp
===
--- lib/Format/WhitespaceManager.cpp(revision 339163)
+++ lib/Format/WhitespaceManager.cpp(working copy)
@@ -432,20 +432,26 @@
 void WhitespaceManager::alignConsecutiveAssignments() {
   if (!Style.AlignConsecutiveAssignments)
 return;
+  std::vector assignment_tokens =
+{tok::equal, tok::pipeequal, tok::caretequal, tok::percentequal,
+ tok::ampequal, tok::plusequal, tok::minusequal, tok::starequal,
+ tok::slashequal, tok::lesslessequal, tok::greatergreaterequal};
+  for (auto assignment_token : assignment_tokens)
+  {
+AlignTokens(Style,
+   [&](const Change &C) {
+ // Do not align on equal signs that are first on a line.
+ if (C.NewlinesBefore > 0)
+   return false;
 
-  AlignTokens(Style,
-  [&](const Change &C) {
-// Do not align on equal signs that are first on a line.
-if (C.NewlinesBefore > 0)
-  return false;
+ // Do not align on equal signs that are last on a line.
+ if (&C != &Changes.back() && (&C + 1)->NewlinesBefore > 0)
+   return false;
 
-// Do not align on equal signs that are last on a line.
-if (&C != &Changes.back() && (&C + 1)->NewlinesBefore > 0)
-  return false;
-
-return C.Tok->is(tok::equal);
-  },
-  Changes, /*StartAt=*/0);
+ return C.Tok->is(assignment_token);
+   },
+   Changes, /*StartAt=*/0);
+  }
 }
 
 void WhitespaceManager::alignConsecutiveDeclarations() {

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


  1   2   3   >