[PATCH] D93377: [Clang] Add __ibm128 type to represent ppc_fp128

2021-03-14 Thread Qiu Chaofan via Phabricator via cfe-commits
qiucf added inline comments.



Comment at: clang/bindings/python/clang/cindex.py:2061-2062
 TypeKind.FLOAT128 = TypeKind(30)
 TypeKind.HALF = TypeKind(31)
+TypeKind.IBM128 = TypeKind(32)
 TypeKind.COMPLEX = TypeKind(100)

hubert.reinterpretcast wrote:
> This looks suspiciously like the result of this file having not been 
> maintained for the additions of:
> ```
>   CXType_Float16 = 32,
>   CXType_ShortAccum = 33,
>   CXType_Accum = 34,
>   CXType_LongAccum = 35,
>   CXType_UShortAccum = 36,
>   CXType_UAccum = 37,
>   CXType_ULongAccum = 38,
>   CXType_BFloat16 = 39,
> ```
> 
> What test coverage fails if the addition of `TypeKind.IBM128` is omitted from 
> this patch?
Change this to `40` for consistency.

Actually I did not get any failure of `check-clang` even when removing all 
these floating point types assignment. Test coverage may miss here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93377

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


[PATCH] D93377: [Clang] Add __ibm128 type to represent ppc_fp128

2021-03-14 Thread Qiu Chaofan via Phabricator via cfe-commits
qiucf updated this revision to Diff 330560.
qiucf marked an inline comment as done.
qiucf added a comment.

Update cindex


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93377

Files:
  clang/bindings/python/clang/cindex.py
  clang/include/clang-c/Index.h
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/BuiltinTypes.def
  clang/include/clang/AST/Type.h
  clang/include/clang/AST/TypeLoc.h
  clang/include/clang/Basic/Specifiers.h
  clang/include/clang/Basic/TargetInfo.h
  clang/include/clang/Basic/TokenKinds.def
  clang/include/clang/Sema/DeclSpec.h
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/AST/NSAPI.cpp
  clang/lib/AST/PrintfFormatString.cpp
  clang/lib/AST/StmtPrinter.cpp
  clang/lib/AST/Type.cpp
  clang/lib/AST/TypeLoc.cpp
  clang/lib/Basic/TargetInfo.cpp
  clang/lib/Basic/Targets/PPC.h
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/CodeGen/CodeGenTypes.cpp
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/Format/FormatToken.cpp
  clang/lib/Index/USRGeneration.cpp
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseExpr.cpp
  clang/lib/Parse/ParseExprCXX.cpp
  clang/lib/Parse/ParseTentative.cpp
  clang/lib/Sema/DeclSpec.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplateVariadic.cpp
  clang/lib/Sema/SemaType.cpp
  clang/lib/Serialization/ASTCommon.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/test/CodeGen/ibm128-cast.c
  clang/test/CodeGen/ibm128-unsupported.c
  clang/test/CodeGenCXX/ibm128-declarations.cpp
  clang/test/Sema/128bitfloat.cpp
  clang/tools/libclang/CXType.cpp

Index: clang/tools/libclang/CXType.cpp
===
--- clang/tools/libclang/CXType.cpp
+++ clang/tools/libclang/CXType.cpp
@@ -60,6 +60,7 @@
 BTCASE(ULongAccum);
 BTCASE(Float16);
 BTCASE(Float128);
+BTCASE(Ibm128);
 BTCASE(NullPtr);
 BTCASE(Overload);
 BTCASE(Dependent);
@@ -577,6 +578,7 @@
 TKIND(ULongAccum);
 TKIND(Float16);
 TKIND(Float128);
+TKIND(Ibm128);
 TKIND(NullPtr);
 TKIND(Overload);
 TKIND(Dependent);
Index: clang/test/Sema/128bitfloat.cpp
===
--- clang/test/Sema/128bitfloat.cpp
+++ clang/test/Sema/128bitfloat.cpp
@@ -13,7 +13,7 @@
   return x + *y;
 }
 
-// expected-no-diagnostics
+// expected-no-error {{__float128 is not supported on this target}}
 #else
 #if !defined(__STRICT_ANSI__)
 __float128 f;  // expected-error {{__float128 is not supported on this target}}
@@ -37,3 +37,18 @@
 
 #endif
 #endif
+
+#ifdef __ppc__
+__ibm128 i;
+template<> struct __is_floating_point_helper<__ibm128> {};
+int w(int x, __ibm128 *y) {
+  return x + *y;
+}
+// expected-no-error {{__ibm128 is not supported on this target}}
+#else
+__ibm128 i; // expected-error {{__ibm128 is not supported on this target}}
+template<> struct __is_floating_point_helper<__ibm128> {}; // expected-error {{__ibm128 is not supported on this target}}
+int w(int x, __ibm128 *y) { // expected-error {{__ibm128 is not supported on this target}}
+  return x + *y;
+}
+#endif
Index: clang/test/CodeGenCXX/ibm128-declarations.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/ibm128-declarations.cpp
@@ -0,0 +1,168 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -emit-llvm -triple powerpc64-unknown-unknown \
+// RUN:   -std=c++20 %s -o - -debug-info-kind=limited | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -triple powerpc64le-unknown-unknown \
+// RUN:   -std=c++20 %s -o - -debug-info-kind=limited | FileCheck %s
+
+#include 
+
+static __ibm128 sgf;
+__ibm128 arrgf[10];
+__ibm128 func1(__ibm128 arg);
+
+class CTest {
+  __ibm128 pf;
+  static const __ibm128 scf;
+  volatile __ibm128 vf;
+public:
+  CTest(__ibm128 arg) : pf(arg), vf(arg) {}
+  __ibm128 func2(__ibm128 arg) {
+return pf + arg;
+  }
+  static __ibm128 func3(__ibm128 arg) {
+return arg * CTest::scf;
+  }
+};
+
+constexpr __ibm128 func_add(__ibm128 a, __ibm128 b) {
+  return a + b;
+}
+
+constinit const __ibm128 ci = func_add(1.0, 2.0);
+__ibm128 gf = ci;
+
+__ibm128 func_arith(__ibm128 a, __ibm128 b, __ibm128 c) {
+  __ibm128 v1 = a + b;
+  __ibm128 v2 = a - c;
+  __ibm128 v3 = v1 * c;
+  __ibm128 v4 = v2 / v3;
+  return v4;
+}
+
+__ibm128 func_vaarg(int n, ...) {
+  va_list ap;
+  va_start(ap, n);
+  __ibm128 r = va_arg(ap, __ibm128);
+  va_end(ap);
+  return r;
+}
+
+template  struct T1 {
+  T mem1;
+};
+template <> struct T1<__ibm128> {
+  __ibm128 mem2;
+};
+
+template <__ibm128 Q> struct T2 {
+  constexpr static 

[PATCH] D98616: [RISCV] Add inline asm constraint 'v' in Clang for RISC-V 'V'.

2021-03-14 Thread Jessica Clarke via Phabricator via cfe-commits
jrtc27 added a comment.

This seems like the obvious choice for the constraint, but it would be good to 
ensure there's consensus with GCC people, especially since their assembly 
constraints are intimately tied to their instruction patterns (or, really, the 
assembly constraints just expose those and we pretend to be GCC) so they have 
less flexibility than us.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98616

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


[PATCH] D98616: [RISCV] Add inline asm constraint 'v' in Clang for RISC-V 'V'.

2021-03-14 Thread Hsiangkai Wang via Phabricator via cfe-commits
HsiangKai created this revision.
HsiangKai added reviewers: craig.topper, frasercrmck, rogfer01.
Herald added subscribers: StephenFan, vkmr, evandro, luismarques, apazos, 
sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, PkmX, the_o, 
brucehoult, MartinMosbeck, edward-jones, zzheng, jrtc27, shiva0217, kito-cheng, 
niosHD, sabuasal, simoncook, johnrusso, rbar, asb.
HsiangKai requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98616

Files:
  clang/lib/Basic/Targets/RISCV.cpp
  clang/test/CodeGen/RISCV/riscv-inline-asm-rvv.c


Index: clang/test/CodeGen/RISCV/riscv-inline-asm-rvv.c
===
--- /dev/null
+++ clang/test/CodeGen/RISCV/riscv-inline-asm-rvv.c
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -triple riscv32 -target-feature +experimental-v \
+// RUN: -O2 -emit-llvm %s -o - \
+// RUN: | FileCheck %s
+// RUN: %clang_cc1 -triple riscv64 -target-feature +experimental-v \
+// RUN: -O2 -emit-llvm %s -o - \
+// RUN: | FileCheck %s
+
+// Test RISC-V V-extension specific inline assembly constraints.
+#include 
+
+void test_v_reg() {
+  asm volatile(
+  "vsetvli x1, x0, e32,m2,tu,mu\n"
+  "vadd.vv v1, v2, v3, v0.t"
+  :
+  :
+  : "v1", "x1");
+// CHECK-LABEL: define{{.*}} @test_v_reg
+// CHECK: "~{v1},~{x1}"
+}
+
+vint32m1_t test_v(vint32m1_t a, vint32m1_t b) {
+// CHECK-LABEL: define{{.*}} @test_v
+// CHECK: %0 = tail call  asm sideeffect "vadd.vv $0, $1, 
$2", "=v,v,v"( %a,  %b)
+  vint32m1_t ret;
+  asm volatile ("vadd.vv %0, %1, %2" : "=v"(ret) : "v"(a), "v"(b));
+  return ret;
+}
Index: clang/lib/Basic/Targets/RISCV.cpp
===
--- clang/lib/Basic/Targets/RISCV.cpp
+++ clang/lib/Basic/Targets/RISCV.cpp
@@ -31,7 +31,13 @@
   "f0",  "f1",  "f2",  "f3",  "f4",  "f5",  "f6",  "f7",
   "f8",  "f9",  "f10", "f11", "f12", "f13", "f14", "f15",
   "f16", "f17", "f18", "f19", "f20", "f21", "f22", "f23",
-  "f24", "f25", "f26", "f27", "f28", "f29", "f30", "f31"};
+  "f24", "f25", "f26", "f27", "f28", "f29", "f30", "f31",
+
+  // Vector registers
+  "v0",  "v1",  "v2",  "v3",  "v4",  "v5",  "v6",  "v7",
+  "v8",  "v9",  "v10", "v11", "v12", "v13", "v14", "v15",
+  "v16", "v17", "v18", "v19", "v20", "v21", "v22", "v23",
+  "v24", "v25", "v26", "v27", "v28", "v29", "v30", "v31"};
   return llvm::makeArrayRef(GCCRegNames);
 }
 
@@ -81,6 +87,10 @@
 // An address that is held in a general-purpose register.
 Info.setAllowsMemory();
 return true;
+  case 'v':
+// A vector register.
+Info.setAllowsRegister();
+return true;
   }
 }
 


Index: clang/test/CodeGen/RISCV/riscv-inline-asm-rvv.c
===
--- /dev/null
+++ clang/test/CodeGen/RISCV/riscv-inline-asm-rvv.c
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -triple riscv32 -target-feature +experimental-v \
+// RUN: -O2 -emit-llvm %s -o - \
+// RUN: | FileCheck %s
+// RUN: %clang_cc1 -triple riscv64 -target-feature +experimental-v \
+// RUN: -O2 -emit-llvm %s -o - \
+// RUN: | FileCheck %s
+
+// Test RISC-V V-extension specific inline assembly constraints.
+#include 
+
+void test_v_reg() {
+  asm volatile(
+  "vsetvli x1, x0, e32,m2,tu,mu\n"
+  "vadd.vv v1, v2, v3, v0.t"
+  :
+  :
+  : "v1", "x1");
+// CHECK-LABEL: define{{.*}} @test_v_reg
+// CHECK: "~{v1},~{x1}"
+}
+
+vint32m1_t test_v(vint32m1_t a, vint32m1_t b) {
+// CHECK-LABEL: define{{.*}} @test_v
+// CHECK: %0 = tail call  asm sideeffect "vadd.vv $0, $1, $2", "=v,v,v"( %a,  %b)
+  vint32m1_t ret;
+  asm volatile ("vadd.vv %0, %1, %2" : "=v"(ret) : "v"(a), "v"(b));
+  return ret;
+}
Index: clang/lib/Basic/Targets/RISCV.cpp
===
--- clang/lib/Basic/Targets/RISCV.cpp
+++ clang/lib/Basic/Targets/RISCV.cpp
@@ -31,7 +31,13 @@
   "f0",  "f1",  "f2",  "f3",  "f4",  "f5",  "f6",  "f7",
   "f8",  "f9",  "f10", "f11", "f12", "f13", "f14", "f15",
   "f16", "f17", "f18", "f19", "f20", "f21", "f22", "f23",
-  "f24", "f25", "f26", "f27", "f28", "f29", "f30", "f31"};
+  "f24", "f25", "f26", "f27", "f28", "f29", "f30", "f31",
+
+  // Vector registers
+  "v0",  "v1",  "v2",  "v3",  "v4",  "v5",  "v6",  "v7",
+  "v8",  "v9",  "v10", "v11", "v12", "v13", "v14", "v15",
+  "v16", "v17", "v18", "v19", "v20", "v21", "v22", "v23",
+  "v24", "v25", "v26", "v27", "v28", "v29", "v30", "v31"};
   return llvm::makeArrayRef(GCCRegNames);
 }
 
@@ -81,6 +87,10 @@
 // An address that is held in a general-purpose register.
 Info.setAllowsMemory();
 return true;
+  case 'v':
+// A vector register.
+Info.setAllowsRegister();
+return true;
   }
 }
 
___
cfe-commits 

[PATCH] D98610: [RISCV] Support clang -fpatchable-function-entry && GNU function attribute 'patchable_function_entry'

2021-03-14 Thread Luís Marques via Phabricator via cfe-commits
luismarques added inline comments.



Comment at: llvm/test/CodeGen/RISCV/patchable-function-entry.ll:1-3
+;; Test the function attribute "patchable-function-entry".
+; RUN: llc -mtriple=riscv32 < %s | FileCheck %s --check-prefixes=CHECK,32
+; RUN: llc -mtriple=riscv64 < %s | FileCheck %s --check-prefixes=CHECK,64

jrtc27 wrote:
> Please match the style of the other tests: 
> - update_llc_test_checks.py
> - RV32I/RV32IC/RV64I/RV64IC
> Please match the style of the other tests: 
> - update_llc_test_checks.py

I was going to comment on that but I was unsure it applied here, given that 
this test was running more than just `llc`. The other RISC-V CodeGen tests we 
have with objdump don't use the update script IIRC. (And these manual tests 
were neatly written and much more condensed that the sprawling output of the 
auto updated checks). But I agree that in general using the script is the way 
to go for the RISC-V tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98610

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


[PATCH] D98610: [RISCV] Support clang -fpatchable-function-entry && GNU function attribute 'patchable_function_entry'

2021-03-14 Thread Jessica Clarke via Phabricator via cfe-commits
jrtc27 added inline comments.



Comment at: llvm/lib/Target/RISCV/RISCVInstrInfo.cpp:53
 
+void RISCVInstrInfo::getNoop(MCInst ) const {
+  if (STI.getFeatureBits()[RISCV::FeatureStdExtC])

I will forever wonder why TII didn't make it `MCInst getNoop()`...



Comment at: llvm/lib/Target/RISCV/RISCVMCInstLower.cpp:247
   }
+  return false;
 }

true, surely?



Comment at: llvm/test/CodeGen/RISCV/patchable-function-entry.ll:1-3
+;; Test the function attribute "patchable-function-entry".
+; RUN: llc -mtriple=riscv32 < %s | FileCheck %s --check-prefixes=CHECK,32
+; RUN: llc -mtriple=riscv64 < %s | FileCheck %s --check-prefixes=CHECK,64

Please match the style of the other tests: 
- update_llc_test_checks.py
- RV32I/RV32IC/RV64I/RV64IC



Comment at: llvm/test/CodeGen/RISCV/patchable-function-entry.ll:5-9
+;; RVC uses 2-byte nop.
+; RUN: llc -filetype=obj -mtriple=riscv64 %s -o %t.o
+; RUN: llvm-objdump -d %t.o | FileCheck %s --check-prefix=NORVC
+; RUN: llc -filetype=obj -mtriple=riscv64 -mattr=+c %s -o %tc.o
+; RUN: llvm-objdump -d %tc.o | FileCheck %s --check-prefix=RVC

I don't think this is particularly useful if we've checked the assembly output 
(and it stops us using update_llc_test_checks.py), we know nops get emitted 
correctly, that's tested in various other places.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98610

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


[PATCH] D98610: [RISCV] Support clang -fpatchable-function-entry && GNU function attribute 'patchable_function_entry'

2021-03-14 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 330548.
MaskRay added a comment.

fix comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98610

Files:
  clang/include/clang/Basic/Attr.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/fpatchable-function-entry.c
  clang/test/Sema/patchable-function-entry-attr.cpp
  llvm/lib/Target/RISCV/RISCV.h
  llvm/lib/Target/RISCV/RISCVAsmPrinter.cpp
  llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
  llvm/lib/Target/RISCV/RISCVInstrInfo.h
  llvm/lib/Target/RISCV/RISCVMCInstLower.cpp
  llvm/test/CodeGen/RISCV/patchable-function-entry.ll

Index: llvm/test/CodeGen/RISCV/patchable-function-entry.ll
===
--- /dev/null
+++ llvm/test/CodeGen/RISCV/patchable-function-entry.ll
@@ -0,0 +1,71 @@
+;; Test the function attribute "patchable-function-entry".
+; RUN: llc -mtriple=riscv32 < %s | FileCheck %s --check-prefixes=CHECK,32
+; RUN: llc -mtriple=riscv64 < %s | FileCheck %s --check-prefixes=CHECK,64
+
+;; RVC uses 2-byte nop.
+; RUN: llc -filetype=obj -mtriple=riscv64 %s -o %t.o
+; RUN: llvm-objdump -d %t.o | FileCheck %s --check-prefix=NORVC
+; RUN: llc -filetype=obj -mtriple=riscv64 -mattr=+c %s -o %tc.o
+; RUN: llvm-objdump -d %tc.o | FileCheck %s --check-prefix=RVC
+
+; NORVC: 13 00 00 00  nop
+; RVC:   01 00nop
+
+define void @f0() "patchable-function-entry"="0" {
+; CHECK-LABEL: f0:
+; CHECK-NEXT:  .Lfunc_begin0:
+; CHECK-NOT: nop
+; CHECK: ret
+; CHECK-NOT:   .section __patchable_function_entries
+  ret void
+}
+
+define void @f1() "patchable-function-entry"="1" {
+; CHECK-LABEL: f1:
+; CHECK-NEXT: .Lfunc_begin1:
+; CHECK: nop
+; CHECK-NEXT:ret
+; CHECK:   .section __patchable_function_entries,"awo",@progbits,f1{{$}}
+; 32:  .p2align 2
+; 32-NEXT: .word .Lfunc_begin1
+; 64:  .p2align 3
+; 64-NEXT: .quad .Lfunc_begin1
+  ret void
+}
+
+$f5 = comdat any
+define void @f5() "patchable-function-entry"="5" comdat {
+; CHECK-LABEL: f5:
+; CHECK-NEXT:  .Lfunc_begin2:
+; CHECK-COUNT-5: nop
+; CHECK-NEXT:ret
+; CHECK:   .section __patchable_function_entries,"aGwo",@progbits,f5,comdat,f5{{$}}
+; 32:  .p2align 2
+; 32-NEXT: .word .Lfunc_begin2
+; 64:  .p2align 3
+; 64-NEXT: .quad .Lfunc_begin2
+  ret void
+}
+
+;; -fpatchable-function-entry=3,2
+;; "patchable-function-prefix" emits data before the function entry label.
+define void @f3_2() "patchable-function-entry"="1" "patchable-function-prefix"="2" {
+; CHECK-LABEL: .type f3_2,@function
+; CHECK-NEXT:  .Ltmp0: # @f3_2
+; CHECK-NEXT:nop
+; CHECK-NEXT:nop
+; CHECK-NEXT:  f3_2:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:nop
+; CHECK-NEXT:addi sp, sp, -16
+;; .size does not include the prefix.
+; CHECK:  .Lfunc_end3:
+; CHECK-NEXT: .size f3_2, .Lfunc_end3-f3_2
+; CHECK:  .section __patchable_function_entries,"awo",@progbits,f3_2{{$}}
+; 32: .p2align 2
+; 32-NEXT:.word .Ltmp0
+; 64: .p2align 3
+; 64-NEXT:.quad .Ltmp0
+  %frame = alloca i8, i32 16
+  ret void
+}
Index: llvm/lib/Target/RISCV/RISCVMCInstLower.cpp
===
--- llvm/lib/Target/RISCV/RISCVMCInstLower.cpp
+++ llvm/lib/Target/RISCV/RISCVMCInstLower.cpp
@@ -204,10 +204,10 @@
   return true;
 }
 
-void llvm::LowerRISCVMachineInstrToMCInst(const MachineInstr *MI, MCInst ,
-  const AsmPrinter ) {
+bool llvm::lowerRISCVMachineInstrToMCInst(const MachineInstr *MI, MCInst ,
+  AsmPrinter ) {
   if (lowerRISCVVMachineInstrToMCInst(MI, OutMI))
-return;
+return false;
 
   OutMI.setOpcode(MI->getOpcode());
 
@@ -217,19 +217,32 @@
   OutMI.addOperand(MCOp);
   }
 
-  if (OutMI.getOpcode() == RISCV::PseudoReadVLENB) {
+  switch (OutMI.getOpcode()) {
+  case TargetOpcode::PATCHABLE_FUNCTION_ENTER: {
+const Function  = MI->getParent()->getParent()->getFunction();
+if (F.hasFnAttribute("patchable-function-entry")) {
+  unsigned Num;
+  if (F.getFnAttribute("patchable-function-entry")
+  .getValueAsString()
+  .getAsInteger(10, Num))
+return false;
+  AP.emitNops(Num);
+  return true;
+}
+break;
+  }
+  case RISCV::PseudoReadVLENB:
 OutMI.setOpcode(RISCV::CSRRS);
 OutMI.addOperand(MCOperand::createImm(
 RISCVSysReg::lookupSysRegByName("VLENB")->Encoding));
 OutMI.addOperand(MCOperand::createReg(RISCV::X0));
-return;
-  }
-
-  if (OutMI.getOpcode() == RISCV::PseudoReadVL) {
+break;
+  case RISCV::PseudoReadVL:
 OutMI.setOpcode(RISCV::CSRRS);
-OutMI.addOperand(MCOperand::createImm(
-RISCVSysReg::lookupSysRegByName("VL")->Encoding));
+OutMI.addOperand(
+MCOperand::createImm(RISCVSysReg::lookupSysRegByName("VL")->Encoding));
 

[clang] 6e303a9 - Revert "[AST] Add generator for source location introspection"

2021-03-14 Thread Stephen Kelly via cfe-commits

Author: Stephen Kelly
Date: 2021-03-15T01:16:10Z
New Revision: 6e303a982d6ce5a281ba95238ed376a2caf27a52

URL: 
https://github.com/llvm/llvm-project/commit/6e303a982d6ce5a281ba95238ed376a2caf27a52
DIFF: 
https://github.com/llvm/llvm-project/commit/6e303a982d6ce5a281ba95238ed376a2caf27a52.diff

LOG: Revert "[AST] Add generator for source location introspection"

This reverts commit 91abaa1f8d97e8efa249c31686fd643ff5f1e2c2.

Added: 


Modified: 
clang/lib/Tooling/CMakeLists.txt
clang/unittests/CMakeLists.txt
llvm/utils/gn/secondary/clang/lib/Tooling/BUILD.gn
llvm/utils/gn/secondary/clang/unittests/BUILD.gn

Removed: 
clang/include/clang/Tooling/NodeIntrospection.h
clang/lib/Tooling/DumpTool/APIData.h
clang/lib/Tooling/DumpTool/ASTSrcLocProcessor.cpp
clang/lib/Tooling/DumpTool/ASTSrcLocProcessor.h
clang/lib/Tooling/DumpTool/CMakeLists.txt
clang/lib/Tooling/DumpTool/ClangSrcLocDump.cpp
clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py
clang/lib/Tooling/NodeIntrospection.cpp
clang/unittests/Introspection/CMakeLists.txt
clang/unittests/Introspection/IntrospectionTest.cpp
llvm/utils/gn/secondary/clang/lib/Tooling/DumpTool/BUILD.gn
llvm/utils/gn/secondary/clang/unittests/Introspection/BUILD.gn



diff  --git a/clang/include/clang/Tooling/NodeIntrospection.h 
b/clang/include/clang/Tooling/NodeIntrospection.h
deleted file mode 100644
index abaa58b674a1..
--- a/clang/include/clang/Tooling/NodeIntrospection.h
+++ /dev/null
@@ -1,85 +0,0 @@
-//===- NodeIntrospection.h *- 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
-//
-//===--===//
-//
-//  This file contains the implementation of the NodeIntrospection.
-//
-//===--===//
-
-#ifndef LLVM_CLANG_TOOLING_NODEINTROSPECTION_H
-#define LLVM_CLANG_TOOLING_NODEINTROSPECTION_H
-
-#include "clang/AST/ASTTypeTraits.h"
-#include "clang/AST/DeclarationName.h"
-
-#include 
-#include 
-
-namespace clang {
-
-class Stmt;
-
-namespace tooling {
-
-class LocationCall {
-public:
-  enum LocationCallFlags { NoFlags, ReturnsPointer, IsCast };
-  LocationCall(std::shared_ptr on, std::string name,
-   LocationCallFlags flags = NoFlags)
-  : m_on(on), m_name(name), m_flags(flags) {}
-  LocationCall(std::shared_ptr on, std::string name,
-   std::vector const ,
-   LocationCallFlags flags = NoFlags)
-  : m_on(on), m_name(name), m_flags(flags) {}
-
-  LocationCall *on() const { return m_on.get(); }
-  StringRef name() const { return m_name; }
-  std::vector const () const { return m_args; }
-  bool returnsPointer() const { return m_flags & ReturnsPointer; }
-  bool isCast() const { return m_flags & IsCast; }
-
-private:
-  std::shared_ptr m_on;
-  std::string m_name;
-  std::vector m_args;
-  LocationCallFlags m_flags;
-};
-
-class LocationCallFormatterCpp {
-public:
-  static std::string format(LocationCall *Call);
-};
-
-namespace internal {
-struct RangeLessThan {
-  bool operator()(
-  std::pair> const ,
-  std::pair> const ) const;
-};
-} // namespace internal
-
-template >>
-using UniqueMultiMap = std::set, Comp>;
-
-using SourceLocationMap =
-UniqueMultiMap>;
-using SourceRangeMap =
-UniqueMultiMap,
-   internal::RangeLessThan>;
-
-struct NodeLocationAccessors {
-  SourceLocationMap LocationAccessors;
-  SourceRangeMap RangeAccessors;
-};
-
-namespace NodeIntrospection {
-NodeLocationAccessors GetLocations(clang::Stmt const *Object);
-NodeLocationAccessors GetLocations(clang::DynTypedNode const );
-} // namespace NodeIntrospection
-} // namespace tooling
-} // namespace clang
-#endif

diff  --git a/clang/lib/Tooling/CMakeLists.txt 
b/clang/lib/Tooling/CMakeLists.txt
index e8a2e35b6215..7a58af59dad1 100644
--- a/clang/lib/Tooling/CMakeLists.txt
+++ b/clang/lib/Tooling/CMakeLists.txt
@@ -8,112 +8,10 @@ add_subdirectory(Core)
 add_subdirectory(Inclusions)
 add_subdirectory(Refactoring)
 add_subdirectory(ASTDiff)
-add_subdirectory(DumpTool)
 add_subdirectory(Syntax)
 add_subdirectory(DependencyScanning)
 add_subdirectory(Transformer)
 
-find_package(Python3 COMPONENTS Interpreter)
-
-# Replace the last lib component of the current binary directory with include
-string(FIND ${CMAKE_CURRENT_BINARY_DIR} "/lib/" PATH_LIB_START REVERSE)
-if(PATH_LIB_START EQUAL -1)
-  message(FATAL_ERROR "Couldn't find lib component in binary directory")
-endif()
-math(EXPR PATH_LIB_END "${PATH_LIB_START}+5")
-string(SUBSTRING ${CMAKE_CURRENT_BINARY_DIR} 0 ${PATH_LIB_START} PATH_HEAD)
-string(SUBSTRING ${CMAKE_CURRENT_BINARY_DIR} 

[clang] 370b9b4 - Revert "Attempt to fix ARM buildbot"

2021-03-14 Thread Stephen Kelly via cfe-commits

Author: Stephen Kelly
Date: 2021-03-15T01:16:07Z
New Revision: 370b9b4aea5fe1c9ca25e4c00f104eba75ac5c7b

URL: 
https://github.com/llvm/llvm-project/commit/370b9b4aea5fe1c9ca25e4c00f104eba75ac5c7b
DIFF: 
https://github.com/llvm/llvm-project/commit/370b9b4aea5fe1c9ca25e4c00f104eba75ac5c7b.diff

LOG: Revert "Attempt to fix ARM buildbot"

This reverts commit 12dac66f6b33dd14b72076800726817f682ab785.

Added: 


Modified: 
clang/lib/Tooling/CMakeLists.txt

Removed: 




diff  --git a/clang/lib/Tooling/CMakeLists.txt 
b/clang/lib/Tooling/CMakeLists.txt
index e820f63d5b3d..e8a2e35b6215 100644
--- a/clang/lib/Tooling/CMakeLists.txt
+++ b/clang/lib/Tooling/CMakeLists.txt
@@ -30,7 +30,6 @@ if (NOT Python3_EXECUTABLE
 OR APPLE
 OR GENERATOR_IS_MULTI_CONFIG
 OR NOT LLVM_NATIVE_ARCH IN_LIST LLVM_TARGETS_TO_BUILD
-OR NOT X86 IN_LIST LLVM_TARGETS_TO_BUILD
 )
   file(GENERATE OUTPUT ${BINARY_INCLUDE_DIR}/NodeIntrospection.inc
 CONTENT "



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


[PATCH] D98594: [clang/docs/LibASTMatchersTutorial.rst,clang/docs/HowToSetupToolingForLLVM.rst] ninja now uses `configure.py` rather than `bootstrap.py`

2021-03-14 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert accepted this revision.
jdoerfert added a comment.
This revision is now accepted and ready to land.

LG, use `[Docs]` as tag for the commit, it should not be verbose but helpful to 
determine if a commit is interesting.


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

https://reviews.llvm.org/D98594

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


[PATCH] D97916: [Driver][RISCV] Support parsing multi-lib config from GCC.

2021-03-14 Thread Luís Marques via Phabricator via cfe-commits
luismarques added a comment.

This patch seems to be in pretty good shape now.

One thing that might be useful (important?) to add is additional diagnostics 
when run in verbose mode. Currently `clang -v` will indicate that it found the 
GCC installation and will list the multilibs but there will be no indication 
that the multilib list came from GCC. Also, if things like the `ExecuteAndWait` 
(in `getRISCVMultilibFromGCC`) fail shouldn't we print some kind of diagnostic, 
at least in verbose mode? Otherwise when problems occur it might be tricky to 
figure out what's going on.




Comment at: clang/lib/Driver/ToolChains/Arch/RISCV.cpp:726
+StringRef riscv::getRISCVCodeModel(const llvm::opt::ArgList ) {
+  // Default code model is small(medlow).
+  StringRef CodeModel;

Nitpicking suggestion: `\\ Default code model is 'small' (what GCC calls 
'medlow').`



Comment at: clang/lib/Driver/ToolChains/Gnu.cpp:1657
+  for (StringRef Line : Lines) {
+if (Line.empty())
+  continue;

Maybe trim whitespace before checking for empty lines, for extra robustness?



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97916

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


[clang] 12dac66 - Attempt to fix ARM buildbot

2021-03-14 Thread Stephen Kelly via cfe-commits

Author: Stephen Kelly
Date: 2021-03-15T00:20:39Z
New Revision: 12dac66f6b33dd14b72076800726817f682ab785

URL: 
https://github.com/llvm/llvm-project/commit/12dac66f6b33dd14b72076800726817f682ab785
DIFF: 
https://github.com/llvm/llvm-project/commit/12dac66f6b33dd14b72076800726817f682ab785.diff

LOG: Attempt to fix ARM buildbot

Added: 


Modified: 
clang/lib/Tooling/CMakeLists.txt

Removed: 




diff  --git a/clang/lib/Tooling/CMakeLists.txt 
b/clang/lib/Tooling/CMakeLists.txt
index e8a2e35b6215..e820f63d5b3d 100644
--- a/clang/lib/Tooling/CMakeLists.txt
+++ b/clang/lib/Tooling/CMakeLists.txt
@@ -30,6 +30,7 @@ if (NOT Python3_EXECUTABLE
 OR APPLE
 OR GENERATOR_IS_MULTI_CONFIG
 OR NOT LLVM_NATIVE_ARCH IN_LIST LLVM_TARGETS_TO_BUILD
+OR NOT X86 IN_LIST LLVM_TARGETS_TO_BUILD
 )
   file(GENERATE OUTPUT ${BINARY_INCLUDE_DIR}/NodeIntrospection.inc
 CONTENT "



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


[clang] 91abaa1 - [AST] Add generator for source location introspection

2021-03-14 Thread Stephen Kelly via cfe-commits

Author: Stephen Kelly
Date: 2021-03-15T00:00:29Z
New Revision: 91abaa1f8d97e8efa249c31686fd643ff5f1e2c2

URL: 
https://github.com/llvm/llvm-project/commit/91abaa1f8d97e8efa249c31686fd643ff5f1e2c2
DIFF: 
https://github.com/llvm/llvm-project/commit/91abaa1f8d97e8efa249c31686fd643ff5f1e2c2.diff

LOG: [AST] Add generator for source location introspection

Generate a json file containing descriptions of AST classes and their
public accessors which return SourceLocation or SourceRange.

Use the JSON file to generate a C++ API and implementation for accessing
the source locations and method names for accessing them for a given AST
node.

This new API can be used to implement 'srcloc' output in clang-query:

  http://ce.steveire.com/z/m_kTIo

The JSON file can also be used to generate bindings for other languages,
such as Python and Javascript:

  https://steveire.wordpress.com/2019/04/30/the-future-of-ast-matching

In this first version of this feature, only the accessors for Stmt
classes are generated, not Decls, TypeLocs etc.  Those can be added
after this change is reviewed, as this change is mostly about
infrastructure of these code generators.

Also in this version, the platforms/cmake configurations are excluded as
much as possible so that support can be added iteratively.  Currently a
break on any platform causes a revert of the entire feature.  This way,
the `OR WIN32` can be removed in a future commit and if it breaks the
buildbots, only that commit gets reverted, making the entire process
easier to manage.

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

Added: 
clang/include/clang/Tooling/NodeIntrospection.h
clang/lib/Tooling/DumpTool/APIData.h
clang/lib/Tooling/DumpTool/ASTSrcLocProcessor.cpp
clang/lib/Tooling/DumpTool/ASTSrcLocProcessor.h
clang/lib/Tooling/DumpTool/CMakeLists.txt
clang/lib/Tooling/DumpTool/ClangSrcLocDump.cpp
clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py
clang/lib/Tooling/NodeIntrospection.cpp
clang/unittests/Introspection/CMakeLists.txt
clang/unittests/Introspection/IntrospectionTest.cpp
llvm/utils/gn/secondary/clang/lib/Tooling/DumpTool/BUILD.gn
llvm/utils/gn/secondary/clang/unittests/Introspection/BUILD.gn

Modified: 
clang/lib/Tooling/CMakeLists.txt
clang/unittests/CMakeLists.txt
llvm/utils/gn/secondary/clang/lib/Tooling/BUILD.gn
llvm/utils/gn/secondary/clang/unittests/BUILD.gn

Removed: 




diff  --git a/clang/include/clang/Tooling/NodeIntrospection.h 
b/clang/include/clang/Tooling/NodeIntrospection.h
new file mode 100644
index ..abaa58b674a1
--- /dev/null
+++ b/clang/include/clang/Tooling/NodeIntrospection.h
@@ -0,0 +1,85 @@
+//===- NodeIntrospection.h *- 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
+//
+//===--===//
+//
+//  This file contains the implementation of the NodeIntrospection.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLING_NODEINTROSPECTION_H
+#define LLVM_CLANG_TOOLING_NODEINTROSPECTION_H
+
+#include "clang/AST/ASTTypeTraits.h"
+#include "clang/AST/DeclarationName.h"
+
+#include 
+#include 
+
+namespace clang {
+
+class Stmt;
+
+namespace tooling {
+
+class LocationCall {
+public:
+  enum LocationCallFlags { NoFlags, ReturnsPointer, IsCast };
+  LocationCall(std::shared_ptr on, std::string name,
+   LocationCallFlags flags = NoFlags)
+  : m_on(on), m_name(name), m_flags(flags) {}
+  LocationCall(std::shared_ptr on, std::string name,
+   std::vector const ,
+   LocationCallFlags flags = NoFlags)
+  : m_on(on), m_name(name), m_flags(flags) {}
+
+  LocationCall *on() const { return m_on.get(); }
+  StringRef name() const { return m_name; }
+  std::vector const () const { return m_args; }
+  bool returnsPointer() const { return m_flags & ReturnsPointer; }
+  bool isCast() const { return m_flags & IsCast; }
+
+private:
+  std::shared_ptr m_on;
+  std::string m_name;
+  std::vector m_args;
+  LocationCallFlags m_flags;
+};
+
+class LocationCallFormatterCpp {
+public:
+  static std::string format(LocationCall *Call);
+};
+
+namespace internal {
+struct RangeLessThan {
+  bool operator()(
+  std::pair> const ,
+  std::pair> const ) const;
+};
+} // namespace internal
+
+template >>
+using UniqueMultiMap = std::set, Comp>;
+
+using SourceLocationMap =
+UniqueMultiMap>;
+using SourceRangeMap =
+UniqueMultiMap,
+   internal::RangeLessThan>;
+
+struct NodeLocationAccessors {
+  SourceLocationMap LocationAccessors;
+  SourceRangeMap RangeAccessors;
+};
+
+namespace NodeIntrospection 

[clang] e312b4b - Revert "[AST] Add generator for source location introspection"

2021-03-14 Thread Stephen Kelly via cfe-commits

Author: Stephen Kelly
Date: 2021-03-14T22:51:45Z
New Revision: e312b4b6c74d455ba8193f46d7f0f8f1c8ac4757

URL: 
https://github.com/llvm/llvm-project/commit/e312b4b6c74d455ba8193f46d7f0f8f1c8ac4757
DIFF: 
https://github.com/llvm/llvm-project/commit/e312b4b6c74d455ba8193f46d7f0f8f1c8ac4757.diff

LOG: Revert "[AST] Add generator for source location introspection"

This reverts commit 477e4b974653f92960c0bf569d88da7baacef68a.

Added: 


Modified: 
clang/lib/Tooling/CMakeLists.txt
clang/unittests/CMakeLists.txt
llvm/utils/gn/secondary/clang/lib/Tooling/BUILD.gn
llvm/utils/gn/secondary/clang/unittests/BUILD.gn

Removed: 
clang/include/clang/Tooling/NodeIntrospection.h
clang/lib/Tooling/DumpTool/APIData.h
clang/lib/Tooling/DumpTool/ASTSrcLocProcessor.cpp
clang/lib/Tooling/DumpTool/ASTSrcLocProcessor.h
clang/lib/Tooling/DumpTool/CMakeLists.txt
clang/lib/Tooling/DumpTool/ClangSrcLocDump.cpp
clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py
clang/lib/Tooling/NodeIntrospection.cpp
clang/unittests/Introspection/CMakeLists.txt
clang/unittests/Introspection/IntrospectionTest.cpp
llvm/utils/gn/secondary/clang/lib/Tooling/DumpTool/BUILD.gn
llvm/utils/gn/secondary/clang/unittests/Introspection/BUILD.gn



diff  --git a/clang/include/clang/Tooling/NodeIntrospection.h 
b/clang/include/clang/Tooling/NodeIntrospection.h
deleted file mode 100644
index abaa58b674a1..
--- a/clang/include/clang/Tooling/NodeIntrospection.h
+++ /dev/null
@@ -1,85 +0,0 @@
-//===- NodeIntrospection.h *- 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
-//
-//===--===//
-//
-//  This file contains the implementation of the NodeIntrospection.
-//
-//===--===//
-
-#ifndef LLVM_CLANG_TOOLING_NODEINTROSPECTION_H
-#define LLVM_CLANG_TOOLING_NODEINTROSPECTION_H
-
-#include "clang/AST/ASTTypeTraits.h"
-#include "clang/AST/DeclarationName.h"
-
-#include 
-#include 
-
-namespace clang {
-
-class Stmt;
-
-namespace tooling {
-
-class LocationCall {
-public:
-  enum LocationCallFlags { NoFlags, ReturnsPointer, IsCast };
-  LocationCall(std::shared_ptr on, std::string name,
-   LocationCallFlags flags = NoFlags)
-  : m_on(on), m_name(name), m_flags(flags) {}
-  LocationCall(std::shared_ptr on, std::string name,
-   std::vector const ,
-   LocationCallFlags flags = NoFlags)
-  : m_on(on), m_name(name), m_flags(flags) {}
-
-  LocationCall *on() const { return m_on.get(); }
-  StringRef name() const { return m_name; }
-  std::vector const () const { return m_args; }
-  bool returnsPointer() const { return m_flags & ReturnsPointer; }
-  bool isCast() const { return m_flags & IsCast; }
-
-private:
-  std::shared_ptr m_on;
-  std::string m_name;
-  std::vector m_args;
-  LocationCallFlags m_flags;
-};
-
-class LocationCallFormatterCpp {
-public:
-  static std::string format(LocationCall *Call);
-};
-
-namespace internal {
-struct RangeLessThan {
-  bool operator()(
-  std::pair> const ,
-  std::pair> const ) const;
-};
-} // namespace internal
-
-template >>
-using UniqueMultiMap = std::set, Comp>;
-
-using SourceLocationMap =
-UniqueMultiMap>;
-using SourceRangeMap =
-UniqueMultiMap,
-   internal::RangeLessThan>;
-
-struct NodeLocationAccessors {
-  SourceLocationMap LocationAccessors;
-  SourceRangeMap RangeAccessors;
-};
-
-namespace NodeIntrospection {
-NodeLocationAccessors GetLocations(clang::Stmt const *Object);
-NodeLocationAccessors GetLocations(clang::DynTypedNode const );
-} // namespace NodeIntrospection
-} // namespace tooling
-} // namespace clang
-#endif

diff  --git a/clang/lib/Tooling/CMakeLists.txt 
b/clang/lib/Tooling/CMakeLists.txt
index c7fe324a39df..7a58af59dad1 100644
--- a/clang/lib/Tooling/CMakeLists.txt
+++ b/clang/lib/Tooling/CMakeLists.txt
@@ -8,107 +8,10 @@ add_subdirectory(Core)
 add_subdirectory(Inclusions)
 add_subdirectory(Refactoring)
 add_subdirectory(ASTDiff)
-add_subdirectory(DumpTool)
 add_subdirectory(Syntax)
 add_subdirectory(DependencyScanning)
 add_subdirectory(Transformer)
 
-find_package(Python3 COMPONENTS Interpreter)
-
-# Replace the last lib component of the current binary directory with include
-string(FIND ${CMAKE_CURRENT_BINARY_DIR} "/lib/" PATH_LIB_START REVERSE)
-if(PATH_LIB_START EQUAL -1)
-  message(FATAL_ERROR "Couldn't find lib component in binary directory")
-endif()
-math(EXPR PATH_LIB_END "${PATH_LIB_START}+5")
-string(SUBSTRING ${CMAKE_CURRENT_BINARY_DIR} 0 ${PATH_LIB_START} PATH_HEAD)
-string(SUBSTRING ${CMAKE_CURRENT_BINARY_DIR} 

[clang] 9249861 - Revert "Ensure that cache variable is set when not building introspection"

2021-03-14 Thread Stephen Kelly via cfe-commits

Author: Stephen Kelly
Date: 2021-03-14T22:51:40Z
New Revision: 9249861437c0355c79c27c86229b9b92cd8eea5f

URL: 
https://github.com/llvm/llvm-project/commit/9249861437c0355c79c27c86229b9b92cd8eea5f
DIFF: 
https://github.com/llvm/llvm-project/commit/9249861437c0355c79c27c86229b9b92cd8eea5f.diff

LOG: Revert "Ensure that cache variable is set when not building introspection"

This reverts commit 6b010c6f6e354966569e02841180c77df45bbd76.

Added: 


Modified: 
clang/lib/Tooling/CMakeLists.txt

Removed: 




diff  --git a/clang/lib/Tooling/CMakeLists.txt 
b/clang/lib/Tooling/CMakeLists.txt
index efee9227a2c1..c7fe324a39df 100644
--- a/clang/lib/Tooling/CMakeLists.txt
+++ b/clang/lib/Tooling/CMakeLists.txt
@@ -47,7 +47,6 @@ NodeIntrospection::GetLocations(clang::DynTypedNode const &) {
 } // namespace clang
 "
 )
-set(CLANG_TOOLING_BUILD_AST_INTROSPECTION "OFF" CACHE BOOL "")
 else()
   # The generation of ASTNodeAPI.json takes a long time in a
   # Debug build due to parsing AST.h. Disable the processing



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


[clang] 6b010c6 - Ensure that cache variable is set when not building introspection

2021-03-14 Thread Stephen Kelly via cfe-commits

Author: Stephen Kelly
Date: 2021-03-14T22:46:07Z
New Revision: 6b010c6f6e354966569e02841180c77df45bbd76

URL: 
https://github.com/llvm/llvm-project/commit/6b010c6f6e354966569e02841180c77df45bbd76
DIFF: 
https://github.com/llvm/llvm-project/commit/6b010c6f6e354966569e02841180c77df45bbd76.diff

LOG: Ensure that cache variable is set when not building introspection

Added: 


Modified: 
clang/lib/Tooling/CMakeLists.txt

Removed: 




diff  --git a/clang/lib/Tooling/CMakeLists.txt 
b/clang/lib/Tooling/CMakeLists.txt
index c7fe324a39df..efee9227a2c1 100644
--- a/clang/lib/Tooling/CMakeLists.txt
+++ b/clang/lib/Tooling/CMakeLists.txt
@@ -47,6 +47,7 @@ NodeIntrospection::GetLocations(clang::DynTypedNode const &) {
 } // namespace clang
 "
 )
+set(CLANG_TOOLING_BUILD_AST_INTROSPECTION "OFF" CACHE BOOL "")
 else()
   # The generation of ASTNodeAPI.json takes a long time in a
   # Debug build due to parsing AST.h. Disable the processing



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


[PATCH] D93164: [AST] Add generator for source location introspection

2021-03-14 Thread Stephen Kelly via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG477e4b974653: [AST] Add generator for source location 
introspection (authored by stephenkelly).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D93164?vs=329780=330537#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93164

Files:
  clang/include/clang/Tooling/NodeIntrospection.h
  clang/lib/Tooling/CMakeLists.txt
  clang/lib/Tooling/DumpTool/APIData.h
  clang/lib/Tooling/DumpTool/ASTSrcLocProcessor.cpp
  clang/lib/Tooling/DumpTool/ASTSrcLocProcessor.h
  clang/lib/Tooling/DumpTool/CMakeLists.txt
  clang/lib/Tooling/DumpTool/ClangSrcLocDump.cpp
  clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py
  clang/lib/Tooling/NodeIntrospection.cpp
  clang/unittests/CMakeLists.txt
  clang/unittests/Introspection/CMakeLists.txt
  clang/unittests/Introspection/IntrospectionTest.cpp
  llvm/utils/gn/secondary/clang/lib/Tooling/BUILD.gn
  llvm/utils/gn/secondary/clang/lib/Tooling/DumpTool/BUILD.gn
  llvm/utils/gn/secondary/clang/unittests/BUILD.gn
  llvm/utils/gn/secondary/clang/unittests/Introspection/BUILD.gn

Index: llvm/utils/gn/secondary/clang/unittests/Introspection/BUILD.gn
===
--- /dev/null
+++ llvm/utils/gn/secondary/clang/unittests/Introspection/BUILD.gn
@@ -0,0 +1,20 @@
+import("//llvm/utils/unittest/unittest.gni")
+
+unittest("IntrospectionTests") {
+  configs += [ "//llvm/utils/gn/build:clang_code" ]
+  deps = [
+"//clang/lib/AST",
+"//clang/lib/ASTMatchers",
+"//clang/lib/Basic",
+"//clang/lib/Frontend",
+"//clang/lib/Serialization",
+"//clang/lib/Tooling",
+"//llvm/lib/Support",
+"//llvm/lib/Testing/Support",
+  ]
+
+
+  defines = [ "SKIP_INTROSPECTION_GENERATION" ]
+
+  sources = [ "IntrospectionTest.cpp" ]
+}
Index: llvm/utils/gn/secondary/clang/unittests/BUILD.gn
===
--- llvm/utils/gn/secondary/clang/unittests/BUILD.gn
+++ llvm/utils/gn/secondary/clang/unittests/BUILD.gn
@@ -12,6 +12,7 @@
 "Format:FormatTests",
 "Frontend:FrontendTests",
 "Index:IndexTests",
+"Introspection:IntrospectionTests",
 "Lex:LexTests",
 "Rename:ClangRenameTests",
 "Rewrite:RewriteTests",
Index: llvm/utils/gn/secondary/clang/lib/Tooling/DumpTool/BUILD.gn
===
--- /dev/null
+++ llvm/utils/gn/secondary/clang/lib/Tooling/DumpTool/BUILD.gn
@@ -0,0 +1,20 @@
+executable("clang-ast-dump") {
+  configs += [ "//llvm/utils/gn/build:clang_code" ]
+  deps = [
+"//clang/lib/AST",
+"//clang/lib/ASTMatchers",
+"//clang/lib/Basic",
+"//clang/lib/Driver",
+"//clang/lib/Format",
+"//clang/lib/Frontend",
+"//clang/lib/Lex",
+"//clang/lib/Rewrite",
+"//clang/lib/Serialization",
+"//clang/lib/Tooling/Core",
+  ]
+
+  sources = [
+"ASTSrcLocProcessor.cpp",
+"ClangSrcLocDump.cpp",
+  ]
+}
Index: llvm/utils/gn/secondary/clang/lib/Tooling/BUILD.gn
===
--- llvm/utils/gn/secondary/clang/lib/Tooling/BUILD.gn
+++ llvm/utils/gn/secondary/clang/lib/Tooling/BUILD.gn
@@ -1,7 +1,19 @@
+# FIXME: The cmake build runs DumpTool:clang-ast-dump to generate a json
+# file and feeds it into this step in non-debug builds or if an option is set.
+action("node_introspection_inc") {
+  script = "DumpTool/generate_cxx_src_locs.py"
+  outputs = [ "$target_gen_dir/clang/Tooling/NodeIntrospection.inc" ]
+  args = [
+"--empty-implementation=1",
+"--output-file=" + rebase_path(outputs[0], root_build_dir),
+  ]
+}
+
 static_library("Tooling") {
   output_name = "clangTooling"
   configs += [ "//llvm/utils/gn/build:clang_code" ]
   deps = [
+":node_introspection_inc",
 "//clang/include/clang/Driver:Options",
 "//clang/lib/AST",
 "//clang/lib/ASTMatchers",
@@ -13,6 +25,7 @@
 "//clang/lib/Rewrite",
 "//clang/lib/Tooling/Core",
   ]
+  include_dirs = [ target_gen_dir ]
   sources = [
 "AllTUsExecution.cpp",
 "ArgumentsAdjusters.cpp",
@@ -25,6 +38,7 @@
 "GuessTargetAndModeCompilationDatabase.cpp",
 "InterpolatingCompilationDatabase.cpp",
 "JSONCompilationDatabase.cpp",
+"NodeIntrospection.cpp",
 "Refactoring.cpp",
 "RefactoringCallbacks.cpp",
 "StandaloneExecution.cpp",
Index: clang/unittests/Introspection/IntrospectionTest.cpp
===
--- /dev/null
+++ clang/unittests/Introspection/IntrospectionTest.cpp
@@ -0,0 +1,100 @@
+//===- unittest/Introspection/IntrospectionTest.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.
+// 

[clang] 477e4b9 - [AST] Add generator for source location introspection

2021-03-14 Thread Stephen Kelly via cfe-commits

Author: Stephen Kelly
Date: 2021-03-14T22:32:42Z
New Revision: 477e4b974653f92960c0bf569d88da7baacef68a

URL: 
https://github.com/llvm/llvm-project/commit/477e4b974653f92960c0bf569d88da7baacef68a
DIFF: 
https://github.com/llvm/llvm-project/commit/477e4b974653f92960c0bf569d88da7baacef68a.diff

LOG: [AST] Add generator for source location introspection

Generate a json file containing descriptions of AST classes and their
public accessors which return SourceLocation or SourceRange.

Use the JSON file to generate a C++ API and implementation for accessing
the source locations and method names for accessing them for a given AST
node.

This new API can be used to implement 'srcloc' output in clang-query:

  http://ce.steveire.com/z/m_kTIo

The JSON file can also be used to generate bindings for other languages,
such as Python and Javascript:

  https://steveire.wordpress.com/2019/04/30/the-future-of-ast-matching

In this first version of this feature, only the accessors for Stmt
classes are generated, not Decls, TypeLocs etc.  Those can be added
after this change is reviewed, as this change is mostly about
infrastructure of these code generators.

Also in this version, the platforms/cmake configurations are excluded as
much as possible so that support can be added iteratively.  Currently a
break on any platform causes a revert of the entire feature.  This way,
the `OR WIN32` can be removed in a future commit and if it breaks the
buildbots, only that commit gets reverted, making the entire process
easier to manage.

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

Added: 
clang/include/clang/Tooling/NodeIntrospection.h
clang/lib/Tooling/DumpTool/APIData.h
clang/lib/Tooling/DumpTool/ASTSrcLocProcessor.cpp
clang/lib/Tooling/DumpTool/ASTSrcLocProcessor.h
clang/lib/Tooling/DumpTool/CMakeLists.txt
clang/lib/Tooling/DumpTool/ClangSrcLocDump.cpp
clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py
clang/lib/Tooling/NodeIntrospection.cpp
clang/unittests/Introspection/CMakeLists.txt
clang/unittests/Introspection/IntrospectionTest.cpp
llvm/utils/gn/secondary/clang/lib/Tooling/DumpTool/BUILD.gn
llvm/utils/gn/secondary/clang/unittests/Introspection/BUILD.gn

Modified: 
clang/lib/Tooling/CMakeLists.txt
clang/unittests/CMakeLists.txt
llvm/utils/gn/secondary/clang/lib/Tooling/BUILD.gn
llvm/utils/gn/secondary/clang/unittests/BUILD.gn

Removed: 




diff  --git a/clang/include/clang/Tooling/NodeIntrospection.h 
b/clang/include/clang/Tooling/NodeIntrospection.h
new file mode 100644
index ..abaa58b674a1
--- /dev/null
+++ b/clang/include/clang/Tooling/NodeIntrospection.h
@@ -0,0 +1,85 @@
+//===- NodeIntrospection.h *- 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
+//
+//===--===//
+//
+//  This file contains the implementation of the NodeIntrospection.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLING_NODEINTROSPECTION_H
+#define LLVM_CLANG_TOOLING_NODEINTROSPECTION_H
+
+#include "clang/AST/ASTTypeTraits.h"
+#include "clang/AST/DeclarationName.h"
+
+#include 
+#include 
+
+namespace clang {
+
+class Stmt;
+
+namespace tooling {
+
+class LocationCall {
+public:
+  enum LocationCallFlags { NoFlags, ReturnsPointer, IsCast };
+  LocationCall(std::shared_ptr on, std::string name,
+   LocationCallFlags flags = NoFlags)
+  : m_on(on), m_name(name), m_flags(flags) {}
+  LocationCall(std::shared_ptr on, std::string name,
+   std::vector const ,
+   LocationCallFlags flags = NoFlags)
+  : m_on(on), m_name(name), m_flags(flags) {}
+
+  LocationCall *on() const { return m_on.get(); }
+  StringRef name() const { return m_name; }
+  std::vector const () const { return m_args; }
+  bool returnsPointer() const { return m_flags & ReturnsPointer; }
+  bool isCast() const { return m_flags & IsCast; }
+
+private:
+  std::shared_ptr m_on;
+  std::string m_name;
+  std::vector m_args;
+  LocationCallFlags m_flags;
+};
+
+class LocationCallFormatterCpp {
+public:
+  static std::string format(LocationCall *Call);
+};
+
+namespace internal {
+struct RangeLessThan {
+  bool operator()(
+  std::pair> const ,
+  std::pair> const ) const;
+};
+} // namespace internal
+
+template >>
+using UniqueMultiMap = std::set, Comp>;
+
+using SourceLocationMap =
+UniqueMultiMap>;
+using SourceRangeMap =
+UniqueMultiMap,
+   internal::RangeLessThan>;
+
+struct NodeLocationAccessors {
+  SourceLocationMap LocationAccessors;
+  SourceRangeMap RangeAccessors;
+};
+
+namespace NodeIntrospection 

[PATCH] D98610: [RISCV] Support clang -fpatchable-function-entry && GNU function attribute 'patchable_function_entry'

2021-03-14 Thread Luís Marques via Phabricator via cfe-commits
luismarques accepted this revision.
luismarques added a comment.
This revision is now accepted and ready to land.

Overall LGTM.
I just don't understand what you mean with "1-byte NOPs" in the patchable 
prefix case. Regular NOPs are emitted. Please clarify the comment/patch as 
needed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98610

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


[PATCH] D98610: [RISCV] Support clang -fpatchable-function-entry && GNU function attribute 'patchable_function_entry'

2021-03-14 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay created this revision.
MaskRay added reviewers: asb, craig.topper, HsiangKai, khchen.
Herald added subscribers: vkmr, frasercrmck, evandro, luismarques, apazos, 
sameer.abuasal, pengfei, s.egerton, Jim, benna, psnobl, jocewei, PkmX, the_o, 
brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, shiva0217, 
kito-cheng, niosHD, sabuasal, simoncook, johnrusso, rbar, hiraditya, 
kristof.beyls.
Herald added a reviewer: aaron.ballman.
MaskRay requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

Similar to D72215  (AArch64) and D72220 
 (x86).

Recently the mainline kernel started to use -fpatchable-function-entry=8 for 
riscv (https://git.kernel.org/linus/afc76b8b80112189b6f11e67e19cf58301944814).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98610

Files:
  clang/include/clang/Basic/Attr.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/fpatchable-function-entry.c
  clang/test/Sema/patchable-function-entry-attr.cpp
  llvm/lib/Target/RISCV/RISCV.h
  llvm/lib/Target/RISCV/RISCVAsmPrinter.cpp
  llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
  llvm/lib/Target/RISCV/RISCVInstrInfo.h
  llvm/lib/Target/RISCV/RISCVMCInstLower.cpp
  llvm/test/CodeGen/RISCV/patchable-function-entry.ll

Index: llvm/test/CodeGen/RISCV/patchable-function-entry.ll
===
--- /dev/null
+++ llvm/test/CodeGen/RISCV/patchable-function-entry.ll
@@ -0,0 +1,72 @@
+;; Test the function attribute "patchable-function-entry".
+; RUN: llc -mtriple=riscv32 < %s | FileCheck %s --check-prefixes=CHECK,32
+; RUN: llc -mtriple=riscv64 < %s | FileCheck %s --check-prefixes=CHECK,64
+
+; RUN: llc -filetype=obj -mtriple=riscv64 %s -o %t.o
+; RUN: llvm-objdump -d %t.o | FileCheck %s --check-prefix=NORVC
+; RUN: llc -filetype=obj -mtriple=riscv64 -mattr=+c %s -o %tc.o
+; RUN: llvm-objdump -d %tc.o | FileCheck %s --check-prefix=RVC
+
+; NORVC: 13 00 00 00  nop
+; RVC:   01 00nop
+
+define void @f0() "patchable-function-entry"="0" {
+; CHECK-LABEL: f0:
+; CHECK-NEXT:  .Lfunc_begin0:
+; CHECK-NOT: nop
+; CHECK: ret
+; CHECK-NOT:   .section __patchable_function_entries
+  ret void
+}
+
+define void @f1() "patchable-function-entry"="1" {
+; CHECK-LABEL: f1:
+; CHECK-NEXT: .Lfunc_begin1:
+; CHECK: nop
+; CHECK-NEXT:ret
+; CHECK:   .section __patchable_function_entries,"awo",@progbits,f1{{$}}
+; 32:  .p2align 2
+; 32-NEXT: .word .Lfunc_begin1
+; 64:  .p2align 3
+; 64-NEXT: .quad .Lfunc_begin1
+  ret void
+}
+
+$f5 = comdat any
+define void @f5() "patchable-function-entry"="5" comdat {
+; CHECK-LABEL: f5:
+; CHECK-NEXT:  .Lfunc_begin2:
+; CHECK-COUNT-5: nop
+; CHECK-NEXT:ret
+; CHECK:   .section __patchable_function_entries,"aGwo",@progbits,f5,comdat,f5{{$}}
+; 32:  .p2align 2
+; 32-NEXT: .word .Lfunc_begin2
+; 64:  .p2align 3
+; 64-NEXT: .quad .Lfunc_begin2
+  ret void
+}
+
+;; -fpatchable-function-entry=3,2
+;; "patchable-function-prefix" emits data before the function entry label.
+;; We emit 1-byte NOPs before the function entry, so that with a partial patch,
+;; the remaining instructions do not need to be modified.
+define void @f3_2() "patchable-function-entry"="1" "patchable-function-prefix"="2" {
+; CHECK-LABEL: .type f3_2,@function
+; CHECK-NEXT:  .Ltmp0: # @f3_2
+; CHECK-NEXT:nop
+; CHECK-NEXT:nop
+; CHECK-NEXT:  f3_2:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:nop
+; CHECK-NEXT:addi sp, sp, -16
+;; .size does not include the prefix.
+; CHECK:  .Lfunc_end3:
+; CHECK-NEXT: .size f3_2, .Lfunc_end3-f3_2
+; CHECK:  .section __patchable_function_entries,"awo",@progbits,f3_2{{$}}
+; 32: .p2align 2
+; 32-NEXT:.word .Ltmp0
+; 64: .p2align 3
+; 64-NEXT:.quad .Ltmp0
+  %frame = alloca i8, i32 16
+  ret void
+}
Index: llvm/lib/Target/RISCV/RISCVMCInstLower.cpp
===
--- llvm/lib/Target/RISCV/RISCVMCInstLower.cpp
+++ llvm/lib/Target/RISCV/RISCVMCInstLower.cpp
@@ -204,10 +204,10 @@
   return true;
 }
 
-void llvm::LowerRISCVMachineInstrToMCInst(const MachineInstr *MI, MCInst ,
-  const AsmPrinter ) {
+bool llvm::lowerRISCVMachineInstrToMCInst(const MachineInstr *MI, MCInst ,
+  AsmPrinter ) {
   if (lowerRISCVVMachineInstrToMCInst(MI, OutMI))
-return;
+return false;
 
   OutMI.setOpcode(MI->getOpcode());
 
@@ -217,19 +217,32 @@
   OutMI.addOperand(MCOp);
   }
 
-  if (OutMI.getOpcode() == RISCV::PseudoReadVLENB) {
+  switch (OutMI.getOpcode()) {
+  case TargetOpcode::PATCHABLE_FUNCTION_ENTER: {
+const Function  = MI->getParent()->getParent()->getFunction();
+if (F.hasFnAttribute("patchable-function-entry")) {
+  unsigned Num;
+  if 

[PATCH] D91556: [OpenMPIRBuilder} Add capturing of parameters to pass to omp::parallel

2021-03-14 Thread Giorgis Georgakoudis via Phabricator via cfe-commits
ggeorgakoudis added a comment.

In D91556#2620928 , @jdoerfert wrote:

> In D91556#2617144 , 
> @kiranchandramohan wrote:
>
>> Ping @llitchev. Would you have time to take this forward?
>
> I think @ggeorgakoudis is working on an alternative API solution, we might 
> need to pick up the MLIR parts though.

Yes, I have a solution for OMPIRBuilder. It hinges on 
https://reviews.llvm.org/D96854 to use the CodeExtractor for building the 
aggregate.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91556

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


[PATCH] D93164: [AST] Add generator for source location introspection

2021-03-14 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

It may be wise to alter this so there is no need for the python script.
How about altering the dump tool to support outputting both json files and the 
cpp code needed for node introspection.
Maybe have arguments to the tool `--json-output-path` and 
`--introspection-output-path`.
If both are specified write both, if none specified error out.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93164

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


[PATCH] D93164: [AST] Add generator for source location introspection

2021-03-14 Thread Alexander Richardson via Phabricator via cfe-commits
arichardson added inline comments.



Comment at: clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py:1
+#!/usr/bin/python
+# -*- coding: utf-8 -*-

Maybe this should be `#!/use/bin/env python` (or python3) instead?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93164

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


[PATCH] D93164: [AST] Add generator for source location introspection

2021-03-14 Thread Nikita Popov via Phabricator via cfe-commits
nikic added a comment.

@steveire When running the command manually I get:

  
/root/llvm-compile-time-tracker/llvm-project/clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py
 --json-input-path 
/root/llvm-compile-time-tracker/llvm-project-build/ASTNodeAPI.json 
--output-file generated/NodeIntrospection.inc --empty-implementation 0
  -bash: 
/root/llvm-compile-time-tracker/llvm-project/clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py:
 /usr/bin/python: bad interpreter: No such file or directory

So probably this doesn't work on any system that only has Python 3.

As the `.py` file is invoked directly, I assume that `${PYTHON_EXECUTABLE}` is 
empty. Maybe you were looking for `${Python3_EXECUTABLE}`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93164

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


[PATCH] D93164: [AST] Add generator for source location introspection

2021-03-14 Thread Stephen Kelly via Phabricator via cfe-commits
steveire added a comment.

In D93164#2624798 , @nikic wrote:

> Reverted in 
> https://github.com/llvm/llvm-project/commit/e0f70a8a979f5b843e90a0a20442ca79e2507208
>  due to build failure.

@nikic  How do I run a test build on that machine? Or can you diagnose the 
problem instead?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93164

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


[PATCH] D94741: [Utils] Check for more global information in update_test_checks

2021-03-14 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

In D94741#2624475 , @nikic wrote:

> It looks like this has broken handling of `getelementptr %T`, and generates 
> `getelementptr [[T]]` for it now, see e.g. the first change in 
> https://github.com/llvm/llvm-project/commit/7ee96429a0b057bcc97331a6a762fc3cd00aed61.

I don't see the problem:
Source is  `...(%ABC, %ABC, ...`
Before we checked: `...(%ABC, [[ABC:%.*]], ...`
Now we check:  `...([[ABC:%.*]], [[ABC]], ...`
That seems strictly better to me. What am I missing?

> In 
> https://github.com/llvm/llvm-project/commit/6491e0165e96a93960e2dfb338c52c7eb155f408#diff-85c14e813467fc768fb641be9567780053ef1162da8cc12dd6bcb29d5e14384eR575
>  I was forced to rename the function argument to avoid a clash between the 
> type `%S2` and the value `%s2`.

Hm, this one I can see. We could work around that by looking if there is a 
global with the same name and then add a `_lcl` suffix.
I can try to look into it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94741

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


[PATCH] D93164: [AST] Add generator for source location introspection

2021-03-14 Thread Stephen Kelly via Phabricator via cfe-commits
steveire added a comment.

In D93164#2624798 , @nikic wrote:

> Reverted in 
> https://github.com/llvm/llvm-project/commit/e0f70a8a979f5b843e90a0a20442ca79e2507208
>  due to build failure.

Was the problem there just the shebang line?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93164

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


[PATCH] D93164: [AST] Add generator for source location introspection

2021-03-14 Thread Nikita Popov via Phabricator via cfe-commits
nikic reopened this revision.
nikic added a comment.
This revision is now accepted and ready to land.

Reverted in 
https://github.com/llvm/llvm-project/commit/e0f70a8a979f5b843e90a0a20442ca79e2507208
 due to build failure.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93164

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


[clang] e0f70a8 - Revert "[AST] Add generator for source location introspection"

2021-03-14 Thread Nikita Popov via cfe-commits

Author: Nikita Popov
Date: 2021-03-14T17:05:08+01:00
New Revision: e0f70a8a979f5b843e90a0a20442ca79e2507208

URL: 
https://github.com/llvm/llvm-project/commit/e0f70a8a979f5b843e90a0a20442ca79e2507208
DIFF: 
https://github.com/llvm/llvm-project/commit/e0f70a8a979f5b843e90a0a20442ca79e2507208.diff

LOG: Revert "[AST] Add generator for source location introspection"

Breaks the build ... somehow: 
https://llvm-compile-time-tracker.com/show_error.php?commit=77f7d2be214a1de29d583c75739f563593991fc3

FAILED: tools/clang/include/clang/Tooling/NodeIntrospection.inc
cd /root/llvm-compile-time-tracker/llvm-project-build/tools/clang/lib/Tooling 
&& /usr/bin/cmake -E make_directory 
/root/llvm-compile-time-tracker/llvm-project-build/tools/clang/lib/Tooling/generated/
 && 
/root/llvm-compile-time-tracker/llvm-project/clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py
 --json-input-path 
/root/llvm-compile-time-tracker/llvm-project-build/ASTNodeAPI.json 
--output-file generated/NodeIntrospection.inc --empty-implementation 0 && 
/usr/bin/cmake -E copy_if_different 
/root/llvm-compile-time-tracker/llvm-project-build/tools/clang/lib/Tooling/generated/NodeIntrospection.inc
 
/root/llvm-compile-time-tracker/llvm-project-build/tools/clang/include/clang/Tooling/NodeIntrospection.inc
/bin/sh: 1: 
/root/llvm-compile-time-tracker/llvm-project/clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py:
 not found

This reverts commit cefe711135c40b6fb9670cf92118f94f88964b23.
This reverts commit f72f122feebe7f980c22ed4a7e04fc274ce2c976.
This reverts commit 970c21e345548a967c1bc000462198330982ed7e.
This reverts commit 77f7d2be214a1de29d583c75739f563593991fc3.

Added: 


Modified: 
clang/lib/Tooling/CMakeLists.txt
clang/unittests/CMakeLists.txt

Removed: 
clang/include/clang/Tooling/NodeIntrospection.h
clang/lib/Tooling/DumpTool/APIData.h
clang/lib/Tooling/DumpTool/ASTSrcLocProcessor.cpp
clang/lib/Tooling/DumpTool/ASTSrcLocProcessor.h
clang/lib/Tooling/DumpTool/CMakeLists.txt
clang/lib/Tooling/DumpTool/ClangSrcLocDump.cpp
clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py
clang/lib/Tooling/NodeIntrospection.cpp
clang/unittests/Introspection/CMakeLists.txt
clang/unittests/Introspection/IntrospectionTest.cpp



diff  --git a/clang/include/clang/Tooling/NodeIntrospection.h 
b/clang/include/clang/Tooling/NodeIntrospection.h
deleted file mode 100644
index abaa58b674a1..
--- a/clang/include/clang/Tooling/NodeIntrospection.h
+++ /dev/null
@@ -1,85 +0,0 @@
-//===- NodeIntrospection.h *- 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
-//
-//===--===//
-//
-//  This file contains the implementation of the NodeIntrospection.
-//
-//===--===//
-
-#ifndef LLVM_CLANG_TOOLING_NODEINTROSPECTION_H
-#define LLVM_CLANG_TOOLING_NODEINTROSPECTION_H
-
-#include "clang/AST/ASTTypeTraits.h"
-#include "clang/AST/DeclarationName.h"
-
-#include 
-#include 
-
-namespace clang {
-
-class Stmt;
-
-namespace tooling {
-
-class LocationCall {
-public:
-  enum LocationCallFlags { NoFlags, ReturnsPointer, IsCast };
-  LocationCall(std::shared_ptr on, std::string name,
-   LocationCallFlags flags = NoFlags)
-  : m_on(on), m_name(name), m_flags(flags) {}
-  LocationCall(std::shared_ptr on, std::string name,
-   std::vector const ,
-   LocationCallFlags flags = NoFlags)
-  : m_on(on), m_name(name), m_flags(flags) {}
-
-  LocationCall *on() const { return m_on.get(); }
-  StringRef name() const { return m_name; }
-  std::vector const () const { return m_args; }
-  bool returnsPointer() const { return m_flags & ReturnsPointer; }
-  bool isCast() const { return m_flags & IsCast; }
-
-private:
-  std::shared_ptr m_on;
-  std::string m_name;
-  std::vector m_args;
-  LocationCallFlags m_flags;
-};
-
-class LocationCallFormatterCpp {
-public:
-  static std::string format(LocationCall *Call);
-};
-
-namespace internal {
-struct RangeLessThan {
-  bool operator()(
-  std::pair> const ,
-  std::pair> const ) const;
-};
-} // namespace internal
-
-template >>
-using UniqueMultiMap = std::set, Comp>;
-
-using SourceLocationMap =
-UniqueMultiMap>;
-using SourceRangeMap =
-UniqueMultiMap,
-   internal::RangeLessThan>;
-
-struct NodeLocationAccessors {
-  SourceLocationMap LocationAccessors;
-  SourceRangeMap RangeAccessors;
-};
-
-namespace NodeIntrospection {
-NodeLocationAccessors GetLocations(clang::Stmt const *Object);
-NodeLocationAccessors GetLocations(clang::DynTypedNode const );
-} // namespace NodeIntrospection
-} // 

[PATCH] D93164: [AST] Add generator for source location introspection

2021-03-14 Thread Stephen Kelly via Phabricator via cfe-commits
steveire added a comment.

In D93164#2624760 , @dmgreen wrote:

> Hello. Does this work when the default target triple isn't native? This seems 
> to be trying to compile clang sources with the just built clang - something 
> that I don't think is always possible. I'm seeing errors like `fatal error: 
> 'cstddef' file not found`, and failing to link the new IntrospectionTests, 
> with undefined references to NodeIntrospection::GetLocations, as a full 
> toolchain is not setup. I don't believe the buildbots are working right now, 
> so it's difficult to see if any other systems have similar problems.

Can you report if running `cmake . -DCLANG_TOOLING_BUILD_AST_INTROSPECTION=OFF` 
allows you to complete the build?

Is there some way I can check that the default target triple isn't native in 
the cmake code? Then I can set that option automatically.

> Also some of the files here have been added with a University of Illinois 
> Open Source License. They should presumably be using the newer Apache license 
> now.

Fixed, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93164

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


[clang] cefe711 - Fix license headers

2021-03-14 Thread Stephen Kelly via cfe-commits

Author: Stephen Kelly
Date: 2021-03-14T15:45:53Z
New Revision: cefe711135c40b6fb9670cf92118f94f88964b23

URL: 
https://github.com/llvm/llvm-project/commit/cefe711135c40b6fb9670cf92118f94f88964b23
DIFF: 
https://github.com/llvm/llvm-project/commit/cefe711135c40b6fb9670cf92118f94f88964b23.diff

LOG: Fix license headers

Added: 


Modified: 
clang/lib/Tooling/DumpTool/APIData.h
clang/lib/Tooling/DumpTool/ASTSrcLocProcessor.cpp
clang/lib/Tooling/DumpTool/ASTSrcLocProcessor.h
clang/lib/Tooling/DumpTool/ClangSrcLocDump.cpp

Removed: 




diff  --git a/clang/lib/Tooling/DumpTool/APIData.h 
b/clang/lib/Tooling/DumpTool/APIData.h
index bf68a3b2a89e..0ec53f6e7dc3 100644
--- a/clang/lib/Tooling/DumpTool/APIData.h
+++ b/clang/lib/Tooling/DumpTool/APIData.h
@@ -1,9 +1,8 @@
 //===- APIData.h -*- C++ 
-*===//
 //
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// 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
 //
 
//===--===//
 

diff  --git a/clang/lib/Tooling/DumpTool/ASTSrcLocProcessor.cpp 
b/clang/lib/Tooling/DumpTool/ASTSrcLocProcessor.cpp
index 3f97b7d9d798..ff279d9425d8 100644
--- a/clang/lib/Tooling/DumpTool/ASTSrcLocProcessor.cpp
+++ b/clang/lib/Tooling/DumpTool/ASTSrcLocProcessor.cpp
@@ -1,9 +1,8 @@
 //===- ASTSrcLocProcessor.cpp *- C++ 
-*===//
 //
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// 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
 //
 
//===--===//
 

diff  --git a/clang/lib/Tooling/DumpTool/ASTSrcLocProcessor.h 
b/clang/lib/Tooling/DumpTool/ASTSrcLocProcessor.h
index a4a9856485c8..00994758e03c 100644
--- a/clang/lib/Tooling/DumpTool/ASTSrcLocProcessor.h
+++ b/clang/lib/Tooling/DumpTool/ASTSrcLocProcessor.h
@@ -1,9 +1,8 @@
 //===- ASTSrcLocProcessor.h -*- C++ 
-*-===//
 //
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// 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
 //
 
//===--===//
 

diff  --git a/clang/lib/Tooling/DumpTool/ClangSrcLocDump.cpp 
b/clang/lib/Tooling/DumpTool/ClangSrcLocDump.cpp
index e987de7c800e..28337eae9e85 100644
--- a/clang/lib/Tooling/DumpTool/ClangSrcLocDump.cpp
+++ b/clang/lib/Tooling/DumpTool/ClangSrcLocDump.cpp
@@ -1,9 +1,8 @@
 //===- ClangSrcLocDump.cpp *- C++ 
-*---===//
 //
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// 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
 //
 
//===--===//
 



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


[PATCH] D93164: [AST] Add generator for source location introspection

2021-03-14 Thread Stephen Kelly via Phabricator via cfe-commits
steveire added a comment.

In D93164#2624690 , @thakis wrote:

> A few more high-level questions:
>
> - What's the point of the intermediary json file? Why not generate the final 
> c++ directly? (As far as I can tell, this wasn't discussed during the review 
> yet)

It came up in review earlier: https://reviews.llvm.org/D93164#2456181

> - Do we need to generate code for this at all? Could this be done via xmacros 
> or tablegen?

Can you say more? Would this require generating the declarations in 
`include/clang/AST`? It sounds like a large maintenance burden, but maybe I'm 
missing something.

> Having a bespoke custom python -> json -> python -> c++ pipeline here seems 
> like it's fairly different from how the rest of clang does things, and it 
> seems like it duplicates some of the existing tooling we have here.
>
> (Having said that, I'm no code owner here -- @rsmith is. Maybe he has an 
> opinion.)
>
> Lower-level: Did you see all the comments on 
> https://reviews.llvm.org/rGd627a27d264b47eda3f15f086ff419dfe053ebf7 ? This 
> relanded with them unaddressed. Please address them in a follow-up. (Sorry 
> for leaving the comments on the commit instead of the review!)

Done, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93164

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


[clang] 970c21e - Remove unneeded targets dependency

2021-03-14 Thread Stephen Kelly via cfe-commits

Author: Stephen Kelly
Date: 2021-03-14T15:37:30Z
New Revision: 970c21e345548a967c1bc000462198330982ed7e

URL: 
https://github.com/llvm/llvm-project/commit/970c21e345548a967c1bc000462198330982ed7e
DIFF: 
https://github.com/llvm/llvm-project/commit/970c21e345548a967c1bc000462198330982ed7e.diff

LOG: Remove unneeded targets dependency

Added: 


Modified: 
clang/unittests/Introspection/CMakeLists.txt

Removed: 




diff  --git a/clang/unittests/Introspection/CMakeLists.txt 
b/clang/unittests/Introspection/CMakeLists.txt
index 2010379ae51c..3dd8aec56b76 100644
--- a/clang/unittests/Introspection/CMakeLists.txt
+++ b/clang/unittests/Introspection/CMakeLists.txt
@@ -1,5 +1,4 @@
 set(LLVM_LINK_COMPONENTS
-  ${LLVM_TARGETS_TO_BUILD}
   FrontendOpenMP
   Support
   )



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


[clang] f72f122 - Update python script per review comments

2021-03-14 Thread Stephen Kelly via cfe-commits

Author: Stephen Kelly
Date: 2021-03-14T15:37:30Z
New Revision: f72f122feebe7f980c22ed4a7e04fc274ce2c976

URL: 
https://github.com/llvm/llvm-project/commit/f72f122feebe7f980c22ed4a7e04fc274ce2c976
DIFF: 
https://github.com/llvm/llvm-project/commit/f72f122feebe7f980c22ed4a7e04fc274ce2c976.diff

LOG: Update python script per review comments

Wrap to 80 cols, introduce main() function and use argparse instead of
optparse.

Added: 


Modified: 
clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py

Removed: 




diff  --git a/clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py 
b/clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py
index aafae2c15b29..0740db0c7629 100755
--- a/clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py
+++ b/clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py
@@ -5,40 +5,7 @@
 import sys
 import json
 
-from optparse import OptionParser
-
-parser = OptionParser()
-parser.add_option('--json-input-path',
-  help='Read API description from FILE', metavar='FILE')
-parser.add_option('--output-file', help='Generate output in FILEPATH',
-  metavar='FILEPATH')
-parser.add_option('--empty-implementation', help='Generate empty 
implementation',
-  action="store", type="int", metavar='FILEPATH')
-
-(options, args) = parser.parse_args()
-
-if options.empty_implementation:
-with open(os.path.join(os.getcwd(),
-  options.output_file), 'w') as f:
-f.write("""
-namespace clang {
-namespace tooling {
-
-NodeLocationAccessors NodeIntrospection::GetLocations(clang::Stmt const *) {
-  return {};
-}
-NodeLocationAccessors
-NodeIntrospection::GetLocations(clang::DynTypedNode const &) {
-  return {};
-}
-} // namespace tooling
-} // namespace clang
-""")
-sys.exit(0)
-
-with open(options.json_input_path) as f:
-jsonData = json.load(f)
-
+import argparse
 
 class Generator(object):
 
@@ -66,7 +33,8 @@ def GeneratePrologue(self):
 def GenerateBaseGetLocationsDeclaration(self, CladeName):
 self.implementationContent += \
 """
-void GetLocationsImpl(std::shared_ptr const& Prefix, clang::{0} 
const *Object, SourceLocationMap ,
+void GetLocationsImpl(std::shared_ptr const& Prefix,
+clang::{0} const *Object, SourceLocationMap ,
 SourceRangeMap );
 """.format(CladeName)
 
@@ -84,7 +52,8 @@ def GenerateSrcLocMethod(self, ClassName, ClassData):
 for locName in ClassData['sourceLocations']:
 self.implementationContent += \
 """
-  Locs.insert(LocationAndString(Object.{0}(), 
std::make_shared(Prefix, "{0}")));
+  Locs.insert(LocationAndString(Object.{0}(),
+std::make_shared(Prefix, "{0}")));
 """.format(locName)
 
 self.implementationContent += '\n'
@@ -93,7 +62,8 @@ def GenerateSrcLocMethod(self, ClassName, ClassData):
 for rngName in ClassData['sourceRanges']:
 self.implementationContent += \
 """
-  Rngs.insert(RangeAndString(Object.{0}(), 
std::make_shared(Prefix, "{0}")));
+  Rngs.insert(RangeAndString(Object.{0}(),
+std::make_shared(Prefix, "{0}")));
 """.format(rngName)
 
 self.implementationContent += '\n'
@@ -105,16 +75,6 @@ def GenerateFiles(self, OutputFile):
   OutputFile), 'w') as f:
 f.write(self.implementationContent)
 
-def GenerateTrivialBaseGetLocationsFunction(self, CladeName):
-MethodReturnType = 'NodeLocationAccessors'
-
-Signature = \
-'GetLocations(clang::{0} const *Object)'.format(CladeName)
-
-self.implementationContent += \
-'{0} NodeIntrospection::{1} {{ return {{}}; 
}}'.format(MethodReturnType,
-Signature)
-
 def GenerateBaseGetLocationsFunction(self, ASTClassNames, CladeName):
 
 MethodReturnType = 'NodeLocationAccessors'
@@ -129,7 +89,8 @@ def GenerateBaseGetLocationsFunction(self, ASTClassNames, 
CladeName):
 """.format(CladeName)
 
 self.implementationContent += \
-'void {0} {{ GetLocations{1}(Prefix, *Object, Locs, 
Rngs);'.format(ImplSignature,
+'void {0} {{ GetLocations{1}(Prefix, *Object, Locs, Rngs);'.format(
+ImplSignature,
 CladeName)
 
 for ASTClassName in ASTClassNames:
@@ -180,29 +141,61 @@ def GenerateEpilogue(self):
 }
 '''
 
+def main():
+
+parser = argparse.ArgumentParser()
+parser.add_argument('--json-input-path',
+  help='Read API description from FILE', metavar='FILE')
+parser.add_argument('--output-file', help='Generate output in FILEPATH',
+  metavar='FILEPATH')
+parser.add_argument('--empty-implementation',
+  help='Generate empty implementation',
+  action="store", type=int)
+
+options = parser.parse_args()
+
+if options.empty_implementation:
+with 

[PATCH] D93164: [AST] Add generator for source location introspection

2021-03-14 Thread Dave Green via Phabricator via cfe-commits
dmgreen added a comment.

Hello. Does this work when the default target triple isn't native? This seems 
to be trying to compile clang sources with the just built clang - something 
that I don't think is always possible. I'm seeing errors like `fatal error: 
'cstddef' file not found`, and failing to link the new IntrospectionTests, with 
undefined references to NodeIntrospection::GetLocations, as a full toolchain is 
not setup. I don't believe the buildbots are working right now, so it's 
difficult to see if any other systems have similar problems.

Also some of the files here have been added with a University of Illinois Open 
Source License. They should presumably be using the newer Apache license now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93164

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


[PATCH] D97121: [clang-tidy] Add a Standalone diagnostics mode to clang-tidy

2021-03-14 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 330511.
njames93 added a comment.

Update.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97121

Files:
  clang-tools-extra/clang-tidy/ClangTidyCheck.h
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
  clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.cpp
  clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp
  
clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.cpp
  
clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
  clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
  clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp
  clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp
  clang-tools-extra/clang-tidy/modernize/ReplaceAutoPtrCheck.cpp
  clang-tools-extra/clang-tidy/modernize/ReplaceRandomShuffleCheck.cpp
  clang-tools-extra/clang-tidy/performance/TypePromotionInMathFnCheck.cpp
  clang-tools-extra/clang-tidy/performance/UnnecessaryValueParamCheck.cpp
  clang-tools-extra/clang-tidy/utils/IncludeInserter.cpp
  clang-tools-extra/clang-tidy/utils/IncludeInserter.h
  clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp
  clang-tools-extra/clangd/ParsedAST.cpp
  clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
  clang-tools-extra/unittests/clang-tidy/IncludeInserterTest.cpp

Index: clang-tools-extra/unittests/clang-tidy/IncludeInserterTest.cpp
===
--- clang-tools-extra/unittests/clang-tidy/IncludeInserterTest.cpp
+++ clang-tools-extra/unittests/clang-tidy/IncludeInserterTest.cpp
@@ -30,8 +30,10 @@
 public:
   IncludeInserterCheckBase(StringRef CheckName, ClangTidyContext *Context,
utils::IncludeSorter::IncludeStyle Style =
-   utils::IncludeSorter::IS_Google)
-  : ClangTidyCheck(CheckName, Context), Inserter(Style) {}
+   utils::IncludeSorter::IS_Google,
+   bool SelfContainedDiags = false)
+  : ClangTidyCheck(CheckName, Context),
+Inserter(Style, SelfContainedDiags) {}
 
   void registerPPCallbacks(const SourceManager , Preprocessor *PP,
Preprocessor *ModuleExpanderPP) override {
@@ -85,6 +87,19 @@
   }
 };
 
+class MultipleHeaderSingleInserterCheck : public IncludeInserterCheckBase {
+public:
+  MultipleHeaderSingleInserterCheck(StringRef CheckName,
+ClangTidyContext *Context)
+  : IncludeInserterCheckBase(CheckName, Context,
+ utils::IncludeSorter::IS_Google,
+ /*SelfContainedDiags=*/true) {}
+
+  std::vector headersToInclude() const override {
+return {"path/to/header.h", "path/to/header2.h", "path/to/header.h"};
+  }
+};
+
 class CSystemIncludeInserterCheck : public IncludeInserterCheckBase {
 public:
   CSystemIncludeInserterCheck(StringRef CheckName, ClangTidyContext *Context)
@@ -246,6 +261,41 @@
 PreCode, "clang_tidy/tests/insert_includes_test_input2.cc"));
 }
 
+TEST(IncludeInserterTest, InsertMultipleIncludesNoDeduplicate) {
+  const char *PreCode = R"(
+#include "clang_tidy/tests/insert_includes_test_header.h"
+
+#include 
+#include 
+
+#include "path/to/a/header.h"
+
+void foo() {
+  int a = 0;
+})";
+  // FIXME: ClangFormat bug - https://bugs.llvm.org/show_bug.cgi?id=49298
+  // clang-format off
+  const char *PostCode = R"(
+#include "clang_tidy/tests/insert_includes_test_header.h"
+
+#include 
+#include 
+
+#include "path/to/a/header.h"
+#include "path/to/header.h"
+#include "path/to/header2.h"
+#include "path/to/header.h"
+
+void foo() {
+  int a = 0;
+})";
+  // clang-format on
+
+  EXPECT_EQ(PostCode,
+runCheckOnCode(
+PreCode, "clang_tidy/tests/insert_includes_test_input2.cc"));
+}
+
 TEST(IncludeInserterTest, InsertBeforeFirstNonSystemInclude) {
   const char *PreCode = R"(
 #include "clang_tidy/tests/insert_includes_test_header.h"
Index: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
===
--- clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -517,6 +517,67 @@
   ElementsAre(Diag(Main.range(), "do not use 'else' after 'return'")));
 }
 
+TEST(DiagnosticTest, ClangTidySelfContainedDiags) {
+  Annotations Main(R"cpp($MathHeader[[]]
+struct Foo{
+  int A, B;
+  Foo()$Fix[[]] {
+$A[[A = 1;]]
+$B[[B = 1;]]
+  }
+};
+void InitVariables() {
+  float $C[[C]]$CFix[[]];
+  double $D[[D]]$DFix[[]];
+}
+  )cpp");
+  TestTU TU = TestTU::withCode(Main.code());
+  TU.ClangTidyProvider =
+  

[PATCH] D97121: [clang-tidy] Add a Standalone diagnostics mode to clang-tidy

2021-03-14 Thread Nathan James via Phabricator via cfe-commits
njames93 marked 6 inline comments as done.
njames93 added inline comments.



Comment at: clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h:217
   bool AllowEnablingAnalyzerAlphaCheckers;
+  bool SelfContainedDiags;
 };

steveire wrote:
> The order of members here is starting to look suspicious, size-wise. Not 
> something for this change though.
Not something I'm prepared to worry about in this patch.



Comment at: clang-tools-extra/unittests/clang-tidy/IncludeInserterTest.cpp:94
+  : IncludeInserterCheckBase(CheckName, Context,
+ utils::IncludeSorter::IS_Google, true) {}
+

steveire wrote:
> I think the `true` here points to this being a boolean trap. Consider using 
> an enum for the parameter instead.
I don't see a point in defining an enum for this when its only a test case, 
though a parameter comment should be added.



Comment at: clang-tools-extra/unittests/clang-tidy/IncludeInserterTest.cpp:285
+#include "path/to/header2.h"
+#include "path/to/header.h"
+

steveire wrote:
> I still find it really confusing that the "single inserter" mode results in 
> multiple of the same header being added.  Perhaps the names should be along 
> the lines of "duplicating" and "deduplicating" instead of "single" and 
> "multi"?
The name of the test is `InsertMultipleIncludesNoDeduplicate`, Is that not 
sufficient?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97121

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


[PATCH] D93377: [Clang] Add __ibm128 type to represent ppc_fp128

2021-03-14 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added inline comments.



Comment at: clang/bindings/python/clang/cindex.py:2061-2062
 TypeKind.FLOAT128 = TypeKind(30)
 TypeKind.HALF = TypeKind(31)
+TypeKind.IBM128 = TypeKind(32)
 TypeKind.COMPLEX = TypeKind(100)

This looks suspiciously like the result of this file having not been maintained 
for the additions of:
```
  CXType_Float16 = 32,
  CXType_ShortAccum = 33,
  CXType_Accum = 34,
  CXType_LongAccum = 35,
  CXType_UShortAccum = 36,
  CXType_UAccum = 37,
  CXType_ULongAccum = 38,
  CXType_BFloat16 = 39,
```

What test coverage fails if the addition of `TypeKind.IBM128` is omitted from 
this patch?



Comment at: clang/include/clang-c/Index.h:3283
   CXType_FirstBuiltin = CXType_Void,
   CXType_LastBuiltin = CXType_BFloat16,
 

Looks like `CXType_Ibm128` is the "last" built-in type now?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93377

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


[PATCH] D97121: [clang-tidy] Add a Standalone diagnostics mode to clang-tidy

2021-03-14 Thread Stephen Kelly via Phabricator via cfe-commits
steveire added inline comments.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.



Comment at: clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h:178
 
+  void setSelfContainedDiags(bool Value = true) { SelfContainedDiags = Value; }
+

I don't think this `Value` should be `= true`. It makes call sites confusing.

There is precedent though according to 

```
git grep "void set.*bool.*=.*)"
```

so consider this a nit.



Comment at: clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h:217
   bool AllowEnablingAnalyzerAlphaCheckers;
+  bool SelfContainedDiags;
 };

The order of members here is starting to look suspicious, size-wise. Not 
something for this change though.



Comment at: clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp:805
  LoopFixerKind FixerKind) {
-  // If we already modified the range of this for loop, don't do any further
+  // In single fix mode we don't want dependancies on other loops, otherwise, 
If
+  // we already modified the range of this for loop, don't do any further

Can you update this comment to not refer to "single fix" mode?



Comment at: clang-tools-extra/clang-tidy/utils/IncludeInserter.h:63
+  explicit IncludeInserter(IncludeSorter::IncludeStyle Style,
+   bool SingleFixMode);
 

Should the "single fix" naming here also be changed?



Comment at: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp:520
 
+TEST(DiagnosticTest, ClangTidySingleFixMode) {
+  Annotations Main(R"cpp($MathHeader[[]]

More "single fix" naming here.



Comment at: clang-tools-extra/unittests/clang-tidy/IncludeInserterTest.cpp:34
+   utils::IncludeSorter::IS_Google,
+   bool SingleFixMode = false)
+  : ClangTidyCheck(CheckName, Context), Inserter(Style, SingleFixMode) {}

"Single fix" naming here too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97121

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


[PATCH] D93164: [AST] Add generator for source location introspection

2021-03-14 Thread Nico Weber via Phabricator via cfe-commits
thakis added a subscriber: rsmith.
thakis added a comment.

A few more high-level questions:

- What's the point of the intermediary json file? Why not generate the final 
c++ directly? (As far as I can tell, this wasn't discussed during the review 
yet)
- Do we need to generate code for this at all? Could this be done via xmacros 
or tablegen?

Having a bespoke custom python -> json -> python -> c++ pipeline here seems 
like it's fairly different from how the rest of clang does things, and it seems 
like it duplicates some of the existing tooling we have here.

(Having said that, I'm no code owner here -- @rsmith is. Maybe he has an 
opinion.)

Lower-level: Did you see all the comments on 
https://reviews.llvm.org/rGd627a27d264b47eda3f15f086ff419dfe053ebf7 ? This 
relanded with them unaddressed. Please address them in a follow-up. (Sorry for 
leaving the comments on the commit instead of the review!)




Comment at: clang/lib/Tooling/CMakeLists.txt:31
+COMMENT Generate ASTNodeAPI.json
+OUTPUT ${CMAKE_BINARY_DIR}/ASTNodeAPI.json
+DEPENDS clang-ast-dump clang-headers

Putting this in the root of the build dir seems a bit untidy. I think 
`CMAKE_CURRENT_BINARY_DIR` is what we usually use for generated files.



Comment at: clang/lib/Tooling/CMakeLists.txt:74
+${CMAKE_COMMAND} -E copy_if_different
+  ${CMAKE_CURRENT_BINARY_DIR}/generated/NodeIntrospection.inc
+  ${BINARY_INCLUDE_DIR}/NodeIntrospection.inc

...like used here. Why `generated/`? Everything in CMAKE_CURRENT_BINARY_DIR is 
generated. (Compare to `find . -name '*.inc'`)

Also, why not make the python script write the file only if changed instead of 
making a copy here? (like llvm-tblgen does)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93164

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


[PATCH] D97563: [clang-tidy] Enable modernize-concat-nested-namespaces also on headers

2021-03-14 Thread Nathan James via Phabricator via cfe-commits
njames93 accepted this revision.
njames93 added a comment.
This revision is now accepted and ready to land.
Herald added projects: LLVM, clang-tools-extra.
Herald added a subscriber: llvm-commits.

Is DAG required because the header file warnings are printed in a different 
order depending on things like platform?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97563

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


[PATCH] D98510: [Clang][ARM] Reenable arm_acle.c test.

2021-03-14 Thread Dave Green via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2b3c81314343: [Clang][ARM] Reenable arm_acle.c test. 
(authored by dmgreen).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D98510?vs=330244=330502#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98510

Files:
  clang/test/CodeGen/arm_acle.c

Index: clang/test/CodeGen/arm_acle.c
===
--- clang/test/CodeGen/arm_acle.c
+++ clang/test/CodeGen/arm_acle.c
@@ -1,125 +1,231 @@
-// RUN: %clang_cc1 -ffreestanding -triple armv8-eabi -target-cpu cortex-a57 -O2  -fno-experimental-new-pass-manager -S -emit-llvm -o - %s | FileCheck %s -check-prefix=ARM -check-prefix=AArch32 -check-prefix=ARM-LEGACY -check-prefix=AArch32-LEGACY
-// RUN: %clang_cc1 -ffreestanding -triple armv8-eabi -target-cpu cortex-a57 -O2  -fexperimental-new-pass-manager -S -emit-llvm -o - %s | FileCheck %s -check-prefix=ARM -check-prefix=AArch32 -check-prefix=ARM-NEWPM -check-prefix=AArch32-NEWPM
-// RUN: %clang_cc1 -ffreestanding -triple aarch64-eabi -target-cpu cortex-a57 -target-feature +neon -target-feature +crc -target-feature +crypto -O2 -fno-experimental-new-pass-manager -S -emit-llvm -o - %s | FileCheck %s -check-prefix=ARM -check-prefix=AArch64 -check-prefix=ARM-LEGACY -check-prefix=AArch64-LEGACY
-// RUN: %clang_cc1 -ffreestanding -triple aarch64-eabi -target-cpu cortex-a57 -target-feature +neon -target-feature +crc -target-feature +crypto -O2 -fexperimental-new-pass-manager -S -emit-llvm -o - %s | FileCheck %s -check-prefix=ARM -check-prefix=AArch64 -check-prefix=ARM-NEWPM -check-prefix=AArch64-NEWPM
-// RUN: %clang_cc1 -ffreestanding -triple aarch64-eabi -target-cpu cortex-a57 -target-feature +v8.3a -O2 -fexperimental-new-pass-manager -S -emit-llvm -o - %s | FileCheck %s -check-prefix=AArch64-v8_3
-// RUN: %clang_cc1 -ffreestanding -triple aarch64-eabi -target-cpu cortex-a57 -target-feature +v8.4a -O2 -fexperimental-new-pass-manager -S -emit-llvm -o - %s | FileCheck %s -check-prefix=AArch64-v8_3
-// RUN: %clang_cc1 -ffreestanding -triple aarch64-eabi -target-cpu cortex-a57 -target-feature +v8.5a -O2 -fexperimental-new-pass-manager -S -emit-llvm -o - %s | FileCheck %s -check-prefix=AArch64-v8_3
-
-// REQUIRES: rewrite
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -ffreestanding -triple armv8a-none-eabi -target-feature +crc -target-feature +dsp -O0 -disable-O0-optnone -fexperimental-new-pass-manager -S -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s -check-prefixes=ARM,AArch32
+// RUN: %clang_cc1 -ffreestanding -triple aarch64-none-eabi -target-feature +neon -target-feature +crc -target-feature +crypto -O0 -disable-O0-optnone -fexperimental-new-pass-manager -S -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s -check-prefixes=ARM,AArch64
+// RUN: %clang_cc1 -ffreestanding -triple aarch64-none-eabi -target-feature +v8.3a -O0 -disable-O0-optnone -fexperimental-new-pass-manager -S -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s -check-prefixes=ARM,AArch64,AArch6483
+// RUN: %clang_cc1 -ffreestanding -triple aarch64-none-eabi -target-feature +v8.5a -O0 -disable-O0-optnone -fexperimental-new-pass-manager -S -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s -check-prefixes=ARM,AArch64,AArch6483
 
 #include 
 
+// REQUIRES: arm-registered-target,aarch64-registered-target
+
 /* 8 SYNCHRONIZATION, BARRIER AND HINT INTRINSICS */
 /* 8.3 Memory Barriers */
-// ARM-LABEL: test_dmb
-// AArch32: call void @llvm.arm.dmb(i32 1)
-// AArch64: call void @llvm.aarch64.dmb(i32 1)
+
+// AArch32-LABEL: @test_dmb(
+// AArch32-NEXT:  entry:
+// AArch32-NEXT:call void @llvm.arm.dmb(i32 1)
+// AArch32-NEXT:ret void
+//
+// AArch64-LABEL: @test_dmb(
+// AArch64-NEXT:  entry:
+// AArch64-NEXT:call void @llvm.aarch64.dmb(i32 1)
+// AArch64-NEXT:ret void
+//
 void test_dmb(void) {
   __dmb(1);
 }
 
-// ARM-LABEL: test_dsb
-// AArch32: call void @llvm.arm.dsb(i32 2)
-// AArch64: call void @llvm.aarch64.dsb(i32 2)
+// AArch32-LABEL: @test_dsb(
+// AArch32-NEXT:  entry:
+// AArch32-NEXT:call void @llvm.arm.dsb(i32 2)
+// AArch32-NEXT:ret void
+//
+// AArch64-LABEL: @test_dsb(
+// AArch64-NEXT:  entry:
+// AArch64-NEXT:call void @llvm.aarch64.dsb(i32 2)
+// AArch64-NEXT:ret void
+//
 void test_dsb(void) {
   __dsb(2);
 }
 
-// ARM-LABEL: test_isb
-// AArch32: call void @llvm.arm.isb(i32 3)
-// AArch64: call void @llvm.aarch64.isb(i32 3)
+// AArch32-LABEL: @test_isb(
+// AArch32-NEXT:  entry:
+// AArch32-NEXT:call void @llvm.arm.isb(i32 3)
+// AArch32-NEXT:ret void
+//
+// AArch64-LABEL: @test_isb(
+// AArch64-NEXT:  entry:
+// AArch64-NEXT:call void @llvm.aarch64.isb(i32 3)
+// AArch64-NEXT:ret 

[clang] 2b3c813 - [Clang][ARM] Reenable arm_acle.c test.

2021-03-14 Thread David Green via cfe-commits

Author: David Green
Date: 2021-03-14T10:59:24Z
New Revision: 2b3c8131434374caf3825c2bd4e012c85f8128de

URL: 
https://github.com/llvm/llvm-project/commit/2b3c8131434374caf3825c2bd4e012c85f8128de
DIFF: 
https://github.com/llvm/llvm-project/commit/2b3c8131434374caf3825c2bd4e012c85f8128de.diff

LOG: [Clang][ARM] Reenable arm_acle.c test.

This test was apparently disabled in 6fcd4e080f09c9765d6, without any
sign of how it was going to be reenabled. This patch rewrites the test
to use update_cc_test_checks, with midend optimizations other that
mem2reg disabled.

The first attempt of this patch in 5ae949a9276542b46 failed on bots even
though it worked locally.  I've attempted to adjust the RUN lines and
made the test AArch64/ARM specific.

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

Added: 


Modified: 
clang/test/CodeGen/arm_acle.c

Removed: 




diff  --git a/clang/test/CodeGen/arm_acle.c b/clang/test/CodeGen/arm_acle.c
index 9f0ad22bda4f..dead8a085f86 100644
--- a/clang/test/CodeGen/arm_acle.c
+++ b/clang/test/CodeGen/arm_acle.c
@@ -1,125 +1,231 @@
-// RUN: %clang_cc1 -ffreestanding -triple armv8-eabi -target-cpu cortex-a57 
-O2  -fno-experimental-new-pass-manager -S -emit-llvm -o - %s | FileCheck %s 
-check-prefix=ARM -check-prefix=AArch32 -check-prefix=ARM-LEGACY 
-check-prefix=AArch32-LEGACY
-// RUN: %clang_cc1 -ffreestanding -triple armv8-eabi -target-cpu cortex-a57 
-O2  -fexperimental-new-pass-manager -S -emit-llvm -o - %s | FileCheck %s 
-check-prefix=ARM -check-prefix=AArch32 -check-prefix=ARM-NEWPM 
-check-prefix=AArch32-NEWPM
-// RUN: %clang_cc1 -ffreestanding -triple aarch64-eabi -target-cpu cortex-a57 
-target-feature +neon -target-feature +crc -target-feature +crypto -O2 
-fno-experimental-new-pass-manager -S -emit-llvm -o - %s | FileCheck %s 
-check-prefix=ARM -check-prefix=AArch64 -check-prefix=ARM-LEGACY 
-check-prefix=AArch64-LEGACY
-// RUN: %clang_cc1 -ffreestanding -triple aarch64-eabi -target-cpu cortex-a57 
-target-feature +neon -target-feature +crc -target-feature +crypto -O2 
-fexperimental-new-pass-manager -S -emit-llvm -o - %s | FileCheck %s 
-check-prefix=ARM -check-prefix=AArch64 -check-prefix=ARM-NEWPM 
-check-prefix=AArch64-NEWPM
-// RUN: %clang_cc1 -ffreestanding -triple aarch64-eabi -target-cpu cortex-a57 
-target-feature +v8.3a -O2 -fexperimental-new-pass-manager -S -emit-llvm -o - 
%s | FileCheck %s -check-prefix=AArch64-v8_3
-// RUN: %clang_cc1 -ffreestanding -triple aarch64-eabi -target-cpu cortex-a57 
-target-feature +v8.4a -O2 -fexperimental-new-pass-manager -S -emit-llvm -o - 
%s | FileCheck %s -check-prefix=AArch64-v8_3
-// RUN: %clang_cc1 -ffreestanding -triple aarch64-eabi -target-cpu cortex-a57 
-target-feature +v8.5a -O2 -fexperimental-new-pass-manager -S -emit-llvm -o - 
%s | FileCheck %s -check-prefix=AArch64-v8_3
-
-// REQUIRES: rewrite
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -ffreestanding -triple armv8a-none-eabi -target-feature 
+crc -target-feature +dsp -O0 -disable-O0-optnone 
-fexperimental-new-pass-manager -S -emit-llvm -o - %s | opt -S -mem2reg | 
FileCheck %s -check-prefixes=ARM,AArch32
+// RUN: %clang_cc1 -ffreestanding -triple aarch64-none-eabi -target-feature 
+neon -target-feature +crc -target-feature +crypto -O0 -disable-O0-optnone 
-fexperimental-new-pass-manager -S -emit-llvm -o - %s | opt -S -mem2reg | 
FileCheck %s -check-prefixes=ARM,AArch64
+// RUN: %clang_cc1 -ffreestanding -triple aarch64-none-eabi -target-feature 
+v8.3a -O0 -disable-O0-optnone -fexperimental-new-pass-manager -S -emit-llvm -o 
- %s | opt -S -mem2reg | FileCheck %s -check-prefixes=ARM,AArch64,AArch6483
+// RUN: %clang_cc1 -ffreestanding -triple aarch64-none-eabi -target-feature 
+v8.5a -O0 -disable-O0-optnone -fexperimental-new-pass-manager -S -emit-llvm -o 
- %s | opt -S -mem2reg | FileCheck %s -check-prefixes=ARM,AArch64,AArch6483
 
 #include 
 
+// REQUIRES: arm-registered-target,aarch64-registered-target
+
 /* 8 SYNCHRONIZATION, BARRIER AND HINT INTRINSICS */
 /* 8.3 Memory Barriers */
-// ARM-LABEL: test_dmb
-// AArch32: call void @llvm.arm.dmb(i32 1)
-// AArch64: call void @llvm.aarch64.dmb(i32 1)
+
+// AArch32-LABEL: @test_dmb(
+// AArch32-NEXT:  entry:
+// AArch32-NEXT:call void @llvm.arm.dmb(i32 1)
+// AArch32-NEXT:ret void
+//
+// AArch64-LABEL: @test_dmb(
+// AArch64-NEXT:  entry:
+// AArch64-NEXT:call void @llvm.aarch64.dmb(i32 1)
+// AArch64-NEXT:ret void
+//
 void test_dmb(void) {
   __dmb(1);
 }
 
-// ARM-LABEL: test_dsb
-// AArch32: call void @llvm.arm.dsb(i32 2)
-// AArch64: call void @llvm.aarch64.dsb(i32 2)
+// AArch32-LABEL: @test_dsb(
+// AArch32-NEXT:  entry:
+// AArch32-NEXT:call void @llvm.arm.dsb(i32 2)
+// AArch32-NEXT:ret void
+//
+// AArch64-LABEL: @test_dsb(
+// AArch64-NEXT:  entry:
+// AArch64-NEXT:call void @llvm.aarch64.dsb(i32 2)
+// AArch64-NEXT:

[clang] 77f7d2b - [AST] Add generator for source location introspection

2021-03-14 Thread Stephen Kelly via cfe-commits

Author: Stephen Kelly
Date: 2021-03-14T10:54:33Z
New Revision: 77f7d2be214a1de29d583c75739f563593991fc3

URL: 
https://github.com/llvm/llvm-project/commit/77f7d2be214a1de29d583c75739f563593991fc3
DIFF: 
https://github.com/llvm/llvm-project/commit/77f7d2be214a1de29d583c75739f563593991fc3.diff

LOG: [AST] Add generator for source location introspection

Generate a json file containing descriptions of AST classes and their
public accessors which return SourceLocation or SourceRange.

Use the JSON file to generate a C++ API and implementation for accessing
the source locations and method names for accessing them for a given AST
node.

This new API can be used to implement 'srcloc' output in clang-query:

  http://ce.steveire.com/z/m_kTIo

In this first version of this feature, only the accessors for Stmt
classes are generated, not Decls, TypeLocs etc.  Those can be added
after this change is reviewed, as this change is mostly about
infrastructure of these code generators.

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

Added: 
clang/include/clang/Tooling/NodeIntrospection.h
clang/lib/Tooling/DumpTool/APIData.h
clang/lib/Tooling/DumpTool/ASTSrcLocProcessor.cpp
clang/lib/Tooling/DumpTool/ASTSrcLocProcessor.h
clang/lib/Tooling/DumpTool/CMakeLists.txt
clang/lib/Tooling/DumpTool/ClangSrcLocDump.cpp
clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py
clang/lib/Tooling/NodeIntrospection.cpp
clang/unittests/Introspection/CMakeLists.txt
clang/unittests/Introspection/IntrospectionTest.cpp

Modified: 
clang/lib/Tooling/CMakeLists.txt
clang/unittests/CMakeLists.txt

Removed: 




diff  --git a/clang/include/clang/Tooling/NodeIntrospection.h 
b/clang/include/clang/Tooling/NodeIntrospection.h
new file mode 100644
index ..abaa58b674a1
--- /dev/null
+++ b/clang/include/clang/Tooling/NodeIntrospection.h
@@ -0,0 +1,85 @@
+//===- NodeIntrospection.h *- 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
+//
+//===--===//
+//
+//  This file contains the implementation of the NodeIntrospection.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLING_NODEINTROSPECTION_H
+#define LLVM_CLANG_TOOLING_NODEINTROSPECTION_H
+
+#include "clang/AST/ASTTypeTraits.h"
+#include "clang/AST/DeclarationName.h"
+
+#include 
+#include 
+
+namespace clang {
+
+class Stmt;
+
+namespace tooling {
+
+class LocationCall {
+public:
+  enum LocationCallFlags { NoFlags, ReturnsPointer, IsCast };
+  LocationCall(std::shared_ptr on, std::string name,
+   LocationCallFlags flags = NoFlags)
+  : m_on(on), m_name(name), m_flags(flags) {}
+  LocationCall(std::shared_ptr on, std::string name,
+   std::vector const ,
+   LocationCallFlags flags = NoFlags)
+  : m_on(on), m_name(name), m_flags(flags) {}
+
+  LocationCall *on() const { return m_on.get(); }
+  StringRef name() const { return m_name; }
+  std::vector const () const { return m_args; }
+  bool returnsPointer() const { return m_flags & ReturnsPointer; }
+  bool isCast() const { return m_flags & IsCast; }
+
+private:
+  std::shared_ptr m_on;
+  std::string m_name;
+  std::vector m_args;
+  LocationCallFlags m_flags;
+};
+
+class LocationCallFormatterCpp {
+public:
+  static std::string format(LocationCall *Call);
+};
+
+namespace internal {
+struct RangeLessThan {
+  bool operator()(
+  std::pair> const ,
+  std::pair> const ) const;
+};
+} // namespace internal
+
+template >>
+using UniqueMultiMap = std::set, Comp>;
+
+using SourceLocationMap =
+UniqueMultiMap>;
+using SourceRangeMap =
+UniqueMultiMap,
+   internal::RangeLessThan>;
+
+struct NodeLocationAccessors {
+  SourceLocationMap LocationAccessors;
+  SourceRangeMap RangeAccessors;
+};
+
+namespace NodeIntrospection {
+NodeLocationAccessors GetLocations(clang::Stmt const *Object);
+NodeLocationAccessors GetLocations(clang::DynTypedNode const );
+} // namespace NodeIntrospection
+} // namespace tooling
+} // namespace clang
+#endif

diff  --git a/clang/lib/Tooling/CMakeLists.txt 
b/clang/lib/Tooling/CMakeLists.txt
index 7a58af59dad1..9572ad09df0a 100644
--- a/clang/lib/Tooling/CMakeLists.txt
+++ b/clang/lib/Tooling/CMakeLists.txt
@@ -8,10 +8,83 @@ add_subdirectory(Core)
 add_subdirectory(Inclusions)
 add_subdirectory(Refactoring)
 add_subdirectory(ASTDiff)
+add_subdirectory(DumpTool)
 add_subdirectory(Syntax)
 add_subdirectory(DependencyScanning)
 add_subdirectory(Transformer)
 
+find_package(Python3 COMPONENTS Interpreter)
+
+# The generation of ASTNodeAPI.json takes a long time in a
+# Debug