[PATCH] D15528: Teach clang-tidy how to -Werror checks.

2020-06-12 Thread Nathan James via Phabricator via cfe-commits
njames93 added inline comments.
Herald added a subscriber: arphaman.



Comment at: clang-tidy/tool/ClangTidyMain.cpp:362
+ << Plural << "\n";
+return WErrorCount;
+  }

Was there any specific reason for returning the error count instead of 
returning 1. It results in undefined behaviour on POSIX shells if a value is 
returned outside the range of 0<=n<=255. See 
https://bugs.llvm.org/show_bug.cgi?id=46305


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

https://reviews.llvm.org/D15528



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


[PATCH] D74166: [AIX][Frontend] Static init implementation for AIX considering no priority

2020-06-12 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added inline comments.



Comment at: clang/lib/CodeGen/CGDeclCXX.cpp:277
+ llvm::FunctionType::get(CGM.VoidTy, false) &&
+ "atexit has wrong parameter type.");
+

s/atexit has wrong parameter type/Argument to atexit has a wrong type/;



Comment at: clang/lib/CodeGen/CGDeclCXX.cpp:302
+ llvm::FunctionType::get(CGM.VoidTy, false) &&
+ "unatexit has wrong parameter type.");
+

s/unatexit has wrong parameter type/Argument to unatexit has a wrong type/;



Comment at: clang/lib/CodeGen/CGDeclCXX.cpp:649
+FuncName = llvm::Twine("__sinit8000_clang_", GlobalUniqueModuleId)
+   .toNullTerminatedStringRef(FuncName);
+  else {

Replace the call to `toNullTerminatedStringRef` and the assignment with a call 
to `toVector`.



Comment at: clang/lib/CodeGen/CGDeclCXX.cpp:657
+   getTransformedFileName(getModule(), Storage))
+   .toNullTerminatedStringRef(FuncName);
   }

Replace the call to `toNullTerminatedStringRef` and the assignment with a call 
to `toVector`.



Comment at: clang/lib/CodeGen/CGDeclCXX.cpp:664
+  if (getCXXABI().useSinitAndSterm())
+Fn->setLinkage(llvm::Function::ExternalLinkage);
 

`CreateGlobalInitOrDestructFunction` currently calls `Create` with 
`llvm::GlobalValue::InternalLinkage` and also calls 
`SetInternalFunctionAttributes`. Setting `ExternalLinkage` after-the-fact seems 
brittle.



Comment at: clang/lib/CodeGen/CGDeclCXX.cpp:690
 
-void CodeGenModule::EmitCXXGlobalDtorFunc() {
-  if (CXXGlobalDtors.empty())
+void CodeGenModule::EmitCXXGlobalDestructFunc() {
+  if (CXXGlobalDtorsOrStermFinalizers.empty())

I think "cleanup" works here too.



Comment at: clang/lib/CodeGen/CGDeclCXX.cpp:697
 
   // Create our global destructor function.
+  llvm::Function *Fn = nullptr;

s/Create our global destructor function/Create our global cleanup function/;



Comment at: clang/lib/CodeGen/CGDeclCXX.cpp:822
 
 // Emit the dtors, in reverse order from construction.
+for (unsigned i = 0, e = DtorsOrStermFinalizers.size(); i != e; ++i) {

s/dtors/cleanups/;



Comment at: clang/lib/CodeGen/CodeGenModule.h:472
   /// Global destructor functions and arguments that need to run on 
termination.
+  /// Global destructor functions and arguments that need to run on 
termination;
+  /// When UseSinitAndSterm is set, it contains sterm finalizers functions

Near duplicate comment line.



Comment at: clang/lib/CodeGen/CodeGenModule.h:473
+  /// Global destructor functions and arguments that need to run on 
termination;
+  /// When UseSinitAndSterm is set, it contains sterm finalizers functions
+  /// instead that need to run on unloading a shared library.

s/finalizers/finalizer/;
s/it contains/it instead contains/;



Comment at: clang/lib/CodeGen/CodeGenModule.h:474
+  /// When UseSinitAndSterm is set, it contains sterm finalizers functions
+  /// instead that need to run on unloading a shared library.
   std::vector<

s/instead that need to run/, which also run/;



Comment at: clang/lib/CodeGen/CodeGenModule.h:1059
+
+  /// Add a destructor to the C++ global destructor function.
+  void AddCXXDtorEntry(llvm::FunctionCallee DtorFn) {

s/a destructor/an sterm finalizer/;
s/global destructor/global cleanup/;



Comment at: clang/lib/CodeGen/CodeGenModule.h:1060
+  /// Add a destructor to the C++ global destructor function.
+  void AddCXXDtorEntry(llvm::FunctionCallee DtorFn) {
+CXXGlobalDtorsOrStermFinalizers.emplace_back(DtorFn.getFunctionType(),

s/Dtor/StermFinalizer/;



Comment at: clang/lib/CodeGen/CodeGenModule.h:1462
 
-  /// Emit the function that destroys C++ globals.
-  void EmitCXXGlobalDtorFunc();
+  /// Emit the function that destructs C++ globals.
+  void EmitCXXGlobalDestructFunc();

s/destructs/performs cleanup associated with/;



Comment at: clang/lib/CodeGen/ItaniumCXXABI.cpp:4448
+  if (CGM.getCodeGenOpts().CXAAtExit)
+llvm::report_fatal_error("using __cxa_atexit unsupported on AIX.");
+  // Register above __dtor with atexit().

There should not be period at the end of a `report_fatal_error` message.



Comment at: clang/lib/CodeGen/ItaniumCXXABI.cpp:4452
+
+  // Emit __finalize function to unregister __dtor and call __dtor.
+  emitCXXStermFinalizer(D, dtorStub, addr);

s/and/and (as appropriate)/;



Comment at: clang/lib/CodeGen/ItaniumCXXABI.cpp:4477
+  // registered by the atexit subroutine. If the referenced function is foun

[PATCH] D74166: [AIX][Frontend] Static init implementation for AIX considering no priority

2020-06-12 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added inline comments.



Comment at: clang/test/CodeGen/static-init.cpp:8
+// RUN:   FileCheck %s
 
 struct test {

Xiangling_L wrote:
> jasonliu wrote:
> > Looks like the non-inline comments are easier to get ignored and missed, so 
> > I will copy paste the non-inlined comment I previously had:
> > ```
> > -fregister_global_dtors_with_atexit does not seem to work properly in 
> > current implementation.
> > We should consider somehow disabling/report_fatal_error it instead of 
> > letting it generate invalid code on AIX.
> > ```
> Thanks for doing so!
> 
> The semantic of `global_dtors` here on AIX is `__sterm` function, which we 
> are never gonna register with `__atexit`. I am thinking we can disable it in 
> a follow-up driver patch with the handling of `-fno-use-cxa-atexit`.
The semantic of `global_dtors` is not limited to the `__sterm` functions 
associated with C++ cleanup actions. With respect to user-declared 
`__attribute__((__destructor__))` functions, the option could improve the 
interleaving of those cleanup actions with cleanup actions registered by 
user-declared `__attribute__((__constructor__))` functions.

This provides that rationale for separating the `__sterm` functions associated 
with the C++ cleanup actions from the other "destructor" functions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74166



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


[PATCH] D81688: [WebAssembly] WebAssembly doesn't support "protected" visibility

2020-06-12 Thread Dan Gohman via Phabricator via cfe-commits
sunfish closed this revision.
sunfish added a comment.

Landed in 66042959590d6db9d2a12803a16476d4e3508f3f 
.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81688



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


[clang] 6604295 - [WebAssembly] WebAssembly doesn't support "protected" visibility

2020-06-12 Thread Dan Gohman via cfe-commits

Author: Dan Gohman
Date: 2020-06-12T19:52:35-07:00
New Revision: 66042959590d6db9d2a12803a16476d4e3508f3f

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

LOG: [WebAssembly] WebAssembly doesn't support "protected" visibility

Implement the `hasProtectedVisibility()` hook to indicate that, like
Darwin, WebAssembly doesn't support "protected" visibility.

On ELF, "protected" visibility is intended to be an optimization, however
in practice it often [isn't], and ELF documentation generally ranges from
[not mentioning it at all] to [strongly discouraging its use].

[isn't]: https://www.airs.com/blog/archives/307
[not mentioning it at all]: https://gcc.gnu.org/wiki/Visibility
[strongly discouraging its use]: https://www.akkadia.org/drepper/dsohowto.pdf

While here, also mention the new Reactor support in the release notes.

Added: 


Modified: 
clang/lib/Basic/Targets/WebAssembly.h
llvm/docs/ReleaseNotes.rst

Removed: 




diff  --git a/clang/lib/Basic/Targets/WebAssembly.h 
b/clang/lib/Basic/Targets/WebAssembly.h
index 030d79ea2ecc..e09e21d90802 100644
--- a/clang/lib/Basic/Targets/WebAssembly.h
+++ b/clang/lib/Basic/Targets/WebAssembly.h
@@ -132,7 +132,14 @@ class LLVM_LIBRARY_VISIBILITY WebAssemblyTargetInfo : 
public TargetInfo {
   }
 
   bool hasExtIntType() const override { return true; }
+
+  bool hasProtectedVisibility() const override {
+// TODO: For now, continue to advertise "protected" support for
+// Emscripten targets.
+return getTriple().isOSEmscripten();
+  }
 };
+
 class LLVM_LIBRARY_VISIBILITY WebAssembly32TargetInfo
 : public WebAssemblyTargetInfo {
 public:

diff  --git a/llvm/docs/ReleaseNotes.rst b/llvm/docs/ReleaseNotes.rst
index ea1fad1f6390..7d71d0c58a4c 100644
--- a/llvm/docs/ReleaseNotes.rst
+++ b/llvm/docs/ReleaseNotes.rst
@@ -144,8 +144,14 @@ Changes to the AVR Target
 Changes to the WebAssembly Target
 -
 
-During this release ...
-
+* Programs which don't have a "main" function, called "reactors" are now
+  properly supported, with a new `-mexec-model=reactor` flag. Programs which
+  previously used `-Wl,--no-entry` to avoid having a main function should
+  switch to this new flag, so that static initialization is properly
+  performed.
+
+* `__attribute__((visibility("protected")))` now evokes a warning, as
+  WebAssembly does not support "protected" visibility.
 
 Changes to the OCaml bindings
 -



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


[PATCH] D74166: [AIX][Frontend] Static init implementation for AIX considering no priority

2020-06-12 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added inline comments.



Comment at: clang/test/CodeGen/static-init.cpp:31
+// CHECK: @llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] 
[{ i32, void ()*, i8* } { i32 65535, void ()* 
@__sinit8000_clang_510e898aa8d263cac999dd03eeed5b51, i8* null }]
+// CHECK: @llvm.global_dtors = appending global [1 x { i32, void ()*, i8* }] 
[{ i32, void ()*, i8* } { i32 65535, void ()* 
@__sterm8000_clang_510e898aa8d263cac999dd03eeed5b51, i8* null }]
+

Okay, the restricted scope of this patch seems to landed in a place where how 
the `llvm.global_dtors` array will be handled is not indicated...

The backend should implement the semantics of the IR construct. When handling 
said array in the IR, it seems the method to handle the requisite semantics 
would be to generate an alias (with the appropriate linkage for the linker to 
pick it up) that is named using the `__sinit`/`__sterm` convention. Which is to 
say that at least some part of the naming should eventually move into the LLVM 
side and out of Clang.

Please update the description of this patch to indicate that:

  - The `llvm.global_ctors` and `llvm.global_dtors` functionality has not yet 
been implemented on AIX.
  - This patch temporarily side-steps the need to implement that functionality.
  - The apparent uses of that functionality in this patch (with respect to the 
name of the functions involved) are not representative of how the functionality 
will be used once implemented.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74166



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


[PATCH] D81781: Add additional text format functions to Google style.

2020-06-12 Thread Nicholas Seckar via Phabricator via cfe-commits
nseckar updated this revision to Diff 270559.
nseckar added a comment.

Add reviewers


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81781

Files:
  clang/lib/Format/Format.cpp


Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -1007,6 +1007,8 @@
   "PARSE_PARTIAL_TEXT_PROTO",
   "PARSE_TEST_PROTO",
   "PARSE_TEXT_PROTO",
+  "ParsePartialTestProto",
+  "ParseTestProto",
   "ParseTextOrDie",
   "ParseTextProtoOrDie",
   },


Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -1007,6 +1007,8 @@
   "PARSE_PARTIAL_TEXT_PROTO",
   "PARSE_TEST_PROTO",
   "PARSE_TEXT_PROTO",
+  "ParsePartialTestProto",
+  "ParseTestProto",
   "ParseTextOrDie",
   "ParseTextProtoOrDie",
   },
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D74166: [AIX][Frontend] Static init implementation for AIX considering no priority

2020-06-12 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast marked an inline comment as done.
hubert.reinterpretcast added inline comments.



Comment at: clang/lib/CodeGen/CGDeclCXX.cpp:700
+
+Fn = CreateGlobalInitOrDestructFunction(
+FTy, llvm::Twine("__sterm8000_clang_") + GlobalUniqueModuleId, FI,

Xiangling_L wrote:
> hubert.reinterpretcast wrote:
> > The called function is to be renamed.
> Any suggestions here about how to represent the functionality of `__sterm` 
> and `_GLOBAL__D_a` into one word? Cannot think of a good name...
> 
> Actually I am wondering do we need to rename the `Destruct` part? The 
> `__sterm` and `_GLOBAL__D_a` do destruct the object by calling sterm 
> finalizers and object destructors?
Being clear in the naming of the function helps to signal its purpose to future 
maintainers. The sterm finalizers are unlikely to be understood from `Destruct` 
(it implies plain destruction a bit too much). Maybe "cleanup"?



Comment at: clang/lib/CodeGen/CGDeclCXX.cpp:807
 
 void CodeGenFunction::GenerateCXXGlobalDtorsFunc(
 llvm::Function *Fn,

Xiangling_L wrote:
> hubert.reinterpretcast wrote:
> > This function is to be renamed.
>  I will try `GenerateCXXGlobalDestructFunc` based on the thoughts as I also 
> mentioned elsewhere that the `__sterm` and `_GLOBAL__D_` function do destruct 
> the object by calling sterm finalizers and object destructors.
> 
> Any suggestions or concerns about this renaming? Or do we really need to 
> rename this one?
I think "cleanup" works here too.



Comment at: clang/lib/CodeGen/CGDeclCXX.cpp:639
+  if (CXXGlobalInits.empty())
+return;
 

Xiangling_L wrote:
> hubert.reinterpretcast wrote:
> > Can this part be committed in a separate patch? It does not appear to have 
> > dependencies on other parts of this patch and has the appearance of being a 
> > possible change for other platforms.
> Sure. I will create a NFC patch for this part and try to commit it first. But 
> so far, I think I can keep this part in this patch just for review purpose to 
> make the patch look nicer?
Sure; you'd need the new patch to exist before rebasing on it anyway. We can 
leave the rebasing to the commit or later in the review.



Comment at: clang/lib/CodeGen/ItaniumCXXABI.cpp:4467
+
+  // Create a variable destruction function.
+  const CGFunctionInfo &FI = CGM.getTypes().arrangeNullaryFunction();

Xiangling_L wrote:
> hubert.reinterpretcast wrote:
> > Suggestion:
> > Create the finalization action associated with a variable.
> I don't get your point, can you elaborate on this a little bit?
This is my suggestion for the comment (to replace "Create a variable 
destruction function").


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74166



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


[PATCH] D81781: Add additional text format functions to Google style.

2020-06-12 Thread Nicholas Seckar via Phabricator via cfe-commits
nseckar created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
nseckar updated this revision to Diff 270559.
nseckar added a comment.
nseckar added a reviewer: djasper.

Add reviewers


This adds a few more function names expecting a text proto argument.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81781

Files:
  clang/lib/Format/Format.cpp


Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -1007,6 +1007,8 @@
   "PARSE_PARTIAL_TEXT_PROTO",
   "PARSE_TEST_PROTO",
   "PARSE_TEXT_PROTO",
+  "ParsePartialTestProto",
+  "ParseTestProto",
   "ParseTextOrDie",
   "ParseTextProtoOrDie",
   },


Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -1007,6 +1007,8 @@
   "PARSE_PARTIAL_TEXT_PROTO",
   "PARSE_TEST_PROTO",
   "PARSE_TEXT_PROTO",
+  "ParsePartialTestProto",
+  "ParseTestProto",
   "ParseTextOrDie",
   "ParseTextProtoOrDie",
   },
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D81242: [StackSafety] Run ThinLTO

2020-06-12 Thread Vitaly Buka via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc1e47b47f884: [StackSafety] Run ThinLTO (authored by 
vitalybuka).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81242

Files:
  clang/test/Driver/memtag_lto.c
  llvm/include/llvm/Analysis/StackSafetyAnalysis.h
  llvm/lib/Analysis/StackSafetyAnalysis.cpp
  llvm/lib/LTO/LTO.cpp
  llvm/test/Analysis/StackSafetyAnalysis/ipa-alias.ll
  llvm/test/Analysis/StackSafetyAnalysis/ipa.ll

Index: llvm/test/Analysis/StackSafetyAnalysis/ipa.ll
===
--- llvm/test/Analysis/StackSafetyAnalysis/ipa.ll
+++ llvm/test/Analysis/StackSafetyAnalysis/ipa.ll
@@ -10,6 +10,111 @@
 ; RUN: opt -S -analyze -stack-safety %t.combined.bc | FileCheck %s --check-prefixes=CHECK,GLOBAL,NOLTO
 ; RUN: opt -S -passes="print-stack-safety" -disable-output %t.combined.bc 2>&1 | FileCheck %s --check-prefixes=CHECK,GLOBAL,NOLTO
 
+; Do an end-to-test using the new LTO API
+; TODO: Hideous llvm-lto2 invocation, add a --default-symbol-resolution to llvm-lto2?
+; RUN: opt -module-summary %s -o %t.summ0.bc
+; RUN: opt -module-summary %S/Inputs/ipa.ll -o %t.summ1.bc
+
+; RUN: llvm-lto2 run %t.summ0.bc %t.summ1.bc -o %t.lto -stack-safety-print -stack-safety-run -save-temps -thinlto-threads 1 -O0 \
+; RUN:  -r %t.summ0.bc,Write1, \
+; RUN:  -r %t.summ0.bc,Write4, \
+; RUN:  -r %t.summ0.bc,Write4_2, \
+; RUN:  -r %t.summ0.bc,Write8, \
+; RUN:  -r %t.summ0.bc,WriteAndReturn8, \
+; RUN:  -r %t.summ0.bc,TestUpdateArg,px \
+; RUN:  -r %t.summ0.bc,ExternalCall, \
+; RUN:  -r %t.summ0.bc,PreemptableWrite1, \
+; RUN:  -r %t.summ0.bc,InterposableWrite1, \
+; RUN:  -r %t.summ0.bc,ReturnDependent, \
+; RUN:  -r %t.summ0.bc,Rec2, \
+; RUN:  -r %t.summ0.bc,RecursiveNoOffset, \
+; RUN:  -r %t.summ0.bc,RecursiveWithOffset, \
+; RUN:  -r %t.summ0.bc,f1,px \
+; RUN:  -r %t.summ0.bc,f2,px \
+; RUN:  -r %t.summ0.bc,f3,px \
+; RUN:  -r %t.summ0.bc,f4,px \
+; RUN:  -r %t.summ0.bc,f5,px \
+; RUN:  -r %t.summ0.bc,f6,px \
+; RUN:  -r %t.summ0.bc,PreemptableCall,px \
+; RUN:  -r %t.summ0.bc,InterposableCall,px \
+; RUN:  -r %t.summ0.bc,PrivateCall,px \
+; RUN:  -r %t.summ0.bc,f7,px \
+; RUN:  -r %t.summ0.bc,f8left,px \
+; RUN:  -r %t.summ0.bc,f8right,px \
+; RUN:  -r %t.summ0.bc,f8oobleft,px \
+; RUN:  -r %t.summ0.bc,f8oobright,px \
+; RUN:  -r %t.summ0.bc,TwoArguments,px \
+; RUN:  -r %t.summ0.bc,TwoArgumentsOOBOne,px \
+; RUN:  -r %t.summ0.bc,TwoArgumentsOOBOther,px \
+; RUN:  -r %t.summ0.bc,TwoArgumentsOOBBoth,px \
+; RUN:  -r %t.summ0.bc,TestRecursiveNoOffset,px \
+; RUN:  -r %t.summ0.bc,TestRecursiveWithOffset,px \
+; RUN:  -r %t.summ1.bc,Write1,px \
+; RUN:  -r %t.summ1.bc,Write4,px \
+; RUN:  -r %t.summ1.bc,Write4_2,px \
+; RUN:  -r %t.summ1.bc,Write8,px \
+; RUN:  -r %t.summ1.bc,WriteAndReturn8,px \
+; RUN:  -r %t.summ1.bc,ExternalCall,px \
+; RUN:  -r %t.summ1.bc,PreemptableWrite1,px \
+; RUN:  -r %t.summ1.bc,InterposableWrite1,px \
+; RUN:  -r %t.summ1.bc,ReturnDependent,px \
+; RUN:  -r %t.summ1.bc,Rec0,px \
+; RUN:  -r %t.summ1.bc,Rec1,px \
+; RUN:  -r %t.summ1.bc,Rec2,px \
+; RUN:  -r %t.summ1.bc,RecursiveNoOffset,px \
+; RUN:  -r %t.summ1.bc,RecursiveWithOffset,px \
+; RUN:  -r %t.summ1.bc,ReturnAlloca,px 2>&1 | FileCheck %s --check-prefixes=CHECK,GLOBAL,LTO
+
+; RUN: llvm-lto2 run %t.summ0.bc %t.summ1.bc -o %t-newpm.lto -use-new-pm -stack-safety-print -stack-safety-run -save-temps -thinlto-threads 1 -O0 \
+; RUN:  -r %t.summ0.bc,Write1, \
+; RUN:  -r %t.summ0.bc,Write4, \
+; RUN:  -r %t.summ0.bc,Write4_2, \
+; RUN:  -r %t.summ0.bc,Write8, \
+; RUN:  -r %t.summ0.bc,WriteAndReturn8, \
+; RUN:  -r %t.summ0.bc,TestUpdateArg,px \
+; RUN:  -r %t.summ0.bc,ExternalCall, \
+; RUN:  -r %t.summ0.bc,PreemptableWrite1, \
+; RUN:  -r %t.summ0.bc,InterposableWrite1, \
+; RUN:  -r %t.summ0.bc,ReturnDependent, \
+; RUN:  -r %t.summ0.bc,Rec2, \
+; RUN:  -r %t.summ0.bc,RecursiveNoOffset, \
+; RUN:  -r %t.summ0.bc,RecursiveWithOffset, \
+; RUN:  -r %t.summ0.bc,f1,px \
+; RUN:  -r %t.summ0.bc,f2,px \
+; RUN:  -r %t.summ0.bc,f3,px \
+; RUN:  -r %t.summ0.bc,f4,px \
+; RUN:  -r %t.summ0.bc,f5,px \
+; RUN:  -r %t.summ0.bc,f6,px \
+; RUN:  -r %t.summ0.bc,PreemptableCall,px \
+; RUN:  -r %t.summ0.bc,InterposableCall,px \
+; RUN:  -r %t.summ0.bc,PrivateCall,px \
+; RUN:  -r %t.summ0.bc,f7,px \
+; RUN:  -r %t.summ0.bc,f8left,px \
+; RUN:  -r %t.summ0.bc,f8right,px \
+; RUN:  -r %t.summ0.bc,f8oobleft,px \
+; RUN:  -r %t.summ0.bc,f8oobright,px \
+; RUN:  -r %t.summ0.bc,TwoArguments,px \
+; RUN:  -r %t.summ0.bc,TwoArgumentsOOBOne,px \
+; RUN:  -r %t.summ0.bc,TwoArgumentsOOBOther,px \
+; RUN:  -r %t.summ0.bc,TwoArgumentsOOBBoth,px \
+; RUN:  -r %t.summ0.bc,TestRecursiveNoOffset,px \
+; RUN:  -r %t.summ0.bc,TestRecursiveWithOffset,px \
+; RUN:  -r %t.summ1.bc,Write1,px \
+; RUN:  -r %t.summ1.bc,Write4,px \
+; RUN:  -r %t.summ1.bc,Write4_2,px \
+; RUN:  -r %t.summ1

[PATCH] D81242: [StackSafety] Run ThinLTO

2020-06-12 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added inline comments.



Comment at: llvm/lib/Analysis/StackSafetyAnalysis.cpp:618
+ConstantRange Access = Found->sextOrTrunc(Use.Range.getBitWidth());
+if (Access.signedAddMayOverflow(C.Offset) !=
+ConstantRange::OverflowResult::NeverOverflows)

eugenis wrote:
> vitalybuka wrote:
> > eugenis wrote:
> > > Do we have a test for this overflow check?
> > yes
> > Example, in bit width 8
> > [-128,-127)+[-128,-127) = [0,1)
> > both non-wrapped and result is non-wrapped so we have no way to spot 
> > overflow
> Sure. I was asking if we have a testcase that covers the overflow check.
I've extracted this into function and added test to cover that.
It is possible to test this check, however we discussed clamping offsets to 
something more useful, e.g. 2^(ptrwidth/2). This way we will not be able to hit 
this check.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81242



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


[PATCH] D79796: Sketch support for generating CC1 command line from CompilerInvocation

2020-06-12 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added inline comments.



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:3845
+  IS_POSITIVE != DEFAULT_VALUE && this->KEYPATH != DEFAULT_VALUE)  
\
+Args.push_back(StringAllocator(Twine(PREFIX_TYPE[0]) + NAME));
+#include "clang/Driver/Options.inc"

Bigcheese wrote:
> It's a little sad that we need to allocation every string just because of the 
> `-`. We definitely need to be able to allocate strings for options with data, 
> but it would be good if we could just have the strings with `-` prefixed in 
> the option table if that's reasonable to do.
I want to highlight @Bigcheese's comment again so it doesn't get lost. I think 
a reasonable name would be `SPELLING`.



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:3903
+  Args.push_back(StringAllocator(Twine(PREFIX_TYPE[0]) + NAME));   
\
+  Args.push_back(StringAllocator(DENORMALIZER(this->KEYPATH)));
\
+}  
\

The denormalizer should take the `StringAllocator` as an argument, and only 
allocate when necessary.



Comment at: llvm/utils/TableGen/OptParserEmitter.cpp:327
+  OS << "\n";
+  OS << "#ifdef AUTO_NORMALIZING_OPTIONS";
+  OS << "\n\n";

Since this is meant to be included exactly once (as opposed to being an 
x-macro), perhaps this should be split out into a separate `.inc`.



Comment at: llvm/utils/TableGen/OptParserEmitter.cpp:351-354
+OS << "#define " << MacroName << "(V, D) .Case(V, D)\n";
+emitValueTable(OS, OptionName, R.getValueAsString("Values"),
+   NormalizedValuesScope, NormalizedValues);
+OS << "#undef " << MacroName << "\n";

It seems unnecessary to generate macros here; you can just generate the code 
directly...

But looking more closely, I wonder if we really need this generated code at all.

Instead, can we create a table like this in Options.inc?
```
struct EnumValue {
  const char *Name;
  unsigned Value;
};

struct EnumValueTable {
  const EnumValue *Table;
  unsigned Size;
};

static const EnumValue RelocationModelTable[] = {
  {"static", static_cast(llvm::Reloc::Static)},
  {"pic", static_cast(llvm::Reloc::_PIC)},
  // ...
};

static const EnumValue SomeOtherTable[] = {
  {"name", static_cast(clang::SomeOtherEnumValue)},
  // ...
};

static const EnumValueTable *EnumValueTables[] = {
  {&RelocationModelTable, sizeof(RelocationModelTable) / sizeof(EnumValue)},
  {&SomeOtherTable, sizeof(SomeOtherTable) / sizeof(EnumValue)},
};
static const unsigned EnumValueTablesSize =
sizeof(EnumValueTables) / sizeof(EnumValueTable);
```

We can then have this code directly in Options.cpp:
```
static llvm::Optional extractSimpleEnum(
llvm::opt::OptSpecifier Opt, int TableIndex,
const ArgList &ArgList, DiagnosticsEngine &Diags) {
  assert(TableIndex >= 0);
  assert(TableIndex < EnumValueTablesSize);
  const EnumValueTable &Table = *EnumValueTables[TableIndex];

  auto Arg = Args.getLastArg(Opt);
  if (!Arg)
return None;

  StringRef ArgValue = Arg->getValue();
  for (int I = 0, E = Table.Size; I != E; ++I)
if (ArgValue == Table.Table[I].Name)
  return Table.Table[I].Value;

  Diags.Report(diag::err_drv_invalid_value)
  << Arg->getAsString(ArgList) << ArgValue;
  return None;
}
```
and change the normalizer contract to:
- return an `Optional`,
- take an `llvm::opt::OptSpecifier`,
- take an index into a table (set to `-1` if there's no relevant table), and
- be responsible for the boilerplate call to `getLastArg`.
Simple enums would have `NORMALIZER` hardcoded to `extractSimpleEnum`. The 
handler code that calls it needs new arguments `TABLE_INDEX` and `TYPE` but 
also looks simpler this way:
```
if (auto MaybeValue = NORMALIZER(Opt##ID, TABLE_INDEX, Args, Diags)) \
  this->KEYPATH = static_cast(*MaybeValue);\
else \
  this->KEYPATH = DEFAULT_VALUE;
```

We could similarly have a single `serializeSimpleEnum` function in Options.cpp 
for a hardcoded `DENORMALIZER` for simple enums:
```
static const char *serializeSimpleEnum(int TableIndex, unsigned Value) {
  assert(TableIndex >= 0);
  assert(TableIndex < EnumValueTablesSize);
  const EnumValueTable &Table = *EnumValueTables[TableIndex];
  for (int I = 0, E = Table.Size; I != E; ++I)
if (Value == Table.Table[I].Value)
  return Table.Table[I].Name;

  llvm::report_fatal_error("good error message");
}
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79796



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


[PATCH] D81242: [StackSafety] Run ThinLTO

2020-06-12 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka updated this revision to Diff 270553.
vitalybuka marked 3 inline comments as done.
vitalybuka added a comment.

address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81242

Files:
  clang/test/Driver/memtag_lto.c
  llvm/include/llvm/Analysis/StackSafetyAnalysis.h
  llvm/lib/Analysis/StackSafetyAnalysis.cpp
  llvm/lib/LTO/LTO.cpp
  llvm/test/Analysis/StackSafetyAnalysis/ipa-alias.ll
  llvm/test/Analysis/StackSafetyAnalysis/ipa.ll

Index: llvm/test/Analysis/StackSafetyAnalysis/ipa.ll
===
--- llvm/test/Analysis/StackSafetyAnalysis/ipa.ll
+++ llvm/test/Analysis/StackSafetyAnalysis/ipa.ll
@@ -10,6 +10,111 @@
 ; RUN: opt -S -analyze -stack-safety %t.combined.bc | FileCheck %s --check-prefixes=CHECK,GLOBAL,NOLTO
 ; RUN: opt -S -passes="print-stack-safety" -disable-output %t.combined.bc 2>&1 | FileCheck %s --check-prefixes=CHECK,GLOBAL,NOLTO
 
+; Do an end-to-test using the new LTO API
+; TODO: Hideous llvm-lto2 invocation, add a --default-symbol-resolution to llvm-lto2?
+; RUN: opt -module-summary %s -o %t.summ0.bc
+; RUN: opt -module-summary %S/Inputs/ipa.ll -o %t.summ1.bc
+
+; RUN: llvm-lto2 run %t.summ0.bc %t.summ1.bc -o %t.lto -stack-safety-print -stack-safety-run -save-temps -thinlto-threads 1 -O0 \
+; RUN:  -r %t.summ0.bc,Write1, \
+; RUN:  -r %t.summ0.bc,Write4, \
+; RUN:  -r %t.summ0.bc,Write4_2, \
+; RUN:  -r %t.summ0.bc,Write8, \
+; RUN:  -r %t.summ0.bc,WriteAndReturn8, \
+; RUN:  -r %t.summ0.bc,TestUpdateArg,px \
+; RUN:  -r %t.summ0.bc,ExternalCall, \
+; RUN:  -r %t.summ0.bc,PreemptableWrite1, \
+; RUN:  -r %t.summ0.bc,InterposableWrite1, \
+; RUN:  -r %t.summ0.bc,ReturnDependent, \
+; RUN:  -r %t.summ0.bc,Rec2, \
+; RUN:  -r %t.summ0.bc,RecursiveNoOffset, \
+; RUN:  -r %t.summ0.bc,RecursiveWithOffset, \
+; RUN:  -r %t.summ0.bc,f1,px \
+; RUN:  -r %t.summ0.bc,f2,px \
+; RUN:  -r %t.summ0.bc,f3,px \
+; RUN:  -r %t.summ0.bc,f4,px \
+; RUN:  -r %t.summ0.bc,f5,px \
+; RUN:  -r %t.summ0.bc,f6,px \
+; RUN:  -r %t.summ0.bc,PreemptableCall,px \
+; RUN:  -r %t.summ0.bc,InterposableCall,px \
+; RUN:  -r %t.summ0.bc,PrivateCall,px \
+; RUN:  -r %t.summ0.bc,f7,px \
+; RUN:  -r %t.summ0.bc,f8left,px \
+; RUN:  -r %t.summ0.bc,f8right,px \
+; RUN:  -r %t.summ0.bc,f8oobleft,px \
+; RUN:  -r %t.summ0.bc,f8oobright,px \
+; RUN:  -r %t.summ0.bc,TwoArguments,px \
+; RUN:  -r %t.summ0.bc,TwoArgumentsOOBOne,px \
+; RUN:  -r %t.summ0.bc,TwoArgumentsOOBOther,px \
+; RUN:  -r %t.summ0.bc,TwoArgumentsOOBBoth,px \
+; RUN:  -r %t.summ0.bc,TestRecursiveNoOffset,px \
+; RUN:  -r %t.summ0.bc,TestRecursiveWithOffset,px \
+; RUN:  -r %t.summ1.bc,Write1,px \
+; RUN:  -r %t.summ1.bc,Write4,px \
+; RUN:  -r %t.summ1.bc,Write4_2,px \
+; RUN:  -r %t.summ1.bc,Write8,px \
+; RUN:  -r %t.summ1.bc,WriteAndReturn8,px \
+; RUN:  -r %t.summ1.bc,ExternalCall,px \
+; RUN:  -r %t.summ1.bc,PreemptableWrite1,px \
+; RUN:  -r %t.summ1.bc,InterposableWrite1,px \
+; RUN:  -r %t.summ1.bc,ReturnDependent,px \
+; RUN:  -r %t.summ1.bc,Rec0,px \
+; RUN:  -r %t.summ1.bc,Rec1,px \
+; RUN:  -r %t.summ1.bc,Rec2,px \
+; RUN:  -r %t.summ1.bc,RecursiveNoOffset,px \
+; RUN:  -r %t.summ1.bc,RecursiveWithOffset,px \
+; RUN:  -r %t.summ1.bc,ReturnAlloca,px 2>&1 | FileCheck %s --check-prefixes=CHECK,GLOBAL,LTO
+
+; RUN: llvm-lto2 run %t.summ0.bc %t.summ1.bc -o %t-newpm.lto -use-new-pm -stack-safety-print -stack-safety-run -save-temps -thinlto-threads 1 -O0 \
+; RUN:  -r %t.summ0.bc,Write1, \
+; RUN:  -r %t.summ0.bc,Write4, \
+; RUN:  -r %t.summ0.bc,Write4_2, \
+; RUN:  -r %t.summ0.bc,Write8, \
+; RUN:  -r %t.summ0.bc,WriteAndReturn8, \
+; RUN:  -r %t.summ0.bc,TestUpdateArg,px \
+; RUN:  -r %t.summ0.bc,ExternalCall, \
+; RUN:  -r %t.summ0.bc,PreemptableWrite1, \
+; RUN:  -r %t.summ0.bc,InterposableWrite1, \
+; RUN:  -r %t.summ0.bc,ReturnDependent, \
+; RUN:  -r %t.summ0.bc,Rec2, \
+; RUN:  -r %t.summ0.bc,RecursiveNoOffset, \
+; RUN:  -r %t.summ0.bc,RecursiveWithOffset, \
+; RUN:  -r %t.summ0.bc,f1,px \
+; RUN:  -r %t.summ0.bc,f2,px \
+; RUN:  -r %t.summ0.bc,f3,px \
+; RUN:  -r %t.summ0.bc,f4,px \
+; RUN:  -r %t.summ0.bc,f5,px \
+; RUN:  -r %t.summ0.bc,f6,px \
+; RUN:  -r %t.summ0.bc,PreemptableCall,px \
+; RUN:  -r %t.summ0.bc,InterposableCall,px \
+; RUN:  -r %t.summ0.bc,PrivateCall,px \
+; RUN:  -r %t.summ0.bc,f7,px \
+; RUN:  -r %t.summ0.bc,f8left,px \
+; RUN:  -r %t.summ0.bc,f8right,px \
+; RUN:  -r %t.summ0.bc,f8oobleft,px \
+; RUN:  -r %t.summ0.bc,f8oobright,px \
+; RUN:  -r %t.summ0.bc,TwoArguments,px \
+; RUN:  -r %t.summ0.bc,TwoArgumentsOOBOne,px \
+; RUN:  -r %t.summ0.bc,TwoArgumentsOOBOther,px \
+; RUN:  -r %t.summ0.bc,TwoArgumentsOOBBoth,px \
+; RUN:  -r %t.summ0.bc,TestRecursiveNoOffset,px \
+; RUN:  -r %t.summ0.bc,TestRecursiveWithOffset,px \
+; RUN:  -r %t.summ1.bc,Write1,px \
+; RUN:  -r %t.summ1.bc,Write4,px \
+; RUN:  -r %t.summ1.bc,Write4_2,px \
+; RUN:  -r %t.summ1.bc,Write8,px \
+; 

[clang] c1e47b4 - [StackSafety] Run ThinLTO

2020-06-12 Thread Vitaly Buka via cfe-commits

Author: Vitaly Buka
Date: 2020-06-12T18:11:29-07:00
New Revision: c1e47b47f8848bb4c1ead8c530940d783c1fbf46

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

LOG: [StackSafety] Run ThinLTO

Summary:
ThinLTO linking runs dataflow processing on collected
function parameters. Then StackSafetyGlobalInfoWrapperPass
in ThinLTO backend will run as usual looking up to external
symbol in the summary if needed.

Depends on D80985.

Reviewers: eugenis, pcc

Reviewed By: eugenis

Subscribers: inglorion, hiraditya, steven_wu, dexonsmith, cfe-commits, 
llvm-commits

Tags: #clang, #llvm

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

Added: 


Modified: 
clang/test/Driver/memtag_lto.c
llvm/include/llvm/Analysis/StackSafetyAnalysis.h
llvm/lib/Analysis/StackSafetyAnalysis.cpp
llvm/lib/LTO/LTO.cpp
llvm/test/Analysis/StackSafetyAnalysis/ipa-alias.ll
llvm/test/Analysis/StackSafetyAnalysis/ipa.ll

Removed: 




diff  --git a/clang/test/Driver/memtag_lto.c b/clang/test/Driver/memtag_lto.c
index 81a6f7b842e1..3421e4028db1 100644
--- a/clang/test/Driver/memtag_lto.c
+++ b/clang/test/Driver/memtag_lto.c
@@ -85,7 +85,7 @@
 // RUN:  -r %t.ltonewpm2.bc,use,plx \
 // RUN:  -r %t.ltonewpm2.bc,z, 2>&1 | FileCheck %s 
-check-prefixes=SSI,XSAFE,YSAFE
 
-// FIXME: Thin LTO: both are safe.
+// Thin LTO: both are safe.
 // RUN: %clang -fno-experimental-new-pass-manager -O1 -target 
aarch64-unknown-linux -march=armv8+memtag -fsanitize=memtag -c %s -flto=thin -o 
%t.thinlto1.bc
 // RUN: %clang -fno-experimental-new-pass-manager -O1 -target 
aarch64-unknown-linux -march=armv8+memtag -fsanitize=memtag -c -DBUILD2 %s 
-flto=thin -o %t.thinlto2.bc
 // RUN: llvm-lto2 run -o %t.thinlto %t.thinlto1.bc %t.thinlto2.bc -save-temps 
-stack-safety-print -thinlto-threads 1 -O1 \
@@ -94,9 +94,9 @@
 // RUN:  -r %t.thinlto1.bc,use_local,plx \
 // RUN:  -r %t.thinlto1.bc,w, \
 // RUN:  -r %t.thinlto2.bc,use,plx \
-// RUN:  -r %t.thinlto2.bc,z, 2>&1 | FileCheck %s 
-check-prefixes=SSI,XUNSAFE,YSAFE
+// RUN:  -r %t.thinlto2.bc,z, 2>&1 | FileCheck %s 
-check-prefixes=SSI,XSAFE,YSAFE
 
-// FIXME: Thin LTO, new PM: both are safe.
+// Thin LTO, new PM: both are safe.
 // RUN: %clang -fexperimental-new-pass-manager -O1 -target 
aarch64-unknown-linux -march=armv8+memtag -fsanitize=memtag -c %s -flto=thin -o 
%t.thinltonewpm1.bc
 // RUN: %clang -fexperimental-new-pass-manager -O1 -target 
aarch64-unknown-linux -march=armv8+memtag -fsanitize=memtag -c -DBUILD2 %s 
-flto=thin -o %t.thinltonewpm2.bc
 // RUN: llvm-lto2 run -use-new-pm -o %t.thinltonewpm %t.thinltonewpm1.bc 
%t.thinltonewpm2.bc -save-temps -stack-safety-print -thinlto-threads 1 -O1 \
@@ -105,7 +105,7 @@
 // RUN:  -r %t.thinltonewpm1.bc,use_local,plx \
 // RUN:  -r %t.thinltonewpm1.bc,w, \
 // RUN:  -r %t.thinltonewpm2.bc,use,plx \
-// RUN:  -r %t.thinltonewpm2.bc,z, 2>&1 | FileCheck %s 
-check-prefixes=SSI,XUNSAFE,YSAFE
+// RUN:  -r %t.thinltonewpm2.bc,z, 2>&1 | FileCheck %s 
-check-prefixes=SSI,XSAFE,YSAFE
 
 void use(int *p);
 

diff  --git a/llvm/include/llvm/Analysis/StackSafetyAnalysis.h 
b/llvm/include/llvm/Analysis/StackSafetyAnalysis.h
index 0b37decfccca..3ee520eb0411 100644
--- a/llvm/include/llvm/Analysis/StackSafetyAnalysis.h
+++ b/llvm/include/llvm/Analysis/StackSafetyAnalysis.h
@@ -151,6 +151,8 @@ class StackSafetyGlobalInfoWrapperPass : public ModulePass {
 
 bool needsParamAccessSummary(const Module &M);
 
+void generateParamAccessSummary(ModuleSummaryIndex &Index);
+
 } // end namespace llvm
 
 #endif // LLVM_ANALYSIS_STACKSAFETYANALYSIS_H

diff  --git a/llvm/lib/Analysis/StackSafetyAnalysis.cpp 
b/llvm/lib/Analysis/StackSafetyAnalysis.cpp
index 3fb5c294acf6..a59d564cd1cc 100644
--- a/llvm/lib/Analysis/StackSafetyAnalysis.cpp
+++ b/llvm/lib/Analysis/StackSafetyAnalysis.cpp
@@ -544,6 +544,22 @@ StackSafetyDataFlowAnalysis::run() {
   return Functions;
 }
 
+FunctionSummary *resolveCallee(GlobalValueSummary *S) {
+  while (S) {
+if (!S->isLive() || !S->isDSOLocal())
+  return nullptr;
+if (FunctionSummary *FS = dyn_cast(S))
+  return FS;
+AliasSummary *AS = dyn_cast(S);
+if (!AS)
+  return nullptr;
+S = AS->getBaseObject();
+if (S == AS)
+  return nullptr;
+  }
+  return nullptr;
+}
+
 const Function *findCalleeInModule(const GlobalValue *GV) {
   while (GV) {
 if (GV->isDeclaration() || GV->isInterposable() || !GV->isDSOLocal())
@@ -560,7 +576,28 @@ const Function *findCalleeInModule(const GlobalValue *GV) {
   return nullptr;
 }
 
-template  void resolveAllCalls(UseInfo &Use) {
+GlobalValueSummary *getGlobalValueSummary(const ModuleSummaryIndex *Index,
+  uint64_t ValueGUID) {
+  auto VI = Index->getValueInfo(ValueGUID);
+  if (!VI || VI.getSummaryList(

[PATCH] D74166: [AIX][Frontend] Static init implementation for AIX considering no priority

2020-06-12 Thread Xiangling Liao via Phabricator via cfe-commits
Xiangling_L updated this revision to Diff 270548.
Xiangling_L marked 35 inline comments as done.
Xiangling_L edited the summary of this revision.
Xiangling_L added a comment.

Address another round of reviews;


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74166

Files:
  clang/include/clang/AST/Mangle.h
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/CodeGen/CGCXXABI.h
  clang/lib/CodeGen/CGDeclCXX.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/aix-constructor-attribute.cpp
  clang/test/CodeGen/aix-destructor-attribute.cpp
  clang/test/CodeGen/aix-init-priority-attribute.cpp
  clang/test/CodeGen/static-init.cpp

Index: clang/test/CodeGen/static-init.cpp
===
--- clang/test/CodeGen/static-init.cpp
+++ clang/test/CodeGen/static-init.cpp
@@ -1,12 +1,139 @@
-// RUN: not %clang_cc1 -triple powerpc-ibm-aix-xcoff -S -emit-llvm -x c++ %s \
-// RUN: -o /dev/null 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -S -emit-llvm -x c++ \
+// RUN: -fno-use-cxa-atexit -std=c++2a < %s | \
+// RUN:   FileCheck --check-prefixes=CHECK,CHECK32 %s
 
-// RUN: not %clang_cc1 -triple powerpc64-ibm-aix-xcoff -S -emit-llvm -x c++ %s \
-// RUN: -o /dev/null 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -S -emit-llvm -x c++ \
+// RUN: -fno-use-cxa-atexit -std=c++2a < %s | \
+// RUN:   FileCheck --check-prefixes=CHECK,CHECK64 %s
 
-struct test {
-  test();
-  ~test();
-} t;
+namespace test1 {
+  struct Test1 {
+Test1();
+~Test1();
+  } t1, t2;
+}; // namespace test1
 
-// CHECK: error in backend: Static initialization has not been implemented on XL ABI yet.
+namespace test2 {
+  int foo() { return 3; }
+  int x = foo();
+}; // namespace test2
+
+namespace test3 {
+  struct Test {
+constexpr Test() {};
+~Test() {};
+  };
+
+  constinit Test t;
+}; // namespace test3
+
+// CHECK: @llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @__sinit8000_clang_510e898aa8d263cac999dd03eeed5b51, i8* null }]
+// CHECK: @llvm.global_dtors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @__sterm8000_clang_510e898aa8d263cac999dd03eeed5b51, i8* null }]
+
+// CHECK: define internal void @__cxx_global_var_init() #0 {
+// CHECK: entry: 
+// CHECK:   call void @_ZN5test15Test1C1Ev(%"struct.test1::Test1"* @_ZN5test12t1E)
+// CHECK:   %0 = call i32 @atexit(void ()* @__dtor__ZN5test12t1E)
+// CHECK:   ret void
+// CHECK: }
+
+// CHECK: define internal void @__dtor__ZN5test12t1E() #0 {
+// CHECK: entry:
+// CHECK:   call void @_ZN5test15Test1D1Ev(%"struct.test1::Test1"* @_ZN5test12t1E)
+// CHECK:   ret void
+// CHECK: }
+
+// CHECK: declare i32 @atexit(void ()*)
+
+// CHECK: define internal void @__finalize__ZN5test12t1E() #0 {
+// CHECK: entry:
+// CHECK:   %0 = call i32 @unatexit(void ()* @__dtor__ZN5test12t1E)
+// CHECK:   %needsDestruct = icmp eq i32 %0, 0
+// CHECK:   br i1 %needsDestruct, label %destruct.call, label %destruct.end
+
+// CHECK: destruct.call:
+// CHECK:   call void @__dtor__ZN5test12t1E()
+// CHECK:   br label %destruct.end
+
+// CHECK: destruct.end:
+// CHECK:   ret void
+// CHECK: }
+
+// CHECK: declare i32 @unatexit(void ()*)
+
+// CHECK: define internal void @__cxx_global_var_init.1() #0 {
+// CHECK: entry:
+// CHECK:   call void @_ZN5test15Test1C1Ev(%"struct.test1::Test1"* @_ZN5test12t2E)
+// CHECK:   %0 = call i32 @atexit(void ()* @__dtor__ZN5test12t2E)
+// CHECK:   ret void
+// CHECK: }
+
+// CHECK: define internal void @__dtor__ZN5test12t2E() #0 {
+// CHECK: entry:
+// CHECK:   call void @_ZN5test15Test1D1Ev(%"struct.test1::Test1"* @_ZN5test12t2E)
+// CHECK:   ret void
+// CHECK: }
+
+// CHECK: define internal void @__finalize__ZN5test12t2E() #0 {
+// CHECK: entry:
+// CHECK:   %0 = call i32 @unatexit(void ()* @__dtor__ZN5test12t2E)
+// CHECK:   %needsDestruct = icmp eq i32 %0, 0
+// CHECK:   br i1 %needsDestruct, label %destruct.call, label %destruct.end
+
+// CHECK: destruct.call:
+// CHECK:   call void @__dtor__ZN5test12t2E()
+// CHECK:   br label %destruct.end
+
+// CHECK: destruct.end:
+// CHECK:   ret void
+// CHECK: }
+
+// CHECK: define internal void @__cxx_global_var_init.2() #0 {
+// CHECK: entry:
+// CHECK32: %call = call i32 @_ZN5test23fooEv()
+// CHECK64: %call = call signext i32 @_ZN5test23fooEv()
+// CHECK:   store i32 %call, i32* @_ZN5test21xE
+// CHECK:   ret void
+// CHECK: }
+
+// CHECK: define internal void @__cxx_global_var_init.3() #0 {
+// CHECK: entry:
+// CHECK:   %0 = call i32 @atexit(void ()* @__dtor__ZN5test31tE)
+// CHECK:   ret void
+// CHECK: }
+
+// CHECK: define internal void @__dtor__ZN5test31tE() #0 {
+// CHECK: e

[PATCH] D74166: [AIX][Frontend] Static init implementation for AIX considering no priority

2020-06-12 Thread Xiangling Liao via Phabricator via cfe-commits
Xiangling_L added inline comments.



Comment at: clang/lib/CodeGen/CGDeclCXX.cpp:639
+  if (CXXGlobalInits.empty())
+return;
 

hubert.reinterpretcast wrote:
> Can this part be committed in a separate patch? It does not appear to have 
> dependencies on other parts of this patch and has the appearance of being a 
> possible change for other platforms.
Sure. I will create a NFC patch for this part and try to commit it first. But 
so far, I think I can keep this part in this patch just for review purpose to 
make the patch look nicer?



Comment at: clang/lib/CodeGen/CGDeclCXX.cpp:704
   AddGlobalDtor(Fn);
+  CXXGlobalDtors.clear();
 }

hubert.reinterpretcast wrote:
> If this is another drive-by fix, can we put it in a separate patch?
Sure, I will put it in the above mentioned clean-up NFC patch as well.



Comment at: clang/lib/CodeGen/CGDeclCXX.cpp:700
+
+Fn = CreateGlobalInitOrDestructFunction(
+FTy, llvm::Twine("__sterm8000_clang_") + GlobalUniqueModuleId, FI,

hubert.reinterpretcast wrote:
> The called function is to be renamed.
Any suggestions here about how to represent the functionality of `__sterm` and 
`_GLOBAL__D_a` into one word? Cannot think of a good name...

Actually I am wondering do we need to rename the `Destruct` part? The `__sterm` 
and `_GLOBAL__D_a` do destruct the object by calling sterm finalizers and 
object destructors?



Comment at: clang/lib/CodeGen/CGDeclCXX.cpp:807
 
 void CodeGenFunction::GenerateCXXGlobalDtorsFunc(
 llvm::Function *Fn,

hubert.reinterpretcast wrote:
> This function is to be renamed.
 I will try `GenerateCXXGlobalDestructFunc` based on the thoughts as I also 
mentioned elsewhere that the `__sterm` and `_GLOBAL__D_` function do destruct 
the object by calling sterm finalizers and object destructors.

Any suggestions or concerns about this renaming? Or do we really need to rename 
this one?



Comment at: clang/lib/CodeGen/ItaniumCXXABI.cpp:4467
+
+  // Create a variable destruction function.
+  const CGFunctionInfo &FI = CGM.getTypes().arrangeNullaryFunction();

hubert.reinterpretcast wrote:
> Suggestion:
> Create the finalization action associated with a variable.
I don't get your point, can you elaborate on this a little bit?



Comment at: clang/test/CodeGen/static-init.cpp:8
+// RUN:   FileCheck %s
 
 struct test {

jasonliu wrote:
> Looks like the non-inline comments are easier to get ignored and missed, so I 
> will copy paste the non-inlined comment I previously had:
> ```
> -fregister_global_dtors_with_atexit does not seem to work properly in current 
> implementation.
> We should consider somehow disabling/report_fatal_error it instead of letting 
> it generate invalid code on AIX.
> ```
Thanks for doing so!

The semantic of `global_dtors` here on AIX is `__sterm` function, which we are 
never gonna register with `__atexit`. I am thinking we can disable it in a 
follow-up driver patch with the handling of `-fno-use-cxa-atexit`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74166



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


[PATCH] D81774: [PowerPC][Power10] Implement VSX PCV Generate Operations in LLVM/Clang

2020-06-12 Thread Amy Kwan via Phabricator via cfe-commits
amyk created this revision.
amyk added reviewers: nemanjai, saghir, power-llvm-team, PowerPC, hfinkel.
amyk added projects: LLVM, clang, PowerPC.
Herald added subscribers: shchenz, hiraditya.

This patch implements builtins for the following prototypes for the VSX Permute 
Control Vector Generate with Mask Instructions:

  vector unsigned char vec_genpcvm (vector unsigned char, const int);
  vector unsigned short vec_genpcvm (vector unsigned short, const int);
  vector unsigned int vec_genpcvm (vector unsigned int, const int);
  vector unsigned long long vec_genpcvm (vector unsigned long long, const int);

Depends on D80935 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81774

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

Index: llvm/test/MC/PowerPC/p10.s
===
--- llvm/test/MC/PowerPC/p10.s
+++ llvm/test/MC/PowerPC/p10.s
@@ -15,3 +15,15 @@
 # CHECK-BE: pextd 1, 2, 4 # encoding: [0x7c,0x41,0x21,0x78]
 # CHECK-LE: pextd 1, 2, 4 # encoding: [0x78,0x21,0x41,0x7c]
 pextd 1, 2, 4
+# CHECK-BE: xxgenpcvbm 0, 1, 2# encoding: [0xf0,0x02,0x0f,0x28]
+# CHECK-LE: xxgenpcvbm 0, 1, 2# encoding: [0x28,0x0f,0x02,0xf0]
+xxgenpcvbm 0, 1, 2
+# CHECK-BE: xxgenpcvhm 0, 1, 2# encoding: [0xf0,0x02,0x0f,0x2a]
+# CHECK-LE: xxgenpcvhm 0, 1, 2# encoding: [0x2a,0x0f,0x02,0xf0]
+xxgenpcvhm 0, 1, 2
+# CHECK-BE: xxgenpcvwm 0, 1, 2# encoding: [0xf0,0x02,0x0f,0x68]
+# CHECK-LE: xxgenpcvwm 0, 1, 2# encoding: [0x68,0x0f,0x02,0xf0]
+xxgenpcvwm 0, 1, 2
+# CHECK-BE: xxgenpcvdm 0, 1, 2# encoding: [0xf0,0x02,0x0f,0x6a]
+# CHECK-LE: xxgenpcvdm 0, 1, 2# encoding: [0x6a,0x0f,0x02,0xf0]
+xxgenpcvdm 0, 1, 2
Index: llvm/test/MC/Disassembler/PowerPC/p10insts.txt
===
--- llvm/test/MC/Disassembler/PowerPC/p10insts.txt
+++ llvm/test/MC/Disassembler/PowerPC/p10insts.txt
@@ -12,3 +12,15 @@
 
 # CHECK: pextd 1, 2, 4
 0x7c 0x41 0x21 0x78
+
+# CHECK xxgenpcvbm 0, 1, 2
+0xf0 0x02 0x0f 0x28
+
+# CHECK xxgenpcvhm 0, 1, 2
+0xf0 0x02 0x0f 0x2a
+
+# CHECK xxgenpcvwm 0, 1, 2
+0xf0 0x02 0x0f 0x68
+
+# CHECK xxgenpcvdm 0, 1, 2
+0xf0 0x02 0x0f 0x6a
Index: llvm/test/CodeGen/PowerPC/p10-vsx-pcv.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/p10-vsx-pcv.ll
@@ -0,0 +1,51 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu \
+; RUN:   -mcpu=pwr10 -ppc-asm-full-reg-names -ppc-vsr-nums-as-vr < %s | \
+; RUN:   FileCheck %s
+
+; These test cases aim to test the VSX PCV Generate Operations on Power10.
+
+declare <16 x i8> @llvm.ppc.vsx.xxgenpcvbm(<16 x i8>, i32)
+declare <8 x i16> @llvm.ppc.vsx.xxgenpcvhm(<8 x i16>, i32)
+declare <4 x i32> @llvm.ppc.vsx.xxgenpcvwm(<4 x i32>, i32)
+declare <2 x i64> @llvm.ppc.vsx.xxgenpcvdm(<2 x i64>, i32)
+
+define <16 x i8> @test_xxgenpcvbm(<16 x i8> %a) {
+; CHECK-LABEL: test_xxgenpcvbm:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:xxgenpcvbm v2, v2, 1
+; CHECK-NEXT:blr
+entry:
+  %gen = tail call <16 x i8> @llvm.ppc.vsx.xxgenpcvbm(<16 x i8> %a, i32 1)
+  ret <16 x i8> %gen
+}
+
+define <8 x i16> @test_xxgenpcvhm(<8 x i16> %a) {
+; CHECK-LABEL: test_xxgenpcvhm:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:xxgenpcvhm v2, v2, 1
+; CHECK-NEXT:blr
+entry:
+  %gen = tail call <8 x i16> @llvm.ppc.vsx.xxgenpcvhm(<8 x i16> %a, i32 1)
+  ret <8 x i16> %gen
+}
+
+define <4 x i32> @test_xxgenpcvwm(<4 x i32> %a) {
+; CHECK-LABEL: test_xxgenpcvwm:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:xxgenpcvwm v2, v2, 1
+; CHECK-NEXT:blr
+entry:
+  %gen = tail call <4 x i32> @llvm.ppc.vsx.xxgenpcvwm(<4 x i32> %a, i32 1)
+  ret <4 x i32> %gen
+}
+
+define <2 x i64> @test_xxgenpcvdm(<2 x i64> %a) {
+; CHECK-LABEL: test_xxgenpcvdm:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:xxgenpcvdm v2, v2, 1
+; CHECK-NEXT:blr
+entry:
+  %gen = tail call <2 x i64> @llvm.ppc.vsx.xxgenpcvdm(<2 x i64> %a, i32 1)
+  ret <2 x i64> %gen
+}
Index: llvm/lib/Target/PowerPC/PPCInstrPrefix.td
===
--- llvm/lib/Target/PowerPC/PPCInstrPrefix.td
+++ llvm/lib/Target/PowerPC/PPCInstrPrefix.td
@@ -161,6 +161,22 @@
   let Inst{48-63} = D_RA{15-0}; // d1
 }
 
+// X-Form: [PO T IMM VRB XO TX]
+class XF

[PATCH] D81721: [SVE] Ensure proper mangling of ACLE tuple types

2020-06-12 Thread Eli Friedman via Phabricator via cfe-commits
efriedma accepted this revision.
efriedma 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/D81721/new/

https://reviews.llvm.org/D81721



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


[PATCH] D81041: Use existing path sep style in clang::FileManager::FixupRelativePath

2020-06-12 Thread Adrian McCarthy via Phabricator via cfe-commits
amccarth added a comment.

In D81041#2072396 , @ctetreau wrote:

> After some further investigation, I have come to believe that the root cause 
> of the issue I am seeing is on line 783 of clang/lib/Lex/HeaderSearch.cpp. A 
> path is constructed using string concatenation (dir + '/' + file), which is 
> obviously not robust to the various issues in path construction. A fix had 
> been committed and reverted back in 2015.


When I was fixing portability problems with VFS paths, I started out by trying 
to make paths canonical, and that always led to roadblocks.  A clang developer 
told me that clang philosophically does not try to do any regularization of 
paths.  It turns out that's actually key to making VFS paths viable.  Since 
they can truly consist of a mix of styles, there is no "correct" canonical 
form.  Once I took that approach, most of the VFS portability problems were 
simple to fix without inflicting collateral damage.  So I'm not surprised that 
the 2015 "fix" causes problems.

I'm happy to look at future proposals, and I'll CC myself on that bug report.  
But since you've said you have other priorities now, I'll treat this patch as 
dormant.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81041



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


[PATCH] D79972: [OpenMP5.0] map item can be non-contiguous for target update

2020-06-12 Thread Chi Chun Chen via Phabricator via cfe-commits
cchen updated this revision to Diff 270536.
cchen added a comment.

Fix based on feedback


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79972

Files:
  clang/include/clang/AST/OpenMPClause.h
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.h
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/OpenMP/target_update_ast_print.cpp
  clang/test/OpenMP/target_update_codegen.cpp
  clang/test/OpenMP/target_update_messages.cpp
  clang/test/OpenMP/target_update_to_messages.cpp

Index: clang/test/OpenMP/target_update_to_messages.cpp
===
--- clang/test/OpenMP/target_update_to_messages.cpp
+++ clang/test/OpenMP/target_update_to_messages.cpp
@@ -79,6 +79,10 @@
 #pragma omp target update to(*(*(this->ptr)+a+this->ptr)) // le45-error {{expected expression containing only member accesses and/or array sections based on named variables}} le45-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
 #pragma omp target update to(*(this+this)) // expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}} expected-error {{invalid operands to binary expression ('S8 *' and 'S8 *')}}
 {}
+
+double marr[10][5][10];
+#pragma omp target update to(marr [0:] [2:4] [1:2]) // le45-error {{array section does not specify contiguous storage}} le45-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+{}
   }
 };
 
Index: clang/test/OpenMP/target_update_messages.cpp
===
--- clang/test/OpenMP/target_update_messages.cpp
+++ clang/test/OpenMP/target_update_messages.cpp
@@ -1,6 +1,8 @@
-// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,le45 -fopenmp -ferror-limit 100 %s -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,le50 -fopenmp -fopenmp-version=50 -ferror-limit 100 %s -Wuninitialized
 
-// RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 %s -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,le45 -fopenmp-simd -ferror-limit 100 %s -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,le50 -fopenmp-simd -fopenmp-version=50 -ferror-limit 100 %s -Wuninitialized
 
 void xxx(int argc) {
   int x; // expected-note {{initialize the variable 'x' to silence this warning}}
@@ -36,5 +38,21 @@
   {
 foo();
   }
+
+  double marr[10][5][10];
+#pragma omp target update to(marr [0:] [2:4] [1:2]) // le45-error {{array section does not specify contiguous storage}} le45-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+  {}
+#pragma omp target update from(marr [0:] [2:4] [1:2]) // le45-error {{array section does not specify contiguous storage}} le45-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+
+  int arr[4][3][2][1];
+#pragma omp target update to(arr [0:2] [2:4][:2][1]) // le45-error {{array section does not specify contiguous storage}} le45-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+  {}
+#pragma omp target update from(arr [0:2] [2:4][:2][1]) // le45-error {{array section does not specify contiguous storage}} le45-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+
+  double ***dptr;
+#pragma omp target update to(dptr [0:2] [2:4] [1:2]) // le45-error {{array section does not specify contiguous storage}} le50-error 2 {{section length is unspecified and cannot be inferred because subscripted value is an array of unknown bound}} le45-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+  {}
+#pragma omp target update from(dptr [0:2] [2:4] [1:2]) // le45-error {{array section does not specify contiguous storage}} le50-error 2 {{section length is unspecified and cannot be inferred because subscripted value is an array of unknown bound}} le45-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+
   return tmain(argc, argv);
 }
Index: clang/test/OpenMP/target_update_codegen.cpp
===
--- clang/test/OpenMP/target_update_codegen.cpp
+++ clang/test/OpenMP/target_update_codegen.cpp
@@ -1059,5 +1059,283 @@
   #pragma omp target update from(([sa][5])f)
 }
 
+#endif
+
+///==///
+// RUN: %clang_cc1 -DCK19 -verify -fopenmp -fopenmp-version=50 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck %s --check-prefix CK19 --check-

[PATCH] D79972: [OpenMP5.0] map item can be non-contiguous for target update

2020-06-12 Thread Chi Chun Chen via Phabricator via cfe-commits
cchen marked 4 inline comments as done.
cchen added inline comments.



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:7821
+  Context.getTypeSizeInChars(ElementType).getQuantity();
+} else if (VAT) {
+  ElementType = VAT->getElementType().getTypePtr();

ABataev wrote:
> What if the base is a pointer, not an array?
The `if (ElementType)` condition only push back stride when base is not 
pointer. I'm now allowing one dimension size to be unknown (pointer as base) 
and sema has analysis to check if more than one indirection as base. My last 
codegen test case is for testing pointer as base.



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:7831-7838
+  llvm::Value *SizeV = nullptr;
+  if (CAT) {
+llvm::APInt Size = CAT->getSize();
+SizeV = llvm::ConstantInt::get(CGF.SizeTy, Size);
+  } else if (VAT) {
+const Expr *Size = VAT->getSizeExpr();
+SizeV = CGF.EmitScalarExpr(Size);

ABataev wrote:
> The code for `SizeV` must be under the control of the next `if`:
> ```
> if (DimSizes.size() < Components.size() - 1) {
>  
> }
> ```
I don't think I understand this one. Why do you remove SizeV in the if 
condition?



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:7834
+llvm::APInt Size = CAT->getSize();
+SizeV = llvm::ConstantInt::get(CGF.SizeTy, Size);
+  } else if (VAT) {

ABataev wrote:
> Create directly as of `CGF.Int64Ty` type.
Doing this I'll get assertion error in this exact line if on a 32-bits target.



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:7872-7873
+  } else {
+Offset = CGF.Builder.CreateIntCast(CGF.EmitScalarExpr(OffsetExpr),
+   CGF.Int64Ty,
+   /*isSigned=*/false);

ABataev wrote:
> Do you really to pass real offsets here? Can we use pointers instead?
Do you mean I should set the type of Offset to Expr*?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79972



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


[PATCH] D81772: Reduce -Wregister from DefaultError to a default-on warning.

2020-06-12 Thread James Y Knight via Phabricator via cfe-commits
jyknight created this revision.
jyknight added a reviewer: rsmith.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

There is a lot of C++ code in the wild still using 'register', which
will become broken if we switch the default compilation mode to
C++17. A default-on warning seems to get the message across
sufficiently, without unnecessarily breaking code that hasn't asked
for it (e.g. with -Werror). GCC has also chosen to make -Wregister an
on-by-default warning.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81772

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/test/SemaCXX/deprecated.cpp


Index: clang/test/SemaCXX/deprecated.cpp
===
--- clang/test/SemaCXX/deprecated.cpp
+++ clang/test/SemaCXX/deprecated.cpp
@@ -27,13 +27,13 @@
 
 void stuff(register int q) {
 #if __cplusplus > 201402L
-  // expected-error@-2 {{ISO C++17 does not allow 'register' storage class 
specifier}}
+  // expected-warning@-2 {{ISO C++17 does not allow 'register' storage class 
specifier}}
 #elif __cplusplus >= 201103L && !defined(NO_DEPRECATED_FLAGS)
   // expected-warning@-4 {{'register' storage class specifier is deprecated}}
 #endif
   register int n;
 #if __cplusplus > 201402L
-  // expected-error@-2 {{ISO C++17 does not allow 'register' storage class 
specifier}}
+  // expected-warning@-2 {{ISO C++17 does not allow 'register' storage class 
specifier}}
 #elif __cplusplus >= 201103L && !defined(NO_DEPRECATED_FLAGS)
   // expected-warning@-4 {{'register' storage class specifier is deprecated}}
 #endif
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -240,7 +240,7 @@
   "and incompatible with C++17">, InGroup;
 def ext_register_storage_class : ExtWarn<
   "ISO C++17 does not allow 'register' storage class specifier">,
-  DefaultError, InGroup;
+  InGroup;
 
 def err_invalid_decl_spec_combination : Error<
   "cannot combine with previous '%0' declaration specifier">;


Index: clang/test/SemaCXX/deprecated.cpp
===
--- clang/test/SemaCXX/deprecated.cpp
+++ clang/test/SemaCXX/deprecated.cpp
@@ -27,13 +27,13 @@
 
 void stuff(register int q) {
 #if __cplusplus > 201402L
-  // expected-error@-2 {{ISO C++17 does not allow 'register' storage class specifier}}
+  // expected-warning@-2 {{ISO C++17 does not allow 'register' storage class specifier}}
 #elif __cplusplus >= 201103L && !defined(NO_DEPRECATED_FLAGS)
   // expected-warning@-4 {{'register' storage class specifier is deprecated}}
 #endif
   register int n;
 #if __cplusplus > 201402L
-  // expected-error@-2 {{ISO C++17 does not allow 'register' storage class specifier}}
+  // expected-warning@-2 {{ISO C++17 does not allow 'register' storage class specifier}}
 #elif __cplusplus >= 201103L && !defined(NO_DEPRECATED_FLAGS)
   // expected-warning@-4 {{'register' storage class specifier is deprecated}}
 #endif
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -240,7 +240,7 @@
   "and incompatible with C++17">, InGroup;
 def ext_register_storage_class : ExtWarn<
   "ISO C++17 does not allow 'register' storage class specifier">,
-  DefaultError, InGroup;
+  InGroup;
 
 def err_invalid_decl_spec_combination : Error<
   "cannot combine with previous '%0' declaration specifier">;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D80833: [CodeView] Add full repro to LF_BUILDINFO record

2020-06-12 Thread Adrian McCarthy via Phabricator via cfe-commits
amccarth accepted this revision.
amccarth added a comment.

My only real concern was about the possible reproducibility impact of 
introducing absolute paths into the binaries.  If @thakis and @hans are 
satisfied this is OK, then LGTM.




Comment at: clang/test/CodeGen/debug-info-codeview-buildinfo.c:8
+// CHECK: 
+// CHECK: 0x[[PWD:.+]] | LF_STRING_ID [size = {{.+}}] ID: , String: 
[[PWDVAL:.+]]
+// CHECK: 0x[[FILEPATH:.+]] | LF_STRING_ID [size = {{.+}}] ID: , 
String: [[FILEPATHVAL:.+[\\/]debug-info-codeview-buildinfo.c]]

aganea wrote:
> amccarth wrote:
> > PWD?  Did you mean CWD (current working directory)?
> I meant the current working directory when the program starts. I was under 
> the impression that the nomenclature for that is PWD = CWD at startup. While 
> CWD is the current directory at any point in time during the execution, and 
> can be different of PWD.
> Would you prefer if I changed the regex capture name to CWD?
Sorry, I always misread "pwd" as "password."




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80833



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


[PATCH] D80751: [clang][diagnostics] Add '-Wundef-prefix' warning option

2020-06-12 Thread Zixu Wang via Phabricator via cfe-commits
zixuw added inline comments.



Comment at: clang/lib/Lex/PPExpressions.cpp:262
+  // string to UndefPrefixes as an explicit "-Wundef" does.
+  if (UndefPrefixes.empty() ||
+  llvm::any_of(UndefPrefixes,

arphaman wrote:
> zixuw wrote:
> > ributzka wrote:
> > > What happens when you use `-Werror=undef` and `-Wundef-prefix=`?
> > Then we only get errors for `undef-prefix=`. Yes this needs to be 
> > fixed.
> > Perhaps a better way to handle the `-Werror=undef` implication of `-Wundef`.
> We should try to fix this in this PR then. Can you check the severity of the 
> diagnostic, and if it's an error always emit it here?
That is an option. But then we lose the ability to intentionally turning just 
the prefixes into errors, like `-Wundef-prefix=FOO -Werror` or 
`-Wundef-prefix=BAR -Werror=undef-prefix`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80751



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


[PATCH] D81771: [CUDA,HIP] Use VFS for SDK detection.

2020-06-12 Thread Artem Belevich via Phabricator via cfe-commits
tra created this revision.
tra added reviewers: yaxunl, arsenm.
Herald added subscribers: kerbowa, sanjoy.google, bixia, nhaehnle, wdng, 
jvesely.
Herald added a project: clang.
tra updated this revision to Diff 270533.
tra edited the summary of this revision.
tra added a comment.

Replaced another use of D.getVFS.


It's useful for using clang from tools that may need need to provide SDK files
from non-standard locations.

Clang CLI only provides `-ivfsoverlay` for include files, but not for the 
driver's use in general, so there's no
good way to test this yet.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81771

Files:
  clang/lib/Driver/ToolChains/AMDGPU.cpp
  clang/lib/Driver/ToolChains/Cuda.cpp


Index: clang/lib/Driver/ToolChains/Cuda.cpp
===
--- clang/lib/Driver/ToolChains/Cuda.cpp
+++ clang/lib/Driver/ToolChains/Cuda.cpp
@@ -78,6 +78,7 @@
 
   // In decreasing order so we prefer newer versions to older versions.
   std::initializer_list Versions = {"8.0", "7.5", "7.0"};
+  auto &FS = D.getVFS();
 
   if (Args.hasArg(clang::driver::options::OPT_cuda_path_EQ)) {
 Candidates.emplace_back(
@@ -114,7 +115,7 @@
 for (const char *Ver : Versions)
   Candidates.emplace_back(D.SysRoot + "/usr/local/cuda-" + Ver);
 
-Distro Dist(D.getVFS(), llvm::Triple(llvm::sys::getProcessTriple()));
+Distro Dist(FS, llvm::Triple(llvm::sys::getProcessTriple()));
 if (Dist.IsDebian() || Dist.IsUbuntu())
   // Special case for Debian to have nvidia-cuda-toolkit work
   // out of the box. More info on http://bugs.debian.org/882505
@@ -125,14 +126,13 @@
 
   for (const auto &Candidate : Candidates) {
 InstallPath = Candidate.Path;
-if (InstallPath.empty() || !D.getVFS().exists(InstallPath))
+if (InstallPath.empty() || !FS.exists(InstallPath))
   continue;
 
 BinPath = InstallPath + "/bin";
 IncludePath = InstallPath + "/include";
 LibDevicePath = InstallPath + "/nvvm/libdevice";
 
-auto &FS = D.getVFS();
 if (!(FS.exists(IncludePath) && FS.exists(BinPath)))
   continue;
 bool CheckLibDevice = (!NoCudaLib || Candidate.StrictChecking);
@@ -177,7 +177,8 @@
   }
 } else {
   std::error_code EC;
-  for (llvm::sys::fs::directory_iterator LI(LibDevicePath, EC), LE;
+  for (llvm::vfs::directory_iterator LI = FS.dir_begin(LibDevicePath, EC),
+ LE;
!EC && LI != LE; LI = LI.increment(EC)) {
 StringRef FilePath = LI->path();
 StringRef FileName = llvm::sys::path::filename(FilePath);
Index: clang/lib/Driver/ToolChains/AMDGPU.cpp
===
--- clang/lib/Driver/ToolChains/AMDGPU.cpp
+++ clang/lib/Driver/ToolChains/AMDGPU.cpp
@@ -27,7 +27,9 @@
   const StringRef Suffix(".bc");
 
   std::error_code EC;
-  for (llvm::sys::fs::directory_iterator LI(LibDevicePath, EC), LE;
+  for (llvm::vfs::directory_iterator
+   LI = D.getVFS().dir_begin(LibDevicePath, EC),
+   LE;
!EC && LI != LE; LI = LI.increment(EC)) {
 StringRef FilePath = LI->path();
 StringRef FileName = llvm::sys::path::filename(FilePath);
@@ -137,11 +139,12 @@
 LibDevicePath = LibPathEnv;
   }
 
+  auto &FS = D.getVFS();
   if (!LibDevicePath.empty()) {
 // Maintain compatability with HIP flag/envvar pointing directly at the
 // bitcode library directory. This points directly at the library path 
instead
 // of the rocm root installation.
-if (!D.getVFS().exists(LibDevicePath))
+if (!FS.exists(LibDevicePath))
   return;
 
 scanLibDevicePath();
@@ -151,7 +154,7 @@
 
   for (const auto &Candidate : Candidates) {
 InstallPath = Candidate.Path;
-if (InstallPath.empty() || !D.getVFS().exists(InstallPath))
+if (InstallPath.empty() || !FS.exists(InstallPath))
   continue;
 
 // The install path situation in old versions of ROCm is a real mess, and
@@ -167,8 +170,6 @@
 llvm::sys::path::append(IncludePath, InstallPath, "include");
 llvm::sys::path::append(LibDevicePath, InstallPath, "amdgcn", "bitcode");
 
-auto &FS = D.getVFS();
-
 // We don't need the include path for OpenCL, since clang already ships 
with
 // the default header.
 


Index: clang/lib/Driver/ToolChains/Cuda.cpp
===
--- clang/lib/Driver/ToolChains/Cuda.cpp
+++ clang/lib/Driver/ToolChains/Cuda.cpp
@@ -78,6 +78,7 @@
 
   // In decreasing order so we prefer newer versions to older versions.
   std::initializer_list Versions = {"8.0", "7.5", "7.0"};
+  auto &FS = D.getVFS();
 
   if (Args.hasArg(clang::driver::options::OPT_cuda_path_EQ)) {
 Candidates.emplace_back(
@@ -114,7 +115,7 @@
 for (const char *Ver : Versions)
   Candidates.emplace_back(D.SysRoot + "/usr/local/cuda-" + Ver);
 
-Distro Dist(D.getVFS(), llvm::Triple(llvm::sys::getProcessTriple(

[PATCH] D81771: [CUDA,HIP] Use VFS for SDK detection.

2020-06-12 Thread Artem Belevich via Phabricator via cfe-commits
tra updated this revision to Diff 270533.
tra edited the summary of this revision.
tra added a comment.

Replaced another use of D.getVFS.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81771

Files:
  clang/lib/Driver/ToolChains/AMDGPU.cpp
  clang/lib/Driver/ToolChains/Cuda.cpp


Index: clang/lib/Driver/ToolChains/Cuda.cpp
===
--- clang/lib/Driver/ToolChains/Cuda.cpp
+++ clang/lib/Driver/ToolChains/Cuda.cpp
@@ -78,6 +78,7 @@
 
   // In decreasing order so we prefer newer versions to older versions.
   std::initializer_list Versions = {"8.0", "7.5", "7.0"};
+  auto &FS = D.getVFS();
 
   if (Args.hasArg(clang::driver::options::OPT_cuda_path_EQ)) {
 Candidates.emplace_back(
@@ -114,7 +115,7 @@
 for (const char *Ver : Versions)
   Candidates.emplace_back(D.SysRoot + "/usr/local/cuda-" + Ver);
 
-Distro Dist(D.getVFS(), llvm::Triple(llvm::sys::getProcessTriple()));
+Distro Dist(FS, llvm::Triple(llvm::sys::getProcessTriple()));
 if (Dist.IsDebian() || Dist.IsUbuntu())
   // Special case for Debian to have nvidia-cuda-toolkit work
   // out of the box. More info on http://bugs.debian.org/882505
@@ -125,14 +126,13 @@
 
   for (const auto &Candidate : Candidates) {
 InstallPath = Candidate.Path;
-if (InstallPath.empty() || !D.getVFS().exists(InstallPath))
+if (InstallPath.empty() || !FS.exists(InstallPath))
   continue;
 
 BinPath = InstallPath + "/bin";
 IncludePath = InstallPath + "/include";
 LibDevicePath = InstallPath + "/nvvm/libdevice";
 
-auto &FS = D.getVFS();
 if (!(FS.exists(IncludePath) && FS.exists(BinPath)))
   continue;
 bool CheckLibDevice = (!NoCudaLib || Candidate.StrictChecking);
@@ -177,7 +177,8 @@
   }
 } else {
   std::error_code EC;
-  for (llvm::sys::fs::directory_iterator LI(LibDevicePath, EC), LE;
+  for (llvm::vfs::directory_iterator LI = FS.dir_begin(LibDevicePath, EC),
+ LE;
!EC && LI != LE; LI = LI.increment(EC)) {
 StringRef FilePath = LI->path();
 StringRef FileName = llvm::sys::path::filename(FilePath);
Index: clang/lib/Driver/ToolChains/AMDGPU.cpp
===
--- clang/lib/Driver/ToolChains/AMDGPU.cpp
+++ clang/lib/Driver/ToolChains/AMDGPU.cpp
@@ -27,7 +27,9 @@
   const StringRef Suffix(".bc");
 
   std::error_code EC;
-  for (llvm::sys::fs::directory_iterator LI(LibDevicePath, EC), LE;
+  for (llvm::vfs::directory_iterator
+   LI = D.getVFS().dir_begin(LibDevicePath, EC),
+   LE;
!EC && LI != LE; LI = LI.increment(EC)) {
 StringRef FilePath = LI->path();
 StringRef FileName = llvm::sys::path::filename(FilePath);
@@ -137,11 +139,12 @@
 LibDevicePath = LibPathEnv;
   }
 
+  auto &FS = D.getVFS();
   if (!LibDevicePath.empty()) {
 // Maintain compatability with HIP flag/envvar pointing directly at the
 // bitcode library directory. This points directly at the library path 
instead
 // of the rocm root installation.
-if (!D.getVFS().exists(LibDevicePath))
+if (!FS.exists(LibDevicePath))
   return;
 
 scanLibDevicePath();
@@ -151,7 +154,7 @@
 
   for (const auto &Candidate : Candidates) {
 InstallPath = Candidate.Path;
-if (InstallPath.empty() || !D.getVFS().exists(InstallPath))
+if (InstallPath.empty() || !FS.exists(InstallPath))
   continue;
 
 // The install path situation in old versions of ROCm is a real mess, and
@@ -167,8 +170,6 @@
 llvm::sys::path::append(IncludePath, InstallPath, "include");
 llvm::sys::path::append(LibDevicePath, InstallPath, "amdgcn", "bitcode");
 
-auto &FS = D.getVFS();
-
 // We don't need the include path for OpenCL, since clang already ships 
with
 // the default header.
 


Index: clang/lib/Driver/ToolChains/Cuda.cpp
===
--- clang/lib/Driver/ToolChains/Cuda.cpp
+++ clang/lib/Driver/ToolChains/Cuda.cpp
@@ -78,6 +78,7 @@
 
   // In decreasing order so we prefer newer versions to older versions.
   std::initializer_list Versions = {"8.0", "7.5", "7.0"};
+  auto &FS = D.getVFS();
 
   if (Args.hasArg(clang::driver::options::OPT_cuda_path_EQ)) {
 Candidates.emplace_back(
@@ -114,7 +115,7 @@
 for (const char *Ver : Versions)
   Candidates.emplace_back(D.SysRoot + "/usr/local/cuda-" + Ver);
 
-Distro Dist(D.getVFS(), llvm::Triple(llvm::sys::getProcessTriple()));
+Distro Dist(FS, llvm::Triple(llvm::sys::getProcessTriple()));
 if (Dist.IsDebian() || Dist.IsUbuntu())
   // Special case for Debian to have nvidia-cuda-toolkit work
   // out of the box. More info on http://bugs.debian.org/882505
@@ -125,14 +126,13 @@
 
   for (const auto &Candidate : Candidates) {
 InstallPath = Candidate.Path;
-i

[PATCH] D81242: [StackSafety] Run ThinLTO

2020-06-12 Thread Evgenii Stepanov via Phabricator via cfe-commits
eugenis accepted this revision.
eugenis added a comment.
This revision is now accepted and ready to land.

LGTM with 2 notes




Comment at: llvm/lib/Analysis/StackSafetyAnalysis.cpp:618
+ConstantRange Access = Found->sextOrTrunc(Use.Range.getBitWidth());
+if (Access.signedAddMayOverflow(C.Offset) !=
+ConstantRange::OverflowResult::NeverOverflows)

vitalybuka wrote:
> eugenis wrote:
> > Do we have a test for this overflow check?
> yes
> Example, in bit width 8
> [-128,-127)+[-128,-127) = [0,1)
> both non-wrapped and result is non-wrapped so we have no way to spot overflow
Sure. I was asking if we have a testcase that covers the overflow check.



Comment at: llvm/lib/Analysis/StackSafetyAnalysis.cpp:926
+  }
+  // Reset data for all sammaries. Alive and DSO local will be set back 
from
+  // of data flow results below. Anything else will not be accessed

typo: summaries


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81242



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


[PATCH] D81769: Repair various issues with modernize-avoid-bind

2020-06-12 Thread Jeff Trull via Phabricator via cfe-commits
jaafar marked 3 inline comments as done.
jaafar added inline comments.



Comment at: clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp:38
 enum BindArgumentKind { BK_Temporary, BK_Placeholder, BK_CallExpr, BK_Other };
-enum CaptureMode { CM_None, CM_ByRef, CM_ByValue, CM_InitExpression };
+enum CaptureMode { CM_None, CM_ByRef, CM_ByValue };
+enum CaptureExpr { CE_None, CE_Var, CE_InitExpression };

"Captured by reference" and "uses init expression" are not mutually exclusive - 
that gave rise to item 6 above.



Comment at: clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp:150
 
+static bool tryCaptureAsLocalVariable(const MatchFinder::MatchResult &Result,
+  BindArgument &B, const Expr *E);

These forward declarations seemed to make the diffs a lot easier to read. It's 
also possible to move the two functions into this position, of course.



Comment at: clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp:243
+  if ((std::distance(ME->child_begin(), ME->child_end()) == 1) &&
+  isa(*ME->children().begin())) {
+// reference to data member without explicit "this"

Is there a better way to express this? "a single child of type ThisExpr" was 
what I was going for...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81769



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


[PATCH] D81769: Repair various issues with modernize-avoid-bind

2020-06-12 Thread Jeff Trull via Phabricator via cfe-commits
jaafar created this revision.
jaafar added reviewers: aaron.ballman, alexfh, hokein.
jaafar added a project: clang-tools-extra.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

In the process of running this check on a large codebase 
 I found a number of limitations, and 
thought I would pass on my fixes for possible integration upstream:

1. Templated function call operators are not supported
2. Function object constructors are always used directly in the lambda body, 
even if their arguments are not captured
3. Placeholders with namespace qualifiers (`std::placeholders::_1`) are not 
detected
4. Lambda arguments should be forwarded to the stored function
5. Data members from other classes still get captured with `this`
6. Expressions (as opposed to variables) inside `std::ref` are not captured 
properly
7. Function object templates sometimes have their template arguments replaced 
with concrete types

This patch resolves all those issues and adds suitable unit tests.

If desired, I can separate these commits out into 7 separate diffs, but it 
seemed like it might be easier to evaluate them all at once.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81769

Files:
  clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp
  
clang-tools-extra/test/clang-tidy/checkers/modernize-avoid-bind-permissive-parameter-list.cpp
  clang-tools-extra/test/clang-tidy/checkers/modernize-avoid-bind.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/modernize-avoid-bind.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/modernize-avoid-bind.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/modernize-avoid-bind.cpp
@@ -7,11 +7,11 @@
 
 template 
 bind_rt bind(Fp &&, Arguments &&...);
-}
+} // namespace impl
 
 template 
 T ref(T &t);
-}
+} // namespace std
 
 namespace boost {
 template 
@@ -58,12 +58,33 @@
 
 void UseF(F);
 
+struct G {
+  G() : _member(0) {}
+  G(int m) : _member(m) {}
+
+  template 
+  void operator()(T) const {}
+
+  int _member;
+};
+
+template 
+struct H {
+  void operator()(T) const {};
+};
+
 struct placeholder {};
 placeholder _1;
 placeholder _2;
 
+namespace placeholders {
+using ::_1;
+using ::_2;
+} // namespace placeholders
+
 int add(int x, int y) { return x + y; }
 int addThree(int x, int y, int z) { return x + y + z; }
+void sub(int &x, int y) { x += y; }
 
 // Let's fake a minimal std::function-like facility.
 namespace std {
@@ -107,6 +128,7 @@
   int MemberVariable;
   static int StaticMemberVariable;
   F MemberStruct;
+  G MemberStructWithData;
 
   void testCaptureByValue(int Param, F f) {
 int x = 3;
@@ -145,6 +167,11 @@
 auto GGG = boost::bind(UseF, MemberStruct);
 // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: prefer a lambda to boost::bind [modernize-avoid-bind]
 // CHECK-FIXES: auto GGG = [this] { return UseF(MemberStruct); };
+
+auto HHH = std::bind(add, MemberStructWithData._member, 1);
+// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: prefer a lambda to std::bind
+// Correctly distinguish data members of other classes
+// CHECK-FIXES: auto HHH = [capture0 = MemberStructWithData._member] { return add(capture0, 1); };
   }
 };
 
@@ -217,17 +244,38 @@
   auto EEE = std::bind(*D::create(), 1, 2);
   // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: prefer a lambda to std::bind
   // CHECK-FIXES: auto EEE = [Func = *D::create()] { return Func(1, 2); };
+
+  auto FFF = std::bind(G(), 1);
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: prefer a lambda to std::bind
+  // Templated function call operators may be used
+  // CHECK-FIXES: auto FFF = [] { return G()(1); };
+
+  int CTorArg = 42;
+  auto GGG = std::bind(G(CTorArg), 1);
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: prefer a lambda to std::bind
+  // Function objects with constructor arguments should be captured
+  // CHECK-FIXES: auto GGG = [Func = G(CTorArg)] { return Func(1); };
 }
 
+template 
+void testMemberFnOfClassTemplate(T) {
+  auto HHH = std::bind(H(), 42);
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: prefer a lambda to std::bind
+  // Ensure function class template arguments are preserved
+  // CHECK-FIXES: auto HHH = [] { return H()(42); };
+}
+
+template void testMemberFnOfClassTemplate(int);
+
 void testPlaceholders() {
   int x = 2;
   auto AAA = std::bind(add, x, _1);
   // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: prefer a lambda to std::bind
-  // CHECK-FIXES: auto AAA = [x](auto && PH1) { return add(x, PH1); };
+  // CHECK-FIXES: auto AAA = [x](auto && PH1) { return add(x, std::forward(PH1)); };
 
   auto BBB = std::bind(add, _2, _1);
   // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: prefer a lambda to std::bind
-  // CHECK-FIXES: auto BBB = [](auto && PH1, auto && PH2) { return add(PH2, PH1); };
+  // CHECK-FIXES: auto BBB = [](auto && PH1, auto && PH2) { return add(std::forward(PH2), std::forward(PH1)); };
 
   // No fix is 

[PATCH] D80751: [clang][diagnostics] Add '-Wundef-prefix' warning option

2020-06-12 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticGroups.td:108
+def Undefined : DiagGroup<"undef">;
+def UndefinedPrefix : DiagGroup<"undef-prefix", [Undefined]>;
 def UnsupportedNan : DiagGroup<"unsupported-nan">;

zixuw wrote:
> arphaman wrote:
> > It seems like you're not using the `UndefinedPrefix` group in this patch. 
> > Is that intentional, or was this left in the patch by mistake?
> This is intentional to map both `Wundef` and `Wundef-prefix` to the same 
> warning. And since `Wundef` is changed to an alias, the `Undefined` subgroup 
> is used to keep existing outputs/behaviors consistent (to make 
> `-Werror=undef` work, and to keep the `[-Wundef]` option name in the 
> diagnostic message).
Got it, thanks!



Comment at: clang/lib/Lex/PPExpressions.cpp:262
+  // string to UndefPrefixes as an explicit "-Wundef" does.
+  if (UndefPrefixes.empty() ||
+  llvm::any_of(UndefPrefixes,

zixuw wrote:
> ributzka wrote:
> > What happens when you use `-Werror=undef` and `-Wundef-prefix=`?
> Then we only get errors for `undef-prefix=`. Yes this needs to be fixed.
> Perhaps a better way to handle the `-Werror=undef` implication of `-Wundef`.
We should try to fix this in this PR then. Can you check the severity of the 
diagnostic, and if it's an error always emit it here?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80751



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


[PATCH] D80961: Ignore template instantiations if not in AsIs mode

2020-06-12 Thread Stephen Kelly via Phabricator via cfe-commits
steveire updated this revision to Diff 270517.
steveire added a comment.

Update


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80961

Files:
  clang-tools-extra/clang-tidy/abseil/TimeSubtractionCheck.cpp
  clang-tools-extra/clang-tidy/abseil/UpgradeDurationConversionsCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/TooSmallLoopVariableCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/UndefinedMemoryManipulationCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/VirtualNearMissCheck.cpp
  clang-tools-extra/clang-tidy/google/UpgradeGoogletestCaseCheck.cpp
  clang-tools-extra/clang-tidy/hicpp/ExceptionBaseclassCheck.cpp
  clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
  clang-tools-extra/clang-tidy/modernize/DeprecatedIosBaseAliasesCheck.cpp
  clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp
  clang-tools-extra/clang-tidy/modernize/ReplaceAutoPtrCheck.cpp
  clang-tools-extra/clang-tidy/modernize/UseOverrideCheck.cpp
  clang-tools-extra/clang-tidy/modernize/UseUncaughtExceptionsCheck.cpp
  clang-tools-extra/clang-tidy/performance/FasterStringFindCheck.cpp
  clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.cpp
  clang-tools-extra/clang-tidy/readability/QualifiedAutoCheck.cpp
  
clang-tools-extra/clang-tidy/readability/StaticAccessedThroughInstanceCheck.cpp
  clang-tools-extra/clang-tidy/zircon/TemporaryObjectsCheck.cpp
  clang/include/clang/AST/ASTNodeTraverser.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/ASTMatchers/ASTMatchersInternal.h
  clang/lib/AST/ASTDumper.cpp
  clang/lib/ASTMatchers/ASTMatchFinder.cpp
  clang/lib/ASTMatchers/ASTMatchersInternal.cpp
  clang/unittests/AST/ASTContextParentMapTest.cpp
  clang/unittests/AST/ASTImporterTest.cpp
  clang/unittests/AST/ASTTraverserTest.cpp
  clang/unittests/AST/SourceLocationTest.cpp
  clang/unittests/AST/StructuralEquivalenceTest.cpp
  clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
  clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
  clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
  clang/unittests/ASTMatchers/Dynamic/RegistryTest.cpp
  clang/unittests/Sema/GslOwnerPointerInference.cpp
  clang/unittests/Tooling/TransformerTest.cpp

Index: clang/unittests/Tooling/TransformerTest.cpp
===
--- clang/unittests/Tooling/TransformerTest.cpp
+++ clang/unittests/Tooling/TransformerTest.cpp
@@ -695,6 +695,70 @@
   EXPECT_EQ(ErrorCount, 0);
 }
 
+TEST_F(TransformerTest, TemplateInstantiation) {
+
+  std::string NonTemplatesInput = R"cpp(
+struct S {
+  int m_i;
+};
+)cpp";
+  std::string NonTemplatesExpected = R"cpp(
+struct S {
+  safe_int m_i;
+};
+)cpp";
+
+  std::string TemplatesInput = R"cpp(
+template
+struct TemplStruct {
+  TemplStruct() {}
+  ~TemplStruct() {}
+
+private:
+  T m_t;
+};
+
+void instantiate()
+{
+  TemplStruct ti;
+}
+)cpp";
+
+  auto MatchedField = fieldDecl(hasType(asString("int"))).bind("theField");
+
+  // Changes the 'int' in 'S', but not the 'T' in 'TemplStruct':
+  testRule(makeRule(traverse(TK_IgnoreUnlessSpelledInSource, MatchedField),
+changeTo(cat("safe_int ", name("theField",
+   NonTemplatesInput + TemplatesInput,
+   NonTemplatesExpected + TemplatesInput);
+
+  // In AsIs mode, template instantiations are modified, which is
+  // often not desired:
+
+  std::string IncorrectTemplatesExpected = R"cpp(
+template
+struct TemplStruct {
+  TemplStruct() {}
+  ~TemplStruct() {}
+
+private:
+  safe_int m_t;
+};
+
+void instantiate()
+{
+  TemplStruct ti;
+}
+)cpp";
+
+  // Changes the 'int' in 'S', and (incorrectly) the 'T' in 'TemplStruct':
+  testRule(makeRule(traverse(TK_AsIs, MatchedField),
+changeTo(cat("safe_int ", name("theField",
+
+   NonTemplatesInput + TemplatesInput,
+   NonTemplatesExpected + IncorrectTemplatesExpected);
+}
+
 // Transformation of macro source text when the change encompasses the entirety
 // of the expanded text.
 TEST_F(TransformerTest, SimpleMacro) {
Index: clang/unittests/Sema/GslOwnerPointerInference.cpp
===
--- clang/unittests/Sema/GslOwnerPointerInference.cpp
+++ clang/unittests/Sema/GslOwnerPointerInference.cpp
@@ -14,42 +14,45 @@
 using namespace ast_matchers;
 
 TEST(OwnerPointer, BothHaveAttributes) {
-  EXPECT_TRUE(matches("template"
-  "class [[gsl::Owner]] C;"
+  EXPECT_TRUE(matches(
+  "template"
+  "class [[gsl::Owner]] C;"
 
-  "template"
-  "class [[gsl::Owner]] C {};"
+  "template"
+  "class [[gsl::Owner]] C {};"
 
-  "C c;",
-  classTemplateSpecializationDecl(
-  hasName("C"), hasAttr(clang::attr::Owner;
+

[PATCH] D81757: [WebAssembly] Add intrinsic for i64x2.mul

2020-06-12 Thread Thomas Lively via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd2c394e74fc5: [WebAssembly] Add intrinsic for i64x2.mul 
(authored by tlively).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81757

Files:
  clang/lib/Headers/wasm_simd128.h


Index: clang/lib/Headers/wasm_simd128.h
===
--- clang/lib/Headers/wasm_simd128.h
+++ clang/lib/Headers/wasm_simd128.h
@@ -864,6 +864,11 @@
   return (v128_t)((__u64x2)__a - (__u64x2)__b);
 }
 
+static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i64x2_mul(v128_t __a,
+   v128_t __b) {
+  return (v128_t)((__u64x2)__a * (__u64x2)__b);
+}
+
 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f32x4_abs(v128_t __a) {
   return (v128_t)__builtin_wasm_abs_f32x4((__f32x4)__a);
 }


Index: clang/lib/Headers/wasm_simd128.h
===
--- clang/lib/Headers/wasm_simd128.h
+++ clang/lib/Headers/wasm_simd128.h
@@ -864,6 +864,11 @@
   return (v128_t)((__u64x2)__a - (__u64x2)__b);
 }
 
+static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i64x2_mul(v128_t __a,
+   v128_t __b) {
+  return (v128_t)((__u64x2)__a * (__u64x2)__b);
+}
+
 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f32x4_abs(v128_t __a) {
   return (v128_t)__builtin_wasm_abs_f32x4((__f32x4)__a);
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D81420: Fix size for _ExtInt types with builtins

2020-06-12 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.

LGTM, thanks!


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

https://reviews.llvm.org/D81420



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


[clang] d2c394e - [WebAssembly] Add intrinsic for i64x2.mul

2020-06-12 Thread Thomas Lively via cfe-commits

Author: Thomas Lively
Date: 2020-06-12T14:08:18-07:00
New Revision: d2c394e74fc5eb33581b58f238a745d7dd18f219

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

LOG: [WebAssembly] Add intrinsic for i64x2.mul

Summary:
This instruction was implemented in 3181273be7, but that commit did
not add an intrinsic for it.

Reviewers: aheejin

Subscribers: dschuff, sbc100, jgravelle-google, sunfish, cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/lib/Headers/wasm_simd128.h

Removed: 




diff  --git a/clang/lib/Headers/wasm_simd128.h 
b/clang/lib/Headers/wasm_simd128.h
index 258198a7de34..b78123834b64 100644
--- a/clang/lib/Headers/wasm_simd128.h
+++ b/clang/lib/Headers/wasm_simd128.h
@@ -864,6 +864,11 @@ static __inline__ v128_t __DEFAULT_FN_ATTRS 
wasm_i64x2_sub(v128_t __a,
   return (v128_t)((__u64x2)__a - (__u64x2)__b);
 }
 
+static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i64x2_mul(v128_t __a,
+   v128_t __b) {
+  return (v128_t)((__u64x2)__a * (__u64x2)__b);
+}
+
 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f32x4_abs(v128_t __a) {
   return (v128_t)__builtin_wasm_abs_f32x4((__f32x4)__a);
 }



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


[PATCH] D81552: [ASTMatchers] Added hasDirectBase and hasClass Matchers

2020-06-12 Thread Jan Korous via Phabricator via cfe-commits
jkorous added inline comments.



Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:3553
+/// \endcode
+AST_MATCHER_P(CXXBaseSpecifier, hasClass, internal::Matcher,
+  InnerMatcher) {

aaron.ballman wrote:
> njames93 wrote:
> > jkorous wrote:
> > > aaron.ballman wrote:
> > > > jkorous wrote:
> > > > > Nit: while "[base specifier] `hasType`" sounds natural to me for some 
> > > > > reason `hasClass` doesn't. English is not my first language though.
> > > > I agree that `hasClass` seems unnatural here. Out of curiosity, could 
> > > > we modify the `hasName` matcher to work on base specifiers so you can 
> > > > write: `cxxRecordDecl(hasAnyBase(hasName("Base")))` as shorthand for 
> > > > the more wordy version 
> > > > `cxxRecordDecl(hasAnyBase(hasType(cxxRecordDecl(hasName("Base")`?
> > > Wouldn't it be strange to treat `hasName` differently than all the other 
> > > narrowing matchers? Honest question - I feel that `hasName` might be the 
> > > most commonly used, just don't know if that's enough to justify this.
> > > https://clang.llvm.org/docs/LibASTMatchersReference.html#narrowing-matchers
> > Repurposing `hasName` would be a pain especially considering 99% of its use 
> > cases wont be for base class matching.
> > Wouldn't it be strange to treat hasName differently than all the other 
> > narrowing matchers? Honest question - I feel that hasName might be the most 
> > commonly used, just don't know if that's enough to justify this. 
> > https://clang.llvm.org/docs/LibASTMatchersReference.html#narrowing-matchers
> 
> Different how? I'm suggesting to overload `hasName` to work on a 
> `CXXBaseSpecifier` since those have a name.
> 
> > Repurposing hasName would be a pain especially considering 99% of its use 
> > cases wont be for base class matching.
> 
> I'm asking what the right API is for users, though, which is a bit different. 
> Base specifiers have names (there are no unnamed base specifiers), so to me, 
> it makes more sense for `hasName` to work with them directly since that is 
> the thing that does name matching.
> 
> I think you can accomplish this by using a `PolymorphicMatcherWithParam1` 
> like we do for `hasOverloadedOperatorName` which can narrow to either a 
> `CXXOperatorCallExpr` or a `FunctionDecl`.
>> Wouldn't it be strange to treat hasName differently than all the other 
>> narrowing matchers? Honest question - I feel that hasName might be the most 
>> commonly used, just don't know if that's enough to justify this. 
>> https://clang.llvm.org/docs/LibASTMatchersReference.html#narrowing-matchers

> Different how? I'm suggesting to overload hasName to work on a 
> CXXBaseSpecifier since those have a name.

What I meant is that technically we can overload any `Matcher` 
matcher in the same fashion so having the overloaded version of `hasName` only 
makes it somewhat special (and someone might argue that it'd impact consistency 
of matchers composability). Anyway, I'm fine with your suggestion!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81552



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


[PATCH] D81336: [clang-tidy] simplify-bool-expr ignores template instantiations

2020-06-12 Thread Richard via Phabricator via cfe-commits
LegalizeAdulthood added a comment.

Yeah, the restriction to the header file is a bug.  It was a misconception on 
my part when I originally wrote the matcher.

See https://bugs.llvm.org/show_bug.cgi?id=26332 which should also be fixed by 
the change here.

I had attempted to make progress on fixing that bug (26332) but some retooling 
of the testing framework is needed to validate
that the **header** has a fixit applied to it.  I made some progress by 
refactoring the python script, but as usual it got bogged
down in clang review hell and I haven't had time to make any more forward 
progress on it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81336



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


[PATCH] D78126: [analyzer][NFC] Don't allow dependency checkers to emit diagnostics

2020-06-12 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus reopened this revision.
Szelethus added a comment.
This revision is now accepted and ready to land.

Reverted in rGe64059828f19f629081220bffeb3ef7582870111 
.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78126



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


[PATCH] D81627: [HIP] Do not call opt/llc for -fno-gpu-rdc

2020-06-12 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In D81627#2090499 , @tra wrote:

> LGTM.  Good to go if @arsenm is OK with fixing -fgpu-rdc in a separate patch.


@arsenm Are you OK with fixing -fgpu-rdc in a separate patch? The fix for that 
is orthogonal to the current patch. Mixing them together will clutter things 
up. Also the need for -fgpu-rdc is not so urgent since only rccl needs it. 
Requesting this patch to fix -fgpu-rdc will delay fixing issues for all other 
math libs and frameworks.


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

https://reviews.llvm.org/D81627



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


[PATCH] D81761: [analyzer] Force dependency checkers to be hidden

2020-06-12 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus created this revision.
Szelethus added reviewers: NoQ, vsavchenko, dcoughlin, xazax.hun, balazske, 
martong, baloghadamsoftware.
Szelethus added a project: clang.
Herald added subscribers: cfe-commits, ASDenysPetrov, steakhal, Charusso, 
gamesh411, dkrupp, donat.nagy, mikhail.ramalho, a.sidorin, rnkovacs, szepet, 
whisperity.
Szelethus edited the summary of this revision.

Since strong dependencies aren't user-facing (its hardly ever legal to disable 
them), lets enforce that they are hidden. Modeling checkers that aren't 
dependencies are of course not impacted, but there is only so much you can do 
against developers shooting themselves in the foot :^)

I also made some changes to the test files, reversing the "test" package for, 
well, testing.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81761

Files:
  clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
  
clang/lib/Analysis/plugins/CheckerDependencyHandling/CheckerDependencyHandling.cpp
  clang/lib/Analysis/plugins/CheckerOptionHandling/CheckerOptionHandling.cpp
  clang/lib/Analysis/plugins/SampleAnalyzer/MainCallChecker.cpp
  clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
  clang/test/Analysis/checker-plugins.c
  clang/unittests/StaticAnalyzer/RegisterCustomCheckersTest.cpp

Index: clang/unittests/StaticAnalyzer/RegisterCustomCheckersTest.cpp
===
--- clang/unittests/StaticAnalyzer/RegisterCustomCheckersTest.cpp
+++ clang/unittests/StaticAnalyzer/RegisterCustomCheckersTest.cpp
@@ -41,17 +41,16 @@
 
 void addCustomChecker(AnalysisASTConsumer &AnalysisConsumer,
   AnalyzerOptions &AnOpts) {
-  AnOpts.CheckersAndPackages = {{"custom.CustomChecker", true}};
+  AnOpts.CheckersAndPackages = {{"test.CustomChecker", true}};
   AnalysisConsumer.AddCheckerRegistrationFn([](CheckerRegistry &Registry) {
-Registry.addChecker("custom.CustomChecker", "Description",
-   "");
+Registry.addChecker("test.CustomChecker", "Description", "");
   });
 }
 
 TEST(RegisterCustomCheckers, RegisterChecker) {
   std::string Diags;
   EXPECT_TRUE(runCheckerOnCode("void f() {;}", Diags));
-  EXPECT_EQ(Diags, "custom.CustomChecker:Custom diagnostic description\n");
+  EXPECT_EQ(Diags, "test.CustomChecker:Custom diagnostic description\n");
 }
 
 //===--===//
@@ -120,7 +119,7 @@
 void addCheckerRegistrationOrderPrinter(CheckerRegistry &Registry) {
   Registry.addChecker(registerCheckerRegistrationOrderPrinter,
   shouldRegisterCheckerRegistrationOrderPrinter,
-  "custom.RegistrationOrder", "Description", "", false);
+  "test.RegistrationOrder", "Description", "", false);
 }
 
 #define UNITTEST_CHECKER(CHECKER_NAME, DIAG_MSG)   \
@@ -141,7 +140,7 @@
   }\
   void add##CHECKER_NAME(CheckerRegistry &Registry) {  \
 Registry.addChecker(register##CHECKER_NAME, shouldRegister##CHECKER_NAME,  \
-"custom." #CHECKER_NAME, "Description", "", false);\
+"test." #CHECKER_NAME, "Description", "", false);  \
   }
 
 UNITTEST_CHECKER(StrongDep, "Strong")
@@ -154,22 +153,22 @@
 
 void addDep(AnalysisASTConsumer &AnalysisConsumer,
   AnalyzerOptions &AnOpts) {
-  AnOpts.CheckersAndPackages = {{"custom.Dep", true},
-{"custom.RegistrationOrder", true}};
+  AnOpts.CheckersAndPackages = {{"test.Dep", true},
+{"test.RegistrationOrder", true}};
   AnalysisConsumer.AddCheckerRegistrationFn([](CheckerRegistry &Registry) {
 Registry.addChecker(registerStrongDep, shouldRegisterStrongFALSE,
-"custom.Strong", "Description", "", false);
+"test.Strong", "Description", "", false);
 addStrongDep(Registry);
 addDep(Registry);
 addCheckerRegistrationOrderPrinter(Registry);
-Registry.addDependency("custom.Dep", "custom.Strong");
+Registry.addDependency("test.Dep", "test.Strong");
   });
 }
 
 TEST(RegisterDeps, UnsatisfiedDependency) {
   std::string Diags;
   EXPECT_TRUE(runCheckerOnCode("void f() {int i;}", Diags));
-  EXPECT_EQ(Diags, "custom.RegistrationOrder:custom.RegistrationOrder\n");
+  EXPECT_EQ(Diags, "test.RegistrationOrder:test.RegistrationOrder\n");
 }
 
 //===--===//
@@ -180,52 +179,52 @@
 
 void addWeakDepCheckerBothEnabled(AnalysisASTConsumer &AnalysisConsumer,
   AnalyzerOptions &AnOpts) {
-  AnOpts.CheckersAndPackages = {{"custom.Dep", true},
-{"custom.WeakDep", true},
-{"custom.RegistrationOrder", true}};
+  AnOp

[PATCH] D81752: Revert "[analyzer][NFC] Don't allow dependency checkers to emit diagnostics"

2020-06-12 Thread Sterling Augustine via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe64059828f19: Revert "[analyzer][NFC] Don't allow 
dependency checkers to emit diagnostics" (authored by saugustine).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81752

Files:
  clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
  clang/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h
  clang/lib/StaticAnalyzer/Core/BugReporter.cpp
  clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp

Index: clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
===
--- clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
+++ clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
@@ -94,10 +94,6 @@
 // Methods of CmdLineOption, PackageInfo and CheckerInfo.
 //===--===//
 
-LLVM_DUMP_METHOD void CheckerRegistry::CmdLineOption::dump() const {
-  dumpToStream(llvm::errs());
-}
-
 LLVM_DUMP_METHOD void
 CheckerRegistry::CmdLineOption::dumpToStream(llvm::raw_ostream &Out) const {
   // The description can be just checked in Checkers.inc, the point here is to
@@ -119,10 +115,6 @@
   llvm_unreachable("Unhandled CheckerRegistry::StateFromCmdLine enum");
 }
 
-LLVM_DUMP_METHOD void CheckerRegistry::CheckerInfo::dump() const {
-  dumpToStream(llvm::errs());
-}
-
 LLVM_DUMP_METHOD void
 CheckerRegistry::CheckerInfo::dumpToStream(llvm::raw_ostream &Out) const {
   // The description can be just checked in Checkers.inc, the point here is to
@@ -145,10 +137,6 @@
   }
 }
 
-LLVM_DUMP_METHOD void CheckerRegistry::PackageInfo::dump() const {
-  dumpToStream(llvm::errs());
-}
-
 LLVM_DUMP_METHOD void
 CheckerRegistry::PackageInfo::dumpToStream(llvm::raw_ostream &Out) const {
   Out << FullName << "\n";
Index: clang/lib/StaticAnalyzer/Core/BugReporter.cpp
===
--- clang/lib/StaticAnalyzer/Core/BugReporter.cpp
+++ clang/lib/StaticAnalyzer/Core/BugReporter.cpp
@@ -40,7 +40,6 @@
 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/SVals.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h"
-#include "clang/StaticAnalyzer/Frontend/CheckerRegistry.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/DenseSet.h"
@@ -2107,32 +2106,6 @@
 // Methods for BugReport and subclasses.
 //===--===//
 
-static bool isDependency(const CheckerRegistry &Registry,
- StringRef CheckerName) {
-  for (const std::pair &Pair : Registry.Dependencies) {
-if (Pair.second == CheckerName)
-  return true;
-  }
-  return false;
-}
-
-PathSensitiveBugReport::PathSensitiveBugReport(
-const BugType &bt, StringRef shortDesc, StringRef desc,
-const ExplodedNode *errorNode, PathDiagnosticLocation LocationToUnique,
-const Decl *DeclToUnique)
-: BugReport(Kind::PathSensitive, bt, shortDesc, desc), ErrorNode(errorNode),
-  ErrorNodeRange(getStmt() ? getStmt()->getSourceRange() : SourceRange()),
-  UniqueingLocation(LocationToUnique), UniqueingDecl(DeclToUnique) {
-  assert(!isDependency(ErrorNode->getState()
-   ->getAnalysisManager()
-   .getCheckerManager()
-   ->getCheckerRegistry(),
-   bt.getCheckerName()) &&
- "Some checkers depend on this one! We don't allow dependency "
- "checkers to emit warnings, because checkers should depend on "
- "*modeling*, not *diagnostics*.");
-}
-
 void PathSensitiveBugReport::addVisitor(
 std::unique_ptr visitor) {
   if (!visitor)
@@ -2221,12 +2194,12 @@
   return;
 case bugreporter::TrackingKind::Condition:
   return;
-}
+  }
 
-llvm_unreachable(
-"BugReport::markInteresting currently can only handle 2 different "
-"tracking kinds! Please define what tracking kind should this entitiy"
-"have, if it was already marked as interesting with a different kind!");
+  llvm_unreachable(
+  "BugReport::markInteresting currently can only handle 2 different "
+  "tracking kinds! Please define what tracking kind should this entitiy"
+  "have, if it was already marked as interesting with a different kind!");
 }
 
 void PathSensitiveBugReport::markInteresting(SymbolRef sym,
Index: clang/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h
===
--- clang/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h
+++ clang/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h
@@ -135,7 +135,7 @@
  "Invalid development status!");
 }
 
-LLVM_DUMP_METHOD void dump() const;
+L

[PATCH] D81757: [WebAssembly] Add intrinsic for i64x2.mul

2020-06-12 Thread Thomas Lively via Phabricator via cfe-commits
tlively created this revision.
tlively added a reviewer: aheejin.
Herald added subscribers: cfe-commits, sunfish, jgravelle-google, sbc100, 
dschuff.
Herald added a project: clang.

This instruction was implemented in 3181273be7 
, but that 
commit did
not add an intrinsic for it.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81757

Files:
  clang/lib/Headers/wasm_simd128.h


Index: clang/lib/Headers/wasm_simd128.h
===
--- clang/lib/Headers/wasm_simd128.h
+++ clang/lib/Headers/wasm_simd128.h
@@ -864,6 +864,11 @@
   return (v128_t)((__u64x2)__a - (__u64x2)__b);
 }
 
+static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i64x2_mul(v128_t __a,
+   v128_t __b) {
+  return (v128_t)((__u64x2)__a * (__u64x2)__b);
+}
+
 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f32x4_abs(v128_t __a) {
   return (v128_t)__builtin_wasm_abs_f32x4((__f32x4)__a);
 }


Index: clang/lib/Headers/wasm_simd128.h
===
--- clang/lib/Headers/wasm_simd128.h
+++ clang/lib/Headers/wasm_simd128.h
@@ -864,6 +864,11 @@
   return (v128_t)((__u64x2)__a - (__u64x2)__b);
 }
 
+static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i64x2_mul(v128_t __a,
+   v128_t __b) {
+  return (v128_t)((__u64x2)__a * (__u64x2)__b);
+}
+
 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f32x4_abs(v128_t __a) {
   return (v128_t)__builtin_wasm_abs_f32x4((__f32x4)__a);
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D81420: Fix size for _ExtInt types with builtins

2020-06-12 Thread Mott, Jeffrey T via Phabricator via cfe-commits
jtmott-intel marked an inline comment as done.
jtmott-intel added inline comments.



Comment at: clang/lib/Sema/SemaChecking.cpp:327
   return true;
 TheCall->setArg(2, Arg.get());
   }

rjmccall wrote:
> jtmott-intel wrote:
> > rjmccall wrote:
> > > I know this is existing code, but this is a broken mess.  Please change 
> > > this to:
> > > 
> > > ```
> > >   ExprResult Arg = 
> > > DefaultFunctionArrayLvalueConversion(TheCall->getArg(2));
> > >   if (Arg.isInvalid()) return true;
> > >   TheCall->setArg(2, Arg.get());
> > > 
> > >   QualType Ty = Arg.get()->getType();
> > >   const auto *PtrTy = Ty->getAs();
> > >   if (!PtrTy ||
> > >   !PtrTy->getPointeeType()->isIntegerType() ||
> > >   PtrTy->getPointeeType().isConstQualified()) {
> > > S.Diag(Arg.get()->getBeginLoc(),
> > >diag::err_overflow_builtin_must_be_ptr_int)
> > >   << Ty << Arg.get()->getSourceRange();
> > > return true;
> > >   }
> > > ```
> > > 
> > > Test case would be something like (in ObjC):
> > > 
> > > ```
> > > @interface HasPointer
> > > @property int *pointer;
> > > @end
> > > 
> > > void test(HasPointer *hp) {
> > >   __builtin_add_overflow(x, y, hp.pointer);
> > > }
> > > ```
> > > 
> > > And the earlier block needs essentially the same change (but obviously 
> > > checking for a different type).  You can't check types before doing 
> > > placeholder conversions, and once you do l-value conversions and a 
> > > type-check, you really don't need the full parameter-initialization logic.
> > I've implemented this locally but I have a quick question about the test. 
> > It passed even before I applied this code change. Is this test expected to 
> > fail before this change and pass after? Or is it just to prove that the 
> > feature (placeholder argument types?) works in general?
> Oh, we seem to handle placeholders specially, nevermind.  Well, what I said 
> about doing conversions before checking the type still holds, but the test 
> case is just this:
> 
> ```
> int z[1];
> __builtin_add_overflow(x, y, z);
> ```
> 
> where we should decay the argument to a pointer instead of rejecting it.
Done. Latest updated patch includes these code changes.


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

https://reviews.llvm.org/D81420



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


[PATCH] D81420: Fix size for _ExtInt types with builtins

2020-06-12 Thread Mott, Jeffrey T via Phabricator via cfe-commits
jtmott-intel updated this revision to Diff 270482.
jtmott-intel added a comment.

- Removed sign/unsign select.
- Added test and support for placeholder types in builtins.


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

https://reviews.llvm.org/D81420

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/builtins-overflow.c
  clang/test/Sema/builtins-overflow.c
  clang/test/Sema/builtins-overflow.m

Index: clang/test/Sema/builtins-overflow.m
===
--- /dev/null
+++ clang/test/Sema/builtins-overflow.m
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// expected-no-diagnostics
+
+void test() {
+  int z[1];
+  __builtin_add_overflow(1, 1, z);
+}
Index: clang/test/Sema/builtins-overflow.c
===
--- clang/test/Sema/builtins-overflow.c
+++ clang/test/Sema/builtins-overflow.c
@@ -19,4 +19,23 @@
   __builtin_add_overflow(1, 1, 3);  // expected-error {{result argument to overflow builtin must be a pointer to a non-const integer ('int' invalid)}}
   __builtin_add_overflow(1, 1, &f);  // expected-error {{result argument to overflow builtin must be a pointer to a non-const integer ('float *' invalid)}}
   __builtin_add_overflow(1, 1, &q);  // expected-error {{result argument to overflow builtin must be a pointer to a non-const integer ('const unsigned int *' invalid)}}
+
+  {
+_ExtInt(128) x = 1;
+_ExtInt(128) y = 1;
+_ExtInt(128) result;
+_Bool status = __builtin_mul_overflow(x, y, &result); // expect ok
+  }
+  {
+unsigned _ExtInt(129) x = 1;
+unsigned _ExtInt(129) y = 1;
+unsigned _ExtInt(129) result;
+_Bool status = __builtin_mul_overflow(x, y, &result); // expect ok
+  }
+  {
+_ExtInt(129) x = 1;
+_ExtInt(129) y = 1;
+_ExtInt(129) result;
+_Bool status = __builtin_mul_overflow(x, y, &result); // expected-error {{__builtin_mul_overflow does not support signed _ExtInt operands of more than 128 bits}}
+  }
 }
Index: clang/test/CodeGen/builtins-overflow.c
===
--- clang/test/CodeGen/builtins-overflow.c
+++ clang/test/CodeGen/builtins-overflow.c
@@ -41,6 +41,20 @@
   return r;
 }
 
+int test_add_overflow_xint31_xint31_xint31(_ExtInt(31) x, _ExtInt(31) y) {
+  // CHECK-LABEL: define {{(dso_local )?}}i32 @test_add_overflow_xint31_xint31_xint31({{.+}})
+  // CHECK-NOT: ext
+  // CHECK: [[S:%.+]] = call { i31, i1 } @llvm.sadd.with.overflow.i31(i31 %{{.+}}, i31 %{{.+}})
+  // CHECK-DAG: [[C:%.+]] = extractvalue { i31, i1 } [[S]], 1
+  // CHECK-DAG: [[Q:%.+]] = extractvalue { i31, i1 } [[S]], 0
+  // CHECK: store i31 [[Q]], i31*
+  // CHECK: br i1 [[C]]
+  _ExtInt(31) r;
+  if (__builtin_add_overflow(x, y, &r))
+overflowed();
+  return r;
+}
+
 unsigned test_sub_overflow_uint_uint_uint(unsigned x, unsigned y) {
   // CHECK-LABEL: define {{(dso_local )?}}i32 @test_sub_overflow_uint_uint_uint
   // CHECK-NOT: ext
@@ -69,6 +83,20 @@
   return r;
 }
 
+int test_sub_overflow_xint31_xint31_xint31(_ExtInt(31) x, _ExtInt(31) y) {
+  // CHECK-LABEL: define {{(dso_local )?}}i32 @test_sub_overflow_xint31_xint31_xint31({{.+}})
+  // CHECK-NOT: ext
+  // CHECK: [[S:%.+]] = call { i31, i1 } @llvm.ssub.with.overflow.i31(i31 %{{.+}}, i31 %{{.+}})
+  // CHECK-DAG: [[C:%.+]] = extractvalue { i31, i1 } [[S]], 1
+  // CHECK-DAG: [[Q:%.+]] = extractvalue { i31, i1 } [[S]], 0
+  // CHECK: store i31 [[Q]], i31*
+  // CHECK: br i1 [[C]]
+  _ExtInt(31) r;
+  if (__builtin_sub_overflow(x, y, &r))
+overflowed();
+  return r;
+}
+
 unsigned test_mul_overflow_uint_uint_uint(unsigned x, unsigned y) {
   // CHECK-LABEL: define {{(dso_local )?}}i32 @test_mul_overflow_uint_uint_uint
   // CHECK-NOT: ext
@@ -97,6 +125,48 @@
   return r;
 }
 
+int test_mul_overflow_xint31_xint31_xint31(_ExtInt(31) x, _ExtInt(31) y) {
+  // CHECK-LABEL: define {{(dso_local )?}}i32 @test_mul_overflow_xint31_xint31_xint31({{.+}})
+  // CHECK-NOT: ext
+  // CHECK: [[S:%.+]] = call { i31, i1 } @llvm.smul.with.overflow.i31(i31 %{{.+}}, i31 %{{.+}})
+  // CHECK-DAG: [[C:%.+]] = extractvalue { i31, i1 } [[S]], 1
+  // CHECK-DAG: [[Q:%.+]] = extractvalue { i31, i1 } [[S]], 0
+  // CHECK: store i31 [[Q]], i31*
+  // CHECK: br i1 [[C]]
+  _ExtInt(31) r;
+  if (__builtin_mul_overflow(x, y, &r))
+overflowed();
+  return r;
+}
+
+int test_mul_overflow_xint127_xint127_xint127(_ExtInt(127) x, _ExtInt(127) y) {
+  // CHECK-LABEL: define {{(dso_local )?}}i32 @test_mul_overflow_xint127_xint127_xint127({{.+}})
+  // CHECK-NOT: ext
+  // CHECK: [[S:%.+]] = call { i127, i1 } @llvm.smul.with.overflow.i127(i127 %{{.+}}, i127 %{{.+}})
+  // CHECK-DAG: [[C:%.+]] = extractvalue { i127, i1 } [[S]], 1
+  // CHECK-DAG: [[Q:%.+]] = extractvalue { i127, i1 } [[S]], 0
+  // CHECK: store i127 [[Q]], i127*
+  // CHECK: br i1 [[C]]
+  _ExtInt(

[clang] f8d87ce - [CMake] Use 'ssh.py' executor to run the remote library tests.

2020-06-12 Thread Vladimir Vereschaka via cfe-commits

Author: Vladimir Vereschaka
Date: 2020-06-12T12:31:59-07:00
New Revision: f8d87ce9ca23a696dbcc52b4b3458272a2ba8091

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

LOG: [CMake] Use 'ssh.py' executor to run the remote library tests.

In order to support the libcxx new format changes SSHExecutor was
replaced with ssh.py script in the following way:

LIBxxx_EXECUTOR="/libcxx/utils/ssh.py --host @"

See 96e6cbbf941d0f937b7e823433d4c222967a1817 commit for details.

Added: 


Modified: 
clang/cmake/caches/CrossWinToARMLinux.cmake

Removed: 




diff  --git a/clang/cmake/caches/CrossWinToARMLinux.cmake 
b/clang/cmake/caches/CrossWinToARMLinux.cmake
index 3d1e961ada8d..41ddb836f60e 100644
--- a/clang/cmake/caches/CrossWinToARMLinux.cmake
+++ b/clang/cmake/caches/CrossWinToARMLinux.cmake
@@ -102,7 +102,7 @@ set(RUNTIMES_CMAKE_ARGS 
"-DCMAKE_SYSTEM_NAME=Linux;-DCMAKE_A
 
 # Remote test configuration.
 if(DEFINED REMOTE_TEST_HOST)
-  set(DEFAULT_TEST_EXECUTOR 
"SSHExecutor('${REMOTE_TEST_HOST}', '${REMOTE_TEST_USER}')")
+  set(DEFAULT_TEST_EXECUTOR 
"${LLVM_PROJECT_DIR}/libcxx/utils/ssh.py 
--host='${REMOTE_TEST_USER}@${REMOTE_TEST_HOST}'")
   set(DEFAULT_TEST_TARGET_INFO  
"libcxx.test.target_info.LinuxRemoteTI")
 
   # Allow override with the custom values.



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


[clang] e640598 - Revert "[analyzer][NFC] Don't allow dependency checkers to emit diagnostics"

2020-06-12 Thread Sterling Augustine via cfe-commits

Author: Sterling Augustine
Date: 2020-06-12T12:10:13-07:00
New Revision: e64059828f19f629081220bffeb3ef7582870111

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

LOG: Revert "[analyzer][NFC] Don't allow dependency checkers to emit 
diagnostics"

Summary:
This reverts commit 33fb9cbe211d1b43d4b84edf34e11001f04cddf0.

That commit violates layering by adding a dependency from StaticAnalyzer/Core
back to StaticAnalyzer/FrontEnd, creating a circular dependency.

I can't see a clean way to fix it except refactoring.

Reviewers: echristo, Szelethus, martong

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

Tags: #clang

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

Added: 


Modified: 
clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
clang/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h
clang/lib/StaticAnalyzer/Core/BugReporter.cpp
clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp

Removed: 




diff  --git a/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h 
b/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
index 27bc0dda1f1c..51565524db1e 100644
--- a/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
+++ b/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
@@ -19,7 +19,6 @@
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Lex/Preprocessor.h"
 #include "clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h"
-#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
 #include "clang/StaticAnalyzer/Core/CheckerManager.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h"
@@ -136,7 +135,7 @@ class BugReport {
   SmallVector Fixits;
 
   BugReport(Kind kind, const BugType &bt, StringRef desc)
-  : BugReport(kind, bt, "", desc) {}
+  : K(kind), BT(bt), Description(desc) {}
 
   BugReport(Kind K, const BugType &BT, StringRef ShortDescription,
 StringRef Description)
@@ -370,13 +369,16 @@ class PathSensitiveBugReport : public BugReport {
 public:
   PathSensitiveBugReport(const BugType &bt, StringRef desc,
  const ExplodedNode *errorNode)
-  : PathSensitiveBugReport(bt, desc, desc, errorNode) {}
+  : BugReport(Kind::PathSensitive, bt, desc), ErrorNode(errorNode),
+ErrorNodeRange(getStmt() ? getStmt()->getSourceRange()
+ : SourceRange()) {}
 
   PathSensitiveBugReport(const BugType &bt, StringRef shortDesc, StringRef 
desc,
  const ExplodedNode *errorNode)
-  : PathSensitiveBugReport(bt, shortDesc, desc, errorNode,
-   /*LocationToUnique*/ {},
-   /*DeclToUnique*/ nullptr) {}
+  : BugReport(Kind::PathSensitive, bt, shortDesc, desc),
+ErrorNode(errorNode),
+ErrorNodeRange(getStmt() ? getStmt()->getSourceRange()
+ : SourceRange()) {}
 
   /// Create a PathSensitiveBugReport with a custom uniqueing location.
   ///
@@ -389,13 +391,11 @@ class PathSensitiveBugReport : public BugReport {
  const ExplodedNode *errorNode,
  PathDiagnosticLocation LocationToUnique,
  const Decl *DeclToUnique)
-  : PathSensitiveBugReport(bt, desc, desc, errorNode, LocationToUnique,
-   DeclToUnique) {}
-
-  PathSensitiveBugReport(const BugType &bt, StringRef shortDesc, StringRef 
desc,
- const ExplodedNode *errorNode,
- PathDiagnosticLocation LocationToUnique,
- const Decl *DeclToUnique);
+  : BugReport(Kind::PathSensitive, bt, desc), ErrorNode(errorNode),
+ErrorNodeRange(getStmt() ? getStmt()->getSourceRange() : 
SourceRange()),
+UniqueingLocation(LocationToUnique), UniqueingDecl(DeclToUnique) {
+assert(errorNode);
+  }
 
   static bool classof(const BugReport *R) {
 return R->getKind() == Kind::PathSensitive;

diff  --git a/clang/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h 
b/clang/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h
index 795067cba582..7b72fae0fefe 100644
--- a/clang/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h
+++ b/clang/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h
@@ -135,7 +135,7 @@ class CheckerRegistry {
  "Invalid development status!");
 }
 
-LLVM_DUMP_METHOD void dump() const;
+LLVM_DUMP_METHOD void dump() const { dumpToStream(llvm::errs()); }
 LLVM_DUMP_METHOD void dumpToStream(llvm::raw_o

[PATCH] D81736: [openmp] Base of tablegen generated OpenMP common declaration

2020-06-12 Thread Valentin Clement via Phabricator via cfe-commits
clementval updated this revision to Diff 270481.
clementval added a comment.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Keep same ordering than OMPKinds.def + add dependency


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81736

Files:
  clang/lib/Tooling/CMakeLists.txt
  llvm/include/llvm/CMakeLists.txt
  llvm/include/llvm/Frontend/Directive/DirectiveBase.td
  llvm/include/llvm/Frontend/OpenMP/CMakeLists.txt
  llvm/include/llvm/Frontend/OpenMP/OMP.td
  llvm/include/llvm/Frontend/OpenMP/OMPConstants.h
  llvm/lib/Frontend/OpenMP/CMakeLists.txt
  llvm/test/TableGen/directive.td
  llvm/utils/TableGen/CMakeLists.txt
  llvm/utils/TableGen/DirectiveEmitter.cpp
  llvm/utils/TableGen/TableGen.cpp
  llvm/utils/TableGen/TableGenBackends.h

Index: llvm/utils/TableGen/TableGenBackends.h
===
--- llvm/utils/TableGen/TableGenBackends.h
+++ llvm/utils/TableGen/TableGenBackends.h
@@ -90,6 +90,7 @@
 void EmitRegisterBank(RecordKeeper &RK, raw_ostream &OS);
 void EmitExegesis(RecordKeeper &RK, raw_ostream &OS);
 void EmitAutomata(RecordKeeper &RK, raw_ostream &OS);
+void EmitDirectives(RecordKeeper &RK, raw_ostream &OS);
 
 } // End llvm namespace
 
Index: llvm/utils/TableGen/TableGen.cpp
===
--- llvm/utils/TableGen/TableGen.cpp
+++ llvm/utils/TableGen/TableGen.cpp
@@ -54,6 +54,7 @@
   GenRegisterBank,
   GenExegesis,
   GenAutomata,
+  GenDirectives,
 };
 
 namespace llvm {
@@ -128,7 +129,9 @@
"Generate registers bank descriptions"),
 clEnumValN(GenExegesis, "gen-exegesis",
"Generate llvm-exegesis tables"),
-clEnumValN(GenAutomata, "gen-automata", "Generate generic automata")));
+clEnumValN(GenAutomata, "gen-automata", "Generate generic automata"),
+clEnumValN(GenDirectives, "gen-directive-decls",
+   "Generate directive related declaration code")));
 
 cl::OptionCategory PrintEnumsCat("Options for -print-enums");
 cl::opt Class("class", cl::desc("Print Enum list for this class"),
@@ -253,6 +256,8 @@
   case GenAutomata:
 EmitAutomata(Records, OS);
 break;
+  case GenDirectives:
+EmitDirectives(Records, OS);
   }
 
   return false;
Index: llvm/utils/TableGen/DirectiveEmitter.cpp
===
--- /dev/null
+++ llvm/utils/TableGen/DirectiveEmitter.cpp
@@ -0,0 +1,103 @@
+//===- DirectiveEmitter.cpp - Directive Language Emitter --===//
+//
+// 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
+//
+//===--===//
+//
+// DirectiveEmitter uses the descriptions of directives and clauses to construct
+// common code declarations to be used in Frontends.
+//
+//===--===//
+
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/TableGen/Error.h"
+#include "llvm/TableGen/Record.h"
+#include "llvm/TableGen/TableGenBackend.h"
+
+namespace llvm {
+void EmitDirectives(RecordKeeper &Records, raw_ostream &OS) {
+
+  const auto &directiveLanguages =
+  Records.getAllDerivedDefinitions("DirectiveLanguage");
+
+  if (directiveLanguages.size() != 1) {
+PrintError("A single definition of DirectiveLanguage is needed.");
+return;
+  }
+
+  const auto &directiveLanguage = directiveLanguages[0];
+  StringRef directivePrefix =
+  directiveLanguage->getValueAsString("directivePrefix");
+  StringRef clausePrefix = directiveLanguage->getValueAsString("clausePrefix");
+  StringRef cppNamespace = directiveLanguage->getValueAsString("cppNamespace");
+  bool makeEnumAvailableInNamespace =
+  directiveLanguage->getValueAsBit("makeEnumAvailableInNamespace");
+  bool enableBitmaskEnumInNamespace =
+  directiveLanguage->getValueAsBit("enableBitmaskEnumInNamespace");
+
+  if (enableBitmaskEnumInNamespace)
+OS << "#include \"llvm/ADT/BitmaskEnum.h\"\n";
+
+  OS << "namespace llvm {\n";
+
+  // Open namespaces defined in the directive language
+  llvm::SmallVector namespaces;
+  llvm::SplitString(cppNamespace, namespaces, "::");
+  for (auto ns : namespaces)
+OS << "namespace " << ns << " {\n";
+
+  if (enableBitmaskEnumInNamespace)
+OS << "LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE();\n";
+
+  // Emit Directive enumeration
+  OS << "enum class Directive {\n";
+  const auto &directives = Records.getAllDerivedDefinitions("Directive");
+  for (const auto &d : directives) {
+const auto name = d->getValueAsString("name");
+std::string n = name.str();
+std::replace(n.begin(), n

[PATCH] D81713: [HIP] Fix rocm not found on rocm3.5

2020-06-12 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

In D81713#2090309 , @arsenm wrote:

> > I can tell that it does not. We're still looking under `/opt/rocm` by 
> > default. I've ran into it trying to get comgr working with the recent LLVM 
> > which prompted my comment on Github 
> > 
>
> Not sure how that would be related to comgr? comgr doesn't rely on the 
> dynamic path and embeds the bitcode in the library. The comgr build finds the 
> libraries through cmake and doesn't care where they're located


The version I have  (~3.2. I should update it, maybe 3.5 is different) uses 
libclang (built from LLVM tree close to HEAD), creates Driver() instance and 
that driver instance goes through the motions trying to find ROCm installation 
and fails. Clang itself also fails the same way -- there's no 
/opt/rocm/amdgcn/bitcode/ it's looking for.


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

https://reviews.llvm.org/D81713



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


[PATCH] D81627: [HIP] Do not call opt/llc for -fno-gpu-rdc

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

LGTM.  Good to go if @arsenm is OK with fixing -fgpu-rdc in a separate patch.


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

https://reviews.llvm.org/D81627



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


[PATCH] D60620: [HIP] Support target id by --offload-arch

2020-06-12 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

In D60620#2089722 , @yaxunl wrote:

> In D60620#2067134 , @tra wrote:
>
> > Do you expect users to specify these IDs? How do you see it being used in 
> > practice? I think you do need to implement a user-friendly shortcut and 
> > expand it to the detailed offload-id internally. I'm fine with allowing 
> > explicit offload id as a hidden argument, but I don't think it's suitable 
> > for something that will be used by everyone who can't be expected to be 
> > aware of all the gory details of particular GPU features.
>
>
> The good thing about this target id is that it is backward compatible with 
> GPU arch. For common users who are not concerned with specific GPU 
> configurations, they can just use the old GPU arch and nothing changes. This 
> is because GPU arch without features implies default value for these 
> features, which work on all configurations. For advanced users who do need to 
> build for specific GPU configurations, they should already have the knowledge 
> about the name and meaning of these configurations by reading the AMDGPU user 
> guide (http://llvm.org/docs/AMDGPUUsage.html). Therefore a target id in the 
> form of gfx908:xnack+ is not something cryptic to them. On the other hand, an 
> encoded GPU arch like gfx908a is cryptic since it has no meaning at all.


I don't quite agree with the `gfx908:xnack+ is not something cryptic` 
assertion. I've looked at the AMDGPUUsage.html and I am pretty sure that I 
still have no clue which ID will be correct for my WX8200. It does not mention 
the card, nor does it specify the offload format. Having to type the IDs with 
the features ordered just so (i.e. without normalization) puts a fair amount of 
burden on the user. Not only they must remember which features must be on or 
off, but they also need to specify them in a very specific order (it's not even 
lexicographically ordered) . I think adding normalization to make it possible 
to specify features in arbitrary order would mitigate some of it.

As it's implemented now, my bet is that it will be *very* annoying to use in 
practice.

At the very least,  you should document the requirements for the offload ID 
format with the specific examples. It would also be useful to provide specific 
offload IDs for particular GPU cards as that's what regular users will have 
info about. Right now the AMDGPUUsage doc does not provide sufficient details 
to derive correct offload ID if all you have is a name of the GPU card. That's 
going to be the case for most of clang users who just want to build things for 
their GPU.

That said, the scheme in the current version of the patch is flexible enough to 
retrofit simplified names later, so I'm overall OK with proceeding with the 
patch once documentation has been updated.


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

https://reviews.llvm.org/D60620



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


[PATCH] D80961: Ignore template instantiations if not in AsIs mode

2020-06-12 Thread Stephen Kelly via Phabricator via cfe-commits
steveire updated this revision to Diff 270472.
steveire edited the summary of this revision.
steveire added a comment.

Update


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80961

Files:
  clang-tools-extra/clang-tidy/abseil/TimeSubtractionCheck.cpp
  clang-tools-extra/clang-tidy/abseil/UpgradeDurationConversionsCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/TooSmallLoopVariableCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/UndefinedMemoryManipulationCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/VirtualNearMissCheck.cpp
  clang-tools-extra/clang-tidy/google/UpgradeGoogletestCaseCheck.cpp
  clang-tools-extra/clang-tidy/hicpp/ExceptionBaseclassCheck.cpp
  clang-tools-extra/clang-tidy/modernize/DeprecatedIosBaseAliasesCheck.cpp
  clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp
  clang-tools-extra/clang-tidy/modernize/ReplaceAutoPtrCheck.cpp
  clang-tools-extra/clang-tidy/modernize/UseOverrideCheck.cpp
  clang-tools-extra/clang-tidy/modernize/UseUncaughtExceptionsCheck.cpp
  clang-tools-extra/clang-tidy/performance/FasterStringFindCheck.cpp
  clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.cpp
  clang-tools-extra/clang-tidy/readability/QualifiedAutoCheck.cpp
  
clang-tools-extra/clang-tidy/readability/StaticAccessedThroughInstanceCheck.cpp
  clang-tools-extra/clang-tidy/zircon/TemporaryObjectsCheck.cpp
  clang/include/clang/AST/ASTNodeTraverser.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/ASTMatchers/ASTMatchersInternal.h
  clang/lib/AST/ASTDumper.cpp
  clang/lib/ASTMatchers/ASTMatchFinder.cpp
  clang/lib/ASTMatchers/ASTMatchersInternal.cpp
  clang/unittests/AST/ASTContextParentMapTest.cpp
  clang/unittests/AST/ASTImporterTest.cpp
  clang/unittests/AST/ASTTraverserTest.cpp
  clang/unittests/AST/SourceLocationTest.cpp
  clang/unittests/AST/StructuralEquivalenceTest.cpp
  clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
  clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
  clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
  clang/unittests/ASTMatchers/Dynamic/RegistryTest.cpp
  clang/unittests/Sema/GslOwnerPointerInference.cpp
  clang/unittests/Tooling/TransformerTest.cpp

Index: clang/unittests/Tooling/TransformerTest.cpp
===
--- clang/unittests/Tooling/TransformerTest.cpp
+++ clang/unittests/Tooling/TransformerTest.cpp
@@ -695,6 +695,70 @@
   EXPECT_EQ(ErrorCount, 0);
 }
 
+TEST_F(TransformerTest, TemplateInstantiation) {
+
+  std::string NonTemplatesInput = R"cpp(
+struct S {
+  int m_i;
+};
+)cpp";
+  std::string NonTemplatesExpected = R"cpp(
+struct S {
+  safe_int m_i;
+};
+)cpp";
+
+  std::string TemplatesInput = R"cpp(
+template
+struct TemplStruct {
+  TemplStruct() {}
+  ~TemplStruct() {}
+
+private:
+  T m_t;
+};
+
+void instantiate()
+{
+  TemplStruct ti;
+}
+)cpp";
+
+  auto MatchedField = fieldDecl(hasType(asString("int"))).bind("theField");
+
+  // Changes the 'int' in 'S', but not the 'T' in 'TemplStruct':
+  testRule(makeRule(traverse(TK_IgnoreUnlessSpelledInSource, MatchedField),
+changeTo(cat("safe_int ", name("theField",
+   NonTemplatesInput + TemplatesInput,
+   NonTemplatesExpected + TemplatesInput);
+
+  // In AsIs mode, template instantiations are modified, which is
+  // often not desired:
+
+  std::string IncorrectTemplatesExpected = R"cpp(
+template
+struct TemplStruct {
+  TemplStruct() {}
+  ~TemplStruct() {}
+
+private:
+  safe_int m_t;
+};
+
+void instantiate()
+{
+  TemplStruct ti;
+}
+)cpp";
+
+  // Changes the 'int' in 'S', and (incorrectly) the 'T' in 'TemplStruct':
+  testRule(makeRule(traverse(TK_AsIs, MatchedField),
+changeTo(cat("safe_int ", name("theField",
+
+   NonTemplatesInput + TemplatesInput,
+   NonTemplatesExpected + IncorrectTemplatesExpected);
+}
+
 // Transformation of macro source text when the change encompasses the entirety
 // of the expanded text.
 TEST_F(TransformerTest, SimpleMacro) {
Index: clang/unittests/Sema/GslOwnerPointerInference.cpp
===
--- clang/unittests/Sema/GslOwnerPointerInference.cpp
+++ clang/unittests/Sema/GslOwnerPointerInference.cpp
@@ -14,42 +14,45 @@
 using namespace ast_matchers;
 
 TEST(OwnerPointer, BothHaveAttributes) {
-  EXPECT_TRUE(matches("template"
-  "class [[gsl::Owner]] C;"
+  EXPECT_TRUE(matches(
+  "template"
+  "class [[gsl::Owner]] C;"
 
-  "template"
-  "class [[gsl::Owner]] C {};"
+  "template"
+  "class [[gsl::Owner]] C {};"
 
-  "C c;",
-  classTemplateSpecializationDecl(
-  hasName("C"), hasAttr(clang::attr::Owner;
+  "C c;",
+ 

[PATCH] D81752: Revert "[analyzer][NFC] Don't allow dependency checkers to emit diagnostics"

2020-06-12 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus accepted this revision.
Szelethus added a comment.

Yup, I agree. Detailed my answer here a bit: D78126#inline-751477 
. Thanks for taking initiative!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81752



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


[PATCH] D78126: [analyzer][NFC] Don't allow dependency checkers to emit diagnostics

2020-06-12 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus marked an inline comment as done.
Szelethus added inline comments.



Comment at: clang/lib/StaticAnalyzer/Core/BugReporter.cpp:43
 #include "clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h"
+#include "clang/StaticAnalyzer/Frontend/CheckerRegistry.h"
 #include "llvm/ADT/ArrayRef.h"

saugustine wrote:
> Unfortunately, this include creates a circular dependency from 
> StaticAnalyzer/Core to StaticAnalyzer/Frontend back to StaticAnalyzer/Core.
> 
> I'm hoping to figure out a fix that doesn't involve reverting it, but if you 
> have a quick fix, that would be really great.
Yup, this is a common theme with these changes, the divide in between the 
analyzer's libraries isn't too well defined.

`CheckerRegistry` definitely belongs to the frontend, and `BugReporter` isn't 
really moving anywhere either. The registry is responsible for parsing the 
command line arguments (which checker is enabled, values of checker options, 
resolving dependencies, etc), but this information is really desired in the 
rest of the analyzer as well.

I think the obvious (to me, that is) solution would be to move the containers 
to the Core library, and leave the rest of the logic in the frontend. While I 
dare claiming that I have great knowledge about this part of the codebase (its 
usually just me maintaining it), I would be more comfortable doing that without 
needing to rush the solution :)

An uncomfortable hack would be to simply implement the new functions in the 
frontend library -- but the former solution better describes where the data 
CheckerRegistry holds should lie.

I'll revert this. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78126



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


[clang] 58de24c - [AMDGPU] Sorted targets in amdgpu-features.cl. NFC.

2020-06-12 Thread Stanislav Mekhanoshin via cfe-commits

Author: Stanislav Mekhanoshin
Date: 2020-06-12T11:57:40-07:00
New Revision: 58de24ce6cb413afea1470ec183f3fc5d9ca6817

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

LOG: [AMDGPU] Sorted targets in amdgpu-features.cl. NFC.

Added: 


Modified: 
clang/test/CodeGenOpenCL/amdgpu-features.cl

Removed: 




diff  --git a/clang/test/CodeGenOpenCL/amdgpu-features.cl 
b/clang/test/CodeGenOpenCL/amdgpu-features.cl
index 7529a4d4abb1..344d4bca44c9 100644
--- a/clang/test/CodeGenOpenCL/amdgpu-features.cl
+++ b/clang/test/CodeGenOpenCL/amdgpu-features.cl
@@ -3,26 +3,26 @@
 // Check that appropriate features are defined for every supported AMDGPU
 // "-target" and "-mcpu" options.
 
+// RUN: %clang_cc1 -triple amdgcn -target-cpu gfx600 -S -emit-llvm -o - %s | 
FileCheck --check-prefix=GFX600 %s
+// RUN: %clang_cc1 -triple amdgcn -target-cpu gfx601 -S -emit-llvm -o - %s | 
FileCheck --check-prefix=GFX601 %s
+// RUN: %clang_cc1 -triple amdgcn -target-cpu gfx700 -S -emit-llvm -o - %s | 
FileCheck --check-prefix=GFX700 %s
+// RUN: %clang_cc1 -triple amdgcn -target-cpu gfx801 -S -emit-llvm -o - %s | 
FileCheck --check-prefix=GFX801 %s
 // RUN: %clang_cc1 -triple amdgcn -target-cpu gfx904 -S -emit-llvm -o - %s | 
FileCheck --check-prefix=GFX904 %s
 // RUN: %clang_cc1 -triple amdgcn -target-cpu gfx906 -S -emit-llvm -o - %s | 
FileCheck --check-prefix=GFX906 %s
 // RUN: %clang_cc1 -triple amdgcn -target-cpu gfx908 -S -emit-llvm -o - %s | 
FileCheck --check-prefix=GFX908 %s
 // RUN: %clang_cc1 -triple amdgcn -target-cpu gfx1010 -S -emit-llvm -o - %s | 
FileCheck --check-prefix=GFX1010 %s
 // RUN: %clang_cc1 -triple amdgcn -target-cpu gfx1011 -S -emit-llvm -o - %s | 
FileCheck --check-prefix=GFX1011 %s
 // RUN: %clang_cc1 -triple amdgcn -target-cpu gfx1012 -S -emit-llvm -o - %s | 
FileCheck --check-prefix=GFX1012 %s
-// RUN: %clang_cc1 -triple amdgcn -target-cpu gfx801 -S -emit-llvm -o - %s | 
FileCheck --check-prefix=GFX801 %s
-// RUN: %clang_cc1 -triple amdgcn -target-cpu gfx700 -S -emit-llvm -o - %s | 
FileCheck --check-prefix=GFX700 %s
-// RUN: %clang_cc1 -triple amdgcn -target-cpu gfx600 -S -emit-llvm -o - %s | 
FileCheck --check-prefix=GFX600 %s
-// RUN: %clang_cc1 -triple amdgcn -target-cpu gfx601 -S -emit-llvm -o - %s | 
FileCheck --check-prefix=GFX601 %s
 
+// GFX600-NOT: "target-features"
+// GFX601-NOT: "target-features"
+// GFX700: "target-features"="+ci-insts,+flat-address-space"
+// GFX801: 
"target-features"="+16-bit-insts,+ci-insts,+dpp,+flat-address-space,+gfx8-insts,+s-memrealtime"
 // GFX904: 
"target-features"="+16-bit-insts,+ci-insts,+dpp,+flat-address-space,+gfx8-insts,+gfx9-insts,+s-memrealtime"
 // GFX906: 
"target-features"="+16-bit-insts,+ci-insts,+dl-insts,+dot1-insts,+dot2-insts,+dpp,+flat-address-space,+gfx8-insts,+gfx9-insts,+s-memrealtime"
 // GFX908: 
"target-features"="+16-bit-insts,+ci-insts,+dl-insts,+dot1-insts,+dot2-insts,+dot3-insts,+dot4-insts,+dot5-insts,+dot6-insts,+dpp,+flat-address-space,+gfx8-insts,+gfx9-insts,+mai-insts,+s-memrealtime"
 // GFX1010: 
"target-features"="+16-bit-insts,+ci-insts,+dl-insts,+dpp,+flat-address-space,+gfx10-insts,+gfx8-insts,+gfx9-insts,+s-memrealtime"
 // GFX1011: 
"target-features"="+16-bit-insts,+ci-insts,+dl-insts,+dot1-insts,+dot2-insts,+dot5-insts,+dot6-insts,+dpp,+flat-address-space,+gfx10-insts,+gfx8-insts,+gfx9-insts,+s-memrealtime"
 // GFX1012: 
"target-features"="+16-bit-insts,+ci-insts,+dl-insts,+dot1-insts,+dot2-insts,+dot5-insts,+dot6-insts,+dpp,+flat-address-space,+gfx10-insts,+gfx8-insts,+gfx9-insts,+s-memrealtime"
-// GFX801: 
"target-features"="+16-bit-insts,+ci-insts,+dpp,+flat-address-space,+gfx8-insts,+s-memrealtime"
-// GFX700: "target-features"="+ci-insts,+flat-address-space"
-// GFX600-NOT: "target-features"
-// GFX601-NOT: "target-features"
 
 kernel void test() {}



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


[PATCH] D81752: Revert "[analyzer][NFC] Don't allow dependency checkers to emit diagnostics"

2020-06-12 Thread Sterling Augustine via Phabricator via cfe-commits
saugustine created this revision.
saugustine added reviewers: echristo, Szelethus, martong.
Herald added subscribers: cfe-commits, ASDenysPetrov, Charusso, dkrupp, 
donat.nagy, mikhail.ramalho, a.sidorin, rnkovacs, szepet, baloghadamsoftware, 
xazax.hun.
Herald added a project: clang.

This reverts commit 33fb9cbe211d1b43d4b84edf34e11001f04cddf0 
.

That commit violates layering by adding a dependency from StaticAnalyzer/Core
back to StaticAnalyzer/FrontEnd, creating a circular dependency.

I can't see a clean way to fix it except refactoring.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81752

Files:
  clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
  clang/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h
  clang/lib/StaticAnalyzer/Core/BugReporter.cpp
  clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp

Index: clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
===
--- clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
+++ clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
@@ -94,10 +94,6 @@
 // Methods of CmdLineOption, PackageInfo and CheckerInfo.
 //===--===//
 
-LLVM_DUMP_METHOD void CheckerRegistry::CmdLineOption::dump() const {
-  dumpToStream(llvm::errs());
-}
-
 LLVM_DUMP_METHOD void
 CheckerRegistry::CmdLineOption::dumpToStream(llvm::raw_ostream &Out) const {
   // The description can be just checked in Checkers.inc, the point here is to
@@ -119,10 +115,6 @@
   llvm_unreachable("Unhandled CheckerRegistry::StateFromCmdLine enum");
 }
 
-LLVM_DUMP_METHOD void CheckerRegistry::CheckerInfo::dump() const {
-  dumpToStream(llvm::errs());
-}
-
 LLVM_DUMP_METHOD void
 CheckerRegistry::CheckerInfo::dumpToStream(llvm::raw_ostream &Out) const {
   // The description can be just checked in Checkers.inc, the point here is to
@@ -145,10 +137,6 @@
   }
 }
 
-LLVM_DUMP_METHOD void CheckerRegistry::PackageInfo::dump() const {
-  dumpToStream(llvm::errs());
-}
-
 LLVM_DUMP_METHOD void
 CheckerRegistry::PackageInfo::dumpToStream(llvm::raw_ostream &Out) const {
   Out << FullName << "\n";
Index: clang/lib/StaticAnalyzer/Core/BugReporter.cpp
===
--- clang/lib/StaticAnalyzer/Core/BugReporter.cpp
+++ clang/lib/StaticAnalyzer/Core/BugReporter.cpp
@@ -40,7 +40,6 @@
 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/SVals.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h"
-#include "clang/StaticAnalyzer/Frontend/CheckerRegistry.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/DenseSet.h"
@@ -2107,32 +2106,6 @@
 // Methods for BugReport and subclasses.
 //===--===//
 
-static bool isDependency(const CheckerRegistry &Registry,
- StringRef CheckerName) {
-  for (const std::pair &Pair : Registry.Dependencies) {
-if (Pair.second == CheckerName)
-  return true;
-  }
-  return false;
-}
-
-PathSensitiveBugReport::PathSensitiveBugReport(
-const BugType &bt, StringRef shortDesc, StringRef desc,
-const ExplodedNode *errorNode, PathDiagnosticLocation LocationToUnique,
-const Decl *DeclToUnique)
-: BugReport(Kind::PathSensitive, bt, shortDesc, desc), ErrorNode(errorNode),
-  ErrorNodeRange(getStmt() ? getStmt()->getSourceRange() : SourceRange()),
-  UniqueingLocation(LocationToUnique), UniqueingDecl(DeclToUnique) {
-  assert(!isDependency(ErrorNode->getState()
-   ->getAnalysisManager()
-   .getCheckerManager()
-   ->getCheckerRegistry(),
-   bt.getCheckerName()) &&
- "Some checkers depend on this one! We don't allow dependency "
- "checkers to emit warnings, because checkers should depend on "
- "*modeling*, not *diagnostics*.");
-}
-
 void PathSensitiveBugReport::addVisitor(
 std::unique_ptr visitor) {
   if (!visitor)
@@ -2221,12 +2194,12 @@
   return;
 case bugreporter::TrackingKind::Condition:
   return;
-}
+  }
 
-llvm_unreachable(
-"BugReport::markInteresting currently can only handle 2 different "
-"tracking kinds! Please define what tracking kind should this entitiy"
-"have, if it was already marked as interesting with a different kind!");
+  llvm_unreachable(
+  "BugReport::markInteresting currently can only handle 2 different "
+  "tracking kinds! Please define what tracking kind should this entitiy"
+  "have, if it was already marked as interesting with a different kind!");
 }
 
 void PathSensitiveBugReport::markInteresting(SymbolRef sym,
Index: clang/include/clang/StaticAnalyzer/Fronte

[PATCH] D80681: [clang][SourceManager] cache Macro Expansions

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

Also forgot to say, thanks a lot for taking your time to investigate this issue 
and coming up with a patch!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80681



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


[PATCH] D81713: [HIP] Fix rocm not found on rocm3.5

2020-06-12 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.

In D81713#2090265 , @tra wrote:

> In D81713#2089760 , @arsenm wrote:
>
> > In D81713#2089680 , @yaxunl wrote:
> >
> > > In D81713#2089672 , @arsenm 
> > > wrote:
> > >
> > > > Can you add tests for this? Is this also sufficient with the directory 
> > > > layout change?
> > >
> > >
> > > You mean does this work after we move device lib from /opt/rocm/lib to 
> > > /opt/rocm/amdgcn/bitcode ?
> >
> >
> > Yes
>
>
> I can tell that it does not. We're still looking under `/opt/rocm` by 
> default. I've ran into it trying to get comgr working with the recent LLVM 
> which prompted my comment on Github 
> 


Not sure how that would be related to comgr? comgr doesn't rely on the dynamic 
path and embeds the bitcode in the library. The comgr build finds the libraries 
through cmake and doesn't care where they're located


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

https://reviews.llvm.org/D81713



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


[PATCH] D81751: [SemaObjC] Fix a -Wobjc-signed-char-bool false-positive with binary conditional operator

2020-06-12 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington created this revision.
erik.pilkington added a reviewer: rjmccall.
Herald added subscribers: ributzka, dexonsmith, jkorous.

We were previously bypassing the conditional expression special case for binary 
conditional expressions. Also, dig through the OpaqueValueExpr on the left of 
the ?:.

rdar://64134411


https://reviews.llvm.org/D81751

Files:
  clang/lib/Sema/SemaChecking.cpp
  clang/test/SemaObjC/signed-char-bool-conversion.m


Index: clang/test/SemaObjC/signed-char-bool-conversion.m
===
--- clang/test/SemaObjC/signed-char-bool-conversion.m
+++ clang/test/SemaObjC/signed-char-bool-conversion.m
@@ -108,3 +108,15 @@
   f(); // expected-note {{in instantiation of function template 
specialization 'f' requested here}}
 }
 #endif
+
+void t5(BOOL b) {
+  int i;
+  b = b ?: YES; // no warning
+  b = b ?: i; // expected-warning {{implicit conversion from integral type 
'int' to 'BOOL'}}
+  b = (b = i) // expected-warning {{implicit conversion from integral type 
'int' to 'BOOL'}}
+   ?: YES;
+  b = (1 ? YES : i) ?: YES; // expected-warning {{implicit conversion from 
integral type 'int' to 'BOOL'}}
+  b = b ?: (1 ? i : i); // expected-warning 2 {{implicit conversion from 
integral type 'int' to 'BOOL'}}
+
+  b = b ? YES : (i ?: 0); // expected-warning {{implicit conversion from 
integral type 'int' to 'BOOL'}}
+}
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -11803,27 +11803,33 @@
   }
 }
 
-static void CheckConditionalOperator(Sema &S, ConditionalOperator *E,
+static void CheckConditionalOperator(Sema &S, AbstractConditionalOperator *E,
  SourceLocation CC, QualType T);
 
 static void CheckConditionalOperand(Sema &S, Expr *E, QualType T,
 SourceLocation CC, bool &ICContext) {
   E = E->IgnoreParenImpCasts();
 
-  if (isa(E))
-return CheckConditionalOperator(S, cast(E), CC, T);
+  if (auto *CO = dyn_cast(E))
+return CheckConditionalOperator(S, CO, CC, T);
 
   AnalyzeImplicitConversions(S, E, CC);
   if (E->getType() != T)
 return CheckImplicitConversion(S, E, T, CC, &ICContext);
 }
 
-static void CheckConditionalOperator(Sema &S, ConditionalOperator *E,
+static void CheckConditionalOperator(Sema &S, AbstractConditionalOperator *E,
  SourceLocation CC, QualType T) {
   AnalyzeImplicitConversions(S, E->getCond(), E->getQuestionLoc());
 
+  Expr *TrueExpr = E->getTrueExpr();
+  if (isa(E))
+if (auto *OVE = dyn_cast(TrueExpr))
+  if (Expr *SourceExpr = OVE->getSourceExpr())
+TrueExpr = SourceExpr;
+
   bool Suspicious = false;
-  CheckConditionalOperand(S, E->getTrueExpr(), T, CC, Suspicious);
+  CheckConditionalOperand(S, TrueExpr, T, CC, Suspicious);
   CheckConditionalOperand(S, E->getFalseExpr(), T, CC, Suspicious);
 
   if (T->isBooleanType())
@@ -11842,7 +11848,7 @@
   if (E->getType() == T) return;
 
   Suspicious = false;
-  CheckImplicitConversion(S, E->getTrueExpr()->IgnoreParenImpCasts(),
+  CheckImplicitConversion(S, TrueExpr->IgnoreParenImpCasts(),
   E->getType(), CC, &Suspicious);
   if (!Suspicious)
 CheckImplicitConversion(S, E->getFalseExpr()->IgnoreParenImpCasts(),
@@ -11905,7 +11911,7 @@
 
   // For conditional operators, we analyze the arguments as if they
   // were being fed directly into the output.
-  if (auto *CO = dyn_cast(SourceExpr)) {
+  if (auto *CO = dyn_cast(SourceExpr)) {
 CheckConditionalOperator(S, CO, CC, T);
 return;
   }


Index: clang/test/SemaObjC/signed-char-bool-conversion.m
===
--- clang/test/SemaObjC/signed-char-bool-conversion.m
+++ clang/test/SemaObjC/signed-char-bool-conversion.m
@@ -108,3 +108,15 @@
   f(); // expected-note {{in instantiation of function template specialization 'f' requested here}}
 }
 #endif
+
+void t5(BOOL b) {
+  int i;
+  b = b ?: YES; // no warning
+  b = b ?: i; // expected-warning {{implicit conversion from integral type 'int' to 'BOOL'}}
+  b = (b = i) // expected-warning {{implicit conversion from integral type 'int' to 'BOOL'}}
+   ?: YES;
+  b = (1 ? YES : i) ?: YES; // expected-warning {{implicit conversion from integral type 'int' to 'BOOL'}}
+  b = b ?: (1 ? i : i); // expected-warning 2 {{implicit conversion from integral type 'int' to 'BOOL'}}
+
+  b = b ? YES : (i ?: 0); // expected-warning {{implicit conversion from integral type 'int' to 'BOOL'}}
+}
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -11803,27 +11803,33 @@
   }
 }
 
-static void CheckConditionalOperator(Sema &S, ConditionalOperator *E,
+static void CheckCon

[PATCH] D80681: [clang][SourceManager] cache Macro Expansions

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

I am not the best person to review this, but dig a little bit into your issues 
and history of this file. Your diagnosis and fix seems reasonable, AFAICT the 
existing caching behavior was chosen to optimize files with many macro 
invocations that are expanding into relatively few tokens. So this case will 
definitely regress after this patch, proportional to 
`number_of_macro_name_tokens/number_of_total_tokens` but I would expect that 
ratio to be quite small in any sane file hence regression to be negligible.

OTOH, when that ratio is low, if number of tokens coming from each/some macro 
expansions is huge (which IIUC is your case) updating that cache makes a lot of 
sense.

Also your claim on `builds of LLVM itself don't change due to this patch.` 
sounds promising. I've seen quite nice benchmarks for kernel build times in the 
issues you've mentioned it would be nice if you could back that claim with 
similar data(not that I don't take your word for it, I just love tables and I 
am jealous that kernel has some but we don't :( )

Apart from all of this, I believe this patch (even though has relatively few 
lines) contains 3 distinct patches that should be split:

- Changing caching behaviour to apply to macro expansions
- Adding a more optimized way of checking if an offset is inside a local file
- Getting rid of some "dead" code.

I can say this patch LG from my side, but my understanding of this code isn't 
quite strong so I would wait for a couple more days to see if someone else will 
chime in.




Comment at: clang/include/clang/Basic/SourceManager.h:1747
   return getLoadedSLocEntryByID(ID, Invalid);
-return getLocalSLocEntry(static_cast(ID), Invalid);
+return getLocalSLocEntry(static_cast(ID));
   }

i think this deserves its separate patch.

We still can satisfy the interface requirements of libclang by introducing 
another member `getLocalSLocEntryWithInvalid` and change the assertion into an 
if check, populating `Invalid` in case of failure, what to return is more 
tricky though it is a const ref, I suppose we can return a dummy entry.

Feel free to keep the newly added calls without an `Invalid` argument, but I 
wouldn't modify the already existing ones in this patch.



Comment at: clang/lib/Basic/SourceManager.cpp:896
+FileID Res = FileID::get(MiddleIndex);
+if (isOffsetInLocalFileID(Res, SLocOffset)) {
+  // Remember it.  We have good locality across FileID lookups.

we already call getLocalSLocEntry for `MiddleIndex` above, moreover we even 
early exit `if (SlocOffset < MidOffset)` which is the second case in your new 
function. So I would say we could even gain more by:

```
const auto &SLocForMiddle = getLocalSLocEntry(MiddleIndex);
auto MidOffset = SLocForMiddle.getOffset();
.
.
.
if (MiddleIndex + 1 ==LocalSLocEntryTable.size() || SLocOffset < 
getLocalSLocEntry(MiddleIndex + 1).getOffset()) {
// we've got a hit!
}
```

That way you also wouldn't need to introduce a new function.

Even though there's value in new helpers, IMO `SourceManager` is already 
complicated and has enough variants of each function to shoot yourself in the 
foot. If you want feel free to put a FIXME saying `we can extract a 
isOffsetInLocalFile helper from these lines if usage is more spread`.


Again I would say this is worth doing in a separate patch. As it should be a 
clear win for all.



Comment at: clang/lib/Basic/SourceManager.cpp:967
 
 if (isOffsetInFileID(FileID::get(-int(MiddleIndex) - 2), SLocOffset)) {
   FileID Res = FileID::get(-int(MiddleIndex) - 2);

my comments above for `isOffsetnLocalFileID` applies to here as well, in case 
you decide to move them into a separate patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80681



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


[PATCH] D81739: [clangd] Turn on RecoveryAST for clangd by default.

2020-06-12 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang-tools-extra/clangd/tool/ClangdMain.cpp:285
+desc("Preserve expressions in AST for broken code (C++ only)."),
+init(true),
 };

Ah actually in other options, we set the default in the struct and reference it 
here. Can we do that here too?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81739



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


[PATCH] D81713: [HIP] Fix rocm not found on rocm3.5

2020-06-12 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

In D81713#2089760 , @arsenm wrote:

> In D81713#2089680 , @yaxunl wrote:
>
> > In D81713#2089672 , @arsenm wrote:
> >
> > > Can you add tests for this? Is this also sufficient with the directory 
> > > layout change?
> >
> >
> > You mean does this work after we move device lib from /opt/rocm/lib to 
> > /opt/rocm/amdgcn/bitcode ?
>
>
> Yes


I can tell that it does not. We're still looking under `/opt/rocm` by default. 
I've ran into it trying to get comgr working with the recent LLVM which 
prompted my comment on Github 



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

https://reviews.llvm.org/D81713



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


[PATCH] D81678: Introduce partialinit attribute at call sites for stricter poison analysis

2020-06-12 Thread Gui Andrade via Phabricator via cfe-commits
guiand added inline comments.



Comment at: clang/include/clang/AST/Type.h:2139-2141
+  /// Check if this type has only two possible values, and so may be lowered to
+  /// a bool.
+  bool hasBooleanRepresentation() const;

rsmith wrote:
> This seems like a CodeGen-specific concern; I'm not sure this makes sense as 
> a query on the Type.
Makes sense, I can move it.



Comment at: clang/lib/AST/Type.cpp:2752-2753
+
+  if (const EnumType *ET = getAs())
+return ET->getDecl()->getIntegerType()->isBooleanType();
+

rsmith wrote:
> Under `-fstrict-enums` in C++, `enum E { a = 0, b = 1 };` has only two 
> distinct valid values. Should we consider that case?
I factored this code out of CGExpr.cpp, as it looked like this function 
governed whether `i1` values were lifted to `i8` (to meet the requirements of 
`bool`). I wanted to avoid struct `bool` members being marked `partialinit`. Do 
you think that would be a worthwhile separate change?



Comment at: clang/lib/CodeGen/CGRecordLayoutBuilder.cpp:679
 
+void CGRecordLowering::determineMemberPartialInit() {
+  auto hasTailPadding = [&](QualType FieldTypePtr) {

rsmith wrote:
> We already have support for C++'s `__has_unique_object_representations` 
> (`ASTContext::hasUniqueObjectRepresentations`), which does something very 
> similar to this. Do we need both? (Are there cases where this is 
> intentionally diverging from `__has_unique_object_representations`?)
For the purposes of this commit, I think I can change the decisions made in 
CGRecordLayoutBuilder to defer to `ASTContext::hasUniqueObjectRepresentations`. 
In an upcoming change though, I'd like to determine exactly what *kind* of 
padding is present in the field, most importantly between basic field padding 
and bitfield/union padding. The reasoning is as follows:

- Union padding (e.g. `union { i32 a; i8 b; }`) is completely erased from the 
outgoing LLVM type, as it's lowered to a `{ i32 }`; same thing goes for 
bitfield tail padding.
- On the other hand, field padding (e.g. in `struct { i8 a; i16 b; }`) is 
preserved in the lowered LLVM type `{ i8, i16 }`.

This means that under certain CGCall conventions, if we only observe field 
padding, we can get away with not using `partialinit`.
- If we're flattening a struct (without coercion) that contains no "lost" 
padding, then each function argument will be a fully initialized field of the 
struct.
- Same thing goes if we're returning an uncoerced LLVM type such as `{ i8, i16 
}`: each individual field is still present and fully initialized.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81678



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


[PATCH] D81750: [analyzer] Don't allow hidden checkers to emit diagnostics

2020-06-12 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus created this revision.
Szelethus added reviewers: NoQ, vsavchenko, dcoughlin, martong, balazske, 
baloghadamsoftware, xazax.hun.
Szelethus added a project: clang.
Herald added subscribers: cfe-commits, ASDenysPetrov, steakhal, Charusso, 
gamesh411, dkrupp, donat.nagy, mikhail.ramalho, a.sidorin, rnkovacs, szepet, 
whisperity.

Exactly what it says on the tin! I moved `StdLibraryFunctionsArg` checker to 
the `unix` package from `apiModeling` as it violated this rule. I believe this 
change doesn't deserve a different revision because it is in alpha, and the 
name is so bad anyways I don't immediately care where it is, because we'll have 
to revisit it soon enough.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81750

Files:
  clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
  clang/lib/StaticAnalyzer/Core/BugReporter.cpp
  clang/test/Analysis/std-c-library-functions-arg-constraints.c
  clang/test/Analysis/std-c-library-functions-arg-constraints.cpp
  clang/test/Analysis/weak-dependencies.c

Index: clang/test/Analysis/weak-dependencies.c
===
--- clang/test/Analysis/weak-dependencies.c
+++ clang/test/Analysis/weak-dependencies.c
@@ -1,5 +1,5 @@
 // RUN: %clang_analyze_cc1 %s -verify \
-// RUN:   -analyzer-checker=alpha.apiModeling.StdCLibraryFunctionArgs \
+// RUN:   -analyzer-checker=alpha.unix.StdCLibraryFunctionArgs \
 // RUN:   -analyzer-checker=core
 
 typedef __typeof(sizeof(int)) size_t;
Index: clang/test/Analysis/std-c-library-functions-arg-constraints.cpp
===
--- clang/test/Analysis/std-c-library-functions-arg-constraints.cpp
+++ clang/test/Analysis/std-c-library-functions-arg-constraints.cpp
@@ -1,7 +1,7 @@
 // RUN: %clang_analyze_cc1 %s \
 // RUN:   -analyzer-checker=core \
 // RUN:   -analyzer-checker=apiModeling.StdCLibraryFunctions \
-// RUN:   -analyzer-checker=alpha.apiModeling.StdCLibraryFunctionArgs \
+// RUN:   -analyzer-checker=alpha.unix.StdCLibraryFunctionArgs \
 // RUN:   -analyzer-checker=debug.StdCLibraryFunctionsTester \
 // RUN:   -analyzer-checker=debug.ExprInspection \
 // RUN:   -analyzer-config eagerly-assume=false \
Index: clang/test/Analysis/std-c-library-functions-arg-constraints.c
===
--- clang/test/Analysis/std-c-library-functions-arg-constraints.c
+++ clang/test/Analysis/std-c-library-functions-arg-constraints.c
@@ -2,7 +2,7 @@
 // RUN: %clang_analyze_cc1 %s \
 // RUN:   -analyzer-checker=core \
 // RUN:   -analyzer-checker=apiModeling.StdCLibraryFunctions \
-// RUN:   -analyzer-checker=alpha.apiModeling.StdCLibraryFunctionArgs \
+// RUN:   -analyzer-checker=alpha.unix.StdCLibraryFunctionArgs \
 // RUN:   -analyzer-checker=debug.StdCLibraryFunctionsTester \
 // RUN:   -analyzer-checker=debug.ExprInspection \
 // RUN:   -triple x86_64-unknown-linux-gnu \
@@ -12,7 +12,7 @@
 // RUN: %clang_analyze_cc1 %s \
 // RUN:   -analyzer-checker=core \
 // RUN:   -analyzer-checker=apiModeling.StdCLibraryFunctions \
-// RUN:   -analyzer-checker=alpha.apiModeling.StdCLibraryFunctionArgs \
+// RUN:   -analyzer-checker=alpha.unix.StdCLibraryFunctionArgs \
 // RUN:   -analyzer-checker=debug.StdCLibraryFunctionsTester \
 // RUN:   -analyzer-checker=debug.ExprInspection \
 // RUN:   -triple x86_64-unknown-linux-gnu \
Index: clang/lib/StaticAnalyzer/Core/BugReporter.cpp
===
--- clang/lib/StaticAnalyzer/Core/BugReporter.cpp
+++ clang/lib/StaticAnalyzer/Core/BugReporter.cpp
@@ -2107,7 +2107,7 @@
 // Methods for BugReport and subclasses.
 //===--===//
 
-static bool isDependency(const CheckerRegistry &Registry,
+LLVM_ATTRIBUTE_USED static bool isDependency(const CheckerRegistry &Registry,
  StringRef CheckerName) {
   for (const std::pair &Pair : Registry.Dependencies) {
 if (Pair.second == CheckerName)
@@ -2116,6 +2116,17 @@
   return false;
 }
 
+LLVM_ATTRIBUTE_USED static bool isHidden(const CheckerRegistry &Registry,
+ StringRef CheckerName) {
+  for (const CheckerRegistry::CheckerInfo &Checker : Registry.Checkers) {
+if (Checker.FullName == CheckerName)
+  return Checker.IsHidden;
+  }
+  llvm_unreachable(
+  "Checker name not found in CheckerRegistry -- did you retrieve it "
+  "correctly from CheckerManager::getCurrentCheckerName?");
+}
+
 PathSensitiveBugReport::PathSensitiveBugReport(
 const BugType &bt, StringRef shortDesc, StringRef desc,
 const ExplodedNode *errorNode, PathDiagnosticLocation LocationToUnique,
@@ -2131,6 +2142,16 @@
  "Some checkers depend on this one! We don't allow dependency "
  "checkers to emit warnings, because checkers should depend on "
  "*modeling*, not *diagnostics*.");
+
+  assert(
+  bt.getCheckerName

[PATCH] D80961: Ignore template instantiations if not in AsIs mode

2020-06-12 Thread Stephen Kelly via Phabricator via cfe-commits
steveire added a comment.

In D80961#2079419 , @aaron.ballman 
wrote:

> In D80961#2079044 , @klimek wrote:
>
> > In D80961#2076242 , @aaron.ballman 
> > wrote:
> >
> > > In D80961#2073049 , @klimek 
> > > wrote:
> > >
> > > > Without jumping into the discussion whether it should be the default, I 
> > > > think we should be able to control template instantiation visitation 
> > > > separately from other implicit nodes.
> > > >  Having to put AsIs on a matcher every time you need to match template 
> > > > instantiations is a rather big change (suddenly you have to change all 
> > > > the matchers you've written so far).
> > >
> > >
> > > I think that's the intended meaning of `AsIs` though. Template 
> > > instantiations are not source code the user wrote, they're source code 
> > > the compiler stamped out from code the user wrote. I hope 
> > > `IgnoreUnlessSpelledInSource` isn't a misnomer.
> > >
> > > > I love the idea of being able to control visitation of template 
> > > > instantiation.
> > > >  I am somewhat torn on whether it should be the default, and would like 
> > > > to see more data.
> > > >  I feel more strongly about needing AsIs when I want to match template 
> > > > instantiations.
> > >
> > > FWIW, my experience in clang-tidy has been that template instantiations 
> > > are ignored far more often than they're desired. In fact, instantiations 
> > > tend to be a source of bugs for us because they're easy to forget about 
> > > when writing matchers without keeping templates in mind. The times when 
> > > template instantiations become important to *not* ignore within the 
> > > checks is when the check is specific to template behavior, but that's a 
> > > minority of the public checks thus far.
> >
> >
> > So I assume the idea is that this will work & be what we'll want people to 
> > write?
> >  traverse(AsIs, decl(traverse(IgnoreImplicit, hasFoo)))
>
>
> I believe so, yes. It's explicit about which traversal mode you want any 
> given set of matchers to match with, so it is more flexible at the expense of 
> being more verbose. Alternatively, you could be in `AsIs` mode for all of it 
> and explicitly ignore the implicit nodes you wish to ignore (which may be 
> even more verbose with the same results, depending on the matchers involved).


As far as I can tell, the people who had "standing objections" to fixing this 
bug have been convinced that it makes sense. At least that is implied.

The problem is they haven't explicitly reversed so progress is still blocked.

Please respond to either say you're no longer blocking this or say why you 
continue to block it.

There is no reason not to fix this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80961



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


[PATCH] D78126: [analyzer][NFC] Don't allow dependency checkers to emit diagnostics

2020-06-12 Thread Sterling Augustine via Phabricator via cfe-commits
saugustine added inline comments.



Comment at: clang/lib/StaticAnalyzer/Core/BugReporter.cpp:43
 #include "clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h"
+#include "clang/StaticAnalyzer/Frontend/CheckerRegistry.h"
 #include "llvm/ADT/ArrayRef.h"

Unfortunately, this include creates a circular dependency from 
StaticAnalyzer/Core to StaticAnalyzer/Frontend back to StaticAnalyzer/Core.

I'm hoping to figure out a fix that doesn't involve reverting it, but if you 
have a quick fix, that would be really great.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78126



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


[clang] c32d261 - Don't diagnose a redeclaration of a deduction guide if the prior

2020-06-12 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2020-06-12T10:29:01-07:00
New Revision: c32d261e27c8c63653799fa6e411c373bd81d519

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

LOG: Don't diagnose a redeclaration of a deduction guide if the prior
declaration is not visible.

In passing, add a test for a similar case of conflicting redeclarations
of internal-linkage structured bindings. (This case already works).

Added: 
clang/test/Modules/Inputs/cxx17/unimported.h
clang/test/Modules/Inputs/cxx20/decls.h
clang/test/Modules/Inputs/cxx20/module.modulemap
clang/test/Modules/Inputs/cxx20/unimported.h
clang/test/Modules/cxx20.cpp

Modified: 
clang/lib/Sema/SemaDeclCXX.cpp
clang/test/Modules/Inputs/cxx17/module.modulemap
clang/test/Modules/cxx17.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index a77f7a460242..f1ade752e2fe 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -678,7 +678,7 @@ bool Sema::MergeCXXFunctionDecl(FunctionDecl *New, 
FunctionDecl *Old,
   //   for the same class template shall not have equivalent
   //   parameter-declaration-clauses.
   if (isa(New) &&
-  !New->isFunctionTemplateSpecialization()) {
+  !New->isFunctionTemplateSpecialization() && isVisible(Old)) {
 Diag(New->getLocation(), diag::err_deduction_guide_redeclared);
 Diag(Old->getLocation(), diag::note_previous_declaration);
   }

diff  --git a/clang/test/Modules/Inputs/cxx17/module.modulemap 
b/clang/test/Modules/Inputs/cxx17/module.modulemap
index 2339e49e03bd..c80e6e7b13eb 100644
--- a/clang/test/Modules/Inputs/cxx17/module.modulemap
+++ b/clang/test/Modules/Inputs/cxx17/module.modulemap
@@ -1 +1,4 @@
-module Decls { header "decls.h" }
+module Decls {
+  header "decls.h"
+  explicit module Unimported { header "unimported.h" }
+}

diff  --git a/clang/test/Modules/Inputs/cxx17/unimported.h 
b/clang/test/Modules/Inputs/cxx17/unimported.h
new file mode 100644
index ..97c75e635d83
--- /dev/null
+++ b/clang/test/Modules/Inputs/cxx17/unimported.h
@@ -0,0 +1,2 @@
+template struct DeductionGuide {};
+DeductionGuide() -> DeductionGuide;

diff  --git a/clang/test/Modules/Inputs/cxx20/decls.h 
b/clang/test/Modules/Inputs/cxx20/decls.h
new file mode 100644
index ..e69de29bb2d1

diff  --git a/clang/test/Modules/Inputs/cxx20/module.modulemap 
b/clang/test/Modules/Inputs/cxx20/module.modulemap
new file mode 100644
index ..c80e6e7b13eb
--- /dev/null
+++ b/clang/test/Modules/Inputs/cxx20/module.modulemap
@@ -0,0 +1,4 @@
+module Decls {
+  header "decls.h"
+  explicit module Unimported { header "unimported.h" }
+}

diff  --git a/clang/test/Modules/Inputs/cxx20/unimported.h 
b/clang/test/Modules/Inputs/cxx20/unimported.h
new file mode 100644
index ..226b087c0848
--- /dev/null
+++ b/clang/test/Modules/Inputs/cxx20/unimported.h
@@ -0,0 +1,4 @@
+namespace StructuredBinding {
+  struct Q { int p, q; };
+  static auto [a, b] = Q();
+}

diff  --git a/clang/test/Modules/cxx17.cpp b/clang/test/Modules/cxx17.cpp
index 1efb490828db..87039ef76656 100644
--- a/clang/test/Modules/cxx17.cpp
+++ b/clang/test/Modules/cxx17.cpp
@@ -9,3 +9,7 @@ struct MergeExceptionSpec {
 #include "decls.h"
 
 MergeExceptionSpec mergeExceptionSpec2;
+
+template struct DeductionGuide {};
+DeductionGuide() -> DeductionGuide;
+DeductionGuide a;

diff  --git a/clang/test/Modules/cxx20.cpp b/clang/test/Modules/cxx20.cpp
new file mode 100644
index ..e85bc9ad8a8f
--- /dev/null
+++ b/clang/test/Modules/cxx20.cpp
@@ -0,0 +1,11 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -x c++ -std=c++20 -fmodules-cache-path=%t -fmodules 
-fimplicit-module-maps -I %S/Inputs/cxx20 %s -verify -fno-modules-error-recovery
+
+// expected-no-diagnostics
+
+#include "decls.h"
+
+namespace StructuredBinding {
+  struct R { int x, y; };
+  static auto [a, b] = R();
+}



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


[PATCH] D80681: [clang][SourceManager] cache Macro Expansions

2020-06-12 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment.

Bumping for review.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80681



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


[PATCH] D79796: Sketch support for generating CC1 command line from CompilerInvocation

2020-06-12 Thread Daniel Grumberg via Phabricator via cfe-commits
dang updated this revision to Diff 270445.
dang edited the summary of this revision.
dang added a comment.

Implemented a draft of normalizer generation for simple enum based options


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79796

Files:
  clang/include/clang/Driver/CC1Options.td
  clang/include/clang/Frontend/CompilerInvocation.h
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/unittests/Frontend/CMakeLists.txt
  clang/unittests/Frontend/CompilerInvocationTest.cpp
  llvm/include/llvm/Option/OptParser.td
  llvm/utils/TableGen/OptParserEmitter.cpp

Index: llvm/utils/TableGen/OptParserEmitter.cpp
===
--- llvm/utils/TableGen/OptParserEmitter.cpp
+++ llvm/utils/TableGen/OptParserEmitter.cpp
@@ -10,6 +10,7 @@
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/Twine.h"
+#include "llvm/Support/raw_ostream.h"
 #include "llvm/TableGen/Record.h"
 #include "llvm/TableGen/TableGenBackend.h"
 #include 
@@ -33,6 +34,50 @@
   return OS;
 }
 
+static void emitMarshallingInfoFlag(raw_ostream &OS, const Record &R) {
+  OS << R.getValueAsBit("IsPositive");
+}
+
+static void emitMarshallingInfoString(raw_ostream &OS, const Record &R) {
+  OS << R.getValueAsString("Normalizer");
+  OS << ", ";
+  OS << R.getValueAsString("Denormalizer");
+}
+
+static void emitScopedNormalizedValue(raw_ostream &OS,
+  StringRef NormalizedValuesScope,
+  StringRef NormalizedValue) {
+  if (!NormalizedValuesScope.empty())
+OS << NormalizedValuesScope << "::";
+  OS << NormalizedValue;
+}
+
+static void emitValueTable(raw_ostream &OS, StringRef OptionID,
+   StringRef Values, StringRef NormalizedValuesScope,
+   std::vector NormalizedValues) {
+  SmallVector SplitValues;
+  Values.split(SplitValues, ',');
+  assert(SplitValues.size() == NormalizedValues.size() &&
+ "The number of associated definitions doesn't match the number of "
+ "values");
+
+  SmallString<64> MacroName("HANDLE_");
+  MacroName += OptionID.upper();
+  MacroName += "_VALUES";
+  OS << "#ifdef " << MacroName << "\n";
+  for (unsigned I = 0, E = SplitValues.size(); I != E; ++I) {
+OS << MacroName << "(\"" << SplitValues[I] << "\",";
+emitScopedNormalizedValue(OS, NormalizedValuesScope, NormalizedValues[I]);
+OS << ")\n";
+  }
+  OS << "#endif\n";
+}
+
+struct MarshallingKindInfo {
+  const char *MacroName;
+  void (*Emit)(raw_ostream &OS, const Record &R);
+};
+
 /// OptParserEmitter - This tablegen backend takes an input .td file
 /// describing a list of options and emits a data structure for parsing and
 /// working with those options when given an input command line.
@@ -135,12 +180,8 @@
 
   OS << "//\n";
   OS << "// Options\n\n";
-  for (unsigned i = 0, e = Opts.size(); i != e; ++i) {
-const Record &R = *Opts[i];
-
-// Start a single option entry.
-OS << "OPTION(";
 
+  auto WriteOptRecordFields = [&](raw_ostream &OS, const Record &R) {
 // The option prefix;
 std::vector prf = R.getValueAsListOfStrings("Prefixes");
 OS << Prefixes[PrefixKeyT(prf.begin(), prf.end())] << ", ";
@@ -223,11 +264,119 @@
   write_cstring(OS, R.getValueAsString("Values"));
 else
   OS << "nullptr";
+  };
 
+  std::vector OptsWithMarshalling;
+  for (unsigned i = 0, e = Opts.size(); i != e; ++i) {
+const Record &R = *Opts[i];
+
+// Start a single option entry.
+OS << "OPTION(";
+WriteOptRecordFields(OS, R);
 OS << ")\n";
+if (!isa(R.getValueInit("MarshallingKind")))
+  OptsWithMarshalling.push_back(&R);
   }
   OS << "#endif // OPTION\n";
 
+  std::vector AutoNormalizableOpts;
+  for (unsigned I = 0, E = OptsWithMarshalling.size(); I != E; ++I) {
+const Record &R = *OptsWithMarshalling[I];
+assert(!isa(R.getValueInit("KeyPath")) &&
+   !isa(R.getValueInit("DefaultValue")) &&
+   "Must provide at least a key-path and a default value for emitting "
+   "marshalling information");
+StringRef KindStr = R.getValueAsString("MarshallingKind");
+auto KindInfo = StringSwitch(KindStr)
+.Case("flag", {"OPTION_WITH_MARSHALLING_FLAG",
+   &emitMarshallingInfoFlag})
+.Case("string", {"OPTION_WITH_MARSHALLING_STRING",
+ &emitMarshallingInfoString})
+.Default({"", nullptr});
+StringRef NormalizedValuesScope;
+if (!isa(R.getValueInit("NormalizedValuesScope")))
+  NormalizedValuesScope = R.getValueAsString("NormalizedValuesScope");
+
+OS << "#ifdef " << KindInfo.MacroName << "\n";
+OS << KindInfo.MacroName << "(";
+WriteOptRecordFields(OS, R);
+OS << ", ";
+OS << R.getValueAsBit("Should

[PATCH] D81392: [clang] Rename Decl::isHidden() to isUnconditionallyVisible()

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

In D81392#2089251 , @mboehme wrote:

> In D81392#2088131 , @rsmith wrote:
>
> > Maybe we should dump the ModuleOwnershipKind in general, not only an 
> > indicator of whether it's Visible or something else?
>
>
> I like this -- though would we then always dump the ModuleOwnershipKind (i.e. 
> causing a lot of churn, as discussed above) or only if it's 
> `VisibleWhenImported` or `ModulePrivate` (i.e. not unconditionally visible)?


I think only producing output for the "non-default" state (not Visible) would 
be best, both too minimize the test churn and to keep the dump smaller and 
simpler in simple cases.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81392



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


[PATCH] D74166: [AIX][Frontend] Static init implementation for AIX considering no priority

2020-06-12 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added inline comments.



Comment at: clang/lib/CodeGen/CGDeclCXX.cpp:807
 
 void CodeGenFunction::GenerateCXXGlobalDtorsFunc(
 llvm::Function *Fn,

This function is to be renamed.



Comment at: clang/lib/CodeGen/CodeGenModule.h:401
+  /// A unique trailing identifier as a part of sinit/sterm function when
+  /// UseSinitAndSterm of CXXABI set as true.
+  std::string GlobalUniqueModuleId;

Minor nit: s/set/is set/;


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

https://reviews.llvm.org/D74166



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


[PATCH] D74166: [AIX][Frontend] Static init implementation for AIX considering no priority

2020-06-12 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added inline comments.



Comment at: clang/test/CodeGen/static-init.cpp:12
   ~test();
-} t;
+} t1, t2;
 

I suggest adding also one each of the following:

  - a dynamic initialization of a non-local variable of type `int`
  - a `constinit` initialization of a non-local variable with non-constant 
destruction



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

https://reviews.llvm.org/D74166



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


Re: [clang] 1eddce4 - Fix non-determinism issue with implicit lambda captures.

2020-06-12 Thread Richard Smith via cfe-commits
On Fri, 12 Jun 2020 at 09:17, Erich Keane via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

>
> Author: Erich Keane
> Date: 2020-06-12T09:16:43-07:00
> New Revision: 1eddce4177cfddc86d4696b758904443b0b4f193
>
> URL:
> https://github.com/llvm/llvm-project/commit/1eddce4177cfddc86d4696b758904443b0b4f193
> DIFF:
> https://github.com/llvm/llvm-project/commit/1eddce4177cfddc86d4696b758904443b0b4f193.diff
>
> LOG: Fix non-determinism issue with implicit lambda captures.
>
> We were using llvm::SmallPtrSet for our ODR-use set which was also used
> for instantiating the implicit lambda captures. The order in which the
> captures are added depends on this, so the lambda's layout ended up
> changing.  The test just uses floats, but this was noticed with other
> types as well.
>
> This test replaces the short-lived SmallPtrSet (it lasts only for an
> expression, which, though is a long time for lambdas, is at least not
> forever) with a SmallSetVector.
>

Wow, that's bad. Nice catch.


> Added:
> clang/test/CodeGenCXX/lambda-deterministic-captures.cpp
>
> Modified:
> clang/include/clang/Sema/Sema.h
> clang/lib/Sema/SemaExpr.cpp
>
> Removed:
>
>
>
>
> 
> diff  --git a/clang/include/clang/Sema/Sema.h
> b/clang/include/clang/Sema/Sema.h
> index 266192087d35..a3f4313c0d65 100644
> --- a/clang/include/clang/Sema/Sema.h
> +++ b/clang/include/clang/Sema/Sema.h
> @@ -627,7 +627,7 @@ class Sema final {
>/// we won't know until all lvalue-to-rvalue and discarded value
> conversions
>/// have been applied to all subexpressions of the enclosing full
> expression.
>/// This is cleared at the end of each full expression.
> -  using MaybeODRUseExprSet = llvm::SmallPtrSet;
> +  using MaybeODRUseExprSet = llvm::SmallSetVector;
>MaybeODRUseExprSet MaybeODRUseExprs;
>
>std::unique_ptr CachedFunctionScope;
>
> diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
> index 6477979e92fe..6965acdb6163 100644
> --- a/clang/lib/Sema/SemaExpr.cpp
> +++ b/clang/lib/Sema/SemaExpr.cpp
> @@ -17553,7 +17553,7 @@ static ExprResult
> rebuildPotentialResultsAsNonOdrUsed(Sema &S, Expr *E,
>
>// Mark that this expression does not constitute an odr-use.
>auto MarkNotOdrUsed = [&] {
> -S.MaybeODRUseExprs.erase(E);
> +S.MaybeODRUseExprs.remove(E);
>  if (LambdaScopeInfo *LSI = S.getCurLambda())
>LSI->markVariableExprAsNonODRUsed(E);
>};
>
> diff  --git a/clang/test/CodeGenCXX/lambda-deterministic-captures.cpp
> b/clang/test/CodeGenCXX/lambda-deterministic-captures.cpp
> new file mode 100644
> index ..d025a431d5c5
> --- /dev/null
> +++ b/clang/test/CodeGenCXX/lambda-deterministic-captures.cpp
> @@ -0,0 +1,33 @@
> +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm
> --std=c++17 %s -o - | FileCheck %s
> +
> +struct stream {
> +  friend const stream &operator<<(const stream &, const float &);
> +};
> +
> +void foo() {
> +  constexpr float f_zero = 0.0f;
> +  constexpr float f_one = 1.0f;
> +  constexpr float f_two = 2.0f;
> +
> +  stream s;
> +  [=]() {
> +s << f_zero << f_one << f_two;
> +  }();
> +}
> +
> +// CHECK: define void @_Z3foov
> +// CHECK: getelementptr inbounds %{{.+}}, %{{.+}}* %{{.+}}, i32 0, i32 0
> +// CHECK-NEXT: getelementptr inbounds %{{.+}}, %{{.+}}* %{{.+}}, i32 0,
> i32 1
> +// CHECK-NEXT: store float 0.000
> +// CHECK-NEXT: getelementptr inbounds %{{.+}}, %{{.+}}* %{{.+}}, i32 0,
> i32 2
> +// CHECK-NEXT: store float 1.000
> +// CHECK-NEXT: getelementptr inbounds %{{.+}}, %{{.+}}* %{{.+}}, i32 0,
> i32 3
> +// CHECK-NEXT: store float 2.000
> +
> +// The lambda body.  Reverse iteration when the captures aren't
> deterministic
> +// causes these to be laid out
> diff erently in the lambda.
> +// CHECK: define internal void
> +// CHECK: getelementptr inbounds %{{.+}}, %{{.+}}* %{{.+}}, i32 0, i32 0
> +// CHECK: getelementptr inbounds %{{.+}}, %{{.+}}* %{{.+}}, i32 0, i32 1
> +// CHECK: getelementptr inbounds %{{.+}}, %{{.+}}* %{{.+}}, i32 0, i32 2
> +// CHECK: getelementptr inbounds %{{.+}}, %{{.+}}* %{{.+}}, i32 0, i32 3
>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 270d580 - [analyzer] Avoid unused variable warning in opt build

2020-06-12 Thread Jacques Pienaar via cfe-commits

Author: Jacques Pienaar
Date: 2020-06-12T09:48:49-07:00
New Revision: 270d580a0e9ff2f2e1b6240fccedee7c25dc3bfa

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

LOG: [analyzer] Avoid unused variable warning in opt build

Added: 


Modified: 
clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp 
b/clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
index 4a7e0d91ea23..461d08f3d2c7 100644
--- a/clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
+++ b/clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
@@ -297,7 +297,9 @@ CheckerRegistry::CheckerRegistry(
  "A strong dependency mustn't have weak dependencies!");
   assert(WeakDepPair.second != DepPair.second &&
  "A strong dependency mustn't be a weak dependency as well!");
+  (void)WeakDepPair;
 }
+(void)DepPair;
   }
 #endif
 



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


[PATCH] D78933: [analyzer] RangeConstraintManager optimizations in comparison expressions

2020-06-12 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun accepted this revision.
xazax.hun added a comment.

I would not call the results of the measurement within the margin of error but 
the results do not look bad. Unless there is some objection from someone else I 
am ok with committing this but please change the title of revision before 
committing. When one says optimization we often think about performance.  It 
should say something like reasoning about more comparison operations.


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

https://reviews.llvm.org/D78933



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


[clang] 1eddce4 - Fix non-determinism issue with implicit lambda captures.

2020-06-12 Thread Erich Keane via cfe-commits

Author: Erich Keane
Date: 2020-06-12T09:16:43-07:00
New Revision: 1eddce4177cfddc86d4696b758904443b0b4f193

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

LOG: Fix non-determinism issue with implicit lambda captures.

We were using llvm::SmallPtrSet for our ODR-use set which was also used
for instantiating the implicit lambda captures. The order in which the
captures are added depends on this, so the lambda's layout ended up
changing.  The test just uses floats, but this was noticed with other
types as well.

This test replaces the short-lived SmallPtrSet (it lasts only for an
expression, which, though is a long time for lambdas, is at least not
forever) with a SmallSetVector.

Added: 
clang/test/CodeGenCXX/lambda-deterministic-captures.cpp

Modified: 
clang/include/clang/Sema/Sema.h
clang/lib/Sema/SemaExpr.cpp

Removed: 




diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 266192087d35..a3f4313c0d65 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -627,7 +627,7 @@ class Sema final {
   /// we won't know until all lvalue-to-rvalue and discarded value conversions
   /// have been applied to all subexpressions of the enclosing full expression.
   /// This is cleared at the end of each full expression.
-  using MaybeODRUseExprSet = llvm::SmallPtrSet;
+  using MaybeODRUseExprSet = llvm::SmallSetVector;
   MaybeODRUseExprSet MaybeODRUseExprs;
 
   std::unique_ptr CachedFunctionScope;

diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 6477979e92fe..6965acdb6163 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -17553,7 +17553,7 @@ static ExprResult 
rebuildPotentialResultsAsNonOdrUsed(Sema &S, Expr *E,
 
   // Mark that this expression does not constitute an odr-use.
   auto MarkNotOdrUsed = [&] {
-S.MaybeODRUseExprs.erase(E);
+S.MaybeODRUseExprs.remove(E);
 if (LambdaScopeInfo *LSI = S.getCurLambda())
   LSI->markVariableExprAsNonODRUsed(E);
   };

diff  --git a/clang/test/CodeGenCXX/lambda-deterministic-captures.cpp 
b/clang/test/CodeGenCXX/lambda-deterministic-captures.cpp
new file mode 100644
index ..d025a431d5c5
--- /dev/null
+++ b/clang/test/CodeGenCXX/lambda-deterministic-captures.cpp
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm --std=c++17 %s 
-o - | FileCheck %s
+
+struct stream {
+  friend const stream &operator<<(const stream &, const float &);
+};
+
+void foo() {
+  constexpr float f_zero = 0.0f;
+  constexpr float f_one = 1.0f;
+  constexpr float f_two = 2.0f;
+
+  stream s;
+  [=]() {
+s << f_zero << f_one << f_two;
+  }();
+}
+
+// CHECK: define void @_Z3foov
+// CHECK: getelementptr inbounds %{{.+}}, %{{.+}}* %{{.+}}, i32 0, i32 0
+// CHECK-NEXT: getelementptr inbounds %{{.+}}, %{{.+}}* %{{.+}}, i32 0, i32 1
+// CHECK-NEXT: store float 0.000
+// CHECK-NEXT: getelementptr inbounds %{{.+}}, %{{.+}}* %{{.+}}, i32 0, i32 2
+// CHECK-NEXT: store float 1.000
+// CHECK-NEXT: getelementptr inbounds %{{.+}}, %{{.+}}* %{{.+}}, i32 0, i32 3
+// CHECK-NEXT: store float 2.000
+
+// The lambda body.  Reverse iteration when the captures aren't deterministic
+// causes these to be laid out 
diff erently in the lambda.
+// CHECK: define internal void
+// CHECK: getelementptr inbounds %{{.+}}, %{{.+}}* %{{.+}}, i32 0, i32 0
+// CHECK: getelementptr inbounds %{{.+}}, %{{.+}}* %{{.+}}, i32 0, i32 1
+// CHECK: getelementptr inbounds %{{.+}}, %{{.+}}* %{{.+}}, i32 0, i32 2
+// CHECK: getelementptr inbounds %{{.+}}, %{{.+}}* %{{.+}}, i32 0, i32 3



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


[PATCH] D81745: [analyzer][MallocChecker] PR46253: Correctly recognize standard realloc

2020-06-12 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus created this revision.
Szelethus added reviewers: NoQ, hokein, baloghadamsoftware, balazske, 
xazax.hun, dcoughlin, vsavchenko, martong.
Szelethus added a project: clang.
Herald added subscribers: cfe-commits, ASDenysPetrov, steakhal, Charusso, 
gamesh411, dkrupp, donat.nagy, mikhail.ramalho, a.sidorin, rnkovacs, szepet, 
whisperity.

https://bugs.llvm.org/show_bug.cgi?id=46253

This is an obvious hack because `realloc` isn't any more affected than other 
functions modeled by MallocChecker (or any user of `CallDescription` really), 
but the nice solution will take some time to implement.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81745

Files:
  clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
  clang/test/Analysis/malloc.cpp


Index: clang/test/Analysis/malloc.cpp
===
--- clang/test/Analysis/malloc.cpp
+++ clang/test/Analysis/malloc.cpp
@@ -172,3 +172,21 @@
   // ZERO_SIZE_PTR is specially handled but only for malloc family
   delete Ptr; // expected-warning{{Argument to 'delete' is a constant address 
(16)}}
 }
+
+namespace pr46253_class {
+class a {
+  void *realloc(int, bool = false) { realloc(1); } // no-crash
+};
+} // namespace pr46253_class
+
+namespace pr46253_retty{
+void realloc(void *ptr, size_t size) { realloc(ptr, size); } // no-crash
+} // namespace pr46253_retty
+
+namespace pr46253_paramty{
+void *realloc(void **ptr, size_t size) { realloc(ptr, size); } // no-crash
+} // namespace pr46253_paramty
+
+namespace pr46253_paramty2{
+void *realloc(void *ptr, int size) { realloc(ptr, size); } // no-crash
+} // namespace pr46253_paramty2
Index: clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
@@ -47,6 +47,7 @@
 #include "AllocationState.h"
 #include "InterCheckerAPI.h"
 #include "clang/AST/Attr.h"
+#include "clang/AST/DeclCXX.h"
 #include "clang/AST/Expr.h"
 #include "clang/AST/ExprCXX.h"
 #include "clang/AST/ParentMap.h"
@@ -1037,9 +1038,44 @@
   C.addTransition(State);
 }
 
-void MallocChecker::checkRealloc(const CallEvent &Call,
- CheckerContext &C,
+static bool isStandardRealloc(const CallEvent &Call) {
+  const FunctionDecl *FD = dyn_cast(Call.getDecl());
+  assert(FD);
+  ASTContext &AC = FD->getASTContext();
+
+  if (isa(FD))
+return false;
+
+  return FD->getDeclaredReturnType().getDesugaredType(AC) == AC.VoidPtrTy &&
+ FD->getParamDecl(0)->getType().getDesugaredType(AC) == AC.VoidPtrTy &&
+ FD->getParamDecl(1)->getType().getDesugaredType(AC) ==
+ AC.getSizeType();
+}
+
+static bool isGRealloc(const CallEvent &Call) {
+  const FunctionDecl *FD = dyn_cast(Call.getDecl());
+  assert(FD);
+  ASTContext &AC = FD->getASTContext();
+
+  if (isa(FD))
+return false;
+
+  return FD->getDeclaredReturnType().getDesugaredType(AC) == AC.VoidPtrTy &&
+ FD->getParamDecl(0)->getType().getDesugaredType(AC) == AC.VoidPtrTy &&
+ FD->getParamDecl(1)->getType().getDesugaredType(AC) ==
+ AC.UnsignedLongTy;
+}
+
+void MallocChecker::checkRealloc(const CallEvent &Call, CheckerContext &C,
  bool ShouldFreeOnFail) const {
+  // HACK: CallDescription currently recognizes non-standard realloc functions
+  // as standard because it doesn't check the type, or wether its a non-method
+  // function. This should be solved by making CallDescription smarter.
+  // Mind that this came from a bug report, and all other functions suffer from
+  // this.
+  // https://bugs.llvm.org/show_bug.cgi?id=46253
+  if (!isStandardRealloc(Call) && !isGRealloc(Call))
+return;
   ProgramStateRef State = C.getState();
   State = ReallocMemAux(C, Call, ShouldFreeOnFail, State, AF_Malloc);
   State = ProcessZeroAllocCheck(Call, 1, State);


Index: clang/test/Analysis/malloc.cpp
===
--- clang/test/Analysis/malloc.cpp
+++ clang/test/Analysis/malloc.cpp
@@ -172,3 +172,21 @@
   // ZERO_SIZE_PTR is specially handled but only for malloc family
   delete Ptr; // expected-warning{{Argument to 'delete' is a constant address (16)}}
 }
+
+namespace pr46253_class {
+class a {
+  void *realloc(int, bool = false) { realloc(1); } // no-crash
+};
+} // namespace pr46253_class
+
+namespace pr46253_retty{
+void realloc(void *ptr, size_t size) { realloc(ptr, size); } // no-crash
+} // namespace pr46253_retty
+
+namespace pr46253_paramty{
+void *realloc(void **ptr, size_t size) { realloc(ptr, size); } // no-crash
+} // namespace pr46253_paramty
+
+namespace pr46253_paramty2{
+void *realloc(void *ptr, int size) { realloc(ptr, size); } // no-crash
+} // namespace pr46253_paramty2
Index: clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp

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

2020-06-12 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 270413.
hokein added a comment.

rebase and adjust the test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81163

Files:
  clang/lib/Sema/SemaExpr.cpp
  clang/test/AST/ast-dump-recovery.cpp
  clang/test/SemaTemplate/instantiate-expr-3.cpp


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


Index: clang/test/SemaTemplate/instantiate-expr-3.cpp
===
--- clang/test/SemaTemplate/instantiate-expr-3.cpp
+++ clang/test/SemaTemplate/instantiate-expr-3.cpp
@@ -65,7 +65,7 @@
   void f(T t) {
 (void)({
 if (t) // expected-error{{contextually convertible}}
-  t = t + 17;
+  t = t + 17; // expected-error {{invalid operands to binary expression ('N1::X' and 'int')}}
 t + 12; // expected-error{{invalid operands}}
   });
   }
Index: clang/test/AST/ast-dump-recovery.cpp
===
--- clang/test/AST/ast-dump-recovery.cpp
+++ clang/test/AST/ast-dump-recovery.cpp
@@ -211,3 +211,30 @@
 } NoCrashOnInvalidInitList = {
   .abc = nullptr,
 };
+
+void InvalidCondition() {
+  // CHECK:  IfStmt {{.*}}
+  // CHECK-NEXT: |-RecoveryExpr {{.*}}  '' contains-errors
+  // CHECK-NEXT: | `-UnresolvedLookupExpr {{.*}} 
+  if (invalid()) {}
+
+  // CHECK:  WhileStmt {{.*}}
+  // CHECK-NEXT: |-RecoveryExpr {{.*}}  '' contains-errors
+  // CHECK-NEXT: | `-UnresolvedLookupExpr {{.*}} 
+  while (invalid()) {}
+
+  // CHECK:  SwitchStmt {{.*}}
+  // CHECK-NEXT: |-RecoveryExpr {{.*}} '' contains-errors
+  // CHECK-NEXT: | `-UnresolvedLookupExpr {{.*}} 
+  switch(invalid()) {
+case 1:
+  break;
+  }
+  // FIXME: figure out why the type of ConditionalOperator is not int.
+  // CHECK:  ConditionalOperator {{.*}} '' contains-errors
+  // CHECK-NEXT: |-RecoveryExpr {{.*}} '' contains-errors
+  // CHECK-NEXT: | `-UnresolvedLookupExpr {{.*}}
+  // CHECK-NEXT: |-IntegerLiteral {{.*}} 'int' 1
+  // CHECK-NEXT: `-IntegerLiteral {{.*}} 'int' 2
+  invalid() ? 1 : 2;
+}
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -18466,9 +18466,12 @@
 Cond = CheckSwitchCondition(Loc, SubExpr);
 break;
   }
-  if (Cond.isInvalid())
-return ConditionError();
-
+  if (Cond.isInvalid()) {
+Cond = CreateRecoveryExpr(SubExpr->getBeginLoc(), SubExpr->getEndLoc(),
+  {SubExpr});
+i

[clang] b2a37cf - [Analyzer] Replace `assert` with `ASSERT_TRUE` in a unit test to silence warnings

2020-06-12 Thread Adam Balogh via cfe-commits

Author: Adam Balogh
Date: 2020-06-12T17:09:34+02:00
New Revision: b2a37cfe2bda0bc8c4d2e981922b5ac59c429bdc

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

LOG: [Analyzer] Replace `assert` with `ASSERT_TRUE` in a unit test to silence 
warnings

Added: 


Modified: 
clang/unittests/StaticAnalyzer/ParamRegionTest.cpp

Removed: 




diff  --git a/clang/unittests/StaticAnalyzer/ParamRegionTest.cpp 
b/clang/unittests/StaticAnalyzer/ParamRegionTest.cpp
index 7ec032a7beae..3dbbc7ba1578 100644
--- a/clang/unittests/StaticAnalyzer/ParamRegionTest.cpp
+++ b/clang/unittests/StaticAnalyzer/ParamRegionTest.cpp
@@ -19,7 +19,7 @@ class ParamRegionTestConsumer : public ExprEngineConsumer {
   void checkForSameParamRegions(MemRegionManager &MRMgr,
 const StackFrameContext *SFC,
 const ParmVarDecl *PVD) {
-assert(llvm::all_of(PVD->redecls(), [&](const clang::VarDecl *D2) {
+ASSERT_TRUE(llvm::all_of(PVD->redecls(), [&](const clang::VarDecl *D2) {
   return MRMgr.getVarRegion(PVD, SFC) ==
  MRMgr.getVarRegion(cast(D2), SFC);
 }));



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


[PATCH] D81090: [AST][RecoveryExpr] Preserve the AST for invalid class constructions.

2020-06-12 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 270402.
hokein added a comment.

rebase to master and adjust the diagnostic tests after "-frecovery-ast" is 
flipped on.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81090

Files:
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/AST/ast-dump-recovery.cpp
  clang/test/SemaCXX/constant-expression-cxx11.cpp
  clang/test/SemaCXX/cxx0x-initializer-constructor.cpp
  clang/test/SemaCXX/cxx1z-copy-omission.cpp


Index: clang/test/SemaCXX/cxx1z-copy-omission.cpp
===
--- clang/test/SemaCXX/cxx1z-copy-omission.cpp
+++ clang/test/SemaCXX/cxx1z-copy-omission.cpp
@@ -106,7 +106,7 @@
   sizeof(Indestructible{}); // expected-error {{deleted}}
   sizeof(make_indestructible()); // expected-error {{deleted}}
   sizeof(make_incomplete()); // expected-error {{incomplete}}
-  typeid(Indestructible{}); // expected-error {{deleted}}
+  typeid(Indestructible{}); // expected-error {{deleted}} expected-error {{you 
need to include }}
   typeid(make_indestructible()); // expected-error {{deleted}} \
  // expected-error {{need to include 
}}
   typeid(make_incomplete()); // expected-error {{incomplete}} \
Index: clang/test/SemaCXX/cxx0x-initializer-constructor.cpp
===
--- clang/test/SemaCXX/cxx0x-initializer-constructor.cpp
+++ clang/test/SemaCXX/cxx0x-initializer-constructor.cpp
@@ -163,7 +163,7 @@
 // (for the second phase, no constructor is viable)
 G g1{1, 2, 3}; // expected-error {{no matching constructor}}
 (void) new G{1, 2, 3}; // expected-error {{no matching constructor}}
-(void) G{1, 2, 3} // expected-error {{no matching constructor}}
+(void) G{1, 2, 3}; // expected-error {{no matching constructor}}
 
 // valid (T deduced to <>).
 G g2({1, 2, 3});
Index: clang/test/SemaCXX/constant-expression-cxx11.cpp
===
--- clang/test/SemaCXX/constant-expression-cxx11.cpp
+++ clang/test/SemaCXX/constant-expression-cxx11.cpp
@@ -2043,14 +2043,11 @@
 X::n; // expected-note {{in evaluation of exception 
specification for 'BadDefaultInit::A::A' needed here}}
   };
 
-  // FIXME: The "constexpr constructor must initialize all members" diagnostic
-  // here is bogus (we discard the k(k) initializer because the parameter 'k'
-  // has been marked invalid).
   struct B {
-constexpr B( // expected-warning {{initialize all members}}
+constexpr B(
 int k = X::n) : // expected-error {{default argument to 
function 'B' that is declared later}} expected-note {{here}}
   k(k) {}
-int k; // expected-note {{not initialized}}
+int k;
   };
 }
 
Index: clang/test/AST/ast-dump-recovery.cpp
===
--- clang/test/AST/ast-dump-recovery.cpp
+++ clang/test/AST/ast-dump-recovery.cpp
@@ -159,11 +159,18 @@
   // CHECK-NEXT: `-RecoveryExpr {{.*}} contains-errors
   // CHECK-NEXT:  `-InitListExpr
   Bar b2 = {1};
-  // FIXME: preserve the invalid initializer.
-  // CHECK: `-VarDecl {{.*}} b3 'Bar'
+  // CHECK: `-VarDecl {{.*}} b3 'Bar'
+  // CHECK-NEXT:  `-CXXConstructExpr {{.*}}  'Bar' 
contains-errors
+  // CHECK-NEXT:`-ImplicitCastExpr {{.*}}  'const Bar' 
contains-errors
+  // CHECK-NEXT:  `-RecoveryExpr {{.*}} 'Bar' contains-errors lvalue
+  // CHECK-NEXT:`-DeclRefExpr {{.*}} 'x' 'int'
   Bar b3 = Bar(x);
-  // FIXME: preserve the invalid initializer.
-  // CHECK: `-VarDecl {{.*}} b4 'Bar'
+  // CHECK: `-VarDecl {{.*}} b4 'Bar'
+  // CHECK-NEXT:  `-CXXConstructExpr {{.*}}  'Bar' 
contains-errors
+  // CHECK-NEXT:`-ImplicitCastExpr {{.*}} 'const Bar' contains-errors
+  // CHECK-NEXT:  `-RecoveryExpr {{.*}} 'Bar' contains-errors
+  // CHECK-NEXT:`-InitListExpr {{.*}} 'void'
+  // CHECK-NEXT:  `-DeclRefExpr {{.*}} 'x' 'int'
   Bar b4 = Bar{x};
   // CHECK: `-VarDecl {{.*}} b5 'Bar'
   // CHECK-NEXT: `-CXXUnresolvedConstructExpr {{.*}} 'Bar' contains-errors 
'Bar'
@@ -176,6 +183,10 @@
   // CHECK-NEXT:   `-RecoveryExpr {{.*}} contains-errors
   // CHECK-NEXT: `-UnresolvedLookupExpr {{.*}} 'invalid'
   Bar b6 = Bar{invalid()};
+
+  // CHECK: `-RecoveryExpr {{.*}} 'Bar' contains-errors
+  // CHECK-NEXT:  `-IntegerLiteral {{.*}} 'int' 1
+  Bar(1);
 }
 void InitializerForAuto() {
   // CHECK: `-VarDecl {{.*}} invalid a 'auto'
Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -1389,6 +1389,9 @@
   if (!Result.isInvalid() && Result.get()->isInstantiationDependent() &&
   !Result.get()->isTypeDependent())
 Result = CorrectDelayedTyposInExpr(Result.get());
+  else if (Result.isInvalid())
+Result = CreateRecovery

[PATCH] D81474: Handle delayed-template-parsing functions imported into a non-dtp TU

2020-06-12 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG05ed3efc2ac7: Handle delayed-template-parsing functions 
imported into a non-dtp TU (authored by sammccall).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81474

Files:
  clang/lib/Parse/Parser.cpp
  clang/test/PCH/delayed-template-parsing.cpp


Index: clang/test/PCH/delayed-template-parsing.cpp
===
--- /dev/null
+++ clang/test/PCH/delayed-template-parsing.cpp
@@ -0,0 +1,14 @@
+// Check any combination of delayed-template-parsing between PCH and TU works.
+// RUN: %clang_cc1 %s -emit-pch -o %t.pch
+// RUN: %clang_cc1 -fdelayed-template-parsing %s -emit-pch -o %t.delayed.pch
+// RUN: %clang_cc1 -DMAIN_FILE -include-pch %t.pch %s
+// RUN: %clang_cc1 -DMAIN_FILE -fdelayed-template-parsing -include-pch %t.pch 
%s
+// RUN: %clang_cc1 -DMAIN_FILE -include-pch %t.delayed.pch %s
+// RUN: %clang_cc1 -DMAIN_FILE -fdelayed-template-parsing -include-pch 
%t.delayed.pch %s
+
+#ifndef MAIN_FILE
+template 
+T successor(T Value) { return Value + 1; }
+#else
+int x = successor(42);
+#endif
Index: clang/lib/Parse/Parser.cpp
===
--- clang/lib/Parse/Parser.cpp
+++ clang/lib/Parse/Parser.cpp
@@ -652,9 +652,7 @@
 }
 
 // Late template parsing can begin.
-if (getLangOpts().DelayedTemplateParsing)
-  Actions.SetLateTemplateParser(LateTemplateParserCallback, nullptr,
-this);
+Actions.SetLateTemplateParser(LateTemplateParserCallback, nullptr, this);
 if (!PP.isIncrementalProcessingEnabled())
   Actions.ActOnEndOfTranslationUnit();
 //else don't tell Sema that we ended parsing: more input might come.


Index: clang/test/PCH/delayed-template-parsing.cpp
===
--- /dev/null
+++ clang/test/PCH/delayed-template-parsing.cpp
@@ -0,0 +1,14 @@
+// Check any combination of delayed-template-parsing between PCH and TU works.
+// RUN: %clang_cc1 %s -emit-pch -o %t.pch
+// RUN: %clang_cc1 -fdelayed-template-parsing %s -emit-pch -o %t.delayed.pch
+// RUN: %clang_cc1 -DMAIN_FILE -include-pch %t.pch %s
+// RUN: %clang_cc1 -DMAIN_FILE -fdelayed-template-parsing -include-pch %t.pch %s
+// RUN: %clang_cc1 -DMAIN_FILE -include-pch %t.delayed.pch %s
+// RUN: %clang_cc1 -DMAIN_FILE -fdelayed-template-parsing -include-pch %t.delayed.pch %s
+
+#ifndef MAIN_FILE
+template 
+T successor(T Value) { return Value + 1; }
+#else
+int x = successor(42);
+#endif
Index: clang/lib/Parse/Parser.cpp
===
--- clang/lib/Parse/Parser.cpp
+++ clang/lib/Parse/Parser.cpp
@@ -652,9 +652,7 @@
 }
 
 // Late template parsing can begin.
-if (getLangOpts().DelayedTemplateParsing)
-  Actions.SetLateTemplateParser(LateTemplateParserCallback, nullptr,
-this);
+Actions.SetLateTemplateParser(LateTemplateParserCallback, nullptr, this);
 if (!PP.isIncrementalProcessingEnabled())
   Actions.ActOnEndOfTranslationUnit();
 //else don't tell Sema that we ended parsing: more input might come.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D81315: [analyzer] Warning for default constructed unique pointer dereferences

2020-06-12 Thread Nithin VR via Phabricator via cfe-commits
vrnithinkumar marked 38 inline comments as done.
vrnithinkumar added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp:31
 namespace {
-class SmartPtrModeling : public Checker {
+struct RegionState {
+private:

vsavchenko wrote:
> xazax.hun wrote:
> > I think `RegionState` is not very descriptive. I'd call it something like 
> > `RegionNullness`.
> linter: LLVM coding standards require to use `class` keyword in situations 
> like this 
> (https://llvm.org/docs/CodingStandards.html#use-of-class-and-struct-keywords).
>   I would even say that `struct` is good for POD types.
With the new changes, the struct is removed.



Comment at: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp:31
 namespace {
-class SmartPtrModeling : public Checker {
+struct RegionState {
+private:

vrnithinkumar wrote:
> vsavchenko wrote:
> > xazax.hun wrote:
> > > I think `RegionState` is not very descriptive. I'd call it something like 
> > > `RegionNullness`.
> > linter: LLVM coding standards require to use `class` keyword in situations 
> > like this 
> > (https://llvm.org/docs/CodingStandards.html#use-of-class-and-struct-keywords).
> >   I would even say that `struct` is good for POD types.
> With the new changes, the struct is removed.
With the new changes, the struct is removed.



Comment at: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp:33
+private:
+  enum Kind { Null, NonNull, Unknown } K;
+  RegionState(Kind InK) : K(InK) {}

vsavchenko wrote:
> I think that it would be better to put declarations for `enum` and for a 
> field separately.
> Additionally, I don't think that `K` is a very good name for a data member.  
> It should be evident from the name of the member what is it.  Shot names like 
> that can be fine only for iterators or for certain `clang`-specific 
> structures because of existing traditions (like `SM` for `SourceManager` and 
> `LO` for `LanguageOptions`).
With the new changes, the `enum`  is removed.



Comment at: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp:46
+};
+} // end of anonymous namespace
+

Szelethus wrote:
> xazax.hun wrote:
> > You can merge the two anonymous namespaces, this and the one below.
> [[https://llvm.org/docs/CodingStandards.html#anonymous-namespaces | I prefer 
> them like this. ]]
with new change only one anonymous namespace is there



Comment at: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp:60
+private:
+  mutable std::unique_ptr BT;
+  void reportBug(CheckerContext &C, const CallEvent &Call) const;

xazax.hun wrote:
> This is how we used to do it, but we did not update all the checks yet. 
> Nowadays we can just initialize bugtypes immediately, see 
> https://github.com/llvm/llvm-project/blob/master/clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp#L169
updated to initialize bugtype immediately



Comment at: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp:65
+
+  // STL smart pointers which we are trying to model
+  const llvm::StringSet<> StdSmartPtrs = {

xazax.hun wrote:
> In LLVM we aim for full sentences as comments with a period at the end.
Updated the comments as LLVM style



Comment at: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp:72-76
+  // STL smart pointer methods which resets to null
+  const llvm::StringSet<> ResetMethods = {"reset", "release", "swap"};
+
+  // STL smart pointer methods which resets to null via null argument
+  const llvm::StringSet<> NullResetMethods = {"reset", "swap"};

NoQ wrote:
> Please consider `CallDescription` and `CallDescriptionMap`!
Made changes to use `CallDescription` and `CallDescriptionMap`



Comment at: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp:81
+// to track the mem region and curresponding states
+REGISTER_MAP_WITH_PROGRAMSTATE(TrackedRegionMap, const MemRegion *, 
RegionState)
+// to track the Symbols which will get inner raw pointer via unique_ptr.get()

NoQ wrote:
> I ultimately believe this map should go away. The only thing we really need 
> is the map from smart pointer region to the symbol for its current raw 
> pointer. As long as we have such data we can discover the nullness of that 
> symbol (which *is* the nullness of the smart pointer as well) from Range 
> Constraints.
Removed this map.
Now maping region to SVal



Comment at: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp:119
+  ProgramStateRef State = C.getState();
+  const auto OC = dyn_cast(&Call);
+  if (!OC)

vsavchenko wrote:
> xazax.hun wrote:
> > Here the const applies for the pointer, not the pointee. We usually do 
> > `const auto *OC` instead.
> As I said above, I think we should be really careful about abbreviated and 
> extremely short variable na

cfe-commits@lists.llvm.org

2020-06-12 Thread Ties Stuij via Phabricator via cfe-commits
stuij accepted this revision.
stuij added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks!


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

https://reviews.llvm.org/D80716



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


cfe-commits@lists.llvm.org

2020-06-12 Thread Luke Geeson via Phabricator via cfe-commits
LukeGeeson created this revision.
LukeGeeson added reviewers: stuij, t.p.northover, SjoerdMeijer, sdesmalen, 
fpetrogalli.
Herald added subscribers: llvm-commits, cfe-commits, hiraditya, kristof.beyls.
Herald added projects: clang, LLVM.
LukeGeeson added a parent revision: D81486: [ARM][BFloat] Implement lowering of 
bf16 load/store intrinsics.

This patch upstreams support for BFloat Matrix Multiplication Intrinsics
and Code Generation from __bf16 to AArch32. This includes IR intrinsics. 
Unittests are
provided as needed.

This patch is part of a series implementing the Bfloat16 extension of
the
Armv8.6-a architecture, as detailed here:

https://community.arm.com/developer/ip-products/processors/b/processors-ip-blog/posts/arm-architecture-developments-armv8-6-a

The bfloat type, and its properties are specified in the Arm
Architecture
Reference Manual:

https://developer.arm.com/docs/ddi0487/latest/arm-architecture-reference-manual-armv8-for-armv8-a-architecture-profile

The following people contributed to this patch:

- Luke Geeson
- Momchil Velikov
- Mikhail Maltsev
- Luke Cheeseman


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81740

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/arm-bf16-dotprod-intrinsics.c
  llvm/include/llvm/IR/IntrinsicsARM.td
  llvm/lib/Target/ARM/ARMInstrNEON.td
  llvm/test/CodeGen/ARM/arm-bf16-dotprod-intrinsics.ll

Index: llvm/test/CodeGen/ARM/arm-bf16-dotprod-intrinsics.ll
===
--- /dev/null
+++ llvm/test/CodeGen/ARM/arm-bf16-dotprod-intrinsics.ll
@@ -0,0 +1,164 @@
+; RUN: llc -mtriple armv8.6a-arm-none-eabi  -mattr=+bf16 -float-abi=hard %s -o - | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-BF16
+; RUN: llc -mtriple armv8.6a-arm-none-eabi  -mattr=+bf16 -float-abi=hard %s -o - | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-NO-BF16
+
+; CHECK-LABEL: test_vbfdot_f32
+; CHECK-BF16: vdot.bf16   d{{[0-9]+}}, d{{[0-9]+}}, d{{[0-9]+}}
+; CHECK-NO-BF16: vdot.bf16   d{{[0-9]+}}, d{{[0-9]+}}, d{{[0-9]+}}
+define arm_aapcs_vfpcc <2 x float> @test_vbfdot_f32(<2 x float> %r, <4 x bfloat> %a, <4 x bfloat> %b) local_unnamed_addr #0 {
+entry:
+  %0 = bitcast <4 x bfloat> %a to <8 x i8>
+  %1 = bitcast <4 x bfloat> %b to <8 x i8>
+  %vbfdot1.i = tail call <2 x float> @llvm.arm.neon.bfdot.v2f32.v8i8(<2 x float> %r, <8 x i8> %0, <8 x i8> %1) #3
+  ret <2 x float> %vbfdot1.i
+}
+
+; CHECK-LABEL: test_vbfdotq_f32
+; CHECK-BF16: vdot.bf16   q{{[0-9]+}}, q{{[0-9]+}}, q{{[0-9]+}}
+; CHECK-NO-BF16: vdot.bf16   q{{[0-9]+}}, q{{[0-9]+}}, q{{[0-9]+}}
+define <4 x float> @test_vbfdotq_f32(<4 x float> %r, <8 x bfloat> %a, <8 x bfloat> %b) local_unnamed_addr #1 {
+entry:
+  %0 = bitcast <8 x bfloat> %a to <16 x i8>
+  %1 = bitcast <8 x bfloat> %b to <16 x i8>
+  %vbfdot1.i = tail call <4 x float> @llvm.arm.neon.bfdot.v4f32.v16i8(<4 x float> %r, <16 x i8> %0, <16 x i8> %1) #3
+  ret <4 x float> %vbfdot1.i
+}
+
+; CHECK-LABEL: test_vbfdot_lane_f32
+; CHECK-BF16: vdot.bf16   d{{[0-9]+}}, d{{[0-9]+}}, d{{[0-9]+}}[0]
+; CHECK-NO-BF16: vdot.bf16   d{{[0-9]+}}, d{{[0-9]+}}, d{{[0-9]+}}[0]
+define <2 x float> @test_vbfdot_lane_f32(<2 x float> %r, <4 x bfloat> %a, <4 x bfloat> %b) local_unnamed_addr #0 {
+entry:
+  %0 = bitcast <4 x bfloat> %b to <2 x float>
+  %shuffle = shufflevector <2 x float> %0, <2 x float> undef, <2 x i32> zeroinitializer
+  %1 = bitcast <4 x bfloat> %a to <8 x i8>
+  %2 = bitcast <2 x float> %shuffle to <8 x i8>
+  %vbfdot1.i = tail call <2 x float> @llvm.arm.neon.bfdot.v2f32.v8i8(<2 x float> %r, <8 x i8> %1, <8 x i8> %2) #3
+  ret <2 x float> %vbfdot1.i
+}
+
+; CHECK-LABEL: test_vbfdotq_laneq_f32
+; CHECK-BF16: vdup.32 q{{[0-9]+}}, d{{[0-9]+}}[1]
+; CHECK-BF16: vdot.bf16   q{{[0-9]+}}, q{{[0-9]+}}, q{{[0-9]+}}
+; CHECK-NO-BF16: vdot.bf16   q{{[0-9]+}}, q{{[0-9]+}}, q{{[0-9]+}}
+define <4 x float> @test_vbfdotq_laneq_f32(<4 x float> %r, <8 x bfloat> %a, <8 x bfloat> %b) local_unnamed_addr #1 {
+entry:
+  %0 = bitcast <8 x bfloat> %b to <4 x float>
+  %shuffle = shufflevector <4 x float> %0, <4 x float> undef, <4 x i32> 
+  %1 = bitcast <8 x bfloat> %a to <16 x i8>
+  %2 = bitcast <4 x float> %shuffle to <16 x i8>
+  %vbfdot1.i = tail call <4 x float> @llvm.arm.neon.bfdot.v4f32.v16i8(<4 x float> %r, <16 x i8> %1, <16 x i8> %2) #3
+  ret <4 x float> %vbfdot1.i
+}
+
+; CHECK-LABEL: test_vbfdot_laneq_f32
+; CHECK-BF16: vdot.bf16   d{{[0-9]+}}, d{{[0-9]+}}, d{{[0-9]+}}[1]
+; CHECK-NO-BF16: vdot.bf16   d{{[0-9]+}}, d{{[0-9]+}}, d{{[0-9]+}}[1]
+define <2 x float> @test_vbfdot_laneq_f32(<2 x float> %r, <4 x bfloat> %a, <8 x bfloat> %b) local_unnamed_addr #1 {
+entry:
+  %0 = bitcast <8 x bfloat> %b to <4 x float>
+  %shuffle = shufflevector <4 x float> %0, <4 x float> undef, <2 x i32> 
+  %1 = bitcast <4 x bfloat> %a to <8 x i8>
+  %2 = bitcast <2 x float> %shuffle to <8 x i8>
+  %vbfdot1.i = tail call <2 x float> @llvm.arm.neon.bfdot.v2f32.v

[PATCH] D81315: [analyzer] Warning for default constructed unique pointer dereferences

2020-06-12 Thread Nithin VR via Phabricator via cfe-commits
vrnithinkumar updated this revision to Diff 270391.
vrnithinkumar retitled this revision from "[analyzer][Draft] [Prototype] 
warning for default constructed unique pointer dereferences" to "[analyzer] 
Warning for default constructed unique pointer dereferences".
vrnithinkumar added a comment.

Addressing the review comments


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

https://reviews.llvm.org/D81315

Files:
  clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
  clang/test/Analysis/Inputs/system-header-simulator-cxx.h
  clang/test/Analysis/smart-ptr.cpp

Index: clang/test/Analysis/smart-ptr.cpp
===
--- clang/test/Analysis/smart-ptr.cpp
+++ clang/test/Analysis/smart-ptr.cpp
@@ -10,7 +10,7 @@
   std::unique_ptr Q = std::move(P);
   if (Q)
 clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
-  *Q.get() = 1; // no-warning
+  *Q.get() = 1; // no-warning
   if (P)
 clang_analyzer_warnIfReached(); // no-warning
   // TODO: Report a null dereference (instead).
@@ -26,3 +26,64 @@
   (s->*func)(); // no-crash
 }
 } // namespace testUnknownCallee
+
+class A {
+public:
+  A(){};
+  void foo();
+};
+
+A *return_null() {
+  return nullptr;
+}
+
+void derefAfterValidCtr() {
+  std::unique_ptr P(new A());
+  P->foo(); // No warning.
+}
+
+void derefAfterDefaultCtr() {
+  std::unique_ptr P;
+  P->foo(); // expected-warning {{Dereference of null smart pointer [cplusplus.SmartPtr]}}
+}
+
+void derefAfterCtrWithNull() {
+  std::unique_ptr P(nullptr);
+  *P; // expected-warning {{Dereference of null smart pointer [cplusplus.SmartPtr]}}
+}
+
+void derefAfterCtrWithNullReturnMethod() {
+  std::unique_ptr P(return_null());
+  P->foo(); // expected-warning {{Dereference of null smart pointer [cplusplus.SmartPtr]}}
+}
+
+void derefAfterRelease() {
+  std::unique_ptr P(new A());
+  P.release();
+  P->foo(); // expected-warning {{Dereference of null smart pointer [cplusplus.SmartPtr]}}
+}
+
+void derefAfterReset() {
+  std::unique_ptr P(new A());
+  P.reset();
+  P->foo(); // expected-warning {{Dereference of null smart pointer [cplusplus.SmartPtr]}}
+}
+
+void derefAfterResetWithNull() {
+  std::unique_ptr P(new A());
+  P.reset(nullptr);
+  P->foo(); // expected-warning {{Dereference of null smart pointer [cplusplus.SmartPtr]}}
+}
+
+void derefAfterResetWithNonNull() {
+  std::unique_ptr P;
+  P.reset(new A());
+  P->foo(); // No warning.
+}
+
+void derefAfterReleaseAndResetWithNonNull() {
+  std::unique_ptr P(new A());
+  P.release();
+  P.reset(new A());
+  P->foo(); // No warning.
+}
\ No newline at end of file
Index: clang/test/Analysis/Inputs/system-header-simulator-cxx.h
===
--- clang/test/Analysis/Inputs/system-header-simulator-cxx.h
+++ clang/test/Analysis/Inputs/system-header-simulator-cxx.h
@@ -946,10 +946,15 @@
   template  // TODO: Implement the stub for deleter.
   class unique_ptr {
   public:
+unique_ptr() {}
+unique_ptr(T *) {}
 unique_ptr(const unique_ptr &) = delete;
 unique_ptr(unique_ptr &&);
 
 T *get() const;
+T *release() const;
+void reset(T *p = nullptr) const;
+void swap(unique_ptr &p) const;
 
 typename std::add_lvalue_reference::type operator*() const;
 T *operator->() const;
Index: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
+++ clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
@@ -13,26 +13,60 @@
 
 #include "Move.h"
 
+#include "clang/AST/DeclCXX.h"
 #include "clang/AST/ExprCXX.h"
+#include "clang/AST/Type.h"
 #include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h"
 #include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
 #include "clang/StaticAnalyzer/Core/Checker.h"
 #include "clang/StaticAnalyzer/Core/CheckerManager.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/SVals.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/SymExpr.h"
 
 using namespace clang;
 using namespace ento;
 
 namespace {
-class SmartPtrModeling : public Checker {
+class SmartPtrModeling
+: public Checker {
   bool isNullAfterMoveMethod(const CallEvent &Call) const;
+  BugType NullDereferenceBugType{this, "Null-smartPtr-deref",
+ "C++ smart pointer"};
 
 public:
   bool evalCall(const CallEvent &Call, CheckerContext &C) const;
+  void checkPostCall(const CallEvent &MC, CheckerContext &C) const;
+  void checkDeadSymbols(SymbolReaper &SymReaper, CheckerContext &C) const;
+
+private:
+  void reportBug(CheckerContext &C, const CallEvent &Call) const;
+  bool isStdSmartPointerClass(const CXXRecordDecl *RD) const;
+  void updateTrackedRegion(const CallEvent &Call, Chec

[PATCH] D81739: [clangd] Turn on RecoveryAST for clangd by default.

2020-06-12 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: sammccall.
Herald added subscribers: usaxena95, kadircet, arphaman, jkorous, MaskRay, 
ilya-biryukov.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81739

Files:
  clang-tools-extra/clangd/tool/ClangdMain.cpp


Index: clang-tools-extra/clangd/tool/ClangdMain.cpp
===
--- clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -281,11 +281,10 @@
 opt RecoveryAST{
 "recovery-ast",
 cat(Features),
-desc("Preserve expressions in AST for broken code (C++ only). Note that "
- "this feature is experimental and may lead to crashes"),
-init(false),
-Hidden,
+desc("Preserve expressions in AST for broken code (C++ only)."),
+init(true),
 };
+
 opt RecoveryASTType{
 "recovery-ast-type",
 cat(Features),


Index: clang-tools-extra/clangd/tool/ClangdMain.cpp
===
--- clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -281,11 +281,10 @@
 opt RecoveryAST{
 "recovery-ast",
 cat(Features),
-desc("Preserve expressions in AST for broken code (C++ only). Note that "
- "this feature is experimental and may lead to crashes"),
-init(false),
-Hidden,
+desc("Preserve expressions in AST for broken code (C++ only)."),
+init(true),
 };
+
 opt RecoveryASTType{
 "recovery-ast-type",
 cat(Features),
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


cfe-commits@lists.llvm.org

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

- removed unnecessary contents of test


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

https://reviews.llvm.org/D80716

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

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

[PATCH] D81713: [HIP] Fix rocm not found on rocm3.5

2020-06-12 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.

In D81713#2089680 , @yaxunl wrote:

> In D81713#2089672 , @arsenm wrote:
>
> > Can you add tests for this? Is this also sufficient with the directory 
> > layout change?
>
>
> You mean does this work after we move device lib from /opt/rocm/lib to 
> /opt/rocm/amdgcn/bitcode ?


Yes


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

https://reviews.llvm.org/D81713



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


[clang-tools-extra] 4160f4c - Reland [clangd] Parse std::make_unique, and emit template diagnostics at expansion.

2020-06-12 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2020-06-12T16:18:26+02:00
New Revision: 4160f4c37615f6d5b7615666eb202d9cbb58f4bb

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

LOG: Reland [clangd] Parse std::make_unique, and emit template diagnostics at 
expansion.

This was originally 658af9435071 and reverted in 665dbe91f2ed.
The clang bug this triggered was fixed in 05ed3efc2ac.

Added: 


Modified: 
clang-tools-extra/clangd/Diagnostics.cpp
clang-tools-extra/clangd/Diagnostics.h
clang-tools-extra/clangd/Preamble.cpp
clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
clang/include/clang/Frontend/PrecompiledPreamble.h
clang/lib/Frontend/PrecompiledPreamble.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/Diagnostics.cpp 
b/clang-tools-extra/clangd/Diagnostics.cpp
index f1fbaf4646ba..da554ff8c331 100644
--- a/clang-tools-extra/clangd/Diagnostics.cpp
+++ b/clang-tools-extra/clangd/Diagnostics.cpp
@@ -24,6 +24,7 @@
 #include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/ScopeExit.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/Twine.h"
@@ -120,49 +121,96 @@ Range diagnosticRange(const clang::Diagnostic &D, const 
LangOptions &L) {
   return halfOpenToRange(M, R);
 }
 
-// Returns whether the \p D is modified.
-bool adjustDiagFromHeader(Diag &D, const clang::Diagnostic &Info,
-  const LangOptions &LangOpts) {
-  // We only report diagnostics with at least error severity from headers.
-  // Use default severity to avoid noise with -Werror.
-  if (!Info.getDiags()->getDiagnosticIDs()->isDefaultMappingAsError(
-  Info.getID()))
-return false;
-
-  const SourceManager &SM = Info.getSourceManager();
-  const SourceLocation &DiagLoc = SM.getExpansionLoc(Info.getLocation());
-  SourceLocation IncludeInMainFile;
+// Try to find a location in the main-file to report the diagnostic D.
+// Returns a description like "in included file", or nullptr on failure.
+const char *getMainFileRange(const Diag &D, const SourceManager &SM,
+ SourceLocation DiagLoc, Range &R) {
+  // Look for a note in the main file indicating template instantiation.
+  for (const auto &N : D.Notes) {
+if (N.InsideMainFile) {
+  switch (N.ID) {
+  case diag::note_template_class_instantiation_was_here:
+  case diag::note_template_class_explicit_specialization_was_here:
+  case diag::note_template_class_instantiation_here:
+  case diag::note_template_member_class_here:
+  case diag::note_template_member_function_here:
+  case diag::note_function_template_spec_here:
+  case diag::note_template_static_data_member_def_here:
+  case diag::note_template_variable_def_here:
+  case diag::note_template_enum_def_here:
+  case diag::note_template_nsdmi_here:
+  case diag::note_template_type_alias_instantiation_here:
+  case diag::note_template_exception_spec_instantiation_here:
+  case diag::note_template_requirement_instantiation_here:
+  case diag::note_evaluating_exception_spec_here:
+  case diag::note_default_arg_instantiation_here:
+  case diag::note_default_function_arg_instantiation_here:
+  case diag::note_explicit_template_arg_substitution_here:
+  case diag::note_function_template_deduction_instantiation_here:
+  case diag::note_deduced_template_arg_substitution_here:
+  case diag::note_prior_template_arg_substitution:
+  case diag::note_template_default_arg_checking:
+  case diag::note_concept_specialization_here:
+  case diag::note_nested_requirement_here:
+  case diag::note_checking_constraints_for_template_id_here:
+  case diag::note_checking_constraints_for_var_spec_id_here:
+  case diag::note_checking_constraints_for_class_spec_id_here:
+  case diag::note_checking_constraints_for_function_here:
+  case diag::note_constraint_substitution_here:
+  case diag::note_constraint_normalization_here:
+  case diag::note_parameter_mapping_substitution_here:
+R = N.Range;
+return "in template";
+  default:
+break;
+  }
+}
+  }
+  // Look for where the file with the error was #included.
   auto GetIncludeLoc = [&SM](SourceLocation SLoc) {
 return SM.getIncludeLoc(SM.getFileID(SLoc));
   };
-  for (auto IncludeLocation = GetIncludeLoc(DiagLoc); 
IncludeLocation.isValid();
+  for (auto IncludeLocation = GetIncludeLoc(SM.getExpansionLoc(DiagLoc));
+   IncludeLocation.isValid();
IncludeLocation = GetIncludeLoc(IncludeLocation)) {
 if (clangd::isInsideMainFile(IncludeLocation, SM)) {
-  IncludeInMainFile = IncludeLocation;
-  break;
+  R.start = sourceLocToPosition

[clang] 05ed3ef - Handle delayed-template-parsing functions imported into a non-dtp TU

2020-06-12 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2020-06-12T16:09:38+02:00
New Revision: 05ed3efc2ac7b34bd62b1cbac88ff9a47b649cc5

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

LOG: Handle delayed-template-parsing functions imported into a non-dtp TU

Summary:
DelayedTemplateParsing is marked as BENIGN_LANGOPT, so we are allowed to
use a delayed template in a non-delayed TU.
(This is clangd's default configuration on windows: delayed-template-parsing
is on for the preamble and forced off for the current file)

However today clang fails to parse implicit instantiations in a non-dtp
TU of templates defined in a dtp PCH file (and presumably module?).
In this case the delayed parser is not registered, so the function is
simply marked "delayed" again. We then hit an assert:
end of TU template instantiation should not create more late-parsed templates

Reviewers: rsmith

Subscribers: ilya-biryukov, usaxena95, cfe-commits, kadircet

Tags: #clang

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

Added: 
clang/test/PCH/delayed-template-parsing.cpp

Modified: 
clang/lib/Parse/Parser.cpp

Removed: 




diff  --git a/clang/lib/Parse/Parser.cpp b/clang/lib/Parse/Parser.cpp
index 2cea7307b3ac..764d4e8e9d52 100644
--- a/clang/lib/Parse/Parser.cpp
+++ b/clang/lib/Parse/Parser.cpp
@@ -652,9 +652,7 @@ bool Parser::ParseTopLevelDecl(DeclGroupPtrTy &Result, bool 
IsFirstDecl) {
 }
 
 // Late template parsing can begin.
-if (getLangOpts().DelayedTemplateParsing)
-  Actions.SetLateTemplateParser(LateTemplateParserCallback, nullptr,
-this);
+Actions.SetLateTemplateParser(LateTemplateParserCallback, nullptr, this);
 if (!PP.isIncrementalProcessingEnabled())
   Actions.ActOnEndOfTranslationUnit();
 //else don't tell Sema that we ended parsing: more input might come.

diff  --git a/clang/test/PCH/delayed-template-parsing.cpp 
b/clang/test/PCH/delayed-template-parsing.cpp
new file mode 100644
index ..b4404c757634
--- /dev/null
+++ b/clang/test/PCH/delayed-template-parsing.cpp
@@ -0,0 +1,14 @@
+// Check any combination of delayed-template-parsing between PCH and TU works.
+// RUN: %clang_cc1 %s -emit-pch -o %t.pch
+// RUN: %clang_cc1 -fdelayed-template-parsing %s -emit-pch -o %t.delayed.pch
+// RUN: %clang_cc1 -DMAIN_FILE -include-pch %t.pch %s
+// RUN: %clang_cc1 -DMAIN_FILE -fdelayed-template-parsing -include-pch %t.pch 
%s
+// RUN: %clang_cc1 -DMAIN_FILE -include-pch %t.delayed.pch %s
+// RUN: %clang_cc1 -DMAIN_FILE -fdelayed-template-parsing -include-pch 
%t.delayed.pch %s
+
+#ifndef MAIN_FILE
+template 
+T successor(T Value) { return Value + 1; }
+#else
+int x = successor(42);
+#endif



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


[PATCH] D75169: [ARM] Supporting lowering of half-precision FP arguments and returns in AArch32's backend

2020-06-12 Thread Lucas Prates via Phabricator via cfe-commits
pratlucas added a comment.

Hi @efriedma,

From @SjoerdMeijer's comment and the links he pointed to, it seems to me that 
making `f16` types legal for all ARM subtargets would be a major undertaking 
and far from trivial to implement. It's also not clear to me how significant 
would be the returns of this effort.
My feeling is that we could proceed with the current approach and discuss the 
possbility of making `f16` legal in a separate follow up effort, as mentioned 
by @dnsampaio.

What's your view on this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75169



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


[PATCH] D60620: [HIP] Support target id by --offload-arch

2020-06-12 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In D60620#2067134 , @tra wrote:

> Do you expect users to specify these IDs? How do you see it being used in 
> practice? I think you do need to implement a user-friendly shortcut and 
> expand it to the detailed offload-id internally. I'm fine with allowing 
> explicit offload id as a hidden argument, but I don't think it's suitable for 
> something that will be used by everyone who can't be expected to be aware of 
> all the gory details of particular GPU features.


The good thing about this target id is that it is backward compatible with GPU 
arch. For common users who are not concerned with specific GPU configurations, 
they can just use the old GPU arch and nothing changes. This is because GPU 
arch without features implies default value for these features, which work on 
all configurations. For advanced users who do need to build for specific GPU 
configurations, they should already have the knowledge about the name and 
meaning of these configurations by reading the AMDGPU user guide 
(http://llvm.org/docs/AMDGPUUsage.html). Therefore a target id in the form of 
gfx908:xnack+ is not something cryptic to them. On the other hand, an encoded 
GPU arch like gfx908a is cryptic since it has no meaning at all.


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

https://reviews.llvm.org/D60620



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


[PATCH] D81734: Initial smart pointer check

2020-06-12 Thread Nithin VR via Phabricator via cfe-commits
vrnithinkumar created this revision.
Herald added subscribers: cfe-commits, martong.
Herald added a project: clang.
vrnithinkumar abandoned this revision.
vrnithinkumar added a comment.

It was a mistake 
I was supposed to update an existing review.
first time use of arc


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81734

Files:
  clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
  clang/test/Analysis/Inputs/system-header-simulator-cxx.h
  clang/test/Analysis/smart-ptr.cpp

Index: clang/test/Analysis/smart-ptr.cpp
===
--- clang/test/Analysis/smart-ptr.cpp
+++ clang/test/Analysis/smart-ptr.cpp
@@ -10,7 +10,7 @@
   std::unique_ptr Q = std::move(P);
   if (Q)
 clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
-  *Q.get() = 1; // no-warning
+  *Q.get() = 1; // no-warning
   if (P)
 clang_analyzer_warnIfReached(); // no-warning
   // TODO: Report a null dereference (instead).
@@ -26,3 +26,64 @@
   (s->*func)(); // no-crash
 }
 } // namespace testUnknownCallee
+
+class A {
+public:
+  A(){};
+  void foo();
+};
+
+A *return_null() {
+  return nullptr;
+}
+
+void derefAfterValidCtr() {
+  std::unique_ptr P(new A());
+  P->foo(); // No warning.
+}
+
+void derefAfterDefaultCtr() {
+  std::unique_ptr P;
+  P->foo(); // expected-warning {{Dereference of null smart pointer [cplusplus.SmartPtr]}}
+}
+
+void derefAfterCtrWithNull() {
+  std::unique_ptr P(nullptr);
+  *P; // expected-warning {{Dereference of null smart pointer [cplusplus.SmartPtr]}}
+}
+
+void derefAfterCtrWithNullReturnMethod() {
+  std::unique_ptr P(return_null());
+  P->foo(); // expected-warning {{Dereference of null smart pointer [cplusplus.SmartPtr]}}
+}
+
+void derefAfterRelease() {
+  std::unique_ptr P(new A());
+  P.release();
+  P->foo(); // expected-warning {{Dereference of null smart pointer [cplusplus.SmartPtr]}}
+}
+
+void derefAfterReset() {
+  std::unique_ptr P(new A());
+  P.reset();
+  P->foo(); // expected-warning {{Dereference of null smart pointer [cplusplus.SmartPtr]}}
+}
+
+void derefAfterResetWithNull() {
+  std::unique_ptr P(new A());
+  P.reset(nullptr);
+  P->foo(); // expected-warning {{Dereference of null smart pointer [cplusplus.SmartPtr]}}
+}
+
+void derefAfterResetWithNonNull() {
+  std::unique_ptr P;
+  P.reset(new A());
+  P->foo(); // No warning.
+}
+
+void derefAfterReleaseAndResetWithNonNull() {
+  std::unique_ptr P(new A());
+  P.release();
+  P.reset(new A());
+  P->foo(); // No warning.
+}
\ No newline at end of file
Index: clang/test/Analysis/Inputs/system-header-simulator-cxx.h
===
--- clang/test/Analysis/Inputs/system-header-simulator-cxx.h
+++ clang/test/Analysis/Inputs/system-header-simulator-cxx.h
@@ -946,10 +946,15 @@
   template  // TODO: Implement the stub for deleter.
   class unique_ptr {
   public:
+unique_ptr() {}
+unique_ptr(T *) {}
 unique_ptr(const unique_ptr &) = delete;
 unique_ptr(unique_ptr &&);
 
 T *get() const;
+T *release() const;
+void reset(T *p = nullptr) const;
+void swap(unique_ptr &p) const;
 
 typename std::add_lvalue_reference::type operator*() const;
 T *operator->() const;
Index: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
+++ clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
@@ -13,26 +13,60 @@
 
 #include "Move.h"
 
+#include "clang/AST/DeclCXX.h"
 #include "clang/AST/ExprCXX.h"
+#include "clang/AST/Type.h"
 #include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h"
 #include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
 #include "clang/StaticAnalyzer/Core/Checker.h"
 #include "clang/StaticAnalyzer/Core/CheckerManager.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/SVals.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/SymExpr.h"
 
 using namespace clang;
 using namespace ento;
 
 namespace {
-class SmartPtrModeling : public Checker {
+class SmartPtrModeling
+: public Checker {
   bool isNullAfterMoveMethod(const CallEvent &Call) const;
+  BugType NullDereferenceBugType{this, "Null-smartPtr-deref",
+ "C++ smart pointer"};
 
 public:
   bool evalCall(const CallEvent &Call, CheckerContext &C) const;
+  void checkPostCall(const CallEvent &MC, CheckerContext &C) const;
+  void checkDeadSymbols(SymbolReaper &SymReaper, CheckerContext &C) const;
+
+private:
+  void reportBug(CheckerContext &C, const CallEvent &Call) const;
+  bool isStdSmartPointerClass(const CXXRecordDecl *RD) const;
+  void updateTrackedRegion(const CallEvent &Call, CheckerContext &C,
+   const MemRegion *Region) const;
+  void 

[PATCH] D74166: [AIX][Frontend] Static init implementation for AIX considering no priority

2020-06-12 Thread Jason Liu via Phabricator via cfe-commits
jasonliu added inline comments.



Comment at: clang/test/CodeGen/static-init.cpp:8
+// RUN:   FileCheck %s
 
 struct test {

Looks like the non-inline comments are easier to get ignored and missed, so I 
will copy paste the non-inlined comment I previously had:
```
-fregister_global_dtors_with_atexit does not seem to work properly in current 
implementation.
We should consider somehow disabling/report_fatal_error it instead of letting 
it generate invalid code on AIX.
```


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

https://reviews.llvm.org/D74166



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


[PATCH] D81734: Initial smart pointer check

2020-06-12 Thread Nithin VR via Phabricator via cfe-commits
vrnithinkumar abandoned this revision.
vrnithinkumar added a comment.

It was a mistake 
I was supposed to update an existing review.
first time use of arc


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81734



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


[PATCH] D81713: [HIP] Fix rocm not found on rocm3.5

2020-06-12 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In D81713#2089672 , @arsenm wrote:

> Can you add tests for this? Is this also sufficient with the directory layout 
> change?


You mean does this work after we move device lib from /opt/rocm/lib to 
/opt/rocm/amdgcn/bitcode ?


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

https://reviews.llvm.org/D81713



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


[clang] e4b3fc1 - Get rid of -Wunused warnings in release build, NFC.

2020-06-12 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2020-06-12T15:42:29+02:00
New Revision: e4b3fc18d33199e2081d300f14687d81be48b6a0

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

LOG: Get rid of -Wunused warnings in release build, NFC.

Added: 


Modified: 
clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp 
b/clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
index c2ca9c12b025..4a7e0d91ea23 100644
--- a/clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
+++ b/clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
@@ -285,6 +285,7 @@ CheckerRegistry::CheckerRegistry(
   resolveDependencies();
   resolveDependencies();
 
+#ifndef NDEBUG // avoid -Wunused warnings in release build.
   for (auto &DepPair : Dependencies) {
 for (auto &WeakDepPair : WeakDependencies) {
   // Some assertions to enforce that strong dependencies are relations in
@@ -298,6 +299,7 @@ CheckerRegistry::CheckerRegistry(
  "A strong dependency mustn't be a weak dependency as well!");
 }
   }
+#endif
 
   resolveCheckerAndPackageOptions();
 



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


[PATCH] D78126: [analyzer][NFC] Don't allow dependency checkers to emit diagnostics

2020-06-12 Thread Kristóf Umann via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG33fb9cbe211d: [analyzer][NFC] Don't allow dependency 
checkers to emit diagnostics (authored by Szelethus).

Changed prior to commit:
  https://reviews.llvm.org/D78126?vs=262387&id=270372#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78126

Files:
  clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
  clang/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h
  clang/lib/StaticAnalyzer/Core/BugReporter.cpp
  clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp

Index: clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
===
--- clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
+++ clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
@@ -94,6 +94,10 @@
 // Methods of CmdLineOption, PackageInfo and CheckerInfo.
 //===--===//
 
+LLVM_DUMP_METHOD void CheckerRegistry::CmdLineOption::dump() const {
+  dumpToStream(llvm::errs());
+}
+
 LLVM_DUMP_METHOD void
 CheckerRegistry::CmdLineOption::dumpToStream(llvm::raw_ostream &Out) const {
   // The description can be just checked in Checkers.inc, the point here is to
@@ -115,6 +119,10 @@
   llvm_unreachable("Unhandled CheckerRegistry::StateFromCmdLine enum");
 }
 
+LLVM_DUMP_METHOD void CheckerRegistry::CheckerInfo::dump() const {
+  dumpToStream(llvm::errs());
+}
+
 LLVM_DUMP_METHOD void
 CheckerRegistry::CheckerInfo::dumpToStream(llvm::raw_ostream &Out) const {
   // The description can be just checked in Checkers.inc, the point here is to
@@ -137,6 +145,10 @@
   }
 }
 
+LLVM_DUMP_METHOD void CheckerRegistry::PackageInfo::dump() const {
+  dumpToStream(llvm::errs());
+}
+
 LLVM_DUMP_METHOD void
 CheckerRegistry::PackageInfo::dumpToStream(llvm::raw_ostream &Out) const {
   Out << FullName << "\n";
Index: clang/lib/StaticAnalyzer/Core/BugReporter.cpp
===
--- clang/lib/StaticAnalyzer/Core/BugReporter.cpp
+++ clang/lib/StaticAnalyzer/Core/BugReporter.cpp
@@ -40,6 +40,7 @@
 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/SVals.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h"
+#include "clang/StaticAnalyzer/Frontend/CheckerRegistry.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/DenseSet.h"
@@ -2106,6 +2107,32 @@
 // Methods for BugReport and subclasses.
 //===--===//
 
+static bool isDependency(const CheckerRegistry &Registry,
+ StringRef CheckerName) {
+  for (const std::pair &Pair : Registry.Dependencies) {
+if (Pair.second == CheckerName)
+  return true;
+  }
+  return false;
+}
+
+PathSensitiveBugReport::PathSensitiveBugReport(
+const BugType &bt, StringRef shortDesc, StringRef desc,
+const ExplodedNode *errorNode, PathDiagnosticLocation LocationToUnique,
+const Decl *DeclToUnique)
+: BugReport(Kind::PathSensitive, bt, shortDesc, desc), ErrorNode(errorNode),
+  ErrorNodeRange(getStmt() ? getStmt()->getSourceRange() : SourceRange()),
+  UniqueingLocation(LocationToUnique), UniqueingDecl(DeclToUnique) {
+  assert(!isDependency(ErrorNode->getState()
+   ->getAnalysisManager()
+   .getCheckerManager()
+   ->getCheckerRegistry(),
+   bt.getCheckerName()) &&
+ "Some checkers depend on this one! We don't allow dependency "
+ "checkers to emit warnings, because checkers should depend on "
+ "*modeling*, not *diagnostics*.");
+}
+
 void PathSensitiveBugReport::addVisitor(
 std::unique_ptr visitor) {
   if (!visitor)
@@ -2194,12 +2221,12 @@
   return;
 case bugreporter::TrackingKind::Condition:
   return;
-  }
+}
 
-  llvm_unreachable(
-  "BugReport::markInteresting currently can only handle 2 different "
-  "tracking kinds! Please define what tracking kind should this entitiy"
-  "have, if it was already marked as interesting with a different kind!");
+llvm_unreachable(
+"BugReport::markInteresting currently can only handle 2 different "
+"tracking kinds! Please define what tracking kind should this entitiy"
+"have, if it was already marked as interesting with a different kind!");
 }
 
 void PathSensitiveBugReport::markInteresting(SymbolRef sym,
Index: clang/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h
===
--- clang/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h
+++ clang/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h
@@ -135,7 +135,7 @@
  "Invalid devel

[PATCH] D81713: [HIP] Fix rocm not found on rocm3.5

2020-06-12 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.

Can you add tests for this? Is this also sufficient with the directory layout 
change?


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

https://reviews.llvm.org/D81713



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


[PATCH] D78350: [AST] Build recovery expressions by default for C++.

2020-06-12 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG58ea1059df97: [AST][RecoveryExpr] Build recovery expressions 
by default for C++. (authored by hokein).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78350

Files:
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/AST/ast-dump-openmp-begin-declare-variant_namespace_1.cpp
  clang/test/CXX/class.access/p4.cpp
  clang/test/CXX/special/class.ctor/p5-0x.cpp
  clang/test/CXX/stmt.stmt/stmt.iter/stmt.ranged/p1.cpp
  clang/test/OpenMP/declare_variant_messages.cpp
  clang/test/OpenMP/target_update_from_messages.cpp
  clang/test/OpenMP/target_update_to_messages.cpp
  clang/test/Parser/objcxx0x-lambda-expressions.mm
  clang/test/Parser/objcxx11-invalid-lambda.cpp
  clang/test/SemaCXX/cast-conversion.cpp
  clang/test/SemaCXX/constant-expression-cxx11.cpp
  clang/test/SemaCXX/constructor-initializer.cpp
  clang/test/SemaCXX/cxx0x-deleted-default-ctor.cpp
  clang/test/SemaCXX/cxx1y-deduced-return-type.cpp
  clang/test/SemaCXX/cxx1z-copy-omission.cpp
  clang/test/SemaCXX/decltype-crash.cpp
  clang/test/SemaCXX/enable_if.cpp
  clang/test/SemaCXX/for-range-dereference.cpp
  clang/test/SemaCXX/recovery-default-init.cpp
  clang/test/SemaCXX/recovery-initializer.cpp
  clang/test/SemaCXX/varargs.cpp
  clang/test/SemaCXX/virtual-base-used.cpp
  clang/test/SemaObjCXX/arc-0x.mm
  clang/test/SemaOpenCLCXX/address-space-references.cl
  clang/test/SemaTemplate/instantiate-function-params.cpp
  clang/test/SemaTemplate/instantiate-init.cpp

Index: clang/test/SemaTemplate/instantiate-init.cpp
===
--- clang/test/SemaTemplate/instantiate-init.cpp
+++ clang/test/SemaTemplate/instantiate-init.cpp
@@ -108,7 +108,7 @@
 integral_c<1> ic1 = array_lengthof(Description::data);
 (void)sizeof(array_lengthof(Description::data));
 
-sizeof(array_lengthof( // expected-error{{no matching function for call to 'array_lengthof'}}
+(void)sizeof(array_lengthof( // expected-error{{no matching function for call to 'array_lengthof'}}
   Description::data // expected-note{{in instantiation of static data member 'PR7985::Description::data' requested here}}
   ));
 
Index: clang/test/SemaTemplate/instantiate-function-params.cpp
===
--- clang/test/SemaTemplate/instantiate-function-params.cpp
+++ clang/test/SemaTemplate/instantiate-function-params.cpp
@@ -3,32 +3,32 @@
 // PR6619
 template struct if_c { };
 template struct if_ {
-  typedef if_c< static_cast(T1::value)> almost_type_; // expected-note 5{{in instantiation}}
+  typedef if_c< static_cast(T1::value)> almost_type_; // expected-note 7{{in instantiation}}
 };
 template  struct wrap_constraints { };
 template  
 inline char has_constraints_(Model* , // expected-note 3{{candidate template ignored}}
-   wrap_constraints* = 0); // expected-note 2{{in instantiation}}
+   wrap_constraints* = 0); // expected-note 4{{in instantiation}}
 
 template  struct not_satisfied {
   static const bool value = sizeof( has_constraints_((Model*)0)  == 1); // expected-error 3{{no matching function}} \
-  // expected-note 2{{while substituting deduced template arguments into function template 'has_constraints_' [with }}
+  // expected-note 4{{while substituting deduced template arguments into function template 'has_constraints_' [with }}
 };
 template  struct requirement_;
 template  struct instantiate {
 };
-template  struct requirement_   : if_<   not_satisfied >::type { // expected-note 5{{in instantiation}}
+template  struct requirement_   : if_<   not_satisfied >::type { // expected-error 3{{no type named 'type' in}} expected-note 7{{in instantiation}}
 };
 template  struct usage_requirements {
 };
 template < typename TT > struct InputIterator{
-typedef  instantiate< & requirement_ x)>::failed> boost_concept_check1; // expected-note {{in instantiation}}
+typedef  instantiate< & requirement_ x)>::failed> boost_concept_check1; // expected-note 2{{in instantiation}}
 };
-template < typename TT > struct ForwardIterator  : InputIterator  { // expected-note {{in instantiation}}
-  typedef instantiate< & requirement_ x)>::failed> boost_concept_check2; // expected-note {{in instantiation}}
+template < typename TT > struct ForwardIterator  : InputIterator  { // expected-note 2{{in instantiation}}
+  typedef instantiate< & requirement_ x)>::failed> boost_concept_check2; // expected-note 2{{in instantiation}}
 
 };
-typedef instantiat

[PATCH] D81552: [ASTMatchers] Added hasDirectBase and hasClass Matchers

2020-06-12 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:3553
+/// \endcode
+AST_MATCHER_P(CXXBaseSpecifier, hasClass, internal::Matcher,
+  InnerMatcher) {

njames93 wrote:
> jkorous wrote:
> > aaron.ballman wrote:
> > > jkorous wrote:
> > > > Nit: while "[base specifier] `hasType`" sounds natural to me for some 
> > > > reason `hasClass` doesn't. English is not my first language though.
> > > I agree that `hasClass` seems unnatural here. Out of curiosity, could we 
> > > modify the `hasName` matcher to work on base specifiers so you can write: 
> > > `cxxRecordDecl(hasAnyBase(hasName("Base")))` as shorthand for the more 
> > > wordy version 
> > > `cxxRecordDecl(hasAnyBase(hasType(cxxRecordDecl(hasName("Base")`?
> > Wouldn't it be strange to treat `hasName` differently than all the other 
> > narrowing matchers? Honest question - I feel that `hasName` might be the 
> > most commonly used, just don't know if that's enough to justify this.
> > https://clang.llvm.org/docs/LibASTMatchersReference.html#narrowing-matchers
> Repurposing `hasName` would be a pain especially considering 99% of its use 
> cases wont be for base class matching.
> Wouldn't it be strange to treat hasName differently than all the other 
> narrowing matchers? Honest question - I feel that hasName might be the most 
> commonly used, just don't know if that's enough to justify this. 
> https://clang.llvm.org/docs/LibASTMatchersReference.html#narrowing-matchers

Different how? I'm suggesting to overload `hasName` to work on a 
`CXXBaseSpecifier` since those have a name.

> Repurposing hasName would be a pain especially considering 99% of its use 
> cases wont be for base class matching.

I'm asking what the right API is for users, though, which is a bit different. 
Base specifiers have names (there are no unnamed base specifiers), so to me, it 
makes more sense for `hasName` to work with them directly since that is the 
thing that does name matching.

I think you can accomplish this by using a `PolymorphicMatcherWithParam1` like 
we do for `hasOverloadedOperatorName` which can narrow to either a 
`CXXOperatorCallExpr` or a `FunctionDecl`.



Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:3621
+/// \endcode
+AST_MATCHER_P(CXXBaseSpecifier, hasClassOrClassTemplate,
+  internal::Matcher, InnerMatcher) {

jkorous wrote:
> I think we should just use `eachOf` matcher for this kind of composition.
> 
> https://clang.llvm.org/docs/LibASTMatchersReference.html#traversal-matchers
+1


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81552



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


[PATCH] D69599: [analyzer] DynamicSize: Remove 'getSizeInElements()' from store

2020-06-12 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment.
Herald added subscribers: martong, steakhal.

@Charusso 
I think this patch may fix this bug https://bugs.llvm.org/show_bug.cgi?id=25284
Could you please verify and close it if so?
At least I couldn't reproduce it on the latest build.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69599



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


  1   2   >