[PATCH] D64310: [clangd] Added semantic highlighting for constructors and destructors.

2019-07-08 Thread Johan Vikström via Phabricator via cfe-commits
jvikstrom created this revision.
jvikstrom added reviewers: hokein, ilya-biryukov.
Herald added subscribers: cfe-commits, kadircet, arphaman, jkorous, MaskRay.
Herald added a project: clang.

Add semantic highlighting to constructor and destructor declarations.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D64310

Files:
  clang-tools-extra/clangd/SemanticHighlighting.cpp
  clang-tools-extra/clangd/SemanticHighlighting.h
  clang-tools-extra/clangd/test/semantic-highlighting.test
  clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp

Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -34,7 +34,9 @@
   auto AST = TestTU::withCode(Test.code()).build();
   static const std::map KindToString{
   {HighlightingKind::Variable, "Variable"},
-  {HighlightingKind::Function, "Function"}};
+  {HighlightingKind::Function, "Function"},
+  {HighlightingKind::Constructor, "Constructor"},
+  {HighlightingKind::Destructor, "Destructor"}};
   std::vector ExpectedTokens;
   for (const auto &KindString : KindToString) {
 std::vector Toks =
@@ -71,11 +73,12 @@
 )cpp",
 R"cpp(
   struct A {
-A();
-~A();
+$Constructor[[A]]();
+$Destructor[[~A]]()  {}
 void $Function[[abc]]();
 void operator<<(int);
   };
+  struct B {};
 )cpp"};
   for (const auto &TestCase : TestCases) {
 checkHighlightings(TestCase);
Index: clang-tools-extra/clangd/test/semantic-highlighting.test
===
--- clang-tools-extra/clangd/test/semantic-highlighting.test
+++ clang-tools-extra/clangd/test/semantic-highlighting.test
@@ -10,6 +10,12 @@
 # CHECK-NEXT:  [
 # CHECK-NEXT:"entity.name.function.cpp"
 # CHECK-NEXT:  ]
+# CHECK-NEXT:  [
+# CHECK-NEXT:"entity.name.function.constructor.cpp"
+# CHECK-NEXT:  ],
+# CHECK-NEXT:  [
+# CHECK-NEXT:"entity.name.function.destructor.cpp"
+# CHECK-NEXT:  ]
 # CHECK-NEXT:]
 # CHECK-NEXT:  },
 ---
Index: clang-tools-extra/clangd/SemanticHighlighting.h
===
--- clang-tools-extra/clangd/SemanticHighlighting.h
+++ clang-tools-extra/clangd/SemanticHighlighting.h
@@ -26,6 +26,8 @@
 enum class HighlightingKind {
   Variable = 0,
   Function,
+  Constructor,
+  Destructor,
 
   NumKinds,
 };
Index: clang-tools-extra/clangd/SemanticHighlighting.cpp
===
--- clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -36,7 +36,10 @@
 
   bool VisitNamedDecl(NamedDecl *ND) {
 // FIXME: (De)Constructors/operator need to be highlighted some other way.
-if (ND->getDeclName().getNameKind() != DeclarationName::Identifier)
+auto Kind = ND->getDeclName().getNameKind();
+if (Kind != DeclarationName::Identifier &&
+Kind != DeclarationName::CXXConstructorName &&
+Kind != DeclarationName::CXXDestructorName)
   return true;
 
 if (ND->getDeclName().isEmpty())
@@ -58,6 +61,21 @@
 
 private:
   void addToken(SourceLocation Loc, const Decl *D) {
+if (Loc.isMacroID())
+  // FIXME: skip tokens inside macros for now.
+  return;
+
+if(isa(D)) {
+  addToken(Loc, HighlightingKind::Constructor);
+  return;
+}
+if (isa(D)) {
+  addToken(
+  Loc,
+  dyn_cast(D)->getDeclName().getAsString().size(),
+  HighlightingKind::Destructor);
+  return;
+}
 if (isa(D)) {
   addToken(Loc, HighlightingKind::Variable);
   return;
@@ -69,10 +87,6 @@
   }
 
   void addToken(SourceLocation Loc, HighlightingKind Kind) {
-if (Loc.isMacroID())
-  // FIXME: skip tokens inside macros for now.
-  return;
-
 auto R = getTokenRange(SM, Ctx.getLangOpts(), Loc);
 if (!R) {
   // R should always have a value, if it doesn't something is very wrong.
@@ -82,6 +96,13 @@
 
 Tokens.push_back({Kind, R.getValue()});
   }
+  void addToken(SourceLocation Loc, int Len, HighlightingKind Kind) {
+auto StartLoc = sourceLocToPosition(SM, Loc);
+Position EndLoc;
+EndLoc.line = StartLoc.line;
+EndLoc.character = StartLoc.character + Len;
+Tokens.push_back({Kind, {StartLoc, EndLoc}});
+  }
 };
 
 // Encode binary data into base64.
@@ -176,6 +197,10 @@
 return "entity.name.function.cpp";
   case HighlightingKind::Variable:
 return "variable.cpp";
+  case HighlightingKind::Constructor:
+return "entity.name.function.constructor.cpp";
+  case HighlightingKind::Destructor:
+return "entity.name.function.destructor.cpp";
   case HighlightingKind::NumKinds

[PATCH] D64257: [clangd] Added highlighting for non-builtin types

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



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:68
+
+TagDecl *D = TL.getTypePtr()->getAsTagDecl();
+if (!D)

We are only interested in `TagDecl`, maybe use the `VisitTagLoc` callback, so 
that you can get rid of the filtering code above.



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:72
+
+if (auto RD = dyn_cast(D)) {
+  if (auto DC = RD->getDestructor()) {

nit: auto => `const auto *`, we usually spell out the `pointer type` explicitly.



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:73
+if (auto RD = dyn_cast(D)) {
+  if (auto DC = RD->getDestructor()) {
+auto Range = DC->getSourceRange();

Here is the case:

```
class Foo {
   ~Foo
 // ^~~ we get a TypeLoc whose TagDecl is a cxxRecordDecl.
}
```
not sure this is expected in clang AST, but it is unreasonable in highlighting 
context -- ideally, we want to highlight `~Foo` as a destructor (we may 
encounter a tricky case, like `~ /*comment*/ Foo()`, but I assume this is 
rarce, should be fine), @sammccall, @ilya-biryukov, thoughts?



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:99
 }
+if(isa(D)) {
+  addToken(Loc, HighlightingKind::Type);

nit: clang-format



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:214
+  case HighlightingKind::Type:
+return "entity.name.type.cpp";
   case HighlightingKind::NumKinds:

`entity.name.type.class.cpp`?



Comment at: clang-tools-extra/clangd/SemanticHighlighting.h:29
   Function,
+  Type,
 

`Type` is general, can match different types, I think we want distinguish 
different types (class, enum, etc).

Since this patch is highlighting `class`, I think the name should be `Class`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64257



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


r365298 - [AArch64] Fix vsqadd scalar intrinsics operands

2019-07-08 Thread Diogo N. Sampaio via cfe-commits
Author: dnsampaio
Date: Mon Jul  8 01:35:05 2019
New Revision: 365298

URL: http://llvm.org/viewvc/llvm-project?rev=365298&view=rev
Log:
[AArch64] Fix vsqadd scalar intrinsics operands

Summary:
Change the vsqadd scalar instrinsics to have the second argument as signed 
values, not unsigned,
accordingly to 
https://developer.arm.com/architectures/instruction-sets/simd-isas/neon/intrinsics

The existing unsigned argument can cause faulty code as negative float to 
unsigned conversion is
undefined, which llvm/clang optimizes away.

Reviewers: LukeCheeseman, john.brawn

Reviewed By: john.brawn

Subscribers: john.brawn, javed.absar, kristof.beyls, cfe-commits

Tags: #clang

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

Added:
cfe/trunk/test/CodeGen/aarch64-neon-vsqadd-float-conversion.c
Modified:
cfe/trunk/include/clang/Basic/arm_neon.td
cfe/trunk/test/CodeGen/aarch64-neon-intrinsics.c

Modified: cfe/trunk/include/clang/Basic/arm_neon.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/arm_neon.td?rev=365298&r1=365297&r2=365298&view=diff
==
--- cfe/trunk/include/clang/Basic/arm_neon.td (original)
+++ cfe/trunk/include/clang/Basic/arm_neon.td Mon Jul  8 01:35:05 2019
@@ -1337,7 +1337,7 @@ def SCALAR_SUQADD : SInst<"vuqadd", "sss
 
 

 // Scalar Unsigned Saturating Accumulated of Signed Value
-def SCALAR_USQADD : SInst<"vsqadd", "sss", "SUcSUsSUiSUl">;
+def SCALAR_USQADD : SInst<"vsqadd", "ss$", "SUcSUsSUiSUl">;
 
 

 // Signed Saturating Doubling Multiply-Add Long

Modified: cfe/trunk/test/CodeGen/aarch64-neon-intrinsics.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/aarch64-neon-intrinsics.c?rev=365298&r1=365297&r2=365298&view=diff
==
--- cfe/trunk/test/CodeGen/aarch64-neon-intrinsics.c (original)
+++ cfe/trunk/test/CodeGen/aarch64-neon-intrinsics.c Mon Jul  8 01:35:05 2019
@@ -13913,7 +13913,7 @@ int64_t test_vuqaddd_s64(int64_t a, int6
 // CHECK:   [[VSQADDB_U8_I:%.*]] = call <8 x i8> 
@llvm.aarch64.neon.usqadd.v8i8(<8 x i8> [[TMP0]], <8 x i8> [[TMP1]])
 // CHECK:   [[TMP2:%.*]] = extractelement <8 x i8> [[VSQADDB_U8_I]], i64 0
 // CHECK:   ret i8 [[TMP2]]
-uint8_t test_vsqaddb_u8(uint8_t a, uint8_t b) {
+uint8_t test_vsqaddb_u8(uint8_t a, int8_t b) {
   return (uint8_t)vsqaddb_u8(a, b);
 }
 
@@ -13923,21 +13923,21 @@ uint8_t test_vsqaddb_u8(uint8_t a, uint8
 // CHECK:   [[VSQADDH_U16_I:%.*]] = call <4 x i16> 
@llvm.aarch64.neon.usqadd.v4i16(<4 x i16> [[TMP0]], <4 x i16> [[TMP1]])
 // CHECK:   [[TMP2:%.*]] = extractelement <4 x i16> [[VSQADDH_U16_I]], i64 0
 // CHECK:   ret i16 [[TMP2]]
-uint16_t test_vsqaddh_u16(uint16_t a, uint16_t b) {
+uint16_t test_vsqaddh_u16(uint16_t a, int16_t b) {
   return (uint16_t)vsqaddh_u16(a, b);
 }
 
 // CHECK-LABEL: @test_vsqadds_u32(
 // CHECK:   [[VSQADDS_U32_I:%.*]] = call i32 @llvm.aarch64.neon.usqadd.i32(i32 
%a, i32 %b)
 // CHECK:   ret i32 [[VSQADDS_U32_I]]
-uint32_t test_vsqadds_u32(uint32_t a, uint32_t b) {
+uint32_t test_vsqadds_u32(uint32_t a, int32_t b) {
   return (uint32_t)vsqadds_u32(a, b);
 }
 
 // CHECK-LABEL: @test_vsqaddd_u64(
 // CHECK:   [[VSQADDD_U64_I:%.*]] = call i64 @llvm.aarch64.neon.usqadd.i64(i64 
%a, i64 %b)
 // CHECK:   ret i64 [[VSQADDD_U64_I]]
-uint64_t test_vsqaddd_u64(uint64_t a, uint64_t b) {
+uint64_t test_vsqaddd_u64(uint64_t a, int64_t b) {
   return (uint64_t)vsqaddd_u64(a, b);
 }
 

Added: cfe/trunk/test/CodeGen/aarch64-neon-vsqadd-float-conversion.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/aarch64-neon-vsqadd-float-conversion.c?rev=365298&view=auto
==
--- cfe/trunk/test/CodeGen/aarch64-neon-vsqadd-float-conversion.c (added)
+++ cfe/trunk/test/CodeGen/aarch64-neon-vsqadd-float-conversion.c Mon Jul  8 
01:35:05 2019
@@ -0,0 +1,49 @@
+// RUN: %clang_cc1 -triple arm64-none-linux-gnu -target-feature +neon \
+// RUN:  -S -disable-O0-optnone -emit-llvm -o - %s | opt -S -mem2reg -dce \
+// RUN: | FileCheck %s
+
+#include 
+
+// Check float conversion is accepted for int argument
+uint8_t test_vsqaddb_u8(){
+  return vsqaddb_u8(1, -1.0f);
+}
+
+uint16_t test_vsqaddh_u16() {
+  return vsqaddh_u16(1, -1.0f);
+}
+
+uint32_t test_vsqadds_u32() {
+  return vsqadds_u32(1, -1.0f);
+}
+
+uint64_t test_vsqaddd_u64() {
+  return vsqaddd_u64(1, -1.0f);
+}
+
+// CHECK-LABEL: @test_vsqaddb_u8()
+// CHECK: entry:
+// CHECK-NEXT: [[T0:%.*]] = insertelement <8 x i8> undef, i8 1, i64 0
+// CHECK-NEXT: [[T1:%.*]] = insertelement <8 x i8> undef, i8 -1, i64 0
+// CHECK-NEXT: [[V:%.*]] = call <8 x i8> @llvm.aarch64.neon.usqadd.v8i8(<8 x 
i8> [[T0]], <8 x i8> [[T1]])
+// CHECK-NEXT: [[R:%.*]] = ex

[PATCH] D64239: [AArch64] Fix vsqadd scalar intrinsics operands

2019-07-08 Thread Diogo N. Sampaio via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL365298: [AArch64] Fix vsqadd scalar intrinsics operands 
(authored by dnsampaio, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D64239?vs=208137&id=208330#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D64239

Files:
  cfe/trunk/include/clang/Basic/arm_neon.td
  cfe/trunk/test/CodeGen/aarch64-neon-intrinsics.c
  cfe/trunk/test/CodeGen/aarch64-neon-vsqadd-float-conversion.c

Index: cfe/trunk/include/clang/Basic/arm_neon.td
===
--- cfe/trunk/include/clang/Basic/arm_neon.td
+++ cfe/trunk/include/clang/Basic/arm_neon.td
@@ -1337,7 +1337,7 @@
 
 
 // Scalar Unsigned Saturating Accumulated of Signed Value
-def SCALAR_USQADD : SInst<"vsqadd", "sss", "SUcSUsSUiSUl">;
+def SCALAR_USQADD : SInst<"vsqadd", "ss$", "SUcSUsSUiSUl">;
 
 
 // Signed Saturating Doubling Multiply-Add Long
Index: cfe/trunk/test/CodeGen/aarch64-neon-vsqadd-float-conversion.c
===
--- cfe/trunk/test/CodeGen/aarch64-neon-vsqadd-float-conversion.c
+++ cfe/trunk/test/CodeGen/aarch64-neon-vsqadd-float-conversion.c
@@ -0,0 +1,49 @@
+// RUN: %clang_cc1 -triple arm64-none-linux-gnu -target-feature +neon \
+// RUN:  -S -disable-O0-optnone -emit-llvm -o - %s | opt -S -mem2reg -dce \
+// RUN: | FileCheck %s
+
+#include 
+
+// Check float conversion is accepted for int argument
+uint8_t test_vsqaddb_u8(){
+  return vsqaddb_u8(1, -1.0f);
+}
+
+uint16_t test_vsqaddh_u16() {
+  return vsqaddh_u16(1, -1.0f);
+}
+
+uint32_t test_vsqadds_u32() {
+  return vsqadds_u32(1, -1.0f);
+}
+
+uint64_t test_vsqaddd_u64() {
+  return vsqaddd_u64(1, -1.0f);
+}
+
+// CHECK-LABEL: @test_vsqaddb_u8()
+// CHECK: entry:
+// CHECK-NEXT: [[T0:%.*]] = insertelement <8 x i8> undef, i8 1, i64 0
+// CHECK-NEXT: [[T1:%.*]] = insertelement <8 x i8> undef, i8 -1, i64 0
+// CHECK-NEXT: [[V:%.*]] = call <8 x i8> @llvm.aarch64.neon.usqadd.v8i8(<8 x i8> [[T0]], <8 x i8> [[T1]])
+// CHECK-NEXT: [[R:%.*]] = extractelement <8 x i8> [[V]], i64 0
+// CHECK-NEXT: ret i8 [[R]]
+
+// CHECK-LABEL: @test_vsqaddh_u16()
+// CHECK: entry:
+// CHECK-NEXT: [[T0:%.*]] = insertelement <4 x i16> undef, i16 1, i64 0
+// CHECK-NEXT: [[T1:%.*]] = insertelement <4 x i16> undef, i16 -1, i64 0
+// CHECK-NEXT: [[V:%.*]]  = call <4 x i16> @llvm.aarch64.neon.usqadd.v4i16(<4 x i16> [[T0]], <4 x i16> [[T1]])
+// CHECK-NEXT: [[R:%.*]] = extractelement <4 x i16> [[V]], i64 0
+// CHECK-NEXT: ret i16 [[R]]
+
+// CHECK-LABEL: @test_vsqadds_u32()
+// CHECK: entry:
+// CHECK-NEXT: [[V:%.*]] = call i32 @llvm.aarch64.neon.usqadd.i32(i32 1, i32 -1)
+// CHECK-NEXT: ret i32 [[V]]
+
+// CHECK-LABEL: @test_vsqaddd_u64()
+// CHECK: entry:
+// CHECK-NEXT: [[V:%.*]] = call i64 @llvm.aarch64.neon.usqadd.i64(i64 1, i64 -1)
+// CHECK-NEXT: ret i64 [[V]]
+
Index: cfe/trunk/test/CodeGen/aarch64-neon-intrinsics.c
===
--- cfe/trunk/test/CodeGen/aarch64-neon-intrinsics.c
+++ cfe/trunk/test/CodeGen/aarch64-neon-intrinsics.c
@@ -13913,7 +13913,7 @@
 // CHECK:   [[VSQADDB_U8_I:%.*]] = call <8 x i8> @llvm.aarch64.neon.usqadd.v8i8(<8 x i8> [[TMP0]], <8 x i8> [[TMP1]])
 // CHECK:   [[TMP2:%.*]] = extractelement <8 x i8> [[VSQADDB_U8_I]], i64 0
 // CHECK:   ret i8 [[TMP2]]
-uint8_t test_vsqaddb_u8(uint8_t a, uint8_t b) {
+uint8_t test_vsqaddb_u8(uint8_t a, int8_t b) {
   return (uint8_t)vsqaddb_u8(a, b);
 }
 
@@ -13923,21 +13923,21 @@
 // CHECK:   [[VSQADDH_U16_I:%.*]] = call <4 x i16> @llvm.aarch64.neon.usqadd.v4i16(<4 x i16> [[TMP0]], <4 x i16> [[TMP1]])
 // CHECK:   [[TMP2:%.*]] = extractelement <4 x i16> [[VSQADDH_U16_I]], i64 0
 // CHECK:   ret i16 [[TMP2]]
-uint16_t test_vsqaddh_u16(uint16_t a, uint16_t b) {
+uint16_t test_vsqaddh_u16(uint16_t a, int16_t b) {
   return (uint16_t)vsqaddh_u16(a, b);
 }
 
 // CHECK-LABEL: @test_vsqadds_u32(
 // CHECK:   [[VSQADDS_U32_I:%.*]] = call i32 @llvm.aarch64.neon.usqadd.i32(i32 %a, i32 %b)
 // CHECK:   ret i32 [[VSQADDS_U32_I]]
-uint32_t test_vsqadds_u32(uint32_t a, uint32_t b) {
+uint32_t test_vsqadds_u32(uint32_t a, int32_t b) {
   return (uint32_t)vsqadds_u32(a, b);
 }
 
 // CHECK-LABEL: @test_vsqaddd_u64(
 // CHECK:   [[VSQADDD_U64_I:%.*]] = call i64 @llvm.aarch64.neon.usqadd.i64(i64 %a, i64 %b)
 // CHECK:   ret i64 [[VSQADDD_U64_I]]
-uint64_t test_vsqaddd_u64(uint64_t a, uint64_t b) {
+uint64_t test_vsqaddd_u64(uint64_t a, int64_t b) {
   return (uint64_t)vsqaddd_u64(a, b);
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi

r365300 - [AArch64] Fix scalar vuqadd intrinsics operands

2019-07-08 Thread Diogo N. Sampaio via cfe-commits
Author: dnsampaio
Date: Mon Jul  8 01:47:47 2019
New Revision: 365300

URL: http://llvm.org/viewvc/llvm-project?rev=365300&view=rev
Log:
[AArch64] Fix scalar vuqadd intrinsics operands

Summary:
Change the vuqadd scalar instrinsics to have the second argument as unsigned 
values, not signed,
accordingly to 
https://developer.arm.com/architectures/instruction-sets/simd-isas/neon/intrinsics

So now the compiler correctly warns that a undefined negative float conversion 
is being done.

Reviewers: LukeCheeseman, john.brawn

Reviewed By: john.brawn

Subscribers: john.brawn, javed.absar, kristof.beyls, cfe-commits

Tags: #clang

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

Added:
cfe/trunk/test/CodeGen/aarch64-neon-vuqadd-float-conversion-warning.c
Modified:
cfe/trunk/include/clang/Basic/arm_neon.td
cfe/trunk/test/CodeGen/aarch64-neon-intrinsics.c

Modified: cfe/trunk/include/clang/Basic/arm_neon.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/arm_neon.td?rev=365300&r1=365299&r2=365300&view=diff
==
--- cfe/trunk/include/clang/Basic/arm_neon.td (original)
+++ cfe/trunk/include/clang/Basic/arm_neon.td Mon Jul  8 01:47:47 2019
@@ -1333,7 +1333,7 @@ def SCALAR_SQNEG : SInst<"vqneg", "ss",
 
 

 // Scalar Signed Saturating Accumulated of Unsigned Value
-def SCALAR_SUQADD : SInst<"vuqadd", "sss", "ScSsSiSl">;
+def SCALAR_SUQADD : SInst<"vuqadd", "ssb", "ScSsSiSl">;
 
 

 // Scalar Unsigned Saturating Accumulated of Signed Value

Modified: cfe/trunk/test/CodeGen/aarch64-neon-intrinsics.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/aarch64-neon-intrinsics.c?rev=365300&r1=365299&r2=365300&view=diff
==
--- cfe/trunk/test/CodeGen/aarch64-neon-intrinsics.c (original)
+++ cfe/trunk/test/CodeGen/aarch64-neon-intrinsics.c Mon Jul  8 01:47:47 2019
@@ -13879,7 +13879,7 @@ int64_t test_vqnegd_s64(int64_t a) {
 // CHECK:   [[VUQADDB_S8_I:%.*]] = call <8 x i8> 
@llvm.aarch64.neon.suqadd.v8i8(<8 x i8> [[TMP0]], <8 x i8> [[TMP1]])
 // CHECK:   [[TMP2:%.*]] = extractelement <8 x i8> [[VUQADDB_S8_I]], i64 0
 // CHECK:   ret i8 [[TMP2]]
-int8_t test_vuqaddb_s8(int8_t a, int8_t b) {
+int8_t test_vuqaddb_s8(int8_t a, uint8_t b) {
   return (int8_t)vuqaddb_s8(a, b);
 }
 
@@ -13889,21 +13889,21 @@ int8_t test_vuqaddb_s8(int8_t a, int8_t
 // CHECK:   [[VUQADDH_S16_I:%.*]] = call <4 x i16> 
@llvm.aarch64.neon.suqadd.v4i16(<4 x i16> [[TMP0]], <4 x i16> [[TMP1]])
 // CHECK:   [[TMP2:%.*]] = extractelement <4 x i16> [[VUQADDH_S16_I]], i64 0
 // CHECK:   ret i16 [[TMP2]]
-int16_t test_vuqaddh_s16(int16_t a, int16_t b) {
+int16_t test_vuqaddh_s16(int16_t a, uint16_t b) {
   return (int16_t)vuqaddh_s16(a, b);
 }
 
 // CHECK-LABEL: @test_vuqadds_s32(
 // CHECK:   [[VUQADDS_S32_I:%.*]] = call i32 @llvm.aarch64.neon.suqadd.i32(i32 
%a, i32 %b)
 // CHECK:   ret i32 [[VUQADDS_S32_I]]
-int32_t test_vuqadds_s32(int32_t a, int32_t b) {
+int32_t test_vuqadds_s32(int32_t a, uint32_t b) {
   return (int32_t)vuqadds_s32(a, b);
 }
 
 // CHECK-LABEL: @test_vuqaddd_s64(
 // CHECK:   [[VUQADDD_S64_I:%.*]] = call i64 @llvm.aarch64.neon.suqadd.i64(i64 
%a, i64 %b)
 // CHECK:   ret i64 [[VUQADDD_S64_I]]
-int64_t test_vuqaddd_s64(int64_t a, int64_t b) {
+int64_t test_vuqaddd_s64(int64_t a, uint64_t b) {
   return (int64_t)vuqaddd_s64(a, b);
 }
 

Added: cfe/trunk/test/CodeGen/aarch64-neon-vuqadd-float-conversion-warning.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/aarch64-neon-vuqadd-float-conversion-warning.c?rev=365300&view=auto
==
--- cfe/trunk/test/CodeGen/aarch64-neon-vuqadd-float-conversion-warning.c 
(added)
+++ cfe/trunk/test/CodeGen/aarch64-neon-vuqadd-float-conversion-warning.c Mon 
Jul  8 01:47:47 2019
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -triple arm64-none-linux-gnu -target-feature +neon \
+// RUN:  -S -disable-O0-optnone -emit-llvm -o - %s 2>&1 | FileCheck %s
+
+#include 
+
+// Check float conversion is not accepted for unsigned int argument
+int8_t test_vuqaddb_s8(){
+  return vuqaddb_s8(1, -1.0f);
+}
+
+int16_t test_vuqaddh_s16() {
+  return vuqaddh_s16(1, -1.0f);
+}
+
+int32_t test_vuqadds_s32() {
+  return vuqadds_s32(1, -1.0f);
+}
+
+int64_t test_vuqaddd_s64() {
+  return vuqaddd_s64(1, -1.0f);
+}
+// CHECK: warning: implicit conversion of out of range value from 'float' to 
'uint8_t' (aka 'unsigned char') is undefined
+// CHECK: warning: implicit conversion of out of range value from 'float' to 
'uint16_t' (aka 'unsigned short') is undefined
+// CHECK: warning: implicit conversion of out of range value from 'float' to 
'uint32_t' (aka 'unsigned int') is undefined
+// CHECK: wa

[PATCH] D64242: [AArch64] Fix scalar vuqadd intrinsics operands

2019-07-08 Thread Diogo N. Sampaio via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL365300: [AArch64] Fix scalar vuqadd intrinsics operands 
(authored by dnsampaio, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D64242?vs=208144&id=208332#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D64242

Files:
  cfe/trunk/include/clang/Basic/arm_neon.td
  cfe/trunk/test/CodeGen/aarch64-neon-intrinsics.c
  cfe/trunk/test/CodeGen/aarch64-neon-vuqadd-float-conversion-warning.c


Index: cfe/trunk/include/clang/Basic/arm_neon.td
===
--- cfe/trunk/include/clang/Basic/arm_neon.td
+++ cfe/trunk/include/clang/Basic/arm_neon.td
@@ -1333,7 +1333,7 @@
 
 

 // Scalar Signed Saturating Accumulated of Unsigned Value
-def SCALAR_SUQADD : SInst<"vuqadd", "sss", "ScSsSiSl">;
+def SCALAR_SUQADD : SInst<"vuqadd", "ssb", "ScSsSiSl">;
 
 

 // Scalar Unsigned Saturating Accumulated of Signed Value
Index: cfe/trunk/test/CodeGen/aarch64-neon-intrinsics.c
===
--- cfe/trunk/test/CodeGen/aarch64-neon-intrinsics.c
+++ cfe/trunk/test/CodeGen/aarch64-neon-intrinsics.c
@@ -13879,7 +13879,7 @@
 // CHECK:   [[VUQADDB_S8_I:%.*]] = call <8 x i8> 
@llvm.aarch64.neon.suqadd.v8i8(<8 x i8> [[TMP0]], <8 x i8> [[TMP1]])
 // CHECK:   [[TMP2:%.*]] = extractelement <8 x i8> [[VUQADDB_S8_I]], i64 0
 // CHECK:   ret i8 [[TMP2]]
-int8_t test_vuqaddb_s8(int8_t a, int8_t b) {
+int8_t test_vuqaddb_s8(int8_t a, uint8_t b) {
   return (int8_t)vuqaddb_s8(a, b);
 }
 
@@ -13889,21 +13889,21 @@
 // CHECK:   [[VUQADDH_S16_I:%.*]] = call <4 x i16> 
@llvm.aarch64.neon.suqadd.v4i16(<4 x i16> [[TMP0]], <4 x i16> [[TMP1]])
 // CHECK:   [[TMP2:%.*]] = extractelement <4 x i16> [[VUQADDH_S16_I]], i64 0
 // CHECK:   ret i16 [[TMP2]]
-int16_t test_vuqaddh_s16(int16_t a, int16_t b) {
+int16_t test_vuqaddh_s16(int16_t a, uint16_t b) {
   return (int16_t)vuqaddh_s16(a, b);
 }
 
 // CHECK-LABEL: @test_vuqadds_s32(
 // CHECK:   [[VUQADDS_S32_I:%.*]] = call i32 @llvm.aarch64.neon.suqadd.i32(i32 
%a, i32 %b)
 // CHECK:   ret i32 [[VUQADDS_S32_I]]
-int32_t test_vuqadds_s32(int32_t a, int32_t b) {
+int32_t test_vuqadds_s32(int32_t a, uint32_t b) {
   return (int32_t)vuqadds_s32(a, b);
 }
 
 // CHECK-LABEL: @test_vuqaddd_s64(
 // CHECK:   [[VUQADDD_S64_I:%.*]] = call i64 @llvm.aarch64.neon.suqadd.i64(i64 
%a, i64 %b)
 // CHECK:   ret i64 [[VUQADDD_S64_I]]
-int64_t test_vuqaddd_s64(int64_t a, int64_t b) {
+int64_t test_vuqaddd_s64(int64_t a, uint64_t b) {
   return (int64_t)vuqaddd_s64(a, b);
 }
 
Index: cfe/trunk/test/CodeGen/aarch64-neon-vuqadd-float-conversion-warning.c
===
--- cfe/trunk/test/CodeGen/aarch64-neon-vuqadd-float-conversion-warning.c
+++ cfe/trunk/test/CodeGen/aarch64-neon-vuqadd-float-conversion-warning.c
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -triple arm64-none-linux-gnu -target-feature +neon \
+// RUN:  -S -disable-O0-optnone -emit-llvm -o - %s 2>&1 | FileCheck %s
+
+#include 
+
+// Check float conversion is not accepted for unsigned int argument
+int8_t test_vuqaddb_s8(){
+  return vuqaddb_s8(1, -1.0f);
+}
+
+int16_t test_vuqaddh_s16() {
+  return vuqaddh_s16(1, -1.0f);
+}
+
+int32_t test_vuqadds_s32() {
+  return vuqadds_s32(1, -1.0f);
+}
+
+int64_t test_vuqaddd_s64() {
+  return vuqaddd_s64(1, -1.0f);
+}
+// CHECK: warning: implicit conversion of out of range value from 'float' to 
'uint8_t' (aka 'unsigned char') is undefined
+// CHECK: warning: implicit conversion of out of range value from 'float' to 
'uint16_t' (aka 'unsigned short') is undefined
+// CHECK: warning: implicit conversion of out of range value from 'float' to 
'uint32_t' (aka 'unsigned int') is undefined
+// CHECK: warning: implicit conversion of out of range value from 'float' to 
'uint64_t' (aka 'unsigned long') is undefined
+


Index: cfe/trunk/include/clang/Basic/arm_neon.td
===
--- cfe/trunk/include/clang/Basic/arm_neon.td
+++ cfe/trunk/include/clang/Basic/arm_neon.td
@@ -1333,7 +1333,7 @@
 
 
 // Scalar Signed Saturating Accumulated of Unsigned Value
-def SCALAR_SUQADD : SInst<"vuqadd", "sss", "ScSsSiSl">;
+def SCALAR_SUQADD : SInst<"vuqadd", "ssb", "ScSsSiSl">;
 
 
 // Scalar Unsigned Saturating Accumulated of Signed Value
Index: cfe/trunk/test/CodeGen/aarch64-neon-intrinsics.c
===
--- cfe/trunk/test/

[PATCH] D63793: Treat the range of representable values of floating-point types as [-inf, +inf] not as [-max, +max].

2019-07-08 Thread Oliver Stannard (Linaro) via Phabricator via cfe-commits
ostannard added a comment.

There are a number of buildbot failures which look related to this, e.g.

- 
http://lab.llvm.org:8011/builders/clang-cmake-armv7-full/builds/6730/steps/ninja%20check%201/logs/FAIL%3A%20UBSan-AddressSanitizer-armhf%3A%3Adiv-zero.cpp
- 
http://lab.llvm.org:8011/builders/clang-cmake-armv7-full/builds/6730/steps/ninja%20check%201/logs/FAIL%3A%20UBSan-AddressSanitizer-armhf%3A%3Adiv-zero.cpp

I think that removing the float-divide-by-zero sanitizer from 
-fsanitize=undefined has also caused it to be marked as not supported, so it 
can't be enabled even explicitly.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D63793



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


r365305 - [RISCV] Specify registers used for exception handling

2019-07-08 Thread Alex Bradbury via cfe-commits
Author: asb
Date: Mon Jul  8 02:38:06 2019
New Revision: 365305

URL: http://llvm.org/viewvc/llvm-project?rev=365305&view=rev
Log:
[RISCV] Specify registers used for exception handling

Implements the handling of __builtin_eh_return_regno().

Differential Revision: https://reviews.llvm.org/D63417
Patch by Edward Jones.

Added:
cfe/trunk/test/CodeGen/builtins-riscv.c
Modified:
cfe/trunk/lib/Basic/Targets/RISCV.h

Modified: cfe/trunk/lib/Basic/Targets/RISCV.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/RISCV.h?rev=365305&r1=365304&r2=365305&view=diff
==
--- cfe/trunk/lib/Basic/Targets/RISCV.h (original)
+++ cfe/trunk/lib/Basic/Targets/RISCV.h Mon Jul  8 02:38:06 2019
@@ -57,6 +57,15 @@ public:
 
   ArrayRef getGCCRegNames() const override;
 
+  int getEHDataRegisterNumber(unsigned RegNo) const override {
+if (RegNo == 0)
+  return 10;
+else if (RegNo == 1)
+  return 11;
+else
+  return -1;
+  }
+
   ArrayRef getGCCRegAliases() const override;
 
   bool validateAsmConstraint(const char *&Name,

Added: cfe/trunk/test/CodeGen/builtins-riscv.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins-riscv.c?rev=365305&view=auto
==
--- cfe/trunk/test/CodeGen/builtins-riscv.c (added)
+++ cfe/trunk/test/CodeGen/builtins-riscv.c Mon Jul  8 02:38:06 2019
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -Wall -Werror -triple riscv32 -disable-O0-optnone 
-emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s
+// RUN: %clang_cc1 -Wall -Werror -triple riscv64 -disable-O0-optnone 
-emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s
+
+void test_eh_return_data_regno() {
+  // CHECK: store volatile i32 10
+  // CHECK: store volatile i32 11
+  volatile int res;
+  res = __builtin_eh_return_data_regno(0);
+  res = __builtin_eh_return_data_regno(1);
+}


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


[PATCH] D63793: Treat the range of representable values of floating-point types as [-inf, +inf] not as [-max, +max].

2019-07-08 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

In D63793#1572977 , @ostannard wrote:

> There are a number of buildbot failures which look related to this, e.g.
>
> - 
> http://lab.llvm.org:8011/builders/clang-cmake-armv7-full/builds/6730/steps/ninja%20check%201/logs/FAIL%3A%20UBSan-AddressSanitizer-armhf%3A%3Adiv-zero.cpp
> - 
> http://lab.llvm.org:8011/builders/clang-cmake-armv7-full/builds/6730/steps/ninja%20check%201/logs/FAIL%3A%20UBSan-AddressSanitizer-armhf%3A%3Adiv-zero.cpp
>
>   I think that removing the float-divide-by-zero sanitizer from 
> -fsanitize=undefined has also caused it to be marked as not supported, so it 
> can't be enabled even explicitly.


Should be fixed by rCRT365307 .


Repository:
  rL LLVM

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

https://reviews.llvm.org/D63793



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


[PATCH] D64257: [clangd] Added highlighting for non-builtin types

2019-07-08 Thread Johan Vikström via Phabricator via cfe-commits
jvikstrom updated this revision to Diff 208354.
jvikstrom marked an inline comment as done.
jvikstrom added a comment.

Type -> Class
Also added more tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64257

Files:
  clang-tools-extra/clangd/SemanticHighlighting.cpp
  clang-tools-extra/clangd/SemanticHighlighting.h
  clang-tools-extra/clangd/test/semantic-highlighting.test
  clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp

Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -34,11 +34,12 @@
   auto AST = TestTU::withCode(Test.code()).build();
   static const std::map KindToString{
   {HighlightingKind::Variable, "Variable"},
-  {HighlightingKind::Function, "Function"}};
+  {HighlightingKind::Function, "Function"},
+  {HighlightingKind::Class, "Class"}};
   std::vector ExpectedTokens;
   for (const auto &KindString : KindToString) {
-std::vector Toks =
-makeHighlightingTokens(Test.ranges(KindString.second), KindString.first);
+std::vector Toks = makeHighlightingTokens(
+Test.ranges(KindString.second), KindString.first);
 ExpectedTokens.insert(ExpectedTokens.end(), Toks.begin(), Toks.end());
   }
 
@@ -49,14 +50,14 @@
 TEST(SemanticHighlighting, GetsCorrectTokens) {
   const char *TestCases[] = {
 R"cpp(
-  struct AS {
+  struct $Class[[AS]] {
 double SomeMember;
   };
-  struct {
+  $Class[[struct]] {
   } $Variable[[S]];
-  void $Function[[foo]](int $Variable[[A]]) {
+  void $Function[[foo]](int $Variable[[A]], $Class[[AS]] $Variable[[As]]) {
 auto $Variable[[VeryLongVariableName]] = 12312;
-AS $Variable[[AA]];
+$Class[[AS]] $Variable[[AA]];
 auto $Variable[[L]] = $Variable[[AA]].SomeMember + $Variable[[A]];
 auto $Variable[[FN]] = [ $Variable[[AA]]](int $Variable[[A]]) -> void {};
 $Variable[[FN]](12312);
@@ -70,11 +71,28 @@
   }
 )cpp",
 R"cpp(
-  struct A {
+  namespace abc {
+template
+struct $Class[[A]] {
+  T t;
+};
+  }
+  abc::$Class[[A]] $Variable[[AA]];
+  typedef abc::$Class[[A]] AAA;
+  enum class E {};
+  enum EE {};
+  struct $Class[[B]] {
+E EEE;
+EE ;
+$Class[[AAA]] AA;
+  };
+)cpp",
+R"cpp(
+  struct $Class[[A]] {
 A();
 ~A();
 void $Function[[abc]]();
-void operator<<(int);
+void operator<<($Class[[A]]);
   };
 )cpp"};
   for (const auto &TestCase : TestCases) {
Index: clang-tools-extra/clangd/test/semantic-highlighting.test
===
--- clang-tools-extra/clangd/test/semantic-highlighting.test
+++ clang-tools-extra/clangd/test/semantic-highlighting.test
@@ -10,6 +10,9 @@
 # CHECK-NEXT:  [
 # CHECK-NEXT:"entity.name.function.cpp"
 # CHECK-NEXT:  ]
+# CHECK-NEXT:  [
+# CHECK-NEXT:"entity.name.type.class.cpp"
+# CHECK-NEXT:  ]
 # CHECK-NEXT:]
 # CHECK-NEXT:  },
 ---
Index: clang-tools-extra/clangd/SemanticHighlighting.h
===
--- clang-tools-extra/clangd/SemanticHighlighting.h
+++ clang-tools-extra/clangd/SemanticHighlighting.h
@@ -26,6 +26,7 @@
 enum class HighlightingKind {
   Variable = 0,
   Function,
+  Class,
 
   NumKinds,
 };
Index: clang-tools-extra/clangd/SemanticHighlighting.cpp
===
--- clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -12,6 +12,7 @@
 #include "SourceCode.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/RecursiveASTVisitor.h"
+#include "clang/AST/TypeLoc.h"
 
 namespace clang {
 namespace clangd {
@@ -56,6 +57,36 @@
 return true;
   }
 
+  bool VisitTypeLoc(TypeLoc &TL) {
+// The check for DependentName is so namespace qualifiers are not
+// highlighted. The check for elaborated type is for not getting two entries
+// whenever there is an anonymous struct.
+if (TL.getTypeLocClass() == TypeLoc::TypeLocClass::DependentName ||
+TL.getTypeLocClass() == TypeLoc::TypeLocClass::Elaborated) {
+  return true;
+}
+
+TagDecl *D = TL.getTypePtr()->getAsTagDecl();
+if (!D)
+  return true;
+
+if (const auto *RD = dyn_cast(D)) {
+  if (const auto *DC = RD->getDestructor()) {
+auto Range = DC->getSourceRange();
+// Destructors appear as a TagTypeLoc RecordDecl. To not highlight
+// destructors incorrectly the TagTypeLoc is skipped if it is wrapped
+

[PATCH] D64319: [OpenCL] Add function attributes handling for builtin functions

2019-07-08 Thread Pierre GONDOIS via Phabricator via cfe-commits
Pierre created this revision.
Pierre added reviewers: Anastasia, svenvh.
Pierre added projects: clang, LLVM.
Herald added subscribers: cfe-commits, kristina.

Add handling to for the "overload, "pure", "constant" and 
"convergent" function attributes for OpenCL builtin functions.


Repository:
  rC Clang

https://reviews.llvm.org/D64319

Files:
  clang/lib/Sema/OpenCLBuiltins.td
  clang/lib/Sema/SemaLookup.cpp
  clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp

Index: clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
===
--- clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
+++ clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
@@ -461,6 +461,12 @@
   // the SignatureTable must be considered to build the signature.
   // The first type at index SigTableIndex is the return type.
   const unsigned NumTypes;
+  // OpenCL attribute : __attribute__((pure))
+  const bool IsPure;
+  // OpenCL attribute : __attribute__((const))
+  const bool IsConst;
+  // OpenCL attribute : __attribute__((convergent))
+  const bool IsConv;
   // Extension to which the signature belongs (e.g.: cl_khr_subgroups)
   const enum OpenCLFctExtensionID Extension;
   // Version in which it was introduced (e.g.: CL20). MinVersion is inclusive.
@@ -614,6 +620,9 @@
   OS << "  { "
  << Overload.second << ", "
  << Overload.first->getValueAsListOfDefs("Signature").size() << ", "
+ << (Overload.first->getValueAsBit("IsPure")) << ", "
+ << (Overload.first->getValueAsBit("IsConst")) << ", "
+ << (Overload.first->getValueAsBit("IsConv")) << ", "
  << "OCLE_" << Overload.first->getValueAsDef("Extension")->getValueAsString("ID") << ", "
  << Overload.first->getValueAsDef("MinVersion")->getValueAsInt("Name") << ", "
  << Overload.first->getValueAsDef("MaxVersion")->getValueAsInt("Name")
@@ -634,7 +643,13 @@
   for (unsigned Index = 0; Index < Candidate->size(); Index++) {
 Rec   = SignatureList[Index].first;
 Rec2  = (SignatureListMap.find(Candidate)->second.first)[Index].first;
-if (Rec->getValueAsDef("MinVersion")->getValueAsInt("Name") ==
+if (Rec->getValueAsBit("IsPure") ==
+Rec2->getValueAsBit("IsPure") &&
+Rec->getValueAsBit("IsConst") ==
+Rec2->getValueAsBit("IsConst") &&
+Rec->getValueAsBit("IsConv") ==
+Rec2->getValueAsBit("IsConv") &&
+Rec->getValueAsDef("MinVersion")->getValueAsInt("Name") ==
 Rec2->getValueAsDef("MinVersion")->getValueAsInt("Name") &&
 Rec->getValueAsDef("MaxVersion")->getValueAsInt("Name") ==
 Rec2->getValueAsDef("MaxVersion")->getValueAsInt("Name") &&
Index: clang/lib/Sema/SemaLookup.cpp
===
--- clang/lib/Sema/SemaLookup.cpp
+++ clang/lib/Sema/SemaLookup.cpp
@@ -885,7 +885,19 @@
 }
 NewOpenCLBuiltin->setParams(ParmList);
   }
-  NewOpenCLBuiltin->addAttr(OverloadableAttr::CreateImplicit(Context));
+
+  // Add function attributes.
+  if (OpenCLBuiltin.IsPure)
+NewOpenCLBuiltin->addAttr(PureAttr::CreateImplicit(
+Context));
+  if (OpenCLBuiltin.IsConst)
+NewOpenCLBuiltin->addAttr(ConstAttr::CreateImplicit(
+Context));
+  if (OpenCLBuiltin.IsConv)
+NewOpenCLBuiltin->addAttr(ConvergentAttr::CreateImplicit(
+Context));
+  if (GenTypeMaxCnt > 1 || Len > 1)
+NewOpenCLBuiltin->addAttr(OverloadableAttr::CreateImplicit(Context));
 
   // Add extensions
   AddExtensions(S, OpenCLBuiltin, NewOpenCLBuiltin, Index);
Index: clang/lib/Sema/OpenCLBuiltins.td
===
--- clang/lib/Sema/OpenCLBuiltins.td
+++ clang/lib/Sema/OpenCLBuiltins.td
@@ -208,13 +208,19 @@
 //===--===//
 //  OpenCL C class for builtin functions
 //===--===//
-class Builtin _Signature> {
+class Builtin _Signature, list _Attributes = [0, 0, 0]> {
   // Name of the builtin function
   string Name = _Name;
   // List of types used by the function. The first one is the return type and
   // the following are the arguments. The list must have at least one element
   // (the return type).
   list Signature = _Signature;
+  // OpenCL attribute : __attribute__((pure))
+  bit IsPure = _Attributes[0];
+  // OpenCL attribute : __attribute__((const))
+  bit IsConst = _Attributes[1];
+  // OpenCL attribute : __attribute__((convergent))
+  bit IsConv = _Attributes[2];
   // OpenCL extensions to which the function belongs (e.g.: cl_khr_subgroups)
   FctExtension Extension = NoFctExt;
   // Version of OpenCL from which the function is available (e.g.: CL10).
@@ -322,12 +328,1

[PATCH] D64257: [clangd] Added highlighting for non-builtin types

2019-07-08 Thread Johan Vikström via Phabricator via cfe-commits
jvikstrom marked 4 inline comments as done.
jvikstrom added inline comments.



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:68
+
+TagDecl *D = TL.getTypePtr()->getAsTagDecl();
+if (!D)

hokein wrote:
> We are only interested in `TagDecl`, maybe use the `VisitTagLoc` callback, so 
> that you can get rid of the filtering code above.
With just VisitTagLoc it does not catch this case: 
```
namespace abc {
  template
  struct $Type[[A]] {};
}
abc::$Type[[A]] $Variable[[AA]];```

I guess I could add a bunch of ```Visit*TypeLoc``` methods but I can't seem to 
find the correct Visit method for the case above... 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64257



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


[PATCH] D64320: [OpenCL] Print builtin function prototypes if ambiguous

2019-07-08 Thread Pierre GONDOIS via Phabricator via cfe-commits
Pierre created this revision.
Pierre added reviewers: Anastasia, svenvh.
Pierre added projects: clang, LLVM.
Herald added subscribers: cfe-commits, kristina.

When hitting an ambigous call to a builtin function with the
-fdeclare-opencl-builtins option, diagnostics don't print the prototypes
that clash.
When not using the option above, they are displayed.
This patch prints them.

This is changing this diagnostic:

  test.cl:86:11: error: call to 'acos' is ambiguous
int a = acos(p);
^~~~
  test.cl:86:11: note: candidate function
  test.cl:86:11: note: candidate function
  [not printing everything ...]
  test.cl:86:11: note: candidate function
  1 error generated.

To this:

  test.cl:86:11: error: call to 'acos' is ambiguous
int a = acos(p);
^~~~
  test.cl:86:11: note: candidate function
  float acos(float)
  test.cl:86:11: note: candidate function
  double acos(double)
  [not printing everything ...]
  test.cl:86:11: note: candidate function
  __fp16 __attribute__((ext_vector_type(16))) acos(__fp16 
__attribute__((ext_vector_type(16
  1 error generated.


Repository:
  rC Clang

https://reviews.llvm.org/D64320

Files:
  clang/lib/Sema/SemaOverload.cpp


Index: clang/lib/Sema/SemaOverload.cpp
===
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -10425,6 +10425,25 @@
 
 // We don't really have anything else to say about viable candidates.
 S.NoteOverloadCandidate(Cand->FoundDecl, Fn);
+
+// If this is a builtin function, give the available definitions.
+if (S.getLangOpts().OpenCL && Fn->isImplicit()) {
+  raw_ostream &OS = llvm::outs();
+  unsigned NumParams = Fn->getNumParams();
+
+  OS << Fn->getReturnType().getAsString() << " ";
+  OS << Fn->getNameInfo().getAsString() << "(";
+
+  if (NumParams > 0) {
+OS << Fn->getParamDecl(0)->getOriginalType().getAsString();
+  }
+  for (unsigned i = 1; i < NumParams; i++) {
+OS << ", ";
+OS << Fn->getParamDecl(i)->getOriginalType().getAsString();
+  }
+  OS << ")\n";
+}
+
 return;
   }
 


Index: clang/lib/Sema/SemaOverload.cpp
===
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -10425,6 +10425,25 @@
 
 // We don't really have anything else to say about viable candidates.
 S.NoteOverloadCandidate(Cand->FoundDecl, Fn);
+
+// If this is a builtin function, give the available definitions.
+if (S.getLangOpts().OpenCL && Fn->isImplicit()) {
+  raw_ostream &OS = llvm::outs();
+  unsigned NumParams = Fn->getNumParams();
+
+  OS << Fn->getReturnType().getAsString() << " ";
+  OS << Fn->getNameInfo().getAsString() << "(";
+
+  if (NumParams > 0) {
+OS << Fn->getParamDecl(0)->getOriginalType().getAsString();
+  }
+  for (unsigned i = 1; i < NumParams; i++) {
+OS << ", ";
+OS << Fn->getParamDecl(i)->getOriginalType().getAsString();
+  }
+  OS << ")\n";
+}
+
 return;
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D64321: [OpenCL] Change diagnostic for function declaration

2019-07-08 Thread Pierre GONDOIS via Phabricator via cfe-commits
Pierre created this revision.
Pierre added reviewers: Anastasia, svenvh.
Pierre added projects: clang, LLVM.
Herald added a subscriber: cfe-commits.

When declaring functions only differing by their return type,
diagnostic was indicating "conflicting types for" the function.
Similarly to c++, it is now indicating that "functions that differ
only in their return type cannot be overloaded".

For this code example:

  float test (float p) {return 2.;}
  double test (float p) {return 2.;}

This is changing this diagnostic:

  tmp.cl:5:37: error: conflicting types for 'tee'
  float __attribute__((overloadable)) test (float p) {return 2.;}
  ^
  tmp.cl:4:38: note: previous definition is here
  double __attribute__((overloadable)) test (float p) {return 2.;}
   ^
  1 error generated.

To this:

  tmp.cl:5:37: error: functions that differ only in their return type cannot be 
overloaded
  float __attribute__((overloadable)) test (float p) {return 2.;}
  ~   ^
  1 error generated.

This should maybe be extended to other languages.


Repository:
  rC Clang

https://reviews.llvm.org/D64321

Files:
  clang/lib/Sema/SemaDecl.cpp


Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -3466,6 +3466,18 @@
   return false;
 
 // Fall through for conflicting redeclarations and redefinitions.
+  } else if (getLangOpts().OpenCL) {
+QualType OldDeclaredReturnType = Old->getDeclaredReturnType();
+QualType NewDeclaredReturnType = New->getDeclaredReturnType();
+
+if (!Context.hasSameType(OldDeclaredReturnType, NewDeclaredReturnType) &&
+canFullyTypeCheckRedeclaration(New, Old, NewDeclaredReturnType,
+   OldDeclaredReturnType)) {
+
+Diag(New->getLocation(), diag::err_ovl_diff_return_type)
+<< New->getReturnTypeSourceRange();
+return true;
+}
   }
 
   // C: Function types need to be compatible, not identical. This handles


Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -3466,6 +3466,18 @@
   return false;
 
 // Fall through for conflicting redeclarations and redefinitions.
+  } else if (getLangOpts().OpenCL) {
+QualType OldDeclaredReturnType = Old->getDeclaredReturnType();
+QualType NewDeclaredReturnType = New->getDeclaredReturnType();
+
+if (!Context.hasSameType(OldDeclaredReturnType, NewDeclaredReturnType) &&
+canFullyTypeCheckRedeclaration(New, Old, NewDeclaredReturnType,
+   OldDeclaredReturnType)) {
+
+Diag(New->getLocation(), diag::err_ovl_diff_return_type)
+<< New->getReturnTypeSourceRange();
+return true;
+}
   }
 
   // C: Function types need to be compatible, not identical. This handles
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D60456: [RISCV] Hard float ABI support

2019-07-08 Thread Alex Bradbury via Phabricator via cfe-commits
asb added inline comments.



Comment at: clang/lib/CodeGen/TargetInfo.cpp:9232
+if (IsFloat && Size > FLen)
+  return false;
+// Can't be eligible if an integer type was already found (only fp+int or

rjmccall wrote:
> Is this the only consideration for floating-point types?  Clang does have 
> increasing support for `half` / various `float16` types.
These types aren't supported on RISC-V currently. As the ABI hasn't really been 
explicitly confirmed, I've defaulted to the integer ABI in that case. Could 
move to an assert if you prefer, though obviously any future move to enable 
half floats for RISC-V should include ABI tests too.



Comment at: clang/lib/CodeGen/TargetInfo.cpp:9236
+if (IsInt && Field1Ty && Field1Ty->isIntegerTy())
+  return false;
+if (!Field1Ty) {

rjmccall wrote:
> The comment here is wrong because fp+fp is allowed, right?
> 
> Is this not already caught by the post-processing checks you do in 
> `detectFPCCEligibleStruct`?  Would it make more sense to just do all those 
> checks there?
Thanks, I meant to say int+int isn't eligible. Reworded to say that.

I don't think it would simplify things to do all checks in 
detectFPCCEligibleStruct. More repetition would be required in order to do 
checks on both Float1Ty and Float2Ty.



Comment at: clang/lib/CodeGen/TargetInfo.cpp:9288
+  return false;
+for (const FieldDecl *FD : RD->fields()) {
+  const ASTRecordLayout &Layout = getContext().getASTRecordLayout(RD);

rjmccall wrote:
> I really expect there to be something in this block about whether the field 
> is a bit-field.  What exactly does your ABI specify if there's a bit-field?
I've updated to handle bitfields and submitted a [pull 
request](https://github.com/riscv/riscv-elf-psabi-doc/pull/100) to the RISC-V 
psABI to improve the documentation. Unfortunately the handling of zero-width 
bitfields is a little weird, but the preference seems to be to just document 
what GCC does.


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

https://reviews.llvm.org/D60456



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


[PATCH] D63417: [RISCV] Specify registers used for exception handling

2019-07-08 Thread Alex Bradbury via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL365305: [RISCV] Specify registers used for exception 
handling (authored by asb, committed by ).
Herald added subscribers: llvm-commits, lenary, MaskRay.
Herald added a project: LLVM.

Changed prior to commit:
  https://reviews.llvm.org/D63417?vs=207769&id=208339#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D63417

Files:
  cfe/trunk/lib/Basic/Targets/RISCV.h
  cfe/trunk/test/CodeGen/builtins-riscv.c


Index: cfe/trunk/test/CodeGen/builtins-riscv.c
===
--- cfe/trunk/test/CodeGen/builtins-riscv.c
+++ cfe/trunk/test/CodeGen/builtins-riscv.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -Wall -Werror -triple riscv32 -disable-O0-optnone 
-emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s
+// RUN: %clang_cc1 -Wall -Werror -triple riscv64 -disable-O0-optnone 
-emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s
+
+void test_eh_return_data_regno() {
+  // CHECK: store volatile i32 10
+  // CHECK: store volatile i32 11
+  volatile int res;
+  res = __builtin_eh_return_data_regno(0);
+  res = __builtin_eh_return_data_regno(1);
+}
Index: cfe/trunk/lib/Basic/Targets/RISCV.h
===
--- cfe/trunk/lib/Basic/Targets/RISCV.h
+++ cfe/trunk/lib/Basic/Targets/RISCV.h
@@ -57,6 +57,15 @@
 
   ArrayRef getGCCRegNames() const override;
 
+  int getEHDataRegisterNumber(unsigned RegNo) const override {
+if (RegNo == 0)
+  return 10;
+else if (RegNo == 1)
+  return 11;
+else
+  return -1;
+  }
+
   ArrayRef getGCCRegAliases() const override;
 
   bool validateAsmConstraint(const char *&Name,


Index: cfe/trunk/test/CodeGen/builtins-riscv.c
===
--- cfe/trunk/test/CodeGen/builtins-riscv.c
+++ cfe/trunk/test/CodeGen/builtins-riscv.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -Wall -Werror -triple riscv32 -disable-O0-optnone -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s
+// RUN: %clang_cc1 -Wall -Werror -triple riscv64 -disable-O0-optnone -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s
+
+void test_eh_return_data_regno() {
+  // CHECK: store volatile i32 10
+  // CHECK: store volatile i32 11
+  volatile int res;
+  res = __builtin_eh_return_data_regno(0);
+  res = __builtin_eh_return_data_regno(1);
+}
Index: cfe/trunk/lib/Basic/Targets/RISCV.h
===
--- cfe/trunk/lib/Basic/Targets/RISCV.h
+++ cfe/trunk/lib/Basic/Targets/RISCV.h
@@ -57,6 +57,15 @@
 
   ArrayRef getGCCRegNames() const override;
 
+  int getEHDataRegisterNumber(unsigned RegNo) const override {
+if (RegNo == 0)
+  return 10;
+else if (RegNo == 1)
+  return 11;
+else
+  return -1;
+  }
+
   ArrayRef getGCCRegAliases() const override;
 
   bool validateAsmConstraint(const char *&Name,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D60456: [RISCV] Hard float ABI support

2019-07-08 Thread Roger Ferrer Ibanez via Phabricator via cfe-commits
rogfer01 added inline comments.



Comment at: clang/lib/CodeGen/TargetInfo.cpp:9352
+return false;
+  // As a quirk of the ABI, zero-width bitfields aren't ignored for fp+fp
+  // or int+fp structs, but are ignored for a struct with an fp field and

I found some mismatch in behaviour between gcc and g++ that we may want to 
address in the psABI first.

For instance, given the following struct (I'm using gcc 8.3.0)

```lang=cpp
// t.c
struct A
{
  int :0;
  double d;
  int :0;
  long x;
  int :0;
};

extern void bar(struct A);
void foo(struct A a)
{
  a.d =- a.d;
  a.x += 1;
  return bar(a);
}
```

we are emitting this

```
$ clang --target=riscv64 -march=rv64gc -mabi=lp64d -S -o-  t.c -O2  
...
foo:# @foo
# %bb.0:# %entry
addia2, zero, -1
sllia2, a2, 63
xor a0, a0, a2
addia1, a1, 1
tailbar
```

which matches with what g++ does (i.e in both cases `a0` is `a.d` and `a1` is 
`a.x`)

```
$ ./riscv64-unknown-linux-gnu-g++ -S -O2 -o- -x c test.cc
...
foo:
fmv.d.x fa5,a0
addisp,sp,-16
fneg.d  fa5,fa5
addia1,a1,1
addisp,sp,16
fmv.x.d a0,fa5
tailbar
```

But I found a mismatch while using C++. Clang emits the same for C and C++ 
(modulo `.cfi` stuff)

```
$ clang --target=riscv64 -march=rv64gc -mabi=lp64d -S -o-  -x c++ t.c -O2  
_Z3foo1A:   # @_Z3foo1A
.cfi_startproc
# %bb.0:# %entry
addia2, zero, -1
sllia2, a2, 63
xor a0, a0, a2
addia1, a1, 1
.cfi_def_cfa_offset 0
tail_Z3bar1A
```

But g++ seems to ignore the zero-width bitfields: `fa0` is  `a.d` and `a0` is 
`a.x`

```
$ riscv64-unknown-linux-gnu-g++  -S -O2 -x c++ t.c -o-
...
_Z3foo1A:
.LFB0:
.cfi_startproc
fneg.d  fa0,fa0
addisp,sp,-16
.cfi_def_cfa_offset 16
addia0,a0,1
addisp,sp,16
.cfi_def_cfa_offset 0
tail_Z3bar1A
.cfi_endproc
```

This is a bit worrying as it might complicate interoperability between C and 
C++ (I tried wrapping everything inside an `extern "C"` just in case but it 
didn't change g++'s behaviour).

Do you mind to confirm this issue?



Comment at: clang/lib/CodeGen/TargetInfo.cpp:9394
+// Call getCoerceAndExpand for the two-element flattened struct described by
+// Field1Ty, Filed2Ty, Filed2Off. This method will create an appropriate
+// coerceToType and unpaddedCoerceToType.

Typo  in `Filed2Ty` and `Filed2Off`


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

https://reviews.llvm.org/D60456



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


[PATCH] D60456: [RISCV] Hard float ABI support

2019-07-08 Thread Alex Bradbury via Phabricator via cfe-commits
asb updated this revision to Diff 208308.
asb marked 7 inline comments as done.
asb retitled this revision from "[RISCV][WIP/RFC] Hard float ABI support" to 
"[RISCV] Hard float ABI support".
asb edited the summary of this revision.
asb added a comment.
Herald added subscribers: lenary, Jim, MaskRay.

Address all review comments from @rjmccall. Bitfield handling matches observed 
behaviour of GCC and I have an active PR 
 to properly document 
this in the RISC-V psabi. Tests are updated to check this behaviour.

Many thanks for the review comments - do you think this is ready to land?


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

https://reviews.llvm.org/D60456

Files:
  clang/lib/Basic/Targets/RISCV.cpp
  clang/lib/Basic/Targets/RISCV.h
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGen/riscv32-ilp32-ilp32f-abi.c
  clang/test/CodeGen/riscv32-ilp32-ilp32f-ilp32d-abi.c
  clang/test/CodeGen/riscv32-ilp32d-abi.c
  clang/test/CodeGen/riscv32-ilp32f-abi.c
  clang/test/CodeGen/riscv32-ilp32f-ilp32d-abi.c
  clang/test/CodeGen/riscv64-lp64-lp64f-abi.c
  clang/test/CodeGen/riscv64-lp64-lp64f-lp64d-abi.c
  clang/test/CodeGen/riscv64-lp64d-abi.c
  clang/test/CodeGen/riscv64-lp64f-lp64d-abi.c
  clang/test/Preprocessor/riscv-target-features.c

Index: clang/test/Preprocessor/riscv-target-features.c
===
--- clang/test/Preprocessor/riscv-target-features.c
+++ clang/test/Preprocessor/riscv-target-features.c
@@ -47,3 +47,27 @@
 // RUN: %clang -target riscv64-unknown-linux-gnu -march=rv64ic -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-C-EXT %s
 // CHECK-C-EXT: __riscv_compressed 1
+
+// RUN: %clang -target riscv32-unknown-linux-gnu -march=rv32ifd -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-SOFT %s
+// RUN: %clang -target riscv64-unknown-linux-gnu -march=rv64ifd -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-SOFT %s
+// CHECK-SOFT: __riscv_float_abi_soft 1
+// CHECK-SOFT-NOT: __riscv_float_abi_single
+// CHECK-SOFT-NOT: __riscv_float_abi_double
+
+// RUN: %clang -target riscv32-unknown-linux-gnu -march=rv32ifd -mabi=ilp32f -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-SINGLE %s
+// RUN: %clang -target riscv64-unknown-linux-gnu -march=rv64ifd -mabi=lp64f -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-SINGLE %s
+// CHECK-SINGLE: __riscv_float_abi_single 1
+// CHECK-SINGLE-NOT: __riscv_float_abi_soft
+// CHECK-SINGLE-NOT: __riscv_float_abi_double
+
+// RUN: %clang -target riscv32-unknown-linux-gnu -march=rv32ifd -mabi=ilp32f -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-DOUBLE %s
+// RUN: %clang -target riscv64-unknown-linux-gnu -march=rv64ifd -mabi=lp64f -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-DOUBLE %s
+// CHECK-DOUBLE: __riscv_float_abi_double 1
+// CHECK-DOUBLE-NOT: __riscv_float_abi_soft
+// CHECK-DOUBLE-NOT: __riscv_float_abi_single
Index: clang/test/CodeGen/riscv64-lp64f-lp64d-abi.c
===
--- /dev/null
+++ clang/test/CodeGen/riscv64-lp64f-lp64d-abi.c
@@ -0,0 +1,265 @@
+// RUN: %clang_cc1 -triple riscv64 -target-feature +f -target-abi lp64f -emit-llvm %s -o - \
+// RUN: | FileCheck %s
+// RUN: %clang_cc1 -triple riscv64 -target-feature +d -target-abi lp64d -emit-llvm %s -o - \
+// RUN: | FileCheck %s
+
+#include 
+
+// Verify that the tracking of used GPRs and FPRs works correctly by checking
+// that small integers are sign/zero extended when passed in registers.
+
+// Floats are passed in FPRs, so argument 'i' will be passed zero-extended
+// because it will be passed in a GPR.
+
+// CHECK: define void @f_fpr_tracking(float %a, float %b, float %c, float %d, float %e, float %f, float %g, float %h, i8 zeroext %i)
+void f_fpr_tracking(float a, float b, float c, float d, float e, float f,
+float g, float h, uint8_t i) {}
+
+// Check that fp, fp+fp, and int+fp structs are lowered correctly. These will
+// be passed in FPR, FPR+FPR, or GPR+FPR regs if sufficient registers are
+// available the widths are <= XLEN and FLEN, and should be expanded to
+// separate arguments in IR. They are passed by the same rules for returns,
+// but will be lowered to simple two-element structs if necessary (as LLVM IR
+// functions cannot return multiple values).
+
+// A struct containing just one floating-point real is passed as though it
+// were a standalone floating-point real.
+
+struct float_s { float f; };
+
+// CHECK: define void @f_float_s_arg(float)
+void f_float_s_arg(struct float_s a) {}
+
+// CHECK: define float @f_ret_float_s()
+struct float_s f_ret_float_s() {
+  return (struct float_s){1.0};
+}
+
+// A struct containing a float and any number of zero-width bitfields is
+// passed as though it were a standalone floating-point real.
+
+struct zbf_float_s { int : 0; flo

[PATCH] D64256: Teach some warnings to respect gsl::Pointer and gsl::Owner attributes

2019-07-08 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr added inline comments.



Comment at: clang/lib/Sema/SemaInit.cpp:6510
 LifetimeBoundCall,
+LifetimePointerInit,
+LifetimeTempOwner

What is this name supposed to mean? Initialization of a "lifetime pointer"? 
What's a "lifetime pointer"?

If you were imitating "LifetimeBoundCall", it is a reference to the attribute: 
https://clang.llvm.org/docs/AttributeReference.html#lifetimebound .



Comment at: clang/lib/Sema/SemaInit.cpp:6587
+
 static void visitLifetimeBoundArguments(IndirectLocalPath &Path, Expr *Call,
 LocalVisitor Visit) {

I feel like the code would be better off if we defined another function for 
handling gsl::Pointer semantics.

This function is for clang::lifetimebound, and mixing the logic is confusing 
IMO.



Comment at: clang/lib/Sema/SemaInit.cpp:7049
 
+// Skipping a chain of initializing lifetime Pointer objects.
+// We are looking only for the final value to find out if it was

Sorry, I can't parse this: "... initializing lifetime Pointer ..."



Comment at: clang/test/Sema/warn-lifetime-analysis-nocfg.cpp:10
+struct [[gsl::Pointer(int)]] MyPointer {
+  MyPointer(int *p = 0);
+  MyPointer(const MyOwner &);

`= nullptr`



Comment at: clang/test/Sema/warn-lifetime-analysis-nocfg.cpp:16
+
+struct [[gsl::Owner(int)]] T {
+  T();

Can `T` and `MyOwner` be the same type?

It is confusing to have two -- for example, `toOwner()` returning `T` instead 
of `MyOwner` is confusing.



Comment at: clang/test/Sema/warn-lifetime-analysis-nocfg.cpp:20
+  int &operator*();
+  MyPointer release();
+  int *release2();

"ReleaseAsMyPointer'



Comment at: clang/test/Sema/warn-lifetime-analysis-nocfg.cpp:21
+  MyPointer release();
+  int *release2();
+  int *c_str() const;

"ReleaseAsRawPointer"



Comment at: clang/test/Sema/warn-lifetime-analysis-nocfg.cpp:22
+  int *release2();
+  int *c_str() const;
+};

This method is confusing -- is it a name that the warning is supposed to know 
about?



Comment at: clang/test/Sema/warn-lifetime-analysis-nocfg.cpp:25
+
+void f() {
+  new MyPointer(T{}); // expected-warning {{object backing the pointer will be 
destroyed at the end of the full-expression}}

It would be helpful to rename this test function and other functions below 
according to what they test.

`f`, `g`, `g2`, `i`, `i2` -- unclear what the test is supposed to be about, and 
why tests are grouped like that.



Comment at: clang/test/Sema/warn-lifetime-analysis-nocfg.cpp:33
+  MyPointer p{&i}; // ok
+  new MyPointer(MyPointer{p}); // ok
+}

Why is the last line OK? Looks like a false negative to me -- the pointer on 
the heap is pointing to a local variable, just like in `f`, which produces a 
warning.

If it is an intentional false negative, please annotate it as such in comments.



Comment at: clang/test/Sema/warn-lifetime-analysis-nocfg.cpp:38
+  T t;
+  return t.release(); // ok
+}

Is "release" a magic name that the warning understands?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64256



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


[PATCH] D64257: [clangd] Added highlighting for non-builtin types

2019-07-08 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:68
+
+TagDecl *D = TL.getTypePtr()->getAsTagDecl();
+if (!D)

jvikstrom wrote:
> hokein wrote:
> > We are only interested in `TagDecl`, maybe use the `VisitTagLoc` callback, 
> > so that you can get rid of the filtering code above.
> With just VisitTagLoc it does not catch this case: 
> ```
> namespace abc {
>   template
>   struct $Type[[A]] {};
> }
> abc::$Type[[A]] $Variable[[AA]];```
> 
> I guess I could add a bunch of ```Visit*TypeLoc``` methods but I can't seem 
> to find the correct Visit method for the case above... 
Your logic seems sound to me, but please add a comment like "This covers 
classes, class templates, etc"



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:99
 }
+if(isa(D)) {
+  addToken(Loc, HighlightingKind::Type);

hokein wrote:
> nit: clang-format
RecordDecl, unless you're trying to distinguish C++ from C for some reason



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:61
+  bool VisitTypeLoc(TypeLoc &TL) {
+// The check for DependentName is so namespace qualifiers are not
+// highlighted. The check for elaborated type is for not getting two 
entries

should you highlight DependentNameTypeLoc::getNameLoc()? (As some generic 
"type" rather than "class" as we can't resolve the name) Or is the unqualified 
name highlighted by traversing some other node?



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:62
+// The check for DependentName is so namespace qualifiers are not
+// highlighted. The check for elaborated type is for not getting two 
entries
+// whenever there is an anonymous struct.

Nit: consider splitting this || into two statements so you can comment each.

The comments should ideally say what drives the actual behavior in this 
situation, e.g. "For elaborated types, the underlying type will be highlighted 
when visiting the inner typeloc"



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:70
+TagDecl *D = TL.getTypePtr()->getAsTagDecl();
+if (!D)
+  return true;

The patch description says "non-builtin types".

It's fine to just handle tag types (struct class enum union) in this patch, but 
there are other cases you may want to handle later (e.g. typedefs/using).

Random thought for the future: you could highlight `auto` differently based on 
the actual underlying type (e.g. class vs enum vs pointer...) 



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:73
+
+if (const auto *RD = dyn_cast(D)) {
+  if (const auto *DC = RD->getDestructor()) {

This code is doing something really weird: you've seen a mention of a class, 
now you're checking to see if the destructor's declaration encloses the mention 
so you can not highlight it.

First, I'm not convinced highlighting it is bad or worth any complexity to 
avoid, happy to discuss further.

Second, this will get a bunch of cases wrong:
 - a call to the destructor (`a->~Foo()`) will still be highligthed
 - the out-of-line definition of the destructor (`Foo::~Foo() { ... }`) will 
still be highlighted
 - a (separate) mention of the class name within the body of the destructor 
(defined inline) will not be highlighted



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:100
 }
+if (isa(D)) {
+  addToken(Loc, HighlightingKind::Class);

consider implementing `enum` in this patch too: it's a TagDecl so you've 
already done almost all the work, just need to add another if here


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64257



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


[clang-tools-extra] r365311 - [clangd] Use xxhash instead of SHA1 for background index file digests.

2019-07-08 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Mon Jul  8 04:33:17 2019
New Revision: 365311

URL: http://llvm.org/viewvc/llvm-project?rev=365311&view=rev
Log:
[clangd] Use xxhash instead of SHA1 for background index file digests.

Summary:
Currently SHA1 is about 10% of our CPU, this patch reduces it to ~1%.

xxhash is a well-defined (stable) non-cryptographic hash optimized for
fast checksums (like crc32).
Collisions shouldn't be a problem, despite the reduced length:
 - for actual file content (used to invalidate bg index shards), there
   are only two versions that can collide (new shard and old shard).
 - for file paths in bg index shard filenames, we would need 2^32 files
   with the same filename to expect a collision. Imperfect hashing may
   reduce this a bit but it's well beyond what's plausible.

This will invalidate shards on disk (as usual; I bumped the version),
but this time the filenames are changing so the old files will stick
around :-( So this is more expensive than the usual bump, but would be
good to land before the v9 branch when everyone will start using bg index.

Reviewers: kadircet

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

Tags: #llvm

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

Modified:
clang-tools-extra/trunk/clangd/SourceCode.cpp
clang-tools-extra/trunk/clangd/SourceCode.h
clang-tools-extra/trunk/clangd/index/Background.cpp
clang-tools-extra/trunk/clangd/index/Background.h
clang-tools-extra/trunk/clangd/index/BackgroundIndexStorage.cpp
clang-tools-extra/trunk/clangd/index/Serialization.cpp
clang-tools-extra/trunk/clangd/unittests/SerializationTests.cpp

Modified: clang-tools-extra/trunk/clangd/SourceCode.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/SourceCode.cpp?rev=365311&r1=365310&r2=365311&view=diff
==
--- clang-tools-extra/trunk/clangd/SourceCode.cpp (original)
+++ clang-tools-extra/trunk/clangd/SourceCode.cpp Mon Jul  8 04:33:17 2019
@@ -25,6 +25,7 @@
 #include "llvm/Support/Error.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/Path.h"
+#include "llvm/Support/xxhash.h"
 #include 
 
 namespace clang {
@@ -376,7 +377,13 @@ bool isRangeConsecutive(const Range &Lef
 }
 
 FileDigest digest(llvm::StringRef Content) {
-  return llvm::SHA1::hash({(const uint8_t *)Content.data(), Content.size()});
+  uint64_t Hash{llvm::xxHash64(Content)};
+  FileDigest Result;
+  for (unsigned I = 0; I < Result.size(); ++I) {
+Result[I] = uint8_t(Hash);
+Hash >>= 8;
+  }
+  return Result;
 }
 
 llvm::Optional digestFile(const SourceManager &SM, FileID FID) {

Modified: clang-tools-extra/trunk/clangd/SourceCode.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/SourceCode.h?rev=365311&r1=365310&r2=365311&view=diff
==
--- clang-tools-extra/trunk/clangd/SourceCode.h (original)
+++ clang-tools-extra/trunk/clangd/SourceCode.h Mon Jul  8 04:33:17 2019
@@ -22,7 +22,6 @@
 #include "clang/Tooling/Core/Replacement.h"
 #include "llvm/ADT/StringSet.h"
 #include "llvm/ADT/StringRef.h"
-#include "llvm/Support/SHA1.h"
 
 namespace clang {
 class SourceManager;
@@ -32,7 +31,7 @@ namespace clangd {
 // We tend to generate digests for source codes in a lot of different places.
 // This represents the type for those digests to prevent us hard coding details
 // of hashing function at every place that needs to store this information.
-using FileDigest = decltype(llvm::SHA1::hash({}));
+using FileDigest = std::array;
 FileDigest digest(StringRef Content);
 Optional digestFile(const SourceManager &SM, FileID FID);
 

Modified: clang-tools-extra/trunk/clangd/index/Background.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/Background.cpp?rev=365311&r1=365310&r2=365311&view=diff
==
--- clang-tools-extra/trunk/clangd/index/Background.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/Background.cpp Mon Jul  8 04:33:17 2019
@@ -32,7 +32,6 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/StringSet.h"
 #include "llvm/Support/Error.h"
-#include "llvm/Support/SHA1.h"
 #include "llvm/Support/Threading.h"
 
 #include 

Modified: clang-tools-extra/trunk/clangd/index/Background.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/Background.h?rev=365311&r1=365310&r2=365311&view=diff
==
--- clang-tools-extra/trunk/clangd/index/Background.h (original)
+++ clang-tools-extra/trunk/clangd/index/Background.h Mon Jul  8 04:33:17 2019
@@ -19,7 +19,6 @@
 #include "index/Serialization.h"
 #include "clang/Tooling/CompilationDatabase.h"
 #include "llvm/ADT/StringMap.h"
-#include "llvm/Support/SHA1.h"
 #include "llvm/Support/Threading.h"
 #inc

r365314 - [analyzer] Add analyzer option to limit the number of imported TUs

2019-07-08 Thread Endre Fulop via cfe-commits
Author: gamesh411
Date: Mon Jul  8 05:37:10 2019
New Revision: 365314

URL: http://llvm.org/viewvc/llvm-project?rev=365314&view=rev
Log:
[analyzer] Add analyzer option to limit the number of imported TUs

Summary:
During CTU analysis of complex projects, the loaded AST-contents of
imported TUs can grow bigger than available system memory. This option
introduces a threshold on the number of TUs to be imported for a single
TU in order to prevent such cases.

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

Added:
cfe/trunk/test/Analysis/ctu-import-threshold.c
Modified:
cfe/trunk/include/clang/CrossTU/CrossTranslationUnit.h
cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
cfe/trunk/lib/CrossTU/CrossTranslationUnit.cpp
cfe/trunk/test/Analysis/analyzer-config.c
cfe/trunk/unittests/CrossTU/CrossTranslationUnitTest.cpp

Modified: cfe/trunk/include/clang/CrossTU/CrossTranslationUnit.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/CrossTU/CrossTranslationUnit.h?rev=365314&r1=365313&r2=365314&view=diff
==
--- cfe/trunk/include/clang/CrossTU/CrossTranslationUnit.h (original)
+++ cfe/trunk/include/clang/CrossTU/CrossTranslationUnit.h Mon Jul  8 05:37:10 
2019
@@ -45,7 +45,8 @@ enum class index_error_code {
   failed_to_generate_usr,
   triple_mismatch,
   lang_mismatch,
-  lang_dialect_mismatch
+  lang_dialect_mismatch,
+  load_threshold_reached
 };
 
 class IndexError : public llvm::ErrorInfo {
@@ -134,7 +135,8 @@ public:
   /// A definition with the same declaration will be looked up in the
   /// index file which should be in the \p CrossTUDir directory, called
   /// \p IndexName. In case the declaration is found in the index the
-  /// corresponding AST file will be loaded.
+  /// corresponding AST file will be loaded. If the number of TUs imported
+  /// reaches \p CTULoadTreshold, no loading is performed.
   ///
   /// \return Returns a pointer to the ASTUnit that contains the definition of
   /// the looked up name or an Error.
@@ -182,6 +184,10 @@ private:
   CompilerInstance &CI;
   ASTContext &Context;
   std::shared_ptr ImporterSharedSt;
+  /// \p CTULoadTreshold should serve as an upper limit to the number of TUs
+  /// imported in order to reduce the memory footprint of CTU analysis.
+  const unsigned CTULoadThreshold;
+  unsigned NumASTLoaded{0u};
 };
 
 } // namespace cross_tu

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def?rev=365314&r1=365313&r2=365314&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def Mon Jul  8 
05:37:10 2019
@@ -300,6 +300,14 @@ ANALYZER_OPTION(bool, ShouldTrackConditi
 "Whether to place an event at each tracked condition.",
 false)
 
+ANALYZER_OPTION(unsigned, CTUImportThreshold, "ctu-import-threshold",
+"The maximal amount of translation units that is considered "
+"for import when inlining functions during CTU analysis. "
+"Lowering this threshold can alleviate the memory burder of "
+"analysis with many interdependent definitions located in "
+"various translation units.",
+100u)
+
 
//===--===//
 // Unsinged analyzer options.
 
//===--===//

Modified: cfe/trunk/lib/CrossTU/CrossTranslationUnit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CrossTU/CrossTranslationUnit.cpp?rev=365314&r1=365313&r2=365314&view=diff
==
--- cfe/trunk/lib/CrossTU/CrossTranslationUnit.cpp (original)
+++ cfe/trunk/lib/CrossTU/CrossTranslationUnit.cpp Mon Jul  8 05:37:10 2019
@@ -47,6 +47,8 @@ STATISTIC(NumNameConflicts, "The # of im
 STATISTIC(NumTripleMismatch, "The # of triple mismatches");
 STATISTIC(NumLangMismatch, "The # of language mismatches");
 STATISTIC(NumLangDialectMismatch, "The # of language dialect mismatches");
+STATISTIC(NumASTLoadThresholdReached,
+  "The # of ASTs not loaded because of threshold");
 
 // Same as Triple's equality operator, but we check a field only if that is
 // known in both instances.
@@ -106,6 +108,8 @@ public:
   return "Language mismatch";
 case index_error_code::lang_dialect_mismatch:
   return "Language dialect mismatch";
+case index_error_code::load_threshold_reached:
+  return "Load threshold reached";
 }
 llvm_unreachable("Unrecognized index_error_code.");
   }
@@ -184,7 +188,8 @@ template  static bool hasBod
 }
 
 CrossT

[PATCH] D59798: [analyzer] Add analyzer option to limit the number of imported TUs

2019-07-08 Thread Endre Fülöp via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL365314: [analyzer] Add analyzer option to limit the number 
of imported TUs (authored by gamesh411, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D59798?vs=207712&id=208375#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D59798

Files:
  cfe/trunk/include/clang/CrossTU/CrossTranslationUnit.h
  cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
  cfe/trunk/lib/CrossTU/CrossTranslationUnit.cpp
  cfe/trunk/test/Analysis/analyzer-config.c
  cfe/trunk/test/Analysis/ctu-import-threshold.c
  cfe/trunk/unittests/CrossTU/CrossTranslationUnitTest.cpp

Index: cfe/trunk/include/clang/CrossTU/CrossTranslationUnit.h
===
--- cfe/trunk/include/clang/CrossTU/CrossTranslationUnit.h
+++ cfe/trunk/include/clang/CrossTU/CrossTranslationUnit.h
@@ -45,7 +45,8 @@
   failed_to_generate_usr,
   triple_mismatch,
   lang_mismatch,
-  lang_dialect_mismatch
+  lang_dialect_mismatch,
+  load_threshold_reached
 };
 
 class IndexError : public llvm::ErrorInfo {
@@ -134,7 +135,8 @@
   /// A definition with the same declaration will be looked up in the
   /// index file which should be in the \p CrossTUDir directory, called
   /// \p IndexName. In case the declaration is found in the index the
-  /// corresponding AST file will be loaded.
+  /// corresponding AST file will be loaded. If the number of TUs imported
+  /// reaches \p CTULoadTreshold, no loading is performed.
   ///
   /// \return Returns a pointer to the ASTUnit that contains the definition of
   /// the looked up name or an Error.
@@ -182,6 +184,10 @@
   CompilerInstance &CI;
   ASTContext &Context;
   std::shared_ptr ImporterSharedSt;
+  /// \p CTULoadTreshold should serve as an upper limit to the number of TUs
+  /// imported in order to reduce the memory footprint of CTU analysis.
+  const unsigned CTULoadThreshold;
+  unsigned NumASTLoaded{0u};
 };
 
 } // namespace cross_tu
Index: cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
===
--- cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
@@ -300,6 +300,14 @@
 "Whether to place an event at each tracked condition.",
 false)
 
+ANALYZER_OPTION(unsigned, CTUImportThreshold, "ctu-import-threshold",
+"The maximal amount of translation units that is considered "
+"for import when inlining functions during CTU analysis. "
+"Lowering this threshold can alleviate the memory burder of "
+"analysis with many interdependent definitions located in "
+"various translation units.",
+100u)
+
 //===--===//
 // Unsinged analyzer options.
 //===--===//
Index: cfe/trunk/test/Analysis/ctu-import-threshold.c
===
--- cfe/trunk/test/Analysis/ctu-import-threshold.c
+++ cfe/trunk/test/Analysis/ctu-import-threshold.c
@@ -0,0 +1,5 @@
+// Ensure analyzer option 'ctu-import-threshold' is a recognized option.
+//
+// RUN: %clang_cc1 -analyze -analyzer-config ctu-import-threshold=30 -verify %s
+//
+// expected-no-diagnostics
Index: cfe/trunk/test/Analysis/analyzer-config.c
===
--- cfe/trunk/test/Analysis/analyzer-config.c
+++ cfe/trunk/test/Analysis/analyzer-config.c
@@ -27,6 +27,7 @@
 // CHECK-NEXT: cplusplus.Move:WarnOn = KnownsAndLocals
 // CHECK-NEXT: crosscheck-with-z3 = false
 // CHECK-NEXT: ctu-dir = ""
+// CHECK-NEXT: ctu-import-threshold = 100
 // CHECK-NEXT: ctu-index-name = externalDefMap.txt
 // CHECK-NEXT: debug.AnalysisOrder:* = false
 // CHECK-NEXT: debug.AnalysisOrder:Bind = false
@@ -90,4 +91,4 @@
 // CHECK-NEXT: unroll-loops = false
 // CHECK-NEXT: widen-loops = false
 // CHECK-NEXT: [stats]
-// CHECK-NEXT: num-entries = 87
+// CHECK-NEXT: num-entries = 88
Index: cfe/trunk/lib/CrossTU/CrossTranslationUnit.cpp
===
--- cfe/trunk/lib/CrossTU/CrossTranslationUnit.cpp
+++ cfe/trunk/lib/CrossTU/CrossTranslationUnit.cpp
@@ -47,6 +47,8 @@
 STATISTIC(NumTripleMismatch, "The # of triple mismatches");
 STATISTIC(NumLangMismatch, "The # of language mismatches");
 STATISTIC(NumLangDialectMismatch, "The # of language dialect mismatches");
+STATISTIC(NumASTLoadThresholdReached,
+  "The # of ASTs not loaded because of threshold");
 
 // Same as Triple's equality operator, but we check a field only if that is
 //

r365315 - [ASTImporter] Fix import of lambda in function param

2019-07-08 Thread Gabor Marton via cfe-commits
Author: martong
Date: Mon Jul  8 05:49:13 2019
New Revision: 365315

URL: http://llvm.org/viewvc/llvm-project?rev=365315&view=rev
Log:
[ASTImporter] Fix import of lambda in function param

Summary:
The current import implementation fails to import the definition of a
lambda class if the lambda class is defined in a function param.
E.g., the lambda class below will be imported without any methods:
```
  template 
  void f(F L = [](){}) {}
```

Reviewers: a_sidorin, a.sidorin, shafik

Subscribers: rnkovacs, dkrupp, Szelethus, gamesh411, cfe-commits

Tags: #clang

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

Modified:
cfe/trunk/lib/AST/ASTImporter.cpp
cfe/trunk/unittests/AST/ASTImporterTest.cpp

Modified: cfe/trunk/lib/AST/ASTImporter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTImporter.cpp?rev=365315&r1=365314&r2=365315&view=diff
==
--- cfe/trunk/lib/AST/ASTImporter.cpp (original)
+++ cfe/trunk/lib/AST/ASTImporter.cpp Mon Jul  8 05:49:13 2019
@@ -1708,8 +1708,18 @@ static Error setTypedefNameForAnonDecl(T
 Error ASTNodeImporter::ImportDefinition(
 RecordDecl *From, RecordDecl *To, ImportDefinitionKind Kind) {
   if (To->getDefinition() || To->isBeingDefined()) {
-if (Kind == IDK_Everything)
-  return ImportDeclContext(From, /*ForceImport=*/true);
+if (Kind == IDK_Everything ||
+// In case of lambdas, the class already has a definition ptr set, but
+// the contained decls are not imported yet. Also, isBeingDefined was
+// set in CXXRecordDecl::CreateLambda.  We must import the contained
+// decls here and finish the definition.
+(To->isLambda() && shouldForceImportDeclContext(Kind))) {
+  Error Result = ImportDeclContext(From, /*ForceImport=*/true);
+  // Finish the definition of the lambda, set isBeingDefined to false.
+  if (To->isLambda())
+To->completeDefinition();
+  return Result;
+}
 
 return Error::success();
   }
@@ -7422,19 +7432,10 @@ ExpectedStmt ASTNodeImporter::VisitLambd
 return ToClassOrErr.takeError();
   CXXRecordDecl *ToClass = *ToClassOrErr;
 
-  // NOTE: lambda classes are created with BeingDefined flag set up.
-  // It means that ImportDefinition doesn't work for them and we should fill it
-  // manually.
-  if (ToClass->isBeingDefined())
-if (Error Err = ImportDeclContext(FromClass, /*ForceImport = */ true))
-  return std::move(Err);
-
   auto ToCallOpOrErr = import(E->getCallOperator());
   if (!ToCallOpOrErr)
 return ToCallOpOrErr.takeError();
 
-  ToClass->completeDefinition();
-
   SmallVector ToCaptures;
   ToCaptures.reserve(E->capture_size());
   for (const auto &FromCapture : E->captures()) {

Modified: cfe/trunk/unittests/AST/ASTImporterTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/AST/ASTImporterTest.cpp?rev=365315&r1=365314&r2=365315&view=diff
==
--- cfe/trunk/unittests/AST/ASTImporterTest.cpp (original)
+++ cfe/trunk/unittests/AST/ASTImporterTest.cpp Mon Jul  8 05:49:13 2019
@@ -5083,6 +5083,45 @@ INSTANTIATE_TEST_CASE_P(ParameterizedTes
 INSTANTIATE_TEST_CASE_P(ParameterizedTests, CanonicalRedeclChain,
 ::testing::Values(ArgVector()), );
 
+TEST_P(ASTImporterOptionSpecificTestBase, LambdaInFunctionBody) {
+  Decl *FromTU = getTuDecl(
+  R"(
+  void f() {
+auto L = [](){};
+  }
+  )",
+  Lang_CXX11, "input0.cc");
+  auto Pattern = lambdaExpr();
+  CXXRecordDecl *FromL =
+  FirstDeclMatcher().match(FromTU, Pattern)->getLambdaClass();
+
+  auto ToL = Import(FromL, Lang_CXX11);
+  unsigned ToLSize = std::distance(ToL->decls().begin(), ToL->decls().end());
+  unsigned FromLSize =
+  std::distance(FromL->decls().begin(), FromL->decls().end());
+  EXPECT_NE(ToLSize, 0u);
+  EXPECT_EQ(ToLSize, FromLSize);
+}
+
+TEST_P(ASTImporterOptionSpecificTestBase, LambdaInFunctionParam) {
+  Decl *FromTU = getTuDecl(
+  R"(
+  template 
+  void f(F L = [](){}) {}
+  )",
+  Lang_CXX11, "input0.cc");
+  auto Pattern = lambdaExpr();
+  CXXRecordDecl *FromL =
+  FirstDeclMatcher().match(FromTU, Pattern)->getLambdaClass();
+
+  auto ToL = Import(FromL, Lang_CXX11);
+  unsigned ToLSize = std::distance(ToL->decls().begin(), ToL->decls().end());
+  unsigned FromLSize =
+  std::distance(FromL->decls().begin(), FromL->decls().end());
+  EXPECT_NE(ToLSize, 0u);
+  EXPECT_EQ(ToLSize, FromLSize);
+}
+
 INSTANTIATE_TEST_CASE_P(ParameterizedTests, ASTImporterLookupTableTest,
 DefaultTestValuesForRunOptions, );
 


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


[PATCH] D64073: [ASTImporter] Fix import of lambda in function param

2019-07-08 Thread Gabor Marton via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL365315: [ASTImporter] Fix import of lambda in function param 
(authored by martong, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D64073?vs=207776&id=208377#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D64073

Files:
  cfe/trunk/lib/AST/ASTImporter.cpp
  cfe/trunk/unittests/AST/ASTImporterTest.cpp


Index: cfe/trunk/lib/AST/ASTImporter.cpp
===
--- cfe/trunk/lib/AST/ASTImporter.cpp
+++ cfe/trunk/lib/AST/ASTImporter.cpp
@@ -1708,8 +1708,18 @@
 Error ASTNodeImporter::ImportDefinition(
 RecordDecl *From, RecordDecl *To, ImportDefinitionKind Kind) {
   if (To->getDefinition() || To->isBeingDefined()) {
-if (Kind == IDK_Everything)
-  return ImportDeclContext(From, /*ForceImport=*/true);
+if (Kind == IDK_Everything ||
+// In case of lambdas, the class already has a definition ptr set, but
+// the contained decls are not imported yet. Also, isBeingDefined was
+// set in CXXRecordDecl::CreateLambda.  We must import the contained
+// decls here and finish the definition.
+(To->isLambda() && shouldForceImportDeclContext(Kind))) {
+  Error Result = ImportDeclContext(From, /*ForceImport=*/true);
+  // Finish the definition of the lambda, set isBeingDefined to false.
+  if (To->isLambda())
+To->completeDefinition();
+  return Result;
+}
 
 return Error::success();
   }
@@ -7422,19 +7432,10 @@
 return ToClassOrErr.takeError();
   CXXRecordDecl *ToClass = *ToClassOrErr;
 
-  // NOTE: lambda classes are created with BeingDefined flag set up.
-  // It means that ImportDefinition doesn't work for them and we should fill it
-  // manually.
-  if (ToClass->isBeingDefined())
-if (Error Err = ImportDeclContext(FromClass, /*ForceImport = */ true))
-  return std::move(Err);
-
   auto ToCallOpOrErr = import(E->getCallOperator());
   if (!ToCallOpOrErr)
 return ToCallOpOrErr.takeError();
 
-  ToClass->completeDefinition();
-
   SmallVector ToCaptures;
   ToCaptures.reserve(E->capture_size());
   for (const auto &FromCapture : E->captures()) {
Index: cfe/trunk/unittests/AST/ASTImporterTest.cpp
===
--- cfe/trunk/unittests/AST/ASTImporterTest.cpp
+++ cfe/trunk/unittests/AST/ASTImporterTest.cpp
@@ -5083,6 +5083,45 @@
 INSTANTIATE_TEST_CASE_P(ParameterizedTests, CanonicalRedeclChain,
 ::testing::Values(ArgVector()), );
 
+TEST_P(ASTImporterOptionSpecificTestBase, LambdaInFunctionBody) {
+  Decl *FromTU = getTuDecl(
+  R"(
+  void f() {
+auto L = [](){};
+  }
+  )",
+  Lang_CXX11, "input0.cc");
+  auto Pattern = lambdaExpr();
+  CXXRecordDecl *FromL =
+  FirstDeclMatcher().match(FromTU, Pattern)->getLambdaClass();
+
+  auto ToL = Import(FromL, Lang_CXX11);
+  unsigned ToLSize = std::distance(ToL->decls().begin(), ToL->decls().end());
+  unsigned FromLSize =
+  std::distance(FromL->decls().begin(), FromL->decls().end());
+  EXPECT_NE(ToLSize, 0u);
+  EXPECT_EQ(ToLSize, FromLSize);
+}
+
+TEST_P(ASTImporterOptionSpecificTestBase, LambdaInFunctionParam) {
+  Decl *FromTU = getTuDecl(
+  R"(
+  template 
+  void f(F L = [](){}) {}
+  )",
+  Lang_CXX11, "input0.cc");
+  auto Pattern = lambdaExpr();
+  CXXRecordDecl *FromL =
+  FirstDeclMatcher().match(FromTU, Pattern)->getLambdaClass();
+
+  auto ToL = Import(FromL, Lang_CXX11);
+  unsigned ToLSize = std::distance(ToL->decls().begin(), ToL->decls().end());
+  unsigned FromLSize =
+  std::distance(FromL->decls().begin(), FromL->decls().end());
+  EXPECT_NE(ToLSize, 0u);
+  EXPECT_EQ(ToLSize, FromLSize);
+}
+
 INSTANTIATE_TEST_CASE_P(ParameterizedTests, ASTImporterLookupTableTest,
 DefaultTestValuesForRunOptions, );
 


Index: cfe/trunk/lib/AST/ASTImporter.cpp
===
--- cfe/trunk/lib/AST/ASTImporter.cpp
+++ cfe/trunk/lib/AST/ASTImporter.cpp
@@ -1708,8 +1708,18 @@
 Error ASTNodeImporter::ImportDefinition(
 RecordDecl *From, RecordDecl *To, ImportDefinitionKind Kind) {
   if (To->getDefinition() || To->isBeingDefined()) {
-if (Kind == IDK_Everything)
-  return ImportDeclContext(From, /*ForceImport=*/true);
+if (Kind == IDK_Everything ||
+// In case of lambdas, the class already has a definition ptr set, but
+// the contained decls are not imported yet. Also, isBeingDefined was
+// set in CXXRecordDecl::CreateLambda.  We must import the contained
+// decls here and finish the definition.
+(To->isLambda() && shouldForceImportDeclContext(Kind))) {
+  Error Result = ImportDeclContext(From

[PATCH] D64317: [Driver] Add float-divide-by-zero back to supported sanitizers after D63793/rC365272

2019-07-08 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 208378.
MaskRay retitled this revision from "[ubsan] Delete the FloatDivideByZero 
ErrorType" to "[Driver] Add float-divide-by-zero back to supported sanitizers 
after D63793/rC365272".
MaskRay edited the summary of this revision.
MaskRay added a comment.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Fix -fsanitize=float-divide-by-zero


Repository:
  rC Clang

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

https://reviews.llvm.org/D64317

Files:
  lib/Driver/ToolChain.cpp
  test/Driver/fsanitize.c


Index: test/Driver/fsanitize.c
===
--- test/Driver/fsanitize.c
+++ test/Driver/fsanitize.c
@@ -840,3 +840,6 @@
 // CHECK-POINTER-SUB-NEEDS-ADDRESS: error: invalid argument 
'-fsanitize=pointer-subtract' only allowed with '-fsanitize=address'
 // CHECK-NO-POINTER-SUB-NOT: {{.*}}asan-detect-invalid-pointer{{.*}}
 // CHECK-NO-POINTER-CMP-NOT: {{.*}}asan-detect-invalid-pointer{{.*}}
+
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=float-divide-by-zero %s 
-### 2>&1 | FileCheck %s --check-prefix=CHECK-FLOAT-DIV-BY-ZERO:
+// CHECK-FLOAT-DIV-BY-ZERO: "-fsanitize=float-divide-by-zero"
Index: lib/Driver/ToolChain.cpp
===
--- lib/Driver/ToolChain.cpp
+++ lib/Driver/ToolChain.cpp
@@ -896,6 +896,7 @@
~SanitizerKind::Function) |
   (SanitizerKind::CFI & ~SanitizerKind::CFIICall) |
   SanitizerKind::CFICastStrict |
+  SanitizerKind::FloatDivideByZero |
   SanitizerKind::UnsignedIntegerOverflow |
   SanitizerKind::ImplicitConversion |
   SanitizerKind::Nullability | SanitizerKind::LocalBounds;


Index: test/Driver/fsanitize.c
===
--- test/Driver/fsanitize.c
+++ test/Driver/fsanitize.c
@@ -840,3 +840,6 @@
 // CHECK-POINTER-SUB-NEEDS-ADDRESS: error: invalid argument '-fsanitize=pointer-subtract' only allowed with '-fsanitize=address'
 // CHECK-NO-POINTER-SUB-NOT: {{.*}}asan-detect-invalid-pointer{{.*}}
 // CHECK-NO-POINTER-CMP-NOT: {{.*}}asan-detect-invalid-pointer{{.*}}
+
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=float-divide-by-zero %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-FLOAT-DIV-BY-ZERO:
+// CHECK-FLOAT-DIV-BY-ZERO: "-fsanitize=float-divide-by-zero"
Index: lib/Driver/ToolChain.cpp
===
--- lib/Driver/ToolChain.cpp
+++ lib/Driver/ToolChain.cpp
@@ -896,6 +896,7 @@
~SanitizerKind::Function) |
   (SanitizerKind::CFI & ~SanitizerKind::CFIICall) |
   SanitizerKind::CFICastStrict |
+  SanitizerKind::FloatDivideByZero |
   SanitizerKind::UnsignedIntegerOverflow |
   SanitizerKind::ImplicitConversion |
   SanitizerKind::Nullability | SanitizerKind::LocalBounds;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D64317: [Driver] Add float-divide-by-zero back to supported sanitizers after D63793/rC365272

2019-07-08 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 208382.
MaskRay added a comment.

Remove a stray :


Repository:
  rC Clang

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

https://reviews.llvm.org/D64317

Files:
  lib/Driver/ToolChain.cpp
  test/Driver/fsanitize.c


Index: test/Driver/fsanitize.c
===
--- test/Driver/fsanitize.c
+++ test/Driver/fsanitize.c
@@ -840,3 +840,6 @@
 // CHECK-POINTER-SUB-NEEDS-ADDRESS: error: invalid argument 
'-fsanitize=pointer-subtract' only allowed with '-fsanitize=address'
 // CHECK-NO-POINTER-SUB-NOT: {{.*}}asan-detect-invalid-pointer{{.*}}
 // CHECK-NO-POINTER-CMP-NOT: {{.*}}asan-detect-invalid-pointer{{.*}}
+
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=float-divide-by-zero %s 
-### 2>&1 | FileCheck %s --check-prefix=CHECK-FLOAT-DIV-BY-ZERO
+// CHECK-FLOAT-DIV-BY-ZERO: "-fsanitize=float-divide-by-zero"
Index: lib/Driver/ToolChain.cpp
===
--- lib/Driver/ToolChain.cpp
+++ lib/Driver/ToolChain.cpp
@@ -896,6 +896,7 @@
~SanitizerKind::Function) |
   (SanitizerKind::CFI & ~SanitizerKind::CFIICall) |
   SanitizerKind::CFICastStrict |
+  SanitizerKind::FloatDivideByZero |
   SanitizerKind::UnsignedIntegerOverflow |
   SanitizerKind::ImplicitConversion |
   SanitizerKind::Nullability | SanitizerKind::LocalBounds;


Index: test/Driver/fsanitize.c
===
--- test/Driver/fsanitize.c
+++ test/Driver/fsanitize.c
@@ -840,3 +840,6 @@
 // CHECK-POINTER-SUB-NEEDS-ADDRESS: error: invalid argument '-fsanitize=pointer-subtract' only allowed with '-fsanitize=address'
 // CHECK-NO-POINTER-SUB-NOT: {{.*}}asan-detect-invalid-pointer{{.*}}
 // CHECK-NO-POINTER-CMP-NOT: {{.*}}asan-detect-invalid-pointer{{.*}}
+
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=float-divide-by-zero %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-FLOAT-DIV-BY-ZERO
+// CHECK-FLOAT-DIV-BY-ZERO: "-fsanitize=float-divide-by-zero"
Index: lib/Driver/ToolChain.cpp
===
--- lib/Driver/ToolChain.cpp
+++ lib/Driver/ToolChain.cpp
@@ -896,6 +896,7 @@
~SanitizerKind::Function) |
   (SanitizerKind::CFI & ~SanitizerKind::CFIICall) |
   SanitizerKind::CFICastStrict |
+  SanitizerKind::FloatDivideByZero |
   SanitizerKind::UnsignedIntegerOverflow |
   SanitizerKind::ImplicitConversion |
   SanitizerKind::Nullability | SanitizerKind::LocalBounds;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D64310: [clangd] Added semantic highlighting for constructors and destructors.

2019-07-08 Thread Johan Vikström via Phabricator via cfe-commits
jvikstrom abandoned this revision.
jvikstrom added a comment.

Abandoning after discussion with sammccall and hokein.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64310



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


[PATCH] D64329: [Clangd] Fixed SelectionTree bug for macros

2019-07-08 Thread Shaurya Gupta via Phabricator via cfe-commits
SureYeaah created this revision.
SureYeaah added reviewers: sammccall, kadircet.
Herald added subscribers: cfe-commits, arphaman, jkorous, MaskRay, 
ilya-biryukov.
Herald added a project: clang.

Fixed SelectionTree bug for macros

- Fixed SelectionTree claimRange for macros and template instantiations
- Fixed SelectionTree unit tests


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D64329

Files:
  clang-tools-extra/clangd/Selection.cpp
  clang-tools-extra/clangd/SourceCode.cpp
  clang-tools-extra/clangd/SourceCode.h
  clang-tools-extra/clangd/unittests/SelectionTests.cpp

Index: clang-tools-extra/clangd/unittests/SelectionTests.cpp
===
--- clang-tools-extra/clangd/unittests/SelectionTests.cpp
+++ clang-tools-extra/clangd/unittests/SelectionTests.cpp
@@ -37,15 +37,13 @@
 Range nodeRange(const SelectionTree::Node *N, ParsedAST &AST) {
   if (!N)
 return Range{};
-  SourceManager &SM = AST.getSourceManager();
+  const SourceManager &SM = AST.getSourceManager();
+  const LangOptions &LangOpts = AST.getASTContext().getLangOpts();
   StringRef Buffer = SM.getBufferData(SM.getMainFileID());
   SourceRange SR = N->ASTNode.getSourceRange();
-  SR.setBegin(SM.getFileLoc(SR.getBegin()));
-  SR.setEnd(SM.getFileLoc(SR.getEnd()));
-  CharSourceRange R =
-  Lexer::getAsCharRange(SR, SM, AST.getASTContext().getLangOpts());
-  return Range{offsetToPosition(Buffer, SM.getFileOffset(R.getBegin())),
-   offsetToPosition(Buffer, SM.getFileOffset(R.getEnd()))};
+  SR = getFileRange(SR, SM, LangOpts);
+  return Range{offsetToPosition(Buffer, SM.getFileOffset(SR.getBegin())),
+   offsetToPosition(Buffer, SM.getFileOffset(SR.getEnd()))};
 }
 
 std::string nodeKind(const SelectionTree::Node *N) {
@@ -144,17 +142,17 @@
   R"cpp(
 void foo();
 #define CALL_FUNCTION(X) X()
-void bar() [[{ CALL_FUNC^TION(fo^o); }]]
+void bar() { [[CALL_FUNC^TION(fo^o)]]; }
   )cpp",
-  "CompoundStmt",
+  "CallExpr",
   },
   {
   R"cpp(
 void foo();
 #define CALL_FUNCTION(X) X()
-void bar() [[{ C^ALL_FUNC^TION(foo); }]]
+void bar() { [[C^ALL_FUNC^TION(foo)]]; }
   )cpp",
-  "CompoundStmt",
+  "CallExpr",
   },
   {
   R"cpp(
@@ -308,7 +306,7 @@
   R"cpp(
   template 
   struct unique_ptr {};
-  void foo(^$C[[unique_ptr>]]^ a) {}
+  void foo(^$C[[unique_ptr<$C[[unique_ptr<$C[[int]]>]]>]]^ a) {}
   )cpp",
   };
   for (const char *C : Cases) {
Index: clang-tools-extra/clangd/SourceCode.h
===
--- clang-tools-extra/clangd/SourceCode.h
+++ clang-tools-extra/clangd/SourceCode.h
@@ -20,8 +20,8 @@
 #include "clang/Basic/SourceManager.h"
 #include "clang/Format/Format.h"
 #include "clang/Tooling/Core/Replacement.h"
-#include "llvm/ADT/StringSet.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/StringSet.h"
 #include "llvm/Support/SHA1.h"
 
 namespace clang {
@@ -201,6 +201,9 @@
 std::vector visibleNamespaces(llvm::StringRef Code,
const format::FormatStyle &Style);
 
+// Return the FileRange for a given range where the ends can be in different
+// files. Note that the end of the FileRange is the end of the last token.
+SourceRange getFileRange(SourceRange Range, const SourceManager &SM, const LangOptions &LangOpts);
 } // namespace clangd
 } // namespace clang
 #endif
Index: clang-tools-extra/clangd/SourceCode.cpp
===
--- clang-tools-extra/clangd/SourceCode.cpp
+++ clang-tools-extra/clangd/SourceCode.cpp
@@ -12,6 +12,7 @@
 #include "Logger.h"
 #include "Protocol.h"
 #include "clang/AST/ASTContext.h"
+#include "clang/Basic/LangOptions.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/TokenKinds.h"
 #include "clang/Format/Format.h"
@@ -24,6 +25,7 @@
 #include "llvm/Support/Error.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/Path.h"
+#include "llvm/Support/raw_ostream.h"
 #include 
 
 namespace clang {
@@ -444,8 +446,8 @@
 namespace {
 enum NamespaceEvent {
   BeginNamespace, // namespace  {. Payload is resolved .
-  EndNamespace,   // } // namespace .  Payload is resolved *outer* namespace.
-  UsingDirective  // using namespace . Payload is unresolved .
+  EndNamespace,  // } // namespace .  Payload is resolved *outer* namespace.
+  UsingDirective // using namespace . Payload is unresolved .
 };
 // Scans C++ source code for constructs that change the visible namespaces.
 void parseNamespaceEvents(
@@ -468,7 +470,7 @@
   std::string NSName;
 
   lex(Code, Style, [&](const clang::Token &Tok) {
-switch(Tok.getKind()) {
+switch (Tok.getKind()) {
 case tok::raw_identifier:
   // In raw mode, this could 

[PATCH] D64329: [Clangd] Fixed SelectionTree bug for macros

2019-07-08 Thread Shaurya Gupta via Phabricator via cfe-commits
SureYeaah updated this revision to Diff 208387.
SureYeaah added a comment.

Removed debugging code


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64329

Files:
  clang-tools-extra/clangd/Selection.cpp
  clang-tools-extra/clangd/SourceCode.cpp
  clang-tools-extra/clangd/SourceCode.h
  clang-tools-extra/clangd/unittests/SelectionTests.cpp

Index: clang-tools-extra/clangd/unittests/SelectionTests.cpp
===
--- clang-tools-extra/clangd/unittests/SelectionTests.cpp
+++ clang-tools-extra/clangd/unittests/SelectionTests.cpp
@@ -37,15 +37,13 @@
 Range nodeRange(const SelectionTree::Node *N, ParsedAST &AST) {
   if (!N)
 return Range{};
-  SourceManager &SM = AST.getSourceManager();
+  const SourceManager &SM = AST.getSourceManager();
+  const LangOptions &LangOpts = AST.getASTContext().getLangOpts();
   StringRef Buffer = SM.getBufferData(SM.getMainFileID());
   SourceRange SR = N->ASTNode.getSourceRange();
-  SR.setBegin(SM.getFileLoc(SR.getBegin()));
-  SR.setEnd(SM.getFileLoc(SR.getEnd()));
-  CharSourceRange R =
-  Lexer::getAsCharRange(SR, SM, AST.getASTContext().getLangOpts());
-  return Range{offsetToPosition(Buffer, SM.getFileOffset(R.getBegin())),
-   offsetToPosition(Buffer, SM.getFileOffset(R.getEnd()))};
+  SR = getFileRange(SR, SM, LangOpts);
+  return Range{offsetToPosition(Buffer, SM.getFileOffset(SR.getBegin())),
+   offsetToPosition(Buffer, SM.getFileOffset(SR.getEnd()))};
 }
 
 std::string nodeKind(const SelectionTree::Node *N) {
@@ -144,17 +142,17 @@
   R"cpp(
 void foo();
 #define CALL_FUNCTION(X) X()
-void bar() [[{ CALL_FUNC^TION(fo^o); }]]
+void bar() { [[CALL_FUNC^TION(fo^o)]]; }
   )cpp",
-  "CompoundStmt",
+  "CallExpr",
   },
   {
   R"cpp(
 void foo();
 #define CALL_FUNCTION(X) X()
-void bar() [[{ C^ALL_FUNC^TION(foo); }]]
+void bar() { [[C^ALL_FUNC^TION(foo)]]; }
   )cpp",
-  "CompoundStmt",
+  "CallExpr",
   },
   {
   R"cpp(
@@ -308,7 +306,7 @@
   R"cpp(
   template 
   struct unique_ptr {};
-  void foo(^$C[[unique_ptr>]]^ a) {}
+  void foo(^$C[[unique_ptr<$C[[unique_ptr<$C[[int]]>]]>]]^ a) {}
   )cpp",
   };
   for (const char *C : Cases) {
Index: clang-tools-extra/clangd/SourceCode.h
===
--- clang-tools-extra/clangd/SourceCode.h
+++ clang-tools-extra/clangd/SourceCode.h
@@ -20,8 +20,8 @@
 #include "clang/Basic/SourceManager.h"
 #include "clang/Format/Format.h"
 #include "clang/Tooling/Core/Replacement.h"
-#include "llvm/ADT/StringSet.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/StringSet.h"
 #include "llvm/Support/SHA1.h"
 
 namespace clang {
@@ -201,6 +201,9 @@
 std::vector visibleNamespaces(llvm::StringRef Code,
const format::FormatStyle &Style);
 
+// Return the FileRange for a given range where the ends can be in different
+// files. Note that the end of the FileRange is the end of the last token.
+SourceRange getFileRange(SourceRange Range, const SourceManager &SM, const LangOptions &LangOpts);
 } // namespace clangd
 } // namespace clang
 #endif
Index: clang-tools-extra/clangd/SourceCode.cpp
===
--- clang-tools-extra/clangd/SourceCode.cpp
+++ clang-tools-extra/clangd/SourceCode.cpp
@@ -12,6 +12,7 @@
 #include "Logger.h"
 #include "Protocol.h"
 #include "clang/AST/ASTContext.h"
+#include "clang/Basic/LangOptions.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/TokenKinds.h"
 #include "clang/Format/Format.h"
@@ -24,6 +25,7 @@
 #include "llvm/Support/Error.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/Path.h"
+#include "llvm/Support/raw_ostream.h"
 #include 
 
 namespace clang {
@@ -444,8 +446,8 @@
 namespace {
 enum NamespaceEvent {
   BeginNamespace, // namespace  {. Payload is resolved .
-  EndNamespace,   // } // namespace .  Payload is resolved *outer* namespace.
-  UsingDirective  // using namespace . Payload is unresolved .
+  EndNamespace,  // } // namespace .  Payload is resolved *outer* namespace.
+  UsingDirective // using namespace . Payload is unresolved .
 };
 // Scans C++ source code for constructs that change the visible namespaces.
 void parseNamespaceEvents(
@@ -468,7 +470,7 @@
   std::string NSName;
 
   lex(Code, Style, [&](const clang::Token &Tok) {
-switch(Tok.getKind()) {
+switch (Tok.getKind()) {
 case tok::raw_identifier:
   // In raw mode, this could be a keyword or a name.
   switch (State) {
@@ -570,40 +572,37 @@
   // Map from namespace to (resolved) namespaces introduced via using directive.
   llvm::StringMap> 

[PATCH] D64276: [ItaniumMangle] Refactor long double/__float128 mangling and fix the mangled code

2019-07-08 Thread Erich Keane via Phabricator via cfe-commits
erichkeane accepted this revision.
erichkeane added a comment.
This revision is now accepted and ready to land.

I think the function names are awkward, but otherwise I think this should be 
acceptable.  I'll accept, but give 24 hrs for the other reviewers to get 
through their mondays.




Comment at: include/clang/Basic/TargetInfo.h:603
+  /// Return the mangled code of long double.
+  virtual const char *getMangledCodeOfLongDouble() const { return "e"; }
+

getLongDoubleMangling/getFloat128Mangling seems to make more sense for these 
names.


Repository:
  rC Clang

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

https://reviews.llvm.org/D64276



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


[PATCH] D64329: [Clangd] Fixed SelectionTree bug for macros

2019-07-08 Thread Shaurya Gupta via Phabricator via cfe-commits
SureYeaah updated this revision to Diff 208389.
SureYeaah added a comment.

Removed extra includes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64329

Files:
  clang-tools-extra/clangd/Selection.cpp
  clang-tools-extra/clangd/SourceCode.cpp
  clang-tools-extra/clangd/SourceCode.h
  clang-tools-extra/clangd/unittests/SelectionTests.cpp

Index: clang-tools-extra/clangd/unittests/SelectionTests.cpp
===
--- clang-tools-extra/clangd/unittests/SelectionTests.cpp
+++ clang-tools-extra/clangd/unittests/SelectionTests.cpp
@@ -37,15 +37,13 @@
 Range nodeRange(const SelectionTree::Node *N, ParsedAST &AST) {
   if (!N)
 return Range{};
-  SourceManager &SM = AST.getSourceManager();
+  const SourceManager &SM = AST.getSourceManager();
+  const LangOptions &LangOpts = AST.getASTContext().getLangOpts();
   StringRef Buffer = SM.getBufferData(SM.getMainFileID());
   SourceRange SR = N->ASTNode.getSourceRange();
-  SR.setBegin(SM.getFileLoc(SR.getBegin()));
-  SR.setEnd(SM.getFileLoc(SR.getEnd()));
-  CharSourceRange R =
-  Lexer::getAsCharRange(SR, SM, AST.getASTContext().getLangOpts());
-  return Range{offsetToPosition(Buffer, SM.getFileOffset(R.getBegin())),
-   offsetToPosition(Buffer, SM.getFileOffset(R.getEnd()))};
+  SR = getFileRange(SR, SM, LangOpts);
+  return Range{offsetToPosition(Buffer, SM.getFileOffset(SR.getBegin())),
+   offsetToPosition(Buffer, SM.getFileOffset(SR.getEnd()))};
 }
 
 std::string nodeKind(const SelectionTree::Node *N) {
@@ -144,17 +142,17 @@
   R"cpp(
 void foo();
 #define CALL_FUNCTION(X) X()
-void bar() [[{ CALL_FUNC^TION(fo^o); }]]
+void bar() { [[CALL_FUNC^TION(fo^o)]]; }
   )cpp",
-  "CompoundStmt",
+  "CallExpr",
   },
   {
   R"cpp(
 void foo();
 #define CALL_FUNCTION(X) X()
-void bar() [[{ C^ALL_FUNC^TION(foo); }]]
+void bar() { [[C^ALL_FUNC^TION(foo)]]; }
   )cpp",
-  "CompoundStmt",
+  "CallExpr",
   },
   {
   R"cpp(
@@ -308,7 +306,7 @@
   R"cpp(
   template 
   struct unique_ptr {};
-  void foo(^$C[[unique_ptr>]]^ a) {}
+  void foo(^$C[[unique_ptr<$C[[unique_ptr<$C[[int]]>]]>]]^ a) {}
   )cpp",
   };
   for (const char *C : Cases) {
Index: clang-tools-extra/clangd/SourceCode.h
===
--- clang-tools-extra/clangd/SourceCode.h
+++ clang-tools-extra/clangd/SourceCode.h
@@ -20,8 +20,8 @@
 #include "clang/Basic/SourceManager.h"
 #include "clang/Format/Format.h"
 #include "clang/Tooling/Core/Replacement.h"
-#include "llvm/ADT/StringSet.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/StringSet.h"
 #include "llvm/Support/SHA1.h"
 
 namespace clang {
@@ -201,6 +201,9 @@
 std::vector visibleNamespaces(llvm::StringRef Code,
const format::FormatStyle &Style);
 
+// Return the FileRange for a given range where the ends can be in different
+// files. Note that the end of the FileRange is the end of the last token.
+SourceRange getFileRange(SourceRange Range, const SourceManager &SM, const LangOptions &LangOpts);
 } // namespace clangd
 } // namespace clang
 #endif
Index: clang-tools-extra/clangd/SourceCode.cpp
===
--- clang-tools-extra/clangd/SourceCode.cpp
+++ clang-tools-extra/clangd/SourceCode.cpp
@@ -12,6 +12,7 @@
 #include "Logger.h"
 #include "Protocol.h"
 #include "clang/AST/ASTContext.h"
+#include "clang/Basic/LangOptions.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/TokenKinds.h"
 #include "clang/Format/Format.h"
@@ -444,8 +445,8 @@
 namespace {
 enum NamespaceEvent {
   BeginNamespace, // namespace  {. Payload is resolved .
-  EndNamespace,   // } // namespace .  Payload is resolved *outer* namespace.
-  UsingDirective  // using namespace . Payload is unresolved .
+  EndNamespace,  // } // namespace .  Payload is resolved *outer* namespace.
+  UsingDirective // using namespace . Payload is unresolved .
 };
 // Scans C++ source code for constructs that change the visible namespaces.
 void parseNamespaceEvents(
@@ -468,7 +469,7 @@
   std::string NSName;
 
   lex(Code, Style, [&](const clang::Token &Tok) {
-switch(Tok.getKind()) {
+switch (Tok.getKind()) {
 case tok::raw_identifier:
   // In raw mode, this could be a keyword or a name.
   switch (State) {
@@ -570,40 +571,37 @@
   // Map from namespace to (resolved) namespaces introduced via using directive.
   llvm::StringMap> UsingDirectives;
 
-  parseNamespaceEvents(Code, Style,
-   [&](NamespaceEvent Event, llvm::StringRef NS) {
- switch (Event) {
-   

[PATCH] D60456: [RISCV] Hard float ABI support

2019-07-08 Thread Alex Bradbury via Phabricator via cfe-commits
asb marked an inline comment as done.
asb added inline comments.



Comment at: clang/lib/CodeGen/TargetInfo.cpp:9352
+return false;
+  // As a quirk of the ABI, zero-width bitfields aren't ignored for fp+fp
+  // or int+fp structs, but are ignored for a struct with an fp field and

rogfer01 wrote:
> I found some mismatch in behaviour between gcc and g++ that we may want to 
> address in the psABI first.
> 
> For instance, given the following struct (I'm using gcc 8.3.0)
> 
> ```lang=cpp
> // t.c
> struct A
> {
>   int :0;
>   double d;
>   int :0;
>   long x;
>   int :0;
> };
> 
> extern void bar(struct A);
> void foo(struct A a)
> {
>   a.d =- a.d;
>   a.x += 1;
>   return bar(a);
> }
> ```
> 
> we are emitting this
> 
> ```
> $ clang --target=riscv64 -march=rv64gc -mabi=lp64d -S -o-  t.c -O2  
> ...
> foo:# @foo
> # %bb.0:# %entry
> addia2, zero, -1
> sllia2, a2, 63
> xor a0, a0, a2
> addia1, a1, 1
> tailbar
> ```
> 
> which matches with what g++ does (i.e in both cases `a0` is `a.d` and `a1` is 
> `a.x`)
> 
> ```
> $ ./riscv64-unknown-linux-gnu-g++ -S -O2 -o- -x c test.cc
> ...
> foo:
>   fmv.d.x fa5,a0
>   addisp,sp,-16
>   fneg.d  fa5,fa5
>   addia1,a1,1
>   addisp,sp,16
>   fmv.x.d a0,fa5
>   tailbar
> ```
> 
> But I found a mismatch while using C++. Clang emits the same for C and C++ 
> (modulo `.cfi` stuff)
> 
> ```
> $ clang --target=riscv64 -march=rv64gc -mabi=lp64d -S -o-  -x c++ t.c -O2  
> _Z3foo1A:   # @_Z3foo1A
> .cfi_startproc
> # %bb.0:# %entry
> addia2, zero, -1
> sllia2, a2, 63
> xor a0, a0, a2
> addia1, a1, 1
> .cfi_def_cfa_offset 0
> tail_Z3bar1A
> ```
> 
> But g++ seems to ignore the zero-width bitfields: `fa0` is  `a.d` and `a0` is 
> `a.x`
> 
> ```
> $ riscv64-unknown-linux-gnu-g++  -S -O2 -x c++ t.c -o-
> ...
> _Z3foo1A:
> .LFB0:
> .cfi_startproc
> fneg.d  fa0,fa0
> addisp,sp,-16
> .cfi_def_cfa_offset 16
> addia0,a0,1
> addisp,sp,16
> .cfi_def_cfa_offset 0
> tail_Z3bar1A
> .cfi_endproc
> ```
> 
> This is a bit worrying as it might complicate interoperability between C and 
> C++ (I tried wrapping everything inside an `extern "C"` just in case but it 
> didn't change g++'s behaviour).
> 
> Do you mind to confirm this issue?
Thanks, I'm seeing this in GCC 9.1.0 as well. I left[ a 
comment](https://github.com/riscv/riscv-elf-psabi-doc/issues/99#issuecomment-509233798)
 on the relevant psABI issue. It seems there is a GCC bug here, but hopefully 
someone can confirm what the "correct" behaviour is.


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

https://reviews.llvm.org/D60456



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


[PATCH] D60456: [RISCV] Hard float ABI support

2019-07-08 Thread Alex Bradbury via Phabricator via cfe-commits
asb updated this revision to Diff 208392.
asb marked an inline comment as done.
asb added a comment.

Updated to address comment typo picked up by @rogfer01 (thanks!).

As noted in another comment, it's not entirely clear what zero-width bitfield 
behaviour to match (see here 
)
 as GCC seems buggy and the ABI is under-specified. Ideally I'd like to land 
this patch and follow-up to adjust the zero-width bitfield behaviour if 
necessary once that psABI issue is resolved.


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

https://reviews.llvm.org/D60456

Files:
  clang/lib/Basic/Targets/RISCV.cpp
  clang/lib/Basic/Targets/RISCV.h
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGen/riscv32-ilp32-ilp32f-abi.c
  clang/test/CodeGen/riscv32-ilp32-ilp32f-ilp32d-abi.c
  clang/test/CodeGen/riscv32-ilp32d-abi.c
  clang/test/CodeGen/riscv32-ilp32f-abi.c
  clang/test/CodeGen/riscv32-ilp32f-ilp32d-abi.c
  clang/test/CodeGen/riscv64-lp64-lp64f-abi.c
  clang/test/CodeGen/riscv64-lp64-lp64f-lp64d-abi.c
  clang/test/CodeGen/riscv64-lp64d-abi.c
  clang/test/CodeGen/riscv64-lp64f-lp64d-abi.c
  clang/test/Preprocessor/riscv-target-features.c

Index: clang/test/Preprocessor/riscv-target-features.c
===
--- clang/test/Preprocessor/riscv-target-features.c
+++ clang/test/Preprocessor/riscv-target-features.c
@@ -47,3 +47,27 @@
 // RUN: %clang -target riscv64-unknown-linux-gnu -march=rv64ic -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-C-EXT %s
 // CHECK-C-EXT: __riscv_compressed 1
+
+// RUN: %clang -target riscv32-unknown-linux-gnu -march=rv32ifd -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-SOFT %s
+// RUN: %clang -target riscv64-unknown-linux-gnu -march=rv64ifd -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-SOFT %s
+// CHECK-SOFT: __riscv_float_abi_soft 1
+// CHECK-SOFT-NOT: __riscv_float_abi_single
+// CHECK-SOFT-NOT: __riscv_float_abi_double
+
+// RUN: %clang -target riscv32-unknown-linux-gnu -march=rv32ifd -mabi=ilp32f -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-SINGLE %s
+// RUN: %clang -target riscv64-unknown-linux-gnu -march=rv64ifd -mabi=lp64f -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-SINGLE %s
+// CHECK-SINGLE: __riscv_float_abi_single 1
+// CHECK-SINGLE-NOT: __riscv_float_abi_soft
+// CHECK-SINGLE-NOT: __riscv_float_abi_double
+
+// RUN: %clang -target riscv32-unknown-linux-gnu -march=rv32ifd -mabi=ilp32f -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-DOUBLE %s
+// RUN: %clang -target riscv64-unknown-linux-gnu -march=rv64ifd -mabi=lp64f -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-DOUBLE %s
+// CHECK-DOUBLE: __riscv_float_abi_double 1
+// CHECK-DOUBLE-NOT: __riscv_float_abi_soft
+// CHECK-DOUBLE-NOT: __riscv_float_abi_single
Index: clang/test/CodeGen/riscv64-lp64f-lp64d-abi.c
===
--- /dev/null
+++ clang/test/CodeGen/riscv64-lp64f-lp64d-abi.c
@@ -0,0 +1,265 @@
+// RUN: %clang_cc1 -triple riscv64 -target-feature +f -target-abi lp64f -emit-llvm %s -o - \
+// RUN: | FileCheck %s
+// RUN: %clang_cc1 -triple riscv64 -target-feature +d -target-abi lp64d -emit-llvm %s -o - \
+// RUN: | FileCheck %s
+
+#include 
+
+// Verify that the tracking of used GPRs and FPRs works correctly by checking
+// that small integers are sign/zero extended when passed in registers.
+
+// Floats are passed in FPRs, so argument 'i' will be passed zero-extended
+// because it will be passed in a GPR.
+
+// CHECK: define void @f_fpr_tracking(float %a, float %b, float %c, float %d, float %e, float %f, float %g, float %h, i8 zeroext %i)
+void f_fpr_tracking(float a, float b, float c, float d, float e, float f,
+float g, float h, uint8_t i) {}
+
+// Check that fp, fp+fp, and int+fp structs are lowered correctly. These will
+// be passed in FPR, FPR+FPR, or GPR+FPR regs if sufficient registers are
+// available the widths are <= XLEN and FLEN, and should be expanded to
+// separate arguments in IR. They are passed by the same rules for returns,
+// but will be lowered to simple two-element structs if necessary (as LLVM IR
+// functions cannot return multiple values).
+
+// A struct containing just one floating-point real is passed as though it
+// were a standalone floating-point real.
+
+struct float_s { float f; };
+
+// CHECK: define void @f_float_s_arg(float)
+void f_float_s_arg(struct float_s a) {}
+
+// CHECK: define float @f_ret_float_s()
+struct float_s f_ret_float_s() {
+  return (struct float_s){1.0};
+}
+
+// A struct containing a float and any number of zero-width bitfields is
+// passed as though it were a standalone floating-point real.
+
+struct zbf_float_s { int : 0; float f; };
+struct zbf_float_zbf_s { int : 0; float f; int : 0; };
+
+// CHECK: define void @f

[PATCH] D64317: [Driver] Add float-divide-by-zero back to supported sanitizers after D63793/rC365272

2019-07-08 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 208395.
MaskRay edited the summary of this revision.
MaskRay added a comment.

make various sanitizer features work


Repository:
  rC Clang

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

https://reviews.llvm.org/D64317

Files:
  lib/Driver/SanitizerArgs.cpp
  lib/Driver/ToolChain.cpp
  test/Driver/fsanitize-coverage.c
  test/Driver/fsanitize.c
  test/Driver/sanitizer-ld.c


Index: test/Driver/sanitizer-ld.c
===
--- test/Driver/sanitizer-ld.c
+++ test/Driver/sanitizer-ld.c
@@ -838,3 +838,8 @@
 // CHECK-DSO-SHARED-HWASAN-AARCH64-LINUX-NOT: "-ldl"
 // CHECK-DSO-SHARED-HWASAN-AARCH64-LINUX-NOT: "--export-dynamic"
 // CHECK-DSO-SHARED-HWASAN-AARCH64-LINUX-NOT: "--dynamic-list"
+
+// RUN: %clang -fsanitize=float-divide-by-zero %s -### -o %t.o 2>&1 \
+// RUN: -target x86_64-unknown-linux -fuse-ld=ld \
+// RUN:   | FileCheck --check-prefix=CHECK-SHADOWCALLSTACK-LINUX-X86-64 %s
+// CHECK-SHADOWCALLSTACK-LINUX-X86-64-NOT: error:
Index: test/Driver/fsanitize.c
===
--- test/Driver/fsanitize.c
+++ test/Driver/fsanitize.c
@@ -840,3 +840,17 @@
 // CHECK-POINTER-SUB-NEEDS-ADDRESS: error: invalid argument 
'-fsanitize=pointer-subtract' only allowed with '-fsanitize=address'
 // CHECK-NO-POINTER-SUB-NOT: {{.*}}asan-detect-invalid-pointer{{.*}}
 // CHECK-NO-POINTER-CMP-NOT: {{.*}}asan-detect-invalid-pointer{{.*}}
+
+// RUN: %clang -target x86_64-linux -fsanitize=float-divide-by-zero %s -### 
2>&1 | FileCheck %s --check-prefixes=CHECK-DIVBYZERO,CHECK-DIVBYZERO-RECOVER
+// RUN: %clang -target x86_64-linux -fsanitize=float-divide-by-zero %s 
-fno-sanitize-recover=float-divide-by-zero -### 2>&1 | FileCheck %s 
--check-prefixes=CHECK-DIVBYZERO,CHECK-DIVBYZERO-NORECOVER
+// RUN: %clang -target x86_64-linux -fsanitize=float-divide-by-zero 
-fsanitize-trap=float-divide-by-zero %s -### 2>&1 | FileCheck %s 
--check-prefixes=CHECK-DIVBYZERO,CHECK-DIVBYZERO-NORECOVER,CHECK-DIVBYZERO-TRAP
+// CHECK-DIVBYZERO: "-fsanitize=float-divide-by-zero"
+// CHECK-DIVBYZERO-RECOVER: "-fsanitize-recover=float-divide-by-zero"
+// CHECK-DIVBYZERO-NORECOVER-NOT: "-fsanitize-recover=float-divide-by-zero"
+// CHECK-DIVBYZERO-TRAP: "-fsanitize-trap=float-divide-by-zero"
+
+// RUN: %clang -target x86_64-linux -fsanitize=float-divide-by-zero 
-fsanitize-minimal-runtime %s -### 2>&1 | FileCheck %s 
--check-prefixes=CHECK-DIVBYZERO,CHECK-DIVBYZERO-MINIMAL
+// CHECK-DIVBYZERO-MINIMAL: "-fsanitize-minimal-runtime"
+
+// RUN: %clang -target x86_64-linux -fsanitize=undefined,float-divide-by-zero 
%s -### 2>&1 | FileCheck %s --check-prefix=CHECK-DIVBYZERO-UBSAN
+// CHECK-DIVBYZERO-UBSAN: "-fsanitize={{.*}},float-divide-by-zero,{{.*}}"
Index: test/Driver/fsanitize-coverage.c
===
--- test/Driver/fsanitize-coverage.c
+++ test/Driver/fsanitize-coverage.c
@@ -14,6 +14,7 @@
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=undefined 
-fsanitize-coverage=func,trace-pc %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-SANITIZE-COVERAGE-FUNC
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=bool 
-fsanitize-coverage=func,trace-pc %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-SANITIZE-COVERAGE-FUNC
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=dataflow 
-fsanitize-coverage=func,trace-pc %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-SANITIZE-COVERAGE-FUNC
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=float-divide-by-zero 
-fsanitize-coverage=func,trace-pc %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-SANITIZE-COVERAGE-FUNC
 // RUN: %clang -target x86_64-linux-gnu 
-fsanitize-coverage=func,trace-pc %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-SANITIZE-COVERAGE-FUNC
 // CHECK-SANITIZE-COVERAGE-FUNC: fsanitize-coverage-type=1
 
Index: lib/Driver/ToolChain.cpp
===
--- lib/Driver/ToolChain.cpp
+++ lib/Driver/ToolChain.cpp
@@ -896,6 +896,7 @@
~SanitizerKind::Function) |
   (SanitizerKind::CFI & ~SanitizerKind::CFIICall) |
   SanitizerKind::CFICastStrict |
+  SanitizerKind::FloatDivideByZero |
   SanitizerKind::UnsignedIntegerOverflow |
   SanitizerKind::ImplicitConversion |
   SanitizerKind::Nullability | SanitizerKind::LocalBounds;
Index: lib/Driver/SanitizerArgs.cpp
===
--- lib/Driver/SanitizerArgs.cpp
+++ lib/Driver/SanitizerArgs.cpp
@@ -27,7 +27,7 @@
 static const SanitizerMask NeedsUbsanRt =
 SanitizerKind::Undefined | SanitizerKind::Integer |
 SanitizerKind::ImplicitConversion | SanitizerKind::Nullability |
-SanitizerKind::CFI;
+SanitizerKind::CFI | SanitizerKind::FloatDivideByZero;
 static 

[PATCH] D64276: [ItaniumMangle] Refactor long double/__float128 mangling and fix the mangled code

2019-07-08 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 208399.
MaskRay edited the summary of this revision.
MaskRay added a comment.

getMangledTypeOfLongDouble -> getLongDoubleMangling
as erichkeane suggested.


Repository:
  rC Clang

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

https://reviews.llvm.org/D64276

Files:
  include/clang/Basic/TargetInfo.h
  lib/AST/ItaniumMangle.cpp
  lib/Basic/Targets/PPC.h
  lib/Basic/Targets/SystemZ.h
  lib/Basic/Targets/X86.h
  test/CodeGenCXX/float128-declarations.cpp

Index: test/CodeGenCXX/float128-declarations.cpp
===
--- test/CodeGenCXX/float128-declarations.cpp
+++ test/CodeGenCXX/float128-declarations.cpp
@@ -84,15 +84,15 @@
 // CHECK-DAG: @_ZN12_GLOBAL__N_13f2nE = internal global fp128 0xL40040800
 // CHECK-DAG: @_ZN12_GLOBAL__N_15arr1nE = internal global [10 x fp128]
 // CHECK-DAG: @_ZN12_GLOBAL__N_15arr2nE = internal global [3 x fp128] [fp128 0xL3FFF, fp128 0xL40008000, fp128 0xL4025176592E0]
-// CHECK-DAG: define internal fp128 @_ZN12_GLOBAL__N_16func1nERKU10__float128(fp128*
+// CHECK-DAG: define internal fp128 @_ZN12_GLOBAL__N_16func1nERKu9__ieee128(fp128*
 // CHECK-DAG: @f1f = global fp128 0xL
 // CHECK-DAG: @f2f = global fp128 0xL40040333
 // CHECK-DAG: @arr1f = global [10 x fp128]
 // CHECK-DAG: @arr2f = global [3 x fp128] [fp128 0xLBFFF, fp128 0xLC0008000, fp128 0xLC025176592E0]
-// CHECK-DAG: declare fp128 @_Z6func1fU10__float128(fp128)
-// CHECK-DAG: define linkonce_odr void @_ZN2C1C2EU10__float128(%class.C1* %this, fp128 %arg)
-// CHECK-DAG: define linkonce_odr fp128 @_ZN2C16func2cEU10__float128(fp128 %arg)
-// CHECK-DAG: define linkonce_odr fp128 @_Z6func1tIU10__float128ET_S0_(fp128 %arg)
+// CHECK-DAG: declare fp128 @_Z6func1fu9__ieee128(fp128)
+// CHECK-DAG: define linkonce_odr void @_ZN2C1C2Eu9__ieee128(%class.C1* %this, fp128 %arg)
+// CHECK-DAG: define linkonce_odr fp128 @_ZN2C16func2cEu9__ieee128(fp128 %arg)
+// CHECK-DAG: define linkonce_odr fp128 @_Z6func1tIu9__ieee128ET_S0_(fp128 %arg)
 // CHECK-DAG: @__const.main.s1 = private unnamed_addr constant %struct.S1 { fp128 0xL40060800 }
 // CHECK-DAG: store fp128 0xLF0AFD0EBFF292DCE42E0B38CDD83F26F, fp128* %f1l, align 16
 // CHECK-DAG: store fp128 0xL8000, fp128* %f2l, align 16
Index: lib/Basic/Targets/X86.h
===
--- lib/Basic/Targets/X86.h
+++ lib/Basic/Targets/X86.h
@@ -848,7 +848,7 @@
 LongDoubleFormat = &llvm::APFloat::IEEEquad();
   }
 
-  bool useFloat128ManglingForLongDouble() const override { return true; }
+  const char *getLongDoubleMangling() const override { return "g"; }
 };
 } // namespace targets
 } // namespace clang
Index: lib/Basic/Targets/SystemZ.h
===
--- lib/Basic/Targets/SystemZ.h
+++ lib/Basic/Targets/SystemZ.h
@@ -141,7 +141,7 @@
 return "";
   }
 
-  bool useFloat128ManglingForLongDouble() const override { return true; }
+  const char *getLongDoubleMangling() const override { return "g"; }
 };
 } // namespace targets
 } // namespace clang
Index: lib/Basic/Targets/PPC.h
===
--- lib/Basic/Targets/PPC.h
+++ lib/Basic/Targets/PPC.h
@@ -314,11 +314,14 @@
 
   bool hasSjLjLowering() const override { return true; }
 
-  bool useFloat128ManglingForLongDouble() const override {
-return LongDoubleWidth == 128 &&
-   LongDoubleFormat == &llvm::APFloat::PPCDoubleDouble() &&
-   getTriple().isOSBinFormatELF();
+  const char *getLongDoubleMangling() const override {
+if (LongDoubleWidth == 64)
+  return "e";
+return LongDoubleFormat == &llvm::APFloat::PPCDoubleDouble()
+   ? "g"
+   : "u9__ieee128";
   }
+  const char *getFloat128Mangling() const override { return "u9__ieee128"; }
 };
 
 class LLVM_LIBRARY_VISIBILITY PPC32TargetInfo : public PPCTargetInfo {
Index: lib/AST/ItaniumMangle.cpp
===
--- lib/AST/ItaniumMangle.cpp
+++ lib/AST/ItaniumMangle.cpp
@@ -2608,30 +2608,19 @@
 Out << 'd';
 break;
   case BuiltinType::LongDouble: {
-bool UseFloat128Mangling =
-getASTContext().getTargetInfo().useFloat128ManglingForLongDouble();
-if (getASTContext().getLangOpts().OpenMP &&
-getASTContext().getLangOpts().OpenMPIsDevice) {
-  UseFloat128Mangling = getASTContext()
-.getAuxTargetInfo()
-->useFloat128ManglingForLongDouble();
-}
-Out << (UseFloat128Mangling ? 'g' : 'e');
+const TargetInfo *TI = getASTContext().getLangOpts().OpenMP &&

[PATCH] D64277: [X86][PowerPC] Support -mlong-double-128

2019-07-08 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 208402.
MaskRay added a comment.

Rebase after getMangledCodeOfLongDouble -> getLongDoubleMangling rename


Repository:
  rC Clang

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

https://reviews.llvm.org/D64277

Files:
  include/clang/Driver/Options.td
  lib/Basic/TargetInfo.cpp
  lib/Basic/Targets/PPC.cpp
  lib/Basic/Targets/X86.h
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/ppc64-long-double.cpp
  test/CodeGen/x86-long-double.cpp
  test/Driver/mlong-double-128.c
  test/OpenMP/nvptx_unsupported_type_codegen.cpp

Index: test/OpenMP/nvptx_unsupported_type_codegen.cpp
===
--- test/OpenMP/nvptx_unsupported_type_codegen.cpp
+++ test/OpenMP/nvptx_unsupported_type_codegen.cpp
@@ -76,6 +76,3 @@
   f = 1;
   return f;
 }
-
-// CHECK: define weak void @__omp_offloading_{{.+}}foo{{.+}}_l75([[BIGTYPE:.+]]*
-// CHECK: store [[BIGTYPE]] 0xL3FFF, [[BIGTYPE]]* %
Index: test/Driver/mlong-double-128.c
===
--- /dev/null
+++ test/Driver/mlong-double-128.c
@@ -0,0 +1,11 @@
+// RUN: %clang -target powerpc-linux-musl -c -### %s -mlong-double-128 2>&1 | FileCheck %s
+// RUN: %clang -target powerpc64-pc-freebsd12 -c -### %s -mlong-double-128 2>&1 | FileCheck %s
+// RUN: %clang -target powerpc64le-linux-musl -c -### %s -mlong-double-128 2>&1 | FileCheck %s
+// RUN: %clang -target i686-linux-gnu -c -### %s -mlong-double-128 2>&1 | FileCheck %s
+// RUN: %clang -target x86_64-linux-musl -c -### %s -mlong-double-128 2>&1 | FileCheck %s
+
+// CHECK: "-mlong-double-128"
+
+// RUN: %clang -target aarch64 -c -### %s -mlong-double-128 2>&1 | FileCheck --check-prefix=ERR %s
+
+// ERR: error: unsupported option '-mlong-double-128' for target 'aarch64'
Index: test/CodeGen/x86-long-double.cpp
===
--- test/CodeGen/x86-long-double.cpp
+++ test/CodeGen/x86-long-double.cpp
@@ -16,6 +16,15 @@
 // RUN: %clang_cc1 %s -emit-llvm -o - -triple=x86_64-apple-darwin -mlong-double-64 | \
 // RUN:   FileCheck --check-prefixes=FP64,FP64-X64 %s
 
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple=i686 -mlong-double-128 | \
+// RUN:   FileCheck --check-prefix=FP128 %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple=i686-apple-darwin -mlong-double-128 | \
+// RUN:   FileCheck --check-prefix=FP128 %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple=x86_64 -mlong-double-128 | \
+// RUN:   FileCheck --check-prefix=FP128 %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple=x86_64-apple-darwin -mlong-double-128 | \
+// RUN:   FileCheck --check-prefix=FP128 %s
+
 // Check -malign-double increases the alignment from 4 to 8 on x86-32.
 // RUN: %clang_cc1 %s -emit-llvm -o - -triple=i686 -mlong-double-64 \
 // RUN:   -malign-double | FileCheck --check-prefixes=FP64,FP64-X64 %s
@@ -37,7 +46,11 @@
 // FP64-X64: @x = global double {{.*}}, align 8
 // FP64-X64: @size = global i32 8
 
+// FP128: @x = global fp128 {{.*}}, align 16
+// FP128: @size = global i32 16
+
 long double foo(long double d) { return d; }
 
 // FP64: double @_Z3fooe(double %d)
 // FP80: x86_fp80 @_Z3fooe(x86_fp80 %d)
+// FP128: fp128 @_Z3foog(fp128 %d)
Index: test/CodeGen/ppc64-long-double.cpp
===
--- test/CodeGen/ppc64-long-double.cpp
+++ test/CodeGen/ppc64-long-double.cpp
@@ -2,8 +2,11 @@
 // RUN:   FileCheck --check-prefix=FP64 %s
 // RUN: %clang_cc1 -triple powerpc64-linux-gnu -emit-llvm -o - %s -mlong-double-64 | \
 // RUN:   FileCheck --check-prefix=FP64 %s
+
 // RUN: %clang_cc1 -triple powerpc64-linux-gnu -emit-llvm -o - %s | \
 // RUN:   FileCheck --check-prefix=IBM128 %s
+// RUN: %clang_cc1 -triple powerpc64-linux-musl -emit-llvm -o - -mlong-double-128 %s | \
+// RUN:   FileCheck --check-prefix=IBM128 %s
 
 long double x = 0;
 int size = sizeof(x);
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -2742,7 +2742,9 @@
   Opts.PackStruct = getLastArgIntValue(Args, OPT_fpack_struct_EQ, 0, Diags);
   Opts.MaxTypeAlign = getLastArgIntValue(Args, OPT_fmax_type_align_EQ, 0, Diags);
   Opts.AlignDouble = Args.hasArg(OPT_malign_double);
-  Opts.LongDoubleSize = Args.hasArg(OPT_mlong_double_64) ? 64 : 0;
+  Opts.LongDoubleSize = Args.hasArg(OPT_mlong_double_128)
+? 128
+: Args.hasArg(OPT_mlong_double_64) ? 64 : 0;
   Opts.PICLevel = getLastArgIntValue(Args, OPT_pic_level, 0, Diags);
   Opts.ROPI = Args.hasArg(OPT_fropi);
   Opts.RWPI = Args.hasArg(OPT_frwpi);
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -4001,11

[PATCH] D64169: ARM MTE stack sanitizer.

2019-07-08 Thread Oliver Stannard (Linaro) via Phabricator via cfe-commits
ostannard accepted this revision.
ostannard added a comment.
This revision is now accepted and ready to land.

LGTM with one minor nit.




Comment at: llvm/include/llvm/Bitcode/LLVMBitCodes.h:632
   ATTR_KIND_WILLRETURN = 61,
+  ATTR_KIND_SANITIZE_MEMTAG = 62
 };

Please leave the trailing comma on, to keep the git-blame clean.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64169



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


[PATCH] D64317: [Driver] Add float-divide-by-zero back to supported sanitizers after D63793/rC365272

2019-07-08 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 208410.
MaskRay added a comment.

Fix sanitizer-ld.c test


Repository:
  rC Clang

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

https://reviews.llvm.org/D64317

Files:
  lib/Driver/SanitizerArgs.cpp
  lib/Driver/ToolChain.cpp
  test/Driver/fsanitize-coverage.c
  test/Driver/fsanitize.c
  test/Driver/sanitizer-ld.c


Index: test/Driver/sanitizer-ld.c
===
--- test/Driver/sanitizer-ld.c
+++ test/Driver/sanitizer-ld.c
@@ -263,6 +263,11 @@
 // RUN: --sysroot=%S/Inputs/basic_linux_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-UBSAN-LINUX %s
 
+// RUN: %clang -fsanitize=float-divide-by-zero %s -### -o %t.o 2>&1 \
+// RUN: -target i386-unknown-linux -fuse-ld=ld \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-UBSAN-LINUX %s
+
 // RUN: %clang -fsanitize=undefined %s -### -o %t.o 2>&1 \
 // RUN: -target i386-unknown-linux -fuse-ld=ld \
 // RUN: --sysroot=%S/Inputs/basic_linux_tree \
Index: test/Driver/fsanitize.c
===
--- test/Driver/fsanitize.c
+++ test/Driver/fsanitize.c
@@ -840,3 +840,17 @@
 // CHECK-POINTER-SUB-NEEDS-ADDRESS: error: invalid argument 
'-fsanitize=pointer-subtract' only allowed with '-fsanitize=address'
 // CHECK-NO-POINTER-SUB-NOT: {{.*}}asan-detect-invalid-pointer{{.*}}
 // CHECK-NO-POINTER-CMP-NOT: {{.*}}asan-detect-invalid-pointer{{.*}}
+
+// RUN: %clang -target x86_64-linux -fsanitize=float-divide-by-zero %s -### 
2>&1 | FileCheck %s --check-prefixes=CHECK-DIVBYZERO,CHECK-DIVBYZERO-RECOVER
+// RUN: %clang -target x86_64-linux -fsanitize=float-divide-by-zero %s 
-fno-sanitize-recover=float-divide-by-zero -### 2>&1 | FileCheck %s 
--check-prefixes=CHECK-DIVBYZERO,CHECK-DIVBYZERO-NORECOVER
+// RUN: %clang -target x86_64-linux -fsanitize=float-divide-by-zero 
-fsanitize-trap=float-divide-by-zero %s -### 2>&1 | FileCheck %s 
--check-prefixes=CHECK-DIVBYZERO,CHECK-DIVBYZERO-NORECOVER,CHECK-DIVBYZERO-TRAP
+// CHECK-DIVBYZERO: "-fsanitize=float-divide-by-zero"
+// CHECK-DIVBYZERO-RECOVER: "-fsanitize-recover=float-divide-by-zero"
+// CHECK-DIVBYZERO-NORECOVER-NOT: "-fsanitize-recover=float-divide-by-zero"
+// CHECK-DIVBYZERO-TRAP: "-fsanitize-trap=float-divide-by-zero"
+
+// RUN: %clang -target x86_64-linux -fsanitize=float-divide-by-zero 
-fsanitize-minimal-runtime %s -### 2>&1 | FileCheck %s 
--check-prefixes=CHECK-DIVBYZERO,CHECK-DIVBYZERO-MINIMAL
+// CHECK-DIVBYZERO-MINIMAL: "-fsanitize-minimal-runtime"
+
+// RUN: %clang -target x86_64-linux -fsanitize=undefined,float-divide-by-zero 
%s -### 2>&1 | FileCheck %s --check-prefix=CHECK-DIVBYZERO-UBSAN
+// CHECK-DIVBYZERO-UBSAN: "-fsanitize={{.*}},float-divide-by-zero,{{.*}}"
Index: test/Driver/fsanitize-coverage.c
===
--- test/Driver/fsanitize-coverage.c
+++ test/Driver/fsanitize-coverage.c
@@ -14,6 +14,7 @@
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=undefined 
-fsanitize-coverage=func,trace-pc %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-SANITIZE-COVERAGE-FUNC
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=bool 
-fsanitize-coverage=func,trace-pc %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-SANITIZE-COVERAGE-FUNC
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=dataflow 
-fsanitize-coverage=func,trace-pc %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-SANITIZE-COVERAGE-FUNC
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=float-divide-by-zero 
-fsanitize-coverage=func,trace-pc %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-SANITIZE-COVERAGE-FUNC
 // RUN: %clang -target x86_64-linux-gnu 
-fsanitize-coverage=func,trace-pc %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-SANITIZE-COVERAGE-FUNC
 // CHECK-SANITIZE-COVERAGE-FUNC: fsanitize-coverage-type=1
 
Index: lib/Driver/ToolChain.cpp
===
--- lib/Driver/ToolChain.cpp
+++ lib/Driver/ToolChain.cpp
@@ -896,6 +896,7 @@
~SanitizerKind::Function) |
   (SanitizerKind::CFI & ~SanitizerKind::CFIICall) |
   SanitizerKind::CFICastStrict |
+  SanitizerKind::FloatDivideByZero |
   SanitizerKind::UnsignedIntegerOverflow |
   SanitizerKind::ImplicitConversion |
   SanitizerKind::Nullability | SanitizerKind::LocalBounds;
Index: lib/Driver/SanitizerArgs.cpp
===
--- lib/Driver/SanitizerArgs.cpp
+++ lib/Driver/SanitizerArgs.cpp
@@ -27,7 +27,7 @@
 static const SanitizerMask NeedsUbsanRt =
 SanitizerKind::Undefined | SanitizerKind::Integer |
 SanitizerKind::ImplicitConversion | SanitizerKind::Nullability |
-SanitizerKind::CFI;
+SanitizerKind::CFI | SanitizerKind::FloatDi

[PATCH] D64257: [clangd] Added highlighting for non-builtin types

2019-07-08 Thread Johan Vikström via Phabricator via cfe-commits
jvikstrom updated this revision to Diff 208412.
jvikstrom marked 5 inline comments as done.
jvikstrom added a comment.

Addressed comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64257

Files:
  clang-tools-extra/clangd/SemanticHighlighting.cpp
  clang-tools-extra/clangd/SemanticHighlighting.h
  clang-tools-extra/clangd/test/semantic-highlighting.test
  clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp

Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -34,11 +34,13 @@
   auto AST = TestTU::withCode(Test.code()).build();
   static const std::map KindToString{
   {HighlightingKind::Variable, "Variable"},
-  {HighlightingKind::Function, "Function"}};
+  {HighlightingKind::Function, "Function"},
+  {HighlightingKind::Class, "Class"},
+  {HighlightingKind::Enum, "Enum"}};
   std::vector ExpectedTokens;
   for (const auto &KindString : KindToString) {
-std::vector Toks =
-makeHighlightingTokens(Test.ranges(KindString.second), KindString.first);
+std::vector Toks = makeHighlightingTokens(
+Test.ranges(KindString.second), KindString.first);
 ExpectedTokens.insert(ExpectedTokens.end(), Toks.begin(), Toks.end());
   }
 
@@ -49,14 +51,14 @@
 TEST(SemanticHighlighting, GetsCorrectTokens) {
   const char *TestCases[] = {
 R"cpp(
-  struct AS {
+  struct $Class[[AS]] {
 double SomeMember;
   };
-  struct {
+  $Class[[struct]] {
   } $Variable[[S]];
-  void $Function[[foo]](int $Variable[[A]]) {
+  void $Function[[foo]](int $Variable[[A]], $Class[[AS]] $Variable[[As]]) {
 auto $Variable[[VeryLongVariableName]] = 12312;
-AS $Variable[[AA]];
+$Class[[AS]] $Variable[[AA]];
 auto $Variable[[L]] = $Variable[[AA]].SomeMember + $Variable[[A]];
 auto $Variable[[FN]] = [ $Variable[[AA]]](int $Variable[[A]]) -> void {};
 $Variable[[FN]](12312);
@@ -70,12 +72,40 @@
   }
 )cpp",
 R"cpp(
-  struct A {
-A();
-~A();
+  namespace abc {
+template
+struct $Class[[A]] {
+  T t;
+};
+  }
+  template
+  struct $Class[[C]] : abc::A {
+typename T::A* D;
+  };
+  abc::$Class[[A]] $Variable[[AA]];
+  typedef abc::$Class[[A]] AAA;
+  enum class $Enum[[E]] {};
+  enum $Enum[[EE]] {};
+  struct $Class[[B]] {
+$Enum[[E]] EEE;
+$Enum[[EE]] ;
+$Class[[AAA]] AA;
+  };
+  void $Function[[f]] () {
+$Class[[B]] $Variable[[BB]] = $Class[[B]]();
+$Variable[[BB]].~$Class[[B]]();
+$Class[[B]]();
+  }
+)cpp",
+R"cpp(
+  struct $Class[[A]] {
+$Class[[A]]();
+~$Class[[A]]();
 void $Function[[abc]]();
-void operator<<(int);
+void operator<<($Class[[A]]);
   };
+  $Class[[A]]::$Class[[A]]() {}
+  $Class[[A]]::~$Class[[A]]() {}
 )cpp"};
   for (const auto &TestCase : TestCases) {
 checkHighlightings(TestCase);
Index: clang-tools-extra/clangd/test/semantic-highlighting.test
===
--- clang-tools-extra/clangd/test/semantic-highlighting.test
+++ clang-tools-extra/clangd/test/semantic-highlighting.test
@@ -10,6 +10,12 @@
 # CHECK-NEXT:  [
 # CHECK-NEXT:"entity.name.function.cpp"
 # CHECK-NEXT:  ]
+# CHECK-NEXT:  [
+# CHECK-NEXT:"entity.name.type.class.cpp"
+# CHECK-NEXT:  ],
+# CHECK-NEXT:  [
+# CHECK-NEXT:"entity.name.type.enum.cpp"
+# CHECK-NEXT:  ]
 # CHECK-NEXT:]
 # CHECK-NEXT:  },
 ---
Index: clang-tools-extra/clangd/SemanticHighlighting.h
===
--- clang-tools-extra/clangd/SemanticHighlighting.h
+++ clang-tools-extra/clangd/SemanticHighlighting.h
@@ -26,6 +26,8 @@
 enum class HighlightingKind {
   Variable = 0,
   Function,
+  Class,
+  Enum,
 
   NumKinds,
 };
Index: clang-tools-extra/clangd/SemanticHighlighting.cpp
===
--- clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -35,7 +35,11 @@
   }
 
   bool VisitNamedDecl(NamedDecl *ND) {
-// FIXME: (De)Constructors/operator need to be highlighted some other way.
+if(ND->getDeclName().getNameKind() == DeclarationName::CXXConstructorName) {
+  addToken(ND->getLocation(), ND);
+  return true;
+}
+
 if (ND->getDeclName().getNameKind() != DeclarationName::Identifier)
   return true;
 
@@ -56,8 +60,25 @@
 return true;
   }
 
+  bool

[PATCH] D60456: [RISCV] Hard float ABI support

2019-07-08 Thread Roger Ferrer Ibanez via Phabricator via cfe-commits
rogfer01 added a comment.

> As noted in another comment, it's not entirely clear what zero-width bitfield 
> behaviour to match (see here 
> )
>  as GCC seems buggy and the ABI is under-specified. Ideally I'd like to land 
> this patch and follow-up to adjust the zero-width bitfield behaviour if 
> necessary once that psABI issue is resolved.

Agreed, I presume the original intent in the psABI was to have C and C++ behave 
the same. We're siding with gcc in this patch but it should not be difficult to 
change if the psABI resolves this in favour of g++.


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

https://reviews.llvm.org/D60456



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


[PATCH] D64247: [clangd] Filter out non-governed files from broadcast

2019-07-08 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang-tools-extra/clangd/GlobalCompilationDatabase.cpp:94
+
+  // It doesn't make sense to perform a traversal if user said their 
compilation
+  // database is in a different place. Return that directory for all files.

The duplication here is a bit troublesome.

And we have divergences in behavior - probably not important ones, but I can't 
say I know for sure. (e.g. here we won't create the CDB as a side-effect of 
getPathInfo() if there's a CompileCommandsDir, and will return the dir even if 
the CDB doesn't exist)

I think we might want to have some central logic parameterized by a struct, e.g.
```
struct DirectoryBasedCompilationDatabase::Lookup {
  // inputs
  PathRef File;
  bool ShouldBroadcast;

  // outputs
  tooling::CompilationDatabase *CDB;
  ProjectInfo Info;
  bool EverBroadcast;
};
lookupCDB(Lookup); // replaces getCDBInDirLocked
```



Comment at: clang-tools-extra/clangd/GlobalCompilationDatabase.cpp:176
+std::vector GovernedFiles;
+for (llvm::StringRef File : CDB->getAllFiles()) {
+  auto PI = getProjectInfo(File);

here we're locking/unlocking the mutex maybe thousands of times, to do mostly 
redundant lookups into the cache

Seems worth doing at least one of:
 - deduplicate directories, so we lock once for each distinct directory and 
build a string->bool map. Then use that map to filter the results
 - lock around the whole loop and use getCDBInDirLocked()



Comment at: clang-tools-extra/clangd/index/Background.cpp:653
+auto PI = CDB.getProjectInfo(File);
+assert(PI && "Found CDB but no ProjectInfo!");
+

This looks like a bad assertion: it should be OK to provide compile commands 
but not project info.

(Otherwise getProjectInfo should be pure virtual, but I'm concerned about the 
raciness if we're going to insist they're consistent but not provide any way of 
synchronizing)

I'd suggest we should just not index such files (for now). Later we can start 
passing "" to the index storage factory to get the fallback storage (I think 
today we pass "", but the factory doesn't handle it - oops!)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64247



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


[PATCH] D64257: [clangd] Added highlighting for non-builtin types

2019-07-08 Thread Johan Vikström via Phabricator via cfe-commits
jvikstrom added inline comments.



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:73
+if (auto RD = dyn_cast(D)) {
+  if (auto DC = RD->getDestructor()) {
+auto Range = DC->getSourceRange();

hokein wrote:
> Here is the case:
> 
> ```
> class Foo {
>~Foo
>  // ^~~ we get a TypeLoc whose TagDecl is a cxxRecordDecl.
> }
> ```
> not sure this is expected in clang AST, but it is unreasonable in 
> highlighting context -- ideally, we want to highlight `~Foo` as a destructor 
> (we may encounter a tricky case, like `~ /*comment*/ Foo()`, but I assume 
> this is rarce, should be fine), @sammccall, @ilya-biryukov, thoughts?
Do we want to highlight the entire "~Foo" or only the ~"Foo" for destructors?



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64257



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


[PATCH] D64257: [clangd] Added highlighting for non-builtin types

2019-07-08 Thread Johan Vikström via Phabricator via cfe-commits
jvikstrom updated this revision to Diff 208416.
jvikstrom added a comment.

Clang formatted.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64257

Files:
  clang-tools-extra/clangd/SemanticHighlighting.cpp
  clang-tools-extra/clangd/SemanticHighlighting.h
  clang-tools-extra/clangd/test/semantic-highlighting.test
  clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp

Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -34,11 +34,13 @@
   auto AST = TestTU::withCode(Test.code()).build();
   static const std::map KindToString{
   {HighlightingKind::Variable, "Variable"},
-  {HighlightingKind::Function, "Function"}};
+  {HighlightingKind::Function, "Function"},
+  {HighlightingKind::Class, "Class"},
+  {HighlightingKind::Enum, "Enum"}};
   std::vector ExpectedTokens;
   for (const auto &KindString : KindToString) {
-std::vector Toks =
-makeHighlightingTokens(Test.ranges(KindString.second), KindString.first);
+std::vector Toks = makeHighlightingTokens(
+Test.ranges(KindString.second), KindString.first);
 ExpectedTokens.insert(ExpectedTokens.end(), Toks.begin(), Toks.end());
   }
 
@@ -49,14 +51,14 @@
 TEST(SemanticHighlighting, GetsCorrectTokens) {
   const char *TestCases[] = {
 R"cpp(
-  struct AS {
+  struct $Class[[AS]] {
 double SomeMember;
   };
-  struct {
+  $Class[[struct]] {
   } $Variable[[S]];
-  void $Function[[foo]](int $Variable[[A]]) {
+  void $Function[[foo]](int $Variable[[A]], $Class[[AS]] $Variable[[As]]) {
 auto $Variable[[VeryLongVariableName]] = 12312;
-AS $Variable[[AA]];
+$Class[[AS]] $Variable[[AA]];
 auto $Variable[[L]] = $Variable[[AA]].SomeMember + $Variable[[A]];
 auto $Variable[[FN]] = [ $Variable[[AA]]](int $Variable[[A]]) -> void {};
 $Variable[[FN]](12312);
@@ -70,12 +72,40 @@
   }
 )cpp",
 R"cpp(
-  struct A {
-A();
-~A();
+  namespace abc {
+template
+struct $Class[[A]] {
+  T t;
+};
+  }
+  template
+  struct $Class[[C]] : abc::A {
+typename T::A* D;
+  };
+  abc::$Class[[A]] $Variable[[AA]];
+  typedef abc::$Class[[A]] AAA;
+  enum class $Enum[[E]] {};
+  enum $Enum[[EE]] {};
+  struct $Class[[B]] {
+$Enum[[E]] EEE;
+$Enum[[EE]] ;
+$Class[[AAA]] AA;
+  };
+  void $Function[[f]] () {
+$Class[[B]] $Variable[[BB]] = $Class[[B]]();
+$Variable[[BB]].~$Class[[B]]();
+$Class[[B]]();
+  }
+)cpp",
+R"cpp(
+  struct $Class[[A]] {
+$Class[[A]]();
+~$Class[[A]]();
 void $Function[[abc]]();
-void operator<<(int);
+void operator<<($Class[[A]]);
   };
+  $Class[[A]]::$Class[[A]]() {}
+  $Class[[A]]::~$Class[[A]]() {}
 )cpp"};
   for (const auto &TestCase : TestCases) {
 checkHighlightings(TestCase);
Index: clang-tools-extra/clangd/test/semantic-highlighting.test
===
--- clang-tools-extra/clangd/test/semantic-highlighting.test
+++ clang-tools-extra/clangd/test/semantic-highlighting.test
@@ -10,6 +10,12 @@
 # CHECK-NEXT:  [
 # CHECK-NEXT:"entity.name.function.cpp"
 # CHECK-NEXT:  ]
+# CHECK-NEXT:  [
+# CHECK-NEXT:"entity.name.type.class.cpp"
+# CHECK-NEXT:  ],
+# CHECK-NEXT:  [
+# CHECK-NEXT:"entity.name.type.enum.cpp"
+# CHECK-NEXT:  ]
 # CHECK-NEXT:]
 # CHECK-NEXT:  },
 ---
Index: clang-tools-extra/clangd/SemanticHighlighting.h
===
--- clang-tools-extra/clangd/SemanticHighlighting.h
+++ clang-tools-extra/clangd/SemanticHighlighting.h
@@ -26,6 +26,8 @@
 enum class HighlightingKind {
   Variable = 0,
   Function,
+  Class,
+  Enum,
 
   NumKinds,
 };
Index: clang-tools-extra/clangd/SemanticHighlighting.cpp
===
--- clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -35,7 +35,12 @@
   }
 
   bool VisitNamedDecl(NamedDecl *ND) {
-// FIXME: (De)Constructors/operator need to be highlighted some other way.
+if (ND->getDeclName().getNameKind() ==
+DeclarationName::CXXConstructorName) {
+  addToken(ND->getLocation(), ND);
+  return true;
+}
+
 if (ND->getDeclName().getNameKind() != DeclarationName::Identifier)
   return true;
 
@@ -56,8 +61,27 @@
 return true;
   }
 
+  bool VisitTypeLoc(TypeLoc &TL) {
+// 

r365329 - [RISCV][NFC] Make use of Triple::isRISCV

2019-07-08 Thread Alex Bradbury via cfe-commits
Author: asb
Date: Mon Jul  8 08:07:12 2019
New Revision: 365329

URL: http://llvm.org/viewvc/llvm-project?rev=365329&view=rev
Log:
[RISCV][NFC] Make use of Triple::isRISCV

Use new helper introduced in rL365327.

Modified:
cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
cfe/trunk/lib/Driver/ToolChains/Linux.cpp

Modified: cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Gnu.cpp?rev=365329&r1=365328&r2=365329&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Gnu.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Gnu.cpp Mon Jul  8 08:07:12 2019
@@ -933,10 +933,6 @@ static bool isMicroMips(const ArgList &A
   return A && A->getOption().matches(options::OPT_mmicromips);
 }
 
-static bool isRISCV(llvm::Triple::ArchType Arch) {
-  return Arch == llvm::Triple::riscv32 || Arch == llvm::Triple::riscv64;
-}
-
 static bool isMSP430(llvm::Triple::ArchType Arch) {
   return Arch == llvm::Triple::msp430;
 }
@@ -2312,7 +2308,7 @@ bool Generic_GCC::GCCInstallationDetecto
   } else if (TargetTriple.isMIPS()) {
 if (!findMIPSMultilibs(D, TargetTriple, Path, Args, Detected))
   return false;
-  } else if (isRISCV(TargetArch)) {
+  } else if (TargetTriple.isRISCV()) {
 findRISCVMultilibs(D, TargetTriple, Path, Args, Detected);
   } else if (isMSP430(TargetArch)) {
 findMSP430Multilibs(D, TargetTriple, Path, Args, Detected);

Modified: cfe/trunk/lib/Driver/ToolChains/Linux.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Linux.cpp?rev=365329&r1=365328&r2=365329&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Linux.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Linux.cpp Mon Jul  8 08:07:12 2019
@@ -276,8 +276,7 @@ Linux::Linux(const Driver &D, const llvm
   const bool IsAndroid = Triple.isAndroid();
   const bool IsMips = Triple.isMIPS();
   const bool IsHexagon = Arch == llvm::Triple::hexagon;
-  const bool IsRISCV =
-  Arch == llvm::Triple::riscv32 || Arch == llvm::Triple::riscv64;
+  const bool IsRISCV = Triple.isRISCV();
 
   if (IsMips && !SysRoot.empty())
 ExtraOpts.push_back("--sysroot=" + SysRoot);


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


[PATCH] D64257: [clangd] Added highlighting for non-builtin types

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



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:73
+if (auto RD = dyn_cast(D)) {
+  if (auto DC = RD->getDestructor()) {
+auto Range = DC->getSourceRange();

jvikstrom wrote:
> hokein wrote:
> > Here is the case:
> > 
> > ```
> > class Foo {
> >~Foo
> >  // ^~~ we get a TypeLoc whose TagDecl is a cxxRecordDecl.
> > }
> > ```
> > not sure this is expected in clang AST, but it is unreasonable in 
> > highlighting context -- ideally, we want to highlight `~Foo` as a 
> > destructor (we may encounter a tricky case, like `~ /*comment*/ Foo()`, but 
> > I assume this is rarce, should be fine), @sammccall, @ilya-biryukov, 
> > thoughts?
> Do we want to highlight the entire "~Foo" or only the ~"Foo" for destructors?
> 
based on our discussion, we'd just highlight ~"Foo" as a class type for now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64257



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


[PATCH] D64256: Teach some warnings to respect gsl::Pointer and gsl::Owner attributes

2019-07-08 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun marked 5 inline comments as done.
xazax.hun added inline comments.



Comment at: clang/lib/Sema/SemaInit.cpp:6510
 LifetimeBoundCall,
+LifetimePointerInit,
+LifetimeTempOwner

gribozavr wrote:
> What is this name supposed to mean? Initialization of a "lifetime pointer"? 
> What's a "lifetime pointer"?
> 
> If you were imitating "LifetimeBoundCall", it is a reference to the 
> attribute: https://clang.llvm.org/docs/AttributeReference.html#lifetimebound .
When we were working on the lifetime analysis we needed to distinguish raw 
pointers from the user defined types that are categorized as pointers. We 
adopted this notion of Lifetime Pointer which stands for the user defined type 
that is annotated with gsl::Pointer.

In case this is confusing I could rename it `GslPointerInit` and 
`GslTempOwner`. What do you think?



Comment at: clang/lib/Sema/SemaInit.cpp:7049
 
+// Skipping a chain of initializing lifetime Pointer objects.
+// We are looking only for the final value to find out if it was

gribozavr wrote:
> Sorry, I can't parse this: "... initializing lifetime Pointer ..."
We called gsl::Pointer annotated types lifetime pointers (to distinguish from 
raw pointers). Should we use gsl::Pointer in the comments too? Or do you have 
an alternative in mind?



Comment at: clang/test/Sema/warn-lifetime-analysis-nocfg.cpp:16
+
+struct [[gsl::Owner(int)]] T {
+  T();

gribozavr wrote:
> Can `T` and `MyOwner` be the same type?
> 
> It is confusing to have two -- for example, `toOwner()` returning `T` instead 
> of `MyOwner` is confusing.
I agree that T might not be a great name. The reason why we have two types 
because one can be converted to a Pointer using a conversion operator the other 
can be converted using a one argument non-explicit constructor. These two are 
generating different ASTs, thus I wanted to test both ways. 



Comment at: clang/test/Sema/warn-lifetime-analysis-nocfg.cpp:33
+  MyPointer p{&i}; // ok
+  new MyPointer(MyPointer{p}); // ok
+}

gribozavr wrote:
> Why is the last line OK? Looks like a false negative to me -- the pointer on 
> the heap is pointing to a local variable, just like in `f`, which produces a 
> warning.
> 
> If it is an intentional false negative, please annotate it as such in 
> comments.
Yeah, this is an intentional false negative as we do not have enough 
information in a statement local analysis to warn about this case. Will fix the 
comment thanks!



Comment at: clang/test/Sema/warn-lifetime-analysis-nocfg.cpp:38
+  T t;
+  return t.release(); // ok
+}

gribozavr wrote:
> Is "release" a magic name that the warning understands?
Method calls are not handled yet, but the idea is to understand some STL 
specific methods, like the `std::unique_ptr::release`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64256



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


[PATCH] D61681: [clangd] A code tweak to expand a macro

2019-07-08 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clang-tools-extra/clangd/refactor/tweaks/ExpandMacro.cpp:57
+  if (It == Spelled.begin())
+return Spelled.end();
+  // Check the token we found actually touches the cursor position.

sammccall wrote:
> it's pretty weird for a function whose return type is spelled "Token*" to use 
> Spelled.end() rather than nullptr as a sentinel
Yeah, especially given that the function below uses `nullptr` as a sentinel...
Thanks for pointing this out!



Comment at: clang-tools-extra/clangd/unittests/TweakTests.cpp:288
+#define FUNC(X) X+X+X
+^F^O^O^ BAR ^F^O^O^
+^F^U^N^C^(1)

sammccall wrote:
> Can you verify we don't trigger here? `FOO[[ ]]BAR`
> 
> The zero-width range in `FOO^ BAR` is indeed interpreted as pointing at FOO 
> by SelectionTree, but that's a whitespace-sensitive heuristic.
> 
> Given
> ```
> int x(int);
> #define B x
> int y = B^(42);
> ```
> 
> The `^` points at the `(`. (Maybe we should lift this logic into 
> Tweak::Selection)
It does trigger, unfortunately. There is no way to unbreak this, as we don't 
have a way to get the selection range in inputs of the tweak.
I've added a FIXME, will address with a follow-up.

Note that we don't use selection tree, as it's AST-based and we need 
token-level information for that tweak (that's pretty unique, I expect most 
tweaks are not like that)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61681



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


[PATCH] D61681: [clangd] A code tweak to expand a macro

2019-07-08 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 208425.
ilya-biryukov marked 5 inline comments as done.
ilya-biryukov added a comment.

- Replace bsearch with partition_point.
- Include macro name in the title.
- Added a FIXME for empty selection case.
- Return null when no token is found.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61681

Files:
  clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt
  clang-tools-extra/clangd/refactor/tweaks/ExpandMacro.cpp
  clang-tools-extra/clangd/unittests/TweakTests.cpp
  clang/include/clang/Tooling/Syntax/Tokens.h

Index: clang/include/clang/Tooling/Syntax/Tokens.h
===
--- clang/include/clang/Tooling/Syntax/Tokens.h
+++ clang/include/clang/Tooling/Syntax/Tokens.h
@@ -66,6 +66,15 @@
 
   unsigned length() const { return End - Begin; }
 
+  /// Check if \p Offset is inside the range.
+  bool contains(unsigned Offset) const {
+return Begin <= Offset && Offset < End;
+  }
+  /// Check \p Offset is inside the range or equal to its endpoint.
+  bool touches(unsigned Offset) const {
+return Begin <= Offset && Offset <= End;
+  }
+
   /// Gets the substring that this FileRange refers to.
   llvm::StringRef text(const SourceManager &SM) const;
 
Index: clang-tools-extra/clangd/unittests/TweakTests.cpp
===
--- clang-tools-extra/clangd/unittests/TweakTests.cpp
+++ clang-tools-extra/clangd/unittests/TweakTests.cpp
@@ -286,6 +286,99 @@
   checkTransform(ID, Input, Output);
 }
 
+TEST(TweakTest, ExpandMacro) {
+  llvm::StringLiteral ID = "ExpandMacro";
+
+  // Available on macro names, not available anywhere else.
+  checkAvailable(ID, R"cpp(
+#define FOO 1 2 3
+#define FUNC(X) X+X+X
+^F^O^O^ BAR ^F^O^O^
+^F^U^N^C^(1)
+)cpp");
+  checkNotAvailable(ID, R"cpp(
+^#^d^efine^ ^FO^O 1 ^2 ^3^
+FOO ^B^A^R^ FOO ^
+FUNC(^1^)^
+)cpp");
+
+  // Works as expected on object-like macros.
+  checkTransform(ID, R"cpp(
+#define FOO 1 2 3
+^FOO BAR FOO
+)cpp",
+ R"cpp(
+#define FOO 1 2 3
+1 2 3 BAR FOO
+)cpp");
+  checkTransform(ID, R"cpp(
+#define FOO 1 2 3
+FOO BAR ^FOO
+)cpp",
+ R"cpp(
+#define FOO 1 2 3
+FOO BAR 1 2 3
+)cpp");
+
+  // And function-like macros.
+  checkTransform(ID, R"cpp(
+#define FUNC(X) X+X+X
+F^UNC(2)
+)cpp",
+ R"cpp(
+#define FUNC(X) X+X+X
+2 + 2 + 2
+)cpp");
+
+  // Works on empty macros.
+  checkTransform(ID, R"cpp(
+#define EMPTY
+int a ^EMPTY;
+  )cpp",
+ R"cpp(
+#define EMPTY
+int a ;
+  )cpp");
+  checkTransform(ID, R"cpp(
+#define EMPTY_FN(X)
+int a ^EMPTY_FN(1 2 3);
+  )cpp",
+ R"cpp(
+#define EMPTY_FN(X)
+int a ;
+  )cpp");
+  checkTransform(ID, R"cpp(
+#define EMPTY
+#define EMPTY_FN(X)
+int a = 123 ^EMPTY EMPTY_FN(1);
+  )cpp",
+ R"cpp(
+#define EMPTY
+#define EMPTY_FN(X)
+int a = 123  EMPTY_FN(1);
+  )cpp");
+  checkTransform(ID, R"cpp(
+#define EMPTY
+#define EMPTY_FN(X)
+int a = 123 ^EMPTY_FN(1) EMPTY;
+  )cpp",
+ R"cpp(
+#define EMPTY
+#define EMPTY_FN(X)
+int a = 123  EMPTY;
+  )cpp");
+  checkTransform(ID, R"cpp(
+#define EMPTY
+#define EMPTY_FN(X)
+int a = 123 EMPTY_FN(1) ^EMPTY;
+  )cpp",
+ R"cpp(
+#define EMPTY
+#define EMPTY_FN(X)
+int a = 123 EMPTY_FN(1) ;
+  )cpp");
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/refactor/tweaks/ExpandMacro.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/refactor/tweaks/ExpandMacro.cpp
@@ -0,0 +1,136 @@
+//===--- ExpandMacro.cpp -*- C++-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "refactor/Tweak.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/SourceManager.h"
+#include "clang/Basic/TokenKinds.h"
+#include "clang/Tooling/Core/Replacement.h"
+#include "clang/Tooling/Syntax/Tokens.h"
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/Support/Error.h"
+#include 
+namespace clang {
+namespace clangd {
+namespace {
+
+/// Replaces a reference to a macro under the cursor with its expansion.
+/// Before:
+///   #define FOO(X) X+X
+///   FOO(10*a)
+///   ^^^
+/// After:
+///   #define FOO(X) X+X
+///   10*a+10*a
+class ExpandMacro : public Tweak {
+public:
+  const char *id() const override final;
+  Intent intent() const override { return Intent::Refactor; }
+
+  bool prepare(const Selection &Inputs) override;
+  Expected apply(const Selection &Inputs) override;
+  std::string title() const override;
+
+private:
+

[PATCH] D63756: [AMDGPU] Increased the number of implicit argument bytes for both OpenCL and HIP (CLANG).

2019-07-08 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl accepted this revision.
yaxunl added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks.


Repository:
  rC Clang

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

https://reviews.llvm.org/D63756



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


[clang-tools-extra] r365331 - [clangd] A code tweak to expand a macro

2019-07-08 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Mon Jul  8 08:25:16 2019
New Revision: 365331

URL: http://llvm.org/viewvc/llvm-project?rev=365331&view=rev
Log:
[clangd] A code tweak to expand a macro

Reviewers: sammccall

Reviewed By: sammccall

Subscribers: mgorny, MaskRay, jkorous, arphaman, kadircet, cfe-commits

Tags: #clang

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

Added:
clang-tools-extra/trunk/clangd/refactor/tweaks/ExpandMacro.cpp
Modified:
clang-tools-extra/trunk/clangd/refactor/tweaks/CMakeLists.txt
clang-tools-extra/trunk/clangd/unittests/TweakTests.cpp

Modified: clang-tools-extra/trunk/clangd/refactor/tweaks/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/refactor/tweaks/CMakeLists.txt?rev=365331&r1=365330&r2=365331&view=diff
==
--- clang-tools-extra/trunk/clangd/refactor/tweaks/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clangd/refactor/tweaks/CMakeLists.txt Mon Jul  8 
08:25:16 2019
@@ -14,6 +14,7 @@ set(LLVM_LINK_COMPONENTS
 add_clang_library(clangDaemonTweaks OBJECT
   AnnotateHighlightings.cpp
   DumpAST.cpp
+  ExpandMacro.cpp
   RawStringLiteral.cpp
   SwapIfBranches.cpp
 
@@ -22,4 +23,5 @@ add_clang_library(clangDaemonTweaks OBJE
   clangBasic
   clangDaemon
   clangToolingCore
+  clangToolingSyntax
   )

Added: clang-tools-extra/trunk/clangd/refactor/tweaks/ExpandMacro.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/refactor/tweaks/ExpandMacro.cpp?rev=365331&view=auto
==
--- clang-tools-extra/trunk/clangd/refactor/tweaks/ExpandMacro.cpp (added)
+++ clang-tools-extra/trunk/clangd/refactor/tweaks/ExpandMacro.cpp Mon Jul  8 
08:25:16 2019
@@ -0,0 +1,136 @@
+//===--- ExpandMacro.cpp -*- 
C++-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "refactor/Tweak.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/SourceManager.h"
+#include "clang/Basic/TokenKinds.h"
+#include "clang/Tooling/Core/Replacement.h"
+#include "clang/Tooling/Syntax/Tokens.h"
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/Support/Error.h"
+#include 
+namespace clang {
+namespace clangd {
+namespace {
+
+/// Replaces a reference to a macro under the cursor with its expansion.
+/// Before:
+///   #define FOO(X) X+X
+///   FOO(10*a)
+///   ^^^
+/// After:
+///   #define FOO(X) X+X
+///   10*a+10*a
+class ExpandMacro : public Tweak {
+public:
+  const char *id() const override final;
+  Intent intent() const override { return Intent::Refactor; }
+
+  bool prepare(const Selection &Inputs) override;
+  Expected apply(const Selection &Inputs) override;
+  std::string title() const override;
+
+private:
+  syntax::TokenBuffer::Expansion Expansion;
+  std::string MacroName;
+};
+
+REGISTER_TWEAK(ExpandMacro)
+
+/// Finds a spelled token that the cursor is pointing at.
+static const syntax::Token *
+findTokenUnderCursor(const SourceManager &SM,
+ llvm::ArrayRef Spelled,
+ unsigned CursorOffset) {
+  // Find the token that strats after the offset, then look at a previous one.
+  auto It = llvm::partition_point(Spelled, [&](const syntax::Token &T) {
+assert(T.location().isFileID());
+return SM.getFileOffset(T.location()) <= CursorOffset;
+  });
+  if (It == Spelled.begin())
+return nullptr;
+  // Check the token we found actually touches the cursor position.
+  --It;
+  return It->range(SM).touches(CursorOffset) ? It : nullptr;
+}
+
+static const syntax::Token *
+findIdentifierUnderCursor(const syntax::TokenBuffer &Tokens,
+  SourceLocation Cursor) {
+  assert(Cursor.isFileID());
+
+  auto &SM = Tokens.sourceManager();
+  auto Spelled = Tokens.spelledTokens(SM.getFileID(Cursor));
+
+  auto *T = findTokenUnderCursor(SM, Spelled, SM.getFileOffset(Cursor));
+  if (!T)
+return nullptr;
+  if (T->kind() == tok::identifier)
+return T;
+  // Also try the previous token when the cursor is at the boundary, e.g.
+  //   FOO^()
+  //   FOO^+
+  if (T == Spelled.begin())
+return nullptr;
+  --T;
+  if (T->endLocation() != Cursor || T->kind() != tok::identifier)
+return nullptr;
+  return T;
+}
+
+bool ExpandMacro::prepare(const Selection &Inputs) {
+  // FIXME: we currently succeed on selection at the end of the token, e.g.
+  //'FOO[[ ]]BAR'. We should not trigger in that case.
+
+  // Find a token under the cursor.
+  auto *T = findIdentifierUnderCursor(Inputs.AST.getTokens(), Inputs.Cursor);
+  // We are interested only in identifiers, other tokens can't be macro 

r365331 - [clangd] A code tweak to expand a macro

2019-07-08 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Mon Jul  8 08:25:16 2019
New Revision: 365331

URL: http://llvm.org/viewvc/llvm-project?rev=365331&view=rev
Log:
[clangd] A code tweak to expand a macro

Reviewers: sammccall

Reviewed By: sammccall

Subscribers: mgorny, MaskRay, jkorous, arphaman, kadircet, cfe-commits

Tags: #clang

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

Modified:
cfe/trunk/include/clang/Tooling/Syntax/Tokens.h

Modified: cfe/trunk/include/clang/Tooling/Syntax/Tokens.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Syntax/Tokens.h?rev=365331&r1=365330&r2=365331&view=diff
==
--- cfe/trunk/include/clang/Tooling/Syntax/Tokens.h (original)
+++ cfe/trunk/include/clang/Tooling/Syntax/Tokens.h Mon Jul  8 08:25:16 2019
@@ -66,6 +66,15 @@ struct FileRange {
 
   unsigned length() const { return End - Begin; }
 
+  /// Check if \p Offset is inside the range.
+  bool contains(unsigned Offset) const {
+return Begin <= Offset && Offset < End;
+  }
+  /// Check \p Offset is inside the range or equal to its endpoint.
+  bool touches(unsigned Offset) const {
+return Begin <= Offset && Offset <= End;
+  }
+
   /// Gets the substring that this FileRange refers to.
   llvm::StringRef text(const SourceManager &SM) const;
 


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


[PATCH] D61681: [clangd] A code tweak to expand a macro

2019-07-08 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL365331: [clangd] A code tweak to expand a macro (authored by 
ibiryukov, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D61681?vs=208425&id=208426#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D61681

Files:
  cfe/trunk/include/clang/Tooling/Syntax/Tokens.h
  clang-tools-extra/trunk/clangd/refactor/tweaks/CMakeLists.txt
  clang-tools-extra/trunk/clangd/refactor/tweaks/ExpandMacro.cpp
  clang-tools-extra/trunk/clangd/unittests/TweakTests.cpp

Index: clang-tools-extra/trunk/clangd/refactor/tweaks/CMakeLists.txt
===
--- clang-tools-extra/trunk/clangd/refactor/tweaks/CMakeLists.txt
+++ clang-tools-extra/trunk/clangd/refactor/tweaks/CMakeLists.txt
@@ -14,6 +14,7 @@
 add_clang_library(clangDaemonTweaks OBJECT
   AnnotateHighlightings.cpp
   DumpAST.cpp
+  ExpandMacro.cpp
   RawStringLiteral.cpp
   SwapIfBranches.cpp
 
@@ -22,4 +23,5 @@
   clangBasic
   clangDaemon
   clangToolingCore
+  clangToolingSyntax
   )
Index: clang-tools-extra/trunk/clangd/refactor/tweaks/ExpandMacro.cpp
===
--- clang-tools-extra/trunk/clangd/refactor/tweaks/ExpandMacro.cpp
+++ clang-tools-extra/trunk/clangd/refactor/tweaks/ExpandMacro.cpp
@@ -0,0 +1,136 @@
+//===--- ExpandMacro.cpp -*- C++-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "refactor/Tweak.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/SourceManager.h"
+#include "clang/Basic/TokenKinds.h"
+#include "clang/Tooling/Core/Replacement.h"
+#include "clang/Tooling/Syntax/Tokens.h"
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/Support/Error.h"
+#include 
+namespace clang {
+namespace clangd {
+namespace {
+
+/// Replaces a reference to a macro under the cursor with its expansion.
+/// Before:
+///   #define FOO(X) X+X
+///   FOO(10*a)
+///   ^^^
+/// After:
+///   #define FOO(X) X+X
+///   10*a+10*a
+class ExpandMacro : public Tweak {
+public:
+  const char *id() const override final;
+  Intent intent() const override { return Intent::Refactor; }
+
+  bool prepare(const Selection &Inputs) override;
+  Expected apply(const Selection &Inputs) override;
+  std::string title() const override;
+
+private:
+  syntax::TokenBuffer::Expansion Expansion;
+  std::string MacroName;
+};
+
+REGISTER_TWEAK(ExpandMacro)
+
+/// Finds a spelled token that the cursor is pointing at.
+static const syntax::Token *
+findTokenUnderCursor(const SourceManager &SM,
+ llvm::ArrayRef Spelled,
+ unsigned CursorOffset) {
+  // Find the token that strats after the offset, then look at a previous one.
+  auto It = llvm::partition_point(Spelled, [&](const syntax::Token &T) {
+assert(T.location().isFileID());
+return SM.getFileOffset(T.location()) <= CursorOffset;
+  });
+  if (It == Spelled.begin())
+return nullptr;
+  // Check the token we found actually touches the cursor position.
+  --It;
+  return It->range(SM).touches(CursorOffset) ? It : nullptr;
+}
+
+static const syntax::Token *
+findIdentifierUnderCursor(const syntax::TokenBuffer &Tokens,
+  SourceLocation Cursor) {
+  assert(Cursor.isFileID());
+
+  auto &SM = Tokens.sourceManager();
+  auto Spelled = Tokens.spelledTokens(SM.getFileID(Cursor));
+
+  auto *T = findTokenUnderCursor(SM, Spelled, SM.getFileOffset(Cursor));
+  if (!T)
+return nullptr;
+  if (T->kind() == tok::identifier)
+return T;
+  // Also try the previous token when the cursor is at the boundary, e.g.
+  //   FOO^()
+  //   FOO^+
+  if (T == Spelled.begin())
+return nullptr;
+  --T;
+  if (T->endLocation() != Cursor || T->kind() != tok::identifier)
+return nullptr;
+  return T;
+}
+
+bool ExpandMacro::prepare(const Selection &Inputs) {
+  // FIXME: we currently succeed on selection at the end of the token, e.g.
+  //'FOO[[ ]]BAR'. We should not trigger in that case.
+
+  // Find a token under the cursor.
+  auto *T = findIdentifierUnderCursor(Inputs.AST.getTokens(), Inputs.Cursor);
+  // We are interested only in identifiers, other tokens can't be macro names.
+  if (!T)
+return false;
+  // If the identifier is a macro we will find the corresponding expansion.
+  auto Expansion = Inputs.AST.getTokens().expansionStartingAt(T);
+  if (!Expansion)
+return false;
+  this->MacroName = T->text(Inputs.AST.getSourceManager());
+  this->Expansion = *Expans

[PATCH] D64349: clang-cl: Port cl.exe's C4659 to clang-cl

2019-07-08 Thread Nico Weber via Phabricator via cfe-commits
thakis created this revision.
thakis added a reviewer: rnk.

https://reviews.llvm.org/D64349

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaAttr.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/Sema/pragma-section.c

Index: clang/test/Sema/pragma-section.c
===
--- clang/test/Sema/pragma-section.c
+++ clang/test/Sema/pragma-section.c
@@ -42,3 +42,17 @@
 #pragma section(".my_seg", nopage) // expected-warning {{known but unsupported action 'nopage' for '#pragma section' - ignored}}
 #pragma section(".my_seg", read, write) // expected-error {{this causes a section type conflict with a prior #pragma section}}
 #pragma section(".my_seg", read, write, 1) //  expected-warning {{expected action or ')' in '#pragma section' - ignored}}
+
+#pragma bss_seg(".drectve") // expected-warning{{#pragma bss_seg(".drectve") has undefined behavior, use #pragma comment(linker, ...) instead}}
+#pragma code_seg(".drectve") // expected-warning{{#pragma code_seg(".drectve") has undefined behavior, use #pragma comment(linker, ...) instead}} 
+#pragma const_seg(".drectve")  // expected-warning{{#pragma const_seg(".drectve") has undefined behavior, use #pragma comment(linker, ...) instead}}
+#pragma data_seg(".drectve")  // expected-warning{{#pragma data_seg(".drectve") has undefined behavior, use #pragma comment(linker, ...) instead}}
+#pragma code_seg(".my_seg")
+
+// cl.exe doesn't warn on this, so match that.
+// (Technically it ICEs on this particular example, but if it's on a class then
+// it just doesn't warn.)
+__declspec(code_seg(".drectve")) void drectve_fn(void) {}
+
+// Not sure if this should warn or not.
+__attribute__((section(".drectve"))) int drectve_int;
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -2280,8 +2280,9 @@
   // For the MS ABI, propagate DLL attributes to base class templates.
   if (Context.getTargetInfo().getCXXABI().isMicrosoft()) {
 if (Attr *ClassAttr = getDLLAttr(Class)) {
-  if (auto *BaseTemplate = dyn_cast_or_null(
-  BaseType->getAsCXXRecordDecl())) {
+  if (auto *BaseTemplate =
+  dyn_cast_or_null(
+  BaseType->getAsCXXRecordDecl())) {
 propagateDLLAttrToBaseClassTemplate(Class, ClassAttr, BaseTemplate,
 BaseLoc);
   }
@@ -2311,7 +2312,8 @@
   const auto *BaseCSA = CXXBaseDecl->getAttr();
   const auto *DerivedCSA = Class->getAttr();
   if ((DerivedCSA || BaseCSA) &&
-  (!BaseCSA || !DerivedCSA || BaseCSA->getName() != DerivedCSA->getName())) {
+  (!BaseCSA || !DerivedCSA ||
+   BaseCSA->getName() != DerivedCSA->getName())) {
 Diag(Class->getLocation(), diag::err_mismatched_code_seg_base);
 Diag(CXXBaseDecl->getLocation(), diag::note_base_class_specified_here)
   << CXXBaseDecl;
@@ -5665,7 +5667,8 @@
   for (auto *Method : Class->methods()) {
 if (Method->isUserProvided())
   continue;
-if (Attr *A = getImplicitCodeSegOrSectionAttrForFunction(Method, /*IsDefinition=*/true))
+if (Attr *A = getImplicitCodeSegOrSectionAttrForFunction(
+Method, /*IsDefinition=*/true))
   Method->addAttr(A);
   }
 }
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -3011,13 +3011,18 @@
 D->addAttr(NewAttr);
 }
 
-static bool checkCodeSegName(Sema&S, SourceLocation LiteralLoc, StringRef CodeSegName) {
-  std::string Error = S.Context.getTargetInfo().isValidSectionSpecifier(CodeSegName);
+// This is used for `__declspec(code_seg("segname"))` on a decl.
+// `#pragma code_seg("segname")` uses checkSectionName() instead.
+static bool checkCodeSegName(Sema &S, SourceLocation LiteralLoc,
+ StringRef CodeSegName) {
+  std::string Error =
+  S.Context.getTargetInfo().isValidSectionSpecifier(CodeSegName);
   if (!Error.empty()) {
-S.Diag(LiteralLoc, diag::err_attribute_section_invalid_for_target) << Error
-   << 0 /*'code-seg'*/;
+S.Diag(LiteralLoc, diag::err_attribute_section_invalid_for_target)
+<< Error << 0 /*'code-seg'*/;
 return false;
   }
+
   return true;
 }
 
Index: clang/lib/Sema/SemaAttr.cpp
===
--- clang/lib/Sema/SemaAttr.cpp
+++ clang/lib/Sema/SemaAttr.cpp
@@ -403,9 +403,15 @@
   if (Action & PSK_Pop && Stack->Stack.empty())
 Diag(PragmaLocation, diag::warn_pragma_pop_failed) << PragmaName
 << "stack empty";
-  if (SegmentName &&
-  !checkSectionName(SegmentName->getBeginLoc(), SegmentName->getString()))
-return;
+  if (SegmentName) {

[PATCH] D64128: [CodeGen] Generate llvm.ptrmask instead of inttoptr(and(ptrtoint, C)) if possible.

2019-07-08 Thread Hal Finkel via Phabricator via cfe-commits
hfinkel added a comment.

In D64128#1572504 , @rjmccall wrote:

> I would be opposed to any addition of a `-f` flag for this absent any 
> evidence that it's valuable for some actual C code; this patch appears to be 
> purely speculative.  I certainly don't think we should be adding it 
> default-on.  Your argument about alignment is what I was referring to when I 
> mentioned that this is enforcing alignment restrictions in places we 
> traditionally and intentionally haven't.


My underlying thought here is: The more we generate a particular IR construct 
the more quickly we'll find the bugs and the better we'll end up optimizing it. 
Thus, I found the idea behind this patch appealing. My experience is also that 
providing more pointer underlying-object information tends to help code 
quality. However, I definitely see your point that this is potentially risky: 
bugs uncovered by generating this intrinsic based on this code pattern might 
reveal only code doing interesting things with pointer bits and not actual 
optimizer bugs. I think that we have different feelings on the magnitude of 
that risk, but I definitely glad that you weighed in here.

I suggest that we drop this unless and until we have benchmark data showing it 
to be useful. If we do, then we can consider an off-by-default flag. It will 
also be interesting to explore adding a Clang intrinsic.

> Note that it won't help Clang's major uses of `PointerIntPair` and 
> `PointerUnion` because our traits say that types like `Decl` and `Type` have 
> more alignment bits than their formal alignment would indicate, and 
> `PointerIntPair` occupies alignment bits starting with the most significant.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64128



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


[PATCH] D64256: Teach some warnings to respect gsl::Pointer and gsl::Owner attributes

2019-07-08 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added inline comments.



Comment at: clang/test/Sema/warn-lifetime-analysis-nocfg.cpp:22
+  int *release2();
+  int *c_str() const;
+};

gribozavr wrote:
> This method is confusing -- is it a name that the warning is supposed to know 
> about?
Not yet, see my other answer below.


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

https://reviews.llvm.org/D64256



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


[PATCH] D64256: Teach some warnings to respect gsl::Pointer and gsl::Owner attributes

2019-07-08 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun updated this revision to Diff 208439.
xazax.hun marked 12 inline comments as done.
xazax.hun added a comment.

- Address review comments.


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

https://reviews.llvm.org/D64256

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaInit.cpp
  clang/test/Sema/warn-lifetime-analysis-nocfg.cpp

Index: clang/test/Sema/warn-lifetime-analysis-nocfg.cpp
===
--- /dev/null
+++ clang/test/Sema/warn-lifetime-analysis-nocfg.cpp
@@ -0,0 +1,108 @@
+// RUN: %clang_cc1 -fsyntax-only -Wdangling -Wdangling-field -Wreturn-stack-address -verify %s
+struct [[gsl::Owner(int)]] MyOwner {
+  MyOwner();
+  int &operator*();
+};
+
+struct OwnerWithConv;
+
+// Conversion operator and constructor conversion will result in two
+// different shaped ASTs. Thus we have two owner types in the tests.
+struct [[gsl::Pointer(int)]] MyPointer {
+  MyPointer(int *p = nullptr);
+  MyPointer(const MyOwner &);
+  int &operator*();
+  OwnerWithConv toOwner();
+};
+
+struct [[gsl::Owner(int)]] OwnerWithConv {
+  OwnerWithConv();
+  operator MyPointer();
+  int &operator*();
+  MyPointer releaseAsMyPointer();
+  int *releaseAsRawPointer();
+  int *c_str() const;
+};
+
+void danglingHeapObject() {
+  new MyPointer(OwnerWithConv{}); // expected-warning {{object backing the pointer will be destroyed at the end of the full-expression}}
+  new MyPointer(MyOwner{}); // expected-warning {{object backing the pointer will be destroyed at the end of the full-expression}}
+}
+
+void intentionalFalseNegative() {
+  int i;
+  MyPointer p{&i};
+  // In this case we do not have enough information in a statement local
+  // analysis to detect the problem.
+  new MyPointer(MyPointer{p});
+}
+
+MyPointer ownershipTransferToMyPointer() {
+  OwnerWithConv t;
+  return t.releaseAsMyPointer(); // ok
+}
+
+int *ownershipTransferToRawPointer() {
+  OwnerWithConv t;
+  return t.releaseAsRawPointer(); // ok
+}
+
+int *danglingRawPtrFromLocal() {
+  OwnerWithConv t;
+  return t.c_str(); // TODO
+}
+
+int *danglingRawPtrFromTemp() {
+  MyPointer p;
+  return p.toOwner().c_str(); // TODO
+}
+
+struct Y {
+  int a[4];
+};
+
+void dangligGslPtrFromTemporary() {
+  MyPointer p = Y{}.a; // expected-warning {{temporary whose address is used as value of local variable 'p' will be destroyed at the end of the full-expression}}
+  (void)p;
+}
+
+struct DanglingGslPtrField {
+  MyPointer p; // expected-note 3{{pointer member declared here}}
+  DanglingGslPtrField(int i) : p(&i) {} // expected-warning {{initializing pointer member 'p' with the stack address of parameter 'i'}}
+  DanglingGslPtrField() : p(OwnerWithConv{}) {} // expected-warning {{initializing pointer member 'p' to point to a temporary object whose lifetime is shorter than the lifetime of the constructed object}}
+  DanglingGslPtrField(double) : p(MyOwner{}) {} // expected-warning {{initializing pointer member 'p' to point to a temporary object whose lifetime is shorter than the lifetime of the constructed object}}
+};
+
+MyPointer danglingGslPtrFromLocal() {
+  int j;
+  return &j; // expected-warning {{address of stack memory associated with local variable 'j' returned}}
+}
+
+MyPointer daglingGslPtrFromLocalOwner() {
+  OwnerWithConv t;
+  return t; // TODO
+}
+
+MyPointer danglingGslPtrFromTemporary() {
+  return OwnerWithConv{}; // expected-warning {{returning address of local temporary object}}
+}
+
+MyPointer global;
+
+void initLocalGslPtrWithTempOwner() {
+  MyPointer p = MyOwner{}; // expected-warning {{object backing the pointer will be destroyed at the end of the full-expression}}
+  p = MyOwner{}; // TODO ?
+  global = MyOwner{}; // TODO ?
+  p = OwnerWithConv{}; // TODO ?
+  global = OwnerWithConv{}; // TODO ?
+}
+
+struct IntVector {
+  int *begin();
+  int *end();
+};
+
+void modelIterators() {
+  int *it = IntVector{}.begin(); // TODO ?
+  (void)it;
+}
Index: clang/lib/Sema/SemaInit.cpp
===
--- clang/lib/Sema/SemaInit.cpp
+++ clang/lib/Sema/SemaInit.cpp
@@ -6507,6 +6507,8 @@
 VarInit,
 LValToRVal,
 LifetimeBoundCall,
+GslPointerInit,
+GslTempPointer
   } Kind;
   Expr *E;
   const Decl *D = nullptr;
@@ -6543,6 +6545,13 @@
   });
 }
 
+static bool
+pathInitializeLifetimePointer(llvm::ArrayRef Path) {
+  return Path.size() > 0 && llvm::all_of(Path, [=](IndirectLocalPathEntry E) {
+return E.Kind == IndirectLocalPathEntry::GslPointerInit;
+  });
+}
+
 static void visitLocalsRetainedByInitializer(IndirectLocalPath &Path,
  Expr *Init, LocalVisitor Visit,
  bool RevisitSubinits);
@@ -6551,6 +6560,47 @@
   Expr *Init, ReferenceKind RK,
   LocalVisitor Visit);
 
+template
+static bool record

[PATCH] D53157: Teach the IRBuilder about constrained fadd and friends

2019-07-08 Thread Kevin P. Neal via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rL365339: Teach the IRBuilder about fadd and friends. 
(authored by kpn, committed by ).
Herald added a project: LLVM.

Changed prior to commit:
  https://reviews.llvm.org/D53157?vs=207829&id=208440#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D53157

Files:
  llvm/trunk/include/llvm/IR/IRBuilder.h
  llvm/trunk/include/llvm/IR/IntrinsicInst.h
  llvm/trunk/lib/IR/IntrinsicInst.cpp
  llvm/trunk/lib/IR/Verifier.cpp
  llvm/trunk/unittests/IR/IRBuilderTest.cpp

Index: llvm/trunk/lib/IR/IntrinsicInst.cpp
===
--- llvm/trunk/lib/IR/IntrinsicInst.cpp
+++ llvm/trunk/lib/IR/IntrinsicInst.cpp
@@ -103,39 +103,86 @@
   return ConstantInt::get(Type::getInt64Ty(Context), 1);
 }
 
-ConstrainedFPIntrinsic::RoundingMode
+Optional
 ConstrainedFPIntrinsic::getRoundingMode() const {
   unsigned NumOperands = getNumArgOperands();
   Metadata *MD =
   dyn_cast(getArgOperand(NumOperands - 2))->getMetadata();
   if (!MD || !isa(MD))
-return rmInvalid;
-  StringRef RoundingArg = cast(MD)->getString();
+return None;
+  return StrToRoundingMode(cast(MD)->getString());
+}
 
+Optional
+ConstrainedFPIntrinsic::StrToRoundingMode(StringRef RoundingArg) {
   // For dynamic rounding mode, we use round to nearest but we will set the
   // 'exact' SDNodeFlag so that the value will not be rounded.
-  return StringSwitch(RoundingArg)
+  return StringSwitch>(RoundingArg)
 .Case("round.dynamic",rmDynamic)
 .Case("round.tonearest",  rmToNearest)
 .Case("round.downward",   rmDownward)
 .Case("round.upward", rmUpward)
 .Case("round.towardzero", rmTowardZero)
-.Default(rmInvalid);
+.Default(None);
 }
 
-ConstrainedFPIntrinsic::ExceptionBehavior
+Optional
+ConstrainedFPIntrinsic::RoundingModeToStr(RoundingMode UseRounding) {
+  Optional RoundingStr = None;
+  switch (UseRounding) {
+  case ConstrainedFPIntrinsic::rmDynamic:
+RoundingStr = "round.dynamic";
+break;
+  case ConstrainedFPIntrinsic::rmToNearest:
+RoundingStr = "round.tonearest";
+break;
+  case ConstrainedFPIntrinsic::rmDownward:
+RoundingStr = "round.downward";
+break;
+  case ConstrainedFPIntrinsic::rmUpward:
+RoundingStr = "round.upward";
+break;
+  case ConstrainedFPIntrinsic::rmTowardZero:
+RoundingStr = "round.tozero";
+break;
+  }
+  return RoundingStr;
+}
+
+Optional
 ConstrainedFPIntrinsic::getExceptionBehavior() const {
   unsigned NumOperands = getNumArgOperands();
   Metadata *MD =
   dyn_cast(getArgOperand(NumOperands - 1))->getMetadata();
   if (!MD || !isa(MD))
-return ebInvalid;
-  StringRef ExceptionArg = cast(MD)->getString();
-  return StringSwitch(ExceptionArg)
+return None;
+  return StrToExceptionBehavior(cast(MD)->getString());
+}
+
+Optional
+ConstrainedFPIntrinsic::StrToExceptionBehavior(StringRef ExceptionArg) {
+  return StringSwitch>(ExceptionArg)
 .Case("fpexcept.ignore",  ebIgnore)
 .Case("fpexcept.maytrap", ebMayTrap)
 .Case("fpexcept.strict",  ebStrict)
-.Default(ebInvalid);
+.Default(None);
+}
+
+Optional
+ConstrainedFPIntrinsic::ExceptionBehaviorToStr(ExceptionBehavior UseExcept) {
+  Optional ExceptStr = None;
+  switch (UseExcept) {
+  case ConstrainedFPIntrinsic::ebStrict:
+ExceptStr = "fpexcept.strict";
+break;
+  case ConstrainedFPIntrinsic::ebIgnore:
+ExceptStr = "fpexcept.ignore";
+break;
+  case ConstrainedFPIntrinsic::ebMayTrap:
+ExceptStr = "fpexcept.maytrap";
+break;
+  }
+  return ExceptStr;
 }
 
 bool ConstrainedFPIntrinsic::isUnaryOp() const {
Index: llvm/trunk/lib/IR/Verifier.cpp
===
--- llvm/trunk/lib/IR/Verifier.cpp
+++ llvm/trunk/lib/IR/Verifier.cpp
@@ -4776,11 +4776,11 @@
   // argument type check is needed here.
 
   if (HasExceptionMD) {
-Assert(FPI.getExceptionBehavior() != ConstrainedFPIntrinsic::ebInvalid,
+Assert(FPI.getExceptionBehavior().hasValue(),
"invalid exception behavior argument", &FPI);
   }
   if (HasRoundingMD) {
-Assert(FPI.getRoundingMode() != ConstrainedFPIntrinsic::rmInvalid,
+Assert(FPI.getRoundingMode().hasValue(),
"invalid rounding mode argument", &FPI);
   }
 }
Index: llvm/trunk/unittests/IR/IRBuilderTest.cpp
===
--- llvm/trunk/unittests/IR/IRBuilderTest.cpp
+++ llvm/trunk/unittests/IR/IRBuilderTest.cpp
@@ -122,6 +122,70 @@
   EXPECT_FALSE(II->hasNoNaNs());
 }
 
+TEST_F(IRBuilderTest, ConstrainedFP) {
+  IRBuilder<> Builder(BB);
+  Value *V;
+  CallInst *Call;
+  IntrinsicInst *II;
+
+  V = Builder.CreateLoad(GV);
+
+  // See if we get constrained intrinsics instead of non-constrained
+  // instructio

[PATCH] D64256: Teach some warnings to respect gsl::Pointer and gsl::Owner attributes

2019-07-08 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun updated this revision to Diff 208441.
xazax.hun added a comment.

- Fix a typo.


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

https://reviews.llvm.org/D64256

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaInit.cpp
  clang/test/Sema/warn-lifetime-analysis-nocfg.cpp

Index: clang/test/Sema/warn-lifetime-analysis-nocfg.cpp
===
--- /dev/null
+++ clang/test/Sema/warn-lifetime-analysis-nocfg.cpp
@@ -0,0 +1,108 @@
+// RUN: %clang_cc1 -fsyntax-only -Wdangling -Wdangling-field -Wreturn-stack-address -verify %s
+struct [[gsl::Owner(int)]] MyOwner {
+  MyOwner();
+  int &operator*();
+};
+
+struct OwnerWithConv;
+
+// Conversion operator and constructor conversion will result in two
+// different shaped ASTs. Thus we have two owner types in the tests.
+struct [[gsl::Pointer(int)]] MyPointer {
+  MyPointer(int *p = nullptr);
+  MyPointer(const MyOwner &);
+  int &operator*();
+  OwnerWithConv toOwner();
+};
+
+struct [[gsl::Owner(int)]] OwnerWithConv {
+  OwnerWithConv();
+  operator MyPointer();
+  int &operator*();
+  MyPointer releaseAsMyPointer();
+  int *releaseAsRawPointer();
+  int *c_str() const;
+};
+
+void danglingHeapObject() {
+  new MyPointer(OwnerWithConv{}); // expected-warning {{object backing the pointer will be destroyed at the end of the full-expression}}
+  new MyPointer(MyOwner{}); // expected-warning {{object backing the pointer will be destroyed at the end of the full-expression}}
+}
+
+void intentionalFalseNegative() {
+  int i;
+  MyPointer p{&i};
+  // In this case we do not have enough information in a statement local
+  // analysis to detect the problem.
+  new MyPointer(MyPointer{p});
+}
+
+MyPointer ownershipTransferToMyPointer() {
+  OwnerWithConv t;
+  return t.releaseAsMyPointer(); // ok
+}
+
+int *ownershipTransferToRawPointer() {
+  OwnerWithConv t;
+  return t.releaseAsRawPointer(); // ok
+}
+
+int *danglingRawPtrFromLocal() {
+  OwnerWithConv t;
+  return t.c_str(); // TODO
+}
+
+int *danglingRawPtrFromTemp() {
+  MyPointer p;
+  return p.toOwner().c_str(); // TODO
+}
+
+struct Y {
+  int a[4];
+};
+
+void dangligGslPtrFromTemporary() {
+  MyPointer p = Y{}.a; // expected-warning {{temporary whose address is used as value of local variable 'p' will be destroyed at the end of the full-expression}}
+  (void)p;
+}
+
+struct DanglingGslPtrField {
+  MyPointer p; // expected-note 3{{pointer member declared here}}
+  DanglingGslPtrField(int i) : p(&i) {} // expected-warning {{initializing pointer member 'p' with the stack address of parameter 'i'}}
+  DanglingGslPtrField() : p(OwnerWithConv{}) {} // expected-warning {{initializing pointer member 'p' to point to a temporary object whose lifetime is shorter than the lifetime of the constructed object}}
+  DanglingGslPtrField(double) : p(MyOwner{}) {} // expected-warning {{initializing pointer member 'p' to point to a temporary object whose lifetime is shorter than the lifetime of the constructed object}}
+};
+
+MyPointer danglingGslPtrFromLocal() {
+  int j;
+  return &j; // expected-warning {{address of stack memory associated with local variable 'j' returned}}
+}
+
+MyPointer daglingGslPtrFromLocalOwner() {
+  OwnerWithConv t;
+  return t; // TODO
+}
+
+MyPointer danglingGslPtrFromTemporary() {
+  return OwnerWithConv{}; // expected-warning {{returning address of local temporary object}}
+}
+
+MyPointer global;
+
+void initLocalGslPtrWithTempOwner() {
+  MyPointer p = MyOwner{}; // expected-warning {{object backing the pointer will be destroyed at the end of the full-expression}}
+  p = MyOwner{}; // TODO ?
+  global = MyOwner{}; // TODO ?
+  p = OwnerWithConv{}; // TODO ?
+  global = OwnerWithConv{}; // TODO ?
+}
+
+struct IntVector {
+  int *begin();
+  int *end();
+};
+
+void modelIterators() {
+  int *it = IntVector{}.begin(); // TODO ?
+  (void)it;
+}
Index: clang/lib/Sema/SemaInit.cpp
===
--- clang/lib/Sema/SemaInit.cpp
+++ clang/lib/Sema/SemaInit.cpp
@@ -6507,6 +6507,8 @@
 VarInit,
 LValToRVal,
 LifetimeBoundCall,
+GslPointerInit,
+GslTempOwner
   } Kind;
   Expr *E;
   const Decl *D = nullptr;
@@ -6543,6 +6545,13 @@
   });
 }
 
+static bool
+pathInitializeLifetimePointer(llvm::ArrayRef Path) {
+  return Path.size() > 0 && llvm::all_of(Path, [=](IndirectLocalPathEntry E) {
+return E.Kind == IndirectLocalPathEntry::GslPointerInit;
+  });
+}
+
 static void visitLocalsRetainedByInitializer(IndirectLocalPath &Path,
  Expr *Init, LocalVisitor Visit,
  bool RevisitSubinits);
@@ -6551,6 +6560,47 @@
   Expr *Init, ReferenceKind RK,
   LocalVisitor Visit);
 
+template
+static bool recordHasAttr(QualType Type) {
+  if (auto *RD = Type->getAsCXXRec

r365341 - Add nofree attribute to CodeGenOpenCL/convergent.cl test

2019-07-08 Thread Brian Homerding via cfe-commits
Author: homerdin
Date: Mon Jul  8 09:24:10 2019
New Revision: 365341

URL: http://llvm.org/viewvc/llvm-project?rev=365341&view=rev
Log:
Add nofree attribute to CodeGenOpenCL/convergent.cl test

The revision at https://reviews.llvm.org/rL365336 added inference of the nofree
attribute.  This revision updates the test to reflect this.

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

Modified:
cfe/trunk/test/CodeGenOpenCL/convergent.cl

Modified: cfe/trunk/test/CodeGenOpenCL/convergent.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/convergent.cl?rev=365341&r1=365340&r2=365341&view=diff
==
--- cfe/trunk/test/CodeGenOpenCL/convergent.cl (original)
+++ cfe/trunk/test/CodeGenOpenCL/convergent.cl Mon Jul  8 09:24:10 2019
@@ -139,7 +139,7 @@ kernel void assume_convergent_asm()
   __asm__ volatile("s_barrier");
 }
 
-// CHECK: attributes #0 = { noinline norecurse nounwind "
+// CHECK: attributes #0 = { nofree noinline norecurse nounwind "
 // CHECK: attributes #1 = { {{[^}]*}}convergent{{[^}]*}} }
 // CHECK: attributes #2 = { {{[^}]*}}convergent{{[^}]*}} }
 // CHECK: attributes #3 = { {{[^}]*}}convergent noduplicate{{[^}]*}} }


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


[PATCH] D63161: Devirtualize destructor of final class.

2019-07-08 Thread Hiroshi Yamauchi via Phabricator via cfe-commits
yamauchi added a comment.

This was reverted due to some internal test failure. But it turned out a false 
alarm. I'll work on recommitting it.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D63161



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


[PATCH] D64294: [Driver] Consolidate shouldUseFramePointer() and shouldUseLeafFramePointer()

2019-07-08 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

In D56353 , I remember @chandlerc thought 
`-f(no-)omit-frame-pointer` should win over `-m(no-)omit-leaf-frame-pointer`. 
I'm not sure what his thoughts on this now. @chandlerc ?


Repository:
  rC Clang

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

https://reviews.llvm.org/D64294



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


[PATCH] D63773: [clangd] dummy variable extraction on a function scope

2019-07-08 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

Awesome! Do you have commit access?




Comment at: clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp:90
+bool isAFunctionRef(const clang::Expr *Expr) {
+  const clang::DeclRefExpr *DeclRef = dyn_cast_or_null(Expr);
+  if (DeclRef && isa(DeclRef->getDecl()))

SureYeaah wrote:
> sammccall wrote:
> > sammccall wrote:
> > > Extracting just a declrefexpr (and replacing it with another declrefexpr) 
> > > doesn't seem useful. Any reason to only do this for functions, rather 
> > > than all declrefexprs?
> > a syntactically similar case is MemberExpr where isImplicitAccess() is 
> > true. (This is referring to a method of the current class, without 
> > qualification)
> Extracting
>   int a = [[f]]();
> yields
>   auto dummy = f;
>   int a = dummy();
> 
> I thought this should be prevented. But now I see there's no need to do that.
> I'll add a triviality check if needed in the next patch.
sure - I just mean `int a = b;` -> `auto dummy = b; int a = dummy;` is equally 
pointless, so I wasn't sure about the function check. But fine to defer.



Comment at: clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp:37
+const ASTContext &Ctx);
+  // return the expr
+  const clang::Expr *getExpr() const { return Expr; }

nit: drop comments that just echo the name, like this one



Comment at: clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp:82
+
+// An expr is not extractable if it's null, a delete expression or a comma
+// separated expression

why a delete expression? if this generalises to "expression of type void" then 
you can check for that directly



Comment at: clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp:101
+ReferencedDecls = computeReferencedDecls(Expr);
+if ((InsertionPoint = computeInsertionPoint()))
+  Extractable = true;

nit: remove extra parens



Comment at: clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp:107
+// checks whether extracting before InsertionPoint will take a
+// variable out of scope
+bool ExtractionContext::exprIsValidOutside(const clang::Stmt *Scope) const {

nit: a variable reference out of scope



Comment at: clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp:134
+if (const clang::Stmt *Stmt = InsertionPoint->ASTNode.get()) {
+  // Allow all expressions except LambdaExpr
+  if (isa(Stmt))

why?



Comment at: clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp:137
+return !isa(Stmt);
+  return isa(Stmt) || isa(Stmt) ||
+ isa(Stmt) || isa(Stmt) || isa(Stmt) ||

can you add a comment explaining approximately why many (most) stmts are 
allowed but some others cause problems?



Comment at: clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp:187
+  std::string ExtractedVarDecl = std::string("auto ") + VarName.str() + " = " +
+ ExtractionCode.str() + "; ";
+  return tooling::Replacement(SM, InsertionLoc, 0, ExtractedVarDecl);

nit: trailing space? should this be a newline?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63773



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


[PATCH] D64329: [Clangd] Fixed SelectionTree bug for macros

2019-07-08 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang-tools-extra/clangd/Selection.cpp:247
   return SelectionTree::Unselected;
-// getTopMacroCallerLoc() allows selection of constructs in macro args. 
e.g:
+// getFileRange() allows selecting macro arg expansions
 //   #define LOOP_FOREVER(Body) for(;;) { Body }

the new wording seems less clear to me



Comment at: clang-tools-extra/clangd/SourceCode.cpp:447
   BeginNamespace, // namespace  {. Payload is resolved .
-  EndNamespace,   // } // namespace .  Payload is resolved *outer* 
namespace.
-  UsingDirective  // using namespace . Payload is unresolved .

It looks like your editor might be set up to format the whole file, rather than 
just changed lines (`git clang-format` will also do this).

Please avoid this in general as it messes up blame history.
No need to go back and revert everything though.



Comment at: clang-tools-extra/clangd/SourceCode.cpp:655
+// Returns the location of the end of the token present at a given location
+static SourceLocation getLocationAtTokenEnd(SourceLocation Loc,
+const SourceManager &SM,

This is Lexer::getLocForEndOfToken(Loc, 0,  SM, LangOpts), I think



Comment at: clang-tools-extra/clangd/SourceCode.cpp:663
+// Finds the union of two ranges. If any of the ranges is a Token Range, it 
uses
+// the token ending.
+static CharSourceRange unionCharSourceRange(CharSourceRange R1,

Returns a half-open CharSourceRange.
(Because closed character CharSourceRanges are also a thing...)



Comment at: clang-tools-extra/clangd/SourceCode.cpp:683
+return {{Loc, getLocationAtTokenEnd(Loc, SM, LangOpts)}, false};
+  CharSourceRange FileRange({Loc}, false);
+  do {

nit: do the conversion from the previous line here, and write the loop as a 
regular while loop?



Comment at: clang-tools-extra/clangd/SourceCode.h:204
 
+// Return the FileRange for a given range where the ends can be in different
+// files. Note that the end of the FileRange is the end of the last token.

This is closely related to `toHalfOpenFileRange` and should be moved up there.

Actually... is this just a less-buggy replacement for `toHalfOpenFileRange`? If 
so, we should give it that name. It'd be nice to add a few unit tests (and 
verify that they fail with the old version of the function).



Comment at: clang-tools-extra/clangd/SourceCode.h:205
+// Return the FileRange for a given range where the ends can be in different
+// files. Note that the end of the FileRange is the end of the last token.
+SourceRange getFileRange(SourceRange Range, const SourceManager &SM, const 
LangOptions &LangOpts);

"end of the last token" is confusing: does it point to the last char, or 
one-past-last?

The latter seems nicest and is easily described by the existing "half-open" name


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64329



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


[PATCH] D61637: [Syntax] Introduce syntax trees

2019-07-08 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 208454.
ilya-biryukov marked 4 inline comments as done.
ilya-biryukov added a comment.

- s/TranslationUnitDeclaration/TranslationUnit
- Remove accessor from 'eof', add a FIXME to remove it from the tree altogether


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61637

Files:
  clang/include/clang/Tooling/Syntax/BuildTree.h
  clang/include/clang/Tooling/Syntax/Nodes.h
  clang/include/clang/Tooling/Syntax/Tree.h
  clang/lib/Tooling/Syntax/BuildTree.cpp
  clang/lib/Tooling/Syntax/CMakeLists.txt
  clang/lib/Tooling/Syntax/Nodes.cpp
  clang/lib/Tooling/Syntax/Tree.cpp
  clang/unittests/Tooling/Syntax/CMakeLists.txt
  clang/unittests/Tooling/Syntax/TreeTest.cpp

Index: clang/unittests/Tooling/Syntax/TreeTest.cpp
===
--- /dev/null
+++ clang/unittests/Tooling/Syntax/TreeTest.cpp
@@ -0,0 +1,160 @@
+//===- TreeTest.cpp ---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "clang/Tooling/Syntax/Tree.h"
+#include "clang/AST/ASTConsumer.h"
+#include "clang/AST/Decl.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Frontend/FrontendAction.h"
+#include "clang/Lex/PreprocessorOptions.h"
+#include "clang/Tooling/Syntax/BuildTree.h"
+#include "clang/Tooling/Syntax/Nodes.h"
+#include "clang/Tooling/Tooling.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/StringRef.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+#include 
+
+using namespace clang;
+
+namespace {
+class SyntaxTreeTest : public ::testing::Test {
+protected:
+  // Build a syntax tree for the code.
+  syntax::TranslationUnit *buildTree(llvm::StringRef Code) {
+// FIXME: this code is almost the identical to the one in TokensTest. Share
+//it.
+class BuildSyntaxTree : public ASTConsumer {
+public:
+  BuildSyntaxTree(syntax::TranslationUnit *&Root,
+  std::unique_ptr &Arena,
+  std::unique_ptr Tokens)
+  : Root(Root), Arena(Arena), Tokens(std::move(Tokens)) {
+assert(this->Tokens);
+  }
+
+  void HandleTranslationUnit(ASTContext &Ctx) override {
+Arena = llvm::make_unique(Ctx.getSourceManager(),
+ Ctx.getLangOpts(),
+ std::move(*Tokens).consume());
+Tokens = nullptr; // make sure we fail if this gets called twice.
+Root = syntax::buildSyntaxTree(*Arena, *Ctx.getTranslationUnitDecl());
+  }
+
+private:
+  syntax::TranslationUnit *&Root;
+  std::unique_ptr &Arena;
+  std::unique_ptr Tokens;
+};
+
+class BuildSyntaxTreeAction : public ASTFrontendAction {
+public:
+  BuildSyntaxTreeAction(syntax::TranslationUnit *&Root,
+std::unique_ptr &Arena)
+  : Root(Root), Arena(Arena) {}
+
+  std::unique_ptr
+  CreateASTConsumer(CompilerInstance &CI, StringRef InFile) override {
+// We start recording the tokens, ast consumer will take on the result.
+auto Tokens =
+llvm::make_unique(CI.getPreprocessor());
+return llvm::make_unique(Root, Arena,
+  std::move(Tokens));
+  }
+
+private:
+  syntax::TranslationUnit *&Root;
+  std::unique_ptr &Arena;
+};
+
+constexpr const char *FileName = "./input.cpp";
+FS->addFile(FileName, time_t(), llvm::MemoryBuffer::getMemBufferCopy(""));
+// Prepare to run a compiler.
+std::vector Args = {"syntax-test", "-std=c++11",
+  "-fsyntax-only", FileName};
+auto CI = createInvocationFromCommandLine(Args, Diags, FS);
+assert(CI);
+CI->getFrontendOpts().DisableFree = false;
+CI->getPreprocessorOpts().addRemappedFile(
+FileName, llvm::MemoryBuffer::getMemBufferCopy(Code).release());
+CompilerInstance Compiler;
+Compiler.setInvocation(std::move(CI));
+if (!Diags->getClient())
+  Diags->setClient(new IgnoringDiagConsumer);
+Compiler.setDiagnostics(Diags.get());
+Compiler.setFileManager(FileMgr.get());
+Compiler.setSourceManager(SourceMgr.get());
+
+syntax::TranslationUnit *Root = nullptr;
+BuildSyntaxTreeAction Recorder(Root, this->Arena);
+if (!Compiler.ExecuteAction(Recorder)) {
+  ADD_FAILURE() << "failed to run the frontend";
+  std::abort();
+}
+return Root;
+  }
+
+  // Adds a file to the test VFS.
+  void addFile(llvm::StringRef Path, llvm::StringRef Contents) {
+if (!FS->addFile(Path, time_t(),
+  

r365355 - [Syntax] Introduce syntax trees

2019-07-08 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Mon Jul  8 10:25:02 2019
New Revision: 365355

URL: http://llvm.org/viewvc/llvm-project?rev=365355&view=rev
Log:
[Syntax] Introduce syntax trees

Summary:
A tooling-focused alternative to the AST. This commit focuses on the
memory-management strategy and the structure of the AST.

More to follow later:
  - Operations to mutate the syntax trees and corresponding textual
replacements.
  - Mapping between clang AST nodes and syntax tree nodes.
  - More node types corresponding to the language constructs.

Reviewers: sammccall

Reviewed By: sammccall

Subscribers: llvm-commits, mgorny, cfe-commits

Tags: #clang, #llvm

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

Added:
cfe/trunk/include/clang/Tooling/Syntax/BuildTree.h
cfe/trunk/include/clang/Tooling/Syntax/Nodes.h
cfe/trunk/include/clang/Tooling/Syntax/Tree.h
cfe/trunk/lib/Tooling/Syntax/BuildTree.cpp
cfe/trunk/lib/Tooling/Syntax/Nodes.cpp
cfe/trunk/lib/Tooling/Syntax/Tree.cpp
cfe/trunk/unittests/Tooling/Syntax/TreeTest.cpp
Modified:
cfe/trunk/lib/Tooling/Syntax/CMakeLists.txt
cfe/trunk/unittests/Tooling/Syntax/CMakeLists.txt

Added: cfe/trunk/include/clang/Tooling/Syntax/BuildTree.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Syntax/BuildTree.h?rev=365355&view=auto
==
--- cfe/trunk/include/clang/Tooling/Syntax/BuildTree.h (added)
+++ cfe/trunk/include/clang/Tooling/Syntax/BuildTree.h Mon Jul  8 10:25:02 2019
@@ -0,0 +1,24 @@
+//===- BuildTree.h - build syntax trees ---*- C++ 
-*-=//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+// Functions to construct a syntax tree from an AST.
+//===--===//
+#ifndef LLVM_CLANG_TOOLING_SYNTAX_TREE_H
+#define LLVM_CLANG_TOOLING_SYNTAX_TREE_H
+
+#include "clang/AST/Decl.h"
+#include "clang/Tooling/Syntax/Nodes.h"
+
+namespace clang {
+namespace syntax {
+
+/// Build a syntax tree for the main file.
+syntax::TranslationUnit *buildSyntaxTree(Arena &A,
+ const clang::TranslationUnitDecl &TU);
+} // namespace syntax
+} // namespace clang
+#endif

Added: cfe/trunk/include/clang/Tooling/Syntax/Nodes.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Syntax/Nodes.h?rev=365355&view=auto
==
--- cfe/trunk/include/clang/Tooling/Syntax/Nodes.h (added)
+++ cfe/trunk/include/clang/Tooling/Syntax/Nodes.h Mon Jul  8 10:25:02 2019
@@ -0,0 +1,85 @@
+//===- Nodes.h - syntax nodes for C/C++ grammar constructs *- C++ 
-*-=//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+// Syntax tree nodes for C, C++ and Objective-C grammar constructs.
+//===--===//
+#ifndef LLVM_CLANG_TOOLING_SYNTAX_NODES_H
+#define LLVM_CLANG_TOOLING_SYNTAX_NODES_H
+
+#include "clang/Basic/TokenKinds.h"
+#include "clang/Lex/Token.h"
+#include "clang/Tooling/Syntax/Tokens.h"
+#include "clang/Tooling/Syntax/Tree.h"
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/raw_ostream.h"
+
+namespace clang {
+namespace syntax {
+
+/// A kind of a syntax node, used for implementing casts.
+enum class NodeKind : uint16_t {
+  Leaf,
+  TranslationUnit,
+  TopLevelDeclaration,
+  CompoundStatement
+};
+/// For debugging purposes.
+llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, NodeKind K);
+
+/// A root node for a translation unit. Parent is always null.
+class TranslationUnit final : public Tree {
+public:
+  TranslationUnit() : Tree(NodeKind::TranslationUnit) {}
+  static bool classof(const Node *N) {
+return N->kind() == NodeKind::TranslationUnit;
+  }
+};
+
+/// FIXME: this node is temporary and will be replaced with nodes for various
+///'declarations' and 'declarators' from the C/C++ grammar
+///
+/// Represents any top-level declaration. Only there to give the syntax tree a
+/// bit of structure until we implement syntax nodes for declarations and
+/// declarators.
+class TopLevelDeclaration final : public Tree {
+public:
+  TopLevelDeclaration() : Tree(NodeKind::TopLevelDeclaration) {}
+  static bool classof(const Node *N) {
+return N->kind() == NodeKind::TopLevelDeclaration;
+  }
+};
+
+/// An abstract node for C++ statements, e.g. 'while', 'if', etc

[clang-tools-extra] r365356 - [clangd] Use -completion-style=bundled by default if signature help is available

2019-07-08 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Mon Jul  8 10:27:15 2019
New Revision: 365356

URL: http://llvm.org/viewvc/llvm-project?rev=365356&view=rev
Log:
[clangd] Use -completion-style=bundled by default if signature help is available

Summary:
I didn't manage to find something nicer than optional, but at least I
found a sneakier comment.

Reviewers: kadircet

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

Tags: #llvm

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

Modified:
clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
clang-tools-extra/trunk/clangd/CodeComplete.cpp
clang-tools-extra/trunk/clangd/CodeComplete.h
clang-tools-extra/trunk/clangd/Protocol.cpp
clang-tools-extra/trunk/clangd/Protocol.h
clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp

Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp?rev=365356&r1=365355&r2=365356&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp Mon Jul  8 10:27:15 2019
@@ -366,6 +366,8 @@ void ClangdLSPServer::onInitialize(const
 
   CCOpts.EnableSnippets = Params.capabilities.CompletionSnippets;
   CCOpts.IncludeFixIts = Params.capabilities.CompletionFixes;
+  if (!CCOpts.BundleOverloads.hasValue())
+CCOpts.BundleOverloads = Params.capabilities.HasSignatureHelp;
   DiagOpts.EmbedFixesInDiagnostics = Params.capabilities.DiagnosticFixes;
   DiagOpts.SendDiagnosticCategory = Params.capabilities.DiagnosticCategory;
   DiagOpts.EmitRelatedLocations =

Modified: clang-tools-extra/trunk/clangd/CodeComplete.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/CodeComplete.cpp?rev=365356&r1=365355&r2=365356&view=diff
==
--- clang-tools-extra/trunk/clangd/CodeComplete.cpp (original)
+++ clang-tools-extra/trunk/clangd/CodeComplete.cpp Mon Jul  8 10:27:15 2019
@@ -169,7 +169,7 @@ struct CompletionCandidate {
   // Returns a token identifying the overload set this is part of.
   // 0 indicates it's not part of any overload set.
   size_t overloadSet(const CodeCompleteOptions &Opts) const {
-if (!Opts.BundleOverloads)
+if (!Opts.BundleOverloads.getValueOr(false))
   return 0;
 llvm::SmallString<256> Scratch;
 if (IndexResult) {

Modified: clang-tools-extra/trunk/clangd/CodeComplete.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/CodeComplete.h?rev=365356&r1=365355&r2=365356&view=diff
==
--- clang-tools-extra/trunk/clangd/CodeComplete.h (original)
+++ clang-tools-extra/trunk/clangd/CodeComplete.h Mon Jul  8 10:27:15 2019
@@ -62,7 +62,10 @@ struct CodeCompleteOptions {
   bool IncludeIneligibleResults = false;
 
   /// Combine overloads into a single completion item where possible.
-  bool BundleOverloads = false;
+  /// If none, the the implementation may choose an appropriate behavior.
+  /// (In practice, ClangdLSPServer enables bundling if the client claims
+  /// to supports signature help).
+  llvm::Optional BundleOverloads;
 
   /// Limit the number of results returned (0 means no limit).
   /// If more results are available, we set CompletionList.isIncomplete.

Modified: clang-tools-extra/trunk/clangd/Protocol.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Protocol.cpp?rev=365356&r1=365355&r2=365356&view=diff
==
--- clang-tools-extra/trunk/clangd/Protocol.cpp (original)
+++ clang-tools-extra/trunk/clangd/Protocol.cpp Mon Jul  8 10:27:15 2019
@@ -323,6 +323,7 @@ bool fromJSON(const llvm::json::Value &P
   }
 }
 if (auto *Help = TextDocument->getObject("signatureHelp")) {
+  R.HasSignatureHelp = true;
   if (auto *Info = Help->getObject("signatureInformation")) {
 if (auto *Parameter = Info->getObject("parameterInformation")) {
   if (auto OffsetSupport = Parameter->getBoolean("labelOffsetSupport"))

Modified: clang-tools-extra/trunk/clangd/Protocol.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Protocol.h?rev=365356&r1=365355&r2=365356&view=diff
==
--- clang-tools-extra/trunk/clangd/Protocol.h (original)
+++ clang-tools-extra/trunk/clangd/Protocol.h Mon Jul  8 10:27:15 2019
@@ -393,9 +393,15 @@ struct ClientCapabilities {
   bool CompletionFixes = false;
 
   /// Client supports hierarchical document symbols.
+  /// textDocument.documentSymbol.hierarchicalDocumentSymbolSupport
   bool HierarchicalDocumentSymbol = false;
 
+  /// Client supports signature help.
+  /// textDocument.signatureHelp
+  bool HasSignatureHel

[PATCH] D61637: [Syntax] Introduce syntax trees

2019-07-08 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clang/include/clang/Tooling/Syntax/Nodes.h:35
+/// A root node for a translation unit. Parent is always null.
+class TranslationUnitDeclaration final : public Tree {
+public:

sammccall wrote:
> I don't think TU is actually a declaration. Is there a reason to consider it 
> one from a syntax POV?
It's a declaration in a sense that it has a corresponding instance of 
`clang::Decl` that it "introduces", i.e. the `clang::TranslationUnitDecl`.

But you are right, `TranslationUnit` is a better name: this aligns with the C++ 
grammar from the standard (`translation-unit`), it does lack similarity with 
other declarations from the standard (and from clang).


Renamed to `TranslationUnit`



Comment at: clang/include/clang/Tooling/Syntax/Nodes.h:41
+  }
+  syntax::Leaf *eof();
+

sammccall wrote:
> I have a slight feeling the EOF token is going to be annoying, e.g. can't 
> just splice stuff in at the end of the list. But not sure if it'll be a big 
> deal, and whether the alternatives are better.
That's a good point, I actually don't see how `eof` token in a tree would be 
useful (it's probably fine to have in the `TokenBuffer`, though, allows). 
Moreover, it could cause confusion and bugs when working with multiple 
translation units (I imagine moving nodes between two different TUs and ending 
up with multiple `eof`s somewhere) 

I've removed the corresponding accessor from the `TranslationUnit` node and 
added a FIXME to remove it from the tree altogether.



Comment at: clang/include/clang/Tooling/Syntax/Nodes.h:43
+
+  struct Roles {
+static constexpr NodeRole eof = 1;

sammccall wrote:
> we discussed offline - with 256 values, is it possible to come up with a 
> single role enum that would cover all node types?
> 
> Advantage would be that certain logic could be generic (e.g. `Recovery` could 
> be a role for leaves under any Tree, `LParen`/`RParen`/`MainKeyword` could 
> apply to if, while, switch...)
Will need to do some estimations to answer this properly, but my gut feeling is 
that 256 could end up being too limiting in the long run (I would expect each 
node to have at least one child, so without deduplication we can at least as 
many roles as we have kinds).

Could imagine a two-level numbering scheme, though:
- some generic roles like `lparen`, `rparen`, etc, take first `N` roles.
- higher numbers are for node-specific roles (e.g. LHS or RHS of a 
`BinaryExpr`).

But at that point, we probably don't have the benefits of a single enum.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61637



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


[PATCH] D61637: [Syntax] Introduce syntax trees

2019-07-08 Thread Ilya Biryukov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb736969eddce: [Syntax] Introduce syntax trees (authored by 
ilya-biryukov).

Changed prior to commit:
  https://reviews.llvm.org/D61637?vs=208454&id=208455#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61637

Files:
  clang/include/clang/Tooling/Syntax/BuildTree.h
  clang/include/clang/Tooling/Syntax/Nodes.h
  clang/include/clang/Tooling/Syntax/Tree.h
  clang/lib/Tooling/Syntax/BuildTree.cpp
  clang/lib/Tooling/Syntax/CMakeLists.txt
  clang/lib/Tooling/Syntax/Nodes.cpp
  clang/lib/Tooling/Syntax/Tree.cpp
  clang/unittests/Tooling/Syntax/CMakeLists.txt
  clang/unittests/Tooling/Syntax/TreeTest.cpp

Index: clang/unittests/Tooling/Syntax/TreeTest.cpp
===
--- /dev/null
+++ clang/unittests/Tooling/Syntax/TreeTest.cpp
@@ -0,0 +1,160 @@
+//===- TreeTest.cpp ---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "clang/Tooling/Syntax/Tree.h"
+#include "clang/AST/ASTConsumer.h"
+#include "clang/AST/Decl.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Frontend/FrontendAction.h"
+#include "clang/Lex/PreprocessorOptions.h"
+#include "clang/Tooling/Syntax/BuildTree.h"
+#include "clang/Tooling/Syntax/Nodes.h"
+#include "clang/Tooling/Tooling.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/StringRef.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+#include 
+
+using namespace clang;
+
+namespace {
+class SyntaxTreeTest : public ::testing::Test {
+protected:
+  // Build a syntax tree for the code.
+  syntax::TranslationUnit *buildTree(llvm::StringRef Code) {
+// FIXME: this code is almost the identical to the one in TokensTest. Share
+//it.
+class BuildSyntaxTree : public ASTConsumer {
+public:
+  BuildSyntaxTree(syntax::TranslationUnit *&Root,
+  std::unique_ptr &Arena,
+  std::unique_ptr Tokens)
+  : Root(Root), Arena(Arena), Tokens(std::move(Tokens)) {
+assert(this->Tokens);
+  }
+
+  void HandleTranslationUnit(ASTContext &Ctx) override {
+Arena = llvm::make_unique(Ctx.getSourceManager(),
+ Ctx.getLangOpts(),
+ std::move(*Tokens).consume());
+Tokens = nullptr; // make sure we fail if this gets called twice.
+Root = syntax::buildSyntaxTree(*Arena, *Ctx.getTranslationUnitDecl());
+  }
+
+private:
+  syntax::TranslationUnit *&Root;
+  std::unique_ptr &Arena;
+  std::unique_ptr Tokens;
+};
+
+class BuildSyntaxTreeAction : public ASTFrontendAction {
+public:
+  BuildSyntaxTreeAction(syntax::TranslationUnit *&Root,
+std::unique_ptr &Arena)
+  : Root(Root), Arena(Arena) {}
+
+  std::unique_ptr
+  CreateASTConsumer(CompilerInstance &CI, StringRef InFile) override {
+// We start recording the tokens, ast consumer will take on the result.
+auto Tokens =
+llvm::make_unique(CI.getPreprocessor());
+return llvm::make_unique(Root, Arena,
+  std::move(Tokens));
+  }
+
+private:
+  syntax::TranslationUnit *&Root;
+  std::unique_ptr &Arena;
+};
+
+constexpr const char *FileName = "./input.cpp";
+FS->addFile(FileName, time_t(), llvm::MemoryBuffer::getMemBufferCopy(""));
+// Prepare to run a compiler.
+std::vector Args = {"syntax-test", "-std=c++11",
+  "-fsyntax-only", FileName};
+auto CI = createInvocationFromCommandLine(Args, Diags, FS);
+assert(CI);
+CI->getFrontendOpts().DisableFree = false;
+CI->getPreprocessorOpts().addRemappedFile(
+FileName, llvm::MemoryBuffer::getMemBufferCopy(Code).release());
+CompilerInstance Compiler;
+Compiler.setInvocation(std::move(CI));
+if (!Diags->getClient())
+  Diags->setClient(new IgnoringDiagConsumer);
+Compiler.setDiagnostics(Diags.get());
+Compiler.setFileManager(FileMgr.get());
+Compiler.setSourceManager(SourceMgr.get());
+
+syntax::TranslationUnit *Root = nullptr;
+BuildSyntaxTreeAction Recorder(Root, this->Arena);
+if (!Compiler.ExecuteAction(Recorder)) {
+  ADD_FAILURE() << "failed to run the frontend";
+  std::abort();
+}
+return Root;
+  }
+
+  // Adds a file to the test VFS.
+  void addFile(llvm::StringRef Path, llvm::StringRef Contents) {
+if (!FS->addFile(Path, time_t(),
+ 

[PATCH] D64058: [cxx2a] P0624R2 fix: only lambdas with no lambda-capture are default-constructible and assignable.

2019-07-08 Thread Logan Smith via Phabricator via cfe-commits
logan-5 added a comment.

*ping*


Repository:
  rC Clang

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

https://reviews.llvm.org/D64058



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


r365357 - Replace temporary variable matches in test since r363952 causes an

2019-07-08 Thread Amy Huang via cfe-commits
Author: akhuang
Date: Mon Jul  8 10:35:28 2019
New Revision: 365357

URL: http://llvm.org/viewvc/llvm-project?rev=365357&view=rev
Log:
Replace temporary variable matches in test since r363952 causes an
extra temporary variable to be created.

Modified:
cfe/trunk/test/CodeGenCXX/cxx2a-compare.cpp

Modified: cfe/trunk/test/CodeGenCXX/cxx2a-compare.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/cxx2a-compare.cpp?rev=365357&r1=365356&r2=365357&view=diff
==
--- cfe/trunk/test/CodeGenCXX/cxx2a-compare.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/cxx2a-compare.cpp Mon Jul  8 10:35:28 2019
@@ -18,9 +18,9 @@
 // CHECK-LABEL: @_Z11test_signedii
 auto test_signed(int x, int y) {
   // CHECK: %[[DEST:retval|agg.result]]
-  // CHECK: %cmp.lt = icmp slt i32 %0, %1
+  // CHECK: %cmp.lt = icmp slt i32 %{{.+}}, %{{.+}}
   // CHECK: %sel.lt = select i1 %cmp.lt, i8 [[LT]], i8 [[GT]]
-  // CHECK: %cmp.eq = icmp eq i32 %0, %1
+  // CHECK: %cmp.eq = icmp eq i32 %{{.+}}, %{{.+}}
   // CHECK: %sel.eq = select i1 %cmp.eq, i8 [[EQ]], i8 %sel.lt
   // CHECK: %__value_ = getelementptr inbounds %[[SO]], %[[SO]]* %[[DEST]]
   // CHECK: store i8 %sel.eq, i8* %__value_, align 1
@@ -31,9 +31,9 @@ auto test_signed(int x, int y) {
 // CHECK-LABEL: @_Z13test_unsignedjj
 auto test_unsigned(unsigned x, unsigned y) {
   // CHECK: %[[DEST:retval|agg.result]]
-  // CHECK: %cmp.lt = icmp ult i32 %0, %1
+  // CHECK: %cmp.lt = icmp ult i32 %{{.+}}, %{{.+}}
   // CHECK: %sel.lt = select i1 %cmp.lt, i8 [[LT]], i8 [[GT]]
-  // CHECK: %cmp.eq = icmp eq i32 %0, %1
+  // CHECK: %cmp.eq = icmp eq i32 %{{.+}}, %{{.+}}
   // CHECK: %sel.eq = select i1 %cmp.eq, i8 [[EQ]], i8 %sel.lt
   // CHECK: %__value_ = getelementptr inbounds %[[SO]], %[[SO]]* %[[DEST]]
   // CHECK: store i8 %sel.eq, i8* %__value_
@@ -44,11 +44,11 @@ auto test_unsigned(unsigned x, unsigned
 // CHECK-LABEL: @_Z10float_testdd
 auto float_test(double x, double y) {
   // CHECK: %[[DEST:retval|agg.result]]
-  // CHECK: %cmp.eq = fcmp oeq double %0, %1
+  // CHECK: %cmp.eq = fcmp oeq double %{{.+}}, %{{.+}}
   // CHECK: %sel.eq = select i1 %cmp.eq, i8 [[EQ]], i8 [[UNORD]]
-  // CHECK: %cmp.gt = fcmp ogt double %0, %1
+  // CHECK: %cmp.gt = fcmp ogt double %{{.+}}, %{{.+}}
   // CHECK: %sel.gt = select i1 %cmp.gt, i8 [[GT]], i8 %sel.eq
-  // CHECK: %cmp.lt = fcmp olt double %0, %1
+  // CHECK: %cmp.lt = fcmp olt double %{{.+}}, %{{.+}}
   // CHECK: %sel.lt = select i1 %cmp.lt, i8 [[LT]], i8 %sel.gt
   // CHECK: %__value_ = getelementptr inbounds %[[PO]], %[[PO]]* %[[DEST]]
   // CHECK: store i8 %sel.lt, i8* %__value_
@@ -59,9 +59,9 @@ auto float_test(double x, double y) {
 // CHECK-LABEL: @_Z8ptr_testPiS_
 auto ptr_test(int *x, int *y) {
   // CHECK: %[[DEST:retval|agg.result]]
-  // CHECK: %cmp.lt = icmp ult i32* %0, %1
+  // CHECK: %cmp.lt = icmp ult i32* %{{.+}}, %{{.+}}
   // CHECK: %sel.lt = select i1 %cmp.lt, i8 [[LT]], i8 [[GT]]
-  // CHECK: %cmp.eq = icmp eq i32* %0, %1
+  // CHECK: %cmp.eq = icmp eq i32* %{{.+}}, %{{.+}}
   // CHECK: %sel.eq = select i1 %cmp.eq, i8 [[EQ]], i8 %sel.lt
   // CHECK: %__value_ = getelementptr inbounds %[[SO]], %[[SO]]* %[[DEST]]
   // CHECK: store i8 %sel.eq, i8* %__value_, align 1
@@ -92,7 +92,7 @@ auto mem_ptr_test(MemPtrT x, MemPtrT y)
 // CHECK-LABEL: @_Z13mem_data_testM6MemPtriS0_
 auto mem_data_test(MemDataT x, MemDataT y) {
   // CHECK: %[[DEST:retval|agg.result]]
-  // CHECK: %[[CMP:.*]] = icmp eq i{{[0-9]+}} %0, %1
+  // CHECK: %[[CMP:.*]] = icmp eq i{{[0-9]+}} %{{.+}}, %{{.+}}
   // CHECK: %sel.eq = select i1 %[[CMP]], i8 [[EQ]], i8 [[NE]]
   // CHECK: %__value_ = getelementptr inbounds %[[SE]], %[[SE]]* %[[DEST]]
   // CHECK: store i8 %sel.eq, i8* %__value_, align 1
@@ -114,7 +114,7 @@ auto test_constant() {
 // CHECK-LABEL: @_Z16test_nullptr_objPiDn
 auto test_nullptr_obj(int* x, decltype(nullptr) y) {
   // CHECK: %[[DEST:retval|agg.result]]
-  // CHECK: %cmp.eq = icmp eq i32* %0, null
+  // CHECK: %cmp.eq = icmp eq i32* %{{.+}}, null
   // CHECK: %sel.eq = select i1 %cmp.eq, i8 [[EQ]], i8 [[NE]]
   // CHECK: %__value_ = getelementptr inbounds %[[SE]], %[[SE]]* %[[DEST]]
   // CHECK: store i8 %sel.eq, i8* %__value_, align 1


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


[PATCH] D64169: ARM MTE stack sanitizer.

2019-07-08 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka accepted this revision.
vitalybuka added inline comments.



Comment at: clang/lib/CodeGen/SanitizerMetadata.cpp:28
+  if (!CGM.getLangOpts().Sanitize.hasOneOf(
+  SanitizerKind::Address | SanitizerKind::KernelAddress |
+  SanitizerKind::HWAddress | SanitizerKind::KernelHWAddress |

maybe shared constant or function for :
SanitizerKind::Address | SanitizerKind::KernelAddress |
  SanitizerKind::HWAddress | SanitizerKind::KernelHWAddress |
  SanitizerKind::MemTag



Comment at: llvm/docs/BitCodeFormat.rst:1060
 * code 58: ``shadowcallstack``
+* code 62: ``sanitize_memtag``
 

why it's 62 and not e.g. 59?



Comment at: llvm/test/Bitcode/attributes.ll:363
+{
+ret void;
+}

indentation is inconsistent


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64169



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


[PATCH] D62829: [clang-tidy] Check for dynamically initialized statics in headers.

2019-07-08 Thread Charles Zhang via Phabricator via cfe-commits
czhang marked an inline comment as done.
czhang added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/bugprone/DynamicStaticInitializersCheck.cpp:39
+return;
+  Finder->addMatcher(varDecl(hasGlobalStorage()).bind("var"), this);
+}

aaron.ballman wrote:
> Do you want to restrict this matcher to only variable declarations that have 
> initializers, or are you also intending for this check to cover cases like:
> ```
> // At file scope.
> struct S { S(); } s;
> ```
I think only variables with static storage are relevant to the stated goal of 
the checker.



Comment at: 
clang-tools-extra/clang-tidy/bugprone/DynamicStaticInitializersCheck.cpp:55
+  SourceLocation Loc = Var->getLocation();
+  if (!Loc.isValid() || !utils::isPresumedLocInHeaderFile(Loc, 
*Result.SourceManager,
+  
HeaderFileExtensions))

aaron.ballman wrote:
> We have an AST matcher for this (`isExpansionInSystemHeader()`).
Isn't this for system headers only, not just included 'user' headers?


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

https://reviews.llvm.org/D62829



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


[PATCH] D63835: [Syntax] Add nodes for most common statements

2019-07-08 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang/include/clang/Tooling/Syntax/Nodes.h:25
 /// A kind of a syntax node, used for implementing casts.
 enum class NodeKind : uint16_t {
   Leaf,

there are going to be many of these. I'd suggest either sorting them all, or 
breaking them into blocks (e.g. statements vs declarations vs leaf/tu/etc) and 
sorting those blocks.



Comment at: clang/include/clang/Tooling/Syntax/Nodes.h:99
 /// An abstract node for C++ statements, e.g. 'while', 'if', etc.
 class Statement : public Tree {
 public:

Do you want to expose the statement-ending-semicolon here?

(Not all statements have it, but common enough you may want it in the base 
class instead of all children)



Comment at: clang/include/clang/Tooling/Syntax/Nodes.h:144
+  syntax::Leaf *switchKeyword();
+  syntax::Statement *body();
+

The fact that this can be an arbitrary statement is kind of shocking. But 
apparently true!

In the long run, we're probably going to be able to find the case statements 
somehow, even though they're not part of the immediate grammar. Not sure 
whether this should be via the regular AST or by adding links here. Anyway, 
problem for another day.



Comment at: clang/include/clang/Tooling/Syntax/Nodes.h:159
+  }
+  syntax::Leaf *caseKeyword();
+  syntax::Statement *body();

expression for the value?



Comment at: clang/include/clang/Tooling/Syntax/Nodes.h:160
+  syntax::Leaf *caseKeyword();
+  syntax::Statement *body();
+

syntactically, is it useful to model the body as a single statement? It's not a 
CompoundStmt as it has no braces. Seems like a sequence...

Or is the idea that the first following statement is the body (might be 
nothing), and subsequent ones aren't part of the body? Why is this more useful 
than making the body a sibling?



Comment at: clang/include/clang/Tooling/Syntax/Nodes.h:176
+  syntax::Leaf *defaultKeyword();
+  syntax::Statement *body();
+

might be handy to unify this with CaseStatement somehow (a base class, or make 
it literally a CaseStatement with a null body and a bool isDefaultCase() that 
looks at the keyword token)

Mostly thinking about code that's going to iterate over case statements.



Comment at: clang/include/clang/Tooling/Syntax/Nodes.h:185
+/// if (cond)  else 
+class IfStatement final : public Statement {
+public:

I guess the missing cond here (and similar below) are due to complexities 
around the variable declaring variants?

Warrants a FIXME I think



Comment at: clang/include/clang/Tooling/Syntax/Nodes.h:193
+  syntax::Statement *thenStatement();
+  syntax::Leaf *elseKeyword();
+  syntax::Statement *elseStatement();

I think throughout it's important to mark which of these are:
 - nullable in correct code
 - nullable in code generated by recovery



Comment at: clang/include/clang/Tooling/Syntax/Nodes.h:265
+/// return ;
+class ReturnStatement final : public Statement {
+public:

(any reason we can't already have the expr here?)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63835



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


[PATCH] D63846: [clang] Preserve names of addrspacecast'ed values.

2019-07-08 Thread Vyacheslav Zakharin via Phabricator via cfe-commits
vzakhari added a comment.

ping


Repository:
  rC Clang

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

https://reviews.llvm.org/D63846



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


[PATCH] D63846: [clang] Preserve names of addrspacecast'ed values.

2019-07-08 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

The change itself doesn't really bother me at all, however the test will fail 
if we build without preserving names.  In order to validate this you'll have to 
do fno-discard-value-names on a test.




Comment at: clang/test/CodeGenOpenCL/address-spaces-conversions.cl:16
   arg_gen = &var_priv; // implicit cast with obtaining adr, private -> generic
-  // CHECK: %{{[0-9]+}} = addrspacecast i32* %var_priv to i32 addrspace(4)*
+  // CHECK: %var_priv.ascast = addrspacecast i32* %var_priv to i32 
addrspace(4)*
   // CHECK-NOFAKE-NOT: addrspacecast

You probably don't want to remove the wildcard here.  If this is built without 
names being saved, this change will fail.


Repository:
  rC Clang

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

https://reviews.llvm.org/D63846



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


[clang-tools-extra] r365364 - [clangd] Don't insert absolute paths, give up instead.

2019-07-08 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Mon Jul  8 11:07:46 2019
New Revision: 365364

URL: http://llvm.org/viewvc/llvm-project?rev=365364&view=rev
Log:
[clangd] Don't insert absolute paths, give up instead.

Summary: Also implement resolution of paths relative to mainfile without 
HeaderSearchInfo.

Reviewers: kadircet

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

Tags: #llvm

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

Modified:
clang-tools-extra/trunk/clangd/CodeComplete.cpp
clang-tools-extra/trunk/clangd/Headers.cpp
clang-tools-extra/trunk/clangd/Headers.h
clang-tools-extra/trunk/clangd/IncludeFixer.cpp
clang-tools-extra/trunk/clangd/unittests/HeadersTests.cpp

Modified: clang-tools-extra/trunk/clangd/CodeComplete.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/CodeComplete.cpp?rev=365364&r1=365363&r2=365364&view=diff
==
--- clang-tools-extra/trunk/clangd/CodeComplete.cpp (original)
+++ clang-tools-extra/trunk/clangd/CodeComplete.cpp Mon Jul  8 11:07:46 2019
@@ -327,8 +327,12 @@ struct CodeCompletionBuilder {
   auto ResolvedInserted = toHeaderFile(Header, FileName);
   if (!ResolvedInserted)
 return ResolvedInserted.takeError();
+  auto Spelled = Includes.calculateIncludePath(*ResolvedInserted, 
FileName);
+  if (!Spelled)
+return llvm::createStringError(llvm::inconvertibleErrorCode(),
+   "Header not on include path");
   return std::make_pair(
-  Includes.calculateIncludePath(*ResolvedInserted, FileName),
+  std::move(*Spelled),
   Includes.shouldInsertInclude(*ResolvedDeclaring, *ResolvedInserted));
 };
 bool ShouldInsert = C.headerToInsertIfAllowed(Opts).hasValue();

Modified: clang-tools-extra/trunk/clangd/Headers.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Headers.cpp?rev=365364&r1=365363&r2=365364&view=diff
==
--- clang-tools-extra/trunk/clangd/Headers.cpp (original)
+++ clang-tools-extra/trunk/clangd/Headers.cpp Mon Jul  8 11:07:46 2019
@@ -186,19 +186,29 @@ bool IncludeInserter::shouldInsertInclud
   return !Included(DeclaringHeader) && !Included(InsertedHeader.File);
 }
 
-std::string
+llvm::Optional
 IncludeInserter::calculateIncludePath(const HeaderFile &InsertedHeader,
   llvm::StringRef IncludingFile) const {
   assert(InsertedHeader.valid());
   if (InsertedHeader.Verbatim)
 return InsertedHeader.File;
   bool IsSystem = false;
-  // FIXME(kadircet): Handle same directory includes even if there is no
-  // HeaderSearchInfo.
-  if (!HeaderSearchInfo)
-return "\"" + InsertedHeader.File + "\"";
-  std::string Suggested = HeaderSearchInfo->suggestPathToFileForDiagnostics(
-  InsertedHeader.File, BuildDir, IncludingFile, &IsSystem);
+  std::string Suggested;
+  if (HeaderSearchInfo) {
+Suggested = HeaderSearchInfo->suggestPathToFileForDiagnostics(
+InsertedHeader.File, BuildDir, IncludingFile, &IsSystem);
+  } else {
+// Calculate include relative to including file only.
+StringRef IncludingDir = llvm::sys::path::parent_path(IncludingFile);
+SmallString<256> RelFile(InsertedHeader.File);
+// Replacing with "" leaves "/RelFile" if IncludingDir doesn't end in "/".
+llvm::sys::path::replace_path_prefix(RelFile, IncludingDir, "./");
+Suggested = llvm::sys::path::convert_to_slash(
+llvm::sys::path::remove_leading_dotslash(RelFile));
+  }
+  // FIXME: should we allow (some limited number of) "../header.h"?
+  if (llvm::sys::path::is_absolute(Suggested))
+return None;
   if (IsSystem)
 Suggested = "<" + Suggested + ">";
   else

Modified: clang-tools-extra/trunk/clangd/Headers.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Headers.h?rev=365364&r1=365363&r2=365364&view=diff
==
--- clang-tools-extra/trunk/clangd/Headers.h (original)
+++ clang-tools-extra/trunk/clangd/Headers.h Mon Jul  8 11:07:46 2019
@@ -171,15 +171,16 @@ public:
   /// search path. Usually this will prefer a shorter representation like
   /// 'Foo/Bar.h' over a longer one like 'Baz/include/Foo/Bar.h'.
   ///
-  /// \param InsertedHeader The preferred header to be inserted. This could be
-  /// the same as DeclaringHeader but must be provided.
+  /// \param InsertedHeader The preferred header to be inserted.
   ///
   /// \param IncludingFile is the absolute path of the file that InsertedHeader
   /// will be inserted.
   ///
-  /// \return A quoted "path" or  to be included.
-  std::string calculateIncludePath(const HeaderFile &InsertedHeader,
-   llvm::StringRef IncludingFile) const;
+  /// \return A quoted "path" or  to be included, or None if it

[PATCH] D64317: [Driver] Add float-divide-by-zero back to supported sanitizers after D63793/rC365272

2019-07-08 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

is the patch description still correct?


Repository:
  rC Clang

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

https://reviews.llvm.org/D64317



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


[PATCH] D63663: [clang-doc] Add html links to references

2019-07-08 Thread Diego Astiazarán via Phabricator via cfe-commits
DiegoAstiazaran updated this revision to Diff 208463.
DiegoAstiazaran added a comment.

Rebase after D52847  was pushed.
Path added to parent Info in serialization, this is required after D63911 
 was pushed.


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

https://reviews.llvm.org/D63663

Files:
  clang-tools-extra/clang-doc/BitcodeReader.cpp
  clang-tools-extra/clang-doc/BitcodeWriter.cpp
  clang-tools-extra/clang-doc/BitcodeWriter.h
  clang-tools-extra/clang-doc/Generators.cpp
  clang-tools-extra/clang-doc/Generators.h
  clang-tools-extra/clang-doc/HTMLGenerator.cpp
  clang-tools-extra/clang-doc/MDGenerator.cpp
  clang-tools-extra/clang-doc/Mapper.cpp
  clang-tools-extra/clang-doc/Representation.cpp
  clang-tools-extra/clang-doc/Representation.h
  clang-tools-extra/clang-doc/Serialize.cpp
  clang-tools-extra/clang-doc/Serialize.h
  clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
  clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp
  clang-tools-extra/unittests/clang-doc/SerializeTest.cpp

Index: clang-tools-extra/unittests/clang-doc/SerializeTest.cpp
===
--- clang-tools-extra/unittests/clang-doc/SerializeTest.cpp
+++ clang-tools-extra/unittests/clang-doc/SerializeTest.cpp
@@ -37,7 +37,7 @@
 
   template  bool mapDecl(const T *D) {
 auto I = serialize::emitInfo(D, getComment(D), /*Line=*/0,
- /*File=*/"test.cpp", Public);
+ /*File=*/"test.cpp", Public, "");
 if (I.first)
   EmittedInfos.emplace_back(std::move(I.first));
 if (I.second)
Index: clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp
===
--- clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp
+++ clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp
@@ -57,7 +57,8 @@
   
 OneFunction
 
-   OneFunction()
+  OneFunction(
+  )
 
   
   Enums
@@ -78,9 +79,10 @@
   I.DefLoc = Location(10, llvm::SmallString<16>{"test.cpp"});
   I.Loc.emplace_back(12, llvm::SmallString<16>{"test.cpp"});
 
-  I.Members.emplace_back("int", "X", AccessSpecifier::AS_private);
+  I.Members.emplace_back("int", "/path/to", "X", AccessSpecifier::AS_private);
   I.TagType = TagTypeKind::TTK_Class;
-  I.Parents.emplace_back(EmptySID, "F", InfoType::IT_record);
+  I.Parents.emplace_back(EmptySID, "F", InfoType::IT_record,
+ llvm::SmallString<128>("/path/to"));
   I.VirtualParents.emplace_back(EmptySID, "G", InfoType::IT_record);
 
   I.ChildRecords.emplace_back(EmptySID, "ChildStruct", InfoType::IT_record);
@@ -104,11 +106,14 @@
 Defined at line 10 of test.cpp
   
   
-Inherits from F, G
+Inherits from 
+F
+, 
+G
   
   Members
   
-private int X
+private int X
   
   Records
   
@@ -118,7 +123,8 @@
   
 OneFunction
 
-   OneFunction()
+  OneFunction(
+  )
 
   
   Enums
@@ -139,8 +145,8 @@
   I.DefLoc = Location(10, llvm::SmallString<16>{"test.cpp"});
   I.Loc.emplace_back(12, llvm::SmallString<16>{"test.cpp"});
 
-  I.ReturnType = TypeInfo(EmptySID, "void", InfoType::IT_default);
-  I.Params.emplace_back("int", "P");
+  I.ReturnType = TypeInfo(EmptySID, "float", InfoType::IT_default, "/path/to");
+  I.Params.emplace_back("int", "/path/to", "P");
   I.IsMethod = true;
   I.Parent = Reference(EmptySID, "Parent", InfoType::IT_record);
 
@@ -156,7 +162,12 @@
 
   f
   
-void f(int P)
+float
+ 
+f(
+int
+ P
+)
   
   
 Defined at line 10 of test.cpp
@@ -250,7 +261,15 @@
 
   f
   
-void f(int I, int J)
+void
+ 
+f(
+int
+ I
+, 
+int
+ J
+)
   
   
 Defined at line 10 of test.cpp
Index: clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
===
--- clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
+++ clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
@@ -110,12 +110,13 @@
   return false;
 }
 
-// A function to extract the appropriate path name for a given info's
-// documentation. The path returned is a composite of the parent namespaces as
-// directories plus the decl name as the filename.
+// A function to extract the appropriate file name for a given info's
+// documentation. The path returned is a composite of the direcory and the
+// info's name. The directory should have been constructed in the serialization
+// phase.
 //
-// Example: Given the below, the  path for class C will be <
-// root>/A/B/C.
+// Example: Given the below, the  path for class C will be
+// /A/B/C.
 //
 // namespace A {
 // namesapce B {
@@ -125,15 +126,7 @@
 // }
 // }
 llvm::Expected>
-getInfoOutputFile(StringRef Root,
-  llvm::SmallVectorImpl &Namespaces,
-  StringRef Name, StringRef Ext) {
-  std::error_code OK;
-

[PATCH] D64356: [OPENMP]Initial fix PR42392: Improve -Wuninitialized warnings for OpenMP programs.

2019-07-08 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev created this revision.
ABataev added reviewers: NoQ, Szelethus, dcoughlin, xazax.hun, a.sidorin, 
george.karpenkov, szepet.
Herald added subscribers: jdoerfert, jfb, guansong, rnkovacs.
Herald added a project: clang.

Some OpenMP clauses rely on the values of the variables. If the variable
is not initialized and used in OpenMP clauses that depend on the
variables values, it should be reported that the uninitialized variable
is used in the OpenMP clause expression.
This patch adds initial processing for uninitialized variables in OpenMP
constructs. Currently, it checks for use of the uninitialized variables
in the structured blocks.


Repository:
  rC Clang

https://reviews.llvm.org/D64356

Files:
  include/clang/AST/StmtOpenMP.h
  lib/AST/StmtOpenMP.cpp
  lib/Analysis/CFG.cpp
  lib/Analysis/UninitializedValues.cpp
  test/OpenMP/atomic_messages.c
  test/OpenMP/critical_messages.cpp
  test/OpenMP/distribute_parallel_for_messages.cpp
  test/OpenMP/distribute_parallel_for_simd_misc_messages.c
  test/OpenMP/distribute_simd_misc_messages.c
  test/OpenMP/for_misc_messages.c
  test/OpenMP/for_simd_misc_messages.c
  test/OpenMP/master_messages.cpp
  test/OpenMP/ordered_messages.cpp
  test/OpenMP/parallel_for_messages.cpp
  test/OpenMP/parallel_for_simd_messages.cpp
  test/OpenMP/parallel_messages.cpp
  test/OpenMP/parallel_sections_messages.cpp
  test/OpenMP/sections_misc_messages.c
  test/OpenMP/simd_misc_messages.c
  test/OpenMP/single_misc_messages.c
  test/OpenMP/target_depend_messages.cpp
  test/OpenMP/target_parallel_for_messages.cpp
  test/OpenMP/target_parallel_for_simd_messages.cpp
  test/OpenMP/target_parallel_messages.cpp
  test/OpenMP/target_simd_messages.cpp
  test/OpenMP/target_teams_distribute_messages.cpp
  test/OpenMP/target_teams_distribute_parallel_for_messages.cpp
  test/OpenMP/target_teams_distribute_parallel_for_simd_messages.cpp
  test/OpenMP/target_teams_distribute_simd_messages.cpp
  test/OpenMP/target_teams_messages.cpp
  test/OpenMP/target_update_messages.cpp
  test/OpenMP/task_messages.cpp
  test/OpenMP/taskgroup_messages.cpp
  test/OpenMP/taskloop_misc_messages.c
  test/OpenMP/taskloop_simd_misc_messages.c
  test/OpenMP/teams_distribute_parallel_for_messages.cpp
  test/OpenMP/teams_distribute_parallel_for_simd_messages.cpp
  test/OpenMP/teams_distribute_simd_messages.cpp
  test/OpenMP/teams_messages.cpp

Index: test/OpenMP/teams_messages.cpp
===
--- test/OpenMP/teams_messages.cpp
+++ test/OpenMP/teams_messages.cpp
@@ -2,6 +2,13 @@
 
 // RUN: %clang_cc1 -verify -fopenmp-simd -std=c++11 -o - %s -Wuninitialized
 
+void xxx(int argc) {
+  int x; // expected-note {{initialize the variable 'x' to silence this warning}}
+#pragma omp target
+#pragma omp teams
+  argc = x; // expected-warning {{variable 'x' is uninitialized when used here}}
+}
+
 void foo() {
 }
 
Index: test/OpenMP/teams_distribute_simd_messages.cpp
===
--- test/OpenMP/teams_distribute_simd_messages.cpp
+++ test/OpenMP/teams_distribute_simd_messages.cpp
@@ -2,6 +2,14 @@
 
 // RUN: %clang_cc1 -verify -fopenmp-simd -std=c++11 %s -Wuninitialized
 
+void xxx(int argc) {
+  int x; // expected-note {{initialize the variable 'x' to silence this warning}}
+#pragma omp target
+#pragma omp teams distribute simd
+  for (int i = 0; i < 10; ++i)
+argc = x; // expected-warning {{variable 'x' is uninitialized when used here}}
+}
+
 void foo() {
 }
 
Index: test/OpenMP/teams_distribute_parallel_for_simd_messages.cpp
===
--- test/OpenMP/teams_distribute_parallel_for_simd_messages.cpp
+++ test/OpenMP/teams_distribute_parallel_for_simd_messages.cpp
@@ -2,6 +2,14 @@
 
 // RUN: %clang_cc1 -verify -fopenmp-simd -std=c++11 %s -Wuninitialized
 
+void xxx(int argc) {
+  int x; // expected-note {{initialize the variable 'x' to silence this warning}}
+#pragma omp target
+#pragma omp teams distribute parallel for simd
+  for (int i = 0; i < 10; ++i)
+argc = x; // expected-warning {{variable 'x' is uninitialized when used here}}
+}
+
 void foo() {
 }
 
Index: test/OpenMP/teams_distribute_parallel_for_messages.cpp
===
--- test/OpenMP/teams_distribute_parallel_for_messages.cpp
+++ test/OpenMP/teams_distribute_parallel_for_messages.cpp
@@ -2,6 +2,14 @@
 
 // RUN: %clang_cc1 -verify -fopenmp-simd -std=c++11 %s -Wuninitialized
 
+void xxx(int argc) {
+  int x; // expected-note {{initialize the variable 'x' to silence this warning}}
+#pragma omp target
+#pragma omp teams distribute parallel for
+  for (int i = 0; i < 10; ++i)
+argc = x; // expected-warning {{variable 'x' is uninitialized when used here}}
+}
+
 void foo() {
 }
 
Index: test/OpenMP/taskloop_simd_misc_messages.c
===
--- test/OpenMP/taskloop_simd_misc_messages.c
+++

Re: [libunwind] r364217 - Merging r360861:

2019-07-08 Thread Dimitry Andric via cfe-commits
On 24 Jun 2019, at 20:40, Tom Stellard via cfe-commits 
 wrote:
> 
> Author: tstellar
> Date: Mon Jun 24 11:40:58 2019
> New Revision: 364217
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=364217&view=rev
> Log:
> Merging r360861:
> 
> 
> r360861 | mstorsjo | 2019-05-15 23:49:13 -0700 (Wed, 15 May 2019) | 13 lines
> 
> [PPC64][libunwind] Fix r2 not properly restored

> Modified: libunwind/branches/release_80/src/assembly.h
> URL: 
> http://llvm.org/viewvc/llvm-project/libunwind/branches/release_80/src/assembly.h?rev=364217&r1=364216&r2=364217&view=diff
> ==
> --- libunwind/branches/release_80/src/assembly.h (original)
> +++ libunwind/branches/release_80/src/assembly.h Mon Jun 24 11:40:58 2019
> @@ -35,6 +35,20 @@
> #define SEPARATOR ;
> #endif
> 
> +#if defined(__powerpc64__) && (!defined(_CALL_ELF) || _CALL_ELF == 1)
> +#define PPC64_OPD1 .section .opd,"aw",@progbits SEPARATOR
> +#define PPC64_OPD2 SEPARATOR \
> +  .p2align 3 SEPARATOR \
> +  .quad .Lfunc_begin0 SEPARATOR \
> +  .quad .TOC.@tocbase SEPARATOR \
> +  .quad 0 SEPARATOR \
> +  .text SEPARATOR \
> +.Lfunc_begin0:
> +#else
> +#define PPC64_OPD1
> +#define PPC64_OPD2
> +#endif
> +
> #define GLUE2(a, b) a ## b
> #define GLUE(a, b) GLUE2(a, b)
> #define SYMBOL_NAME(name) GLUE(__USER_LABEL_PREFIX__, name)
> @@ -95,7 +109,9 @@
>   .globl SYMBOL_NAME(name) SEPARATOR  \
>   EXPORT_SYMBOL(name) SEPARATOR   \
>   SYMBOL_IS_FUNC(SYMBOL_NAME(name)) SEPARATOR \
> -  SYMBOL_NAME(name):
> +  PPC64_OPD1  \
> +  SYMBOL_NAME(name):  \
> +  PPC64_OPD2
> 
> #define DEFINE_LIBUNWIND_PRIVATE_FUNCTION(name)   \
>   .globl SYMBOL_NAME(name) SEPARATOR  \
> 

I think this merge missed that the DEFINE_LIBUNWIND_PRIVATE_FUNCTION
macro went away in r357640 ("[libunwind] Export the unw_* symbols as
weak symbols").

It looks like the PPC64_OPD1 and PPC64_OPD2 lines should also be added
to the expansion of DEFINE_LIBUNWIND_PRIVATE_FUNCTION?

-Dimitry



signature.asc
Description: Message signed with OpenPGP
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D64274: [analyzer] VirtualCallChecker overhaul.

2019-07-08 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

Hmm, wait, i don't really break backwards compatibility. Fridays...

Previously we have impure-checking when we enable the optin checker and 
pureonly-checking when we disable the option.

I can easily bring back the option, only for the purposes of backwards 
compatibility, so that it was turning off impure-checking.

In this case we'll still have impure-checking when we enable the optin checker 
and pureonly-checking when we disable the option. The only difference is that 
pureonly-checking is now going to be on by default.


Repository:
  rC Clang

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

https://reviews.llvm.org/D64274



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


[PATCH] D63846: [clang] Preserve names of addrspacecast'ed values.

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

Please don't check IR names in test output.  That actually includes anonymous 
names like `%2`; these should always be tested with FileCheck variables.  I 
suggest using `%.*` as the pattern; if you're matching the LHS of an LLVM 
assignment, that shouldn't have problems with accidentally matching too much.


Repository:
  rC Clang

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

https://reviews.llvm.org/D63846



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


LLVM buildmaster will be updated and restarted tonight

2019-07-08 Thread Galina Kistanova via cfe-commits
 Hello everyone,

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

Thanks

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


[PATCH] D61879: WIP: Prototype of DSE optimizations for -ftrivial-auto-var-init

2019-07-08 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea added inline comments.



Comment at: llvm/include/llvm/Analysis/MemorySSA.h:1109
 // else.
-if (MemoryPhi *MP = dyn_cast(Access))
+if (const MemoryPhi *MP = dyn_cast(Access))
   return MP->getIncomingValue(ArgNo);

Could changes in this file be landed separately?
They seem unrelated and not in need of review.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61879



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


[PATCH] D64317: [Driver] Add float-divide-by-zero back to supported sanitizers after D63793/rC365272

2019-07-08 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

In D64317#1574007 , @vitalybuka wrote:

> is the patch description still correct?


Yes.

> Also, add SanitizerMask::FloatDivideByZero to a few other masks to make 
> -fsanitize-trap, -fsanitize-recover, -fsanitize-minimal-runtime and 
> -fsanitize-coverage work.

`-fsanitize=float-divide-by-zero` was accidentally removed by D63793 
. This patch adds it back.


Repository:
  rC Clang

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

https://reviews.llvm.org/D64317



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


Re: r281071 - Myriad: nominally "support" ASAN.

2019-07-08 Thread Richard Smith via cfe-commits
On Fri, 9 Sep 2016 at 11:29, Douglas Katzman via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: dougk
> Date: Fri Sep  9 13:20:49 2016
> New Revision: 281071
>
> URL: http://llvm.org/viewvc/llvm-project?rev=281071&view=rev
> Log:
> Myriad: nominally "support" ASAN.
>
> Doesn't work, but needs to be enabled in order to get there.
>
> Modified:
> cfe/trunk/lib/Driver/ToolChains.cpp
> cfe/trunk/lib/Driver/ToolChains.h
> cfe/trunk/lib/Driver/Tools.cpp
> cfe/trunk/test/Driver/sanitizer-ld.c
>
> Modified: cfe/trunk/lib/Driver/ToolChains.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=281071&r1=281070&r2=281071&view=diff
>
> ==
> --- cfe/trunk/lib/Driver/ToolChains.cpp (original)
> +++ cfe/trunk/lib/Driver/ToolChains.cpp Fri Sep  9 13:20:49 2016
> @@ -5042,6 +5042,10 @@ Tool *MyriadToolChain::buildLinker() con
>return new tools::Myriad::Linker(*this);
>  }
>
> +SanitizerMask MyriadToolChain::getSupportedSanitizers() const {
> +  return SanitizerKind::Address;
>

This change disabled the use of UBSan on Myriad; was that intentional? (All
other overriders call the base class version to get a list of sanitizers
that don't require special platform support, and then add values to the
mask that it returns.)


> +}
> +
>  WebAssembly::WebAssembly(const Driver &D, const llvm::Triple &Triple,
>   const llvm::opt::ArgList &Args)
>: ToolChain(D, Triple, Args) {
>
> Modified: cfe/trunk/lib/Driver/ToolChains.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.h?rev=281071&r1=281070&r2=281071&view=diff
>
> ==
> --- cfe/trunk/lib/Driver/ToolChains.h (original)
> +++ cfe/trunk/lib/Driver/ToolChains.h Fri Sep  9 13:20:49 2016
> @@ -1147,6 +1147,7 @@ public:
>llvm::opt::ArgStringList &CC1Args) const override;
>Tool *SelectTool(const JobAction &JA) const override;
>unsigned GetDefaultDwarfVersion() const override { return 2; }
> +  SanitizerMask getSupportedSanitizers() const override;
>
>  protected:
>Tool *buildLinker() const override;
>
> Modified: cfe/trunk/lib/Driver/Tools.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=281071&r1=281070&r2=281071&view=diff
>
> ==
> --- cfe/trunk/lib/Driver/Tools.cpp (original)
> +++ cfe/trunk/lib/Driver/Tools.cpp Fri Sep  9 13:20:49 2016
> @@ -3081,11 +3081,15 @@ static void linkSanitizerRuntimeDeps(con
>// Force linking against the system libraries sanitizers depends on
>// (see PR15823 why this is necessary).
>CmdArgs.push_back("--no-as-needed");
> -  CmdArgs.push_back("-lpthread");
> -  CmdArgs.push_back("-lrt");
> +  // There's no libpthread or librt on RTEMS.
> +  if (TC.getTriple().getOS() != llvm::Triple::RTEMS) {
> +CmdArgs.push_back("-lpthread");
> +CmdArgs.push_back("-lrt");
> +  }
>CmdArgs.push_back("-lm");
> -  // There's no libdl on FreeBSD.
> -  if (TC.getTriple().getOS() != llvm::Triple::FreeBSD)
> +  // There's no libdl on FreeBSD or RTEMS.
> +  if (TC.getTriple().getOS() != llvm::Triple::FreeBSD &&
> +  TC.getTriple().getOS() != llvm::Triple::RTEMS)
>  CmdArgs.push_back("-ldl");
>  }
>
> @@ -11055,9 +11059,12 @@ void tools::Myriad::Linker::ConstructJob
>
>TC.AddFilePathLibArgs(Args, CmdArgs);
>
> +  bool NeedsSanitizerDeps = addSanitizerRuntimes(TC, Args, CmdArgs);
>AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs);
>
>if (UseDefaultLibs) {
> +if (NeedsSanitizerDeps)
> +  linkSanitizerRuntimeDeps(TC, CmdArgs);
>  if (C.getDriver().CCCIsCXX())
>CmdArgs.push_back("-lstdc++");
>  if (T.getOS() == llvm::Triple::RTEMS) {
>
> Modified: cfe/trunk/test/Driver/sanitizer-ld.c
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/sanitizer-ld.c?rev=281071&r1=281070&r2=281071&view=diff
>
> ==
> --- cfe/trunk/test/Driver/sanitizer-ld.c (original)
> +++ cfe/trunk/test/Driver/sanitizer-ld.c Fri Sep  9 13:20:49 2016
> @@ -151,6 +151,15 @@
>  // CHECK-ASAN-ANDROID-SHARED: libclang_rt.asan-arm-android.so"
>  // CHECK-ASAN-ANDROID-SHARED-NOT: "-lpthread"
>
> +// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
> +// RUN: -target sparcel-myriad-rtems-elf -fsanitize=address \
> +// RUN: --sysroot=%S/Inputs/basic_myriad_tree \
> +// RUN:   | FileCheck --check-prefix=CHECK-ASAN-MYRIAD %s
> +//
> +// CHECK-ASAN-MYRIAD: "{{(.*[^.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
> +// CHECK-ASAN-MYRIAD-NOT: "-lc"
> +// CHECK-ASAN-MYRIAD: libclang_rt.asan-sparcel.a"
> +
>  // RUN: %clangxx -no-canonical-prefixes %s -### -o %t.o 2>&1 \
>  // RUN: -target x86_64-unknown-linux -stdlib=platform -lstdc++ \
>  // RUN: -fsanitize=thread \
>

[PATCH] D64274: [analyzer] VirtualCallChecker overhaul.

2019-07-08 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

Mmm, no, not really; it seems that if i introduce a checker dependency, i also 
have to put the option onto the base checker, otherwise the checker name 
wouldn't match when i do 
`getCheckerBooleanOption(getChecker(), "PureOnly")`. Which 
means that the option name will inevitably change. @Szelethus, do i understand 
this correctly?


Repository:
  rC Clang

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

https://reviews.llvm.org/D64274



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


r365374 - [OPENMP]Improve error message for device unsupported types.

2019-07-08 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Mon Jul  8 12:21:54 2019
New Revision: 365374

URL: http://llvm.org/viewvc/llvm-project?rev=365374&view=rev
Log:
[OPENMP]Improve error message for device unsupported types.

Provide more data to the user in the error message about unsupported
type for device compilation.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/nvptx_unsupported_type_messages.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=365374&r1=365373&r2=365374&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Mon Jul  8 12:21:54 
2019
@@ -9269,6 +9269,8 @@ def err_omp_invariant_or_linear_dependen
   "expected loop invariant expression or ' * %0 + ' 
kind of expression">;
 def err_omp_wrong_dependency_iterator_type : Error<
   "expected an integer or a pointer type of the outer loop counter '%0' for 
non-rectangular nests">;
+def err_omp_unsupported_type : Error <
+  "host requires %0 bit size %1 type support, but device '%2' does not support 
it">;
 } // end of OpenMP category
 
 let CategoryName = "Related Result Type Issue" in {

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=365374&r1=365373&r2=365374&view=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Mon Jul  8 12:21:54 2019
@@ -1593,8 +1593,9 @@ void Sema::checkOpenMPDeviceExpr(const E
!Context.getTargetInfo().hasFloat128Type()) ||
   (Ty->isIntegerType() && Context.getTypeSize(Ty) == 128 &&
!Context.getTargetInfo().hasInt128Type()))
-targetDiag(E->getExprLoc(), diag::err_type_unsupported)
-<< Ty << E->getSourceRange();
+targetDiag(E->getExprLoc(), diag::err_omp_unsupported_type)
+<< static_cast(Context.getTypeSize(Ty)) << Ty
+<< Context.getTargetInfo().getTriple().str() << E->getSourceRange();
 }
 
 bool Sema::isOpenMPCapturedByRef(const ValueDecl *D, unsigned Level) const {

Modified: cfe/trunk/test/OpenMP/nvptx_unsupported_type_messages.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/nvptx_unsupported_type_messages.cpp?rev=365374&r1=365373&r2=365374&view=diff
==
--- cfe/trunk/test/OpenMP/nvptx_unsupported_type_messages.cpp (original)
+++ cfe/trunk/test/OpenMP/nvptx_unsupported_type_messages.cpp Mon Jul  8 
12:21:54 2019
@@ -14,9 +14,9 @@ struct T {
   char c;
   T() : a(12), f(15) {}
 #ifndef _ARCH_PPC
-// expected-error@+4 {{'__float128' is not supported on this target}}
+// expected-error@+4 {{host requires 128 bit size '__float128' type support, 
but device 'nvptx64-unknown-unknown' does not support it}}
 #else
-// expected-error@+2 {{'long double' is not supported on this target}}
+// expected-error@+2 {{host requires 128 bit size 'long double' type support, 
but device 'nvptx64-unknown-unknown' does not support it}}
 #endif
   T &operator+(T &b) { f += b.a; return *this;}
 };


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


[PATCH] D64274: [analyzer] VirtualCallChecker overhaul.

2019-07-08 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ updated this revision to Diff 208473.
NoQ added a comment.

Fix the crash on enabling both checkers, add a test.


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

https://reviews.llvm.org/D64274

Files:
  clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
  clang/lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp
  clang/test/Analysis/analyzer-config.c
  clang/test/Analysis/virtualcall.cpp
  clang/test/Analysis/virtualcall.h

Index: clang/test/Analysis/virtualcall.h
===
--- clang/test/Analysis/virtualcall.h
+++ clang/test/Analysis/virtualcall.h
@@ -2,12 +2,7 @@
   class Z {
   public:
 Z() {
-  foo();
-#if !PUREONLY
-	// expected-warning-re@-2 ^}}Call to virtual function during construction}}
-	// expected-note-re@-3 ^}}This constructor of an object of type 'Z' has not returned when the virtual method was called}}
-	// expected-note-re@-4 ^}}Call to virtual function during construction}}	
-#endif
+  foo(); // impure-warning {{Call to virtual function during construction}}
 }
 virtual int foo();
   };
Index: clang/test/Analysis/virtualcall.cpp
===
--- clang/test/Analysis/virtualcall.cpp
+++ clang/test/Analysis/virtualcall.cpp
@@ -1,6 +1,12 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=optin.cplusplus.VirtualCall -analyzer-store region -analyzer-output=text -verify -std=c++11 %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,optin.cplusplus.VirtualCall \
+// RUN:-std=c++11 -verify=expected,impure %s
 
-// RUN: %clang_analyze_cc1 -analyzer-checker=optin.cplusplus.VirtualCall -analyzer-store region -analyzer-config optin.cplusplus.VirtualCall:PureOnly=true -DPUREONLY=1 -analyzer-output=text -verify -std=c++11 %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,cplusplus.PureVirtualCall \
+// RUN:-std=c++11 -verify=expected -std=c++11 %s
+
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,cplusplus.PureVirtualCall \
+// RUN:-analyzer-checker=optin.cplusplus.VirtualCall \
+// RUN:-std=c++11 -verify=expected,impure -std=c++11 %s
 
 #include "virtualcall.h"
 
@@ -13,54 +19,31 @@
   virtual int foo() = 0;
   virtual void bar() = 0;
   void f() {
-foo();
-	// expected-warning-re@-1 ^}}Call to pure virtual function during construction}}
-	// expected-note-re@-2 ^}}Call to pure virtual function during construction}}
+foo(); // expected-warning{{Call to pure virtual function during construction}}
   }
 };
 
 class B : public A {
 public:
-  B() { // expected-note {{Calling default constructor for 'A'}}
-foo(); 
-#if !PUREONLY
-  	// expected-warning-re@-2 ^}}Call to virtual function during construction}}
-	// expected-note-re@-3 ^}}This constructor of an object of type 'B' has not returned when the virtual method was called}}
-  	// expected-note-re@-4 ^}}Call to virtual function during construction}}
-#endif
+  B() {
+foo(); // impure-warning {{Call to virtual function during construction}}
   }
   ~B();
 
   virtual int foo();
   virtual void bar() {
-foo(); 
-#if !PUREONLY
-  	// expected-warning-re@-2 ^}}Call to virtual function during destruction}}
-  	// expected-note-re@-3 ^}}Call to virtual function during destruction}}
-#endif
-  } 
+foo(); // impure-warning{{Call to virtual function during destruction}}
+  }
 };
 
-A::A() { 
-  f(); 
-// expected-note-re@-1 ^}}This constructor of an object of type 'A' has not returned when the virtual method was called}}
-// expected-note-re@-2 ^}}Calling 'A::f'}}
+A::A() {
+  f();
 }
 
 B::~B() {
   this->B::foo(); // no-warning
   this->B::bar();
-#if !PUREONLY
- 	 // expected-note-re@-2 ^}}This destructor of an object of type '~B' has not returned when the virtual method was called}}
- 	 // expected-note-re@-3 ^}}Calling 'B::bar'}}
-#endif
-  this->foo(); 
-#if !PUREONLY
- 	 // expected-warning-re@-2 ^}}Call to virtual function during destruction}}
- 	 // expected-note-re@-3 ^}}This destructor of an object of type '~B' has not returned when the virtual method was called}}
- 	 // expected-note-re@-4 ^}}Call to virtual function during destruction}}
-#endif
-	
+  this->foo(); // impure-warning {{Call to virtual function during destruction}}
 }
 
 class C : public B {
@@ -73,12 +56,7 @@
 };
 
 C::C() {
-  f(foo()); 
-#if !PUREONLY
-  	// expected-warning-re@-2 ^}}Call to virtual function during construction}}
-	// expected-note-re@-3 ^}}This constructor of an object of type 'C' has not returned when the virtual method was called}}
-  	// expected-note-re@-4 ^}}Call to virtual function during construction}}
-#endif
+  f(foo()); // impure-warning {{Call to virtual function during construction}}
 }
 
 class D : public B {
@@ -97,9 +75,6 @@
 foo(); // no-warning
   }
   ~E() { bar(); }
-#if !PUREONLY
- 	 // expecte

Re: r365030 - Make a buildbot using a buggy gcc happy

2019-07-08 Thread JF Bastien via cfe-commits
Kristof,

It looks like your fix didn’t address all the bots:

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/tools/clang/lib/Analysis/Dominators.cpp:14:48:
 error: explicit specialization of 'anchor' after instantiation
void CFGDominatorTreeImpl::anchor() {}
   ^
/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/tools/clang/include/clang/Analysis/Analyses/Dominators.h:225:3:
 note: implicit instantiation first required here
  ControlDependencyCalculator(CFG *cfg)
  ^

Can you please address the issue?
http://green.lab.llvm.org/green/job/clang-stage2-coverage-R/4153/consoleFull 


Thanks,

JF


> On Jul 3, 2019, at 5:06 AM, Kristof Umann via cfe-commits 
>  wrote:
> 
> Author: szelethus
> Date: Wed Jul  3 05:06:10 2019
> New Revision: 365030
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=365030&view=rev
> Log:
> Make a buildbot using a buggy gcc happy
> 
> When specializing a template in a namespace, it has to be in a namespace
> block, else gcc will get confused. Hopefully this fixes the issue.
> 
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56480
> 
> Modified:
>cfe/trunk/lib/Analysis/Dominators.cpp
> 
> Modified: cfe/trunk/lib/Analysis/Dominators.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/Dominators.cpp?rev=365030&r1=365029&r2=365030&view=diff
> ==
> --- cfe/trunk/lib/Analysis/Dominators.cpp (original)
> +++ cfe/trunk/lib/Analysis/Dominators.cpp Wed Jul  3 05:06:10 2019
> @@ -8,10 +8,12 @@
> 
> #include "clang/Analysis/Analyses/Dominators.h"
> 
> -using namespace clang;
> +namespace clang {
> 
> template <>
> -void clang::CFGDominatorTreeImpl::anchor() {}
> +void CFGDominatorTreeImpl::anchor() {}
> 
> template <>
> -void clang::CFGDominatorTreeImpl::anchor() {}
> +void CFGDominatorTreeImpl::anchor() {}
> +
> +} // end of namespace clang
> 
> 
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

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


[PATCH] D64317: [Driver] Add float-divide-by-zero back to supported sanitizers after D63793/rC365272

2019-07-08 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: lib/Driver/SanitizerArgs.cpp:27-30
 static const SanitizerMask NeedsUbsanRt =
 SanitizerKind::Undefined | SanitizerKind::Integer |
 SanitizerKind::ImplicitConversion | SanitizerKind::Nullability |
+SanitizerKind::CFI | SanitizerKind::FloatDivideByZero;

Duplicating this list of "all sanitizers covered by the ubsan runtime" in many 
places is leading to lots of bugs.

This change misses `getPPTransparentSanitizers()` in 
`include/clang/Basic/Sanitizers.h`. Previous changes forgot to add 
`UnsignedIntegerOverflow` and `LocalBounds` to that function and also here and 
in `SupportsCoverage` and `RecoverableByDefault` below (but did update 
`TrappingSupported` and `getSupportedSanitizers`).

A better approach would be to change `Sanitizers.def` to specify the relevant 
properties of the sanitizer (whether it's in the ubsan runtime, whether it's 
recoverable, whether it supports coverage, whether it supports trapping, 
whether it affects preprocessing) along with its definition.



Comment at: test/Driver/fsanitize.c:844
+
+// RUN: %clang -target x86_64-linux -fsanitize=float-divide-by-zero %s -### 
2>&1 | FileCheck %s --check-prefixes=CHECK-DIVBYZERO,CHECK-DIVBYZERO-RECOVER
+// RUN: %clang -target x86_64-linux -fsanitize=float-divide-by-zero %s 
-fno-sanitize-recover=float-divide-by-zero -### 2>&1 | FileCheck %s 
--check-prefixes=CHECK-DIVBYZERO,CHECK-DIVBYZERO-NORECOVER

I think these tests should be target-independent. We should support this 
sanitizer (and indeed almost all of ubsan) regardless of the target. (Currently 
this is true on all targets except Myriad, where the latter is disallowed only 
due to a bug in r281071.)


Repository:
  rC Clang

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

https://reviews.llvm.org/D64317



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


[PATCH] D60456: [RISCV] Hard float ABI support

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

I'm fine with proceeding with your best guess about what the ABI should be.




Comment at: clang/lib/CodeGen/TargetInfo.cpp:9232
+if (IsFloat && Size > FLen)
+  return false;
+// Can't be eligible if an integer type was already found (only fp+int or

asb wrote:
> rjmccall wrote:
> > Is this the only consideration for floating-point types?  Clang does have 
> > increasing support for `half` / various `float16` types.
> These types aren't supported on RISC-V currently. As the ABI hasn't really 
> been explicitly confirmed, I've defaulted to the integer ABI in that case. 
> Could move to an assert if you prefer, though obviously any future move to 
> enable half floats for RISC-V should include ABI tests too.
Defaulting to the integer ABI is fine.



Comment at: clang/lib/CodeGen/TargetInfo.cpp:9236
+if (IsInt && Field1Ty && Field1Ty->isIntegerTy())
+  return false;
+if (!Field1Ty) {

asb wrote:
> rjmccall wrote:
> > The comment here is wrong because fp+fp is allowed, right?
> > 
> > Is this not already caught by the post-processing checks you do in 
> > `detectFPCCEligibleStruct`?  Would it make more sense to just do all those 
> > checks there?
> Thanks, I meant to say int+int isn't eligible. Reworded to say that.
> 
> I don't think it would simplify things to do all checks in 
> detectFPCCEligibleStruct. More repetition would be required in order to do 
> checks on both Float1Ty and Float2Ty.
Okay.  It just seemed to me that responsibility was oddly split between the 
functions.



Comment at: clang/lib/CodeGen/TargetInfo.cpp:9340
+if (getContext().getTypeSize(QTy) > XLen && BitWidth <= XLen)
+  QTy = getContext().getIntTypeForBitwidth(XLen, false);
+if (BitWidth == 0) {

Okay.  So consecutive bit-fields are considered individually, not packed into a 
single storage unit and then considered?  Unfortunate ABI rule, but if it's 
what you have to implement, so be it.


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

https://reviews.llvm.org/D60456



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


[PATCH] D60456: [RISCV] Hard float ABI support

2019-07-08 Thread Alex Bradbury via Phabricator via cfe-commits
asb added inline comments.



Comment at: clang/lib/CodeGen/TargetInfo.cpp:9236
+if (IsInt && Field1Ty && Field1Ty->isIntegerTy())
+  return false;
+if (!Field1Ty) {

rjmccall wrote:
> asb wrote:
> > rjmccall wrote:
> > > The comment here is wrong because fp+fp is allowed, right?
> > > 
> > > Is this not already caught by the post-processing checks you do in 
> > > `detectFPCCEligibleStruct`?  Would it make more sense to just do all 
> > > those checks there?
> > Thanks, I meant to say int+int isn't eligible. Reworded to say that.
> > 
> > I don't think it would simplify things to do all checks in 
> > detectFPCCEligibleStruct. More repetition would be required in order to do 
> > checks on both Float1Ty and Float2Ty.
> Okay.  It just seemed to me that responsibility was oddly split between the 
> functions.
I added a comment to document this. It's not something I'd expose in a public 
API, but I think it's defensible to catch this case outside of the helper. I 
had another look at refactoring but the readability just seemed to be reduced 
when pulling out all the checks to the caller (rather than catching the single 
case that detectFPCCEligibleStructHelper can't handle).



Comment at: clang/lib/CodeGen/TargetInfo.cpp:9340
+if (getContext().getTypeSize(QTy) > XLen && BitWidth <= XLen)
+  QTy = getContext().getIntTypeForBitwidth(XLen, false);
+if (BitWidth == 0) {

rjmccall wrote:
> Okay.  So consecutive bit-fields are considered individually, not packed into 
> a single storage unit and then considered?  Unfortunate ABI rule, but if it's 
> what you have to implement, so be it.
I'm afraid that's the rule as written, and what gcc seems to implement.


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

https://reviews.llvm.org/D60456



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


[PATCH] D60456: [RISCV] Hard float ABI support

2019-07-08 Thread Alex Bradbury via Phabricator via cfe-commits
asb updated this revision to Diff 208477.
asb marked 4 inline comments as done.
asb added a comment.

Tweaked a code comment.

Just to confirm, @rjmccall are you happy for me to commit this?


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

https://reviews.llvm.org/D60456

Files:
  clang/lib/Basic/Targets/RISCV.cpp
  clang/lib/Basic/Targets/RISCV.h
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGen/riscv32-ilp32-ilp32f-abi.c
  clang/test/CodeGen/riscv32-ilp32-ilp32f-ilp32d-abi.c
  clang/test/CodeGen/riscv32-ilp32d-abi.c
  clang/test/CodeGen/riscv32-ilp32f-abi.c
  clang/test/CodeGen/riscv32-ilp32f-ilp32d-abi.c
  clang/test/CodeGen/riscv64-lp64-lp64f-abi.c
  clang/test/CodeGen/riscv64-lp64-lp64f-lp64d-abi.c
  clang/test/CodeGen/riscv64-lp64d-abi.c
  clang/test/CodeGen/riscv64-lp64f-lp64d-abi.c
  clang/test/Preprocessor/riscv-target-features.c

Index: clang/test/Preprocessor/riscv-target-features.c
===
--- clang/test/Preprocessor/riscv-target-features.c
+++ clang/test/Preprocessor/riscv-target-features.c
@@ -47,3 +47,27 @@
 // RUN: %clang -target riscv64-unknown-linux-gnu -march=rv64ic -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-C-EXT %s
 // CHECK-C-EXT: __riscv_compressed 1
+
+// RUN: %clang -target riscv32-unknown-linux-gnu -march=rv32ifd -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-SOFT %s
+// RUN: %clang -target riscv64-unknown-linux-gnu -march=rv64ifd -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-SOFT %s
+// CHECK-SOFT: __riscv_float_abi_soft 1
+// CHECK-SOFT-NOT: __riscv_float_abi_single
+// CHECK-SOFT-NOT: __riscv_float_abi_double
+
+// RUN: %clang -target riscv32-unknown-linux-gnu -march=rv32ifd -mabi=ilp32f -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-SINGLE %s
+// RUN: %clang -target riscv64-unknown-linux-gnu -march=rv64ifd -mabi=lp64f -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-SINGLE %s
+// CHECK-SINGLE: __riscv_float_abi_single 1
+// CHECK-SINGLE-NOT: __riscv_float_abi_soft
+// CHECK-SINGLE-NOT: __riscv_float_abi_double
+
+// RUN: %clang -target riscv32-unknown-linux-gnu -march=rv32ifd -mabi=ilp32f -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-DOUBLE %s
+// RUN: %clang -target riscv64-unknown-linux-gnu -march=rv64ifd -mabi=lp64f -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-DOUBLE %s
+// CHECK-DOUBLE: __riscv_float_abi_double 1
+// CHECK-DOUBLE-NOT: __riscv_float_abi_soft
+// CHECK-DOUBLE-NOT: __riscv_float_abi_single
Index: clang/test/CodeGen/riscv64-lp64f-lp64d-abi.c
===
--- /dev/null
+++ clang/test/CodeGen/riscv64-lp64f-lp64d-abi.c
@@ -0,0 +1,265 @@
+// RUN: %clang_cc1 -triple riscv64 -target-feature +f -target-abi lp64f -emit-llvm %s -o - \
+// RUN: | FileCheck %s
+// RUN: %clang_cc1 -triple riscv64 -target-feature +d -target-abi lp64d -emit-llvm %s -o - \
+// RUN: | FileCheck %s
+
+#include 
+
+// Verify that the tracking of used GPRs and FPRs works correctly by checking
+// that small integers are sign/zero extended when passed in registers.
+
+// Floats are passed in FPRs, so argument 'i' will be passed zero-extended
+// because it will be passed in a GPR.
+
+// CHECK: define void @f_fpr_tracking(float %a, float %b, float %c, float %d, float %e, float %f, float %g, float %h, i8 zeroext %i)
+void f_fpr_tracking(float a, float b, float c, float d, float e, float f,
+float g, float h, uint8_t i) {}
+
+// Check that fp, fp+fp, and int+fp structs are lowered correctly. These will
+// be passed in FPR, FPR+FPR, or GPR+FPR regs if sufficient registers are
+// available the widths are <= XLEN and FLEN, and should be expanded to
+// separate arguments in IR. They are passed by the same rules for returns,
+// but will be lowered to simple two-element structs if necessary (as LLVM IR
+// functions cannot return multiple values).
+
+// A struct containing just one floating-point real is passed as though it
+// were a standalone floating-point real.
+
+struct float_s { float f; };
+
+// CHECK: define void @f_float_s_arg(float)
+void f_float_s_arg(struct float_s a) {}
+
+// CHECK: define float @f_ret_float_s()
+struct float_s f_ret_float_s() {
+  return (struct float_s){1.0};
+}
+
+// A struct containing a float and any number of zero-width bitfields is
+// passed as though it were a standalone floating-point real.
+
+struct zbf_float_s { int : 0; float f; };
+struct zbf_float_zbf_s { int : 0; float f; int : 0; };
+
+// CHECK: define void @f_zbf_float_s_arg(float)
+void f_zbf_float_s_arg(struct zbf_float_s a) {}
+
+// CHECK: define float @f_ret_zbf_float_s()
+struct zbf_float_s f_ret_zbf_float_s() {
+  return (struct zbf_float_s){1.0};
+}
+
+// CHECK: define void @f_zbf_float_zbf_s_arg(float)
+void f_zbf_float_zbf_s_arg(struct zbf_float_zbf_s a) {}
+
+// CHECK: define float @f_ret_zbf_float_zbf_s()

Re: r365030 - Make a buildbot using a buggy gcc happy

2019-07-08 Thread Kristóf Umann via cfe-commits
Hi!

Unfortunately, I'm out of town for the week -- I'll see whether I can ask
someone in the office to help out with this.

On Mon, 8 Jul 2019, 21:29 JF Bastien,  wrote:

> Kristof,
>
> It looks like your fix didn’t address all the bots:
>
> /Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/tools/clang/lib/Analysis/Dominators.cpp:14:48:
> error: explicit specialization of 'anchor' after instantiation void
> CFGDominatorTreeImpl::anchor() {} ^
> /Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/tools/clang/include/clang/Analysis/Analyses/Dominators.h:225:3:
> note: implicit instantiation first required here
> ControlDependencyCalculator(CFG *cfg) ^
>
> Can you please address the issue?
>
> http://green.lab.llvm.org/green/job/clang-stage2-coverage-R/4153/consoleFull
>
> Thanks,
>
> JF
>
>
> On Jul 3, 2019, at 5:06 AM, Kristof Umann via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
> Author: szelethus
> Date: Wed Jul  3 05:06:10 2019
> New Revision: 365030
>
> URL: http://llvm.org/viewvc/llvm-project?rev=365030&view=rev
> Log:
> Make a buildbot using a buggy gcc happy
>
> When specializing a template in a namespace, it has to be in a namespace
> block, else gcc will get confused. Hopefully this fixes the issue.
>
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56480
>
> Modified:
>cfe/trunk/lib/Analysis/Dominators.cpp
>
> Modified: cfe/trunk/lib/Analysis/Dominators.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/Dominators.cpp?rev=365030&r1=365029&r2=365030&view=diff
>
> ==
> --- cfe/trunk/lib/Analysis/Dominators.cpp (original)
> +++ cfe/trunk/lib/Analysis/Dominators.cpp Wed Jul  3 05:06:10 2019
> @@ -8,10 +8,12 @@
>
> #include "clang/Analysis/Analyses/Dominators.h"
>
> -using namespace clang;
> +namespace clang {
>
> template <>
> -void clang::CFGDominatorTreeImpl::anchor() {}
> +void CFGDominatorTreeImpl::anchor() {}
>
> template <>
> -void clang::CFGDominatorTreeImpl::anchor() {}
> +void CFGDominatorTreeImpl::anchor() {}
> +
> +} // end of namespace clang
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r365030 - Make a buildbot using a buggy gcc happy

2019-07-08 Thread Richard Smith via cfe-commits
This is in any case the wrong fix. The code *is* wrong, for the reason this
compiler is reporting.

The correct fix is to declare the explicit specializations in the header
file:

template <> void CFGDominatorTreeImpl::anchor();
template <> void CFGDominatorTreeImpl::anchor();

Clang will tell you to do this under -Wundefined-func-template (which we
haven't turned on by default because people get this wrong too often...).

On Mon, 8 Jul 2019 at 12:29, JF Bastien via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Kristof,
>
> It looks like your fix didn’t address all the bots:
>
> /Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/tools/clang/lib/Analysis/Dominators.cpp:14:48:
> error: explicit specialization of 'anchor' after instantiation void
> CFGDominatorTreeImpl::anchor() {} ^
> /Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/tools/clang/include/clang/Analysis/Analyses/Dominators.h:225:3:
> note: implicit instantiation first required here
> ControlDependencyCalculator(CFG *cfg) ^
>
> Can you please address the issue?
>
> http://green.lab.llvm.org/green/job/clang-stage2-coverage-R/4153/consoleFull
>
> Thanks,
>
> JF
>
>
> On Jul 3, 2019, at 5:06 AM, Kristof Umann via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
> Author: szelethus
> Date: Wed Jul  3 05:06:10 2019
> New Revision: 365030
>
> URL: http://llvm.org/viewvc/llvm-project?rev=365030&view=rev
> Log:
> Make a buildbot using a buggy gcc happy
>
> When specializing a template in a namespace, it has to be in a namespace
> block, else gcc will get confused. Hopefully this fixes the issue.
>
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56480
>
> Modified:
>cfe/trunk/lib/Analysis/Dominators.cpp
>
> Modified: cfe/trunk/lib/Analysis/Dominators.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/Dominators.cpp?rev=365030&r1=365029&r2=365030&view=diff
>
> ==
> --- cfe/trunk/lib/Analysis/Dominators.cpp (original)
> +++ cfe/trunk/lib/Analysis/Dominators.cpp Wed Jul  3 05:06:10 2019
> @@ -8,10 +8,12 @@
>
> #include "clang/Analysis/Analyses/Dominators.h"
>
> -using namespace clang;
> +namespace clang {
>
> template <>
> -void clang::CFGDominatorTreeImpl::anchor() {}
> +void CFGDominatorTreeImpl::anchor() {}
>
> template <>
> -void clang::CFGDominatorTreeImpl::anchor() {}
> +void CFGDominatorTreeImpl::anchor() {}
> +
> +} // end of namespace clang
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D64058: [cxx2a] P0624R2 fix: only lambdas with no lambda-capture are default-constructible and assignable.

2019-07-08 Thread David Blaikie via Phabricator via cfe-commits
dblaikie accepted this revision.
dblaikie added a comment.
This revision is now accepted and ready to land.

Looks good to me. (possible the check (for no default capture and no captures) 
could be unified with the same check/language used for the implicit function 
pointer conversion operator ("if (Captures.empty() && CaptureDefault == 
LCD_None)" - around 1744 in SemaLambda.cpp) - maybe a common utility function 
to test this condition or the like. But it's hardly a big thing to have it 
written in two places, really)


Repository:
  rC Clang

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

https://reviews.llvm.org/D64058



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


Re: r365030 - Make a buildbot using a buggy gcc happy

2019-07-08 Thread Kristóf Umann via cfe-commits
Noted, thanks! Gabor, could you please fix this?

On Mon, 8 Jul 2019, 21:37 Richard Smith,  wrote:

> This is in any case the wrong fix. The code *is* wrong, for the reason
> this compiler is reporting.
>
> The correct fix is to declare the explicit specializations in the header
> file:
>
> template <> void CFGDominatorTreeImpl::anchor();
> template <> void CFGDominatorTreeImpl::anchor();
>
> Clang will tell you to do this under -Wundefined-func-template (which we
> haven't turned on by default because people get this wrong too often...).
>
> On Mon, 8 Jul 2019 at 12:29, JF Bastien via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Kristof,
>>
>> It looks like your fix didn’t address all the bots:
>>
>> /Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/tools/clang/lib/Analysis/Dominators.cpp:14:48:
>> error: explicit specialization of 'anchor' after instantiation void
>> CFGDominatorTreeImpl::anchor() {} ^
>> /Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/tools/clang/include/clang/Analysis/Analyses/Dominators.h:225:3:
>> note: implicit instantiation first required here
>> ControlDependencyCalculator(CFG *cfg) ^
>>
>> Can you please address the issue?
>>
>> http://green.lab.llvm.org/green/job/clang-stage2-coverage-R/4153/consoleFull
>>
>> Thanks,
>>
>> JF
>>
>>
>> On Jul 3, 2019, at 5:06 AM, Kristof Umann via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>> Author: szelethus
>> Date: Wed Jul  3 05:06:10 2019
>> New Revision: 365030
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=365030&view=rev
>> Log:
>> Make a buildbot using a buggy gcc happy
>>
>> When specializing a template in a namespace, it has to be in a namespace
>> block, else gcc will get confused. Hopefully this fixes the issue.
>>
>> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56480
>>
>> Modified:
>>cfe/trunk/lib/Analysis/Dominators.cpp
>>
>> Modified: cfe/trunk/lib/Analysis/Dominators.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/Dominators.cpp?rev=365030&r1=365029&r2=365030&view=diff
>>
>> ==
>> --- cfe/trunk/lib/Analysis/Dominators.cpp (original)
>> +++ cfe/trunk/lib/Analysis/Dominators.cpp Wed Jul  3 05:06:10 2019
>> @@ -8,10 +8,12 @@
>>
>> #include "clang/Analysis/Analyses/Dominators.h"
>>
>> -using namespace clang;
>> +namespace clang {
>>
>> template <>
>> -void clang::CFGDominatorTreeImpl::anchor() {}
>> +void CFGDominatorTreeImpl::anchor() {}
>>
>> template <>
>> -void clang::CFGDominatorTreeImpl::anchor() {}
>> +void CFGDominatorTreeImpl::anchor() {}
>> +
>> +} // end of namespace clang
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r365030 - Make a buildbot using a buggy gcc happy

2019-07-08 Thread Richard Smith via cfe-commits
I'll commit the change below once my testing finishes :)

On Mon, 8 Jul 2019 at 12:40, Kristóf Umann via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Noted, thanks! Gabor, could you please fix this?
>
> On Mon, 8 Jul 2019, 21:37 Richard Smith,  wrote:
>
>> This is in any case the wrong fix. The code *is* wrong, for the reason
>> this compiler is reporting.
>>
>> The correct fix is to declare the explicit specializations in the header
>> file:
>>
>> template <> void CFGDominatorTreeImpl::anchor();
>> template <> void CFGDominatorTreeImpl::anchor();
>>
>> Clang will tell you to do this under -Wundefined-func-template (which we
>> haven't turned on by default because people get this wrong too often...).
>>
>> On Mon, 8 Jul 2019 at 12:29, JF Bastien via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Kristof,
>>>
>>> It looks like your fix didn’t address all the bots:
>>>
>>> /Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/tools/clang/lib/Analysis/Dominators.cpp:14:48:
>>> error: explicit specialization of 'anchor' after instantiation void
>>> CFGDominatorTreeImpl::anchor() {} ^
>>> /Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/tools/clang/include/clang/Analysis/Analyses/Dominators.h:225:3:
>>> note: implicit instantiation first required here
>>> ControlDependencyCalculator(CFG *cfg) ^
>>>
>>> Can you please address the issue?
>>>
>>> http://green.lab.llvm.org/green/job/clang-stage2-coverage-R/4153/consoleFull
>>>
>>> Thanks,
>>>
>>> JF
>>>
>>>
>>> On Jul 3, 2019, at 5:06 AM, Kristof Umann via cfe-commits <
>>> cfe-commits@lists.llvm.org> wrote:
>>>
>>> Author: szelethus
>>> Date: Wed Jul  3 05:06:10 2019
>>> New Revision: 365030
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=365030&view=rev
>>> Log:
>>> Make a buildbot using a buggy gcc happy
>>>
>>> When specializing a template in a namespace, it has to be in a namespace
>>> block, else gcc will get confused. Hopefully this fixes the issue.
>>>
>>> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56480
>>>
>>> Modified:
>>>cfe/trunk/lib/Analysis/Dominators.cpp
>>>
>>> Modified: cfe/trunk/lib/Analysis/Dominators.cpp
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/Dominators.cpp?rev=365030&r1=365029&r2=365030&view=diff
>>>
>>> ==
>>> --- cfe/trunk/lib/Analysis/Dominators.cpp (original)
>>> +++ cfe/trunk/lib/Analysis/Dominators.cpp Wed Jul  3 05:06:10 2019
>>> @@ -8,10 +8,12 @@
>>>
>>> #include "clang/Analysis/Analyses/Dominators.h"
>>>
>>> -using namespace clang;
>>> +namespace clang {
>>>
>>> template <>
>>> -void clang::CFGDominatorTreeImpl::anchor() {}
>>> +void CFGDominatorTreeImpl::anchor() {}
>>>
>>> template <>
>>> -void clang::CFGDominatorTreeImpl::anchor() {}
>>> +void CFGDominatorTreeImpl::anchor() {}
>>> +
>>> +} // end of namespace clang
>>>
>>>
>>> ___
>>> cfe-commits mailing list
>>> cfe-commits@lists.llvm.org
>>> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>>
>>>
>>> ___
>>> cfe-commits mailing list
>>> cfe-commits@lists.llvm.org
>>> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>>
>> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   3   >