[PATCH] D79895: Add a new warning to warn when passing uninitialized variables as const reference parameters to a function

2020-06-04 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru added a comment.

@zequanwu could you please update the release notes? thanks
https://github.com/llvm/llvm-project/blob/master/clang/docs/ReleaseNotes.rst


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79895



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


[PATCH] D80941: [PowerPC][Power10] Implement Count Leading/Trailing Zeroes Builtins under bit Mask in LLVM/Clang

2020-06-04 Thread Amy Kwan via Phabricator via cfe-commits
amyk updated this revision to Diff 268470.
amyk added a comment.

Revert back to the initial implementation of the patch. Thanks Nemanja for 
clarifying.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80941

Files:
  clang/include/clang/Basic/BuiltinsPPC.def
  clang/lib/Headers/altivec.h
  clang/test/CodeGen/builtins-ppc-p10.c
  clang/test/CodeGen/builtins-ppc-p10vector.c
  llvm/include/llvm/IR/IntrinsicsPowerPC.td
  llvm/lib/Target/PowerPC/PPCInstrPrefix.td
  llvm/test/CodeGen/PowerPC/p10-bit-manip-ops.ll
  llvm/test/MC/Disassembler/PowerPC/p10insts.txt
  llvm/test/MC/PowerPC/p10.s

Index: llvm/test/MC/PowerPC/p10.s
===
--- llvm/test/MC/PowerPC/p10.s
+++ llvm/test/MC/PowerPC/p10.s
@@ -15,3 +15,15 @@
 # CHECK-BE: pextd 1, 2, 4 # encoding: [0x7c,0x41,0x21,0x78]
 # CHECK-LE: pextd 1, 2, 4 # encoding: [0x78,0x21,0x41,0x7c]
 pextd 1, 2, 4
+# CHECK-BE: vclzdm 1, 2, 3# encoding: [0x10,0x22,0x1f,0x84]
+# CHECK-LE: vclzdm 1, 2, 3# encoding: [0x84,0x1f,0x22,0x10]
+vclzdm 1, 2, 3
+# CHECK-BE: vctzdm 1, 2, 3# encoding: [0x10,0x22,0x1f,0xc4]
+# CHECK-LE: vctzdm 1, 2, 3# encoding: [0xc4,0x1f,0x22,0x10]
+vctzdm 1, 2, 3
+# CHECK-BE: cntlzdm 1, 3, 2   # encoding: [0x7c,0x61,0x10,0x76]
+# CHECK-LE: cntlzdm 1, 3, 2   # encoding: [0x76,0x10,0x61,0x7c]
+cntlzdm 1, 3, 2
+# CHECK-BE: cnttzdm 1, 3, 2   # encoding: [0x7c,0x61,0x14,0x76]
+# CHECK-LE: cnttzdm 1, 3, 2   # encoding: [0x76,0x14,0x61,0x7c]
+cnttzdm 1, 3, 2
Index: llvm/test/MC/Disassembler/PowerPC/p10insts.txt
===
--- llvm/test/MC/Disassembler/PowerPC/p10insts.txt
+++ llvm/test/MC/Disassembler/PowerPC/p10insts.txt
@@ -12,3 +12,15 @@
 
 # CHECK: pextd 1, 2, 4
 0x7c 0x41 0x21 0x78
+
+# CHECK: vclzdm 1, 2, 3
+0x10 0x22 0x1f 0x84
+
+# CHECK: vctzdm 1, 2, 3
+0x10 0x22 0x1f 0xc4
+
+# CHECK: cntlzdm 1, 3, 2
+0x7c 0x61 0x10 0x76
+
+# CHECK: cnttzdm 1, 3, 2
+0x7c 0x61 0x14 0x76
Index: llvm/test/CodeGen/PowerPC/p10-bit-manip-ops.ll
===
--- llvm/test/CodeGen/PowerPC/p10-bit-manip-ops.ll
+++ llvm/test/CodeGen/PowerPC/p10-bit-manip-ops.ll
@@ -9,6 +9,10 @@
 declare <2 x i64> @llvm.ppc.altivec.vpextd(<2 x i64>, <2 x i64>)
 declare i64 @llvm.ppc.pdepd(i64, i64)
 declare i64 @llvm.ppc.pextd(i64, i64)
+declare <2 x i64> @llvm.ppc.altivec.vclzdm(<2 x i64>, <2 x i64>)
+declare <2 x i64> @llvm.ppc.altivec.vctzdm(<2 x i64>, <2 x i64>)
+declare i64 @llvm.ppc.cntlzdm(i64, i64)
+declare i64 @llvm.ppc.cnttzdm(i64, i64)
 
 define <2 x i64> @test_vpdepd(<2 x i64> %a, <2 x i64> %b) {
 ; CHECK-LABEL: test_vpdepd:
@@ -49,3 +53,43 @@
   %tmp = tail call i64 @llvm.ppc.pextd(i64 %a, i64 %b)
   ret i64 %tmp
 }
+
+define <2 x i64> @test_vclzdm(<2 x i64> %a, <2 x i64> %b) {
+; CHECK-LABEL: test_vclzdm:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vclzdm v2, v2, v3
+; CHECK-NEXT:blr
+entry:
+  %tmp = tail call <2 x i64> @llvm.ppc.altivec.vclzdm(<2 x i64> %a, <2 x i64> %b)
+  ret <2 x i64> %tmp
+}
+
+define <2 x i64> @test_vctzdm(<2 x i64> %a, <2 x i64> %b) {
+; CHECK-LABEL: test_vctzdm:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vctzdm v2, v2, v3
+; CHECK-NEXT:blr
+entry:
+  %tmp = tail call <2 x i64> @llvm.ppc.altivec.vctzdm(<2 x i64> %a, <2 x i64> %b)
+  ret <2 x i64> %tmp
+}
+
+define i64 @test_cntlzdm(i64 %a, i64 %b) {
+; CHECK-LABEL: test_cntlzdm:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:cntlzdm r3, r3, r4
+; CHECK-NEXT:blr
+entry:
+  %tmp = tail call i64 @llvm.ppc.cntlzdm(i64 %a, i64 %b)
+  ret i64 %tmp
+}
+
+define i64 @test_cnttzdm(i64 %a, i64 %b) {
+; CHECK-LABEL: test_cnttzdm:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:cnttzdm r3, r3, r4
+; CHECK-NEXT:blr
+entry:
+  %tmp = tail call i64 @llvm.ppc.cnttzdm(i64 %a, i64 %b)
+  ret i64 %tmp
+}
Index: llvm/lib/Target/PowerPC/PPCInstrPrefix.td
===
--- llvm/lib/Target/PowerPC/PPCInstrPrefix.td
+++ llvm/lib/Target/PowerPC/PPCInstrPrefix.td
@@ -516,4 +516,20 @@
def PEXTD : XForm_6<31, 188, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB),
"pextd $rA, $rS, $rB", IIC_IntGeneral,
[(set i64:$rA, (int_ppc_pextd i64:$rS, i64:$rB))]>;
+   def VCLZDM : VXForm_1<1924, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
+ "vclzdm $vD, $vA, $vB", IIC_VecGeneral,
+ [(set v2i64:$vD,
+ (int_ppc_altivec_vclzdm v2i64:$vA, v2i64:$vB))]>;
+   def VCTZDM : VXForm_1<1988, (outs vrrc:$vD), (ins vrrc:$vA, 

[PATCH] D62922: [WebAssembly] Implement "Reactor" mode

2020-06-04 Thread Dan Gohman via Phabricator via cfe-commits
sunfish marked an inline comment as done.
sunfish added inline comments.



Comment at: clang/test/Driver/wasm-toolchain.c:116
+// CHECK-COMMAND: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
+// CHECK-COMMAND: wasm-ld{{.*}}" "crt1.o" "[[temp]]" "-lc" 
"{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
+

bjope wrote:
> bjope wrote:
> > This isn't working for me on redhat 7 servers. I get
> > ```
> >  "wasm-ld" "-L/lib" "/lib/crt1.o" ...
> > ```
> > No idea why I get the full patch to crt1.o. But it's not matching with the 
> > FileCheck pattern.
> /full patch/full path/
Would you be able to test whether the following patch fixes it?

```diff
diff --git a/clang/test/Driver/wasm-toolchain.c 
b/clang/test/Driver/wasm-toolchain.c
index 8300a81614e..332e6048cc5 100644
--- a/clang/test/Driver/wasm-toolchain.c
+++ b/clang/test/Driver/wasm-toolchain.c
@@ -110,11 +110,11 @@

 // Basic exec-model tests.

-// RUN: %clang %s -### -no-canonical-prefixes -target wasm32-unknown-unknown 
-mexec-model=command 2>&1 \
+// RUN: %clang %s -### -no-canonical-prefixes -target wasm32-unknown-unknown 
--sysroot=%s/no-sysroot-there -mexec-model=command 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-COMMAND %s
 // CHECK-COMMAND: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
 // CHECK-COMMAND: wasm-ld{{.*}}" "crt1.o" "[[temp]]" "-lc" 
"{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"

-// RUN: %clang %s -### -no-canonical-prefixes -target wasm32-unknown-unknown 
-mexec-model=reactor 2>&1 \
+// RUN: %clang %s -### -no-canonical-prefixes -target wasm32-unknown-unknown 
--sysroot=%s/no-sysroot-there -mexec-model=reactor 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-REACTOR %s
 // CHECK-REACTOR: wasm-ld{{.*}}" {{.*}} "--entry" "_initialize" {{.*}}
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62922



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


[clang] 9ca5a6d - [OPENMP]Fix PR46146: Do not consider globalized variables as NRVO candidates.

2020-06-04 Thread Alexey Bataev via cfe-commits

Author: Alexey Bataev
Date: 2020-06-04T12:33:25-04:00
New Revision: 9ca5a6d3b523688be8b4c2315482297fa943c777

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

LOG: [OPENMP]Fix PR46146: Do not consider globalized variables as NRVO 
candidates.

Summary:
If the variables must be globalized in OpenMP mode (local automatic
variable, GPU compilation mode, the variable may escape its declaration
context by the reference or by the pointer), it should not be considered
as the NRVO candidate. Otherwise, incorrect the return value of the
function might not be updated.

Reviewers: jdoerfert

Subscribers: yaxunl, guansong, sstefan1, cfe-commits, caomhin

Tags: #clang

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

Added: 
clang/test/OpenMP/nvptx_NRVO_variable.cpp

Modified: 
clang/lib/CodeGen/CGStmt.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGStmt.cpp b/clang/lib/CodeGen/CGStmt.cpp
index 3559e77fc764..cccb15a0a909 100644
--- a/clang/lib/CodeGen/CGStmt.cpp
+++ b/clang/lib/CodeGen/CGStmt.cpp
@@ -11,6 +11,7 @@
 
//===--===//
 
 #include "CGDebugInfo.h"
+#include "CGOpenMPRuntime.h"
 #include "CodeGenFunction.h"
 #include "CodeGenModule.h"
 #include "TargetInfo.h"
@@ -1106,8 +1107,13 @@ void CodeGenFunction::EmitReturnStmt(const ReturnStmt 
) {
 
   // FIXME: Clean this up by using an LValue for ReturnTemp,
   // EmitStoreThroughLValue, and EmitAnyExpr.
-  if (getLangOpts().ElideConstructors &&
-  S.getNRVOCandidate() && S.getNRVOCandidate()->isNRVOVariable()) {
+  // Check if the NRVO candidate was not globalized in OpenMP mode.
+  if (getLangOpts().ElideConstructors && S.getNRVOCandidate() &&
+  S.getNRVOCandidate()->isNRVOVariable() &&
+  (!getLangOpts().OpenMP ||
+   !CGM.getOpenMPRuntime()
+.getAddressOfLocalVariable(*this, S.getNRVOCandidate())
+.isValid())) {
 // Apply the named return value optimization for this return statement,
 // which means doing nothing: the appropriate result has already been
 // constructed into the NRVO variable.

diff  --git a/clang/test/OpenMP/nvptx_NRVO_variable.cpp 
b/clang/test/OpenMP/nvptx_NRVO_variable.cpp
new file mode 100644
index ..9bbe5d00028e
--- /dev/null
+++ b/clang/test/OpenMP/nvptx_NRVO_variable.cpp
@@ -0,0 +1,30 @@
+// Test target codegen - host bc file has to be created first.
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown 
-fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device 
-fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+
+struct S {
+  int a;
+  S() : a(1) {}
+};
+
+#pragma omp declare target
+void bar(S &);
+// CHECK-LABEL: foo
+S foo() {
+  // CHECK: [[RETVAL:%.+]] = alloca %struct.S,
+  S s;
+  // CHECK: call void @{{.+}}bar{{.+}}(%struct.S* {{.*}}[[S_REF:%.+]])
+  bar(s);
+  // CHECK: [[DEST:%.+]] = bitcast %struct.S* [[RETVAL]] to i8*
+  // CHECK: [[SOURCE:%.+]] = bitcast %struct.S* [[S_REF]] to i8*
+  // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* {{.*}}[[DEST]], i8* 
{{.*}}[[SOURCE]], i64 4, i1 false)
+  // CHECK: [[VAL:%.+]] = load %struct.S, %struct.S* [[RETVAL]],
+  // CHECK: ret %struct.S [[VAL]]
+  return s;
+}
+#pragma omp end declare target
+
+#endif



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


[clang-tools-extra] 6271b96 - [clang-tidy][modernize-loop-convert] Make loop var type human readable

2020-06-04 Thread Zinovy Nis via cfe-commits

Author: Zinovy Nis
Date: 2020-06-04T19:51:45+03:00
New Revision: 6271b96bef479882cf43397941a4c95aa9f47403

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

LOG: [clang-tidy][modernize-loop-convert] Make loop var type human readable

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp

clang-tools-extra/test/clang-tidy/checkers/Inputs/modernize-loop-convert/structures.h

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp 
b/clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
index aa914ef7bbf5..be3a7141a5cc 100644
--- a/clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
@@ -621,6 +621,7 @@ void LoopConvertCheck::doConversion(
   QualType Type = Context->getAutoDeductType();
   if (!Descriptor.ElemType.isNull() && 
Descriptor.ElemType->isFundamentalType())
 Type = Descriptor.ElemType.getUnqualifiedType();
+  Type = Type.getDesugaredType(*Context);
 
   // If the new variable name is from the aliased variable, then the reference
   // type for the new variable should only be used if the aliased variable was

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/Inputs/modernize-loop-convert/structures.h
 
b/clang-tools-extra/test/clang-tidy/checkers/Inputs/modernize-loop-convert/structures.h
index 02d440c21a52..22b70f082d7b 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/Inputs/modernize-loop-convert/structures.h
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/Inputs/modernize-loop-convert/structures.h
@@ -40,13 +40,14 @@ struct S {
 };
 
 struct T {
+  typedef int value_type;
   struct iterator {
-int& operator*();
-const int& operator*()const;
+value_type *();
+const value_type *() const;
 iterator& operator ++();
 bool operator!=(const iterator );
-void insert(int);
-int X;
+void insert(value_type);
+value_type X;
   };
   iterator begin();
   iterator end();



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


[PATCH] D62922: [WebAssembly] Implement "Reactor" mode

2020-06-04 Thread Bjorn Pettersson via Phabricator via cfe-commits
bjope added inline comments.



Comment at: clang/test/Driver/wasm-toolchain.c:116
+// CHECK-COMMAND: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
+// CHECK-COMMAND: wasm-ld{{.*}}" "crt1.o" "[[temp]]" "-lc" 
"{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
+

This isn't working for me on redhat 7 servers. I get
```
 "wasm-ld" "-L/lib" "/lib/crt1.o" ...
```
No idea why I get the full patch to crt1.o. But it's not matching with the 
FileCheck pattern.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62922



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


[PATCH] D80932: [SYCL] Make default address space a superset of OpenCL address spaces.

2020-06-04 Thread Victor Lomuller via Phabricator via cfe-commits
Naghasan added a comment.

In D80932#2072064 , @Anastasia wrote:

> In D80932#2071321 , @bader wrote:
>
> > In D80932#2068863 , @Anastasia 
> > wrote:
> >
> > >
> >
> >
> >
> >
> > > Why? Can you explain what you are trying to achieve with this?
> >
> > I think @asavonic can provide more detailed answer, but IIRC we spent a lot 
> > time trying to marry template meta-programming with OpenCL address space 
> > deductions, but even simplest template functions from C++ standard library 
> > breaks compilation. It's important to note one important difference in 
> > design goals for SYCL and C++ for OpenCL. SYCL aims to enable compilation 
> > of regular C++ as much as possible where as one of the C++ for OpenCL goals 
> > is to keep compatibility with OpenCL C. These two goals might lead to 
> > different design decisions.
>
>
> I don't see a contradiction in those goals. We plan to support C++ libraries 
> with C++ for OpenCL of course with functionality that is accepted by 
> conformant OpenCL implementations. For example, libraries that use virtual 
> functions leading to function pointers are not going to work portably in 
> OpenCL devices. If SYCL aims to compile to conformant OpenCL devices then it 
> should not be very different I imagine?


There is a fundamental difference (given the direction taken for OpenCL), 
OpenCL mode actively modifies user's types  (C and C++ for OpenCL AFAIK). So 
inside a function, this:

  int var;

becomes

  VarDecl  var '__private int'

Which is fine in C where you can't really do much  with your types, but this 
has a massive and destructive effect in C++. For instance this does not compile 
in C++ for OpenCL:

  void foo() {
  int var; // '__private int' not 'int'
  int* ptr1 =  // '__generic int* __private' not 'int*'
  decltype(var)* ptr2 = ptr1; // error: cannot initialize a variable of 
type 'decltype(var) *__private' (aka '__private int *__private') with an lvalue 
of type '__generic int *__private'
  }



> We plan to support C++ libraries with C++ for OpenCL

With the direction taken so far, C++ for OpenCL can't properly implement or use 
basic C++ due to this. Trivial example using a `is_same` implementation 
(https://godbolt.org/z/CLFV6z):

  template
  struct is_same {
  static constexpr int value = 0;
  };
  
  template
  struct is_same {
  static constexpr int value = 1;
  };
  
  void foo(int p) {
  static_assert(is_same::value, "int is not an int?"); // 
Fails: p is '__private int' != 'int'
  static_assert(is_same::value, "int* is not an 
int*?");  // Fails: p is '__private int*' != '__generic int*'
  }

So yes, you could implement `std::is_same` but it won't work as one would 
expect.

That's the reason why SYCL actively tries to prevent changing any type, this 
would prevent the compilation of valid C++ code without a fundamental reason 
(e.g. the target is not able to support it).

> Default address space is a Clang concept that is generally used for an 
> automatic storage.

That's not true in CUDA. On the other hand they actively avoids using address 
space.
Plus in `isAddressSpaceSupersetOf` you have:

  // Consider pointer size address spaces to be equivalent to default.
  ((isPtrSizeAddressSpace(A) || A == LangAS::Default) &&
  (isPtrSizeAddressSpace(B) || B == LangAS::Default))

An alternative would be to clone the address space. But that would be shame to 
not find a way to reuse the opencl one as down the line, they map to the same 
thing.




Comment at: clang/include/clang/AST/Type.h:493
+other.getAddressSpace()) ||
+   (!hasAddressSpace() &&
+(other.getAddressSpace() == LangAS::opencl_private ||

Not sure how to make it better, but this may not be true depending on what is 
allowed by the language.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80932



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


[PATCH] D81150: Use libClangTesting in the unittest for AST matchers

2020-06-04 Thread Marcel Hlopko via Phabricator via cfe-commits
hlopko accepted this revision.
hlopko added a comment.
This revision is now accepted and ready to land.

Nice! :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81150



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


[PATCH] D81157: Propose naming principle for NodeRole and apply it

2020-06-04 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 added inline comments.



Comment at: clang/include/clang/Tooling/Syntax/Nodes.h:94
 /// a binary expression'. Used for implementing accessors.
+// How to name NodeRole:
+// If the child node is a token/keyword, end its name with 'Token'/'Keyword'

I'd suggest to make this into a doc comment, but phrase it in a way that is 
useful for users, so that they can understand the pattern too. For example:

Some roles describe parent/child relations that occur multiple times in 
language grammar. We define only one role to describe all instances of such 
recurring relations. For example, grammar for both "if" and "while" statements 
requires an opening paren and a closing paren. The opening paren token is 
assigned the `OpenParen` role regardless of whether it appears as a child of 
`IfStatement` or `WhileStatement` node. More generally, when grammar requires a 
certain fixed token (like a specific keyword, or an opening paren), we define a 
role for this token and use it across all grammar rules with the same 
requirement. Names of such reusable roles end with a `~Token` or a `~Keyword` 
suffix.

Some roles are assigned only to child nodes of one specific parent syntax node 
type. Names of such roles start with the name of the parent syntax tree node 
type. For example, a syntax node with a role 
`BinaryOperatorExpression_leftHandSide` can only appear as a child of a 
`BinaryOperatorExpression` node.





Comment at: clang/include/clang/Tooling/Syntax/Nodes.h:124
   IfStatement_thenStatement,
   IfStatement_elseKeyword,
   IfStatement_elseStatement,

Shouldn't `elseKeyword` have no prefix?



Comment at: clang/include/clang/Tooling/Syntax/Nodes.h:133
   TemplateDeclaration_declaration,
   ExplicitTemplateInstantiation_externKeyword,
   ExplicitTemplateInstantiation_declaration,

Shouldn't `externKeyword` have no prefix?



Comment at: clang/include/clang/Tooling/Syntax/Nodes.h:136
   ArraySubscript_sizeExpression,
-  TrailingReturnType_arrow,
+  TrailingReturnType_arrowToken,
   TrailingReturnType_declarator,

Shouldn't `arrowToken` have no prefix?



Comment at: clang/lib/Tooling/Syntax/Nodes.cpp:124
+  case syntax::NodeRole::LiteralToken:
 return OS << "IntegerLiteralExpression_literalToken";
+  case syntax::NodeRole::OperatorExpression_operatorToken:

Please update the textual representations of roles that you renamed, and 
reorder the switch to correspond to the new declaration order.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81157



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


[PATCH] D77168: Add a flag to debug automatic variable initialization

2020-06-04 Thread JF Bastien via Phabricator via cfe-commits
jfb added a comment.

Can you add a test for the diagnostic firing after the correct number of 
initializations? This should include a few types of auto-init, including VLAs.




Comment at: clang/include/clang/Basic/DiagnosticDriverKinds.td:489
+  "-ftrivial-auto-var-init-stop-after=* has been enabled to limit the number 
of times ftrivial-auto-var-init=zero/pattern gets applied.">,
+  InGroup>;
+

I don't think this is sufficiently clear: automatic variable initialization is 
now disabled because ftrivial-auto-var-init-stop-after has reached its limit.



Comment at: clang/lib/CodeGen/CGDecl.cpp:1684
+  if (CGM.stopAutoInit())
+return;
+  if (trivialAutoVarInit == LangOptions::TrivialAutoVarInitKind::Zero)

I'd rather repeat this than fallthrought and repeat the condition in if/else.



Comment at: clang/lib/CodeGen/CodeGenModule.h:1390
+  if (NumAutoVarInit >= StopAfter)
+return true;
+  ++NumAutoVarInit;

The first time this returns true is when the diagnostic should be emitted.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:3092
+  Args.getLastArg(options::OPT_ftrivial_auto_var_init_stop_after)) {
+D.Diag(diag::warn_drv_trivial_auto_var_init_stop_after_enabled);
+A->claim();

Not here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77168



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


[PATCH] D81150: Use libClangTesting in the unittest for AST matchers

2020-06-04 Thread Dmitri Gribenko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb5fc1deb5ba1: Use libClangTesting in the unittest for AST 
matchers (authored by gribozavr).

Changed prior to commit:
  https://reviews.llvm.org/D81150?vs=268440=268495#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81150

Files:
  clang/include/clang/Testing/CommandLineArgs.h
  clang/lib/Testing/CommandLineArgs.cpp
  clang/unittests/ASTMatchers/ASTMatchersInternalTest.cpp
  clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
  clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
  clang/unittests/ASTMatchers/ASTMatchersTest.h
  clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
  clang/unittests/ASTMatchers/CMakeLists.txt
  clang/unittests/ASTMatchers/Dynamic/CMakeLists.txt
  clang/unittests/Sema/CMakeLists.txt

Index: clang/unittests/Sema/CMakeLists.txt
===
--- clang/unittests/Sema/CMakeLists.txt
+++ clang/unittests/Sema/CMakeLists.txt
@@ -18,6 +18,7 @@
   clangParse
   clangSema
   clangSerialization
+  clangTesting
   clangTooling
   )
 
Index: clang/unittests/ASTMatchers/Dynamic/CMakeLists.txt
===
--- clang/unittests/ASTMatchers/Dynamic/CMakeLists.txt
+++ clang/unittests/ASTMatchers/Dynamic/CMakeLists.txt
@@ -17,5 +17,6 @@
   clangDynamicASTMatchers
   clangFrontend
   clangSerialization
+  clangTesting
   clangTooling
   )
Index: clang/unittests/ASTMatchers/CMakeLists.txt
===
--- clang/unittests/ASTMatchers/CMakeLists.txt
+++ clang/unittests/ASTMatchers/CMakeLists.txt
@@ -27,6 +27,7 @@
   clangBasic
   clangFrontend
   clangSerialization
+  clangTesting
   clangTooling
   )
 
Index: clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -951,13 +951,13 @@
   "template\n"
   "int Struct::field = 123;\n";
   EXPECT_TRUE(
-  matches(input, templateTypeParmDecl(hasName("T")), LanguageMode::Cxx14));
+  matches(input, templateTypeParmDecl(hasName("T")), langCxx14OrLater()));
   EXPECT_TRUE(
-  matches(input, templateTypeParmDecl(hasName("T2")), LanguageMode::Cxx14));
+  matches(input, templateTypeParmDecl(hasName("T2")), langCxx14OrLater()));
   EXPECT_TRUE(
-  matches(input, templateTypeParmDecl(hasName("U")), LanguageMode::Cxx14));
+  matches(input, templateTypeParmDecl(hasName("U")), langCxx14OrLater()));
   EXPECT_TRUE(
-  matches(input, templateTypeParmDecl(hasName("U2")), LanguageMode::Cxx14));
+  matches(input, templateTypeParmDecl(hasName("U2")), langCxx14OrLater()));
 }
 
 TEST(TemplateTypeParmDecl, ClassTemplatePartialSpecializationDecl) {
@@ -1487,18 +1487,18 @@
 TEST(Member, MatchesMemberAllocationFunction) {
   // Fails in C++11 mode
   EXPECT_TRUE(matchesConditionally(
-"namespace std { typedef typeof(sizeof(int)) size_t; }"
+  "namespace std { typedef typeof(sizeof(int)) size_t; }"
   "class X { void *operator new(std::size_t); };",
-cxxMethodDecl(ofClass(hasName("X"))), true, "-std=gnu++98"));
+  cxxMethodDecl(ofClass(hasName("X"))), true, {"-std=gnu++03"}));
 
   EXPECT_TRUE(matches("class X { void operator delete(void*); };",
   cxxMethodDecl(ofClass(hasName("X");
 
   // Fails in C++11 mode
   EXPECT_TRUE(matchesConditionally(
-"namespace std { typedef typeof(sizeof(int)) size_t; }"
+  "namespace std { typedef typeof(sizeof(int)) size_t; }"
   "class X { void operator delete[](void*, std::size_t); };",
-cxxMethodDecl(ofClass(hasName("X"))), true, "-std=gnu++98"));
+  cxxMethodDecl(ofClass(hasName("X"))), true, {"-std=gnu++03"}));
 }
 
 TEST(HasDestinationType, MatchesSimpleCase) {
@@ -1542,7 +1542,7 @@
   cxxOperatorCallExpr(hasArgument(
   1, callExpr(hasArgument(
  0, ignoringElidableConstructorCall(callExpr()),
-  LanguageMode::Cxx11OrLater));
+  langCxx11OrLater()));
   EXPECT_TRUE(
   matches("struct H {};"
   "template H B(T A);"
@@ -1553,7 +1553,7 @@
   cxxOperatorCallExpr(hasArgument(
   1, callExpr(hasArgument(0, ignoringElidableConstructorCall(
  integerLiteral()),
-  LanguageMode::Cxx11OrLater));
+  langCxx11OrLater()));
   EXPECT_TRUE(matches(
   "struct H {};"
   "H G();"
@@ -1563,7 +1563,7 @@
   varDecl(hasInitializer(anyOf(
   ignoringElidableConstructorCall(callExpr()),
   exprWithCleanups(has(ignoringElidableConstructorCall(callExpr())),
-  

[PATCH] D80887: [clang-tidy] ignore builtin varargs from pro-type-vararg-check

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

LGTM, thank you for the fixes!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80887



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


[clang] e82e388 - [Doc] update ReleaseNotes with new warning note.

2020-06-04 Thread via cfe-commits

Author: ZequanWu
Date: 2020-06-04T09:45:04-07:00
New Revision: e82e388a493345d8287175f884b34c3f38f71057

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

LOG: [Doc] update ReleaseNotes with new warning note.

Added: 


Modified: 
clang/docs/ReleaseNotes.rst

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 8f9dc81ec0b3..25ff809120de 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -54,6 +54,10 @@ Improvements to Clang's diagnostics
 - -Wpointer-to-int-cast is a new warning group. This group warns about C-style
   casts of pointers to a integer type too small to hold all possible values.
 
+- -Wuninitialized-const-reference is a new warning controlled by 
+  -Wuninitialized. It warns on cases where uninitialized variables are passed
+  as const reference arguments to a function.
+
 Non-comprehensive list of changes in this release
 -
 



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


[PATCH] D81169: [clangd] Improve hover on arguments to function call

2020-06-04 Thread Adam Czachorowski via Phabricator via cfe-commits
adamcz created this revision.
adamcz added a reviewer: kadircet.
Herald added subscribers: cfe-commits, usaxena95, arphaman, jkorous, MaskRay, 
ilya-biryukov.
Herald added a project: clang.

In cases like:

  foo(a, ^b);

We now additionally show the name and type of the parameter to foo that
corresponds that "b" is passed as.

The name should help with understanding what it's used for and type can
be useful to find out if call to foo() can mutate variable "b" or not
(i.e. if it is pass by value, reference, const reference, etc).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81169

Files:
  clang-tools-extra/clangd/Hover.cpp
  clang-tools-extra/clangd/Hover.h
  clang-tools-extra/clangd/unittests/HoverTests.cpp

Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -696,6 +696,51 @@
  HI.Parameters->back().Name = "v";
  HI.AccessSpecifier = "public";
}},
+  {// Extra info for function call.
+   R"cpp(
+  void fun(int arg_a, int _b) {};
+  void code() {
+int a = 1, b = 2;
+fun(a, [[^b]]);
+  }
+  )cpp",
+   [](HoverInfo ) {
+ HI.Name = "b";
+ HI.Kind = index::SymbolKind::Variable;
+ HI.NamespaceScope = "";
+ HI.Definition = "int b = 2";
+ HI.LocalScope = "code::";
+ HI.Value = "2";
+ HI.Type = "int";
+ HI.CalleeArgInfo.emplace();
+ HI.CalleeArgInfo->Name = "arg_b";
+ HI.CalleeArgInfo->Type = "int &";
+   }},
+  {// Extra info for method call.
+   R"cpp(
+  class C {
+   public:
+void fun(int arg_a = 3, int arg_b = 4) {}
+  };
+  void code() {
+int a = 1, b = 2;
+C c;
+c.fun([[^a]], b);
+  }
+  )cpp",
+   [](HoverInfo ) {
+ HI.Name = "a";
+ HI.Kind = index::SymbolKind::Variable;
+ HI.NamespaceScope = "";
+ HI.Definition = "int a = 1";
+ HI.LocalScope = "code::";
+ HI.Value = "1";
+ HI.Type = "int";
+ HI.CalleeArgInfo.emplace();
+ HI.CalleeArgInfo->Name = "arg_a";
+ HI.CalleeArgInfo->Type = "int";
+ HI.CalleeArgInfo->Default = "3";
+   }},
   };
   for (const auto  : Cases) {
 SCOPED_TRACE(Case.Code);
@@ -729,6 +774,7 @@
 EXPECT_EQ(H->Size, Expected.Size);
 EXPECT_EQ(H->Offset, Expected.Offset);
 EXPECT_EQ(H->AccessSpecifier, Expected.AccessSpecifier);
+EXPECT_EQ(H->CalleeArgInfo, Expected.CalleeArgInfo);
   }
 }
 
@@ -2022,6 +2068,29 @@
 
 // In namespace ns1
 private: union foo {})",
+  },
+  {
+  [](HoverInfo ) {
+HI.Kind = index::SymbolKind::Variable;
+HI.Name = "foo";
+HI.Definition = "int foo = 3";
+HI.LocalScope = "test::Bar::";
+HI.Value = "3";
+HI.Type = "int";
+HI.CalleeArgInfo.emplace();
+HI.CalleeArgInfo->Name = "arg_a";
+HI.CalleeArgInfo->Type = "int";
+HI.CalleeArgInfo->Default = "7";
+  },
+  R"(variable foo
+
+Type: int
+Value = 3
+
+// In test::Bar
+int foo = 3
+
+Passed as int arg_a = 7)",
   }};
 
   for (const auto  : Cases) {
Index: clang-tools-extra/clangd/Hover.h
===
--- clang-tools-extra/clangd/Hover.h
+++ clang-tools-extra/clangd/Hover.h
@@ -77,6 +77,9 @@
   llvm::Optional Size;
   /// Contains the offset of fields within the enclosing class.
   llvm::Optional Offset;
+  // Set when symbol is inside function call. Contains information extracted
+  // from the callee definition about the argument this is passed as.
+  llvm::Optional CalleeArgInfo;
 
   /// Produce a user-readable information.
   markup::Document present() const;
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -289,6 +289,26 @@
 : PVD->getDefaultArg();
 }
 
+void fillParam(const ParmVarDecl *PVD, HoverInfo::Param ,
+   const PrintingPolicy ) {
+  if (!PVD->getType().isNull()) {
+Out.Type = printType(PVD->getType(), Policy);
+  } else {
+std::string Param;
+llvm::raw_string_ostream OS(Param);
+PVD->dump(OS);
+OS.flush();
+elog("Got param with null type: {0}", Param);
+  }
+  if (!PVD->getName().empty())
+Out.Name = PVD->getNameAsString();
+  if (const Expr *DefArg = getDefaultArg(PVD)) {
+Out.Default.emplace();
+llvm::raw_string_ostream OS(*Out.Default);
+DefArg->printPretty(OS, nullptr, Policy);
+  }
+}
+
 // Populates Type, ReturnType, and Parameters for function-like decls.
 void 

[PATCH] D81083: [Clang] Allow "vector_size" applied to Booleans

2020-06-04 Thread Simon Moll via Phabricator via cfe-commits
simoll updated this revision to Diff 268488.
simoll added a comment.

- Improved documentation for the size argument of vector_size.
- Rebased


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81083

Files:
  clang/docs/LanguageExtensions.rst
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/TypePrinter.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/CodeGen/CodeGenTypes.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/SemaCXX/vector.cpp

Index: clang/test/SemaCXX/vector.cpp
===
--- clang/test/SemaCXX/vector.cpp
+++ clang/test/SemaCXX/vector.cpp
@@ -331,8 +331,7 @@
 typedef __attribute__((ext_vector_type(4))) int vi4;
 const int _to_vec_element = vi4(1).x;
 
-// PR12649
-typedef bool bad __attribute__((__vector_size__(16)));  // expected-error {{invalid vector element type 'bool'}}
+typedef bool good __attribute__((__vector_size__(16)));
 
 namespace Templates {
 template 
@@ -350,9 +349,7 @@
 void Init() {
   const TemplateVectorType::type Works = {};
   const TemplateVectorType::type Works2 = {};
-  // expected-error@#1 {{invalid vector element type 'bool'}}
-  // expected-note@+1 {{in instantiation of template class 'Templates::TemplateVectorType' requested here}}
-  const TemplateVectorType::type NoBool = {};
+  const TemplateVectorType::type BoolWorks = {};
   // expected-error@#1 {{invalid vector element type 'int __attribute__((ext_vector_type(4)))' (vector of 4 'int' values)}}
   // expected-note@+1 {{in instantiation of template class 'Templates::TemplateVectorType' requested here}}
   const TemplateVectorType::type NoComplex = {};
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -2464,10 +2464,10 @@
 
 QualType Sema::BuildVectorType(QualType CurType, Expr *SizeExpr,
SourceLocation AttrLoc) {
-  // The base type must be integer (not Boolean or enumeration) or float, and
+  // The base type must be boolean or integer (not enumeration) or float, and
   // can't already be a vector.
   if (!CurType->isDependentType() &&
-  (!CurType->isBuiltinType() || CurType->isBooleanType() ||
+  (!CurType->isBuiltinType() ||
(!CurType->isIntegerType() && !CurType->isRealFloatingType( {
 Diag(AttrLoc, diag::err_attribute_invalid_vector_type) << CurType;
 return QualType();
@@ -2496,8 +2496,14 @@
 << SizeExpr->getSourceRange() << "vector";
 return QualType();
   }
-  uint64_t VectorSizeBits = VecSize.getZExtValue() * 8;
-  unsigned TypeSize = static_cast(Context.getTypeSize(CurType));
+
+  uint64_t VectorSizeBits =
+  CurType->isBooleanType()
+  ? VecSize.getZExtValue()
+  : VecSize.getZExtValue() * 8; // FIXME "bitsof(CharUnit)"
+  unsigned TypeSize = CurType->isBooleanType()
+  ? 1
+  : static_cast(Context.getTypeSize(CurType));
 
   if (VectorSizeBits == 0) {
 Diag(AttrLoc, diag::err_attribute_zero_size)
@@ -7549,13 +7555,13 @@
   T = Context.getAdjustedType(T, Wrapped);
 }
 
-/// HandleVectorSizeAttribute - this attribute is only applicable to integral
-/// and float scalars, although arrays, pointers, and function return values are
-/// allowed in conjunction with this construct. Aggregates with this attribute
-/// are invalid, even if they are of the same size as a corresponding scalar.
-/// The raw attribute should contain precisely 1 argument, the vector size for
-/// the variable, measured in bytes. If curType and rawAttr are well formed,
-/// this routine will return a new vector type.
+/// HandleVectorSizeAttribute - this attribute is only applicable to boolean,
+/// integral and float scalars, although arrays, pointers, and function return
+/// values are allowed in conjunction with this construct. Aggregates with this
+/// attribute are invalid, even if they are of the same size as a corresponding
+/// scalar. The raw attribute should contain precisely 1 argument, the vector
+/// size for the variable, measured in bytes. If curType and rawAttr are well
+/// formed, this routine will return a new vector type.
 static void HandleVectorSizeAttr(QualType , const ParsedAttr ,
  Sema ) {
   // Check the attribute arguments.
Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -5947,7 +5947,8 @@
   } else if (LHSVT || RHSVT) {
 ResultType = CheckVectorOperands(
 LHS, RHS, QuestionLoc, 

[clang] b5fc1de - Use libClangTesting in the unittest for AST matchers

2020-06-04 Thread Dmitri Gribenko via cfe-commits

Author: Dmitri Gribenko
Date: 2020-06-04T17:40:39+02:00
New Revision: b5fc1deb5ba1f3cd432ecb8b86c2536470463163

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

LOG: Use libClangTesting in the unittest for AST matchers

Summary:
The unittest for AST matchers has its own way to specify language
standards. I unified it with the shared infrastructure from
libClangTesting.

Reviewers: jdoerfert, hlopko

Reviewed By: hlopko

Subscribers: mgorny, sstefan1, cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/include/clang/Testing/CommandLineArgs.h
clang/lib/Testing/CommandLineArgs.cpp
clang/unittests/ASTMatchers/ASTMatchersInternalTest.cpp
clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
clang/unittests/ASTMatchers/ASTMatchersTest.h
clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
clang/unittests/ASTMatchers/CMakeLists.txt
clang/unittests/ASTMatchers/Dynamic/CMakeLists.txt
clang/unittests/Sema/CMakeLists.txt

Removed: 




diff  --git a/clang/include/clang/Testing/CommandLineArgs.h 
b/clang/include/clang/Testing/CommandLineArgs.h
index 432a112b2e15..95979a2bfb80 100644
--- a/clang/include/clang/Testing/CommandLineArgs.h
+++ b/clang/include/clang/Testing/CommandLineArgs.h
@@ -13,6 +13,8 @@
 #ifndef LLVM_CLANG_TESTING_COMMANDLINEARGS_H
 #define LLVM_CLANG_TESTING_COMMANDLINEARGS_H
 
+#include "clang/Basic/LLVM.h"
+#include "llvm/ADT/StringRef.h"
 #include 
 #include 
 
@@ -32,6 +34,8 @@ enum TestLanguage {
 
 std::vector getCommandLineArgsForTesting(TestLanguage Lang);
 
+StringRef getFilenameForTesting(TestLanguage Lang);
+
 } // end namespace clang
 
 #endif

diff  --git a/clang/lib/Testing/CommandLineArgs.cpp 
b/clang/lib/Testing/CommandLineArgs.cpp
index 1d12187494be..7375dbc6ee70 100644
--- a/clang/lib/Testing/CommandLineArgs.cpp
+++ b/clang/lib/Testing/CommandLineArgs.cpp
@@ -45,4 +45,25 @@ std::vector 
getCommandLineArgsForTesting(TestLanguage Lang) {
   return Args;
 }
 
+StringRef getFilenameForTesting(TestLanguage Lang) {
+  switch (Lang) {
+  case Lang_C89:
+  case Lang_C99:
+return "input.c";
+
+  case Lang_CXX03:
+  case Lang_CXX11:
+  case Lang_CXX14:
+  case Lang_CXX17:
+  case Lang_CXX20:
+return "input.cc";
+
+  case Lang_OpenCL:
+return "input.cl";
+
+  case Lang_OBJCXX:
+return "input.mm";
+  }
+}
+
 } // end namespace clang

diff  --git a/clang/unittests/ASTMatchers/ASTMatchersInternalTest.cpp 
b/clang/unittests/ASTMatchers/ASTMatchersInternalTest.cpp
index 2886481ea262..2354f45de409 100644
--- a/clang/unittests/ASTMatchers/ASTMatchersInternalTest.cpp
+++ b/clang/unittests/ASTMatchers/ASTMatchersInternalTest.cpp
@@ -212,18 +212,18 @@ TEST(Matcher, IsExpansionInMainFileMatcher) {
   M.push_back(std::make_pair("/other", "class X {};"));
   EXPECT_TRUE(matchesConditionally("#include \n",
recordDecl(isExpansionInMainFile()), false,
-   "-isystem/", M));
+   {"-isystem/"}, M));
 }
 
 TEST(Matcher, IsExpansionInSystemHeader) {
   FileContentMappings M;
   M.push_back(std::make_pair("/other", "class X {};"));
-  EXPECT_TRUE(matchesConditionally(
-  "#include \"other\"\n", recordDecl(isExpansionInSystemHeader()), true,
-  "-isystem/", M));
   EXPECT_TRUE(matchesConditionally("#include \"other\"\n",
recordDecl(isExpansionInSystemHeader()),
-   false, "-I/", M));
+   true, {"-isystem/"}, M));
+  EXPECT_TRUE(matchesConditionally("#include \"other\"\n",
+   recordDecl(isExpansionInSystemHeader()),
+   false, {"-I/"}, M));
   EXPECT_TRUE(notMatches("class X {};",
  recordDecl(isExpansionInSystemHeader(;
   EXPECT_TRUE(notMatches("", recordDecl(isExpansionInSystemHeader(;
@@ -238,13 +238,13 @@ TEST(Matcher, IsExpansionInFileMatching) {
   "#include \n"
   "class X {};",
   recordDecl(isExpansionInFileMatching("b.*"), hasName("B")), true,
-  "-isystem/", M));
+  {"-isystem/"}, M));
   EXPECT_TRUE(matchesConditionally(
   "#include \n"
   "#include \n"
   "class X {};",
   recordDecl(isExpansionInFileMatching("f.*"), hasName("X")), false,
-  "-isystem/", M));
+  {"-isystem/"}, M));
 }
 
 #endif // _WIN32

diff  --git a/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp 
b/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
index 80eebf227a31..fa5c61eece29 100644
--- a/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ 

[PATCH] D80804: [AMDGPU] Introduce Clang builtins to be mapped to AMDGCN atomic inc/dec intrinsics

2020-06-04 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added inline comments.



Comment at: clang/include/clang/Basic/BuiltinsAMDGPU.def:62-63
 BUILTIN(__builtin_amdgcn_fence, "vUicC*", "n")
+BUILTIN(__builtin_amdgcn_atomic_inc, "iiD*iUicC*", "n")
+BUILTIN(__builtin_amdgcn_atomic_dec, "iiD*iUicC*", "n")
 

My main concern is we should probably have both 32 and 64-bit variants


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80804



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


[PATCH] D81168: Add support for id-expression in SyntaxTree

2020-06-04 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas added a subscriber: gribozavr2.
eduucaldas marked an inline comment as done.
eduucaldas added inline comments.



Comment at: clang/unittests/Tooling/Syntax/TreeTest.cpp:829
+| | | | | `-::
+| | | | `-TypeSpecifier
+| | | |   |-S

Perhaps we shouldn't differ between specifiers as that is semantical information


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81168



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


[PATCH] D80947: Add to the Coding Standard our that single-line bodies omit braces

2020-06-04 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast accepted this revision.
hubert.reinterpretcast added a comment.
This revision is now accepted and ready to land.

This LGTM. I believe we have not heard back from @arsenm on the response to 
some of their comments though.




Comment at: llvm/docs/CodingStandards.rst:1603
+
+  // This should also omit braces.  The for loop contains only a single 
statement,
+  // so it shouldn't have braces.  The if also only contains a single 
statement (the

erichkeane wrote:
> arsenm wrote:
> > This loop should use braces. It covers multiple lines. Omitting braces 
> > invariably just increases diffs/merge conflicts when something else is 
> > added to the loop body.
> > 
> > This one isn't consistently applied and I've been enforcing the opposite
> This is how we've been enforcing the rule however, can you suggest a change 
> to the wording that you think would match our current enforcement?
Much as it may be seen to be "ideal" that conventions are uniform throughout 
the project, it is the case that different areas of the code have somewhat of a 
local convention. The example may lean towards not using braces as the general 
case, but the wording was done so that areas of code where the observed 
increase in diffs/merge conflicts occur frequently can use and enforce braces 
because said occurrences would be indicative of harm caused by the omission of 
braces.


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

https://reviews.llvm.org/D80947



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


[PATCH] D81083: [Clang] Allow "vector_size" applied to Booleans

2020-06-04 Thread Simon Moll via Phabricator via cfe-commits
simoll marked an inline comment as done.
simoll added inline comments.



Comment at: clang/docs/LanguageExtensions.rst:473
+architectures.  The size parameter of a boolean vector type is the number of
+bits in the vector (for all non-bool vectors, the number refers to the number
+of bytes in the vector).

lenary wrote:
> It would be nice if this aside about non-bool vectors was more prominently 
> displayed - it's something I hadn't realised before.
Yep. that caught me by surprise too. I'll move that sentence to the paragraph 
about GCC vectors above.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81083



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


[clang] 62305f6 - Rename arrow -> arrowToken for unified naming

2020-06-04 Thread Dmitri Gribenko via cfe-commits

Author: Eduardo Caldas
Date: 2020-06-04T16:12:16+02:00
New Revision: 62305f6db4ed642c6b2b005dcb7951eb38342dca

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

LOG: Rename arrow -> arrowToken for unified naming

Reviewers: gribozavr2

Reviewed By: gribozavr2

Subscribers: cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/include/clang/Tooling/Syntax/Nodes.h
clang/lib/Tooling/Syntax/Nodes.cpp

Removed: 




diff  --git a/clang/include/clang/Tooling/Syntax/Nodes.h 
b/clang/include/clang/Tooling/Syntax/Nodes.h
index bf0308c95ba4..7d0c4439e279 100644
--- a/clang/include/clang/Tooling/Syntax/Nodes.h
+++ b/clang/include/clang/Tooling/Syntax/Nodes.h
@@ -639,7 +639,7 @@ class TrailingReturnType final : public Tree {
 return N->kind() == NodeKind::TrailingReturnType;
   }
   // TODO: add accessors for specifiers.
-  syntax::Leaf *arrow();
+  syntax::Leaf *arrowToken();
   syntax::SimpleDeclarator *declarator();
 };
 

diff  --git a/clang/lib/Tooling/Syntax/Nodes.cpp 
b/clang/lib/Tooling/Syntax/Nodes.cpp
index d70b89b07200..bad902b8c6d7 100644
--- a/clang/lib/Tooling/Syntax/Nodes.cpp
+++ b/clang/lib/Tooling/Syntax/Nodes.cpp
@@ -400,7 +400,7 @@ syntax::Leaf *syntax::ArraySubscript::rbracket() {
   findChild(syntax::NodeRole::CloseParen));
 }
 
-syntax::Leaf *syntax::TrailingReturnType::arrow() {
+syntax::Leaf *syntax::TrailingReturnType::arrowToken() {
   return llvm::cast_or_null(
   findChild(syntax::NodeRole::TrailingReturnType_arrow));
 }



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


[clang] 9520bf1 - [clang-format] Update GoogleStyle for C# code to match Google's internal C# style guide

2020-06-04 Thread Jonathan Coe via cfe-commits

Author: Jonathan Coe
Date: 2020-06-04T15:48:00+01:00
New Revision: 9520bf146dd3baae8608755d7de0855db4664c77

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

LOG: [clang-format] Update GoogleStyle for C# code to match Google's internal 
C# style guide

Summary: Google's C# style guide is at 
https://google.github.io/styleguide/csharp-style.html

Reviewers: krasimir, MyDeveloperDay, sammccall

Reviewed By: MyDeveloperDay

Subscribers: cfe-commits, klimek

Tags: #clang-format, #clang

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

Added: 


Modified: 
clang/lib/Format/Format.cpp
clang/unittests/Format/FormatTestCSharp.cpp

Removed: 




diff  --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index f3743921d52e..1f7a8029bac0 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -14,6 +14,7 @@
 
 #include "clang/Format/Format.h"
 #include "AffectedRangeManager.h"
+#include "BreakableToken.h"
 #include "ContinuationIndenter.h"
 #include "FormatInternal.h"
 #include "FormatTokenLexer.h"
@@ -1068,6 +1069,12 @@ FormatStyle getGoogleStyle(FormatStyle::LanguageKind 
Language) {
 // #imports, etc.)
 GoogleStyle.IncludeStyle.IncludeBlocks =
 tooling::IncludeStyle::IBS_Preserve;
+  } else if (Language == FormatStyle::LK_CSharp) {
+GoogleStyle.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Empty;
+GoogleStyle.AllowShortIfStatementsOnASingleLine = FormatStyle::SIS_Never;
+GoogleStyle.BreakStringLiterals = false;
+GoogleStyle.ColumnLimit = 100;
+GoogleStyle.NamespaceIndentation = FormatStyle::NI_All;
   }
 
   return GoogleStyle;

diff  --git a/clang/unittests/Format/FormatTestCSharp.cpp 
b/clang/unittests/Format/FormatTestCSharp.cpp
index 5567e19e5bdd..dd2ed292ccd8 100644
--- a/clang/unittests/Format/FormatTestCSharp.cpp
+++ b/clang/unittests/Format/FormatTestCSharp.cpp
@@ -583,8 +583,7 @@ TEST_F(FormatTestCSharp, CSharpNamedArguments) {
   FormatStyle Style = getGoogleStyle(FormatStyle::LK_CSharp);
 
   verifyFormat(R"(//
-PrintOrderDetails(orderNum: 31, productName: "Red Mug",
-  sellerName: "Gift Shop");)",
+PrintOrderDetails(orderNum: 31, productName: "Red Mug", sellerName: "Gift 
Shop");)",
Style);
 
   // Ensure that trailing comments do not cause problems.
@@ -641,8 +640,7 @@ class TimePeriod {
 get { return _seconds / 3600; }
 set {
   if (value < 0 || value > 24)
-throw new ArgumentOutOfRangeException(
-$"{nameof(value)} must be between 0 and 24.");
+throw new ArgumentOutOfRangeException($"{nameof(value)} must be 
between 0 and 24.");
   _seconds = value * 3600;
 }
   }
@@ -755,7 +753,9 @@ TEST_F(FormatTestCSharp, CSharpNullableTypes) {
 
   verifyFormat(R"(//
 public class A {
-  void foo() { int? value = some.bar(); }
+  void foo() {
+int? value = some.bar();
+  }
 })",
Style); // int? is nullable not a conditional expression.
 
@@ -800,16 +800,15 @@ class Dictionary
 where TKey : IComparable
 where TVal : IMyInterface {
   public void MyMethod(T t)
-  where T : IMyInterface { doThing(); }
+  where T : IMyInterface {
+doThing();
+  }
 })",
Style);
 
   verifyFormat(R"(//
 class ItemFactory
-where T : new(),
-  IAnInterface,
-  IAnotherInterface,
-  IAnotherInterfaceStill {})",
+where T : new(), IAnInterface, IAnotherInterface, 
IAnotherInterfaceStill {})",
Style);
 
   Style.ColumnLimit = 50; // Force lines to be wrapped.



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


[PATCH] D80735: [OpenMP][NFC] Reuse OMPIRBuilder `struct ident_t` handling in Clang

2020-06-04 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added a comment.

Here's one of the stack traces. Calling `InternalOMPBuilder.initialize()` is 
what triggers it to start failing, which is confusing because all that function 
does is initialize the named types from OMPConstants, which should be working 
or else the old solution wouldn't work. Unless the compiler is just straight up 
optimizing out the Irbuilder without the initialize call which I find highly 
unlikely.

   #0 0x7fc6b112701a llvm::sys::PrintStackTrace(llvm::raw_ostream&) 
(/home/jhuber/Documents/llvm-project/build/bin/../lib/libLLVMSupport.so.11git+0x1b301a)
   #1 0x7fc6b1124e54 llvm::sys::RunSignalHandlers() 
(/home/jhuber/Documents/llvm-project/build/bin/../lib/libLLVMSupport.so.11git+0x1b0e54)
   #2 0x7fc6b1124f98 SignalHandler(int) 
(/home/jhuber/Documents/llvm-project/build/bin/../lib/libLLVMSupport.so.11git+0x1b0f98)
   #3 0x7fc6b517f800 __restore_rt (/usr/lib/libpthread.so.0+0x14800)
   #4 0x7fc6b0aa0ce5 raise (/usr/lib/libc.so.6+0x3bce5)
   #5 0x7fc6b0a8a857 abort (/usr/lib/libc.so.6+0x25857)
   #6 0x7fc6b0a8a727 _nl_load_domain.cold (/usr/lib/libc.so.6+0x25727)
   #7 0x7fc6b0a99426 (/usr/lib/libc.so.6+0x34426)
   #8 0x7fc6b148c223 llvm::CallInst::init(llvm::FunctionType*, 
llvm::Value*, llvm::ArrayRef, 
llvm::ArrayRef >, llvm::Twine const&) 
(/home/jhuber/Documents/llvm-project/build/bin/../lib/libLLVMCore.so.11git+0x1ce223)
   #9 0x7fc6b41dc007 llvm::IRBuilderBase::CreateCall(llvm::FunctionType*, 
llvm::Value*, llvm::ArrayRef, 
llvm::ArrayRef >, llvm::Twine const&, 
llvm::MDNode*) 
(/home/jhuber/Documents/llvm-project/build/bin/../lib/libclangCodeGen.so.11git+0x1c3007)
  #10 0x7fc6b41eb3d6 
clang::CodeGen::CodeGenFunction::EmitRuntimeCall(llvm::FunctionCallee, 
llvm::ArrayRef, llvm::Twine const&) 
(/home/jhuber/Documents/llvm-project/build/bin/../lib/libclangCodeGen.so.11git+0x1d23d6)
  #11 0x7fc6b43acbf0 
clang::CodeGen::CGOpenMPRuntime::emitTaskInit(clang::CodeGen::CodeGenFunction&, 
clang::SourceLocation, clang::OMPExecutableDirective const&, llvm::Function*, 
clang::QualType, clang::CodeGen::Address, clang::CodeGen::OMPTaskDataTy const&) 
(/home/jhuber/Documents/llvm-project/build/bin/../lib/libclangCodeGen.so.11git+0x393bf0)
  #12 0x7fc6b43afb67 
clang::CodeGen::CGOpenMPRuntime::emitTaskCall(clang::CodeGen::CodeGenFunction&, 
clang::SourceLocation, clang::OMPExecutableDirective const&, llvm::Function*, 
clang::QualType, clang::CodeGen::Address, clang::Expr const*, 
clang::CodeGen::OMPTaskDataTy const&) 
(/home/jhuber/Documents/llvm-project/build/bin/../lib/libclangCodeGen.so.11git+0x396b67)
  #13 0x7fc6b43ff10d void llvm::function_ref::callback_fn(long, clang::CodeGen::CodeGenFunction&, 
llvm::Function*, clang::CodeGen::OMPTaskDataTy const&) 
(/home/jhuber/Documents/llvm-project/build/bin/../lib/libclangCodeGen.so.11git+0x3e610d)
  #14 0x7fc6b442facb 
clang::CodeGen::CodeGenFunction::EmitOMPTaskBasedDirective(clang::OMPExecutableDirective
 const&, llvm::omp::Directive, clang::CodeGen::RegionCodeGenTy const&, 
llvm::function_ref const&, clang::CodeGen::OMPTaskDataTy&) 
(/home/jhuber/Documents/llvm-project/build/bin/../lib/libclangCodeGen.so.11git+0x416acb)
  #15 0x7fc6b443034b 
clang::CodeGen::CodeGenFunction::EmitOMPTaskDirective(clang::OMPTaskDirective 
const&) 
(/home/jhuber/Documents/llvm-project/build/bin/../lib/libclangCodeGen.so.11git+0x41734b)
  #16 0x7fc6b43f9b73 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt 
const*, llvm::ArrayRef) 
(/home/jhuber/Documents/llvm-project/build/bin/../lib/libclangCodeGen.so.11git+0x3e0b73)
  #17 0x7fc6b43f9fd4 
clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt
 const&, bool, clang::CodeGen::AggValueSlot) 
(/home/jhuber/Documents/llvm-project/build/bin/../lib/libclangCodeGen.so.11git+0x3e0fd4)
  #18 0x7fc6b43fa3cf 
clang::CodeGen::CodeGenFunction::EmitCompoundStmt(clang::CompoundStmt const&, 
bool, clang::CodeGen::AggValueSlot) 
(/home/jhuber/Documents/llvm-project/build/bin/../lib/libclangCodeGen.so.11git+0x3e13cf)
  #19 0x7fc6b43fde5f 
clang::CodeGen::CodeGenFunction::EmitSimpleStmt(clang::Stmt const*) 
(/home/jhuber/Documents/llvm-project/build/bin/../lib/libclangCodeGen.so.11git+0x3e4e5f)
  #20 0x7fc6b43f97f2 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt 
const*, llvm::ArrayRef) 
(/home/jhuber/Documents/llvm-project/build/bin/../lib/libclangCodeGen.so.11git+0x3e07f2)
  #21 0x7fc6b4402811 emitBody(clang::CodeGen::CodeGenFunction&, clang::Stmt 
const*, clang::Stmt const*, int, int) 
(/home/jhuber/Documents/llvm-project/build/bin/../lib/libclangCodeGen.so.11git+0x3e9811)
  #22 0x7fc6b440ce23 
clang::CodeGen::CodeGenFunction::EmitOMPLoopBody(clang::OMPLoopDirective 
const&, clang::CodeGen::CodeGenFunction::JumpDest) 
(/home/jhuber/Documents/llvm-project/build/bin/../lib/libclangCodeGen.so.11git+0x3f3e23)
  #23 0x7fc6b440d180 void llvm::function_ref::callback_fn 

[PATCH] D80900: [clangd] Use different FS in PreambleThread

2020-06-04 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

In D80900#2071207 , @sammccall wrote:

> That makes sense. However I don't think that contract is conceptually that 
> great, having the ideas of "threadsafe FS" and "maybe-context-aware FS" 
> coupled together is... weird. The benefit is that it's an easier contract to 
> satisfy.
>
> It's already the case that the context could/should be plumbed through to the 
> actual FS operations and other extension points. Things like tracing rely on 
> it. I think saying "we always plumb context through to everything" is a 
> better contract even if it's a bit stronger than we need and harder to prove 
> satisfied. This frees up FileSystemProvider to be the conceptually-simple 
> ThreadsafeFS that could be lifted from clangd/support to llvm/support if we 
> want.
>
> WDYT?


Did that in D81173 , there were two issues:

- Sometimes we create ParseInputs without an access to an FSProvider, overcome 
this one with a helper that wraps a VFS and returns an FSProvider for it.
- TestTU::inputs() needs to return a ParseInputs, but it is unclear which 
FSProvider it should point to :/ make it a parameter to the function. Since it 
needs to out-live the returned ParseInputs.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80900



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


[PATCH] D79895: Add a new warning to warn when passing uninitialized variables as const reference parameters to a function

2020-06-04 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu added a comment.

In D79895#2073698 , @sylvestre.ledru 
wrote:

> @zequanwu could you please update the release notes? thanks
>  https://github.com/llvm/llvm-project/blob/master/clang/docs/ReleaseNotes.rst


Done.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79895



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


[PATCH] D80536: [clang-tidy][modernize-loop-convert] Make loop var type human readable

2020-06-04 Thread Zinovy Nis via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6271b96bef47: [clang-tidy][modernize-loop-convert] Make loop 
var type human readable (authored by zinovy.nis).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80536

Files:
  clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/modernize-loop-convert/structures.h


Index: 
clang-tools-extra/test/clang-tidy/checkers/Inputs/modernize-loop-convert/structures.h
===
--- 
clang-tools-extra/test/clang-tidy/checkers/Inputs/modernize-loop-convert/structures.h
+++ 
clang-tools-extra/test/clang-tidy/checkers/Inputs/modernize-loop-convert/structures.h
@@ -40,13 +40,14 @@
 };
 
 struct T {
+  typedef int value_type;
   struct iterator {
-int& operator*();
-const int& operator*()const;
+value_type *();
+const value_type *() const;
 iterator& operator ++();
 bool operator!=(const iterator );
-void insert(int);
-int X;
+void insert(value_type);
+value_type X;
   };
   iterator begin();
   iterator end();
Index: clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
===
--- clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
+++ clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
@@ -621,6 +621,7 @@
   QualType Type = Context->getAutoDeductType();
   if (!Descriptor.ElemType.isNull() && 
Descriptor.ElemType->isFundamentalType())
 Type = Descriptor.ElemType.getUnqualifiedType();
+  Type = Type.getDesugaredType(*Context);
 
   // If the new variable name is from the aliased variable, then the reference
   // type for the new variable should only be used if the aliased variable was


Index: clang-tools-extra/test/clang-tidy/checkers/Inputs/modernize-loop-convert/structures.h
===
--- clang-tools-extra/test/clang-tidy/checkers/Inputs/modernize-loop-convert/structures.h
+++ clang-tools-extra/test/clang-tidy/checkers/Inputs/modernize-loop-convert/structures.h
@@ -40,13 +40,14 @@
 };
 
 struct T {
+  typedef int value_type;
   struct iterator {
-int& operator*();
-const int& operator*()const;
+value_type *();
+const value_type *() const;
 iterator& operator ++();
 bool operator!=(const iterator );
-void insert(int);
-int X;
+void insert(value_type);
+value_type X;
   };
   iterator begin();
   iterator end();
Index: clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
===
--- clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
+++ clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
@@ -621,6 +621,7 @@
   QualType Type = Context->getAutoDeductType();
   if (!Descriptor.ElemType.isNull() && Descriptor.ElemType->isFundamentalType())
 Type = Descriptor.ElemType.getUnqualifiedType();
+  Type = Type.getDesugaredType(*Context);
 
   // If the new variable name is from the aliased variable, then the reference
   // type for the new variable should only be used if the aliased variable was
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D81168: Add support for id-expression in SyntaxTree

2020-06-04 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 added inline comments.



Comment at: clang/unittests/Tooling/Syntax/TreeTest.cpp:815
+| |   `-UnknownExpression
+| | `-s
+| `-;

This part does not seem to appear in the source.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81168



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


[PATCH] D80936: [OPENMP]Fix PR46146: Do not consider globalized variables as NRVO candidates.

2020-06-04 Thread Alexey Bataev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9ca5a6d3b523: [OPENMP]Fix PR46146: Do not consider 
globalized variables as NRVO candidates. (authored by ABataev).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80936

Files:
  clang/lib/CodeGen/CGStmt.cpp
  clang/test/OpenMP/nvptx_NRVO_variable.cpp


Index: clang/test/OpenMP/nvptx_NRVO_variable.cpp
===
--- /dev/null
+++ clang/test/OpenMP/nvptx_NRVO_variable.cpp
@@ -0,0 +1,30 @@
+// Test target codegen - host bc file has to be created first.
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown 
-fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device 
-fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+
+struct S {
+  int a;
+  S() : a(1) {}
+};
+
+#pragma omp declare target
+void bar(S &);
+// CHECK-LABEL: foo
+S foo() {
+  // CHECK: [[RETVAL:%.+]] = alloca %struct.S,
+  S s;
+  // CHECK: call void @{{.+}}bar{{.+}}(%struct.S* {{.*}}[[S_REF:%.+]])
+  bar(s);
+  // CHECK: [[DEST:%.+]] = bitcast %struct.S* [[RETVAL]] to i8*
+  // CHECK: [[SOURCE:%.+]] = bitcast %struct.S* [[S_REF]] to i8*
+  // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* {{.*}}[[DEST]], i8* 
{{.*}}[[SOURCE]], i64 4, i1 false)
+  // CHECK: [[VAL:%.+]] = load %struct.S, %struct.S* [[RETVAL]],
+  // CHECK: ret %struct.S [[VAL]]
+  return s;
+}
+#pragma omp end declare target
+
+#endif
Index: clang/lib/CodeGen/CGStmt.cpp
===
--- clang/lib/CodeGen/CGStmt.cpp
+++ clang/lib/CodeGen/CGStmt.cpp
@@ -11,6 +11,7 @@
 
//===--===//
 
 #include "CGDebugInfo.h"
+#include "CGOpenMPRuntime.h"
 #include "CodeGenFunction.h"
 #include "CodeGenModule.h"
 #include "TargetInfo.h"
@@ -1106,8 +1107,13 @@
 
   // FIXME: Clean this up by using an LValue for ReturnTemp,
   // EmitStoreThroughLValue, and EmitAnyExpr.
-  if (getLangOpts().ElideConstructors &&
-  S.getNRVOCandidate() && S.getNRVOCandidate()->isNRVOVariable()) {
+  // Check if the NRVO candidate was not globalized in OpenMP mode.
+  if (getLangOpts().ElideConstructors && S.getNRVOCandidate() &&
+  S.getNRVOCandidate()->isNRVOVariable() &&
+  (!getLangOpts().OpenMP ||
+   !CGM.getOpenMPRuntime()
+.getAddressOfLocalVariable(*this, S.getNRVOCandidate())
+.isValid())) {
 // Apply the named return value optimization for this return statement,
 // which means doing nothing: the appropriate result has already been
 // constructed into the NRVO variable.


Index: clang/test/OpenMP/nvptx_NRVO_variable.cpp
===
--- /dev/null
+++ clang/test/OpenMP/nvptx_NRVO_variable.cpp
@@ -0,0 +1,30 @@
+// Test target codegen - host bc file has to be created first.
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+
+struct S {
+  int a;
+  S() : a(1) {}
+};
+
+#pragma omp declare target
+void bar(S &);
+// CHECK-LABEL: foo
+S foo() {
+  // CHECK: [[RETVAL:%.+]] = alloca %struct.S,
+  S s;
+  // CHECK: call void @{{.+}}bar{{.+}}(%struct.S* {{.*}}[[S_REF:%.+]])
+  bar(s);
+  // CHECK: [[DEST:%.+]] = bitcast %struct.S* [[RETVAL]] to i8*
+  // CHECK: [[SOURCE:%.+]] = bitcast %struct.S* [[S_REF]] to i8*
+  // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* {{.*}}[[DEST]], i8* {{.*}}[[SOURCE]], i64 4, i1 false)
+  // CHECK: [[VAL:%.+]] = load %struct.S, %struct.S* [[RETVAL]],
+  // CHECK: ret %struct.S [[VAL]]
+  return s;
+}
+#pragma omp end declare target
+
+#endif
Index: clang/lib/CodeGen/CGStmt.cpp
===
--- clang/lib/CodeGen/CGStmt.cpp
+++ clang/lib/CodeGen/CGStmt.cpp
@@ -11,6 +11,7 @@
 //===--===//
 
 #include "CGDebugInfo.h"
+#include "CGOpenMPRuntime.h"
 #include "CodeGenFunction.h"
 #include "CodeGenModule.h"
 #include "TargetInfo.h"
@@ -1106,8 +1107,13 @@
 
   // FIXME: Clean this up by using an LValue for ReturnTemp,
   // EmitStoreThroughLValue, and EmitAnyExpr.
-  if (getLangOpts().ElideConstructors &&
-  S.getNRVOCandidate() && S.getNRVOCandidate()->isNRVOVariable()) {
+  // Check if the 

[PATCH] D81157: Propose naming principle for NodeRole and apply it

2020-06-04 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 added inline comments.



Comment at: clang/include/clang/Tooling/Syntax/Nodes.h:124
   IfStatement_thenStatement,
   IfStatement_elseKeyword,
   IfStatement_elseStatement,

eduucaldas wrote:
> gribozavr2 wrote:
> > Shouldn't `elseKeyword` have no prefix?
> When a keyword can only be used by IfStatement, then I think it actually 
> helps readability to have it prepended with the ParentKind. Here everything 
> is nicely grouped, and if someone needs to change IfStatement, it is clear to 
> see where to make the change.
OK, makes sense.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81157



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


[PATCH] D81150: Use libClangTesting in the unittest for AST matchers

2020-06-04 Thread Nathan James via Phabricator via cfe-commits
njames93 added inline comments.



Comment at: clang/unittests/ASTMatchers/ASTMatchersTest.h:62
+inline ArrayRef langCxx11OrLater() {
+  static std::vector Result = {Lang_CXX11, Lang_CXX14, 
Lang_CXX17,
+ Lang_CXX20};

Bit late, but surely these should have been const arrays instead of vectors.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81150



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


[PATCH] D80752: [AArch64]: BFloat MatMul Intrinsics

2020-06-04 Thread Luke Geeson via Phabricator via cfe-commits
LukeGeeson updated this revision to Diff 268520.
LukeGeeson added a comment.

- used `update_cc_test_checks.py` to generate correct checks


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

https://reviews.llvm.org/D80752

Files:
  clang/include/clang/Basic/arm_neon.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/aarch64-bf16-dotprod-intrinsics.c
  llvm/include/llvm/IR/IntrinsicsAArch64.td
  llvm/lib/Target/AArch64/AArch64InstrFormats.td
  llvm/lib/Target/AArch64/AArch64InstrInfo.td
  llvm/test/CodeGen/AArch64/aarch64-bf16-dotprod-intrinsics.ll

Index: llvm/test/CodeGen/AArch64/aarch64-bf16-dotprod-intrinsics.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/aarch64-bf16-dotprod-intrinsics.ll
@@ -0,0 +1,180 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple aarch64-arm-none-eabi  -mattr=+bf16 %s -o - | FileCheck %s
+
+define <2 x float> @test_vbfdot_f32(<2 x float> %r, <4 x bfloat> %a, <4 x bfloat> %b) {
+; CHECK-LABEL: test_vbfdot_f32:
+; CHECK:   // %bb.0: // %entry
+; CHECK-NEXT:bfdot v0.2s, v1.4h, v2.4h
+; CHECK-NEXT:ret
+entry:
+  %0 = bitcast <4 x bfloat> %a to <8 x i8>
+  %1 = bitcast <4 x bfloat> %b to <8 x i8>
+  %vbfdot1.i = tail call <2 x float> @llvm.aarch64.neon.bfdot.v2f32.v8i8(<2 x float> %r, <8 x i8> %0, <8 x i8> %1)
+  ret <2 x float> %vbfdot1.i
+}
+
+define <4 x float> @test_vbfdotq_f32(<4 x float> %r, <8 x bfloat> %a, <8 x bfloat> %b) {
+; CHECK-LABEL: test_vbfdotq_f32:
+; CHECK:   // %bb.0: // %entry
+; CHECK-NEXT:bfdot v0.4s, v1.8h, v2.8h
+; CHECK-NEXT:ret
+entry:
+  %0 = bitcast <8 x bfloat> %a to <16 x i8>
+  %1 = bitcast <8 x bfloat> %b to <16 x i8>
+  %vbfdot1.i = tail call <4 x float> @llvm.aarch64.neon.bfdot.v4f32.v16i8(<4 x float> %r, <16 x i8> %0, <16 x i8> %1)
+  ret <4 x float> %vbfdot1.i
+}
+
+define <2 x float> @test_vbfdot_lane_f32(<2 x float> %r, <4 x bfloat> %a, <4 x bfloat> %b) {
+; CHECK-LABEL: test_vbfdot_lane_f32:
+; CHECK:   // %bb.0: // %entry
+; CHECK-NEXT:// kill: def $d2 killed $d2 def $q2
+; CHECK-NEXT:bfdot v0.2s, v1.4h, v2.2h[0]
+; CHECK-NEXT:ret
+entry:
+  %0 = bitcast <4 x bfloat> %b to <2 x float>
+  %shuffle = shufflevector <2 x float> %0, <2 x float> undef, <2 x i32> zeroinitializer
+  %1 = bitcast <4 x bfloat> %a to <8 x i8>
+  %2 = bitcast <2 x float> %shuffle to <8 x i8>
+  %vbfdot1.i = tail call <2 x float> @llvm.aarch64.neon.bfdot.v2f32.v8i8(<2 x float> %r, <8 x i8> %1, <8 x i8> %2)
+  ret <2 x float> %vbfdot1.i
+}
+
+define <4 x float> @test_vbfdotq_laneq_f32(<4 x float> %r, <8 x bfloat> %a, <8 x bfloat> %b) {
+; CHECK-LABEL: test_vbfdotq_laneq_f32:
+; CHECK:   // %bb.0: // %entry
+; CHECK-NEXT:bfdot v0.4s, v1.8h, v2.2h[3]
+; CHECK-NEXT:ret
+entry:
+  %0 = bitcast <8 x bfloat> %b to <4 x float>
+  %shuffle = shufflevector <4 x float> %0, <4 x float> undef, <4 x i32> 
+  %1 = bitcast <8 x bfloat> %a to <16 x i8>
+  %2 = bitcast <4 x float> %shuffle to <16 x i8>
+  %vbfdot1.i = tail call <4 x float> @llvm.aarch64.neon.bfdot.v4f32.v16i8(<4 x float> %r, <16 x i8> %1, <16 x i8> %2)
+  ret <4 x float> %vbfdot1.i
+}
+
+define <2 x float> @test_vbfdot_laneq_f32(<2 x float> %r, <4 x bfloat> %a, <8 x bfloat> %b) {
+; CHECK-LABEL: test_vbfdot_laneq_f32:
+; CHECK:   // %bb.0: // %entry
+; CHECK-NEXT:bfdot v0.2s, v1.4h, v2.2h[3]
+; CHECK-NEXT:ret
+entry:
+  %0 = bitcast <8 x bfloat> %b to <4 x float>
+  %shuffle = shufflevector <4 x float> %0, <4 x float> undef, <2 x i32> 
+  %1 = bitcast <4 x bfloat> %a to <8 x i8>
+  %2 = bitcast <2 x float> %shuffle to <8 x i8>
+  %vbfdot1.i = tail call <2 x float> @llvm.aarch64.neon.bfdot.v2f32.v8i8(<2 x float> %r, <8 x i8> %1, <8 x i8> %2)
+  ret <2 x float> %vbfdot1.i
+}
+
+define <4 x float> @test_vbfdotq_lane_f32(<4 x float> %r, <8 x bfloat> %a, <4 x bfloat> %b) {
+; CHECK-LABEL: test_vbfdotq_lane_f32:
+; CHECK:   // %bb.0: // %entry
+; CHECK-NEXT:// kill: def $d2 killed $d2 def $q2
+; CHECK-NEXT:bfdot v0.4s, v1.8h, v2.2h[0]
+; CHECK-NEXT:ret
+entry:
+  %0 = bitcast <4 x bfloat> %b to <2 x float>
+  %shuffle = shufflevector <2 x float> %0, <2 x float> undef, <4 x i32> zeroinitializer
+  %1 = bitcast <8 x bfloat> %a to <16 x i8>
+  %2 = bitcast <4 x float> %shuffle to <16 x i8>
+  %vbfdot1.i = tail call <4 x float> @llvm.aarch64.neon.bfdot.v4f32.v16i8(<4 x float> %r, <16 x i8> %1, <16 x i8> %2)
+  ret <4 x float> %vbfdot1.i
+}
+
+define <4 x float> @test_vbfmmlaq_f32(<4 x float> %r, <8 x bfloat> %a, <8 x bfloat> %b) {
+; CHECK-LABEL: test_vbfmmlaq_f32:
+; CHECK:   // %bb.0: // %entry
+; CHECK-NEXT:bfmmla v0.4s, v1.8h, v2.8h
+; CHECK-NEXT:ret
+entry:
+  %0 = bitcast <8 x bfloat> %a to <16 x i8>
+  %1 = bitcast <8 x bfloat> %b to <16 x i8>
+  %vbfmmla1.i = tail call <4 x float> @llvm.aarch64.neon.bfmmla.v4f32.v16i8(<4 x float> %r, <16 x i8> %0, <16 x i8> %1)
+  ret <4 x float> %vbfmmla1.i

[PATCH] D80887: [clang-tidy] ignore builtin varargs from pro-type-vararg-check

2020-06-04 Thread Nathan James via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe21c3f223a35: [clang-tidy] ignore builtin varargs from 
pro-type-vararg-check (authored by njames93).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80887

Files:
  clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeVarargCheck.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-vararg.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-vararg.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-vararg.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-vararg.cpp
@@ -39,13 +39,22 @@
 #include 
 void my_printf(const char* format, ...) {
   va_list ap;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not declare variables of type va_list; use variadic templates instead
   va_start(ap, format);
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not call c-style vararg functions
   va_list n;
-  va_copy(n, ap); // Don't warn, va_copy is anyway useless without va_start
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not declare variables of type va_list; use variadic templates instead
+  va_copy(n, ap);
   int i = va_arg(ap, int);
-  // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: do not use va_start/va_arg to define c-style vararg functions; use variadic templates instead
-  va_end(ap); // Don't warn, va_end is anyway useless without va_start
+  // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: do not use va_arg to define c-style vararg functions; use variadic templates instead
+  va_end(ap);
 }
 
 int my_vprintf(const char* format, va_list arg ); // OK to declare function taking va_list
+
+void ignoredBuiltinsTest() {
+  (void)__builtin_assume_aligned(0, 8);
+  (void)__builtin_constant_p(0);
+  (void)__builtin_fpclassify(0, 0, 0, 0, 0, 0.f);
+  (void)__builtin_isinf_sign(0.f);
+  (void)__builtin_prefetch(nullptr);
+}
Index: clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeVarargCheck.cpp
===
--- clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeVarargCheck.cpp
+++ clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeVarargCheck.cpp
@@ -9,6 +9,7 @@
 #include "ProTypeVarargCheck.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
 
 using namespace clang::ast_matchers;
 
@@ -18,11 +19,72 @@
 
 const internal::VariadicDynCastAllOfMatcher vAArgExpr;
 
+static constexpr StringRef AllowedVariadics[] = {
+// clang-format off
+"__builtin_isgreater", 
+"__builtin_isgreaterequal", 
+"__builtin_isless",
+"__builtin_islessequal", 
+"__builtin_islessgreater", 
+"__builtin_isunordered",
+"__builtin_fpclassify", 
+"__builtin_isfinite", 
+"__builtin_isinf",
+"__builtin_isinf_sign", 
+"__builtin_isnan", 
+"__builtin_isnormal",
+"__builtin_signbit", 
+"__builtin_constant_p", 
+"__builtin_classify_type",
+"__builtin_va_start",
+"__builtin_assume_aligned", // Documented as variadic to support default 
+// parameters.
+"__builtin_prefetch",   // Documented as variadic to support default
+// parameters.
+"__builtin_shufflevector",  // Documented as variadic but with a defined
+// number of args based on vector size.
+"__builtin_convertvector", 
+"__builtin_call_with_static_chain",
+"__builtin_annotation", 
+"__builtin_add_overflow", 
+"__builtin_sub_overflow",
+"__builtin_mul_overflow", 
+"__builtin_preserve_access_index",
+"__builtin_nontemporal_store", 
+"__builtin_nontemporal_load",
+"__builtin_ms_va_start",
+// clang-format on
+};
+
+namespace {
+AST_MATCHER(QualType, isVAList) {
+  ASTContext  = Finder->getASTContext();
+  QualType Desugar = Node.getDesugaredType(Context);
+  return Context.getBuiltinVaListType().getDesugaredType(Context) == Desugar ||
+ Context.getBuiltinMSVaListType().getDesugaredType(Context) == Desugar;
+}
+
+AST_MATCHER_P(AdjustedType, hasOriginalType,
+  ast_matchers::internal::Matcher, InnerType) {
+  return InnerType.matches(Node.getOriginalType(), Finder, Builder);
+}
+} // namespace
+
 void ProTypeVarargCheck::registerMatchers(MatchFinder *Finder) {
   Finder->addMatcher(vAArgExpr().bind("va_use"), this);
 
   Finder->addMatcher(
-  callExpr(callee(functionDecl(isVariadic(.bind("callvararg"), this);
+  callExpr(callee(functionDecl(isVariadic(),
+   unless(hasAnyName(AllowedVariadics)
+  .bind("callvararg"),
+  this);
+
+  Finder->addMatcher(
+  varDecl(unless(parmVarDecl()),
+  

[PATCH] D81157: Propose naming principle for NodeRole and apply it

2020-06-04 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas updated this revision to Diff 268519.
eduucaldas added a comment.

fixed


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81157

Files:
  clang/include/clang/Tooling/Syntax/Nodes.h
  clang/lib/Tooling/Syntax/BuildTree.cpp
  clang/lib/Tooling/Syntax/Nodes.cpp

Index: clang/lib/Tooling/Syntax/Nodes.cpp
===
--- clang/lib/Tooling/Syntax/Nodes.cpp
+++ clang/lib/Tooling/Syntax/Nodes.cpp
@@ -110,6 +110,12 @@
 return OS << "CloseParen";
   case syntax::NodeRole::IntroducerKeyword:
 return OS << "IntroducerKeyword";
+  case syntax::NodeRole::LiteralToken:
+return OS << "LiteralToken";
+  case syntax::NodeRole::ArrowToken:
+return OS << "ArrowToken";
+  case syntax::NodeRole::ExternKeyword:
+return OS << "ExternKeyword";
   case syntax::NodeRole::BodyStatement:
 return OS << "BodyStatement";
   case syntax::NodeRole::CaseStatement_value:
@@ -120,18 +126,12 @@
 return OS << "IfStatement_elseKeyword";
   case syntax::NodeRole::IfStatement_elseStatement:
 return OS << "IfStatement_elseStatement";
-  case syntax::NodeRole::IntegerLiteralExpression_literalToken:
-return OS << "IntegerLiteralExpression_literalToken";
-  case syntax::NodeRole::CxxNullPtrExpression_keyword:
-return OS << "CxxNullPtrExpression_keyword";
-  case syntax::NodeRole::UnaryOperatorExpression_operatorToken:
-return OS << "UnaryOperatorExpression_operatorToken";
+  case syntax::NodeRole::OperatorExpression_operatorToken:
+return OS << "OperatorExpression_operatorToken";
   case syntax::NodeRole::UnaryOperatorExpression_operand:
 return OS << "UnaryOperatorExpression_operand";
   case syntax::NodeRole::BinaryOperatorExpression_leftHandSide:
 return OS << "BinaryOperatorExpression_leftHandSide";
-  case syntax::NodeRole::BinaryOperatorExpression_operatorToken:
-return OS << "BinaryOperatorExpression_operatorToken";
   case syntax::NodeRole::BinaryOperatorExpression_rightHandSide:
 return OS << "BinaryOperatorExpression_rightHandSide";
   case syntax::NodeRole::ReturnStatement_value:
@@ -148,14 +148,10 @@
 return OS << "SimpleDeclaration_declarator";
   case syntax::NodeRole::TemplateDeclaration_declaration:
 return OS << "TemplateDeclaration_declaration";
-  case syntax::NodeRole::ExplicitTemplateInstantiation_externKeyword:
-return OS << "ExplicitTemplateInstantiation_externKeyword";
   case syntax::NodeRole::ExplicitTemplateInstantiation_declaration:
 return OS << "ExplicitTemplateInstantiation_declaration";
   case syntax::NodeRole::ArraySubscript_sizeExpression:
 return OS << "ArraySubscript_sizeExpression";
-  case syntax::NodeRole::TrailingReturnType_arrow:
-return OS << "TrailingReturnType_arrow";
   case syntax::NodeRole::TrailingReturnType_declarator:
 return OS << "TrailingReturnType_declarator";
   case syntax::NodeRole::ParametersAndQualifiers_parameter:
@@ -168,12 +164,12 @@
 
 syntax::Leaf *syntax::IntegerLiteralExpression::literalToken() {
   return llvm::cast_or_null(
-  findChild(syntax::NodeRole::IntegerLiteralExpression_literalToken));
+  findChild(syntax::NodeRole::LiteralToken));
 }
 
 syntax::Leaf *syntax::CxxNullPtrExpression::nullPtrKeyword() {
   return llvm::cast_or_null(
-  findChild(syntax::NodeRole::CxxNullPtrExpression_keyword));
+  findChild(syntax::NodeRole::LiteralToken));
 }
 
 syntax::Expression *syntax::BinaryOperatorExpression::lhs() {
@@ -183,7 +179,7 @@
 
 syntax::Leaf *syntax::UnaryOperatorExpression::operatorToken() {
   return llvm::cast_or_null(
-  findChild(syntax::NodeRole::UnaryOperatorExpression_operatorToken));
+  findChild(syntax::NodeRole::OperatorExpression_operatorToken));
 }
 
 syntax::Expression *syntax::UnaryOperatorExpression::operand() {
@@ -193,7 +189,7 @@
 
 syntax::Leaf *syntax::BinaryOperatorExpression::operatorToken() {
   return llvm::cast_or_null(
-  findChild(syntax::NodeRole::BinaryOperatorExpression_operatorToken));
+  findChild(syntax::NodeRole::OperatorExpression_operatorToken));
 }
 
 syntax::Expression *syntax::BinaryOperatorExpression::rhs() {
@@ -367,7 +363,7 @@
 
 syntax::Leaf *syntax::ExplicitTemplateInstantiation::externKeyword() {
   return llvm::cast_or_null(
-  findChild(syntax::NodeRole::ExplicitTemplateInstantiation_externKeyword));
+  findChild(syntax::NodeRole::ExternKeyword));
 }
 
 syntax::Declaration *syntax::ExplicitTemplateInstantiation::declaration() {
@@ -402,7 +398,7 @@
 
 syntax::Leaf *syntax::TrailingReturnType::arrow() {
   return llvm::cast_or_null(
-  findChild(syntax::NodeRole::TrailingReturnType_arrow));
+  findChild(syntax::NodeRole::ArrowToken));
 }
 
 syntax::SimpleDeclarator *syntax::TrailingReturnType::declarator() {
Index: clang/lib/Tooling/Syntax/BuildTree.cpp
===
--- 

[PATCH] D81157: Propose naming principle for NodeRole and apply it

2020-06-04 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas updated this revision to Diff 268517.
eduucaldas added a comment.

`ArrowToken`, `ExternKeyword`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81157

Files:
  clang/include/clang/Tooling/Syntax/Nodes.h
  clang/lib/Tooling/Syntax/BuildTree.cpp
  clang/lib/Tooling/Syntax/Nodes.cpp

Index: clang/lib/Tooling/Syntax/Nodes.cpp
===
--- clang/lib/Tooling/Syntax/Nodes.cpp
+++ clang/lib/Tooling/Syntax/Nodes.cpp
@@ -110,6 +110,8 @@
 return OS << "CloseParen";
   case syntax::NodeRole::IntroducerKeyword:
 return OS << "IntroducerKeyword";
+  case syntax::NodeRole::LiteralToken:
+return OS << "LiteralToken";
   case syntax::NodeRole::BodyStatement:
 return OS << "BodyStatement";
   case syntax::NodeRole::CaseStatement_value:
@@ -120,18 +122,12 @@
 return OS << "IfStatement_elseKeyword";
   case syntax::NodeRole::IfStatement_elseStatement:
 return OS << "IfStatement_elseStatement";
-  case syntax::NodeRole::IntegerLiteralExpression_literalToken:
-return OS << "IntegerLiteralExpression_literalToken";
-  case syntax::NodeRole::CxxNullPtrExpression_keyword:
-return OS << "CxxNullPtrExpression_keyword";
-  case syntax::NodeRole::UnaryOperatorExpression_operatorToken:
-return OS << "UnaryOperatorExpression_operatorToken";
+  case syntax::NodeRole::OperatorExpression_operatorToken:
+return OS << "OperatorExpression_operatorToken";
   case syntax::NodeRole::UnaryOperatorExpression_operand:
 return OS << "UnaryOperatorExpression_operand";
   case syntax::NodeRole::BinaryOperatorExpression_leftHandSide:
 return OS << "BinaryOperatorExpression_leftHandSide";
-  case syntax::NodeRole::BinaryOperatorExpression_operatorToken:
-return OS << "BinaryOperatorExpression_operatorToken";
   case syntax::NodeRole::BinaryOperatorExpression_rightHandSide:
 return OS << "BinaryOperatorExpression_rightHandSide";
   case syntax::NodeRole::ReturnStatement_value:
@@ -148,14 +144,14 @@
 return OS << "SimpleDeclaration_declarator";
   case syntax::NodeRole::TemplateDeclaration_declaration:
 return OS << "TemplateDeclaration_declaration";
-  case syntax::NodeRole::ExplicitTemplateInstantiation_externKeyword:
-return OS << "ExplicitTemplateInstantiation_externKeyword";
+  case syntax::NodeRole::ExternKeyword:
+return OS << "ExternKeyword";
   case syntax::NodeRole::ExplicitTemplateInstantiation_declaration:
 return OS << "ExplicitTemplateInstantiation_declaration";
   case syntax::NodeRole::ArraySubscript_sizeExpression:
 return OS << "ArraySubscript_sizeExpression";
-  case syntax::NodeRole::TrailingReturnType_arrow:
-return OS << "TrailingReturnType_arrow";
+  case syntax::NodeRole::ArrowToken:
+return OS << "ArrowToken";
   case syntax::NodeRole::TrailingReturnType_declarator:
 return OS << "TrailingReturnType_declarator";
   case syntax::NodeRole::ParametersAndQualifiers_parameter:
@@ -168,12 +164,12 @@
 
 syntax::Leaf *syntax::IntegerLiteralExpression::literalToken() {
   return llvm::cast_or_null(
-  findChild(syntax::NodeRole::IntegerLiteralExpression_literalToken));
+  findChild(syntax::NodeRole::LiteralToken));
 }
 
 syntax::Leaf *syntax::CxxNullPtrExpression::nullPtrKeyword() {
   return llvm::cast_or_null(
-  findChild(syntax::NodeRole::CxxNullPtrExpression_keyword));
+  findChild(syntax::NodeRole::LiteralToken));
 }
 
 syntax::Expression *syntax::BinaryOperatorExpression::lhs() {
@@ -183,7 +179,7 @@
 
 syntax::Leaf *syntax::UnaryOperatorExpression::operatorToken() {
   return llvm::cast_or_null(
-  findChild(syntax::NodeRole::UnaryOperatorExpression_operatorToken));
+  findChild(syntax::NodeRole::OperatorExpression_operatorToken));
 }
 
 syntax::Expression *syntax::UnaryOperatorExpression::operand() {
@@ -193,7 +189,7 @@
 
 syntax::Leaf *syntax::BinaryOperatorExpression::operatorToken() {
   return llvm::cast_or_null(
-  findChild(syntax::NodeRole::BinaryOperatorExpression_operatorToken));
+  findChild(syntax::NodeRole::OperatorExpression_operatorToken));
 }
 
 syntax::Expression *syntax::BinaryOperatorExpression::rhs() {
@@ -367,7 +363,7 @@
 
 syntax::Leaf *syntax::ExplicitTemplateInstantiation::externKeyword() {
   return llvm::cast_or_null(
-  findChild(syntax::NodeRole::ExplicitTemplateInstantiation_externKeyword));
+  findChild(syntax::NodeRole::ExternKeyword));
 }
 
 syntax::Declaration *syntax::ExplicitTemplateInstantiation::declaration() {
@@ -402,7 +398,7 @@
 
 syntax::Leaf *syntax::TrailingReturnType::arrow() {
   return llvm::cast_or_null(
-  findChild(syntax::NodeRole::TrailingReturnType_arrow));
+  findChild(syntax::NodeRole::ArrowToken));
 }
 
 syntax::SimpleDeclarator *syntax::TrailingReturnType::declarator() {
Index: clang/lib/Tooling/Syntax/BuildTree.cpp
===
--- 

[PATCH] D80735: [OpenMP][NFC] Reuse OMPIRBuilder `struct ident_t` handling in Clang

2020-06-04 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added a comment.

The failure message is pretty much always this assertion as far as I can tell

  clang-11: 
/home/jhuber/Documents/llvm-project/llvm/lib/IR/Instructions.cpp:439: void 
llvm::CallInst::init(llvm::FunctionType*, llvm::Value*, 
llvm::ArrayRef, 
llvm::ArrayRef >, const llvm::Twine&): 
Assertion `(i >= FTy->getNumParams() || FTy->getParamType(i) == 
Args[i]->getType()) && "Calling a function with a bad signature!"' failed.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80735



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


[PATCH] D81155: Rename arrow -> arrowToken for unified naming

2020-06-04 Thread Dmitri Gribenko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG62305f6db4ed: Rename arrow - arrowToken for unified 
naming (authored by eduucaldas, committed by gribozavr).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81155

Files:
  clang/include/clang/Tooling/Syntax/Nodes.h
  clang/lib/Tooling/Syntax/Nodes.cpp


Index: clang/lib/Tooling/Syntax/Nodes.cpp
===
--- clang/lib/Tooling/Syntax/Nodes.cpp
+++ clang/lib/Tooling/Syntax/Nodes.cpp
@@ -400,7 +400,7 @@
   findChild(syntax::NodeRole::CloseParen));
 }
 
-syntax::Leaf *syntax::TrailingReturnType::arrow() {
+syntax::Leaf *syntax::TrailingReturnType::arrowToken() {
   return llvm::cast_or_null(
   findChild(syntax::NodeRole::TrailingReturnType_arrow));
 }
Index: clang/include/clang/Tooling/Syntax/Nodes.h
===
--- clang/include/clang/Tooling/Syntax/Nodes.h
+++ clang/include/clang/Tooling/Syntax/Nodes.h
@@ -639,7 +639,7 @@
 return N->kind() == NodeKind::TrailingReturnType;
   }
   // TODO: add accessors for specifiers.
-  syntax::Leaf *arrow();
+  syntax::Leaf *arrowToken();
   syntax::SimpleDeclarator *declarator();
 };
 


Index: clang/lib/Tooling/Syntax/Nodes.cpp
===
--- clang/lib/Tooling/Syntax/Nodes.cpp
+++ clang/lib/Tooling/Syntax/Nodes.cpp
@@ -400,7 +400,7 @@
   findChild(syntax::NodeRole::CloseParen));
 }
 
-syntax::Leaf *syntax::TrailingReturnType::arrow() {
+syntax::Leaf *syntax::TrailingReturnType::arrowToken() {
   return llvm::cast_or_null(
   findChild(syntax::NodeRole::TrailingReturnType_arrow));
 }
Index: clang/include/clang/Tooling/Syntax/Nodes.h
===
--- clang/include/clang/Tooling/Syntax/Nodes.h
+++ clang/include/clang/Tooling/Syntax/Nodes.h
@@ -639,7 +639,7 @@
 return N->kind() == NodeKind::TrailingReturnType;
   }
   // TODO: add accessors for specifiers.
-  syntax::Leaf *arrow();
+  syntax::Leaf *arrowToken();
   syntax::SimpleDeclarator *declarator();
 };
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D69987: [RISCV] Assemble/Disassemble v-ext instructions.

2020-06-04 Thread Hsiangkai Wang via Phabricator via cfe-commits
HsiangKai added a comment.

Ping.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69987



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


[PATCH] D80735: [OpenMP][NFC] Reuse OMPIRBuilder `struct ident_t` handling in Clang

2020-06-04 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

In D80735#2073639 , @jhuber6 wrote:

> The failure message is pretty much always this assertion as far as I can tell
>
>   clang-11: 
> /home/jhuber/Documents/llvm-project/llvm/lib/IR/Instructions.cpp:439: void 
> llvm::CallInst::init(llvm::FunctionType*, llvm::Value*, 
> llvm::ArrayRef, 
> llvm::ArrayRef >, const llvm::Twine&): 
> Assertion `(i >= FTy->getNumParams() || FTy->getParamType(i) == 
> Args[i]->getType()) && "Calling a function with a bad signature!"' failed.
>


Now we have to figure out what the types are and what is expected. Can you go 
back the stack trace and add some prints to this end?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80735



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


[PATCH] D81168: Add support for id-expression in SyntaxTree

2020-06-04 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
eduucaldas added a subscriber: gribozavr2.
eduucaldas marked an inline comment as done.
eduucaldas added inline comments.
eduucaldas marked an inline comment as not done.



Comment at: clang/unittests/Tooling/Syntax/TreeTest.cpp:829
+| | | | | `-::
+| | | | `-TypeSpecifier
+| | | |   |-S

Perhaps we shouldn't differ between specifiers as that is semantical information


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81168

Files:
  clang/unittests/Tooling/Syntax/TreeTest.cpp

Index: clang/unittests/Tooling/Syntax/TreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/TreeTest.cpp
+++ clang/unittests/Tooling/Syntax/TreeTest.cpp
@@ -692,6 +692,152 @@
 )txt"));
 }
 
+TEST_P(SyntaxTreeTest, UnqualifiedId) {
+  if (!GetParam().isCXX()) {
+return;
+  }
+  EXPECT_TRUE(treeDumpEqual(
+  R"cpp(
+void test(int b) {
+  int a;
+  a = b;
+}
+)cpp",
+  R"txt(
+*: TranslationUnit
+`-SimpleDeclaration
+  |-void
+  |-SimpleDeclarator
+  | |-test
+  | `-ParametersAndQualifiers
+  |   |-(
+  |   |-SimpleDeclaration
+  |   | |-int
+  |   | `-SimpleDeclarator
+  |   |   `-b
+  |   `-)
+  `-CompoundStatement
+|-{
+|-DeclarationStatement
+| |-SimpleDeclaration
+| | |-int
+| | `-SimpleDeclarator
+| |   `-a
+| `-;
+|-ExpressionStatement
+| |-BinaryOperatorExpression
+| | |-IdExpression
+| | | `-UnqualifiedId
+| | |   `-a
+| | |-=
+| | `-IdExpression
+| |   `-UnqualifiedId
+| | `-b
+| `-;
+`-}
+)txt"));
+}
+
+TEST_P(SyntaxTreeTest, QualifiedId) {
+  if (!GetParam().isCXX()) {
+return;
+  }
+  EXPECT_TRUE(treeDumpEqual(
+  R"cpp(
+namespace a {
+  namespace b {
+struct S {
+  int i;
+  static void f(){}
+};
+  }
+}
+void test(int b) {
+  ::a::b::S::f();
+}
+)cpp",
+  R"txt(
+*: TranslationUnit
+|-NamespaceDefinition
+| |-namespace
+| |-a
+| |-{
+| |-NamespaceDefinition
+| | |-namespace
+| | |-b
+| | |-{
+| | |-SimpleDeclaration
+| | | |-struct
+| | | |-S
+| | | |-{
+| | | |-SimpleDeclaration
+| | | | |-int
+| | | | |-SimpleDeclarator
+| | | | | `-i
+| | | | `-;
+| | | |-SimpleDeclaration
+| | | | |-static
+| | | | |-void
+| | | | |-SimpleDeclarator
+| | | | | |-f
+| | | | | `-ParametersAndQualifiers
+| | | | |   |-(
+| | | | |   `-)
+| | | | `-CompoundStatement
+| | | |   |-{
+| | | |   `-}
+| | | |-}
+| | | `-;
+| | `-}
+| `-}
+`-SimpleDeclaration
+  |-void
+  |-SimpleDeclarator
+  | |-test
+  | `-ParametersAndQualifiers
+  |   |-(
+  |   |-SimpleDeclaration
+  |   | |-int
+  |   | `-SimpleDeclarator
+  |   |   `-b
+  |   `-)
+  `-CompoundStatement
+|-{
+|-DeclarationStatement
+| |-SimpleDeclaration
+| | |-a
+| | |-::
+| | |-b
+| | |-::
+| | |-S
+| | `-SimpleDeclarator
+| |   `-UnknownExpression
+| | `-s
+| `-;
+|-ExpressionStatement
+| |-UnknownExpression
+| | |-IdExpression
+| | | |-NameSpecifiers
+| | | | |-GlobalNamespaceSpecifier
+| | | | | `::
+| | | | |-NamespaceSpecifier
+| | | | | |-a
+| | | | | `-::
+| | | | |-NamespaceSpecifier
+| | | | | |-b
+| | | | | `-::
+| | | | `-TypeSpecifier
+| | | |   |-S
+| | | |   `-::
+| | | `-UnqualifiedId
+| | |   `-f
+| | |-(
+| | `-)
+| `-;
+`-}
+)txt"));
+}
+
 TEST_P(SyntaxTreeTest, CxxNullPtrLiteral) {
   if (!GetParam().isCXX11OrLater()) {
 return;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D62922: [WebAssembly] Implement "Reactor" mode

2020-06-04 Thread Bjorn Pettersson via Phabricator via cfe-commits
bjope added inline comments.



Comment at: clang/test/Driver/wasm-toolchain.c:116
+// CHECK-COMMAND: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
+// CHECK-COMMAND: wasm-ld{{.*}}" "crt1.o" "[[temp]]" "-lc" 
"{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
+

sunfish wrote:
> bjope wrote:
> > bjope wrote:
> > > This isn't working for me on redhat 7 servers. I get
> > > ```
> > >  "wasm-ld" "-L/lib" "/lib/crt1.o" ...
> > > ```
> > > No idea why I get the full patch to crt1.o. But it's not matching with 
> > > the FileCheck pattern.
> > /full patch/full path/
> Would you be able to test whether the following patch fixes it?
> 
> ```diff
> diff --git a/clang/test/Driver/wasm-toolchain.c 
> b/clang/test/Driver/wasm-toolchain.c
> index 8300a81614e..332e6048cc5 100644
> --- a/clang/test/Driver/wasm-toolchain.c
> +++ b/clang/test/Driver/wasm-toolchain.c
> @@ -110,11 +110,11 @@
> 
>  // Basic exec-model tests.
> 
> -// RUN: %clang %s -### -no-canonical-prefixes -target wasm32-unknown-unknown 
> -mexec-model=command 2>&1 \
> +// RUN: %clang %s -### -no-canonical-prefixes -target wasm32-unknown-unknown 
> --sysroot=%s/no-sysroot-there -mexec-model=command 2>&1 \
>  // RUN:   | FileCheck -check-prefix=CHECK-COMMAND %s
>  // CHECK-COMMAND: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
>  // CHECK-COMMAND: wasm-ld{{.*}}" "crt1.o" "[[temp]]" "-lc" 
> "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
> 
> -// RUN: %clang %s -### -no-canonical-prefixes -target wasm32-unknown-unknown 
> -mexec-model=reactor 2>&1 \
> +// RUN: %clang %s -### -no-canonical-prefixes -target wasm32-unknown-unknown 
> --sysroot=%s/no-sysroot-there -mexec-model=reactor 2>&1 \
>  // RUN:   | FileCheck -check-prefix=CHECK-REACTOR %s
>  // CHECK-REACTOR: wasm-ld{{.*}}" {{.*}} "--entry" "_initialize" {{.*}}
> ```
Yes, that is working.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62922



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


[clang-tools-extra] e21c3f2 - [clang-tidy] ignore builtin varargs from pro-type-vararg-check

2020-06-04 Thread Nathan James via cfe-commits

Author: Nathan James
Date: 2020-06-04T17:58:23+01:00
New Revision: e21c3f223a3537df0d9d02fce5038b3d7b98ab52

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

LOG: [clang-tidy] ignore builtin varargs from pro-type-vararg-check

Disables the check from warning on some built in vararg functions, Address [[ 
https://bugs.llvm.org/show_bug.cgi?id=45860 | Clang-tidy should not consider 
__builtin_constant_p a variadic function. ]]

Reviewed By: aaron.ballman

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeVarargCheck.cpp

clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-vararg.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeVarargCheck.cpp 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeVarargCheck.cpp
index 4509c934ddc5..f6aeb8321337 100644
--- a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeVarargCheck.cpp
+++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeVarargCheck.cpp
@@ -9,6 +9,7 @@
 #include "ProTypeVarargCheck.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
 
 using namespace clang::ast_matchers;
 
@@ -18,11 +19,72 @@ namespace cppcoreguidelines {
 
 const internal::VariadicDynCastAllOfMatcher vAArgExpr;
 
+static constexpr StringRef AllowedVariadics[] = {
+// clang-format off
+"__builtin_isgreater", 
+"__builtin_isgreaterequal", 
+"__builtin_isless",
+"__builtin_islessequal", 
+"__builtin_islessgreater", 
+"__builtin_isunordered",
+"__builtin_fpclassify", 
+"__builtin_isfinite", 
+"__builtin_isinf",
+"__builtin_isinf_sign", 
+"__builtin_isnan", 
+"__builtin_isnormal",
+"__builtin_signbit", 
+"__builtin_constant_p", 
+"__builtin_classify_type",
+"__builtin_va_start",
+"__builtin_assume_aligned", // Documented as variadic to support default 
+// parameters.
+"__builtin_prefetch",   // Documented as variadic to support default
+// parameters.
+"__builtin_shufflevector",  // Documented as variadic but with a defined
+// number of args based on vector size.
+"__builtin_convertvector", 
+"__builtin_call_with_static_chain",
+"__builtin_annotation", 
+"__builtin_add_overflow", 
+"__builtin_sub_overflow",
+"__builtin_mul_overflow", 
+"__builtin_preserve_access_index",
+"__builtin_nontemporal_store", 
+"__builtin_nontemporal_load",
+"__builtin_ms_va_start",
+// clang-format on
+};
+
+namespace {
+AST_MATCHER(QualType, isVAList) {
+  ASTContext  = Finder->getASTContext();
+  QualType Desugar = Node.getDesugaredType(Context);
+  return Context.getBuiltinVaListType().getDesugaredType(Context) == Desugar ||
+ Context.getBuiltinMSVaListType().getDesugaredType(Context) == Desugar;
+}
+
+AST_MATCHER_P(AdjustedType, hasOriginalType,
+  ast_matchers::internal::Matcher, InnerType) {
+  return InnerType.matches(Node.getOriginalType(), Finder, Builder);
+}
+} // namespace
+
 void ProTypeVarargCheck::registerMatchers(MatchFinder *Finder) {
   Finder->addMatcher(vAArgExpr().bind("va_use"), this);
 
   Finder->addMatcher(
-  callExpr(callee(functionDecl(isVariadic(.bind("callvararg"), this);
+  callExpr(callee(functionDecl(isVariadic(),
+   unless(hasAnyName(AllowedVariadics)
+  .bind("callvararg"),
+  this);
+
+  Finder->addMatcher(
+  varDecl(unless(parmVarDecl()),
+  hasType(qualType(
+  anyOf(isVAList(), 
decayedType(hasOriginalType(isVAList()))
+  .bind("va_list"),
+  this);
 }
 
 static bool hasSingleVariadicArgumentWithValue(const CallExpr *C, uint64_t I) {
@@ -54,7 +116,7 @@ void ProTypeVarargCheck::check(const 
MatchFinder::MatchResult ) {
 
   if (const auto *Matched = Result.Nodes.getNodeAs("va_use")) {
 diag(Matched->getExprLoc(),
- "do not use va_start/va_arg to define c-style vararg functions; "
+ "do not use va_arg to define c-style vararg functions; "
  "use variadic templates instead");
   }
 

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-vararg.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-vararg.cpp
index 021322aacb62..1e3b5ee036ca 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-vararg.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-vararg.cpp
@@ -39,13 +39,22 @@ void CallFooIfAvailable(T& t) {
 #include 
 void 

[PATCH] D80725: [Analyzer][StreamChecker] Updated initialization of BugType's.

2020-06-04 Thread Balázs Kéri via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0bfd70bdad7e: [Analyzer][StreamChecker] Updated 
initialization of BugTypes. (authored by balazske).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80725

Files:
  clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp

Index: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
@@ -195,9 +195,29 @@
 
 class StreamChecker
 : public Checker {
-  mutable std::unique_ptr BT_nullfp, BT_illegalwhence,
-  BT_UseAfterClose, BT_UseAfterOpenFailed, BT_ResourceLeak, BT_StreamEof,
-  BT_IndeterminatePosition;
+  BuiltinBug BT_FileNull{this, "NULL stream pointer",
+ "Stream pointer might be NULL."};
+  BuiltinBug BT_UseAfterClose{
+  this, "Closed stream",
+  "Stream might be already closed. Causes undefined behaviour."};
+  BuiltinBug BT_UseAfterOpenFailed{this, "Invalid stream",
+   "Stream might be invalid after "
+   "(re-)opening it has failed. "
+   "Can cause undefined behaviour."};
+  BuiltinBug BT_IndeterminatePosition{
+  this, "Invalid stream state",
+  "File position of the stream might be 'indeterminate' "
+  "after a failed operation. "
+  "Can cause undefined behavior."};
+  BuiltinBug BT_IllegalWhence{this, "Illegal whence argument",
+  "The whence argument to fseek() should be "
+  "SEEK_SET, SEEK_END, or SEEK_CUR."};
+  BuiltinBug BT_StreamEof{this, "Stream already in EOF",
+  "Read function called when stream is in EOF state. "
+  "Function has no effect."};
+  BuiltinBug BT_ResourceLeak{
+  this, "Resource Leak",
+  "Opened File never closed. Potential Resource leak."};
 
 public:
   void checkPreCall(const CallEvent , CheckerContext ) const;
@@ -755,11 +775,8 @@
 
   if (!StateNotNull && StateNull) {
 if (ExplodedNode *N = C.generateErrorNode(StateNull)) {
-  if (!BT_nullfp)
-BT_nullfp.reset(new BuiltinBug(this, "NULL stream pointer",
-   "Stream pointer might be NULL."));
   C.emitReport(std::make_unique(
-  *BT_nullfp, BT_nullfp->getDescription(), N));
+  BT_FileNull, BT_FileNull.getDescription(), N));
 }
 return nullptr;
   }
@@ -783,12 +800,8 @@
 // according to cppreference.com .
 ExplodedNode *N = C.generateErrorNode();
 if (N) {
-  if (!BT_UseAfterClose)
-BT_UseAfterClose.reset(new BuiltinBug(this, "Closed stream",
-  "Stream might be already closed. "
-  "Causes undefined behaviour."));
   C.emitReport(std::make_unique(
-  *BT_UseAfterClose, BT_UseAfterClose->getDescription(), N));
+  BT_UseAfterClose, BT_UseAfterClose.getDescription(), N));
   return nullptr;
 }
 
@@ -802,14 +815,8 @@
 // failed to open.
 ExplodedNode *N = C.generateErrorNode();
 if (N) {
-  if (!BT_UseAfterOpenFailed)
-BT_UseAfterOpenFailed.reset(
-new BuiltinBug(this, "Invalid stream",
-   "Stream might be invalid after "
-   "(re-)opening it has failed. "
-   "Can cause undefined behaviour."));
   C.emitReport(std::make_unique(
-  *BT_UseAfterOpenFailed, BT_UseAfterOpenFailed->getDescription(), N));
+  BT_UseAfterOpenFailed, BT_UseAfterOpenFailed.getDescription(), N));
   return nullptr;
 }
 return State;
@@ -831,13 +838,6 @@
   assert(SS->isOpened() && "First ensure that stream is opened.");
 
   if (SS->FilePositionIndeterminate) {
-if (!BT_IndeterminatePosition)
-  BT_IndeterminatePosition.reset(
-  new BuiltinBug(this, "Invalid stream state",
- "File position of the stream might be 'indeterminate' "
- "after a failed operation. "
- "Can cause undefined behavior."));
-
 if (SS->ErrorState & ErrorFEof) {
   // The error is unknown but may be FEOF.
   // Continue analysis with the FEOF error state.
@@ -847,7 +847,7 @@
 return nullptr;
 
   C.emitReport(std::make_unique(
-  *BT_IndeterminatePosition, BT_IndeterminatePosition->getDescription(),
+  BT_IndeterminatePosition, BT_IndeterminatePosition.getDescription(),
   N));
   return State->set(
   Sym, StreamState::getOpened(SS->LastOperation, ErrorFEof, false));
@@ -858,7 +858,7 @@
 ExplodedNode *N = C.generateErrorNode(State);
 if (N)
   

[clang] 0bfd70b - [Analyzer][StreamChecker] Updated initialization of BugType's.

2020-06-04 Thread Balázs Kéri via cfe-commits

Author: Balázs Kéri
Date: 2020-06-04T16:06:07+02:00
New Revision: 0bfd70bdad7e4ac22d96503fa78a5dd55d4b430e

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

LOG: [Analyzer][StreamChecker] Updated initialization of BugType's.

Summary:
BugType objects are initialized in-class instead of by lazy initialization.
FuchsiaHandleChecker does this already.

Reviewers: Szelethus, baloghadamsoftware, martong

Reviewed By: Szelethus

Subscribers: rnkovacs, xazax.hun, baloghadamsoftware, szepet, a.sidorin, 
mikhail.ramalho, Szelethus, donat.nagy, dkrupp, gamesh411, Charusso, martong, 
ASDenysPetrov, cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
index 63ebfaf90dc8..bfb788c24e24 100644
--- a/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
@@ -195,9 +195,29 @@ ProgramStateRef bindInt(uint64_t Value, ProgramStateRef 
State,
 
 class StreamChecker
 : public Checker {
-  mutable std::unique_ptr BT_nullfp, BT_illegalwhence,
-  BT_UseAfterClose, BT_UseAfterOpenFailed, BT_ResourceLeak, BT_StreamEof,
-  BT_IndeterminatePosition;
+  BuiltinBug BT_FileNull{this, "NULL stream pointer",
+ "Stream pointer might be NULL."};
+  BuiltinBug BT_UseAfterClose{
+  this, "Closed stream",
+  "Stream might be already closed. Causes undefined behaviour."};
+  BuiltinBug BT_UseAfterOpenFailed{this, "Invalid stream",
+   "Stream might be invalid after "
+   "(re-)opening it has failed. "
+   "Can cause undefined behaviour."};
+  BuiltinBug BT_IndeterminatePosition{
+  this, "Invalid stream state",
+  "File position of the stream might be 'indeterminate' "
+  "after a failed operation. "
+  "Can cause undefined behavior."};
+  BuiltinBug BT_IllegalWhence{this, "Illegal whence argument",
+  "The whence argument to fseek() should be "
+  "SEEK_SET, SEEK_END, or SEEK_CUR."};
+  BuiltinBug BT_StreamEof{this, "Stream already in EOF",
+  "Read function called when stream is in EOF state. "
+  "Function has no effect."};
+  BuiltinBug BT_ResourceLeak{
+  this, "Resource Leak",
+  "Opened File never closed. Potential Resource leak."};
 
 public:
   void checkPreCall(const CallEvent , CheckerContext ) const;
@@ -755,11 +775,8 @@ StreamChecker::ensureStreamNonNull(SVal StreamVal, 
CheckerContext ,
 
   if (!StateNotNull && StateNull) {
 if (ExplodedNode *N = C.generateErrorNode(StateNull)) {
-  if (!BT_nullfp)
-BT_nullfp.reset(new BuiltinBug(this, "NULL stream pointer",
-   "Stream pointer might be NULL."));
   C.emitReport(std::make_unique(
-  *BT_nullfp, BT_nullfp->getDescription(), N));
+  BT_FileNull, BT_FileNull.getDescription(), N));
 }
 return nullptr;
   }
@@ -783,12 +800,8 @@ ProgramStateRef StreamChecker::ensureStreamOpened(SVal 
StreamVal,
 // according to cppreference.com .
 ExplodedNode *N = C.generateErrorNode();
 if (N) {
-  if (!BT_UseAfterClose)
-BT_UseAfterClose.reset(new BuiltinBug(this, "Closed stream",
-  "Stream might be already closed. 
"
-  "Causes undefined behaviour."));
   C.emitReport(std::make_unique(
-  *BT_UseAfterClose, BT_UseAfterClose->getDescription(), N));
+  BT_UseAfterClose, BT_UseAfterClose.getDescription(), N));
   return nullptr;
 }
 
@@ -802,14 +815,8 @@ ProgramStateRef StreamChecker::ensureStreamOpened(SVal 
StreamVal,
 // failed to open.
 ExplodedNode *N = C.generateErrorNode();
 if (N) {
-  if (!BT_UseAfterOpenFailed)
-BT_UseAfterOpenFailed.reset(
-new BuiltinBug(this, "Invalid stream",
-   "Stream might be invalid after "
-   "(re-)opening it has failed. "
-   "Can cause undefined behaviour."));
   C.emitReport(std::make_unique(
-  *BT_UseAfterOpenFailed, BT_UseAfterOpenFailed->getDescription(), N));
+  BT_UseAfterOpenFailed, BT_UseAfterOpenFailed.getDescription(), N));
   return nullptr;
 }
 return State;
@@ -831,13 +838,6 @@ ProgramStateRef 
StreamChecker::ensureNoFilePositionIndeterminate(
   assert(SS->isOpened() && "First ensure that stream is opened.");
 
   

[PATCH] D80699: [Analyzer][StreamChecker] Add check for pointer escape.

2020-06-04 Thread Balázs Kéri via Phabricator via cfe-commits
balazske updated this revision to Diff 268459.
balazske added a comment.

Using range-based for loop.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80699

Files:
  clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
  clang/test/Analysis/stream.c

Index: clang/test/Analysis/stream.c
===
--- clang/test/Analysis/stream.c
+++ clang/test/Analysis/stream.c
@@ -192,4 +192,51 @@
 rewind(f1); // expected-warning {{Stream might be invalid}}
 fclose(f1);
   }
-}
\ No newline at end of file
+}
+
+extern FILE *GlobalF;
+extern void takeFile(FILE *);
+
+void check_escape1() {
+  FILE *F = tmpfile();
+  if (!F)
+return;
+  fwrite("1", 1, 1, F); // may fail
+  GlobalF = F;
+  fwrite("1", 1, 1, F); // no warning
+}
+
+void check_escape2() {
+  FILE *F = tmpfile();
+  if (!F)
+return;
+  fwrite("1", 1, 1, F); // may fail
+  takeFile(F);
+  fwrite("1", 1, 1, F); // no warning
+}
+
+void check_escape3() {
+  FILE *F = tmpfile();
+  if (!F)
+return;
+  takeFile(F);
+  F = freopen(0, "w", F);
+  if (!F)
+return;
+  fwrite("1", 1, 1, F); // may fail
+  fwrite("1", 1, 1, F); // no warning
+}
+
+void check_escape4() {
+  FILE *F = tmpfile();
+  if (!F)
+return;
+  fwrite("1", 1, 1, F); // may fail
+
+  // no escape at (non-StreamChecker-handled) system call
+  // FIXME: all such calls should be handled by the checker
+  fprintf(F, "0");
+
+  fwrite("1", 1, 1, F); // expected-warning {{might be 'indeterminate'}}
+  fclose(F);
+}
Index: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
@@ -193,8 +193,8 @@
   return State;
 }
 
-class StreamChecker
-: public Checker {
+class StreamChecker : public Checker {
   mutable std::unique_ptr BT_nullfp, BT_illegalwhence,
   BT_UseAfterClose, BT_UseAfterOpenFailed, BT_ResourceLeak, BT_StreamEof,
   BT_IndeterminatePosition;
@@ -203,6 +203,10 @@
   void checkPreCall(const CallEvent , CheckerContext ) const;
   bool evalCall(const CallEvent , CheckerContext ) const;
   void checkDeadSymbols(SymbolReaper , CheckerContext ) const;
+  ProgramStateRef checkPointerEscape(ProgramStateRef State,
+ const InvalidatedSymbols ,
+ const CallEvent *Call,
+ PointerEscapeKind Kind) const;
 
   /// If true, evaluate special testing stream functions.
   bool TestMode = false;
@@ -428,10 +432,14 @@
 
   SymbolRef StreamSym = StreamVal->getAsSymbol();
   // Do not care about concrete values for stream ("(FILE *)0x12345"?).
-  // FIXME: Are stdin, stdout, stderr such values?
+  // FIXME: Can be stdin, stdout, stderr such values?
   if (!StreamSym)
 return;
 
+  // Do not handle untracked stream. It is probably escaped.
+  if (!State->get(StreamSym))
+return;
+
   // Generate state for non-failed case.
   // Return value is the passed stream pointer.
   // According to the documentations, the stream is closed first
@@ -932,6 +940,28 @@
   }
 }
 
+ProgramStateRef StreamChecker::checkPointerEscape(
+ProgramStateRef State, const InvalidatedSymbols ,
+const CallEvent *Call, PointerEscapeKind Kind) const {
+  // Check for file-handling system call that is not handled by the checker.
+  // FIXME: The checker should be updated to handle all system calls that take
+  // 'FILE*' argument. These are now ignored.
+  if (Kind == PSK_DirectEscapeOnCall && Call->isInSystemHeader())
+return State;
+
+  for (SymbolRef Sym : Escaped) {
+// The symbol escaped.
+// From now the stream can be manipulated in unknown way to the checker,
+// it is not possible to handle it any more.
+// Optimistically, assume that the corresponding file handle will be closed
+// somewhere else.
+// Remove symbol from state so the following stream calls on this symbol are
+// not handled by the checker.
+State = State->remove(Sym);
+  }
+  return State;
+}
+
 void ento::registerStreamChecker(CheckerManager ) {
   Mgr.registerChecker();
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D62922: [WebAssembly] Implement "Reactor" mode

2020-06-04 Thread Bjorn Pettersson via Phabricator via cfe-commits
bjope added inline comments.



Comment at: clang/test/Driver/wasm-toolchain.c:116
+// CHECK-COMMAND: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
+// CHECK-COMMAND: wasm-ld{{.*}}" "crt1.o" "[[temp]]" "-lc" 
"{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
+

bjope wrote:
> This isn't working for me on redhat 7 servers. I get
> ```
>  "wasm-ld" "-L/lib" "/lib/crt1.o" ...
> ```
> No idea why I get the full patch to crt1.o. But it's not matching with the 
> FileCheck pattern.
/full patch/full path/


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62922



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


[PATCH] D81083: [Clang] Allow "vector_size" applied to Booleans

2020-06-04 Thread Sam Elliott via Phabricator via cfe-commits
lenary added inline comments.



Comment at: clang/docs/LanguageExtensions.rst:473
+architectures.  The size parameter of a boolean vector type is the number of
+bits in the vector (for all non-bool vectors, the number refers to the number
+of bytes in the vector).

It would be nice if this aside about non-bool vectors was more prominently 
displayed - it's something I hadn't realised before.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81083



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


[PATCH] D74025: [clangd] Add the missing elaborated types in FindTarget.

2020-06-04 Thread Jeff Trull via Phabricator via cfe-commits
jaafar added a comment.

I'm very happy this fix exists. I see it's in master, but not in 10.0.0 or 
10.0.1-rc1 either. Is there any chance it can be released?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74025



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


[PATCH] D81168: Add support for id-expression in SyntaxTree

2020-06-04 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas updated this revision to Diff 268503.
eduucaldas marked an inline comment as done.
eduucaldas added a comment.

.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81168

Files:
  clang/unittests/Tooling/Syntax/TreeTest.cpp

Index: clang/unittests/Tooling/Syntax/TreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/TreeTest.cpp
+++ clang/unittests/Tooling/Syntax/TreeTest.cpp
@@ -692,6 +692,152 @@
 )txt"));
 }
 
+TEST_P(SyntaxTreeTest, UnqualifiedId) {
+  if (!GetParam().isCXX()) {
+return;
+  }
+  EXPECT_TRUE(treeDumpEqual(
+  R"cpp(
+void test(int b) {
+  int a;
+  a = b;
+}
+)cpp",
+  R"txt(
+*: TranslationUnit
+`-SimpleDeclaration
+  |-void
+  |-SimpleDeclarator
+  | |-test
+  | `-ParametersAndQualifiers
+  |   |-(
+  |   |-SimpleDeclaration
+  |   | |-int
+  |   | `-SimpleDeclarator
+  |   |   `-b
+  |   `-)
+  `-CompoundStatement
+|-{
+|-DeclarationStatement
+| |-SimpleDeclaration
+| | |-int
+| | `-SimpleDeclarator
+| |   `-a
+| `-;
+|-ExpressionStatement
+| |-BinaryOperatorExpression
+| | |-IdExpression
+| | | `-UnqualifiedId
+| | |   `-a
+| | |-=
+| | `-IdExpression
+| |   `-UnqualifiedId
+| | `-b
+| `-;
+`-}
+)txt"));
+}
+
+TEST_P(SyntaxTreeTest, QualifiedId) {
+  if (!GetParam().isCXX()) {
+return;
+  }
+  EXPECT_TRUE(treeDumpEqual(
+  R"cpp(
+namespace a {
+  namespace b {
+struct S {
+  int i;
+  static void f(){}
+};
+  }
+}
+void test(int b) {
+  ::a::b::S::f();
+}
+)cpp",
+  R"txt(
+*: TranslationUnit
+|-NamespaceDefinition
+| |-namespace
+| |-a
+| |-{
+| |-NamespaceDefinition
+| | |-namespace
+| | |-b
+| | |-{
+| | |-SimpleDeclaration
+| | | |-struct
+| | | |-S
+| | | |-{
+| | | |-SimpleDeclaration
+| | | | |-int
+| | | | |-SimpleDeclarator
+| | | | | `-i
+| | | | `-;
+| | | |-SimpleDeclaration
+| | | | |-static
+| | | | |-void
+| | | | |-SimpleDeclarator
+| | | | | |-f
+| | | | | `-ParametersAndQualifiers
+| | | | |   |-(
+| | | | |   `-)
+| | | | `-CompoundStatement
+| | | |   |-{
+| | | |   `-}
+| | | |-}
+| | | `-;
+| | `-}
+| `-}
+`-SimpleDeclaration
+  |-void
+  |-SimpleDeclarator
+  | |-test
+  | `-ParametersAndQualifiers
+  |   |-(
+  |   |-SimpleDeclaration
+  |   | |-int
+  |   | `-SimpleDeclarator
+  |   |   `-b
+  |   `-)
+  `-CompoundStatement
+|-{
+|-DeclarationStatement
+| |-SimpleDeclaration
+| | |-a
+| | |-::
+| | |-b
+| | |-::
+| | |-S
+| | `-SimpleDeclarator
+| |   `-UnknownExpression
+| | `-s
+| `-;
+|-ExpressionStatement
+| |-UnknownExpression
+| | |-IdExpression
+| | | |-NestedNameSpecifier
+| | | | |-GlobalNamespaceSpecifier
+| | | | | `::
+| | | | |-NamespaceNameSpecifier
+| | | | | |-a
+| | | | | `-::
+| | | | |-NamespaceNameSpecifier
+| | | | | |-b
+| | | | | `-::
+| | | | `-TypeNameSpecifier
+| | | |   |-S
+| | | |   `-::
+| | | `-UnqualifiedId
+| | |   `-f
+| | |-(
+| | `-)
+| `-;
+`-}
+)txt"));
+}
+
 TEST_P(SyntaxTreeTest, CxxNullPtrLiteral) {
   if (!GetParam().isCXX11OrLater()) {
 return;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D81157: Propose naming principle for NodeRole and apply it

2020-06-04 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas added inline comments.



Comment at: clang/include/clang/Tooling/Syntax/Nodes.h:94
 /// a binary expression'. Used for implementing accessors.
+// How to name NodeRole:
+// If the child node is a token/keyword, end its name with 'Token'/'Keyword'

gribozavr2 wrote:
> I'd suggest to make this into a doc comment, but phrase it in a way that is 
> useful for users, so that they can understand the pattern too. For example:
> 
> Some roles describe parent/child relations that occur multiple times in 
> language grammar. We define only one role to describe all instances of such 
> recurring relations. For example, grammar for both "if" and "while" 
> statements requires an opening paren and a closing paren. The opening paren 
> token is assigned the `OpenParen` role regardless of whether it appears as a 
> child of `IfStatement` or `WhileStatement` node. More generally, when grammar 
> requires a certain fixed token (like a specific keyword, or an opening 
> paren), we define a role for this token and use it across all grammar rules 
> with the same requirement. Names of such reusable roles end with a `~Token` 
> or a `~Keyword` suffix.
> 
> Some roles are assigned only to child nodes of one specific parent syntax 
> node type. Names of such roles start with the name of the parent syntax tree 
> node type. For example, a syntax node with a role 
> `BinaryOperatorExpression_leftHandSide` can only appear as a child of a 
> `BinaryOperatorExpression` node.
> 
> 
Thank you a lot. This is really well explained



Comment at: clang/include/clang/Tooling/Syntax/Nodes.h:124
   IfStatement_thenStatement,
   IfStatement_elseKeyword,
   IfStatement_elseStatement,

gribozavr2 wrote:
> Shouldn't `elseKeyword` have no prefix?
When a keyword can only be used by IfStatement, then I think it actually helps 
readability to have it prepended with the ParentKind. Here everything is nicely 
grouped, and if someone needs to change IfStatement, it is clear to see where 
to make the change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81157



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


[PATCH] D81168: Add support for id-expression in SyntaxTree

2020-06-04 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas added inline comments.



Comment at: clang/unittests/Tooling/Syntax/TreeTest.cpp:829
+| | | | | `-::
+| | | | `-TypeSpecifier
+| | | |   |-S

eduucaldas wrote:
> Perhaps we shouldn't differ between specifiers as that is semantical 
> information
Followed the [[ https://eel.is/c++draft/expr.prim.id.qual | grammar ]], but 
added specifier in the end as we also hold the `::` and not only the names


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81168



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


[PATCH] D77168: Add a flag to debug automatic variable initialization

2020-06-04 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

In D77168#2070334 , @llozano wrote:

> In D77168#2070083 , @MaskRay wrote:
>
> > In D77168#2070049 , @jcai19 wrote:
> >
> > > In D77168#2069783 , @MaskRay 
> > > wrote:
> > >
> > > > Do we have a mechanism bisecting pragmas? If yes, we can let that tool 
> > > > add `#pragma clang attribute push([[clang::uninitialized]], apply_to = 
> > > > variable)`
> > >
> > >
> > > Not that I am aware of unfortunately. The whole point of having this 
> > > patch is to add the ability to bisect programmatically, along the 
> > > approach of using pragma as introduced in https://reviews.llvm.org/D78693.
> >
> >
> > If we have a mechanism bisecting pragmas, this option will not be needed.
>
>
> I think you are coming late into the discussion. If you read before, We had 
> already agreed that having mechanisms for automatic triaging is "very 
> compelling". The change suggested here just makes automatic triaging much 
> easier at a very low cost.


I expressed my opinion very early in https://reviews.llvm.org/D77168#1955507  
If other reviewers find this useful even if we have a generic framework, I will 
not object.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77168



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


[PATCH] D81157: Propose naming principle for NodeRole and apply it

2020-06-04 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas updated this revision to Diff 268502.
eduucaldas marked 2 inline comments as done.
eduucaldas added a comment.

Fix cout, add explanation


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81157

Files:
  clang/include/clang/Tooling/Syntax/Nodes.h
  clang/lib/Tooling/Syntax/BuildTree.cpp
  clang/lib/Tooling/Syntax/Nodes.cpp

Index: clang/lib/Tooling/Syntax/Nodes.cpp
===
--- clang/lib/Tooling/Syntax/Nodes.cpp
+++ clang/lib/Tooling/Syntax/Nodes.cpp
@@ -110,6 +110,8 @@
 return OS << "CloseParen";
   case syntax::NodeRole::IntroducerKeyword:
 return OS << "IntroducerKeyword";
+  case syntax::NodeRole::LiteralToken:
+return OS << "LiteralToken";
   case syntax::NodeRole::BodyStatement:
 return OS << "BodyStatement";
   case syntax::NodeRole::CaseStatement_value:
@@ -120,18 +122,12 @@
 return OS << "IfStatement_elseKeyword";
   case syntax::NodeRole::IfStatement_elseStatement:
 return OS << "IfStatement_elseStatement";
-  case syntax::NodeRole::IntegerLiteralExpression_literalToken:
-return OS << "IntegerLiteralExpression_literalToken";
-  case syntax::NodeRole::CxxNullPtrExpression_keyword:
-return OS << "CxxNullPtrExpression_keyword";
-  case syntax::NodeRole::UnaryOperatorExpression_operatorToken:
-return OS << "UnaryOperatorExpression_operatorToken";
+  case syntax::NodeRole::OperatorExpression_operatorToken:
+return OS << "OperatorExpression_operatorToken";
   case syntax::NodeRole::UnaryOperatorExpression_operand:
 return OS << "UnaryOperatorExpression_operand";
   case syntax::NodeRole::BinaryOperatorExpression_leftHandSide:
 return OS << "BinaryOperatorExpression_leftHandSide";
-  case syntax::NodeRole::BinaryOperatorExpression_operatorToken:
-return OS << "BinaryOperatorExpression_operatorToken";
   case syntax::NodeRole::BinaryOperatorExpression_rightHandSide:
 return OS << "BinaryOperatorExpression_rightHandSide";
   case syntax::NodeRole::ReturnStatement_value:
@@ -154,8 +150,8 @@
 return OS << "ExplicitTemplateInstantiation_declaration";
   case syntax::NodeRole::ArraySubscript_sizeExpression:
 return OS << "ArraySubscript_sizeExpression";
-  case syntax::NodeRole::TrailingReturnType_arrow:
-return OS << "TrailingReturnType_arrow";
+  case syntax::NodeRole::TrailingReturnType_arrowToken:
+return OS << "TrailingReturnType_arrowToken";
   case syntax::NodeRole::TrailingReturnType_declarator:
 return OS << "TrailingReturnType_declarator";
   case syntax::NodeRole::ParametersAndQualifiers_parameter:
@@ -168,12 +164,12 @@
 
 syntax::Leaf *syntax::IntegerLiteralExpression::literalToken() {
   return llvm::cast_or_null(
-  findChild(syntax::NodeRole::IntegerLiteralExpression_literalToken));
+  findChild(syntax::NodeRole::LiteralToken));
 }
 
 syntax::Leaf *syntax::CxxNullPtrExpression::nullPtrKeyword() {
   return llvm::cast_or_null(
-  findChild(syntax::NodeRole::CxxNullPtrExpression_keyword));
+  findChild(syntax::NodeRole::LiteralToken));
 }
 
 syntax::Expression *syntax::BinaryOperatorExpression::lhs() {
@@ -183,7 +179,7 @@
 
 syntax::Leaf *syntax::UnaryOperatorExpression::operatorToken() {
   return llvm::cast_or_null(
-  findChild(syntax::NodeRole::UnaryOperatorExpression_operatorToken));
+  findChild(syntax::NodeRole::OperatorExpression_operatorToken));
 }
 
 syntax::Expression *syntax::UnaryOperatorExpression::operand() {
@@ -193,7 +189,7 @@
 
 syntax::Leaf *syntax::BinaryOperatorExpression::operatorToken() {
   return llvm::cast_or_null(
-  findChild(syntax::NodeRole::BinaryOperatorExpression_operatorToken));
+  findChild(syntax::NodeRole::OperatorExpression_operatorToken));
 }
 
 syntax::Expression *syntax::BinaryOperatorExpression::rhs() {
@@ -402,7 +398,7 @@
 
 syntax::Leaf *syntax::TrailingReturnType::arrow() {
   return llvm::cast_or_null(
-  findChild(syntax::NodeRole::TrailingReturnType_arrow));
+  findChild(syntax::NodeRole::TrailingReturnType_arrowToken));
 }
 
 syntax::SimpleDeclarator *syntax::TrailingReturnType::declarator() {
Index: clang/lib/Tooling/Syntax/BuildTree.cpp
===
--- clang/lib/Tooling/Syntax/BuildTree.cpp
+++ clang/lib/Tooling/Syntax/BuildTree.cpp
@@ -609,26 +609,22 @@
   }
 
   bool WalkUpFromIntegerLiteral(IntegerLiteral *S) {
-Builder.markChildToken(
-S->getLocation(),
-syntax::NodeRole::IntegerLiteralExpression_literalToken);
+Builder.markChildToken(S->getLocation(), syntax::NodeRole::LiteralToken);
 Builder.foldNode(Builder.getExprRange(S),
  new (allocator()) syntax::IntegerLiteralExpression, S);
 return true;
   }
 
   bool WalkUpFromCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *S) {
-Builder.markChildToken(S->getLocation(),
-   

[PATCH] D81163: [AST][RecoveryExpr] Preserve the AST for invalid conditions.

2020-06-04 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: sammccall.
Herald added a project: clang.

Tested with enabling "-frecovery-ast", only 1 failure, which is
an improvement of secondary diagnostic.

  --
  error: 'error' diagnostics seen but not expected:
File /workspace/llvm-project/clang/test/SemaTemplate/instantiate-expr-3.cpp 
Line 68: invalid operands to binary expression ('N1::X' and 'int')
  1 error generated.
  
  --


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81163

Files:
  clang/lib/Sema/SemaExpr.cpp
  clang/test/AST/ast-dump-recovery.cpp


Index: clang/test/AST/ast-dump-recovery.cpp
===
--- clang/test/AST/ast-dump-recovery.cpp
+++ clang/test/AST/ast-dump-recovery.cpp
@@ -211,3 +211,30 @@
 } NoCrashOnInvalidInitList = {
   .abc = nullptr,
 };
+
+void InvalidCondition() {
+  // CHECK:  IfStmt {{.*}}
+  // CHECK-NEXT: |-RecoveryExpr {{.*}}  '' 
contains-errors
+  // CHECK-NEXT: | `-UnresolvedLookupExpr {{.*}} 
+  if (invalid()) {}
+
+  // CHECK:  WhileStmt {{.*}}
+  // CHECK-NEXT: |-RecoveryExpr {{.*}}  '' 
contains-errors
+  // CHECK-NEXT: | `-UnresolvedLookupExpr {{.*}} 
+  while (invalid()) {}
+
+  // CHECK:  SwitchStmt {{.*}}
+  // CHECK-NEXT: |-RecoveryExpr {{.*}} '' contains-errors
+  // CHECK-NEXT: | `-UnresolvedLookupExpr {{.*}} 
+  switch(invalid()) {
+case 1:
+  break;
+  }
+  // FIXME: figure out why the type of ConditionalOperator is not int.
+  // CHECK:  ConditionalOperator {{.*}} '' contains-errors
+  // CHECK-NEXT: |-RecoveryExpr {{.*}} '' contains-errors
+  // CHECK-NEXT: | `-UnresolvedLookupExpr {{.*}}
+  // CHECK-NEXT: |-IntegerLiteral {{.*}} 'int' 1
+  // CHECK-NEXT: `-IntegerLiteral {{.*}} 'int' 2
+  invalid() ? 1 : 2;
+}
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -18420,9 +18420,12 @@
 Cond = CheckSwitchCondition(Loc, SubExpr);
 break;
   }
-  if (Cond.isInvalid())
-return ConditionError();
-
+  if (Cond.isInvalid()) {
+Cond = CreateRecoveryExpr(SubExpr->getBeginLoc(), SubExpr->getEndLoc(),
+  {SubExpr});
+if (!Cond.get())
+  return ConditionError();
+  }
   // FIXME: FullExprArg doesn't have an invalid bit, so check nullness instead.
   FullExprArg FullExpr = MakeFullExpr(Cond.get(), Loc);
   if (!FullExpr.get())


Index: clang/test/AST/ast-dump-recovery.cpp
===
--- clang/test/AST/ast-dump-recovery.cpp
+++ clang/test/AST/ast-dump-recovery.cpp
@@ -211,3 +211,30 @@
 } NoCrashOnInvalidInitList = {
   .abc = nullptr,
 };
+
+void InvalidCondition() {
+  // CHECK:  IfStmt {{.*}}
+  // CHECK-NEXT: |-RecoveryExpr {{.*}}  '' contains-errors
+  // CHECK-NEXT: | `-UnresolvedLookupExpr {{.*}} 
+  if (invalid()) {}
+
+  // CHECK:  WhileStmt {{.*}}
+  // CHECK-NEXT: |-RecoveryExpr {{.*}}  '' contains-errors
+  // CHECK-NEXT: | `-UnresolvedLookupExpr {{.*}} 
+  while (invalid()) {}
+
+  // CHECK:  SwitchStmt {{.*}}
+  // CHECK-NEXT: |-RecoveryExpr {{.*}} '' contains-errors
+  // CHECK-NEXT: | `-UnresolvedLookupExpr {{.*}} 
+  switch(invalid()) {
+case 1:
+  break;
+  }
+  // FIXME: figure out why the type of ConditionalOperator is not int.
+  // CHECK:  ConditionalOperator {{.*}} '' contains-errors
+  // CHECK-NEXT: |-RecoveryExpr {{.*}} '' contains-errors
+  // CHECK-NEXT: | `-UnresolvedLookupExpr {{.*}}
+  // CHECK-NEXT: |-IntegerLiteral {{.*}} 'int' 1
+  // CHECK-NEXT: `-IntegerLiteral {{.*}} 'int' 2
+  invalid() ? 1 : 2;
+}
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -18420,9 +18420,12 @@
 Cond = CheckSwitchCondition(Loc, SubExpr);
 break;
   }
-  if (Cond.isInvalid())
-return ConditionError();
-
+  if (Cond.isInvalid()) {
+Cond = CreateRecoveryExpr(SubExpr->getBeginLoc(), SubExpr->getEndLoc(),
+  {SubExpr});
+if (!Cond.get())
+  return ConditionError();
+  }
   // FIXME: FullExprArg doesn't have an invalid bit, so check nullness instead.
   FullExprArg FullExpr = MakeFullExpr(Cond.get(), Loc);
   if (!FullExpr.get())
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D79715: [clang-format] Update GoogleStyle for C# code to match Google's internal C# style guide

2020-06-04 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9520bf146dd3: [clang-format] Update GoogleStyle for C# code 
to match Googles internal C#… (authored by Jonathan Coe 
jb...@google.com).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79715

Files:
  clang/lib/Format/Format.cpp
  clang/unittests/Format/FormatTestCSharp.cpp


Index: clang/unittests/Format/FormatTestCSharp.cpp
===
--- clang/unittests/Format/FormatTestCSharp.cpp
+++ clang/unittests/Format/FormatTestCSharp.cpp
@@ -583,8 +583,7 @@
   FormatStyle Style = getGoogleStyle(FormatStyle::LK_CSharp);
 
   verifyFormat(R"(//
-PrintOrderDetails(orderNum: 31, productName: "Red Mug",
-  sellerName: "Gift Shop");)",
+PrintOrderDetails(orderNum: 31, productName: "Red Mug", sellerName: "Gift 
Shop");)",
Style);
 
   // Ensure that trailing comments do not cause problems.
@@ -641,8 +640,7 @@
 get { return _seconds / 3600; }
 set {
   if (value < 0 || value > 24)
-throw new ArgumentOutOfRangeException(
-$"{nameof(value)} must be between 0 and 24.");
+throw new ArgumentOutOfRangeException($"{nameof(value)} must be 
between 0 and 24.");
   _seconds = value * 3600;
 }
   }
@@ -755,7 +753,9 @@
 
   verifyFormat(R"(//
 public class A {
-  void foo() { int? value = some.bar(); }
+  void foo() {
+int? value = some.bar();
+  }
 })",
Style); // int? is nullable not a conditional expression.
 
@@ -800,16 +800,15 @@
 where TKey : IComparable
 where TVal : IMyInterface {
   public void MyMethod(T t)
-  where T : IMyInterface { doThing(); }
+  where T : IMyInterface {
+doThing();
+  }
 })",
Style);
 
   verifyFormat(R"(//
 class ItemFactory
-where T : new(),
-  IAnInterface,
-  IAnotherInterface,
-  IAnotherInterfaceStill {})",
+where T : new(), IAnInterface, IAnotherInterface, 
IAnotherInterfaceStill {})",
Style);
 
   Style.ColumnLimit = 50; // Force lines to be wrapped.
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -14,6 +14,7 @@
 
 #include "clang/Format/Format.h"
 #include "AffectedRangeManager.h"
+#include "BreakableToken.h"
 #include "ContinuationIndenter.h"
 #include "FormatInternal.h"
 #include "FormatTokenLexer.h"
@@ -1068,6 +1069,12 @@
 // #imports, etc.)
 GoogleStyle.IncludeStyle.IncludeBlocks =
 tooling::IncludeStyle::IBS_Preserve;
+  } else if (Language == FormatStyle::LK_CSharp) {
+GoogleStyle.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Empty;
+GoogleStyle.AllowShortIfStatementsOnASingleLine = FormatStyle::SIS_Never;
+GoogleStyle.BreakStringLiterals = false;
+GoogleStyle.ColumnLimit = 100;
+GoogleStyle.NamespaceIndentation = FormatStyle::NI_All;
   }
 
   return GoogleStyle;


Index: clang/unittests/Format/FormatTestCSharp.cpp
===
--- clang/unittests/Format/FormatTestCSharp.cpp
+++ clang/unittests/Format/FormatTestCSharp.cpp
@@ -583,8 +583,7 @@
   FormatStyle Style = getGoogleStyle(FormatStyle::LK_CSharp);
 
   verifyFormat(R"(//
-PrintOrderDetails(orderNum: 31, productName: "Red Mug",
-  sellerName: "Gift Shop");)",
+PrintOrderDetails(orderNum: 31, productName: "Red Mug", sellerName: "Gift Shop");)",
Style);
 
   // Ensure that trailing comments do not cause problems.
@@ -641,8 +640,7 @@
 get { return _seconds / 3600; }
 set {
   if (value < 0 || value > 24)
-throw new ArgumentOutOfRangeException(
-$"{nameof(value)} must be between 0 and 24.");
+throw new ArgumentOutOfRangeException($"{nameof(value)} must be between 0 and 24.");
   _seconds = value * 3600;
 }
   }
@@ -755,7 +753,9 @@
 
   verifyFormat(R"(//
 public class A {
-  void foo() { int? value = some.bar(); }
+  void foo() {
+int? value = some.bar();
+  }
 })",
Style); // int? is nullable not a conditional expression.
 
@@ -800,16 +800,15 @@
 where TKey : IComparable
 where TVal : IMyInterface {
   public void MyMethod(T t)
-  where T : IMyInterface { doThing(); }
+  where T : IMyInterface {
+doThing();
+  }
 })",
Style);
 
   verifyFormat(R"(//
 class ItemFactory
-where T : new(),
-  IAnInterface,
-  IAnotherInterface,
-  IAnotherInterfaceStill {})",
+where T : new(), IAnInterface, IAnotherInterface, IAnotherInterfaceStill {})",
Style);
 
   Style.ColumnLimit = 50; // Force lines to be wrapped.
Index: clang/lib/Format/Format.cpp
===
--- 

[PATCH] D79781: [OpenCL] Add cl_khr_extended_subgroup extensions

2020-06-04 Thread Piotr Fusik via Phabricator via cfe-commits
PiotrFusik marked 2 inline comments as done.
PiotrFusik added inline comments.



Comment at: clang/lib/Headers/opencl-c.h:15594
+int __ovld sub_group_elect(void);
+int __ovld sub_group_non_uniform_all( int predicate );
+int __ovld sub_group_non_uniform_any( int predicate );

Anastasia wrote:
> PiotrFusik wrote:
> > Anastasia wrote:
> > > PiotrFusik wrote:
> > > > Anastasia wrote:
> > > > > PiotrFusik wrote:
> > > > > > Anastasia wrote:
> > > > > > > PiotrFusik wrote:
> > > > > > > > Anastasia wrote:
> > > > > > > > > Ideally `convergent` attribute was intended to be used in the 
> > > > > > > > > non-divergent scenarios. So I don't know if it's going to do 
> > > > > > > > > what is needed here. Did you look into this already?
> > > > > > > > > 
> > > > > > > > > If we look at the Clang documentation it says:
> > > > > > > > > 
> > > > > > > > > > In languages designed for SPMD/SIMT programming model, e.g. 
> > > > > > > > > > OpenCL or CUDA, the call instructions of a function with 
> > > > > > > > > > this attribute must be executed by all work items or 
> > > > > > > > > > threads in a work group or sub group.
> > > > > > > > > 
> > > > > > > > > 
> > > > > > > > > I remember @nhaehnle  was looking at using `convergent` with 
> > > > > > > > > operations in the divergent control flow some time ago 
> > > > > > > > > https://reviews.llvm.org/D68994? I am not sure where this 
> > > > > > > > > thread ended up and whether we can expect this to work 
> > > > > > > > > currently?
> > > > > > > > Thanks for pointing this out! My understanding of the 
> > > > > > > > `convergent` attribute was that it's for uniform control flow, 
> > > > > > > > as per the documentation you cited.
> > > > > > > > A quick check shows that Intel Graphics Compiler doesn't suffer 
> > > > > > > > from this invalid optimization.
> > > > > > > > Yet I agree that the functions should be marked somehow. It is 
> > > > > > > > with `__conv` ?
> > > > > > > 
> > > > > > > > A quick check shows that Intel Graphics Compiler doesn't suffer 
> > > > > > > > from this invalid optimization.
> > > > > > > 
> > > > > > > Did you check on the examples that @nhaehnle provided in the 
> > > > > > > review?
> > > > > > > 
> > > > > > > > Yet I agree that the functions should be marked somehow. It is 
> > > > > > > > with __conv ?
> > > > > > > 
> > > > > > > I am not sure there is a solution to this in the upstream LLVM at 
> > > > > > > present. I am hoping @nhaehnle  can provide us more information. 
> > > > > > > Alternatively, we could run his examples against the latest LLVM 
> > > > > > > revision to see if the problem still remains or not. I am not 
> > > > > > > saying that it should block this review, I am ok that we commit 
> > > > > > > your patch but if we know already that this functionality can't 
> > > > > > > be fully supported it would be good to at least create a bug to 
> > > > > > > OpenCL component to record this.
> > > > > > The following example:
> > > > > > ```
> > > > > > kernel void test(global int *data)
> > > > > > {
> > > > > > uint id = (uint) get_global_id(0);
> > > > > > if (id < 4)
> > > > > > data[id] = sub_group_elect();
> > > > > > else
> > > > > > data[id] = sub_group_elect();
> > > > > > }
> > > > > > ```
> > > > > > with `clang -S -emit-llvm` emits invalid code both with and without 
> > > > > > the `convergent` attribute.
> > > > > > 
> > > > > > We don't have this problem in our Intel Graphics Compiler though. 
> > > > > > That's because we replace the subgroup functions with internal 
> > > > > > intrinsics early enough. These intrinsics are marked with both the 
> > > > > > `convergent` and `inaccessiblememonly` attributes. Then in the 
> > > > > > `SimplifyCFG` pass we prevent optimization if both of these 
> > > > > > attributes are present: 
> > > > > > https://github.com/intel/intel-graphics-compiler/blob/master/IGC/Compiler/GenTTI.cpp#L397
> > > > > > 
> > > > > > I don't understand what can go wrong in the second example (with 
> > > > > > the jump threading pass) ?
> > > > > > 
> > > > > Thanks for checking. Do you mind creating a bug to clang for now 
> > > > > under OpenCL component 
> > > > > https://bugs.llvm.org/enter_bug.cgi?product=clang although we might 
> > > > > reclassify this for a wider scope later on.
> > > > > 
> > > > > 
> > > > > 
> > > > > >  Then in the SimplifyCFG pass we prevent optimization if both of 
> > > > > > these attributes are present: 
> > > > > > https://github.com/intel/intel-graphics-compiler/blob/master/IGC/Compiler/GenTTI.cpp#L397
> > > > > 
> > > > > I see. Perhaps we need to come up with a new semantic of `convergent` 
> > > > > and update LLVM passes... or maybe we have to introduce a new 
> > > > > attribute. Not sure. I suggest we add a comment to 
> > > > > https://reviews.llvm.org/D68994 and see if it gets picked up.
> > > > > 
> > > > > 
> > > > Do you mean a bug for the invalid 

[PATCH] D81173: [clangd] Change ParseInputs to store FSProvider rather than VFS

2020-06-04 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: sammccall.
Herald added subscribers: cfe-commits, usaxena95, arphaman, jkorous, MaskRay, 
javed.absar, ilya-biryukov.
Herald added a project: clang.

This ensures ParseInputs provides a read-only access to FS.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81173

Files:
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/Compiler.cpp
  clang-tools-extra/clangd/Compiler.h
  clang-tools-extra/clangd/ParsedAST.cpp
  clang-tools-extra/clangd/Preamble.cpp
  clang-tools-extra/clangd/index/Background.cpp
  clang-tools-extra/clangd/support/FSProvider.cpp
  clang-tools-extra/clangd/support/FSProvider.h
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
  clang-tools-extra/clangd/unittests/CompilerTests.cpp
  clang-tools-extra/clangd/unittests/FileIndexTests.cpp
  clang-tools-extra/clangd/unittests/HeadersTests.cpp
  clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
  clang-tools-extra/clangd/unittests/PreambleTests.cpp
  clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
  clang-tools-extra/clangd/unittests/TestFS.h
  clang-tools-extra/clangd/unittests/TestTU.cpp
  clang-tools-extra/clangd/unittests/TestTU.h

Index: clang-tools-extra/clangd/unittests/TestTU.h
===
--- clang-tools-extra/clangd/unittests/TestTU.h
+++ clang-tools-extra/clangd/unittests/TestTU.h
@@ -19,6 +19,7 @@
 
 #include "Compiler.h"
 #include "ParsedAST.h"
+#include "TestFS.h"
 #include "index/Index.h"
 #include "support/Path.h"
 #include "llvm/ADT/StringMap.h"
@@ -69,7 +70,7 @@
   // Suppress this behavior by adding an 'error-ok' comment to the code.
   ParsedAST build() const;
   std::shared_ptr preamble() const;
-  ParseInputs inputs() const;
+  ParseInputs inputs(MockFSProvider ) const;
   SymbolSlab headerSymbols() const;
   RefSlab headerRefs() const;
   std::unique_ptr index() const;
Index: clang-tools-extra/clangd/unittests/TestTU.cpp
===
--- clang-tools-extra/clangd/unittests/TestTU.cpp
+++ clang-tools-extra/clangd/unittests/TestTU.cpp
@@ -20,7 +20,7 @@
 namespace clang {
 namespace clangd {
 
-ParseInputs TestTU::inputs() const {
+ParseInputs TestTU::inputs(MockFSProvider ) const {
   std::string FullFilename = testPath(Filename),
   FullHeaderName = testPath(HeaderFilename),
   ImportThunk = testPath("import_thunk.h");
@@ -29,10 +29,10 @@
   // guard without messing up offsets). In this case, use an intermediate file.
   std::string ThunkContents = "#import \"" + FullHeaderName + "\"\n";
 
-  llvm::StringMap Files(AdditionalFiles);
-  Files[FullFilename] = Code;
-  Files[FullHeaderName] = HeaderCode;
-  Files[ImportThunk] = ThunkContents;
+  FSProvider.Files = AdditionalFiles;
+  FSProvider.Files[FullFilename] = Code;
+  FSProvider.Files[FullHeaderName] = HeaderCode;
+  FSProvider.Files[ImportThunk] = ThunkContents;
 
   ParseInputs Inputs;
   auto  = Inputs.CompileCommand.CommandLine;
@@ -54,7 +54,7 @@
   Inputs.CompileCommand.Filename = FullFilename;
   Inputs.CompileCommand.Directory = testRoot();
   Inputs.Contents = Code;
-  Inputs.FS = buildTestFS(Files);
+  Inputs.FSProvider = 
   Inputs.Opts = ParseOptions();
   Inputs.Opts.BuildRecoveryAST = true;
   Inputs.Opts.PreserveRecoveryASTType = true;
@@ -67,7 +67,8 @@
 }
 
 std::shared_ptr TestTU::preamble() const {
-  auto Inputs = inputs();
+  MockFSProvider FSProvider;
+  auto Inputs = inputs(FSProvider);
   IgnoreDiagnostics Diags;
   auto CI = buildCompilerInvocation(Inputs, Diags);
   assert(CI && "Failed to build compilation invocation.");
@@ -77,7 +78,8 @@
 }
 
 ParsedAST TestTU::build() const {
-  auto Inputs = inputs();
+  MockFSProvider FSProvider;
+  auto Inputs = inputs(FSProvider);
   StoreDiags Diags;
   auto CI = buildCompilerInvocation(Inputs, Diags);
   assert(CI && "Failed to build compilation invocation.");
Index: clang-tools-extra/clangd/unittests/TestFS.h
===
--- clang-tools-extra/clangd/unittests/TestFS.h
+++ clang-tools-extra/clangd/unittests/TestFS.h
@@ -31,11 +31,12 @@
 class MockFSProvider : public FileSystemProvider {
 public:
   IntrusiveRefCntPtr getFileSystem() const override {
-return buildTestFS(Files);
+return buildTestFS(Files, Timestamps);
   }
 
   // If relative paths are used, they are resolved with testPath().
   llvm::StringMap Files;
+  llvm::StringMap Timestamps;
 };
 
 // A Compilation database that returns a fixed set of compile flags.
Index: clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
===
--- clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
+++ clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
@@ -16,6 +16,7 @@
 #include "TestFS.h"
 #include "support/Cancellation.h"
 #include 

[PATCH] D81122: Reland: Use -fdebug-compilation-dir to form absolute paths in coverage mappings

2020-06-04 Thread Keith Smiley via Phabricator via cfe-commits
keith updated this revision to Diff 268510.
keith added a comment.

Update relative paths to include the leading ./

This makes these remappings more analogous to lldb's source remapping, and
makes using `-path-equivalence` with `llvm-cov` more familiar.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81122

Files:
  clang/lib/CodeGen/CoverageMappingGen.cpp
  clang/lib/CodeGen/CoverageMappingGen.h
  clang/test/CoverageMapping/debug-dir.cpp


Index: clang/test/CoverageMapping/debug-dir.cpp
===
--- /dev/null
+++ clang/test/CoverageMapping/debug-dir.cpp
@@ -0,0 +1,16 @@
+// %s expands to an absolute path, so to test relative paths we need to create 
a
+// clean directory, put the source there, and cd into it.
+// RUN: rm -rf %t
+// RUN: mkdir -p %t/foo/bar/baz
+// RUN: cp %s %t/foo/bar/baz/debug-dir.cpp
+// RUN: cd %t/foo/bar
+
+// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -emit-llvm 
-mllvm -enable-name-compression=false -main-file-name debug-dir.cpp 
baz/debug-dir.cpp  -o - | FileCheck -check-prefix=ABSOLUTE %s
+//
+// ABSOLUTE: @__llvm_coverage_mapping = 
{{.*"\\01.*foo.*bar.*baz.*debug-dir\.cpp}}
+
+// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -emit-llvm 
-mllvm -enable-name-compression=false -main-file-name debug-dir.cpp 
baz/debug-dir.cpp -fdebug-compilation-dir . -o - | FileCheck 
-check-prefix=RELATIVE %s
+//
+// RELATIVE: @__llvm_coverage_mapping = 
{{.*"\\01[^/]*\.(/|)baz.*debug-dir\.cpp}}
+
+void f1() {}
Index: clang/lib/CodeGen/CoverageMappingGen.h
===
--- clang/lib/CodeGen/CoverageMappingGen.h
+++ clang/lib/CodeGen/CoverageMappingGen.h
@@ -60,14 +60,16 @@
   llvm::SmallDenseMap FileEntries;
   std::vector FunctionNames;
   std::vector FunctionRecords;
+  SmallString<256> CWD;
+
+  std::string normalizeFilename(StringRef Filename);
 
   /// Emit a function record.
   void emitFunctionMappingRecord(const FunctionInfo ,
  uint64_t FilenamesRef);
 
 public:
-  CoverageMappingModuleGen(CodeGenModule , CoverageSourceInfo )
-  : CGM(CGM), SourceInfo(SourceInfo) {}
+  CoverageMappingModuleGen(CodeGenModule , CoverageSourceInfo );
 
   CoverageSourceInfo () const {
 return SourceInfo;
Index: clang/lib/CodeGen/CoverageMappingGen.cpp
===
--- clang/lib/CodeGen/CoverageMappingGen.cpp
+++ clang/lib/CodeGen/CoverageMappingGen.cpp
@@ -1279,13 +1279,6 @@
   }
 };
 
-std::string normalizeFilename(StringRef Filename) {
-  llvm::SmallString<256> Path(Filename);
-  llvm::sys::fs::make_absolute(Path);
-  llvm::sys::path::remove_dots(Path, /*remove_dot_dot=*/true);
-  return std::string(Path);
-}
-
 } // end anonymous namespace
 
 static void dump(llvm::raw_ostream , StringRef FunctionName,
@@ -1318,6 +1311,24 @@
   }
 }
 
+CoverageMappingModuleGen::CoverageMappingModuleGen(
+CodeGenModule , CoverageSourceInfo )
+: CGM(CGM), SourceInfo(SourceInfo) {
+  // Honor -fdebug-compilation-dir in paths in coverage data. Otherwise, use 
the
+  // regular working directory when normalizing paths.
+  if (!CGM.getCodeGenOpts().DebugCompilationDir.empty())
+CWD = CGM.getCodeGenOpts().DebugCompilationDir;
+  else
+llvm::sys::fs::current_path(CWD);
+}
+
+std::string CoverageMappingModuleGen::normalizeFilename(StringRef Filename) {
+  llvm::SmallString<256> Path(Filename);
+  llvm::sys::path::remove_dots(Path, /*remove_dot_dot=*/true);
+  llvm::sys::fs::make_absolute(CWD, Path);
+  return Path.str().str();
+}
+
 static std::string getInstrProfSection(const CodeGenModule ,
llvm::InstrProfSectKind SK) {
   return llvm::getInstrProfSectionName(


Index: clang/test/CoverageMapping/debug-dir.cpp
===
--- /dev/null
+++ clang/test/CoverageMapping/debug-dir.cpp
@@ -0,0 +1,16 @@
+// %s expands to an absolute path, so to test relative paths we need to create a
+// clean directory, put the source there, and cd into it.
+// RUN: rm -rf %t
+// RUN: mkdir -p %t/foo/bar/baz
+// RUN: cp %s %t/foo/bar/baz/debug-dir.cpp
+// RUN: cd %t/foo/bar
+
+// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -emit-llvm -mllvm -enable-name-compression=false -main-file-name debug-dir.cpp baz/debug-dir.cpp  -o - | FileCheck -check-prefix=ABSOLUTE %s
+//
+// ABSOLUTE: @__llvm_coverage_mapping = {{.*"\\01.*foo.*bar.*baz.*debug-dir\.cpp}}
+
+// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -emit-llvm -mllvm -enable-name-compression=false -main-file-name debug-dir.cpp baz/debug-dir.cpp -fdebug-compilation-dir . -o - | FileCheck -check-prefix=RELATIVE %s
+//
+// RELATIVE: @__llvm_coverage_mapping = {{.*"\\01[^/]*\.(/|)baz.*debug-dir\.cpp}}
+
+void f1() {}
Index: 

[PATCH] D81157: Propose naming principle for NodeRole and apply it

2020-06-04 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 added inline comments.



Comment at: clang/include/clang/Tooling/Syntax/Nodes.h:110
+/// BinaryOperatorExpression_leftHandSide can only appear as a child of a
+/// BinaryOperatorExpression node.end with `NodeKind_` of the parent
 enum class NodeRole : uint8_t {

There are some leftovers of old text after the period.



Comment at: clang/lib/Tooling/Syntax/Nodes.cpp:154
+  case syntax::NodeRole::ArrowToken:
+return OS << "ArrowToken";
   case syntax::NodeRole::TrailingReturnType_declarator:

Please reorder.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81157



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


[PATCH] D69987: [RISCV] Assemble/Disassemble v-ext instructions.

2020-06-04 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

Drive-by comment: the clang side change isn't tightly coupled with the LLVM 
side changes. It should be a separate patch.




Comment at: llvm/test/MC/RISCV/rvv/add.s:1
+# RUN: llvm-mc -triple=riscv64 -show-encoding --mattr=+experimental-v < %s \
+# RUN:| FileCheck %s --check-prefixes=CHECK-ENCODING,CHECK-INST

`< %s` -> `%s`

ditto for every other test.

A check prefix does not have to start with `CHECK-`.
If shortening the prefix can avoid wrapped lines, probably worth considering it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69987



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


[PATCH] D81157: Propose naming principle for NodeRole and apply it

2020-06-04 Thread Dmitri Gribenko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG42f6fec3878d: Propose naming principle for NodeRole and 
apply it (authored by eduucaldas, committed by gribozavr).

Changed prior to commit:
  https://reviews.llvm.org/D81157?vs=268519=268543#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81157

Files:
  clang/include/clang/Tooling/Syntax/Nodes.h
  clang/lib/Tooling/Syntax/BuildTree.cpp
  clang/lib/Tooling/Syntax/Nodes.cpp

Index: clang/lib/Tooling/Syntax/Nodes.cpp
===
--- clang/lib/Tooling/Syntax/Nodes.cpp
+++ clang/lib/Tooling/Syntax/Nodes.cpp
@@ -110,6 +110,12 @@
 return OS << "CloseParen";
   case syntax::NodeRole::IntroducerKeyword:
 return OS << "IntroducerKeyword";
+  case syntax::NodeRole::LiteralToken:
+return OS << "LiteralToken";
+  case syntax::NodeRole::ArrowToken:
+return OS << "ArrowToken";
+  case syntax::NodeRole::ExternKeyword:
+return OS << "ExternKeyword";
   case syntax::NodeRole::BodyStatement:
 return OS << "BodyStatement";
   case syntax::NodeRole::CaseStatement_value:
@@ -120,18 +126,12 @@
 return OS << "IfStatement_elseKeyword";
   case syntax::NodeRole::IfStatement_elseStatement:
 return OS << "IfStatement_elseStatement";
-  case syntax::NodeRole::IntegerLiteralExpression_literalToken:
-return OS << "IntegerLiteralExpression_literalToken";
-  case syntax::NodeRole::CxxNullPtrExpression_keyword:
-return OS << "CxxNullPtrExpression_keyword";
-  case syntax::NodeRole::UnaryOperatorExpression_operatorToken:
-return OS << "UnaryOperatorExpression_operatorToken";
+  case syntax::NodeRole::OperatorExpression_operatorToken:
+return OS << "OperatorExpression_operatorToken";
   case syntax::NodeRole::UnaryOperatorExpression_operand:
 return OS << "UnaryOperatorExpression_operand";
   case syntax::NodeRole::BinaryOperatorExpression_leftHandSide:
 return OS << "BinaryOperatorExpression_leftHandSide";
-  case syntax::NodeRole::BinaryOperatorExpression_operatorToken:
-return OS << "BinaryOperatorExpression_operatorToken";
   case syntax::NodeRole::BinaryOperatorExpression_rightHandSide:
 return OS << "BinaryOperatorExpression_rightHandSide";
   case syntax::NodeRole::ReturnStatement_value:
@@ -148,14 +148,10 @@
 return OS << "SimpleDeclaration_declarator";
   case syntax::NodeRole::TemplateDeclaration_declaration:
 return OS << "TemplateDeclaration_declaration";
-  case syntax::NodeRole::ExplicitTemplateInstantiation_externKeyword:
-return OS << "ExplicitTemplateInstantiation_externKeyword";
   case syntax::NodeRole::ExplicitTemplateInstantiation_declaration:
 return OS << "ExplicitTemplateInstantiation_declaration";
   case syntax::NodeRole::ArraySubscript_sizeExpression:
 return OS << "ArraySubscript_sizeExpression";
-  case syntax::NodeRole::TrailingReturnType_arrow:
-return OS << "TrailingReturnType_arrow";
   case syntax::NodeRole::TrailingReturnType_declarator:
 return OS << "TrailingReturnType_declarator";
   case syntax::NodeRole::ParametersAndQualifiers_parameter:
@@ -168,12 +164,12 @@
 
 syntax::Leaf *syntax::IntegerLiteralExpression::literalToken() {
   return llvm::cast_or_null(
-  findChild(syntax::NodeRole::IntegerLiteralExpression_literalToken));
+  findChild(syntax::NodeRole::LiteralToken));
 }
 
 syntax::Leaf *syntax::CxxNullPtrExpression::nullPtrKeyword() {
   return llvm::cast_or_null(
-  findChild(syntax::NodeRole::CxxNullPtrExpression_keyword));
+  findChild(syntax::NodeRole::LiteralToken));
 }
 
 syntax::Expression *syntax::BinaryOperatorExpression::lhs() {
@@ -183,7 +179,7 @@
 
 syntax::Leaf *syntax::UnaryOperatorExpression::operatorToken() {
   return llvm::cast_or_null(
-  findChild(syntax::NodeRole::UnaryOperatorExpression_operatorToken));
+  findChild(syntax::NodeRole::OperatorExpression_operatorToken));
 }
 
 syntax::Expression *syntax::UnaryOperatorExpression::operand() {
@@ -193,7 +189,7 @@
 
 syntax::Leaf *syntax::BinaryOperatorExpression::operatorToken() {
   return llvm::cast_or_null(
-  findChild(syntax::NodeRole::BinaryOperatorExpression_operatorToken));
+  findChild(syntax::NodeRole::OperatorExpression_operatorToken));
 }
 
 syntax::Expression *syntax::BinaryOperatorExpression::rhs() {
@@ -367,7 +363,7 @@
 
 syntax::Leaf *syntax::ExplicitTemplateInstantiation::externKeyword() {
   return llvm::cast_or_null(
-  findChild(syntax::NodeRole::ExplicitTemplateInstantiation_externKeyword));
+  findChild(syntax::NodeRole::ExternKeyword));
 }
 
 syntax::Declaration *syntax::ExplicitTemplateInstantiation::declaration() {
@@ -402,7 +398,7 @@
 
 syntax::Leaf *syntax::TrailingReturnType::arrowToken() {
   return llvm::cast_or_null(
-  findChild(syntax::NodeRole::TrailingReturnType_arrow));
+  findChild(syntax::NodeRole::ArrowToken));
 }
 
 

[clang] 714e84b - [SemaOverload] Use iterator_range to iterate over VectorTypes (NFC).

2020-06-04 Thread Florian Hahn via cfe-commits

Author: Florian Hahn
Date: 2020-06-04T20:47:16+01:00
New Revision: 714e84be4615d6e1195f2798c0c3c8c54017dd5f

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

LOG: [SemaOverload] Use iterator_range to iterate over VectorTypes (NFC).

We can simplify the code a bit by using iterator_range instead of
plain iterators. Matrix type support here (added in 6f6e91d19337)
already uses an iterator_range.

Reviewers: rjmccall, arphaman, jfb, Bigcheese

Reviewed By: rjmccall

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

Added: 


Modified: 
clang/lib/Sema/SemaOverload.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index 11b6e40e8cd4..f3ac2036cb0d 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -7745,8 +7745,7 @@ class BuiltinCandidateTypeSet  {
   /// enumeration_end - Past the last enumeration type found;
   iterator enumeration_end() { return EnumerationTypes.end(); }
 
-  iterator vector_begin() { return VectorTypes.begin(); }
-  iterator vector_end() { return VectorTypes.end(); }
+  llvm::iterator_range vector_types() { return VectorTypes; }
 
   llvm::iterator_range matrix_types() { return MatrixTypes; }
 
@@ -8292,13 +8291,8 @@ class BuiltinOperatorOverloadBuilder {
 }
 
 // Extension: We also add these operators for vector types.
-for (BuiltinCandidateTypeSet::iterator
-  Vec = CandidateTypes[0].vector_begin(),
-   VecEnd = CandidateTypes[0].vector_end();
- Vec != VecEnd; ++Vec) {
-  QualType VecTy = *Vec;
+for (QualType VecTy : CandidateTypes[0].vector_types())
   S.AddBuiltinCandidate(, Args, CandidateSet);
-}
   }
 
   // C++ [over.built]p8:
@@ -8332,13 +8326,8 @@ class BuiltinOperatorOverloadBuilder {
 }
 
 // Extension: We also add this operator for vector types.
-for (BuiltinCandidateTypeSet::iterator
-  Vec = CandidateTypes[0].vector_begin(),
-   VecEnd = CandidateTypes[0].vector_end();
- Vec != VecEnd; ++Vec) {
-  QualType VecTy = *Vec;
+for (QualType VecTy : CandidateTypes[0].vector_types())
   S.AddBuiltinCandidate(, Args, CandidateSet);
-}
   }
 
   // C++ [over.match.oper]p16:
@@ -8569,18 +8558,11 @@ class BuiltinOperatorOverloadBuilder {
 
 // Extension: Add the binary operators ==, !=, <, <=, >=, >, *, /, and the
 // conditional operator for vector types.
-for (BuiltinCandidateTypeSet::iterator
-  Vec1 = CandidateTypes[0].vector_begin(),
-   Vec1End = CandidateTypes[0].vector_end();
- Vec1 != Vec1End; ++Vec1) {
-  for (BuiltinCandidateTypeSet::iterator
-Vec2 = CandidateTypes[1].vector_begin(),
- Vec2End = CandidateTypes[1].vector_end();
-   Vec2 != Vec2End; ++Vec2) {
-QualType LandR[2] = { *Vec1, *Vec2 };
+for (QualType Vec1Ty : CandidateTypes[0].vector_types())
+  for (QualType Vec2Ty : CandidateTypes[1].vector_types()) {
+QualType LandR[2] = {Vec1Ty, Vec2Ty};
 S.AddBuiltinCandidate(LandR, Args, CandidateSet);
   }
-}
   }
 
   /// Add binary operator overloads for each candidate matrix type M1, M2:
@@ -8861,30 +8843,23 @@ class BuiltinOperatorOverloadBuilder {
 }
 
 // Extension: Add the binary operators =, +=, -=, *=, /= for vector types.
-for (BuiltinCandidateTypeSet::iterator
-  Vec1 = CandidateTypes[0].vector_begin(),
-   Vec1End = CandidateTypes[0].vector_end();
- Vec1 != Vec1End; ++Vec1) {
-  for (BuiltinCandidateTypeSet::iterator
-Vec2 = CandidateTypes[1].vector_begin(),
- Vec2End = CandidateTypes[1].vector_end();
-   Vec2 != Vec2End; ++Vec2) {
+for (QualType Vec1Ty : CandidateTypes[0].vector_types())
+  for (QualType Vec2Ty : CandidateTypes[0].vector_types()) {
 QualType ParamTypes[2];
-ParamTypes[1] = *Vec2;
+ParamTypes[1] = Vec2Ty;
 // Add this built-in operator as a candidate (VQ is empty).
-ParamTypes[0] = S.Context.getLValueReferenceType(*Vec1);
+ParamTypes[0] = S.Context.getLValueReferenceType(Vec1Ty);
 S.AddBuiltinCandidate(ParamTypes, Args, CandidateSet,
   /*IsAssignmentOperator=*/isEqualOp);
 
 // Add this built-in operator as a candidate (VQ is 'volatile').
 if (VisibleTypeConversionsQuals.hasVolatile()) {
-  ParamTypes[0] = S.Context.getVolatileType(*Vec1);
+  ParamTypes[0] = S.Context.getVolatileType(Vec1Ty);
   ParamTypes[0] = S.Context.getLValueReferenceType(ParamTypes[0]);
   S.AddBuiltinCandidate(ParamTypes, Args, CandidateSet,
 /*IsAssignmentOperator=*/isEqualOp);

[clang] bd1c03d - [OPENMP50]Codegen for inscan reductions in worksharing directives.

2020-06-04 Thread Alexey Bataev via cfe-commits

Author: Alexey Bataev
Date: 2020-06-04T16:29:33-04:00
New Revision: bd1c03d7b7c8bdd80b534cf2fa956c36a2f8249f

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

LOG: [OPENMP50]Codegen for inscan reductions in worksharing directives.

Summary:
Implemented codegen for reduction clauses with inscan modifiers in
worksharing constructs.

Emits the code for the directive with inscan reductions.
The code is the following:
```
size num_iters = ;
 buffer[num_iters];
for (i: 0..) {
  ;
  buffer[i] = red;
}
for (int k = 0; k != ceil(log2(num_iters)); ++k)
for (size cnt = last_iter; cnt >= pow(2, k); --k)
  buffer[i] op= buffer[i-pow(2,k)];
for (0..) {
  red = InclusiveScan ? buffer[i] : buffer[i-1];
  ;
}
```

Reviewers: jdoerfert

Subscribers: yaxunl, guansong, arphaman, cfe-commits, caomhin

Tags: #clang

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

Added: 
clang/test/OpenMP/for_scan_codegen.cpp

Modified: 
clang/include/clang/AST/OpenMPClause.h
clang/include/clang/AST/RecursiveASTVisitor.h
clang/lib/AST/OpenMPClause.cpp
clang/lib/AST/StmtProfile.cpp
clang/lib/CodeGen/CGStmt.cpp
clang/lib/CodeGen/CGStmtOpenMP.cpp
clang/lib/CodeGen/CodeGenFunction.h
clang/lib/Sema/SemaOpenMP.cpp
clang/lib/Serialization/ASTReader.cpp
clang/lib/Serialization/ASTWriter.cpp
clang/test/OpenMP/scan_messages.cpp
clang/tools/libclang/CIndex.cpp

Removed: 




diff  --git a/clang/include/clang/AST/OpenMPClause.h 
b/clang/include/clang/AST/OpenMPClause.h
index 91e4d011a3e9..6c2ca1cb1008 100644
--- a/clang/include/clang/AST/OpenMPClause.h
+++ b/clang/include/clang/AST/OpenMPClause.h
@@ -2839,6 +2839,41 @@ class OMPReductionClause final
 return llvm::makeArrayRef(getRHSExprs().end(), varlist_size());
   }
 
+  /// Set list of helper copy operations for inscan reductions.
+  /// The form is: Temps[i] = LHS[i];
+  void setInscanCopyOps(ArrayRef Ops);
+
+  /// Get the list of helper inscan copy operations.
+  MutableArrayRef getInscanCopyOps() {
+return MutableArrayRef(getReductionOps().end(), varlist_size());
+  }
+  ArrayRef getInscanCopyOps() const {
+return llvm::makeArrayRef(getReductionOps().end(), varlist_size());
+  }
+
+  /// Set list of helper temp vars for inscan copy array operations.
+  void setInscanCopyArrayTemps(ArrayRef CopyArrayTemps);
+
+  /// Get the list of helper inscan copy temps.
+  MutableArrayRef getInscanCopyArrayTemps() {
+return MutableArrayRef(getInscanCopyOps().end(), varlist_size());
+  }
+  ArrayRef getInscanCopyArrayTemps() const {
+return llvm::makeArrayRef(getInscanCopyOps().end(), varlist_size());
+  }
+
+  /// Set list of helper temp elements vars for inscan copy array operations.
+  void setInscanCopyArrayElems(ArrayRef CopyArrayElems);
+
+  /// Get the list of helper inscan copy temps.
+  MutableArrayRef getInscanCopyArrayElems() {
+return MutableArrayRef(getInscanCopyArrayTemps().end(),
+   varlist_size());
+  }
+  ArrayRef getInscanCopyArrayElems() const {
+return llvm::makeArrayRef(getInscanCopyArrayTemps().end(), varlist_size());
+  }
+
 public:
   /// Creates clause with a list of variables \a VL.
   ///
@@ -2869,6 +2904,12 @@ class OMPReductionClause final
   /// \endcode
   /// Required for proper codegen of final reduction operation performed by the
   /// reduction clause.
+  /// \param CopyOps List of copy operations for inscan reductions:
+  /// \code
+  /// TempExprs = LHSExprs;
+  /// \endcode
+  /// \param CopyArrayTemps Temp arrays for prefix sums.
+  /// \param CopyArrayElems Temp arrays for prefix sums.
   /// \param PreInit Statement that must be executed before entering the OpenMP
   /// region with this clause.
   /// \param PostUpdate Expression that must be executed after exit from the
@@ -2880,13 +2921,18 @@ class OMPReductionClause final
  ArrayRef VL, NestedNameSpecifierLoc QualifierLoc,
  const DeclarationNameInfo , ArrayRef Privates,
  ArrayRef LHSExprs, ArrayRef RHSExprs,
- ArrayRef ReductionOps, Stmt *PreInit, Expr *PostUpdate);
+ ArrayRef ReductionOps, ArrayRef CopyOps,
+ ArrayRef CopyArrayTemps, ArrayRef CopyArrayElems,
+ Stmt *PreInit, Expr *PostUpdate);
 
   /// Creates an empty clause with the place for \a N variables.
   ///
   /// \param C AST context.
   /// \param N The number of variables.
-  static OMPReductionClause *CreateEmpty(const ASTContext , unsigned N);
+  /// \param Modifier Reduction modifier.
+  static OMPReductionClause *
+  CreateEmpty(const ASTContext , unsigned N,
+  OpenMPReductionClauseModifier Modifier);
 
   /// Returns modifier.
   OpenMPReductionClauseModifier getModifier() const { return Modifier; }
@@ -2943,6 +2989,36 @@ class 

[PATCH] D81176: [HIP] Add default header and include path

2020-06-04 Thread Artem Belevich via Phabricator via cfe-commits
tra accepted this revision.
tra added a comment.
This revision is now accepted and ready to land.

Thank you for the patch. This will make my life a lot easier.

There are a few nits, but it's LGTM in general.

Do I understand it correctly that for detection of HIP installation all we need 
is to find the bitcode libraries?




Comment at: clang/lib/Driver/ToolChains/ROCm.h:68
+
+  // CUDA architectures for which we have raised an error in
+  // CheckRocmVersionSupportsArch.

CUDA -> GPU?
Looks like there are number of other mentions of CUDA that should be fixed.



Comment at: clang/lib/Headers/__clang_hip_math.h:26
+__DEVICE__
+inline uint64_t __make_mantissa_base8(const char *tagp) {
+  uint64_t r = 0;

Arguments for compiler-internal declarations and local symbols should all be 
prefixed with `__`.




Comment at: clang/lib/Headers/__clang_hip_math.h:931-935
+#pragma push_macro("__DEF_FLOAT_FUN")
+#pragma push_macro("__DEF_FLOAT_FUN2")
+#pragma push_macro("__DEF_FLOAT_FUN2I")
+#pragma push_macro("__HIP_OVERLOAD")
+#pragma push_macro("__HIP_OVERLOAD2")

The macros pushed here do not match the set of macros defined below.
E.g. `__HIP_OVERLOAD` vs `__HIP_OVERLOAD1`, `__DEF_FLOAT_FUN` vs. `__DEF_FUN1`, 
etc.


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

https://reviews.llvm.org/D81176



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


[PATCH] D72778: [Matrix] Add __builtin_matrix_transpose to Clang.

2020-06-04 Thread Florian Hahn via Phabricator via cfe-commits
fhahn updated this revision to Diff 268569.
fhahn added a comment.

Ping.

Simplified code and update tests to use more targeted check lines.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72778

Files:
  clang/include/clang/Basic/Builtins.def
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/matrix-type-builtins.c
  clang/test/CodeGenCXX/matrix-type-builtins.cpp
  clang/test/Sema/matrix-type-builtins.c
  clang/test/SemaCXX/matrix-type-builtins.cpp

Index: clang/test/SemaCXX/matrix-type-builtins.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/matrix-type-builtins.cpp
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 %s -fenable-matrix -pedantic -std=c++11 -verify -triple=x86_64-apple-darwin9
+
+template 
+struct MyMatrix {
+  using matrix_t = EltTy __attribute__((matrix_type(Rows, Columns)));
+
+  matrix_t value;
+};
+
+template 
+typename MyMatrix::matrix_t transpose(MyMatrix ) {
+  char *v1 = __builtin_matrix_transpose(A.value);
+  // expected-error@-1 {{cannot initialize a variable of type 'char *' with an rvalue of type 'unsigned int __attribute__((matrix_type(3, 2)))'}}
+  // expected-error@-2 {{cannot initialize a variable of type 'char *' with an rvalue of type 'unsigned int __attribute__((matrix_type(3, 3)))'}}
+
+  __builtin_matrix_transpose(A);
+  // expected-error@-1 {{first argument must be a matrix}}
+  // expected-error@-2 {{first argument must be a matrix}}
+
+  return __builtin_matrix_transpose(A.value);
+  // expected-error@-1 {{cannot initialize return object of type 'typename MyMatrix::matrix_t' (aka 'unsigned int __attribute__((matrix_type(2, 3)))') with an rvalue of type 'unsigned int __attribute__((matrix_type(3, 2)))'}}
+  // expected-error@-2 {{cannot initialize return object of type 'typename MyMatrix::matrix_t' (aka 'unsigned int __attribute__((matrix_type(2, 3)))') with an rvalue of type 'unsigned int __attribute__((matrix_type(3, 3)))'}}
+}
+
+void test_transpose_template(unsigned *Ptr1, float *Ptr2) {
+  MyMatrix Mat1;
+  MyMatrix Mat2;
+  Mat1.value = *((decltype(Mat1)::matrix_t *)Ptr1);
+  Mat1.value = transpose(Mat1);
+  // expected-note@-1 {{in instantiation of function template specialization 'transpose' requested here}}
+
+  Mat1.value = transpose(Mat2);
+  // expected-note@-1 {{in instantiation of function template specialization 'transpose' requested here}}
+}
Index: clang/test/Sema/matrix-type-builtins.c
===
--- /dev/null
+++ clang/test/Sema/matrix-type-builtins.c
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 %s -fenable-matrix -pedantic -verify -triple=x86_64-apple-darwin9
+
+typedef float sx5x10_t __attribute__((matrix_type(5, 10)));
+typedef int ix3x2_t __attribute__((matrix_type(3, 2)));
+
+void transpose(sx5x10_t a, ix3x2_t b, int *c, int d) {
+  a = __builtin_matrix_transpose(b);
+  // expected-error@-1 {{assigning to 'sx5x10_t' (aka 'float __attribute__((matrix_type(5, 10)))') from incompatible type 'int __attribute__((matrix_type(2, 3)))'}}
+  b = __builtin_matrix_transpose(b);
+  // expected-error@-1 {{assigning to 'ix3x2_t' (aka 'int __attribute__((matrix_type(3, 2)))') from incompatible type 'int __attribute__((matrix_type(2, 3)))'}}
+  __builtin_matrix_transpose(c);
+  // expected-error@-1 {{first argument must be a matrix}}
+  __builtin_matrix_transpose(d);
+  // expected-error@-1 {{first argument must be a matrix}}
+  __builtin_matrix_transpose("test");
+  // expected-error@-1 {{first argument must be a matrix}}
+}
Index: clang/test/CodeGenCXX/matrix-type-builtins.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/matrix-type-builtins.cpp
@@ -0,0 +1,53 @@
+// RUN: %clang_cc1 -fenable-matrix -triple x86_64-apple-darwin %s -emit-llvm -disable-llvm-passes -o - -std=c++17 | FileCheck %s
+
+// Tests for the matrix type builtins.
+
+template 
+using matrix_t = EltTy __attribute__((matrix_type(Rows, Columns)));
+
+template 
+struct MyMatrix {
+  matrix_t value;
+};
+
+template 
+MyMatrix transpose(const MyMatrix ) {
+  MyMatrix Res;
+  Res.value = __builtin_matrix_transpose(M.value);
+  return Res;
+}
+
+void test_transpose_template1() {
+  // CHECK-LABEL: define void @_Z24test_transpose_template1v()
+  // CHECK: call void @_Z9transposeIiLj4ELj10EE8MyMatrixIT_XT1_EXT0_EERKS0_IS1_XT0_EXT1_EE(%struct.MyMatrix.0* sret align 4 %M1_t, %struct.MyMatrix* nonnull align 4 dereferenceable(160) %M1)
+
+  // CHECK-LABEL: define linkonce_odr void @_Z9transposeIiLj4ELj10EE8MyMatrixIT_XT1_EXT0_EERKS0_IS1_XT0_EXT1_EE(
+  // CHECK: [[M:%.*]] = load <40 x i32>, <40 x i32>* {{.*}}, align 4
+  // CHECK-NEXT:[[M_T:%.*]] = call <40 x i32> @llvm.matrix.transpose.v40i32(<40 x i32> [[M]], i32 4, i32 

[PATCH] D81138: [SemaOverload] Use iterator_range to iterate over VectorTypes (NFC).

2020-06-04 Thread Florian Hahn via Phabricator via cfe-commits
fhahn added a comment.

In D81138#2074313 , @rjmccall wrote:

> Thanks, LGTM.  (But you can use QualType by value.)


Thanks, changed in the committed version.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81138



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


[PATCH] D81169: [clangd] Improve hover on arguments to function call

2020-06-04 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet marked an inline comment as done.
kadircet added a comment.

thanks! that looks really useful, especially knowing when a parameter is being 
passed as a ref/val.




Comment at: clang-tools-extra/clangd/Hover.cpp:292
 
+void fillParam(const ParmVarDecl *PVD, HoverInfo::Param ,
+   const PrintingPolicy ) {

why not return a `HoverInfo::Param` instead ?



Comment at: clang-tools-extra/clangd/Hover.cpp:525
 
+  if (const auto *Var = dyn_cast(D)) {
+// Check if we are inside CallExpr

umm, is this a fixme or a leftover? I suppose it is from a previous version of 
the patch.



Comment at: clang-tools-extra/clangd/Hover.cpp:698
+// information about that argument.
+void maybeAddCalleeArgInfo(const SelectionTree::Node *N, HoverInfo ,
+   const PrintingPolicy ) {

nit: move into anonymous namespace



Comment at: clang-tools-extra/clangd/Hover.cpp:700
+   const PrintingPolicy ) {
+  if (!N || !N->outerImplicit().Parent)
+return;

nit: extract `N->outerImplicit()` to a variable, it seems to be repeated along.



Comment at: clang-tools-extra/clangd/Hover.cpp:713
+  }
+  if (I >= CE->getNumArgs())
+return;

i don't think this is necessary, we are baling out if `FD->getNumParams() <= I` 
anyways.



Comment at: clang-tools-extra/clangd/Hover.cpp:716
+  // Extract matching argument from function declaration.
+  if (const FunctionDecl *FD = CE->getDirectCallee()) {
+if (FD->isOverloadedOperator() || FD->isVariadic() ||

nit: put this before arg index finding logic and do an early exit:

```
if(!CE) return;
auto *FD = CE->getDirectCallee();
if(!FD || FD->isOverloaded || variadic..) return;
```

after doing this you can also change the arg index finding logic to:
```
auto *SelectedArg = N->outerImplicit().ASTNode.get();
if(!SelectedParam) return; // you can also move this above other exit 
conditions.
for (unsigned I = 0; I < min(CE->getNumArgs, FD->getNumParams())...) { // I 
suppose these two can be different in presence of default params ?
  if (CE->getArg(I) == SelectedArg) {
  // do magic;
  break;
  }
}
``



Comment at: clang-tools-extra/clangd/Hover.cpp:717
+  if (const FunctionDecl *FD = CE->getDirectCallee()) {
+if (FD->isOverloadedOperator() || FD->isVariadic() ||
+FD->getNumParams() <= I)

i can see the reason for variadics, but why bail out on overloaded operators? 
also can we have some tests for these two?



Comment at: clang-tools-extra/clangd/Hover.cpp:787
   HI->Value = printExprValue(N, AST.getASTContext());
+maybeAddCalleeArgInfo(N, *HI, AST.getASTContext().getPrintingPolicy());
   } else if (const Expr *E = N->ASTNode.get()) {

this place is getting crowded. maybe we should start passing `N` into 
`getHoverContents` and encapsulate the logic in there or something. no action 
needed, just thinking out loud.



Comment at: clang-tools-extra/clangd/Hover.cpp:893
+
+  if (CalleeArgInfo) {
+Output.addRuler();

let's put this after `Size` and before `Documentation` we've been keeping the 
documentation and definition as kind of a `footer` for a while now.
that would also drop the need for a ruler.



Comment at: clang-tools-extra/clangd/Hover.cpp:897
+llvm::raw_string_ostream OS(Buffer);
+OS << "Passed as " << *CalleeArgInfo;
+Output.addParagraph().appendText(OS.str());

i bet there will always be some people getting confused no matter what we say 
in here (especially since we are not just printing the type, and I totally find 
printing param name useful especially in case of literals). But to align with 
other types of information we provide maybe say:

`Substitutes: ` ?



Comment at: clang-tools-extra/clangd/unittests/HoverTests.cpp:728
+C c;
+c.fun([[^a]], b);
+  }

can you also add a test for a literal ?



Comment at: clang-tools-extra/clangd/unittests/HoverTests.cpp:2093
+
+Passed as int arg_a = 7)",
   }};

i find showing the default value a little bit confusing, as user is providing a 
different value. i can also see some value in it though, so up to you.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81169



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


[PATCH] D81188: [RISCV] Support experimental v extensions.

2020-06-04 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/test/Driver/riscv-arch.c:364
+
+// RUN: %clang -target riscv32-unknown-elf -march=rv32iv -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck 
-check-prefix=RV32-EXPERIMENTAL-V-NOFLAG %s

For the RUN lines, I'd prefer the suggestion in 
https://reviews.llvm.org/D80838?id=267971#inline-744878

You replace -fsyntax-only to -c if it is too long.




Comment at: clang/test/Driver/riscv-arch.c:379
+
+// RUN: %clang -target riscv32-unknown-elf -march=rv32iv0p8 
-menable-experimental-extensions -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck 
-check-prefix=RV32-EXPERIMENTAL-V-GOODVERS %s

Should there be a p7 test? Along with a p8 test, we can know that p8 is the 
split line.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81188



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


[PATCH] D81192: [OPENMP]Fix PR45854: prevent code movement out of the critical region.

2020-06-04 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev created this revision.
ABataev added reviewers: jdoerfert, mikerice.
Herald added subscribers: llvm-commits, sstefan1, jfb, guansong, hiraditya, 
yaxunl.
Herald added projects: clang, LLVM.

Need to emit memory barriers upon enter/exit to/from critical region to
prevent code movement.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81192

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/test/OpenMP/critical_codegen.cpp
  clang/test/OpenMP/openmp_win_codegen.cpp
  clang/test/OpenMP/simd_codegen.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp

Index: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
===
--- llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -814,13 +814,14 @@
   Instruction *ExitCall = Builder.CreateCall(ExitRTLFn, Args);
 
   return EmitOMPInlinedRegion(OMPD, EntryCall, ExitCall, BodyGenCB, FiniCB,
-  /*Conditional*/ false, /*hasFinalize*/ true);
+  /*Conditional*/ false, /*hasFinalize*/ true,
+  /*WithMemBarrier=*/true);
 }
 
 OpenMPIRBuilder::InsertPointTy OpenMPIRBuilder::EmitOMPInlinedRegion(
 Directive OMPD, Instruction *EntryCall, Instruction *ExitCall,
 BodyGenCallbackTy BodyGenCB, FinalizeCallbackTy FiniCB, bool Conditional,
-bool HasFinalize) {
+bool HasFinalize, bool WithMemBarrier) {
 
   if (HasFinalize)
 FinalizationStack.push_back({FiniCB, OMPD, /*IsCancellable*/ false});
@@ -837,6 +838,8 @@
 
   Builder.SetInsertPoint(EntryBB->getTerminator());
   emitCommonDirectiveEntry(OMPD, EntryCall, ExitBB, Conditional);
+  if (WithMemBarrier)
+Builder.CreateFence(AtomicOrdering::Acquire);
 
   // generate body
   BodyGenCB(/* AllocaIP */ InsertPointTy(),
@@ -861,7 +864,7 @@
 assert(FiniBB->getTerminator()->getNumSuccessors() == 1 &&
FiniBB->getTerminator()->getSuccessor(0) == ExitBB &&
"Unexpected control flow graph state!!");
-emitCommonDirectiveExit(OMPD, FinIP, ExitCall, HasFinalize);
+emitCommonDirectiveExit(OMPD, FinIP, ExitCall, HasFinalize, WithMemBarrier);
 assert(FiniBB->getUniquePredecessor()->getUniqueSuccessor() == FiniBB &&
"Unexpected Control Flow State!");
 MergeBlockIntoPredecessor(FiniBB);
@@ -919,7 +922,7 @@
 
 OpenMPIRBuilder::InsertPointTy OpenMPIRBuilder::emitCommonDirectiveExit(
 omp::Directive OMPD, InsertPointTy FinIP, Instruction *ExitCall,
-bool HasFinalize) {
+bool HasFinalize, bool WithMemBarrier) {
 
   Builder.restoreIP(FinIP);
 
@@ -940,6 +943,8 @@
 Builder.SetInsertPoint(FiniBBTI);
   }
 
+  if (WithMemBarrier)
+Builder.CreateFence(AtomicOrdering::Release);
   // place the Exitcall as last instruction before Finalization block terminator
   ExitCall->removeFromParent();
   Builder.Insert(ExitCall);
Index: llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
===
--- llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
+++ llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
@@ -354,12 +354,15 @@
   /// \param HasFinalize indicate if the directive will require finalization
   /// and has a finalization callback in the stack that
   ///should be called.
+  /// \param WithMemBarrier true if the memory fence instructios are required to
+  /// prevent optimizations.
   ///
   /// \return The insertion position in exit block
   InsertPointTy emitCommonDirectiveExit(omp::Directive OMPD,
 InsertPointTy FinIP,
 Instruction *ExitCall,
-bool HasFinalize = true);
+bool HasFinalize = true,
+bool WithMemBarrier = false);
 
   /// Common Interface to generate OMP inlined regions
   ///
@@ -374,6 +377,8 @@
   /// \param HasFinalize indicate if the directive will require finalization
   /// and has a finalization callback in the stack that
   /// shouldbe called.
+  /// \param WithMemBarrier true if the memory fence instructios are required to
+  /// prevent optimizations.
   ///
   /// \return The insertion point after the region
 
@@ -381,7 +386,7 @@
   EmitOMPInlinedRegion(omp::Directive OMPD, Instruction *EntryCall,
Instruction *ExitCall, BodyGenCallbackTy BodyGenCB,
FinalizeCallbackTy FiniCB, bool Conditional = false,
-   bool HasFinalize = true);
+   bool HasFinalize = true, bool WithMemBarrier = false);
 
   /// Get the platform-specific name separator.
   /// \param Parts different parts of the final name that needs separation
Index: clang/test/OpenMP/simd_codegen.cpp
===
--- 

[PATCH] D80802: [RISCV] Upgrade RVV MC to v0.9.

2020-06-04 Thread Evandro Menezes via Phabricator via cfe-commits
evandro added a comment.

Again, the `clang` part should be split in another patch and be made a child of 
D81188 .




Comment at: llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp:297
+LMUL_F8 = 5,
+LMUL_F4 = 6,
+LMUL_F2 = 7

This and the next value don't need to be specified.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80802



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


[PATCH] D75181: [AArch64] Handle BTI/PAC in case of generated functions.

2020-06-04 Thread Daniel Kiss via Phabricator via cfe-commits
danielkiss added a comment.

depends on D80791 


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

https://reviews.llvm.org/D75181



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


[PATCH] D80743: (PR46111) Desugar Elaborated types in Deduction Guides.

2020-06-04 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

In D80743#2074121 , @erichkeane wrote:

> @rsmith I think this implements what you've suggested?


Yes, thanks.

> This seems to 'work' for a small subset of works, but it doesn't properly 
> register the typedef to the LocalInstantiationScope, so the normal template 
> instantiation (like here 
> https://github.com/llvm/llvm-project/blob/master/clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp#L156)
>  ends up hitting the 'findInstantiationOf' assert here: 
> https://github.com/llvm/llvm-project/blob/master/clang/lib/Sema/SemaTemplateInstantiate.cpp#L3564

Hm. Yes, that'd be a problem. To fix that, we'll need to transform the typedef 
declarations as part of transforming the deduction guide. Roughly-speaking, 
we've transformed

  template struct A {
using U = X1;
A(X2);
  };

into something like

  template A(X2) -> A {
using U = X1;
  };

... and the problem is that we need to substitute into the new `using U =` 
typedef before we form a use of `U` when producing the substituted type of the 
alias declaration.

There are a couple of ways we could approach this:

1. when we start transforming a deduction guide, we can walk its `TypedefDecl` 
children, and instantiate those into new typedef declarations immediately, so 
that later references to them work
2. when we reach the reference to the typedef declaration (in 
`FindInstantiatedDecl`, when we see a declaration whose decl context is a 
deduction guide), instantiate the declaration then

These are distinguishable by an example such as:

  template struct Type { using type = typename T::type; };
  struct B { using type = int; };
  template struct A {
using type = Type::type;
A(T, typename T::type, type); // #1
A(...); // #2
  };
  A a(1, 2, 3);

For which option 1 would result in a hard error when substituting T=int into 
the injected typedef for #1, but option 2 would accept, because substitution 
stops at the 'typename T::type' without ever reaching the typedef.

For that reason I think option 2 is the way to go. We already have some logic 
for this in `FindInstantiatedDecl`; search there for `NeedInstantiate` and try 
extending it from local classes and enums to also cover typedefs whose decl 
context is a deduction guide. (You'll need a matching change in 
`findInstantiationOf` to return `nullptr` in that case. This code doesn't seem 
very well factored...)




Comment at: clang/lib/Sema/SemaTemplate.cpp:1969-1970
+SemaRef.getASTContext(),
+SemaRef.getASTContext().getTranslationUnitDecl(), SourceLocation(),
+SourceLocation(), TL.getTypedefNameDecl()->getIdentifier(), TSI);
+MaterializedTypedefs.push_back(Decl);

I think it would be a good idea to retain the source location from the original 
typedef (and to produce a `TypeAliasDecl` if that's what we started with); if 
any diagnostics end up referring to this typedef, we will want them to point to 
the one in the class template (and describe it as a "typedef declaration" or 
"alias declaration" as appropriate).


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

https://reviews.llvm.org/D80743



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


[PATCH] D79948: [OPENMP50]Codegen for inscan reductions in worksharing directives.

2020-06-04 Thread Alexey Bataev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGbd1c03d7b7c8: [OPENMP50]Codegen for inscan reductions in 
worksharing directives. (authored by ABataev).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79948

Files:
  clang/include/clang/AST/OpenMPClause.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/lib/AST/OpenMPClause.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/CodeGen/CGStmt.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/OpenMP/for_scan_codegen.cpp
  clang/test/OpenMP/scan_messages.cpp
  clang/tools/libclang/CIndex.cpp

Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -2376,6 +2376,17 @@
   for (auto *E : C->reduction_ops()) {
 Visitor->AddStmt(E);
   }
+  if (C->getModifier() == clang::OMPC_REDUCTION_inscan) {
+for (auto *E : C->copy_ops()) {
+  Visitor->AddStmt(E);
+}
+for (auto *E : C->copy_array_temps()) {
+  Visitor->AddStmt(E);
+}
+for (auto *E : C->copy_array_elems()) {
+  Visitor->AddStmt(E);
+}
+  }
 }
 void OMPClauseEnqueue::VisitOMPTaskReductionClause(
 const OMPTaskReductionClause *C) {
Index: clang/test/OpenMP/scan_messages.cpp
===
--- clang/test/OpenMP/scan_messages.cpp
+++ clang/test/OpenMP/scan_messages.cpp
@@ -19,32 +19,32 @@
 #pragma omp for simd reduction(inscan, +: argc)
   for (int i = 0; i < 10; ++i)
 if (argc)
-#pragma omp scan inclusive(argc) // expected-error {{'#pragma omp scan' cannot be an immediate substatement}}
+#pragma omp scan inclusive(argc) // expected-error {{'#pragma omp scan' cannot be an immediate substatement}} expected-error {{orphaned 'omp scan' directives are prohibited; perhaps you forget to enclose the directive into a for, simd, for simd, parallel for, or parallel for simd region?}}
 if (argc) {
 #pragma omp scan inclusive(argc) // expected-error {{orphaned 'omp scan' directives are prohibited; perhaps you forget to enclose the directive into a for, simd, for simd, parallel for, or parallel for simd region?}}
 }
 #pragma omp simd reduction(inscan, +: argc)
   for (int i = 0; i < 10; ++i)
   while (argc)
-#pragma omp scan inclusive(argc) // expected-error {{'#pragma omp scan' cannot be an immediate substatement}}
+#pragma omp scan inclusive(argc) // expected-error {{'#pragma omp scan' cannot be an immediate substatement}} expected-error {{orphaned 'omp scan' directives are prohibited; perhaps you forget to enclose the directive into a for, simd, for simd, parallel for, or parallel for simd region?}}
 while (argc) {
 #pragma omp scan inclusive(argc) // expected-error {{orphaned 'omp scan' directives are prohibited; perhaps you forget to enclose the directive into a for, simd, for simd, parallel for, or parallel for simd region?}}
 }
 #pragma omp simd reduction(inscan, +: argc)
   for (int i = 0; i < 10; ++i)
   do
-#pragma omp scan inclusive(argc) // expected-error {{'#pragma omp scan' cannot be an immediate substatement}}
+#pragma omp scan inclusive(argc) // expected-error {{'#pragma omp scan' cannot be an immediate substatement}} expected-error {{orphaned 'omp scan' directives are prohibited; perhaps you forget to enclose the directive into a for, simd, for simd, parallel for, or parallel for simd region?}}
 while (argc)
   ;
-#pragma omp simd reduction(inscan, +: argc)
+#pragma omp simd reduction(inscan, +: argc) // expected-error {{the inscan reduction list item must appear as a list item in an 'inclusive' or 'exclusive' clause on an inner 'omp scan' directive}}
   for (int i = 0; i < 10; ++i)
   do {
-#pragma omp scan inclusive(argc)
+#pragma omp scan inclusive(argc) // expected-error {{orphaned 'omp scan' directives are prohibited; perhaps you forget to enclose the directive into a for, simd, for simd, parallel for, or parallel for simd region?}}
   } while (argc);
 #pragma omp simd reduction(inscan, +: argc)
   for (int i = 0; i < 10; ++i)
   switch (argc)
-#pragma omp scan inclusive(argc) // expected-error {{'#pragma omp scan' cannot be an immediate substatement}}
+#pragma omp scan inclusive(argc) // expected-error {{'#pragma omp scan' cannot be an immediate substatement}} expected-error {{orphaned 'omp scan' directives are prohibited; perhaps you forget to enclose the directive into a for, simd, for simd, parallel for, or parallel for simd region?}}
 switch (argc)
 case 1:
 #pragma omp scan inclusive(argc) // expected-error {{'#pragma omp scan' cannot be an immediate substatement}} expected-error {{orphaned 'omp scan' directives are prohibited; perhaps you forget to enclose the 

[PATCH] D81192: [OPENMP]Fix PR45854: prevent code movement out of the critical region.

2020-06-04 Thread Mike Rice via Phabricator via cfe-commits
mikerice added a comment.

Is it possible to have the same problem with other directives, like 'omp 
single' or 'omp master'?  I haven't seen any test fail for those yet though.




Comment at: llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h:357
   ///should be called.
+  /// \param WithMemBarrier true if the memory fence instructios are required 
to
+  /// prevent optimizations.

instructions



Comment at: llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h:380
   /// shouldbe called.
+  /// \param WithMemBarrier true if the memory fence instructios are required 
to
+  /// prevent optimizations.

instructions


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81192



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


[PATCH] D80301: [yaml][clang-tidy] Fix new line YAML serialization

2020-06-04 Thread Dmitry Polukhin via Phabricator via cfe-commits
DmitryPolukhin updated this revision to Diff 268583.
DmitryPolukhin added a comment.

Apply suggested changes with string split


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80301

Files:
  clang/include/clang/Tooling/ReplacementsYaml.h
  llvm/lib/Support/YAMLTraits.cpp
  llvm/unittests/Support/YAMLIOTest.cpp


Index: llvm/unittests/Support/YAMLIOTest.cpp
===
--- llvm/unittests/Support/YAMLIOTest.cpp
+++ llvm/unittests/Support/YAMLIOTest.cpp
@@ -274,8 +274,8 @@
 
 TEST(YAMLIO, MultilineStrings) {
   WithStringField Original;
-  Original.str1 = "a multiline string\nfoobarbaz";
-  Original.str2 = "another one\rfoobarbaz";
+  Original.str1 = "a\n\nmultiline\nstring\nfoobarbaz";
+  Original.str2 = "another one\rfoobarbaz\n";
   Original.str3 = "a one-line string";
 
   std::string Serialized;
@@ -285,10 +285,10 @@
 YOut << Original;
   }
   auto Expected = "---\n"
-  "str1:'a multiline string\n"
+  "str1:'a\n\n\n\nmultiline\n\nstring\n\n"
   "foobarbaz'\n"
   "str2:'another one\r"
-  "foobarbaz'\n"
+  "foobarbaz\n\n'\n"
   "str3:a one-line string\n"
   "...\n";
   ASSERT_EQ(Serialized, Expected);
Index: llvm/lib/Support/YAMLTraits.cpp
===
--- llvm/lib/Support/YAMLTraits.cpp
+++ llvm/lib/Support/YAMLTraits.cpp
@@ -876,13 +876,33 @@
 }
 
 void ScalarTraits::output(const std::string , void *,
- raw_ostream ) {
-  Out << Val;
+   raw_ostream ) {
+  SmallVector Lines;
+  StringRef(Val).split(Lines, '\n');
+  bool First = true;
+  for (StringRef Line : Lines) {
+if (First)
+  First = false;
+else
+  Out << "\n\n";
+Out << Line;
+  }
 }
 
 StringRef ScalarTraits::input(StringRef Scalar, void *,
- std::string ) {
-  Val = Scalar.str();
+   std::string ) {
+  Val.clear();
+  size_t CurrentPos = 0;
+  size_t LineBreakPos = Scalar.find('\n');
+  while (LineBreakPos != std::string::npos) {
+// '\n\n' convert to '\n' and don't copy single '\n'.
+if (CurrentPos + 1 < Scalar.size() && Scalar[LineBreakPos + 1] == '\n')
+  ++LineBreakPos;
+Val += Scalar.substr(CurrentPos, LineBreakPos - CurrentPos);
+CurrentPos = LineBreakPos + 1;
+LineBreakPos = Scalar.find('\n', CurrentPos);
+  }
+  Val += Scalar.substr(CurrentPos, Scalar.size() - CurrentPos);
   return StringRef();
 }
 
Index: clang/include/clang/Tooling/ReplacementsYaml.h
===
--- clang/include/clang/Tooling/ReplacementsYaml.h
+++ clang/include/clang/Tooling/ReplacementsYaml.h
@@ -35,13 +35,7 @@
 
 NormalizedReplacement(const IO &, const clang::tooling::Replacement )
 : FilePath(R.getFilePath()), Offset(R.getOffset()),
-  Length(R.getLength()), ReplacementText(R.getReplacementText()) {
-  size_t lineBreakPos = ReplacementText.find('\n');
-  while (lineBreakPos != std::string::npos) {
-ReplacementText.replace(lineBreakPos, 1, "\n\n");
-lineBreakPos = ReplacementText.find('\n', lineBreakPos + 2);
-  }
-}
+  Length(R.getLength()), ReplacementText(R.getReplacementText()) {}
 
 clang::tooling::Replacement denormalize(const IO &) {
   return clang::tooling::Replacement(FilePath, Offset, Length,


Index: llvm/unittests/Support/YAMLIOTest.cpp
===
--- llvm/unittests/Support/YAMLIOTest.cpp
+++ llvm/unittests/Support/YAMLIOTest.cpp
@@ -274,8 +274,8 @@
 
 TEST(YAMLIO, MultilineStrings) {
   WithStringField Original;
-  Original.str1 = "a multiline string\nfoobarbaz";
-  Original.str2 = "another one\rfoobarbaz";
+  Original.str1 = "a\n\nmultiline\nstring\nfoobarbaz";
+  Original.str2 = "another one\rfoobarbaz\n";
   Original.str3 = "a one-line string";
 
   std::string Serialized;
@@ -285,10 +285,10 @@
 YOut << Original;
   }
   auto Expected = "---\n"
-  "str1:'a multiline string\n"
+  "str1:'a\n\n\n\nmultiline\n\nstring\n\n"
   "foobarbaz'\n"
   "str2:'another one\r"
-  "foobarbaz'\n"
+  "foobarbaz\n\n'\n"
   "str3:a one-line string\n"
   "...\n";
   ASSERT_EQ(Serialized, Expected);
Index: llvm/lib/Support/YAMLTraits.cpp
===
--- llvm/lib/Support/YAMLTraits.cpp
+++ llvm/lib/Support/YAMLTraits.cpp
@@ -876,13 +876,33 @@
 }
 
 void ScalarTraits::output(const std::string , void 

[PATCH] D81192: [OPENMP]Fix PR45854: prevent code movement out of the critical region.

2020-06-04 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

In D81192#2074677 , @mikerice wrote:

> Is it possible to have the same problem with other directives, like 'omp 
> single' or 'omp master'?  I haven't seen any test fail for those yet though.


I rather doubt. The main problem with the critical directive that load/stores 
should not be moved out of the region (they all should be executed in the 
critical region context, just like atomics). For single and master it should be 
fine.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81192



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


[PATCH] D79835: [Fuchsia] Rely on linker switch rather than dead code ref for profile runtime

2020-06-04 Thread Petr Hosek via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd51054217403: [Fuchsia] Rely on linker switch rather than 
dead code ref for profile runtime (authored by phosek).

Changed prior to commit:
  https://reviews.llvm.org/D79835?vs=267336=268591#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79835

Files:
  clang/lib/Driver/ToolChains/Fuchsia.cpp
  clang/lib/Driver/ToolChains/Fuchsia.h
  clang/test/Driver/fuchsia.c
  llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
  llvm/test/Instrumentation/InstrProfiling/linkage.ll


Index: llvm/test/Instrumentation/InstrProfiling/linkage.ll
===
--- llvm/test/Instrumentation/InstrProfiling/linkage.ll
+++ llvm/test/Instrumentation/InstrProfiling/linkage.ll
@@ -2,9 +2,11 @@
 
 ; RUN: opt < %s -mtriple=x86_64-apple-macosx10.10.0 -instrprof -S | FileCheck 
%s --check-prefixes=POSIX,MACHO
 ; RUN: opt < %s -mtriple=x86_64-unknown-linux -instrprof -S | FileCheck %s 
--check-prefixes=POSIX,LINUX
+; RUN: opt < %s -mtriple=x86_64-unknown-fuchsia -instrprof -S | FileCheck %s 
--check-prefixes=POSIX,LINUX
 ; RUN: opt < %s  -mtriple=x86_64-pc-win32-coff -instrprof -S | FileCheck %s 
--check-prefixes=COFF
 ; RUN: opt < %s -mtriple=x86_64-apple-macosx10.10.0 -passes=instrprof -S | 
FileCheck %s --check-prefixes=POSIX,MACHO
 ; RUN: opt < %s -mtriple=x86_64-unknown-linux -passes=instrprof -S | FileCheck 
%s --check-prefixes=POSIX,LINUX
+; RUN: opt < %s -mtriple=x86_64-unknown-fuchsia -passes=instrprof -S | 
FileCheck %s --check-prefixes=POSIX,LINUX
 ; RUN: opt < %s  -mtriple=x86_64-pc-win32-coff -passes=instrprof -S | 
FileCheck %s --check-prefixes=COFF
 
 ; MACHO: @__llvm_profile_runtime = external global i32
Index: llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
===
--- llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
+++ llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
@@ -1034,9 +1034,9 @@
 }
 
 bool InstrProfiling::emitRuntimeHook() {
-  // We expect the linker to be invoked with -u flag for linux,
-  // for which case there is no need to emit the user function.
-  if (TT.isOSLinux())
+  // We expect the linker to be invoked with -u flag for Linux or
+  // Fuchsia, in which case there is no need to emit the user function.
+  if (TT.isOSLinux() || TT.isOSFuchsia())
 return false;
 
   // If the module's provided its own runtime, we don't need to do anything.
Index: clang/test/Driver/fuchsia.c
===
--- clang/test/Driver/fuchsia.c
+++ clang/test/Driver/fuchsia.c
@@ -242,3 +242,21 @@
 // RUN: -gsplit-dwarf -c %s 2>&1 \
 // RUN: | FileCheck %s -check-prefix=CHECK-SPLIT-DWARF
 // CHECK-SPLIT-DWARF: "-split-dwarf-output" "fuchsia.dwo"
+
+// RUN: %clang %s -### --target=aarch64-fuchsia \
+// RUN: -fprofile-instr-generate -fcoverage-mapping \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
+// RUN: -fuse-ld=lld 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK-PROFRT-AARCH64
+// CHECK-PROFRT-AARCH64: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
+// CHECK-PROFRT-AARCH64: "-u__llvm_profile_runtime"
+// CHECK-PROFRT-AARCH64: 
"[[RESOURCE_DIR]]{{/|}}lib{{/|}}aarch64-fuchsia{{/|}}libclang_rt.profile.a"
+
+// RUN: %clang %s -### --target=x86_64-fuchsia \
+// RUN: -fprofile-instr-generate -fcoverage-mapping \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
+// RUN: -fuse-ld=lld 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK-PROFRT-X86_64
+// CHECK-PROFRT-X86_64: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
+// CHECK-PROFRT-X86_64: "-u__llvm_profile_runtime"
+// CHECK-PROFRT-X86_64: 
"[[RESOURCE_DIR]]{{/|}}lib{{/|}}x86_64-fuchsia{{/|}}libclang_rt.profile.a"
Index: clang/lib/Driver/ToolChains/Fuchsia.h
===
--- clang/lib/Driver/ToolChains/Fuchsia.h
+++ clang/lib/Driver/ToolChains/Fuchsia.h
@@ -69,6 +69,9 @@
   SanitizerMask getSupportedSanitizers() const override;
   SanitizerMask getDefaultSanitizers() const override;
 
+  void addProfileRTLibs(const llvm::opt::ArgList ,
+llvm::opt::ArgStringList ) const override;
+
   RuntimeLibType
   GetRuntimeLibType(const llvm::opt::ArgList ) const override;
   CXXStdlibType
Index: clang/lib/Driver/ToolChains/Fuchsia.cpp
===
--- clang/lib/Driver/ToolChains/Fuchsia.cpp
+++ clang/lib/Driver/ToolChains/Fuchsia.cpp
@@ -15,6 +15,7 @@
 #include "clang/Driver/Options.h"
 #include "clang/Driver/SanitizerArgs.h"
 #include "llvm/Option/ArgList.h"
+#include "llvm/ProfileData/InstrProf.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Path.h"
 #include 

[PATCH] D81192: [OPENMP]Fix PR45854: prevent code movement out of the critical region.

2020-06-04 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev updated this revision to Diff 268592.
ABataev added a comment.

Rebase and fixes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81192

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/test/OpenMP/critical_codegen.cpp
  clang/test/OpenMP/openmp_win_codegen.cpp
  clang/test/OpenMP/simd_codegen.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp

Index: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
===
--- llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -814,13 +814,14 @@
   Instruction *ExitCall = Builder.CreateCall(ExitRTLFn, Args);
 
   return EmitOMPInlinedRegion(OMPD, EntryCall, ExitCall, BodyGenCB, FiniCB,
-  /*Conditional*/ false, /*hasFinalize*/ true);
+  /*Conditional*/ false, /*hasFinalize*/ true,
+  /*WithMemBarrier=*/true);
 }
 
 OpenMPIRBuilder::InsertPointTy OpenMPIRBuilder::EmitOMPInlinedRegion(
 Directive OMPD, Instruction *EntryCall, Instruction *ExitCall,
 BodyGenCallbackTy BodyGenCB, FinalizeCallbackTy FiniCB, bool Conditional,
-bool HasFinalize) {
+bool HasFinalize, bool WithMemBarrier) {
 
   if (HasFinalize)
 FinalizationStack.push_back({FiniCB, OMPD, /*IsCancellable*/ false});
@@ -837,6 +838,8 @@
 
   Builder.SetInsertPoint(EntryBB->getTerminator());
   emitCommonDirectiveEntry(OMPD, EntryCall, ExitBB, Conditional);
+  if (WithMemBarrier)
+Builder.CreateFence(AtomicOrdering::Acquire);
 
   // generate body
   BodyGenCB(/* AllocaIP */ InsertPointTy(),
@@ -861,7 +864,7 @@
 assert(FiniBB->getTerminator()->getNumSuccessors() == 1 &&
FiniBB->getTerminator()->getSuccessor(0) == ExitBB &&
"Unexpected control flow graph state!!");
-emitCommonDirectiveExit(OMPD, FinIP, ExitCall, HasFinalize);
+emitCommonDirectiveExit(OMPD, FinIP, ExitCall, HasFinalize, WithMemBarrier);
 assert(FiniBB->getUniquePredecessor()->getUniqueSuccessor() == FiniBB &&
"Unexpected Control Flow State!");
 MergeBlockIntoPredecessor(FiniBB);
@@ -919,7 +922,7 @@
 
 OpenMPIRBuilder::InsertPointTy OpenMPIRBuilder::emitCommonDirectiveExit(
 omp::Directive OMPD, InsertPointTy FinIP, Instruction *ExitCall,
-bool HasFinalize) {
+bool HasFinalize, bool WithMemBarrier) {
 
   Builder.restoreIP(FinIP);
 
@@ -940,6 +943,8 @@
 Builder.SetInsertPoint(FiniBBTI);
   }
 
+  if (WithMemBarrier)
+Builder.CreateFence(AtomicOrdering::Release);
   // place the Exitcall as last instruction before Finalization block terminator
   ExitCall->removeFromParent();
   Builder.Insert(ExitCall);
Index: llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
===
--- llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
+++ llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
@@ -354,12 +354,15 @@
   /// \param HasFinalize indicate if the directive will require finalization
   /// and has a finalization callback in the stack that
   ///should be called.
+  /// \param WithMemBarrier true if the memory fence instructions are required
+  /// to prevent optimizations.
   ///
   /// \return The insertion position in exit block
   InsertPointTy emitCommonDirectiveExit(omp::Directive OMPD,
 InsertPointTy FinIP,
 Instruction *ExitCall,
-bool HasFinalize = true);
+bool HasFinalize = true,
+bool WithMemBarrier = false);
 
   /// Common Interface to generate OMP inlined regions
   ///
@@ -374,6 +377,8 @@
   /// \param HasFinalize indicate if the directive will require finalization
   /// and has a finalization callback in the stack that
   /// shouldbe called.
+  /// \param WithMemBarrier true if the memory fence instructions are required
+  /// to prevent optimizations.
   ///
   /// \return The insertion point after the region
 
@@ -381,7 +386,7 @@
   EmitOMPInlinedRegion(omp::Directive OMPD, Instruction *EntryCall,
Instruction *ExitCall, BodyGenCallbackTy BodyGenCB,
FinalizeCallbackTy FiniCB, bool Conditional = false,
-   bool HasFinalize = true);
+   bool HasFinalize = true, bool WithMemBarrier = false);
 
   /// Get the platform-specific name separator.
   /// \param Parts different parts of the final name that needs separation
Index: clang/test/OpenMP/simd_codegen.cpp
===
--- clang/test/OpenMP/simd_codegen.cpp
+++ clang/test/OpenMP/simd_codegen.cpp
@@ -243,6 +243,7 @@
 // CHECK-NEXT: store i32 [[CONV]], i32* 

[PATCH] D81115: [PowerPC] Do not special case Darwin on PowerPC in target cpu handling

2020-06-04 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast accepted this revision.
hubert.reinterpretcast added a comment.
This revision is now accepted and ready to land.

LGTM; thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81115



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


[PATCH] D81192: [OPENMP]Fix PR45854: prevent code movement out of the critical region.

2020-06-04 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

In D81192#2074732 , @jdoerfert wrote:

> I doubt this is the right fix. I'll take a closer look.


I believe, the issue is caused by the new attributes for 
kmpc_critical/kmpc_end_critical functions. They are marked as 
`InaccessibleMemOrArgMemOnly` functions. Previously they did not have this 
attribute and optimizer did not move the code across these function calls.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81192



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


[PATCH] D81122: Reland: Use -fdebug-compilation-dir to form absolute paths in coverage mappings

2020-06-04 Thread Keith Smiley via Phabricator via cfe-commits
keith added a comment.

FYI I actually removed that piece this morning since I felt like since this now 
supports `-path-equivalence=.,foo` which is the "expected" behavior from lldb, 
that was "good enough". lmk if you want me to add it back!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81122



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


[PATCH] D81150: Use libClangTesting in the unittest for AST matchers

2020-06-04 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 marked an inline comment as done.
gribozavr2 added inline comments.



Comment at: clang/unittests/ASTMatchers/ASTMatchersTest.h:62
+inline ArrayRef langCxx11OrLater() {
+  static std::vector Result = {Lang_CXX11, Lang_CXX14, 
Lang_CXX17,
+ Lang_CXX20};

njames93 wrote:
> Bit late, but surely these should have been const arrays instead of vectors.
Thanks! https://reviews.llvm.org/D81180


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81150



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


[PATCH] D81180: AST Matchers test: use arrays instead of vectors

2020-06-04 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
gribozavr2 added a reviewer: njames93.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81180

Files:
  clang/unittests/ASTMatchers/ASTMatchersTest.h


Index: clang/unittests/ASTMatchers/ASTMatchersTest.h
===
--- clang/unittests/ASTMatchers/ASTMatchersTest.h
+++ clang/unittests/ASTMatchers/ASTMatchersTest.h
@@ -59,24 +59,23 @@
 };
 
 inline ArrayRef langCxx11OrLater() {
-  static std::vector Result = {Lang_CXX11, Lang_CXX14, 
Lang_CXX17,
- Lang_CXX20};
+  static const TestLanguage Result[] = {Lang_CXX11, Lang_CXX14, Lang_CXX17,
+Lang_CXX20};
   return Result;
 }
 
 inline ArrayRef langCxx14OrLater() {
-  static std::vector Result = {Lang_CXX14, Lang_CXX17,
- Lang_CXX20};
+  static const TestLanguage Result[] = {Lang_CXX14, Lang_CXX17, Lang_CXX20};
   return Result;
 }
 
 inline ArrayRef langCxx17OrLater() {
-  static std::vector Result = {Lang_CXX17, Lang_CXX20};
+  static const TestLanguage Result[] = {Lang_CXX17, Lang_CXX20};
   return Result;
 }
 
 inline ArrayRef langCxx20OrLater() {
-  static std::vector Result = {Lang_CXX20};
+  static const TestLanguage Result[] = {Lang_CXX20};
   return Result;
 }
 


Index: clang/unittests/ASTMatchers/ASTMatchersTest.h
===
--- clang/unittests/ASTMatchers/ASTMatchersTest.h
+++ clang/unittests/ASTMatchers/ASTMatchersTest.h
@@ -59,24 +59,23 @@
 };
 
 inline ArrayRef langCxx11OrLater() {
-  static std::vector Result = {Lang_CXX11, Lang_CXX14, Lang_CXX17,
- Lang_CXX20};
+  static const TestLanguage Result[] = {Lang_CXX11, Lang_CXX14, Lang_CXX17,
+Lang_CXX20};
   return Result;
 }
 
 inline ArrayRef langCxx14OrLater() {
-  static std::vector Result = {Lang_CXX14, Lang_CXX17,
- Lang_CXX20};
+  static const TestLanguage Result[] = {Lang_CXX14, Lang_CXX17, Lang_CXX20};
   return Result;
 }
 
 inline ArrayRef langCxx17OrLater() {
-  static std::vector Result = {Lang_CXX17, Lang_CXX20};
+  static const TestLanguage Result[] = {Lang_CXX17, Lang_CXX20};
   return Result;
 }
 
 inline ArrayRef langCxx20OrLater() {
-  static std::vector Result = {Lang_CXX20};
+  static const TestLanguage Result[] = {Lang_CXX20};
   return Result;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D81138: [SemaOverload] Use iterator_range to iterate over VectorTypes (NFC).

2020-06-04 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

Thanks, LGTM.  (But you can use QualType by value.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81138



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


[PATCH] D81138: [SemaOverload] Use iterator_range to iterate over VectorTypes (NFC).

2020-06-04 Thread Florian Hahn via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG714e84be4615: [SemaOverload] Use iterator_range to iterate 
over VectorTypes (NFC). (authored by fhahn).

Changed prior to commit:
  https://reviews.llvm.org/D81138?vs=268408=268572#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81138

Files:
  clang/lib/Sema/SemaOverload.cpp

Index: clang/lib/Sema/SemaOverload.cpp
===
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -7745,8 +7745,7 @@
   /// enumeration_end - Past the last enumeration type found;
   iterator enumeration_end() { return EnumerationTypes.end(); }
 
-  iterator vector_begin() { return VectorTypes.begin(); }
-  iterator vector_end() { return VectorTypes.end(); }
+  llvm::iterator_range vector_types() { return VectorTypes; }
 
   llvm::iterator_range matrix_types() { return MatrixTypes; }
 
@@ -8292,13 +8291,8 @@
 }
 
 // Extension: We also add these operators for vector types.
-for (BuiltinCandidateTypeSet::iterator
-  Vec = CandidateTypes[0].vector_begin(),
-   VecEnd = CandidateTypes[0].vector_end();
- Vec != VecEnd; ++Vec) {
-  QualType VecTy = *Vec;
+for (QualType VecTy : CandidateTypes[0].vector_types())
   S.AddBuiltinCandidate(, Args, CandidateSet);
-}
   }
 
   // C++ [over.built]p8:
@@ -8332,13 +8326,8 @@
 }
 
 // Extension: We also add this operator for vector types.
-for (BuiltinCandidateTypeSet::iterator
-  Vec = CandidateTypes[0].vector_begin(),
-   VecEnd = CandidateTypes[0].vector_end();
- Vec != VecEnd; ++Vec) {
-  QualType VecTy = *Vec;
+for (QualType VecTy : CandidateTypes[0].vector_types())
   S.AddBuiltinCandidate(, Args, CandidateSet);
-}
   }
 
   // C++ [over.match.oper]p16:
@@ -8569,18 +8558,11 @@
 
 // Extension: Add the binary operators ==, !=, <, <=, >=, >, *, /, and the
 // conditional operator for vector types.
-for (BuiltinCandidateTypeSet::iterator
-  Vec1 = CandidateTypes[0].vector_begin(),
-   Vec1End = CandidateTypes[0].vector_end();
- Vec1 != Vec1End; ++Vec1) {
-  for (BuiltinCandidateTypeSet::iterator
-Vec2 = CandidateTypes[1].vector_begin(),
- Vec2End = CandidateTypes[1].vector_end();
-   Vec2 != Vec2End; ++Vec2) {
-QualType LandR[2] = { *Vec1, *Vec2 };
+for (QualType Vec1Ty : CandidateTypes[0].vector_types())
+  for (QualType Vec2Ty : CandidateTypes[1].vector_types()) {
+QualType LandR[2] = {Vec1Ty, Vec2Ty};
 S.AddBuiltinCandidate(LandR, Args, CandidateSet);
   }
-}
   }
 
   /// Add binary operator overloads for each candidate matrix type M1, M2:
@@ -8861,30 +8843,23 @@
 }
 
 // Extension: Add the binary operators =, +=, -=, *=, /= for vector types.
-for (BuiltinCandidateTypeSet::iterator
-  Vec1 = CandidateTypes[0].vector_begin(),
-   Vec1End = CandidateTypes[0].vector_end();
- Vec1 != Vec1End; ++Vec1) {
-  for (BuiltinCandidateTypeSet::iterator
-Vec2 = CandidateTypes[1].vector_begin(),
- Vec2End = CandidateTypes[1].vector_end();
-   Vec2 != Vec2End; ++Vec2) {
+for (QualType Vec1Ty : CandidateTypes[0].vector_types())
+  for (QualType Vec2Ty : CandidateTypes[0].vector_types()) {
 QualType ParamTypes[2];
-ParamTypes[1] = *Vec2;
+ParamTypes[1] = Vec2Ty;
 // Add this built-in operator as a candidate (VQ is empty).
-ParamTypes[0] = S.Context.getLValueReferenceType(*Vec1);
+ParamTypes[0] = S.Context.getLValueReferenceType(Vec1Ty);
 S.AddBuiltinCandidate(ParamTypes, Args, CandidateSet,
   /*IsAssignmentOperator=*/isEqualOp);
 
 // Add this built-in operator as a candidate (VQ is 'volatile').
 if (VisibleTypeConversionsQuals.hasVolatile()) {
-  ParamTypes[0] = S.Context.getVolatileType(*Vec1);
+  ParamTypes[0] = S.Context.getVolatileType(Vec1Ty);
   ParamTypes[0] = S.Context.getLValueReferenceType(ParamTypes[0]);
   S.AddBuiltinCandidate(ParamTypes, Args, CandidateSet,
 /*IsAssignmentOperator=*/isEqualOp);
 }
   }
-}
   }
 
   // C++ [over.built]p22:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D80932: [SYCL] Make default address space a superset of OpenCL address spaces.

2020-06-04 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

In D80932#2073542 , @Naghasan wrote:

> In D80932#2072064 , @Anastasia wrote:
>
> > In D80932#2071321 , @bader wrote:
> >
> > > In D80932#2068863 , @Anastasia 
> > > wrote:
> > >
> > > >
> > >
> > >
> > >
> > >
> > > > Why? Can you explain what you are trying to achieve with this?
> > >
> > > I think @asavonic can provide more detailed answer, but IIRC we spent a 
> > > lot time trying to marry template meta-programming with OpenCL address 
> > > space deductions, but even simplest template functions from C++ standard 
> > > library breaks compilation. It's important to note one important 
> > > difference in design goals for SYCL and C++ for OpenCL. SYCL aims to 
> > > enable compilation of regular C++ as much as possible where as one of the 
> > > C++ for OpenCL goals is to keep compatibility with OpenCL C. These two 
> > > goals might lead to different design decisions.
> >
> >
> > I don't see a contradiction in those goals. We plan to support C++ 
> > libraries with C++ for OpenCL of course with functionality that is accepted 
> > by conformant OpenCL implementations. For example, libraries that use 
> > virtual functions leading to function pointers are not going to work 
> > portably in OpenCL devices. If SYCL aims to compile to conformant OpenCL 
> > devices then it should not be very different I imagine?
>
>
>   (Edited a bit)
>   
>
> There is a fundamental difference (given the direction taken for OpenCL), 
> OpenCL mode actively modifies user's types  (C and C++ for OpenCL AFAIK). So 
> inside a function, this:
>
>   int var;
>
>
> becomes
>
>   VarDecl  var '__private int'
>
>
> Which is fine in C where you can't really do much  with your types, but this 
> has a massive and destructive effect in C++. For instance this does not 
> compile in C++ for OpenCL:
>
>   void foo() {
>   int var; // '__private int' not 'int'
>   int* ptr1 =  // '__generic int* __private' not 'int*'
>   decltype(var)* ptr2 = ptr1; // error: cannot initialize a variable of 
> type 'decltype(var) *__private' (aka '__private int *__private') with an 
> lvalue of type '__generic int *__private'
>   }
>
>
>


Correct. For this we plan to add a metaprogramming utility to remove address 
space from a type. Here is a proposal:
https://reviews.llvm.org/D76636

However, this would mean modifying the C++ libraries to produce a flavor that 
can be supported by OpenCL devices.

I think my biggest problem is that I don't understand how you can just run C++ 
libraries on OpenCL devices. If we were able to compile plain C++ for OpenCL 
devices would we not just do it? But OpenCL devices have certain constraints. 
Also aren't libraries typically customized for performance depending on the 
range of HW they are being run on? I see the modifications are inevitable.

>> We plan to support C++ libraries with C++ for OpenCL
> 
> With the direction taken so far, C++ for OpenCL can't properly implement or 
> use basic C++ due to this.Small example using a `is_same` implementation 
> (https://godbolt.org/z/CLFV6z):
> 
>   template
>   struct is_same {
>   static constexpr int value = 0;
>   };
>   
>   template
>   struct is_same {
>   static constexpr int value = 1;
>   };
>   
>   void foo(int p) {
>   static_assert(is_same::value, "int is not an int?"); 
> // Fails: p is '__private int' != 'int'
>   static_assert(is_same::value, "int* is not an 
> int*?");  // Fails: p is '__private int*' != '__generic int*'
>   }
> 
> 
> So yes, you could implement `std::is_same` but it won't work as one would 
> expect.
> 
> That's the reason why SYCL actively tries to prevent changing any type, this 
> would prevent the compilation of valid C++ code without a fundamental reason 
> (e.g. the target is not able to support it).
> 
> My point is only that the approach taken for C++ for OpenCL is not suitable 
> for SYCL IMO
> 
>> Default address space is a Clang concept that is generally used for an 
>> automatic storage.
> 
> That's not true in CUDA. On the other hand they actively avoids using address 
> space.

True and I don't think CUDA uses `isAddressSpaceSupersetOf` in their 
implementation? Perhaps SYCL can use the same flow?

> Plus in `isAddressSpaceSupersetOf` you have:
> 
>   // Consider pointer size address spaces to be equivalent to default.
>   ((isPtrSizeAddressSpace(A) || A == LangAS::Default) &&
>   (isPtrSizeAddressSpace(B) || B == LangAS::Default))
> 
> 
> An alternative would be to clone the address space. But that would be shame 
> to not find a way to reuse the opencl one as down the line, they map to the 
> same thing.

I agree that reusing functionality is preferable however it is subject to 
whether it is sufficiently similar. If we end up adding a lot of code to 
diverge special cases or even worse 

[PATCH] D79830: Add support of __builtin_expect_with_probability

2020-06-04 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:10804-10807
+   "probability of __builtin_expect_with_probability must be constant "
+   "floating-point expression">;
+def err_probability_out_of_range : Error<
+   "probability of __builtin_expect_with_probability is outside the "

I think "probability argument to" rather than "probability of" would be clearer.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:2202
+// won't use it for anything.
+// Note, we still IRGen ExpectedValue because it could have side-effects.
+if (CGM.getCodeGenOpts().OptimizationLevel == 0)

erichkeane wrote:
> erichkeane wrote:
> > I believe in EvaluateAsFloat you need to pass  'allow side effects', 
> > because by default it does not.
> Thinking further, Since it is with constant-expressions, we might consider 
> disallowing side effects.
(This is marked as done, but `SE_AllowSideEffects` is still passed above.)



Comment at: clang/lib/Sema/SemaChecking.cpp:1818-1819
+llvm::APFloat Probability = Eval.Val.getFloat();
+if (!(Probability >= llvm::APFloat(0.0) &&
+  Probability <= llvm::APFloat(1.0))) {
+  Diag(ProbArg->getLocStart(), diag::err_probability_out_of_range)

I think this will probably only work if the target `double` type is 
`IEEEdouble`. (Otherwise you'll be comparing an `IEEEdouble` `APFloat` to a 
different kind of `APFloat`.)

We do not guarantee that `double` is `IEEEdouble` for all our supported 
targets. In particular, for TCE and for AVR (at least under `-mdouble=32`), 
`double` is `IEEEsingle` instead.

It looks like your LLVM intrinsic expects an LLVM IR `double` (that is, an 
`IEEEdouble`) as its third argument, so perhaps the right thing to do would be 
to convert the `APFloat` to `IEEEdouble` here and in CodeGen. Please add a test 
for a target where `double` is not `IEEEdouble`.



Comment at: clang/test/Sema/builtin-expect-with-probability.cpp:18
+  bool dummy;
+  dummy = __builtin_expect_with_probability(x > 0, 1, 0.9);
+  dummy = __builtin_expect_with_probability(x > 0, 1, 1.1); // expected-error 
{{probability of __builtin_expect_with_probability is outside the range [0.0, 
1.0]}}

Please also test some more edge cases. such as: if the probability argument is 
not convertible to float, or is inf or nan, negative zero, -denorm_min, or 
1+epsilon.



Comment at: llvm/docs/BranchWeightMetadata.rst:18
 Branch weights might be fetch from the profiling file, or generated based on
-`__builtin_expect`_ instruction.
+`__builtin_expect`_ and `__builtin_expect_with_probability`_ instruction.
 

There are no instructions with these names. There are Clang builtin functions 
with these names and LLVM intrinsics with similar but different names. This 
document should be documenting the `llvm.expect` and 
`llvm.expect.with.probability` intrinsics.



Comment at: llvm/docs/BranchWeightMetadata.rst:128-135
+Built-in ``expect.with.probability`` Instruction
+
+
+``__builtin_expect_with_probability(long exp, long c, double probability)`` has
+the same semantics as ``__builtin_expect``, but the caller provides the
+probability that ``exp == c``. The last argument ``probability`` must be
+constant floating-point expression and be in the range [0.0, 1.0] inclusive.

This whole section of documentation (line 86 to 166) seems inappropriate to me 
as LLVM documentation, because it's talking about the behavior of one 
particular source language with one particular frontend, not LLVM semantics. 
Here's what I'd suggest:

 * Move all of that documentation into the Clang user's manual, as a 
description of the `__builtin_expect*` builtin functions.
 * Here in the LLVM documentation, add documentation for the `llvm.expect` and 
`llvm.expect.with.probability` intrinsic functions, and include a note pointing 
to the Clang documentation and suggesting that `__builtin_expect` and 
`__builtin_expect_with_probability` can be used to generate these intrinsics in 
C and C++ source files.


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

https://reviews.llvm.org/D79830



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


[PATCH] D80752: [AArch64]: BFloat MatMul Intrinsics

2020-06-04 Thread Mikhail Maltsev via Phabricator via cfe-commits
miyuki accepted this revision.
miyuki added a comment.
This revision is now accepted and ready to land.

LGTM


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

https://reviews.llvm.org/D80752



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


[clang] 42f6fec - Propose naming principle for NodeRole and apply it

2020-06-04 Thread Dmitri Gribenko via cfe-commits

Author: Eduardo Caldas
Date: 2020-06-04T20:08:35+02:00
New Revision: 42f6fec3878d708f2791ab0be3a060b07dac9d76

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

LOG: Propose naming principle for NodeRole and apply it

Reviewers: gribozavr2

Reviewed By: gribozavr2

Subscribers: cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/include/clang/Tooling/Syntax/Nodes.h
clang/lib/Tooling/Syntax/BuildTree.cpp
clang/lib/Tooling/Syntax/Nodes.cpp

Removed: 




diff  --git a/clang/include/clang/Tooling/Syntax/Nodes.h 
b/clang/include/clang/Tooling/Syntax/Nodes.h
index 7d0c4439e279..7e05aa968f02 100644
--- a/clang/include/clang/Tooling/Syntax/Nodes.h
+++ b/clang/include/clang/Tooling/Syntax/Nodes.h
@@ -91,6 +91,23 @@ llvm::raw_ostream <<(llvm::raw_ostream , 
NodeKind K);
 
 /// A relation between a parent and child node, e.g. 'left-hand-side of
 /// a binary expression'. Used for implementing accessors.
+///
+/// Some roles describe parent/child relations that occur multiple times in
+/// language grammar. We define only one role to describe all instances of such
+/// recurring relations. For example, grammar for both "if" and "while"
+/// statements requires an opening paren and a closing paren. The opening
+/// paren token is assigned the OpenParen role regardless of whether it appears
+/// as a child of IfStatement or WhileStatement node. More generally, when
+/// grammar requires a certain fixed token (like a specific keyword, or an
+/// opening paren), we define a role for this token and use it across all
+/// grammar rules with the same requirement. Names of such reusable roles end
+/// with a ~Token or a ~Keyword suffix.
+///
+/// Some roles are assigned only to child nodes of one specific parent syntax
+/// node type. Names of such roles start with the name of the parent syntax 
tree
+/// node type. For example, a syntax node with a role
+/// BinaryOperatorExpression_leftHandSide can only appear as a child of a
+/// BinaryOperatorExpression node.
 enum class NodeRole : uint8_t {
   // Roles common to multiple node kinds.
   /// A node without a parent
@@ -103,19 +120,21 @@ enum class NodeRole : uint8_t {
   CloseParen,
   /// A keywords that introduces some grammar construct, e.g. 'if', 'try', etc.
   IntroducerKeyword,
+  /// A token that represents a literal, e.g. 'nullptr', '1', 'true', etc.
+  LiteralToken,
+  /// Tokens or Keywords
+  ArrowToken,
+  ExternKeyword,
   /// An inner statement for those that have only a single child of kind
   /// statement, e.g. loop body for while, for, etc; inner statement for case,
   /// default, etc.
   BodyStatement,
 
   // Roles specific to particular node kinds.
-  UnaryOperatorExpression_operatorToken,
+  OperatorExpression_operatorToken,
   UnaryOperatorExpression_operand,
   BinaryOperatorExpression_leftHandSide,
-  BinaryOperatorExpression_operatorToken,
   BinaryOperatorExpression_rightHandSide,
-  CxxNullPtrExpression_keyword,
-  IntegerLiteralExpression_literalToken,
   CaseStatement_value,
   IfStatement_thenStatement,
   IfStatement_elseKeyword,
@@ -127,10 +146,8 @@ enum class NodeRole : uint8_t {
   StaticAssertDeclaration_message,
   SimpleDeclaration_declarator,
   TemplateDeclaration_declaration,
-  ExplicitTemplateInstantiation_externKeyword,
   ExplicitTemplateInstantiation_declaration,
   ArraySubscript_sizeExpression,
-  TrailingReturnType_arrow,
   TrailingReturnType_declarator,
   ParametersAndQualifiers_parameter,
   ParametersAndQualifiers_trailingReturn

diff  --git a/clang/lib/Tooling/Syntax/BuildTree.cpp 
b/clang/lib/Tooling/Syntax/BuildTree.cpp
index 1f81cb4a12b0..9ce12ac21f8b 100644
--- a/clang/lib/Tooling/Syntax/BuildTree.cpp
+++ b/clang/lib/Tooling/Syntax/BuildTree.cpp
@@ -609,26 +609,22 @@ class BuildTreeVisitor : public 
RecursiveASTVisitor {
   }
 
   bool WalkUpFromIntegerLiteral(IntegerLiteral *S) {
-Builder.markChildToken(
-S->getLocation(),
-syntax::NodeRole::IntegerLiteralExpression_literalToken);
+Builder.markChildToken(S->getLocation(), syntax::NodeRole::LiteralToken);
 Builder.foldNode(Builder.getExprRange(S),
  new (allocator()) syntax::IntegerLiteralExpression, S);
 return true;
   }
 
   bool WalkUpFromCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *S) {
-Builder.markChildToken(S->getLocation(),
-   syntax::NodeRole::CxxNullPtrExpression_keyword);
+Builder.markChildToken(S->getLocation(), syntax::NodeRole::LiteralToken);
 Builder.foldNode(Builder.getExprRange(S),
  new (allocator()) syntax::CxxNullPtrExpression, S);
 return true;
   }
 
   bool WalkUpFromUnaryOperator(UnaryOperator *S) {
-Builder.markChildToken(
-  

[PATCH] D81188: [RISCV] Support experimental v extensions.

2020-06-04 Thread Hsiangkai Wang via Phabricator via cfe-commits
HsiangKai created this revision.
HsiangKai added reviewers: MaskRay, rogfer01.
Herald added subscribers: cfe-commits, evandro, luismarques, apazos, 
sameer.abuasal, pzheng, s.egerton, lenary, Jim, benna, psnobl, jocewei, PkmX, 
rkruppe, the_o, brucehoult, MartinMosbeck, edward-jones, zzheng, jrtc27, 
shiva0217, kito-cheng, niosHD, sabuasal, simoncook, johnrusso, rbar, asb.
Herald added a project: clang.

This follows the design as discussed on the mailing lists in the
following RFC: http://lists.llvm.org/pipermail/llvm-dev/2020-January/138364.html

Support for the vector 'v' extension v0.8.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81188

Files:
  clang/lib/Driver/ToolChains/Arch/RISCV.cpp
  clang/test/Driver/riscv-arch.c


Index: clang/test/Driver/riscv-arch.c
===
--- clang/test/Driver/riscv-arch.c
+++ clang/test/Driver/riscv-arch.c
@@ -360,3 +360,22 @@
 // RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-EXPERIMENTAL-ZBB-ZBP 
%s
 // RV32-EXPERIMENTAL-ZBB-ZBP: "-target-feature" "+experimental-zbb"
 // RV32-EXPERIMENTAL-ZBB-ZBP: "-target-feature" "+experimental-zbp"
+
+// RUN: %clang -target riscv32-unknown-elf -march=rv32iv -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck 
-check-prefix=RV32-EXPERIMENTAL-V-NOFLAG %s
+// RV32-EXPERIMENTAL-V-NOFLAG: error: invalid arch name 'rv32iv'
+// RV32-EXPERIMENTAL-V-NOFLAG: requires '-menable-experimental-extensions'
+
+// RUN: %clang -target riscv32-unknown-elf -march=rv32iv 
-menable-experimental-extensions -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck 
-check-prefix=RV32-EXPERIMENTAL-V-NOVERS %s
+// RV32-EXPERIMENTAL-V-NOVERS: error: invalid arch name 'rv32iv'
+// RV32-EXPERIMENTAL-V-NOVERS: experimental extension requires explicit 
version number
+
+// RUN: %clang -target riscv32-unknown-elf -march=rv32iv0p1 
-menable-experimental-extensions -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck 
-check-prefix=RV32-EXPERIMENTAL-V-BADVERS %s
+// RV32-EXPERIMENTAL-V-BADVERS: error: invalid arch name 'rv32iv0p1'
+// RV32-EXPERIMENTAL-V-BADVERS: unsupported version number 0.1 for 
experimental extension
+
+// RUN: %clang -target riscv32-unknown-elf -march=rv32iv0p8 
-menable-experimental-extensions -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck 
-check-prefix=RV32-EXPERIMENTAL-V-GOODVERS %s
+// RV32-EXPERIMENTAL-V-GOODVERS: "-target-feature" "+experimental-v"
Index: clang/lib/Driver/ToolChains/Arch/RISCV.cpp
===
--- clang/lib/Driver/ToolChains/Arch/RISCV.cpp
+++ clang/lib/Driver/ToolChains/Arch/RISCV.cpp
@@ -62,6 +62,8 @@
   Ext == "zbf" || Ext == "zbm" || Ext == "zbp" || Ext == "zbr" ||
   Ext == "zbs" || Ext == "zbt" || Ext == "zbproposedc")
 return RISCVExtensionVersion{"0", "92"};
+  if (Ext == "v")
+return RISCVExtensionVersion{"0", "8"};
   return None;
 }
 
@@ -399,6 +401,9 @@
 case 'b':
   Features.push_back("+experimental-b");
   break;
+case 'v':
+  Features.push_back("+experimental-v");
+  break;
 }
 
 // Consume full extension name and version, including any optional '_'


Index: clang/test/Driver/riscv-arch.c
===
--- clang/test/Driver/riscv-arch.c
+++ clang/test/Driver/riscv-arch.c
@@ -360,3 +360,22 @@
 // RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-EXPERIMENTAL-ZBB-ZBP %s
 // RV32-EXPERIMENTAL-ZBB-ZBP: "-target-feature" "+experimental-zbb"
 // RV32-EXPERIMENTAL-ZBB-ZBP: "-target-feature" "+experimental-zbp"
+
+// RUN: %clang -target riscv32-unknown-elf -march=rv32iv -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-EXPERIMENTAL-V-NOFLAG %s
+// RV32-EXPERIMENTAL-V-NOFLAG: error: invalid arch name 'rv32iv'
+// RV32-EXPERIMENTAL-V-NOFLAG: requires '-menable-experimental-extensions'
+
+// RUN: %clang -target riscv32-unknown-elf -march=rv32iv -menable-experimental-extensions -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-EXPERIMENTAL-V-NOVERS %s
+// RV32-EXPERIMENTAL-V-NOVERS: error: invalid arch name 'rv32iv'
+// RV32-EXPERIMENTAL-V-NOVERS: experimental extension requires explicit version number
+
+// RUN: %clang -target riscv32-unknown-elf -march=rv32iv0p1 -menable-experimental-extensions -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-EXPERIMENTAL-V-BADVERS %s
+// RV32-EXPERIMENTAL-V-BADVERS: error: invalid arch name 'rv32iv0p1'
+// RV32-EXPERIMENTAL-V-BADVERS: unsupported version number 0.1 for experimental extension
+
+// RUN: %clang -target riscv32-unknown-elf -march=rv32iv0p8 -menable-experimental-extensions -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-EXPERIMENTAL-V-GOODVERS %s
+// RV32-EXPERIMENTAL-V-GOODVERS: "-target-feature" "+experimental-v"
Index: clang/lib/Driver/ToolChains/Arch/RISCV.cpp
===
--- 

[PATCH] D69987: [RISCV] Assemble/Disassemble v-ext instructions.

2020-06-04 Thread Hsiangkai Wang via Phabricator via cfe-commits
HsiangKai added a comment.

In D69987#2074265 , @MaskRay wrote:

> Drive-by comment: the clang side change isn't tightly coupled with the LLVM 
> side changes. It should be a separate patch.


Create https://reviews.llvm.org/D81188 for clang side change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69987



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


[PATCH] D80730: [OPENMP50]Codegen for use_device_addr clauses.

2020-06-04 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev updated this revision to Diff 268587.
ABataev added a comment.

Rebase and fixes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80730

Files:
  clang/lib/AST/OpenMPClause.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/target_data_use_device_addr_codegen.cpp

Index: clang/test/OpenMP/target_data_use_device_addr_codegen.cpp
===
--- /dev/null
+++ clang/test/OpenMP/target_data_use_device_addr_codegen.cpp
@@ -0,0 +1,224 @@
+// RUN: %clang_cc1 -DCK1 -verify -fopenmp -fopenmp-version=50 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -DCK1 -fopenmp -fopenmp-version=50 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
+
+// RUN: %clang_cc1 -DCK1 -verify -fopenmp-simd -fopenmp-version=50 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -DCK1 -fopenmp-simd -fopenmp-version=50 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=50 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
+// expected-no-diagnostics
+
+#ifndef HEADER
+#define HEADER
+
+// CHECK-DAG: [[SIZES1:@.+]] = private unnamed_addr constant [5 x i64] zeroinitializer
+// 96 = 0x60 = OMP_MAP_TARGET_PARAM | OMP_MAP_RETURN_PARAM
+// CHECK-DAG: [[MAPTYPES1:@.+]] = private unnamed_addr constant [5 x i64] [i64 96, i64 96, i64 96, i64 96, i64 96]
+// 32 = 0x20 = OMP_MAP_TARGET_PARAM
+// 281474976710720 = 0x10040 = OMP_MAP_MEMBER_OF | OMP_MAP_RETURN_PARAM
+// CHECK-DAG: [[MAPTYPES2:@.+]] = private unnamed_addr constant [5 x i64] [i64 32, i64 281474976710720, i64 281474976710720, i64 281474976710720, i64 281474976710720]
+struct S {
+  int a = 0;
+  int *ptr = 
+  int  = a;
+  int arr[4];
+  S() {}
+  void foo() {
+#pragma omp target data use_device_addr(a, ptr [3:4], ref, ptr[0], arr[:a])
+++a, ++*ptr, ++ref, ++arr[0];
+  }
+};
+
+int main() {
+  float a = 0;
+  float *ptr = 
+  float  = a;
+  float arr[4];
+  float vla[(int)a];
+  S s;
+  s.foo();
+#pragma omp target data use_device_addr(a, ptr [3:4], ref, ptr[0], arr[:(int)a], vla[0])
+  ++a, ++*ptr, ++ref, ++arr[0], ++vla[0];
+  return a;
+}
+
+// CHECK-LABEL: @main()
+// CHECK: [[A_ADDR:%.+]] = alloca float,
+// CHECK: [[PTR_ADDR:%.+]] = alloca float*,
+// CHECK: [[REF_ADDR:%.+]] = alloca float*,
+// CHECK: [[ARR_ADDR:%.+]] = alloca [4 x float],
+// CHECK: [[BPTRS:%.+]] = alloca [5 x i8*],
+// CHECK: [[PTRS:%.+]] = alloca [5 x i8*],
+// CHECK: [[VLA_ADDR:%.+]] = alloca float, i64 %{{.+}},
+// CHECK: [[PTR:%.+]] = load float*, float** [[PTR_ADDR]],
+// CHECK: [[REF:%.+]] = load float*, float** [[REF_ADDR]],
+// CHECK: [[ARR:%.+]] = getelementptr inbounds [4 x float], [4 x float]* [[ARR_ADDR]], i64 0, i64 0
+// CHECK: [[BPTR0:%.+]] = getelementptr inbounds [5 x i8*], [5 x i8*]* [[BPTRS]], i32 0, i32 0
+// CHECK: [[BPTR0_A_ADDR:%.+]] = bitcast i8** [[BPTR0]] to float**
+// CHECK: store float* [[A_ADDR]], float** [[BPTR0_A_ADDR]],
+// CHECK: [[PTR0:%.+]] = getelementptr inbounds [5 x i8*], [5 x i8*]* [[PTRS]], i32 0, i32 0
+// CHECK: [[PTR0_A_ADDR:%.+]] = bitcast i8** [[PTR0]] to float**
+// CHECK: store float* [[A_ADDR]], float** [[PTR0_A_ADDR]],
+// CHECK: [[BPTR1:%.+]] = getelementptr inbounds [5 x i8*], [5 x i8*]* [[BPTRS]], i32 0, i32 1
+// CHECK: [[BPTR1_PTR_ADDR:%.+]] = bitcast i8** [[BPTR1]] to float**
+// CHECK: store float* [[PTR]], float** [[BPTR1_PTR_ADDR]],
+// CHECK: [[PTR1:%.+]] = getelementptr inbounds [5 x i8*], [5 x i8*]* [[PTRS]], i32 0, i32 1
+// CHECK: [[PTR1_PTR_ADDR:%.+]] = bitcast i8** [[PTR1]] to float**
+// CHECK: store float* [[PTR]], float** [[PTR1_PTR_ADDR]],
+// CHECK: [[BPTR2:%.+]] = getelementptr inbounds [5 x i8*], [5 x i8*]* [[BPTRS]], i32 0, i32 2
+// CHECK: [[BPTR2_REF_ADDR:%.+]] = bitcast i8** [[BPTR2]] to float**
+// CHECK: store float* [[REF]], float** [[BPTR2_REF_ADDR]],
+// CHECK: [[PTR2:%.+]] = getelementptr inbounds [5 x i8*], [5 x i8*]* [[PTRS]], i32 0, i32 2
+// CHECK: [[PTR2_REF_ADDR:%.+]] = bitcast i8** [[PTR2]] to float**
+// CHECK: store float* [[REF]], float** [[PTR2_REF_ADDR]],
+// CHECK: [[BPTR3:%.+]] = getelementptr inbounds 

[PATCH] D81192: [OPENMP]Fix PR45854: prevent code movement out of the critical region.

2020-06-04 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

I doubt this is the right fix. I'll take a closer look.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81192



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


[PATCH] D81115: [PowerPC] Do not special case Darwin on PowerPC in target cpu handling

2020-06-04 Thread Steven Wan via Phabricator via cfe-commits
stevewan updated this revision to Diff 268588.
stevewan added a comment.

Reduce the nested 'if' and reorder it to prefer the more likely case.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81115

Files:
  clang/lib/Driver/ToolChains/CommonArgs.cpp


Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -294,19 +294,19 @@
 std::string TargetCPUName = ppc::getPPCTargetCPU(Args);
 // LLVM may default to generating code for the native CPU,
 // but, like gcc, we default to a more generic option for
-// each architecture. (except on AIX or Darwin)
-if (TargetCPUName.empty()) {
-  if (T.isOSAIX())
-TargetCPUName = "pwr4";
-  else if (!T.isOSDarwin()) {
-if (T.getArch() == llvm::Triple::ppc64)
-  TargetCPUName = "ppc64";
-else if (T.getArch() == llvm::Triple::ppc64le)
-  TargetCPUName = "ppc64le";
-else
-  TargetCPUName = "ppc";
-  }
-}
+// each architecture. (except on AIX)
+if (!TargetCPUName.empty())
+  return TargetCPUName;
+
+if (T.isOSAIX())
+  TargetCPUName = "pwr4";
+else if (T.getArch() == llvm::Triple::ppc64le)
+  TargetCPUName = "ppc64le";
+else if (T.getArch() == llvm::Triple::ppc64)
+  TargetCPUName = "ppc64";
+else
+  TargetCPUName = "ppc";
+
 return TargetCPUName;
   }
 


Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -294,19 +294,19 @@
 std::string TargetCPUName = ppc::getPPCTargetCPU(Args);
 // LLVM may default to generating code for the native CPU,
 // but, like gcc, we default to a more generic option for
-// each architecture. (except on AIX or Darwin)
-if (TargetCPUName.empty()) {
-  if (T.isOSAIX())
-TargetCPUName = "pwr4";
-  else if (!T.isOSDarwin()) {
-if (T.getArch() == llvm::Triple::ppc64)
-  TargetCPUName = "ppc64";
-else if (T.getArch() == llvm::Triple::ppc64le)
-  TargetCPUName = "ppc64le";
-else
-  TargetCPUName = "ppc";
-  }
-}
+// each architecture. (except on AIX)
+if (!TargetCPUName.empty())
+  return TargetCPUName;
+
+if (T.isOSAIX())
+  TargetCPUName = "pwr4";
+else if (T.getArch() == llvm::Triple::ppc64le)
+  TargetCPUName = "ppc64le";
+else if (T.getArch() == llvm::Triple::ppc64)
+  TargetCPUName = "ppc64";
+else
+  TargetCPUName = "ppc";
+
 return TargetCPUName;
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D80450: [CUDA][HIP] Fix implicit HD function resolution

2020-06-04 Thread Yaxun Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG263390d4f5f2: [CUDA][HIP] Fix implicit HD function 
resolution (authored by yaxunl).
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D80450?vs=266366=268590#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80450

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaCUDA.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/test/SemaCUDA/function-overload.cu

Index: clang/test/SemaCUDA/function-overload.cu
===
--- clang/test/SemaCUDA/function-overload.cu
+++ clang/test/SemaCUDA/function-overload.cu
@@ -1,8 +1,8 @@
 // REQUIRES: x86-registered-target
 // REQUIRES: nvptx-registered-target
 
-// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fsyntax-only -verify %s
-// RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -fsyntax-only -fcuda-is-device -verify %s
+// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-linux-gnu -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c++14 -triple nvptx64-nvidia-cuda -fsyntax-only -fcuda-is-device -verify %s
 
 #include "Inputs/cuda.h"
 
@@ -14,6 +14,13 @@
 struct HostDeviceReturnTy {};
 struct TemplateReturnTy {};
 
+struct CorrectOverloadRetTy{};
+#if __CUDA_ARCH__
+// expected-note@-2 {{candidate constructor (the implicit copy constructor) not viable: no known conversion from 'IncorrectOverloadRetTy' to 'const CorrectOverloadRetTy &' for 1st argument}}
+// expected-note@-3 {{candidate constructor (the implicit move constructor) not viable: no known conversion from 'IncorrectOverloadRetTy' to 'CorrectOverloadRetTy &&' for 1st argument}}
+#endif
+struct IncorrectOverloadRetTy{};
+
 typedef HostReturnTy (*HostFnPtr)();
 typedef DeviceReturnTy (*DeviceFnPtr)();
 typedef HostDeviceReturnTy (*HostDeviceFnPtr)();
@@ -331,9 +338,6 @@
 // If we have a mix of HD and H-only or D-only candidates in the overload set,
 // normal C++ overload resolution rules apply first.
 template  TemplateReturnTy template_vs_hd_function(T arg)
-#ifdef __CUDA_ARCH__
-//expected-note@-2 {{declared here}}
-#endif
 {
   return TemplateReturnTy();
 }
@@ -342,11 +346,13 @@
 }
 
 __host__ __device__ void test_host_device_calls_hd_template() {
-  HostDeviceReturnTy ret1 = template_vs_hd_function(1.0f);
-  TemplateReturnTy ret2 = template_vs_hd_function(1);
 #ifdef __CUDA_ARCH__
-  // expected-error@-2 {{reference to __host__ function 'template_vs_hd_function' in __host__ __device__ function}}
+  typedef HostDeviceReturnTy ExpectedReturnTy;
+#else
+  typedef TemplateReturnTy ExpectedReturnTy;
 #endif
+  HostDeviceReturnTy ret1 = template_vs_hd_function(1.0f);
+  ExpectedReturnTy ret2 = template_vs_hd_function(1);
 }
 
 __host__ void test_host_calls_hd_template() {
@@ -367,14 +373,14 @@
 __device__ DeviceReturnTy device_only_function(int arg) { return DeviceReturnTy(); }
 __device__ DeviceReturnTy2 device_only_function(float arg) { return DeviceReturnTy2(); }
 #ifndef __CUDA_ARCH__
-  // expected-note@-3 {{'device_only_function' declared here}}
-  // expected-note@-3 {{'device_only_function' declared here}}
+  // expected-note@-3 2{{'device_only_function' declared here}}
+  // expected-note@-3 2{{'device_only_function' declared here}}
 #endif
 __host__ HostReturnTy host_only_function(int arg) { return HostReturnTy(); }
 __host__ HostReturnTy2 host_only_function(float arg) { return HostReturnTy2(); }
 #ifdef __CUDA_ARCH__
-  // expected-note@-3 {{'host_only_function' declared here}}
-  // expected-note@-3 {{'host_only_function' declared here}}
+  // expected-note@-3 2{{'host_only_function' declared here}}
+  // expected-note@-3 2{{'host_only_function' declared here}}
 #endif
 
 __host__ __device__ void test_host_device_single_side_overloading() {
@@ -392,6 +398,37 @@
 #endif
 }
 
+// wrong-sided overloading should not cause diagnostic unless it is emitted.
+// This inline function is not emitted.
+inline __host__ __device__ void test_host_device_wrong_side_overloading_inline_no_diag() {
+  DeviceReturnTy ret1 = device_only_function(1);
+  DeviceReturnTy2 ret2 = device_only_function(1.0f);
+  HostReturnTy ret3 = host_only_function(1);
+  HostReturnTy2 ret4 = host_only_function(1.0f);
+}
+
+// wrong-sided overloading should cause diagnostic if it is emitted.
+// This inline function is emitted since it is called by an emitted function.
+inline __host__ __device__ void test_host_device_wrong_side_overloading_inline_diag() {
+  DeviceReturnTy ret1 = device_only_function(1);
+  DeviceReturnTy2 ret2 = device_only_function(1.0f);
+#ifndef __CUDA_ARCH__
+  // expected-error@-3 {{reference to __device__ function 'device_only_function' in __host__ __device__ function}}
+  // expected-error@-3 {{reference to __device__ function 'device_only_function' in __host__ __device__ function}}
+#endif
+  HostReturnTy ret3 = host_only_function(1);
+  

[clang] d510542 - [Fuchsia] Rely on linker switch rather than dead code ref for profile runtime

2020-06-04 Thread Petr Hosek via cfe-commits

Author: Petr Hosek
Date: 2020-06-04T14:25:19-07:00
New Revision: d51054217403b47f452619e11318bd214749a845

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

LOG: [Fuchsia] Rely on linker switch rather than dead code ref for profile 
runtime

Follow the model used on Linux, where the clang driver passes the
linker a -u switch to force the profile runtime to be linked in,
rather than having every TU emit a dead function with a reference.

Patch By: mcgrathr

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/Fuchsia.cpp
clang/lib/Driver/ToolChains/Fuchsia.h
clang/test/Driver/fuchsia.c
llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
llvm/test/Instrumentation/InstrProfiling/linkage.ll

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Fuchsia.cpp 
b/clang/lib/Driver/ToolChains/Fuchsia.cpp
index 8f485802887f..5ac10e37176c 100644
--- a/clang/lib/Driver/ToolChains/Fuchsia.cpp
+++ b/clang/lib/Driver/ToolChains/Fuchsia.cpp
@@ -15,6 +15,7 @@
 #include "clang/Driver/Options.h"
 #include "clang/Driver/SanitizerArgs.h"
 #include "llvm/Option/ArgList.h"
+#include "llvm/ProfileData/InstrProf.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/VirtualFileSystem.h"
@@ -365,3 +366,13 @@ SanitizerMask Fuchsia::getDefaultSanitizers() const {
   }
   return Res;
 }
+
+void Fuchsia::addProfileRTLibs(const llvm::opt::ArgList ,
+   llvm::opt::ArgStringList ) const {
+  // Add linker option -u__llvm_profile_runtime to cause runtime
+  // initialization module to be linked in.
+  if (needsProfileRT(Args))
+CmdArgs.push_back(Args.MakeArgString(
+Twine("-u", llvm::getInstrProfRuntimeHookVarName(;
+  ToolChain::addProfileRTLibs(Args, CmdArgs);
+}

diff  --git a/clang/lib/Driver/ToolChains/Fuchsia.h 
b/clang/lib/Driver/ToolChains/Fuchsia.h
index fee0e018f3ce..3159a54bda06 100644
--- a/clang/lib/Driver/ToolChains/Fuchsia.h
+++ b/clang/lib/Driver/ToolChains/Fuchsia.h
@@ -69,6 +69,9 @@ class LLVM_LIBRARY_VISIBILITY Fuchsia : public ToolChain {
   SanitizerMask getSupportedSanitizers() const override;
   SanitizerMask getDefaultSanitizers() const override;
 
+  void addProfileRTLibs(const llvm::opt::ArgList ,
+llvm::opt::ArgStringList ) const override;
+
   RuntimeLibType
   GetRuntimeLibType(const llvm::opt::ArgList ) const override;
   CXXStdlibType

diff  --git a/clang/test/Driver/fuchsia.c b/clang/test/Driver/fuchsia.c
index 359a2797da21..acc2d3ad75b0 100644
--- a/clang/test/Driver/fuchsia.c
+++ b/clang/test/Driver/fuchsia.c
@@ -242,3 +242,21 @@
 // RUN: -gsplit-dwarf -c %s 2>&1 \
 // RUN: | FileCheck %s -check-prefix=CHECK-SPLIT-DWARF
 // CHECK-SPLIT-DWARF: "-split-dwarf-output" "fuchsia.dwo"
+
+// RUN: %clang %s -### --target=aarch64-fuchsia \
+// RUN: -fprofile-instr-generate -fcoverage-mapping \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
+// RUN: -fuse-ld=lld 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK-PROFRT-AARCH64
+// CHECK-PROFRT-AARCH64: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
+// CHECK-PROFRT-AARCH64: "-u__llvm_profile_runtime"
+// CHECK-PROFRT-AARCH64: 
"[[RESOURCE_DIR]]{{/|}}lib{{/|}}aarch64-fuchsia{{/|}}libclang_rt.profile.a"
+
+// RUN: %clang %s -### --target=x86_64-fuchsia \
+// RUN: -fprofile-instr-generate -fcoverage-mapping \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
+// RUN: -fuse-ld=lld 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK-PROFRT-X86_64
+// CHECK-PROFRT-X86_64: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
+// CHECK-PROFRT-X86_64: "-u__llvm_profile_runtime"
+// CHECK-PROFRT-X86_64: 
"[[RESOURCE_DIR]]{{/|}}lib{{/|}}x86_64-fuchsia{{/|}}libclang_rt.profile.a"

diff  --git a/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp 
b/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
index 7e6903e71144..ceceafa86030 100644
--- a/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
+++ b/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
@@ -1034,9 +1034,9 @@ void InstrProfiling::emitRegistration() {
 }
 
 bool InstrProfiling::emitRuntimeHook() {
-  // We expect the linker to be invoked with -u flag for linux,
-  // for which case there is no need to emit the user function.
-  if (TT.isOSLinux())
+  // We expect the linker to be invoked with -u flag for Linux or
+  // Fuchsia, in which case there is no need to emit the user function.
+  if (TT.isOSLinux() || TT.isOSFuchsia())
 return false;
 
   // If the module's provided its own runtime, we don't need to do anything.

diff  --git a/llvm/test/Instrumentation/InstrProfiling/linkage.ll 

[clang] f9ea86e - [Docs] Add the entry for `Advanced builds` in UserGuide.rst

2020-06-04 Thread Yuanfang Chen via cfe-commits

Author: Yuanfang Chen
Date: 2020-06-04T14:52:51-07:00
New Revision: f9ea86eaa1a3ba18973666c4de56dfde8d488574

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

LOG: [Docs] Add the entry for `Advanced builds` in UserGuide.rst

Also add a link to it from ThinLTO.rst.

Added: 


Modified: 
clang/docs/ThinLTO.rst
llvm/docs/UserGuides.rst

Removed: 




diff  --git a/clang/docs/ThinLTO.rst b/clang/docs/ThinLTO.rst
index 2d5d0a71fa6b..528530c5ae98 100644
--- a/clang/docs/ThinLTO.rst
+++ b/clang/docs/ThinLTO.rst
@@ -194,7 +194,8 @@ Possible key-value pairs are:
 Clang Bootstrap
 ---
 
-To bootstrap clang/LLVM with ThinLTO, follow these steps:
+To `bootstrap clang/LLVM 
`_
+with ThinLTO, follow these steps:
 
 1. The host compiler_ must be a version of clang that supports ThinLTO.
 #. The host linker_ must support ThinLTO (and in the case of gold, must be
@@ -225,7 +226,7 @@ To bootstrap clang/LLVM with ThinLTO, follow these steps:
``CMAKE_EXE_LINKER_FLAGS:STRING=``. Note the configure may fail if
linker plugin options are instead specified directly in the previous step.
 
-The `BOOTSTRAP_LLVM_ENABLE_LTO=Thin`` will enable ThinLTO for stage 2 and
+The ``BOOTSTRAP_LLVM_ENABLE_LTO=Thin`` will enable ThinLTO for stage 2 and
 stage 3 in case the compiler used for stage 1 does not support the ThinLTO
 option.
 

diff  --git a/llvm/docs/UserGuides.rst b/llvm/docs/UserGuides.rst
index 0b91b3cbe66d..6e4329128fab 100644
--- a/llvm/docs/UserGuides.rst
+++ b/llvm/docs/UserGuides.rst
@@ -96,7 +96,10 @@ LLVM Builds and Distributions
 
 :doc:`Support Library `
This document describes the LLVM Support Library (``lib/Support``) and
-   how to keep LLVM source code portable
+   how to keep LLVM source code portable.
+
+:doc:`AdvancedBuilds`
+   This document describes more advanced build configurations.
 
 Optimizations
 -



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


[clang] 263390d - [CUDA][HIP] Fix implicit HD function resolution

2020-06-04 Thread Yaxun Liu via cfe-commits

Author: Yaxun (Sam) Liu
Date: 2020-06-04T16:54:52-04:00
New Revision: 263390d4f5f23967a31af09eb6e0c12e633d6104

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

LOG: [CUDA][HIP] Fix implicit HD function resolution

recommit e03394c6a6ff with fix

When implicit HD function calls a function in device compilation,
if one candidate is an implicit HD function, current resolution rule is:

D wins over HD and H
HD and H are equal

this caused regression when there is an otherwise worse D candidate

This patch changes that to

D, HD and H are all equal

The rationale is that we already know for host compilation there is already
a valid candidate in HD and H candidates that will not cause error. Allowing
HD and H gives us a fall back candidate that will not cause error. If D wins,
that means D has to be a better match otherwise, therefore D should also
be a valid candidate that will not cause error. In this way, we can guarantee
no regression.

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

Added: 


Modified: 
clang/include/clang/Sema/Sema.h
clang/lib/Sema/SemaCUDA.cpp
clang/lib/Sema/SemaOverload.cpp
clang/test/SemaCUDA/function-overload.cu

Removed: 




diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index c8c0a6a6..2a71d01d6edb 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -11686,6 +11686,8 @@ class Sema final {
 return IdentifyCUDATarget(dyn_cast(CurContext));
   }
 
+  static bool IsCUDAImplicitHostDeviceFunction(const FunctionDecl *D);
+
   // CUDA function call preference. Must be ordered numerically from
   // worst to best.
   enum CUDAFunctionPreference {

diff  --git a/clang/lib/Sema/SemaCUDA.cpp b/clang/lib/Sema/SemaCUDA.cpp
index 5d6c15196750..1106cef0eca2 100644
--- a/clang/lib/Sema/SemaCUDA.cpp
+++ b/clang/lib/Sema/SemaCUDA.cpp
@@ -211,6 +211,20 @@ Sema::IdentifyCUDAPreference(const FunctionDecl *Caller,
   llvm_unreachable("All cases should've been handled by now.");
 }
 
+template  static bool hasImplicitAttr(const FunctionDecl *D) {
+  if (!D)
+return false;
+  if (auto *A = D->getAttr())
+return A->isImplicit();
+  return D->isImplicit();
+}
+
+bool Sema::IsCUDAImplicitHostDeviceFunction(const FunctionDecl *D) {
+  bool IsImplicitDevAttr = hasImplicitAttr(D);
+  bool IsImplicitHostAttr = hasImplicitAttr(D);
+  return IsImplicitDevAttr && IsImplicitHostAttr;
+}
+
 void Sema::EraseUnwantedCUDAMatches(
 const FunctionDecl *Caller,
 SmallVectorImpl> ) {

diff  --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index f3ac2036cb0d..2180a9c950c2 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -9387,16 +9387,22 @@ static Comparison compareEnableIfAttrs(const Sema , 
const FunctionDecl *Cand1,
   return Comparison::Equal;
 }
 
-static bool isBetterMultiversionCandidate(const OverloadCandidate ,
-  const OverloadCandidate ) {
+static Comparison
+isBetterMultiversionCandidate(const OverloadCandidate ,
+  const OverloadCandidate ) {
   if (!Cand1.Function || !Cand1.Function->isMultiVersion() || !Cand2.Function 
||
   !Cand2.Function->isMultiVersion())
-return false;
+return Comparison::Equal;
 
-  // If Cand1 is invalid, it cannot be a better match, if Cand2 is invalid, 
this
-  // is obviously better.
-  if (Cand1.Function->isInvalidDecl()) return false;
-  if (Cand2.Function->isInvalidDecl()) return true;
+  // If both are invalid, they are equal. If one of them is invalid, the other
+  // is better.
+  if (Cand1.Function->isInvalidDecl()) {
+if (Cand2.Function->isInvalidDecl())
+  return Comparison::Equal;
+return Comparison::Worse;
+  }
+  if (Cand2.Function->isInvalidDecl())
+return Comparison::Better;
 
   // If this is a cpu_dispatch/cpu_specific multiversion situation, prefer
   // cpu_dispatch, else arbitrarily based on the identifiers.
@@ -9406,16 +9412,18 @@ static bool isBetterMultiversionCandidate(const 
OverloadCandidate ,
   const auto *Cand2CPUSpec = Cand2.Function->getAttr();
 
   if (!Cand1CPUDisp && !Cand2CPUDisp && !Cand1CPUSpec && !Cand2CPUSpec)
-return false;
+return Comparison::Equal;
 
   if (Cand1CPUDisp && !Cand2CPUDisp)
-return true;
+return Comparison::Better;
   if (Cand2CPUDisp && !Cand1CPUDisp)
-return false;
+return Comparison::Worse;
 
   if (Cand1CPUSpec && Cand2CPUSpec) {
 if (Cand1CPUSpec->cpus_size() != Cand2CPUSpec->cpus_size())
-  return Cand1CPUSpec->cpus_size() < Cand2CPUSpec->cpus_size();
+  return Cand1CPUSpec->cpus_size() < Cand2CPUSpec->cpus_size()
+ ? Comparison::Better
+ : Comparison::Worse;
 
   

[PATCH] D81176: [HIP] Add default header and include path

2020-06-04 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.
yaxunl added a reviewer: tra.
Herald added subscribers: kerbowa, mgorny, nhaehnle, jvesely.

To support std::complex and some other standard C/C++ functions in HIP device 
code,
they need to be forced to be `__host__ __device__` functions by pragmas. This 
is done
by some clang standard C++ wrapper headers which are shared between cuda-clang 
and hip-Clang.

For these standard C++ wapper headers to work properly, specific include path 
order
has to be enforced:

1. clang C++ wrapper include path
2. standard C++ include path
3. clang include path

Also, these C++ wrapper headers require device version of some standard C/C++ 
functions
must be declared before including them. This needs to be done by including a 
default
header which declares or defines these device functions. The default header is 
always
included before any other headers are included by users.

This patch adds the the default header and include path for HIP.


https://reviews.llvm.org/D81176

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Driver/Options.td
  clang/include/clang/Driver/ToolChain.h
  clang/lib/Driver/ToolChain.cpp
  clang/lib/Driver/ToolChains/AMDGPU.cpp
  clang/lib/Driver/ToolChains/AMDGPU.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/Cuda.cpp
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/lib/Driver/ToolChains/Gnu.h
  clang/lib/Driver/ToolChains/HIP.cpp
  clang/lib/Driver/ToolChains/HIP.h
  clang/lib/Driver/ToolChains/Linux.cpp
  clang/lib/Driver/ToolChains/Linux.h
  clang/lib/Driver/ToolChains/MSVC.cpp
  clang/lib/Driver/ToolChains/MSVC.h
  clang/lib/Driver/ToolChains/ROCm.h
  clang/lib/Headers/CMakeLists.txt
  clang/lib/Headers/__clang_cuda_math_forward_declares.h
  clang/lib/Headers/__clang_hip_libdevice_declares.h
  clang/lib/Headers/__clang_hip_math.h
  clang/lib/Headers/__clang_hip_runtime_wrapper.h
  clang/test/Driver/Inputs/rocm-device-libs/amdgcn/bitcode/hip.bc
  clang/test/Driver/Inputs/rocm-device-libs/amdgcn/bitcode/ockl.bc
  
clang/test/Driver/Inputs/rocm-device-libs/amdgcn/bitcode/oclc_correctly_rounded_sqrt_off.bc
  
clang/test/Driver/Inputs/rocm-device-libs/amdgcn/bitcode/oclc_correctly_rounded_sqrt_on.bc
  clang/test/Driver/Inputs/rocm-device-libs/amdgcn/bitcode/oclc_daz_opt_off.bc
  clang/test/Driver/Inputs/rocm-device-libs/amdgcn/bitcode/oclc_daz_opt_on.bc
  
clang/test/Driver/Inputs/rocm-device-libs/amdgcn/bitcode/oclc_finite_only_off.bc
  
clang/test/Driver/Inputs/rocm-device-libs/amdgcn/bitcode/oclc_finite_only_on.bc
  
clang/test/Driver/Inputs/rocm-device-libs/amdgcn/bitcode/oclc_isa_version_1010.bc
  
clang/test/Driver/Inputs/rocm-device-libs/amdgcn/bitcode/oclc_isa_version_1011.bc
  
clang/test/Driver/Inputs/rocm-device-libs/amdgcn/bitcode/oclc_isa_version_1012.bc
  
clang/test/Driver/Inputs/rocm-device-libs/amdgcn/bitcode/oclc_isa_version_803.bc
  
clang/test/Driver/Inputs/rocm-device-libs/amdgcn/bitcode/oclc_isa_version_900.bc
  
clang/test/Driver/Inputs/rocm-device-libs/amdgcn/bitcode/oclc_unsafe_math_off.bc
  
clang/test/Driver/Inputs/rocm-device-libs/amdgcn/bitcode/oclc_unsafe_math_on.bc
  
clang/test/Driver/Inputs/rocm-device-libs/amdgcn/bitcode/oclc_wavefrontsize64_off.bc
  
clang/test/Driver/Inputs/rocm-device-libs/amdgcn/bitcode/oclc_wavefrontsize64_on.bc
  clang/test/Driver/Inputs/rocm-device-libs/amdgcn/bitcode/ocml.bc
  clang/test/Driver/Inputs/rocm-device-libs/amdgcn/bitcode/opencl.bc
  clang/test/Driver/Inputs/rocm/amdgcn/bitcode/hip.bc
  clang/test/Driver/Inputs/rocm/amdgcn/bitcode/ockl.bc
  
clang/test/Driver/Inputs/rocm/amdgcn/bitcode/oclc_correctly_rounded_sqrt_off.bc
  clang/test/Driver/Inputs/rocm/amdgcn/bitcode/oclc_correctly_rounded_sqrt_on.bc
  clang/test/Driver/Inputs/rocm/amdgcn/bitcode/oclc_daz_opt_off.bc
  clang/test/Driver/Inputs/rocm/amdgcn/bitcode/oclc_daz_opt_on.bc
  clang/test/Driver/Inputs/rocm/amdgcn/bitcode/oclc_finite_only_off.bc
  clang/test/Driver/Inputs/rocm/amdgcn/bitcode/oclc_finite_only_on.bc
  clang/test/Driver/Inputs/rocm/amdgcn/bitcode/oclc_isa_version_1010.bc
  clang/test/Driver/Inputs/rocm/amdgcn/bitcode/oclc_isa_version_1011.bc
  clang/test/Driver/Inputs/rocm/amdgcn/bitcode/oclc_isa_version_1012.bc
  clang/test/Driver/Inputs/rocm/amdgcn/bitcode/oclc_isa_version_803.bc
  clang/test/Driver/Inputs/rocm/amdgcn/bitcode/oclc_isa_version_900.bc
  clang/test/Driver/Inputs/rocm/amdgcn/bitcode/oclc_unsafe_math_off.bc
  clang/test/Driver/Inputs/rocm/amdgcn/bitcode/oclc_unsafe_math_on.bc
  clang/test/Driver/Inputs/rocm/amdgcn/bitcode/oclc_wavefrontsize64_off.bc
  clang/test/Driver/Inputs/rocm/amdgcn/bitcode/oclc_wavefrontsize64_on.bc
  clang/test/Driver/Inputs/rocm/amdgcn/bitcode/ocml.bc
  clang/test/Driver/Inputs/rocm/amdgcn/bitcode/opencl.bc
  clang/test/Driver/Inputs/rocm/include/hip/hip_runtime.h
  clang/test/Driver/hip-device-libs.hip
  clang/test/Driver/hip-include-path.hip
  clang/test/Driver/rocm-detect.cl
  clang/test/Driver/rocm-detect.hip
  

[PATCH] D80896: [clang-tidy][misc-redundant-expression] Support for CXXFoldExpr

2020-06-04 Thread Zinovy Nis via Phabricator via cfe-commits
zinovy.nis updated this revision to Diff 268527.
zinovy.nis added a comment.

Simplify test.


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

https://reviews.llvm.org/D80896

Files:
  clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
  clang-tools-extra/test/clang-tidy/checkers/misc-redundant-expression.cpp


Index: clang-tools-extra/test/clang-tidy/checkers/misc-redundant-expression.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/misc-redundant-expression.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/misc-redundant-expression.cpp
@@ -793,4 +793,10 @@
 return foo < GetFoo() && foo < maybe_foo;
   }
 };
-}
+
+template 
+struct Bar2 {
+  static_assert((... && (sizeof(Values) > 0)) == (... && (sizeof(Values) > 
0)));
+  // CHECK-MESSAGES: :[[@LINE-1]]:47: warning: both sides of operator are 
equivalent [misc-redundant-expression]
+};
+} // namespace no_crash
Index: clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
===
--- clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
+++ clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
@@ -72,8 +72,8 @@
   Expr::const_child_iterator LeftIter = Left->child_begin();
   Expr::const_child_iterator RightIter = Right->child_begin();
   while (LeftIter != Left->child_end() && RightIter != Right->child_end()) {
-if (!areEquivalentExpr(dyn_cast(*LeftIter),
-   dyn_cast(*RightIter)))
+if (!areEquivalentExpr(dyn_cast_or_null(*LeftIter),
+   dyn_cast_or_null(*RightIter)))
   return false;
 ++LeftIter;
 ++RightIter;
@@ -117,6 +117,9 @@
   case Stmt::MemberExprClass:
 return cast(Left)->getMemberDecl() ==
cast(Right)->getMemberDecl();
+  case Stmt::CXXFoldExprClass:
+return cast(Left)->getOperator() ==
+   cast(Right)->getOperator();
   case Stmt::CXXFunctionalCastExprClass:
   case Stmt::CStyleCastExprClass:
 return cast(Left)->getTypeAsWritten() ==


Index: clang-tools-extra/test/clang-tidy/checkers/misc-redundant-expression.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/misc-redundant-expression.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/misc-redundant-expression.cpp
@@ -793,4 +793,10 @@
 return foo < GetFoo() && foo < maybe_foo;
   }
 };
-}
+
+template 
+struct Bar2 {
+  static_assert((... && (sizeof(Values) > 0)) == (... && (sizeof(Values) > 0)));
+  // CHECK-MESSAGES: :[[@LINE-1]]:47: warning: both sides of operator are equivalent [misc-redundant-expression]
+};
+} // namespace no_crash
Index: clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
===
--- clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
+++ clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
@@ -72,8 +72,8 @@
   Expr::const_child_iterator LeftIter = Left->child_begin();
   Expr::const_child_iterator RightIter = Right->child_begin();
   while (LeftIter != Left->child_end() && RightIter != Right->child_end()) {
-if (!areEquivalentExpr(dyn_cast(*LeftIter),
-   dyn_cast(*RightIter)))
+if (!areEquivalentExpr(dyn_cast_or_null(*LeftIter),
+   dyn_cast_or_null(*RightIter)))
   return false;
 ++LeftIter;
 ++RightIter;
@@ -117,6 +117,9 @@
   case Stmt::MemberExprClass:
 return cast(Left)->getMemberDecl() ==
cast(Right)->getMemberDecl();
+  case Stmt::CXXFoldExprClass:
+return cast(Left)->getOperator() ==
+   cast(Right)->getOperator();
   case Stmt::CXXFunctionalCastExprClass:
   case Stmt::CStyleCastExprClass:
 return cast(Left)->getTypeAsWritten() ==
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D81131: [DebugInfo] Fix assertion for extern void type

2020-06-04 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

Patches without tests shouldn't be approved - and at least the usual/rough 
metric I use for patch approval is (most often - unless I'm reviewing the work 
of the code owner in any area who wants a second opinion, etc) - I approve it 
if I'd be willing to commit a similar patch without approval (with post-commit 
review - ie: I'm fairly sure this is the right direction and folks will agree 
with me, or minor changes can be handled in post-commit iteration). Otherwise 
"approval" gets muddied as to whether it means "you can now commit this" versus 
"I think this is good but you should wait for someone more authoritative to say 
'yes' before it's committed" (usually folks on the project call out the latter 
explicitly - sometimes using Phab's "approve" sometimes not).

In any case: I think if we're going to support "const void" we should support 
"void" too & fix the verifier to allow this & make sure LLVM produces the 
correct debug info for it (which is probably a DW_TAG_variable without a 
DW_AT_type attribute (same as a function with a void return type has no 
DW_AT_type attribute) - and check that GCC does the same thing


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81131



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


  1   2   3   >