[PATCH] D72755: [RISCV] Pass target-abi via module flag metadata

2020-01-20 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe15fb06e2d0a: [RISCV] Pass target-abi via module flag 
metadata (authored by Zakk Chen zakk.c...@sifive.com).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72755

Files:
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGen/riscv-metadata.c


Index: clang/test/CodeGen/riscv-metadata.c
===
--- /dev/null
+++ clang/test/CodeGen/riscv-metadata.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -triple riscv32 -target-abi ilp32 -emit-llvm -o - %s | 
FileCheck -check-prefix=ILP32 %s
+// RUN: %clang_cc1 -triple riscv32 -target-feature +f -target-abi ilp32f 
-emit-llvm -o - %s | FileCheck -check-prefix=ILP32F %s
+// RUN: %clang_cc1 -triple riscv32 -target-feature +d -target-abi ilp32d 
-emit-llvm -o - %s | FileCheck -check-prefix=ILP32D %s
+// RUN: %clang_cc1 -triple riscv64 -target-abi lp64 -emit-llvm -o - %s | 
FileCheck -check-prefix=LP64 %s
+// RUN: %clang_cc1 -triple riscv64 -target-feature +f -target-abi lp64f 
-emit-llvm -o - %s | FileCheck -check-prefix=LP64F %s
+// RUN: %clang_cc1 -triple riscv64 -target-feature +d -target-abi lp64d 
-emit-llvm -o - %s | FileCheck -check-prefix=LP64D %s
+
+// ILP32: !{{[0-9]+}} = !{i32 1, !"target-abi", !"ilp32"}
+// ILP32F: !{{[0-9]+}} = !{i32 1, !"target-abi", !"ilp32f"}
+// ILP32D: !{{[0-9]+}} = !{i32 1, !"target-abi", !"ilp32d"}
+
+// LP64: !{{[0-9]+}} = !{i32 1, !"target-abi", !"lp64"}
+// LP64F: !{{[0-9]+}} = !{i32 1, !"target-abi", !"lp64f"}
+// LP64D: !{{[0-9]+}} = !{i32 1, !"target-abi", !"lp64d"}
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -537,6 +537,13 @@
 getModule().addModuleFlag(llvm::Module::Error, "min_enum_size", EnumWidth);
   }
 
+  if (Arch == llvm::Triple::riscv32 || Arch == llvm::Triple::riscv64) {
+StringRef ABIStr = Target.getABI();
+llvm::LLVMContext  = TheModule.getContext();
+getModule().addModuleFlag(llvm::Module::Error, "target-abi",
+  llvm::MDString::get(Ctx, ABIStr));
+  }
+
   if (CodeGenOpts.SanitizeCfiCrossDso) {
 // Indicate that we want cross-DSO control flow integrity checks.
 getModule().addModuleFlag(llvm::Module::Override, "Cross-DSO CFI", 1);


Index: clang/test/CodeGen/riscv-metadata.c
===
--- /dev/null
+++ clang/test/CodeGen/riscv-metadata.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -triple riscv32 -target-abi ilp32 -emit-llvm -o - %s | FileCheck -check-prefix=ILP32 %s
+// RUN: %clang_cc1 -triple riscv32 -target-feature +f -target-abi ilp32f -emit-llvm -o - %s | FileCheck -check-prefix=ILP32F %s
+// RUN: %clang_cc1 -triple riscv32 -target-feature +d -target-abi ilp32d -emit-llvm -o - %s | FileCheck -check-prefix=ILP32D %s
+// RUN: %clang_cc1 -triple riscv64 -target-abi lp64 -emit-llvm -o - %s | FileCheck -check-prefix=LP64 %s
+// RUN: %clang_cc1 -triple riscv64 -target-feature +f -target-abi lp64f -emit-llvm -o - %s | FileCheck -check-prefix=LP64F %s
+// RUN: %clang_cc1 -triple riscv64 -target-feature +d -target-abi lp64d -emit-llvm -o - %s | FileCheck -check-prefix=LP64D %s
+
+// ILP32: !{{[0-9]+}} = !{i32 1, !"target-abi", !"ilp32"}
+// ILP32F: !{{[0-9]+}} = !{i32 1, !"target-abi", !"ilp32f"}
+// ILP32D: !{{[0-9]+}} = !{i32 1, !"target-abi", !"ilp32d"}
+
+// LP64: !{{[0-9]+}} = !{i32 1, !"target-abi", !"lp64"}
+// LP64F: !{{[0-9]+}} = !{i32 1, !"target-abi", !"lp64f"}
+// LP64D: !{{[0-9]+}} = !{i32 1, !"target-abi", !"lp64d"}
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -537,6 +537,13 @@
 getModule().addModuleFlag(llvm::Module::Error, "min_enum_size", EnumWidth);
   }
 
+  if (Arch == llvm::Triple::riscv32 || Arch == llvm::Triple::riscv64) {
+StringRef ABIStr = Target.getABI();
+llvm::LLVMContext  = TheModule.getContext();
+getModule().addModuleFlag(llvm::Module::Error, "target-abi",
+  llvm::MDString::get(Ctx, ABIStr));
+  }
+
   if (CodeGenOpts.SanitizeCfiCrossDso) {
 // Indicate that we want cross-DSO control flow integrity checks.
 getModule().addModuleFlag(llvm::Module::Override, "Cross-DSO CFI", 1);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] e15fb06 - [RISCV] Pass target-abi via module flag metadata

2020-01-20 Thread Zakk Chen via cfe-commits

Author: Zakk Chen
Date: 2020-01-20T23:30:54-08:00
New Revision: e15fb06e2d0a068de549464d72081811e7fac612

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

LOG: [RISCV] Pass target-abi via module flag metadata

Reviewers: lenary, asb

Reviewed By: lenary

Tags: #clang

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

Added: 
clang/test/CodeGen/riscv-metadata.c

Modified: 
clang/lib/CodeGen/CodeGenModule.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 9e007b35df2c..1fede3445625 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -537,6 +537,13 @@ void CodeGenModule::Release() {
 getModule().addModuleFlag(llvm::Module::Error, "min_enum_size", EnumWidth);
   }
 
+  if (Arch == llvm::Triple::riscv32 || Arch == llvm::Triple::riscv64) {
+StringRef ABIStr = Target.getABI();
+llvm::LLVMContext  = TheModule.getContext();
+getModule().addModuleFlag(llvm::Module::Error, "target-abi",
+  llvm::MDString::get(Ctx, ABIStr));
+  }
+
   if (CodeGenOpts.SanitizeCfiCrossDso) {
 // Indicate that we want cross-DSO control flow integrity checks.
 getModule().addModuleFlag(llvm::Module::Override, "Cross-DSO CFI", 1);

diff  --git a/clang/test/CodeGen/riscv-metadata.c 
b/clang/test/CodeGen/riscv-metadata.c
new file mode 100644
index ..19bde4ca73be
--- /dev/null
+++ b/clang/test/CodeGen/riscv-metadata.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -triple riscv32 -target-abi ilp32 -emit-llvm -o - %s | 
FileCheck -check-prefix=ILP32 %s
+// RUN: %clang_cc1 -triple riscv32 -target-feature +f -target-abi ilp32f 
-emit-llvm -o - %s | FileCheck -check-prefix=ILP32F %s
+// RUN: %clang_cc1 -triple riscv32 -target-feature +d -target-abi ilp32d 
-emit-llvm -o - %s | FileCheck -check-prefix=ILP32D %s
+// RUN: %clang_cc1 -triple riscv64 -target-abi lp64 -emit-llvm -o - %s | 
FileCheck -check-prefix=LP64 %s
+// RUN: %clang_cc1 -triple riscv64 -target-feature +f -target-abi lp64f 
-emit-llvm -o - %s | FileCheck -check-prefix=LP64F %s
+// RUN: %clang_cc1 -triple riscv64 -target-feature +d -target-abi lp64d 
-emit-llvm -o - %s | FileCheck -check-prefix=LP64D %s
+
+// ILP32: !{{[0-9]+}} = !{i32 1, !"target-abi", !"ilp32"}
+// ILP32F: !{{[0-9]+}} = !{i32 1, !"target-abi", !"ilp32f"}
+// ILP32D: !{{[0-9]+}} = !{i32 1, !"target-abi", !"ilp32d"}
+
+// LP64: !{{[0-9]+}} = !{i32 1, !"target-abi", !"lp64"}
+// LP64F: !{{[0-9]+}} = !{i32 1, !"target-abi", !"lp64f"}
+// LP64D: !{{[0-9]+}} = !{i32 1, !"target-abi", !"lp64d"}



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


[PATCH] D69868: Allow "callbr" to return non-void values

2020-01-20 Thread Bill Wendling via Phabricator via cfe-commits
void updated this revision to Diff 239231.
void added a comment.
Herald added a subscriber: MatzeB.

Split the machine basic block after an INLINEASM_BR instruction that has
outputs. The copies then end up in a separate block and the back end doesn't
have to deal with COPY instructions between two terminators.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69868

Files:
  llvm/docs/LangRef.rst
  llvm/include/llvm/CodeGen/MachineBasicBlock.h
  llvm/lib/AsmParser/LLParser.cpp
  llvm/lib/CodeGen/MachineBasicBlock.cpp
  llvm/lib/CodeGen/MachineVerifier.cpp
  llvm/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/lib/IR/Verifier.cpp
  llvm/test/CodeGen/X86/callbr-asm-outputs.ll
  llvm/test/CodeGen/X86/callbr-asm.ll

Index: llvm/test/CodeGen/X86/callbr-asm.ll
===
--- llvm/test/CodeGen/X86/callbr-asm.ll
+++ llvm/test/CodeGen/X86/callbr-asm.ll
@@ -1,5 +1,5 @@
 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
-; RUN: llc < %s -mtriple=i686-- -O3 | FileCheck %s
+; RUN: llc < %s -mtriple=i686-- -O3 -verify-machineinstrs | FileCheck %s
 
 ; Tests for using callbr as an asm-goto wrapper
 
Index: llvm/test/CodeGen/X86/callbr-asm-outputs.ll
===
--- llvm/test/CodeGen/X86/callbr-asm-outputs.ll
+++ llvm/test/CodeGen/X86/callbr-asm-outputs.ll
@@ -1,18 +1,160 @@
-; RUN: not llc -mtriple=i686-- < %s 2> %t
-; RUN: FileCheck %s < %t
+; RUN: llc -mtriple=i686-- -verify-machineinstrs < %s | FileCheck %s
 
-; CHECK: error: asm-goto outputs not supported
+; A test for asm-goto output
 
-; A test for asm-goto output prohibition
-
-define i32 @test(i32 %a) {
+; CHECK-LABEL: test1:
+; CHECK:   movl 4(%esp), %eax
+; CHECK-NEXT:  addl $4, %eax
+; CHECK-NEXT:  #APP
+; CHECK-NEXT:  xorl %eax, %eax
+; CHECK-NEXT:  jmp .Ltmp0
+; CHECK-NEXT:  #NO_APP
+; CHECK-NEXT:  .LBB0_1:
+; CHECK-NEXT:  retl
+; CHECK-LABEL: .Ltmp0: # Address of block that was removed by CodeGen
+define i32 @test1(i32 %x) {
 entry:
-  %0 = add i32 %a, 4
-  %1 = callbr i32 asm "xorl $1, $1; jmp ${1:l}", "=,r,X,~{dirflag},~{fpsr},~{flags}"(i32 %0, i8* blockaddress(@test, %fail)) to label %normal [label %fail]
+  %add = add nsw i32 %x, 4
+  %ret = callbr i32 asm "xorl $1, $0; jmp ${2:l}", "=r,r,X,~{dirflag},~{fpsr},~{flags}"(i32 %add, i8* blockaddress(@test1, %abnormal))
+  to label %normal [label %abnormal]
 
 normal:
-  ret i32 %1
+  ret i32 %ret
 
-fail:
+abnormal:
   ret i32 1
 }
+
+; CHECK-LABEL: test2:
+; CHECK:   # %bb.1: # %if.then
+; CHECK-NEXT:  #APP
+; CHECK-NEXT:  testl %esi, %esi
+; CHECK-NEXT:  testl %edi, %esi
+; CHECK-NEXT:  jne .Ltmp1
+; CHECK-NEXT:  #NO_APP
+; CHECK-NEXT:  .LBB1_2:
+; CHECK-NEXT:  jmp .LBB1_4
+; CHECK-NEXT:  .LBB1_3: # %if.else
+; CHECK-NEXT:  #APP
+; CHECK-NEXT:  testl %esi, %edi
+; CHECK-NEXT:  testl %esi, %edi
+; CHECK-NEXT:  jne .Ltmp2
+; CHECK-NEXT:  #NO_APP
+; CHECK-NEXT:  .LBB1_4:
+; CHECK-NEXT:  movl %esi, %eax
+; CHECK-NEXT:  addl %edi, %eax
+; CHECK-NEXT:  .Ltmp2:
+; CHECK-NEXT:  # %bb.5: # %return
+; CHECK-LABEL: .Ltmp1: # Address of block that was removed by CodeGen
+define i32 @test2(i32 %out1, i32 %out2) {
+entry:
+  %cmp = icmp slt i32 %out1, %out2
+  br i1 %cmp, label %if.then, label %if.else
+
+if.then:  ; preds = %entry
+  %0 = callbr { i32, i32 } asm sideeffect "testl $0, $0; testl $1, $2; jne ${3:l}", "={si},={di},r,X,X,0,1,~{dirflag},~{fpsr},~{flags}"(i32 %out1, i8* blockaddress(@test2, %label_true), i8* blockaddress(@test2, %return), i32 %out1, i32 %out2)
+  to label %if.end [label %label_true, label %return]
+
+if.else:  ; preds = %entry
+  %1 = callbr { i32, i32 } asm sideeffect "testl $0, $1; testl $2, $3; jne ${5:l}", "={si},={di},r,r,X,X,0,1,~{dirflag},~{fpsr},~{flags}"(i32 %out1, i32 %out2, i8* blockaddress(@test2, %label_true), i8* blockaddress(@test2, %return), i32 %out1, i32 %out2)
+  to label %if.end [label %label_true, label %return]
+
+if.end:   ; preds = %if.else, %if.then
+  %.sink11 = phi { i32, i32 } [ %0, %if.then ], [ %1, %if.else ]
+  %asmresult3 = extractvalue { i32, i32 } %.sink11, 0
+  %asmresult4 = extractvalue { i32, i32 } %.sink11, 1
+  %add = add nsw i32 %asmresult4, %asmresult3
+  br label %return
+
+label_true:   ; preds = %if.else, %if.then
+  br label %return
+
+return:   ; preds = %if.then, %if.else, %label_true, %if.end
+  %retval.0 = phi i32 [ %add, %if.end ], [ -2, %label_true ], [ -1, %if.else ], [ -1, %if.then ]
+  ret i32 %retval.0
+}
+
+; CHECK-LABEL: test3:
+; CHECK:   # 

[PATCH] D44609: [clang-format] New option BeforeLambdaBody to manage lambda line break inside function parameter call (in Allman style)

2020-01-20 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

I think if you can fix the missing documentation it looks pretty good to go.

I do like the use of the static functions and the extensive test cases.. thank 
you.




Comment at: clang/lib/Format/ContinuationIndenter.cpp:1442
+// Search for any parameter that is a lambda
+auto const *nextTok = Current.Next;
+while (nextTok != nullptr) {

some people don't like the use of auto if the type isn't obvious,

I think by convention shouldn't this variable be `NextTok`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D44609



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


[PATCH] D44609: [Clang-Format] New option BeforeLambdaBody to manage lambda line break inside function parameter call (in Allman style)

2020-01-20 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

Please can you regenerate the ClangFormatStyleOptions.rst using 
docs/tools/dump_style.py and add an entry into the clang release notes in the 
clang-format section


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D44609



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


[PATCH] D72841: [RFC] Add support for pragma float_control, to control precision and exception behavior at the source level

2020-01-20 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff added inline comments.



Comment at: clang/lib/Parse/ParsePragma.cpp:2537
+if (!Actions.CurContext->isTranslationUnit()) {
+//FIXME this seems to be the wrong way to check file-scope
+//since the token immediately following a function definition

Probably using `Actions.getCurScope()` can help to recognize file scope.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72841



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


[PATCH] D72638: [clangd] Fix rename for explicit destructor calls

2020-01-20 Thread Kirill Bobyrev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG38bdb94120b7: [clangd] Fix rename for explicit destructor 
calls (authored by kbobyrev).

Changed prior to commit:
  https://reviews.llvm.org/D72638?vs=239182=239227#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72638

Files:
  clang-tools-extra/clangd/FindTarget.cpp
  clang-tools-extra/clangd/unittests/FindTargetTests.cpp
  clang-tools-extra/clangd/unittests/RenameTests.cpp

Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -265,6 +265,33 @@
 }
   )cpp",
 
+  // Destructor explicit call.
+  R"cpp(
+class [[F^oo]] {
+public:
+  ~[[^Foo]]();
+};
+
+[[Foo^]]::~[[^Foo]]() {}
+
+int main() {
+  [[Fo^o]] f;
+  f.~/*something*/[[^Foo]]();
+  f.~[[^Foo]]();
+}
+  )cpp",
+
+  // Derived destructor explicit call.
+  R"cpp(
+class [[Bas^e]] {};
+class Derived : public [[Bas^e]] {}
+
+int main() {
+  [[Bas^e]] *foo = new Derived();
+  foo->[[^Base]]::~[[^Base]]();
+}
+  )cpp",
+
   // CXXConstructor initializer list.
   R"cpp(
 class Baz {};
Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -879,6 +879,56 @@
 "8: targets = {INT2}, decl\n"
 "9: targets = {NS}, decl\n"
 "10: targets = {ns}\n"},
+   // User-defined conversion operator.
+   {R"cpp(
+void foo() {
+   class $0^Bar {};
+   class $1^Foo {
+   public:
+ // FIXME: This should have only one reference to Bar.
+ $2^operator $3^$4^Bar();
+   };
+
+   $5^Foo $6^f;
+   $7^f.$8^operator $9^Bar();
+}
+)cpp",
+"0: targets = {Bar}, decl\n"
+"1: targets = {Foo}, decl\n"
+"2: targets = {foo()::Foo::operator Bar}, decl\n"
+"3: targets = {Bar}\n"
+"4: targets = {Bar}\n"
+"5: targets = {Foo}\n"
+"6: targets = {f}, decl\n"
+"7: targets = {f}\n"
+"8: targets = {foo()::Foo::operator Bar}\n"
+"9: targets = {Bar}\n"},
+   // Destructor.
+   {R"cpp(
+ void foo() {
+   class $0^Foo {
+   public:
+ ~$1^Foo() {}
+
+ void $2^destructMe() {
+   this->~$3^Foo();
+ }
+   };
+
+   $4^Foo $5^f;
+   $6^f.~ /*...*/ $7^Foo();
+ }
+   )cpp",
+"0: targets = {Foo}, decl\n"
+// FIXME: It's better to target destructor's FunctionDecl instead of
+// the type itself (similar to constructor).
+"1: targets = {Foo}\n"
+"2: targets = {foo()::Foo::destructMe}, decl\n"
+"3: targets = {Foo}\n"
+"4: targets = {Foo}\n"
+"5: targets = {f}, decl\n"
+"6: targets = {f}\n"
+"7: targets = {Foo}\n"},
// cxx constructor initializer.
{R"cpp(
  class Base {};
Index: clang-tools-extra/clangd/FindTarget.cpp
===
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -614,6 +614,10 @@
 }
 
 void VisitMemberExpr(const MemberExpr *E) {
+  // Skip destructor calls to avoid duplication: TypeLoc within will be
+  // visited separately.
+  if (llvm::dyn_cast(E->getFoundDecl().getDecl()))
+return;
   Refs.push_back(ReferenceLoc{E->getQualifierLoc(),
   E->getMemberNameInfo().getLoc(),
   /*IsDecl=*/false,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] 38bdb94 - [clangd] Fix rename for explicit destructor calls

2020-01-20 Thread Kirill Bobyrev via cfe-commits

Author: Kirill Bobyrev
Date: 2020-01-21T05:33:39+01:00
New Revision: 38bdb94120b76f8f79cd27d721892673e573895a

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

LOG: [clangd] Fix rename for explicit destructor calls

When triggering rename of the class name in the code with explicit destructor
calls, rename fails. Consider the following piece of code:

```
class Foo;

...

Foo f;
f.~/*...*/Foo();
```

`findExplicitReferences` will report two `ReferenceLoc` for destructor call:
one is comming from `MemberExpr` (i.e. destructor call itself) and would point
to the tilde:

```
f.~/*...*/Foo();
  ^
```

And the second one is pointing to the typename and is coming from `TypeLoc`.

```
f.~/*...*/Foo();
  ^
```

This causes rename to produce incorrect textual replacements. This patch
updates `MemberExpr` handler to detect destructor calls and prevents it
from reporting a duplicate reference.

Resolves: https://github.com/clangd/clangd/issues/236

Reviewers: kadircet, hokein

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

Added: 


Modified: 
clang-tools-extra/clangd/FindTarget.cpp
clang-tools-extra/clangd/unittests/FindTargetTests.cpp
clang-tools-extra/clangd/unittests/RenameTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/FindTarget.cpp 
b/clang-tools-extra/clangd/FindTarget.cpp
index 2bab9d4f67b7..0e3c30e16dd5 100644
--- a/clang-tools-extra/clangd/FindTarget.cpp
+++ b/clang-tools-extra/clangd/FindTarget.cpp
@@ -614,6 +614,10 @@ llvm::SmallVector refInExpr(const Expr 
*E) {
 }
 
 void VisitMemberExpr(const MemberExpr *E) {
+  // Skip destructor calls to avoid duplication: TypeLoc within will be
+  // visited separately.
+  if (llvm::dyn_cast(E->getFoundDecl().getDecl()))
+return;
   Refs.push_back(ReferenceLoc{E->getQualifierLoc(),
   E->getMemberNameInfo().getLoc(),
   /*IsDecl=*/false,

diff  --git a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp 
b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
index 408ebe24e773..a420348fcda8 100644
--- a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -879,6 +879,56 @@ TEST_F(FindExplicitReferencesTest, All) {
 "8: targets = {INT2}, decl\n"
 "9: targets = {NS}, decl\n"
 "10: targets = {ns}\n"},
+   // User-defined conversion operator.
+   {R"cpp(
+void foo() {
+   class $0^Bar {};
+   class $1^Foo {
+   public:
+ // FIXME: This should have only one reference to Bar.
+ $2^operator $3^$4^Bar();
+   };
+
+   $5^Foo $6^f;
+   $7^f.$8^operator $9^Bar();
+}
+)cpp",
+"0: targets = {Bar}, decl\n"
+"1: targets = {Foo}, decl\n"
+"2: targets = {foo()::Foo::operator Bar}, decl\n"
+"3: targets = {Bar}\n"
+"4: targets = {Bar}\n"
+"5: targets = {Foo}\n"
+"6: targets = {f}, decl\n"
+"7: targets = {f}\n"
+"8: targets = {foo()::Foo::operator Bar}\n"
+"9: targets = {Bar}\n"},
+   // Destructor.
+   {R"cpp(
+ void foo() {
+   class $0^Foo {
+   public:
+ ~$1^Foo() {}
+
+ void $2^destructMe() {
+   this->~$3^Foo();
+ }
+   };
+
+   $4^Foo $5^f;
+   $6^f.~ /*...*/ $7^Foo();
+ }
+   )cpp",
+"0: targets = {Foo}, decl\n"
+// FIXME: It's better to target destructor's FunctionDecl instead of
+// the type itself (similar to constructor).
+"1: targets = {Foo}\n"
+"2: targets = {foo()::Foo::destructMe}, decl\n"
+"3: targets = {Foo}\n"
+"4: targets = {Foo}\n"
+"5: targets = {f}, decl\n"
+"6: targets = {f}\n"
+"7: targets = {Foo}\n"},
// cxx constructor initializer.
{R"cpp(
  class Base {};

diff  --git a/clang-tools-extra/clangd/unittests/RenameTests.cpp 
b/clang-tools-extra/clangd/unittests/RenameTests.cpp
index 80930b9096d4..d0fc4d1033b5 100644
--- a/clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ b/clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -265,6 +265,33 @@ TEST(RenameTest, WithinFileRename) {
 }
   )cpp",
 
+  // Destructor explicit call.
+  R"cpp(
+class [[F^oo]] {
+public:
+  ~[[^Foo]]();
+};
+
+[[Foo^]]::~[[^Foo]]() {}
+
+int main() {
+  [[Fo^o]] f;
+  f.~/*something*/[[^Foo]]();
+  f.~[[^Foo]]();
+}
+  )cpp",
+
+  

[PATCH] D72829: Implement -fsemantic-interposition

2020-01-20 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: llvm/lib/IR/Globals.cpp:101
+return true;
+  return isInterposableLinkage(getLinkage());
+}

MaskRay wrote:
> Checking `isInterposableLinkage(getLinkage())` first may be more efficient.
`if (!isInterposableLinkage(getLinkage())) return false;`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72829



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


[PATCH] D72829: Implement -fsemantic-interposition

2020-01-20 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

The logic looks good to me.

Linkages which were not interposable before and can be interposable now: 
available_externally, linkonce_odr, weak_odr, external, and appending.

`isDefinitionExact` returned true for external before, and can return false if 
SemanticInterposition is set.




Comment at: clang/include/clang/Driver/Options.td:3266
+def fsemantic_interposition : Flag<["-"], "fsemantic-interposition">, 
Group, Flags<[CC1Option]>;
+def fno_semantic_interposition: Flag<["-"], "fno-semantic-interposition">, 
Group, Flags<[CC1Option]>;
 defm non_call_exceptions : BooleanFFlag<"non-call-exceptions">, 
Group;

fno_semantic_interposition does not need to have the CC1Option flag.

In clangDriver you'll need to do:
```lang=cpp
  if (Args.hasFlag(options::OPT_fsemantic_interposition, 
options::OPT_fno_semantic_interposition, false))
```



Comment at: llvm/include/llvm/IR/GlobalValue.h:287
 
+  bool isDSOPreemptable() const { return !IsDSOLocal; }
+

It seems that this utility is not very necessary.



Comment at: llvm/lib/Analysis/InlineCost.cpp:1845
 } else if (GlobalAlias *GA = dyn_cast(V)) {
-  if (GA->isInterposable())
+  if (GA->isInterposable() || GA->isDSOPreemptable())
 break;

Why this change?



Comment at: llvm/lib/IR/Globals.cpp:101
+return true;
+  return isInterposableLinkage(getLinkage());
+}

Checking `isInterposableLinkage(getLinkage())` first may be more efficient.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72829



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


[PATCH] D73052: [clang-tidy] RenamerClangTidy now renames dependent member expr when the member can be resolved

2020-01-20 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon times-circle color=red} Unit tests: fail. 62040 tests passed, 1 failed 
and 783 were skipped.

  failed: Clang 
Tools.clang-tidy/checkers/readability-identifier-naming-member-decl-usage.cpp

{icon question-circle color=gray} clang-tidy: unknown.

{icon times-circle color=red} clang-format: fail. Please format your changes 
with clang-format by running `git-clang-format HEAD^` or applying this patch 
.

Build artifacts 
: 
diff.json 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73052



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


[PATCH] D73052: [clang-tidy] RenamerClangTidy now renames dependent member expr when the member can be resolved

2020-01-20 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 239218.
njames93 added a comment.

- rebase master figure out the llvm pre-merge lint test fail


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73052

Files:
  clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-member-decl-usage.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-member-decl-usage.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-member-decl-usage.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-member-decl-usage.cpp
@@ -1,7 +1,8 @@
 // RUN: %check_clang_tidy %s readability-identifier-naming %t -- \
 // RUN:   -config='{CheckOptions: [ \
 // RUN: {key: readability-identifier-naming.MemberCase, value: CamelCase}, \
-// RUN: {key: readability-identifier-naming.ParameterCase, value: CamelCase} \
+// RUN: {key: readability-identifier-naming.ParameterCase, value: CamelCase}, \
+// RUN: {key: readability-identifier-naming.MethodCase, value: camelBack} \
 // RUN:  ]}' -- -fno-delayed-template-parsing
 
 int set_up(int);
@@ -76,19 +77,19 @@
 
 // for this example we aren't bothered about how std::vector is treated
 template  //NOLINT
-class vector { //NOLINT
+class vector {//NOLINT
 public:
   void push_back(bool); //NOLINT
-  void pop_back(); //NOLINT
-}; //NOLINT
-}; // namespace std
+  void pop_back();  //NOLINT
+};  //NOLINT
+};  // namespace std
 
-class Foo { 
+class Foo {
   std::vector 
   // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: invalid case style for member 'stack' [readability-identifier-naming]
 public:
   Foo(std::vector )
-  // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: invalid case style for parameter 'stack' [readability-identifier-naming]
+  // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: invalid case style for parameter 'stack' [readability-identifier-naming]
   // CHECK-FIXES: {{^}}  Foo(std::vector )
   : stack(stack) {
 // CHECK-FIXES: {{^}}  : Stack(Stack) {
@@ -134,4 +135,94 @@
 void foo() {
   Container container;
 }
-}; // namespace CtorInits
+} // namespace CtorInits
+
+namespace resolved_dependance {
+template 
+struct A0 {
+  int value;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for member 'value'
+  A0 =(const A0 ) {
+value = Other.value;   // A0
+this->value = Other.value; // A0
+// CHECK-FIXES:  {{^}}Value = Other.Value;   // A0
+// CHECK-FIXES-NEXT: {{^}}this->Value = Other.Value; // A0
+return *this;
+  }
+  void outOfLineReset();
+};
+
+template 
+void A0::outOfLineReset() {
+  this->value -= value; // A0
+  // CHECK-FIXES: {{^}}  this->Value -= Value; // A0
+}
+
+template 
+struct A1 {
+  int value; // A1
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for member 'value'
+  // CHECK-FIXES: {{^}}  int Value; // A1
+  int GetValue() const { return value; } // A1
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for method 'GetValue'
+  // CHECK-FIXES {{^}}  int getValue() const { return Value; } // A1
+  void SetValue(int Value) { this->value = Value; } // A1
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for method 'SetValue'
+  // CHECK-FIXES {{^}}  void setValue(int Value) { this->Value = Value; } // A1
+  A1 =(const A1 ) {
+this->SetValue(Other.GetValue()); // A1
+this->value = Other.value;// A1
+// CHECK-FIXES:  {{^}}this->setValue(Other.getValue()); // A1
+// CHECK-FIXES-NEXT: {{^}}this->Value = Other.Value;// A1
+return *this;
+  }
+  void outOfLineReset();
+};
+
+template 
+void A1::outOfLineReset() {
+  this->value -= value; // A1
+  // CHECK-FIXES: {{^}}  this->Value -= Value; // A1
+}
+
+template 
+struct A2 {
+  int value; // A2
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for member 'value'
+  // CHECK-FIXES: {{^}}  int Value; // A2
+  A2 =(const A2 ) {
+value = Other.value;   // A2
+this->value = Other.value; // A2
+// CHECK-FIXES:  {{^}}Value = Other.Value;   // A2
+// CHECK-FIXES-NEXT: {{^}}this->Value = Other.Value; // A2
+return *this;
+  }
+};
+
+//create some instances to check it works
+A1 AInt{};
+A1 BInt = (AInt.outOfLineReset(), AInt);
+A1 AUnsigned{};
+A1 BUnsigned = AUnsigned;
+} //namespace resolved_dependance
+
+namespace unresolved_dependance {
+template 
+struct DependentBase {
+  int depValue;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for member 'depValue'
+};
+
+template 
+struct Derived : DependentBase {
+  Derived =(const Derived ) {
+this->depValue = Other.depValue;
+// 

[PATCH] D73052: [clang-tidy] RenamerClangTidy now renames dependent member expr when the member can be resolved

2020-01-20 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon times-circle color=red} Unit tests: fail. 62026 tests passed, 1 failed 
and 783 were skipped.

  failed: Clang 
Tools.clang-tidy/checkers/readability-identifier-naming-member-decl-usage.cpp

{icon question-circle color=gray} clang-tidy: unknown.

{icon times-circle color=red} clang-format: fail. Please format your changes 
with clang-format by running `git-clang-format HEAD^` or applying this patch 
.

Build artifacts 
: 
diff.json 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73052



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


[PATCH] D73072: [Driver][CodeGen] Support -fpatchable-function-entry=N,M where M>0

2020-01-20 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon times-circle color=red} Unit tests: fail. 62040 tests passed, 2 failed 
and 783 were skipped.

  failed: Clang.CodeGen/patchable-function-entry.c
  failed: Clang.Driver/fpatchable-function-entry.c

{icon question-circle color=gray} clang-tidy: unknown.

{icon times-circle color=red} clang-format: fail. Please format your changes 
with clang-format by running `git-clang-format HEAD^` or applying this patch 
.

Build artifacts 
: 
diff.json 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73072



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


[PATCH] D71913: [LTO/WPD] Enable aggressive WPD under LTO option

2020-01-20 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson updated this revision to Diff 239214.
tejohnson marked 2 inline comments as done.
tejohnson added a comment.

Address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71913

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/CodeGen/CGClass.cpp
  clang/test/CodeGen/thinlto-distributed-cfi-devirt.ll
  clang/test/CodeGenCXX/lto-visibility-inference.cpp
  clang/test/CodeGenCXX/thinlto-distributed-type-metadata.cpp
  clang/test/CodeGenCXX/type-metadata.cpp
  lld/ELF/Config.h
  lld/ELF/Driver.cpp
  lld/ELF/LTO.cpp
  lld/ELF/Options.td
  lld/test/ELF/lto/devirt_vcall_vis_public.ll
  llvm/include/llvm/LTO/Config.h
  llvm/include/llvm/Transforms/IPO.h
  llvm/include/llvm/Transforms/IPO/LowerTypeTests.h
  llvm/include/llvm/Transforms/IPO/WholeProgramDevirt.h
  llvm/lib/LTO/LTO.cpp
  llvm/lib/LTO/LTOCodeGenerator.cpp
  llvm/lib/LTO/ThinLTOCodeGenerator.cpp
  llvm/lib/Transforms/IPO/LowerTypeTests.cpp
  llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
  llvm/test/ThinLTO/X86/cache-typeid-resolutions.ll
  llvm/test/ThinLTO/X86/cfi-devirt.ll
  llvm/test/ThinLTO/X86/devirt-after-icp.ll
  llvm/test/ThinLTO/X86/devirt.ll
  llvm/test/ThinLTO/X86/devirt2.ll
  llvm/test/ThinLTO/X86/devirt_alias.ll
  llvm/test/ThinLTO/X86/devirt_available_externally.ll
  llvm/test/ThinLTO/X86/devirt_external_comdat_same_guid.ll
  llvm/test/ThinLTO/X86/devirt_promote.ll
  llvm/test/ThinLTO/X86/devirt_promote_legacy.ll
  llvm/test/ThinLTO/X86/devirt_single_hybrid.ll
  llvm/test/ThinLTO/X86/devirt_vcall_vis_hidden.ll
  llvm/test/ThinLTO/X86/devirt_vcall_vis_public.ll
  llvm/test/Transforms/WholeProgramDevirt/bad-read-from-vtable.ll
  llvm/test/Transforms/WholeProgramDevirt/branch-funnel-threshold.ll
  llvm/test/Transforms/WholeProgramDevirt/branch-funnel.ll
  llvm/test/Transforms/WholeProgramDevirt/constant-arg.ll
  llvm/test/Transforms/WholeProgramDevirt/devirt-single-impl-check.ll
  llvm/test/Transforms/WholeProgramDevirt/devirt-single-impl.ll
  llvm/test/Transforms/WholeProgramDevirt/expand-check.ll
  llvm/test/Transforms/WholeProgramDevirt/export-nothing.ll
  llvm/test/Transforms/WholeProgramDevirt/export-single-impl.ll
  llvm/test/Transforms/WholeProgramDevirt/export-uniform-ret-val.ll
  llvm/test/Transforms/WholeProgramDevirt/export-unique-ret-val.ll
  llvm/test/Transforms/WholeProgramDevirt/export-unsuccessful-checked.ll
  llvm/test/Transforms/WholeProgramDevirt/export-vcp.ll
  llvm/test/Transforms/WholeProgramDevirt/non-constant-vtable.ll
  llvm/test/Transforms/WholeProgramDevirt/pointer-vtable.ll
  llvm/test/Transforms/WholeProgramDevirt/soa-vtable.ll
  llvm/test/Transforms/WholeProgramDevirt/struct-vtable.ll
  llvm/test/Transforms/WholeProgramDevirt/uniform-retval-invoke.ll
  llvm/test/Transforms/WholeProgramDevirt/uniform-retval.ll
  llvm/test/Transforms/WholeProgramDevirt/unique-retval.ll
  llvm/test/Transforms/WholeProgramDevirt/vcp-accesses-memory.ll
  llvm/test/Transforms/WholeProgramDevirt/vcp-decl.ll
  llvm/test/Transforms/WholeProgramDevirt/vcp-no-this.ll
  llvm/test/Transforms/WholeProgramDevirt/vcp-non-constant-arg.ll
  llvm/test/Transforms/WholeProgramDevirt/vcp-too-wide-ints.ll
  llvm/test/Transforms/WholeProgramDevirt/vcp-type-mismatch.ll
  llvm/test/Transforms/WholeProgramDevirt/vcp-uses-this.ll
  llvm/test/Transforms/WholeProgramDevirt/virtual-const-prop-begin.ll
  llvm/test/Transforms/WholeProgramDevirt/virtual-const-prop-check.ll
  llvm/test/Transforms/WholeProgramDevirt/virtual-const-prop-end.ll
  llvm/test/Transforms/WholeProgramDevirt/vtable-decl.ll
  llvm/test/tools/gold/X86/devirt_vcall_vis_public.ll
  llvm/tools/gold/gold-plugin.cpp
  llvm/tools/opt/opt.cpp

Index: llvm/tools/opt/opt.cpp
===
--- llvm/tools/opt/opt.cpp
+++ llvm/tools/opt/opt.cpp
@@ -54,6 +54,7 @@
 #include "llvm/Transforms/Coroutines.h"
 #include "llvm/Transforms/IPO/AlwaysInliner.h"
 #include "llvm/Transforms/IPO/PassManagerBuilder.h"
+#include "llvm/Transforms/IPO/WholeProgramDevirt.h"
 #include "llvm/Transforms/Utils/Cloning.h"
 #include "llvm/Transforms/Utils/Debugify.h"
 #include 
@@ -625,6 +626,13 @@
 return 1;
   }
 
+  // Enable testing of whole program devirtualization on this module by invoking
+  // the facility for updating public visibility to linkage unit visibility when
+  // specified by an internal option. This is normally done during LTO which is
+  // not performed via opt.
+  updateVCallVisibilityInModule(*M,
+/* WholeProgramVisibilityEnabledInLTO */ false);
+
   // Figure out what stream we are supposed to write to...
   std::unique_ptr Out;
   std::unique_ptr ThinLinkOut;
Index: llvm/tools/gold/gold-plugin.cpp
===
--- llvm/tools/gold/gold-plugin.cpp
+++ llvm/tools/gold/gold-plugin.cpp
@@ -204,6 +204,8 @@
   static std::string dwo_dir;
   /// Statistics output 

[PATCH] D71913: [LTO/WPD] Enable aggressive WPD under LTO option

2020-01-20 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson marked 4 inline comments as done.
tejohnson added inline comments.



Comment at: llvm/test/Transforms/WholeProgramDevirt/import-indir.ll:2
 ; Test that we correctly import an indir resolution for type identifier 
"typeid1".
-; RUN: opt -S -wholeprogramdevirt -wholeprogramdevirt-summary-action=import 
-wholeprogramdevirt-read-summary=%S/Inputs/import-indir.yaml 
-wholeprogramdevirt-write-summary=%t < %s | FileCheck %s
+; RUN: opt -S -wholeprogramdevirt -whole-program-visibility 
-wholeprogramdevirt-summary-action=import 
-wholeprogramdevirt-read-summary=%S/Inputs/import-indir.yaml 
-wholeprogramdevirt-write-summary=%t < %s | FileCheck %s
 ; RUN: FileCheck --check-prefix=SUMMARY %s < %t

evgeny777 wrote:
> tejohnson wrote:
> > evgeny777 wrote:
> > > Why do you need `-whole-program-visibility` here? Correct me if I'm 
> > > wrong, but AFAIK module scanning doesn't happen during import and GV 
> > > visibility should be taken from imported summary.
> > Before my patch, type tests were only inserted for vtables with hidden LTO 
> > visibility. Therefore, the very presence of type tests communicated the 
> > hidden visibility and enabled the WPD.
> > 
> > With this patch, to support enabling WPD aggressively at LTO time, we now 
> > insert type tests unconditionally under -fwhole-program-vtables. The 
> > vcall_visibility metadata tells LTO how to interpret them. And the new 
> > options allow changing those to hidden visibility to get the more 
> > aggressive WPD.
> > 
> > Because these legacy tests have type tests but no vcall_visibility 
> > metadata, we now will conservatively treat them as having public LTO 
> > visibility. This option is therefore required to convert the summarized 
> > (default public) vcall visibility into hidden to get the prior more 
> > aggressive behavior they are trying to test.
> > 
> > Note I could have instead changed the assembly here to add hidden 
> > vcall_visibility metadata everywhere. That seemed a little onerous so 
> > that's why I just added the option. I could add a comment to that effect if 
> > it would help?
> I think you can remove this option from this test (and probably others using 
> -wholeprogramdevirt-summary-action=import option), because visibility seems 
> to be not analyzed on import phase. I just did this btw and test still passes 
> flawlessly.
Good point, removed from here and a couple other similar tests. I added it a 
little overeagerly to address the failures I got originally.



Comment at: llvm/tools/opt/opt.cpp:634
+  // not performed via opt.
+  updateVCallVisibilityInModule(*M,
+/* WholeProgramVisibilityEnabledInLTO */ 
false);

evgeny777 wrote:
> tejohnson wrote:
> > evgeny777 wrote:
> > > Hm, looks like I don't fully understand this. I have following concerns:
> > > 
> > > 1) According to your changes every time I use `opt -wholeprogramdevirt` I 
> > > also have to pass `-whole-program-visibility`. Has `-wholeprogramdevirt` 
> > > flag become no-op without this additional flag? If so this looks counter 
> > > intuitive to me.
> > > 
> > > 2) When I use `opt -wholeprogramdevirt` default constructor of 
> > > `WholeProgramDevirt` class is called and `UseCommandLine` flag is set to 
> > > true. Can't I use this flag to effectively lower visibility in module 
> > > instead of playing with metadata?
> > > 
> > > ```
> > > if (VS->vCallVisibility() == GlobalObject::VCallVisibilityPublic && 
> > > !UseCommandLine)
> > >  return false;
> > > ```
> > > 
> > > According to your changes every time I use opt -wholeprogramdevirt I also 
> > > have to pass -whole-program-visibility. Has -wholeprogramdevirt flag 
> > > become no-op without this additional flag? If so this looks counter 
> > > intuitive to me.
> > 
> > No, it wouldn't be needed if the tests contained !vcall_visibility metadata 
> > indicating hidden LTO visibility (see my earlier comment response).
> > 
> > > When I use opt -wholeprogramdevirt default constructor of 
> > > WholeProgramDevirt class is called and UseCommandLine flag is set to 
> > > true. Can't I use this flag to effectively lower visibility in module 
> > > instead of playing with metadata?
> > 
> > I could do that. What it would mean though is that we would be unable to 
> > use opt for any future testing of vtables intended to have public vcall 
> > visibility (either through a lack of that metadata, or explicit 
> > vcall_vsibility metadata indicating public). Which might be ok - in fact 
> > all my new testing of this behavior is via llvm-lto2 or the linkers. I 
> > suppose that would obviate this change as well as all the opt based test 
> > changes to pass the flag. Do you think that is better?
> > I could do that. What it would mean though is that we would be unable to 
> > use opt for any future testing of vtables intended to have public vcall 
> > visibility (either through a lack of that metadata, or 

[PATCH] D73052: [clang-tidy] RenamerClangTidy now renames dependent member expr when the member can be resolved

2020-01-20 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon times-circle color=red} Unit tests: fail. 62026 tests passed, 1 failed 
and 783 were skipped.

  failed: Clang 
Tools.clang-tidy/checkers/readability-identifier-naming-member-decl-usage.cpp

{icon question-circle color=gray} clang-tidy: unknown.

{icon times-circle color=red} clang-format: fail. Please format your changes 
with clang-format by running `git-clang-format HEAD^` or applying this patch 
.

Build artifacts 
: 
diff.json 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73052



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


[PATCH] D67678: PR17164: Change clang's default behavior from -flax-vector-conversions=all to -flax-vector-conversions=integer.

2020-01-20 Thread Mitch Phillips via Phabricator via cfe-commits
hctim added a comment.

This change broke the sanitizer buildbots and was reverted here 
. Please 
see here 
 for 
more information:

  
/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/lib/msan/tests/msan_test.cpp:4232:7:
 error: no matching function for call to '_mm_cmpneq_ps'
c = _mm_cmpneq_ps(V4x32{Poisoned(), 1, 2, 3}, V4x32{4, 5, 
Poisoned(), 6});
^
  
/b/sanitizer-x86_64-linux/build/clang_build/lib/clang/11.0.0/include/xmmintrin.h:719:1:
 note: candidate function not viable: no known conversion from '(anonymous 
namespace)::V4x32' (vector of 4 'U4' values) to '__m128' (vector of 4 'float' 
values) for 1st argument
  _mm_cmpneq_ps(__m128 __a, __m128 __b)
  ^
  
/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/lib/msan/tests/msan_test.cpp:4238:7:
 error: no matching function for call to '_mm_cmpneq_ps'
c = _mm_cmpneq_ps(V4x32{0, 1, 2, 3}, V4x32{4, 5, 6, 7});
^
  
/b/sanitizer-x86_64-linux/build/clang_build/lib/clang/11.0.0/include/xmmintrin.h:719:1:
 note: candidate function not viable: no known conversion from '(anonymous 
namespace)::V4x32' (vector of 4 'U4' values) to '__m128' (vector of 4 'float' 
values) for 1st argument
  _mm_cmpneq_ps(__m128 __a, __m128 __b)
  ^
  
/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/lib/msan/tests/msan_test.cpp:4244:7:
 error: no matching function for call to '_mm_cmpneq_sd'
c = _mm_cmpneq_sd(V2x64{Poisoned(), 1}, V2x64{2, 3});
^
  
/b/sanitizer-x86_64-linux/build/clang_build/lib/clang/11.0.0/include/emmintrin.h:866:1:
 note: candidate function not viable: no known conversion from '(anonymous 
namespace)::V2x64' (vector of 2 'U8' values) to '__m128d' (vector of 2 'double' 
values) for 1st argument
  _mm_cmpneq_sd(__m128d __a, __m128d __b)
  ^
  
/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/lib/msan/tests/msan_test.cpp:4246:7:
 error: no matching function for call to '_mm_cmpneq_sd'
c = _mm_cmpneq_sd(V2x64{1, 2}, V2x64{Poisoned(), 3});
^
  
/b/sanitizer-x86_64-linux/build/clang_build/lib/clang/11.0.0/include/emmintrin.h:866:1:
 note: candidate function not viable: no known conversion from '(anonymous 
namespace)::V2x64' (vector of 2 'U8' values) to '__m128d' (vector of 2 'double' 
values) for 1st argument
  _mm_cmpneq_sd(__m128d __a, __m128d __b)
  ^
  
/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/lib/msan/tests/msan_test.cpp:4248:7:
 error: no matching function for call to '_mm_cmpneq_sd'
c = _mm_cmpneq_sd(V2x64{1, 2}, V2x64{3, 4});
^
  
/b/sanitizer-x86_64-linux/build/clang_build/lib/clang/11.0.0/include/emmintrin.h:866:1:
 note: candidate function not viable: no known conversion from '(anonymous 
namespace)::V2x64' (vector of 2 'U8' values) to '__m128d' (vector of 2 'double' 
values) for 1st argument
  _mm_cmpneq_sd(__m128d __a, __m128d __b)
  ^
  
/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/lib/msan/tests/msan_test.cpp:4250:7:
 error: no matching function for call to '_mm_cmpneq_sd'
c = _mm_cmpneq_sd(V2x64{1, Poisoned()}, V2x64{2, Poisoned()});
^
  
/b/sanitizer-x86_64-linux/build/clang_build/lib/clang/11.0.0/include/emmintrin.h:866:1:
 note: candidate function not viable: no known conversion from '(anonymous 
namespace)::V2x64' (vector of 2 'U8' values) to '__m128d' (vector of 2 'double' 
values) for 1st argument
  _mm_cmpneq_sd(__m128d __a, __m128d __b)
  ^
  
/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/lib/msan/tests/msan_test.cpp:4252:7:
 error: no matching function for call to '_mm_cmpneq_sd'
c = _mm_cmpneq_sd(V2x64{1, Poisoned()}, V2x64{1, Poisoned()});
^
  
/b/sanitizer-x86_64-linux/build/clang_build/lib/clang/11.0.0/include/emmintrin.h:866:1:
 note: candidate function not viable: no known conversion from '(anonymous 
namespace)::V2x64' (vector of 2 'U8' values) to '__m128d' (vector of 2 'double' 
values) for 1st argument
  _mm_cmpneq_sd(__m128d __a, __m128d __b)
  ^
  
/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/lib/msan/tests/msan_test.cpp:4258:32:
 error: cannot initialize a parameter of type '__attribute__((__vector_size__(2 
* sizeof(double double' (vector of 2 'double' values) with an rvalue of 
type '(anonymous namespace)::V2x64' (vector of 2 'U8' values)
c = __builtin_ia32_ucomisdlt(V2x64{Poisoned(), 1}, V2x64{2, 3});
 ^~~~
  
/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/lib/msan/tests/msan_test.cpp:4260:32:
 error: cannot initialize a parameter of type '__attribute__((__vector_size__(2 
* sizeof(double double' (vector of 2 'double' values) with an rvalue of 
type '(anonymous namespace)::V2x64' (vector of 2 'U8' values)
c = __builtin_ia32_ucomisdlt(V2x64{1, 2}, V2x64{Poisoned(), 

[PATCH] D73072: [Driver][CodeGen] Support -fpatchable-function-entry=N,M where M>0

2020-01-20 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay created this revision.
MaskRay added reviewers: aaron.ballman, craig.topper, nickdesaulniers, nsz, 
ostannard, peter.smith.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
MaskRay added a parent revision: D73071: [X86] Support 
-fpatchable-function-entry=N,M where M>0.
MaskRay retitled this revision from "[Driver][CodeGen] Support 
-fpatchable-function-prefix=N,M where M>0" to "[Driver][CodeGen] Support 
-fpatchable-function-entry=N,M where M>0".

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73072

Files:
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Driver/CC1Options.td
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/patchable-function-entry.c
  clang/test/Sema/patchable-function-entry-attr.c

Index: clang/test/Sema/patchable-function-entry-attr.c
===
--- clang/test/Sema/patchable-function-entry-attr.c
+++ clang/test/Sema/patchable-function-entry-attr.c
@@ -13,5 +13,5 @@
 // expected-error@+1 {{'patchable_function_entry' attribute requires parameter 0 to be an integer constant}}
 __attribute__((patchable_function_entry(i))) void f();
 
-// expected-error@+1 {{'patchable_function_entry' attribute requires integer constant between 0 and 0 inclusive}}
-__attribute__((patchable_function_entry(1, 1))) void f();
+// expected-error@+1 {{'patchable_function_entry' attribute requires integer constant between 0 and 2 inclusive}}
+__attribute__((patchable_function_entry(2, 3))) void f();
Index: clang/test/CodeGen/patchable-function-entry.c
===
--- clang/test/CodeGen/patchable-function-entry.c
+++ clang/test/CodeGen/patchable-function-entry.c
@@ -17,10 +17,14 @@
 __attribute__((patchable_function_entry(2, 0))) void f20decl();
 void f20decl() {}
 
-// OPT: define void @f() #2
+// CHECK: define void @f52() #2
+__attribute__((patchable_function_entry(5, 2))) void f52() {}
+
+// OPT: define void @f() #3
 void f() {}
 
 /// M in patchable_function_entry(N,M) is currently ignored.
 // CHECK: attributes #0 = { {{.*}} "patchable-function-entry"="0"
 // CHECK: attributes #1 = { {{.*}} "patchable-function-entry"="2"
-// OPT:   attributes #2 = { {{.*}} "patchable-function-entry"="1"
+// CHECK: attributes #2 = { {{.*}} "patchable-function-entry"="3" "patchable-function-prefix"="2"
+// OPT:   attributes #3 = { {{.*}} "patchable-function-entry"="1"
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -4924,9 +4924,9 @@
 Expr *Arg = AL.getArgAsExpr(1);
 if (!checkUInt32Argument(S, AL, Arg, Offset, 1, true))
   return;
-if (Offset) {
+if (Count < Offset) {
   S.Diag(getAttrLoc(AL), diag::err_attribute_argument_out_of_range)
-  <<  << 0 << 0 << Arg->getBeginLoc();
+  <<  << 0 << Count << Arg->getBeginLoc();
   return;
 }
   }
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -1102,6 +1102,8 @@
 
   Opts.PatchableFunctionEntryCount =
   getLastArgIntValue(Args, OPT_fpatchable_function_entry_EQ, 0, Diags);
+  Opts.PatchableFunctionEntryOffset = getLastArgIntValue(
+  Args, OPT_fpatchable_function_entry_offset_EQ, 0, Diags);
   Opts.InstrumentForProfiling = Args.hasArg(OPT_pg);
   Opts.CallFEntry = Args.hasArg(OPT_mfentry);
   Opts.MNopMCount = Args.hasArg(OPT_mnop_mcount);
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5111,20 +5111,23 @@
 
   if (Arg *A = Args.getLastArg(options::OPT_fpatchable_function_entry_EQ)) {
 StringRef S0 = A->getValue(), S = S0;
-unsigned Size, Start = 0;
+unsigned Size, Offset = 0;
 if (!Triple.isAArch64() && Triple.getArch() != llvm::Triple::x86 &&
 Triple.getArch() != llvm::Triple::x86_64)
   D.Diag(diag::err_drv_unsupported_opt_for_target)
   << A->getAsString(Args) << TripleStr;
 else if (S.consumeInteger(10, Size) ||
  (!S.empty() && (!S.consume_front(",") ||
- S.consumeInteger(10, Start) || !S.empty(
+ S.consumeInteger(10, Offset) || !S.empty(
   D.Diag(diag::err_drv_invalid_argument_to_option)
   << S0 << A->getOption().getName();
-else if (Start)
+else if (Size < Offset)
   

[PATCH] D73052: [clang-tidy] RenamerClangTidy now renames dependent member expr when the member can be resolved

2020-01-20 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 239208.
njames93 added a comment.

- Added some sanity tests that fix weird crashes
- Added support for CXXMethodDecls that are referenced with depended scope 
member expr


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73052

Files:
  clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-member-decl-usage.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-member-decl-usage.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-member-decl-usage.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-member-decl-usage.cpp
@@ -1,7 +1,8 @@
 // RUN: %check_clang_tidy %s readability-identifier-naming %t -- \
 // RUN:   -config='{CheckOptions: [ \
 // RUN: {key: readability-identifier-naming.MemberCase, value: CamelCase}, \
-// RUN: {key: readability-identifier-naming.ParameterCase, value: CamelCase} \
+// RUN: {key: readability-identifier-naming.ParameterCase, value: CamelCase}, \
+// RUN: {key: readability-identifier-naming.MethodCase, value: camelBack} \
 // RUN:  ]}' -- -fno-delayed-template-parsing
 
 int set_up(int);
@@ -76,19 +77,19 @@
 
 // for this example we aren't bothered about how std::vector is treated
 template  //NOLINT
-class vector { //NOLINT
+class vector {//NOLINT
 public:
   void push_back(bool); //NOLINT
-  void pop_back(); //NOLINT
-}; //NOLINT
-}; // namespace std
+  void pop_back();  //NOLINT
+};  //NOLINT
+};  // namespace std
 
-class Foo { 
+class Foo {
   std::vector 
   // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: invalid case style for member 'stack' [readability-identifier-naming]
 public:
   Foo(std::vector )
-  // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: invalid case style for parameter 'stack' [readability-identifier-naming]
+  // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: invalid case style for parameter 'stack' [readability-identifier-naming]
   // CHECK-FIXES: {{^}}  Foo(std::vector )
   : stack(stack) {
 // CHECK-FIXES: {{^}}  : Stack(Stack) {
@@ -134,4 +135,94 @@
 void foo() {
   Container container;
 }
-}; // namespace CtorInits
+} // namespace CtorInits
+
+namespace resolved_dependance {
+template 
+struct A0 {
+  int value;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for member 'value'
+  A0 =(const A0 ) {
+value = Other.value;   // A0
+this->value = Other.value; // A0
+// CHECK-FIXES:  {{^}}Value = Other.Value;   // A0
+// CHECK-FIXES-NEXT: {{^}}this->Value = Other.Value; // A0
+return *this;
+  }
+  void outOfLineReset();
+};
+
+template 
+void A0::outOfLineReset() {
+  this->value -= value; // A0
+  // CHECK-FIXES: {{^}}  this->Value -= Value; // A0
+}
+
+template 
+struct A1 {
+  int value; // A1
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for member 'value'
+  // CHECK-FIXES: {{^}}  int Value; // A1
+  int GetValue() const { return value; } // A1
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for method 'GetValue'
+  // CHECK-FIXES {{^}}  int getValue() const { return Value; } // A1
+  void SetValue(int Value) { this->value = Value; } // A1
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for method 'SetValue'
+  // CHECK-FIXES {{^}}  void setValue(int Value) { this->Value = Value; } // A1
+  A1 =(const A1 ) {
+this->SetValue(Other.GetValue()); // A1
+this->value = Other.value;// A1
+// CHECK-FIXES:  {{^}}this->setValue(Other.getValue()); // A1
+// CHECK-FIXES-NEXT: {{^}}this->Value = Other.Value;// A1
+return *this;
+  }
+  void outOfLineReset();
+};
+
+template 
+void A1::outOfLineReset() {
+  this->value -= value; // A1
+  // CHECK-FIXES: {{^}}  this->Value -= Value; // A1
+}
+
+template 
+struct A2 {
+  int value; // A2
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for member 'value'
+  // CHECK-FIXES: {{^}}  int Value; // A2
+  A2 =(const A2 ) {
+value = Other.value;   // A2
+this->value = Other.value; // A2
+// CHECK-FIXES:  {{^}}Value = Other.Value;   // A2
+// CHECK-FIXES-NEXT: {{^}}this->Value = Other.Value; // A2
+return *this;
+  }
+};
+
+//create some instances to check it works
+A1 AInt{};
+A1 BInt = (AInt.outOfLineReset(), AInt);
+A1 AUnsigned{};
+A1 BUnsigned = AUnsigned;
+} //namespace resolved_dependance
+
+namespace unresolved_dependance {
+template 
+struct DependentBase {
+  int depValue;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for member 'depValue'
+};
+
+template 
+struct Derived : DependentBase {
+  Derived 

[PATCH] D49793: [AArch64] - return address signing

2020-01-20 Thread Mitch Phillips via Phabricator via cfe-commits
hctim added a comment.
Herald added a project: LLVM.

This change broke the sanitizer buildbots. Please see here 

 for more information:

  
/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/lib/msan/tests/msan_test.cpp:4232:7:
 error: no matching function for call to '_mm_cmpneq_ps'
c = _mm_cmpneq_ps(V4x32{Poisoned(), 1, 2, 3}, V4x32{4, 5, 
Poisoned(), 6});
^
  
/b/sanitizer-x86_64-linux/build/clang_build/lib/clang/11.0.0/include/xmmintrin.h:719:1:
 note: candidate function not viable: no known conversion from '(anonymous 
namespace)::V4x32' (vector of 4 'U4' values) to '__m128' (vector of 4 'float' 
values) for 1st argument
  _mm_cmpneq_ps(__m128 __a, __m128 __b)
  ^
  
/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/lib/msan/tests/msan_test.cpp:4238:7:
 error: no matching function for call to '_mm_cmpneq_ps'
c = _mm_cmpneq_ps(V4x32{0, 1, 2, 3}, V4x32{4, 5, 6, 7});
^
  
/b/sanitizer-x86_64-linux/build/clang_build/lib/clang/11.0.0/include/xmmintrin.h:719:1:
 note: candidate function not viable: no known conversion from '(anonymous 
namespace)::V4x32' (vector of 4 'U4' values) to '__m128' (vector of 4 'float' 
values) for 1st argument
  _mm_cmpneq_ps(__m128 __a, __m128 __b)
  ^
  
/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/lib/msan/tests/msan_test.cpp:4244:7:
 error: no matching function for call to '_mm_cmpneq_sd'
c = _mm_cmpneq_sd(V2x64{Poisoned(), 1}, V2x64{2, 3});
^
  
/b/sanitizer-x86_64-linux/build/clang_build/lib/clang/11.0.0/include/emmintrin.h:866:1:
 note: candidate function not viable: no known conversion from '(anonymous 
namespace)::V2x64' (vector of 2 'U8' values) to '__m128d' (vector of 2 'double' 
values) for 1st argument
  _mm_cmpneq_sd(__m128d __a, __m128d __b)
  ^
  
/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/lib/msan/tests/msan_test.cpp:4246:7:
 error: no matching function for call to '_mm_cmpneq_sd'
c = _mm_cmpneq_sd(V2x64{1, 2}, V2x64{Poisoned(), 3});
^
  
/b/sanitizer-x86_64-linux/build/clang_build/lib/clang/11.0.0/include/emmintrin.h:866:1:
 note: candidate function not viable: no known conversion from '(anonymous 
namespace)::V2x64' (vector of 2 'U8' values) to '__m128d' (vector of 2 'double' 
values) for 1st argument
  _mm_cmpneq_sd(__m128d __a, __m128d __b)
  ^
  
/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/lib/msan/tests/msan_test.cpp:4248:7:
 error: no matching function for call to '_mm_cmpneq_sd'
c = _mm_cmpneq_sd(V2x64{1, 2}, V2x64{3, 4});
^
  
/b/sanitizer-x86_64-linux/build/clang_build/lib/clang/11.0.0/include/emmintrin.h:866:1:
 note: candidate function not viable: no known conversion from '(anonymous 
namespace)::V2x64' (vector of 2 'U8' values) to '__m128d' (vector of 2 'double' 
values) for 1st argument
  _mm_cmpneq_sd(__m128d __a, __m128d __b)
  ^
  
/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/lib/msan/tests/msan_test.cpp:4250:7:
 error: no matching function for call to '_mm_cmpneq_sd'
c = _mm_cmpneq_sd(V2x64{1, Poisoned()}, V2x64{2, Poisoned()});
^
  
/b/sanitizer-x86_64-linux/build/clang_build/lib/clang/11.0.0/include/emmintrin.h:866:1:
 note: candidate function not viable: no known conversion from '(anonymous 
namespace)::V2x64' (vector of 2 'U8' values) to '__m128d' (vector of 2 'double' 
values) for 1st argument
  _mm_cmpneq_sd(__m128d __a, __m128d __b)
  ^
  
/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/lib/msan/tests/msan_test.cpp:4252:7:
 error: no matching function for call to '_mm_cmpneq_sd'
c = _mm_cmpneq_sd(V2x64{1, Poisoned()}, V2x64{1, Poisoned()});
^
  
/b/sanitizer-x86_64-linux/build/clang_build/lib/clang/11.0.0/include/emmintrin.h:866:1:
 note: candidate function not viable: no known conversion from '(anonymous 
namespace)::V2x64' (vector of 2 'U8' values) to '__m128d' (vector of 2 'double' 
values) for 1st argument
  _mm_cmpneq_sd(__m128d __a, __m128d __b)
  ^
  
/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/lib/msan/tests/msan_test.cpp:4258:32:
 error: cannot initialize a parameter of type '__attribute__((__vector_size__(2 
* sizeof(double double' (vector of 2 'double' values) with an rvalue of 
type '(anonymous namespace)::V2x64' (vector of 2 'U8' values)
c = __builtin_ia32_ucomisdlt(V2x64{Poisoned(), 1}, V2x64{2, 3});
 ^~~~
  
/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/lib/msan/tests/msan_test.cpp:4260:32:
 error: cannot initialize a parameter of type '__attribute__((__vector_size__(2 
* sizeof(double double' (vector of 2 'double' values) with an rvalue of 
type '(anonymous namespace)::V2x64' (vector of 2 'U8' values)
c = __builtin_ia32_ucomisdlt(V2x64{1, 2}, V2x64{Poisoned(), 3});
 

[clang] edd4398 - Revert "PR17164: Change clang's default behavior from -flax-vector-conversions=all to -flax-vector-conversions=integer."

2020-01-20 Thread Mitch Phillips via cfe-commits

Author: Mitch Phillips
Date: 2020-01-20T16:34:09-08:00
New Revision: edd4398f4cd33a305afbca76ac4e6590e9337f4d

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

LOG: Revert "PR17164: Change clang's default behavior from 
-flax-vector-conversions=all to -flax-vector-conversions=integer."

This patch broke the Sanitizer buildbots. Please see the commit's
differential revision for more information
(https://reviews.llvm.org/D67678).

This reverts commit b72a8c65e4e34779b6bc9e466203f553f5294486.

Added: 


Modified: 
clang/docs/CommandGuide/clang.rst
clang/include/clang/Basic/LangOptions.def
clang/test/Headers/altivec-header.c
clang/test/Headers/arm-neon-header.c
clang/test/Headers/x86-intrinsics-headers.c
clang/test/Headers/x86intrin-2.c
clang/test/Headers/x86intrin.c
clang/test/Sema/vector-assign.c
clang/test/Sema/vector-cast.c
clang/test/Sema/vector-ops.c

Removed: 




diff  --git a/clang/docs/CommandGuide/clang.rst 
b/clang/docs/CommandGuide/clang.rst
index 6947450beb43..7b0873600fc3 100644
--- a/clang/docs/CommandGuide/clang.rst
+++ b/clang/docs/CommandGuide/clang.rst
@@ -278,18 +278,9 @@ Language Selection and Mode Options
  Make all string literals default to writable.  This disables uniquing of
  strings and other optimizations.
 
-.. option:: -flax-vector-conversions, -flax-vector-conversions=, 
-fno-lax-vector-conversions
+.. option:: -flax-vector-conversions
 
  Allow loose type checking rules for implicit vector conversions.
- Possible values of :
-
- - ``none``: allow no implicit conversions between vectors
- - ``integer``: allow implicit bitcasts between integer vectors of the same
-   overall bit-width
- - ``all``: allow implicit bitcasts between any vectors of the same
-   overall bit-width
-
-  defaults to ``integer`` if unspecified.
 
 .. option:: -fblocks
 

diff  --git a/clang/include/clang/Basic/LangOptions.def 
b/clang/include/clang/Basic/LangOptions.def
index 4bbe6ea26fba..068f206f4484 100644
--- a/clang/include/clang/Basic/LangOptions.def
+++ b/clang/include/clang/Basic/LangOptions.def
@@ -121,7 +121,7 @@ BENIGN_LANGOPT(PascalStrings, 1, 0, "Pascal string support")
 LANGOPT(WritableStrings   , 1, 0, "writable string support")
 LANGOPT(ConstStrings  , 1, 0, "const-qualified string support")
 ENUM_LANGOPT(LaxVectorConversions, LaxVectorConversionKind, 2,
- LaxVectorConversionKind::Integer, "lax vector conversions")
+ LaxVectorConversionKind::All, "lax vector conversions")
 LANGOPT(ConvergentFunctions, 1, 1, "Assume convergent functions")
 LANGOPT(AltiVec   , 1, 0, "AltiVec-style vector initializers")
 LANGOPT(ZVector   , 1, 0, "System z vector extensions")

diff  --git a/clang/test/Headers/altivec-header.c 
b/clang/test/Headers/altivec-header.c
index aa85a33d26da..00e5f444de7c 100644
--- a/clang/test/Headers/altivec-header.c
+++ b/clang/test/Headers/altivec-header.c
@@ -1,5 +1,5 @@
+// RUN: %clang_cc1 -triple powerpc64-unknown-unknown -target-feature +altivec 
-ffreestanding -emit-llvm -o - %s | FileCheck %s
 // RUN: %clang_cc1 -triple powerpc64-unknown-unknown -target-feature +altivec 
-ffreestanding -emit-llvm -flax-vector-conversions=none -o - %s | FileCheck %s
-// RUN: %clang_cc1 -triple powerpc64-unknown-unknown -target-feature +altivec 
-ffreestanding -emit-llvm -flax-vector-conversions=all -o - %s | FileCheck %s
 // RUN: %clang_cc1 -triple powerpc64-unknown-unknown -target-feature +altivec 
-ffreestanding -emit-llvm -x c++ -o - %s | FileCheck %s
 
 #include 

diff  --git a/clang/test/Headers/arm-neon-header.c 
b/clang/test/Headers/arm-neon-header.c
index 8626a883fdf3..f6362886010a 100644
--- a/clang/test/Headers/arm-neon-header.c
+++ b/clang/test/Headers/arm-neon-header.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple thumbv7-apple-darwin10 -target-cpu cortex-a8 
-fsyntax-only -flax-vector-conversions=all -Wvector-conversions -ffreestanding 
%s
+// RUN: %clang_cc1 -triple thumbv7-apple-darwin10 -target-cpu cortex-a8 
-fsyntax-only -Wvector-conversions -ffreestanding %s
 // RUN: %clang_cc1 -triple thumbv7-apple-darwin10 -target-cpu cortex-a8 
-fsyntax-only -flax-vector-conversions=none -ffreestanding %s
 // RUN: %clang_cc1 -x c++ -triple thumbv7-apple-darwin10 -target-cpu cortex-a8 
-fsyntax-only -Wvector-conversions -ffreestanding %s
 

diff  --git a/clang/test/Headers/x86-intrinsics-headers.c 
b/clang/test/Headers/x86-intrinsics-headers.c
index 2efd3505bca6..59ca354e1160 100644
--- a/clang/test/Headers/x86-intrinsics-headers.c
+++ b/clang/test/Headers/x86-intrinsics-headers.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -ffreestanding -flax-vector-conversions=all %s
+// RUN: %clang_cc1 -fsyntax-only -ffreestanding %s
 // RUN: %clang_cc1 -fsyntax-only -ffreestanding 

[PATCH] D73052: [clang-tidy] RenamerClangTidy now renames dependent member expr when the member can be resolved

2020-01-20 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

hmmm annoyingly this change causes a crash in a side project I'm creating, 
gotta go bug hunting now


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73052



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


[PATCH] D72638: [clangd] Fix rename for explicit destructor calls

2020-01-20 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon question-circle color=gray} Unit tests: unknown.

{icon question-circle color=gray} clang-tidy: unknown.

{icon check-circle color=green} clang-format: pass.

Build artifacts 
: 
diff.json 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72638



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


[PATCH] D72736: [AIX] Add improved interface for retrieving load module paths

2020-01-20 Thread Jonathan Crowther via Phabricator via cfe-commits
Jonathan.Crowther updated this revision to Diff 239198.
Jonathan.Crowther added a comment.

Addressed comments by moving `getLoadModuleFilnameForFunction` to 
`llvm/lib/Support/SystemUtils.cpp`


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

https://reviews.llvm.org/D72736

Files:
  clang/lib/Tooling/CompilationDatabase.cpp
  clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
  clang/tools/libclang/CIndexer.cpp
  llvm/include/llvm/Support/SystemUtils.h
  llvm/lib/Support/SystemUtils.cpp
  llvm/lib/Support/Unix/Path.inc
  llvm/unittests/Support/ProgramTest.cpp

Index: llvm/unittests/Support/ProgramTest.cpp
===
--- llvm/unittests/Support/ProgramTest.cpp
+++ llvm/unittests/Support/ProgramTest.cpp
@@ -58,6 +58,8 @@
 static cl::opt
 ProgramTestStringArg2("program-test-string-arg2");
 
+void DummyFunction() {}
+
 class ProgramEnvTest : public testing::Test {
   std::vector EnvTable;
   std::vector EnvStorage;
@@ -114,8 +116,8 @@
 exit(0);
 
   // getMainExecutable returns an absolute path; prepend the long-path prefix.
-  std::string MyAbsExe =
-  sys::fs::getMainExecutable(TestMainArgv0, );
+  void *MainAddr = (void *)(intptr_t)DummyFunction;
+  std::string MyAbsExe = sys::fs::getMainExecutable(TestMainArgv0, MainAddr);
   std::string MyExe;
   if (!StringRef(MyAbsExe).startswith("?\\"))
 MyExe.append("?\\");
@@ -160,8 +162,8 @@
 exit(1);
   }
 
-  std::string my_exe =
-  sys::fs::getMainExecutable(TestMainArgv0, );
+  void *MainAddr = (void *)(intptr_t)DummyFunction;
+  std::string my_exe = sys::fs::getMainExecutable(TestMainArgv0, MainAddr);
   StringRef argv[] = {
   my_exe,
   "--gtest_filter=ProgramEnvTest.CreateProcessTrailingSlash",
@@ -197,8 +199,8 @@
 exit(0);
   }
 
-  std::string Executable =
-  sys::fs::getMainExecutable(TestMainArgv0, );
+  void *MainAddr = (void *)(intptr_t)DummyFunction;
+  std::string Executable = sys::fs::getMainExecutable(TestMainArgv0, MainAddr);
   StringRef argv[] = {Executable,
   "--gtest_filter=ProgramEnvTest.TestExecuteNoWait"};
 
@@ -252,8 +254,8 @@
 exit(0);
   }
 
-  std::string Executable =
-  sys::fs::getMainExecutable(TestMainArgv0, );
+  void *MainAddr = (void *)(intptr_t)DummyFunction;
+  std::string Executable = sys::fs::getMainExecutable(TestMainArgv0, MainAddr);
   StringRef argv[] = {
   Executable, "--gtest_filter=ProgramEnvTest.TestExecuteAndWaitTimeout"};
 
Index: llvm/lib/Support/Unix/Path.inc
===
--- llvm/lib/Support/Unix/Path.inc
+++ llvm/lib/Support/Unix/Path.inc
@@ -87,6 +87,7 @@
 #include 
 #elif defined(_AIX)
 #include 
+#include 
 
 //  depends on `uint` to be a typedef from  to
 // `uint_t`; however,  does not always declare `uint`. We provide
@@ -222,7 +223,7 @@
   if (getprogpath(exe_path, argv0) != NULL)
 return exe_path;
 #elif defined(__NetBSD__) || defined(__OpenBSD__) || defined(__minix) ||   \
-defined(__DragonFly__) || defined(__FreeBSD_kernel__) || defined(_AIX)
+defined(__DragonFly__) || defined(__FreeBSD_kernel__)
   const char *curproc = "/proc/curproc/file";
   char exe_path[PATH_MAX];
   if (sys::fs::exists(curproc)) {
@@ -238,6 +239,8 @@
   // If we don't have procfs mounted, fall back to argv[0]
   if (getprogpath(exe_path, argv0) != NULL)
 return exe_path;
+#elif defined(_AIX)
+  return getLoadModuleFilenameForFunction(MainAddr)->c_str();
 #elif defined(__linux__) || defined(__CYGWIN__) || defined(__gnu_hurd__)
   char exe_path[MAXPATHLEN];
   const char *aPath = "/proc/self/exe";
Index: llvm/lib/Support/SystemUtils.cpp
===
--- llvm/lib/Support/SystemUtils.cpp
+++ llvm/lib/Support/SystemUtils.cpp
@@ -13,6 +13,17 @@
 
 #include "llvm/Support/SystemUtils.h"
 #include "llvm/Support/raw_ostream.h"
+
+// These typedefs are needed for sys/ldr.h to work on AIX
+#if defined(_AIX)
+typedef unsigned int uint;
+typedef unsigned short ushort;
+typedef void *__ptr64;
+static_assert(sizeof(__ptr64) == 8u, "__ptr64 size error.");
+#include 
+#include 
+#endif
+
 using namespace llvm;
 
 bool llvm::CheckBitcodeOutputToConsole(raw_ostream _to_check,
@@ -28,3 +39,66 @@
   }
   return false;
 }
+
+#if defined(_AIX)
+// Returns the name of the load module that contains the entry point of the
+// function referenced by fp.
+static SmallString<128> getLoadModuleFilenameForFunctionAIX(void (*fp)(void)) {
+  int PrevErrno = errno;
+
+  size_t BufSize = 2048u;
+  std::unique_ptr Buf;
+  while (true) {
+Buf = std::make_unique(BufSize);
+errno = 0;
+int Ret = loadquery(L_GETXINFO, Buf.get(), (unsigned int)BufSize);
+if (Ret != -1)
+  break; // loadquery() was successful.
+if (errno != ENOMEM)
+  llvm_unreachable("Encountered an unexpected loadquery() failure");
+
+// errno == ENOMEM; try to allocate more memory.
+ 

[PATCH] D71566: New checks for fortified sprintf

2020-01-20 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon check-circle color=green} Unit tests: pass. 62028 tests passed, 0 failed 
and 783 were skipped.

{icon question-circle color=gray} clang-tidy: unknown.

{icon times-circle color=red} clang-format: fail. Please format your changes 
with clang-format by running `git-clang-format HEAD^` or applying this patch 
.

Build artifacts 
: 
diff.json 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71566



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


[PATCH] D69978: Separately track input and output denormal mode

2020-01-20 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm updated this revision to Diff 239196.
arsenm added a comment.
Herald added a subscriber: kerbowa.

Rebase


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

https://reviews.llvm.org/D69978

Files:
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Driver/ToolChain.h
  clang/lib/Basic/Targets/AMDGPU.cpp
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Driver/ToolChains/AMDGPU.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/Cuda.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/denormalfpmode.c
  clang/test/CodeGenCUDA/flush-denormals.cu
  clang/test/CodeGenCUDA/propagate-metadata.cu
  clang/test/Driver/cl-denorms-are-zero.cl
  clang/test/Driver/cuda-flush-denormals-to-zero.cu
  clang/test/Driver/denormal-fp-math.c
  llvm/docs/LangRef.rst
  llvm/include/llvm/ADT/FloatingPointMode.h
  llvm/lib/CodeGen/MachineFunction.cpp
  llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
  llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp
  llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
  llvm/unittests/ADT/FloatingPointMode.cpp

Index: llvm/unittests/ADT/FloatingPointMode.cpp
===
--- llvm/unittests/ADT/FloatingPointMode.cpp
+++ llvm/unittests/ADT/FloatingPointMode.cpp
@@ -13,21 +13,122 @@
 
 namespace {
 
-TEST(FloatingPointModeTest, ParseDenormalFPAttribute) {
-  EXPECT_EQ(DenormalMode::IEEE, parseDenormalFPAttribute("ieee"));
-  EXPECT_EQ(DenormalMode::IEEE, parseDenormalFPAttribute(""));
+TEST(FloatingPointModeTest, ParseDenormalFPAttributeComponent) {
+  EXPECT_EQ(DenormalMode::IEEE, parseDenormalFPAttributeComponent("ieee"));
+  EXPECT_EQ(DenormalMode::IEEE, parseDenormalFPAttributeComponent(""));
   EXPECT_EQ(DenormalMode::PreserveSign,
-parseDenormalFPAttribute("preserve-sign"));
+parseDenormalFPAttributeComponent("preserve-sign"));
   EXPECT_EQ(DenormalMode::PositiveZero,
-parseDenormalFPAttribute("positive-zero"));
-  EXPECT_EQ(DenormalMode::Invalid, parseDenormalFPAttribute("foo"));
+parseDenormalFPAttributeComponent("positive-zero"));
+  EXPECT_EQ(DenormalMode::Invalid, parseDenormalFPAttributeComponent("foo"));
 }
 
 TEST(FloatingPointModeTest, DenormalAttributeName) {
-  EXPECT_EQ("ieee", denormalModeName(DenormalMode::IEEE));
-  EXPECT_EQ("preserve-sign", denormalModeName(DenormalMode::PreserveSign));
-  EXPECT_EQ("positive-zero", denormalModeName(DenormalMode::PositiveZero));
-  EXPECT_EQ("", denormalModeName(DenormalMode::Invalid));
+  EXPECT_EQ("ieee", denormalModeKindName(DenormalMode::IEEE));
+  EXPECT_EQ("preserve-sign", denormalModeKindName(DenormalMode::PreserveSign));
+  EXPECT_EQ("positive-zero", denormalModeKindName(DenormalMode::PositiveZero));
+  EXPECT_EQ("", denormalModeKindName(DenormalMode::Invalid));
+}
+
+TEST(FloatingPointModeTest, ParseDenormalFPAttribute) {
+  EXPECT_EQ(DenormalMode(DenormalMode::IEEE, DenormalMode::IEEE),
+parseDenormalFPAttribute("ieee"));
+  EXPECT_EQ(DenormalMode(DenormalMode::IEEE, DenormalMode::IEEE),
+parseDenormalFPAttribute("ieee,ieee"));
+  EXPECT_EQ(DenormalMode(DenormalMode::IEEE, DenormalMode::IEEE),
+parseDenormalFPAttribute("ieee,"));
+  EXPECT_EQ(DenormalMode(DenormalMode::IEEE, DenormalMode::IEEE),
+parseDenormalFPAttribute(""));
+  EXPECT_EQ(DenormalMode(DenormalMode::IEEE, DenormalMode::IEEE),
+parseDenormalFPAttribute(","));
+
+  EXPECT_EQ(DenormalMode(DenormalMode::PreserveSign, DenormalMode::PreserveSign),
+parseDenormalFPAttribute("preserve-sign"));
+  EXPECT_EQ(DenormalMode(DenormalMode::PreserveSign, DenormalMode::PreserveSign),
+parseDenormalFPAttribute("preserve-sign,"));
+  EXPECT_EQ(DenormalMode(DenormalMode::PreserveSign, DenormalMode::PreserveSign),
+parseDenormalFPAttribute("preserve-sign,preserve-sign"));
+
+  EXPECT_EQ(DenormalMode(DenormalMode::PositiveZero, DenormalMode::PositiveZero),
+parseDenormalFPAttribute("positive-zero"));
+  EXPECT_EQ(DenormalMode(DenormalMode::PositiveZero, DenormalMode::PositiveZero),
+parseDenormalFPAttribute("positive-zero,positive-zero"));
+
+
+  EXPECT_EQ(DenormalMode(DenormalMode::IEEE, DenormalMode::PositiveZero),
+parseDenormalFPAttribute("ieee,positive-zero"));
+  EXPECT_EQ(DenormalMode(DenormalMode::PositiveZero, DenormalMode::IEEE),
+parseDenormalFPAttribute("positive-zero,ieee"));
+
+  EXPECT_EQ(DenormalMode(DenormalMode::PreserveSign, DenormalMode::IEEE),
+parseDenormalFPAttribute("preserve-sign,ieee"));
+  EXPECT_EQ(DenormalMode(DenormalMode::IEEE, DenormalMode::PreserveSign),
+parseDenormalFPAttribute("ieee,preserve-sign"));
+
+
+  EXPECT_EQ(DenormalMode(DenormalMode::Invalid, DenormalMode::Invalid),
+parseDenormalFPAttribute("foo"));
+  EXPECT_EQ(DenormalMode(DenormalMode::Invalid, 

[PATCH] D71566: New checks for fortified sprintf

2020-01-20 Thread serge via Phabricator via cfe-commits
serge-sans-paille updated this revision to Diff 239197.
serge-sans-paille marked an inline comment as done.
serge-sans-paille added a comment.

Finer grain lower bound computations, and simpler control-flow for the checking 
function.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71566

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaChecking.cpp
  clang/test/Sema/warn-fortify-source.c

Index: clang/test/Sema/warn-fortify-source.c
===
--- clang/test/Sema/warn-fortify-source.c
+++ clang/test/Sema/warn-fortify-source.c
@@ -11,6 +11,8 @@
 extern "C" {
 #endif
 
+extern int sprintf(char *str, const char *format, ...);
+
 #if defined(USE_PASS_OBJECT_SIZE)
 void *memcpy(void *dst, const void *src, size_t c);
 static void *memcpy(void *dst __attribute__((pass_object_size(1))), const void *src, size_t c) __attribute__((overloadable)) __asm__("merp");
@@ -96,6 +98,55 @@
   __builtin_vsnprintf(buf, 11, "merp", list); // expected-warning {{'vsnprintf' size argument is too large; destination buffer has size 10, but size argument is 11}}
 }
 
+void call_sprintf_chk(char *buf) {
+  __builtin___sprintf_chk(buf, 1, 6, "hell\0 boy"); // expected-warning {{format string contains '\0' within the string body}}
+  __builtin___sprintf_chk(buf, 1, 2, "hell\0 boy"); // expected-warning {{format string contains '\0' within the string body}}
+  // expected-warning@-1 {{'sprintf' will always overflow; destination buffer has size 2, but format string expands to at least 5}}
+  __builtin___sprintf_chk(buf, 1, 6, "hello");
+  __builtin___sprintf_chk(buf, 1, 5, "hello"); // expected-warning {{'sprintf' will always overflow; destination buffer has size 5, but format string expands to at least 6}}
+  __builtin___sprintf_chk(buf, 1, 2, "%c", '9');
+  __builtin___sprintf_chk(buf, 1, 1, "%c", '9'); // expected-warning {{'sprintf' will always overflow; destination buffer has size 1, but format string expands to at least 2}}
+  __builtin___sprintf_chk(buf, 1, 2, "%d", 9);
+  __builtin___sprintf_chk(buf, 1, 1, "%d", 9); // expected-warning {{'sprintf' will always overflow; destination buffer has size 1, but format string expands to at least 2}}
+  __builtin___sprintf_chk(buf, 1, 2, "%%");
+  __builtin___sprintf_chk(buf, 1, 1, "%%"); // expected-warning {{'sprintf' will always overflow; destination buffer has size 1, but format string expands to at least 2}}
+  __builtin___sprintf_chk(buf, 1, 4, "%#x", 9);
+  __builtin___sprintf_chk(buf, 1, 3, "%#x", 9); // expected-warning {{'sprintf' will always overflow; destination buffer has size 3, but format string expands to at least 4}}
+  __builtin___sprintf_chk(buf, 1, 4, "%p", (void *)9);
+  __builtin___sprintf_chk(buf, 1, 3, "%p", (void *)9); // expected-warning {{'sprintf' will always overflow; destination buffer has size 3, but format string expands to at least 4}}
+  __builtin___sprintf_chk(buf, 1, 3, "%+d", 9);
+  __builtin___sprintf_chk(buf, 1, 2, "%+d", 9); // expected-warning {{'sprintf' will always overflow; destination buffer has size 2, but format string expands to at least 3}}
+  __builtin___sprintf_chk(buf, 1, 6, "%5d", 9);
+  __builtin___sprintf_chk(buf, 1, 5, "%5d", 9); // expected-warning {{'sprintf' will always overflow; destination buffer has size 5, but format string expands to at least 6}}
+  __builtin___sprintf_chk(buf, 1, 9, "%f", 9.f);
+  __builtin___sprintf_chk(buf, 1, 8, "%f", 9.f); // expected-warning {{'sprintf' will always overflow; destination buffer has size 8, but format string expands to at least 9}}
+}
+
+void call_sprintf() {
+  char buf[6];
+  sprintf(buf, "hell\0 boy"); // expected-warning {{format string contains '\0' within the string body}}
+  sprintf(buf, "hello b\0y"); // expected-warning {{format string contains '\0' within the string body}}
+  // expected-warning@-1 {{'sprintf' will always overflow; destination buffer has size 6, but format string expands to at least 8}}
+  sprintf(buf, "hello");
+  sprintf(buf, "hello!"); // expected-warning {{'sprintf' will always overflow; destination buffer has size 6, but format string expands to at least 7}}
+  sprintf(buf, "1234%%");
+  sprintf(buf, "12345%%"); // expected-warning {{'sprintf' will always overflow; destination buffer has size 6, but format string expands to at least 7}}
+  sprintf(buf, "1234%c", '9');
+  sprintf(buf, "12345%c", '9'); // expected-warning {{'sprintf' will always overflow; destination buffer has size 6, but format string expands to at least 7}}
+  sprintf(buf, "1234%d", 9);
+  sprintf(buf, "12345%d", 9); // expected-warning {{'sprintf' will always overflow; destination buffer has size 6, but format string expands to at least 7}}
+  sprintf(buf, "12%#x", 9);
+  sprintf(buf, "123%#x", 9); // expected-warning {{'sprintf' will always overflow; destination buffer has size 6, but format string expands to at least 

[PATCH] D72638: [clangd] Fix rename for explicit destructor calls

2020-01-20 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon question-circle color=gray} Unit tests: unknown.

{icon question-circle color=gray} clang-tidy: unknown.

{icon check-circle color=green} clang-format: pass.

Build artifacts 
: 
diff.json 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72638



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


[PATCH] D28955: [analyzer] Enable support for symbolic extension/truncation

2020-01-20 Thread Mikhail Ramalho via Phabricator via cfe-commits
mikhail.ramalho updated this revision to Diff 239186.
mikhail.ramalho added a comment.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.

Two changes:

- Moved the BoolAssignmentChecker changes to separate revision (D73062 
).
- Rebased on top of master.

There are a few cases failing, some because clang is trying to match some 
strings printed by the ranged constraint manager and there is at least 1 
segfault.


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

https://reviews.llvm.org/D28955

Files:
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConstraintManager.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
  clang/lib/StaticAnalyzer/Core/ProgramState.cpp
  clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
  clang/lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp
  clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
  clang/lib/StaticAnalyzer/Core/Store.cpp
  llvm/include/llvm/Support/SMTAPI.h
  llvm/lib/Support/Z3Solver.cpp

Index: llvm/lib/Support/Z3Solver.cpp
===
--- llvm/lib/Support/Z3Solver.cpp
+++ llvm/lib/Support/Z3Solver.cpp
@@ -872,6 +872,8 @@
 
   bool isFPSupported() override { return true; }
 
+  bool isExtTruncSupported() override { return true; }
+
   /// Reset the solver and remove all constraints.
   void reset() override { Z3_solver_reset(Context.Context, Solver); }
 
Index: llvm/include/llvm/Support/SMTAPI.h
===
--- llvm/include/llvm/Support/SMTAPI.h
+++ llvm/include/llvm/Support/SMTAPI.h
@@ -433,6 +433,9 @@
   /// Checks if the solver supports floating-points.
   virtual bool isFPSupported() = 0;
 
+  /// Checks if the solver supports extension/truncation.
+  virtual bool isExtTruncSupported() = 0;
+
   virtual void print(raw_ostream ) const = 0;
 };
 
Index: clang/lib/StaticAnalyzer/Core/Store.cpp
===
--- clang/lib/StaticAnalyzer/Core/Store.cpp
+++ clang/lib/StaticAnalyzer/Core/Store.cpp
@@ -532,7 +532,9 @@
 elementType, Offset, cast(ElemR->getSuperRegion()), Ctx));
   }
 
-  const llvm::APSInt& OffI = Offset.castAs().getValue();
+  // FIXME: This isn't quite correct, but avoids casting the Offset symbol
+  llvm::APSInt OffI = APSIntType(BaseIdxI).convert(
+  Offset.castAs().getValue());
   assert(BaseIdxI.isSigned());
 
   // Compute the new index.
Index: clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
===
--- clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
+++ clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
@@ -72,6 +72,8 @@
 }
 
 SVal SimpleSValBuilder::evalCastFromNonLoc(NonLoc val, QualType castTy) {
+  ConstraintManager  = getStateManager().getConstraintManager();
+
   bool isLocType = Loc::isLocType(castTy);
   if (val.getAs())
 return val;
@@ -79,28 +81,37 @@
   if (Optional LI = val.getAs()) {
 if (isLocType)
   return LI->getLoc();
+
 // FIXME: Correctly support promotions/truncations.
-unsigned castSize = Context.getIntWidth(castTy);
-if (castSize == LI->getNumBits())
+unsigned castSize = Context.getTypeSize(castTy);
+if (!CM.canReasonAboutSymbolicExtTrunc() && castSize == LI->getNumBits())
   return val;
+
 return makeLocAsInteger(LI->getLoc(), castSize);
   }
 
   if (const SymExpr *se = val.getAsSymbolicExpression()) {
 QualType T = Context.getCanonicalType(se->getType());
-// If types are the same or both are integers, ignore the cast.
+// If types are the same, ignore the cast.
+if (haveSameType(T, castTy))
+  return val;
+
+// If types are both integers, ignore the cast.
 // FIXME: Remove this hack when we support symbolic truncation/extension.
 // HACK: If both castTy and T are integers, ignore the cast.  This is
 // not a permanent solution.  Eventually we want to precisely handle
 // extension/truncation of symbolic integers.  This prevents us from losing
 // precision when we assign 'x = y' and 'y' is symbolic and x and y are
 // different integer types.
-   if (haveSameType(T, castTy))
+if (!CM.canReasonAboutSymbolicExtTrunc() &&
+(T->isIntegralOrEnumerationType() &&
+castTy->isIntegralOrEnumerationType()))
   return val;
 
-if (!isLocType)
-  return makeNonLoc(se, T, castTy);
-return UnknownVal();
+if (isLocType)
+  return UnknownVal();
+
+return makeNonLoc(se, T, castTy);
   }
 
   // If value is a non-integer constant, produce unknown.
Index: clang/lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp
+++ 

[PATCH] D72638: [clangd] Fix rename for explicit destructor calls

2020-01-20 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 239182.
kbobyrev marked 2 inline comments as done.
kbobyrev added a comment.

Modify the test to address the comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72638

Files:
  clang-tools-extra/clangd/FindTarget.cpp
  clang-tools-extra/clangd/unittests/FindTargetTests.cpp
  clang-tools-extra/clangd/unittests/RenameTests.cpp

Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -265,6 +265,33 @@
 }
   )cpp",
 
+  // Destructor explicit call.
+  R"cpp(
+class [[F^oo]] {
+public:
+  ~[[^Foo]]();
+};
+
+[[Foo^]]::~[[^Foo]]() {}
+
+int main() {
+  [[Fo^o]] f;
+  f.~/*something*/[[^Foo]]();
+  f.~[[^Foo]]();
+}
+  )cpp",
+
+  // Derived destructor explicit call.
+  R"cpp(
+class [[Bas^e]] {};
+class Derived : public [[Bas^e]] {}
+
+int main() {
+  [[Bas^e]] *foo = new Derived();
+  foo->[[^Base]]::~[[^Base]]();
+}
+  )cpp",
+
   // CXXConstructor initializer list.
   R"cpp(
 class Baz {};
Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -879,6 +879,56 @@
 "8: targets = {INT2}, decl\n"
 "9: targets = {NS}, decl\n"
 "10: targets = {ns}\n"},
+   // User-defined conversion operator.
+   {R"cpp(
+void foo() {
+   class $0^Bar {};
+   class $1^Foo {
+   public:
+ // FIXME: This should have only one reference to Bar.
+ $2^operator $3^$4^Bar();
+   };
+
+   $5^Foo $6^f;
+   $7^f.$8^operator $9^Bar();
+}
+)cpp",
+"0: targets = {Bar}, decl\n"
+"1: targets = {Foo}, decl\n"
+"2: targets = {foo()::Foo::operator Bar}, decl\n"
+"3: targets = {Bar}\n"
+"4: targets = {Bar}\n"
+"5: targets = {Foo}\n"
+"6: targets = {f}, decl\n"
+"7: targets = {f}\n"
+"8: targets = {foo()::Foo::operator Bar}\n"
+"9: targets = {Bar}\n"},
+   // Destructor.
+   {R"cpp(
+ void foo() {
+   class $0^Foo {
+   public:
+ ~$1^Foo() {}
+
+ void $2^destructMe() {
+   this->~$3^Foo();
+ }
+   };
+
+   $4^Foo $5^f;
+   $6^f.~ /*...*/ $7^Foo();
+ }
+   )cpp",
+"0: targets = {Foo}, decl\n"
+// FIXME: It's better to destructor's FunctionDecl instead of the type
+// itself (similar to constructor).
+"1: targets = {Foo}\n"
+"2: targets = {foo()::Foo::destructMe}, decl\n"
+"3: targets = {Foo}\n"
+"4: targets = {Foo}\n"
+"5: targets = {f}, decl\n"
+"6: targets = {f}\n"
+"7: targets = {Foo}\n"},
// cxx constructor initializer.
{R"cpp(
  class Base {};
Index: clang-tools-extra/clangd/FindTarget.cpp
===
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -596,6 +596,10 @@
 }
 
 void VisitMemberExpr(const MemberExpr *E) {
+  // Skip destructor calls to avoid duplication: TypeLoc within will be
+  // visited separately.
+  if (llvm::dyn_cast(E->getFoundDecl().getDecl()))
+return;
   Refs.push_back(ReferenceLoc{E->getQualifierLoc(),
   E->getMemberNameInfo().getLoc(),
   /*IsDecl=*/false,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D73062: [analyzer] Simplify BoolAssignmentChecker

2020-01-20 Thread Mikhail Ramalho via Phabricator via cfe-commits
mikhail.ramalho created this revision.
mikhail.ramalho added a reviewer: NoQ.
Herald added subscribers: cfe-commits, Charusso.
Herald added a project: clang.
mikhail.ramalho retitled this revision from "Simplify BoolAssignmentChecker" to 
"[analyzer] Simplify BoolAssignmentChecker".
Herald added subscribers: dkrupp, donat.nagy, Szelethus, a.sidorin, szepet, 
baloghadamsoftware, xazax.hun.

Instead of checking the range manually, changed the checker to use 
assumeInclusiveRangeDual instead.

This patch was part of D28955 .


Repository:
  rC Clang

https://reviews.llvm.org/D73062

Files:
  clang/lib/StaticAnalyzer/Checkers/BoolAssignmentChecker.cpp
  clang/test/Analysis/bool-assignment.c
  clang/test/Analysis/dead-stores.m
  clang/test/Analysis/misc-ps-eager-assume.m

Index: clang/test/Analysis/misc-ps-eager-assume.m
===
--- clang/test/Analysis/misc-ps-eager-assume.m
+++ clang/test/Analysis/misc-ps-eager-assume.m
@@ -1,5 +1,4 @@
 // RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.core -analyzer-store=region -verify -fblocks %s
-// expected-no-diagnostics
 
 // Delta-reduced header stuff (needed for test cases).
 typedef signed char BOOL;
@@ -56,7 +55,7 @@
 void handle_symbolic_cast_in_condition(void) {
   NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
 
-  BOOL needsAnArray = [@"aString" isEqualToString:@"anotherString"];
+  BOOL needsAnArray = [@"aString" isEqualToString:@"anotherString"]; // expected-warning {{Assignment of a non-Boolean value}}
   NSMutableArray* array = needsAnArray ? [[NSMutableArray alloc] init] : 0;
   if(needsAnArray)
 [array release];
Index: clang/test/Analysis/dead-stores.m
===
--- clang/test/Analysis/dead-stores.m
+++ clang/test/Analysis/dead-stores.m
@@ -54,7 +54,7 @@
 - (void) bar_rbar8527823
 {
  @synchronized(self) {
-   BOOL isExec = baz_rdar8527823(); // no-warning
+   BOOL isExec = baz_rdar8527823(); // expected-warning {{Assignment of a non-Boolean value}}
if (isExec) foo_rdar8527823();
  }
 }
Index: clang/test/Analysis/bool-assignment.c
===
--- clang/test/Analysis/bool-assignment.c
+++ clang/test/Analysis/bool-assignment.c
@@ -43,11 +43,7 @@
 return;
   }
   if (y > 200 && y < 250) {
-#ifdef ANALYZER_CM_Z3
 BOOL x = y; // expected-warning {{Assignment of a non-Boolean value}}
-#else
-BOOL x = y; // no-warning
-#endif
 return;
   }
   if (y >= 127 && y < 150) {
Index: clang/lib/StaticAnalyzer/Checkers/BoolAssignmentChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/BoolAssignmentChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/BoolAssignmentChecker.cpp
@@ -70,8 +70,8 @@
   // Get the value of the right-hand side.  We only care about values
   // that are defined (UnknownVals and UndefinedVals are handled by other
   // checkers).
-  Optional DV = val.getAs();
-  if (!DV)
+  Optional NV = val.getAs();
+  if (!NV)
 return;
 
   // Check if the assigned value meets our criteria for correctness.  It must
@@ -79,78 +79,17 @@
   // the value is possibly < 0 (for a negative value) or greater than 1.
   ProgramStateRef state = C.getState();
   SValBuilder  = C.getSValBuilder();
+  BasicValueFactory  = svalBuilder.getBasicValueFactory();
   ConstraintManager  = C.getConstraintManager();
 
-  // First, ensure that the value is >= 0.
-  DefinedSVal zeroVal = svalBuilder.makeIntVal(0, valTy);
-  SVal greaterThanOrEqualToZeroVal =
-svalBuilder.evalBinOp(state, BO_GE, *DV, zeroVal,
-  svalBuilder.getConditionType());
+  llvm::APSInt Zero = BVF.getValue(0, valTy);
+  llvm::APSInt One = BVF.getValue(1, valTy);
 
-  Optional greaterThanEqualToZero =
-  greaterThanOrEqualToZeroVal.getAs();
+  ProgramStateRef StIn, StOut;
+  std::tie(StIn, StOut) = CM.assumeInclusiveRangeDual(state, *NV, Zero, One);
 
-  if (!greaterThanEqualToZero) {
-// The SValBuilder cannot construct a valid SVal for this condition.
-// This means we cannot properly reason about it.
-return;
-  }
-
-  ProgramStateRef stateLT, stateGE;
-  std::tie(stateGE, stateLT) = CM.assumeDual(state, *greaterThanEqualToZero);
-
-  // Is it possible for the value to be less than zero?
-  if (stateLT) {
-// It is possible for the value to be less than zero.  We only
-// want to emit a warning, however, if that value is fully constrained.
-// If it it possible for the value to be >= 0, then essentially the
-// value is underconstrained and there is nothing left to be done.
-if (!stateGE)
-  emitReport(stateLT, C);
-
-// In either case, we are done.
-return;
-  }
-
-  // If we reach here, it must be the case that the value is constrained
-  // to only be >= 0.
-  assert(stateGE == state);
-
-  // At this point we know that the 

[PATCH] D72638: [clangd] Fix rename for explicit destructor calls

2020-01-20 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev added inline comments.



Comment at: clang-tools-extra/clangd/unittests/FindTargetTests.cpp:905
+   public:
+ ~$1^Foo() {}
+

kadircet wrote:
> this actually looks troublesome, since we are not returning the functiondecl 
> anymore(also for references to it as well), even though it is explicitly 
> spelled in the source code.
> I suppose it is OK to keep that behavior for now, as there are no callers 
> caring about those typednames yet.
> 
> just thinking out loud:
> In case we start to have such clients, it might be more principled to report 
> `$1~$2Foo` in here(I know it is the old behavior :/ )  and handle those 
> differently in the callers' with
> custom needs.
As discussed, I agree with this point and it's kind of unfortunate behaviour 
but we already have that for destructor declaration, too (see above `FIXME`) 
and in several other cases. Might want to fix that in the future though!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72638



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


[PATCH] D73060: [Clang] Fix expansion of response files in -Wp after integrated-cc1 change

2020-01-20 Thread Wenlei He via Phabricator via cfe-commits
wenlei accepted this revision.
wenlei added a comment.
This revision is now accepted and ready to land.

> Is that the desired behavior? This was the previous behavior but I'm not sure 
> it's the right behavior.

Good point. It might be safer to keep that previous behavior though.

Thanks for the quick fix, LGTM!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73060



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


[PATCH] D73020: [Sema] Perform call checking when building CXXNewExpr

2020-01-20 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri updated this revision to Diff 239180.
lebedev.ri added a comment.

Not only do we need to 'insert' size implicit argument,
but we may need to insert alignment implicit argument.
And while for size we can only insert `nullptr`,
for alignment we can actually insert the correct value.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73020

Files:
  clang/lib/AST/ExprConstant.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/SemaCXX/std-align-val-t-in-operator-new.cpp

Index: clang/test/SemaCXX/std-align-val-t-in-operator-new.cpp
===
--- clang/test/SemaCXX/std-align-val-t-in-operator-new.cpp
+++ clang/test/SemaCXX/std-align-val-t-in-operator-new.cpp
@@ -32,7 +32,7 @@
 
 void *ptr_variable(int align) { return new (std::align_val_t(align)) A; }
 void *ptr_align16() { return new (std::align_val_t(16)) A; }
-void *ptr_align15() { return new (std::align_val_t(15)) A; }
+void *ptr_align15() { return new (std::align_val_t(15)) A; } // expected-error {{requested alignment is not a power of 2}}
 
 struct alignas(128) S {
   S() {}
@@ -49,11 +49,9 @@
   return new (std::align_val_t(256)) S;
 }
 void *alloc_overaligned_struct_with_extra_255_alignment(int align) {
-  return new (std::align_val_t(255)) S;
+  return new (std::align_val_t(255)) S; // expected-error {{requested alignment is not a power of 2}}
 }
 
 std::align_val_t align_variable(int align) { return std::align_val_t(align); }
 std::align_val_t align_align16() { return std::align_val_t(16); }
 std::align_val_t align_align15() { return std::align_val_t(15); }
-
-// expected-no-diagnostics
Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -2070,18 +2070,45 @@
 // arguments. Skip the first parameter because we don't have a corresponding
 // argument. Skip the second parameter too if we're passing in the
 // alignment; we've already filled it in.
+unsigned NumImplicitArgs = PassAlignment ? 2 : 1;
 if (GatherArgumentsForCall(PlacementLParen, OperatorNew, Proto,
-   PassAlignment ? 2 : 1, PlacementArgs,
-   AllPlaceArgs, CallType))
+   NumImplicitArgs, PlacementArgs, AllPlaceArgs,
+   CallType))
   return ExprError();
 
 if (!AllPlaceArgs.empty())
   PlacementArgs = AllPlaceArgs;
 
-// FIXME: This is wrong: PlacementArgs misses out the first (size) argument.
-DiagnoseSentinelCalls(OperatorNew, PlacementLParen, PlacementArgs);
+// We would like to perform some checking on the given `operator new` call,
+// but the PlacementArgs does not contain the implicit arguments,
+// namely allocation size and maybe allocation alignment, so we need to
+// conjure them. For size, we can't do anything better than just passing a
+// nullptr, but for alignment we can either also pass a nullptr, or actually
+// materialize the alignment we'll pass into the call.
+llvm::SmallVector CallArgs;
+CallArgs.reserve(NumImplicitArgs + PlacementArgs.size());
+CallArgs.emplace_back(nullptr);
+if (PassAlignment) {
+  // Let's actually synthesize the alignment argument.
+  QualType AlignValT = Context.getTypeDeclType(getStdAlignValT());
+  QualType SizeTy =
+  AlignValT->castAs()->getDecl()->getIntegerType();
+  auto *AlignmentLiteral = IntegerLiteral::Create(
+  Context,
+  llvm::APInt(Context.getTypeSize(SizeTy),
+  Alignment / Context.getCharWidth()),
+  SizeTy, SourceLocation());
+  auto *DesiredAlignmnet = ImplicitCastExpr::Create(
+  Context, AlignValT, CK_IntegralCast, AlignmentLiteral,
+  /*BasePath=*/nullptr, VK_RValue);
+  CallArgs.emplace_back(DesiredAlignmnet);
+}
+CallArgs.insert(CallArgs.end(), PlacementArgs.begin(), PlacementArgs.end());
 
-// FIXME: Missing call to CheckFunctionCall or equivalent
+DiagnoseSentinelCalls(OperatorNew, PlacementLParen, CallArgs);
+
+checkCall(OperatorNew, Proto, /*ThisArg=*/nullptr, CallArgs,
+  /*IsMemberFunction=*/false, StartLoc, Range, CallType);
 
 // Warn if the type is over-aligned and is being allocated by (unaligned)
 // global operator new.
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -14460,8 +14460,10 @@
 const Expr *E,
 llvm::APSInt *Value,
 SourceLocation *Loc) {
-  if (!E->getType()->isIntegralOrUnscopedEnumerationType()) {
-if (Loc) *Loc = 

[PATCH] D68720: Support -fstack-clash-protection for x86

2020-01-20 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon times-circle color=red} Unit tests: fail. 62035 tests passed, 2 failed 
and 783 were skipped.

  failed: Clang.CodeGen/stack-clash-protection.c
  failed: Clang.Misc/warning-flags.c

{icon question-circle color=gray} clang-tidy: unknown.

{icon times-circle color=red} clang-format: fail. Please format your changes 
with clang-format by running `git-clang-format HEAD^` or applying this patch 
.

Build artifacts 
: 
diff.json 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68720



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


[PATCH] D71124: [RISCV] support clang driver to select cpu

2020-01-20 Thread Sam Elliott via Phabricator via cfe-commits
lenary added a comment.

In D71124#1792216 , @khchen wrote:

> The problem is how `-mcpu` interact with explicitly specified `-march` (or 
> target features).
>
> 1. in GCC, -mcpu is only used to chose the pipeline model,


I think you mean "in GCC, `-mtune` is only used to choose the pipeline model" 
(`-mcpu` is not documented in the RISC-V specific GCC options documentation 
).

Clang should attempt to maintain compatibility with GCC flags, but if they only 
implement `-mtune`, then we have a little more freedom to do something 
ergonomic with `-mcpu`.

I'll note that clang already has a large TODO around implementing `-mtune` in 
general, though the AArch64 backend seems to support it for some option choices.

> 
> 
> 2. I also read this 
> 
>  article talking about the X86 and ARM to handle those options.
>   - -march=X: Tells the compiler that X is the minimal architecture the 
> binary must run on.  The compiler is free to use architecture-specific 
> instructions.  This flag behaves differently on Arm and x86.  On Arm, -march 
> does not override -mtune, but on x86 -march will override both -mtune and 
> -mcpu.
>   - -mtune=X: Tells the compiler to optimize for microarchitecture X but does 
> not allow the compiler to change the ABI or make assumptions about available 
> instructions.  This flag has the more-or-less the same meaning on Arm and x86.
>   - -mcpu=X: On Arm, this flag is a combination of -march and -mtune.  It 
> simultaneously specifies the target architecture and optimizes for a given 
> microarchitecture. On x86 this flag is a deprecated synonym for -mtune.
> 
> So maybe it makes sense to treat those flags behaves differently on 
> different target .
> 3. I also tried llc to specific -mcpu and -attr (similar to -march, 
> target-feature) in ARM, -attr will over write the default target-feature in 
> -mcpu.
> 
>   on RISC-V, in sometime (or most?) we have same pipeline model but support 
> different extension combination,

I don't believe this to be correct. lowRISC's Ibex has a completely different 
pipeline model to rocket, and there are countless other RISC-V cores with 
different pipeline characteristics, including out-of-order pipeline 
implementations like BOOM. I don't think we can favour one particular 
scheduling model (beyond the generic ones we already default to).

> so I think maybe distinguishing the purpose of -mcpu and -march and make them 
> with no interaction is a good idea. (behavior is equal to GCC)

In LLVM, if you add `target-cpu` metadata to a function (which is added by 
clang, based on `-mcpu`), that function will have all the features of that CPU 
automatically added to it (as if you had used `-mattr` with all the features in 
the model). If you don't add that metadata, a generic scheduling model will be 
chosen. This suggests at the moment there can be no separation between `-mtune` 
and `-march` as there is in GCC (without changes to the target-independent 
parts of LLVM).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71124



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


[PATCH] D28955: [analyzer] Enable support for symbolic extension/truncation

2020-01-20 Thread Mikhail Ramalho via Phabricator via cfe-commits
mikhail.ramalho added a comment.

I can give some help here, but my time is quite limited as well :/

Let me at least rebase against master.


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

https://reviews.llvm.org/D28955



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


[PATCH] D73019: [Sema] Don't disallow placing `__attribute__((alloc_align(param_idx)))` on `std::align_val_t`-typed parameters

2020-01-20 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri updated this revision to Diff 239179.
lebedev.ri added a comment.

NFC, more tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73019

Files:
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/SemaCXX/std-align-val-t-in-operator-new.cpp


Index: clang/test/SemaCXX/std-align-val-t-in-operator-new.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/std-align-val-t-in-operator-new.cpp
@@ -0,0 +1,59 @@
+// RUN: %clang_cc1 -std=c++11  -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c++11 -faligned-allocation -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c++14  -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c++14 -faligned-allocation -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c++17  -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c++17 -faligned-allocation -fsyntax-only -verify %s
+
+namespace std {
+typedef __SIZE_TYPE__ size_t;
+struct nothrow_t {};
+#if __cplusplus >= 201103L
+enum class align_val_t : size_t {};
+#else
+enum align_val_t {
+// We can't force an underlying type when targeting windows.
+#ifndef _WIN32
+  __zero = 0,
+  __max = (size_t)-1
+#endif
+};
+#endif
+} // namespace std
+
+void *operator new(std::size_t count, std::align_val_t al) 
__attribute__((alloc_align(2)));
+
+#define OVERALIGNED alignas(__STDCPP_DEFAULT_NEW_ALIGNMENT__ * 2)
+
+struct OVERALIGNED A {
+  A();
+  int n[128];
+};
+
+void *ptr_variable(int align) { return new (std::align_val_t(align)) A; }
+void *ptr_align16() { return new (std::align_val_t(16)) A; }
+void *ptr_align15() { return new (std::align_val_t(15)) A; }
+
+struct alignas(128) S {
+  S() {}
+};
+
+void *alloc_overaligned_struct() {
+  return new S;
+}
+
+void *alloc_overaligned_struct_with_extra_variable_alignment(int align) {
+  return new (std::align_val_t(align)) S;
+}
+void *alloc_overaligned_struct_with_extra_256_alignment(int align) {
+  return new (std::align_val_t(256)) S;
+}
+void *alloc_overaligned_struct_with_extra_255_alignment(int align) {
+  return new (std::align_val_t(255)) S;
+}
+
+std::align_val_t align_variable(int align) { return std::align_val_t(align); }
+std::align_val_t align_align16() { return std::align_val_t(16); }
+std::align_val_t align_align15() { return std::align_val_t(15); }
+
+// expected-no-diagnostics
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -1669,7 +1669,8 @@
 return;
 
   QualType Ty = getFunctionOrMethodParamType(D, Idx.getASTIndex());
-  if (!Ty->isDependentType() && !Ty->isIntegralType(Context)) {
+  if (!Ty->isDependentType() && !Ty->isIntegralType(Context) &&
+  !Ty->isAlignValT()) {
 Diag(ParamExpr->getBeginLoc(), diag::err_attribute_integers_only)
 << 
 << FuncDecl->getParamDecl(Idx.getASTIndex())->getSourceRange();


Index: clang/test/SemaCXX/std-align-val-t-in-operator-new.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/std-align-val-t-in-operator-new.cpp
@@ -0,0 +1,59 @@
+// RUN: %clang_cc1 -std=c++11  -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c++11 -faligned-allocation -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c++14  -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c++14 -faligned-allocation -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c++17  -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c++17 -faligned-allocation -fsyntax-only -verify %s
+
+namespace std {
+typedef __SIZE_TYPE__ size_t;
+struct nothrow_t {};
+#if __cplusplus >= 201103L
+enum class align_val_t : size_t {};
+#else
+enum align_val_t {
+// We can't force an underlying type when targeting windows.
+#ifndef _WIN32
+  __zero = 0,
+  __max = (size_t)-1
+#endif
+};
+#endif
+} // namespace std
+
+void *operator new(std::size_t count, std::align_val_t al) __attribute__((alloc_align(2)));
+
+#define OVERALIGNED alignas(__STDCPP_DEFAULT_NEW_ALIGNMENT__ * 2)
+
+struct OVERALIGNED A {
+  A();
+  int n[128];
+};
+
+void *ptr_variable(int align) { return new (std::align_val_t(align)) A; }
+void *ptr_align16() { return new (std::align_val_t(16)) A; }
+void *ptr_align15() { return new (std::align_val_t(15)) A; }
+
+struct alignas(128) S {
+  S() {}
+};
+
+void *alloc_overaligned_struct() {
+  return new S;
+}
+
+void *alloc_overaligned_struct_with_extra_variable_alignment(int align) {
+  return new (std::align_val_t(align)) S;
+}
+void *alloc_overaligned_struct_with_extra_256_alignment(int align) {
+  return new (std::align_val_t(256)) S;
+}
+void *alloc_overaligned_struct_with_extra_255_alignment(int align) {
+  return new (std::align_val_t(255)) S;
+}
+
+std::align_val_t align_variable(int align) { return 

[PATCH] D73056: [clangd] Fix DocumentOutline for concepts

2020-01-20 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGfb3d9153c01b: [clangd] Fix DocumentOutline for concepts 
(authored by kadircet).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73056

Files:
  clang-tools-extra/clangd/FindSymbols.cpp
  clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp


Index: clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
+++ clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
@@ -449,6 +449,15 @@
 SymNameRange(Main.range("def");
 }
 
+TEST_F(DocumentSymbolsTest, Concepts) {
+  CDB.ExtraClangFlags = {"-std=c++2a"};
+  std::string FilePath = testPath("foo.cpp");
+  addFile(FilePath,
+  "template  concept C = requires(T t) { t.foo(); };");
+
+  EXPECT_THAT(getSymbols(FilePath), ElementsAre(WithName("C")));
+}
+
 TEST_F(DocumentSymbolsTest, ExternSymbol) {
   std::string FilePath = testPath("foo.cpp");
   addFile(testPath("foo.h"), R"cpp(
Index: clang-tools-extra/clangd/FindSymbols.cpp
===
--- clang-tools-extra/clangd/FindSymbols.cpp
+++ clang-tools-extra/clangd/FindSymbols.cpp
@@ -193,8 +193,11 @@
   enum class VisitKind { No, OnlyDecl, DeclAndChildren };
 
   void traverseDecl(Decl *D, std::vector ) {
-if (auto *Templ = llvm::dyn_cast(D))
-  D = Templ->getTemplatedDecl();
+if (auto *Templ = llvm::dyn_cast(D)) {
+  // TemplatedDecl might be null, e.g. concepts.
+  if (auto *TD = Templ->getTemplatedDecl())
+D = TD;
+}
 auto *ND = llvm::dyn_cast(D);
 if (!ND)
   return;


Index: clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
+++ clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
@@ -449,6 +449,15 @@
 SymNameRange(Main.range("def");
 }
 
+TEST_F(DocumentSymbolsTest, Concepts) {
+  CDB.ExtraClangFlags = {"-std=c++2a"};
+  std::string FilePath = testPath("foo.cpp");
+  addFile(FilePath,
+  "template  concept C = requires(T t) { t.foo(); };");
+
+  EXPECT_THAT(getSymbols(FilePath), ElementsAre(WithName("C")));
+}
+
 TEST_F(DocumentSymbolsTest, ExternSymbol) {
   std::string FilePath = testPath("foo.cpp");
   addFile(testPath("foo.h"), R"cpp(
Index: clang-tools-extra/clangd/FindSymbols.cpp
===
--- clang-tools-extra/clangd/FindSymbols.cpp
+++ clang-tools-extra/clangd/FindSymbols.cpp
@@ -193,8 +193,11 @@
   enum class VisitKind { No, OnlyDecl, DeclAndChildren };
 
   void traverseDecl(Decl *D, std::vector ) {
-if (auto *Templ = llvm::dyn_cast(D))
-  D = Templ->getTemplatedDecl();
+if (auto *Templ = llvm::dyn_cast(D)) {
+  // TemplatedDecl might be null, e.g. concepts.
+  if (auto *TD = Templ->getTemplatedDecl())
+D = TD;
+}
 auto *ND = llvm::dyn_cast(D);
 if (!ND)
   return;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D73060: [Clang] Fix expansion of response files in -Wp after integrated-cc1 change

2020-01-20 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea created this revision.
aganea added reviewers: hans, thakis, wenlei.
aganea added a project: clang.
Herald added a subscriber: cfe-commits.
aganea edited the summary of this revision.

After rGb4a99a061f517e60985667e39519f60186cbb469 
, passing 
a response file such as `-Wp,@a.rsp` wasn't working anymore because .rsp 
expansion happens inside clang's main() function.

I'm noticing along the way that explicit arguments in `-Wp` are parsed in the 
driver, whereas arguments inside a response file are parsed in the -cc1 tool. 
Is that the desired behavior? This was the previous behavior but I'm not sure 
it's the right behavior.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73060

Files:
  clang/include/clang/Driver/Driver.h
  clang/lib/Driver/Job.cpp
  clang/test/Driver/Wp-args.c
  clang/tools/driver/driver.cpp

Index: clang/tools/driver/driver.cpp
===
--- clang/tools/driver/driver.cpp
+++ clang/tools/driver/driver.cpp
@@ -241,8 +241,6 @@
   *NumberSignPtr = '=';
 }
 
-static int ExecuteCC1Tool(ArrayRef argv);
-
 static void SetBackdoorDriverOutputsFromEnvVars(Driver ) {
   // Handle CC_PRINT_OPTIONS and CC_PRINT_OPTIONS_FILE.
   TheDriver.CCPrintOptions = !!::getenv("CC_PRINT_OPTIONS");
@@ -318,7 +316,6 @@
   // Driver::CC1Main), we need to clean up the options usage count. The options
   // are currently global, and they might have been used previously by the
   // driver.
-  llvm::cl::ResetAllOptionOccurrences();
   StringRef Tool = argv[1];
   void *GetExecutablePathVP = (void *)(intptr_t) GetExecutablePath;
   if (Tool == "-cc1")
@@ -334,17 +331,13 @@
   return 1;
 }
 
-int main(int argc_, const char **argv_) {
-  noteBottomOfStack();
-  llvm::InitLLVM X(argc_, argv_);
-  SmallVector argv(argv_, argv_ + argc_);
-
-  if (llvm::sys::Process::FixupStandardFileDescriptors())
-return 1;
-
-  llvm::InitializeAllTargets();
+int ExecuteClangTool(SmallVectorImpl ) {
   auto TargetAndMode = ToolChain::getTargetAndModeFromProgramName(argv[0]);
 
+  static unsigned ReenteranceCount;
+  if (ReenteranceCount++)
+llvm::cl::ResetAllOptionOccurrences();
+
   llvm::BumpPtrAllocator A;
   llvm::StringSaver Saver(A);
 
@@ -480,7 +473,7 @@
   SetBackdoorDriverOutputsFromEnvVars(TheDriver);
 
   if (!UseNewCC1Process) {
-TheDriver.CC1Main = 
+TheDriver.CC1Main = 
 // Ensure the CC1Command actually catches cc1 crashes
 llvm::CrashRecoveryContext::Enable();
   }
@@ -543,3 +536,15 @@
   // failing command.
   return Res;
 }
+
+int main(int argc_, const char **argv_) {
+  noteBottomOfStack();
+  llvm::InitLLVM X(argc_, argv_);
+  SmallVector argv(argv_, argv_ + argc_);
+
+  if (llvm::sys::Process::FixupStandardFileDescriptors())
+return 1;
+
+  llvm::InitializeAllTargets();
+  return ExecuteClangTool(argv);
+}
Index: clang/test/Driver/Wp-args.c
===
--- clang/test/Driver/Wp-args.c
+++ clang/test/Driver/Wp-args.c
@@ -19,3 +19,9 @@
 // MMD: "-cc1"
 // MMD-NOT: -MMD
 // MMD: "-dependency-file" "Wp-args.d"
+
+// Ensure response files are properly expanded with -Wp
+// RUN: echo -rewrite-macros > %t.rsp
+// RUN: %clang -Wp,@%t.rsp -E %s | FileCheck -check-prefix RSP %s
+
+// RSP: inception
Index: clang/lib/Driver/Job.cpp
===
--- clang/lib/Driver/Job.cpp
+++ clang/lib/Driver/Job.cpp
@@ -384,7 +384,6 @@
   SmallVector Argv;
   Argv.push_back(getExecutable());
   Argv.append(getArguments().begin(), getArguments().end());
-  Argv.push_back(nullptr);
 
   // This flag simply indicates that the program couldn't start, which isn't
   // applicable here.
Index: clang/include/clang/Driver/Driver.h
===
--- clang/include/clang/Driver/Driver.h
+++ clang/include/clang/Driver/Driver.h
@@ -208,7 +208,7 @@
   /// When the clangDriver lib is used through clang.exe, this provides a
   /// shortcut for executing the -cc1 command-line directly, in the same
   /// process.
-  typedef int (*CC1ToolFunc)(ArrayRef argv);
+  typedef int (*CC1ToolFunc)(SmallVectorImpl &);
   CC1ToolFunc CC1Main = nullptr;
 
 private:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72932: [ARM] Follow AACPS standard for volatile bit-fields access width

2020-01-20 Thread Diogo N. Sampaio via Phabricator via cfe-commits
dnsampaio added a comment.

In D72932#1829716 , @ostannard wrote:

> Why are you doing this in CodeGen, rather than adjusting the existing layout 
> code in CGRecordLowering? Doing it this way will result in 
> AdjustAAPCSBitfieldLValue being called for every access to the bit-field, 
> rather than just once. This is probably more fragile too, because it's 
> spreading the logic across multiple parts of the codebase, and has to undo 
> some of the layout done by CGRecordLowering.


Only at CodeGen we definitely know if an access is volatile, due casts to 
volatile.
About undoing what the CGRecordLowering does, that can't be avoided. We only 
can compute if a given offset and width will touch outside the bit-field when 
all fields and padding are defined.
We could add special volatile access fields into CGBitFieldInfo and compute 
them at the end for CGRecordLowering::lower, but these fields would only be 
relevant to ARM. And they will need to be computed even if there are any 
volatile accesses.
I have no strong opinion about which is better, I can add the fields if that 
suites better.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72932



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


[clang-tools-extra] fb3d915 - [clangd] Fix DocumentOutline for concepts

2020-01-20 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2020-01-20T20:20:27+01:00
New Revision: fb3d9153c01b9a560680465190d6ecd804e4c486

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

LOG: [clangd] Fix DocumentOutline for concepts

Summary: Fixes https://github.com/clangd/clangd/issues/256

Reviewers: kbobyrev

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

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clangd/FindSymbols.cpp
clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/FindSymbols.cpp 
b/clang-tools-extra/clangd/FindSymbols.cpp
index 4c92c8896b9d..1ce4222b5764 100644
--- a/clang-tools-extra/clangd/FindSymbols.cpp
+++ b/clang-tools-extra/clangd/FindSymbols.cpp
@@ -193,8 +193,11 @@ class DocumentOutline {
   enum class VisitKind { No, OnlyDecl, DeclAndChildren };
 
   void traverseDecl(Decl *D, std::vector ) {
-if (auto *Templ = llvm::dyn_cast(D))
-  D = Templ->getTemplatedDecl();
+if (auto *Templ = llvm::dyn_cast(D)) {
+  // TemplatedDecl might be null, e.g. concepts.
+  if (auto *TD = Templ->getTemplatedDecl())
+D = TD;
+}
 auto *ND = llvm::dyn_cast(D);
 if (!ND)
   return;

diff  --git a/clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp 
b/clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
index 8eebb190edae..eba920a7a452 100644
--- a/clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
+++ b/clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
@@ -449,6 +449,15 @@ TEST_F(DocumentSymbolsTest, DeclarationDefinition) {
 SymNameRange(Main.range("def");
 }
 
+TEST_F(DocumentSymbolsTest, Concepts) {
+  CDB.ExtraClangFlags = {"-std=c++2a"};
+  std::string FilePath = testPath("foo.cpp");
+  addFile(FilePath,
+  "template  concept C = requires(T t) { t.foo(); };");
+
+  EXPECT_THAT(getSymbols(FilePath), ElementsAre(WithName("C")));
+}
+
 TEST_F(DocumentSymbolsTest, ExternSymbol) {
   std::string FilePath = testPath("foo.cpp");
   addFile(testPath("foo.h"), R"cpp(



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


[PATCH] D73056: [clangd] Fix DocumentOutline for concepts

2020-01-20 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev accepted this revision.
kbobyrev added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73056



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


[PATCH] D73052: [clang-tidy] RenamerClangTidy now renames dependent member expr when the member can be resolved

2020-01-20 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon check-circle color=green} Unit tests: pass. 62027 tests passed, 0 failed 
and 783 were skipped.

{icon question-circle color=gray} clang-tidy: unknown.

{icon times-circle color=red} clang-format: fail. Please format your changes 
with clang-format by running `git-clang-format HEAD^` or applying this patch 
.

Build artifacts 
: 
diff.json 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73052



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


LLVM buildmaster will be updated and restarted tonight

2020-01-20 Thread Galina Kistanova via cfe-commits
 Hello everyone,

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

Thanks

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


[PATCH] D68720: Support -fstack-clash-protection for x86

2020-01-20 Thread serge via Phabricator via cfe-commits
serge-sans-paille updated this revision to Diff 239166.
serge-sans-paille added a comment.

- Harmonize esp/rsp usage as hinted by @craig.topper
- Fix argument detection


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68720

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/DiagnosticCommonKinds.td
  clang/include/clang/Basic/TargetInfo.h
  clang/include/clang/Driver/CC1Options.td
  clang/include/clang/Driver/Options.td
  clang/lib/Basic/Targets/X86.h
  clang/lib/CodeGen/CGStmt.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/stack-clash-protection.c
  clang/test/Driver/stack-clash-protection.c
  llvm/docs/ReleaseNotes.rst
  llvm/include/llvm/CodeGen/TargetLowering.h
  llvm/lib/Target/X86/X86CallFrameOptimization.cpp
  llvm/lib/Target/X86/X86FrameLowering.cpp
  llvm/lib/Target/X86/X86FrameLowering.h
  llvm/lib/Target/X86/X86ISelLowering.cpp
  llvm/lib/Target/X86/X86ISelLowering.h
  llvm/lib/Target/X86/X86InstrCompiler.td
  llvm/lib/Target/X86/X86InstrInfo.td
  llvm/test/CodeGen/X86/stack-clash-dynamic-alloca.ll
  llvm/test/CodeGen/X86/stack-clash-large.ll
  llvm/test/CodeGen/X86/stack-clash-medium-natural-probes-mutliple-objects.ll
  llvm/test/CodeGen/X86/stack-clash-medium-natural-probes.ll
  llvm/test/CodeGen/X86/stack-clash-medium.ll
  llvm/test/CodeGen/X86/stack-clash-no-free-probe.ll
  llvm/test/CodeGen/X86/stack-clash-small.ll
  llvm/test/CodeGen/X86/stack-clash-unknown-call.ll

Index: llvm/test/CodeGen/X86/stack-clash-unknown-call.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/stack-clash-unknown-call.ll
@@ -0,0 +1,31 @@
+; RUN: llc < %s | FileCheck %s
+
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+declare void @llvm.memset.p0i8.i64(i8* nocapture writeonly, i8, i64, i1 immarg);
+
+define void @foo() local_unnamed_addr #0 {
+
+;CHECK-LABEL: foo:
+;CHECK: # %bb.0:
+;CHECK-NEXT:	subq	$4096, %rsp # imm = 0x1000
+; it's important that we don't use the call as a probe here
+;CHECK-NEXT:	movq	$0, (%rsp)
+;CHECK-NEXT:	subq	$3912, %rsp # imm = 0xF48
+;CHECK-NEXT:	.cfi_def_cfa_offset 8016
+;CHECK-NEXT:	movq	%rsp, %rdi
+;CHECK-NEXT:	movl	$8000, %edx # imm = 0x1F40
+;CHECK-NEXT:	xorl	%esi, %esi
+;CHECK-NEXT:	callq	memset
+;CHECK-NEXT:	addq	$8008, %rsp # imm = 0x1F48
+;CHECK-NEXT:	.cfi_def_cfa_offset 8
+;CHECK-NEXT:	retq
+
+  %a = alloca i8, i64 8000, align 16
+  call void @llvm.memset.p0i8.i64(i8* align 16 %a, i8 0, i64 8000, i1 false)
+  ret void
+}
+
+attributes #0 =  {"probe-stack"="inline-asm"}
Index: llvm/test/CodeGen/X86/stack-clash-small.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/stack-clash-small.ll
@@ -0,0 +1,25 @@
+; RUN: llc < %s | FileCheck %s
+
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+define i32 @foo() local_unnamed_addr #0 {
+; CHECK-LABEL: foo:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:  subq	$280, %rsp # imm = 0x118
+; CHECK-NEXT:  .cfi_def_cfa_offset 288
+; CHECK-NEXT:  movl	$1, 264(%rsp)
+; CHECK-NEXT:  movl	-128(%rsp), %eax
+; CHECK-NEXT:  addq	$280, %rsp # imm = 0x118
+; CHECK-NEXT:  .cfi_def_cfa_offset 8
+; CHECK-NEXT:  retq
+
+  %a = alloca i32, i64 100, align 16
+  %b = getelementptr inbounds i32, i32* %a, i64 98
+  store volatile i32 1, i32* %b
+  %c = load volatile i32, i32* %a
+  ret i32 %c
+}
+
+attributes #0 =  {"probe-stack"="inline-asm"}
Index: llvm/test/CodeGen/X86/stack-clash-no-free-probe.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/stack-clash-no-free-probe.ll
@@ -0,0 +1,27 @@
+; RUN: llc < %s | FileCheck %s
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+define i32 @foo(i64 %i) local_unnamed_addr #0 {
+; CHECK-LABEL: foo:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:  subq	$4096, %rsp # imm = 0x1000
+; CHECK-NEXT:  movq	$0, (%rsp)
+; CHECK-NEXT:  subq	$3784, %rsp # imm = 0xEC8
+; CHECK-NEXT:  .cfi_def_cfa_offset 7888
+; CHECK-NEXT:  movl	$1, -128(%rsp,%rdi,4)
+; CHECK-NEXT:  movl	-128(%rsp), %eax
+; CHECK-NEXT:  addq	$7880, %rsp # imm = 0x1EC8
+; CHECK-NEXT:  .cfi_def_cfa_offset 8
+; CHECK-NEXT:  retq
+
+  %a = alloca i32, i32 2000, align 16
+  %b = getelementptr inbounds i32, i32* %a, i64 %i
+  store volatile i32 1, i32* %b
+  %c = load volatile i32, i32* %a
+  ret i32 %c
+}
+
+attributes #0 =  {"probe-stack"="inline-asm"}
+
Index: llvm/test/CodeGen/X86/stack-clash-medium.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/stack-clash-medium.ll
@@ 

[PATCH] D72897: List implicit operator== after implicit destructors in a vtable.

2020-01-20 Thread Peter Smith via Phabricator via cfe-commits
peter.smith added a comment.

It is also failing on the other 32-bit arm bots, example 
http://lab.llvm.org:8011/builders/clang-cmake-armv7-quick/builds/13052/steps/ninja%20check%201/logs/FAIL%3A%20Clang%3A%3Avirtual-compare.cpp
Looking at the failure

  // CHECK-SAME: @_ZThn8_N1AD1Ev 

and the output on an Arm machine

  $_ZThn4_N1AD1Ev = comdat any
  
  $_ZThn4_N1AD0Ev = comdat any
  
  $_ZThn4_N1AaSERKS_ = comdat any

It might be a 32-bit/64-bit specific expectation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72897



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


[PATCH] D72488: [clang-tidy] Add check for CERT-OOP57-CPP

2020-01-20 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: clang-tools-extra/docs/clang-tidy/checks/cert-oop57-cpp.rst:25
+   Default is an empty string.
+   The check will detect the following functions:
+   `std::memcpy`, `memcpy`, `std::memmove`, `memmove`, `std::strcpy`,

This should be in general documentation, not in option. Please enclose function 
names in double back-ticks.

Same for other similar statements below.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72488



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


[PATCH] D73052: [clang-tidy] RenamerClangTidy now renames dependent member expr when the member can be resolved

2020-01-20 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 239167.
njames93 marked 4 inline comments as done.
njames93 added a comment.

- Added not type template test case


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73052

Files:
  clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-member-decl-usage.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-member-decl-usage.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-member-decl-usage.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-member-decl-usage.cpp
@@ -134,4 +134,86 @@
 void foo() {
   Container container;
 }
-}; // namespace CtorInits
+} // namespace CtorInits
+
+namespace resolved_dependance {
+template 
+struct A0 {
+  int value;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for member 'value'
+  A0 =(const A0 ) {
+value = Other.value;   // A0
+this->value = Other.value; // A0
+// CHECK-FIXES:  {{^}}Value = Other.Value;   // A0
+// CHECK-FIXES-NEXT: {{^}}this->Value = Other.Value; // A0
+return *this;
+  }
+  void outOfLineReset();
+};
+
+template 
+void A0::outOfLineReset() {
+  this->value -= value; // A0
+  // CHECK-FIXES: {{^}}  this->Value -= Value; // A0
+}
+
+template 
+struct A1 {
+  int value;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for member 'value'
+  A1 =(const A1 ) {
+value = Other.value;   // A1
+this->value = Other.value; // A1
+// CHECK-FIXES:  {{^}}Value = Other.Value;   // A1
+// CHECK-FIXES-NEXT: {{^}}this->Value = Other.Value; // A1
+return *this;
+  }
+  void outOfLineReset();
+};
+
+template 
+void A1::outOfLineReset() {
+  this->value -= value; // A1
+  // CHECK-FIXES: {{^}}  this->Value -= Value; // A1
+}
+
+template 
+struct A2 {
+  int value;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for member 'value'
+  A2 =(const A2 ) {
+value = Other.value;   // A2
+this->value = Other.value; // A2
+// CHECK-FIXES:  {{^}}Value = Other.Value;   // A2
+// CHECK-FIXES-NEXT: {{^}}this->Value = Other.Value; // A2
+return *this;
+  }
+};
+
+//create some instances to check it works
+A1 AInt{};
+A1 BInt = (AInt.outOfLineReset(), AInt);
+A1 AUnsigned{};
+A1 BUnsigned = AUnsigned;
+} //namespace resolved_dependance
+
+namespace unresolved_dependance {
+template 
+struct DependentBase {
+  int depValue;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for member 'depValue'
+};
+
+template 
+struct Derived : DependentBase {
+  Derived =(const Derived ) {
+this->depValue = Other.depValue;
+// CHECK-FIXES-NOT: {{^}}this->DepValue = Other.DepValue;
+return *this;
+  }
+};
+
+Derived AInt{};
+Derived BInt = AInt;
+
+} //namespace unresolved_dependance
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -97,6 +97,11 @@
 Changes in existing checks
 ^^
 
+- Improved :doc:'readability-identifier-naming
+  ` check.
+
+  Now able to rename member references in class template definitions with 
+  explicit access.
 
 Renamed checks
 ^^
Index: clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
===
--- clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
+++ clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
@@ -106,20 +106,22 @@
  this);
   Finder->addMatcher(typeLoc().bind("typeLoc"), this);
   Finder->addMatcher(nestedNameSpecifierLoc().bind("nestedNameLoc"), this);
+  auto MemberOrDependent =
+  expr(eachOf(memberExpr().bind("memberExpr"),
+  cxxDependentScopeMemberExpr().bind("depMemberExpr")));
   Finder->addMatcher(
   functionDecl(unless(cxxMethodDecl(isImplicit())),
-   hasBody(forEachDescendant(memberExpr().bind("memberExpr",
+   hasBody(forEachDescendant(MemberOrDependent))),
   this);
   Finder->addMatcher(
-  cxxConstructorDecl(
-  unless(isImplicit()),
-  forEachConstructorInitializer(
-  allOf(isWritten(), withInitializer(forEachDescendant(
- memberExpr().bind("memberExpr")),
+  cxxConstructorDecl(unless(isImplicit()),
+ forEachConstructorInitializer(allOf(
+ isWritten(), withInitializer(forEachDescendant(
+  MemberOrDependent),
+  

[PATCH] D73052: [clang-tidy] RenamerClangTidy now renames dependent member expr when the member can be resolved

2020-01-20 Thread Nathan James via Phabricator via cfe-commits
njames93 added inline comments.



Comment at: clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp:282
+: DepMemberRef->getBaseType();
+CXXRecordDecl *Base = BaseType.getTypePtr()->getAsCXXRecordDecl();
+if (!Base)

JonasToth wrote:
> can `Base` be a `const` pointer?
> 
> In which case will this pointer be a `nullptr`? Your test-cases seem to 
> exercise only cases where `Base` is not-null.
Base can be a const pointer. However I don't think it can be a nullptr, but I 
put the check in there just in case it ever is, maybe an assert would be the 
correct solution.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-member-decl-usage.cpp:187
+};
+
+Derived AInt{};

JonasToth wrote:
> Could you please provide a test-case with non-type template parameters as 
> well?
> 
> Another question but maybe/most likely off topic: are how are member-pointers 
> handled? Both for data and member-functions.
> -> Maybe a test-case for such a situation would be good, as well? :)
> 
> Crème de la Crème would be if templated member-pointers are treated properly, 
> too.
The test for non-type isn't strictly needed. in these test cases the template 
type isn't used but they still show up as dependent scope exprs. 

MemberPointers is something that this doesn't handle and probably something I 
wont add as you can have issues with specialisation meaning the member may not 
exist in a specialization 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73052



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


[PATCH] D72675: [Clang][Driver] Fix -ffast-math/-ffp-contract interaction

2020-01-20 Thread Hal Finkel via Phabricator via cfe-commits
hfinkel added a comment.

> I'm not sure whether this is deliberate (but it seems weird) or just a bug. I 
> can ask the GCC developers ...

Please do. If there's a rationale, we should know.


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

https://reviews.llvm.org/D72675



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


[PATCH] D73056: [clangd] Fix DocumentOutline for concepts

2020-01-20 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon check-circle color=green} Unit tests: pass. 62012 tests passed, 0 failed 
and 783 were skipped.

{icon question-circle color=gray} clang-tidy: unknown.

{icon check-circle color=green} clang-format: pass.

Build artifacts 
: 
diff.json 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73056



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


[PATCH] D72557: Add pretty printers for llvm::PointerIntPair and llvm::PointerUnion.

2020-01-20 Thread Christian Sigg via Phabricator via cfe-commits
csigg added a comment.

Hi David. Thanks a lot for you review. I did another pass to switch to factory 
methods that catch exceptions without spewing common errors on the GDB console. 
Would you mind taking another quick peek? Thanks a lot for your patience!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72557



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


[PATCH] D72557: Add pretty printers for llvm::PointerIntPair and llvm::PointerUnion.

2020-01-20 Thread Christian Sigg via Phabricator via cfe-commits
csigg updated this revision to Diff 239160.
csigg added a comment.
Herald added a subscriber: wuzish.

Fix base. I'm so terrible at this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72557

Files:
  debuginfo-tests/llvm-prettyprinters/gdb/prettyprinters.cpp
  debuginfo-tests/llvm-prettyprinters/gdb/prettyprinters.gdb
  llvm/include/llvm/ADT/PointerIntPair.h
  llvm/utils/gdb-scripts/prettyprinters.py

Index: llvm/utils/gdb-scripts/prettyprinters.py
===
--- llvm/utils/gdb-scripts/prettyprinters.py
+++ llvm/utils/gdb-scripts/prettyprinters.py
@@ -2,6 +2,7 @@
 import sys
 
 import gdb.printing
+import gdb.types
 
 class Iterator:
   def __iter__(self):
@@ -315,6 +316,51 @@
   def to_string(self):
 return self.string_from_twine_object(self._val)
 
+def make_printer(string = None, children = None, hint = None):
+  """Create a printer from the parameters."""
+  class Printer : pass
+  printer = Printer()
+  if string:
+setattr(printer, 'to_string', lambda: string)
+  if children:
+setattr(printer, 'children', lambda: children)
+  if hint:
+setattr(printer, 'display_hint', lambda: hint)
+  return printer
+
+def get_pointer_int_pair(val):
+  """Get iterable with zero or single tuple from llvm::PointerIntPair."""
+  info_name = val.type.template_argument(4).strip_typedefs().name
+  try:
+enum_type = gdb.lookup_type(info_name + '::MaskAndShiftConstants')
+  except gdb.error:
+return
+  enum_dict = gdb.types.make_enum_dict(enum_type)
+  ptr_mask = enum_dict[info_name + '::PointerBitMask']
+  int_shift = enum_dict[info_name + '::IntShift']
+  int_mask = enum_dict[info_name + '::IntMask']
+  pair_union = val['Value']
+  pointer = (pair_union & ptr_mask)
+  value = ((pair_union >> int_shift) & int_mask)
+  yield (pointer, value)
+
+def make_pointer_int_pair_printer(val):
+  """Factory for an llvm::PointerIntPair printer."""
+  for (pointer, value) in get_pointer_int_pair(val):
+pointer_type = val.type.template_argument(0)
+value_type = val.type.template_argument(2)
+string = 'llvm::PointerIntPair<%s>' % pointer_type
+children = [('pointer', pointer.cast(pointer_type)), 
+('value', value.cast(value_type))]
+return make_printer(string, children)
+
+def make_pointer_union_printer(val):
+  """Factory for an llvm::PointerUnion printer."""
+  for (pointer, value) in get_pointer_int_pair(val['Val']):
+pointer_type = val.type.template_argument(int(value))
+string = 'llvm::PointerUnion containing %s' % pointer_type
+return make_printer(string, [('pointer', pointer.cast(pointer_type))])
+
 pp = gdb.printing.RegexpCollectionPrettyPrinter("LLVMSupport")
 pp.add_printer('llvm::SmallString', '^llvm::SmallString<.*>$', SmallStringPrinter)
 pp.add_printer('llvm::StringRef', '^llvm::StringRef$', StringRefPrinter)
@@ -324,4 +370,6 @@
 pp.add_printer('llvm::Optional', '^llvm::Optional<.*>$', OptionalPrinter)
 pp.add_printer('llvm::DenseMap', '^llvm::DenseMap<.*>$', DenseMapPrinter)
 pp.add_printer('llvm::Twine', '^llvm::Twine$', TwinePrinter)
+pp.add_printer('llvm::PointerIntPair', '^llvm::PointerIntPair<.*>$', make_pointer_int_pair_printer)
+pp.add_printer('llvm::PointerUnion', '^llvm::PointerUnion<.*>$', make_pointer_union_printer)
 gdb.printing.register_pretty_printer(gdb.current_objfile(), pp)
Index: llvm/include/llvm/ADT/PointerIntPair.h
===
--- llvm/include/llvm/ADT/PointerIntPair.h
+++ llvm/include/llvm/ADT/PointerIntPair.h
@@ -147,7 +147,7 @@
 "cannot use a pointer type that has all bits free");
   static_assert(IntBits <= PtrTraits::NumLowBitsAvailable,
 "PointerIntPair with integer size too large for pointer");
-  enum : uintptr_t {
+  enum MaskAndShiftConstants : uintptr_t {
 /// PointerBitMask - The bits that come from the pointer.
 PointerBitMask =
 ~(uintptr_t)(((intptr_t)1 << PtrTraits::NumLowBitsAvailable) - 1),
Index: debuginfo-tests/llvm-prettyprinters/gdb/prettyprinters.gdb
===
--- debuginfo-tests/llvm-prettyprinters/gdb/prettyprinters.gdb
+++ debuginfo-tests/llvm-prettyprinters/gdb/prettyprinters.gdb
@@ -39,3 +39,10 @@
 # CHECK: "\"foo\"\"bar\""
 p Twine
 
+# CHECK: llvm::PointerIntPair = {pointer = 0xabc, value = 1}
+p PointerIntPair
+
+# CHECK: llvm::PointerUnion containing int * = {pointer = 0xabc}
+p PointerUnion
+
+
Index: debuginfo-tests/llvm-prettyprinters/gdb/prettyprinters.cpp
===
--- debuginfo-tests/llvm-prettyprinters/gdb/prettyprinters.cpp
+++ debuginfo-tests/llvm-prettyprinters/gdb/prettyprinters.cpp
@@ -1,12 +1,15 @@
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/Optional.h"
+#include "llvm/ADT/PointerIntPair.h"

[PATCH] D73056: [clangd] Fix DocumentOutline for concepts

2020-01-20 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: kbobyrev.
Herald added subscribers: cfe-commits, usaxena95, arphaman, jkorous, MaskRay, 
ilya-biryukov.
Herald added a project: clang.

Fixes https://github.com/clangd/clangd/issues/256


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73056

Files:
  clang-tools-extra/clangd/FindSymbols.cpp
  clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp


Index: clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
+++ clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
@@ -449,6 +449,15 @@
 SymNameRange(Main.range("def");
 }
 
+TEST_F(DocumentSymbolsTest, Concepts) {
+  CDB.ExtraClangFlags = {"-std=c++2a"};
+  std::string FilePath = testPath("foo.cpp");
+  addFile(FilePath,
+  "template  concept C = requires(T t) { t.foo(); };");
+
+  EXPECT_THAT(getSymbols(FilePath), ElementsAre(WithName("C")));
+}
+
 TEST_F(DocumentSymbolsTest, ExternSymbol) {
   std::string FilePath = testPath("foo.cpp");
   addFile(testPath("foo.h"), R"cpp(
Index: clang-tools-extra/clangd/FindSymbols.cpp
===
--- clang-tools-extra/clangd/FindSymbols.cpp
+++ clang-tools-extra/clangd/FindSymbols.cpp
@@ -193,8 +193,11 @@
   enum class VisitKind { No, OnlyDecl, DeclAndChildren };
 
   void traverseDecl(Decl *D, std::vector ) {
-if (auto *Templ = llvm::dyn_cast(D))
-  D = Templ->getTemplatedDecl();
+if (auto *Templ = llvm::dyn_cast(D)) {
+  // TemplatedDecl might be null, e.g. concepts.
+  if (auto *TD = Templ->getTemplatedDecl())
+D = TD;
+}
 auto *ND = llvm::dyn_cast(D);
 if (!ND)
   return;


Index: clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
+++ clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
@@ -449,6 +449,15 @@
 SymNameRange(Main.range("def");
 }
 
+TEST_F(DocumentSymbolsTest, Concepts) {
+  CDB.ExtraClangFlags = {"-std=c++2a"};
+  std::string FilePath = testPath("foo.cpp");
+  addFile(FilePath,
+  "template  concept C = requires(T t) { t.foo(); };");
+
+  EXPECT_THAT(getSymbols(FilePath), ElementsAre(WithName("C")));
+}
+
 TEST_F(DocumentSymbolsTest, ExternSymbol) {
   std::string FilePath = testPath("foo.cpp");
   addFile(testPath("foo.h"), R"cpp(
Index: clang-tools-extra/clangd/FindSymbols.cpp
===
--- clang-tools-extra/clangd/FindSymbols.cpp
+++ clang-tools-extra/clangd/FindSymbols.cpp
@@ -193,8 +193,11 @@
   enum class VisitKind { No, OnlyDecl, DeclAndChildren };
 
   void traverseDecl(Decl *D, std::vector ) {
-if (auto *Templ = llvm::dyn_cast(D))
-  D = Templ->getTemplatedDecl();
+if (auto *Templ = llvm::dyn_cast(D)) {
+  // TemplatedDecl might be null, e.g. concepts.
+  if (auto *TD = Templ->getTemplatedDecl())
+D = TD;
+}
 auto *ND = llvm::dyn_cast(D);
 if (!ND)
   return;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D71512: [clang-format] Fix short block when braking after control statement

2020-01-20 Thread Pablo Martin-Gomez via Phabricator via cfe-commits
Bouska marked an inline comment as done.
Bouska added inline comments.



Comment at: clang/unittests/Format/FormatTest.cpp:662
"{\n"
-   "  ff();\n"
"}",

MyDeveloperDay wrote:
> I'm just not comfortable with changing tests, code can still be written in 
> the way it was before, and I cannot tell what it would now be, I believe 
> tests should be additive
Ok, I'll keep the original test and add two new ones.


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

https://reviews.llvm.org/D71512



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


[PATCH] D72675: [Clang][Driver] Fix -ffast-math/-ffp-contract interaction

2020-01-20 Thread Ulrich Weigand via Phabricator via cfe-commits
uweigand added a comment.

I've had a quick look at GCC, and it seems there's a couple of different issues.

First of all, `-ffast-math` is a "collective" flag that has no separate meaning 
except setting a bunch of other flags.  Currently, these flags are:  
`-fno-math-errno`, ` -funsafe-math-optimizations` (which is itself a collective 
flag enabling `-fno-signed-zeros`, `-fno-trapping-math`, `-fassociative-math`, 
and `-freciprocal-math`),  `-ffinite-math-only`, `-fno-rounding-math`, 
`-fno-signaling-nans`, `-fcx-limited-range`, and  `-fexcess-precision=fast`.

When deciding whether to define `__FAST_MATH__`, GCC will not specifically look 
at whether or not the -ffast-math option itself was given, but whether the 
status of those other flags matches what would have been set by -ffast-math.  
However, it does not include all of the flags; currently only `-fmath-errno`, 
`-funsafe-math-optimizations`, `-fsigned-zeros`, `-ftrapping-math`, 
`-ffinite-math-only`,  and `-fexcess-precision` are checked, while 
`-fassociative-math`, `-freciprocal-math`, `-frounding-math`, 
`-fsignaling-nans`, and `-fcx-limited-range` are ignored.

I'm not sure whether this is deliberate (but it seems weird) or just a bug.  I 
can ask the GCC developers ...

A separate question is the interaction of `-ffast-math` with `-ffp-contract=`.  
Currently, there is no such interaction whatsoever in GCC: `-ffast-math` does 
not imply any particular `-ffp-contract=` setting, and vice versa the 
`-ffp-contract=` setting is not considered at all when defining 
`__FAST_MATH__`.  This seems at least internally consistent.


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

https://reviews.llvm.org/D72675



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


[PATCH] D73007: [Sema] Avoid Wrange-loop-analysis false positives

2020-01-20 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert added a comment.

In D73007#1829709 , @xbolva00 wrote:

> Yes, but minimal fix is better for release branch, so @hans should merge it.


I think `-Wall` shouldn't warn about reference types in a range-based for loop 
(unless it's the wrong type and inadvertently creates a copy).

> Handling your case probably needs more work and patches..

See my inline comments. The bug in itself is not terribly troublesome, this 
issue has existed in many previous releases. The problem is that the warning is 
now in `-Wall`, and I think we should be more conservative in `-Wall`.




Comment at: clang/lib/Sema/SemaStmt.cpp:2703-2704
 // suggest the const reference type that would do so.
 // For instance, given "for (const  : Range)", suggest
 // "for (const Foo : Range)" to denote a copy is made for the loop.  If
 // possible, also suggest "for (const  : Range)" if this type prevents

That's the part the bothers me.



Comment at: clang/lib/Sema/SemaStmt.cpp:2768-2778
 // The range always returns a copy, so a temporary is always created.
 // Suggest removing the reference from the loop variable.
 // If the type is a rvalue reference do not warn since that changes the
 // semantic of the code.
 SemaRef.Diag(VD->getLocation(), diag::warn_for_range_variable_always_copy)
 << VD << RangeInitType;
 QualType NonReferenceType = VariableType.getNonReferenceType();

We could either remove this part or group `warn_for_range_variable_always_copy` 
under a separate flag that's not in `-Wall`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73007



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


[PATCH] D72488: [clang-tidy] Add check for CERT-OOP57-CPP

2020-01-20 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon check-circle color=green} Unit tests: pass. 62027 tests passed, 0 failed 
and 783 were skipped.

{icon question-circle color=gray} clang-tidy: unknown.

{icon times-circle color=red} clang-format: fail. Please format your changes 
with clang-format by running `git-clang-format HEAD^` or applying this patch 
.

Build artifacts 
: 
diff.json 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72488



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


[PATCH] D62445: [test] Fix plugin tests

2020-01-20 Thread Mikhail Ramalho via Phabricator via cfe-commits
mikhail.ramalho added a comment.
Herald added a subscriber: Charusso.

Hi, I just found this revision.

Could you point out how can I run the CSA tests with Z3 as backend? We used to 
do `$ ninja check-clang-analyzer-z3`, however, it now fails and suggests:

   $ ninja check-clang-analyzer-z3
  ninja: error: unknown target 'check-clang-analyzer-z3', did you mean 
'check-clang-analysis-z3'?

`check-clang-analysis-z3` only runs one test though.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D62445



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


[PATCH] D73052: [clang-tidy] RenamerClangTidy now renames dependent member expr when the member can be resolved

2020-01-20 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon check-circle color=green} Unit tests: pass. 61955 tests passed, 0 failed 
and 783 were skipped.

{icon question-circle color=gray} clang-tidy: unknown.

{icon times-circle color=red} clang-format: fail. Please format your changes 
with clang-format by running `git-clang-format HEAD^` or applying this patch 
.

Build artifacts 
: 
diff.json 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73052



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


[PATCH] D44609: [Clang-Format] New option BeforeLambdaBody to manage lambda line break inside function parameter call (in Allman style)

2020-01-20 Thread Francois JEAN via Phabricator via cfe-commits
Wawha marked 2 inline comments as done.
Wawha added a comment.

Hello,
@klimek will you have time to review this patch? The current patch integrate 
the last remarks and also modification due to inline lambda.




Comment at: lib/Format/ContinuationIndenter.cpp:1179
+   Current.is(TT_LambdaLSquare;
   }
 

MyDeveloperDay wrote:
> oh boy... I have to say.. that I don't like these kinds of massive if 
> statements without some sort of comment.. as to what it's doing, it's so 
> hard, later on, to read through the various clauses and understand which bit 
> of functionality this section covers
I make some change in the last patch. Hope it's better.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D44609



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


[PATCH] D71512: [clang-format] Fix short block when braking after control statement

2020-01-20 Thread Pablo Martin-Gomez via Phabricator via cfe-commits
Bouska marked an inline comment as done.
Bouska added inline comments.



Comment at: clang/lib/Format/UnwrappedLineFormatter.cpp:344
-  return MergedLines;
-}
 // Don't merge block with left brace wrapped after ObjC special blocks

MyDeveloperDay wrote:
> I just can't understand how we are free to just remove a chunk of code. Why 
> is this not being some sort of 
> 
> 
> ```
> if (Style.AllowShortBlocksOnASingleLine)
> ```
> 
> You are just not giving a convincing argument that this is a safe change 
> without us having to go in a debug the original problem ourselves.
This chunk of code only provides a bogus formatting and nothing else. So in 
order to fix the bug, I need to remove the whole block of code.

I wasn't clear on why this chunk of code created the bug, so let me explained. 
Let's take an example:
```
if (true)
{
doStuff();
}
```
with //Style.BraceWrapping.AfterControlStatement = FormatStyle::BWACS_Always// 
and //Style.AllowShortBlocksOnASingleLine != FormatStyle::SBS_Never//.

When formatting the first line, the control statement @ line 308 is going to 
fail (because //Style.BraceWrapping.AfterControlStatement != 
FormatStyle::BWACS_Always//) but the control statement @ line 322 is going to 
pass (because the second line is a left brace and the first token of the line 
is a //if//). As //Style.BraceWrapping.AfterControlStatement == 
FormatStyle::BWACS_Always//, //tryMergeSimpleBlock()// is going to handle the 
merging. There is two possible outcomes : either the block is simple and not 
too long and it can be merge in one line, or it is not and the whole block 
stays as it is. That line is then considered formated (due to the //return//).

When formatting the second line, the control statement @ line 332 (because the 
first and only token of the line is a left brace and the first token of the 
first line is a //if//) is going to pass and 
//Style.AllowShortBlocksOnASingleLine != FormatStyle::SBS_Never//, so we are 
going to redo //tryMergeSimpleBlock()// on the first line which failed the 
first time! So this is the part I understand, we are doing someting we already 
did. The part I don't understand is that this time //tryMergeSimpleBlock()// 
managed to merge the line (probably because of some changes on the annoted 
first line). As the merging worked, //MergedLines > 0// @ line 340 is true so 
//MergedLines// is decremented (as explained by the comment) and we end up with 
the block merged but without the control statement:
 ```
if (true)
{ doStuff(); }
```
Which is not the expected formating.

I think there might be another bug hidden somewhere in 
//tryMergeSimpleBlock()//.


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

https://reviews.llvm.org/D71512



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


[PATCH] D73052: [clang-tidy] RenamerClangTidy now renames dependent member expr when the member can be resolved

2020-01-20 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon check-circle color=green} Unit tests: pass. 61955 tests passed, 0 failed 
and 783 were skipped.

{icon question-circle color=gray} clang-tidy: unknown.

{icon times-circle color=red} clang-format: fail. Please format your changes 
with clang-format by running `git-clang-format HEAD^` or applying this patch 
.

Build artifacts 
: 
diff.json 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73052



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


[PATCH] D72488: [clang-tidy] Add check for CERT-OOP57-CPP

2020-01-20 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 239153.
njames93 added a comment.

- rebase truck


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72488

Files:
  clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp
  clang-tools-extra/clang-tidy/cert/CMakeLists.txt
  clang-tools-extra/clang-tidy/cert/NonTrivialTypesLibcMemoryCallsCheck.cpp
  clang-tools-extra/clang-tidy/cert/NonTrivialTypesLibcMemoryCallsCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/cert-oop57-cpp.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/test/clang-tidy/checkers/cert-oop57-cpp.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/cert-oop57-cpp.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/cert-oop57-cpp.cpp
@@ -0,0 +1,90 @@
+// RUN: %check_clang_tidy %s cert-oop57-cpp %t -- \
+// RUN: -config='{CheckOptions: \
+// RUN:  [{key: cert-oop57-cpp.MemSetNames, value: mymemset}, \
+// RUN:  {key: cert-oop57-cpp.MemCpyNames, value: mymemcpy}, \
+// RUN:  {key: cert-oop57-cpp.MemCmpNames, value: mymemcmp}]}' \
+// RUN: --
+
+void mymemset(void *, unsigned char, decltype(sizeof(int)));
+void mymemcpy(void *, const void *, decltype(sizeof(int)));
+int mymemcmp(const void *, const void *, decltype(sizeof(int)));
+
+namespace std {
+void memset(void *, unsigned char, decltype(sizeof(int)));
+void memcpy(void *, const void *, decltype(sizeof(int)));
+void memmove(void *, const void *, decltype(sizeof(int)));
+void strcpy(void *, const void *, decltype(sizeof(int)));
+int memcmp(const void *, const void *, decltype(sizeof(int)));
+int strcmp(const void *, const void *, decltype(sizeof(int)));
+} // namespace std
+
+struct Trivial {
+  int I;
+  int J;
+};
+
+struct NonTrivial {
+  int I;
+  int J;
+
+  NonTrivial() : I(0), J(0) {}
+  NonTrivial =(const NonTrivial ) {
+I = Other.I;
+J = Other.J;
+return *this;
+  }
+
+  bool operator==(const Trivial ) const {
+return I == Other.I && J == Other.J;
+  }
+  bool operator!=(const Trivial ) const {
+return !(*this == Other);
+  }
+};
+
+void foo(const Trivial ) {
+  Trivial Data;
+  std::memset(, 0, sizeof(Data));
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:3: warning: calling 'memset' on a non-trivially default constructible class is undefined
+  std::memset(, 0, sizeof(Trivial));
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:3: warning: calling 'memset' on a non-trivially default constructible class is undefined
+  std::memcpy(, , sizeof(Data));
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:3: warning: calling 'memcpy' on a non-trivially copyable class is undefined
+  std::memmove(, , sizeof(Data));
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:3: warning: calling 'memmove' on a non-trivially copyable class is undefined
+  std::strcpy(, , sizeof(Data));
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:3: warning: calling 'strcpy' on a non-trivially copyable class is undefined
+  std::memcmp(, , sizeof(Data));
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:3: warning: consider using comparison operators instead of calling 'memcmp'
+  std::strcmp(, , sizeof(Data));
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:3: warning: consider using comparison operators instead of calling 'strcmp'
+}
+
+void bar(const NonTrivial ) {
+  NonTrivial Data;
+  std::memset(, 0, sizeof(Data));
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: calling 'memset' on a non-trivially default constructible class is undefined
+  // Check it detects sizeof(Type) as well as sizeof(Instantiation)
+  std::memset(, 0, sizeof(NonTrivial));
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: calling 'memset' on a non-trivially default constructible class is undefined
+  std::memcpy(, , sizeof(Data));
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: calling 'memcpy' on a non-trivially copyable class is undefined
+  std::memmove(, , sizeof(Data));
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: calling 'memmove' on a non-trivially copyable class is undefined
+  std::strcpy(, , sizeof(Data));
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: calling 'strcpy' on a non-trivially copyable class is undefined
+  std::memcmp(, , sizeof(Data));
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: consider using comparison operators instead of calling 'memcmp'
+  std::strcmp(, , sizeof(Data));
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: consider using comparison operators instead of calling 'strcmp'
+}
+
+void baz(const NonTrivial ) {
+  NonTrivial Data;
+  mymemset(, 0, sizeof(Data));
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: calling 'mymemset' on a non-trivially default constructible class is undefined
+  mymemcpy(, , sizeof(Data));
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: calling 'mymemcpy' on a non-trivially copyable class is undefined
+  mymemcmp(, , sizeof(Data));
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: consider using comparison 

[PATCH] D72488: [clang-tidy] Add check for CERT-OOP57-CPP

2020-01-20 Thread Nathan James via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa42c3eb599cb: [clang-tidy] Add check for CERT-OOP57-CPP 
(authored by njames93).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72488

Files:
  clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp
  clang-tools-extra/clang-tidy/cert/CMakeLists.txt
  clang-tools-extra/clang-tidy/cert/NonTrivialTypesLibcMemoryCallsCheck.cpp
  clang-tools-extra/clang-tidy/cert/NonTrivialTypesLibcMemoryCallsCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/cert-oop57-cpp.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/test/clang-tidy/checkers/cert-oop57-cpp.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/cert-oop57-cpp.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/cert-oop57-cpp.cpp
@@ -0,0 +1,90 @@
+// RUN: %check_clang_tidy %s cert-oop57-cpp %t -- \
+// RUN: -config='{CheckOptions: \
+// RUN:  [{key: cert-oop57-cpp.MemSetNames, value: mymemset}, \
+// RUN:  {key: cert-oop57-cpp.MemCpyNames, value: mymemcpy}, \
+// RUN:  {key: cert-oop57-cpp.MemCmpNames, value: mymemcmp}]}' \
+// RUN: --
+
+void mymemset(void *, unsigned char, decltype(sizeof(int)));
+void mymemcpy(void *, const void *, decltype(sizeof(int)));
+int mymemcmp(const void *, const void *, decltype(sizeof(int)));
+
+namespace std {
+void memset(void *, unsigned char, decltype(sizeof(int)));
+void memcpy(void *, const void *, decltype(sizeof(int)));
+void memmove(void *, const void *, decltype(sizeof(int)));
+void strcpy(void *, const void *, decltype(sizeof(int)));
+int memcmp(const void *, const void *, decltype(sizeof(int)));
+int strcmp(const void *, const void *, decltype(sizeof(int)));
+} // namespace std
+
+struct Trivial {
+  int I;
+  int J;
+};
+
+struct NonTrivial {
+  int I;
+  int J;
+
+  NonTrivial() : I(0), J(0) {}
+  NonTrivial =(const NonTrivial ) {
+I = Other.I;
+J = Other.J;
+return *this;
+  }
+
+  bool operator==(const Trivial ) const {
+return I == Other.I && J == Other.J;
+  }
+  bool operator!=(const Trivial ) const {
+return !(*this == Other);
+  }
+};
+
+void foo(const Trivial ) {
+  Trivial Data;
+  std::memset(, 0, sizeof(Data));
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:3: warning: calling 'memset' on a non-trivially default constructible class is undefined
+  std::memset(, 0, sizeof(Trivial));
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:3: warning: calling 'memset' on a non-trivially default constructible class is undefined
+  std::memcpy(, , sizeof(Data));
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:3: warning: calling 'memcpy' on a non-trivially copyable class is undefined
+  std::memmove(, , sizeof(Data));
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:3: warning: calling 'memmove' on a non-trivially copyable class is undefined
+  std::strcpy(, , sizeof(Data));
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:3: warning: calling 'strcpy' on a non-trivially copyable class is undefined
+  std::memcmp(, , sizeof(Data));
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:3: warning: consider using comparison operators instead of calling 'memcmp'
+  std::strcmp(, , sizeof(Data));
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:3: warning: consider using comparison operators instead of calling 'strcmp'
+}
+
+void bar(const NonTrivial ) {
+  NonTrivial Data;
+  std::memset(, 0, sizeof(Data));
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: calling 'memset' on a non-trivially default constructible class is undefined
+  // Check it detects sizeof(Type) as well as sizeof(Instantiation)
+  std::memset(, 0, sizeof(NonTrivial));
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: calling 'memset' on a non-trivially default constructible class is undefined
+  std::memcpy(, , sizeof(Data));
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: calling 'memcpy' on a non-trivially copyable class is undefined
+  std::memmove(, , sizeof(Data));
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: calling 'memmove' on a non-trivially copyable class is undefined
+  std::strcpy(, , sizeof(Data));
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: calling 'strcpy' on a non-trivially copyable class is undefined
+  std::memcmp(, , sizeof(Data));
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: consider using comparison operators instead of calling 'memcmp'
+  std::strcmp(, , sizeof(Data));
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: consider using comparison operators instead of calling 'strcmp'
+}
+
+void baz(const NonTrivial ) {
+  NonTrivial Data;
+  mymemset(, 0, sizeof(Data));
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: calling 'mymemset' on a non-trivially default constructible class is undefined
+  mymemcpy(, , sizeof(Data));
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: calling 'mymemcpy' on a non-trivially copyable class is undefined
+  mymemcmp(, , 

[clang-tools-extra] a42c3eb - [clang-tidy] Add check for CERT-OOP57-CPP

2020-01-20 Thread via cfe-commits

Author: Nathan
Date: 2020-01-20T17:09:03Z
New Revision: a42c3eb599cb3b83a07e6296d4ade213f1d74f0f

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

LOG: [clang-tidy] Add check for CERT-OOP57-CPP

Summary:
This is a very basic warning implementation of [[ 
https://wiki.sei.cmu.edu/confluence/display/cplusplus/OOP57-CPP.+Prefer+special+member+functions+and+overloaded+operators+to+C+Standard+Library+functions
 | Prefer special member functions and overloaded operators to C Standard 
Library functions ]]

It absolutely needs some fine tuning though.

Reviewers: alexfh, hokein, aaron.ballman, JonasToth

Reviewed By: aaron.ballman

Subscribers: merge_guards_bot, Eugene.Zelenko, mgorny, xazax.hun, cfe-commits

Tags: #clang, #clang-tools-extra

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

Added: 
clang-tools-extra/clang-tidy/cert/NonTrivialTypesLibcMemoryCallsCheck.cpp
clang-tools-extra/clang-tidy/cert/NonTrivialTypesLibcMemoryCallsCheck.h
clang-tools-extra/docs/clang-tidy/checks/cert-oop57-cpp.rst
clang-tools-extra/test/clang-tidy/checkers/cert-oop57-cpp.cpp

Modified: 
clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp
clang-tools-extra/clang-tidy/cert/CMakeLists.txt
clang-tools-extra/docs/ReleaseNotes.rst
clang-tools-extra/docs/clang-tidy/checks/list.rst

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp 
b/clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp
index ab1fbbe94402..226526d31970 100644
--- a/clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp
+++ b/clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp
@@ -25,6 +25,7 @@
 #include "FloatLoopCounter.h"
 #include "LimitedRandomnessCheck.h"
 #include "MutatingCopyCheck.h"
+#include "NonTrivialTypesLibcMemoryCallsCheck.h"
 #include "PostfixOperatorCheck.h"
 #include "ProperlySeededRandomGeneratorCheck.h"
 #include "SetLongJmpCheck.h"
@@ -73,6 +74,8 @@ class CERTModule : public ClangTidyModule {
 "cert-oop11-cpp");
 CheckFactories.registerCheck(
 "cert-oop54-cpp");
+CheckFactories.registerCheck(
+"cert-oop57-cpp");
 CheckFactories.registerCheck(
 "cert-oop58-cpp");
 

diff  --git a/clang-tools-extra/clang-tidy/cert/CMakeLists.txt 
b/clang-tools-extra/clang-tidy/cert/CMakeLists.txt
index 66ea2a13acdd..91f329d2b034 100644
--- a/clang-tools-extra/clang-tidy/cert/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/cert/CMakeLists.txt
@@ -8,6 +8,7 @@ add_clang_library(clangTidyCERTModule
   FloatLoopCounter.cpp
   LimitedRandomnessCheck.cpp
   MutatingCopyCheck.cpp
+  NonTrivialTypesLibcMemoryCallsCheck.cpp
   PostfixOperatorCheck.cpp
   ProperlySeededRandomGeneratorCheck.cpp
   SetLongJmpCheck.cpp

diff  --git 
a/clang-tools-extra/clang-tidy/cert/NonTrivialTypesLibcMemoryCallsCheck.cpp 
b/clang-tools-extra/clang-tidy/cert/NonTrivialTypesLibcMemoryCallsCheck.cpp
new file mode 100644
index ..a7bd38173eb0
--- /dev/null
+++ b/clang-tools-extra/clang-tidy/cert/NonTrivialTypesLibcMemoryCallsCheck.cpp
@@ -0,0 +1,152 @@
+//===--- NonTrivialTypesLibcMemoryCallsCheck.cpp - clang-tidy --===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "NonTrivialTypesLibcMemoryCallsCheck.h"
+#include "../utils/OptionsUtils.h"
+#include "clang/AST/Decl.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/ASTMatchers/ASTMatchersInternal.h"
+#include "clang/ASTMatchers/ASTMatchersMacros.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/raw_ostream.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace cert {
+
+namespace {
+AST_MATCHER(CXXRecordDecl, isTriviallyDefaultConstructible) {
+  return Node.hasTrivialDefaultConstructor();
+}
+AST_MATCHER(CXXRecordDecl, isTriviallyCopyable) {
+  return Node.hasTrivialCopyAssignment() && Node.hasTrivialCopyConstructor();
+}
+AST_MATCHER_P(NamedDecl, hasAnyNameStdString, std::vector,
+  String) {
+  return ast_matchers::internal::HasNameMatcher(String).matchesNode(Node);
+}
+} // namespace
+
+static const char BuiltinMemSet[] = "::std::memset;"
+"::memset;";
+static const char BuiltinMemCpy[] = "::std::memcpy;"
+"::memcpy;"
+"::std::memmove;"
+"::memmove;"
+"::std::strcpy;"
+   

[PATCH] D72841: [RFC] Add support for pragma float_control, to control precision and exception behavior at the source level

2020-01-20 Thread Melanie Blower via Phabricator via cfe-commits
mibintc marked 2 inline comments as done.
mibintc added a comment.

Added inline reply




Comment at: clang/lib/CodeGen/CodeGenFunction.cpp:111
 // the corresponding enum in the IR.
-static llvm::fp::RoundingMode ToConstrainedRoundingMD(
+llvm::fp::RoundingMode clang::ToConstrainedRoundingMD(
   LangOptions::FPRoundingModeKind Kind) {

sepavloff wrote:
> Is `clang::` necessary here? The file already has `using namespace clang;`.
Yes the clang:: is necessary here, without it there are undefined symbols at 
link time. the using modifies name lookup but not declaration. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72841



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


[PATCH] D73052: [clang-tidy] RenamerClangTidy now renames dependent member expr when the member can be resolved

2020-01-20 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added inline comments.



Comment at: clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp:282
+: DepMemberRef->getBaseType();
+CXXRecordDecl *Base = BaseType.getTypePtr()->getAsCXXRecordDecl();
+if (!Base)

can `Base` be a `const` pointer?

In which case will this pointer be a `nullptr`? Your test-cases seem to 
exercise only cases where `Base` is not-null.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-member-decl-usage.cpp:187
+};
+
+Derived AInt{};

Could you please provide a test-case with non-type template parameters as well?

Another question but maybe/most likely off topic: are how are member-pointers 
handled? Both for data and member-functions.
-> Maybe a test-case for such a situation would be good, as well? :)

Crème de la Crème would be if templated member-pointers are treated properly, 
too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73052



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


[PATCH] D73052: [clang-tidy] RenamerClangTidy now renames dependent member expr when the member can be resolved

2020-01-20 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 239150.
njames93 added a comment.

- replace auto when type isnt explicit


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73052

Files:
  clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-member-decl-usage.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-member-decl-usage.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-member-decl-usage.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-member-decl-usage.cpp
@@ -134,4 +134,58 @@
 void foo() {
   Container container;
 }
-}; // namespace CtorInits
+} // namespace CtorInits
+
+namespace resolved_dependance {
+template 
+class A0 {
+  int value;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for member 'value'
+  A0 =(const A0 ) {
+value = Other.value;   // A0
+this->value = Other.value; // A0
+// CHECK-FIXES:  {{^}}Value = Other.Value;   // A0
+// CHECK-FIXES-NEXT: {{^}}this->Value = Other.Value; // A0
+return *this;
+  }
+};
+
+template 
+class A1 {
+  int value;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for member 'value'
+  A1 =(const A1 ) {
+value = Other.value;   // A1
+this->value = Other.value; // A1
+// CHECK-FIXES:  {{^}}Value = Other.Value;   // A1
+// CHECK-FIXES-NEXT: {{^}}this->Value = Other.Value; // A1
+return *this;
+  }
+};
+//create some instances to check it works
+A1 AInt{};
+A1 BInt = AInt;
+A1 AUnsigned{};
+A1 BUnsigned = AUnsigned;
+} //namespace resolved_dependance
+
+namespace unresolved_dependance {
+template 
+struct DependentBase {
+  int depValue;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for member 'depValue'
+};
+
+template 
+struct Derived : DependentBase {
+  Derived =(const Derived ) {
+this->depValue = Other.depValue;
+// CHECK-FIXES-NOT: {{^}}this->DepValue = Other.DepValue;
+return *this;
+  }
+};
+
+Derived AInt{};
+Derived BInt = AInt;
+
+} //namespace unresolved_dependance
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -91,6 +91,11 @@
 Changes in existing checks
 ^^
 
+- Improved :doc:'readability-identifier-naming
+  ` check.
+
+  Now able to rename member references in class template definitions with 
+  explicit access.
 
 Renamed checks
 ^^
Index: clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
===
--- clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
+++ clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
@@ -106,20 +106,22 @@
  this);
   Finder->addMatcher(typeLoc().bind("typeLoc"), this);
   Finder->addMatcher(nestedNameSpecifierLoc().bind("nestedNameLoc"), this);
+  auto MemberOrDependent =
+  expr(eachOf(memberExpr().bind("memberExpr"),
+  cxxDependentScopeMemberExpr().bind("depMemberExpr")));
   Finder->addMatcher(
   functionDecl(unless(cxxMethodDecl(isImplicit())),
-   hasBody(forEachDescendant(memberExpr().bind("memberExpr",
+   hasBody(forEachDescendant(MemberOrDependent))),
   this);
   Finder->addMatcher(
-  cxxConstructorDecl(
-  unless(isImplicit()),
-  forEachConstructorInitializer(
-  allOf(isWritten(), withInitializer(forEachDescendant(
- memberExpr().bind("memberExpr")),
+  cxxConstructorDecl(unless(isImplicit()),
+ forEachConstructorInitializer(allOf(
+ isWritten(), withInitializer(forEachDescendant(
+  MemberOrDependent),
+  this);
+  Finder->addMatcher(
+  fieldDecl(hasInClassInitializer(forEachDescendant(MemberOrDependent))),
   this);
-  Finder->addMatcher(fieldDecl(hasInClassInitializer(
- forEachDescendant(memberExpr().bind("memberExpr",
- this);
 }
 
 void RenamerClangTidyCheck::registerPPCallbacks(
@@ -271,6 +273,29 @@
 return;
   }
 
+  if (const auto *DepMemberRef =
+  Result.Nodes.getNodeAs(
+  "depMemberExpr")) {
+QualType BaseType = DepMemberRef->isArrow()
+? DepMemberRef->getBaseType()->getPointeeType()
+: DepMemberRef->getBaseType();
+CXXRecordDecl *Base = BaseType.getTypePtr()->getAsCXXRecordDecl();
+if (!Base)
+  return;

[PATCH] D73052: [clang-tidy] RenamerClangTidy now renames dependent member expr when the member can be resolved

2020-01-20 Thread Nathan James via Phabricator via cfe-commits
njames93 created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
njames93 retitled this revision from "First Draft" to "[clang-tidy] 
RenamerClangTidy now renames dependent member expr when the member can be 
resolved".
njames93 added reviewers: aaron.ballman, JonasToth, logan-5.
Herald added a subscriber: xazax.hun.
njames93 edited the summary of this revision.

take this code

  template
  class A{
int value;
A& operator=(const A& Other){
  value = Other.value;
  this->value = Other.value;
  return *this;
}
  };

Any explicit access to value is handled by the AST as a 
CXXDependentScopeMemberExpr. However we have enough information to be able to 
resolve that the explicit access is refering to `int value;`. The old behaviour 
of the RenamerClangTidy logic would be to ignore this access, This patch 
addresses this shortfall


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73052

Files:
  clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-member-decl-usage.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-member-decl-usage.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-member-decl-usage.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-member-decl-usage.cpp
@@ -134,4 +134,58 @@
 void foo() {
   Container container;
 }
-}; // namespace CtorInits
+} // namespace CtorInits
+
+namespace resolved_dependance {
+template 
+class A0 {
+  int value;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for member 'value'
+  A0 =(const A0 ) {
+value = Other.value;   // A0
+this->value = Other.value; // A0
+// CHECK-FIXES:  {{^}}Value = Other.Value;   // A0
+// CHECK-FIXES-NEXT: {{^}}this->Value = Other.Value; // A0
+return *this;
+  }
+};
+
+template 
+class A1 {
+  int value;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for member 'value'
+  A1 =(const A1 ) {
+value = Other.value;   // A1
+this->value = Other.value; // A1
+// CHECK-FIXES:  {{^}}Value = Other.Value;   // A1
+// CHECK-FIXES-NEXT: {{^}}this->Value = Other.Value; // A1
+return *this;
+  }
+};
+//create some instances to check it works
+A1 AInt{};
+A1 BInt = AInt;
+A1 AUnsigned{};
+A1 BUnsigned = AUnsigned;
+} //namespace resolved_dependance
+
+namespace unresolved_dependance {
+template 
+struct DependentBase {
+  int depValue;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for member 'depValue'
+};
+
+template 
+struct Derived : DependentBase {
+  Derived =(const Derived ) {
+this->depValue = Other.depValue;
+// CHECK-FIXES-NOT: {{^}}this->DepValue = Other.DepValue;
+return *this;
+  }
+};
+
+Derived AInt{};
+Derived BInt = AInt;
+
+} //namespace unresolved_dependance
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -91,6 +91,11 @@
 Changes in existing checks
 ^^
 
+- Improved :doc:'readability-identifier-naming
+  ` check.
+
+  Now able to rename member references in class template definitions with 
+  explicit access.
 
 Renamed checks
 ^^
Index: clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
===
--- clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
+++ clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
@@ -106,20 +106,22 @@
  this);
   Finder->addMatcher(typeLoc().bind("typeLoc"), this);
   Finder->addMatcher(nestedNameSpecifierLoc().bind("nestedNameLoc"), this);
+  auto MemberOrDependent =
+  expr(eachOf(memberExpr().bind("memberExpr"),
+  cxxDependentScopeMemberExpr().bind("depMemberExpr")));
   Finder->addMatcher(
   functionDecl(unless(cxxMethodDecl(isImplicit())),
-   hasBody(forEachDescendant(memberExpr().bind("memberExpr",
+   hasBody(forEachDescendant(MemberOrDependent))),
   this);
   Finder->addMatcher(
-  cxxConstructorDecl(
-  unless(isImplicit()),
-  forEachConstructorInitializer(
-  allOf(isWritten(), withInitializer(forEachDescendant(
- memberExpr().bind("memberExpr")),
+  cxxConstructorDecl(unless(isImplicit()),
+ forEachConstructorInitializer(allOf(
+ isWritten(), withInitializer(forEachDescendant(
+  MemberOrDependent),
+  this);
+  Finder->addMatcher(
+  

[PATCH] D72932: [ARM] Follow AACPS standard for volatile bit-fields access width

2020-01-20 Thread Oliver Stannard (Linaro) via Phabricator via cfe-commits
ostannard added a comment.

Why are you doing this in CodeGen, rather than adjusting the existing layout 
code in CGRecordLowering? Doing it this way will result in 
AdjustAAPCSBitfieldLValue being called for every access to the bitfield, rather 
than just once. This is probably more fragile too, because it's spreading the 
logic across multiple parts of the codebase, and has to undo some of the layout 
done by CGRecordLowering.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72932



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


[PATCH] D71698: [AArch64][SVE] Add intrinsic for non-faulting loads

2020-01-20 Thread Kerry McLaughlin via Phabricator via cfe-commits
kmclaughlin updated this revision to Diff 239144.
kmclaughlin added a comment.

- Some minor changes to performSignExtendInRegCombine to address comments from 
@sdesmalen


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

https://reviews.llvm.org/D71698

Files:
  llvm/include/llvm/IR/IntrinsicsAArch64.td
  llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
  llvm/lib/Target/AArch64/AArch64ISelLowering.h
  llvm/lib/Target/AArch64/AArch64InstrInfo.td
  llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
  llvm/lib/Target/AArch64/SVEInstrFormats.td
  llvm/test/CodeGen/AArch64/sve-intrinsics-loads-nf.ll

Index: llvm/test/CodeGen/AArch64/sve-intrinsics-loads-nf.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/sve-intrinsics-loads-nf.ll
@@ -0,0 +1,182 @@
+; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve < %s | FileCheck %s
+
+define  @ldnf1b( %pg, i8* %a) {
+; CHECK-LABEL: ldnf1b:
+; CHECK: ldnf1b { z0.b }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldnf1.nxv16i8( %pg, i8* %a)
+  ret  %load
+}
+
+define  @ldnf1b_h( %pg, i8* %a) {
+; CHECK-LABEL: ldnf1b_h:
+; CHECK: ldnf1b { z0.h }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldnf1.nxv8i8( %pg, i8* %a)
+  %res = zext  %load to 
+  ret  %res
+}
+
+define  @ldnf1sb_h( %pg, i8* %a) {
+; CHECK-LABEL: ldnf1sb_h:
+; CHECK: ldnf1sb { z0.h }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldnf1.nxv8i8( %pg, i8* %a)
+  %res = sext  %load to 
+  ret  %res
+}
+
+define  @ldnf1h( %pg, i16* %a) {
+; CHECK-LABEL: ldnf1h:
+; CHECK: ldnf1h { z0.h }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldnf1.nxv8i16( %pg, i16* %a)
+  ret  %load
+}
+
+define  @ldnf1h_f16( %pg, half* %a) {
+; CHECK-LABEL: ldnf1h_f16:
+; CHECK: ldnf1h { z0.h }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldnf1.nxv8f16( %pg, half* %a)
+  ret  %load
+}
+
+define  @ldnf1b_s( %pg, i8* %a) {
+; CHECK-LABEL: ldnf1b_s:
+; CHECK: ldnf1b { z0.s }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldnf1.nxv4i8( %pg, i8* %a)
+  %res = zext  %load to 
+  ret  %res
+}
+
+define  @ldnf1sb_s( %pg, i8* %a) {
+; CHECK-LABEL: ldnf1sb_s:
+; CHECK: ldnf1sb { z0.s }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldnf1.nxv4i8( %pg, i8* %a)
+  %res = sext  %load to 
+  ret  %res
+}
+
+define  @ldnf1h_s( %pg, i16* %a) {
+; CHECK-LABEL: ldnf1h_s:
+; CHECK: ldnf1h { z0.s }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldnf1.nxv4i16( %pg, i16* %a)
+  %res = zext  %load to 
+  ret  %res
+}
+
+define  @ldnf1sh_s( %pg, i16* %a) {
+; CHECK-LABEL: ldnf1sh_s:
+; CHECK: ldnf1sh { z0.s }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldnf1.nxv4i16( %pg, i16* %a)
+  %res = sext  %load to 
+  ret  %res
+}
+
+define  @ldnf1w( %pg, i32* %a) {
+; CHECK-LABEL: ldnf1w:
+; CHECK: ldnf1w { z0.s }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldnf1.nxv4i32( %pg, i32* %a)
+  ret  %load
+}
+
+define  @ldnf1w_f32( %pg, float* %a) {
+; CHECK-LABEL: ldnf1w_f32:
+; CHECK: ldnf1w { z0.s }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldnf1.nxv4f32( %pg, float* %a)
+  ret  %load
+}
+
+define  @ldnf1b_d( %pg, i8* %a) {
+; CHECK-LABEL: ldnf1b_d:
+; CHECK: ldnf1b { z0.d }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldnf1.nxv2i8( %pg, i8* %a)
+  %res = zext  %load to 
+  ret  %res
+}
+
+define  @ldnf1sb_d( %pg, i8* %a) {
+; CHECK-LABEL: ldnf1sb_d:
+; CHECK: ldnf1sb { z0.d }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldnf1.nxv2i8( %pg, i8* %a)
+  %res = sext  %load to 
+  ret  %res
+}
+
+define  @ldnf1h_d( %pg, i16* %a) {
+; CHECK-LABEL: ldnf1h_d:
+; CHECK: ldnf1h { z0.d }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldnf1.nxv2i16( %pg, i16* %a)
+  %res = zext  %load to 
+  ret  %res
+}
+
+define  @ldnf1sh_d( %pg, i16* %a) {
+; CHECK-LABEL: ldnf1sh_d:
+; CHECK: ldnf1sh { z0.d }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldnf1.nxv2i16( %pg, i16* %a)
+  %res = sext  %load to 
+  ret  %res
+}
+
+define  @ldnf1w_d( %pg, i32* %a) {
+; CHECK-LABEL: ldnf1w_d:
+; CHECK: ldnf1w { z0.d }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldnf1.nxv2i32( %pg, i32* %a)
+  %res = zext  %load to 
+  ret  %res
+}
+
+define  @ldnf1sw_d( %pg, i32* %a) {
+; CHECK-LABEL: ldnf1sw_d:
+; CHECK: ldnf1sw { z0.d }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldnf1.nxv2i32( %pg, i32* %a)
+  %res = sext  %load to 
+  ret  %res
+}
+
+define  @ldnf1d( %pg, i64* %a) {
+; CHECK-LABEL: ldnf1d:
+; CHECK: ldnf1d { z0.d }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldnf1.nxv2i64( %pg, i64* %a)
+  ret  %load
+}
+
+define  @ldnf1d_f64( %pg, double* %a) {
+; CHECK-LABEL: ldnf1d_f64:
+; CHECK: ldnf1d { z0.d }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  

[PATCH] D73007: [Sema] Avoid Wrange-loop-analysis false positives

2020-01-20 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added a subscriber: hans.
xbolva00 added a comment.

Yes, but minimal fix is better for release branch, so @hans should merge it.

Handling your case probably needs more work and patches..


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73007



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


[PATCH] D71566: New checks for fortified sprintf

2020-01-20 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:745-746
+def warn_fortify_source_format_overflow : Warning<
+  "'%0' will always overflow; destination buffer has size %1,"
+  " but format string expands to at least %2">,
+  InGroup;

I'm fine with the current wording because it's consistent with the existing 
diagnostics, but I wish we would quantify the size with units in these 
diagnostics. (e.g., mention that this is measured in bytes as opposed to 
anything else).



Comment at: clang/lib/Sema/SemaChecking.cpp:405-406
+  bool HandlePrintfSpecifier(const analyze_printf::PrintfSpecifier ,
+ const char *startSpecifier,
+ unsigned specifierLen) override {
+const analyze_format_string::OptionalAmount  = FS.getFieldWidth();

Naming nits: `StartSpecifier` and `SpecifierLen`. It looks like 
`startSpecifier` isn't used and the name can probably just be dropped.



Comment at: clang/lib/Sema/SemaChecking.cpp:436-437
+switch (FS.getConversionSpecifier().getKind()) {
+case analyze_format_string::ConversionSpecifier::pArg: // leading 0x
+  Size += 3;
+  break;

Why is size incremented by 3 here instead of 2 as above with a leading 0x?



Comment at: clang/lib/Sema/SemaChecking.cpp:448
+}
+Size -= specifierLen;
+return true;

Guard against wraparound?



Comment at: clang/lib/Sema/SemaChecking.cpp:489
+if (auto *Format = dyn_cast(FormatExpr)) {
+
+  if (!Format->isAscii() && !Format->isUTF8())

Spurious whitespace.



Comment at: clang/lib/Sema/SemaChecking.cpp:490
+
+  if (!Format->isAscii() && !Format->isUTF8())
+return;

We can handle UTF-8 format strings even when they contain non-ASCII characters?



Comment at: clang/lib/Sema/SemaChecking.cpp:8237
   H.DoneProcessing();
+
   } else if (Type == Sema::FST_Scanf) {

Spurious whitespace change?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71566



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


[clang] 3663563 - [OPENMP]Fix PR44578: crash in target construct with captured global.

2020-01-20 Thread Alexey Bataev via cfe-commits

Author: Alexey Bataev
Date: 2020-01-20T11:10:17-05:00
New Revision: 366356361cf3abf97fbcfe9a0467b1ed1610401f

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

LOG: [OPENMP]Fix PR44578: crash in target construct with captured global.

Target regions have implicit outer region which may erroneously capture
some globals when it should not. It may lead to a compiler crash at the
compile time.

Added: 


Modified: 
clang/include/clang/Sema/Sema.h
clang/lib/Sema/SemaExpr.cpp
clang/lib/Sema/SemaOpenMP.cpp
clang/test/OpenMP/target_depend_codegen.cpp
clang/test/OpenMP/target_messages.cpp
clang/test/OpenMP/target_parallel_depend_codegen.cpp
clang/test/OpenMP/target_parallel_for_depend_codegen.cpp
clang/test/OpenMP/target_parallel_for_simd_depend_codegen.cpp
clang/test/OpenMP/target_simd_depend_codegen.cpp
clang/test/OpenMP/target_teams_depend_codegen.cpp
clang/test/OpenMP/target_teams_distribute_depend_codegen.cpp
clang/test/OpenMP/target_teams_distribute_parallel_for_depend_codegen.cpp

clang/test/OpenMP/target_teams_distribute_parallel_for_simd_depend_codegen.cpp
clang/test/OpenMP/target_teams_distribute_simd_depend_codegen.cpp

Removed: 




diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 2fb758bc75d6..6e3ae96b3afc 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -9681,7 +9681,8 @@ class Sema final {
   /// Check if the specified variable is captured  by 'target' directive.
   /// \param Level Relative level of nested OpenMP construct for that the check
   /// is performed.
-  bool isOpenMPTargetCapturedDecl(const ValueDecl *D, unsigned Level) const;
+  bool isOpenMPTargetCapturedDecl(const ValueDecl *D, unsigned Level,
+  unsigned CaptureLevel) const;
 
   ExprResult PerformOpenMPImplicitIntegerConversion(SourceLocation OpLoc,
 Expr *Op);

diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index ea4b93ee6a5a..67b68ffb5eda 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -16280,8 +16280,10 @@ bool Sema::tryCaptureVariable(
   captureVariablyModifiedType(Context, QTy, OuterRSI);
 }
   }
-  bool IsTargetCap = !IsOpenMPPrivateDecl &&
- isOpenMPTargetCapturedDecl(Var, RSI->OpenMPLevel);
+  bool IsTargetCap =
+  !IsOpenMPPrivateDecl &&
+  isOpenMPTargetCapturedDecl(Var, RSI->OpenMPLevel,
+ RSI->OpenMPCaptureLevel);
   // When we detect target captures we are looking from inside the
   // target region, therefore we need to propagate the capture from the
   // enclosing region. Therefore, the capture is not initially nested.

diff  --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 3fce0e27e9b3..72afe63749ac 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -31,6 +31,7 @@
 #include "clang/Sema/SemaInternal.h"
 #include "llvm/ADT/IndexedMap.h"
 #include "llvm/ADT/PointerEmbeddedInt.h"
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/Frontend/OpenMP/OMPConstants.h"
 using namespace clang;
 using namespace llvm::omp;
@@ -2010,7 +2011,23 @@ VarDecl *Sema::isOpenMPCapturedDecl(ValueDecl *D, bool 
CheckScopeInfo,
   //
   if (OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(VD))
 return nullptr;
-  return VD;
+  CapturedRegionScopeInfo *CSI = nullptr;
+  for (FunctionScopeInfo *FSI : llvm::drop_begin(
+   llvm::reverse(FunctionScopes),
+   CheckScopeInfo ? (FunctionScopes.size() - (StopAt + 1)) : 0)) {
+if (!isa(FSI))
+  return nullptr;
+if (auto *RSI = dyn_cast(FSI))
+  if (RSI->CapRegionKind == CR_OpenMP) {
+CSI = RSI;
+break;
+  }
+  }
+  SmallVector Regions;
+  getOpenMPCaptureRegions(Regions,
+  DSAStack->getDirective(CSI->OpenMPLevel));
+  if (Regions[CSI->OpenMPCaptureLevel] != OMPD_task)
+return VD;
 }
   }
 
@@ -2151,15 +2168,18 @@ void Sema::setOpenMPCaptureKind(FieldDecl *FD, const 
ValueDecl *D,
 FD->addAttr(OMPCaptureKindAttr::CreateImplicit(Context, OMPC));
 }
 
-bool Sema::isOpenMPTargetCapturedDecl(const ValueDecl *D,
-  unsigned Level) const {
+bool Sema::isOpenMPTargetCapturedDecl(const ValueDecl *D, unsigned Level,
+  unsigned CaptureLevel) const {
   assert(LangOpts.OpenMP && "OpenMP is not allowed");
   // Return true if the current level is no longer 

[PATCH] D73007: [Sema] Avoid Wrange-loop-analysis false positives

2020-01-20 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert added a comment.

As I wrote on the bug , I think we 
should only suppress one of the warnings in templates (and maybe always):

  :18:22: warning: loop variable '_' is always a copy because the range 
of type 'const Rng' does not return a reference [-Wrange-loop-analysis]
  for (const auto& _ : t)
   ^
  :26:5: note: in instantiation of function template specialization 
'f' requested here
  f(Rng{});
  ^
  :18:10: note: use non-reference type 'int'
  for (const auto& _ : t)
   ^~~

However, I think we shouldn't suppress the other:

  :18:21: warning: loop variable '_' of type 'const X' creates a copy 
from type 'const X' [-Wrange-loop-analysis]
  for (const auto _ : t)
  ^
  :25:5: note: in instantiation of function template specialization 
'f' requested here
  f(array);
  ^
  :18:10: note: use reference type 'const X &' to prevent copying
  for (const auto _ : t)
   ^~
  &

This generates a bunch of unneeded non-trivial copies, and I think we want to 
warn about that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73007



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


patch via mailing list: Use getLocation() in too few/many arguments diagnostic

2020-01-20 Thread John Marshall via cfe-commits
This small patch improves the diagnostics when calling a function with the 
wrong number of arguments. For example, given

int
foo(int a, int b);

int bar() { return foo(1); }

The existing compiler shows the error message and a note for "foo declared 
here" showing only the "int" line. Ideally it would show the line containing 
the word "foo" instead, which it does after this patch. Also if the function 
declaration starts with some incidental macro, a trace of macro expansion is 
shown which is likely irrelevant. See for example 
https://github.com/samtools/htslib/issues/1013 and PR#23564.

I have not contributed to LLVM before and I am unfamiliar with the difference 
between getBeginLoc() and getLocation() and the implications of using each. 
However this patch does fix PR#23564 and perhaps this fix would be mostly a 
no-brainer for those who are familiar with the code and these two location 
functions in particular?

Thanks,

John


commit 12c8979abaf40aa76c6769d6270f3565d71f3011
Author: John Marshall 
Date:   Mon Jan 20 14:58:14 2020 +

Use getLocation() in too few/many arguments diagnostic

Use the more accurate location when emitting the location of the
function being called's prototype in diagnostics emitted when calling
a function with an incorrect number of arguments.

In particular, avoids showing a trace of irrelevant macro expansions
for "MY_EXPORT static int AwesomeFunction(int, int);". Fixes PR#23564.

diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index ea4b93ee6a5..19dfc7c7fd7 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -5194,7 +5194,7 @@ Sema::ConvertArgumentsForCall(CallExpr *Call, Expr *Fn,
 
   // Emit the location of the prototype.
   if (!TC && FDecl && !FDecl->getBuiltinID() && !IsExecConfig)
-Diag(FDecl->getBeginLoc(), diag::note_callee_decl) << FDecl;
+Diag(FDecl->getLocation(), diag::note_callee_decl) << FDecl;
 
   return true;
 }
@@ -5239,7 +5239,7 @@ Sema::ConvertArgumentsForCall(CallExpr *Call, Expr *Fn,
 
   // Emit the location of the prototype.
   if (!TC && FDecl && !FDecl->getBuiltinID() && !IsExecConfig)
-Diag(FDecl->getBeginLoc(), diag::note_callee_decl) << FDecl;
+Diag(FDecl->getLocation(), diag::note_callee_decl) << FDecl;
 
   // This deletes the extra arguments.
   Call->shrinkNumArgs(NumParams);

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


[PATCH] D73026: clang-format: [JS] fix `??` opreator wrapping.

2020-01-20 Thread Martin Probst via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4c9d6914453d: clang-format: [JS] fix `??` opreator wrapping. 
(authored by mprobst).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73026

Files:
  clang/lib/Format/FormatTokenLexer.cpp
  clang/unittests/Format/FormatTestJS.cpp


Index: clang/unittests/Format/FormatTestJS.cpp
===
--- clang/unittests/Format/FormatTestJS.cpp
+++ clang/unittests/Format/FormatTestJS.cpp
@@ -2294,6 +2294,11 @@
 
 TEST_F(FormatTestJS, NullishCoalescingOperator) {
   verifyFormat("const val = something ?? 'some other default';\n");
+  verifyFormat(
+  "const val = something ?? otherDefault ??\n"
+  "evenMore ?? evenMore;\n",
+  "const val = something ?? otherDefault ?? evenMore ?? evenMore;\n",
+  getGoogleJSStyleWithColumns(40));
 }
 
 TEST_F(FormatTestJS, Conditional) {
Index: clang/lib/Format/FormatTokenLexer.cpp
===
--- clang/lib/Format/FormatTokenLexer.cpp
+++ clang/lib/Format/FormatTokenLexer.cpp
@@ -120,8 +120,11 @@
   Tokens.back()->Tok.setKind(tok::starequal);
   return;
 }
-if (tryMergeTokens(JSNullishOperator, TT_JsNullishCoalescingOperator))
+if (tryMergeTokens(JSNullishOperator, TT_JsNullishCoalescingOperator)) {
+  // Treat like the "||" operator (as opposed to the ternary ?).
+  Tokens.back()->Tok.setKind(tok::pipepipe);
   return;
+}
 if (tryMergeTokens(JSNullPropagatingOperator,
TT_JsNullPropagatingOperator)) {
   // Treat like a regular "." access.


Index: clang/unittests/Format/FormatTestJS.cpp
===
--- clang/unittests/Format/FormatTestJS.cpp
+++ clang/unittests/Format/FormatTestJS.cpp
@@ -2294,6 +2294,11 @@
 
 TEST_F(FormatTestJS, NullishCoalescingOperator) {
   verifyFormat("const val = something ?? 'some other default';\n");
+  verifyFormat(
+  "const val = something ?? otherDefault ??\n"
+  "evenMore ?? evenMore;\n",
+  "const val = something ?? otherDefault ?? evenMore ?? evenMore;\n",
+  getGoogleJSStyleWithColumns(40));
 }
 
 TEST_F(FormatTestJS, Conditional) {
Index: clang/lib/Format/FormatTokenLexer.cpp
===
--- clang/lib/Format/FormatTokenLexer.cpp
+++ clang/lib/Format/FormatTokenLexer.cpp
@@ -120,8 +120,11 @@
   Tokens.back()->Tok.setKind(tok::starequal);
   return;
 }
-if (tryMergeTokens(JSNullishOperator, TT_JsNullishCoalescingOperator))
+if (tryMergeTokens(JSNullishOperator, TT_JsNullishCoalescingOperator)) {
+  // Treat like the "||" operator (as opposed to the ternary ?).
+  Tokens.back()->Tok.setKind(tok::pipepipe);
   return;
+}
 if (tryMergeTokens(JSNullPropagatingOperator,
TT_JsNullPropagatingOperator)) {
   // Treat like a regular "." access.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 4c9d691 - clang-format: [JS] fix `??` opreator wrapping.

2020-01-20 Thread Martin Probst via cfe-commits

Author: Martin Probst
Date: 2020-01-20T17:07:14+01:00
New Revision: 4c9d6914453d970b7b8202b7efd7524b2f0a72ac

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

LOG: clang-format: [JS] fix `??` opreator wrapping.

Summary:
clang-format currently treats the nullish coalescing operator `??` like
the ternary operator. That causes multiple nullish terms to be each
indented relative to the last `??`, as they would in a ternary.

The `??` operator is often used in chains though, and as such more
similar to other binary operators, such as `||`. So to fix the indent,
set its token type to `||`, so it inherits the same treatment.

This opens up the question of operator precedence. However, `??` is
required to be parenthesized when mixed with `||` and `&&`, so this is
not a problem that can come up in syntactically legal code.

Reviewers: krasimir

Subscribers: cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/lib/Format/FormatTokenLexer.cpp
clang/unittests/Format/FormatTestJS.cpp

Removed: 




diff  --git a/clang/lib/Format/FormatTokenLexer.cpp 
b/clang/lib/Format/FormatTokenLexer.cpp
index ef20ba884fb3..9c9fee2b0c32 100644
--- a/clang/lib/Format/FormatTokenLexer.cpp
+++ b/clang/lib/Format/FormatTokenLexer.cpp
@@ -120,8 +120,11 @@ void FormatTokenLexer::tryMergePreviousTokens() {
   Tokens.back()->Tok.setKind(tok::starequal);
   return;
 }
-if (tryMergeTokens(JSNullishOperator, TT_JsNullishCoalescingOperator))
+if (tryMergeTokens(JSNullishOperator, TT_JsNullishCoalescingOperator)) {
+  // Treat like the "||" operator (as opposed to the ternary ?).
+  Tokens.back()->Tok.setKind(tok::pipepipe);
   return;
+}
 if (tryMergeTokens(JSNullPropagatingOperator,
TT_JsNullPropagatingOperator)) {
   // Treat like a regular "." access.

diff  --git a/clang/unittests/Format/FormatTestJS.cpp 
b/clang/unittests/Format/FormatTestJS.cpp
index ffeb53d9a33c..ef3c6361355a 100644
--- a/clang/unittests/Format/FormatTestJS.cpp
+++ b/clang/unittests/Format/FormatTestJS.cpp
@@ -2294,6 +2294,11 @@ TEST_F(FormatTestJS, NullPropagatingOperator) {
 
 TEST_F(FormatTestJS, NullishCoalescingOperator) {
   verifyFormat("const val = something ?? 'some other default';\n");
+  verifyFormat(
+  "const val = something ?? otherDefault ??\n"
+  "evenMore ?? evenMore;\n",
+  "const val = something ?? otherDefault ?? evenMore ?? evenMore;\n",
+  getGoogleJSStyleWithColumns(40));
 }
 
 TEST_F(FormatTestJS, Conditional) {



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


[PATCH] D73035: [clangd] Avoid redundant testcases in rename unittest, NFC.

2020-01-20 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3de9a5db629a: [clangd] Avoid redundant testcases in rename 
unittest, NFC. (authored by hokein).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73035

Files:
  clang-tools-extra/clangd/refactor/Rename.cpp
  clang-tools-extra/clangd/unittests/RenameTests.cpp


Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -722,7 +722,7 @@
 void onDiagnosticsReady(PathRef File,
 std::vector Diagnostics) override {}
   } DiagConsumer;
-  // rename is runnning on the "^" point in FooH, and "[[]]" ranges are the
+  // rename is runnning on all "^" points in FooH, and "[[]]" ranges are the
   // expected rename occurrences.
   struct Case {
 llvm::StringRef FooH;
@@ -763,28 +763,10 @@
   )cpp",
   },
   {
-  // Constructor.
+  // rename on constructor and destructor.
   R"cpp(
 class [[Foo]] {
   [[^Foo]]();
-  ~[[Foo]]();
-};
-  )cpp",
-  R"cpp(
-#include "foo.h"
-[[Foo]]::[[Foo]]() {}
-[[Foo]]::~[[Foo]]() {}
-
-void func() {
-  [[Foo]] foo;
-}
-  )cpp",
-  },
-  {
-  // Destructor (selecting before the identifier).
-  R"cpp(
-class [[Foo]] {
-  [[Foo]]();
   ~[[Foo^]]();
 };
   )cpp",
@@ -891,12 +873,15 @@
 runAddDocument(Server, FooCCPath, FooCC.code());
 
 llvm::StringRef NewName = "NewName";
-auto FileEditsList =
-llvm::cantFail(runRename(Server, FooHPath, FooH.point(), NewName));
-EXPECT_THAT(applyEdits(std::move(FileEditsList)),
-UnorderedElementsAre(
-Pair(Eq(FooHPath), Eq(expectedResult(T.FooH, NewName))),
-Pair(Eq(FooCCPath), Eq(expectedResult(T.FooCC, 
NewName);
+for (const auto  : FooH.points()) {
+  auto FileEditsList =
+  llvm::cantFail(runRename(Server, FooHPath, RenamePos, NewName));
+  EXPECT_THAT(
+  applyEdits(std::move(FileEditsList)),
+  UnorderedElementsAre(
+  Pair(Eq(FooHPath), Eq(expectedResult(T.FooH, NewName))),
+  Pair(Eq(FooCCPath), Eq(expectedResult(T.FooCC, NewName);
+}
   }
 }
 
Index: clang-tools-extra/clangd/refactor/Rename.cpp
===
--- clang-tools-extra/clangd/refactor/Rename.cpp
+++ clang-tools-extra/clangd/refactor/Rename.cpp
@@ -215,7 +215,7 @@
   // getUSRsForDeclaration will find other related symbols, e.g. virtual and 
its
   // overriddens, primary template and all explicit specializations.
   // FIXME: Get rid of the remaining tooling APIs.
-  const auto RenameDecl =
+  const auto *RenameDecl =
   ND.getDescribedTemplate() ? ND.getDescribedTemplate() : 
   std::vector RenameUSRs =
   tooling::getUSRsForDeclaration(RenameDecl, AST.getASTContext());


Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -722,7 +722,7 @@
 void onDiagnosticsReady(PathRef File,
 std::vector Diagnostics) override {}
   } DiagConsumer;
-  // rename is runnning on the "^" point in FooH, and "[[]]" ranges are the
+  // rename is runnning on all "^" points in FooH, and "[[]]" ranges are the
   // expected rename occurrences.
   struct Case {
 llvm::StringRef FooH;
@@ -763,28 +763,10 @@
   )cpp",
   },
   {
-  // Constructor.
+  // rename on constructor and destructor.
   R"cpp(
 class [[Foo]] {
   [[^Foo]]();
-  ~[[Foo]]();
-};
-  )cpp",
-  R"cpp(
-#include "foo.h"
-[[Foo]]::[[Foo]]() {}
-[[Foo]]::~[[Foo]]() {}
-
-void func() {
-  [[Foo]] foo;
-}
-  )cpp",
-  },
-  {
-  // Destructor (selecting before the identifier).
-  R"cpp(
-class [[Foo]] {
-  [[Foo]]();
   ~[[Foo^]]();
 };
   )cpp",
@@ -891,12 +873,15 @@
 runAddDocument(Server, FooCCPath, FooCC.code());
 
 llvm::StringRef NewName = "NewName";
-auto FileEditsList =
-llvm::cantFail(runRename(Server, FooHPath, FooH.point(), NewName));
-EXPECT_THAT(applyEdits(std::move(FileEditsList)),
-UnorderedElementsAre(
-Pair(Eq(FooHPath), Eq(expectedResult(T.FooH, NewName))),
-Pair(Eq(FooCCPath), Eq(expectedResult(T.FooCC, NewName);
+for (const auto  : FooH.points()) {
+

[clang-tools-extra] 3de9a5d - [clangd] Avoid redundant testcases in rename unittest, NFC.

2020-01-20 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2020-01-20T17:01:05+01:00
New Revision: 3de9a5db629ac9d633576513d025a8f038a3cdec

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

LOG: [clangd] Avoid redundant testcases in rename unittest, NFC.

Reviewers: kadircet

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

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clangd/refactor/Rename.cpp
clang-tools-extra/clangd/unittests/RenameTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/refactor/Rename.cpp 
b/clang-tools-extra/clangd/refactor/Rename.cpp
index 80917e1abb27..9518d848eff5 100644
--- a/clang-tools-extra/clangd/refactor/Rename.cpp
+++ b/clang-tools-extra/clangd/refactor/Rename.cpp
@@ -215,7 +215,7 @@ std::vector 
findOccurrencesWithinFile(ParsedAST ,
   // getUSRsForDeclaration will find other related symbols, e.g. virtual and 
its
   // overriddens, primary template and all explicit specializations.
   // FIXME: Get rid of the remaining tooling APIs.
-  const auto RenameDecl =
+  const auto *RenameDecl =
   ND.getDescribedTemplate() ? ND.getDescribedTemplate() : 
   std::vector RenameUSRs =
   tooling::getUSRsForDeclaration(RenameDecl, AST.getASTContext());

diff  --git a/clang-tools-extra/clangd/unittests/RenameTests.cpp 
b/clang-tools-extra/clangd/unittests/RenameTests.cpp
index 6ced22bf3515..80930b9096d4 100644
--- a/clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ b/clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -722,7 +722,7 @@ TEST(CrossFileRenameTests, WithUpToDateIndex) {
 void onDiagnosticsReady(PathRef File,
 std::vector Diagnostics) override {}
   } DiagConsumer;
-  // rename is runnning on the "^" point in FooH, and "[[]]" ranges are the
+  // rename is runnning on all "^" points in FooH, and "[[]]" ranges are the
   // expected rename occurrences.
   struct Case {
 llvm::StringRef FooH;
@@ -763,28 +763,10 @@ TEST(CrossFileRenameTests, WithUpToDateIndex) {
   )cpp",
   },
   {
-  // Constructor.
+  // rename on constructor and destructor.
   R"cpp(
 class [[Foo]] {
   [[^Foo]]();
-  ~[[Foo]]();
-};
-  )cpp",
-  R"cpp(
-#include "foo.h"
-[[Foo]]::[[Foo]]() {}
-[[Foo]]::~[[Foo]]() {}
-
-void func() {
-  [[Foo]] foo;
-}
-  )cpp",
-  },
-  {
-  // Destructor (selecting before the identifier).
-  R"cpp(
-class [[Foo]] {
-  [[Foo]]();
   ~[[Foo^]]();
 };
   )cpp",
@@ -891,12 +873,15 @@ TEST(CrossFileRenameTests, WithUpToDateIndex) {
 runAddDocument(Server, FooCCPath, FooCC.code());
 
 llvm::StringRef NewName = "NewName";
-auto FileEditsList =
-llvm::cantFail(runRename(Server, FooHPath, FooH.point(), NewName));
-EXPECT_THAT(applyEdits(std::move(FileEditsList)),
-UnorderedElementsAre(
-Pair(Eq(FooHPath), Eq(expectedResult(T.FooH, NewName))),
-Pair(Eq(FooCCPath), Eq(expectedResult(T.FooCC, 
NewName);
+for (const auto  : FooH.points()) {
+  auto FileEditsList =
+  llvm::cantFail(runRename(Server, FooHPath, RenamePos, NewName));
+  EXPECT_THAT(
+  applyEdits(std::move(FileEditsList)),
+  UnorderedElementsAre(
+  Pair(Eq(FooHPath), Eq(expectedResult(T.FooH, NewName))),
+  Pair(Eq(FooCCPath), Eq(expectedResult(T.FooCC, NewName);
+}
   }
 }
 



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


[PATCH] D71607: [clang-tidy] Add unsigned subtraction warning, with suggestion to convert to unsigned literals.

2020-01-20 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D71607#1828055 , @sorenj wrote:

> Okay, but as you can see the majority of my test cases are intentionally 
> false negatives `- -Wsign-conversion` triggers so often than many people 
> don't use it.


Then we should be addressing that issue rather than duplicating the 
functionality, no?

> And, `unsigned x = 2;` does not trigger a sign conversion warning despite 
> there being a conversion form 2 to 2u.

That should *not* trigger a sign conversion warning because there is no sign 
conversion. We know the exact value of the RHS and can see that it does not 
change signs.

> This check is targeting a very specific but frequent case of functions that 
> do not guard against containers that might be empty.

We should consider a better name for the check then and limit its utility to 
those cases. Truthfully, I think that check would be quite useful, but it would 
almost certainly be a clang static analyzer check to handle control and data 
flow. e.g., such a check should be able to handle these situations:

  size_t count1 = some_container.size() - 1; // Bad if empty
  size_t num_elements = some_container.size();
  size_t count2 = num_elements - 1; // Bad if empty
  if (num_element)
size_t count3 = num_elements - 1; // Just fine
  size_t count4 = std::size(some_container) - 1; // Bad if empty
  size_t count5 = std::distance(some_container.begin(), some_container.end()) - 
1; // Bad if empty? (Note, there's no type-based sign conversion here)
  
  num_elements + 1;
  size_t count6 = num_elements - 1; // Just fine



> Regarding the false positives - I think you are focusing on the semantics of 
> the fix-it which is literally a no-op. The code before and after may be just 
> as wrong, but the salience of the implied conversion is a bit higher. Maybe 
> that's not a good idea for a change that may be applied automatically, even 
> if safe.
> 
> In short I'm not sure if you are objecting the principle here, or the 
> implementation.

A bit of both. I don't think clang-tidy should get a -Wsign-conversion check -- 
the frontend handles that, and if there are deficiencies with that handling, we 
should address those. However, a check that's focused solely on container and 
container-like situations where an empty container would cause problems seems 
like a very interesting check that has value. I'm not certain that implementing 
it in clang-tidy would catch the cases with a reasonable false-positive rate, 
but it seems like it wouldn't be bad as a static analyzer check instead.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71607



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


[PATCH] D73007: [Sema] Avoid Wrange-loop-analysis false positives

2020-01-20 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! Do you think this should also be pushed onto the release branch?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73007



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


[PATCH] D72488: [clang-tidy] Add check for CERT-OOP57-CPP

2020-01-20 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Btw, do you need me to commit this on your behalf, or have you obtained your 
commit privileges?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72488



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


[PATCH] D71512: [clang-format] Fix short block when braking after control statement

2020-01-20 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay requested changes to this revision.
MyDeveloperDay added a comment.
This revision now requires changes to proceed.

In D71512#1815512 , @Bouska wrote:

> Ping @MyDeveloperDay @klimek







Comment at: clang/lib/Format/UnwrappedLineFormatter.cpp:344
-  return MergedLines;
-}
 // Don't merge block with left brace wrapped after ObjC special blocks

I just can't understand how we are free to just remove a chunk of code. Why is 
this not being some sort of 


```
if (Style.AllowShortBlocksOnASingleLine)
```

You are just not giving a convincing argument that this is a safe change 
without us having to go in a debug the original problem ourselves.



Comment at: clang/unittests/Format/FormatTest.cpp:662
"{\n"
-   "  ff();\n"
"}",

I'm just not comfortable with changing tests, code can still be written in the 
way it was before, and I cannot tell what it would now be, I believe tests 
should be additive


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

https://reviews.llvm.org/D71512



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


[PATCH] D72755: [RISCV] Pass target-abi via module flag metadata

2020-01-20 Thread Sam Elliott via Phabricator via cfe-commits
lenary accepted this revision.
lenary added a comment.
This revision is now accepted and ready to land.

LGTM, Thank You!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72755



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


[PATCH] D71451: Support to emit extern variables debuginfo with "-fstandalone-debug"

2020-01-20 Thread Jaydeep Chauhan via Phabricator via cfe-commits
Jac1494 updated this revision to Diff 239115.

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

https://reviews.llvm.org/D71451

Files:
  clang/include/clang/Basic/TargetInfo.h
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGen/debug-info-extern-variable-basic.c
  clang/test/CodeGen/debug-info-extern-variable-unused.c


Index: clang/test/CodeGen/debug-info-extern-variable-unused.c
===
--- /dev/null
+++ clang/test/CodeGen/debug-info-extern-variable-unused.c
@@ -0,0 +1,10 @@
+// RUN: %clang -emit-llvm -S -g -fstandalone-debug %s -o - | FileCheck %s
+
+extern int i;
+int foo() {
+  extern int j;
+  return 0;
+}
+
+// CHECK-NOT: distinct !DIGlobalVariable(name: "i"
+// CHECK-NOT: distinct !DIGlobalVariable(name: "j"
Index: clang/test/CodeGen/debug-info-extern-variable-basic.c
===
--- /dev/null
+++ clang/test/CodeGen/debug-info-extern-variable-basic.c
@@ -0,0 +1,10 @@
+// RUN: %clang -emit-llvm -S -g -fstandalone-debug %s -o - | FileCheck %s
+
+extern int i;
+int foo() {
+  extern int j;
+  return i+j;
+}
+
+// CHECK: distinct !DIGlobalVariable(name: "i"
+// CHECK: distinct !DIGlobalVariable(name: "j"
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -4619,6 +4619,8 @@
   assert(CGM.getCodeGenOpts().hasReducedDebugInfo());
   if (D->hasAttr())
 return;
+  if (DebugKind < clang::codegenoptions::FullDebugInfo)
+return;
 
   auto Align = getDeclAlignIfRequired(D, CGM.getContext());
   llvm::DIFile *Unit = getOrCreateFile(D->getLocation());
Index: clang/include/clang/Basic/TargetInfo.h
===
--- clang/include/clang/Basic/TargetInfo.h
+++ clang/include/clang/Basic/TargetInfo.h
@@ -1388,7 +1388,7 @@
   virtual void setAuxTarget(const TargetInfo *Aux) {}
 
   /// Whether target allows debuginfo types for decl only variables.
-  virtual bool allowDebugInfoForExternalVar() const { return false; }
+  virtual bool allowDebugInfoForExternalVar() const { return true; }
 
 protected:
   /// Copy type and layout related info.


Index: clang/test/CodeGen/debug-info-extern-variable-unused.c
===
--- /dev/null
+++ clang/test/CodeGen/debug-info-extern-variable-unused.c
@@ -0,0 +1,10 @@
+// RUN: %clang -emit-llvm -S -g -fstandalone-debug %s -o - | FileCheck %s
+
+extern int i;
+int foo() {
+  extern int j;
+  return 0;
+}
+
+// CHECK-NOT: distinct !DIGlobalVariable(name: "i"
+// CHECK-NOT: distinct !DIGlobalVariable(name: "j"
Index: clang/test/CodeGen/debug-info-extern-variable-basic.c
===
--- /dev/null
+++ clang/test/CodeGen/debug-info-extern-variable-basic.c
@@ -0,0 +1,10 @@
+// RUN: %clang -emit-llvm -S -g -fstandalone-debug %s -o - | FileCheck %s
+
+extern int i;
+int foo() {
+  extern int j;
+  return i+j;
+}
+
+// CHECK: distinct !DIGlobalVariable(name: "i"
+// CHECK: distinct !DIGlobalVariable(name: "j"
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -4619,6 +4619,8 @@
   assert(CGM.getCodeGenOpts().hasReducedDebugInfo());
   if (D->hasAttr())
 return;
+  if (DebugKind < clang::codegenoptions::FullDebugInfo)
+return;
 
   auto Align = getDeclAlignIfRequired(D, CGM.getContext());
   llvm::DIFile *Unit = getOrCreateFile(D->getLocation());
Index: clang/include/clang/Basic/TargetInfo.h
===
--- clang/include/clang/Basic/TargetInfo.h
+++ clang/include/clang/Basic/TargetInfo.h
@@ -1388,7 +1388,7 @@
   virtual void setAuxTarget(const TargetInfo *Aux) {}
 
   /// Whether target allows debuginfo types for decl only variables.
-  virtual bool allowDebugInfoForExternalVar() const { return false; }
+  virtual bool allowDebugInfoForExternalVar() const { return true; }
 
 protected:
   /// Copy type and layout related info.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72830: [ARM][MVE][Intrinsics] Take abs() of VMINNMAQ, VMAXNMAQ intrinsics' first arguments.

2020-01-20 Thread Mark Murray via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb10a0eb04adf: [ARM][MVE][Intrinsics] Take abs() of VMINNMAQ, 
VMAXNMAQ intrinsics first… (authored by MarkMurrayARM).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72830

Files:
  clang/include/clang/Basic/arm_mve.td
  clang/test/CodeGen/arm-mve-intrinsics/vmaxnmaq.c
  clang/test/CodeGen/arm-mve-intrinsics/vminnmaq.c
  llvm/lib/Target/ARM/ARMInstrMVE.td
  llvm/test/CodeGen/Thumb2/mve-intrinsics/vmaxnmaq.ll
  llvm/test/CodeGen/Thumb2/mve-intrinsics/vminnmaq.ll

Index: llvm/test/CodeGen/Thumb2/mve-intrinsics/vminnmaq.ll
===
--- llvm/test/CodeGen/Thumb2/mve-intrinsics/vminnmaq.ll
+++ llvm/test/CodeGen/Thumb2/mve-intrinsics/vminnmaq.ll
@@ -7,9 +7,10 @@
 ; CHECK-NEXT:vminnma.f16 q0, q1
 ; CHECK-NEXT:bx lr
 entry:
-  %0 = tail call <8 x half> @llvm.fabs.v8f16(<8 x half> %b)
-  %1 = tail call <8 x half> @llvm.minnum.v8f16(<8 x half> %a, <8 x half> %0)
-  ret <8 x half> %1
+  %0 = tail call <8 x half> @llvm.fabs.v8f16(<8 x half> %a)
+  %1 = tail call <8 x half> @llvm.fabs.v8f16(<8 x half> %b)
+  %2 = tail call <8 x half> @llvm.minnum.v8f16(<8 x half> %0, <8 x half> %1)
+  ret <8 x half> %2
 }
 
 declare <8 x half> @llvm.fabs.v8f16(<8 x half>) #1
@@ -22,9 +23,10 @@
 ; CHECK-NEXT:vminnma.f32 q0, q1
 ; CHECK-NEXT:bx lr
 entry:
-  %0 = tail call <4 x float> @llvm.fabs.v4f32(<4 x float> %b)
-  %1 = tail call <4 x float> @llvm.minnum.v4f32(<4 x float> %a, <4 x float> %0)
-  ret <4 x float> %1
+  %0 = tail call <4 x float> @llvm.fabs.v4f32(<4 x float> %a)
+  %1 = tail call <4 x float> @llvm.fabs.v4f32(<4 x float> %b)
+  %2 = tail call <4 x float> @llvm.minnum.v4f32(<4 x float> %0, <4 x float> %1)
+  ret <4 x float> %2
 }
 
 declare <4 x float> @llvm.fabs.v4f32(<4 x float>) #1
Index: llvm/test/CodeGen/Thumb2/mve-intrinsics/vmaxnmaq.ll
===
--- llvm/test/CodeGen/Thumb2/mve-intrinsics/vmaxnmaq.ll
+++ llvm/test/CodeGen/Thumb2/mve-intrinsics/vmaxnmaq.ll
@@ -7,9 +7,10 @@
 ; CHECK-NEXT:vmaxnma.f16 q0, q1
 ; CHECK-NEXT:bx lr
 entry:
-  %0 = tail call <8 x half> @llvm.fabs.v8f16(<8 x half> %b)
-  %1 = tail call <8 x half> @llvm.maxnum.v8f16(<8 x half> %a, <8 x half> %0)
-  ret <8 x half> %1
+  %0 = tail call <8 x half> @llvm.fabs.v8f16(<8 x half> %a)
+  %1 = tail call <8 x half> @llvm.fabs.v8f16(<8 x half> %b)
+  %2 = tail call <8 x half> @llvm.maxnum.v8f16(<8 x half> %0, <8 x half> %1)
+  ret <8 x half> %2
 }
 
 declare <8 x half> @llvm.fabs.v8f16(<8 x half>) #1
@@ -22,9 +23,10 @@
 ; CHECK-NEXT:vmaxnma.f32 q0, q1
 ; CHECK-NEXT:bx lr
 entry:
-  %0 = tail call <4 x float> @llvm.fabs.v4f32(<4 x float> %b)
-  %1 = tail call <4 x float> @llvm.maxnum.v4f32(<4 x float> %a, <4 x float> %0)
-  ret <4 x float> %1
+  %0 = tail call <4 x float> @llvm.fabs.v4f32(<4 x float> %a)
+  %1 = tail call <4 x float> @llvm.fabs.v4f32(<4 x float> %b)
+  %2 = tail call <4 x float> @llvm.maxnum.v4f32(<4 x float> %0, <4 x float> %1)
+  ret <4 x float> %2
 }
 
 declare <4 x float> @llvm.fabs.v4f32(<4 x float>) #1
Index: llvm/lib/Target/ARM/ARMInstrMVE.td
===
--- llvm/lib/Target/ARM/ARMInstrMVE.td
+++ llvm/lib/Target/ARM/ARMInstrMVE.td
@@ -3655,7 +3655,8 @@
 
   let Predicates = [HasMVEInt] in {
 // Unpredicated v(max|min)nma
-def : Pat<(VTI.Vec (unpred_op (VTI.Vec MQPR:$Qd), (fabs (VTI.Vec MQPR:$Qm,
+def : Pat<(VTI.Vec (unpred_op (fabs (VTI.Vec MQPR:$Qd)),
+  (fabs (VTI.Vec MQPR:$Qm,
   (VTI.Vec (Inst (VTI.Vec MQPR:$Qd), (VTI.Vec MQPR:$Qm)))>;
 
 // Predicated v(max|min)nma
Index: clang/test/CodeGen/arm-mve-intrinsics/vminnmaq.c
===
--- clang/test/CodeGen/arm-mve-intrinsics/vminnmaq.c
+++ clang/test/CodeGen/arm-mve-intrinsics/vminnmaq.c
@@ -6,9 +6,10 @@
 
 // CHECK-LABEL: @test_vminnmaq_f16(
 // CHECK-NEXT:  entry:
-// CHECK-NEXT:[[TMP0:%.*]] = tail call <8 x half> @llvm.fabs.v8f16(<8 x half> [[B:%.*]])
-// CHECK-NEXT:[[TMP1:%.*]] = tail call <8 x half> @llvm.minnum.v8f16(<8 x half> [[A:%.*]], <8 x half> [[TMP0]])
-// CHECK-NEXT:ret <8 x half> [[TMP1]]
+// CHECK-NEXT:[[TMP0:%.*]] = tail call <8 x half> @llvm.fabs.v8f16(<8 x half> [[A:%.*]])
+// CHECK-NEXT:[[TMP1:%.*]] = tail call <8 x half> @llvm.fabs.v8f16(<8 x half> [[B:%.*]])
+// CHECK-NEXT:[[TMP2:%.*]] = tail call <8 x half> @llvm.minnum.v8f16(<8 x half> [[TMP0]], <8 x half> [[TMP1]])
+// CHECK-NEXT:ret <8 x half> [[TMP2]]
 //
 float16x8_t test_vminnmaq_f16(float16x8_t a, float16x8_t b)
 {
@@ -21,9 +22,10 @@
 
 // CHECK-LABEL: @test_vminnmaq_f32(
 // CHECK-NEXT:  entry:
-// CHECK-NEXT:[[TMP0:%.*]] = tail call <4 x float> @llvm.fabs.v4f32(<4 x 

[clang] b10a0eb - [ARM][MVE][Intrinsics] Take abs() of VMINNMAQ, VMAXNMAQ intrinsics' first arguments.

2020-01-20 Thread Mark Murray via cfe-commits

Author: Mark Murray
Date: 2020-01-20T14:33:26Z
New Revision: b10a0eb04adfc4186cc6198cf8231358b2b04d89

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

LOG: [ARM][MVE][Intrinsics] Take abs() of VMINNMAQ, VMAXNMAQ intrinsics' first 
arguments.

Summary: Fix VMINNMAQ, VMAXNMAQ intrinsics; BOTH arguments have the absolute 
values taken.

Reviewers: dmgreen, simon_tatham

Subscribers: kristof.beyls, hiraditya, cfe-commits, llvm-commits

Tags: #clang, #llvm

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

Added: 


Modified: 
clang/include/clang/Basic/arm_mve.td
clang/test/CodeGen/arm-mve-intrinsics/vmaxnmaq.c
clang/test/CodeGen/arm-mve-intrinsics/vminnmaq.c
llvm/lib/Target/ARM/ARMInstrMVE.td
llvm/test/CodeGen/Thumb2/mve-intrinsics/vmaxnmaq.ll
llvm/test/CodeGen/Thumb2/mve-intrinsics/vminnmaq.ll

Removed: 




diff  --git a/clang/include/clang/Basic/arm_mve.td 
b/clang/include/clang/Basic/arm_mve.td
index a348713b2aa3..d28f97390614 100644
--- a/clang/include/clang/Basic/arm_mve.td
+++ b/clang/include/clang/Basic/arm_mve.td
@@ -307,10 +307,12 @@ let params = T.Float in {
  (IRIntBase<"maxnum", [Vector]> $a, $b)>;
   def vminnmaq: Intrinsic
-   $a, (IRIntBase<"fabs", [Vector]> $b))>;
+   (IRIntBase<"fabs", [Vector]> $a),
+   (IRIntBase<"fabs", [Vector]> $b))>;
   def vmaxnmaq: Intrinsic
-   $a, (IRIntBase<"fabs", [Vector]> $b))>;
+   (IRIntBase<"fabs", [Vector]> $a),
+   (IRIntBase<"fabs", [Vector]> $b))>;
 }
 
 def vpselq: Intrinsic @llvm.fabs.v8f16(<8 x 
half> [[B:%.*]])
-// CHECK-NEXT:[[TMP1:%.*]] = tail call <8 x half> @llvm.maxnum.v8f16(<8 x 
half> [[A:%.*]], <8 x half> [[TMP0]])
-// CHECK-NEXT:ret <8 x half> [[TMP1]]
+// CHECK-NEXT:[[TMP0:%.*]] = tail call <8 x half> @llvm.fabs.v8f16(<8 x 
half> [[A:%.*]])
+// CHECK-NEXT:[[TMP1:%.*]] = tail call <8 x half> @llvm.fabs.v8f16(<8 x 
half> [[B:%.*]])
+// CHECK-NEXT:[[TMP2:%.*]] = tail call <8 x half> @llvm.maxnum.v8f16(<8 x 
half> [[TMP0]], <8 x half> [[TMP1]])
+// CHECK-NEXT:ret <8 x half> [[TMP2]]
 //
 float16x8_t test_vmaxnmaq_f16(float16x8_t a, float16x8_t b)
 {
@@ -21,9 +22,10 @@ float16x8_t test_vmaxnmaq_f16(float16x8_t a, float16x8_t b)
 
 // CHECK-LABEL: @test_vmaxnmaq_f32(
 // CHECK-NEXT:  entry:
-// CHECK-NEXT:[[TMP0:%.*]] = tail call <4 x float> @llvm.fabs.v4f32(<4 x 
float> [[B:%.*]])
-// CHECK-NEXT:[[TMP1:%.*]] = tail call <4 x float> @llvm.maxnum.v4f32(<4 x 
float> [[A:%.*]], <4 x float> [[TMP0]])
-// CHECK-NEXT:ret <4 x float> [[TMP1]]
+// CHECK-NEXT:[[TMP0:%.*]] = tail call <4 x float> @llvm.fabs.v4f32(<4 x 
float> [[A:%.*]])
+// CHECK-NEXT:[[TMP1:%.*]] = tail call <4 x float> @llvm.fabs.v4f32(<4 x 
float> [[B:%.*]])
+// CHECK-NEXT:[[TMP2:%.*]] = tail call <4 x float> @llvm.maxnum.v4f32(<4 x 
float> [[TMP0]], <4 x float> [[TMP1]])
+// CHECK-NEXT:ret <4 x float> [[TMP2]]
 //
 float32x4_t test_vmaxnmaq_f32(float32x4_t a, float32x4_t b)
 {

diff  --git a/clang/test/CodeGen/arm-mve-intrinsics/vminnmaq.c 
b/clang/test/CodeGen/arm-mve-intrinsics/vminnmaq.c
index e16ede06f691..955e8feab52a 100644
--- a/clang/test/CodeGen/arm-mve-intrinsics/vminnmaq.c
+++ b/clang/test/CodeGen/arm-mve-intrinsics/vminnmaq.c
@@ -6,9 +6,10 @@
 
 // CHECK-LABEL: @test_vminnmaq_f16(
 // CHECK-NEXT:  entry:
-// CHECK-NEXT:[[TMP0:%.*]] = tail call <8 x half> @llvm.fabs.v8f16(<8 x 
half> [[B:%.*]])
-// CHECK-NEXT:[[TMP1:%.*]] = tail call <8 x half> @llvm.minnum.v8f16(<8 x 
half> [[A:%.*]], <8 x half> [[TMP0]])
-// CHECK-NEXT:ret <8 x half> [[TMP1]]
+// CHECK-NEXT:[[TMP0:%.*]] = tail call <8 x half> @llvm.fabs.v8f16(<8 x 
half> [[A:%.*]])
+// CHECK-NEXT:[[TMP1:%.*]] = tail call <8 x half> @llvm.fabs.v8f16(<8 x 
half> [[B:%.*]])
+// CHECK-NEXT:[[TMP2:%.*]] = tail call <8 x half> @llvm.minnum.v8f16(<8 x 
half> [[TMP0]], <8 x half> [[TMP1]])
+// CHECK-NEXT:ret <8 x half> [[TMP2]]
 //
 float16x8_t test_vminnmaq_f16(float16x8_t a, float16x8_t b)
 {
@@ -21,9 +22,10 @@ float16x8_t test_vminnmaq_f16(float16x8_t a, float16x8_t b)
 
 // CHECK-LABEL: @test_vminnmaq_f32(
 // CHECK-NEXT:  entry:
-// CHECK-NEXT:[[TMP0:%.*]] = tail call <4 x float> @llvm.fabs.v4f32(<4 x 
float> [[B:%.*]])
-// CHECK-NEXT:[[TMP1:%.*]] = tail call <4 x float> @llvm.minnum.v4f32(<4 x 
float> [[A:%.*]], <4 x float> [[TMP0]])
-// CHECK-NEXT:ret <4 x float> [[TMP1]]
+// CHECK-NEXT:[[TMP0:%.*]] = tail call <4 x float> @llvm.fabs.v4f32(<4 x 
float> [[A:%.*]])
+// CHECK-NEXT:[[TMP1:%.*]] = tail call <4 x float> @llvm.fabs.v4f32(<4 x 
float> 

[PATCH] D72830: [ARM][MVE][Intrinsics] Take abs() of VMINNMAQ, VMAXNMAQ intrinsics' first arguments.

2020-01-20 Thread Mark Murray via Phabricator via cfe-commits
MarkMurrayARM updated this revision to Diff 239112.
MarkMurrayARM added a comment.

Rebase.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72830

Files:
  clang/include/clang/Basic/arm_mve.td
  clang/test/CodeGen/arm-mve-intrinsics/vmaxnmaq.c
  clang/test/CodeGen/arm-mve-intrinsics/vminnmaq.c
  llvm/lib/Target/ARM/ARMInstrMVE.td
  llvm/test/CodeGen/Thumb2/mve-intrinsics/vmaxnmaq.ll
  llvm/test/CodeGen/Thumb2/mve-intrinsics/vminnmaq.ll

Index: llvm/test/CodeGen/Thumb2/mve-intrinsics/vminnmaq.ll
===
--- llvm/test/CodeGen/Thumb2/mve-intrinsics/vminnmaq.ll
+++ llvm/test/CodeGen/Thumb2/mve-intrinsics/vminnmaq.ll
@@ -7,9 +7,10 @@
 ; CHECK-NEXT:vminnma.f16 q0, q1
 ; CHECK-NEXT:bx lr
 entry:
-  %0 = tail call <8 x half> @llvm.fabs.v8f16(<8 x half> %b)
-  %1 = tail call <8 x half> @llvm.minnum.v8f16(<8 x half> %a, <8 x half> %0)
-  ret <8 x half> %1
+  %0 = tail call <8 x half> @llvm.fabs.v8f16(<8 x half> %a)
+  %1 = tail call <8 x half> @llvm.fabs.v8f16(<8 x half> %b)
+  %2 = tail call <8 x half> @llvm.minnum.v8f16(<8 x half> %0, <8 x half> %1)
+  ret <8 x half> %2
 }
 
 declare <8 x half> @llvm.fabs.v8f16(<8 x half>) #1
@@ -22,9 +23,10 @@
 ; CHECK-NEXT:vminnma.f32 q0, q1
 ; CHECK-NEXT:bx lr
 entry:
-  %0 = tail call <4 x float> @llvm.fabs.v4f32(<4 x float> %b)
-  %1 = tail call <4 x float> @llvm.minnum.v4f32(<4 x float> %a, <4 x float> %0)
-  ret <4 x float> %1
+  %0 = tail call <4 x float> @llvm.fabs.v4f32(<4 x float> %a)
+  %1 = tail call <4 x float> @llvm.fabs.v4f32(<4 x float> %b)
+  %2 = tail call <4 x float> @llvm.minnum.v4f32(<4 x float> %0, <4 x float> %1)
+  ret <4 x float> %2
 }
 
 declare <4 x float> @llvm.fabs.v4f32(<4 x float>) #1
Index: llvm/test/CodeGen/Thumb2/mve-intrinsics/vmaxnmaq.ll
===
--- llvm/test/CodeGen/Thumb2/mve-intrinsics/vmaxnmaq.ll
+++ llvm/test/CodeGen/Thumb2/mve-intrinsics/vmaxnmaq.ll
@@ -7,9 +7,10 @@
 ; CHECK-NEXT:vmaxnma.f16 q0, q1
 ; CHECK-NEXT:bx lr
 entry:
-  %0 = tail call <8 x half> @llvm.fabs.v8f16(<8 x half> %b)
-  %1 = tail call <8 x half> @llvm.maxnum.v8f16(<8 x half> %a, <8 x half> %0)
-  ret <8 x half> %1
+  %0 = tail call <8 x half> @llvm.fabs.v8f16(<8 x half> %a)
+  %1 = tail call <8 x half> @llvm.fabs.v8f16(<8 x half> %b)
+  %2 = tail call <8 x half> @llvm.maxnum.v8f16(<8 x half> %0, <8 x half> %1)
+  ret <8 x half> %2
 }
 
 declare <8 x half> @llvm.fabs.v8f16(<8 x half>) #1
@@ -22,9 +23,10 @@
 ; CHECK-NEXT:vmaxnma.f32 q0, q1
 ; CHECK-NEXT:bx lr
 entry:
-  %0 = tail call <4 x float> @llvm.fabs.v4f32(<4 x float> %b)
-  %1 = tail call <4 x float> @llvm.maxnum.v4f32(<4 x float> %a, <4 x float> %0)
-  ret <4 x float> %1
+  %0 = tail call <4 x float> @llvm.fabs.v4f32(<4 x float> %a)
+  %1 = tail call <4 x float> @llvm.fabs.v4f32(<4 x float> %b)
+  %2 = tail call <4 x float> @llvm.maxnum.v4f32(<4 x float> %0, <4 x float> %1)
+  ret <4 x float> %2
 }
 
 declare <4 x float> @llvm.fabs.v4f32(<4 x float>) #1
Index: llvm/lib/Target/ARM/ARMInstrMVE.td
===
--- llvm/lib/Target/ARM/ARMInstrMVE.td
+++ llvm/lib/Target/ARM/ARMInstrMVE.td
@@ -3655,7 +3655,8 @@
 
   let Predicates = [HasMVEInt] in {
 // Unpredicated v(max|min)nma
-def : Pat<(VTI.Vec (unpred_op (VTI.Vec MQPR:$Qd), (fabs (VTI.Vec MQPR:$Qm,
+def : Pat<(VTI.Vec (unpred_op (fabs (VTI.Vec MQPR:$Qd)),
+  (fabs (VTI.Vec MQPR:$Qm,
   (VTI.Vec (Inst (VTI.Vec MQPR:$Qd), (VTI.Vec MQPR:$Qm)))>;
 
 // Predicated v(max|min)nma
Index: clang/test/CodeGen/arm-mve-intrinsics/vminnmaq.c
===
--- clang/test/CodeGen/arm-mve-intrinsics/vminnmaq.c
+++ clang/test/CodeGen/arm-mve-intrinsics/vminnmaq.c
@@ -6,9 +6,10 @@
 
 // CHECK-LABEL: @test_vminnmaq_f16(
 // CHECK-NEXT:  entry:
-// CHECK-NEXT:[[TMP0:%.*]] = tail call <8 x half> @llvm.fabs.v8f16(<8 x half> [[B:%.*]])
-// CHECK-NEXT:[[TMP1:%.*]] = tail call <8 x half> @llvm.minnum.v8f16(<8 x half> [[A:%.*]], <8 x half> [[TMP0]])
-// CHECK-NEXT:ret <8 x half> [[TMP1]]
+// CHECK-NEXT:[[TMP0:%.*]] = tail call <8 x half> @llvm.fabs.v8f16(<8 x half> [[A:%.*]])
+// CHECK-NEXT:[[TMP1:%.*]] = tail call <8 x half> @llvm.fabs.v8f16(<8 x half> [[B:%.*]])
+// CHECK-NEXT:[[TMP2:%.*]] = tail call <8 x half> @llvm.minnum.v8f16(<8 x half> [[TMP0]], <8 x half> [[TMP1]])
+// CHECK-NEXT:ret <8 x half> [[TMP2]]
 //
 float16x8_t test_vminnmaq_f16(float16x8_t a, float16x8_t b)
 {
@@ -21,9 +22,10 @@
 
 // CHECK-LABEL: @test_vminnmaq_f32(
 // CHECK-NEXT:  entry:
-// CHECK-NEXT:[[TMP0:%.*]] = tail call <4 x float> @llvm.fabs.v4f32(<4 x float> [[B:%.*]])
-// CHECK-NEXT:[[TMP1:%.*]] = tail call <4 x float> @llvm.minnum.v4f32(<4 x float> [[A:%.*]], <4 x 

[PATCH] D71001: [clang-tidy] New check: bugprone-misplaced-pointer-arithmetic-in-alloc

2020-01-20 Thread Balogh, Ádám via Phabricator via cfe-commits
baloghadamsoftware updated this revision to Diff 239103.
baloghadamsoftware added a comment.

Updated according to the comments.


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

https://reviews.llvm.org/D71001

Files:
  clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
  
clang-tools-extra/clang-tidy/bugprone/MisplacedPointerArithmeticInAllocCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/MisplacedPointerArithmeticInAllocCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/bugprone-misplaced-pointer-arithmetic-in-alloc.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-misplaced-pointer-arithmetic-in-alloc.c
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-misplaced-pointer-arithmetic-in-alloc.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-misplaced-pointer-arithmetic-in-alloc.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-misplaced-pointer-arithmetic-in-alloc.cpp
@@ -0,0 +1,53 @@
+// RUN: %check_clang_tidy %s bugprone-misplaced-pointer-arithmetic-in-alloc %t
+
+class C {
+  int num;
+public:
+  explicit C(int n) : num(n) {}
+};
+
+void bad_new(int n, int m) {
+  C *p = new C(n) + 10;
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: arithmetic operation is applied to the result of operator new() instead of its size-like argument
+  // CHECK-FIXES: C *p = new C(n + 10);
+
+  p = new C(n) - 10;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: arithmetic operation is applied to the result of operator new() instead of its size-like argument
+  // CHECK-FIXES: p = new C(n - 10);
+
+  p = new C(n) + m;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: arithmetic operation is applied to the result of operator new() instead of its size-like argument
+  // CHECK-FIXES: p = new C(n + m);
+
+  p = new C(n) - (m + 10);
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: arithmetic operation is applied to the result of operator new() instead of its size-like argument
+  // CHECK-FIXES: p = new C(n - (m + 10));
+
+  p = new C(n) - m + 10;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: arithmetic operation is applied to the result of operator new() instead of its size-like argument
+  // CHECK-FIXES: p = new C(n - m) + 10;
+  // FIXME: Should be p = new C(n - m + 10);
+}
+
+void bad_new_array(int n, int m) {
+  char *p = new char[n] + 10;
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: arithmetic operation is applied to the result of operator new[]() instead of its size-like argument
+  // CHECK-FIXES: char *p = new char[n + 10];
+
+  p = new char[n] - 10;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: arithmetic operation is applied to the result of operator new[]() instead of its size-like argument
+  // CHECK-FIXES: p = new char[n - 10];
+
+  p = new char[n] + m;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: arithmetic operation is applied to the result of operator new[]() instead of its size-like argument
+  // CHECK-FIXES: p = new char[n + m];
+
+  p = new char[n] - (m + 10);
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: arithmetic operation is applied to the result of operator new[]() instead of its size-like argument
+  // CHECK-FIXES: p = new char[n - (m + 10)];
+
+  p = new char[n] - m + 10;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: arithmetic operation is applied to the result of operator new[]() instead of its size-like argument
+  // CHECK-FIXES: p = new char[n - m] + 10;
+  // FIXME: should be p = new char[n - m + 10];
+}
Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-misplaced-pointer-arithmetic-in-alloc.c
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-misplaced-pointer-arithmetic-in-alloc.c
@@ -0,0 +1,56 @@
+// RUN: %check_clang_tidy %s bugprone-misplaced-pointer-arithmetic-in-alloc %t
+
+typedef __typeof(sizeof(int)) size_t;
+void *malloc(size_t);
+void *alloca(size_t);
+void *calloc(size_t, size_t);
+void *realloc(void *, size_t);
+
+void bad_malloc(int n) {
+  char *p = (char *)malloc(n) + 10;
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: arithmetic operation is applied to the result of malloc() instead of its size-like argument
+  // CHECK-FIXES: char *p = (char *)malloc(n + 10);
+
+  p = (char *)malloc(n) - 10;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: arithmetic operation is applied to the result of malloc() instead of its size-like argument
+  // CHECK-FIXES: p = (char *)malloc(n - 10);
+
+  p = (char *)malloc(n) + n;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: arithmetic operation is applied to the result of malloc() instead of its size-like argument
+  // CHECK-FIXES: p = (char *)malloc(n + n);
+
+  p = (char *)malloc(n) - (n + 10);
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: arithmetic 

[PATCH] D71001: [clang-tidy] New check: bugprone-misplaced-pointer-arithmetic-in-alloc

2020-01-20 Thread Balogh, Ádám via Phabricator via cfe-commits
baloghadamsoftware marked 5 inline comments as done.
baloghadamsoftware added a comment.

Hello,

Thank you for your useful comments. I think I fixed them all now.


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

https://reviews.llvm.org/D71001



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


[PATCH] D72934: [ARM,MVE] Support immediate vbicq,vorrq,vmvnq intrinsics.

2020-01-20 Thread Dave Green via Phabricator via cfe-commits
dmgreen added a comment.

In D72934#1829387 , @simon_tatham 
wrote:

> In D72934#1829331 , @dmgreen wrote:
>
> > What is the reason that this can't be lowered in tablegen, in the same way 
> > as the VMOVimm's are?
>
>
> In NEON, immediate VBIC is represented as a single MC instruction, which 
> takes its immediate operand already encoded into the NEON format (8 data 
> bits, op and cmode). That's the same format that `ARMISD::VBICIMM` has 
> encoded the operand in after lowering. So you only need one tablegen pattern, 
> which passes the immediate through unchanged between the input and output 
> SDNode types.
>
> In MVE, immediate VBIC is represented as four separate MC instructions, for 
> an 8-bit immediate shifted left by 0, 8, 16 or 24 bits. Each one takes the 
> immediate operand in the 'natural' form, i.e. the numerical value that would 
> be combined into the vector lane and shown in assembly. For example, 
> `MVE_VBICIZ16v4i32` takes an operand such as `0xab` which NEON VBIC would 
> represent as `0xab | (control bits << 8)`. So the C++ isel code I've written 
> has to undo the NEON encoding and turn it back into the 'natural' immediate 
> value plus a choice of which MVE opcode to use.
>
> I suppose an alternative would be to rework the MC representation of MVE 
> VBIC/VORR so that they look more like the NEON versions. I don't exactly know 
> why MVE was done differently in the first place (the commit here has my name 
> on it, but it was a team effort). One possibility is that the 
> pseudo-instruction reversed forms `vand` and `vorn` might be hard to 
> represent that way, but I don't know.


I believe that the downstream VMOVimm's were rewritten like this when the other 
BUILDVECTOR handling was added by DavidS.  If it is possible to structure this 
way for BIC's too, it sounds like it might be a little cleaner.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72934



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


[PATCH] D72675: [Clang][Driver] Fix -ffast-math/-ffp-contract interaction

2020-01-20 Thread Sanjay Patel via Phabricator via cfe-commits
spatel added a comment.

In D72675#1827893 , @wristow wrote:

> How to handle this seems like an implementation question.  The code here is 
> just deciding whether or not we intend to pass "-ffast-math" to cc1 (it isn't 
> directly defining `__FAST_MATH__`).  If we do pass it to cc1, then 
> "clang/lib/Frontend/InitPreprocessor.cpp" will pre-define `__FAST_MATH__`:
>
>   if (LangOpts.FastMath)
> Builder.defineMacro("__FAST_MATH__");
>   
>
> It seems to me that a straightforward way to deal with this question is to 
> make the above test more elaborate (that is, if `LangOpts.FastMath` is set, 
> OR whatever the appropriate subset of fast-math switches are set).  If we do 
> that, we don't need to deal with the "umbrella" aspect of "-ffast-math", 
> which gets messy.
>
> Which is to say the approach here can stay the same as it currently is 
> (`-ffp-contract=off/on` suppressing the passing of "-ffast-math" to cc1).  
> Although the comment about `__FAST_MATH__` here in "Clang.cpp" should be 
> changed, if we take this approach.


That sounds fine to me, so could update that comment/this patch.

Let's give this a couple of days after updating to see if anyone else has 
feedback though. I'm never exactly sure what our responsibility is with respect 
to gcc compatibility.


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

https://reviews.llvm.org/D72675



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


[PATCH] D72934: [ARM,MVE] Support immediate vbicq,vorrq,vmvnq intrinsics.

2020-01-20 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham marked 2 inline comments as done.
simon_tatham added a comment.

In D72934#1829331 , @dmgreen wrote:

> What is the reason that this can't be lowered in tablegen, in the same way as 
> the VMOVimm's are?


In NEON, immediate VBIC is represented as a single MC instruction, which takes 
its immediate operand already encoded into the NEON format (8 data bits, op and 
cmode). That's the same format that `ARMISD::VBICIMM` has encoded the operand 
in after lowering. So you only need one tablegen pattern, which passes the 
immediate through unchanged between the input and output SDNode types.

In MVE, immediate VBIC is represented as four separate MC instructions, for an 
8-bit immediate shifted left by 0, 8, 16 or 24 bits. Each one takes the 
immediate operand in the 'natural' form, i.e. the numerical value that would be 
combined into the vector lane and shown in assembly. For example, 
`MVE_VBICIZ16v4i32` takes an operand such as `0xab` which NEON VBIC would 
represent as `0xab | (control bits << 8)`. So the C++ isel code I've written 
has to undo the NEON encoding and turn it back into the 'natural' immediate 
value plus a choice of which MVE opcode to use.

I suppose an alternative would be to rework the MC representation of MVE 
VBIC/VORR so that they look more like the NEON versions. I don't exactly know 
why MVE was done differently in the first place (the commit here has my name on 
it, but it was a team effort). One possibility is that the pseudo-instruction 
reversed forms `vand` and `vorn` might be hard to represent that way, but I 
don't know.

> Do you have any tests for what would be invalid bic values under MVE?

True, I suppose I could provide some immediates that are valid for other 
`VMOVModImmType`s, like `0xabff`, and make sure nothing goes wrong.




Comment at: llvm/lib/Target/ARM/ARMISelLowering.cpp:12181
   BVN->isConstantSplat(SplatBits, SplatUndef, SplatBitSize, HasAnyUndefs)) 
{
 if (SplatBitSize <= 64) {
   EVT VbicVT;

dmgreen wrote:
> This is OK because we are passing OtherModImm to isVMOVModifiedImm, and MVE 
> supports the same patterns as NEON?
Yes: `OtherModImm` only matches values of the form '8-bit number shifted left 
by a multiple of 8 bits', which is just what MVE VBIC and VORR take as well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72934



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


[PATCH] D71451: Support to emit extern variables debuginfo with "-fstandalone-debug"

2020-01-20 Thread Jaydeep Chauhan via Phabricator via cfe-commits
Jac1494 updated this revision to Diff 239089.

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

https://reviews.llvm.org/D71451

Files:
  clang/include/clang/Basic/TargetInfo.h
  clang/lib/CodeGen/CGDebugInfo.cpp


Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -4619,6 +4619,8 @@
   assert(CGM.getCodeGenOpts().hasReducedDebugInfo());
   if (D->hasAttr())
 return;
+  if (DebugKind < clang::codegenoptions::FullDebugInfo)
+return;
 
   auto Align = getDeclAlignIfRequired(D, CGM.getContext());
   llvm::DIFile *Unit = getOrCreateFile(D->getLocation());
Index: clang/include/clang/Basic/TargetInfo.h
===
--- clang/include/clang/Basic/TargetInfo.h
+++ clang/include/clang/Basic/TargetInfo.h
@@ -1388,7 +1388,7 @@
   virtual void setAuxTarget(const TargetInfo *Aux) {}
 
   /// Whether target allows debuginfo types for decl only variables.
-  virtual bool allowDebugInfoForExternalVar() const { return false; }
+  virtual bool allowDebugInfoForExternalVar() const { return true; }
 
 protected:
   /// Copy type and layout related info.


Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -4619,6 +4619,8 @@
   assert(CGM.getCodeGenOpts().hasReducedDebugInfo());
   if (D->hasAttr())
 return;
+  if (DebugKind < clang::codegenoptions::FullDebugInfo)
+return;
 
   auto Align = getDeclAlignIfRequired(D, CGM.getContext());
   llvm::DIFile *Unit = getOrCreateFile(D->getLocation());
Index: clang/include/clang/Basic/TargetInfo.h
===
--- clang/include/clang/Basic/TargetInfo.h
+++ clang/include/clang/Basic/TargetInfo.h
@@ -1388,7 +1388,7 @@
   virtual void setAuxTarget(const TargetInfo *Aux) {}
 
   /// Whether target allows debuginfo types for decl only variables.
-  virtual bool allowDebugInfoForExternalVar() const { return false; }
+  virtual bool allowDebugInfoForExternalVar() const { return true; }
 
 protected:
   /// Copy type and layout related info.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D73037: Add a way to set traversal mode in clang-query

2020-01-20 Thread Stephen Kelly via Phabricator via cfe-commits
steveire created this revision.
steveire added a reviewer: aaron.ballman.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73037

Files:
  clang-tools-extra/clang-query/Query.cpp
  clang-tools-extra/clang-query/Query.h
  clang-tools-extra/clang-query/QueryParser.cpp
  clang-tools-extra/clang-query/QueryParser.h
  clang-tools-extra/clang-query/QuerySession.h
  clang-tools-extra/unittests/clang-query/QueryParserTest.cpp

Index: clang-tools-extra/unittests/clang-query/QueryParserTest.cpp
===
--- clang-tools-extra/unittests/clang-query/QueryParserTest.cpp
+++ clang-tools-extra/unittests/clang-query/QueryParserTest.cpp
@@ -110,6 +110,11 @@
   ASSERT_TRUE(isa >(Q));
   EXPECT_EQ(::BindRoot, cast >(Q)->Var);
   EXPECT_EQ(true, cast >(Q)->Value);
+
+  Q = parse("set traversal AsIs");
+  ASSERT_TRUE(isa >(Q));
+  EXPECT_EQ(::TK, cast >(Q)->Var);
+  EXPECT_EQ(ast_type_traits::TK_AsIs, cast >(Q)->Value);
 }
 
 TEST_F(QueryParserTest, Match) {
@@ -197,6 +202,11 @@
   EXPECT_EQ("utput ", Comps[0].TypedText);
   EXPECT_EQ("output", Comps[0].DisplayText);
 
+  Comps = QueryParser::complete("set t", 5, QS);
+  ASSERT_EQ(1u, Comps.size());
+  EXPECT_EQ("raversal ", Comps[0].TypedText);
+  EXPECT_EQ("traversal", Comps[0].DisplayText);
+
   Comps = QueryParser::complete("enable ", 7, QS);
   ASSERT_EQ(1u, Comps.size());
   EXPECT_EQ("output ", Comps[0].TypedText);
@@ -214,6 +224,16 @@
   EXPECT_EQ("dump ", Comps[3].TypedText);
   EXPECT_EQ("dump", Comps[3].DisplayText);
 
+  Comps = QueryParser::complete("set traversal ", 14, QS);
+  ASSERT_EQ(3u, Comps.size());
+
+  EXPECT_EQ("AsIs ", Comps[0].TypedText);
+  EXPECT_EQ("AsIs", Comps[0].DisplayText);
+  EXPECT_EQ("IgnoreImplicitCastsAndParentheses ", Comps[1].TypedText);
+  EXPECT_EQ("IgnoreImplicitCastsAndParentheses", Comps[1].DisplayText);
+  EXPECT_EQ("IgnoreUnlessSpelledInSource ", Comps[2].TypedText);
+  EXPECT_EQ("IgnoreUnlessSpelledInSource", Comps[2].DisplayText);
+
   Comps = QueryParser::complete("match while", 11, QS);
   ASSERT_EQ(1u, Comps.size());
   EXPECT_EQ("Stmt(", Comps[0].TypedText);
Index: clang-tools-extra/clang-query/QuerySession.h
===
--- clang-tools-extra/clang-query/QuerySession.h
+++ clang-tools-extra/clang-query/QuerySession.h
@@ -9,6 +9,7 @@
 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_QUERY_QUERY_SESSION_H
 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_QUERY_QUERY_SESSION_H
 
+#include "clang/AST/ASTTypeTraits.h"
 #include "clang/ASTMatchers/Dynamic/VariantValue.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/StringMap.h"
@@ -25,7 +26,7 @@
   QuerySession(llvm::ArrayRef> ASTs)
   : ASTs(ASTs), PrintOutput(false), DiagOutput(true),
 DetailedASTOutput(false), BindRoot(true), PrintMatcher(false),
-Terminate(false) {}
+Terminate(false), TK(ast_type_traits::TK_IgnoreUnlessSpelledInSource) {}
 
   llvm::ArrayRef> ASTs;
 
@@ -36,6 +37,8 @@
   bool BindRoot;
   bool PrintMatcher;
   bool Terminate;
+
+  ast_type_traits::TraversalKind TK;
   llvm::StringMap NamedValues;
 };
 
Index: clang-tools-extra/clang-query/QueryParser.h
===
--- clang-tools-extra/clang-query/QueryParser.h
+++ clang-tools-extra/clang-query/QueryParser.h
@@ -43,6 +43,8 @@
   template  struct LexOrCompleteWord;
 
   QueryRef parseSetBool(bool QuerySession::*Var);
+  QueryRef
+  parseSetTraversalKind(ast_type_traits::TraversalKind QuerySession::*Var);
   template  QueryRef parseSetOutputKind();
   QueryRef completeMatcherExpression();
 
Index: clang-tools-extra/clang-query/QueryParser.cpp
===
--- clang-tools-extra/clang-query/QueryParser.cpp
+++ clang-tools-extra/clang-query/QueryParser.cpp
@@ -127,6 +127,24 @@
   llvm_unreachable("Invalid output kind");
 }
 
+QueryRef QueryParser::parseSetTraversalKind(
+ast_type_traits::TraversalKind QuerySession::*Var) {
+  StringRef ValStr;
+  unsigned Value =
+  LexOrCompleteWord(this, ValStr)
+  .Case("AsIs", ast_type_traits::TK_AsIs)
+  .Case("IgnoreImplicitCastsAndParentheses",
+ast_type_traits::TK_IgnoreImplicitCastsAndParentheses)
+  .Case("IgnoreUnlessSpelledInSource",
+ast_type_traits::TK_IgnoreUnlessSpelledInSource)
+  .Default(~0u);
+  if (Value == ~0u) {
+return new InvalidQuery("expected traversal kind, got '" + ValStr + "'");
+  }
+  return new SetQuery(
+  Var, static_cast(Value));
+}
+
 QueryRef QueryParser::endQuery(QueryRef Q) {
   StringRef Extra = Line;
   StringRef ExtraTrimmed = Extra.drop_while(
@@ -170,7 +188,8 @@
   PQV_Invalid,
   PQV_Output,
   PQV_BindRoot,
-  PQV_PrintMatcher
+  PQV_PrintMatcher,
+  PQV_Traversal
 };
 
 QueryRef makeInvalidQueryFromDiagnostics(const Diagnostics ) {
@@ 

[PATCH] D73035: [clangd] Avoid redundant testcases in rename unittest, NFC.

2020-01-20 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon check-circle color=green} Unit tests: pass. 62009 tests passed, 0 failed 
and 783 were skipped.

{icon question-circle color=gray} clang-tidy: unknown.

{icon check-circle color=green} clang-format: pass.

Build artifacts 
: 
diff.json 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73035



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


  1   2   >