[PATCH] D82244: [SanitizeCoverage] Rename -fsanitize-coverage-{white,black}list to -fsanitize-coverage-{allow,block}list

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



Comment at: clang/docs/ClangCommandLineReference.rst:891
 
 Restrict sanitizer coverage instrumentation exclusively to modules and 
functions that match the provided special case list, except the blacklisted ones
 

echristo wrote:
> MaskRay wrote:
> > echristo wrote:
> > > MaskRay wrote:
> > > > echristo wrote:
> > > > > I'd remove the uses of blacklist and whitelist here and below. Just 
> > > > > have the language and the documentation be for the new option.
> > > > `clang-tblgen -gen-opt-docs` does not seem to provide a feature to hide 
> > > > an option. HelpHidden does not hide the option.
> > > Please remove blacklist and whitelist from the option description.
> > I can do that but the next person updating the documentation will add them 
> > back.
> > 
> > I believe `clang-tblgen -gen-opt-docs` just doesn't have the feature. Maybe 
> > we can delete the old options earlier so that we don't need to worry about 
> > the documentation.
> Ugh. Yes, I hope so too. Can you raise it on cfe-dev?
I can but I need to understand more about `clang-tblgen -gen-opt-docs` first...

Very few people know how to regenerate the doc I think... 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82244



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


[PATCH] D82244: [SanitizeCoverage] Rename -fsanitize-coverage-{white,black}list to -fsanitize-coverage-{allow,block}list

2020-06-19 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 272237.
MaskRay marked 4 inline comments as done.
MaskRay added a comment.

Address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82244

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/docs/SanitizerCoverage.rst
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Driver/Options.td
  clang/include/clang/Driver/SanitizerArgs.h
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/SanitizerArgs.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  
compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_allowlist_blocklist.cpp
  
compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_whitelist_blacklist.cpp
  llvm/include/llvm/Transforms/Instrumentation/SanitizerCoverage.h
  llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp

Index: llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
===
--- llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
+++ llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
@@ -200,10 +200,10 @@
 public:
   ModuleSanitizerCoverage(
   const SanitizerCoverageOptions  = SanitizerCoverageOptions(),
-  const SpecialCaseList *Whitelist = nullptr,
-  const SpecialCaseList *Blacklist = nullptr)
-  : Options(OverrideFromCL(Options)), Whitelist(Whitelist),
-Blacklist(Blacklist) {}
+  const SpecialCaseList *Allowlist = nullptr,
+  const SpecialCaseList *Blocklist = nullptr)
+  : Options(OverrideFromCL(Options)), Allowlist(Allowlist),
+Blocklist(Blocklist) {}
   bool instrumentModule(Module , DomTreeCallback DTCallback,
 PostDomTreeCallback PDTCallback);
 
@@ -268,31 +268,31 @@
 
   SanitizerCoverageOptions Options;
 
-  const SpecialCaseList *Whitelist;
-  const SpecialCaseList *Blacklist;
+  const SpecialCaseList *Allowlist;
+  const SpecialCaseList *Blocklist;
 };
 
 class ModuleSanitizerCoverageLegacyPass : public ModulePass {
 public:
   ModuleSanitizerCoverageLegacyPass(
   const SanitizerCoverageOptions  = SanitizerCoverageOptions(),
-  const std::vector  =
+  const std::vector  =
   std::vector(),
-  const std::vector  =
+  const std::vector  =
   std::vector())
   : ModulePass(ID), Options(Options) {
-if (WhitelistFiles.size() > 0)
-  Whitelist = SpecialCaseList::createOrDie(WhitelistFiles,
+if (AllowlistFiles.size() > 0)
+  Allowlist = SpecialCaseList::createOrDie(AllowlistFiles,
*vfs::getRealFileSystem());
-if (BlacklistFiles.size() > 0)
-  Blacklist = SpecialCaseList::createOrDie(BlacklistFiles,
+if (BlocklistFiles.size() > 0)
+  Blocklist = SpecialCaseList::createOrDie(BlocklistFiles,
*vfs::getRealFileSystem());
 initializeModuleSanitizerCoverageLegacyPassPass(
 *PassRegistry::getPassRegistry());
   }
   bool runOnModule(Module ) override {
-ModuleSanitizerCoverage ModuleSancov(Options, Whitelist.get(),
- Blacklist.get());
+ModuleSanitizerCoverage ModuleSancov(Options, Allowlist.get(),
+ Blocklist.get());
 auto DTCallback = [this](Function ) -> const DominatorTree * {
   return >getAnalysis(F).getDomTree();
 };
@@ -314,16 +314,16 @@
 private:
   SanitizerCoverageOptions Options;
 
-  std::unique_ptr Whitelist;
-  std::unique_ptr Blacklist;
+  std::unique_ptr Allowlist;
+  std::unique_ptr Blocklist;
 };
 
 } // namespace
 
 PreservedAnalyses ModuleSanitizerCoveragePass::run(Module ,
ModuleAnalysisManager ) {
-  ModuleSanitizerCoverage ModuleSancov(Options, Whitelist.get(),
-   Blacklist.get());
+  ModuleSanitizerCoverage ModuleSancov(Options, Allowlist.get(),
+   Blocklist.get());
   auto  = MAM.getResult(M).getManager();
   auto DTCallback = [](Function ) -> const DominatorTree * {
 return (F);
@@ -396,11 +396,11 @@
 Module , DomTreeCallback DTCallback, PostDomTreeCallback PDTCallback) {
   if (Options.CoverageType == SanitizerCoverageOptions::SCK_None)
 return false;
-  if (Whitelist &&
-  !Whitelist->inSection("coverage", "src", M.getSourceFileName()))
+  if (Allowlist &&
+  !Allowlist->inSection("coverage", "src", M.getSourceFileName()))
 return false;
-  if (Blacklist &&
-  Blacklist->inSection("coverage", "src", M.getSourceFileName()))
+  if (Blocklist &&
+  Blocklist->inSection("coverage", "src", M.getSourceFileName()))
 return false;
   C = &(M.getContext());
   DL = ();
@@ -639,9 +639,9 @@
   if (F.hasPersonalityFn() &&
   isAsynchronousEHPersonality(classifyEHPersonality(F.getPersonalityFn(
 return;
-  if 

[PATCH] D82244: [SanitizeCoverage] Rename -fsanitize-coverage-{white,black}list to -fsanitize-coverage-{allow,block}list

2020-06-19 Thread Eric Christopher via Phabricator via cfe-commits
echristo added inline comments.



Comment at: clang/docs/ClangCommandLineReference.rst:891
 
 Restrict sanitizer coverage instrumentation exclusively to modules and 
functions that match the provided special case list, except the blacklisted ones
 

MaskRay wrote:
> echristo wrote:
> > MaskRay wrote:
> > > echristo wrote:
> > > > I'd remove the uses of blacklist and whitelist here and below. Just 
> > > > have the language and the documentation be for the new option.
> > > `clang-tblgen -gen-opt-docs` does not seem to provide a feature to hide 
> > > an option. HelpHidden does not hide the option.
> > Please remove blacklist and whitelist from the option description.
> I can do that but the next person updating the documentation will add them 
> back.
> 
> I believe `clang-tblgen -gen-opt-docs` just doesn't have the feature. Maybe 
> we can delete the old options earlier so that we don't need to worry about 
> the documentation.
Ugh. Yes, I hope so too. Can you raise it on cfe-dev?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82244



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


[PATCH] D82244: [SanitizeCoverage] Rename -fsanitize-coverage-{white,black}list to -fsanitize-coverage-{allow,block}list

2020-06-19 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay marked an inline comment as done.
MaskRay added inline comments.



Comment at: clang/docs/ClangCommandLineReference.rst:891
 
 Restrict sanitizer coverage instrumentation exclusively to modules and 
functions that match the provided special case list, except the blacklisted ones
 

echristo wrote:
> MaskRay wrote:
> > echristo wrote:
> > > I'd remove the uses of blacklist and whitelist here and below. Just have 
> > > the language and the documentation be for the new option.
> > `clang-tblgen -gen-opt-docs` does not seem to provide a feature to hide an 
> > option. HelpHidden does not hide the option.
> Please remove blacklist and whitelist from the option description.
I can do that but the next person updating the documentation will add them back.

I believe `clang-tblgen -gen-opt-docs` just doesn't have the feature. Maybe we 
can delete the old options earlier so that we don't need to worry about the 
documentation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82244



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


[PATCH] D82244: [SanitizeCoverage] Rename -fsanitize-coverage-{white,black}list to -fsanitize-coverage-{allow,block}list

2020-06-19 Thread Eric Christopher via Phabricator via cfe-commits
echristo accepted this revision.
echristo added a comment.
This revision is now accepted and ready to land.

Couple of inline comments then looks good to go. Thank you so much for your 
effort here.

-eric




Comment at: clang/docs/ClangCommandLineReference.rst:891
 
 Restrict sanitizer coverage instrumentation exclusively to modules and 
functions that match the provided special case list, except the blacklisted ones
 

MaskRay wrote:
> echristo wrote:
> > I'd remove the uses of blacklist and whitelist here and below. Just have 
> > the language and the documentation be for the new option.
> `clang-tblgen -gen-opt-docs` does not seem to provide a feature to hide an 
> option. HelpHidden does not hide the option.
Please remove blacklist and whitelist from the option description.



Comment at: 
compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_allowlist_blocklist.cpp:89
+
+/// Kept for compatibility.
+// RUN: %clangxx -O0 %s -S -o - -emit-llvm 
-fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table 
-fsanitize-coverage-whitelist=al_bar.txt  
-fsanitize-coverage-blacklist=bl_bar.txt   2>&1 | not grep -f patterns.txt

Make a note that the options below ware deprecated and will be removed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82244



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


[PATCH] D80977: Diagnose cases where the name of a class member is used within a class definition before the member name is declared.

2020-06-19 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

(Partial review; I'll continue reviewing later.)




Comment at: clang/lib/Sema/SemaDecl.cpp:1543
+// in class 'C', where we look up 'f' to determine if we're declaring a
+// constructor.
+  } else if (D->isInIdentifierNamespace(Lookup.FirstIDNS)) {

Not really about this patch, but take given the following example:

```
typedef int f;
class C { C (f)(); };
```

It looks like every compiler somehow parses this as an invalid constructor 
declaration.  As far as I can tell, it doesn't conform to the grammar for a 
constructor, though: parentheses aren't allowed after the 
parameter-declaration-clause. So it should declare a member function f, whether 
or not `f` is a type.  Maybe I'm missing something, though.

It doesn't matter for this patch, of course, because you can also write 
`C(f());`, which actually depends on whether `f` is a type.



Comment at: clang/test/CXX/basic/basic.scope/basic.scope.class/p2.cpp:154
+
+  static int a = unique_member_function_name(); // expected-error {{undeclared 
identifier}}
+  static int unique_member_function_name();

I'm seeing a test failure here with this patch applied.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80977



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


[PATCH] D78655: [CUDA][HIP] Let non-caputuring lambda be host device

2020-06-19 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked 2 inline comments as done.
yaxunl added a comment.

In D78655#2019290 , @rsmith wrote:

> There are two behaviors that seem to make sense:
>
> - Treat lambdas as implicitly HD (like constexpr functions) in all CUDA / HIP 
> language modes. I don't think it makes sense for lambdas to become implicitly 
> HD in C++17 simply because they become implicitly `constexpr`, nor for their 
> HDness to depend on whether their parameter types happen to be literal types, 
> etc. So in C++17, where lambdas are constexpr whenever they can be, the 
> logical behavior would seem to be that lambdas are implicitly HD. And then 
> for consistency with that, I'd expect them to be implicitly HD across all 
> language modes.
> - Implicitly give lambdas the same HD-ness as the enclosing function (if 
> there is one).
>
>   I would think the best choice may be to do both of these things: if there 
> is an enclosing function, inherit its host or device attributes. And if not, 
> then treat the lambda as implicitly HD. A slight variation on that, that 
> might be better: lambdas with no lambda-capture are implicitly HD; lambdas 
> with any lambda-capture (which must therefore have an enclosing function) 
> inherit the enclosing function's HDness.
>
>   (Note that if we go this way, it makes no difference if there are reference 
> captures, because they're always references on the same "side".)


Sorry for the delay.  I updated the patch as you suggested:

- lambdas without enclosing function are implicitly HD
- lambdas with no lambda-capture are implicitly HD
- lambdas with any lambda-capture (which must therefore have an enclosing 
function) inherit the enclosing function's HDness.






Comment at: clang/test/SemaCUDA/lambda.cu:25-35
+  kernel<<<1,1>>>([&](){ hd(); });
+  // expected-note@-1 {{in instantiation of function template specialization 
'kernel<(lambda at}}
+  // expected-note@-2 {{candidate function not viable: call to __host__ 
function from __global__ function}}
+
+  kernel<<<1,1>>>([=, ](){ hd(); });
+  // expected-note@-1 {{in instantiation of function template specialization 
'kernel<(lambda at}}
+  // expected-note@-2 {{candidate function not viable: call to __host__ 
function from __global__ function}}

tra wrote:
> We may need a better diagnostic for this. Here we've correctly rejected 
> captured lambdas, but the diagnostic is a generic 'can't use that'.
> If would be helpful to let user know that we can't use that because of the 
> capturing lambdas.
added more information about lambda function to the diagnostic message


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

https://reviews.llvm.org/D78655



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


[PATCH] D78655: [CUDA][HIP] Let non-caputuring lambda be host device

2020-06-19 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 272225.
yaxunl marked 4 inline comments as done.
yaxunl added a comment.

improve diagnostic message


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

https://reviews.llvm.org/D78655

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaCUDA.cpp
  clang/lib/Sema/SemaLambda.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/test/CodeGenCUDA/lambda.cu
  clang/test/SemaCUDA/Inputs/cuda.h
  clang/test/SemaCUDA/lambda.cu

Index: clang/test/SemaCUDA/lambda.cu
===
--- /dev/null
+++ clang/test/SemaCUDA/lambda.cu
@@ -0,0 +1,53 @@
+// RUN: %clang_cc1 -std=c++17 -fsyntax-only -verify %s
+
+#include "Inputs/cuda.h"
+
+// file-scope lambda is implicitly host device function.
+auto global_lambda = [] () { return 123; };
+
+template
+__global__ void kernel(F f) { f(); }
+// expected-error@-1 6{{no matching function for call to object of type}}
+
+constexpr __host__ __device__ void hd();
+
+int main(void) {
+  auto lambda_kernel = [&]__global__(){};
+  // expected-error@-1 {{kernel function 'operator()' must be a free function or static member function}}
+
+  int b;
+  kernel<<<1,1>>>(global_lambda);
+
+  kernel<<<1,1>>>([](){ hd(); });
+
+  kernel<<<1,1>>>([=](){ hd(); });
+  // expected-note@-1 {{in instantiation of function template specialization 'kernel<(lambda at}}
+  // expected-note@-2 {{candidate function not viable: call to __host__ function from __global__ function. Consider adding proper host/device attribute to the lambda function or making it non-capturing}}
+
+  kernel<<<1,1>>>([b](){ hd(); });
+  // expected-note@-1 {{in instantiation of function template specialization 'kernel<(lambda at}}
+  // expected-note@-2 {{candidate function not viable: call to __host__ function from __global__ function. Consider adding proper host/device attribute to the lambda function or making it non-capturing}}
+
+  kernel<<<1,1>>>([&]()constexpr{ hd(); });
+  // expected-note@-1 {{in instantiation of function template specialization 'kernel<(lambda at}}
+  // expected-note@-2 {{candidate function not viable: call to __host__ function from __global__ function. Consider adding proper host/device attribute to the lambda function or making it non-capturing}}
+
+  kernel<<<1,1>>>([&](){ hd(); });
+  // expected-note@-1 {{in instantiation of function template specialization 'kernel<(lambda at}}
+  // expected-note@-2 {{candidate function not viable: call to __host__ function from __global__ function. Consider adding proper host/device attribute to the lambda function or making it non-capturing}}
+
+  kernel<<<1,1>>>([=, ](){ hd(); });
+  // expected-note@-1 {{in instantiation of function template specialization 'kernel<(lambda at}}
+  // expected-note@-2 {{candidate function not viable: call to __host__ function from __global__ function. Consider adding proper host/device attribute to the lambda function or making it non-capturing}}
+
+  kernel<<<1,1>>>([&, b](){ hd(); });
+  // expected-note@-1 {{in instantiation of function template specialization 'kernel<(lambda at}}
+  // expected-note@-2 {{candidate function not viable: call to __host__ function from __global__ function. Consider adding proper host/device attribute to the lambda function or making it non-capturing}}
+
+  kernel<<<1,1>>>([](){
+  auto f = [&]{ hd(); };
+  f();
+  });
+
+  return 0;
+}
Index: clang/test/SemaCUDA/Inputs/cuda.h
===
--- clang/test/SemaCUDA/Inputs/cuda.h
+++ clang/test/SemaCUDA/Inputs/cuda.h
@@ -17,6 +17,19 @@
   __host__ __device__ dim3(unsigned x, unsigned y = 1, unsigned z = 1) : x(x), y(y), z(z) {}
 };
 
+#ifdef __HIP__
+typedef struct hipStream *hipStream_t;
+typedef enum hipError {} hipError_t;
+int hipConfigureCall(dim3 gridSize, dim3 blockSize, size_t sharedSize = 0,
+ hipStream_t stream = 0);
+extern "C" hipError_t __hipPushCallConfiguration(dim3 gridSize, dim3 blockSize,
+ size_t sharedSize = 0,
+ hipStream_t stream = 0);
+extern "C" hipError_t hipLaunchKernel(const void *func, dim3 gridDim,
+  dim3 blockDim, void **args,
+  size_t sharedMem,
+  hipStream_t stream);
+#else
 typedef struct cudaStream *cudaStream_t;
 typedef enum cudaError {} cudaError_t;
 
@@ -29,6 +42,7 @@
 extern "C" cudaError_t cudaLaunchKernel(const void *func, dim3 gridDim,
 dim3 blockDim, void **args,
 size_t sharedMem, cudaStream_t stream);
+#endif
 
 // Host- and device-side placement new overloads.
 void *operator new(__SIZE_TYPE__, void *p) { return p; }
Index: clang/test/CodeGenCUDA/lambda.cu

[PATCH] D81938: [InferAddressSpaces] Handle the pair of `ptrtoint`/`inttoptr`.

2020-06-19 Thread Michael Liao via Phabricator via cfe-commits
hliao added a comment.

PING


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81938



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


[PATCH] D82249: [HWASan] Disable GlobalISel/FastISel for HWASan Globals.

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

Is the fallback not working correctly in this case for some reason?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82249



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


[clang] d5f9c4a - [ODRHash] Remove use of 'whitelist'.

2020-06-19 Thread via cfe-commits

Author: Weverything
Date: 2020-06-19T18:39:30-07:00
New Revision: d5f9c4a3d10d166af1f445d20510705117eb6fea

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

LOG: [ODRHash] Remove use of 'whitelist'.

Added: 


Modified: 
clang/include/clang/AST/ODRHash.h
clang/lib/AST/ODRHash.cpp
clang/lib/Serialization/ASTReader.cpp

Removed: 




diff  --git a/clang/include/clang/AST/ODRHash.h 
b/clang/include/clang/AST/ODRHash.h
index cd4a6f37f5db..2e8593e0b835 100644
--- a/clang/include/clang/AST/ODRHash.h
+++ b/clang/include/clang/AST/ODRHash.h
@@ -89,7 +89,7 @@ class ODRHash {
   // Save booleans until the end to lower the size of data to process.
   void AddBoolean(bool value);
 
-  static bool isWhitelistedDecl(const Decl* D, const DeclContext *Parent);
+  static bool isDeclToBeProcessed(const Decl* D, const DeclContext *Parent);
 
 private:
   void AddDeclarationNameImpl(DeclarationName Name);

diff  --git a/clang/lib/AST/ODRHash.cpp b/clang/lib/AST/ODRHash.cpp
index 1f9ff9e407dc..735bcff8f113 100644
--- a/clang/lib/AST/ODRHash.cpp
+++ b/clang/lib/AST/ODRHash.cpp
@@ -440,7 +440,7 @@ class ODRDeclVisitor : public 
ConstDeclVisitor {
 
 // Only allow a small portion of Decl's to be processed.  Remove this once
 // all Decl's can be handled.
-bool ODRHash::isWhitelistedDecl(const Decl *D, const DeclContext *Parent) {
+bool ODRHash::isDeclToBeProcessed(const Decl *D, const DeclContext *Parent) {
   if (D->isImplicit()) return false;
   if (D->getDeclContext() != Parent) return false;
 
@@ -487,7 +487,7 @@ void ODRHash::AddCXXRecordDecl(const CXXRecordDecl *Record) 
{
   // accurate count of Decl's.
   llvm::SmallVector Decls;
   for (Decl *SubDecl : Record->decls()) {
-if (isWhitelistedDecl(SubDecl, Record)) {
+if (isDeclToBeProcessed(SubDecl, Record)) {
   Decls.push_back(SubDecl);
   if (auto *Function = dyn_cast(SubDecl)) {
 // Compute/Preload ODRHash into FunctionDecl.
@@ -588,7 +588,7 @@ void ODRHash::AddFunctionDecl(const FunctionDecl *Function,
   // accurate count of Decl's.
   llvm::SmallVector Decls;
   for (Decl *SubDecl : Function->decls()) {
-if (isWhitelistedDecl(SubDecl, Function)) {
+if (isDeclToBeProcessed(SubDecl, Function)) {
   Decls.push_back(SubDecl);
 }
   }
@@ -614,7 +614,7 @@ void ODRHash::AddEnumDecl(const EnumDecl *Enum) {
   // accurate count of Decl's.
   llvm::SmallVector Decls;
   for (Decl *SubDecl : Enum->decls()) {
-if (isWhitelistedDecl(SubDecl, Enum)) {
+if (isDeclToBeProcessed(SubDecl, Enum)) {
   assert(isa(SubDecl) && "Unexpected Decl");
   Decls.push_back(SubDecl);
 }

diff  --git a/clang/lib/Serialization/ASTReader.cpp 
b/clang/lib/Serialization/ASTReader.cpp
index 3a8ac5abc60a..4dd2054d4b07 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -9581,7 +9581,7 @@ void ASTReader::diagnoseOdrViolations() {
 
   // Used with err_module_odr_violation_mismatch_decl and
   // note_module_odr_violation_mismatch_decl
-  // This list should be the same Decl's as in ODRHash::isWhiteListedDecl
+  // This list should be the same Decl's as in ODRHash::isDeclToBeProcessed
   enum ODRMismatchDecl {
 EndOfClass,
 PublicSpecifer,
@@ -9924,7 +9924,7 @@ void ASTReader::diagnoseOdrViolations() {
  RecordDecl *Record,
  const DeclContext *DC) {
 for (auto *D : Record->decls()) {
-  if (!ODRHash::isWhitelistedDecl(D, DC))
+  if (!ODRHash::isDeclToBeProcessed(D, DC))
 continue;
   Hashes.emplace_back(D, ComputeSubDeclODRHash(D));
 }
@@ -11410,7 +11410,7 @@ void ASTReader::diagnoseOdrViolations() {
   for (auto *D : Enum->decls()) {
 // Due to decl merging, the first EnumDecl is the parent of
 // Decls in both records.
-if (!ODRHash::isWhitelistedDecl(D, FirstEnum))
+if (!ODRHash::isDeclToBeProcessed(D, FirstEnum))
   continue;
 assert(isa(D) && "Unexpected Decl kind");
 Hashes.emplace_back(cast(D),



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


[PATCH] D82223: [clang-tidy] Implement storeOptions for checks missing it.

2020-06-19 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment.

Looks OK for me, but Aaron is proper person to approve patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82223



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


[PATCH] D82249: [HWASan] Disable GlobalISel/FastISel for HWASan Globals.

2020-06-19 Thread Mitch Phillips via Phabricator via cfe-commits
hctim created this revision.
hctim added reviewers: pcc, ostannard.
Herald added subscribers: llvm-commits, Sanitizers, cfe-commits, kristof.beyls, 
rovka.
Herald added projects: clang, Sanitizers, LLVM.

HWASan globals instruction selection lowering hasn't been implemented in
GlobalISel or FastISel. We need to ensure that we get SelectionDAGISel
in all cases where HWASan is enabled.

GlobalISel is the default ISel for aarch64 at -O0. All others go to
SelectionDAGISel. When we disable GlobalISel, we get FastISel, so
disable that too.

Add a regression test to HWASan, and tighten up the instruction
selection test to also include both PIC and static relocation models.

We intend to add lowering for at least GlobalISel at a later date, but this
is a temporary fix.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82249

Files:
  clang/lib/Driver/SanitizerArgs.cpp
  clang/test/Driver/fsanitize.c
  compiler-rt/test/hwasan/TestCases/exported-tagged-global.c
  llvm/test/CodeGen/AArch64/tagged-globals.ll

Index: llvm/test/CodeGen/AArch64/tagged-globals.ll
===
--- llvm/test/CodeGen/AArch64/tagged-globals.ll
+++ llvm/test/CodeGen/AArch64/tagged-globals.ll
@@ -1,31 +1,70 @@
-; RUN: llc < %s | FileCheck %s
+; RUN: llc --relocation-model=static < %s | FileCheck %s
+; RUN: llc --relocation-model=pic < %s | FileCheck %s -check-prefix=CHECK-PIC
 
 target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
 target triple = "aarch64-unknown-linux-android"
 
-@global = external hidden global i32
+@global = external global i32
 declare void @func()
 
 define i32* @global_addr() #0 {
   ; CHECK: global_addr:
-  ; CHECK: adrp x0, :pg_hi21_nc:global
-  ; CHECK: movk x0, #:prel_g3:global+4294967296
-  ; CHECK: add x0, x0, :lo12:global
+  ; CHECK: adrp [[REG:x[0-9]+]], :pg_hi21_nc:global
+  ; CHECK: movk [[REG]], #:prel_g3:global+4294967296
+  ; CHECK: add x0, [[REG]], :lo12:global
+  ; CHECK: ret
+
+  ; CHECK-PIC: global_addr:
+  ; CHECK-PIC: adrp [[REG:x[0-9]+]], :got:global
+  ; CHECK-PIC: ldr x0, {{\[}}[[REG]], :got_lo12:global]
+  ; CHECK-PIC: ret
+
   ret i32* @global
 }
 
 define i32 @global_load() #0 {
   ; CHECK: global_load:
-  ; CHECK: adrp x8, :pg_hi21_nc:global
-  ; CHECK: ldr w0, [x8, :lo12:global]
+  ; CHECK: adrp [[REG:x[0-9]+]], :pg_hi21_nc:global
+  ; CHECK: ldr w0, {{\[}}[[REG]], :lo12:global{{\]}}
+  ; CHECK: ret
+
+  ; CHECK-PIC: global_load:
+  ; CHECK-PIC: adrp [[REG:x[0-9]+]], :got:global
+  ; CHECK-PIC: ldr  [[REG]], {{\[}}[[REG]], :got_lo12:global]
+  ; CHECK-PIC: ldr w0, {{\[}}[[REG]]{{\]}}
+  ; CHECK-PIC: ret
+
   %load = load i32, i32* @global
   ret i32 %load
 }
 
+define void @global_store() #0 {
+  ; CHECK: global_store:
+  ; CHECK: adrp [[REG:x[0-9]+]], :pg_hi21_nc:global
+  ; CHECK: str wzr, {{\[}}[[REG]], :lo12:global{{\]}}
+  ; CHECK: ret
+
+  ; CHECK-PIC: global_store:
+  ; CHECK-PIC: adrp [[REG:x[0-9]+]], :got:global
+  ; CHECK-PIC: ldr  [[REG]], {{\[}}[[REG]], :got_lo12:global]
+  ; CHECK-PIC: str wzr, {{\[}}[[REG]]{{\]}}
+  ; CHECK-PIC: ret
+
+  store i32 0, i32* @global
+  ret void
+}
+
 define void ()* @func_addr() #0 {
   ; CHECK: func_addr:
-  ; CHECK: adrp x0, func
-  ; CHECK: add x0, x0, :lo12:func
+  ; CHECK: adrp [[REG:x[0-9]+]], func
+  ; CHECK: add x0, [[REG]], :lo12:func
+  ; CHECK: ret
+
+  ; CHECK-PIC: func_addr:
+  ; CHECK-PIC: adrp [[REG:x[0-9]+]], :got:func
+  ; CHECK-PIC: ldr  x0, {{\[}}[[REG]], :got_lo12:func]
+  ; CHECK-PIC: ret
+
   ret void ()* @func
 }
 
Index: compiler-rt/test/hwasan/TestCases/exported-tagged-global.c
===
--- /dev/null
+++ compiler-rt/test/hwasan/TestCases/exported-tagged-global.c
@@ -0,0 +1,16 @@
+// RUN: %clang_hwasan %s -o %t
+// RUN: %run %t
+// RUN: %clang_hwasan -O1 %s -o %t
+// RUN: %run %t
+
+static int global;
+
+__attribute__((optnone)) int* address_of_global() {
+  return 
+}
+
+int main(int argc, char **argv) {
+  int* global_address = address_of_global();
+  *global_address = 13;
+  return 0;
+}
Index: clang/test/Driver/fsanitize.c
===
--- clang/test/Driver/fsanitize.c
+++ clang/test/Driver/fsanitize.c
@@ -869,8 +869,12 @@
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=hwaddress -fsanitize-hwaddress-abi=foo %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-HWASAN-FOO-ABI
 // CHECK-HWASAN-INTERCEPTOR-ABI: "-default-function-attr" "hwasan-abi=interceptor"
 // CHECK-HWASAN-INTERCEPTOR-ABI: "-target-feature" "+tagged-globals"
+// CHECK-HWASAN-INTERCEPTOR-ABI: "-mllvm" "--aarch64-enable-global-isel-at-O=-1"
+// CHECK-HWASAN-INTERCEPTOR-ABI: "-mllvm" "-fast-isel=false"
 // CHECK-HWASAN-PLATFORM-ABI: "-default-function-attr" "hwasan-abi=platform"
 // CHECK-HWASAN-PLATFORM-ABI: "-target-feature" "+tagged-globals"
+// CHECK-HWASAN-PLATFORM-ABI: "-mllvm" "--aarch64-enable-global-isel-at-O=-1"
+// CHECK-HWASAN-PLATFORM-ABI: 

[PATCH] D82213: [Remarks] Add callsite locations to inline remarks

2020-06-19 Thread Wenlei He via Phabricator via cfe-commits
wenlei marked an inline comment as done.
wenlei added inline comments.



Comment at: llvm/lib/Analysis/InlineAdvisor.cpp:391
+Remark << ore::NV("Caller", );
+if (ProfileGuidedInline)
+  Remark << " by profile guided inliner";

davidxl wrote:
> is this necessary? User should know if their build has profile or not.
> 
> What is more useful is when PGO is on, but some callsite does not have 
> profile data, then it is worth reporting.
> is this necessary? User should know if their build has profile or not.

This was used to differentiate between SampleProfileLoader inline vs CGSCC 
inline. Maybe the message `by profile guided inliner` isn't great, but can't 
think of a better and concise way..

With the differentiation in the message, the inlinee tree recovered through 
some parsing is what I'm looking for (`[P]` for SampleProfileLoader inline, 
`[C]` for CGSCC inline):

```
Inlinees for main
[P]  _ZN15largesolidarrayIP6regobjEixEi @ 369
[P]  _Z7random1i @ 363
[C]_Z8myrandomv @ 2
[P]  _Z7random1i @ 364
[C]_Z8myrandomv @ 2
[P]  _ZN15largesolidarrayIP6regobjEixEi @ 366
[P]  _ZN6wayobj9createwayERP8point16tRi @ 327
[P]_ZN6wayobj11createwayarEiiRP8point16tRi @ 37.1
[P]  _ZN6wayobj5indexEii @ 143
[P]  _ZN6wayobj5indexEii @ 130
[P]  _ZN6wayobj6indexxEi @ 31
[P]  _ZN6wayobj6indexyEi @ 32
[C]  _ZN8point16tC2Ess @ 2
[C]  _ZN8point16tC2Ess @ 2.1
```

> What is more useful is when PGO is on, but some callsite does not have 
> profile data, then it is worth reporting.

That can be useful. I was also looking for a way to get call site count printed 
(if we have a count), but looks like it's not available from `InlineCost`. I'm 
going to defer that for now if that's ok. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82213



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


[PATCH] D79945: [Sema] Comparison of pointers to complete and incomplete types

2020-06-19 Thread Eli Friedman via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc310bf8256f8: [Sema] Comparison of pointers to complete and 
incomplete types (authored by pestctrl, committed by efriedma).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79945

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaExpr.cpp
  clang/test/Sema/complete-incomplete-pointer-relational-c99.c


Index: clang/test/Sema/complete-incomplete-pointer-relational-c99.c
===
--- /dev/null
+++ clang/test/Sema/complete-incomplete-pointer-relational-c99.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c99 -Wc11-extensions %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c89 -Wc11-extensions %s
+
+int incomplete[]; // expected-warning {{tentative array definition assumed to 
have one element}}
+int complete[6];
+
+int test_comparison_between_incomplete_and_complete_pointer() {
+  return ( < ) &&  // expected-warning {{pointer 
comparisons before C11 need to be between two complete or two incomplete types; 
'int (*)[]' is incomplete and 'int (*)[6]' is complete}}
+ ( <= ) && // expected-warning {{pointer 
comparisons before C11 need to be between two complete or two incomplete types; 
'int (*)[]' is incomplete and 'int (*)[6]' is complete}}
+ ( > ) &&  // expected-warning {{pointer 
comparisons before C11 need to be between two complete or two incomplete types; 
'int (*)[]' is incomplete and 'int (*)[6]' is complete}}
+ ( >= ) && // expected-warning {{pointer 
comparisons before C11 need to be between two complete or two incomplete types; 
'int (*)[]' is incomplete and 'int (*)[6]' is complete}}
+ ( == ) &&
+ ( != );
+}
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -11584,11 +11584,22 @@
 // C99 6.5.9p2 and C99 6.5.8p2
 if (Context.typesAreCompatible(LCanPointeeTy.getUnqualifiedType(),
RCanPointeeTy.getUnqualifiedType())) {
-  // Valid unless a relational comparison of function pointers
-  if (IsRelational && LCanPointeeTy->isFunctionType()) {
-Diag(Loc, diag::ext_typecheck_ordered_comparison_of_function_pointers)
-  << LHSType << RHSType << LHS.get()->getSourceRange()
-  << RHS.get()->getSourceRange();
+  if (IsRelational) {
+// Pointers both need to point to complete or incomplete types
+if ((LCanPointeeTy->isIncompleteType() !=
+ RCanPointeeTy->isIncompleteType()) &&
+!getLangOpts().C11) {
+  Diag(Loc, diag::ext_typecheck_compare_complete_incomplete_pointers)
+  << LHS.get()->getSourceRange() << RHS.get()->getSourceRange()
+  << LHSType << RHSType << LCanPointeeTy->isIncompleteType()
+  << RCanPointeeTy->isIncompleteType();
+}
+if (LCanPointeeTy->isFunctionType()) {
+  // Valid unless a relational comparison of function pointers
+  Diag(Loc, 
diag::ext_typecheck_ordered_comparison_of_function_pointers)
+  << LHSType << RHSType << LHS.get()->getSourceRange()
+  << RHS.get()->getSourceRange();
+}
   }
 } else if (!IsRelational &&
(LCanPointeeTy->isVoidType() || RCanPointeeTy->isVoidType())) {
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -6446,6 +6446,12 @@
   "ordered comparison between pointer and zero (%0 and %1)">;
 def err_typecheck_three_way_comparison_of_pointer_and_zero : Error<
   "three-way comparison between pointer and zero">;
+def ext_typecheck_compare_complete_incomplete_pointers : Extension<
+  "pointer comparisons before C11 "
+  "need to be between two complete or two incomplete types; "
+  "%0 is %select{|in}2complete and "
+  "%1 is %select{|in}3complete">,
+  InGroup;
 def ext_typecheck_ordered_comparison_of_function_pointers : ExtWarn<
   "ordered comparison of function pointers (%0 and %1)">,
   InGroup>;


Index: clang/test/Sema/complete-incomplete-pointer-relational-c99.c
===
--- /dev/null
+++ clang/test/Sema/complete-incomplete-pointer-relational-c99.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c99 -Wc11-extensions %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c89 -Wc11-extensions %s
+
+int incomplete[]; // expected-warning {{tentative array definition assumed to have one element}}
+int complete[6];
+
+int test_comparison_between_incomplete_and_complete_pointer() {
+  return ( < ) &&  // expected-warning {{pointer comparisons 

[clang] c310bf8 - [Sema] Comparison of pointers to complete and incomplete types

2020-06-19 Thread Eli Friedman via cfe-commits

Author: Benson Chu
Date: 2020-06-19T17:01:03-07:00
New Revision: c310bf8256f83f365921562cebc5e4c9aec8e87e

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

LOG: [Sema] Comparison of pointers to complete and incomplete types

Clang is missing one of the conditions for C99 6.5.9p2, where comparison
between pointers must either both point to incomplete types or both
point to complete types. This patch adds an extra check to the clause
where two pointers are of compatible types.

This only applies to C89/C99; the relevant part of the standard was
rewritten for C11.

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

Added: 
clang/test/Sema/complete-incomplete-pointer-relational-c99.c

Modified: 
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaExpr.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index a7b8a992f745..7c72eba8c2c1 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -6446,6 +6446,12 @@ def err_typecheck_ordered_comparison_of_pointer_and_zero 
: Error<
   "ordered comparison between pointer and zero (%0 and %1)">;
 def err_typecheck_three_way_comparison_of_pointer_and_zero : Error<
   "three-way comparison between pointer and zero">;
+def ext_typecheck_compare_complete_incomplete_pointers : Extension<
+  "pointer comparisons before C11 "
+  "need to be between two complete or two incomplete types; "
+  "%0 is %select{|in}2complete and "
+  "%1 is %select{|in}3complete">,
+  InGroup;
 def ext_typecheck_ordered_comparison_of_function_pointers : ExtWarn<
   "ordered comparison of function pointers (%0 and %1)">,
   InGroup>;

diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 59e7d88b7691..fdc050603188 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -11584,11 +11584,22 @@ QualType Sema::CheckCompareOperands(ExprResult , 
ExprResult ,
 // C99 6.5.9p2 and C99 6.5.8p2
 if (Context.typesAreCompatible(LCanPointeeTy.getUnqualifiedType(),
RCanPointeeTy.getUnqualifiedType())) {
-  // Valid unless a relational comparison of function pointers
-  if (IsRelational && LCanPointeeTy->isFunctionType()) {
-Diag(Loc, diag::ext_typecheck_ordered_comparison_of_function_pointers)
-  << LHSType << RHSType << LHS.get()->getSourceRange()
-  << RHS.get()->getSourceRange();
+  if (IsRelational) {
+// Pointers both need to point to complete or incomplete types
+if ((LCanPointeeTy->isIncompleteType() !=
+ RCanPointeeTy->isIncompleteType()) &&
+!getLangOpts().C11) {
+  Diag(Loc, diag::ext_typecheck_compare_complete_incomplete_pointers)
+  << LHS.get()->getSourceRange() << RHS.get()->getSourceRange()
+  << LHSType << RHSType << LCanPointeeTy->isIncompleteType()
+  << RCanPointeeTy->isIncompleteType();
+}
+if (LCanPointeeTy->isFunctionType()) {
+  // Valid unless a relational comparison of function pointers
+  Diag(Loc, 
diag::ext_typecheck_ordered_comparison_of_function_pointers)
+  << LHSType << RHSType << LHS.get()->getSourceRange()
+  << RHS.get()->getSourceRange();
+}
   }
 } else if (!IsRelational &&
(LCanPointeeTy->isVoidType() || RCanPointeeTy->isVoidType())) {

diff  --git a/clang/test/Sema/complete-incomplete-pointer-relational-c99.c 
b/clang/test/Sema/complete-incomplete-pointer-relational-c99.c
new file mode 100644
index ..ea6e4055eb52
--- /dev/null
+++ b/clang/test/Sema/complete-incomplete-pointer-relational-c99.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c99 -Wc11-extensions %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c89 -Wc11-extensions %s
+
+int incomplete[]; // expected-warning {{tentative array definition assumed to 
have one element}}
+int complete[6];
+
+int test_comparison_between_incomplete_and_complete_pointer() {
+  return ( < ) &&  // expected-warning {{pointer 
comparisons before C11 need to be between two complete or two incomplete types; 
'int (*)[]' is incomplete and 'int (*)[6]' is complete}}
+ ( <= ) && // expected-warning {{pointer 
comparisons before C11 need to be between two complete or two incomplete types; 
'int (*)[]' is incomplete and 'int (*)[6]' is complete}}
+ ( > ) &&  // expected-warning {{pointer 
comparisons before C11 need to be between two complete or two incomplete types; 
'int (*)[]' is incomplete and 'int (*)[6]' is complete}}
+ ( >= ) && // expected-warning {{pointer 
comparisons before C11 need to be 

[PATCH] D82244: [SanitizeCoverage] Rename -fsanitize-coverage-{white,black}list to -fsanitize-coverage-{allow,block}list

2020-06-19 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay marked 6 inline comments as done.
MaskRay added inline comments.



Comment at: clang/docs/ClangCommandLineReference.rst:891
 
 Restrict sanitizer coverage instrumentation exclusively to modules and 
functions that match the provided special case list, except the blacklisted ones
 

echristo wrote:
> I'd remove the uses of blacklist and whitelist here and below. Just have the 
> language and the documentation be for the new option.
`clang-tblgen -gen-opt-docs` does not seem to provide a feature to hide an 
option. HelpHidden does not hide the option.



Comment at: clang/docs/SanitizerCoverage.rst:435
 Options
-  -blacklist= - Blacklist file (sanitizer blacklist 
format).
+  -blacklist= - Blocklist file (sanitizer blocklist 
format).
   -demangle   - Print demangled function name.

echristo wrote:
> blacklist here.
sancov is another tool that is not touched by this patch. It should be updated 
separately.



Comment at: clang/include/clang/Driver/Options.td:1002
 HelpText<"Restrict sanitizer coverage instrumentation exclusively to 
modules and functions that match the provided special case list, except the 
blacklisted ones">;
-def fsanitize_coverage_blacklist : Joined<["-"], 
"fsanitize-coverage-blacklist=">,
+def : Joined<["-"], "fsanitize-coverage-whitelist=">,
+  Group, Flags<[CoreOption, HelpHidden]>, 
Alias;

echristo wrote:
> Deprecate the option and comment it as such.
HelpHidden will hide the options from help.



Comment at: 
compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_allowlist_blocklist.cpp:2
+// Tests -fsanitize-coverage-allowlist=whitelist.txt and
+// -fsanitize-coverage-blocklist=blacklist.txt with libFuzzer-like coverage
 // options

echristo wrote:
> blacklist filename. probably want to change wl_* and bl_* below as well.
wl_ -> al_

bl_ can still mean blocklist.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82244



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


[PATCH] D82244: [SanitizeCoverage] Rename -fsanitize-coverage-{white,black}list to -fsanitize-coverage-{allow,block}list

2020-06-19 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 272209.
MaskRay marked an inline comment as done.
MaskRay added a comment.

Fix more words


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82244

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/docs/SanitizerCoverage.rst
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Driver/Options.td
  clang/include/clang/Driver/SanitizerArgs.h
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/SanitizerArgs.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  
compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_allowlist_blocklist.cpp
  
compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_whitelist_blacklist.cpp
  llvm/include/llvm/Transforms/Instrumentation/SanitizerCoverage.h
  llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp

Index: llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
===
--- llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
+++ llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
@@ -200,10 +200,10 @@
 public:
   ModuleSanitizerCoverage(
   const SanitizerCoverageOptions  = SanitizerCoverageOptions(),
-  const SpecialCaseList *Whitelist = nullptr,
-  const SpecialCaseList *Blacklist = nullptr)
-  : Options(OverrideFromCL(Options)), Whitelist(Whitelist),
-Blacklist(Blacklist) {}
+  const SpecialCaseList *Allowlist = nullptr,
+  const SpecialCaseList *Blocklist = nullptr)
+  : Options(OverrideFromCL(Options)), Allowlist(Allowlist),
+Blocklist(Blocklist) {}
   bool instrumentModule(Module , DomTreeCallback DTCallback,
 PostDomTreeCallback PDTCallback);
 
@@ -268,31 +268,31 @@
 
   SanitizerCoverageOptions Options;
 
-  const SpecialCaseList *Whitelist;
-  const SpecialCaseList *Blacklist;
+  const SpecialCaseList *Allowlist;
+  const SpecialCaseList *Blocklist;
 };
 
 class ModuleSanitizerCoverageLegacyPass : public ModulePass {
 public:
   ModuleSanitizerCoverageLegacyPass(
   const SanitizerCoverageOptions  = SanitizerCoverageOptions(),
-  const std::vector  =
+  const std::vector  =
   std::vector(),
-  const std::vector  =
+  const std::vector  =
   std::vector())
   : ModulePass(ID), Options(Options) {
-if (WhitelistFiles.size() > 0)
-  Whitelist = SpecialCaseList::createOrDie(WhitelistFiles,
+if (AllowlistFiles.size() > 0)
+  Allowlist = SpecialCaseList::createOrDie(AllowlistFiles,
*vfs::getRealFileSystem());
-if (BlacklistFiles.size() > 0)
-  Blacklist = SpecialCaseList::createOrDie(BlacklistFiles,
+if (BlocklistFiles.size() > 0)
+  Blocklist = SpecialCaseList::createOrDie(BlocklistFiles,
*vfs::getRealFileSystem());
 initializeModuleSanitizerCoverageLegacyPassPass(
 *PassRegistry::getPassRegistry());
   }
   bool runOnModule(Module ) override {
-ModuleSanitizerCoverage ModuleSancov(Options, Whitelist.get(),
- Blacklist.get());
+ModuleSanitizerCoverage ModuleSancov(Options, Allowlist.get(),
+ Blocklist.get());
 auto DTCallback = [this](Function ) -> const DominatorTree * {
   return >getAnalysis(F).getDomTree();
 };
@@ -314,16 +314,16 @@
 private:
   SanitizerCoverageOptions Options;
 
-  std::unique_ptr Whitelist;
-  std::unique_ptr Blacklist;
+  std::unique_ptr Allowlist;
+  std::unique_ptr Blocklist;
 };
 
 } // namespace
 
 PreservedAnalyses ModuleSanitizerCoveragePass::run(Module ,
ModuleAnalysisManager ) {
-  ModuleSanitizerCoverage ModuleSancov(Options, Whitelist.get(),
-   Blacklist.get());
+  ModuleSanitizerCoverage ModuleSancov(Options, Allowlist.get(),
+   Blocklist.get());
   auto  = MAM.getResult(M).getManager();
   auto DTCallback = [](Function ) -> const DominatorTree * {
 return (F);
@@ -396,11 +396,11 @@
 Module , DomTreeCallback DTCallback, PostDomTreeCallback PDTCallback) {
   if (Options.CoverageType == SanitizerCoverageOptions::SCK_None)
 return false;
-  if (Whitelist &&
-  !Whitelist->inSection("coverage", "src", M.getSourceFileName()))
+  if (Allowlist &&
+  !Allowlist->inSection("coverage", "src", M.getSourceFileName()))
 return false;
-  if (Blacklist &&
-  Blacklist->inSection("coverage", "src", M.getSourceFileName()))
+  if (Blocklist &&
+  Blocklist->inSection("coverage", "src", M.getSourceFileName()))
 return false;
   C = &(M.getContext());
   DL = ();
@@ -639,9 +639,9 @@
   if (F.hasPersonalityFn() &&
   isAsynchronousEHPersonality(classifyEHPersonality(F.getPersonalityFn(
 return;
-  if 

[PATCH] D82213: [Remarks] Add callsite locations to inline remarks

2020-06-19 Thread David Li via Phabricator via cfe-commits
davidxl added a comment.

Can you add a test case where there is more than one level of inline contexts 
for the callsite?




Comment at: llvm/lib/Analysis/InlineAdvisor.cpp:391
+Remark << ore::NV("Caller", );
+if (ProfileGuidedInline)
+  Remark << " by profile guided inliner";

is this necessary? User should know if their build has profile or not.

What is more useful is when PGO is on, but some callsite does not have profile 
data, then it is worth reporting.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82213



___
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-19 Thread Ravi Narayanaswamy via Phabricator via cfe-commits
RaviNarayanaswamy added a comment.

How do you plan to support 
#pragma omp target update to (arr[1:2][1:2][0:2], x, b[1:5][0:2])
Are you going to split this into 3 updates since your are using the arg fields.


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] D82244: [SanitizeCoverage] Rename -fsanitize-coverage-{white,black}list to -fsanitize-coverage-{allow,block}list

2020-06-19 Thread Eric Christopher via Phabricator via cfe-commits
echristo added inline comments.



Comment at: clang/docs/ClangCommandLineReference.rst:313-316
+.. option:: -mharden-sls=
+
+Select straight-line speculation hardening scope
+

Miss merge?



Comment at: clang/docs/ClangCommandLineReference.rst:891
 
 Restrict sanitizer coverage instrumentation exclusively to modules and 
functions that match the provided special case list, except the blacklisted ones
 

I'd remove the uses of blacklist and whitelist here and below. Just have the 
language and the documentation be for the new option.



Comment at: clang/docs/SanitizerCoverage.rst:435
 Options
-  -blacklist= - Blacklist file (sanitizer blacklist 
format).
+  -blacklist= - Blocklist file (sanitizer blocklist 
format).
   -demangle   - Print demangled function name.

blacklist here.



Comment at: clang/include/clang/Driver/Options.td:1002
 HelpText<"Restrict sanitizer coverage instrumentation exclusively to 
modules and functions that match the provided special case list, except the 
blacklisted ones">;
-def fsanitize_coverage_blacklist : Joined<["-"], 
"fsanitize-coverage-blacklist=">,
+def : Joined<["-"], "fsanitize-coverage-whitelist=">,
+  Group, Flags<[CoreOption, HelpHidden]>, 
Alias;

Deprecate the option and comment it as such.



Comment at: 
compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_allowlist_blocklist.cpp:2
+// Tests -fsanitize-coverage-allowlist=whitelist.txt and
+// -fsanitize-coverage-blocklist=blacklist.txt with libFuzzer-like coverage
 // options

blacklist filename. probably want to change wl_* and bl_* below as well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82244



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


[PATCH] D82092: [analyzer] Handle `\l` symbol in string literals in exploded-graph-rewriter

2020-06-19 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov marked an inline comment as done.
ASDenysPetrov added a comment.

Thanks for the quick review, guys!




Comment at: 
clang/test/Analysis/exploded-graph-rewriter/l_name_starts_with_l.cpp:25
+
+// This test is passed if exploded_graph_rewriter handles dot file without 
errors.
+// CHECK: digraph "ExplodedGraph"

NoQ wrote:
> I still wouldn't mind testing the actual output.
I'll add more //checks// before the load.


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

https://reviews.llvm.org/D82092



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


[PATCH] D82103: [analyzer] Remove forbidden characters from a SourceLocation filename for a graph dump on Windows

2020-06-19 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov updated this revision to Diff 272204.
ASDenysPetrov added a comment.

Removed accidentally included unrelated changes.


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

https://reviews.llvm.org/D82103

Files:
  clang/include/clang/Basic/JsonSupport.h
  clang/test/Analysis/exploded-graph-rewriter/win_path_forbidden_chars.cpp


Index: clang/test/Analysis/exploded-graph-rewriter/win_path_forbidden_chars.cpp
===
--- /dev/null
+++ clang/test/Analysis/exploded-graph-rewriter/win_path_forbidden_chars.cpp
@@ -0,0 +1,26 @@
+// FIXME: Figure out how to use %clang_analyze_cc1 with our lit.local.cfg.
+// RUN: %clang_cc1 -analyze -triple x86_64-unknown-linux-gnu \
+// RUN: -analyzer-checker=core \
+// RUN: -analyzer-dump-egraph=%t.dot %s
+// RUN: %exploded_graph_rewriter %t.dot | FileCheck %s
+// REQUIRES: asserts
+// UNSUPPORTED: !windows
+
+// Angle brackets shall not be presented in the field `file`,
+// because exploded_graph_rewriter handles it as a file path
+// and such symbols are forbidden on Windows platform.
+
+extern void __assert_fail(__const char *__assertion, __const char *__file,
+  unsigned int __line, __const char *__function)
+__attribute__((__noreturn__));
+#define assert(expr) \
+  ((expr) ? (void)(0) : __assert_fail(#expr, __FILE__, __LINE__, __func__))
+
+int test(int *array, int size) {
+  //Here `assert` helps to produce angle brackets.
+  assert(size);
+  return array[size];
+}
+
+//This test is passed if exploded_graph_rewriter handles dot file without 
errors.
+// CHECK: digraph "ExplodedGraph"
Index: clang/include/clang/Basic/JsonSupport.h
===
--- clang/include/clang/Basic/JsonSupport.h
+++ clang/include/clang/Basic/JsonSupport.h
@@ -13,7 +13,7 @@
 #include "clang/Basic/SourceManager.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/raw_ostream.h"
-
+#include 
 
 namespace clang {
 
@@ -98,7 +98,16 @@
 if (AddBraces)
   Out << "{ ";
 std::string filename(PLoc.getFilename());
-#ifdef _WIN32 // Handle windows-specific path delimiters.
+#ifdef _WIN32
+// Remove forbidden Windows path characters
+auto RemoveIt =
+std::remove_if(filename.begin(), filename.end(), [](auto Char) {
+  static const char ForbiddenChars[] = "<>*?\"|";
+  return std::find(std::begin(ForbiddenChars), 
std::end(ForbiddenChars),
+   Char) != std::end(ForbiddenChars);
+});
+filename.erase(RemoveIt, filename.end());
+// Handle windows-specific path delimiters.
 std::replace(filename.begin(), filename.end(), '\\', '/');
 #endif
 Out << "\"line\": " << PLoc.getLine()


Index: clang/test/Analysis/exploded-graph-rewriter/win_path_forbidden_chars.cpp
===
--- /dev/null
+++ clang/test/Analysis/exploded-graph-rewriter/win_path_forbidden_chars.cpp
@@ -0,0 +1,26 @@
+// FIXME: Figure out how to use %clang_analyze_cc1 with our lit.local.cfg.
+// RUN: %clang_cc1 -analyze -triple x86_64-unknown-linux-gnu \
+// RUN: -analyzer-checker=core \
+// RUN: -analyzer-dump-egraph=%t.dot %s
+// RUN: %exploded_graph_rewriter %t.dot | FileCheck %s
+// REQUIRES: asserts
+// UNSUPPORTED: !windows
+
+// Angle brackets shall not be presented in the field `file`,
+// because exploded_graph_rewriter handles it as a file path
+// and such symbols are forbidden on Windows platform.
+
+extern void __assert_fail(__const char *__assertion, __const char *__file,
+  unsigned int __line, __const char *__function)
+__attribute__((__noreturn__));
+#define assert(expr) \
+  ((expr) ? (void)(0) : __assert_fail(#expr, __FILE__, __LINE__, __func__))
+
+int test(int *array, int size) {
+  //Here `assert` helps to produce angle brackets.
+  assert(size);
+  return array[size];
+}
+
+//This test is passed if exploded_graph_rewriter handles dot file without errors.
+// CHECK: digraph "ExplodedGraph"
Index: clang/include/clang/Basic/JsonSupport.h
===
--- clang/include/clang/Basic/JsonSupport.h
+++ clang/include/clang/Basic/JsonSupport.h
@@ -13,7 +13,7 @@
 #include "clang/Basic/SourceManager.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/raw_ostream.h"
-
+#include 
 
 namespace clang {
 
@@ -98,7 +98,16 @@
 if (AddBraces)
   Out << "{ ";
 std::string filename(PLoc.getFilename());
-#ifdef _WIN32 // Handle windows-specific path delimiters.
+#ifdef _WIN32
+// Remove forbidden Windows path characters
+auto RemoveIt =
+std::remove_if(filename.begin(), filename.end(), [](auto Char) {
+  static const char ForbiddenChars[] = "<>*?\"|";
+  return std::find(std::begin(ForbiddenChars), std::end(ForbiddenChars),
+   

[PATCH] D82244: [SanitizeCoverage] Rename -fsanitize-coverage-{white,black}list to -fsanitize-coverage-{allow,block}list

2020-06-19 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 272201.
MaskRay added a comment.

Fix documentation


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82244

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/docs/SanitizerCoverage.rst
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/SanitizerArgs.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  
compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_allowlist_blocklist.cpp
  
compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_whitelist_blacklist.cpp
  llvm/include/llvm/Transforms/Instrumentation/SanitizerCoverage.h
  llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp

Index: llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
===
--- llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
+++ llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
@@ -200,10 +200,10 @@
 public:
   ModuleSanitizerCoverage(
   const SanitizerCoverageOptions  = SanitizerCoverageOptions(),
-  const SpecialCaseList *Whitelist = nullptr,
-  const SpecialCaseList *Blacklist = nullptr)
-  : Options(OverrideFromCL(Options)), Whitelist(Whitelist),
-Blacklist(Blacklist) {}
+  const SpecialCaseList *Allowlist = nullptr,
+  const SpecialCaseList *Blocklist = nullptr)
+  : Options(OverrideFromCL(Options)), Allowlist(Allowlist),
+Blocklist(Blocklist) {}
   bool instrumentModule(Module , DomTreeCallback DTCallback,
 PostDomTreeCallback PDTCallback);
 
@@ -268,31 +268,31 @@
 
   SanitizerCoverageOptions Options;
 
-  const SpecialCaseList *Whitelist;
-  const SpecialCaseList *Blacklist;
+  const SpecialCaseList *Allowlist;
+  const SpecialCaseList *Blocklist;
 };
 
 class ModuleSanitizerCoverageLegacyPass : public ModulePass {
 public:
   ModuleSanitizerCoverageLegacyPass(
   const SanitizerCoverageOptions  = SanitizerCoverageOptions(),
-  const std::vector  =
+  const std::vector  =
   std::vector(),
-  const std::vector  =
+  const std::vector  =
   std::vector())
   : ModulePass(ID), Options(Options) {
-if (WhitelistFiles.size() > 0)
-  Whitelist = SpecialCaseList::createOrDie(WhitelistFiles,
+if (AllowlistFiles.size() > 0)
+  Allowlist = SpecialCaseList::createOrDie(AllowlistFiles,
*vfs::getRealFileSystem());
-if (BlacklistFiles.size() > 0)
-  Blacklist = SpecialCaseList::createOrDie(BlacklistFiles,
+if (BlocklistFiles.size() > 0)
+  Blocklist = SpecialCaseList::createOrDie(BlocklistFiles,
*vfs::getRealFileSystem());
 initializeModuleSanitizerCoverageLegacyPassPass(
 *PassRegistry::getPassRegistry());
   }
   bool runOnModule(Module ) override {
-ModuleSanitizerCoverage ModuleSancov(Options, Whitelist.get(),
- Blacklist.get());
+ModuleSanitizerCoverage ModuleSancov(Options, Allowlist.get(),
+ Blocklist.get());
 auto DTCallback = [this](Function ) -> const DominatorTree * {
   return >getAnalysis(F).getDomTree();
 };
@@ -314,16 +314,16 @@
 private:
   SanitizerCoverageOptions Options;
 
-  std::unique_ptr Whitelist;
-  std::unique_ptr Blacklist;
+  std::unique_ptr Allowlist;
+  std::unique_ptr Blocklist;
 };
 
 } // namespace
 
 PreservedAnalyses ModuleSanitizerCoveragePass::run(Module ,
ModuleAnalysisManager ) {
-  ModuleSanitizerCoverage ModuleSancov(Options, Whitelist.get(),
-   Blacklist.get());
+  ModuleSanitizerCoverage ModuleSancov(Options, Allowlist.get(),
+   Blocklist.get());
   auto  = MAM.getResult(M).getManager();
   auto DTCallback = [](Function ) -> const DominatorTree * {
 return (F);
@@ -396,11 +396,11 @@
 Module , DomTreeCallback DTCallback, PostDomTreeCallback PDTCallback) {
   if (Options.CoverageType == SanitizerCoverageOptions::SCK_None)
 return false;
-  if (Whitelist &&
-  !Whitelist->inSection("coverage", "src", M.getSourceFileName()))
+  if (Allowlist &&
+  !Allowlist->inSection("coverage", "src", M.getSourceFileName()))
 return false;
-  if (Blacklist &&
-  Blacklist->inSection("coverage", "src", M.getSourceFileName()))
+  if (Blocklist &&
+  Blocklist->inSection("coverage", "src", M.getSourceFileName()))
 return false;
   C = &(M.getContext());
   DL = ();
@@ -639,9 +639,9 @@
   if (F.hasPersonalityFn() &&
   isAsynchronousEHPersonality(classifyEHPersonality(F.getPersonalityFn(
 return;
-  if (Whitelist && !Whitelist->inSection("coverage", "fun", F.getName()))
+  if (Allowlist && 

[PATCH] D82244: [SanitizeCoverage] Rename -fsanitize-coverage-{white,black}list to -fsanitize-coverage-{allow,block}list

2020-06-19 Thread Eric Christopher via Phabricator via cfe-commits
echristo added a reviewer: HAPPY.
echristo added a comment.

You'll want to grab blacklist/whitelist in the comments around as well.

We've been talking about having a need for deprecated aliases file for these 
options - it's probably worth bringing this patch up on cfe-dev and cc'ing 
richardsmith explicitly. I think we can avoid compatibility aliases, but would 
like Richard to sign off.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82244



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


[PATCH] D82244: [SanitizeCoverage] Rename -fsanitize-coverage-{white,black}list to -fsanitize-coverage-{allow,block}list

2020-06-19 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 272200.
MaskRay edited the summary of this revision.
MaskRay edited reviewers, added: pcc; removed: HAPPY.
MaskRay added a comment.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.

Add aliases


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82244

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/docs/SanitizerCoverage.rst
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/SanitizerArgs.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  
compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_allowlist_blocklist.cpp
  
compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_whitelist_blacklist.cpp
  llvm/include/llvm/Transforms/Instrumentation/SanitizerCoverage.h
  llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp

Index: llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
===
--- llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
+++ llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
@@ -200,10 +200,10 @@
 public:
   ModuleSanitizerCoverage(
   const SanitizerCoverageOptions  = SanitizerCoverageOptions(),
-  const SpecialCaseList *Whitelist = nullptr,
-  const SpecialCaseList *Blacklist = nullptr)
-  : Options(OverrideFromCL(Options)), Whitelist(Whitelist),
-Blacklist(Blacklist) {}
+  const SpecialCaseList *Allowlist = nullptr,
+  const SpecialCaseList *Blocklist = nullptr)
+  : Options(OverrideFromCL(Options)), Allowlist(Allowlist),
+Blocklist(Blocklist) {}
   bool instrumentModule(Module , DomTreeCallback DTCallback,
 PostDomTreeCallback PDTCallback);
 
@@ -268,31 +268,31 @@
 
   SanitizerCoverageOptions Options;
 
-  const SpecialCaseList *Whitelist;
-  const SpecialCaseList *Blacklist;
+  const SpecialCaseList *Allowlist;
+  const SpecialCaseList *Blocklist;
 };
 
 class ModuleSanitizerCoverageLegacyPass : public ModulePass {
 public:
   ModuleSanitizerCoverageLegacyPass(
   const SanitizerCoverageOptions  = SanitizerCoverageOptions(),
-  const std::vector  =
+  const std::vector  =
   std::vector(),
-  const std::vector  =
+  const std::vector  =
   std::vector())
   : ModulePass(ID), Options(Options) {
-if (WhitelistFiles.size() > 0)
-  Whitelist = SpecialCaseList::createOrDie(WhitelistFiles,
+if (AllowlistFiles.size() > 0)
+  Allowlist = SpecialCaseList::createOrDie(AllowlistFiles,
*vfs::getRealFileSystem());
-if (BlacklistFiles.size() > 0)
-  Blacklist = SpecialCaseList::createOrDie(BlacklistFiles,
+if (BlocklistFiles.size() > 0)
+  Blocklist = SpecialCaseList::createOrDie(BlocklistFiles,
*vfs::getRealFileSystem());
 initializeModuleSanitizerCoverageLegacyPassPass(
 *PassRegistry::getPassRegistry());
   }
   bool runOnModule(Module ) override {
-ModuleSanitizerCoverage ModuleSancov(Options, Whitelist.get(),
- Blacklist.get());
+ModuleSanitizerCoverage ModuleSancov(Options, Allowlist.get(),
+ Blocklist.get());
 auto DTCallback = [this](Function ) -> const DominatorTree * {
   return >getAnalysis(F).getDomTree();
 };
@@ -314,16 +314,16 @@
 private:
   SanitizerCoverageOptions Options;
 
-  std::unique_ptr Whitelist;
-  std::unique_ptr Blacklist;
+  std::unique_ptr Allowlist;
+  std::unique_ptr Blocklist;
 };
 
 } // namespace
 
 PreservedAnalyses ModuleSanitizerCoveragePass::run(Module ,
ModuleAnalysisManager ) {
-  ModuleSanitizerCoverage ModuleSancov(Options, Whitelist.get(),
-   Blacklist.get());
+  ModuleSanitizerCoverage ModuleSancov(Options, Allowlist.get(),
+   Blocklist.get());
   auto  = MAM.getResult(M).getManager();
   auto DTCallback = [](Function ) -> const DominatorTree * {
 return (F);
@@ -396,11 +396,11 @@
 Module , DomTreeCallback DTCallback, PostDomTreeCallback PDTCallback) {
   if (Options.CoverageType == SanitizerCoverageOptions::SCK_None)
 return false;
-  if (Whitelist &&
-  !Whitelist->inSection("coverage", "src", M.getSourceFileName()))
+  if (Allowlist &&
+  !Allowlist->inSection("coverage", "src", M.getSourceFileName()))
 return false;
-  if (Blacklist &&
-  Blacklist->inSection("coverage", "src", M.getSourceFileName()))
+  if (Blocklist &&
+  Blocklist->inSection("coverage", "src", M.getSourceFileName()))
 return false;
   C = &(M.getContext());
   DL = ();
@@ -639,9 +639,9 @@
   if (F.hasPersonalityFn() &&
   

[clang-tools-extra] f8a463c - As part of using inclusive language within the llvm project,

2020-06-19 Thread Eric Christopher via cfe-commits

Author: Eric Christopher
Date: 2020-06-19T15:43:51-07:00
New Revision: f8a463c170964bff7e239bb8268a4927a4547d3c

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

LOG: As part of using inclusive language within the llvm project,
migrate away from the use of blacklist and whitelist.

Added: 


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

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.cpp 
b/clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.cpp
index 08f817a4eeab..0a3861e79a3d 100644
--- a/clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.cpp
@@ -712,7 +712,7 @@ bool 
ForLoopIndexUseVisitor::TraverseArraySubscriptExpr(ArraySubscriptExpr *E) {
 /// If we encounter a reference to IndexVar in an unpruned branch of the
 /// traversal, mark this loop as unconvertible.
 ///
-/// This implements the whitelist for convertible loops: any usages of IndexVar
+/// This implements inclusions for convertible loops: any usages of IndexVar
 /// not explicitly considered convertible by this traversal will be caught by
 /// this function.
 ///



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


[clang-tools-extra] 937c135 - As part of using inclusive language within the llvm project,

2020-06-19 Thread Eric Christopher via cfe-commits

Author: Eric Christopher
Date: 2020-06-19T15:41:06-07:00
New Revision: 937c135dd57e86ccd3fd64ca7b07915a75157986

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

LOG: As part of using inclusive language within the llvm project,
migrate away from the use of blacklist and whitelist.

Added: 


Modified: 
clang-tools-extra/clangd/QueryDriverDatabase.cpp
clang-tools-extra/clangd/XRefs.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/QueryDriverDatabase.cpp 
b/clang-tools-extra/clangd/QueryDriverDatabase.cpp
index ba3aa0d66741..9d731f5563cf 100644
--- a/clang-tools-extra/clangd/QueryDriverDatabase.cpp
+++ b/clang-tools-extra/clangd/QueryDriverDatabase.cpp
@@ -27,7 +27,7 @@
 // First argument of the command line received from underlying compilation
 // database is used as compiler driver path. Due to this arbitrary binary
 // execution, this mechanism is not used by default and only executes binaries
-// in the paths that are explicitly whitelisted by the user.
+// in the paths that are explicitly included by the user.
 
 #include "GlobalCompilationDatabase.h"
 #include "support/Logger.h"
@@ -94,7 +94,7 @@ extractSystemIncludes(PathRef Driver, llvm::StringRef Lang,
   SPAN_ATTACH(Tracer, "lang", Lang);
 
   if (!QueryDriverRegex.match(Driver)) {
-vlog("System include extraction: not whitelisted driver {0}", Driver);
+vlog("System include extraction: not allowed driver {0}", Driver);
 return {};
   }
 

diff  --git a/clang-tools-extra/clangd/XRefs.cpp 
b/clang-tools-extra/clangd/XRefs.cpp
index 6aa031541846..a7bbfd4f967c 100644
--- a/clang-tools-extra/clangd/XRefs.cpp
+++ b/clang-tools-extra/clangd/XRefs.cpp
@@ -363,8 +363,8 @@ locateSymbolTextually(const SpelledWord , ParsedAST 
,
   if ((Word.ExpandedToken && !isDependentName(NodeKind)) ||
   !Word.LikelyIdentifier || !Index)
 return {};
-  // We don't want to handle words in string literals. It'd be nice to 
whitelist
-  // comments instead, but they're not retained in TokenBuffer.
+  // We don't want to handle words in string literals. It'd be nice to include
+  // comments, but they're not retained in TokenBuffer.
   if (Word.PartOfSpelledToken &&
   isStringLiteral(Word.PartOfSpelledToken->kind()))
 return {};
@@ -469,8 +469,8 @@ const syntax::Token *findNearbyIdentifier(const SpelledWord 
,
   // Unlikely identifiers are OK if they were used as identifiers nearby.
   if (Word.ExpandedToken)
 return nullptr;
-  // We don't want to handle words in string literals. It'd be nice to 
whitelist
-  // comments instead, but they're not retained in TokenBuffer.
+  // We don't want to handle words in string literals. It'd be nice to include
+  // comments, but they're not retained in TokenBuffer.
   if (Word.PartOfSpelledToken &&
   isStringLiteral(Word.PartOfSpelledToken->kind()))
 return {};



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


[clang-tools-extra] f92011d - As part of using inclusive language within the llvm project,

2020-06-19 Thread Eric Christopher via cfe-commits

Author: Eric Christopher
Date: 2020-06-19T15:12:18-07:00
New Revision: f92011d875cfdca1ed97bf0ab6956364c604b578

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

LOG: As part of using inclusive language within the llvm project,
migrate away from the use of blacklist and whitelist.

Added: 


Modified: 
clang-tools-extra/clangd/CodeComplete.cpp
clang-tools-extra/clangd/Diagnostics.cpp
clang-tools-extra/clangd/Hover.cpp
clang-tools-extra/clangd/refactor/Rename.cpp
clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp
clang-tools-extra/clangd/unittests/RenameTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/CodeComplete.cpp 
b/clang-tools-extra/clangd/CodeComplete.cpp
index f69424c63be1..f79033ac9514 100644
--- a/clang-tools-extra/clangd/CodeComplete.cpp
+++ b/clang-tools-extra/clangd/CodeComplete.cpp
@@ -675,8 +675,8 @@ static bool isInjectedClass(const NamedDecl ) {
   return false;
 }
 
-// Some member calls are blacklisted because they're so rarely useful.
-static bool isBlacklistedMember(const NamedDecl ) {
+// Some member calls are excluded because they're so rarely useful.
+static bool isExcludedMember(const NamedDecl ) {
   // Destructor completion is rarely useful, and works inconsistently.
   // (s.^ completes ~string, but s.~st^ is an error).
   if (D.getKind() == Decl::CXXDestructor)
@@ -759,7 +759,7 @@ struct CompletionRecorder : public CodeCompleteConsumer {
 continue;
   if (Result.Declaration &&
   !Context.getBaseType().isNull() // is this a member-access context?
-  && isBlacklistedMember(*Result.Declaration))
+  && isExcludedMember(*Result.Declaration))
 continue;
   // Skip injected class name when no class scope is not explicitly set.
   // E.g. show injected A::A in `using A::A^` but not in "A^".

diff  --git a/clang-tools-extra/clangd/Diagnostics.cpp 
b/clang-tools-extra/clangd/Diagnostics.cpp
index da554ff8c331..674fa0dbf9ec 100644
--- a/clang-tools-extra/clangd/Diagnostics.cpp
+++ b/clang-tools-extra/clangd/Diagnostics.cpp
@@ -76,7 +76,7 @@ bool mentionsMainFile(const Diag ) {
   return false;
 }
 
-bool isBlacklisted(const Diag ) {
+bool isExcluded(const Diag ) {
   // clang will always fail parsing MS ASM, we don't link in desc + asm parser.
   if (D.ID == clang::diag::err_msasm_unable_to_create_target ||
   D.ID == clang::diag::err_msasm_unsupported_arch)
@@ -738,7 +738,7 @@ void StoreDiags::flushLastDiag() {
 LastDiag.reset();
   });
 
-  if (isBlacklisted(*LastDiag))
+  if (isExcluded(*LastDiag))
 return;
   // Move errors that occur from headers into main file.
   if (!LastDiag->InsideMainFile && LastDiagLoc && LastDiagOriginallyError) {

diff  --git a/clang-tools-extra/clangd/Hover.cpp 
b/clang-tools-extra/clangd/Hover.cpp
index 1cc564be5cf5..2861d63d4d00 100644
--- a/clang-tools-extra/clangd/Hover.cpp
+++ b/clang-tools-extra/clangd/Hover.cpp
@@ -580,7 +580,7 @@ HoverInfo getHoverContents(const DefinedMacro , 
ParsedAST ) {
 
 bool isLiteral(const Expr *E) {
   // Unfortunately there's no common base Literal classes inherits from
-  // (apart from Expr), therefore this is a nasty blacklist.
+  // (apart from Expr), therefore these exclusions.
   return llvm::isa(E) || llvm::isa(E) ||
  llvm::isa(E) ||
  llvm::isa(E) ||

diff  --git a/clang-tools-extra/clangd/refactor/Rename.cpp 
b/clang-tools-extra/clangd/refactor/Rename.cpp
index c08f6ea805aa..ea75de6e86ea 100644
--- a/clang-tools-extra/clangd/refactor/Rename.cpp
+++ b/clang-tools-extra/clangd/refactor/Rename.cpp
@@ -98,10 +98,10 @@ llvm::DenseSet locateDeclAt(ParsedAST 
,
   return Result;
 }
 
-// By default, we blacklist C++ standard symbols and protobuf symbols as rename
+// By default, we exclude C++ standard symbols and protobuf symbols as rename
 // these symbols would change system/generated files which are unlikely to be
 // modified.
-bool isBlacklisted(const NamedDecl ) {
+bool isExcluded(const NamedDecl ) {
   if (isProtoFile(RenameDecl.getLocation(),
   RenameDecl.getASTContext().getSourceManager()))
 return true;
@@ -138,7 +138,7 @@ llvm::Optional renameable(const NamedDecl 
,
   if (RenameDecl.getParentFunctionOrMethod())
 return None;
 
-  if (isBlacklisted(RenameDecl))
+  if (isExcluded(RenameDecl))
 return ReasonToReject::UnsupportedSymbol;
 
   // Check whether the symbol being rename is indexable.

diff  --git a/clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp 
b/clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp
index 69bfe6731418..104f8ba63dd0 100644
--- a/clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp
+++ b/clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp
@@ -339,7 +339,7 @@ const 

[PATCH] D71739: [AssumeBundles] Use operand bundles to encode alignment assumptions

2020-06-19 Thread Tyker via Phabricator via cfe-commits
Tyker updated this revision to Diff 272194.
Tyker added a comment.

sorry for not doing much recently.

i split with an NFC patch with only test updates.
and addressed comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71739

Files:
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/test/CodeGen/align_value.cpp
  clang/test/CodeGen/alloc-align-attr.c
  clang/test/CodeGen/assume-aligned-and-alloc-align-attributes.c
  clang/test/CodeGen/builtin-align-array.c
  clang/test/CodeGen/builtin-align.c
  clang/test/CodeGen/builtin-assume-aligned.c
  
clang/test/CodeGen/catch-alignment-assumption-attribute-align_value-on-lvalue.cpp
  
clang/test/CodeGen/catch-alignment-assumption-attribute-align_value-on-paramvar.cpp
  
clang/test/CodeGen/catch-alignment-assumption-attribute-alloc_align-on-function-variable.cpp
  
clang/test/CodeGen/catch-alignment-assumption-attribute-alloc_align-on-function.cpp
  
clang/test/CodeGen/catch-alignment-assumption-attribute-assume_aligned-on-function-two-params.cpp
  
clang/test/CodeGen/catch-alignment-assumption-attribute-assume_aligned-on-function.cpp
  
clang/test/CodeGen/catch-alignment-assumption-builtin_assume_aligned-three-params-variable.cpp
  
clang/test/CodeGen/catch-alignment-assumption-builtin_assume_aligned-three-params.cpp
  
clang/test/CodeGen/catch-alignment-assumption-builtin_assume_aligned-two-params.cpp
  clang/test/CodeGen/catch-alignment-assumption-openmp.cpp
  clang/test/CodeGen/non-power-of-2-alignment-assumptions.c
  clang/test/OpenMP/simd_codegen.cpp
  clang/test/OpenMP/simd_metadata.c
  clang/test/OpenMP/target_teams_distribute_parallel_for_simd_codegen.cpp
  llvm/include/llvm/IR/IRBuilder.h
  llvm/lib/Analysis/AssumeBundleQueries.cpp
  llvm/lib/IR/IRBuilder.cpp
  llvm/lib/IR/Verifier.cpp
  llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
  llvm/lib/Transforms/Scalar/AlignmentFromAssumptions.cpp
  llvm/test/Transforms/AlignmentFromAssumptions/simple.ll
  llvm/test/Transforms/AlignmentFromAssumptions/simple32.ll
  llvm/test/Transforms/Inline/align.ll
  llvm/test/Transforms/InstCombine/assume.ll
  llvm/test/Transforms/PhaseOrdering/inlining-alignment-assumptions.ll
  llvm/test/Verifier/assume-bundles.ll
  llvm/unittests/Analysis/AssumeBundleQueriesTest.cpp

Index: llvm/unittests/Analysis/AssumeBundleQueriesTest.cpp
===
--- llvm/unittests/Analysis/AssumeBundleQueriesTest.cpp
+++ llvm/unittests/Analysis/AssumeBundleQueriesTest.cpp
@@ -546,3 +546,41 @@
   ASSERT_EQ(AR[0].Index, 1u);
   ASSERT_EQ(AR[0].Assume, &*First);
 }
+
+TEST(AssumeQueryAPI, Alignment) {
+  LLVMContext C;
+  SMDiagnostic Err;
+  std::unique_ptr Mod = parseAssemblyString(
+  "declare void @llvm.assume(i1)\n"
+  "define void @test(i32* %P, i32* %P1, i32* %P2, i32 %I3, i1 %B) {\n"
+  "call void @llvm.assume(i1 true) [\"align\"(i32* %P, i32 8, i32 %I3)]\n"
+  "call void @llvm.assume(i1 true) [\"align\"(i32* %P1, i32 %I3, i32 "
+  "%I3)]\n"
+  "call void @llvm.assume(i1 true) [\"align\"(i32* %P2, i32 16, i32 8)]\n"
+  "ret void\n}\n",
+  Err, C);
+  if (!Mod)
+Err.print("AssumeQueryAPI", errs());
+
+  Function *F = Mod->getFunction("test");
+  BasicBlock::iterator Start = F->begin()->begin();
+  IntrinsicInst *II;
+  RetainedKnowledge RK;
+  II = cast(&*Start);
+  RK = getKnowledgeFromBundle(*II, II->bundle_op_info_begin()[0]);
+  ASSERT_EQ(RK.AttrKind, Attribute::Alignment);
+  ASSERT_EQ(RK.WasOn, F->getArg(0));
+  ASSERT_EQ(RK.ArgValue, 1u);
+  Start++;
+  II = cast(&*Start);
+  RK = getKnowledgeFromBundle(*II, II->bundle_op_info_begin()[0]);
+  ASSERT_EQ(RK.AttrKind, Attribute::Alignment);
+  ASSERT_EQ(RK.WasOn, F->getArg(1));
+  ASSERT_EQ(RK.ArgValue, 1u);
+  Start++;
+  II = cast(&*Start);
+  RK = getKnowledgeFromBundle(*II, II->bundle_op_info_begin()[0]);
+  ASSERT_EQ(RK.AttrKind, Attribute::Alignment);
+  ASSERT_EQ(RK.WasOn, F->getArg(2));
+  ASSERT_EQ(RK.ArgValue, 8u);
+}
Index: llvm/test/Verifier/assume-bundles.ll
===
--- llvm/test/Verifier/assume-bundles.ll
+++ llvm/test/Verifier/assume-bundles.ll
@@ -1,3 +1,4 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
 ; RUN: not opt -verify < %s 2>&1 | FileCheck %s
 
 declare void @llvm.assume(i1)
@@ -6,14 +7,21 @@
 ; CHECK: tags must be valid attribute names
   call void @llvm.assume(i1 true) ["adazdazd"()]
 ; CHECK: the second argument should be a constant integral value
-  call void @llvm.assume(i1 true) ["align"(i32* %P, i32 %P1)]
+  call void @llvm.assume(i1 true) ["dereferenceable"(i32* %P, i32 %P1)]
 ; CHECK: to many arguments
-  call void @llvm.assume(i1 true) ["align"(i32* %P, i32 8, i32 8)]
+  call void @llvm.assume(i1 true) ["dereferenceable"(i32* %P, i32 8, i32 8)]
 ; CHECK: this attribute should have 2 arguments
-  call void @llvm.assume(i1 true) 

[PATCH] D82244: [SanitizeCoverage] Rename -fsanitize-coverage-{white,black}list to -fsanitize-coverage-{allow,block}list

2020-06-19 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 272193.
MaskRay added a comment.

Update more files


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82244

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/docs/SanitizerCoverage.rst
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/SanitizerArgs.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  
compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_whitelist_blacklist.cpp

Index: compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_whitelist_blacklist.cpp
===
--- compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_whitelist_blacklist.cpp
+++ compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_whitelist_blacklist.cpp
@@ -1,5 +1,5 @@
-// Tests -fsanitize-coverage-whitelist=whitelist.txt and
-// -fsanitize-coverage-blacklist=blacklist.txt with libFuzzer-like coverage
+// Tests -fsanitize-coverage-allowlist=whitelist.txt and
+// -fsanitize-coverage-blocklist=blacklist.txt with libFuzzer-like coverage
 // options
 
 // REQUIRES: has_sancovcc,stable-runtime
@@ -38,53 +38,53 @@
 // RUN: echo 'section "__sancov_pcs"'   >> patterns.txt
 
 // RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table  2>&1 | grep -f patterns.txt | count 14
-// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fsanitize-coverage-whitelist=wl_all.txt 2>&1 | grep -f patterns.txt | count 14
-// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fsanitize-coverage-whitelist=wl_none.txt2>&1 | not grep -f patterns.txt
-// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fsanitize-coverage-whitelist=wl_file.txt2>&1 | grep -f patterns.txt | count 14
-// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fsanitize-coverage-whitelist=wl_foo.txt 2>&1 | grep -f patterns.txt | count 9
-// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fsanitize-coverage-whitelist=wl_bar.txt 2>&1 | grep -f patterns.txt | count 5
+// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fsanitize-coverage-allowlist=wl_all.txt 2>&1 | grep -f patterns.txt | count 14
+// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fsanitize-coverage-allowlist=wl_none.txt2>&1 | not grep -f patterns.txt
+// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fsanitize-coverage-allowlist=wl_file.txt2>&1 | grep -f patterns.txt | count 14
+// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fsanitize-coverage-allowlist=wl_foo.txt 2>&1 | grep -f patterns.txt | count 9
+// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fsanitize-coverage-allowlist=wl_bar.txt 2>&1 | grep -f patterns.txt | count 5
 
-// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table   -fsanitize-coverage-blacklist=bl_all.txt   2>&1 | not grep -f patterns.txt
-// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fsanitize-coverage-whitelist=wl_all.txt  -fsanitize-coverage-blacklist=bl_all.txt   2>&1 | not grep -f patterns.txt
-// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fsanitize-coverage-whitelist=wl_none.txt -fsanitize-coverage-blacklist=bl_all.txt   2>&1 | not grep -f patterns.txt
-// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table 

[PATCH] D80055: Diagnose union tail padding

2020-06-19 Thread JF Bastien via Phabricator via cfe-commits
jfb abandoned this revision.
jfb added a comment.

I've gotten what I wanted out of this (diagnosed a particular codebase), and am 
not sure it's worth pursuing further. If anyone is interested, please let me 
know.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80055



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


[PATCH] D82244: [SanitizeCoverage] Rename -fsanitize-coverage-{white,black}list to -fsanitize-coverage-{allow,block}list

2020-06-19 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay created this revision.
MaskRay added reviewers: echristo, mehdi_amini, morehouse.
Herald added subscribers: Sanitizers, cfe-commits, aaron.ballman.
Herald added projects: clang, Sanitizers.
MaskRay updated this revision to Diff 272193.
MaskRay added a comment.

Update more files


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82244

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/docs/SanitizerCoverage.rst
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/SanitizerArgs.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  
compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_whitelist_blacklist.cpp

Index: compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_whitelist_blacklist.cpp
===
--- compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_whitelist_blacklist.cpp
+++ compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_whitelist_blacklist.cpp
@@ -1,5 +1,5 @@
-// Tests -fsanitize-coverage-whitelist=whitelist.txt and
-// -fsanitize-coverage-blacklist=blacklist.txt with libFuzzer-like coverage
+// Tests -fsanitize-coverage-allowlist=whitelist.txt and
+// -fsanitize-coverage-blocklist=blacklist.txt with libFuzzer-like coverage
 // options
 
 // REQUIRES: has_sancovcc,stable-runtime
@@ -38,53 +38,53 @@
 // RUN: echo 'section "__sancov_pcs"'   >> patterns.txt
 
 // RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table  2>&1 | grep -f patterns.txt | count 14
-// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fsanitize-coverage-whitelist=wl_all.txt 2>&1 | grep -f patterns.txt | count 14
-// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fsanitize-coverage-whitelist=wl_none.txt2>&1 | not grep -f patterns.txt
-// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fsanitize-coverage-whitelist=wl_file.txt2>&1 | grep -f patterns.txt | count 14
-// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fsanitize-coverage-whitelist=wl_foo.txt 2>&1 | grep -f patterns.txt | count 9
-// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fsanitize-coverage-whitelist=wl_bar.txt 2>&1 | grep -f patterns.txt | count 5
+// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fsanitize-coverage-allowlist=wl_all.txt 2>&1 | grep -f patterns.txt | count 14
+// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fsanitize-coverage-allowlist=wl_none.txt2>&1 | not grep -f patterns.txt
+// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fsanitize-coverage-allowlist=wl_file.txt2>&1 | grep -f patterns.txt | count 14
+// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fsanitize-coverage-allowlist=wl_foo.txt 2>&1 | grep -f patterns.txt | count 9
+// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fsanitize-coverage-allowlist=wl_bar.txt 2>&1 | grep -f patterns.txt | count 5
 
-// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table   -fsanitize-coverage-blacklist=bl_all.txt   2>&1 | not grep -f patterns.txt
-// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fsanitize-coverage-whitelist=wl_all.txt  -fsanitize-coverage-blacklist=bl_all.txt   2>&1 | not grep -f patterns.txt
-// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fsanitize-coverage-whitelist=wl_none.txt -fsanitize-coverage-blacklist=bl_all.txt   2>&1 | not grep -f patterns.txt
-// RUN: 

[PATCH] D82020: PowerPC-specific builtin constrained FP enablement

2020-06-19 Thread Andrew J Wock via Phabricator via cfe-commits
ajwock updated this revision to Diff 272186.
ajwock added a comment.

Took steven.zhang's suggestion, added REQUIRES line to diff.  Hopefully 
addressed harbormaster concerns.


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

https://reviews.llvm.org/D82020

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/builtins-ppc-fpconstrained.c

Index: clang/test/CodeGen/builtins-ppc-fpconstrained.c
===
--- /dev/null
+++ clang/test/CodeGen/builtins-ppc-fpconstrained.c
@@ -0,0 +1,167 @@
+// REQUIRES: powerpc-registered-target
+// RUN: %clang_cc1 -triple powerpc64le-gnu-linux -target-feature +vsx \
+// RUN: -disable-O0-optnone -Wall -Wno-unused -Werror -emit-llvm %s -o - | \
+// RUN: FileCheck --check-prefix=CHECK-UNCONSTRAINED -vv %s
+// RUN: %clang_cc1 -triple powerpc64le-gnu-linux -target-feature +vsx \
+// RUN: -disable-O0-optnone -ffp-exception-behavior=strict -Wall \
+// RUN: -Wno-unused -Werror -emit-llvm %s -o - | FileCheck \
+// RUN: --check-prefix=CHECK-CONSTRAINED -vv %s
+// RUN: %clang_cc1 -triple powerpc64le-gnu-linux -target-feature +vsx \
+// RUN: -disable-O0-optnone -fallow-half-arguments-and-returns -S -o - %s | \
+// RUN: FileCheck --check-prefix=CHECK-ASM --check-prefix=NOT-FIXME-CHECK  %s
+// RUN: %clang_cc1 -triple powerpc64le-gnu-linux -target-feature +vsx \
+// RUN: -disable-O0-optnone -fallow-half-arguments-and-returns -S \
+// RUN: -ffp-exception-behavior=strict  -o - %s | FileCheck \
+// RUN: --check-prefix=CHECK-ASM --check-prefix=FIXME-CHECK  %s
+
+typedef __attribute__((vector_size(4 * sizeof(float float vec_float;
+typedef __attribute__((vector_size(2 * sizeof(double double vec_double;
+
+volatile vec_double vd;
+volatile vec_float vf;
+
+void test_float(void) {
+  vf = __builtin_vsx_xvsqrtsp(vf);
+  // CHECK-LABEL: try-xvsqrtsp
+  // CHECK-UNCONSTRAINED: @llvm.sqrt.v4f32(<4 x float> %{{.*}})
+  // CHECK-CONSTRAINED: @llvm.experimental.constrained.sqrt.v4f32(<4 x float> %{{.*}}, metadata !"round.tonearest", metadata !"fpexcept.strict")
+  // CHECK-ASM: xvsqrtsp
+
+  vd = __builtin_vsx_xvsqrtdp(vd);
+  // CHECK-LABEL: try-xvsqrtdp
+  // CHECK-UNCONSTRAINED: @llvm.sqrt.v2f64(<2 x double> %{{.*}})
+  // CHECK-CONSTRAINED: @llvm.experimental.constrained.sqrt.v2f64(<2 x double> %{{.*}}, metadata !"round.tonearest", metadata !"fpexcept.strict")
+  // CHECK-ASM: xvsqrtdp
+
+  vf = __builtin_vsx_xvrspim(vf);
+  // CHECK-LABEL: try-xvrspim
+  // CHECK-UNCONSTRAINED: @llvm.floor.v4f32(<4 x float> %{{.*}})
+  // CHECK-CONSTRAINED: @llvm.experimental.constrained.floor.v4f32(<4 x float> %{{.*}}, metadata !"fpexcept.strict")
+  // CHECK-ASM: xvrspim
+
+  vd = __builtin_vsx_xvrdpim(vd);
+  // CHECK-LABEL: try-xvrdpim
+  // CHECK-UNCONSTRAINED: @llvm.floor.v2f64(<2 x double> %{{.*}})
+  // CHECK-CONSTRAINED: @llvm.experimental.constrained.floor.v2f64(<2 x double> %{{.*}}, metadata !"fpexcept.strict")
+  // CHECK-ASM: xvrdpim
+
+  vf = __builtin_vsx_xvrspi(vf);
+  // CHECK-LABEL: try-xvrspi
+  // CHECK-UNCONSTRAINED: @llvm.round.v4f32(<4 x float> %{{.*}})
+  // CHECK-CONSTRAINED: @llvm.experimental.constrained.round.v4f32(<4 x float> %{{.*}}, metadata !"fpexcept.strict")
+  // CHECK-ASM: xvrspi
+
+  vd = __builtin_vsx_xvrdpi(vd);
+  // CHECK-LABEL: try-xvrdpi
+  // CHECK-UNCONSTRAINED: @llvm.round.v2f64(<2 x double> %{{.*}})
+  // CHECK-CONSTRAINED: @llvm.experimental.constrained.round.v2f64(<2 x double> %{{.*}}, metadata !"fpexcept.strict")
+  // CHECK-ASM: xvrdpi
+
+  vf = __builtin_vsx_xvrspic(vf);
+  // CHECK-LABEL: try-xvrspic
+  // CHECK-UNCONSTRAINED: @llvm.nearbyint.v4f32(<4 x float> %{{.*}})
+  // CHECK-CONSTRAINED: @llvm.experimental.constrained.nearbyint.v4f32(<4 x float> %{{.*}}, metadata !"round.tonearest", metadata !"fpexcept.strict")
+  // NO-FIXME-CHECK: xvrspic
+  // FIXME-CHECK: bl nearbyintf
+  // FIXME-CHECK: bl nearbyintf
+  // FIXME-CHECK: bl nearbyintf
+  // FIXME-CHECK: bl nearbyintf
+
+  vd = __builtin_vsx_xvrdpic(vd);
+  // CHECK-LABEL: try-xvrdpic
+  // CHECK-UNCONSTRAINED: @llvm.nearbyint.v2f64(<2 x double> %{{.*}})
+  // CHECK-CONSTRAINED: @llvm.experimental.constrained.nearbyint.v2f64(<2 x double> %{{.*}}, metadata !"round.tonearest", metadata !"fpexcept.strict")
+  // NO-FIXME-CHECK: xvrdpic
+  // FIXME-CHECK: bl nearbyint
+  // FIXME-CHECK: bl nearbyint
+
+  vf = __builtin_vsx_xvrspip(vf);
+  // CHECK-LABEL: try-xvrspip
+  // CHECK-UNCONSTRAINED: @llvm.ceil.v4f32(<4 x float> %{{.*}})
+  // CHECK-CONSTRAINED: @llvm.experimental.constrained.ceil.v4f32(<4 x float> %{{.*}}, metadata !"fpexcept.strict")
+  // CHECK-ASM: xvrspip
+
+  vd = __builtin_vsx_xvrdpip(vd);
+  // CHECK-LABEL: try-xvrdpip
+  // CHECK-UNCONSTRAINED: @llvm.ceil.v2f64(<2 x double> %{{.*}})
+  // CHECK-CONSTRAINED: @llvm.experimental.constrained.ceil.v2f64(<2 x double> %{{.*}}, metadata !"fpexcept.strict")
+  // CHECK-ASM: xvrdpip
+
+  vf = __builtin_vsx_xvrspiz(vf);
+  // CHECK-LABEL: try-xvrspiz
+  // 

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

2020-06-19 Thread Michael Spencer via Phabricator via cfe-commits
Bigcheese added inline comments.



Comment at: clang/include/clang/Frontend/CompilerInvocation.h:193
+  /// \param [out] Args - The generated arguments. Note that the caller is
+  /// responsible for insersting the path to the clang executable and "-cc1" if
+  /// desired.

inserting



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:160-161
+
+  llvm::report_fatal_error("The simple enum value was not correctly defined in 
"
+   "the tablegen option description");
+}

`llvm::report_fatal_error` is only used for code paths we actually expect to 
potentially be hit. For programming errors we instead use `assert` or 
`llvm_unreachable`. See 
https://llvm.org/docs/ProgrammersManual.html#error-handling .



Comment at: llvm/utils/TableGen/OptParserEmitter.cpp:430-440
+  std::vector> OptsWithMarshalling;
+  for (unsigned I = 0, E = Opts.size(); I != E; ++I) {
+const Record  = *Opts[I];
 
+// Start a single option entry.
+OS << "OPTION(";
+WriteOptRecordFields(OS, R);

Just to verify, this doesn't change the output for options that don't have 
marshalling info, right? Just want to make sure this doesn't change anything 
for other users of libOption.



Comment at: llvm/utils/TableGen/OptParserEmitter.cpp:468-469
+  OS << "};\n";
+  OS << "static const unsigned SimpleEnumValueTablesSize = "
+"sizeof(SimpleEnumValueTables) / sizeof(SimpleEnumValueTable);\n";
+

What happens if there are none?


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] D67321: Respect CLANG_LINK_CLANG_DYLIB=ON in libclang and c-index-test

2020-06-19 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert added a comment.

Yup, `c-index-test` crashing was one of the motivators behind this.

I think this should handle all cases. I tried it with `CLANG_LINK_CLANG_DYLIB` 
on/off combined with shared/static/shared+static libraries and inspected the 
generated `build.ninja`, which looked about right in all cases. (I didn't take 
the time to run those 6 builds though.)

Since we're just imitating `llvm_add_library` I think it's even theoretically 
right.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67321



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


[PATCH] D78655: [CUDA][HIP] Let non-caputuring lambda be host device

2020-06-19 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 272171.
yaxunl retitled this revision from "[HIP] Add -fhip-lambda-host-device" to 
"[CUDA][HIP] Let non-caputuring lambda be host device".
yaxunl edited the summary of this revision.
yaxunl added a comment.

Revised by Richard's comments.


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

https://reviews.llvm.org/D78655

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaCUDA.cpp
  clang/lib/Sema/SemaLambda.cpp
  clang/test/CodeGenCUDA/lambda.cu
  clang/test/SemaCUDA/Inputs/cuda.h
  clang/test/SemaCUDA/lambda.cu

Index: clang/test/SemaCUDA/lambda.cu
===
--- /dev/null
+++ clang/test/SemaCUDA/lambda.cu
@@ -0,0 +1,53 @@
+// RUN: %clang_cc1 -std=c++17 -fsyntax-only -verify %s
+
+#include "Inputs/cuda.h"
+
+// file-scope lambda is implicitly host device function.
+auto global_lambda = [] () { return 123; };
+
+template
+__global__ void kernel(F f) { f(); }
+// expected-error@-1 6{{no matching function for call to object of type}}
+
+constexpr __host__ __device__ void hd();
+
+int main(void) {
+  auto lambda_kernel = [&]__global__(){};
+  // expected-error@-1 {{kernel function 'operator()' must be a free function or static member function}}
+
+  int b;
+  kernel<<<1,1>>>(global_lambda);
+
+  kernel<<<1,1>>>([](){ hd(); });
+
+  kernel<<<1,1>>>([=](){ hd(); });
+  // expected-note@-1 {{in instantiation of function template specialization 'kernel<(lambda at}}
+  // expected-note@-2 {{candidate function not viable: call to __host__ function from __global__ function}}
+
+  kernel<<<1,1>>>([b](){ hd(); });
+  // expected-note@-1 {{in instantiation of function template specialization 'kernel<(lambda at}}
+  // expected-note@-2 {{candidate function not viable: call to __host__ function from __global__ function}}
+
+  kernel<<<1,1>>>([&]()constexpr{ hd(); });
+  // expected-note@-1 {{in instantiation of function template specialization 'kernel<(lambda at}}
+  // expected-note@-2 {{candidate function not viable: call to __host__ function from __global__ function}}
+
+  kernel<<<1,1>>>([&](){ hd(); });
+  // expected-note@-1 {{in instantiation of function template specialization 'kernel<(lambda at}}
+  // expected-note@-2 {{candidate function not viable: call to __host__ function from __global__ function}}
+
+  kernel<<<1,1>>>([=, ](){ hd(); });
+  // expected-note@-1 {{in instantiation of function template specialization 'kernel<(lambda at}}
+  // expected-note@-2 {{candidate function not viable: call to __host__ function from __global__ function}}
+
+  kernel<<<1,1>>>([&, b](){ hd(); });
+  // expected-note@-1 {{in instantiation of function template specialization 'kernel<(lambda at}}
+  // expected-note@-2 {{candidate function not viable: call to __host__ function from __global__ function}}
+
+  kernel<<<1,1>>>([](){
+  auto f = [&]{ hd(); };
+  f();
+  });
+
+  return 0;
+}
Index: clang/test/SemaCUDA/Inputs/cuda.h
===
--- clang/test/SemaCUDA/Inputs/cuda.h
+++ clang/test/SemaCUDA/Inputs/cuda.h
@@ -17,6 +17,19 @@
   __host__ __device__ dim3(unsigned x, unsigned y = 1, unsigned z = 1) : x(x), y(y), z(z) {}
 };
 
+#ifdef __HIP__
+typedef struct hipStream *hipStream_t;
+typedef enum hipError {} hipError_t;
+int hipConfigureCall(dim3 gridSize, dim3 blockSize, size_t sharedSize = 0,
+ hipStream_t stream = 0);
+extern "C" hipError_t __hipPushCallConfiguration(dim3 gridSize, dim3 blockSize,
+ size_t sharedSize = 0,
+ hipStream_t stream = 0);
+extern "C" hipError_t hipLaunchKernel(const void *func, dim3 gridDim,
+  dim3 blockDim, void **args,
+  size_t sharedMem,
+  hipStream_t stream);
+#else
 typedef struct cudaStream *cudaStream_t;
 typedef enum cudaError {} cudaError_t;
 
@@ -29,6 +42,7 @@
 extern "C" cudaError_t cudaLaunchKernel(const void *func, dim3 gridDim,
 dim3 blockDim, void **args,
 size_t sharedMem, cudaStream_t stream);
+#endif
 
 // Host- and device-side placement new overloads.
 void *operator new(__SIZE_TYPE__, void *p) { return p; }
Index: clang/test/CodeGenCUDA/lambda.cu
===
--- /dev/null
+++ clang/test/CodeGenCUDA/lambda.cu
@@ -0,0 +1,85 @@
+// RUN: %clang_cc1 -x hip -emit-llvm -std=c++11 %s -o - \
+// RUN:   -triple x86_64-linux-gnu \
+// RUN:   | FileCheck -check-prefix=HOST %s
+// RUN: %clang_cc1 -x hip -emit-llvm -std=c++11 %s -o - \
+// RUN:   -triple amdgcn-amd-amdhsa -fcuda-is-device \
+// RUN:   | FileCheck -check-prefix=DEV %s
+
+#include "Inputs/cuda.h"
+
+// Device side kernel name.
+// HOST: @[[KERN_CAPTURE:[0-9]+]] = {{.*}} 

[PATCH] D82231: [NFC] Remove unused pass name parser classes

2020-06-19 Thread Arthur Eubanks via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2565581e3704: [NFC] Remove unused pass name parser classes 
(authored by aeubanks).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82231

Files:
  llvm/include/llvm/IR/LegacyPassNameParser.h


Index: llvm/include/llvm/IR/LegacyPassNameParser.h
===
--- llvm/include/llvm/IR/LegacyPassNameParser.h
+++ llvm/include/llvm/IR/LegacyPassNameParser.h
@@ -92,47 +92,6 @@
   }
 };
 
-///===--===//
-/// FilteredPassNameParser class - Make use of the pass registration
-/// mechanism to automatically add a command line argument to opt for
-/// each pass that satisfies a filter criteria.  Filter should return
-/// true for passes to be registered as command-line options.
-///
-template
-class FilteredPassNameParser : public PassNameParser {
-private:
-  Filter filter;
-
-public:
-  bool ignorablePassImpl(const PassInfo *P) const override {
-return !filter(*P);
-  }
-};
-
-///===--===//
-/// PassArgFilter - A filter for use with PassNameFilterParser that only
-/// accepts a Pass whose Arg matches certain strings.
-///
-/// Use like this:
-///
-/// extern const char AllowedPassArgs[] = "-anders_aa -dse";
-///
-/// static cl::list<
-///   const PassInfo*,
-///   bool,
-///   FilteredPassNameParser > >
-/// PassList(cl::desc("Passes available:"));
-///
-/// Only the -anders_aa and -dse options will be available to the user.
-///
-template
-class PassArgFilter {
-public:
-  bool operator()(const PassInfo ) const {
-return StringRef(Args).contains(P.getPassArgument());
-  }
-};
-
 } // End llvm namespace
 
 #endif


Index: llvm/include/llvm/IR/LegacyPassNameParser.h
===
--- llvm/include/llvm/IR/LegacyPassNameParser.h
+++ llvm/include/llvm/IR/LegacyPassNameParser.h
@@ -92,47 +92,6 @@
   }
 };
 
-///===--===//
-/// FilteredPassNameParser class - Make use of the pass registration
-/// mechanism to automatically add a command line argument to opt for
-/// each pass that satisfies a filter criteria.  Filter should return
-/// true for passes to be registered as command-line options.
-///
-template
-class FilteredPassNameParser : public PassNameParser {
-private:
-  Filter filter;
-
-public:
-  bool ignorablePassImpl(const PassInfo *P) const override {
-return !filter(*P);
-  }
-};
-
-///===--===//
-/// PassArgFilter - A filter for use with PassNameFilterParser that only
-/// accepts a Pass whose Arg matches certain strings.
-///
-/// Use like this:
-///
-/// extern const char AllowedPassArgs[] = "-anders_aa -dse";
-///
-/// static cl::list<
-///   const PassInfo*,
-///   bool,
-///   FilteredPassNameParser > >
-/// PassList(cl::desc("Passes available:"));
-///
-/// Only the -anders_aa and -dse options will be available to the user.
-///
-template
-class PassArgFilter {
-public:
-  bool operator()(const PassInfo ) const {
-return StringRef(Args).contains(P.getPassArgument());
-  }
-};
-
 } // End llvm namespace
 
 #endif
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D81408: [builtins] Improve compatibility with 16 bit targets

2020-06-19 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

> Those flaky test failures seems to be due to ld.lld being not built from 
> source as part of testing compiler-rt/-only patches.

That should be something we can fix in the build system.  
compiler-rt/test/CMakeLists.txt has a list of executables which the tests 
depend on. If that list isn't complete, it should be updated.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81408



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


[PATCH] D82141: [sve][acle] Add SVE BFloat16 extensions.

2020-06-19 Thread Francesco Petrogalli via Phabricator via cfe-commits
fpetrogalli updated this revision to Diff 272170.
fpetrogalli marked 7 inline comments as done.
fpetrogalli added a comment.

Thank you for the review @sdesmalen!

Francesco


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82141

Files:
  clang/include/clang/Basic/arm_sve.td
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_bfdot.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_bfmlalb.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_bfmlalt.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_bfmmla.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cvt-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cvtnt.c
  clang/utils/TableGen/SveEmitter.cpp
  llvm/include/llvm/IR/IntrinsicsAArch64.td
  llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
  llvm/lib/Target/AArch64/SVEInstrFormats.td
  llvm/test/CodeGen/AArch64/sve-intrinsics-bfloat.ll

Index: llvm/test/CodeGen/AArch64/sve-intrinsics-bfloat.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/sve-intrinsics-bfloat.ll
@@ -0,0 +1,243 @@
+; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve,+bf16 -asm-verbose=0 < %s | FileCheck %s
+
+;
+; BFDOT
+;
+
+define  @bfdot_f32( %a,  %b,  %c) nounwind {
+; CHECK-LABEL: bfdot_f32:
+; CHECK-NEXT:  bfdot z0.s, z1.h, z2.h
+; CHECK-NEXT:  ret
+  %out = call  @llvm.aarch64.sve.bfdot( %a,  %b,  %c)
+  ret  %out
+}
+
+define  @bfdot_lane_0_f32( %a,  %b,  %c) nounwind {
+; CHECK-LABEL: bfdot_lane_0_f32:
+; CHECK-NEXT:  bfdot z0.s, z1.h, z2.h[0]
+; CHECK-NEXT:  ret
+  %out = call  @llvm.aarch64.sve.bfdot.lane( %a,  %b,  %c, i64 0)
+  ret  %out
+}
+
+define  @bfdot_lane_1_f32( %a,  %b,  %c) nounwind {
+; CHECK-LABEL: bfdot_lane_1_f32:
+; CHECK-NEXT:  bfdot z0.s, z1.h, z2.h[1]
+; CHECK-NEXT:  ret
+  %out = call  @llvm.aarch64.sve.bfdot.lane( %a,  %b,  %c, i64 1)
+  ret  %out
+}
+
+define  @bfdot_lane_2_f32( %a,  %b,  %c) nounwind {
+; CHECK-LABEL: bfdot_lane_2_f32:
+; CHECK-NEXT:  bfdot z0.s, z1.h, z2.h[2]
+; CHECK-NEXT:  ret
+  %out = call  @llvm.aarch64.sve.bfdot.lane( %a,  %b,  %c, i64 2)
+  ret  %out
+}
+
+define  @bfdot_lane_3_f32( %a,  %b,  %c) nounwind {
+; CHECK-LABEL: bfdot_lane_3_f32:
+; CHECK-NEXT:  bfdot z0.s, z1.h, z2.h[3]
+; CHECK-NEXT:  ret
+  %out = call  @llvm.aarch64.sve.bfdot.lane( %a,  %b,  %c, i64 3)
+  ret  %out
+}
+
+;
+; BFMLALB
+;
+
+define  @bfmlalb_f32( %a,  %b,  %c) nounwind {
+; CHECK-LABEL: bfmlalb_f32:
+; CHECK-NEXT:  bfmlalb z0.s, z1.h, z2.h
+; CHECK-NEXT:  ret
+  %out = call  @llvm.aarch64.sve.bfmlalb( %a,  %b,  %c)
+  ret  %out
+}
+
+define  @bfmlalb_lane_0_f32( %a,  %b,  %c) nounwind {
+; CHECK-LABEL: bfmlalb_lane_0_f32:
+; CHECK-NEXT:  bfmlalb z0.s, z1.h, z2.h[0]
+; CHECK-NEXT:  ret
+  %out = call  @llvm.aarch64.sve.bfmlalb.lane( %a,  %b,  %c, i64 0)
+  ret  %out
+}
+
+define  @bfmlalb_lane_1_f32( %a,  %b,  %c) nounwind {
+; CHECK-LABEL: bfmlalb_lane_1_f32:
+; CHECK-NEXT:  bfmlalb z0.s, z1.h, z2.h[1]
+; CHECK-NEXT:  ret
+  %out = call  @llvm.aarch64.sve.bfmlalb.lane( %a,  %b,  %c, i64 1)
+  ret  %out
+}
+
+define  @bfmlalb_lane_2_f32( %a,  %b,  %c) nounwind {
+; CHECK-LABEL: bfmlalb_lane_2_f32:
+; CHECK-NEXT:  bfmlalb z0.s, z1.h, z2.h[2]
+; CHECK-NEXT:  ret
+  %out = call  @llvm.aarch64.sve.bfmlalb.lane( %a,  %b,  %c, i64 2)
+  ret  %out
+}
+
+define  @bfmlalb_lane_3_f32( %a,  %b,  %c) nounwind {
+; CHECK-LABEL: bfmlalb_lane_3_f32:
+; CHECK-NEXT:  bfmlalb z0.s, z1.h, z2.h[3]
+; CHECK-NEXT:  ret
+  %out = call  @llvm.aarch64.sve.bfmlalb.lane( %a,  %b,  %c, i64 3)
+  ret  %out
+}
+
+define  @bfmlalb_lane_4_f32( %a,  %b,  %c) nounwind {
+; CHECK-LABEL: bfmlalb_lane_4_f32:
+; CHECK-NEXT:  bfmlalb z0.s, z1.h, z2.h[4]
+; CHECK-NEXT:  ret
+  %out = call  @llvm.aarch64.sve.bfmlalb.lane( %a,  %b,  %c, i64 4)
+  ret  %out
+}
+
+define  @bfmlalb_lane_5_f32( %a,  %b,  %c) nounwind {
+; CHECK-LABEL: bfmlalb_lane_5_f32:
+; CHECK-NEXT:  bfmlalb z0.s, z1.h, z2.h[5]
+; CHECK-NEXT:  ret
+  %out = call  @llvm.aarch64.sve.bfmlalb.lane( %a,  %b,  %c, i64 5)
+  ret  %out
+}
+
+define  @bfmlalb_lane_6_f32( %a,  %b,  %c) nounwind {
+; CHECK-LABEL: bfmlalb_lane_6_f32:
+; CHECK-NEXT:  bfmlalb z0.s, z1.h, z2.h[6]
+; CHECK-NEXT:  ret
+  %out = call  @llvm.aarch64.sve.bfmlalb.lane( %a,  %b,  %c, i64 6)
+  ret  %out
+}
+
+define  @bfmlalb_lane_7_f32( %a,  %b,  %c) nounwind {
+; CHECK-LABEL: bfmlalb_lane_7_f32:
+; CHECK-NEXT:  bfmlalb z0.s, z1.h, z2.h[7]
+; CHECK-NEXT:  ret
+  %out = call  @llvm.aarch64.sve.bfmlalb.lane( %a,  %b,  %c, i64 7)
+  ret  %out
+}
+
+;
+; BFMLALT
+;
+
+define  @bfmlalt_f32( %a,  %b,  %c) nounwind {
+; CHECK-LABEL: bfmlalt_f32:
+; CHECK-NEXT:  bfmlalt z0.s, z1.h, z2.h
+; CHECK-NEXT:  ret
+  %out = call  @llvm.aarch64.sve.bfmlalt( %a,  %b,  %c)
+  ret  %out
+}
+
+define  @bfmlalt_lane_0_f32( %a,  %b,  %c) nounwind {
+; CHECK-LABEL: bfmlalt_lane_0_f32:
+; CHECK-NEXT:  bfmlalt z0.s, z1.h, z2.h[0]
+; CHECK-NEXT:  ret
+  %out = 

[PATCH] D82141: [sve][acle] Add SVE BFloat16 extensions.

2020-06-19 Thread Francesco Petrogalli via Phabricator via cfe-commits
fpetrogalli added inline comments.



Comment at: llvm/include/llvm/IR/IntrinsicsAArch64.td:1811
 
+def int_aarch64_sve_cvt_bf16f32 : Builtin_SVCVT<"svcvt_bf16_f32_m",   
llvm_nxv8bf16_ty, llvm_nxv8i1_ty, llvm_nxv4f32_ty>;
+def int_aarch64_sve_cvtnt_bf16f32   : Builtin_SVCVT<"svcvtnt_bf16_f32_m", 
llvm_nxv8bf16_ty, llvm_nxv8i1_ty, llvm_nxv4f32_ty>;

sdesmalen wrote:
> nit:  use `fcvtbf` instead of `cvt` => `int_aarch64_sve_fcvtbf_bf16f32` ?
Renamed to `int_aarch64_sve_fcvt_bf16f32` and `int_aarch64_sve_fcvtnt_bf16f32` 
respectively, because I think it wouldn't make sense to add the `bf` suffix to 
the `cvtnt` version of the intrinsic.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82141



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


[PATCH] D82103: [analyzer] Remove forbidden characters from a SourceLocation filename for a graph dump on Windows

2020-06-19 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov marked an inline comment as done.
ASDenysPetrov added inline comments.



Comment at: clang/utils/analyzer/exploded-graph-rewriter.py:383
+# when directory name starts with the letter `l`.
+if sys.platform == 'win32':
+# Find all `\l` (like `,\l`, `}\l`, `[\l`) except `\\l`,

NoQ wrote:
> I think this too doesn't need to be platform specific(?)
Oh, so sorry! This is a mess. It somehow got here from my another patch. I'll 
correct it. This should not be here.


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

https://reviews.llvm.org/D82103



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


[PATCH] D80753: [clang-tidy] remove duplicate fixes of alias checkers

2020-06-19 Thread Nathan James via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGaf4f2eb47636: [clang-tidy] remove duplicate fixes of alias 
checkers (authored by Daniel599, committed by njames93).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80753

Files:
  clang-tools-extra/clang-tidy/ClangTidy.cpp
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
  
clang-tools-extra/test/clang-tidy/infrastructure/duplicate-conflicted-fixes-of-alias-checkers.cpp
  
clang-tools-extra/test/clang-tidy/infrastructure/duplicate-fixes-of-alias-checkers.cpp
  clang-tools-extra/test/clang-tidy/infrastructure/duplicate-reports.cpp
  llvm/include/llvm/ADT/StringMap.h
  llvm/unittests/ADT/StringMapTest.cpp

Index: llvm/unittests/ADT/StringMapTest.cpp
===
--- llvm/unittests/ADT/StringMapTest.cpp
+++ llvm/unittests/ADT/StringMapTest.cpp
@@ -387,6 +387,70 @@
   ASSERT_EQ(B.count("x"), 0u);
 }
 
+TEST_F(StringMapTest, EqualEmpty) {
+  StringMap A;
+  StringMap B;
+  ASSERT_TRUE(A == B);
+  ASSERT_FALSE(A != B);
+  ASSERT_TRUE(A == A); // self check
+}
+
+TEST_F(StringMapTest, EqualWithValues) {
+  StringMap A;
+  A["A"] = 1;
+  A["B"] = 2;
+  A["C"] = 3;
+  A["D"] = 3;
+
+  StringMap B;
+  B["A"] = 1;
+  B["B"] = 2;
+  B["C"] = 3;
+  B["D"] = 3;
+
+  ASSERT_TRUE(A == B);
+  ASSERT_TRUE(B == A);
+  ASSERT_FALSE(A != B);
+  ASSERT_FALSE(B != A);
+  ASSERT_TRUE(A == A); // self check
+}
+
+TEST_F(StringMapTest, NotEqualMissingKeys) {
+  StringMap A;
+  A["A"] = 1;
+  A["B"] = 2;
+
+  StringMap B;
+  B["A"] = 1;
+  B["B"] = 2;
+  B["C"] = 3;
+  B["D"] = 3;
+
+  ASSERT_FALSE(A == B);
+  ASSERT_FALSE(B == A);
+  ASSERT_TRUE(A != B);
+  ASSERT_TRUE(B != A);
+}
+
+TEST_F(StringMapTest, NotEqualWithDifferentValues) {
+  StringMap A;
+  A["A"] = 1;
+  A["B"] = 2;
+  A["C"] = 100;
+  A["D"] = 3;
+
+  StringMap B;
+  B["A"] = 1;
+  B["B"] = 2;
+  B["C"] = 3;
+  B["D"] = 3;
+
+  ASSERT_FALSE(A == B);
+  ASSERT_FALSE(B == A);
+  ASSERT_TRUE(A != B);
+  ASSERT_TRUE(B != A);
+}
+
 struct Countable {
   int 
   int Number;
Index: llvm/include/llvm/ADT/StringMap.h
===
--- llvm/include/llvm/ADT/StringMap.h
+++ llvm/include/llvm/ADT/StringMap.h
@@ -248,6 +248,26 @@
 return count(MapEntry.getKey());
   }
 
+  /// equal - check whether both of the containers are equal.
+  bool operator==(const StringMap ) const {
+if (size() != RHS.size())
+  return false;
+
+for (const auto  : *this) {
+  auto FindInRHS = RHS.find(KeyValue.getKey());
+
+  if (FindInRHS == RHS.end())
+return false;
+
+  if (!(KeyValue.getValue() == FindInRHS->getValue()))
+return false;
+}
+
+return true;
+  }
+
+  bool operator!=(const StringMap ) const { return !(*this == RHS); }
+
   /// insert - Insert the specified key/value pair into the map.  If the key
   /// already exists in the map, return false and ignore the request, otherwise
   /// insert it and return true.
Index: clang-tools-extra/test/clang-tidy/infrastructure/duplicate-reports.cpp
===
--- clang-tools-extra/test/clang-tidy/infrastructure/duplicate-reports.cpp
+++ clang-tools-extra/test/clang-tidy/infrastructure/duplicate-reports.cpp
@@ -2,8 +2,7 @@
 
 void alwaysThrows() {
   int ex = 42;
-  // CHECK-MESSAGES: warning: throw expression should throw anonymous temporary values instead [cert-err09-cpp]
-  // CHECK-MESSAGES: warning: throw expression should throw anonymous temporary values instead [cert-err61-cpp]
+  // CHECK-MESSAGES: warning: throw expression should throw anonymous temporary values instead [cert-err09-cpp,cert-err61-cpp]
   throw ex;
 }
 
Index: clang-tools-extra/test/clang-tidy/infrastructure/duplicate-fixes-of-alias-checkers.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/infrastructure/duplicate-fixes-of-alias-checkers.cpp
@@ -0,0 +1,39 @@
+// RUN: %check_clang_tidy %s cppcoreguidelines-pro-type-member-init,hicpp-member-init,modernize-use-emplace,hicpp-use-emplace %t
+
+namespace std {
+
+template 
+class vector {
+public:
+  void push_back(const T &) {}
+  void push_back(T &&) {}
+
+  template 
+  void emplace_back(Args &&... args){};
+};
+} // namespace std
+
+class Foo {
+public:
+  Foo() : _num1(0)
+  // CHECK-MESSAGES: warning: constructor does not initialize these fields: _num2 [cppcoreguidelines-pro-type-member-init,hicpp-member-init]
+  {
+_num1 = 10;
+  }
+
+  int use_the_members() const {
+return _num1 + _num2;
+  }
+
+private:
+  int _num1;
+  int _num2;
+  // CHECK-FIXES: _num2{};
+};
+
+int should_use_emplace(std::vector ) {
+  v.push_back(Foo());
+  // CHECK-FIXES: v.emplace_back();
+  // 

[PATCH] D82231: [NFC] Remove unused pass name parser classes

2020-06-19 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks updated this revision to Diff 272166.
aeubanks added a comment.

Unintended change


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82231

Files:
  llvm/include/llvm/IR/LegacyPassNameParser.h


Index: llvm/include/llvm/IR/LegacyPassNameParser.h
===
--- llvm/include/llvm/IR/LegacyPassNameParser.h
+++ llvm/include/llvm/IR/LegacyPassNameParser.h
@@ -92,47 +92,6 @@
   }
 };
 
-///===--===//
-/// FilteredPassNameParser class - Make use of the pass registration
-/// mechanism to automatically add a command line argument to opt for
-/// each pass that satisfies a filter criteria.  Filter should return
-/// true for passes to be registered as command-line options.
-///
-template
-class FilteredPassNameParser : public PassNameParser {
-private:
-  Filter filter;
-
-public:
-  bool ignorablePassImpl(const PassInfo *P) const override {
-return !filter(*P);
-  }
-};
-
-///===--===//
-/// PassArgFilter - A filter for use with PassNameFilterParser that only
-/// accepts a Pass whose Arg matches certain strings.
-///
-/// Use like this:
-///
-/// extern const char AllowedPassArgs[] = "-anders_aa -dse";
-///
-/// static cl::list<
-///   const PassInfo*,
-///   bool,
-///   FilteredPassNameParser > >
-/// PassList(cl::desc("Passes available:"));
-///
-/// Only the -anders_aa and -dse options will be available to the user.
-///
-template
-class PassArgFilter {
-public:
-  bool operator()(const PassInfo ) const {
-return StringRef(Args).contains(P.getPassArgument());
-  }
-};
-
 } // End llvm namespace
 
 #endif


Index: llvm/include/llvm/IR/LegacyPassNameParser.h
===
--- llvm/include/llvm/IR/LegacyPassNameParser.h
+++ llvm/include/llvm/IR/LegacyPassNameParser.h
@@ -92,47 +92,6 @@
   }
 };
 
-///===--===//
-/// FilteredPassNameParser class - Make use of the pass registration
-/// mechanism to automatically add a command line argument to opt for
-/// each pass that satisfies a filter criteria.  Filter should return
-/// true for passes to be registered as command-line options.
-///
-template
-class FilteredPassNameParser : public PassNameParser {
-private:
-  Filter filter;
-
-public:
-  bool ignorablePassImpl(const PassInfo *P) const override {
-return !filter(*P);
-  }
-};
-
-///===--===//
-/// PassArgFilter - A filter for use with PassNameFilterParser that only
-/// accepts a Pass whose Arg matches certain strings.
-///
-/// Use like this:
-///
-/// extern const char AllowedPassArgs[] = "-anders_aa -dse";
-///
-/// static cl::list<
-///   const PassInfo*,
-///   bool,
-///   FilteredPassNameParser > >
-/// PassList(cl::desc("Passes available:"));
-///
-/// Only the -anders_aa and -dse options will be available to the user.
-///
-template
-class PassArgFilter {
-public:
-  bool operator()(const PassInfo ) const {
-return StringRef(Args).contains(P.getPassArgument());
-  }
-};
-
 } // End llvm namespace
 
 #endif
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D82231: [NFC] Remove unused pass name parser classes

2020-06-19 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks created this revision.
Herald added subscribers: llvm-commits, cfe-commits, mgorny.
Herald added projects: clang, LLVM.
aeubanks added a reviewer: echristo.
aeubanks updated this revision to Diff 272166.
aeubanks added a comment.

Unintended change


Looks like these were for the most part touched over a decade ago.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82231

Files:
  llvm/include/llvm/IR/LegacyPassNameParser.h


Index: llvm/include/llvm/IR/LegacyPassNameParser.h
===
--- llvm/include/llvm/IR/LegacyPassNameParser.h
+++ llvm/include/llvm/IR/LegacyPassNameParser.h
@@ -92,47 +92,6 @@
   }
 };
 
-///===--===//
-/// FilteredPassNameParser class - Make use of the pass registration
-/// mechanism to automatically add a command line argument to opt for
-/// each pass that satisfies a filter criteria.  Filter should return
-/// true for passes to be registered as command-line options.
-///
-template
-class FilteredPassNameParser : public PassNameParser {
-private:
-  Filter filter;
-
-public:
-  bool ignorablePassImpl(const PassInfo *P) const override {
-return !filter(*P);
-  }
-};
-
-///===--===//
-/// PassArgFilter - A filter for use with PassNameFilterParser that only
-/// accepts a Pass whose Arg matches certain strings.
-///
-/// Use like this:
-///
-/// extern const char AllowedPassArgs[] = "-anders_aa -dse";
-///
-/// static cl::list<
-///   const PassInfo*,
-///   bool,
-///   FilteredPassNameParser > >
-/// PassList(cl::desc("Passes available:"));
-///
-/// Only the -anders_aa and -dse options will be available to the user.
-///
-template
-class PassArgFilter {
-public:
-  bool operator()(const PassInfo ) const {
-return StringRef(Args).contains(P.getPassArgument());
-  }
-};
-
 } // End llvm namespace
 
 #endif


Index: llvm/include/llvm/IR/LegacyPassNameParser.h
===
--- llvm/include/llvm/IR/LegacyPassNameParser.h
+++ llvm/include/llvm/IR/LegacyPassNameParser.h
@@ -92,47 +92,6 @@
   }
 };
 
-///===--===//
-/// FilteredPassNameParser class - Make use of the pass registration
-/// mechanism to automatically add a command line argument to opt for
-/// each pass that satisfies a filter criteria.  Filter should return
-/// true for passes to be registered as command-line options.
-///
-template
-class FilteredPassNameParser : public PassNameParser {
-private:
-  Filter filter;
-
-public:
-  bool ignorablePassImpl(const PassInfo *P) const override {
-return !filter(*P);
-  }
-};
-
-///===--===//
-/// PassArgFilter - A filter for use with PassNameFilterParser that only
-/// accepts a Pass whose Arg matches certain strings.
-///
-/// Use like this:
-///
-/// extern const char AllowedPassArgs[] = "-anders_aa -dse";
-///
-/// static cl::list<
-///   const PassInfo*,
-///   bool,
-///   FilteredPassNameParser > >
-/// PassList(cl::desc("Passes available:"));
-///
-/// Only the -anders_aa and -dse options will be available to the user.
-///
-template
-class PassArgFilter {
-public:
-  bool operator()(const PassInfo ) const {
-return StringRef(Args).contains(P.getPassArgument());
-  }
-};
-
 } // End llvm namespace
 
 #endif
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] af4f2eb - [clang-tidy] remove duplicate fixes of alias checkers

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

Author: Daniel
Date: 2020-06-19T20:40:59+01:00
New Revision: af4f2eb476361e6da42d6f66a68cada763625c32

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

LOG: [clang-tidy] remove duplicate fixes of alias checkers

when both a check and its alias are enabled, we should only take the fixes of 
one of them and not both.
This patch fixes bug 45577
https://bugs.llvm.org/show_bug.cgi?id=45577

Reviewed By: aaron.ballman, njames93

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

Added: 

clang-tools-extra/test/clang-tidy/infrastructure/duplicate-conflicted-fixes-of-alias-checkers.cpp

clang-tools-extra/test/clang-tidy/infrastructure/duplicate-fixes-of-alias-checkers.cpp

Modified: 
clang-tools-extra/clang-tidy/ClangTidy.cpp
clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
clang-tools-extra/test/clang-tidy/infrastructure/duplicate-reports.cpp
llvm/include/llvm/ADT/StringMap.h
llvm/unittests/ADT/StringMapTest.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/ClangTidy.cpp 
b/clang-tools-extra/clang-tidy/ClangTidy.cpp
index d9b4b01e7161..163aad2ec378 100644
--- a/clang-tools-extra/clang-tidy/ClangTidy.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidy.cpp
@@ -122,6 +122,8 @@ class ErrorReporter {
 {
   auto Level = static_cast(Error.DiagLevel);
   std::string Name = Error.DiagnosticName;
+  if (!Error.EnabledDiagnosticAliases.empty())
+Name += "," + llvm::join(Error.EnabledDiagnosticAliases, ",");
   if (Error.IsWarningAsError) {
 Name += ",-warnings-as-errors";
 Level = DiagnosticsEngine::Error;

diff  --git a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp 
b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
index 9742cd08d9c3..5c23323b03f0 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
@@ -27,6 +27,7 @@
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/Support/Regex.h"
+#include "llvm/Support/FormatVariadic.h"
 #include 
 #include 
 using namespace clang;
@@ -634,6 +635,8 @@ void 
ClangTidyDiagnosticConsumer::removeIncompatibleErrors() {
 std::tuple Priority;
   };
 
+  removeDuplicatedDiagnosticsOfAliasCheckers();
+
   // Compute error sizes.
   std::vector Sizes;
   std::vector<
@@ -728,3 +731,59 @@ std::vector 
ClangTidyDiagnosticConsumer::take() {
 removeIncompatibleErrors();
   return std::move(Errors);
 }
+
+namespace {
+struct LessClangTidyErrorWithoutDiagnosticName {
+  bool operator()(const ClangTidyError *LHS, const ClangTidyError *RHS) const {
+const tooling::DiagnosticMessage  = LHS->Message;
+const tooling::DiagnosticMessage  = RHS->Message;
+
+return std::tie(M1.FilePath, M1.FileOffset, M1.Message) <
+   std::tie(M2.FilePath, M2.FileOffset, M2.Message);
+  }
+};
+} // end anonymous namespace
+
+void ClangTidyDiagnosticConsumer::removeDuplicatedDiagnosticsOfAliasCheckers() 
{
+  using UniqueErrorSet =
+  std::set;
+  UniqueErrorSet UniqueErrors;
+
+  auto IT = Errors.begin();
+  while (IT != Errors.end()) {
+ClangTidyError  = *IT;
+std::pair Inserted =
+UniqueErrors.insert();
+
+// Unique error, we keep it and move along.
+if (Inserted.second) {
+  ++IT;
+} else {
+  ClangTidyError  = **Inserted.first;
+  const llvm::StringMap  =
+  Error.Message.Fix;
+  const llvm::StringMap  =
+  (*Inserted.first)->Message.Fix;
+
+  if (CandidateFix != ExistingFix) {
+
+// In case of a conflict, don't suggest any fix-it.
+ExistingError.Message.Fix.clear();
+ExistingError.Notes.emplace_back(
+llvm::formatv("cannot apply fix-it because an alias checker has "
+  "suggested a 
diff erent fix-it; please remove one of "
+  "the checkers ('{0}', '{1}') or "
+  "ensure they are both configured the same",
+  ExistingError.DiagnosticName, Error.DiagnosticName)
+.str());
+  }
+
+  if (Error.IsWarningAsError)
+ExistingError.IsWarningAsError = true;
+
+  // Since it is the same error, we should take it as alias and remove it.
+  
ExistingError.EnabledDiagnosticAliases.emplace_back(Error.DiagnosticName);
+  IT = Errors.erase(IT);
+}
+  }
+}

diff  --git a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h 
b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
index 2bb3296b150d..90cc4da3021f 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
+++ 

[PATCH] D82225: [libTooling] Delete deprecated `Stencil` combinators.

2020-06-19 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel updated this revision to Diff 272157.
ymandel added a comment.

fix additional refs


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82225

Files:
  clang/include/clang/Tooling/Transformer/Stencil.h
  clang/lib/Tooling/Transformer/Stencil.cpp
  clang/unittests/Tooling/StencilTest.cpp

Index: clang/unittests/Tooling/StencilTest.cpp
===
--- clang/unittests/Tooling/StencilTest.cpp
+++ clang/unittests/Tooling/StencilTest.cpp
@@ -179,12 +179,12 @@
 
 TEST_F(StencilTest, IfBoundOpBound) {
   StringRef Id = "id";
-  testExpr(Id, "3;", ifBound(Id, text("5"), text("7")), "5");
+  testExpr(Id, "3;", ifBound(Id, cat("5"), cat("7")), "5");
 }
 
 TEST_F(StencilTest, IfBoundOpUnbound) {
   StringRef Id = "id";
-  testExpr(Id, "3;", ifBound("other", text("5"), text("7")), "7");
+  testExpr(Id, "3;", ifBound("other", cat("5"), cat("7")), "7");
 }
 
 TEST_F(StencilTest, ExpressionOpNoParens) {
@@ -292,7 +292,7 @@
 x;
   )cc";
   StringRef Id = "id";
-  testExpr(Id, Snippet, access(Id, text("field")), "x.field");
+  testExpr(Id, Snippet, access(Id, cat("field")), "x.field");
 }
 
 TEST_F(StencilTest, AccessOpValueAddress) {
@@ -436,7 +436,7 @@
 }
 
 TEST(StencilToStringTest, AccessOpSelector) {
-  auto S = access("Id", selection(name("otherId")));
+  auto S = access("Id", cat(name("otherId")));
   StringRef Expected = R"repr(access("Id", selection(...)))repr";
   EXPECT_EQ(S->toString(), Expected);
 }
@@ -448,7 +448,7 @@
 }
 
 TEST(StencilToStringTest, IfBoundOp) {
-  auto S = ifBound("Id", text("trueText"), access("exprId", "memberData"));
+  auto S = ifBound("Id", cat("trueText"), access("exprId", "memberData"));
   StringRef Expected =
   R"repr(ifBound("Id", "trueText", access("exprId", "memberData")))repr";
   EXPECT_EQ(S->toString(), Expected);
@@ -462,7 +462,7 @@
 
 TEST(StencilToStringTest, Sequence) {
   auto S = cat("foo", access("x", "m()"), "bar",
-   ifBound("x", text("t"), access("e", "f")));
+   ifBound("x", cat("t"), access("e", "f")));
   StringRef Expected = R"repr(seq("foo", access("x", "m()"), "bar", )repr"
R"repr(ifBound("x", "t", access("e", "f"repr";
   EXPECT_EQ(S->toString(), Expected);
@@ -481,8 +481,8 @@
 }
 
 TEST(StencilToStringTest, SequenceFromVector) {
-  auto S = catVector({text("foo"), access("x", "m()"), text("bar"),
-  ifBound("x", text("t"), access("e", "f"))});
+  auto S = catVector({cat("foo"), access("x", "m()"), cat("bar"),
+  ifBound("x", cat("t"), access("e", "f"))});
   StringRef Expected = R"repr(seq("foo", access("x", "m()"), "bar", )repr"
R"repr(ifBound("x", "t", access("e", "f"repr";
   EXPECT_EQ(S->toString(), Expected);
Index: clang/lib/Tooling/Transformer/Stencil.cpp
===
--- clang/lib/Tooling/Transformer/Stencil.cpp
+++ clang/lib/Tooling/Transformer/Stencil.cpp
@@ -295,17 +295,11 @@
 };
 } // namespace
 
-Stencil transformer::detail::makeStencil(StringRef Text) { return text(Text); }
-
-Stencil transformer::detail::makeStencil(RangeSelector Selector) {
-  return selection(std::move(Selector));
-}
-
-Stencil transformer::text(StringRef Text) {
+Stencil transformer::detail::makeStencil(StringRef Text) {
   return std::make_shared>(std::string(Text));
 }
 
-Stencil transformer::selection(RangeSelector Selector) {
+Stencil transformer::detail::makeStencil(RangeSelector Selector) {
   return std::make_shared>(std::move(Selector));
 }
 
Index: clang/include/clang/Tooling/Transformer/Stencil.h
===
--- clang/include/clang/Tooling/Transformer/Stencil.h
+++ clang/include/clang/Tooling/Transformer/Stencil.h
@@ -69,14 +69,6 @@
 // Functions for conveniently building stencils.
 //
 
-/// DEPRECATED: Use `cat` instead.
-/// \returns exactly the text provided.
-Stencil text(llvm::StringRef Text);
-
-/// DEPRECATED: Use `cat` instead.
-/// \returns the source corresponding to the selected range.
-Stencil selection(RangeSelector Selector);
-
 /// Generates the source of the expression bound to \p Id, wrapping it in
 /// parentheses if it may parse differently depending on context. For example, a
 /// binary operation is always wrapped, while a variable reference is never
@@ -112,7 +104,7 @@
 /// Additionally, `e` is wrapped in parentheses, if needed.
 Stencil access(llvm::StringRef BaseId, Stencil Member);
 inline Stencil access(llvm::StringRef BaseId, llvm::StringRef Member) {
-  return access(BaseId, text(Member));
+  return access(BaseId, detail::makeStencil(Member));
 }
 
 /// Chooses between the two stencil parts, based on whether \p ID is bound in
@@ -123,7 +115,8 @@
 /// match.
 inline Stencil ifBound(llvm::StringRef Id, llvm::StringRef TrueText,

[PATCH] D82126: [libTooling] Change Transformer's `cat` to handle some cases of text in macros.

2020-06-19 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd81d69f1c0c1: [libTooling] Change Transformers `cat` 
to handle some cases of text in macros. (authored by ymandel).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82126

Files:
  clang-tools-extra/test/clang-tidy/checkers/abseil-string-find-str-contains.cpp
  clang/lib/Tooling/Transformer/Stencil.cpp
  clang/unittests/Tooling/StencilTest.cpp

Index: clang/unittests/Tooling/StencilTest.cpp
===
--- clang/unittests/Tooling/StencilTest.cpp
+++ clang/unittests/Tooling/StencilTest.cpp
@@ -7,6 +7,7 @@
 //===--===//
 
 #include "clang/Tooling/Transformer/Stencil.h"
+#include "clang/AST/ASTTypeTraits.h"
 #include "clang/ASTMatchers/ASTMatchers.h"
 #include "clang/Tooling/FixIt.h"
 #include "clang/Tooling/Tooling.h"
@@ -373,6 +374,48 @@
   testExpr(Id, "3;", run(SimpleFn), "Bound");
 }
 
+TEST_F(StencilTest, CatOfMacroRangeSucceeds) {
+  StringRef Snippet = R"cpp(
+#define MACRO 3.77
+  double foo(double d);
+  foo(MACRO);)cpp";
+
+  auto StmtMatch =
+  matchStmt(Snippet, callExpr(callee(functionDecl(hasName("foo"))),
+  argumentCountIs(1),
+  hasArgument(0, expr().bind("arg";
+  ASSERT_TRUE(StmtMatch);
+  Stencil S = cat(node("arg"));
+  EXPECT_THAT_EXPECTED(S->eval(StmtMatch->Result), HasValue("MACRO"));
+}
+
+TEST_F(StencilTest, CatOfMacroArgRangeSucceeds) {
+  StringRef Snippet = R"cpp(
+#define MACRO(a, b) a + b
+  MACRO(2, 3);)cpp";
+
+  auto StmtMatch =
+  matchStmt(Snippet, binaryOperator(hasRHS(expr().bind("rhs";
+  ASSERT_TRUE(StmtMatch);
+  Stencil S = cat(node("rhs"));
+  EXPECT_THAT_EXPECTED(S->eval(StmtMatch->Result), HasValue("3"));
+}
+
+TEST_F(StencilTest, CatOfMacroArgSubRangeSucceeds) {
+  StringRef Snippet = R"cpp(
+#define MACRO(a, b) a + b
+  int foo(int);
+  MACRO(2, foo(3));)cpp";
+
+  auto StmtMatch = matchStmt(
+  Snippet, binaryOperator(hasRHS(callExpr(
+   callee(functionDecl(hasName("foo"))), argumentCountIs(1),
+   hasArgument(0, expr().bind("arg"));
+  ASSERT_TRUE(StmtMatch);
+  Stencil S = cat(node("arg"));
+  EXPECT_THAT_EXPECTED(S->eval(StmtMatch->Result), HasValue("3"));
+}
+
 TEST_F(StencilTest, CatOfInvalidRangeFails) {
   StringRef Snippet = R"cpp(
 #define MACRO (3.77)
Index: clang/lib/Tooling/Transformer/Stencil.cpp
===
--- clang/lib/Tooling/Transformer/Stencil.cpp
+++ clang/lib/Tooling/Transformer/Stencil.cpp
@@ -12,6 +12,7 @@
 #include "clang/AST/Expr.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Basic/SourceLocation.h"
 #include "clang/Lex/Lexer.h"
 #include "clang/Tooling/Transformer/SourceCode.h"
 #include "clang/Tooling/Transformer/SourceCodeBuilders.h"
@@ -226,12 +227,14 @@
 
 Error evalData(const SelectorData , const MatchFinder::MatchResult ,
std::string *Result) {
-  auto Range = Data.Selector(Match);
-  if (!Range)
-return Range.takeError();
-  if (auto Err = tooling::validateEditRange(*Range, *Match.SourceManager))
+  auto RawRange = Data.Selector(Match);
+  if (!RawRange)
+return RawRange.takeError();
+  CharSourceRange Range = Lexer::makeFileCharRange(
+  *RawRange, *Match.SourceManager, Match.Context->getLangOpts());
+  if (auto Err = tooling::validateEditRange(Range, *Match.SourceManager))
 return Err;
-  *Result += tooling::getText(*Range, *Match.Context);
+  *Result += tooling::getText(Range, *Match.Context);
   return Error::success();
 }
 
Index: clang-tools-extra/test/clang-tidy/checkers/abseil-string-find-str-contains.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/abseil-string-find-str-contains.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/abseil-string-find-str-contains.cpp
@@ -239,16 +239,12 @@
   asv.find('c') == absl::string_view::npos;
 }
 
-#define COMPARE_MACRO(x, y) ((x) == (y))
-#define FIND_MACRO(x, y) ((x).find(y))
-#define FIND_COMPARE_MACRO(x, y, z) ((x).find(y) == (z))
-
-// Confirms that it does not match when a macro is involved.
-void no_macros() {
-  std::string s;
-  COMPARE_MACRO(s.find("a"), std::string::npos);
-  FIND_MACRO(s, "a") == std::string::npos;
-  FIND_COMPARE_MACRO(s, "a", std::string::npos);
+#define FOO(a, b, c, d) ((a).find(b) == std::string::npos ? (c) : (d))
+
+// Confirms that it does not match when a macro would be "torn" by the fix.
+void no_tearing_macros() {
+  std::string h = "helo";
+  FOO(h, "x", 5, 6);
 }
 
 // Confirms that it does not match when the pos parameter is non-zero.
___
cfe-commits mailing list

[PATCH] D82225: [libTooling] Delete deprecated `Stencil` combinators.

2020-06-19 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel created this revision.
ymandel added a reviewer: tdl-g.
Herald added a project: clang.

Deletes `text()` and `selection()` combinators, since they have been deprecated 
for months.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82225

Files:
  clang/include/clang/Tooling/Transformer/Stencil.h
  clang/lib/Tooling/Transformer/Stencil.cpp
  clang/unittests/Tooling/StencilTest.cpp

Index: clang/unittests/Tooling/StencilTest.cpp
===
--- clang/unittests/Tooling/StencilTest.cpp
+++ clang/unittests/Tooling/StencilTest.cpp
@@ -179,12 +179,12 @@
 
 TEST_F(StencilTest, IfBoundOpBound) {
   StringRef Id = "id";
-  testExpr(Id, "3;", ifBound(Id, text("5"), text("7")), "5");
+  testExpr(Id, "3;", ifBound(Id, cat("5"), cat("7")), "5");
 }
 
 TEST_F(StencilTest, IfBoundOpUnbound) {
   StringRef Id = "id";
-  testExpr(Id, "3;", ifBound("other", text("5"), text("7")), "7");
+  testExpr(Id, "3;", ifBound("other", cat("5"), cat("7")), "7");
 }
 
 TEST_F(StencilTest, ExpressionOpNoParens) {
@@ -292,7 +292,7 @@
 x;
   )cc";
   StringRef Id = "id";
-  testExpr(Id, Snippet, access(Id, text("field")), "x.field");
+  testExpr(Id, Snippet, access(Id, cat("field")), "x.field");
 }
 
 TEST_F(StencilTest, AccessOpValueAddress) {
@@ -448,7 +448,7 @@
 }
 
 TEST(StencilToStringTest, IfBoundOp) {
-  auto S = ifBound("Id", text("trueText"), access("exprId", "memberData"));
+  auto S = ifBound("Id", cat("trueText"), access("exprId", "memberData"));
   StringRef Expected =
   R"repr(ifBound("Id", "trueText", access("exprId", "memberData")))repr";
   EXPECT_EQ(S->toString(), Expected);
@@ -462,7 +462,7 @@
 
 TEST(StencilToStringTest, Sequence) {
   auto S = cat("foo", access("x", "m()"), "bar",
-   ifBound("x", text("t"), access("e", "f")));
+   ifBound("x", cat("t"), access("e", "f")));
   StringRef Expected = R"repr(seq("foo", access("x", "m()"), "bar", )repr"
R"repr(ifBound("x", "t", access("e", "f"repr";
   EXPECT_EQ(S->toString(), Expected);
@@ -481,8 +481,8 @@
 }
 
 TEST(StencilToStringTest, SequenceFromVector) {
-  auto S = catVector({text("foo"), access("x", "m()"), text("bar"),
-  ifBound("x", text("t"), access("e", "f"))});
+  auto S = catVector({cat("foo"), access("x", "m()"), cat("bar"),
+  ifBound("x", cat("t"), access("e", "f"))});
   StringRef Expected = R"repr(seq("foo", access("x", "m()"), "bar", )repr"
R"repr(ifBound("x", "t", access("e", "f"repr";
   EXPECT_EQ(S->toString(), Expected);
Index: clang/lib/Tooling/Transformer/Stencil.cpp
===
--- clang/lib/Tooling/Transformer/Stencil.cpp
+++ clang/lib/Tooling/Transformer/Stencil.cpp
@@ -295,17 +295,11 @@
 };
 } // namespace
 
-Stencil transformer::detail::makeStencil(StringRef Text) { return text(Text); }
-
-Stencil transformer::detail::makeStencil(RangeSelector Selector) {
-  return selection(std::move(Selector));
-}
-
-Stencil transformer::text(StringRef Text) {
+Stencil transformer::detail::makeStencil(StringRef Text) {
   return std::make_shared>(std::string(Text));
 }
 
-Stencil transformer::selection(RangeSelector Selector) {
+Stencil transformer::detail::makeStencil(RangeSelector Selector) {
   return std::make_shared>(std::move(Selector));
 }
 
Index: clang/include/clang/Tooling/Transformer/Stencil.h
===
--- clang/include/clang/Tooling/Transformer/Stencil.h
+++ clang/include/clang/Tooling/Transformer/Stencil.h
@@ -69,14 +69,6 @@
 // Functions for conveniently building stencils.
 //
 
-/// DEPRECATED: Use `cat` instead.
-/// \returns exactly the text provided.
-Stencil text(llvm::StringRef Text);
-
-/// DEPRECATED: Use `cat` instead.
-/// \returns the source corresponding to the selected range.
-Stencil selection(RangeSelector Selector);
-
 /// Generates the source of the expression bound to \p Id, wrapping it in
 /// parentheses if it may parse differently depending on context. For example, a
 /// binary operation is always wrapped, while a variable reference is never
@@ -112,7 +104,7 @@
 /// Additionally, `e` is wrapped in parentheses, if needed.
 Stencil access(llvm::StringRef BaseId, Stencil Member);
 inline Stencil access(llvm::StringRef BaseId, llvm::StringRef Member) {
-  return access(BaseId, text(Member));
+  return access(BaseId, detail::makeStencil(Member));
 }
 
 /// Chooses between the two stencil parts, based on whether \p ID is bound in
@@ -123,7 +115,8 @@
 /// match.
 inline Stencil ifBound(llvm::StringRef Id, llvm::StringRef TrueText,
llvm::StringRef FalseText) {
-  return ifBound(Id, text(TrueText), text(FalseText));
+  return ifBound(Id, detail::makeStencil(TrueText),
+ detail::makeStencil(FalseText));
 }
 
 /// Wraps a \c MatchConsumer in a \c Stencil, so that it can be 

[PATCH] D82224: [OpenMP] Remove hard-coded line numbers from test

2020-06-19 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny created this revision.
jdenny added reviewers: ABataev, jdoerfert, hfinkel.
Herald added subscribers: sstefan1, guansong, yaxunl.
jdenny added reviewers: grokos, sfantao, Hahnfeld.

Otherwise, it's painful to insert new code.  There are many existing
examples in the same test file where the line numbers are not
hard-coded.

I intend to do the same for several other OpenMP tests, but I want
to be sure there are no objections before I spend time on it.


Repository:
  rC Clang

https://reviews.llvm.org/D82224

Files:
  clang/test/OpenMP/target_map_codegen.cpp

Index: clang/test/OpenMP/target_map_codegen.cpp
===
--- clang/test/OpenMP/target_map_codegen.cpp
+++ clang/test/OpenMP/target_map_codegen.cpp
@@ -1323,173 +1323,173 @@
 // SIMD-ONLY18-NOT: {{__kmpc|__tgt}}
 #ifdef CK19
 
-// CK19-LABEL: @.__omp_offloading_{{.*}}explicit_maps_single{{.*}}_l1514.region_id = weak constant i8 0
+// CK19-LABEL: @.__omp_offloading_{{.*}}explicit_maps_single{{.*}}_l{{[0-9]+}}.region_id = weak constant i8 0
 // CK19: [[SIZE00:@.+]] = private {{.*}}constant [1 x i64] [i64 4]
 // CK19: [[MTYPE00:@.+]] = private {{.*}}constant [1 x i64] [i64 32]
 
-// CK19-LABEL: @.__omp_offloading_{{.*}}explicit_maps_single{{.*}}_l1535.region_id = weak constant i8 0
+// CK19-LABEL: @.__omp_offloading_{{.*}}explicit_maps_single{{.*}}_l{{[0-9]+}}.region_id = weak constant i8 0
 // CK19: [[SIZE00n:@.+]] = private {{.*}}constant [1 x i64] [i64 4]
 // CK19: [[MTYPE00n:@.+]] = private {{.*}}constant [1 x i64] [i64 32]
 
-// CK19-LABEL: @.__omp_offloading_{{.*}}explicit_maps_single{{.*}}_l1557.region_id = weak constant i8 0
+// CK19-LABEL: @.__omp_offloading_{{.*}}explicit_maps_single{{.*}}_l{{[0-9]+}}.region_id = weak constant i8 0
 // CK19: [[SIZE01:@.+]] = private {{.*}}constant [1 x i64] [i64 400]
 // CK19: [[MTYPE01:@.+]] = private {{.*}}constant [1 x i64] [i64 33]
 
-// CK19-LABEL: @.__omp_offloading_{{.*}}explicit_maps_single{{.*}}_l1576.region_id = weak constant i8 0
+// CK19-LABEL: @.__omp_offloading_{{.*}}explicit_maps_single{{.*}}_l{{[0-9]+}}.region_id = weak constant i8 0
 // CK19: [[SIZE02:@.+]] = private {{.*}}constant [1 x i64] [i64 240]
 // CK19: [[MTYPE02:@.+]] = private {{.*}}constant [1 x i64] [i64 34]
 
-// CK19-LABEL: @.__omp_offloading_{{.*}}explicit_maps_single{{.*}}_l1595.region_id = weak constant i8 0
+// CK19-LABEL: @.__omp_offloading_{{.*}}explicit_maps_single{{.*}}_l{{[0-9]+}}.region_id = weak constant i8 0
 // CK19: [[SIZE03:@.+]] = private {{.*}}constant [1 x i64] [i64 240]
 // CK19: [[MTYPE03:@.+]] = private {{.*}}constant [1 x i64] [i64 35]
 
-// CK19-LABEL: @.__omp_offloading_{{.*}}explicit_maps_single{{.*}}_l1614.region_id = weak constant i8 0
+// CK19-LABEL: @.__omp_offloading_{{.*}}explicit_maps_single{{.*}}_l{{[0-9]+}}.region_id = weak constant i8 0
 // CK19: [[SIZE04:@.+]] = private {{.*}}constant [1 x i64] [i64 400]
 // CK19: [[MTYPE04:@.+]] = private {{.*}}constant [1 x i64] [i64 32]
 
-// CK19-LABEL: @.__omp_offloading_{{.*}}explicit_maps_single{{.*}}_l1633.region_id = weak constant i8 0
+// CK19-LABEL: @.__omp_offloading_{{.*}}explicit_maps_single{{.*}}_l{{[0-9]+}}.region_id = weak constant i8 0
 // CK19: [[SIZE05:@.+]] = private {{.*}}constant [1 x i64] [i64 4]
 // CK19: [[MTYPE05:@.+]] = private {{.*}}constant [1 x i64] [i64 33]
 
-// CK19-LABEL: @.__omp_offloading_{{.*}}explicit_maps_single{{.*}}_l1656.region_id = weak constant i8 0
+// CK19-LABEL: @.__omp_offloading_{{.*}}explicit_maps_single{{.*}}_l{{[0-9]+}}.region_id = weak constant i8 0
 // CK19: [[MTYPE06:@.+]] = private {{.*}}constant [1 x i64] [i64 35]
 
-// CK19-LABEL: @.__omp_offloading_{{.*}}explicit_maps_single{{.*}}_l1679.region_id = weak constant i8 0
+// CK19-LABEL: @.__omp_offloading_{{.*}}explicit_maps_single{{.*}}_l{{[0-9]+}}.region_id = weak constant i8 0
 // CK19: [[MTYPE07:@.+]] = private {{.*}}constant [1 x i64] [i64 32]
 
-// CK19-LABEL: @.__omp_offloading_{{.*}}explicit_maps_single{{.*}}_l1698.region_id = weak constant i8 0
+// CK19-LABEL: @.__omp_offloading_{{.*}}explicit_maps_single{{.*}}_l{{[0-9]+}}.region_id = weak constant i8 0
 // CK19: [[SIZE08:@.+]] = private {{.*}}constant [1 x i64] [i64 4]
 // CK19: [[MTYPE08:@.+]] = private {{.*}}constant [1 x i64] [i64 35]
 
-// CK19-LABEL: @.__omp_offloading_{{.*}}explicit_maps_single{{.*}}_l1719.region_id = weak constant i8 0
+// CK19-LABEL: @.__omp_offloading_{{.*}}explicit_maps_single{{.*}}_l{{[0-9]+}}.region_id = weak constant i8 0
 // CK19: [[SIZE09:@.+]] = private {{.*}}constant [1 x i64] [i64 {{8|4}}]
 // CK19: [[MTYPE09:@.+]] = private {{.*}}constant [1 x i64] [i64 34]
 
-// CK19-LABEL: @.__omp_offloading_{{.*}}explicit_maps_single{{.*}}_l1740.region_id = weak constant i8 0
+// CK19-LABEL: @.__omp_offloading_{{.*}}explicit_maps_single{{.*}}_l{{[0-9]+}}.region_id = weak constant i8 0
 // CK19: [[SIZE10:@.+]] = private {{.*}}constant [1 x i64] [i64 240]
 // CK19: [[MTYPE10:@.+]] = private {{.*}}constant [1 x 

[PATCH] D82179: Move TestClangConfig into libClangTesting and use it in AST Matchers tests

2020-06-19 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel accepted this revision.
ymandel marked an inline comment as done.
ymandel added a comment.
This revision is now accepted and ready to land.

Only nits. Really nice work. I much prefer your new system, having wrestled 
with config and multi-language testing in the existing framework.  However, is 
this worth an RFC to the list?




Comment at: clang/include/clang/Testing/TestClangConfig.h:18
+
+struct TestClangConfig {
+  TestLanguage Language;

Maybe add a brief comment explaining this struct?



Comment at: clang/include/clang/Testing/TestClangConfig.h:20
+  TestLanguage Language;
+  std::string Target;
+

Is this sufficiently obvious to the reader or is it worth commenting on the 
meaning of "target"?



Comment at: clang/include/clang/Testing/TestClangConfig.h:64
+std::string Result;
+llvm::raw_string_ostream OS(Result);
+OS << "{ Language=" << Language << ", Target=" << Target << " }";

Add include? ("llvm/Support/raw_ostream.h")



Comment at: clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp:652
+
+  if (!GetParam().hasDelayedTemplateParsing()) {
+// FIXME: Fix this test to work with delayed template parsing.

Nice!



Comment at: clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp:818
+TEST_P(ASTMatchersTest, MaterializeTemporaryExpr_MatchesTemporaryCXX11CXX14) {
+  if (GetParam().Language != Lang_CXX11 || GetParam().Language != Lang_CXX14 ||
+  GetParam().Language != Lang_CXX17) {

Isn't this always true since any given value can't also be other values? Should 
these be `&&`?



Comment at: clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp:1026
+TEST_P(ASTMatchersTest, Initializers_CXX) {
+  if (GetParam().Language != Lang_CXX03) {
+// FIXME: Make this test pass with other C++ standard versions.

Maybe add comment explaining this restriction? I take it this was some feature 
support by gcc for C++03, which is also supported by clang for compatibility 
(at that language version)?



Comment at: clang/unittests/Tooling/Syntax/TreeTest.cpp:3473
+Lang_CXX14, Lang_CXX17, Lang_CXX20}) {
+TestClangConfig config;
+config.Language = lang;

nit: maybe just
```
all_configs.push_back({lang, "x86_64-pc-linux-gnu"});

// Windows target is interesting to test because it enables
// `-fdelayed-template-parsing`.
all_configs.push_back({lang, "x86_64-pc-win32-msvc"});
```
Or, if you'd like a bit nicer, add a constructor to the struct and use 
`emplace_back`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82179



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


[PATCH] D82126: [libTooling] Change Transformer's `cat` to handle some cases of text in macros.

2020-06-19 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel updated this revision to Diff 272150.
ymandel added a comment.

Fixed clang tidy lit test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82126

Files:
  clang-tools-extra/test/clang-tidy/checkers/abseil-string-find-str-contains.cpp
  clang/lib/Tooling/Transformer/Stencil.cpp
  clang/unittests/Tooling/StencilTest.cpp

Index: clang/unittests/Tooling/StencilTest.cpp
===
--- clang/unittests/Tooling/StencilTest.cpp
+++ clang/unittests/Tooling/StencilTest.cpp
@@ -7,6 +7,7 @@
 //===--===//
 
 #include "clang/Tooling/Transformer/Stencil.h"
+#include "clang/AST/ASTTypeTraits.h"
 #include "clang/ASTMatchers/ASTMatchers.h"
 #include "clang/Tooling/FixIt.h"
 #include "clang/Tooling/Tooling.h"
@@ -373,6 +374,48 @@
   testExpr(Id, "3;", run(SimpleFn), "Bound");
 }
 
+TEST_F(StencilTest, CatOfMacroRangeSucceeds) {
+  StringRef Snippet = R"cpp(
+#define MACRO 3.77
+  double foo(double d);
+  foo(MACRO);)cpp";
+
+  auto StmtMatch =
+  matchStmt(Snippet, callExpr(callee(functionDecl(hasName("foo"))),
+  argumentCountIs(1),
+  hasArgument(0, expr().bind("arg";
+  ASSERT_TRUE(StmtMatch);
+  Stencil S = cat(node("arg"));
+  EXPECT_THAT_EXPECTED(S->eval(StmtMatch->Result), HasValue("MACRO"));
+}
+
+TEST_F(StencilTest, CatOfMacroArgRangeSucceeds) {
+  StringRef Snippet = R"cpp(
+#define MACRO(a, b) a + b
+  MACRO(2, 3);)cpp";
+
+  auto StmtMatch =
+  matchStmt(Snippet, binaryOperator(hasRHS(expr().bind("rhs";
+  ASSERT_TRUE(StmtMatch);
+  Stencil S = cat(node("rhs"));
+  EXPECT_THAT_EXPECTED(S->eval(StmtMatch->Result), HasValue("3"));
+}
+
+TEST_F(StencilTest, CatOfMacroArgSubRangeSucceeds) {
+  StringRef Snippet = R"cpp(
+#define MACRO(a, b) a + b
+  int foo(int);
+  MACRO(2, foo(3));)cpp";
+
+  auto StmtMatch = matchStmt(
+  Snippet, binaryOperator(hasRHS(callExpr(
+   callee(functionDecl(hasName("foo"))), argumentCountIs(1),
+   hasArgument(0, expr().bind("arg"));
+  ASSERT_TRUE(StmtMatch);
+  Stencil S = cat(node("arg"));
+  EXPECT_THAT_EXPECTED(S->eval(StmtMatch->Result), HasValue("3"));
+}
+
 TEST_F(StencilTest, CatOfInvalidRangeFails) {
   StringRef Snippet = R"cpp(
 #define MACRO (3.77)
Index: clang/lib/Tooling/Transformer/Stencil.cpp
===
--- clang/lib/Tooling/Transformer/Stencil.cpp
+++ clang/lib/Tooling/Transformer/Stencil.cpp
@@ -12,6 +12,7 @@
 #include "clang/AST/Expr.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Basic/SourceLocation.h"
 #include "clang/Lex/Lexer.h"
 #include "clang/Tooling/Transformer/SourceCode.h"
 #include "clang/Tooling/Transformer/SourceCodeBuilders.h"
@@ -226,12 +227,14 @@
 
 Error evalData(const SelectorData , const MatchFinder::MatchResult ,
std::string *Result) {
-  auto Range = Data.Selector(Match);
-  if (!Range)
-return Range.takeError();
-  if (auto Err = tooling::validateEditRange(*Range, *Match.SourceManager))
+  auto RawRange = Data.Selector(Match);
+  if (!RawRange)
+return RawRange.takeError();
+  CharSourceRange Range = Lexer::makeFileCharRange(
+  *RawRange, *Match.SourceManager, Match.Context->getLangOpts());
+  if (auto Err = tooling::validateEditRange(Range, *Match.SourceManager))
 return Err;
-  *Result += tooling::getText(*Range, *Match.Context);
+  *Result += tooling::getText(Range, *Match.Context);
   return Error::success();
 }
 
Index: clang-tools-extra/test/clang-tidy/checkers/abseil-string-find-str-contains.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/abseil-string-find-str-contains.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/abseil-string-find-str-contains.cpp
@@ -239,16 +239,12 @@
   asv.find('c') == absl::string_view::npos;
 }
 
-#define COMPARE_MACRO(x, y) ((x) == (y))
-#define FIND_MACRO(x, y) ((x).find(y))
-#define FIND_COMPARE_MACRO(x, y, z) ((x).find(y) == (z))
-
-// Confirms that it does not match when a macro is involved.
-void no_macros() {
-  std::string s;
-  COMPARE_MACRO(s.find("a"), std::string::npos);
-  FIND_MACRO(s, "a") == std::string::npos;
-  FIND_COMPARE_MACRO(s, "a", std::string::npos);
+#define FOO(a, b, c, d) ((a).find(b) == std::string::npos ? (c) : (d))
+
+// Confirms that it does not match when a macro would be "torn" by the fix.
+void no_tearing_macros() {
+  std::string h = "helo";
+  FOO(h, "x", 5, 6);
 }
 
 // Confirms that it does not match when the pos parameter is non-zero.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D82126: [libTooling] Change Transformer's `cat` to handle some cases of text in macros.

2020-06-19 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel added a comment.

In D82126#2104088 , @tdl-g wrote:

> Interesting, in all three of those cases, it's reasonable to replace the 
> entire expression, thus eliminating the macro.  None of those "tear" the 
> macro; if we had a case like
>
> #define FOO(a,b,c,d) ((a).find(b) == std::string::npos ? (c) : (d))
>  FOO("helo", "x", 5, 6);
>
> I guess in that case we'd want to suppress an edit change, since it would 
> have to modify the macro to make the change.  But I guess all the existing 
> test cases are actually safe to convert with the macro.
>
> Do you want to remove the existing macro cases and add the "tearing" one 
> above to confirm that it doesn't propose an edit?


Done.

> 
> 
> In D82126#2103934 , @ymandel wrote:
> 
>> Tests show that this breaks the test for the clang tidy 
>> `abseil-string-find-str-contains`.  Curious if this is a desirable change in 
>> behavior (in which case I'll update your test file) or the wrong behavior:
>>
>> https://github.com/llvm/llvm-project/blob/master/clang-tools-extra/test/clang-tidy/checkers/abseil-string-find-str-contains.cpp#L246-L252
>>
>>   void no_macros() {
>>  std::string s;
>>   -  COMPARE_MACRO(s.find("a"), std::string::npos);
>>   -  FIND_MACRO(s, "a") == std::string::npos;
>>   -  FIND_COMPARE_MACRO(s, "a", std::string::npos);
>>   +  !absl::StrContains(s, "a");
>>   +  !absl::StrContains(s, "a");
>>   +  !absl::StrContains(s, "a");
>>}
>>




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82126



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


[PATCH] D82223: [clang-tidy] Implement storeOptions for checks missing it.

2020-06-19 Thread Nathan James via Phabricator via cfe-commits
njames93 created this revision.
njames93 added reviewers: aaron.ballman, Eugene.Zelenko.
Herald added subscribers: cfe-commits, kbarton, xazax.hun, nemanjai.
Herald added a project: clang.

Just adds the storeOptions for Checks that weren't already storing their 
options.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82223

Files:
  clang-tools-extra/clang-tidy/bugprone/TooSmallLoopVariableCheck.cpp
  clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp
  clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.h
  clang-tools-extra/clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.cpp
  clang-tools-extra/clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.h
  clang-tools-extra/clang-tidy/misc/NonPrivateMemberVariablesInClassesCheck.cpp
  clang-tools-extra/clang-tidy/misc/NonPrivateMemberVariablesInClassesCheck.h
  clang-tools-extra/clang-tidy/misc/ThrowByValueCatchByReferenceCheck.cpp
  clang-tools-extra/clang-tidy/misc/ThrowByValueCatchByReferenceCheck.h
  clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp
  clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.h
  clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
  clang-tools-extra/clang-tidy/modernize/RawStringLiteralCheck.cpp
  clang-tools-extra/clang-tidy/modernize/UseAutoCheck.cpp
  clang-tools-extra/clang-tidy/modernize/UseBoolLiteralsCheck.cpp
  clang-tools-extra/clang-tidy/modernize/UseBoolLiteralsCheck.h
  clang-tools-extra/clang-tidy/modernize/UseEmplaceCheck.cpp
  clang-tools-extra/clang-tidy/modernize/UseTransparentFunctorsCheck.cpp
  clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp
  clang-tools-extra/clang-tidy/modernize/UseUsingCheck.h
  clang-tools-extra/clang-tidy/readability/MagicNumbersCheck.cpp
  clang-tools-extra/clang-tidy/readability/MagicNumbersCheck.h
  clang-tools-extra/clang-tidy/readability/RedundantDeclarationCheck.cpp
  clang-tools-extra/clang-tidy/readability/RedundantDeclarationCheck.h
  clang-tools-extra/clang-tidy/readability/StaticAccessedThroughInstanceCheck.h
  clang-tools-extra/clang-tidy/utils/HeaderGuard.cpp
  clang-tools-extra/clang-tidy/utils/HeaderGuard.h

Index: clang-tools-extra/clang-tidy/utils/HeaderGuard.h
===
--- clang-tools-extra/clang-tidy/utils/HeaderGuard.h
+++ clang-tools-extra/clang-tidy/utils/HeaderGuard.h
@@ -34,6 +34,7 @@
HeaderFileExtensions,
utils::defaultFileExtensionDelimiters());
   }
+  void storeOptions(ClangTidyOptions::OptionMap ) override;
   void registerPPCallbacks(const SourceManager , Preprocessor *PP,
Preprocessor *ModuleExpanderPP) override;
 
Index: clang-tools-extra/clang-tidy/utils/HeaderGuard.cpp
===
--- clang-tools-extra/clang-tidy/utils/HeaderGuard.cpp
+++ clang-tools-extra/clang-tidy/utils/HeaderGuard.cpp
@@ -266,6 +266,10 @@
 };
 } // namespace
 
+void HeaderGuardCheck::storeOptions(ClangTidyOptions::OptionMap ) {
+  Options.store(Opts, "HeaderFileExtensions", RawStringHeaderFileExtensions);
+}
+
 void HeaderGuardCheck::registerPPCallbacks(const SourceManager ,
Preprocessor *PP,
Preprocessor *ModuleExpanderPP) {
@@ -285,7 +289,6 @@
 std::string HeaderGuardCheck::formatEndIf(StringRef HeaderGuard) {
   return "endif // " + HeaderGuard.str();
 }
-
 } // namespace utils
 } // namespace tidy
 } // namespace clang
Index: clang-tools-extra/clang-tidy/readability/StaticAccessedThroughInstanceCheck.h
===
--- clang-tools-extra/clang-tidy/readability/StaticAccessedThroughInstanceCheck.h
+++ clang-tools-extra/clang-tidy/readability/StaticAccessedThroughInstanceCheck.h
@@ -25,7 +25,7 @@
   StaticAccessedThroughInstanceCheck(StringRef Name, ClangTidyContext *Context)
   : ClangTidyCheck(Name, Context),
 NameSpecifierNestingThreshold(
-Options.get("NameSpecifierNestingThreshold", 3)) {}
+Options.get("NameSpecifierNestingThreshold", 3U)) {}
 
   void storeOptions(ClangTidyOptions::OptionMap ) override;
   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
Index: clang-tools-extra/clang-tidy/readability/RedundantDeclarationCheck.h
===
--- clang-tools-extra/clang-tidy/readability/RedundantDeclarationCheck.h
+++ clang-tools-extra/clang-tidy/readability/RedundantDeclarationCheck.h
@@ -22,6 +22,7 @@
 class RedundantDeclarationCheck : public ClangTidyCheck {
 public:
   RedundantDeclarationCheck(StringRef Name, ClangTidyContext *Context);
+  void storeOptions(ClangTidyOptions::OptionMap ) override;
   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
   void check(const ast_matchers::MatchFinder::MatchResult ) 

[clang] d81d69f - [libTooling] Change Transformer's `cat` to handle some cases of text in macros.

2020-06-19 Thread Yitzhak Mandelbaum via cfe-commits

Author: Yitzhak Mandelbaum
Date: 2020-06-19T18:48:54Z
New Revision: d81d69f1c0c161e093531cf1ac9c1fa280ab5bf1

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

LOG: [libTooling] Change Transformer's `cat` to handle some cases of text in 
macros.

Summary:
Currently, `cat` validates range selections before extracting the corresponding
source text. However, this means that any range inside a macro is rejected as an
error. This patch changes the implementation to first try to map the range to
something reasonable. This makes the behavior consistent with handling of ranges
used for selecting portions of the source to edit.

Also updates a clang-tidy lit-test for one of the checks which was affected by
this change.

Reviewers: gribozavr2, tdl-g

Subscribers: cfe-commits

Tags: #clang

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

Added: 


Modified: 

clang-tools-extra/test/clang-tidy/checkers/abseil-string-find-str-contains.cpp
clang/lib/Tooling/Transformer/Stencil.cpp
clang/unittests/Tooling/StencilTest.cpp

Removed: 




diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/abseil-string-find-str-contains.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/abseil-string-find-str-contains.cpp
index 871c830b81cf..9d4b03aa22f2 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/abseil-string-find-str-contains.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/abseil-string-find-str-contains.cpp
@@ -239,16 +239,12 @@ void no_char_param_tests() {
   asv.find('c') == absl::string_view::npos;
 }
 
-#define COMPARE_MACRO(x, y) ((x) == (y))
-#define FIND_MACRO(x, y) ((x).find(y))
-#define FIND_COMPARE_MACRO(x, y, z) ((x).find(y) == (z))
-
-// Confirms that it does not match when a macro is involved.
-void no_macros() {
-  std::string s;
-  COMPARE_MACRO(s.find("a"), std::string::npos);
-  FIND_MACRO(s, "a") == std::string::npos;
-  FIND_COMPARE_MACRO(s, "a", std::string::npos);
+#define FOO(a, b, c, d) ((a).find(b) == std::string::npos ? (c) : (d))
+
+// Confirms that it does not match when a macro would be "torn" by the fix.
+void no_tearing_macros() {
+  std::string h = "helo";
+  FOO(h, "x", 5, 6);
 }
 
 // Confirms that it does not match when the pos parameter is non-zero.

diff  --git a/clang/lib/Tooling/Transformer/Stencil.cpp 
b/clang/lib/Tooling/Transformer/Stencil.cpp
index da6033efa296..31b6ad9332c8 100644
--- a/clang/lib/Tooling/Transformer/Stencil.cpp
+++ b/clang/lib/Tooling/Transformer/Stencil.cpp
@@ -12,6 +12,7 @@
 #include "clang/AST/Expr.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Basic/SourceLocation.h"
 #include "clang/Lex/Lexer.h"
 #include "clang/Tooling/Transformer/SourceCode.h"
 #include "clang/Tooling/Transformer/SourceCodeBuilders.h"
@@ -226,12 +227,14 @@ Error evalData(const UnaryOperationData ,
 
 Error evalData(const SelectorData , const MatchFinder::MatchResult ,
std::string *Result) {
-  auto Range = Data.Selector(Match);
-  if (!Range)
-return Range.takeError();
-  if (auto Err = tooling::validateEditRange(*Range, *Match.SourceManager))
+  auto RawRange = Data.Selector(Match);
+  if (!RawRange)
+return RawRange.takeError();
+  CharSourceRange Range = Lexer::makeFileCharRange(
+  *RawRange, *Match.SourceManager, Match.Context->getLangOpts());
+  if (auto Err = tooling::validateEditRange(Range, *Match.SourceManager))
 return Err;
-  *Result += tooling::getText(*Range, *Match.Context);
+  *Result += tooling::getText(Range, *Match.Context);
   return Error::success();
 }
 

diff  --git a/clang/unittests/Tooling/StencilTest.cpp 
b/clang/unittests/Tooling/StencilTest.cpp
index 2f0a970d8552..9408a1e62dfa 100644
--- a/clang/unittests/Tooling/StencilTest.cpp
+++ b/clang/unittests/Tooling/StencilTest.cpp
@@ -7,6 +7,7 @@
 
//===--===//
 
 #include "clang/Tooling/Transformer/Stencil.h"
+#include "clang/AST/ASTTypeTraits.h"
 #include "clang/ASTMatchers/ASTMatchers.h"
 #include "clang/Tooling/FixIt.h"
 #include "clang/Tooling/Tooling.h"
@@ -373,6 +374,48 @@ TEST_F(StencilTest, RunOp) {
   testExpr(Id, "3;", run(SimpleFn), "Bound");
 }
 
+TEST_F(StencilTest, CatOfMacroRangeSucceeds) {
+  StringRef Snippet = R"cpp(
+#define MACRO 3.77
+  double foo(double d);
+  foo(MACRO);)cpp";
+
+  auto StmtMatch =
+  matchStmt(Snippet, callExpr(callee(functionDecl(hasName("foo"))),
+  argumentCountIs(1),
+  hasArgument(0, expr().bind("arg";
+  ASSERT_TRUE(StmtMatch);
+  Stencil S = cat(node("arg"));
+  EXPECT_THAT_EXPECTED(S->eval(StmtMatch->Result), HasValue("MACRO"));
+}
+
+TEST_F(StencilTest, CatOfMacroArgRangeSucceeds) {

[PATCH] D79910: [x86][seses] Add clang flag; Use lvi-cfi with seses

2020-06-19 Thread Zola Bridges via Phabricator via cfe-commits
zbrid marked 2 inline comments as done.
zbrid added inline comments.



Comment at: clang/include/clang/Driver/Options.td:2244
   HelpText<"Disable control-flow mitigations for Load Value Injection (LVI)">;
+def m_seses : Flag<["-"], "mseses">, Group, Flags<[CoreOption, 
DriverOption]>,
+  HelpText<"Enable speculative execution side effect suppression (SESES). "

MaskRay wrote:
> CoreOption is accepted by clang-cl. You need a `%clang_cl` test if you use 
> CoreOption.
Is there a typical place to put this test? Is this a .cc -> LLVM IR test that's 
wanted? Any examples you can point to?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79910



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


[PATCH] D80242: [Clang] implement -fno-eliminate-unused-debug-types

2020-06-19 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers updated this revision to Diff 272143.
nickdesaulniers marked an inline comment as done.
nickdesaulniers added a comment.

- make cases more uniform, cleanup some missed fixes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80242

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/docs/CommandGuide/clang.rst
  clang/docs/UsersManual.rst
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Basic/DebugInfoOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDebugInfo.h
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/debug-info-unused-types.c
  clang/test/CodeGen/debug-info-unused-types.cpp
  clang/test/Driver/debug-options.c

Index: clang/test/Driver/debug-options.c
===
--- clang/test/Driver/debug-options.c
+++ clang/test/Driver/debug-options.c
@@ -361,3 +361,12 @@
 // GEMBED_2:  error: invalid argument '-gembed-source' only allowed with '-gdwarf-5'
 // NOGEMBED_5-NOT:  "-gembed-source"
 // NOGEMBED_2-NOT:  error: invalid argument '-gembed-source' only allowed with '-gdwarf-5'
+//
+// RUN: %clang -### -g -fno-eliminate-unused-debug-types -c %s 2>&1 \
+// RUN:| FileCheck -check-prefix=DEBUG_UNUSED_TYPES %s
+// DEBUG_UNUSED_TYPES: "-debug-info-kind=unused-types"
+// DEBUG_UNUSED_TYPES-NOT: "-debug-info-kind=limited"
+// RUN: %clang -### -g -feliminate-unused-debug-types -c %s 2>&1 \
+// RUN:| FileCheck -check-prefix=NO_DEBUG_UNUSED_TYPES %s
+// NO_DEBUG_UNUSED_TYPES: "-debug-info-kind=limited"
+// NO_DEBUG_UNUSED_TYPES-NOT: "-debug-info-kind=unused-types"
Index: clang/test/CodeGen/debug-info-unused-types.cpp
===
--- /dev/null
+++ clang/test/CodeGen/debug-info-unused-types.cpp
@@ -0,0 +1,35 @@
+// RUN: %clang++ -fno-eliminate-unused-debug-types -g -emit-llvm -S -o - %s | FileCheck %s
+// RUN: %clang++ -feliminate-unused-debug-types -g -emit-llvm -S -o - %s | FileCheck --check-prefix=NODBG %s
+// RUN: %clang++ -g -emit-llvm -S -o - %s | FileCheck --check-prefix=NODBG %s
+// RUN: %clang++ -emit-llvm -S -o - %s | FileCheck --check-prefix=NODBG %s
+using foo = int;
+class bar {};
+enum class baz { BAZ };
+
+void quux() {
+  using x = int;
+  class y {};
+  enum class z { Z };
+}
+
+// CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "baz"
+// CHECK: !DIEnumerator(name: "BAZ"
+// CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "z"
+// CHECK: !DIEnumerator(name: "Z"
+// CHECK: !DIDerivedType(tag: DW_TAG_typedef, name: "foo"
+// CHECK: !DICompositeType(tag: DW_TAG_class_type, name: "bar"
+// CHECK: !DICompositeType(tag: DW_TAG_class_type, name: "y"
+
+// NODBG-NOT: !DICompositeType(tag: DW_TAG_enumeration_type, name: "baz"
+// NODBG-NOT: !DIEnumerator(name: "BAZ"
+// NODBG-NOT: !DICompositeType(tag: DW_TAG_enumeration_type, name: "z"
+// NODBG-NOT: !DIEnumerator(name: "Z"
+// NODBG-NOT: !DIDerivedType(tag: DW_TAG_typedef, name: "foo"
+// NODBG-NOT: !DICompositeType(tag: DW_TAG_class_type, name: "bar"
+// NODBG-NOT: !DICompositeType(tag: DW_TAG_class_type, name: "y"
+
+class ;
+enum class ;
+
+// NODBG-NOT: ;
+// NODBG-NOT: ;
Index: clang/test/CodeGen/debug-info-unused-types.c
===
--- /dev/null
+++ clang/test/CodeGen/debug-info-unused-types.c
@@ -0,0 +1,60 @@
+// RUN: %clang -fno-eliminate-unused-debug-types -g -emit-llvm -S -o - %s | FileCheck %s
+// RUN: %clang -feliminate-unused-debug-types -g -emit-llvm -S -o - %s | FileCheck --check-prefix=NODBG %s
+// RUN: %clang -g -emit-llvm -S -o - %s | FileCheck --check-prefix=NODBG %s
+// RUN: %clang -emit-llvm -S -o - %s | FileCheck --check-prefix=NODBG %s
+typedef int my_int;
+struct foo {};
+enum bar { BAR };
+union baz {};
+
+void quux(void) {
+  typedef int x;
+  struct y {};
+  enum z { Z };
+  union w {};
+}
+
+// Check that debug info is emitted for the typedef, struct, enum, and union
+// when -fno-eliminate-unused-debug-types and -g are set.
+
+// CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "bar"
+// CHECK: !DIEnumerator(name: "BAR"
+// CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "z"
+// CHECK: !DIEnumerator(name: "Z"
+// CHECK: !DIDerivedType(tag: DW_TAG_typedef, name: "my_int"
+// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "foo"
+// CHECK: !DICompositeType(tag: DW_TAG_union_type, name: "baz"
+// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "y"
+// CHECK: !DICompositeType(tag: DW_TAG_union_type, name: "w"
+
+// Check that debug info is not emitted for the typedef, struct, enum, and
+// 

[PATCH] D80242: [Clang] implement -fno-eliminate-unused-debug-types

2020-06-19 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added inline comments.



Comment at: clang/lib/CodeGen/CGDecl.cpp:103-118
+  case Decl::CXXRecord: // struct/union/class X; [C++]
+if (CGDebugInfo *DI = getDebugInfo())
+  if (CGM.getCodeGenOpts().hasMaybeUnusedDebugInfo() &&
+  cast(D).hasDefinition())
+DI->completeUnusedClass(cast(D));
+return;
   case Decl::Record:// struct/union/class X;

nickdesaulniers wrote:
> dblaikie wrote:
> > All of these might be able to be collapsed together - using 
> > "cast(D).hasDefinition()" ... to have a common implementation.
> `TagDecl` doesn't have a method `hasDefinition`.  Only `CXXRecordDecl` does.
Also, how to get the `QualType` differs between `Decl::Enum` an `Decl::Record`; 
`getEnumType` vs `getRecordType` respectively.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80242



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


[PATCH] D80242: [Clang] implement -fno-eliminate-unused-debug-types

2020-06-19 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added inline comments.



Comment at: clang/lib/CodeGen/CGDecl.cpp:103-118
+  case Decl::CXXRecord: // struct/union/class X; [C++]
+if (CGDebugInfo *DI = getDebugInfo())
+  if (CGM.getCodeGenOpts().hasMaybeUnusedDebugInfo() &&
+  cast(D).hasDefinition())
+DI->completeUnusedClass(cast(D));
+return;
   case Decl::Record:// struct/union/class X;

dblaikie wrote:
> All of these might be able to be collapsed together - using 
> "cast(D).hasDefinition()" ... to have a common implementation.
`TagDecl` doesn't have a method `hasDefinition`.  Only `CXXRecordDecl` does.



Comment at: clang/lib/CodeGen/CGDecl.cpp:116
+if (CGDebugInfo *DI = getDebugInfo())
+  if (cast()->getDefinition())
+DI->EmitAndRetainType(getContext().getEnumType(cast()));

dblaikie wrote:
> I think the right thing to call here (& the other places in this patch) is 
> "hasDefinition" rather than "getDefinition" (this will avoid the definition 
> being deserialized when it's not needed yet (then if we don't end up emitting 
> the type because the flag hasn't been given, it won't be deserialized 
> unnecessarily))
`TagDecl` doesn't have a method `hasDefinition`.  Only `CXXRecordDecl` does.



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:5385
+  if (getCodeGenOpts().hasMaybeUnusedDebugInfo() && CRD->hasDefinition())
+DI->completeUnusedClass(*CRD);
+  else if (auto *ES = D->getASTContext().getExternalSource())

dblaikie wrote:
> I think this might not work as intended if the type trips over the other 
> class deduplication optimizations (try manually testing with a type that has 
> an external VTable?) - and perhaps this codepath should use the EmitAndRetain 
> functionality.
completeUnusedClass eventually calls into CGDebugInfo::completeClass which 
makes use of the TypeCache.  What does it mean for a class to have "an external 
vtable?"  Can you give me an example?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80242



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


[PATCH] D82213: [Remarks] Add callsite locations to inline remarks

2020-06-19 Thread Francis Visoiu Mistrih via Phabricator via cfe-commits
thegameg added subscribers: fhahn, anemet, thegameg.
thegameg added a comment.

This sounds useful indeed. @fhahn, @anemet might want to take a look.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82213



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


[PATCH] D82213: [Remarks] Add callsite locations to inline remarks

2020-06-19 Thread Wenlei He via Phabricator via cfe-commits
wenlei created this revision.
wenlei added reviewers: wmi, davidxl, hoy.
Herald added subscribers: llvm-commits, cfe-commits, hiraditya.
Herald added projects: clang, LLVM.

Add call site location info into inline remarks so we can differentiate inline 
sites.
This can be useful for inliner tuning. We can also reconstruct full 
hierarchical inline 
tree from parsing such remarks. The messege of inline remark is also tweaked so 
we can 
differentiate SampleProfileLoader inline from CGSCC inline.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82213

Files:
  clang/test/Frontend/optimization-remark-with-hotness-new-pm.c
  clang/test/Frontend/optimization-remark-with-hotness.c
  llvm/include/llvm/Analysis/InlineAdvisor.h
  llvm/lib/Analysis/InlineAdvisor.cpp
  llvm/lib/Transforms/IPO/SampleProfile.cpp
  llvm/test/Transforms/Inline/optimization-remarks-passed-yaml.ll
  llvm/test/Transforms/SampleProfile/remarks.ll

Index: llvm/test/Transforms/SampleProfile/remarks.ll
===
--- llvm/test/Transforms/SampleProfile/remarks.ll
+++ llvm/test/Transforms/SampleProfile/remarks.ll
@@ -21,7 +21,7 @@
 
 ; We are expecting foo() to be inlined in main() (almost all the cycles are
 ; spent inside foo).
-; CHECK: remark: remarks.cc:13:21: inlined callee '_Z3foov' into 'main'
+; CHECK: remark: remarks.cc:13:21: _Z3foov inlined into main by profile guided inliner with (cost=130, threshold=225) at callsite main:0
 
 ; The back edge for the loop is the hottest edge in the loop subgraph.
 ; CHECK: remark: remarks.cc:6:9: most popular destination for conditional branches at remarks.cc:5:3
@@ -32,17 +32,26 @@
 ; Checking to see if YAML file is generated and contains remarks
 ;YAML:   --- !Passed
 ;YAML-NEXT:  Pass:sample-profile-inline
-;YAML-NEXT:  Name:InlineSuccess
+;YAML-NEXT:  Name:Inlined
 ;YAML-NEXT:  DebugLoc:{ File: remarks.cc, Line: 13, Column: 21 }
 ;YAML-NEXT:  Function:main
 ;YAML-NEXT:  Args:
-;YAML-NEXT:- String:  'inlined callee '''
 ;YAML-NEXT:- Callee:  _Z3foov
 ;YAML-NEXT:  DebugLoc:{ File: remarks.cc, Line: 3, Column: 0 }
-;YAML-NEXT:- String:  ''' into '''
+;YAML-NEXT:- String:  ' inlined into '
 ;YAML-NEXT:- Caller:  main
 ;YAML-NEXT:DebugLoc:{ File: remarks.cc, Line: 13, Column: 0 }
-;YAML-NEXT:- String:  
+;YAML-NEXT:- String:  ' by profile guided inliner'
+;YAML-NEXT:- String:  ' with '
+;YAML-NEXT:- String:  '(cost='
+;YAML-NEXT:- Cost:'130'
+;YAML-NEXT:- String:  ', threshold='
+;YAML-NEXT:- Threshold:   '225'
+;YAML-NEXT:- String:  ')'
+;YAML-NEXT:- String:  ' at callsite '
+;YAML-NEXT:- String:  main
+;YAML-NEXT:- String:  ':'
+;YAML-NEXT:- Line:'0'
 ;YAML-NEXT:  ...
 ;YAML:  --- !Analysis
 ;YAML-NEXT:  Pass:sample-profile
Index: llvm/test/Transforms/Inline/optimization-remarks-passed-yaml.ll
===
--- llvm/test/Transforms/Inline/optimization-remarks-passed-yaml.ll
+++ llvm/test/Transforms/Inline/optimization-remarks-passed-yaml.ll
@@ -22,7 +22,7 @@
 ;  4   return foo();
 ;  5 }
 
-; CHECK: remark: /tmp/s.c:4:10: foo inlined into bar with (cost={{[0-9\-]+}}, threshold={{[0-9]+}}) (hotness: 30)
+; CHECK: remark: /tmp/s.c:4:10: foo inlined into bar with (cost={{[0-9\-]+}}, threshold={{[0-9]+}}) at callsite bar:1 (hotness: 30)
 
 ; YAML:  --- !Passed
 ; YAML-NEXT: Pass:inline
@@ -42,6 +42,10 @@
 ; YAML-NEXT:   - String: ', threshold='
 ; YAML-NEXT:   - Threshold: '{{[0-9]+}}'
 ; YAML-NEXT:   - String: ')'
+; YAML-NEXT:   - String:  ' at callsite '
+; YAML-NEXT:   - String:  bar
+; YAML-NEXT:   - String:  ':'
+; YAML-NEXT:   - Line:'1'
 ; YAML-NEXT: ...
 
 ; ModuleID = '/tmp/s.c'
Index: llvm/lib/Transforms/IPO/SampleProfile.cpp
===
--- llvm/lib/Transforms/IPO/SampleProfile.cpp
+++ llvm/lib/Transforms/IPO/SampleProfile.cpp
@@ -37,6 +37,7 @@
 #include "llvm/Analysis/AssumptionCache.h"
 #include "llvm/Analysis/CallGraph.h"
 #include "llvm/Analysis/CallGraphSCCPass.h"
+#include "llvm/Analysis/InlineAdvisor.h"
 #include "llvm/Analysis/InlineCost.h"
 #include "llvm/Analysis/LoopInfo.h"
 #include "llvm/Analysis/OptimizationRemarkEmitter.h"
@@ -916,9 +917,8 @@
   InlineFunctionInfo IFI(nullptr, GetAC);
   if (InlineFunction(CB, IFI).isSuccess()) {
 // The call to InlineFunction erases I, so we can't pass it here.
-ORE->emit(OptimizationRemark(CSINLINE_DEBUG, "InlineSuccess", DLoc, BB)
-  << "inlined callee '" << ore::NV("Callee", CalledFunction)
-  << "' into '" << ore::NV("Caller", BB->getParent()) << "'");
+

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

2020-06-19 Thread Daniel Grumberg via Phabricator via cfe-commits
dang updated this revision to Diff 272125.
dang added a comment.

Allocate string when denormalizing an option backed by an `std::string`.


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,11 +10,13 @@
 #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 
 #include 
 #include 
+#include 
 
 using namespace llvm;
 
@@ -33,6 +35,210 @@
   return OS;
 }
 
+static const std::string getOptionSpelling(const Record ,
+   size_t ) {
+  std::vector Prefixes = R.getValueAsListOfStrings("Prefixes");
+  StringRef Name = R.getValueAsString("Name");
+  if (Prefixes.empty()) {
+PrefixLength = 0;
+return Name.str();
+  }
+  PrefixLength = Prefixes[0].size();
+  return (Twine(Prefixes[0]) + Twine(Name)).str();
+}
+
+static const std::string getOptionSpelling(const Record ) {
+  size_t PrefixLength;
+  return getOptionSpelling(R, PrefixLength);
+}
+
+static void emitNameUsingSpelling(raw_ostream , const Record ) {
+  size_t PrefixLength;
+  OS << "&";
+  write_cstring(OS, StringRef(getOptionSpelling(R, PrefixLength)));
+  OS << "[" << PrefixLength << "]";
+}
+
+class MarshallingKindInfo {
+public:
+  const Record 
+  const char *MacroName;
+  bool ShouldAlwaysEmit;
+  StringRef KeyPath;
+  StringRef DefaultValue;
+  StringRef NormalizedValuesScope;
+
+  void emit(raw_ostream ) const {
+write_cstring(OS, StringRef(getOptionSpelling(R)));
+OS << ", ";
+OS << ShouldAlwaysEmit;
+OS << ", ";
+OS << KeyPath;
+OS << ", ";
+emitScopedNormalizedValue(OS, DefaultValue);
+OS << ", ";
+emitSpecific(OS);
+  }
+
+  virtual Optional emitValueTable(raw_ostream ) const {
+return None;
+  }
+
+  virtual ~MarshallingKindInfo() = default;
+
+  static std::unique_ptr create(const Record );
+
+protected:
+  void emitScopedNormalizedValue(raw_ostream ,
+ StringRef NormalizedValue) const {
+if (!NormalizedValuesScope.empty())
+  OS << NormalizedValuesScope << "::";
+OS << NormalizedValue;
+  }
+
+  virtual void emitSpecific(raw_ostream ) const = 0;
+  MarshallingKindInfo(const Record , const char *MacroName)
+  : R(R), MacroName(MacroName) {}
+};
+
+class MarshallingFlagInfo final : public MarshallingKindInfo {
+public:
+  bool IsPositive;
+
+  void emitSpecific(raw_ostream ) const override { OS << IsPositive; }
+
+  static std::unique_ptr create(const Record ) {
+std::unique_ptr Ret(new MarshallingFlagInfo(R));
+Ret->IsPositive = R.getValueAsBit("IsPositive");
+return Ret;
+  }
+
+private:
+  MarshallingFlagInfo(const Record )
+  : MarshallingKindInfo(R, "OPTION_WITH_MARSHALLING_FLAG") {}
+};
+
+class MarshallingStringInfo final : public MarshallingKindInfo {
+public:
+  StringRef NormalizerRetTy;
+  StringRef Normalizer;
+  StringRef Denormalizer;
+  int TableIndex = -1;
+  std::vector Values;
+  std::vector NormalizedValues;
+  std::string ValueTableName;
+
+  static constexpr const char *ValueTablePreamble = R"(
+struct SimpleEnumValue {
+  const char *Name;
+  unsigned Value;
+};
+
+struct SimpleEnumValueTable {
+  const SimpleEnumValue *Table;
+  unsigned Size;
+};
+)";
+
+  static constexpr const char *ValueTablesDecl =
+  "static const SimpleEnumValueTable SimpleEnumValueTables[] = ";
+
+  void emitSpecific(raw_ostream ) const override {
+emitScopedNormalizedValue(OS, NormalizerRetTy);
+OS << ", ";
+OS << Normalizer;
+OS << ", ";
+OS << Denormalizer;
+OS << ", ";
+OS << TableIndex;
+  }
+
+  Optional emitValueTable(raw_ostream ) const override {
+if (TableIndex == -1)
+  return {};
+OS << "static const SimpleEnumValue " << ValueTableName << "[] = {\n";
+for (unsigned I = 0, E = Values.size(); I != E; ++I) {
+  OS << "{";
+  write_cstring(OS, Values[I]);
+  OS << ",";
+  OS << "static_cast(";
+  emitScopedNormalizedValue(OS, NormalizedValues[I]);
+  OS << ")},";
+}
+OS << "};\n";
+return StringRef(ValueTableName);
+  }
+
+  static std::unique_ptr create(const Record ) {
+assert(!isa(R.getValueInit("NormalizerRetTy")) &&
+   "String options must have a type");
+
+std::unique_ptr Ret(new 

[PATCH] D81407: [Analyzer][StreamChecker] Add note tags for file opening.

2020-06-19 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added a comment.

Yup, i think so!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81407



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


[PATCH] D82126: [libTooling] Change Transformer's `cat` to handle some cases of text in macros.

2020-06-19 Thread Tom Lokovic via Phabricator via cfe-commits
tdl-g added a comment.

Interesting, in all three of those cases, it's reasonable to replace the entire 
expression, thus eliminating the macro.  None of those "tear" the macro; if we 
had a case like

#define FOO(a,b,c,d) ((a).find(b) == std::string::npos ? (c) : (d))
FOO("helo", "x", 5, 6);

I guess in that case we'd want to suppress an edit change, since it would have 
to modify the macro to make the change.  But I guess all the existing test 
cases are actually safe to convert with the macro.

Do you want to remove the existing macro cases and add the "tearing" one above 
to confirm that it doesn't propose an edit?

In D82126#2103934 , @ymandel wrote:

> Tests show that this breaks the test for the clang tidy 
> `abseil-string-find-str-contains`.  Curious if this is a desirable change in 
> behavior (in which case I'll update your test file) or the wrong behavior:
>
> https://github.com/llvm/llvm-project/blob/master/clang-tools-extra/test/clang-tidy/checkers/abseil-string-find-str-contains.cpp#L246-L252
>
>   void no_macros() {
>  std::string s;
>   -  COMPARE_MACRO(s.find("a"), std::string::npos);
>   -  FIND_MACRO(s, "a") == std::string::npos;
>   -  FIND_COMPARE_MACRO(s, "a", std::string::npos);
>   +  !absl::StrContains(s, "a");
>   +  !absl::StrContains(s, "a");
>   +  !absl::StrContains(s, "a");
>}
>





Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82126



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


[PATCH] D79910: [x86][seses] Add clang flag; Use lvi-cfi with seses

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



Comment at: clang/include/clang/Driver/Options.td:2244
   HelpText<"Disable control-flow mitigations for Load Value Injection (LVI)">;
+def m_seses : Flag<["-"], "mseses">, Group, Flags<[CoreOption, 
DriverOption]>,
+  HelpText<"Enable speculative execution side effect suppression (SESES). "

CoreOption is accepted by clang-cl. You need a `%clang_cl` test if you use 
CoreOption.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79910



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


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

2020-06-19 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert accepted this revision.
jdoerfert added a comment.

Happy. LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81736



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


[PATCH] D82206: [ARM][BFloat] Implement bf16 get/set_lane without casts to i16 vectors

2020-06-19 Thread Mikhail Maltsev via Phabricator via cfe-commits
miyuki created this revision.
miyuki added reviewers: stuij, labrinea, dmgreen, simon_tatham.
Herald added subscribers: cfe-commits, danielkiss, kristof.beyls.
Herald added a project: clang.
miyuki added a child revision: D80928: [BFloat] Add convert/copy instrinsic 
support.

Currently, in order to extract an element from a bf16 vector, we cast
the vector to an i16 vector, perform the extraction, and cast the result to
bfloat. This behavior was copied from the old fp16 implementation.

The goal of this patch is to achieve optimal code generation for lane
copying intrinsics in a subsequent patch (LLVM fails to fold certain
combinations of bitcast, insertelement, extractelement and
shufflevector instructions leading to the generation of suboptimal code).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82206

Files:
  clang/include/clang/Basic/arm_neon.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/arm-bf16-getset-intrinsics.c

Index: clang/test/CodeGen/arm-bf16-getset-intrinsics.c
===
--- clang/test/CodeGen/arm-bf16-getset-intrinsics.c
+++ clang/test/CodeGen/arm-bf16-getset-intrinsics.c
@@ -1,6 +1,8 @@
 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
 // RUN: %clang_cc1 -triple armv8.6a-arm-none-eabi -target-feature +neon -target-feature +bf16 -mfloat-abi hard \
 // RUN:  -disable-O0-optnone -emit-llvm %s -o - | opt -S -mem2reg -instcombine | FileCheck %s
+// RUN: %clang_cc1 -triple armv8.6a-arm-none-eabi -target-feature +neon -target-feature +bf16 -mfloat-abi soft \
+// RUN:  -disable-O0-optnone -emit-llvm %s -o - | opt -S -mem2reg -instcombine | FileCheck %s
 
 #include 
 
@@ -98,8 +100,8 @@
 
 // CHECK-LABEL: @test_vget_lane_bf16(
 // CHECK-NEXT:  entry:
-// CHECK-NEXT:[[DOTCAST1:%.*]] = extractelement <4 x bfloat> [[V:%.*]], i32 1
-// CHECK-NEXT:ret bfloat [[DOTCAST1]]
+// CHECK-NEXT:[[VGET_LANE:%.*]] = extractelement <4 x bfloat> [[V:%.*]], i32 1
+// CHECK-NEXT:ret bfloat [[VGET_LANE]]
 //
 bfloat16_t test_vget_lane_bf16(bfloat16x4_t v) {
   return vget_lane_bf16(v, 1);
@@ -107,8 +109,8 @@
 
 // CHECK-LABEL: @test_vgetq_lane_bf16(
 // CHECK-NEXT:  entry:
-// CHECK-NEXT:[[DOTCAST1:%.*]] = extractelement <8 x bfloat> [[V:%.*]], i32 7
-// CHECK-NEXT:ret bfloat [[DOTCAST1]]
+// CHECK-NEXT:[[VGET_LANE:%.*]] = extractelement <8 x bfloat> [[V:%.*]], i32 7
+// CHECK-NEXT:ret bfloat [[VGET_LANE]]
 //
 bfloat16_t test_vgetq_lane_bf16(bfloat16x8_t v) {
   return vgetq_lane_bf16(v, 7);
@@ -116,8 +118,8 @@
 
 // CHECK-LABEL: @test_vset_lane_bf16(
 // CHECK-NEXT:  entry:
-// CHECK-NEXT:[[TMP0:%.*]] = insertelement <4 x bfloat> [[V:%.*]], bfloat [[A:%.*]], i32 1
-// CHECK-NEXT:ret <4 x bfloat> [[TMP0]]
+// CHECK-NEXT:[[VSET_LANE:%.*]] = insertelement <4 x bfloat> [[V:%.*]], bfloat [[A:%.*]], i32 1
+// CHECK-NEXT:ret <4 x bfloat> [[VSET_LANE]]
 //
 bfloat16x4_t test_vset_lane_bf16(bfloat16_t a, bfloat16x4_t v) {
   return vset_lane_bf16(a, v, 1);
@@ -125,8 +127,8 @@
 
 // CHECK-LABEL: @test_vsetq_lane_bf16(
 // CHECK-NEXT:  entry:
-// CHECK-NEXT:[[TMP0:%.*]] = insertelement <8 x bfloat> [[V:%.*]], bfloat [[A:%.*]], i32 7
-// CHECK-NEXT:ret <8 x bfloat> [[TMP0]]
+// CHECK-NEXT:[[VSET_LANE:%.*]] = insertelement <8 x bfloat> [[V:%.*]], bfloat [[A:%.*]], i32 7
+// CHECK-NEXT:ret <8 x bfloat> [[VSET_LANE]]
 //
 bfloat16x8_t test_vsetq_lane_bf16(bfloat16_t a, bfloat16x8_t v) {
   return vsetq_lane_bf16(a, v, 7);
@@ -143,8 +145,8 @@
 
 // CHECK-LABEL: @test_vduph_laneq_bf16(
 // CHECK-NEXT:  entry:
-// CHECK-NEXT:[[VGETQ_LANE:%.*]] = extractelement <8 x bfloat> [[V:%.*]], i32 7
-// CHECK-NEXT:ret bfloat [[VGETQ_LANE]]
+// CHECK-NEXT:[[VGET_LANE:%.*]] = extractelement <8 x bfloat> [[V:%.*]], i32 7
+// CHECK-NEXT:ret bfloat [[VGET_LANE]]
 //
 bfloat16_t test_vduph_laneq_bf16(bfloat16x8_t v) {
   return vduph_laneq_bf16(v, 7);
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -6389,21 +6389,27 @@
   default: break;
   case NEON::BI__builtin_neon_vget_lane_i8:
   case NEON::BI__builtin_neon_vget_lane_i16:
+  case NEON::BI__builtin_neon_vget_lane_bf16:
   case NEON::BI__builtin_neon_vget_lane_i32:
   case NEON::BI__builtin_neon_vget_lane_i64:
   case NEON::BI__builtin_neon_vget_lane_f32:
   case NEON::BI__builtin_neon_vgetq_lane_i8:
   case NEON::BI__builtin_neon_vgetq_lane_i16:
+  case NEON::BI__builtin_neon_vgetq_lane_bf16:
   case NEON::BI__builtin_neon_vgetq_lane_i32:
   case NEON::BI__builtin_neon_vgetq_lane_i64:
   case NEON::BI__builtin_neon_vgetq_lane_f32:
+  case NEON::BI__builtin_neon_vduph_lane_bf16:
+  case NEON::BI__builtin_neon_vduph_laneq_bf16:
   case NEON::BI__builtin_neon_vset_lane_i8:
   case NEON::BI__builtin_neon_vset_lane_i16:
+  case NEON::BI__builtin_neon_vset_lane_bf16:
   

[PATCH] D82185: [Analyzer][WIP] Handle pointer implemented as iterators in iterator checkers

2020-06-19 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware marked an inline comment as done.
baloghadamsoftware added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp:256
+  SVal SubVal = State->getSVal(UO->getSubExpr(), C.getLocationContext());
+  SVal Result = State->getSVal(UO, C.getLocationContext());
+

baloghadamsoftware wrote:
> This is the problematic point which is not working. I left the comments 
> intentionally in the code.
> 
> The problem is that in `postStmt` we are //after//  the operation. Thus the 
> value of the operand (`SubExpr`) is not `i` anymore, but the //former value// 
> of `i` (a pointer to a symbolic region initially). Instead, the result is `i` 
> in case of prefix operators, but also the former value in case of postfix 
> operators. This is correct, of course, because here, after the call the value 
> of `i` was changed, thus it is not equal to the parameter. However, we need 
> the region of `i` here and/or the new value bound to it (e.g. the pointer to 
> an element region which is usually the result of a `++` or `--` on a pointer 
> to a symbolic region). How to reach that? Of course, in `preStmt` the operand 
> is `i` as it should be. The same is true for binary operators `+=` and `-=`. 
Of course, I know it is all wrong to increment the //former// value. This is 
also not the goal, probably I cannot reuse `handleIncrement()` and the like 
here. The question is how to get the region of the variable or even better the 
//new// region (e.g. the pointer to element region) bound to it? In the prefix 
case I have the variable, but is there a generic way to get the region bound to 
it? By generic I mean that I hope that I do not have to branch on all possible 
lvalue expressions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82185



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


[PATCH] D79910: [x86][seses] Add clang flag; Use lvi-cfi with seses

2020-06-19 Thread Zola Bridges via Phabricator via cfe-commits
zbrid updated this revision to Diff 272117.
zbrid added a comment.

Fix accidentally deleted clang command line ref


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79910

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Arch/X86.cpp
  clang/test/Driver/x86-target-features.c
  llvm/lib/Target/X86/X86.td
  llvm/lib/Target/X86/X86SpeculativeExecutionSideEffectSuppression.cpp
  llvm/lib/Target/X86/X86Subtarget.h

Index: llvm/lib/Target/X86/X86Subtarget.h
===
--- llvm/lib/Target/X86/X86Subtarget.h
+++ llvm/lib/Target/X86/X86Subtarget.h
@@ -437,6 +437,9 @@
   /// POP+LFENCE+JMP sequence.
   bool UseLVIControlFlowIntegrity = false;
 
+  /// Enable Speculative Execution Side Effect Suppression
+  bool UseSpeculativeExecutionSideEffectSuppression = false;
+
   /// Insert LFENCE instructions to prevent data speculatively injected into
   /// loads from being used maliciously.
   bool UseLVILoadHardening = false;
@@ -744,6 +747,9 @@
   bool useGLMDivSqrtCosts() const { return UseGLMDivSqrtCosts; }
   bool useLVIControlFlowIntegrity() const { return UseLVIControlFlowIntegrity; }
   bool useLVILoadHardening() const { return UseLVILoadHardening; }
+  bool useSpeculativeExecutionSideEffectSuppression() const {
+return UseSpeculativeExecutionSideEffectSuppression;
+  }
 
   unsigned getPreferVectorWidth() const { return PreferVectorWidth; }
   unsigned getRequiredVectorWidth() const { return RequiredVectorWidth; }
Index: llvm/lib/Target/X86/X86SpeculativeExecutionSideEffectSuppression.cpp
===
--- llvm/lib/Target/X86/X86SpeculativeExecutionSideEffectSuppression.cpp
+++ llvm/lib/Target/X86/X86SpeculativeExecutionSideEffectSuppression.cpp
@@ -86,13 +86,14 @@
 
 bool X86SpeculativeExecutionSideEffectSuppression::runOnMachineFunction(
 MachineFunction ) {
-  if (!EnableSpeculativeExecutionSideEffectSuppression)
+  const X86Subtarget  = MF.getSubtarget();
+  if (!Subtarget.useSpeculativeExecutionSideEffectSuppression() &&
+  !EnableSpeculativeExecutionSideEffectSuppression)
 return false;
 
   LLVM_DEBUG(dbgs() << "** " << getPassName() << " : " << MF.getName()
 << " **\n");
   bool Modified = false;
-  const X86Subtarget  = MF.getSubtarget();
   const X86InstrInfo *TII = Subtarget.getInstrInfo();
   for (MachineBasicBlock  : MF) {
 MachineInstr *FirstTerminator = nullptr;
Index: llvm/lib/Target/X86/X86.td
===
--- llvm/lib/Target/X86/X86.td
+++ llvm/lib/Target/X86/X86.td
@@ -444,6 +444,15 @@
   "LFENCE instruction to serialize control flow. Also decompose RET "
   "instructions into a POP+LFENCE+JMP sequence.">;
 
+// Enable SESES to mitigate speculative execution attacks
+def FeatureSpeculativeExecutionSideEffectSuppression
+: SubtargetFeature<
+  "seses", "UseSpeculativeExecutionSideEffectSuppression", "true",
+  "Prevent speculative execution side channel timing attacks by "
+  "inserting a speculation barrier before memory reads, memory writes, "
+  "and conditional branches. Implies LVI Control Flow integrity.",
+  [FeatureLVIControlFlowIntegrity]>;
+
 // Mitigate LVI attacks against data loads
 def FeatureLVILoadHardening
 : SubtargetFeature<
Index: clang/test/Driver/x86-target-features.c
===
--- clang/test/Driver/x86-target-features.c
+++ clang/test/Driver/x86-target-features.c
@@ -178,6 +178,27 @@
 // RUN: %clang -target i386-linux-gnu -mlvi-hardening -mretpoline-external-thunk %s -### -o %t.o 2>&1 | FileCheck -check-prefix=LVIHARDENING-RETPOLINE-EXTERNAL-THUNK %s
 // LVIHARDENING-RETPOLINE-EXTERNAL-THUNK: error: invalid argument 'mretpoline-external-thunk' not allowed with 'mlvi-hardening'
 
+// RUN: %clang -target i386-linux-gnu -mseses %s -### -o %t.o 2>&1 | FileCheck -check-prefix=SESES %s
+// RUN: %clang -target i386-linux-gnu -mno-seses %s -### -o %t.o 2>&1 | FileCheck -check-prefix=NO-SESES %s
+// SESES: "-target-feature" "+seses"
+// SESES: "-target-feature" "+lvi-cfi"
+// NO-SESES-NOT: seses
+// NO-SESES-NOT: lvi-cfi
+
+// RUN: %clang -target i386-linux-gnu -mseses -mno-lvi-cfi %s -### -o %t.o 2>&1 | FileCheck -check-prefix=SESES-NOLVICFI %s
+// SESES-NOLVICFI: "-target-feature" "+seses"
+// SESES-NOLVICFI-NOT: lvi-cfi
+
+// RUN: %clang -target i386-linux-gnu -mseses -mspeculative-load-hardening %s -### -o %t.o 2>&1 | FileCheck -check-prefix=SESES-SLH %s
+// SESES-SLH: error: invalid argument 'mspeculative-load-hardening' not allowed with 'mseses'
+// RUN: %clang -target i386-linux-gnu -mseses -mretpoline %s -### -o %t.o 2>&1 | FileCheck -check-prefix=SESES-RETPOLINE %s
+// 

[PATCH] D81868: [libTooling] Add parser for string representation of `RangeSelector`.

2020-06-19 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel closed this revision.
ymandel added a comment.

Committed as revision rG9ca50e887db7 
.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81868



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


[PATCH] D79910: [x86][seses] Add clang flag; Use lvi-cfi with seses

2020-06-19 Thread Zola Bridges via Phabricator via cfe-commits
zbrid added a comment.

@sconstab @craig.topper @mattdr -- This is ready for another round of review.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79910



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


[PATCH] D82182: [AArch64][SVE] Add bfloat16 support to perm and select intrinsics

2020-06-19 Thread Cullen Rhodes via Phabricator via cfe-commits
c-rhodes added inline comments.



Comment at: clang/include/clang/Basic/arm_sve.td:1115
 
+let ArchGuard = "defined(__ARM_FEATURE_SVE_BF16)" in {
+def SVREV_BF16: SInst<"svrev[_{d}]","dd",   "b", MergeNone, 
"aarch64_sve_rev">;

fpetrogalli wrote:
> nit: could create a multiclass here like @sdesmalen have done in 
> https://reviews.llvm.org/D82187, seems quite a nice way to keep the 
> definition of the intrinsics together (look for `multiclass StructLoad`, for 
> example)
it might be a bit tedious having separate multiclasses, what do you think about:
```multiclass SInstBF16 ft = [], list ch = []> {
  def : SInst;
  let ArchGuard = "defined(__ARM_FEATURE_SVE_BF16)" in {
def : SInst;
  }
}

defm SVREV: SInstBF16<"svrev[_{d}]","dd",   "csilUcUsUiUlhfd", 
MergeNone, "aarch64_sve_rev">;
defm SVSEL: SInstBF16<"svsel[_{d}]","dPdd", "csilUcUsUiUlhfd", 
MergeNone, "aarch64_sve_sel">;
defm SVSPLICE : SInstBF16<"svsplice[_{d}]", "dPdd", "csilUcUsUiUlhfd", 
MergeNone, "aarch64_sve_splice">;
defm SVTRN1   : SInstBF16<"svtrn1[_{d}]",   "ddd",  "csilUcUsUiUlhfd", 
MergeNone, "aarch64_sve_trn1">;
defm SVTRN2   : SInstBF16<"svtrn2[_{d}]",   "ddd",  "csilUcUsUiUlhfd", 
MergeNone, "aarch64_sve_trn2">;
defm SVUZP1   : SInstBF16<"svuzp1[_{d}]",   "ddd",  "csilUcUsUiUlhfd", 
MergeNone, "aarch64_sve_uzp1">;
defm SVUZP2   : SInstBF16<"svuzp2[_{d}]",   "ddd",  "csilUcUsUiUlhfd", 
MergeNone, "aarch64_sve_uzp2">;
defm SVZIP1   : SInstBF16<"svzip1[_{d}]",   "ddd",  "csilUcUsUiUlhfd", 
MergeNone, "aarch64_sve_zip1">;
defm SVZIP2   : SInstBF16<"svzip2[_{d}]",   "ddd",  "csilUcUsUiUlhfd", 
MergeNone, "aarch64_sve_zip2">;```

?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82182



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


[PATCH] D79910: [x86][seses] Add clang flag; Use lvi-cfi with seses

2020-06-19 Thread Zola Bridges via Phabricator via cfe-commits
zbrid updated this revision to Diff 272114.
zbrid added a comment.

seses implies lvi-cfi

also enable-seses -> enable-seses-without-lvi-cfi


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79910

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Arch/X86.cpp
  clang/test/Driver/x86-target-features.c
  llvm/lib/Target/X86/X86.td
  llvm/lib/Target/X86/X86SpeculativeExecutionSideEffectSuppression.cpp
  llvm/lib/Target/X86/X86Subtarget.h

Index: llvm/lib/Target/X86/X86Subtarget.h
===
--- llvm/lib/Target/X86/X86Subtarget.h
+++ llvm/lib/Target/X86/X86Subtarget.h
@@ -437,6 +437,9 @@
   /// POP+LFENCE+JMP sequence.
   bool UseLVIControlFlowIntegrity = false;
 
+  /// Enable Speculative Execution Side Effect Suppression
+  bool UseSpeculativeExecutionSideEffectSuppression = false;
+
   /// Insert LFENCE instructions to prevent data speculatively injected into
   /// loads from being used maliciously.
   bool UseLVILoadHardening = false;
@@ -744,6 +747,9 @@
   bool useGLMDivSqrtCosts() const { return UseGLMDivSqrtCosts; }
   bool useLVIControlFlowIntegrity() const { return UseLVIControlFlowIntegrity; }
   bool useLVILoadHardening() const { return UseLVILoadHardening; }
+  bool useSpeculativeExecutionSideEffectSuppression() const {
+return UseSpeculativeExecutionSideEffectSuppression;
+  }
 
   unsigned getPreferVectorWidth() const { return PreferVectorWidth; }
   unsigned getRequiredVectorWidth() const { return RequiredVectorWidth; }
Index: llvm/lib/Target/X86/X86SpeculativeExecutionSideEffectSuppression.cpp
===
--- llvm/lib/Target/X86/X86SpeculativeExecutionSideEffectSuppression.cpp
+++ llvm/lib/Target/X86/X86SpeculativeExecutionSideEffectSuppression.cpp
@@ -86,13 +86,14 @@
 
 bool X86SpeculativeExecutionSideEffectSuppression::runOnMachineFunction(
 MachineFunction ) {
-  if (!EnableSpeculativeExecutionSideEffectSuppression)
+  const X86Subtarget  = MF.getSubtarget();
+  if (!Subtarget.useSpeculativeExecutionSideEffectSuppression() &&
+  !EnableSpeculativeExecutionSideEffectSuppression)
 return false;
 
   LLVM_DEBUG(dbgs() << "** " << getPassName() << " : " << MF.getName()
 << " **\n");
   bool Modified = false;
-  const X86Subtarget  = MF.getSubtarget();
   const X86InstrInfo *TII = Subtarget.getInstrInfo();
   for (MachineBasicBlock  : MF) {
 MachineInstr *FirstTerminator = nullptr;
Index: llvm/lib/Target/X86/X86.td
===
--- llvm/lib/Target/X86/X86.td
+++ llvm/lib/Target/X86/X86.td
@@ -444,6 +444,15 @@
   "LFENCE instruction to serialize control flow. Also decompose RET "
   "instructions into a POP+LFENCE+JMP sequence.">;
 
+// Enable SESES to mitigate speculative execution attacks
+def FeatureSpeculativeExecutionSideEffectSuppression
+: SubtargetFeature<
+  "seses", "UseSpeculativeExecutionSideEffectSuppression", "true",
+  "Prevent speculative execution side channel timing attacks by "
+  "inserting a speculation barrier before memory reads, memory writes, "
+  "and conditional branches. Implies LVI Control Flow integrity.",
+  [FeatureLVIControlFlowIntegrity]>;
+
 // Mitigate LVI attacks against data loads
 def FeatureLVILoadHardening
 : SubtargetFeature<
Index: clang/test/Driver/x86-target-features.c
===
--- clang/test/Driver/x86-target-features.c
+++ clang/test/Driver/x86-target-features.c
@@ -178,6 +178,27 @@
 // RUN: %clang -target i386-linux-gnu -mlvi-hardening -mretpoline-external-thunk %s -### -o %t.o 2>&1 | FileCheck -check-prefix=LVIHARDENING-RETPOLINE-EXTERNAL-THUNK %s
 // LVIHARDENING-RETPOLINE-EXTERNAL-THUNK: error: invalid argument 'mretpoline-external-thunk' not allowed with 'mlvi-hardening'
 
+// RUN: %clang -target i386-linux-gnu -mseses %s -### -o %t.o 2>&1 | FileCheck -check-prefix=SESES %s
+// RUN: %clang -target i386-linux-gnu -mno-seses %s -### -o %t.o 2>&1 | FileCheck -check-prefix=NO-SESES %s
+// SESES: "-target-feature" "+seses"
+// SESES: "-target-feature" "+lvi-cfi"
+// NO-SESES-NOT: seses
+// NO-SESES-NOT: lvi-cfi
+
+// RUN: %clang -target i386-linux-gnu -mseses -mno-lvi-cfi %s -### -o %t.o 2>&1 | FileCheck -check-prefix=SESES-NOLVICFI %s
+// SESES-NOLVICFI: "-target-feature" "+seses"
+// SESES-NOLVICFI-NOT: lvi-cfi
+
+// RUN: %clang -target i386-linux-gnu -mseses -mspeculative-load-hardening %s -### -o %t.o 2>&1 | FileCheck -check-prefix=SESES-SLH %s
+// SESES-SLH: error: invalid argument 'mspeculative-load-hardening' not allowed with 'mseses'
+// RUN: %clang -target i386-linux-gnu -mseses -mretpoline %s -### -o %t.o 2>&1 | FileCheck 

[PATCH] D79910: [x86][seses] Add clang flag; Use lvi-cfi with seses

2020-06-19 Thread Zola Bridges via Phabricator via cfe-commits
zbrid added inline comments.



Comment at: 
llvm/lib/Target/X86/X86SpeculativeExecutionSideEffectSuppression.cpp:90
+  const X86Subtarget  = MF.getSubtarget();
+  if (!Subtarget.useSpeculativeExecutionSideEffectSuppression() &&
+  !EnableSpeculativeExecutionSideEffectSuppression)

zbrid wrote:
> sconstab wrote:
> > Is it really necessary to have the target feature and the CLI flag? If 
> > SESES is required for, say, a *.ll file, then `+seses` can always be added 
> > as a target feature.
> I think there should be a way to turn on SESES without lvi-cfi. Similar to 
> how there are flags to turn on SLH in various configurations. I'll see if I 
> can lower the number of flags while still enabling that possibility.
Ah I think I'll change the SESES-only flag to enable-without-lvi-cfi, so it's 
more explicit it's missing functionality/security. Updates will come soon.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79910



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


[PATCH] D82029: [Coroutines] Ensure co_await promise.final_suspend() does not throw

2020-06-19 Thread Xun Li via Phabricator via cfe-commits
lxfind updated this revision to Diff 272109.
lxfind added a comment.

Addressed comments: Updated error message, and sorted notes. The tests are kept 
unchanged.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82029

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaCoroutine.cpp
  clang/lib/Sema/SemaExceptionSpec.cpp
  clang/test/AST/Inputs/std-coroutine.h
  clang/test/AST/coroutine-source-location-crash.cpp
  clang/test/Analysis/more-dtors-cfg-output.cpp
  clang/test/CodeGenCXX/ubsan-coroutines.cpp
  clang/test/CodeGenCoroutines/Inputs/coroutine.h
  clang/test/CodeGenCoroutines/coro-alloc.cpp
  clang/test/CodeGenCoroutines/coro-always-inline.cpp
  clang/test/CodeGenCoroutines/coro-await-domination.cpp
  clang/test/CodeGenCoroutines/coro-await-resume-eh.cpp
  clang/test/CodeGenCoroutines/coro-await.cpp
  clang/test/CodeGenCoroutines/coro-dest-slot.cpp
  clang/test/CodeGenCoroutines/coro-gro-nrvo.cpp
  clang/test/CodeGenCoroutines/coro-newpm-pipeline.cpp
  clang/test/CodeGenCoroutines/coro-params.cpp
  clang/test/CodeGenCoroutines/coro-promise-dtor.cpp
  clang/test/CodeGenCoroutines/coro-ret-void.cpp
  clang/test/CodeGenCoroutines/coro-return-voidtype-initlist.cpp
  clang/test/CodeGenCoroutines/coro-return.cpp
  clang/test/CodeGenCoroutines/coro-unhandled-exception.cpp
  clang/test/Index/coroutines.cpp
  clang/test/SemaCXX/Inputs/std-coroutine.h
  clang/test/SemaCXX/co_await-range-for.cpp
  clang/test/SemaCXX/coreturn-eh.cpp
  clang/test/SemaCXX/coreturn.cpp
  clang/test/SemaCXX/coroutine-final-suspend-noexcept.cpp
  clang/test/SemaCXX/coroutine-rvo.cpp
  clang/test/SemaCXX/coroutine-unhandled_exception-warning.cpp
  clang/test/SemaCXX/coroutine-uninitialized-warning-crash.cpp
  clang/test/SemaCXX/coroutines.cpp

Index: clang/test/SemaCXX/coroutines.cpp
===
--- clang/test/SemaCXX/coroutines.cpp
+++ clang/test/SemaCXX/coroutines.cpp
@@ -52,21 +52,24 @@
 };
 
 struct awaitable {
-  bool await_ready();
-  template  void await_suspend(F);
-  void await_resume();
+  bool await_ready() noexcept;
+  template 
+  void await_suspend(F) noexcept;
+  void await_resume() noexcept;
 } a;
 
 struct suspend_always {
-  bool await_ready() { return false; }
-  template  void await_suspend(F);
-  void await_resume() {}
+  bool await_ready() noexcept { return false; }
+  template 
+  void await_suspend(F) noexcept;
+  void await_resume() noexcept {}
 };
 
 struct suspend_never {
-  bool await_ready() { return true; }
-  template  void await_suspend(F);
-  void await_resume() {}
+  bool await_ready() noexcept { return true; }
+  template 
+  void await_suspend(F) noexcept;
+  void await_resume() noexcept {}
 };
 
 struct auto_await_suspend {
@@ -127,7 +130,7 @@
 struct promise {
   void get_return_object();
   suspend_always initial_suspend();
-  suspend_always final_suspend();
+  suspend_always final_suspend() noexcept;
   awaitable yield_value(int); // expected-note 2{{candidate}}
   awaitable yield_value(yielded_thing); // expected-note 2{{candidate}}
   not_awaitable yield_value(void()); // expected-note 2{{candidate}}
@@ -138,7 +141,7 @@
 struct promise_void {
   void get_return_object();
   suspend_always initial_suspend();
-  suspend_always final_suspend();
+  suspend_always final_suspend() noexcept;
   void return_void();
   void unhandled_exception();
 };
@@ -152,13 +155,13 @@
 namespace experimental {
 template 
 struct coroutine_handle {
-  static coroutine_handle from_address(void *);
+  static coroutine_handle from_address(void *) noexcept;
 };
 template <>
 struct coroutine_handle {
   template 
-  coroutine_handle(coroutine_handle);
-  static coroutine_handle from_address(void *);
+  coroutine_handle(coroutine_handle) noexcept;
+  static coroutine_handle from_address(void *) noexcept;
 };
 }} // namespace std::experimental
 
@@ -402,7 +405,7 @@
 
 namespace adl_ns {
 struct coawait_arg_type {};
-awaitable operator co_await(coawait_arg_type);
+awaitable operator co_await(coawait_arg_type) noexcept;
 }
 
 namespace dependent_operator_co_await_lookup {
@@ -434,7 +437,7 @@
 typedef transform_awaitable await_arg;
 coro get_return_object();
 transformed initial_suspend();
-::adl_ns::coawait_arg_type final_suspend();
+::adl_ns::coawait_arg_type final_suspend() noexcept;
 transformed await_transform(transform_awaitable);
 void unhandled_exception();
 void return_void();
@@ -444,7 +447,7 @@
 typedef AwaitArg await_arg;
 coro get_return_object();
 awaitable initial_suspend();
-awaitable final_suspend();
+awaitable final_suspend() noexcept;
 void unhandled_exception();
 void return_void();
   };
@@ -529,7 +532,7 @@
 void return_value(int());
 
 suspend_never initial_suspend();
-suspend_never final_suspend();
+suspend_never final_suspend() 

[PATCH] D79910: [x86][seses] Add clang flag; Use lvi-cfi with seses

2020-06-19 Thread Zola Bridges via Phabricator via cfe-commits
zbrid updated this revision to Diff 272105.
zbrid marked an inline comment as done.
zbrid added a comment.

Update Clang Command Ref with automated tool


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79910

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Arch/X86.cpp
  clang/test/Driver/x86-target-features.c
  llvm/lib/Target/X86/X86.td
  llvm/lib/Target/X86/X86SpeculativeExecutionSideEffectSuppression.cpp
  llvm/lib/Target/X86/X86Subtarget.h

Index: llvm/lib/Target/X86/X86Subtarget.h
===
--- llvm/lib/Target/X86/X86Subtarget.h
+++ llvm/lib/Target/X86/X86Subtarget.h
@@ -437,6 +437,9 @@
   /// POP+LFENCE+JMP sequence.
   bool UseLVIControlFlowIntegrity = false;
 
+  /// Enable Speculative Execution Side Effect Suppression
+  bool UseSpeculativeExecutionSideEffectSuppression = false;
+
   /// Insert LFENCE instructions to prevent data speculatively injected into
   /// loads from being used maliciously.
   bool UseLVILoadHardening = false;
@@ -744,6 +747,9 @@
   bool useGLMDivSqrtCosts() const { return UseGLMDivSqrtCosts; }
   bool useLVIControlFlowIntegrity() const { return UseLVIControlFlowIntegrity; }
   bool useLVILoadHardening() const { return UseLVILoadHardening; }
+  bool useSpeculativeExecutionSideEffectSuppression() const {
+return UseSpeculativeExecutionSideEffectSuppression;
+  }
 
   unsigned getPreferVectorWidth() const { return PreferVectorWidth; }
   unsigned getRequiredVectorWidth() const { return RequiredVectorWidth; }
Index: llvm/lib/Target/X86/X86SpeculativeExecutionSideEffectSuppression.cpp
===
--- llvm/lib/Target/X86/X86SpeculativeExecutionSideEffectSuppression.cpp
+++ llvm/lib/Target/X86/X86SpeculativeExecutionSideEffectSuppression.cpp
@@ -86,13 +86,14 @@
 
 bool X86SpeculativeExecutionSideEffectSuppression::runOnMachineFunction(
 MachineFunction ) {
-  if (!EnableSpeculativeExecutionSideEffectSuppression)
+  const X86Subtarget  = MF.getSubtarget();
+  if (!Subtarget.useSpeculativeExecutionSideEffectSuppression() &&
+  !EnableSpeculativeExecutionSideEffectSuppression)
 return false;
 
   LLVM_DEBUG(dbgs() << "** " << getPassName() << " : " << MF.getName()
 << " **\n");
   bool Modified = false;
-  const X86Subtarget  = MF.getSubtarget();
   const X86InstrInfo *TII = Subtarget.getInstrInfo();
   for (MachineBasicBlock  : MF) {
 MachineInstr *FirstTerminator = nullptr;
Index: llvm/lib/Target/X86/X86.td
===
--- llvm/lib/Target/X86/X86.td
+++ llvm/lib/Target/X86/X86.td
@@ -435,6 +435,13 @@
   "ourselves. Only has effect when combined with some other retpoline "
   "feature", [FeatureRetpolineIndirectCalls]>;
 
+// Enable SESES to mitigate speculative execution attacks
+def FeatureSpeculativeExecutionSideEffectSuppression
+: SubtargetFeature<
+  "seses", "UseSpeculativeExecutionSideEffectSuppression", "true",
+  "Prevent speculative execution side channel timing attacks by "
+  "inserting a speculation barrier before memory reads, memory writes, "
+  "and conditional branches.">;
 // Mitigate LVI attacks against indirect calls/branches and call returns
 def FeatureLVIControlFlowIntegrity
 : SubtargetFeature<
Index: clang/test/Driver/x86-target-features.c
===
--- clang/test/Driver/x86-target-features.c
+++ clang/test/Driver/x86-target-features.c
@@ -178,6 +178,27 @@
 // RUN: %clang -target i386-linux-gnu -mlvi-hardening -mretpoline-external-thunk %s -### -o %t.o 2>&1 | FileCheck -check-prefix=LVIHARDENING-RETPOLINE-EXTERNAL-THUNK %s
 // LVIHARDENING-RETPOLINE-EXTERNAL-THUNK: error: invalid argument 'mretpoline-external-thunk' not allowed with 'mlvi-hardening'
 
+// RUN: %clang -target i386-linux-gnu -mseses %s -### -o %t.o 2>&1 | FileCheck -check-prefix=SESES %s
+// RUN: %clang -target i386-linux-gnu -mno-seses %s -### -o %t.o 2>&1 | FileCheck -check-prefix=NO-SESES %s
+// SESES: "-target-feature" "+seses"
+// SESES: "-target-feature" "+lvi-cfi"
+// NO-SESES-NOT: seses
+// NO-SESES-NOT: lvi-cfi
+
+// RUN: %clang -target i386-linux-gnu -mseses -mno-lvi-cfi %s -### -o %t.o 2>&1 | FileCheck -check-prefix=SESES-NOLVICFI %s
+// SESES-NOLVICFI: "-target-feature" "+seses"
+// SESES-NOLVICFI-NOT: lvi-cfi
+
+// RUN: %clang -target i386-linux-gnu -mseses -mspeculative-load-hardening %s -### -o %t.o 2>&1 | FileCheck -check-prefix=SESES-SLH %s
+// SESES-SLH: error: invalid argument 'mspeculative-load-hardening' not allowed with 'mseses'
+// RUN: %clang -target i386-linux-gnu -mseses -mretpoline %s -### -o %t.o 2>&1 | FileCheck -check-prefix=SESES-RETPOLINE %s
+// SESES-RETPOLINE: error: 

[PATCH] D82126: [libTooling] Change Transformer's `cat` to handle some cases of text in macros.

2020-06-19 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel added a comment.

Tests show that this breaks the test for the clang tidy 
`abseil-string-find-str-contains`.  Curious if this is a desirable change in 
behavior (in which case I'll update your test file) or the wrong behavior:

https://github.com/llvm/llvm-project/blob/master/clang-tools-extra/test/clang-tidy/checkers/abseil-string-find-str-contains.cpp#L246-L252

  void no_macros() {
 std::string s;
  -  COMPARE_MACRO(s.find("a"), std::string::npos);
  -  FIND_MACRO(s, "a") == std::string::npos;
  -  FIND_COMPARE_MACRO(s, "a", std::string::npos);
  +  !absl::StrContains(s, "a");
  +  !absl::StrContains(s, "a");
  +  !absl::StrContains(s, "a");
   }


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82126



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


[PATCH] D82182: [AArch64][SVE] Add bfloat16 support to perm and select intrinsics

2020-06-19 Thread David Sherwood via Phabricator via cfe-commits
david-arm accepted this revision.
david-arm 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/D82182/new/

https://reviews.llvm.org/D82182



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


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

2020-06-19 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny accepted this revision.
jdenny added a comment.
This revision is now accepted and ready to land.

In D81736#2103822 , @clementval wrote:

> @jdoerfert @jdenny Should we wait until Monday to go ahead with this patch? I 
> have several other patches that will follow this one.


One week is the usual grace period.  If @jdoerfert is happy at this point, I'm 
happy.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81736



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


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

2020-06-19 Thread Dmitry Polukhin via Phabricator via cfe-commits
DmitryPolukhin added a comment.

It looks like there is no support for the proposed solution so I found 
alternative solution that might be even better. We can use double quotation `"` 
for multiline strings. It solves problem because in case of double quotation 
LLVM escapes new line like `\n` so there is no need to double newlines. Escaped 
newlines can be parsed correctly by other YAML parsers like pyyaml. BTW, LLVM 
YAML reading also has issue with not removing leading spaces for multiline 
strings so multiline strings serialised by pyyaml with single quotation cannot 
be parsed correctly by clang-apply-replacements. With double quotation it seems 
to work fine in both directions.

What do you think about using double quotation for multiline strings?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80301



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


[PATCH] D82186: [AArch64][SVE] Add bfloat16 support to svlen intrinsic

2020-06-19 Thread Cullen Rhodes via Phabricator via cfe-commits
c-rhodes added inline comments.



Comment at: clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_len.c:2
 // REQUIRES: aarch64-registered-target
-// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -triple aarch64-none-linux-gnu 
-target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall 
-emit-llvm -o - %s | FileCheck %s
-// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -DSVE_OVERLOADED_FORMS -triple 
aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns 
-S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s
-// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -triple aarch64-none-linux-gnu 
-target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -o 
- %s >/dev/null 2>%t
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC 
-D__ARM_FEATURE_SVE_BF16 -triple aarch64-none-linux-gnu -target-feature +sve 
-target-feature +bf16 -fallow-half-arguments-and-returns -S -O1 -Werror -Wall 
-emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC 
-D__ARM_FEATURE_SVE_BF16 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu 
-target-feature +sve -target-feature +bf16 -fallow-half-arguments-and-returns 
-S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s

fpetrogalli wrote:
> We said `ARM_FEATURE_BF16_SCALAR_ARITHMETIC` is implied by 
> `__ARM_FEATURE_SVE_BF16`, so I think you should remove this macro definition.
that's correct but it's not handled yet, `__ARM_FEATURE_SVE_BF16` isn't enabled 
as the implementation is incomplete, it'll eventually be enabled in the driver, 
but for now we need to explicitly define both macros in all tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82186



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


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

2020-06-19 Thread Valentin Clement via Phabricator via cfe-commits
clementval added a comment.

@jdoerfert @jdenny Should we wait until Monday to go ahead with this patch? I 
have several other patches that will follow this one.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81736



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


[PATCH] D81407: [Analyzer][StreamChecker] Add note tags for file opening.

2020-06-19 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added a comment.

So for this patch it would be OK to have the uniqueing location as it is now. A 
next large change can be to add the global resource leak report uniqueing 
feature, this changes anyway more existing checkers (including this one). 
(Still I want to finish other improvements in the `StreamChecker`.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81407



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


[PATCH] D82187: [AArch64][SVE] ACLE: Add bfloat16 to struct load/stores.

2020-06-19 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen marked 2 inline comments as done.
sdesmalen added inline comments.



Comment at: clang/include/clang/Basic/AArch64SVEACLETypes.def:69
 
-SVE_VECTOR_TYPE("__SVBFloat16_t", "__SVBFloat16_t", SveBFloat16, 
SveBFloat16Ty, 8, 16, false, false, true)
+SVE_VECTOR_TYPE("__SVBFloat16_t", "__SVBFloat16_t", SveBFloat16, 
SveBFloat16Ty, 8, 16, true, false, true)
 

fpetrogalli wrote:
> Why did you have to set `IsFP = true`? Seems like an unrelated change?
It's more for consistency with the other definitions (svfloat16/svfloat32/..) 
but is otherwise a non-functional change.



Comment at: clang/utils/TableGen/SveEmitter.cpp:541
 Float = false;
+BFloat = false;
 ElementBitwidth /= 4;

fpetrogalli wrote:
> Are these needed? I don't understand the rule for when to be specific on the 
> values of these variables.
For this patch, it's needed for `'l'` because otherwise it will incorrectly 
assume the type is bfloat if the type specifier is `b`.
It similarly applies to all the other modifiers that are defined as being of 
type `integer`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82187



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


[PATCH] D82126: [libTooling] Change Transformer's `cat` to handle some cases of text in macros.

2020-06-19 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel added a comment.

In D82126#2103772 , @tdl-g wrote:

> LGTM.  I found the change description confusing, since it talks about the 
> selection() stencil but the code is all about the cat() stencil.  I realize 
> (now) that the former is deprecated in favor of the latter.  But the change 
> description is still confusing.


Whoops, I'd forgotten that we'd deprecated that combinator. Thanks for catching 
that. I've updated the description correspondingly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82126



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


[PATCH] D82188: [clang-tidy] Reworked enum options handling(again)

2020-06-19 Thread Nathan James via Phabricator via cfe-commits
njames93 marked an inline comment as done.
njames93 added inline comments.
Herald added a subscriber: wuzish.



Comment at: 
clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp:30
   Options.store(Opts, "GslHeader", GslHeader);
   Options.store(Opts, "IncludeStyle", IncludeStyle);
 }

As a side bonus, this originally incorrect code would cast IncludeStyle to an 
int, then store that value. Now it will store it as the correct enum. Any other 
enums passed to store will error out if there is no mapping specialization for 
them, forcing you to either declare the mapping or cast it to an integer type


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82188



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


[PATCH] D82178: [AArch64][SVE] Guard svbfloat16_t with feature macro in ACLE

2020-06-19 Thread Cullen Rhodes via Phabricator via cfe-commits
c-rhodes updated this revision to Diff 272091.
c-rhodes added a comment.

Changes:

- Include `arm_bf16.h` if `__ARM_FEATURE_BF16_SCALAR_ARITHMETIC` is defined.


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

https://reviews.llvm.org/D82178

Files:
  clang/include/clang/Basic/arm_sve.td
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1ro-bfloat.c
  clang/utils/TableGen/SveEmitter.cpp


Index: clang/utils/TableGen/SveEmitter.cpp
===
--- clang/utils/TableGen/SveEmitter.cpp
+++ clang/utils/TableGen/SveEmitter.cpp
@@ -1085,10 +1085,20 @@
   OS << "typedef __SVUint16_t svuint16_t;\n";
   OS << "typedef __SVUint32_t svuint32_t;\n";
   OS << "typedef __SVUint64_t svuint64_t;\n";
-  OS << "typedef __SVFloat16_t svfloat16_t;\n";
-  OS << "typedef __SVBFloat16_t svbfloat16_t;\n\n";
+  OS << "typedef __SVFloat16_t svfloat16_t;\n\n";
 
-  OS << "#ifdef __ARM_FEATURE_BF16_SCALAR_ARITHMETIC\n";
+  OS << "#if defined(__ARM_FEATURE_SVE_BF16) && "
+"!defined(__ARM_FEATURE_BF16_SCALAR_ARITHMETIC)\n";
+  OS << "#error \"__ARM_FEATURE_BF16_SCALAR_ARITHMETIC must be defined when "
+"__ARM_FEATURE_SVE_BF16 is defined\"\n";
+  OS << "#endif\n\n";
+
+  OS << "#if defined(__ARM_FEATURE_SVE_BF16)\n";
+  OS << "typedef __SVBFloat16_t svbfloat16_t;\n";
+  OS << "#endif\n\n";
+
+  OS << "#if defined(__ARM_FEATURE_BF16_SCALAR_ARITHMETIC)\n";
+  OS << "#include \n";
   OS << "typedef __bf16 bfloat16_t;\n";
   OS << "#endif\n\n";
 
Index: clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1ro-bfloat.c
===
--- clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1ro-bfloat.c
+++ clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1ro-bfloat.c
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -D__ARM_FEATURE_SVE_MATMUL_FP64 
-D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC -D__ARM_FEATURE_SVE -triple 
aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 
-fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | 
FileCheck %s
-// RUN: %clang_cc1 -D__ARM_FEATURE_SVE_MATMUL_FP64 
-D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC -D__ARM_FEATURE_SVE 
-DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve 
-target-feature +bf16 -fallow-half-arguments-and-returns -S -O1 -Werror -Wall 
-emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE_MATMUL_FP64 -D__ARM_FEATURE_SVE_BF16 
-D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC -D__ARM_FEATURE_SVE -triple 
aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 
-fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | 
FileCheck %s
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE_MATMUL_FP64 -D__ARM_FEATURE_SVE_BF16 
-D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC -D__ARM_FEATURE_SVE 
-DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve 
-target-feature +bf16 -fallow-half-arguments-and-returns -S -O1 -Werror -Wall 
-emit-llvm -o - %s | FileCheck %s
 
 #include 
 
Index: clang/include/clang/Basic/arm_sve.td
===
--- clang/include/clang/Basic/arm_sve.td
+++ clang/include/clang/Basic/arm_sve.td
@@ -484,8 +484,8 @@
 let ArchGuard = "defined(__ARM_FEATURE_SVE_MATMUL_FP64)" in {
   def SVLD1RO : SInst<"svld1ro[_{2}]", "dPc", "csilUcUsUiUlhfd", MergeNone, 
"aarch64_sve_ld1ro">;
 }
-let ArchGuard = "defined(__ARM_FEATURE_SVE_MATMUL_FP64) && 
defined(__ARM_FEATURE_BF16_SCALAR_ARITHMETIC)" in {
-  def SVLD1RO_BF : SInst<"svld1ro[_{2}]", "dPc", "b", MergeNone, 
"aarch64_sve_ld1ro">;
+let ArchGuard = "defined(__ARM_FEATURE_SVE_MATMUL_FP64) && 
defined(__ARM_FEATURE_SVE_BF16)" in {
+  def SVLD1RO_BF16 : SInst<"svld1ro[_{2}]", "dPc", "b", MergeNone, 
"aarch64_sve_ld1ro">;
 }
 

 // Stores


Index: clang/utils/TableGen/SveEmitter.cpp
===
--- clang/utils/TableGen/SveEmitter.cpp
+++ clang/utils/TableGen/SveEmitter.cpp
@@ -1085,10 +1085,20 @@
   OS << "typedef __SVUint16_t svuint16_t;\n";
   OS << "typedef __SVUint32_t svuint32_t;\n";
   OS << "typedef __SVUint64_t svuint64_t;\n";
-  OS << "typedef __SVFloat16_t svfloat16_t;\n";
-  OS << "typedef __SVBFloat16_t svbfloat16_t;\n\n";
+  OS << "typedef __SVFloat16_t svfloat16_t;\n\n";
 
-  OS << "#ifdef __ARM_FEATURE_BF16_SCALAR_ARITHMETIC\n";
+  OS << "#if defined(__ARM_FEATURE_SVE_BF16) && "
+"!defined(__ARM_FEATURE_BF16_SCALAR_ARITHMETIC)\n";
+  OS << "#error \"__ARM_FEATURE_BF16_SCALAR_ARITHMETIC must be defined when "
+"__ARM_FEATURE_SVE_BF16 is defined\"\n";
+  OS << "#endif\n\n";
+
+  OS << "#if defined(__ARM_FEATURE_SVE_BF16)\n";
+  OS << "typedef __SVBFloat16_t svbfloat16_t;\n";
+  OS << "#endif\n\n";
+
+  OS << "#if defined(__ARM_FEATURE_BF16_SCALAR_ARITHMETIC)\n";
+  OS << "#include \n";
   OS << "typedef 

[PATCH] D82126: [libTooling] Change `selection` stencil to handle some cases of text in macros.

2020-06-19 Thread Tom Lokovic via Phabricator via cfe-commits
tdl-g added a comment.

LGTM.  I found the change description confusing, since it talks about the 
selection() stencil but the code is all about the cat() stencil.  I realize 
(now) that the former is deprecated in favor of the latter.  But the change 
description is still confusing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82126



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


[PATCH] D82199: [clang-format] restore indent in conditionals AlignOperands is DontAlign

2020-06-19 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
krasimir edited the summary of this revision.

After D50078 , we're experiencing unexpected 
un-indent using a style combining `AlignOperands: DontAlign` with 
`BreakBeforeTernaryOperators: false`, such as Google's JavaScript style:

  % bin/clang-format -style=google ~/test.js
  aaa =  ? cc() :
  dd ? ee :
   f;

The issue lies with the interaction of `AlignOperands: DontAlign` and the 
edited code section in ContinuationIndenter.cpp, which de-dents the intent by 
`Style.ContinuationIndentWidth`. From the documentation 

 of AlignOperands: DontAlign:

> The wrapped lines are indented `ContinuationIndentWidth` spaces from the 
> start of the line.

So the de-dent effectively erases the necessary `ContinuationIndentWidth` in 
that case.

This patch restores the `AlignOperands: DontAlign` behavior, producing:

  % bin/clang-format -style=google ~/test.js
  aaa =  ? cc() :
  dd ? ee :
   f;


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82199

Files:
  clang/lib/Format/ContinuationIndenter.cpp
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -6281,6 +6281,13 @@
"   : bbb ? \n"
" : ;",
Style);
+
+  Style.AlignOperands = FormatStyle::OAS_DontAlign;
+  Style.BreakBeforeTernaryOperators = false;
+  verifyFormat("int x = aaa ? aa :\n"
+   "? cc :\n"
+   "  d;\n",
+   Style);
 }
 
 TEST_F(FormatTest, BreaksConditionalExpressionsAfterOperator) {
Index: clang/lib/Format/ContinuationIndenter.cpp
===
--- clang/lib/Format/ContinuationIndenter.cpp
+++ clang/lib/Format/ContinuationIndenter.cpp
@@ -1041,8 +1041,10 @@
   //* not remove the 'lead' ContinuationIndentWidth
   //* always un-indent by the operator when
   //BreakBeforeTernaryOperators=true
-  unsigned Indent =
-  State.Stack.back().Indent - Style.ContinuationIndentWidth;
+  unsigned Indent = State.Stack.back().Indent;
+  if (Style.AlignOperands != FormatStyle::OAS_DontAlign) {
+Indent -= Style.ContinuationIndentWidth;
+  }
   if (Style.BreakBeforeTernaryOperators &&
   State.Stack.back().UnindentOperator)
 Indent -= 2;


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -6281,6 +6281,13 @@
"   : bbb ? \n"
" : ;",
Style);
+
+  Style.AlignOperands = FormatStyle::OAS_DontAlign;
+  Style.BreakBeforeTernaryOperators = false;
+  verifyFormat("int x = aaa ? aa :\n"
+   "? cc :\n"
+   "  d;\n",
+   Style);
 }
 
 TEST_F(FormatTest, BreaksConditionalExpressionsAfterOperator) {
Index: clang/lib/Format/ContinuationIndenter.cpp
===
--- clang/lib/Format/ContinuationIndenter.cpp
+++ clang/lib/Format/ContinuationIndenter.cpp
@@ -1041,8 +1041,10 @@
   //* not remove the 'lead' ContinuationIndentWidth
   //* always un-indent by the operator when
   //BreakBeforeTernaryOperators=true
-  unsigned Indent =
-  State.Stack.back().Indent - Style.ContinuationIndentWidth;
+  unsigned Indent = State.Stack.back().Indent;
+  if (Style.AlignOperands != FormatStyle::OAS_DontAlign) {
+Indent -= Style.ContinuationIndentWidth;
+  }
   if (Style.BreakBeforeTernaryOperators &&
   State.Stack.back().UnindentOperator)
 Indent -= 2;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D67321: Respect CLANG_LINK_CLANG_DYLIB=ON in libclang and c-index-test

2020-06-19 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

Ping. The current state is that c-index-test crashes for us, and I'd like to 
see it fixed for 10.0.1. I have a patch of my own but it doesn't handle all 
that `_static` magic, so I guess this one's better.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67321



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


[PATCH] D82182: [AArch64][SVE] Add bfloat16 support to perm and select intrinsics

2020-06-19 Thread Francesco Petrogalli via Phabricator via cfe-commits
fpetrogalli added inline comments.



Comment at: clang/include/clang/Basic/arm_sve.td:1115
 
+let ArchGuard = "defined(__ARM_FEATURE_SVE_BF16)" in {
+def SVREV_BF16: SInst<"svrev[_{d}]","dd",   "b", MergeNone, 
"aarch64_sve_rev">;

nit: could create a multiclass here like @sdesmalen have done in 
https://reviews.llvm.org/D82187, seems quite a nice way to keep the definition 
of the intrinsics together (look for `multiclass StructLoad`, for example)



Comment at: clang/include/clang/Basic/arm_sve.td:1298
 
+let ArchGuard = "defined(__ARM_FEATURE_SVE_MATMUL_FP64) && 
defined(__ARM_FEATURE_SVE_BF16)" in {
+def SVTRN1Q_BF16  : SInst<"svtrn1q[_{d}]", "ddd",  "b", MergeNone, 
"aarch64_sve_trn1q">;

Same here, could use a multiclass to merge the "regular" intrinsics definition 
with the BF ones.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82182



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


[PATCH] D82186: [AArch64][SVE] Add bfloat16 support to svlen intrinsic

2020-06-19 Thread Francesco Petrogalli via Phabricator via cfe-commits
fpetrogalli added inline comments.



Comment at: clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_len.c:2
 // REQUIRES: aarch64-registered-target
-// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -triple aarch64-none-linux-gnu 
-target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall 
-emit-llvm -o - %s | FileCheck %s
-// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -DSVE_OVERLOADED_FORMS -triple 
aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns 
-S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s
-// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -triple aarch64-none-linux-gnu 
-target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -o 
- %s >/dev/null 2>%t
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC 
-D__ARM_FEATURE_SVE_BF16 -triple aarch64-none-linux-gnu -target-feature +sve 
-target-feature +bf16 -fallow-half-arguments-and-returns -S -O1 -Werror -Wall 
-emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC 
-D__ARM_FEATURE_SVE_BF16 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu 
-target-feature +sve -target-feature +bf16 -fallow-half-arguments-and-returns 
-S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s

We said `ARM_FEATURE_BF16_SCALAR_ARITHMETIC` is implied by 
`__ARM_FEATURE_SVE_BF16`, so I think you should remove this macro definition.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82186



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


[PATCH] D80025: [ASTMatcher] Correct memoization bug ignoring direction (descendants or ancestors)

2020-06-19 Thread Loïc Joly via Phabricator via cfe-commits
loic-joly-sonarsource added a comment.

Can someone with write access merge this please?
Thank you!


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

https://reviews.llvm.org/D80025



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


[PATCH] D82181: [clang-format] indent in chained conditionals when AlignOperands:DontAlign

2020-06-19 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir updated this revision to Diff 272084.
krasimir added a comment.

- add a regression test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82181

Files:
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -6281,6 +6281,13 @@
"   : bbb ? \n"
" : ;",
Style);
+
+  Style.AlignOperands = FormatStyle::OAS_DontAlign;
+  Style.BreakBeforeTernaryOperators = false;
+  verifyFormat("int x = aaa ? aa :\n"
+   "? cc :\n"
+   "  d;\n",
+   Style);
 }
 
 TEST_F(FormatTest, BreaksConditionalExpressionsAfterOperator) {


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -6281,6 +6281,13 @@
"   : bbb ? \n"
" : ;",
Style);
+
+  Style.AlignOperands = FormatStyle::OAS_DontAlign;
+  Style.BreakBeforeTernaryOperators = false;
+  verifyFormat("int x = aaa ? aa :\n"
+   "? cc :\n"
+   "  d;\n",
+   Style);
 }
 
 TEST_F(FormatTest, BreaksConditionalExpressionsAfterOperator) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D82187: [AArch64][SVE] ACLE: Add bfloat16 to struct load/stores.

2020-06-19 Thread Francesco Petrogalli via Phabricator via cfe-commits
fpetrogalli added inline comments.



Comment at: clang/include/clang/Basic/AArch64SVEACLETypes.def:69
 
-SVE_VECTOR_TYPE("__SVBFloat16_t", "__SVBFloat16_t", SveBFloat16, 
SveBFloat16Ty, 8, 16, false, false, true)
+SVE_VECTOR_TYPE("__SVBFloat16_t", "__SVBFloat16_t", SveBFloat16, 
SveBFloat16Ty, 8, 16, true, false, true)
 

Why did you have to set `IsFP = true`? Seems like an unrelated change?



Comment at: clang/utils/TableGen/SveEmitter.cpp:541
 Float = false;
+BFloat = false;
 ElementBitwidth /= 4;

Are these needed? I don't understand the rule for when to be specific on the 
values of these variables.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82187



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


[PATCH] D81571: [analyzer] SATest: Add initial docker infrastructure

2020-06-19 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added a comment.
This revision is now accepted and ready to land.

Ok then!




Comment at: clang/utils/analyzer/entrypoint.py:31
+
+CMAKE_COMMAND = "cmake -G Ninja -DCMAKE_BUILD_TYPE=Release " \
+"-DCMAKE_INSTALL_PREFIX=/analyzer -DLLVM_TARGETS_TO_BUILD=X86 " \

vsavchenko wrote:
> NoQ wrote:
> > `-DLLVM_ENABLE_ASSERTIONS=ON`???
> I was thinking about adding a separate list of options specifically for 
> building.  Assertions can significantly affect performance and I don't know 
> if that should be a default.
I still think assertions should be on by default; it's much worse when somebody 
accidentally tests a logic-related patch without assertions than when somebody 
tests a performance-related patch with assertions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81571



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


[PATCH] D82122: [analyzer][Liveness][RFC][NFC] Propose to turn statement liveness into expression liveness

2020-06-19 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

I think you're right, this entire thing only makes sense for expressions. I 
think `Environment` occasionally carries values of `ReturnStmt`s (by which it 
means values of their sub-expressions) but even then liveness analysis doesn't 
need to be aware of that flex.

> no lit tests crashed on the added asserts



> the only non-expression statement it queries are `ObjCForCollectionStmt`s

Wait, how did you figure that out if not through crashing tests?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82122



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


[PATCH] D81601: [analyzer] SATest: Use logger in single-threaded mode as well

2020-06-19 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added a comment.
This revision is now accepted and ready to land.

Aha ok nvm then!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81601



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


[PATCH] D81592: [analyzer] SATest: Add a set of initial projects for testing

2020-06-19 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: clang/utils/analyzer/projects/box2d/run_static_analyzer.cmd:1
+cmake . -DCMAKE_BUILD_TYPE=Release -Bbuild -GNinja
+cmake --build build

vsavchenko wrote:
> NoQ wrote:
> > Is there a flag to enable assertions or something like that? Usually we 
> > recommend people to enable assertions during analysis. It's also valuable 
> > to test that assertions are actually working.
> > 
> > Disabling assertions is in fact relatively good for reference results 
> > testing because all the false positives that they suppress are suddenly 
> > visible, and therefore the signal we receive from such testing is amplified 
> > significantly. But i wouldn't force such workflow on our 
> > solution-for-everyone because that requires a certain level of masochism in 
> > order to distinguish between "my patch introduced a false positive and it's 
> > bad" and "my patch introduced a false positive but it would have been 
> > suppressed by assertions and we do actually want to emit the warning in 
> > absence of assertions so it's good".
> CMake doesn't have a unified solution for "Release with assertions" type of 
> build.  It is usually done on per-project basis (like in LLVM).  I guess 
> rather than searching for such a flag for every project, we can indeed change 
> it to **Debug**.
Maybe something like `-DCMAKE_C_FLAGS=-UNDEBUG` could also work (or use 
`scan-build --force-analyze-debug-code` which is basically the same thing) but 
choosing `Debug` indeed sounds like the sanest solution.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81592



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


[PATCH] D82103: [analyzer] Remove forbidden characters from a SourceLocation filename for a graph dump on Windows

2020-06-19 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: clang/utils/analyzer/exploded-graph-rewriter.py:383
+# when directory name starts with the letter `l`.
+if sys.platform == 'win32':
+# Find all `\l` (like `,\l`, `}\l`, `[\l`) except `\\l`,

I think this too doesn't need to be platform specific(?)


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

https://reviews.llvm.org/D82103



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


  1   2   >