[clang] fd33cca - [clang-format] Fix AlignConsecutiveAssignments breaking lambda formatting.

2022-02-01 Thread Marek Kurdej via cfe-commits

Author: Marek Kurdej
Date: 2022-02-01T09:17:59+01:00
New Revision: fd33cca762fac265d28abbb080eec57f011f7cb4

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

LOG: [clang-format] Fix AlignConsecutiveAssignments breaking lambda formatting.

Fixes https://github.com/llvm/llvm-project/issues/52772.

This patch fixes the formatting of the code:
```
auto a = {};
auto b = g([] {
  return;
});
```
which should be left as is, but before this patch was formatted to:
```
auto a = {};
auto b = g([] {
  return;
});
```

Reviewed By: MyDeveloperDay, HazardyKnusperkeks

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

Added: 


Modified: 
clang/lib/Format/WhitespaceManager.cpp
clang/unittests/Format/FormatTest.cpp

Removed: 




diff  --git a/clang/lib/Format/WhitespaceManager.cpp 
b/clang/lib/Format/WhitespaceManager.cpp
index 0d2e507ac587..f868c9d5752f 100644
--- a/clang/lib/Format/WhitespaceManager.cpp
+++ b/clang/lib/Format/WhitespaceManager.cpp
@@ -344,6 +344,10 @@ AlignTokenSequence(const FormatStyle &Style, unsigned 
Start, unsigned End,
 if (Changes[ScopeStart - 1].Tok->is(TT_FunctionDeclarationName))
   return true;
 
+// Lambda.
+if (Changes[ScopeStart - 1].Tok->is(TT_LambdaLBrace))
+  return false;
+
 // Continued function declaration
 if (ScopeStart > Start + 1 &&
 Changes[ScopeStart - 2].Tok->is(TT_FunctionDeclarationName))
@@ -352,8 +356,13 @@ AlignTokenSequence(const FormatStyle &Style, unsigned 
Start, unsigned End,
 // Continued function call
 if (ScopeStart > Start + 1 &&
 Changes[ScopeStart - 2].Tok->is(tok::identifier) &&
-Changes[ScopeStart - 1].Tok->is(tok::l_paren))
+Changes[ScopeStart - 1].Tok->is(tok::l_paren) &&
+Changes[ScopeStart].Tok->isNot(TT_LambdaLSquare)) {
+  if (Changes[i].Tok->MatchingParen &&
+  Changes[i].Tok->MatchingParen->is(TT_LambdaLBrace))
+return false;
   return Style.BinPackArguments;
+}
 
 // Ternary operator
 if (Changes[i].Tok->is(TT_ConditionalExpr))
@@ -372,8 +381,15 @@ AlignTokenSequence(const FormatStyle &Style, unsigned 
Start, unsigned End,
 if (ScopeStart > Start + 1 &&
 Changes[ScopeStart - 2].Tok->isNot(tok::identifier) &&
 Changes[ScopeStart - 1].Tok->is(tok::l_brace) &&
-Changes[i].Tok->isNot(tok::r_brace))
+Changes[i].Tok->isNot(tok::r_brace)) {
+  for (unsigned OuterScopeStart : llvm::reverse(ScopeStack)) {
+// Lambda.
+if (OuterScopeStart > Start &&
+Changes[OuterScopeStart - 1].Tok->is(TT_LambdaLBrace))
+  return false;
+  }
   return true;
+}
 
 return false;
   };

diff  --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index bbe3f53807e6..005e2d6a7b55 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -16571,6 +16571,43 @@ TEST_F(FormatTest, AlignConsecutiveAssignments) {
"int yy  = 1; ///specificlennospace\n"
"int zzz = 2;\n",
Alignment));
+
+  verifyFormat("auto a = {};\n"
+   "auto b = [] {\n"
+   "  f();\n"
+   "  return;\n"
+   "};",
+   Alignment);
+  verifyFormat("auto a = {};\n"
+   "auto b = g([] {\n"
+   "  f();\n"
+   "  return;\n"
+   "});",
+   Alignment);
+  verifyFormat("auto a = {};\n"
+   "auto b = g(param, [] {\n"
+   "  f();\n"
+   "  return;\n"
+   "});",
+   Alignment);
+  verifyFormat("auto a = {};\n"
+   "auto b = [] {\n"
+   "  if (condition) {\n"
+   "return;\n"
+   "  }\n"
+   "};",
+   Alignment);
+
+  verifyFormat("auto b = f(a,\n"
+   "   ccc ? a : b,\n"
+   "   dd);",
+   Alignment);
+  // FIXME: https://llvm.org/PR53497
+  // verifyFormat("auto  = f();\n"
+  //  "auto b= f(a,\n"
+  //  "ccc ? a : b,\n"
+  //  "dd);",
+  //  Alignment);
 }
 
 TEST_F(FormatT

[PATCH] D115972: [clang-format] Fix AlignConsecutiveAssignments breaking lambda formatting.

2022-02-01 Thread Marek Kurdej via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGfd33cca762fa: [clang-format] Fix AlignConsecutiveAssignments 
breaking lambda formatting. (authored by curdeius).

Changed prior to commit:
  https://reviews.llvm.org/D115972?vs=404438&id=404832#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115972

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


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -16571,6 +16571,43 @@
"int yy  = 1; ///specificlennospace\n"
"int zzz = 2;\n",
Alignment));
+
+  verifyFormat("auto a = {};\n"
+   "auto b = [] {\n"
+   "  f();\n"
+   "  return;\n"
+   "};",
+   Alignment);
+  verifyFormat("auto a = {};\n"
+   "auto b = g([] {\n"
+   "  f();\n"
+   "  return;\n"
+   "});",
+   Alignment);
+  verifyFormat("auto a = {};\n"
+   "auto b = g(param, [] {\n"
+   "  f();\n"
+   "  return;\n"
+   "});",
+   Alignment);
+  verifyFormat("auto a = {};\n"
+   "auto b = [] {\n"
+   "  if (condition) {\n"
+   "return;\n"
+   "  }\n"
+   "};",
+   Alignment);
+
+  verifyFormat("auto b = f(a,\n"
+   "   ccc ? a : b,\n"
+   "   dd);",
+   Alignment);
+  // FIXME: https://llvm.org/PR53497
+  // verifyFormat("auto  = f();\n"
+  //  "auto b= f(a,\n"
+  //  "ccc ? a : b,\n"
+  //  "dd);",
+  //  Alignment);
 }
 
 TEST_F(FormatTest, AlignConsecutiveBitFields) {
Index: clang/lib/Format/WhitespaceManager.cpp
===
--- clang/lib/Format/WhitespaceManager.cpp
+++ clang/lib/Format/WhitespaceManager.cpp
@@ -344,6 +344,10 @@
 if (Changes[ScopeStart - 1].Tok->is(TT_FunctionDeclarationName))
   return true;
 
+// Lambda.
+if (Changes[ScopeStart - 1].Tok->is(TT_LambdaLBrace))
+  return false;
+
 // Continued function declaration
 if (ScopeStart > Start + 1 &&
 Changes[ScopeStart - 2].Tok->is(TT_FunctionDeclarationName))
@@ -352,8 +356,13 @@
 // Continued function call
 if (ScopeStart > Start + 1 &&
 Changes[ScopeStart - 2].Tok->is(tok::identifier) &&
-Changes[ScopeStart - 1].Tok->is(tok::l_paren))
+Changes[ScopeStart - 1].Tok->is(tok::l_paren) &&
+Changes[ScopeStart].Tok->isNot(TT_LambdaLSquare)) {
+  if (Changes[i].Tok->MatchingParen &&
+  Changes[i].Tok->MatchingParen->is(TT_LambdaLBrace))
+return false;
   return Style.BinPackArguments;
+}
 
 // Ternary operator
 if (Changes[i].Tok->is(TT_ConditionalExpr))
@@ -372,8 +381,15 @@
 if (ScopeStart > Start + 1 &&
 Changes[ScopeStart - 2].Tok->isNot(tok::identifier) &&
 Changes[ScopeStart - 1].Tok->is(tok::l_brace) &&
-Changes[i].Tok->isNot(tok::r_brace))
+Changes[i].Tok->isNot(tok::r_brace)) {
+  for (unsigned OuterScopeStart : llvm::reverse(ScopeStack)) {
+// Lambda.
+if (OuterScopeStart > Start &&
+Changes[OuterScopeStart - 1].Tok->is(TT_LambdaLBrace))
+  return false;
+  }
   return true;
+}
 
 return false;
   };


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -16571,6 +16571,43 @@
"int yy  = 1; ///specificlennospace\n"
"int zzz = 2;\n",
Alignment));
+
+  verifyFormat("auto a = {};\n"
+   "auto b = [] {\n"
+   "  f();\n"
+   "  return;\n"
+   "};",
+   Alignment);
+  verifyFormat("auto a = {};\n"
+   "auto b = g([] {\n"
+   "  f();\n"
+   "  return;\n"
+   "});",
+   Alignment

[PATCH] D54943: [clang-tidy] implement const-transformation for cppcoreguidelines-const-correctness

2022-02-01 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth marked 2 inline comments as done.
JonasToth added inline comments.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-const-correctness-templates.cpp:16
+  int value_int = 42;
+  // CHECK-MESSAGES:[[@LINE-1]]:3: warning: variable 'value_int' of type 'int' 
can be declared 'const'
+}

LegalizeAdulthood wrote:
> `CHECK-FIXES`?
see my comment in the other test.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-const-correctness-transform-pointer-as-values.cpp:12
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local0' of type 
'double *' can be declared 'const'
+  // CHECK-FIXES: const
+}

0x8000- wrote:
> LegalizeAdulthood wrote:
> > Shouldn't this validate that the `const` was placed in the correct position?
> > e.g. `const double *` is a different meaning from `double *const`
> > 
> > Apply to all the other `CHECK-FIXES` as well
> Can we have the checker merged in first, then we can worry about the 
> automatic fixer?
the checker is its own utility with its own tests and proper test coverage.
yes `const double*` and `double* const` are different and are correctly 
inserted, but that is not tested here, but here: 
https://github.com/llvm/llvm-project/blob/main/clang-tools-extra/unittests/clang-tidy/AddConstTest.cpp

Similar to the actual `const` analysis. That has its own test-suite 
(https://github.com/llvm/llvm-project/blob/main/clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp)

The tests here are concerned with the diagnostics and "real" code. Afterall, 
this functionality is too complex to have all of it checked with these kind of 
tests.
I think the separate testing in specialized unit-tests (as is now) for the 
specialized functions is the right approach and the `CHECK-FIXES` are not 
necessary in this instance, maybe even bad, because it makes the tests 
unclearer.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D54943

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


[PATCH] D54943: [clang-tidy] implement const-transformation for cppcoreguidelines-const-correctness

2022-02-01 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth marked 2 inline comments as done.
JonasToth added inline comments.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-const-correctness-transform-pointer-as-values.cpp:12
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local0' of type 
'double *' can be declared 'const'
+  // CHECK-FIXES: const
+}

JonasToth wrote:
> 0x8000- wrote:
> > LegalizeAdulthood wrote:
> > > Shouldn't this validate that the `const` was placed in the correct 
> > > position?
> > > e.g. `const double *` is a different meaning from `double *const`
> > > 
> > > Apply to all the other `CHECK-FIXES` as well
> > Can we have the checker merged in first, then we can worry about the 
> > automatic fixer?
> the checker is its own utility with its own tests and proper test coverage.
> yes `const double*` and `double* const` are different and are correctly 
> inserted, but that is not tested here, but here: 
> https://github.com/llvm/llvm-project/blob/main/clang-tools-extra/unittests/clang-tidy/AddConstTest.cpp
> 
> Similar to the actual `const` analysis. That has its own test-suite 
> (https://github.com/llvm/llvm-project/blob/main/clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp)
> 
> The tests here are concerned with the diagnostics and "real" code. Afterall, 
> this functionality is too complex to have all of it checked with these kind 
> of tests.
> I think the separate testing in specialized unit-tests (as is now) for the 
> specialized functions is the right approach and the `CHECK-FIXES` are not 
> necessary in this instance, maybe even bad, because it makes the tests 
> unclearer.
sry: The _fixer_ is its own utility ...

Additionally: The test is run on big projects with transformation (LLVM, some 
Qt Stuff).
First everything is transformed and then recompiled. The compiler tells what 
was incorrectly inserted :)

Thats part of the testing too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D54943

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


[PATCH] D118652: Cleanup header dependencies in LLVMCore

2022-02-01 Thread serge via Phabricator via cfe-commits
serge-sans-paille added a comment.

Hi and thanks for taking the time to go through the review.

In D118652#3285601 , @MaskRay wrote:

> Thanks for working on this. I spot checked some files. In general it looks 
> great.
>
> One file replaces a forward declaration with `#include 
> "llvm/IR/BasicBlock.h"`.

Yeah. What happens is that header was previously implicitly included (and 
needed), I just made the include explicit (and the forward declaration useless)

> Some files add `#include "llvm/Support/ToolOutputFile.h"`.

Yeah, that's a consequence of `llvm/IR/LLVMRemarkStreamer.h no longer includes 
llvm/Support/ToolOutputFile.h`

> One files adds `class FunctionPass;`

Yeah, that happens when the file was implicitly including `llvm/Pass.h` but was 
actually only needing a forward declaration.

> Would you mind landing these addition changes separately to make the include 
> removal part more targeted?

The three changes above are tied to individual header removal in specific 
header. I could split that in smaller grain (say each header change + its 
impact on the codebase in individual commits), but that would mean that every 
"component" cleanup would consist in potentially dozens of commits. I 
understand the value of such fine-grain commits, but it means more care (and 
work!) on my side to handle more reviews, craft more decent commit message etc. 
I chose to split the cleanup per component to make review easier, have a decent 
idea of the impact on preprocessed lines. I'm trying to reflect in the commit 
message the major changes to help downstream users update their codebase.

If you really think the split would help the review process, I can do it, but 
please take into account the amount of work it adds on an already not 
super-creative task ;-)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118652

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


[PATCH] D118652: Cleanup header dependencies in LLVMCore

2022-02-01 Thread serge via Phabricator via cfe-commits
serge-sans-paille added a comment.

In D118652#3286018 , @mehdi_amini 
wrote:

> I'm not sure how it'd help clients of the released version of LLVM to delay, 
> the development branch and the release seems fairly disconnected to me from 
> this point of view.
> (what can help are deprecating APIs with instructions about how to update so 
> that they can update to the new API while targeting the current release)

I second that opinion.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118652

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


[PATCH] D117888: [clang][driver][wasm] Support -stdlib=libstdc++ for WebAssembly

2022-02-01 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder updated this revision to Diff 404849.

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

https://reviews.llvm.org/D117888

Files:
  clang/lib/Driver/ToolChains/WebAssembly.cpp
  clang/lib/Driver/ToolChains/WebAssembly.h
  clang/test/Driver/wasm-toolchain.cpp

Index: clang/test/Driver/wasm-toolchain.cpp
===
--- clang/test/Driver/wasm-toolchain.cpp
+++ clang/test/Driver/wasm-toolchain.cpp
@@ -19,6 +19,11 @@
 // LINK: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
 // LINK: wasm-ld{{.*}}" "-L/foo/lib" "crt1.o" "[[temp]]" "-lc++" "-lc++abi" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
 
+// RUN: %clangxx -### -no-canonical-prefixes -target wasm32-unknown-unknown --sysroot=/foo --stdlib=libstdc++ %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=LINK_STDCXX %s
+// LINK_STDCXX: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
+// LINK_STDCXX: wasm-ld{{.*}}" "-L/foo/lib" "crt1.o" "[[temp]]" "-lstdc++" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
+
 // A basic C++ link command-line with optimization with unknown OS.
 
 // RUN: %clangxx -### -O2 -no-canonical-prefixes -target wasm32-unknown-unknown --sysroot=/foo %s --stdlib=libc++ 2>&1 \
@@ -26,6 +31,11 @@
 // LINK_OPT: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
 // LINK_OPT: wasm-ld{{.*}}" "-L/foo/lib" "crt1.o" "[[temp]]" "-lc++" "-lc++abi" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
 
+// RUN: %clangxx -### -O2 -no-canonical-prefixes -target wasm32-unknown-unknown --sysroot=/foo %s --stdlib=libstdc++ 2>&1 \
+// RUN:   | FileCheck -check-prefix=LINK_OPT_STDCXX %s
+// LINK_OPT_STDCXX: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
+// LINK_OPT_STDCXX: wasm-ld{{.*}}" "-L/foo/lib" "crt1.o" "[[temp]]" "-lstdc++" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
+
 // A basic C++ link command-line with known OS.
 
 // RUN: %clangxx -### -no-canonical-prefixes -target wasm32-wasi --sysroot=/foo --stdlib=libc++ %s 2>&1 \
@@ -33,6 +43,11 @@
 // LINK_KNOWN: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
 // LINK_KNOWN: wasm-ld{{.*}}" "-L/foo/lib/wasm32-wasi" "crt1.o" "[[temp]]" "-lc++" "-lc++abi" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
 
+// RUN: %clangxx -### -no-canonical-prefixes -target wasm32-wasi --sysroot=/foo --stdlib=libstdc++ %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=LINK_KNOWN_STDCXX %s
+// LINK_KNOWN_STDCXX: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
+// LINK_KNOWN_STDCXX: wasm-ld{{.*}}" "-L/foo/lib/wasm32-wasi" "crt1.o" "[[temp]]" "-lstdc++" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
+
 // A basic C++ link command-line with optimization with known OS.
 
 // RUN: %clangxx -### -O2 -no-canonical-prefixes -target wasm32-wasi --sysroot=/foo %s --stdlib=libc++ 2>&1 \
@@ -40,6 +55,11 @@
 // LINK_OPT_KNOWN: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
 // LINK_OPT_KNOWN: wasm-ld{{.*}}" "-L/foo/lib/wasm32-wasi" "crt1.o" "[[temp]]" "-lc++" "-lc++abi" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
 
+// RUN: %clangxx -### -O2 -no-canonical-prefixes -target wasm32-wasi --sysroot=/foo %s --stdlib=libstdc++ 2>&1 \
+// RUN:   | FileCheck -check-prefix=LINK_OPT_KNOWN_STDCXX %s
+// LINK_OPT_KNOWN_STDCXX: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
+// LINK_OPT_KNOWN_STDCXX: wasm-ld{{.*}}" "-L/foo/lib/wasm32-wasi" "crt1.o" "[[temp]]" "-lstdc++" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
+
 // A basic C++ compile command-line with known OS.
 
 // RUN: %clangxx -### -no-canonical-prefixes -target wasm32-wasi --sysroot=/foo --stdlib=libc++ %s 2>&1 \
@@ -52,3 +72,14 @@
 // COMPILE: "-internal-isystem" "[[RESOURCE_DIR]]{{(/|)}}include"
 // COMPILE: "-internal-isystem" "/foo/include/wasm32-wasi"
 // COMPILE: "-internal-isystem" "/foo/include"
+
+// RUN: %clangxx -### -no-canonical-prefixes -target wasm32-wasi --sysroot=/foo --stdlib=libstdc++ %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=COMPILE_STDCXX %s
+// COMPILE_STDCXX: clang{{.*}}" "-cc1"
+// COMPILE_STDCXX: "-resource-dir" "[[RESOURCE_DIR:[^"]*]]"
+// COMPILE_STDCXX: "-isysroot" "/foo"
+// COMPILE_STDCXX: "-internal-isystem" "/foo/include/wasm32-wasi/c++/11"
+// COMPILE_STDCXX: "-internal-isystem" "/foo/include/c++/11"
+// COMPILE_STDCXX: "-internal-isystem" "[[RESOURCE_DIR]]{{(/|)}}include"
+// COMPILE_STDCXX: "-internal-isystem" "/foo/include/wasm32-wasi"
+// COMPILE_STDCXX: "-internal-isystem" "/foo/include"
Index: clang/lib/Driver/ToolChains/WebAssembly.h
===
--- clang/lib/Driver/ToolChains/WebAssembly.h
+++ clang/lib/Driver/ToolChains/WebAssembly.h
@@ -70,11 +70,20 @@
 
   const char *getDefaultLinker() const override { return "wasm-ld"; }
 
+  CXXStdlibType GetDefaultCXXStdlibType() const override {
+return ToolChain::CST_Libcxx;
+  }
+
   Tool *buildLinker() const override;
 
   std::string

[PATCH] D117888: [clang][driver][wasm] Support -stdlib=libstdc++ for WebAssembly

2022-02-01 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added inline comments.



Comment at: clang/lib/Driver/ToolChains/WebAssembly.cpp:448
+addSystemInclude(DriverArgs, CC1Args,
+ getDriver().SysRoot + "/include/c++/11");
+break;

sbc100 wrote:
> tbaeder wrote:
> > sbc100 wrote:
> > > Where does `11` come from here?  Do other drivers hardcode this the same 
> > > way?
> > `11` is just the current version. `lib/Driver/ToolChains/Gnu.cpp` figures 
> > out the correct version here via `GCCInstallationDetector`. I thought 
> > hard-coding is find for wasm because the `v1` for libc++ above is also 
> > hardcoded and `Gnu.cpp` figures that out dynamically as well (in 
> > `addLibCxxIncludePaths`).
> I'd rather not hardcode that current version, that seems rather fragile/wrong.
> 
> I agree the `v1` is probably also wrong (feel free to add a TODO or update 
> that too).
> 
Updated both. They both  currently fall back to the old `v1`/`11`. I'm not sure 
how the test would otherwise work. As far as I know, the wasm sysroot will 
basically never contain an actual gcc installation, so 
`GCCInstallationDetector` can't be properly used. 


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

https://reviews.llvm.org/D117888

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


[PATCH] D117795: [AArch64] Add some missing strict FP vector lowering

2022-02-01 Thread Dave Green via Phabricator via cfe-commits
dmgreen added inline comments.



Comment at: llvm/lib/Target/AArch64/AArch64ISelLowering.cpp:1484
+  // of the vector comparison instructions.
+  setOperationAction(ISD::STRICT_FSETCCS, VT, Expand);
+  // FIXME: We could potentially make use of the vector comparison instructions

Can you split this into a separate patch? I know I sound like a broken record, 
but it doesn't seem to be related to the converts below.

Also pre-committing as much of the test that works as possible would cut it 
down from this patch quite a bit.



Comment at: llvm/lib/Target/AArch64/AArch64ISelLowering.cpp:3419
+{NewVT, MVT::Other},
+{Op.getOperand(0), Op.getOperand(1)});
+  return DAG.getNode(Op.getOpcode(), dl, {VT, MVT::Other},

Some formatting apparently needs fixing up.



Comment at: llvm/lib/Target/AArch64/AArch64ISelLowering.cpp:3672
+  In = DAG.getNode(Opc, dl, {CastVT, MVT::Other},
+   {Op.getOperand(0), Op.getOperand(1)});
+  return DAG.getNode(

Op.getOperand(1) -> In?



Comment at: llvm/lib/Target/AArch64/AArch64ISelLowering.cpp:3694
+  if (VT.getVectorNumElements() == 1) {
+SDLoc dl(Op);
+SDValue Extract = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, dl,

dl is already defined.



Comment at: llvm/lib/Target/AArch64/AArch64ISelLowering.cpp:3697
+  InVT.getScalarType(),
+  Op.getOperand(IsStrict ? 1 : 0),
+  DAG.getConstant(0, dl, MVT::i64));

Op.getOperand(IsStrict ? 1 : 0) -> In?



Comment at: llvm/lib/Target/AArch64/AArch64ISelLowering.cpp:3700
+EVT ScalarVT = VT.getScalarType();
+SDValue ScalarCvt;
+if (IsStrict)

This isn't used anywhere


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

https://reviews.llvm.org/D117795

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


[PATCH] D118199: [AArch64] ACLE feature macro for Armv8.8-A MOPS

2022-02-01 Thread Son Tuan Vu via Phabricator via cfe-commits
tyb0807 updated this revision to Diff 404854.
tyb0807 added a comment.

Add support for `+nomops`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118199

Files:
  clang/lib/Basic/Targets/AArch64.cpp
  clang/test/CodeGen/aarch64-mops.c
  clang/test/Preprocessor/aarch64-target-features.c

Index: clang/test/Preprocessor/aarch64-target-features.c
===
--- clang/test/Preprocessor/aarch64-target-features.c
+++ clang/test/Preprocessor/aarch64-target-features.c
@@ -510,9 +510,25 @@
 // CHECK-NO-SVE-VECTOR-BITS-NOT: __ARM_FEATURE_SVE_BITS
 // CHECK-NO-SVE-VECTOR-BITS-NOT: __ARM_FEATURE_SVE_VECTOR_OPERATORS
 
-// == Check Largse System Extensions (LSE)
+// == Check Large System Extensions (LSE)
 // RUN: %clang -target aarch64-none-linux-gnu -march=armv8-a+lse -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-LSE %s
 // RUN: %clang -target arm64-none-linux-gnu -march=armv8-a+lse -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-LSE %s
 // RUN: %clang -target aarch64-none-linux-gnu -march=armv8.1-a -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-LSE %s
 // RUN: %clang -target arm64-none-linux-gnu -march=armv8.1-a -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-LSE %s
 // CHECK-LSE: __ARM_FEATURE_ATOMICS 1
+
+// == Check Armv8.8-A/Armv9.3-A memcpy and memset acceleration instructions (MOPS)
+// RUN: %clang -target aarch64-arm-none-eabi -march=armv8.7-a -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-NOMOPS %s
+// RUN: %clang -target aarch64-arm-none-eabi -march=armv8.7-a+mops-x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-MOPS %s
+// RUN: %clang -target aarch64-arm-none-eabi -march=armv8.8-a -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-MOPS %s
+// RUN: %clang -target aarch64-arm-none-eabi -march=armv8.8-a+nomops  -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-NOMOPS %s
+// RUN: %clang -target aarch64-arm-none-eabi -march=armv8.8-a+nomops+mops -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-MOPS %s
+// RUN: %clang -target aarch64-arm-none-eabi -march=armv8.8-a+mops-x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-MOPS %s
+// RUN: %clang -target aarch64-arm-none-eabi -march=armv8.8-a+mops+nomops -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-NOMOPS %s
+// RUN: %clang -target aarch64-arm-none-eabi -march=armv9.2-a -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-NOMOPS %s
+// RUN: %clang -target aarch64-arm-none-eabi -march=armv9.2-a+mops-x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-MOPS %s
+// RUN: %clang -target aarch64-arm-none-eabi -march=armv9.3-a -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-MOPS %s
+// RUN: %clang -target aarch64-arm-none-eabi -march=armv9.3-a+nomops  -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-NOMOPS %s
+// RUN: %clang -target aarch64-arm-none-eabi -march=armv9.3-a+mops-x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-MOPS %s
+// CHECK-MOPS: __ARM_FEATURE_MOPS 1
+// CHECK-NOMOPS-NOT: __ARM_FEATURE_MOPS 1
Index: clang/test/CodeGen/aarch64-mops.c
===
--- clang/test/CodeGen/aarch64-mops.c
+++ clang/test/CodeGen/aarch64-mops.c
@@ -1,152 +1,281 @@
 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
 
-// RUN: %clang_cc1 -triple aarch64-arm-unknown-eabi -target-feature +mops -target-feature +mte -S -emit-llvm -o - %s  | FileCheck %s
+// RUN: %clang_cc1 -triple aarch64-arm-unknown-eabi -target-feature +mops -target-feature +mte -S -emit-llvm -o - %s  | FileCheck --check-prefix=CHECK-MOPS %s
+// RUN: %clang_cc1 -triple aarch64-arm-unknown-eabi-S -emit-llvm -o - %s  | FileCheck --check-prefix=CHECK-NOMOPS %s
+// RUN: %clang -target aarch64-arm-none-eabi -march=armv8.7-a+mops+memtag -S -emit-llvm %s -o - | FileCheck --check-prefix=CHECK-MOPS %s
+// RUN: %clang -target aarch64-arm-none-eabi -march=armv8.7-a -S -emit-llvm %s -o - | FileCheck --check-prefix=CHECK-NOMOPS %s
+// RUN: %clang -target aarch64-arm-none-eabi -march=armv8.8-a+memtag  -S -emit-llvm %s -o - | FileCheck --check-prefix=CHECK-MOPS %s
+// RUN: %clang -target aarch64-arm-none-eabi -march=armv8.8-a -S -emit-llvm %s -o - | FileCheck --check-prefix=CHECK-NOMOPS %s
+// RUN: %clang -target aarch64-arm-none-eabi -march=armv9.2-a+mops+memtag -S -emit-llvm %s -o - | FileCheck --check-prefix=CHECK-MOPS %s
+// RUN: %clang -target aarch64-arm-none-eabi -march=armv9.2-a -S -emit-llvm %s -o - | FileCheck --check-prefix=CHECK-NOMOPS %s
+// RUN: %clang -target aarch64-arm-none-eabi -march=armv9.3-a+memtag  -S -emit-llvm %s -o - | FileCheck --check-prefix=CHECK-MOPS %s
+// RUN: %clang -target aarch64-arm-none-eabi -marc

[PATCH] D118670: [NFC][AIX]Disable failed tests due to aggressive byval alignment warning on AIX

2022-02-01 Thread Zarko Todorovski via Phabricator via cfe-commits
ZarkoCA added inline comments.



Comment at: clang/test/SemaTemplate/instantiate-attr.cpp:1
 // RUN: %clang_cc1 -fsyntax-only -verify %s
 // expected-no-diagnostics

hubert.reinterpretcast wrote:
> Add `-Wno-aix-compat` instead?
I agree with this, this way AIX still gets the test coverage. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118670

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


[PATCH] D118609: Remove redundant LLVM_HAS_RVALUE_REFERENCE_THIS and LLVM_LVALUE_FUNCTION defines

2022-02-01 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon updated this revision to Diff 404885.
RKSimon added a comment.

clang-format


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118609

Files:
  clang/include/clang/ASTMatchers/ASTMatchersInternal.h
  clang/include/clang/Basic/DirectoryEntry.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h
  llvm/include/llvm/ADT/Optional.h
  llvm/include/llvm/ADT/PointerIntPair.h
  llvm/include/llvm/Support/Compiler.h
  llvm/unittests/ADT/OptionalTest.cpp

Index: llvm/unittests/ADT/OptionalTest.cpp
===
--- llvm/unittests/ADT/OptionalTest.cpp
+++ llvm/unittests/ADT/OptionalTest.cpp
@@ -578,8 +578,6 @@
   Optional TestInstantiation;
 }
 
-#if LLVM_HAS_RVALUE_REFERENCE_THIS
-
 TEST(OptionalTest, MoveGetValueOr) {
   Optional A;
 
@@ -597,8 +595,6 @@
   EXPECT_EQ(2u, MoveOnly::Destructions);
 }
 
-#endif // LLVM_HAS_RVALUE_REFERENCE_THIS
-
 struct EqualTo {
   template  static bool apply(const T &X, const U &Y) {
 return X == Y;
Index: llvm/include/llvm/Support/Compiler.h
===
--- llvm/include/llvm/Support/Compiler.h
+++ llvm/include/llvm/Support/Compiler.h
@@ -98,24 +98,6 @@
 #define LLVM_MSC_PREREQ(version) 0
 #endif
 
-/// Does the compiler support ref-qualifiers for *this?
-///
-/// Sadly, this is separate from just rvalue reference support because GCC
-/// and MSVC implemented this later than everything else. This appears to be
-/// corrected in MSVC 2019 but not MSVC 2017.
-/// FIXME: Remove LLVM_HAS_RVALUE_REFERENCE_THIS macro
-#define LLVM_HAS_RVALUE_REFERENCE_THIS 1
-
-/// Expands to '&' if ref-qualifiers for *this are supported.
-///
-/// This can be used to provide lvalue/rvalue overrides of member functions.
-/// The rvalue override should be guarded by LLVM_HAS_RVALUE_REFERENCE_THIS
-#if LLVM_HAS_RVALUE_REFERENCE_THIS
-#define LLVM_LVALUE_FUNCTION &
-#else
-#define LLVM_LVALUE_FUNCTION
-#endif
-
 /// LLVM_LIBRARY_VISIBILITY - If a class marked with this attribute is linked
 /// into a shared library, then the class should be private to the library and
 /// not accessible from outside it.  Can also be used to mark variables and
Index: llvm/include/llvm/ADT/PointerIntPair.h
===
--- llvm/include/llvm/ADT/PointerIntPair.h
+++ llvm/include/llvm/ADT/PointerIntPair.h
@@ -61,19 +61,19 @@
 
   IntType getInt() const { return (IntType)Info::getInt(Value); }
 
-  void setPointer(PointerTy PtrVal) LLVM_LVALUE_FUNCTION {
+  void setPointer(PointerTy PtrVal) & {
 Value = Info::updatePointer(Value, PtrVal);
   }
 
-  void setInt(IntType IntVal) LLVM_LVALUE_FUNCTION {
+  void setInt(IntType IntVal) & {
 Value = Info::updateInt(Value, static_cast(IntVal));
   }
 
-  void initWithPointer(PointerTy PtrVal) LLVM_LVALUE_FUNCTION {
+  void initWithPointer(PointerTy PtrVal) & {
 Value = Info::updatePointer(0, PtrVal);
   }
 
-  void setPointerAndInt(PointerTy PtrVal, IntType IntVal) LLVM_LVALUE_FUNCTION {
+  void setPointerAndInt(PointerTy PtrVal, IntType IntVal) & {
 Value = Info::updateInt(Info::updatePointer(0, PtrVal),
 static_cast(IntVal));
   }
@@ -91,7 +91,7 @@
 
   void *getOpaqueValue() const { return reinterpret_cast(Value); }
 
-  void setFromOpaqueValue(void *Val) LLVM_LVALUE_FUNCTION {
+  void setFromOpaqueValue(void *Val) & {
 Value = reinterpret_cast(Val);
   }
 
Index: llvm/include/llvm/ADT/Optional.h
===
--- llvm/include/llvm/ADT/Optional.h
+++ llvm/include/llvm/ADT/Optional.h
@@ -81,7 +81,7 @@
   }
 
   template 
-  constexpr explicit OptionalStorage(in_place_t, Args &&... args)
+  constexpr explicit OptionalStorage(in_place_t, Args &&...args)
   : value(std::forward(args)...), hasVal(true) {}
 
   void reset() noexcept {
@@ -93,22 +93,20 @@
 
   constexpr bool hasValue() const noexcept { return hasVal; }
 
-  T &getValue() LLVM_LVALUE_FUNCTION noexcept {
+  T &getValue() &noexcept {
 assert(hasVal);
 return value;
   }
-  constexpr T const &getValue() const LLVM_LVALUE_FUNCTION noexcept {
+  constexpr T const &getValue() const &noexcept {
 assert(hasVal);
 return value;
   }
-#if LLVM_HAS_RVALUE_REFERENCE_THIS
-  T &&getValue() && noexcept {
+  T &&getValue() &&noexcept {
 assert(hasVal);
 return std::move(value);
   }
-#endif
 
-  template  void emplace(Args &&... args) {
+  template  void emplace(Args &&...args) {
 reset();
 ::new ((void *)std::addressof(value)) T(std::forward(args)...);
 hasVal = true;
@@ -193,22 +191,20 @@
 
   constexpr bool hasValue() const noexcept { return hasVal; }
 
-  T &getValue() LLVM_LVALUE_FUNCTION noexcept {
+  T &getValue() &noexcept {
 assert(hasVal);
 return value;
   }
-  constexpr T const &getValue() const LLVM_LVALUE

[PATCH] D118596: [clang][dataflow] Enable comparison of distinct values in Environment

2022-02-01 Thread Stanislav Gatev via Phabricator via cfe-commits
sgatev updated this revision to Diff 404886.
sgatev marked an inline comment as done.
sgatev added a comment.

Address reviewers' comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118596

Files:
  clang/include/clang/Analysis/FlowSensitive/DataflowAnalysis.h
  clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
  clang/include/clang/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.h
  clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
  clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
  clang/unittests/Analysis/FlowSensitive/TestingSupport.h
  clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp

Index: clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
@@ -19,6 +19,7 @@
 #include "clang/Analysis/FlowSensitive/DataflowLattice.h"
 #include "clang/Analysis/FlowSensitive/Value.h"
 #include "clang/Tooling/Tooling.h"
+#include "llvm/ADT/Optional.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallSet.h"
 #include "llvm/ADT/StringRef.h"
@@ -49,53 +50,35 @@
 using ::testing::UnorderedElementsAre;
 
 template 
-class AnalysisCallback : public ast_matchers::MatchFinder::MatchCallback {
-public:
-  AnalysisCallback(AnalysisT (*MakeAnalysis)(ASTContext &))
-  : MakeAnalysis(MakeAnalysis) {}
-  void run(const ast_matchers::MatchFinder::MatchResult &Result) override {
-assert(BlockStates.empty());
-
-const auto *Func = Result.Nodes.getNodeAs("func");
-assert(Func != nullptr);
-
-Stmt *Body = Func->getBody();
-assert(Body != nullptr);
-
-auto CFCtx = llvm::cantFail(
-ControlFlowContext::build(nullptr, Body, Result.Context));
-
-AnalysisT Analysis = MakeAnalysis(*Result.Context);
-DataflowAnalysisContext DACtx;
-Environment Env(DACtx);
-BlockStates = runDataflowAnalysis(CFCtx, Analysis, Env);
-  }
-
-  AnalysisT (*MakeAnalysis)(ASTContext &);
-  std::vector<
-  llvm::Optional>>
-  BlockStates;
-};
-
-template 
-std::vector>>
+llvm::Expected>>>
 runAnalysis(llvm::StringRef Code, AnalysisT (*MakeAnalysis)(ASTContext &)) {
   std::unique_ptr AST =
   tooling::buildASTFromCodeWithArgs(Code, {"-std=c++11"});
 
-  AnalysisCallback Callback(MakeAnalysis);
-  ast_matchers::MatchFinder Finder;
-  Finder.addMatcher(
-  ast_matchers::functionDecl(ast_matchers::hasName("target")).bind("func"),
-  &Callback);
-  Finder.matchAST(AST->getASTContext());
+  auto *Func = selectFirst(
+  "func", match(functionDecl(ast_matchers::hasName("target")).bind("func"),
+AST->getASTContext()));
+  assert(Func != nullptr);
+
+  Stmt *Body = Func->getBody();
+  assert(Body != nullptr);
 
-  return Callback.BlockStates;
+  auto CFCtx = llvm::cantFail(
+  ControlFlowContext::build(nullptr, Body, &AST->getASTContext()));
+
+  AnalysisT Analysis = MakeAnalysis(AST->getASTContext());
+  DataflowAnalysisContext DACtx;
+  Environment Env(DACtx);
+
+  return runDataflowAnalysis(CFCtx, Analysis, Env);
 }
 
 TEST(DataflowAnalysisTest, NoopAnalysis) {
-  auto BlockStates = runAnalysis(
-  "void target() {}", [](ASTContext &C) { return NoopAnalysis(C, false); });
+  auto BlockStates = llvm::cantFail(
+  runAnalysis("void target() {}", [](ASTContext &C) {
+return NoopAnalysis(C, false);
+  }));
   EXPECT_EQ(BlockStates.size(), 2u);
   EXPECT_TRUE(BlockStates[0].hasValue());
   EXPECT_TRUE(BlockStates[1].hasValue());
@@ -132,18 +115,15 @@
 };
 
 TEST(DataflowAnalysisTest, NonConvergingAnalysis) {
-  auto BlockStates = runAnalysis(
-  R"(
+  std::string Code = R"(
 void target() {
   while(true) {}
 }
-  )",
-  [](ASTContext &C) { return NonConvergingAnalysis(C); });
-  EXPECT_EQ(BlockStates.size(), 4u);
-  EXPECT_TRUE(BlockStates[0].hasValue());
-  EXPECT_TRUE(BlockStates[1].hasValue());
-  EXPECT_TRUE(BlockStates[2].hasValue());
-  EXPECT_TRUE(BlockStates[3].hasValue());
+  )";
+  auto Res = runAnalysis(
+  Code, [](ASTContext &C) { return NonConvergingAnalysis(C); });
+  EXPECT_EQ(llvm::toString(Res.takeError()),
+"maximum number of iterations reached");
 }
 
 struct FunctionCallLattice {
@@ -317,8 +297,9 @@
 class OptionalIntAnalysis
 : public DataflowAnalysis {
 public:
-  explicit OptionalIntAnalysis(ASTContext &Context)
-  : DataflowAnalysis(Context) {}
+  explicit OptionalIntAnalysis(ASTContext &Context, BoolValue &HasValueTop)
+  : DataflowAnalysis(Context),
+HasValueTop(HasValueTop) {}
 
   static NoopLattice initialElement() { return {}; }
 
@@ -353,8 +334,20 @@
 }
   }
 
+  bool compareEquivalent(QualType Type, const Value &Val1,
+ const Value &Val2) final

[PATCH] D118596: [clang][dataflow] Enable comparison of distinct values in Environment

2022-02-01 Thread Stanislav Gatev via Phabricator via cfe-commits
sgatev updated this revision to Diff 404888.
sgatev added a comment.

Update comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118596

Files:
  clang/include/clang/Analysis/FlowSensitive/DataflowAnalysis.h
  clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
  clang/include/clang/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.h
  clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
  clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
  clang/unittests/Analysis/FlowSensitive/TestingSupport.h
  clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp

Index: clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
@@ -19,6 +19,7 @@
 #include "clang/Analysis/FlowSensitive/DataflowLattice.h"
 #include "clang/Analysis/FlowSensitive/Value.h"
 #include "clang/Tooling/Tooling.h"
+#include "llvm/ADT/Optional.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallSet.h"
 #include "llvm/ADT/StringRef.h"
@@ -49,53 +50,35 @@
 using ::testing::UnorderedElementsAre;
 
 template 
-class AnalysisCallback : public ast_matchers::MatchFinder::MatchCallback {
-public:
-  AnalysisCallback(AnalysisT (*MakeAnalysis)(ASTContext &))
-  : MakeAnalysis(MakeAnalysis) {}
-  void run(const ast_matchers::MatchFinder::MatchResult &Result) override {
-assert(BlockStates.empty());
-
-const auto *Func = Result.Nodes.getNodeAs("func");
-assert(Func != nullptr);
-
-Stmt *Body = Func->getBody();
-assert(Body != nullptr);
-
-auto CFCtx = llvm::cantFail(
-ControlFlowContext::build(nullptr, Body, Result.Context));
-
-AnalysisT Analysis = MakeAnalysis(*Result.Context);
-DataflowAnalysisContext DACtx;
-Environment Env(DACtx);
-BlockStates = runDataflowAnalysis(CFCtx, Analysis, Env);
-  }
-
-  AnalysisT (*MakeAnalysis)(ASTContext &);
-  std::vector<
-  llvm::Optional>>
-  BlockStates;
-};
-
-template 
-std::vector>>
+llvm::Expected>>>
 runAnalysis(llvm::StringRef Code, AnalysisT (*MakeAnalysis)(ASTContext &)) {
   std::unique_ptr AST =
   tooling::buildASTFromCodeWithArgs(Code, {"-std=c++11"});
 
-  AnalysisCallback Callback(MakeAnalysis);
-  ast_matchers::MatchFinder Finder;
-  Finder.addMatcher(
-  ast_matchers::functionDecl(ast_matchers::hasName("target")).bind("func"),
-  &Callback);
-  Finder.matchAST(AST->getASTContext());
+  auto *Func = selectFirst(
+  "func", match(functionDecl(ast_matchers::hasName("target")).bind("func"),
+AST->getASTContext()));
+  assert(Func != nullptr);
+
+  Stmt *Body = Func->getBody();
+  assert(Body != nullptr);
 
-  return Callback.BlockStates;
+  auto CFCtx = llvm::cantFail(
+  ControlFlowContext::build(nullptr, Body, &AST->getASTContext()));
+
+  AnalysisT Analysis = MakeAnalysis(AST->getASTContext());
+  DataflowAnalysisContext DACtx;
+  Environment Env(DACtx);
+
+  return runDataflowAnalysis(CFCtx, Analysis, Env);
 }
 
 TEST(DataflowAnalysisTest, NoopAnalysis) {
-  auto BlockStates = runAnalysis(
-  "void target() {}", [](ASTContext &C) { return NoopAnalysis(C, false); });
+  auto BlockStates = llvm::cantFail(
+  runAnalysis("void target() {}", [](ASTContext &C) {
+return NoopAnalysis(C, false);
+  }));
   EXPECT_EQ(BlockStates.size(), 2u);
   EXPECT_TRUE(BlockStates[0].hasValue());
   EXPECT_TRUE(BlockStates[1].hasValue());
@@ -132,18 +115,15 @@
 };
 
 TEST(DataflowAnalysisTest, NonConvergingAnalysis) {
-  auto BlockStates = runAnalysis(
-  R"(
+  std::string Code = R"(
 void target() {
   while(true) {}
 }
-  )",
-  [](ASTContext &C) { return NonConvergingAnalysis(C); });
-  EXPECT_EQ(BlockStates.size(), 4u);
-  EXPECT_TRUE(BlockStates[0].hasValue());
-  EXPECT_TRUE(BlockStates[1].hasValue());
-  EXPECT_TRUE(BlockStates[2].hasValue());
-  EXPECT_TRUE(BlockStates[3].hasValue());
+  )";
+  auto Res = runAnalysis(
+  Code, [](ASTContext &C) { return NonConvergingAnalysis(C); });
+  EXPECT_EQ(llvm::toString(Res.takeError()),
+"maximum number of iterations reached");
 }
 
 struct FunctionCallLattice {
@@ -317,8 +297,9 @@
 class OptionalIntAnalysis
 : public DataflowAnalysis {
 public:
-  explicit OptionalIntAnalysis(ASTContext &Context)
-  : DataflowAnalysis(Context) {}
+  explicit OptionalIntAnalysis(ASTContext &Context, BoolValue &HasValueTop)
+  : DataflowAnalysis(Context),
+HasValueTop(HasValueTop) {}
 
   static NoopLattice initialElement() { return {}; }
 
@@ -353,8 +334,20 @@
 }
   }
 
+  bool compareEquivalent(QualType Type, const Value &Val1,
+ const Value &Val2) final {
+// Nothing to say about a value that does not 

[PATCH] D118596: [clang][dataflow] Enable comparison of distinct values in Environment

2022-02-01 Thread Stanislav Gatev via Phabricator via cfe-commits
sgatev added a comment.

Mentioned the breaking interface change in the description.




Comment at: clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp:151
 
-if (auto *FirstVal = dyn_cast(Val)) {
-  auto *SecondVal = cast(It->second);
-  if (&FirstVal->getPointeeLoc() == &SecondVal->getPointeeLoc()) {
-LocToVal.insert({Loc, FirstVal});
+if (auto *Val1 = dyn_cast(Val)) {
+  auto *Val2 = cast(It->second);

xazax.hun wrote:
> Now we have multiple, slightly different versions of equality for values. One 
> here, one in `Environment::equivalentTo`. I'd prefer to have one way to check 
> value equality factored out somewhere and reused it both here and there. 
> Also, `Environment::equivalentTo` works with any indirection, this snippet 
> only works with pointers (and not with references).
> 
> It is also not clear to me at this point what is the role of 
> `compareEquivalent`. Is it intentional that it is not used here?
Good point, I updated the code. Please take a look.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118596

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


[PATCH] D118605: [OpenCL] Add support of language builtins for OpenCL C 3.0

2022-02-01 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: clang/include/clang/Basic/Builtins.def:88
 //   '__builtin_' prefix. It will be implemented in compiler-rt or libgcc.
+//  G -> this function uses generic address space (OpenCL).
+//  P -> this function uses pipes (OpenCL).

Anastasia wrote:
> It might be better to avoid adding such limited language-specific 
> functionality into generic representation of Builtins. Do you think could we 
> could just introduce specific language modes, say:
> 
> `OCLC_PIPES`
> `OCLC_DSE`
> `OCLC_GAS`
> 
> and then check against those in `builtinIsSupported`?
Btw another approach could be to do something similar to `TARGET_BUILTIN` i.e. 
list features in the last parameter as strings. We could add a separate macro 
for such builtins and just reuse target Builtins flow. This might be a bit more 
scalable in case we would need to add more of such builtins later on?



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118605

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


[PATCH] D118596: [clang][dataflow] Enable comparison of distinct values in Environment

2022-02-01 Thread Stanislav Gatev via Phabricator via cfe-commits
sgatev updated this revision to Diff 404890.
sgatev added a comment.

Update comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118596

Files:
  clang/include/clang/Analysis/FlowSensitive/DataflowAnalysis.h
  clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
  clang/include/clang/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.h
  clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
  clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
  clang/unittests/Analysis/FlowSensitive/TestingSupport.h
  clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp

Index: clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
@@ -19,6 +19,7 @@
 #include "clang/Analysis/FlowSensitive/DataflowLattice.h"
 #include "clang/Analysis/FlowSensitive/Value.h"
 #include "clang/Tooling/Tooling.h"
+#include "llvm/ADT/Optional.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallSet.h"
 #include "llvm/ADT/StringRef.h"
@@ -49,53 +50,35 @@
 using ::testing::UnorderedElementsAre;
 
 template 
-class AnalysisCallback : public ast_matchers::MatchFinder::MatchCallback {
-public:
-  AnalysisCallback(AnalysisT (*MakeAnalysis)(ASTContext &))
-  : MakeAnalysis(MakeAnalysis) {}
-  void run(const ast_matchers::MatchFinder::MatchResult &Result) override {
-assert(BlockStates.empty());
-
-const auto *Func = Result.Nodes.getNodeAs("func");
-assert(Func != nullptr);
-
-Stmt *Body = Func->getBody();
-assert(Body != nullptr);
-
-auto CFCtx = llvm::cantFail(
-ControlFlowContext::build(nullptr, Body, Result.Context));
-
-AnalysisT Analysis = MakeAnalysis(*Result.Context);
-DataflowAnalysisContext DACtx;
-Environment Env(DACtx);
-BlockStates = runDataflowAnalysis(CFCtx, Analysis, Env);
-  }
-
-  AnalysisT (*MakeAnalysis)(ASTContext &);
-  std::vector<
-  llvm::Optional>>
-  BlockStates;
-};
-
-template 
-std::vector>>
+llvm::Expected>>>
 runAnalysis(llvm::StringRef Code, AnalysisT (*MakeAnalysis)(ASTContext &)) {
   std::unique_ptr AST =
   tooling::buildASTFromCodeWithArgs(Code, {"-std=c++11"});
 
-  AnalysisCallback Callback(MakeAnalysis);
-  ast_matchers::MatchFinder Finder;
-  Finder.addMatcher(
-  ast_matchers::functionDecl(ast_matchers::hasName("target")).bind("func"),
-  &Callback);
-  Finder.matchAST(AST->getASTContext());
+  auto *Func = selectFirst(
+  "func", match(functionDecl(ast_matchers::hasName("target")).bind("func"),
+AST->getASTContext()));
+  assert(Func != nullptr);
+
+  Stmt *Body = Func->getBody();
+  assert(Body != nullptr);
 
-  return Callback.BlockStates;
+  auto CFCtx = llvm::cantFail(
+  ControlFlowContext::build(nullptr, Body, &AST->getASTContext()));
+
+  AnalysisT Analysis = MakeAnalysis(AST->getASTContext());
+  DataflowAnalysisContext DACtx;
+  Environment Env(DACtx);
+
+  return runDataflowAnalysis(CFCtx, Analysis, Env);
 }
 
 TEST(DataflowAnalysisTest, NoopAnalysis) {
-  auto BlockStates = runAnalysis(
-  "void target() {}", [](ASTContext &C) { return NoopAnalysis(C, false); });
+  auto BlockStates = llvm::cantFail(
+  runAnalysis("void target() {}", [](ASTContext &C) {
+return NoopAnalysis(C, false);
+  }));
   EXPECT_EQ(BlockStates.size(), 2u);
   EXPECT_TRUE(BlockStates[0].hasValue());
   EXPECT_TRUE(BlockStates[1].hasValue());
@@ -132,18 +115,15 @@
 };
 
 TEST(DataflowAnalysisTest, NonConvergingAnalysis) {
-  auto BlockStates = runAnalysis(
-  R"(
+  std::string Code = R"(
 void target() {
   while(true) {}
 }
-  )",
-  [](ASTContext &C) { return NonConvergingAnalysis(C); });
-  EXPECT_EQ(BlockStates.size(), 4u);
-  EXPECT_TRUE(BlockStates[0].hasValue());
-  EXPECT_TRUE(BlockStates[1].hasValue());
-  EXPECT_TRUE(BlockStates[2].hasValue());
-  EXPECT_TRUE(BlockStates[3].hasValue());
+  )";
+  auto Res = runAnalysis(
+  Code, [](ASTContext &C) { return NonConvergingAnalysis(C); });
+  EXPECT_EQ(llvm::toString(Res.takeError()),
+"maximum number of iterations reached");
 }
 
 struct FunctionCallLattice {
@@ -317,8 +297,9 @@
 class OptionalIntAnalysis
 : public DataflowAnalysis {
 public:
-  explicit OptionalIntAnalysis(ASTContext &Context)
-  : DataflowAnalysis(Context) {}
+  explicit OptionalIntAnalysis(ASTContext &Context, BoolValue &HasValueTop)
+  : DataflowAnalysis(Context),
+HasValueTop(HasValueTop) {}
 
   static NoopLattice initialElement() { return {}; }
 
@@ -353,8 +334,20 @@
 }
   }
 
+  bool compareEquivalent(QualType Type, const Value &Val1,
+ const Value &Val2) final {
+// Nothing to say about a value that does not 

[PATCH] D118596: [clang][dataflow] Enable comparison of distinct values in Environment

2022-02-01 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun accepted this revision.
xazax.hun added a comment.

Thanks, this looks much better!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118596

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


[PATCH] D114439: [Annotation] Allow parameter pack expansions and initializer lists in annotate attribute

2022-02-01 Thread Steffen Larsen via Phabricator via cfe-commits
steffenlarsen updated this revision to Diff 404889.
steffenlarsen added a comment.

Added tests for redeclarations and template specialization using 
`clang::annoate` with packs.


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

https://reviews.llvm.org/D114439

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseExpr.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/test/Parser/cxx0x-attributes.cpp
  clang/test/Sema/annotate.c
  clang/test/SemaCXX/attr-annotate.cpp
  clang/test/SemaTemplate/attributes.cpp
  clang/utils/TableGen/ClangAttrEmitter.cpp

Index: clang/utils/TableGen/ClangAttrEmitter.cpp
===
--- clang/utils/TableGen/ClangAttrEmitter.cpp
+++ clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -202,9 +202,9 @@
 bool Fake;
 
   public:
-Argument(const Record &Arg, StringRef Attr)
-: lowerName(std::string(Arg.getValueAsString("Name"))),
-  upperName(lowerName), attrName(Attr), isOpt(false), Fake(false) {
+Argument(StringRef Arg, StringRef Attr)
+: lowerName(std::string(Arg)), upperName(lowerName), attrName(Attr),
+  isOpt(false), Fake(false) {
   if (!lowerName.empty()) {
 lowerName[0] = std::tolower(lowerName[0]);
 upperName[0] = std::toupper(upperName[0]);
@@ -215,6 +215,8 @@
   if (lowerName == "interface")
 lowerName = "interface_";
 }
+Argument(const Record &Arg, StringRef Attr)
+: Argument(Arg.getValueAsString("Name"), Attr) {}
 virtual ~Argument() = default;
 
 StringRef getLowerName() const { return lowerName; }
@@ -666,6 +668,11 @@
   ArgName(getLowerName().str() + "_"), ArgSizeName(ArgName + "Size"),
   RangeName(std::string(getLowerName())) {}
 
+VariadicArgument(StringRef Arg, StringRef Attr, std::string T)
+: Argument(Arg, Attr), Type(std::move(T)),
+  ArgName(getLowerName().str() + "_"), ArgSizeName(ArgName + "Size"),
+  RangeName(std::string(getLowerName())) {}
+
 const std::string &getType() const { return Type; }
 const std::string &getArgName() const { return ArgName; }
 const std::string &getArgSizeName() const { return ArgSizeName; }
@@ -688,6 +695,18 @@
  << "); }\n";
 }
 
+void writeSetter(raw_ostream &OS) const {
+  OS << "  void set" << getUpperName() << "(ASTContext &Ctx, ";
+  writeCtorParameters(OS);
+  OS << ") {\n";
+  OS << "" << ArgSizeName << " = " << getUpperName() << "Size;\n";
+  OS << "" << ArgName << " = new (Ctx, 16) " << getType() << "["
+ << ArgSizeName << "];\n";
+  OS << "  ";
+  writeCtorBody(OS);
+  OS << "  }\n";
+}
+
 void writeCloneArgs(raw_ostream &OS) const override {
   OS << ArgName << ", " << ArgSizeName;
 }
@@ -1169,6 +1188,9 @@
   : VariadicArgument(Arg, Attr, "Expr *")
 {}
 
+VariadicExprArgument(StringRef ArgName, StringRef Attr)
+: VariadicArgument(ArgName, Attr, "Expr *") {}
+
 void writeASTVisitorTraversal(raw_ostream &OS) const override {
   OS << "  {\n";
   OS << "" << getType() << " *I = A->" << getLowerName()
@@ -2138,6 +2160,11 @@
   }
 }
 
+static bool isTypeArgument(const Record *Arg) {
+  return !Arg->getSuperClasses().empty() &&
+ Arg->getSuperClasses().back().first->getName() == "TypeArgument";
+}
+
 /// Emits the first-argument-is-type property for attributes.
 static void emitClangAttrTypeArgList(RecordKeeper &Records, raw_ostream &OS) {
   OS << "#if defined(CLANG_ATTR_TYPE_ARG_LIST)\n";
@@ -2149,7 +2176,7 @@
 if (Args.empty())
   continue;
 
-if (Args[0]->getSuperClasses().back().first->getName() != "TypeArgument")
+if (!isTypeArgument(Args[0]))
   continue;
 
 // All these spellings take a single type argument.
@@ -2179,7 +2206,7 @@
   OS << "#endif // CLANG_ATTR_ARG_CONTEXT_LIST\n\n";
 }
 
-static bool isIdentifierArgument(Record *Arg) {
+static bool isIdentifierArgument(const Record *Arg) {
   return !Arg->getSuperClasses().empty() &&
 llvm::StringSwitch(Arg->getSuperClasses().back().first->getName())
 .Case("IdentifierArgument", true)
@@ -2188,7 +2215,7 @@
 .Default(false);
 }
 
-static bool isVariadicIdentifierArgument(Record *Arg) {
+static bool isVariadicIdentifierArgument(const Record *Arg) {
   return !Arg->getSuperClasses().empty() &&
  llvm::StringSwitch(
  Arg->getSuperClasses().back().first->getName())
@@ -2264,6 +2291,26 @@
   OS << "#endif // CLANG_ATTR_THIS_ISA_IDENTIFIER_ARG_LIST\n\n";
 }
 
+static void emitClangAttrAcceptsExprPack(RecordKeeper &Records,
+ raw_ostream &OS) {
+  OS << "#if defined(CLANG_ATTR_ACCEPTS_EXPR_PACK)\n";
+  ParsedAttrMap Attrs = ge

[PATCH] D115634: [clangd] Cleanup of readability-identifier-naming

2022-02-01 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

Thanks, this is great!
Just a few cases that regex couldn't quite understand, and one bona fide bug!




Comment at: clang-tools-extra/clangd/TUScheduler.cpp:103
 
-static clang::clangd::Key kFileBeingProcessed;
+static clang::clangd::Key KFileBeingProcessed;
 

I think this got reverted - should just be `FileBeingProcessed`



Comment at: clang-tools-extra/clangd/XRefs.cpp:1864
   }
-  QualType VisitCoyieldStmt(const CoyieldExpr *S) {
+  QualType visitCoyieldStmt(const CoyieldExpr *S) {
 return type(S->getOperand());

this was a bug! should be `VisitCoyieldExpr` (capital because it's a CRTP 
override).

But this is is a functional bugfix, please either leave a fixme or change in a 
separate patch



Comment at: clang-tools-extra/clangd/index/YAMLSerialization.cpp:176
 template <> struct MappingTraits {
-  static void mapping(IO &io, SymbolInfo &SymInfo) {
+  static void mapping(IO &Io, SymbolInfo &SymInfo) {
 // FIXME: expose other fields?

sammccall wrote:
> We use `IO` rather than `Io` for initialisms.
> There are cases where the type/name can't match, but this doesn't appear to 
> be one of them (we use `IO &IO` in similar mapping function below)
This change also got lost (and in the next function)



Comment at: clang-tools-extra/clangd/unittests/SerializationTests.cpp:117
 
-MATCHER_P(ID, I, "") { return arg.ID == cantFail(SymbolID::fromStr(I)); }
-MATCHER_P(QName, Name, "") { return (arg.Scope + arg.Name).str() == Name; }
+MATCHER_P(iD, I, "") { return arg.ID == cantFail(SymbolID::fromStr(I)); }
+MATCHER_P(qName, Name, "") { return (arg.Scope + arg.Name).str() == Name; }

`id`, not `iD`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115634

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


[clang] 545317c - [clang-format] Use ranged for loops. NFC.

2022-02-01 Thread Marek Kurdej via cfe-commits

Author: Marek Kurdej
Date: 2022-02-01T14:10:48+01:00
New Revision: 545317cb8eb96947ae20b432525f5667f816df49

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

LOG: [clang-format] Use ranged for loops. NFC.

Added: 


Modified: 
clang/lib/Format/ContinuationIndenter.cpp
clang/lib/Format/Format.cpp
clang/lib/Format/NamespaceEndCommentsFixer.cpp
clang/lib/Format/TokenAnalyzer.cpp
clang/lib/Format/TokenAnnotator.h
clang/lib/Format/UnwrappedLineParser.cpp
clang/lib/Format/UsingDeclarationsSorter.cpp
clang/lib/Format/WhitespaceManager.cpp

Removed: 




diff  --git a/clang/lib/Format/ContinuationIndenter.cpp 
b/clang/lib/Format/ContinuationIndenter.cpp
index b66584652bc82..45a4d23557f76 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -1817,8 +1817,8 @@ unsigned ContinuationIndenter::reformatRawStringLiteral(
   ContentStartsOnNewline || (NewCode->find('\n') != std::string::npos);
   if (IsMultiline) {
 // Break before further function parameters on all levels.
-for (unsigned i = 0, e = State.Stack.size(); i != e; ++i)
-  State.Stack[i].BreakBeforeParameter = true;
+for (ParenState &Paren : State.Stack)
+  Paren.BreakBeforeParameter = true;
   }
   return Fixes.second + PrefixExcessCharacters * Style.PenaltyExcessCharacter;
 }
@@ -1826,8 +1826,8 @@ unsigned ContinuationIndenter::reformatRawStringLiteral(
 unsigned ContinuationIndenter::addMultilineToken(const FormatToken &Current,
  LineState &State) {
   // Break before further function parameters on all levels.
-  for (unsigned i = 0, e = State.Stack.size(); i != e; ++i)
-State.Stack[i].BreakBeforeParameter = true;
+  for (ParenState &Paren : State.Stack)
+Paren.BreakBeforeParameter = true;
 
   unsigned ColumnsUsed = State.Column;
   // We can only affect layout of the first and the last line, so the penalty
@@ -2380,8 +2380,8 @@ ContinuationIndenter::breakProtrudingToken(const 
FormatToken &Current,
 // the next parameter on all levels, so that the next parameter is clearly
 // visible. Line comments already introduce a break.
 if (Current.isNot(TT_LineComment)) {
-  for (unsigned i = 0, e = State.Stack.size(); i != e; ++i)
-State.Stack[i].BreakBeforeParameter = true;
+  for (ParenState &Paren : State.Stack)
+Paren.BreakBeforeParameter = true;
 }
 
 if (Current.is(TT_BlockComment))

diff  --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index baf9c6885a86b..70c7d4d3aceef 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -532,11 +532,9 @@ template <> struct MappingTraits {
 IO.mapOptional("Language", Style.Language);
 
 if (IO.outputting()) {
-  StringRef StylesArray[] = {"LLVM",   "Google", "Chromium", "Mozilla",
- "WebKit", "GNU","Microsoft"};
-  ArrayRef Styles(StylesArray);
-  for (size_t i = 0, e = Styles.size(); i < e; ++i) {
-StringRef StyleName(Styles[i]);
+  StringRef Styles[] = {"LLVM",   "Google", "Chromium", "Mozilla",
+"WebKit", "GNU","Microsoft"};
+  for (StringRef StyleName : Styles) {
 FormatStyle PredefinedStyle;
 if (getPredefinedStyle(StyleName, Style.Language, &PredefinedStyle) &&
 Style == PredefinedStyle) {
@@ -1681,10 +1679,10 @@ std::error_code 
parseConfiguration(llvm::MemoryBufferRef Config,
   // configuration (which can only be at slot 0) after it.
   FormatStyle::FormatStyleSet StyleSet;
   bool LanguageFound = false;
-  for (int i = Styles.size() - 1; i >= 0; --i) {
-if (Styles[i].Language != FormatStyle::LK_None)
-  StyleSet.Add(Styles[i]);
-if (Styles[i].Language == Language)
+  for (const FormatStyle &Style : llvm::reverse(Styles)) {
+if (Style.Language != FormatStyle::LK_None)
+  StyleSet.Add(Style);
+if (Style.Language == Language)
   LanguageFound = true;
   }
   if (!LanguageFound) {
@@ -1890,9 +1888,8 @@ class Formatter : public TokenAnalyzer {
 tooling::Replacements Result;
 deriveLocalStyle(AnnotatedLines);
 AffectedRangeMgr.computeAffectedLines(AnnotatedLines);
-for (unsigned i = 0, e = AnnotatedLines.size(); i != e; ++i) {
-  Annotator.calculateFormattingInformation(*AnnotatedLines[i]);
-}
+for (AnnotatedLine *Line : AnnotatedLines)
+  Annotator.calculateFormattingInformation(*Line);
 Annotator.setCommentLineLevels(AnnotatedLines);
 
 WhitespaceManager Whitespaces(
@@ -1962,10 +1959,10 @@ class Formatter : public TokenAnalyzer {
   deriveLocalStyle(const SmallVectorImpl &AnnotatedLines) {
 bool HasBinPackedFunction = false;
 bool HasOneP

[clang] 34b4f00 - [clang-format] De-pessimize appending newlines. NFC.

2022-02-01 Thread Marek Kurdej via cfe-commits

Author: Marek Kurdej
Date: 2022-02-01T14:10:48+01:00
New Revision: 34b4f00686ffa030fb0fed3bdd24b5e8588dae89

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

LOG: [clang-format] De-pessimize appending newlines. NFC.

* Avoid repeatedly calling std::string::append(char) in a loop.
* Reserve before calling std::string::append(const char *) in a loop.

Added: 


Modified: 
clang/lib/Format/WhitespaceManager.cpp

Removed: 




diff  --git a/clang/lib/Format/WhitespaceManager.cpp 
b/clang/lib/Format/WhitespaceManager.cpp
index 7709fe814864..4c130abd83c3 100644
--- a/clang/lib/Format/WhitespaceManager.cpp
+++ b/clang/lib/Format/WhitespaceManager.cpp
@@ -1347,8 +1347,13 @@ void WhitespaceManager::storeReplacement(SourceRange 
Range, StringRef Text) {
 
 void WhitespaceManager::appendNewlineText(std::string &Text,
   unsigned Newlines) {
-  for (unsigned i = 0; i < Newlines; ++i)
-Text.append(UseCRLF ? "\r\n" : "\n");
+  if (UseCRLF) {
+Text.reserve(Text.size() + 2 * Newlines);
+for (unsigned i = 0; i < Newlines; ++i)
+  Text.append("\r\n");
+  } else {
+Text.append(Newlines, '\n');
+  }
 }
 
 void WhitespaceManager::appendEscapedNewlineText(



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


[PATCH] D118596: [clang][dataflow] Enable comparison of distinct values in Environment

2022-02-01 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel added inline comments.



Comment at: clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h:56
+  /// operations.
+  class ValueModel {
   public:

I really like this new name/API. Much clearer concept.



Comment at: clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h:64
+///
+///  `Val1` must be assigned to a storage location of type `Type`.
+///

What does this comment mean, now that there's no environment? Could we say 
something specific to the values themselves?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118596

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


[clang] e75a342 - [clang-format] Use std::iota and reserve. NFC.

2022-02-01 Thread Marek Kurdej via cfe-commits

Author: Marek Kurdej
Date: 2022-02-01T14:24:01+01:00
New Revision: e75a3428a92016b2689d5efb7ac95ae91761949d

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

LOG: [clang-format] Use std::iota and reserve. NFC.

This way we have at most 1 allocation even if the number of includes is greater 
than the on-stack size of the small vector.

Added: 


Modified: 
clang/lib/Format/Format.cpp

Removed: 




diff  --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 70c7d4d3acee..9611e4ae33f8 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -44,6 +44,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -2521,8 +2522,8 @@ static void sortCppIncludes(const FormatStyle &Style,
   if (!affectsRange(Ranges, IncludesBeginOffset, IncludesEndOffset))
 return;
   SmallVector Indices;
-  for (unsigned i = 0, e = Includes.size(); i != e; ++i)
-Indices.push_back(i);
+  Indices.resize(Includes.size());
+  std::iota(Indices.begin(), Indices.end(), 0);
 
   if (Style.SortIncludes == FormatStyle::SI_CaseInsensitive) {
 llvm::stable_sort(Indices, [&](unsigned LHSI, unsigned RHSI) {



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


[PATCH] D114439: [Annotation] Allow parameter pack expansions and initializer lists in annotate attribute

2022-02-01 Thread Steffen Larsen via Phabricator via cfe-commits
steffenlarsen marked 3 inline comments as done.
steffenlarsen added inline comments.



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:4179
+  MutableArrayRef AllArgs) {
+  assert(AllArgs.size());
+

erichkeane wrote:
> Does this work with a partial specialization?  I'd like to see some tests 
> that ensure we work in that case (both where the partial specialization sets 
> the string literal correctly, and where it doesnt).
I have added such tests in `clang/test/SemaTemplate/attributes.cpp`. Let me 
know if they cover the scenario you were thinking about.



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:4202
+  // If the first argument is value dependent we delay setting the arguments.
+  if (AllArgs.size() && AllArgs[0]->isValueDependent()) {
+auto *Attr = AnnotateAttr::CreateWithDelayedArgs(

erichkeane wrote:
> steffenlarsen wrote:
> > erichkeane wrote:
> > > steffenlarsen wrote:
> > > > steffenlarsen wrote:
> > > > > erichkeane wrote:
> > > > > > if AllArgs.size() == 0, this is an error case.  Annotate requires 
> > > > > > at least 1 parameter.
> > > > > I removed the check but thinking about it again I think it would be 
> > > > > better to reintroduce it and let `HandleAnnotateAttr` call 
> > > > > `checkAtLeastNumArgs`. That way it will also complain about missing 
> > > > > arguments after template instantiation, e.g. if a lone pack expansion 
> > > > > argument evaluates to an empty expression list.
> > > > I have reintroduced the check for `AllArgs.size()` here. This means if 
> > > > `AllArgs` is empty it will continue to `Sema::HandleAnnotateAttr` which 
> > > > will check that there are at least one element in `AllArgs` and fail 
> > > > otherwise with a useful diagnostic. This diagnostic will also be issued 
> > > > if an empty parameter pack is given and that is the only argument of 
> > > > the annotation. Note that `checkAtLeastNumArgs` is a member of 
> > > > `ParsedAttr` which isn't available in `Sema::HandleAnnotateAttr`, so it 
> > > > replicates the check. It could potentially be moved, but given the size 
> > > > I don't think it's necessary in this patch.
> > > > 
> > > > I also added some tests for checking that the diagnostic is issued in 
> > > > the cases (pack expansion and explicitly empty).
> > > > 
> > > > @erichkeane - What do you think?
> > > Hmm... I would expect this to diagnose even in the 'delayed args' case as 
> > > well.  Otherwise:
> > > 
> > > template
> > > [[annotate()]]
> > > 
> > > is not an error, right?
> > Both "delayed args" and immediate instantiation go through the diagnostics 
> > check. The check is intentionally in `Sema::HandleAnnotateAttr` as either 
> > this or template instantiation (if delayed args) goes through it.
> > 
> > ```
> > template [[annotate()]] ...
> > ```
> > 
> > would fail because it does not have any arguments which will be identified 
> > here as "delayed args" will be skipped. 
> > 
> > ```
> > template [[annotate(Is...)]] ...
> > ```
> > 
> > will fail once instantiated with no template arguments as the instantiating 
> > function will pass an empty list of expressions to 
> > `Sema::HandleAnnotationAttr` which will check and fail with the diagnostic. 
> > The latter is tested and I can add the former as a case while adding the 
> > other requested tests.
> Can you make sure both of those have a test?  I missed that the 'no args' 
> case would go right to HandleAnnotateAttr.
For sure. It has been added.



Comment at: clang/test/Parser/cxx0x-attributes.cpp:276
+  void fiz [[clang::annotate("F", Is..., 1, 2, 3)]] ();
+  void fir [[clang::annotate("G", 1, Is..., 2, 3)]] ();
+}

steffenlarsen wrote:
> aaron.ballman wrote:
> > We should also be adding test coverage for things like redeclarations, 
> > partial specializations, etc to make sure that the behavior there is 
> > correct. Those would be Sema tests rather than Parser tests, however.
> Good point. I will add these tests ASAP.
I have added such tests in `clang/test/SemaTemplate/attributes.cpp`. Are these 
along the line of what you were thinking?


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

https://reviews.llvm.org/D114439

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


[clang] af8f1db - [clang-format] Use std::iota and reserve when sorting Java imports. NFC.

2022-02-01 Thread Marek Kurdej via cfe-commits

Author: Marek Kurdej
Date: 2022-02-01T14:29:31+01:00
New Revision: af8f1dbb43bc1a6267ea0b760c7b0fae635938ff

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

LOG: [clang-format] Use std::iota and reserve when sorting Java imports. NFC.

This way we have at most 1 allocation even if the number of includes is greater 
than the on-stack size of the small vector.

Added: 


Modified: 
clang/lib/Format/Format.cpp

Removed: 




diff  --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 9611e4ae33f8..dd4755c2227e 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -2749,13 +2749,16 @@ static void sortJavaImports(const FormatStyle &Style,
   unsigned ImportsBlockSize = ImportsEndOffset - ImportsBeginOffset;
   if (!affectsRange(Ranges, ImportsBeginOffset, ImportsEndOffset))
 return;
+
   SmallVector Indices;
+  Indices.resize(Imports.size());
+  std::iota(Indices.begin(), Indices.end(), 0);
+
   SmallVector JavaImportGroups;
-  for (unsigned i = 0, e = Imports.size(); i != e; ++i) {
-Indices.push_back(i);
-JavaImportGroups.push_back(
-findJavaImportGroup(Style, Imports[i].Identifier));
-  }
+  JavaImportGroups.reserve(Imports.size());
+  for (const JavaImportDirective &Import : Imports)
+JavaImportGroups.push_back(findJavaImportGroup(Style, Import.Identifier));
+
   bool StaticImportAfterNormalImport =
   Style.SortJavaStaticImport == FormatStyle::SJSIO_After;
   llvm::sort(Indices, [&](unsigned LHSI, unsigned RHSI) {



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


[PATCH] D115634: [clangd] Cleanup of readability-identifier-naming

2022-02-01 Thread Christian Kühnel via Phabricator via cfe-commits
kuhnel marked 4 inline comments as done.
kuhnel added a comment.

Thx @sammccall for your patience with this cleanup.




Comment at: clang-tools-extra/clangd/TUScheduler.cpp:103
 
-static clang::clangd::Key kFileBeingProcessed;
+static clang::clangd::Key KFileBeingProcessed;
 

sammccall wrote:
> I think this got reverted - should just be `FileBeingProcessed`
Right, sorry about the backsliding there. If I were ever to do such a cleanup 
again, I need to really split manual and automatic steps into separate commits 
and keep them in a separate branch before squashing them for `arc diff`.



Comment at: clang-tools-extra/clangd/XRefs.cpp:1864
   }
-  QualType VisitCoyieldStmt(const CoyieldExpr *S) {
+  QualType visitCoyieldStmt(const CoyieldExpr *S) {
 return type(S->getOperand());

sammccall wrote:
> this was a bug! should be `VisitCoyieldExpr` (capital because it's a CRTP 
> override).
> 
> But this is is a functional bugfix, please either leave a fixme or change in 
> a separate patch
added FIXME, feel feel free to create a patch for it


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115634

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


[PATCH] D118199: [AArch64] ACLE feature macro for Armv8.8-A MOPS

2022-02-01 Thread Son Tuan Vu via Phabricator via cfe-commits
tyb0807 updated this revision to Diff 404897.
tyb0807 added a comment.

Revert latest patchset, as it should be put into a separate commit for clarity


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118199

Files:
  clang/lib/Basic/Targets/AArch64.cpp
  clang/test/CodeGen/aarch64-mops.c
  clang/test/Preprocessor/aarch64-target-features.c

Index: clang/test/Preprocessor/aarch64-target-features.c
===
--- clang/test/Preprocessor/aarch64-target-features.c
+++ clang/test/Preprocessor/aarch64-target-features.c
@@ -510,9 +510,21 @@
 // CHECK-NO-SVE-VECTOR-BITS-NOT: __ARM_FEATURE_SVE_BITS
 // CHECK-NO-SVE-VECTOR-BITS-NOT: __ARM_FEATURE_SVE_VECTOR_OPERATORS
 
-// == Check Largse System Extensions (LSE)
+// == Check Large System Extensions (LSE)
 // RUN: %clang -target aarch64-none-linux-gnu -march=armv8-a+lse -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-LSE %s
 // RUN: %clang -target arm64-none-linux-gnu -march=armv8-a+lse -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-LSE %s
 // RUN: %clang -target aarch64-none-linux-gnu -march=armv8.1-a -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-LSE %s
 // RUN: %clang -target arm64-none-linux-gnu -march=armv8.1-a -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-LSE %s
 // CHECK-LSE: __ARM_FEATURE_ATOMICS 1
+
+// == Check Armv8.8-A/Armv9.3-A memcpy and memset acceleration instructions (MOPS)
+// RUN: %clang -target aarch64-arm-none-eabi -march=armv8.7-a -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-NOMOPS %s
+// RUN: %clang -target aarch64-arm-none-eabi -march=armv8.7-a+mops -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-MOPS %s
+// RUN: %clang -target aarch64-arm-none-eabi -march=armv8.8-a -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-MOPS %s
+// RUN: %clang -target aarch64-arm-none-eabi -march=armv8.8-a+mops -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-MOPS %s
+// RUN: %clang -target aarch64-arm-none-eabi -march=armv9.2-a -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-NOMOPS %s
+// RUN: %clang -target aarch64-arm-none-eabi -march=armv9.2-a+mops -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-MOPS %s
+// RUN: %clang -target aarch64-arm-none-eabi -march=armv9.3-a -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-MOPS %s
+// RUN: %clang -target aarch64-arm-none-eabi -march=armv9.3-a+mops -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-MOPS %s
+// CHECK-MOPS: __ARM_FEATURE_MOPS 1
+// CHECK-NOMOPS-NOT: __ARM_FEATURE_MOPS 1
Index: clang/test/CodeGen/aarch64-mops.c
===
--- clang/test/CodeGen/aarch64-mops.c
+++ clang/test/CodeGen/aarch64-mops.c
@@ -1,152 +1,281 @@
 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
 
-// RUN: %clang_cc1 -triple aarch64-arm-unknown-eabi -target-feature +mops -target-feature +mte -S -emit-llvm -o - %s  | FileCheck %s
+// RUN: %clang_cc1 -triple aarch64-arm-unknown-eabi -target-feature +mops -target-feature +mte -S -emit-llvm -o - %s  | FileCheck --check-prefix=CHECK-MOPS %s
+// RUN: %clang_cc1 -triple aarch64-arm-unknown-eabi-S -emit-llvm -o - %s  | FileCheck --check-prefix=CHECK-NOMOPS %s
+// RUN: %clang -target aarch64-arm-none-eabi -march=armv8.7-a+mops+memtag -S -emit-llvm %s -o - | FileCheck --check-prefix=CHECK-MOPS %s
+// RUN: %clang -target aarch64-arm-none-eabi -march=armv8.7-a -S -emit-llvm %s -o - | FileCheck --check-prefix=CHECK-NOMOPS %s
+// RUN: %clang -target aarch64-arm-none-eabi -march=armv8.8-a+memtag  -S -emit-llvm %s -o - | FileCheck --check-prefix=CHECK-MOPS %s
+// RUN: %clang -target aarch64-arm-none-eabi -march=armv8.8-a -S -emit-llvm %s -o - | FileCheck --check-prefix=CHECK-NOMOPS %s
+// RUN: %clang -target aarch64-arm-none-eabi -march=armv9.2-a+mops+memtag -S -emit-llvm %s -o - | FileCheck --check-prefix=CHECK-MOPS %s
+// RUN: %clang -target aarch64-arm-none-eabi -march=armv9.2-a -S -emit-llvm %s -o - | FileCheck --check-prefix=CHECK-NOMOPS %s
+// RUN: %clang -target aarch64-arm-none-eabi -march=armv9.3-a+memtag  -S -emit-llvm %s -o - | FileCheck --check-prefix=CHECK-MOPS %s
+// RUN: %clang -target aarch64-arm-none-eabi -march=armv9.3-a -S -emit-llvm %s -o - | FileCheck --check-prefix=CHECK-NOMOPS %s
 
-#define __ARM_FEATURE_MOPS 1
 #include 
 #include 
 
-// CHECK-LABEL: @bzero_0(
-// CHECK-NEXT:  entry:
-// CHECK-NEXT:[[DST_ADDR:%.*]] = alloca i8*, align 8
-// CHECK-NEXT:store i8* [[DST:%.*]], i8** [[DST_ADDR]], align 8
-// CHECK-NEXT:[[TMP0:%.*]] = load i8*, i8** [[DST_ADDR]], align 8
-// CHECK-NEXT:[[TMP1:%.*]] = call i8* @llvm.aarch64.mops.memset.tag(i8* [[TMP0]], i8 0, i64 0)
-// CHECK-NEXT:ret i8* [[TMP1]]
+// CHECK-MOPS-LABEL: @bzero_0(
+// CHECK-M

[PATCH] D117888: [clang][driver][wasm] Support -stdlib=libstdc++ for WebAssembly

2022-02-01 Thread Sam Clegg via Phabricator via cfe-commits
sbc100 added inline comments.



Comment at: clang/lib/Driver/ToolChains/WebAssembly.cpp:445
 addSystemInclude(DriverArgs, CC1Args,
- getDriver().SysRoot + "/include/c++/v1");
+ getDriver().SysRoot + "/include/c++/11");
+break;

Can't these 6 lines be removed now?  (don't they happen as part of 
addLibStdCXXIncludePaths?)



Comment at: clang/lib/Driver/ToolChains/WebAssembly.cpp:493
+// FIXME: Fallback correct?
+Version = "v1";
+  }

Looking at `Gnu.cpp` and `Fuscia.cpp` it seems like `return` (or `return 
false`) here should be fine.



Comment at: clang/lib/Driver/ToolChains/WebAssembly.cpp:544
+
+  if (Version.empty()) {
+// FIXME: Fallback correct?

Just early return here if no headers can be found?  Looking at Gnu.cpp it seems 
that `addLibStdCxxIncludePaths` can simply to nothing if no GCC install is 
found.


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

https://reviews.llvm.org/D117888

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


[PATCH] D118698: [clangd][nfc] cleanup of remaining clang-tidy findings

2022-02-01 Thread Christian Kühnel via Phabricator via cfe-commits
kuhnel created this revision.
kuhnel added a reviewer: sammccall.
Herald added subscribers: usaxena95, kadircet, arphaman.
kuhnel requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

There were some left-overs (or new things) from the previous patches.

This will get us down to 0 open findings except:
clang-tidy is complaining in some files about
`warning: #includes are not sorted properly [llvm-include-order]`
however, clang-format does revert these changes.
It looks like clang-tidy and clang-format disagree there.

Not sure how we can fix that...


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D118698

Files:
  clang-tools-extra/clangd/ConfigYAML.cpp
  clang-tools-extra/clangd/XRefs.cpp
  clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp
  clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp


Index: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
===
--- clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -42,7 +42,6 @@
 using ::testing::Pair;
 using ::testing::SizeIs;
 using ::testing::UnorderedElementsAre;
-using testing::UnorderedElementsAreArray;
 
 ::testing::Matcher withFix(::testing::Matcher FixMatcher) {
   return Field(&Diag::Fixes, ElementsAre(FixMatcher));
Index: clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp
===
--- clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp
+++ clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp
@@ -254,8 +254,9 @@
 if (auto *T = Node->ASTNode.get()) {
   if (T->getAs()) {
 break;
-  } else if (Node->Parent->ASTNode.get() ||
- Node->Parent->ASTNode.get()) {
+  }
+  if (Node->Parent->ASTNode.get() ||
+  Node->Parent->ASTNode.get()) {
 // Node is TypeLoc, but it's parent is either TypeLoc or
 // NestedNameSpecifier. In both cases, we want to go up, to find
 // the outermost TypeLoc.
Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -1930,9 +1930,9 @@
   // FIXME: use HeuristicResolver to unwrap smart pointers?
 
   // Function type => return type.
-  if (auto FT = T->getAs())
+  if (auto *FT = T->getAs())
 return unwrapFindType(FT->getReturnType());
-  if (auto CRD = T->getAsCXXRecordDecl()) {
+  if (auto *CRD = T->getAsCXXRecordDecl()) {
 if (CRD->isLambda())
   return unwrapFindType(CRD->getLambdaCallOperator()->getReturnType());
 // FIXME: more cases we'd prefer the return type of the call operator?
Index: clang-tools-extra/clangd/ConfigYAML.cpp
===
--- clang-tools-extra/clangd/ConfigYAML.cpp
+++ clang-tools-extra/clangd/ConfigYAML.cpp
@@ -349,8 +349,7 @@
 if (auto Scalar = scalarValue(N, Desc)) {
   if (auto Bool = llvm::yaml::parseBool(**Scalar))
 return Located(*Bool, Scalar->Range);
-  else
-warning(Desc + " should be a boolean", N);
+  warning(Desc + " should be a boolean", N);
 }
 return llvm::None;
   }


Index: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
===
--- clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -42,7 +42,6 @@
 using ::testing::Pair;
 using ::testing::SizeIs;
 using ::testing::UnorderedElementsAre;
-using testing::UnorderedElementsAreArray;
 
 ::testing::Matcher withFix(::testing::Matcher FixMatcher) {
   return Field(&Diag::Fixes, ElementsAre(FixMatcher));
Index: clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp
===
--- clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp
+++ clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp
@@ -254,8 +254,9 @@
 if (auto *T = Node->ASTNode.get()) {
   if (T->getAs()) {
 break;
-  } else if (Node->Parent->ASTNode.get() ||
- Node->Parent->ASTNode.get()) {
+  }
+  if (Node->Parent->ASTNode.get() ||
+  Node->Parent->ASTNode.get()) {
 // Node is TypeLoc, but it's parent is either TypeLoc or
 // NestedNameSpecifier. In both cases, we want to go up, to find
 // the outermost TypeLoc.
Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -1930,9 +1930,9 @@
   // FIXME: use HeuristicResolver to unwrap smart pointers?
 
   // Function type => return type.
-  if (auto FT = T->getAs())
+  if (auto *FT = T->getAs())
 return unwrapFindType(F

[PATCH] D118605: [OpenCL] Add support of language builtins for OpenCL C 3.0

2022-02-01 Thread Anton Zabaznov via Phabricator via cfe-commits
azabaznov added inline comments.



Comment at: clang/include/clang/Basic/Builtins.def:88
 //   '__builtin_' prefix. It will be implemented in compiler-rt or libgcc.
+//  G -> this function uses generic address space (OpenCL).
+//  P -> this function uses pipes (OpenCL).

Anastasia wrote:
> Anastasia wrote:
> > It might be better to avoid adding such limited language-specific 
> > functionality into generic representation of Builtins. Do you think could 
> > we could just introduce specific language modes, say:
> > 
> > `OCLC_PIPES`
> > `OCLC_DSE`
> > `OCLC_GAS`
> > 
> > and then check against those in `builtinIsSupported`?
> Btw another approach could be to do something similar to `TARGET_BUILTIN` 
> i.e. list features in the last parameter as strings. We could add a separate 
> macro for such builtins and just reuse target Builtins flow. This might be a 
> bit more scalable in case we would need to add more of such builtins later on?
> 
> It might be better to avoid adding such limited language-specific 
> functionality into generic representation of Builtins.

Nice idea! Though I think LanguageID is not designed to be used this way, it's 
used only to check against specific language version. So it seems pretty 
invasive. Also, function attributes seem more natural to me to specify the type 
of the function. I don't know for sure which way is better...

> Btw another approach could be to do something similar to TARGET_BUILTIN i.e. 
> list features in the last parameter as strings.

I'd prefer to not use TARGET_BUILTIN as it operates on target feature, but 
OpenCL feature is some other concept in clang...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118605

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


[PATCH] D118700: Add support to --gcc-toolchain flag for GCC compiled with --enable-version-specific-runtime-libs.

2022-02-01 Thread Raúl Peñacoba via Phabricator via cfe-commits
rpenacob created this revision.
rpenacob added reviewers: rogfer01, MaskRay, sthibaul.
rpenacob requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

GCC's compiled with --enable-version-specific-runtime-libs. change the paths 
where includes and libs are found.
This patch adds support for these cases


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D118700

Files:
  clang/lib/Driver/ToolChains/Gnu.cpp
  
clang/test/Driver/Inputs/gcc_version_parsing_rt_libs/lib/gcc/x86_64-redhat-linux/10.2.0/crtbegin.o
  
clang/test/Driver/Inputs/gcc_version_parsing_rt_libs/lib/gcc/x86_64-redhat-linux/10.2.0/include/c++/.keep
  
clang/test/Driver/Inputs/gcc_version_parsing_rt_libs/lib/gcc/x86_64-redhat-linux/lib64/.keep
  
clang/test/Driver/Inputs/gcc_version_parsing_rt_libs_multilib/lib/gcc/x86_64-redhat-linux/10.2.0/32/crtbegin.o
  
clang/test/Driver/Inputs/gcc_version_parsing_rt_libs_multilib/lib/gcc/x86_64-redhat-linux/10.2.0/crtbegin.o
  
clang/test/Driver/Inputs/gcc_version_parsing_rt_libs_multilib/lib/gcc/x86_64-redhat-linux/10.2.0/include/c++/.keep
  
clang/test/Driver/Inputs/gcc_version_parsing_rt_libs_multilib/lib/gcc/x86_64-redhat-linux/lib64/.keep
  clang/test/Driver/gcc-toolchain-rt-libs-multi.cpp
  clang/test/Driver/gcc-toolchain-rt-libs.cpp


Index: clang/test/Driver/gcc-toolchain-rt-libs.cpp
===
--- /dev/null
+++ clang/test/Driver/gcc-toolchain-rt-libs.cpp
@@ -0,0 +1,9 @@
+// RUN: (%clangxx %s -v --gcc-toolchain=%S/Inputs/gcc_version_parsing_rt_libs 
--target=x86_64-redhat-linux 2>&1 || true) | FileCheck %s
+
+int main() {}
+
+// CHECK: {{[^ ]*}}clang{{[^ ]*}}" -cc1
+// CHECK-SAME: -internal-isystem {{[^ 
]*}}gcc_version_parsing_rt_libs/lib/gcc/x86_64-redhat-linux/10.2.0/../../../gcc/x86_64-redhat-linux/10.2.0/include/c++
+// CHECK: {{[^ ]*}}ld{{[^ ]*}}"
+// CHECK-SAME: -L{{[^ 
]*}}gcc_version_parsing_rt_libs_multilib/lib/gcc/x86_64-redhat-linux/10.2.0
+// CHECK-SAME: 
-L{{.*}}gcc_version_parsing_rt_libs/lib/gcc/x86_64-redhat-linux/10.2.0/../lib64
Index: clang/test/Driver/gcc-toolchain-rt-libs-multi.cpp
===
--- /dev/null
+++ clang/test/Driver/gcc-toolchain-rt-libs-multi.cpp
@@ -0,0 +1,17 @@
+// RUN: (%clangxx %s -v 
--gcc-toolchain=%S/Inputs/gcc_version_parsing_rt_libs_multilib 
--target=x86_64-redhat-linux 2>&1 || true) | FileCheck %s -check-prefix=X64
+// RUN: (%clangxx %s -m32 -v 
--gcc-toolchain=%S/Inputs/gcc_version_parsing_rt_libs_multilib 
--target=x86_64-redhat-linux 2>&1 || true) | FileCheck %s -check-prefix=X32
+
+int main() {}
+
+// X64: {{[^ ]*}}clang{{[^ ]*}}" -cc1
+// X64-SAME: -internal-isystem {{[^ 
]*}}gcc_version_parsing_rt_libs_multilib/lib/gcc/x86_64-redhat-linux/10.2.0/../../../gcc/x86_64-redhat-linux/10.2.0/include/c++
+// X64: {{[^ ]*}}ld{{[^ ]*}}"
+// X64-SAME: -L{{[^ 
]*}}gcc_version_parsing_rt_libs_multilib/lib/gcc/x86_64-redhat-linux/10.2.0
+// X64-SAME: -L{{[^ 
]*}}gcc_version_parsing_rt_libs_multilib/lib/gcc/x86_64-redhat-linux/10.2.0/../lib64
+
+// X32: {{[^ ]*}}clang{{[^ ]*}}" -cc1
+// X32-SAME: -internal-isystem {{[^ 
]*}}gcc_version_parsing_rt_libs_multilib/lib/gcc/x86_64-redhat-linux/10.2.0/../../../gcc/x86_64-redhat-linux/10.2.0/include/c++
+// X32: {{[^ ]*}}ld{{[^ ]*}}"
+// X32-SAME: -L{{[^ 
]*}}gcc_version_parsing_rt_libs_multilib/lib/gcc/x86_64-redhat-linux/10.2.0/32
+// X32-SAME: -L{{[^ 
]*}}gcc_version_parsing_rt_libs_multilib/lib/gcc/x86_64-redhat-linux/10.2.0/../lib32
+
Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -2803,6 +2803,12 @@
 D, GCCInstallation.getInstallPath() + SelectedMultilib.gccSuffix(),
 Paths);
 
+// Add lib/gcc/$triple/$libdir
+// For GCC built with --enable-version-specific-runtime-libs.
+addPathIfExists(
+D, GCCInstallation.getInstallPath() + "/../" + OSLibDir,
+Paths);
+
 // GCC cross compiling toolchains will install target libraries which ship
 // as part of the toolchain under // rather than as
 // any part of the GCC installation in
@@ -2981,6 +2987,13 @@
   TripleStr, Multilib.includeSuffix(), DriverArgs, CC1Args))
 return true;
 
+  // Try /gcc/$triple/$version/include/c++/ (gcc --print-multiarch is not 
empty).
+  // Like above but for GCC built with --enable-version-specific-runtime-libs.
+  if (addLibStdCXXIncludePaths(
+  LibDir.str() + "/gcc/" + TripleStr + "/" + Version.Text + 
"/include/c++/",
+  TripleStr, Multilib.includeSuffix(), DriverArgs, CC1Args))
+return true;
+
   // Detect Debian g++-multiarch-incdir.diff.
   if (addLibStdCXXIncludePaths(LibDir.str() + "/../include/c++/" + 
Version.Text,
DebianMultiarch, Multilib.includeSuffix(),


Index: clang/test/Driver/gcc-toolc

[PATCH] D118698: [clangd][nfc] cleanup of remaining clang-tidy findings

2022-02-01 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

> clang-tidy is complaining in some files about

Which files? And which clang-tidy --version vs clang-format --version?
I can take a look


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118698

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


[PATCH] D117888: [clang][driver][wasm] Support -stdlib=libstdc++ for WebAssembly

2022-02-01 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder marked an inline comment as done.
tbaeder added inline comments.



Comment at: clang/lib/Driver/ToolChains/WebAssembly.cpp:445
 addSystemInclude(DriverArgs, CC1Args,
- getDriver().SysRoot + "/include/c++/v1");
+ getDriver().SysRoot + "/include/c++/11");
+break;

sbc100 wrote:
> Can't these 6 lines be removed now?  (don't they happen as part of 
> addLibStdCXXIncludePaths?)
Yep, just a leftover, sorry.



Comment at: clang/lib/Driver/ToolChains/WebAssembly.cpp:544
+
+  if (Version.empty()) {
+// FIXME: Fallback correct?

sbc100 wrote:
> Just early return here if no headers can be found?  Looking at Gnu.cpp it 
> seems that `addLibStdCxxIncludePaths` can simply to nothing if no GCC install 
> is found.
I saw that, but I'm not sure if this is correct for wasm. The tests certainly 
break because they check for the `/v1/` (and not `/11/`) include paths but also 
use `-sysroot=/foo`, so the new code doesn't add any flags. Is there a good way 
to update the tests so they stay functional and useful?


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

https://reviews.llvm.org/D117888

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


[PATCH] D109611: Fix CLANG_ENABLE_STATIC_ANALYZER=OFF building all analyzer source

2022-02-01 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added a comment.

@thakis After re-applying this patch locally, I can't see the breakage you 
described with the reproducer provided.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109611

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


[PATCH] D114439: [Annotation] Allow parameter pack expansions and initializer lists in annotate attribute

2022-02-01 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

I think I'm happy, though there are the opens for Aaron (deciding whether the 
'create as delayed' should happen without entry into 'handleAnnotateAttr', and 
whether the 'parsing' looks correct, despite not being the way we discussed), 
so you'll need to wait on him.


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

https://reviews.llvm.org/D114439

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


[PATCH] D118428: [clang-cl] Support the /JMC flag

2022-02-01 Thread Hans Wennborg via Phabricator via cfe-commits
hans added inline comments.



Comment at: llvm/lib/CodeGen/CommandFlags.cpp:462
+  static cl::opt EnableJMCInstrument(
+  "enable-jmc-instrument",
+  cl::desc("Instrument functions with a call to 
__CheckForDebuggerJustMyCode"),

ychen wrote:
> hans wrote:
> > Other "on/off" options don't seem to have "enable" in the name or flag 
> > spelling, e.g. "-strict-dwarf", not "-enable-strict-dwarf". Maybe this 
> > should be just "-jmc-instrument" and JMCInstrument?
> The "-jmc-instrument" is already used by the pass itself (`#define DEBUG_TYPE 
> "jmc-instrument"`). The `DEBUG_TYPE` one enables `opt -jmc-instrument`; this 
> makes `llc -enable-jmc-instrument` to run the pass in IR codegen pipeline.
> 
> Just renamed `cl::opt EnableJMCInstrument` to `cl::opt 
> JMCInstrument`.
Maybe the fact that -jmc-instrument is used by the IR pass is a hint that there 
shouldn't be an llc option for this, then? Looking at the other options here, 
they're all about codegen features, whereas the instrumentation in this patch 
really happens at a higher level.



Comment at: llvm/lib/CodeGen/JMCInstrumenter.cpp:111
+
+void createDefaultCheckFunction(Module &M, const char *CheckFunctionName,
+bool Is32Bit) {

aganea wrote:
> hans wrote:
> > What's the purpose of the default check function? Doesn't the CRT always 
> > provide one? (And if it doesn't, will JMC work at all?)
> @hans That's what MSVC does, to avoid a linker error if the CRT isn't linked 
> in:
> ```
> D:\git\llvm-project>cat main.cpp
> int main() { }
> D:\git\llvm-project>cl main.cpp /JMC /Z7 /c
> Microsoft (R) C/C++ Optimizing Compiler Version 19.29.30139 for x64
> Copyright (C) Microsoft Corporation.  All rights reserved.
> 
> main.cpp
> 
> D:\git\llvm-project>dumpbin /disasm main.obj
> Microsoft (R) COFF/PE Dumper Version 14.29.30139.0
> Copyright (C) Microsoft Corporation.  All rights reserved.
> 
> 
> Dump of file main.obj
> 
> File Type: COFF OBJECT
> 
> main:
>   : 48 83 EC 28sub rsp,28h
>   0004: 48 8D 0D 00 00 00  lea rcx,[__BB04C4AD_main@cpp]
> 00
>   000B: E8 00 00 00 00 call
> __CheckForDebuggerJustMyCode
>   0010: 33 C0  xor eax,eax
>   0012: 48 83 C4 28add rsp,28h
>   0016: C3 ret
> 
> __JustMyCode_Default:
>   : C2 00 00   ret 0
> 
>   Summary
> 
>   50 .chks64
>  228 .debug$S
>  3EC .debug$T
>   70 .drectve
>1 .msvcjmc
>C .pdata
>   1A .text$mn
>8 .xdata
> 
> D:\git\llvm-project>dumpbin /all main.obj | grep -B12 -A5 'COMDAT; sym= 
> __JustMyCode_Default'
> SECTION HEADER #5
> .text$mn name
>0 physical address
>0 virtual address
>3 size of raw data
>  438 file pointer to raw data (0438 to 043A)
>0 file pointer to relocation table
>0 file pointer to line numbers
>0 number of relocations
>0 number of line numbers
> 60501020 flags
>  Code
>  COMDAT; sym= __JustMyCode_Default
>  16 byte align
>  Execute Read
> 
> RAW DATA #5
>   : C2 00 00 □..
> ```
Thanks, I see. Doing the same as MSVC seems fine, but I'm curious why they 
chose this approach.. as far as I understand, JMC will not work for the binary 
in this scenario, so avoiding the link error is not obviously better.



Comment at: llvm/lib/CodeGen/JMCInstrumenter.cpp:175
+M.getOrInsertFunction(CheckFunctionName, getCheckFunctionType(Ctx));
+// FIXME: caching the flag name to prevent repetitive hashing?
+std::string FlagName = getFlagName(*SP, Is32Bit);

ychen wrote:
> hans wrote:
> > Hashing is cheap, but since we're likely to use the same filename again and 
> > again, and it does take some string manipulation, maybe caching the result 
> > is a good idea. Actually, could we cache the flag Constant rather than the 
> > name?
> Yep, used `DenseMap`.
Nice!



Comment at: llvm/lib/CodeGen/JMCInstrumenter.cpp:145
+  LLVMContext &Ctx = M.getContext();
+  bool UseX86FastCall = Triple(M.getTargetTriple()).getArch() == Triple::x86;
+

I still worry a bit about the target-specific code here. Normally, IR passes 
don't have any target-specific knowledge, but ask classes such as 
TargetTransformInfo for target-specific details, or possibly take them as input 
to the pass. For example, see llvm/lib/Transforms/CFGuard/CFGuard.cpp

I'm also not sure that lib/CodeGen/ is the right place for this pass, since 
most files there seem to be machine-IR passes. Maybe the natural place for this 
would be lib/Transforms/Instrumentation/? Is there some good pass we can 
compare this with?



Com

[PATCH] D116541: [OpenMP] Introduce new flag to change offloading driver pipeline

2022-02-01 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Tests have been failing on Mac for over 20 hours now. Time to revert and fix 
async?

   % bin/clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda 
-fopenmp-new-driver -no-canonical-prefixes -ccc-print-bindings 
/Users/thakis/src/llvm-project/clang/test/Driver/openmp-offload-gpu.c -o 
openmp-offload-gpu -fopenmp -fopenmp-targets=nvptx64 -fopenmp-new-driver 
-ccc-print-bindings
  clang version 14.0.0
  Target: x86_64-apple-darwin19.6.0
  Thread model: posix
  InstalledDir: bin
  # "x86_64-apple-darwin19.6.0" - "clang", inputs: 
["/Users/thakis/src/llvm-project/clang/test/Driver/openmp-offload-gpu.c"], 
output: 
"/var/folders/qt/hxckwtm545l643cnk200wzt0gn/T/openmp-offload-gpu-729b05.bc"
  # "nvptx64-nvidia-cuda" - "clang", inputs: 
["/Users/thakis/src/llvm-project/clang/test/Driver/openmp-offload-gpu.c", 
"/var/folders/qt/hxckwtm545l643cnk200wzt0gn/T/openmp-offload-gpu-729b05.bc"],
 output: 
"/var/folders/qt/hxckwtm545l643cnk200wzt0gn/T/openmp-offload-gpu-a35969.s"
  # "nvptx64-nvidia-cuda" - "NVPTX::Assembler", inputs: 
["/var/folders/qt/hxckwtm545l643cnk200wzt0gn/T/openmp-offload-gpu-a35969.s"],
 output: 
"/var/folders/qt/hxckwtm545l643cnk200wzt0gn/T/openmp-offload-gpu-a3f7f0.o"
  # "x86_64-apple-darwin19.6.0" - "clang", inputs: 
["/Users/thakis/src/llvm-project/clang/test/Driver/openmp-offload-gpu.c", 
"/var/folders/qt/hxckwtm545l643cnk200wzt0gn/T/openmp-offload-gpu-a3f7f0.o"],
 output: 
"/var/folders/qt/hxckwtm545l643cnk200wzt0gn/T/openmp-offload-gpu-f53552.bc"
  # "x86_64-apple-darwin19.6.0" - "clang", inputs: 
["/var/folders/qt/hxckwtm545l643cnk200wzt0gn/T/openmp-offload-gpu-f53552.bc"],
 output: 
"/var/folders/qt/hxckwtm545l643cnk200wzt0gn/T/openmp-offload-gpu-86f846.o"
  # "x86_64-apple-darwin19.6.0" - "Offload::Linker", inputs: 
["/var/folders/qt/hxckwtm545l643cnk200wzt0gn/T/openmp-offload-gpu-86f846.o"],
 output: "openmp-offload-gpu"


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116541

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


[PATCH] D116541: [OpenMP] Introduce new flag to change offloading driver pipeline

2022-02-01 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added a comment.

In D116541#3287330 , @thakis wrote:

> Tests have been failing on Mac for over 20 hours now. Time to revert and fix 
> async?
>
>% bin/clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda 
> -fopenmp-new-driver -no-canonical-prefixes -ccc-print-bindings 
> /Users/thakis/src/llvm-project/clang/test/Driver/openmp-offload-gpu.c -o 
> openmp-offload-gpu -fopenmp -fopenmp-targets=nvptx64 -fopenmp-new-driver 
> -ccc-print-bindings
>   clang version 14.0.0
>   Target: x86_64-apple-darwin19.6.0
>   Thread model: posix
>   InstalledDir: bin
>   # "x86_64-apple-darwin19.6.0" - "clang", inputs: 
> ["/Users/thakis/src/llvm-project/clang/test/Driver/openmp-offload-gpu.c"], 
> output: 
> "/var/folders/qt/hxckwtm545l643cnk200wzt0gn/T/openmp-offload-gpu-729b05.bc"
>   # "nvptx64-nvidia-cuda" - "clang", inputs: 
> ["/Users/thakis/src/llvm-project/clang/test/Driver/openmp-offload-gpu.c", 
> "/var/folders/qt/hxckwtm545l643cnk200wzt0gn/T/openmp-offload-gpu-729b05.bc"],
>  output: 
> "/var/folders/qt/hxckwtm545l643cnk200wzt0gn/T/openmp-offload-gpu-a35969.s"
>   # "nvptx64-nvidia-cuda" - "NVPTX::Assembler", inputs: 
> ["/var/folders/qt/hxckwtm545l643cnk200wzt0gn/T/openmp-offload-gpu-a35969.s"],
>  output: 
> "/var/folders/qt/hxckwtm545l643cnk200wzt0gn/T/openmp-offload-gpu-a3f7f0.o"
>   # "x86_64-apple-darwin19.6.0" - "clang", inputs: 
> ["/Users/thakis/src/llvm-project/clang/test/Driver/openmp-offload-gpu.c", 
> "/var/folders/qt/hxckwtm545l643cnk200wzt0gn/T/openmp-offload-gpu-a3f7f0.o"],
>  output: 
> "/var/folders/qt/hxckwtm545l643cnk200wzt0gn/T/openmp-offload-gpu-f53552.bc"
>   # "x86_64-apple-darwin19.6.0" - "clang", inputs: 
> ["/var/folders/qt/hxckwtm545l643cnk200wzt0gn/T/openmp-offload-gpu-f53552.bc"],
>  output: 
> "/var/folders/qt/hxckwtm545l643cnk200wzt0gn/T/openmp-offload-gpu-86f846.o"
>   # "x86_64-apple-darwin19.6.0" - "Offload::Linker", inputs: 
> ["/var/folders/qt/hxckwtm545l643cnk200wzt0gn/T/openmp-offload-gpu-86f846.o"],
>  output: "openmp-offload-gpu"

I'd rather just disable the test, this patch has like 20 others that depend on 
it so we'd need to revert all of those. It's definitely not grabbing the 
bitcode from the cache as expected. I can disable this part of the test for 
now, but do you know how I could figure out how to reproduce this? I've been 
tracking some other buildbots and they don't seem to have the same issue so I'm 
not sure what's special about this one.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116541

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


[PATCH] D117888: [clang][driver][wasm] Support -stdlib=libstdc++ for WebAssembly

2022-02-01 Thread Sam Clegg via Phabricator via cfe-commits
sbc100 added inline comments.



Comment at: clang/lib/Driver/ToolChains/WebAssembly.cpp:544
+
+  if (Version.empty()) {
+// FIXME: Fallback correct?

tbaeder wrote:
> sbc100 wrote:
> > Just early return here if no headers can be found?  Looking at Gnu.cpp it 
> > seems that `addLibStdCxxIncludePaths` can simply to nothing if no GCC 
> > install is found.
> I saw that, but I'm not sure if this is correct for wasm. The tests certainly 
> break because they check for the `/v1/` (and not `/11/`) include paths but 
> also use `-sysroot=/foo`, so the new code doesn't add any flags. Is there a 
> good way to update the tests so they stay functional and useful?
I would take a look at how other platforms test this... perhaps they setup some 
kind of fake header tree?  Or perhaps they don't test these paths at all.   For 
sure they don't depend on the actual system where the tests run, right?

Can you point me to the tests that fail if you simply return empty string like 
on other platforms?


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

https://reviews.llvm.org/D117888

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


[PATCH] D116597: [analyzer] Don't track function calls as control dependencies

2022-02-01 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

Ping ^-^


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

https://reviews.llvm.org/D116597

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


[PATCH] D93298: [RISCV] add the MC layer support of Zfinx extension

2022-02-01 Thread Shao-Ce SUN via Phabricator via cfe-commits
achieveartificialintelligence updated this revision to Diff 404910.
achieveartificialintelligence added a comment.

Separate the Zhinxmin and Zhinx extensions. Inspired by D118581 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93298

Files:
  llvm/lib/Support/RISCVISAInfo.cpp
  llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
  llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp
  llvm/lib/Target/RISCV/RISCV.td
  llvm/lib/Target/RISCV/RISCVInstrInfoD.td
  llvm/lib/Target/RISCV/RISCVInstrInfoF.td
  llvm/lib/Target/RISCV/RISCVInstrInfoZfh.td
  llvm/lib/Target/RISCV/RISCVRegisterInfo.td
  llvm/lib/Target/RISCV/RISCVSubtarget.h
  llvm/test/MC/RISCV/attribute-arch.s
  llvm/test/MC/RISCV/rv32i-invalid.s
  llvm/test/MC/RISCV/rv32zdinx-invalid.s
  llvm/test/MC/RISCV/rv32zdinx-valid.s
  llvm/test/MC/RISCV/rv32zfinx-invalid.s
  llvm/test/MC/RISCV/rv32zfinx-valid.s
  llvm/test/MC/RISCV/rv32zhinx-invalid.s
  llvm/test/MC/RISCV/rv32zhinx-valid.s
  llvm/test/MC/RISCV/rv32zhinxmin-invalid.s
  llvm/test/MC/RISCV/rv32zhinxmin-valid.s
  llvm/test/MC/RISCV/rv64zdinx-invalid.s
  llvm/test/MC/RISCV/rv64zdinx-valid.s
  llvm/test/MC/RISCV/rv64zfinx-invalid.s
  llvm/test/MC/RISCV/rv64zfinx-valid.s
  llvm/test/MC/RISCV/rv64zhinx-invalid.s
  llvm/test/MC/RISCV/rv64zhinx-valid.s
  llvm/test/MC/RISCV/rv64zhinxmin-invalid.s
  llvm/test/MC/RISCV/rv64zhinxmin-valid.s
  llvm/test/MC/RISCV/rvzdinx-aliases-valid.s
  llvm/test/MC/RISCV/rvzfinx-aliases-valid.s
  llvm/test/MC/RISCV/rvzhinx-aliases-valid.s

Index: llvm/test/MC/RISCV/rvzhinx-aliases-valid.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rvzhinx-aliases-valid.s
@@ -0,0 +1,82 @@
+# RUN: llvm-mc %s -triple=riscv32 -mattr=+zhinx -riscv-no-aliases \
+# RUN: | FileCheck -check-prefix=CHECK-INST %s
+# RUN: llvm-mc %s -triple=riscv32 -mattr=+zhinx \
+# RUN: | FileCheck -check-prefix=CHECK-ALIAS %s
+# RUN: llvm-mc %s -triple=riscv64 -mattr=+zhinx -riscv-no-aliases \
+# RUN: | FileCheck -check-prefix=CHECK-INST %s
+# RUN: llvm-mc %s -triple=riscv64 -mattr=+zhinx \
+# RUN: | FileCheck -check-prefix=CHECK-ALIAS %s
+# RUN: llvm-mc -filetype=obj -triple riscv32 -mattr=+zhinx %s \
+# RUN: | llvm-objdump -d --mattr=+zhinx -M no-aliases - \
+# RUN: | FileCheck -check-prefix=CHECK-INST %s
+# RUN: llvm-mc -filetype=obj -triple riscv32 -mattr=+zhinx %s \
+# RUN: | llvm-objdump -d --mattr=+zhinx - \
+# RUN: | FileCheck -check-prefix=CHECK-ALIAS %s
+# RUN: llvm-mc -filetype=obj -triple riscv64 -mattr=+zhinx %s \
+# RUN: | llvm-objdump -d --mattr=+zhinx -M no-aliases - \
+# RUN: | FileCheck -check-prefix=CHECK-INST %s
+# RUN: llvm-mc -filetype=obj -triple riscv64 -mattr=+zhinx %s \
+# RUN: | llvm-objdump -d --mattr=+zhinx - \
+# RUN: | FileCheck -check-prefix=CHECK-ALIAS %s
+
+##===--===##
+## Assembler Pseudo Instructions (User-Level ISA, Version 2.2, Chapter 20)
+##===--===##
+
+# CHECK-INST: fsgnjx.h s1, s2, s2
+# CHECK-ALIAS: fabs.h s1, s2
+fabs.h s1, s2
+# CHECK-INST: fsgnjn.h s2, s3, s3
+# CHECK-ALIAS: fneg.h s2, s3
+fneg.h s2, s3
+
+# CHECK-INST: flt.h tp, s6, s5
+# CHECK-ALIAS: flt.h tp, s6, s5
+fgt.h x4, s5, s6
+# CHECK-INST: fle.h t2, s1, s0
+# CHECK-ALIAS: fle.h t2, s1, s0
+fge.h x7, x8, x9
+
+##===--===##
+## Aliases which omit the rounding mode.
+##===--===##
+
+# CHECK-INST: fmadd.h a0, a1, a2, a3, dyn
+# CHECK-ALIAS: fmadd.h a0, a1, a2, a3
+fmadd.h x10, x11, x12, x13
+# CHECK-INST: fmsub.h a4, a5, a6, a7, dyn
+# CHECK-ALIAS: fmsub.h a4, a5, a6, a7
+fmsub.h x14, x15, x16, x17
+# CHECK-INST: fnmsub.h s2, s3, s4, s5, dyn
+# CHECK-ALIAS: fnmsub.h s2, s3, s4, s5
+fnmsub.h x18, x19, x20, x21
+# CHECK-INST: fnmadd.h s6, s7, s8, s9, dyn
+# CHECK-ALIAS: fnmadd.h s6, s7, s8, s9
+fnmadd.h x22, x23, x24, x25
+# CHECK-INST: fadd.h s10, s11, t3, dyn
+# CHECK-ALIAS: fadd.h s10, s11, t3
+fadd.h x26, x27, x28
+# CHECK-INST: fsub.h t4, t5, t6, dyn
+# CHECK-ALIAS: fsub.h t4, t5, t6
+fsub.h x29, x30, x31
+# CHECK-INST: fmul.h s0, s1, s2, dyn
+# CHECK-ALIAS: fmul.h s0, s1, s2
+fmul.h s0, s1, s2
+# CHECK-INST: fdiv.h s3, s4, s5, dyn
+# CHECK-ALIAS: fdiv.h s3, s4, s5
+fdiv.h s3, s4, s5
+# CHECK-INST: fsqrt.h s6, s7, dyn
+# CHECK-ALIAS: fsqrt.h s6, s7
+fsqrt.h s6, s7
+# CHECK-INST: fcvt.w.h a0, s5, dyn
+# CHECK-ALIAS: fcvt.w.h a0, s5
+fcvt.w.h a0, s5
+# CHECK-INST: fcvt.wu.h a1, s6, dyn
+# CHECK-ALIAS: fcvt.wu.h a1, s6
+fcvt.wu.h a1, s6
+# CHECK-INST: fcvt.h.w t6, a4, dyn
+# CHECK-ALIAS: fcvt.h.w t6, a4
+fcvt.h.w t6, a4
+# CHECK-INST: fcvt.h.wu s0, a5, dyn
+# CHECK-ALIAS: fcvt.h.wu s0, a5
+fcvt.h.wu s0, a5
Index

[PATCH] D116541: [OpenMP] Introduce new flag to change offloading driver pipeline

2022-02-01 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

In D116541#3287342 , @jhuber6 wrote:

> In D116541#3287330 , @thakis wrote:
>
>> Tests have been failing on Mac for over 20 hours now. Time to revert and fix 
>> async?
>>
>>% bin/clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda 
>> -fopenmp-new-driver -no-canonical-prefixes -ccc-print-bindings 
>> /Users/thakis/src/llvm-project/clang/test/Driver/openmp-offload-gpu.c -o 
>> openmp-offload-gpu -fopenmp -fopenmp-targets=nvptx64 -fopenmp-new-driver 
>> -ccc-print-bindings
>>   clang version 14.0.0
>>   Target: x86_64-apple-darwin19.6.0
>>   Thread model: posix
>>   InstalledDir: bin
>>   # "x86_64-apple-darwin19.6.0" - "clang", inputs: 
>> ["/Users/thakis/src/llvm-project/clang/test/Driver/openmp-offload-gpu.c"], 
>> output: 
>> "/var/folders/qt/hxckwtm545l643cnk200wzt0gn/T/openmp-offload-gpu-729b05.bc"
>>   # "nvptx64-nvidia-cuda" - "clang", inputs: 
>> ["/Users/thakis/src/llvm-project/clang/test/Driver/openmp-offload-gpu.c", 
>> "/var/folders/qt/hxckwtm545l643cnk200wzt0gn/T/openmp-offload-gpu-729b05.bc"],
>>  output: 
>> "/var/folders/qt/hxckwtm545l643cnk200wzt0gn/T/openmp-offload-gpu-a35969.s"
>>   # "nvptx64-nvidia-cuda" - "NVPTX::Assembler", inputs: 
>> ["/var/folders/qt/hxckwtm545l643cnk200wzt0gn/T/openmp-offload-gpu-a35969.s"],
>>  output: 
>> "/var/folders/qt/hxckwtm545l643cnk200wzt0gn/T/openmp-offload-gpu-a3f7f0.o"
>>   # "x86_64-apple-darwin19.6.0" - "clang", inputs: 
>> ["/Users/thakis/src/llvm-project/clang/test/Driver/openmp-offload-gpu.c", 
>> "/var/folders/qt/hxckwtm545l643cnk200wzt0gn/T/openmp-offload-gpu-a3f7f0.o"],
>>  output: 
>> "/var/folders/qt/hxckwtm545l643cnk200wzt0gn/T/openmp-offload-gpu-f53552.bc"
>>   # "x86_64-apple-darwin19.6.0" - "clang", inputs: 
>> ["/var/folders/qt/hxckwtm545l643cnk200wzt0gn/T/openmp-offload-gpu-f53552.bc"],
>>  output: 
>> "/var/folders/qt/hxckwtm545l643cnk200wzt0gn/T/openmp-offload-gpu-86f846.o"
>>   # "x86_64-apple-darwin19.6.0" - "Offload::Linker", inputs: 
>> ["/var/folders/qt/hxckwtm545l643cnk200wzt0gn/T/openmp-offload-gpu-86f846.o"],
>>  output: "openmp-offload-gpu"
>
> I'd rather just disable the test, this patch has like 20 others that depend 
> on it so we'd need to revert all of those. It's definitely not grabbing the 
> bitcode from the cache as expected. I can disable this part of the test for 
> now, but do you know how I could figure out how to reproduce this? I've been 
> tracking some other buildbots and they don't seem to have the same issue so 
> I'm not sure what's special about this one.

Just build and run tests on any mac. This fails on 3 different macs I tried (2x 
arm, 1x intel), in a bunch of different build configs.

For the particular build I sent the output from, the cmake invocation looked 
like `/Applications/CMake.app/Contents/bin/cmake -GNinja 
-DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=ON 
-DLLVM_ENABLE_PROJECTS='compiler-rt;libcxx;clang' -DLLVM_APPEND_VC_REV=NO 
-DCMAKE_C_COMPILER=$HOME/src/chrome/src/third_party/llvm-build/Release+Asserts/bin/clang
 
-DCMAKE_CXX_COMPILER=$HOME/src/chrome/src/third_party/llvm-build/Release+Asserts/bin/clang++
 -DCMAKE_OSX_SYSROOT=/Users/thakis/src/llvm-project/sysroot/MacOSX.sdk 
-DDARWIN_macosx_CACHED_SYSROOT=/Users/thakis/src/llvm-project/sysroot/MacOSX.sdk
 
-DDARWIN_iphoneos_CACHED_SYSROOT=/Users/thakis/src/llvm-project/sysroot/iPhoneOS.sdk
 
-DDARWIN_iphonesimulator_CACHED_SYSROOT=/Users/thakis/src/llvm-project/sysroot/iPhoneSimulator.sdk
 ../llvm`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116541

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


[PATCH] D116541: [OpenMP] Introduce new flag to change offloading driver pipeline

2022-02-01 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

ps "This is inconvenient to revert since 20 patches landed" means you're 
landing too many patches too quickly. This landed less than 24h ago, so if it's 
difficult to revert, that's a bit of a problem for the project, right?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116541

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


[clang-tools-extra] e9cba78 - [clangd] Group and extend release notes

2022-02-01 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2022-02-01T15:51:57+01:00
New Revision: e9cba7865323425e9c7d3b8a14d7c19fab3d6b65

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

LOG: [clangd] Group and extend release notes

Added: 


Modified: 
clang-tools-extra/docs/ReleaseNotes.rst

Removed: 




diff  --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index 3724f643c6165..d1f7f6bdf05dc 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -47,85 +47,138 @@ Major New Features
 Improvements to clangd
 --
 
-- `clangd/inlayHints `_
-  LSP extension to provide information not directly available in code,
+Inlay hints
+^^^
+
+- This feature provides texutal hints interleaved with the code,
   like parameter names, deduced types and designated initializers.
 
-- Diagnostics and fixes for `unused include
-  `_ directives, according to
-  IWYU style. Off by default, can be turned on through
-  `Diagnostics.IncludeCleaner `_
-  config option.
+- The `clangd/inlayHints `_
+  LSP extension is now documented, and both position and range.
 
-- Support for ``textDocument/typeDefinition`` LSP request.
+- Inlay hints are now on-by-default in clangd, if the client supports and
+  exposes them. (`vscode-clangd
+  
`_
+  does so). The ``-inlay-hints`` flag has been removed.
 
-- Relevant diagnostics are emitted with ``Deprecated`` and ``Unnecessary``
-  tags from LSP 3.15.
+- Inlay hints can be `disabled or configured
+  `_ in the config file.
 
-- Richer ``semanticTokens`` information for:
+Diagnostics
+^^^
 
-  - Virtual methods
-  - Mutable reference arguments
-  - Lambda captures
+- `Unused #include
+  `_ diagnostics are available.
+  These are off by default, and can be turned on through the
+  `Diagnostics.UnusedIncludes `_
+  config option.
 
-- Support for attributes, (e.g. ``[[nodiscard, gsl::Owner(Foo)]]``) in various
-  features like hover, code completion, go-to-definition.
+- ``Deprecated`` and ``Unnecessary`` tags from LSP 3.15 are set on
+  ``-Wdeprecated`` and ``-Wunused`` diagnostics. Clients may display these
+  in a specialized way.
 
-- ``#pragma mark`` directives now show up in document outline.
+- clangd suggests inserting includes to fix problems in more cases:
 
-- ``hover`` on include directives shows the resolved header path.
+  - calling unknown functions in C, even when an implicit declaration is
+inferred.
+  - incomplete types (some additional cases).
+  - various diagnostics that specify "include " in their text.
 
-- ``hover`` on character literals shows their numeric value.
+- The "populate switch" action is more reliably offered as a fix for
+  ``-Wswitch`` warnings, and works with C enums.
 
-- Include desugared types in hover, controlled with `Hover.ShowAKA
-  `_ config option.
+- Warnings specified by ``ExtraArgs: -W...`` flags in ``.clang-tidy`` config
+  files are now produced.
 
-- Extra diagnostic fixes to insert includes:
+Semantic Highlighting
+^
 
-  - Includes are suggested in C even when an implicit declaration is generated.
-  - Incomplete types (some additional cases).
+- ``virtual`` modifier for method names
+- ``usedAsMutableReference`` modifier for function parameters
+- Lambda captures now marked as local variables.
 
-- Code completion for ``/*ParameterName=*/`` commetns.
+Compile flags
+^
 
-- Provide and improve signature help for:
+- Compile flags like ``-xc++-header`` that must precede input file names are 
now
+  added correctly by the
+  `CompileFlags.Add `_ config option.
 
-  - Variadic functions
-  - Template argument lists
-  - Braced constructor calls
-  - Aggregate initializers
-  - Constructor initializers
+- If multiple architectures are specified (e.g. when targeting Apple M1+Intel),
+  clangd will now use the host architecture instead of failing to parse.
 
-- Improved handling of short identifiers in code completion and workspace 
symbol
-  requests.
+- Added `CompileFlags.Compiler `_
+  option to override executable name in compile flags.
 
-- Improved handling of symbols introduced via using declarations.
+- Copying ``compile_commands.json`` entries from one fil

[PATCH] D116541: [OpenMP] Introduce new flag to change offloading driver pipeline

2022-02-01 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added a comment.

In D116541#3287379 , @thakis wrote:

> Just build and run tests on any mac. This fails on 3 different macs I tried 
> (2x arm, 1x intel), in a bunch of different build configs.
>
> For the particular build I sent the output from, the cmake invocation looked 
> like `/Applications/CMake.app/Contents/bin/cmake -GNinja 
> -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=ON 
> -DLLVM_ENABLE_PROJECTS='compiler-rt;libcxx;clang' -DLLVM_APPEND_VC_REV=NO 
> -DCMAKE_C_COMPILER=$HOME/src/chrome/src/third_party/llvm-build/Release+Asserts/bin/clang
>  
> -DCMAKE_CXX_COMPILER=$HOME/src/chrome/src/third_party/llvm-build/Release+Asserts/bin/clang++
>  -DCMAKE_OSX_SYSROOT=/Users/thakis/src/llvm-project/sysroot/MacOSX.sdk 
> -DDARWIN_macosx_CACHED_SYSROOT=/Users/thakis/src/llvm-project/sysroot/MacOSX.sdk
>  
> -DDARWIN_iphoneos_CACHED_SYSROOT=/Users/thakis/src/llvm-project/sysroot/iPhoneOS.sdk
>  
> -DDARWIN_iphonesimulator_CACHED_SYSROOT=/Users/thakis/src/llvm-project/sysroot/iPhoneSimulator.sdk
>  ../llvm`

I don't have access to a mac computer right now. I'm just going to remove the 
problematic check line so this passes and add it in later once I figure out 
what's going on here. The output you're getting should still work, it's just 
not ideal because we're regenerating the bitcode file so this isn't a breaking 
issue.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116541

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


[clang] 28c1534 - [OpenMP] Temporarily remove checks to fix failing test on MACOS

2022-02-01 Thread Joseph Huber via cfe-commits

Author: Joseph Huber
Date: 2022-02-01T09:56:09-05:00
New Revision: 28c15341368bc8c557313d8929a4220a8c38516c

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

LOG: [OpenMP] Temporarily remove checks to fix failing test on MACOS

Summary:
This patch removes some of the check lines that are problematic on
MACOS. The output on the MAC systems works but should be slightly
different. Because this is simply the output being slightly different
rather than broken functionality the test is being changed.

Added: 


Modified: 
clang/test/Driver/openmp-offload-gpu.c

Removed: 




diff  --git a/clang/test/Driver/openmp-offload-gpu.c 
b/clang/test/Driver/openmp-offload-gpu.c
index a9fc3e7b33a42..af7ba7c802e5d 100644
--- a/clang/test/Driver/openmp-offload-gpu.c
+++ b/clang/test/Driver/openmp-offload-gpu.c
@@ -358,8 +358,6 @@
 // NEW_DRIVER: "[[HOST_TRIPLE:.+]]" - "clang", inputs: ["[[HOST_INPUT:.+]]"], 
output: "[[HOST_BC:.+]]" 
 // NEW_DRIVER: "nvptx64-nvidia-cuda" - "clang", inputs: 
["[[DEVICE_INPUT:.+]]", "[[HOST_BC]]"], output: "[[DEVICE_ASM:.+]]"
 // NEW_DRIVER: "nvptx64-nvidia-cuda" - "NVPTX::Assembler", inputs: 
["[[DEVICE_ASM]]"], output: "[[DEVICE_OBJ:.+]]" 
-// NEW_DRIVER: "[[HOST_TRIPLE:.+]]" - "clang", inputs: ["[[HOST_BC]]", 
"[[DEVICE_OBJ]]"], output: "[[HOST_OBJ:.+]]" 
-// NEW_DRIVER: "[[HOST_TRIPLE:.+]]" - "[[LINKER:.+]]", inputs: 
["[[HOST_OBJ]]"], output: "openmp-offload-gpu"
 
 // RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda 
-Xopenmp-target=nvptx64-nvida-cuda -march=sm_70 \
 // RUN:  
--libomptarget-nvptx-bc-path=%S/Inputs/libomptarget/libomptarget-new-nvptx-test.bc
 \



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


[PATCH] D116541: [OpenMP] Introduce new flag to change offloading driver pipeline

2022-02-01 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added a comment.

Removed the two lines in rG28c15341368b 
, let me 
know if this lets the tests pass. I'll look into getting an access somehow so I 
can reproduce this and figure it out.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116541

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


[clang-tools-extra] 7af1a2e - [clangd] Fix handling of co_await in go-to-type

2022-02-01 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2022-02-01T16:01:53+01:00
New Revision: 7af1a2ed815dda133f9088fdfd3979f843edfcc9

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

LOG: [clangd] Fix handling of co_await in go-to-type

Added: 


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

Removed: 




diff  --git a/clang-tools-extra/clangd/XRefs.cpp 
b/clang-tools-extra/clangd/XRefs.cpp
index c6a24450c0d1..fea143e67824 100644
--- a/clang-tools-extra/clangd/XRefs.cpp
+++ b/clang-tools-extra/clangd/XRefs.cpp
@@ -1861,9 +1861,7 @@ static QualType typeForNode(const SelectionTree::Node *N) 
{
   QualType VisitCXXThrowExpr(const CXXThrowExpr *S) {
 return S->getSubExpr()->getType();
   }
-  // FIXME(sammccall): this should be VisitCoyieldExpr
-  // see https://reviews.llvm.org/D115634
-  QualType visitCoyieldStmt(const CoyieldExpr *S) {
+  QualType VisitCoyieldExpr(const CoyieldExpr *S) {
 return type(S->getOperand());
   }
   // Treat a designated initializer like a reference to the field.



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


[PATCH] D118596: [clang][dataflow] Enable comparison of distinct values in Environment

2022-02-01 Thread Stanislav Gatev via Phabricator via cfe-commits
sgatev updated this revision to Diff 404923.
sgatev marked an inline comment as done.
sgatev added a comment.

Address reviewers' comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118596

Files:
  clang/include/clang/Analysis/FlowSensitive/DataflowAnalysis.h
  clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
  clang/include/clang/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.h
  clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
  clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
  clang/unittests/Analysis/FlowSensitive/TestingSupport.h
  clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp

Index: clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
@@ -19,6 +19,7 @@
 #include "clang/Analysis/FlowSensitive/DataflowLattice.h"
 #include "clang/Analysis/FlowSensitive/Value.h"
 #include "clang/Tooling/Tooling.h"
+#include "llvm/ADT/Optional.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallSet.h"
 #include "llvm/ADT/StringRef.h"
@@ -49,53 +50,35 @@
 using ::testing::UnorderedElementsAre;
 
 template 
-class AnalysisCallback : public ast_matchers::MatchFinder::MatchCallback {
-public:
-  AnalysisCallback(AnalysisT (*MakeAnalysis)(ASTContext &))
-  : MakeAnalysis(MakeAnalysis) {}
-  void run(const ast_matchers::MatchFinder::MatchResult &Result) override {
-assert(BlockStates.empty());
-
-const auto *Func = Result.Nodes.getNodeAs("func");
-assert(Func != nullptr);
-
-Stmt *Body = Func->getBody();
-assert(Body != nullptr);
-
-auto CFCtx = llvm::cantFail(
-ControlFlowContext::build(nullptr, Body, Result.Context));
-
-AnalysisT Analysis = MakeAnalysis(*Result.Context);
-DataflowAnalysisContext DACtx;
-Environment Env(DACtx);
-BlockStates = runDataflowAnalysis(CFCtx, Analysis, Env);
-  }
-
-  AnalysisT (*MakeAnalysis)(ASTContext &);
-  std::vector<
-  llvm::Optional>>
-  BlockStates;
-};
-
-template 
-std::vector>>
+llvm::Expected>>>
 runAnalysis(llvm::StringRef Code, AnalysisT (*MakeAnalysis)(ASTContext &)) {
   std::unique_ptr AST =
   tooling::buildASTFromCodeWithArgs(Code, {"-std=c++11"});
 
-  AnalysisCallback Callback(MakeAnalysis);
-  ast_matchers::MatchFinder Finder;
-  Finder.addMatcher(
-  ast_matchers::functionDecl(ast_matchers::hasName("target")).bind("func"),
-  &Callback);
-  Finder.matchAST(AST->getASTContext());
+  auto *Func = selectFirst(
+  "func", match(functionDecl(ast_matchers::hasName("target")).bind("func"),
+AST->getASTContext()));
+  assert(Func != nullptr);
+
+  Stmt *Body = Func->getBody();
+  assert(Body != nullptr);
 
-  return Callback.BlockStates;
+  auto CFCtx = llvm::cantFail(
+  ControlFlowContext::build(nullptr, Body, &AST->getASTContext()));
+
+  AnalysisT Analysis = MakeAnalysis(AST->getASTContext());
+  DataflowAnalysisContext DACtx;
+  Environment Env(DACtx);
+
+  return runDataflowAnalysis(CFCtx, Analysis, Env);
 }
 
 TEST(DataflowAnalysisTest, NoopAnalysis) {
-  auto BlockStates = runAnalysis(
-  "void target() {}", [](ASTContext &C) { return NoopAnalysis(C, false); });
+  auto BlockStates = llvm::cantFail(
+  runAnalysis("void target() {}", [](ASTContext &C) {
+return NoopAnalysis(C, false);
+  }));
   EXPECT_EQ(BlockStates.size(), 2u);
   EXPECT_TRUE(BlockStates[0].hasValue());
   EXPECT_TRUE(BlockStates[1].hasValue());
@@ -132,18 +115,15 @@
 };
 
 TEST(DataflowAnalysisTest, NonConvergingAnalysis) {
-  auto BlockStates = runAnalysis(
-  R"(
+  std::string Code = R"(
 void target() {
   while(true) {}
 }
-  )",
-  [](ASTContext &C) { return NonConvergingAnalysis(C); });
-  EXPECT_EQ(BlockStates.size(), 4u);
-  EXPECT_TRUE(BlockStates[0].hasValue());
-  EXPECT_TRUE(BlockStates[1].hasValue());
-  EXPECT_TRUE(BlockStates[2].hasValue());
-  EXPECT_TRUE(BlockStates[3].hasValue());
+  )";
+  auto Res = runAnalysis(
+  Code, [](ASTContext &C) { return NonConvergingAnalysis(C); });
+  EXPECT_EQ(llvm::toString(Res.takeError()),
+"maximum number of iterations reached");
 }
 
 struct FunctionCallLattice {
@@ -317,8 +297,9 @@
 class OptionalIntAnalysis
 : public DataflowAnalysis {
 public:
-  explicit OptionalIntAnalysis(ASTContext &Context)
-  : DataflowAnalysis(Context) {}
+  explicit OptionalIntAnalysis(ASTContext &Context, BoolValue &HasValueTop)
+  : DataflowAnalysis(Context),
+HasValueTop(HasValueTop) {}
 
   static NoopLattice initialElement() { return {}; }
 
@@ -353,8 +334,20 @@
 }
   }
 
+  bool compareEquivalent(QualType Type, const Value &Val1,
+ const Value &Val2) final

[PATCH] D118596: [clang][dataflow] Enable comparison of distinct values in Environment

2022-02-01 Thread Stanislav Gatev via Phabricator via cfe-commits
sgatev added inline comments.



Comment at: clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h:64
+///
+///  `Val1` must be assigned to a storage location of type `Type`.
+///

ymandel wrote:
> What does this comment mean, now that there's no environment? Could we say 
> something specific to the values themselves?
Updated the comment and added a FIXME to consider removing the type argument.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118596

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


[PATCH] D118700: Add support to --gcc-toolchain flag for GCC compiled with --enable-version-specific-runtime-libs.

2022-02-01 Thread Raúl Peñacoba via Phabricator via cfe-commits
rpenacob updated this revision to Diff 404930.

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

https://reviews.llvm.org/D118700

Files:
  clang/lib/Driver/ToolChains/Gnu.cpp
  
clang/test/Driver/Inputs/gcc_version_parsing_rt_libs/lib/gcc/x86_64-redhat-linux/10.2.0/crtbegin.o
  
clang/test/Driver/Inputs/gcc_version_parsing_rt_libs/lib/gcc/x86_64-redhat-linux/10.2.0/include/c++/.keep
  
clang/test/Driver/Inputs/gcc_version_parsing_rt_libs/lib/gcc/x86_64-redhat-linux/lib64/.keep
  
clang/test/Driver/Inputs/gcc_version_parsing_rt_libs_multilib/lib/gcc/x86_64-redhat-linux/10.2.0/32/crtbegin.o
  
clang/test/Driver/Inputs/gcc_version_parsing_rt_libs_multilib/lib/gcc/x86_64-redhat-linux/10.2.0/crtbegin.o
  
clang/test/Driver/Inputs/gcc_version_parsing_rt_libs_multilib/lib/gcc/x86_64-redhat-linux/10.2.0/include/c++/.keep
  
clang/test/Driver/Inputs/gcc_version_parsing_rt_libs_multilib/lib/gcc/x86_64-redhat-linux/lib64/.keep
  clang/test/Driver/gcc-toolchain-rt-libs-multi.cpp
  clang/test/Driver/gcc-toolchain-rt-libs.cpp


Index: clang/test/Driver/gcc-toolchain-rt-libs.cpp
===
--- /dev/null
+++ clang/test/Driver/gcc-toolchain-rt-libs.cpp
@@ -0,0 +1,9 @@
+// RUN: (%clangxx %s -v --gcc-toolchain=%S/Inputs/gcc_version_parsing_rt_libs 
--target=x86_64-redhat-linux 2>&1 || true) | FileCheck %s
+
+int main() {}
+
+// CHECK: {{[^ ]*}}clang{{[^ ]*}}" -cc1
+// CHECK-SAME: -internal-isystem {{[^ 
]*}}gcc_version_parsing_rt_libs/lib/gcc/x86_64-redhat-linux/10.2.0/../../../gcc/x86_64-redhat-linux/10.2.0/include/c++
+// CHECK: {{[^ ]*}}ld{{[^ ]*}}"
+// CHECK-SAME: -L{{[^ 
]*}}gcc_version_parsing_rt_libs/lib/gcc/x86_64-redhat-linux/10.2.0
+// CHECK-SAME: -L{{[^ 
]*}}gcc_version_parsing_rt_libs/lib/gcc/x86_64-redhat-linux/10.2.0/../lib64
Index: clang/test/Driver/gcc-toolchain-rt-libs-multi.cpp
===
--- /dev/null
+++ clang/test/Driver/gcc-toolchain-rt-libs-multi.cpp
@@ -0,0 +1,17 @@
+// RUN: (%clangxx %s -v 
--gcc-toolchain=%S/Inputs/gcc_version_parsing_rt_libs_multilib 
--target=x86_64-redhat-linux 2>&1 || true) | FileCheck %s -check-prefix=X64
+// RUN: (%clangxx %s -m32 -v 
--gcc-toolchain=%S/Inputs/gcc_version_parsing_rt_libs_multilib 
--target=x86_64-redhat-linux 2>&1 || true) | FileCheck %s -check-prefix=X32
+
+int main() {}
+
+// X64: {{[^ ]*}}clang{{[^ ]*}}" -cc1
+// X64-SAME: -internal-isystem {{[^ 
]*}}gcc_version_parsing_rt_libs_multilib/lib/gcc/x86_64-redhat-linux/10.2.0/../../../gcc/x86_64-redhat-linux/10.2.0/include/c++
+// X64: {{[^ ]*}}ld{{[^ ]*}}"
+// X64-SAME: -L{{[^ 
]*}}gcc_version_parsing_rt_libs_multilib/lib/gcc/x86_64-redhat-linux/10.2.0
+// X64-SAME: -L{{[^ 
]*}}gcc_version_parsing_rt_libs_multilib/lib/gcc/x86_64-redhat-linux/10.2.0/../lib64
+
+// X32: {{[^ ]*}}clang{{[^ ]*}}" -cc1
+// X32-SAME: -internal-isystem {{[^ 
]*}}gcc_version_parsing_rt_libs_multilib/lib/gcc/x86_64-redhat-linux/10.2.0/../../../gcc/x86_64-redhat-linux/10.2.0/include/c++
+// X32: {{[^ ]*}}ld{{[^ ]*}}"
+// X32-SAME: -L{{[^ 
]*}}gcc_version_parsing_rt_libs_multilib/lib/gcc/x86_64-redhat-linux/10.2.0/32
+// X32-SAME: -L{{[^ 
]*}}gcc_version_parsing_rt_libs_multilib/lib/gcc/x86_64-redhat-linux/10.2.0/../lib32
+
Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -2803,6 +2803,12 @@
 D, GCCInstallation.getInstallPath() + SelectedMultilib.gccSuffix(),
 Paths);
 
+// Add lib/gcc/$triple/$libdir
+// For GCC built with --enable-version-specific-runtime-libs.
+addPathIfExists(
+D, GCCInstallation.getInstallPath() + "/../" + OSLibDir,
+Paths);
+
 // GCC cross compiling toolchains will install target libraries which ship
 // as part of the toolchain under // rather than as
 // any part of the GCC installation in
@@ -2981,6 +2987,13 @@
   TripleStr, Multilib.includeSuffix(), DriverArgs, CC1Args))
 return true;
 
+  // Try /gcc/$triple/$version/include/c++/ (gcc --print-multiarch is not 
empty).
+  // Like above but for GCC built with --enable-version-specific-runtime-libs.
+  if (addLibStdCXXIncludePaths(
+  LibDir.str() + "/gcc/" + TripleStr + "/" + Version.Text + 
"/include/c++/",
+  TripleStr, Multilib.includeSuffix(), DriverArgs, CC1Args))
+return true;
+
   // Detect Debian g++-multiarch-incdir.diff.
   if (addLibStdCXXIncludePaths(LibDir.str() + "/../include/c++/" + 
Version.Text,
DebianMultiarch, Multilib.includeSuffix(),


Index: clang/test/Driver/gcc-toolchain-rt-libs.cpp
===
--- /dev/null
+++ clang/test/Driver/gcc-toolchain-rt-libs.cpp
@@ -0,0 +1,9 @@
+// RUN: (%clangxx %s -v --gcc-toolchain=%S/Inputs/gcc_version_parsing_rt_libs --target=x86_64-redhat-linux 2>&1 || true) | F

[PATCH] D117887: [NVPTX] Expose float tys min, max, abs, neg as builtins

2022-02-01 Thread Jakub Chlanda via Phabricator via cfe-commits
jchlanda added a comment.

In D117887#3262024 , @tra wrote:

> 



> If you only intended to add instructions available in PTX-7.0, which, based 
> on the constraints used in the patch, appears to be the case, I'd mention 
> that in the commit log.

Yeap, we were only going to bump up to 7.0, I don't mind adding the 
`xorsign.abs`, while I'm at it. Will update the diff shortly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D117887

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


[PATCH] D118596: [clang][dataflow] Enable comparison of distinct values in Environment

2022-02-01 Thread Stanislav Gatev via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6b8800dfb5c9: [clang][dataflow] Enable comparison of 
distinct values in Environment (authored by sgatev).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118596

Files:
  clang/include/clang/Analysis/FlowSensitive/DataflowAnalysis.h
  clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
  clang/include/clang/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.h
  clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
  clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
  clang/unittests/Analysis/FlowSensitive/TestingSupport.h
  clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp

Index: clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
@@ -19,6 +19,7 @@
 #include "clang/Analysis/FlowSensitive/DataflowLattice.h"
 #include "clang/Analysis/FlowSensitive/Value.h"
 #include "clang/Tooling/Tooling.h"
+#include "llvm/ADT/Optional.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallSet.h"
 #include "llvm/ADT/StringRef.h"
@@ -49,53 +50,35 @@
 using ::testing::UnorderedElementsAre;
 
 template 
-class AnalysisCallback : public ast_matchers::MatchFinder::MatchCallback {
-public:
-  AnalysisCallback(AnalysisT (*MakeAnalysis)(ASTContext &))
-  : MakeAnalysis(MakeAnalysis) {}
-  void run(const ast_matchers::MatchFinder::MatchResult &Result) override {
-assert(BlockStates.empty());
-
-const auto *Func = Result.Nodes.getNodeAs("func");
-assert(Func != nullptr);
-
-Stmt *Body = Func->getBody();
-assert(Body != nullptr);
-
-auto CFCtx = llvm::cantFail(
-ControlFlowContext::build(nullptr, Body, Result.Context));
-
-AnalysisT Analysis = MakeAnalysis(*Result.Context);
-DataflowAnalysisContext DACtx;
-Environment Env(DACtx);
-BlockStates = runDataflowAnalysis(CFCtx, Analysis, Env);
-  }
-
-  AnalysisT (*MakeAnalysis)(ASTContext &);
-  std::vector<
-  llvm::Optional>>
-  BlockStates;
-};
-
-template 
-std::vector>>
+llvm::Expected>>>
 runAnalysis(llvm::StringRef Code, AnalysisT (*MakeAnalysis)(ASTContext &)) {
   std::unique_ptr AST =
   tooling::buildASTFromCodeWithArgs(Code, {"-std=c++11"});
 
-  AnalysisCallback Callback(MakeAnalysis);
-  ast_matchers::MatchFinder Finder;
-  Finder.addMatcher(
-  ast_matchers::functionDecl(ast_matchers::hasName("target")).bind("func"),
-  &Callback);
-  Finder.matchAST(AST->getASTContext());
+  auto *Func = selectFirst(
+  "func", match(functionDecl(ast_matchers::hasName("target")).bind("func"),
+AST->getASTContext()));
+  assert(Func != nullptr);
+
+  Stmt *Body = Func->getBody();
+  assert(Body != nullptr);
 
-  return Callback.BlockStates;
+  auto CFCtx = llvm::cantFail(
+  ControlFlowContext::build(nullptr, Body, &AST->getASTContext()));
+
+  AnalysisT Analysis = MakeAnalysis(AST->getASTContext());
+  DataflowAnalysisContext DACtx;
+  Environment Env(DACtx);
+
+  return runDataflowAnalysis(CFCtx, Analysis, Env);
 }
 
 TEST(DataflowAnalysisTest, NoopAnalysis) {
-  auto BlockStates = runAnalysis(
-  "void target() {}", [](ASTContext &C) { return NoopAnalysis(C, false); });
+  auto BlockStates = llvm::cantFail(
+  runAnalysis("void target() {}", [](ASTContext &C) {
+return NoopAnalysis(C, false);
+  }));
   EXPECT_EQ(BlockStates.size(), 2u);
   EXPECT_TRUE(BlockStates[0].hasValue());
   EXPECT_TRUE(BlockStates[1].hasValue());
@@ -132,18 +115,15 @@
 };
 
 TEST(DataflowAnalysisTest, NonConvergingAnalysis) {
-  auto BlockStates = runAnalysis(
-  R"(
+  std::string Code = R"(
 void target() {
   while(true) {}
 }
-  )",
-  [](ASTContext &C) { return NonConvergingAnalysis(C); });
-  EXPECT_EQ(BlockStates.size(), 4u);
-  EXPECT_TRUE(BlockStates[0].hasValue());
-  EXPECT_TRUE(BlockStates[1].hasValue());
-  EXPECT_TRUE(BlockStates[2].hasValue());
-  EXPECT_TRUE(BlockStates[3].hasValue());
+  )";
+  auto Res = runAnalysis(
+  Code, [](ASTContext &C) { return NonConvergingAnalysis(C); });
+  EXPECT_EQ(llvm::toString(Res.takeError()),
+"maximum number of iterations reached");
 }
 
 struct FunctionCallLattice {
@@ -317,8 +297,9 @@
 class OptionalIntAnalysis
 : public DataflowAnalysis {
 public:
-  explicit OptionalIntAnalysis(ASTContext &Context)
-  : DataflowAnalysis(Context) {}
+  explicit OptionalIntAnalysis(ASTContext &Context, BoolValue &HasValueTop)
+  : DataflowAnalysis(Context),
+HasValueTop(HasValueTop) {}
 
   static NoopLattice initialElement() { return {}; }
 
@@ -353,8 +334,20 @@
 }
  

[clang] 6b8800d - [clang][dataflow] Enable comparison of distinct values in Environment

2022-02-01 Thread Stanislav Gatev via cfe-commits

Author: Stanislav Gatev
Date: 2022-02-01T15:25:59Z
New Revision: 6b8800dfb5c9486c7302cc2d8d2ae362ef8fdfbd

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

LOG: [clang][dataflow] Enable comparison of distinct values in Environment

Make specializations of `DataflowAnalysis` extendable with domain-specific
logic for comparing distinct values when comparing environments.

This includes a breaking change to the `runDataflowAnalysis` interface
as the return type is now `llvm::Expected<...>`.

This is part of the implementation of the dataflow analysis framework.
See "[RFC] A dataflow analysis framework for Clang AST" on cfe-dev.

Reviewed-by: ymandel, xazax.hun

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

Added: 


Modified: 
clang/include/clang/Analysis/FlowSensitive/DataflowAnalysis.h
clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
clang/include/clang/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.h
clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
clang/unittests/Analysis/FlowSensitive/TestingSupport.h
clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp

Removed: 




diff  --git a/clang/include/clang/Analysis/FlowSensitive/DataflowAnalysis.h 
b/clang/include/clang/Analysis/FlowSensitive/DataflowAnalysis.h
index f327abe63751f..b5a7c061e17bb 100644
--- a/clang/include/clang/Analysis/FlowSensitive/DataflowAnalysis.h
+++ b/clang/include/clang/Analysis/FlowSensitive/DataflowAnalysis.h
@@ -27,6 +27,7 @@
 #include "llvm/ADT/Any.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/STLExtras.h"
+#include "llvm/Support/Error.h"
 
 namespace clang {
 namespace dataflow {
@@ -106,18 +107,24 @@ template  struct DataflowAnalysisState 
{
 
 /// Performs dataflow analysis and returns a mapping from basic block IDs to
 /// dataflow analysis states that model the respective basic blocks. Indices
-/// of the returned vector correspond to basic block IDs.
+/// of the returned vector correspond to basic block IDs. Returns an error if
+/// the dataflow analysis cannot be performed successfully.
 template 
-std::vector>>
+llvm::Expected>>>
 runDataflowAnalysis(const ControlFlowContext &CFCtx, AnalysisT &Analysis,
 const Environment &InitEnv) {
   auto TypeErasedBlockStates =
   runTypeErasedDataflowAnalysis(CFCtx, Analysis, InitEnv);
+  if (!TypeErasedBlockStates)
+return TypeErasedBlockStates.takeError();
+
   std::vector<
   llvm::Optional>>
   BlockStates;
-  BlockStates.reserve(TypeErasedBlockStates.size());
-  llvm::transform(std::move(TypeErasedBlockStates),
+  BlockStates.reserve(TypeErasedBlockStates->size());
+
+  llvm::transform(std::move(*TypeErasedBlockStates),
   std::back_inserter(BlockStates), [](auto &OptState) {
 return std::move(OptState).map([](auto &&State) {
   return DataflowAnalysisState{

diff  --git a/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h 
b/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
index e560305cf5ca2..cebfb66ef242f 100644
--- a/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
+++ b/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
@@ -51,19 +51,36 @@ enum class SkipPast {
 /// Holds the state of the program (store and heap) at a given program point.
 class Environment {
 public:
-  /// Supplements `Environment` with non-standard join operations.
-  class Merger {
+  /// Supplements `Environment` with non-standard comparison and join
+  /// operations.
+  class ValueModel {
   public:
-virtual ~Merger() = default;
+virtual ~ValueModel() = default;
 
-/// Given distinct `Val1` and `Val2`, modifies `MergedVal` to approximate
-/// both `Val1` and `Val2`. This could be a strict lattice join or a more
-/// general widening operation. If this function returns true, `MergedVal`
-/// will be assigned to a storage location of type `Type` in `Env`.
+/// Returns true if and only if `Val1` is equivalent to `Val2`.
 ///
 /// Requirements:
 ///
 ///  `Val1` and `Val2` must be distinct.
+///
+///  `Val1` and `Val2` must model values of type `Type`.
+virtual bool compareEquivalent(QualType Type, const Value &Val1,
+   const Value &Val2) {
+  // FIXME: Consider adding QualType to StructValue and removing the Type
+  // argument here.
+  return false;
+}
+
+/// Modifies `MergedVal` to approximate both `Val1` and `Val2`. This could
+/// be a strict lattice join or a more general widening operation. If this
+/// function returns true, `MergedVal` will be assigne

[PATCH] D117888: [clang][driver][wasm] Support -stdlib=libstdc++ for WebAssembly

2022-02-01 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder updated this revision to Diff 404935.
tbaeder marked an inline comment as done.
tbaeder added a comment.

Stop hardcoding `v1` or `11` and make the tests work like that.


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

https://reviews.llvm.org/D117888

Files:
  clang/lib/Driver/ToolChains/WebAssembly.cpp
  clang/lib/Driver/ToolChains/WebAssembly.h
  clang/test/Driver/wasm-toolchain.cpp

Index: clang/test/Driver/wasm-toolchain.cpp
===
--- clang/test/Driver/wasm-toolchain.cpp
+++ clang/test/Driver/wasm-toolchain.cpp
@@ -19,6 +19,11 @@
 // LINK: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
 // LINK: wasm-ld{{.*}}" "-L/foo/lib" "crt1.o" "[[temp]]" "-lc++" "-lc++abi" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
 
+// RUN: %clangxx -### -no-canonical-prefixes -target wasm32-unknown-unknown --sysroot=/foo --stdlib=libstdc++ %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=LINK_STDCXX %s
+// LINK_STDCXX: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
+// LINK_STDCXX: wasm-ld{{.*}}" "-L/foo/lib" "crt1.o" "[[temp]]" "-lstdc++" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
+
 // A basic C++ link command-line with optimization with unknown OS.
 
 // RUN: %clangxx -### -O2 -no-canonical-prefixes -target wasm32-unknown-unknown --sysroot=/foo %s --stdlib=libc++ 2>&1 \
@@ -26,6 +31,11 @@
 // LINK_OPT: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
 // LINK_OPT: wasm-ld{{.*}}" "-L/foo/lib" "crt1.o" "[[temp]]" "-lc++" "-lc++abi" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
 
+// RUN: %clangxx -### -O2 -no-canonical-prefixes -target wasm32-unknown-unknown --sysroot=/foo %s --stdlib=libstdc++ 2>&1 \
+// RUN:   | FileCheck -check-prefix=LINK_OPT_STDCXX %s
+// LINK_OPT_STDCXX: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
+// LINK_OPT_STDCXX: wasm-ld{{.*}}" "-L/foo/lib" "crt1.o" "[[temp]]" "-lstdc++" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
+
 // A basic C++ link command-line with known OS.
 
 // RUN: %clangxx -### -no-canonical-prefixes -target wasm32-wasi --sysroot=/foo --stdlib=libc++ %s 2>&1 \
@@ -33,6 +43,11 @@
 // LINK_KNOWN: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
 // LINK_KNOWN: wasm-ld{{.*}}" "-L/foo/lib/wasm32-wasi" "crt1.o" "[[temp]]" "-lc++" "-lc++abi" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
 
+// RUN: %clangxx -### -no-canonical-prefixes -target wasm32-wasi --sysroot=/foo --stdlib=libstdc++ %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=LINK_KNOWN_STDCXX %s
+// LINK_KNOWN_STDCXX: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
+// LINK_KNOWN_STDCXX: wasm-ld{{.*}}" "-L/foo/lib/wasm32-wasi" "crt1.o" "[[temp]]" "-lstdc++" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
+
 // A basic C++ link command-line with optimization with known OS.
 
 // RUN: %clangxx -### -O2 -no-canonical-prefixes -target wasm32-wasi --sysroot=/foo %s --stdlib=libc++ 2>&1 \
@@ -40,15 +55,33 @@
 // LINK_OPT_KNOWN: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
 // LINK_OPT_KNOWN: wasm-ld{{.*}}" "-L/foo/lib/wasm32-wasi" "crt1.o" "[[temp]]" "-lc++" "-lc++abi" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
 
+// RUN: %clangxx -### -O2 -no-canonical-prefixes -target wasm32-wasi --sysroot=/foo %s --stdlib=libstdc++ 2>&1 \
+// RUN:   | FileCheck -check-prefix=LINK_OPT_KNOWN_STDCXX %s
+// LINK_OPT_KNOWN_STDCXX: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
+// LINK_OPT_KNOWN_STDCXX: wasm-ld{{.*}}" "-L/foo/lib/wasm32-wasi" "crt1.o" "[[temp]]" "-lstdc++" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
+
 // A basic C++ compile command-line with known OS.
 
-// RUN: %clangxx -### -no-canonical-prefixes -target wasm32-wasi --sysroot=/foo --stdlib=libc++ %s 2>&1 \
+// RUN: %clangxx -### -no-canonical-prefixes -target wasm32-wasi --stdlib=libc++ %s 2>&1 \
+// RUN: --sysroot=%S/Inputs/basic_linux_libcxx_tree/usr \
 // RUN:   | FileCheck -check-prefix=COMPILE %s
 // COMPILE: clang{{.*}}" "-cc1"
 // COMPILE: "-resource-dir" "[[RESOURCE_DIR:[^"]*]]"
-// COMPILE: "-isysroot" "/foo"
-// COMPILE: "-internal-isystem" "/foo/include/wasm32-wasi/c++/v1"
-// COMPILE: "-internal-isystem" "/foo/include/c++/v1"
+// COMPILE: "-isysroot" "[[SYSROOT:[^"]+]]"
+// COMPILE: "-internal-isystem" "[[SYSROOT:[^"]+]]/include/wasm32-wasi/c++/v1"
+// COMPILE: "-internal-isystem" "[[SYSROOT:[^"]+]]/include/c++/v1"
 // COMPILE: "-internal-isystem" "[[RESOURCE_DIR]]{{(/|)}}include"
-// COMPILE: "-internal-isystem" "/foo/include/wasm32-wasi"
-// COMPILE: "-internal-isystem" "/foo/include"
+// COMPILE: "-internal-isystem" "[[SYSROOT:[^"]+]]/include/wasm32-wasi"
+// COMPILE: "-internal-isystem" "[[SYSROOT:[^"]+]]/include"
+
+// RUN: %clangxx -### -no-canonical-prefixes -target wasm32-wasi --stdlib=libstdc++ %s 2>&1 \
+// RUN: --sysroot=%S/Inputs/basic_linux_libstdcxx_libcxxv2_tree/usr \
+// RUN:   | FileCheck -check-prefix=COMPILE_S

[PATCH] D117888: [clang][driver][wasm] Support -stdlib=libstdc++ for WebAssembly

2022-02-01 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder marked 4 inline comments as done.
tbaeder added inline comments.



Comment at: clang/lib/Driver/ToolChains/WebAssembly.cpp:544
+
+  if (Version.empty()) {
+// FIXME: Fallback correct?

sbc100 wrote:
> tbaeder wrote:
> > sbc100 wrote:
> > > Just early return here if no headers can be found?  Looking at Gnu.cpp it 
> > > seems that `addLibStdCxxIncludePaths` can simply to nothing if no GCC 
> > > install is found.
> > I saw that, but I'm not sure if this is correct for wasm. The tests 
> > certainly break because they check for the `/v1/` (and not `/11/`) include 
> > paths but also use `-sysroot=/foo`, so the new code doesn't add any flags. 
> > Is there a good way to update the tests so they stay functional and useful?
> I would take a look at how other platforms test this... perhaps they setup 
> some kind of fake header tree?  Or perhaps they don't test these paths at 
> all.   For sure they don't depend on the actual system where the tests run, 
> right?
> 
> Can you point me to the tests that fail if you simply return empty string 
> like on other platforms?
The test using `/foo` as sysroot was just 
`clang/test/Driver/wasm-toolchain.cpp`.

The driver tests are shipping a file hierarchy to be used for this, so I 
switched the tests to use that as well. 


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

https://reviews.llvm.org/D117888

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


[PATCH] D116541: [OpenMP] Introduce new flag to change offloading driver pipeline

2022-02-01 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Tests are passing again.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116541

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


[PATCH] D91607: [clang][Sparc] Fix __builtin_extract_return_addr etc.

2022-02-01 Thread Rainer Orth via Phabricator via cfe-commits
ro added a comment.

In D91607#3285825 , @efriedma wrote:

> In D91607#3283350 , @ro wrote:
>
>> In D91607#3280808 , @efriedma wrote:
>>
>>> Testcase?
>>
>> I thought the 3 testcases adjusted in D91608 
>>  to use `__builtin_extract_return_addr` and 
>> fixed by this patch were enough.  Otherwise, should I just augment 
>> `clang/test/CodeGen/builtins-sparc.c` or better create a new test?
>
> I'd prefer to have coverage in the clang regression tests, so developers can 
> catch regressions and easily check the expected codegen.  builtins-sparc.c is 
> fine.

Understood: this way you don't rely on native builds and can test SPARC V8 
structure return which isn't exercised by the sanitzer tests.

>>> Do you need to ptrtoint/inttoptr?  I would expect that the address is an 
>>> `i8*`, so you can just GEP an appropriate number of bytes.
>>
>> TBH, I know practically nothing about LLVM codegen, so I rely heavily on 
>> guidance.  IIRC this patch was developed by searching for similar code in 
>> `TargetInfo.cpp` and modifying it until it did what I needed.  Is this the 
>> place to read on GEP ?
>
> That's a good starting place for understanding the complexity of GEP... but 
> you don't need that much here. Here, we just want to pass a single index; 
> that's equivalent to pointer addition in C.
>
> You should be able to just drop the calls to CreatePtrToInt and 
> CreateIntToPtr, and replace CreateAdd with CreateGEP.

Cool: I'd been struggling with `CreateConstInBoundsByteGEP` which seemed what I 
need, but had me fighting with conversion between `llvm::Value *` and `Address`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91607

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


[PATCH] D91607: [clang][Sparc] Fix __builtin_extract_return_addr etc.

2022-02-01 Thread Rainer Orth via Phabricator via cfe-commits
ro updated this revision to Diff 404939.
ro added a comment.
Herald added a subscriber: jrtc27.

- Use `CreateGEP`
- Add testcase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91607

Files:
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGen/builtins-sparc.c


Index: clang/test/CodeGen/builtins-sparc.c
===
--- clang/test/CodeGen/builtins-sparc.c
+++ clang/test/CodeGen/builtins-sparc.c
@@ -1,10 +1,29 @@
 // REQUIRES: sparc-registered-target
 // RUN: %clang_cc1 -triple sparc-unknown-unknown -emit-llvm %s -o - | 
FileCheck %s
-// RUN: %clang_cc1 -triple sparc64-unknown-unknown -emit-llvm %s -o - | 
FileCheck %s
+// RUN: %clang_cc1 -triple sparc64-unknown-unknown -emit-llvm %s -o - | 
FileCheck -check-prefix CHECK-V9 %s
 
 void test_eh_return_data_regno(void)
 {
   volatile int res;
-  res = __builtin_eh_return_data_regno(0);  // CHECK: store volatile i32 24
-  res = __builtin_eh_return_data_regno(1);  // CHECK: store volatile i32 25
+  res = __builtin_eh_return_data_regno(0);  // CHECK,CHECKV9: store volatile 
i32 24
+  res = __builtin_eh_return_data_regno(1);  // CHECK,CHECKV9: store volatile 
i32 25
+}
+
+void *test_extract_return_address(void)
+{
+  // CHECK,CHECKV9: getelementptr i8, i8* %0, i32 8
+  return __builtin_extract_return_addr(__builtin_return_address(0));
 }
+
+struct s {
+  void *p;
+};
+
+struct s test_extract_struct_return_address(void)
+{
+  struct s s;
+  // CHECK:getelementptr i8, i8* %0, i32 12
+  // CHECK-V9: getelementptr i8, i8* %0, i32 8
+  s.p = __builtin_extract_return_addr(__builtin_return_address(0));
+  return s;
+}
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -9472,6 +9472,28 @@
 public:
   SparcV8TargetCodeGenInfo(CodeGenTypes &CGT)
   : TargetCodeGenInfo(std::make_unique(CGT)) {}
+
+  llvm::Value *decodeReturnAddress(CodeGen::CodeGenFunction &CGF,
+   llvm::Value *Address) const override {
+int Offset;
+if (isAggregateTypeForABI(CGF.CurFnInfo->getReturnType()))
+  Offset = 12;
+else
+  Offset = 8;
+return CGF.Builder.CreateGEP(CGF.Int8Ty, Address,
+ llvm::ConstantInt::get(CGF.Int32Ty, Offset));
+  }
+
+  llvm::Value *encodeReturnAddress(CodeGen::CodeGenFunction &CGF,
+   llvm::Value *Address) const override {
+int Offset;
+if (isAggregateTypeForABI(CGF.CurFnInfo->getReturnType()))
+  Offset = -12;
+else
+  Offset = -8;
+return CGF.Builder.CreateGEP(CGF.Int8Ty, Address,
+ llvm::ConstantInt::get(CGF.Int32Ty, Offset));
+  }
 };
 } // end anonymous namespace
 
@@ -9746,6 +9768,18 @@
 
   bool initDwarfEHRegSizeTable(CodeGen::CodeGenFunction &CGF,
llvm::Value *Address) const override;
+
+  llvm::Value *decodeReturnAddress(CodeGen::CodeGenFunction &CGF,
+   llvm::Value *Address) const override {
+return CGF.Builder.CreateGEP(CGF.Int8Ty, Address,
+ llvm::ConstantInt::get(CGF.Int32Ty, 8));
+  }
+
+  llvm::Value *encodeReturnAddress(CodeGen::CodeGenFunction &CGF,
+   llvm::Value *Address) const override {
+return CGF.Builder.CreateGEP(CGF.Int8Ty, Address,
+ llvm::ConstantInt::get(CGF.Int32Ty, -8));
+  }
 };
 } // end anonymous namespace
 


Index: clang/test/CodeGen/builtins-sparc.c
===
--- clang/test/CodeGen/builtins-sparc.c
+++ clang/test/CodeGen/builtins-sparc.c
@@ -1,10 +1,29 @@
 // REQUIRES: sparc-registered-target
 // RUN: %clang_cc1 -triple sparc-unknown-unknown -emit-llvm %s -o - | FileCheck %s
-// RUN: %clang_cc1 -triple sparc64-unknown-unknown -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -triple sparc64-unknown-unknown -emit-llvm %s -o - | FileCheck -check-prefix CHECK-V9 %s
 
 void test_eh_return_data_regno(void)
 {
   volatile int res;
-  res = __builtin_eh_return_data_regno(0);  // CHECK: store volatile i32 24
-  res = __builtin_eh_return_data_regno(1);  // CHECK: store volatile i32 25
+  res = __builtin_eh_return_data_regno(0);  // CHECK,CHECKV9: store volatile i32 24
+  res = __builtin_eh_return_data_regno(1);  // CHECK,CHECKV9: store volatile i32 25
+}
+
+void *test_extract_return_address(void)
+{
+  // CHECK,CHECKV9: getelementptr i8, i8* %0, i32 8
+  return __builtin_extract_return_addr(__builtin_return_address(0));
 }
+
+struct s {
+  void *p;
+};
+
+struct s test_extract_struct_return_address(void)
+{
+  struct s s;
+  // CHECK:getelementptr i8, i8* %0, i32 12
+  // CHECK-V9: getelementptr i8, i8* %0, i32 8
+  s.p = __builtin_extract_return_addr(__builtin

[PATCH] D118050: [analyzer] Different address spaces cannot overlap

2022-02-01 Thread Vince Bridgers via Phabricator via cfe-commits
vabridgers updated this revision to Diff 404940.
vabridgers added a comment.

Simplify assertion per comments.
Add a "temp" fix in SValBuilder that permits the additional
test cases to pass without crash


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118050

Files:
  clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
  clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
  clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
  clang/test/Analysis/cstring-addrspace.c

Index: clang/test/Analysis/cstring-addrspace.c
===
--- /dev/null
+++ clang/test/Analysis/cstring-addrspace.c
@@ -0,0 +1,64 @@
+// RUN: %clang_analyze_cc1 -triple amdgcn-unknown-unknown \
+// RUN: -analyze -analyzer-checker=core,alpha.unix.cstring \
+// RUN: -analyze -analyzer-checker=debug.ExprInspection \
+// RUN: -analyzer-config crosscheck-with-z3=true -verify %s \
+// RUN: -Wno-incompatible-library-redeclaration
+// REQUIRES: z3
+
+void clang_analyzer_warnIfReached();
+
+// From https://llvm.org/docs/AMDGPUUsage.html#address-spaces,
+// select address space 3 (local), since the pointer size is
+// different than Generic.
+#define DEVICE __attribute__((address_space(3)))
+_Static_assert(sizeof(int *) == 8, "");
+_Static_assert(sizeof(DEVICE int *) == 4, "");
+_Static_assert(sizeof(void *) == 8, "");
+_Static_assert(sizeof(DEVICE void *) == 4, "");
+
+// Copy from host to device memory. Note this is specialized
+// since one of the parameters is assigned an address space such
+// that the sizeof the the pointer is different than the other.
+//
+// Some downstream implementations may have specialized memcpy
+// routines that copy from one address space to another. In cases
+// like that, the address spaces are assumed to not overlap, so the
+// cstring overlap check is not needed. When a static analysis report
+// is generated in as case like this, SMTConv may attempt to create
+// a refutation to Z3 with different bitwidth pointers which lead to
+// a crash. This is not common in directly used upstream compiler builds,
+// but can be seen in specialized downstrean implementations. This case
+// covers those specific instances found and debugged.
+//
+// Since memcpy is a builtin, a specialized builtin instance named like
+// 'memcpy_special' will hit in cstring, triggering this behavior. The
+// best we can do for an upstream test is use the same memcpy function name.
+DEVICE void *memcpy(DEVICE void *dst, const void *src, unsigned long len);
+
+void top1(DEVICE void *dst, void *src, int len) {
+  memcpy(dst, src, len);
+
+  // Create a bugreport for triggering Z3 refutation.
+  clang_analyzer_warnIfReached(); // expected-warning {{REACHABLE}}
+}
+
+void top2(DEVICE int *dst, void *src, int len) {
+  memcpy(dst, src, len);
+
+  // Create a bugreport for triggering Z3 refutation.
+  clang_analyzer_warnIfReached(); // expected-warning {{REACHABLE}}
+}
+
+void top3(DEVICE int *dst, int *src, int len) {
+  memcpy(dst, src, len);
+
+  // Create a bugreport for triggering Z3 refutation.
+  clang_analyzer_warnIfReached(); // expected-warning {{REACHABLE}}
+}
+
+void top4() {
+  memcpy((DEVICE void *)1, (const void *)1, 1);
+
+  // Create a bugreport for triggering Z3 refutation.
+  clang_analyzer_warnIfReached(); // expected-warning {{REACHABLE}}
+}
Index: clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
===
--- clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
+++ clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
@@ -715,11 +715,34 @@
   llvm_unreachable("Fields not found in parent record's definition");
 }
 
+static bool assertEqualBitWidths(ProgramStateRef State, Loc RhsLoc,
+ Loc LhsLoc) {
+  // Implements a "best effort" check for RhsLoc and LhsLoc bit widths
+  ASTContext &Ctx = State->getStateManager().getContext();
+  uint64_t RhsBitwidth =
+  RhsLoc.getType(Ctx).isNull() ? 0 : Ctx.getTypeSize(RhsLoc.getType(Ctx));
+  uint64_t LhsBitwidth =
+  LhsLoc.getType(Ctx).isNull() ? 0 : Ctx.getTypeSize(LhsLoc.getType(Ctx));
+  if (RhsBitwidth && LhsBitwidth) {
+assert(RhsBitwidth == LhsBitwidth &&
+   "RhsLoc and LhsLoc bitwidth must be same!");
+return RhsBitwidth == LhsBitwidth;
+  }
+  return false;
+}
+
 // FIXME: all this logic will change if/when we have MemRegion::getLocation().
 SVal SimpleSValBuilder::evalBinOpLL(ProgramStateRef state,
   BinaryOperator::Opcode op,
   Loc lhs, Loc rhs,
   QualType resultTy) {
+
+  // Assert that bitwidth of lhs and rhs are the same.
+  // This can happen if two different address spaces are used,
+  // and the bitwidths of the address spaces are different.
+  // See LIT case clang/test/Analysis/cstring-checker-addressspace.c
+  assertEqualBitWidth

[PATCH] D118050: [analyzer] Different address spaces cannot overlap

2022-02-01 Thread Vince Bridgers via Phabricator via cfe-commits
vabridgers added a comment.

I think @steakhal will have a more comprehensive change to back out the 
makeNull() calls to makeNullWithWidth() calls. I'll back out the change to 
SValBuilder.cpp once that change is pushed. For now, this is my update. Thanks


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118050

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


[PATCH] D118050: [analyzer] Different address spaces cannot overlap

2022-02-01 Thread Vince Bridgers via Phabricator via cfe-commits
vabridgers marked 7 inline comments as done.
vabridgers added a comment.

I think the comments have been addressed for now. Please let me know if I 
missed something, or anything else needs to be done (besides back out the 
change to SValBuilder.cpp when ready). Thanks for the comments. Best


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118050

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


[PATCH] D117972: [PowerPC] Fix SSE translation on FreeBSD

2022-02-01 Thread Piotr Kubaj via Phabricator via cfe-commits
pkubaj added a comment.

Since I'm not a LLVM committer, can you commit it and merge to 14 branch?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D117972

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


[PATCH] D118605: [OpenCL] Add support of language builtins for OpenCL C 3.0

2022-02-01 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: clang/include/clang/Basic/Builtins.def:88
 //   '__builtin_' prefix. It will be implemented in compiler-rt or libgcc.
+//  G -> this function uses generic address space (OpenCL).
+//  P -> this function uses pipes (OpenCL).

azabaznov wrote:
> Anastasia wrote:
> > Anastasia wrote:
> > > It might be better to avoid adding such limited language-specific 
> > > functionality into generic representation of Builtins. Do you think could 
> > > we could just introduce specific language modes, say:
> > > 
> > > `OCLC_PIPES`
> > > `OCLC_DSE`
> > > `OCLC_GAS`
> > > 
> > > and then check against those in `builtinIsSupported`?
> > Btw another approach could be to do something similar to `TARGET_BUILTIN` 
> > i.e. list features in the last parameter as strings. We could add a 
> > separate macro for such builtins and just reuse target Builtins flow. This 
> > might be a bit more scalable in case we would need to add more of such 
> > builtins later on?
> > 
> > It might be better to avoid adding such limited language-specific 
> > functionality into generic representation of Builtins.
> 
> Nice idea! Though I think LanguageID is not designed to be used this way, 
> it's used only to check against specific language version. So it seems pretty 
> invasive. Also, function attributes seem more natural to me to specify the 
> type of the function. I don't know for sure which way is better...
> 
> > Btw another approach could be to do something similar to TARGET_BUILTIN 
> > i.e. list features in the last parameter as strings.
> 
> I'd prefer to not use TARGET_BUILTIN as it operates on target feature, but 
> OpenCL feature is some other concept in clang...
Buitlins handling is pretty vital for clang so if we extend common 
functionality for just a few built-in functions it might not justify the 
overhead in terms of complexity, parsing time or space... so we would need to 
dive in those aspects more before finalizing the design... if we can avoid it 
we should try... and I feel in this case there might be some good ways to avoid 
it.

> Nice idea! Though I think LanguageID is not designed to be used this way, 
> it's used only to check against specific language version. So it seems pretty 
> invasive. Also, function attributes seem more natural to me to specify the 
> type of the function. I don't know for sure which way is better...

I think this `LanguageID` is only used for the purposes of Builtins, so there 
should be no issue in evolving it differently. With the documentation and  
adequate naming we can resolve the confusions in any.

The whole idea of language options in clang is that it is not dependent on the 
target. But we have violated this design already. The whole concept of OpenCL 
3.0 language features that are target-specific is misaligned with the original 
design in clang.

> 
> Btw another approach could be to do something similar to TARGET_BUILTIN 
> i.e. list features in the last parameter as strings.
> 
> I'd prefer to not use TARGET_BUILTIN as it operates on target feature, but 
> OpenCL feature is some other concept in clang...

But we also have target features mirroring these, right? So I see no reason not 
to reuse what we already have... instead of adding another way to do the same 
or very similar thing...

We could also consider extending the functionality slightly to use language 
features instead however I can't see the immediate benefit at this point... 
other than it might be useful in the future... but we can't know for sure.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118605

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


[PATCH] D118706: [clang-format] Correctly parse C99 digraphs: "<:", ":>", "<%", "%>", "%:", "%:%:".

2022-02-01 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius created this revision.
curdeius added reviewers: MyDeveloperDay, HazardyKnusperkeks, owenpan.
curdeius requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Fixes https://github.com/llvm/llvm-project/issues/31592.

This commits enables lexing of digraphs in C++11 and onwards.
Enabling them in C++03 is error-prone, as it would inconditionnally treat 
sequences like "<:" as digraphs, even if they are followed by a single colon, 
e.g. "<::" would be treated as "[:" instead of "<" followed by "::". Lexing in 
C++11 doesn't have this problem as it looks ahead the following token.
The relevant excerpt from Lexer::LexTokenInternal:

  // C++0x [lex.pptoken]p3:
  //  Otherwise, if the next three characters are <:: and the subsequent
  //  character is neither : nor >, the < is treated as a preprocessor
  //  token by itself and not as the first character of the alternative
  //  token <:.

Also, note that both clang and gcc turn on digraphs by default (-fdigraphs), so 
clang-format should match this behaviour.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D118706

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


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -24219,6 +24219,16 @@
Style);
 }
 
+TEST_F(FormatTest, UnderstandsDigraphs) {
+  verifyFormat("int arr<:5:> = {};");
+  verifyFormat("int arr[5] = <%%>;");
+  verifyFormat("int arr<:::qualified_variable:> = {};");
+  verifyFormat("int arr[::qualified_variable] = <%%>;");
+  verifyFormat("%:include ");
+  verifyFormat("%:define A x##y");
+  verifyFormat("#define A x%:%:y");
+}
+
 } // namespace
 } // namespace format
 } // namespace clang
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -3242,6 +3242,10 @@
   LangOpts.CPlusPlus17 = LexingStd >= FormatStyle::LS_Cpp17;
   LangOpts.CPlusPlus20 = LexingStd >= FormatStyle::LS_Cpp20;
   LangOpts.Char8 = LexingStd >= FormatStyle::LS_Cpp20;
+  // Turning on digraphs in standards before C++0x is error-prone, because e.g.
+  // the sequence "<::" will be inconditionally treated as "[:".
+  // Cf. Lexer::LexTokenInternal.
+  LangOpts.Digraphs = LexingStd >= FormatStyle::LS_Cpp11;
 
   LangOpts.LineComment = 1;
   bool AlternativeOperators = Style.isCpp();


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -24219,6 +24219,16 @@
Style);
 }
 
+TEST_F(FormatTest, UnderstandsDigraphs) {
+  verifyFormat("int arr<:5:> = {};");
+  verifyFormat("int arr[5] = <%%>;");
+  verifyFormat("int arr<:::qualified_variable:> = {};");
+  verifyFormat("int arr[::qualified_variable] = <%%>;");
+  verifyFormat("%:include ");
+  verifyFormat("%:define A x##y");
+  verifyFormat("#define A x%:%:y");
+}
+
 } // namespace
 } // namespace format
 } // namespace clang
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -3242,6 +3242,10 @@
   LangOpts.CPlusPlus17 = LexingStd >= FormatStyle::LS_Cpp17;
   LangOpts.CPlusPlus20 = LexingStd >= FormatStyle::LS_Cpp20;
   LangOpts.Char8 = LexingStd >= FormatStyle::LS_Cpp20;
+  // Turning on digraphs in standards before C++0x is error-prone, because e.g.
+  // the sequence "<::" will be inconditionally treated as "[:".
+  // Cf. Lexer::LexTokenInternal.
+  LangOpts.Digraphs = LexingStd >= FormatStyle::LS_Cpp11;
 
   LangOpts.LineComment = 1;
   bool AlternativeOperators = Style.isCpp();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D118670: [NFC][AIX]Disable failed tests due to aggressive byval alignment warning on AIX

2022-02-01 Thread Steven Wan via Phabricator via cfe-commits
stevewan updated this revision to Diff 404947.
stevewan added a comment.

Use "-Wno-aix-compat" so that we don't lose coverage on AIX


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118670

Files:
  clang/test/Analysis/padding_c.c
  clang/test/Analysis/padding_cpp.cpp
  clang/test/CXX/drs/dr6xx.cpp
  clang/test/SemaTemplate/instantiate-attr.cpp


Index: clang/test/SemaTemplate/instantiate-attr.cpp
===
--- clang/test/SemaTemplate/instantiate-attr.cpp
+++ clang/test/SemaTemplate/instantiate-attr.cpp
@@ -1,4 +1,7 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// FIXME -Wno-aix-compat added temporarily while the diagnostic is being
+// refined.
+
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-aix-compat %s
 // expected-no-diagnostics
 template 
 struct A {
Index: clang/test/CXX/drs/dr6xx.cpp
===
--- clang/test/CXX/drs/dr6xx.cpp
+++ clang/test/CXX/drs/dr6xx.cpp
@@ -1,8 +1,10 @@
 // RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors -fno-spell-checking
-// RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors -fno-spell-checking
-// RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors -fno-spell-checking
-// RUN: %clang_cc1 -std=c++17 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors -fno-spell-checking
-// RUN: %clang_cc1 -std=c++20 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors -fno-spell-checking
+// FIXME -Wno-aix-compat added temporarily while the diagnostic is being
+// refined.
+// RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors -fno-spell-checking -Wno-aix-compat
+// RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors -fno-spell-checking -Wno-aix-compat
+// RUN: %clang_cc1 -std=c++17 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors -fno-spell-checking -Wno-aix-compat
+// RUN: %clang_cc1 -std=c++20 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors -fno-spell-checking -Wno-aix-compat
 
 namespace std {
   struct type_info {};
Index: clang/test/Analysis/padding_cpp.cpp
===
--- clang/test/Analysis/padding_cpp.cpp
+++ clang/test/Analysis/padding_cpp.cpp
@@ -1,4 +1,6 @@
-// RUN: %clang_analyze_cc1 -std=c++14 -analyzer-checker=optin.performance 
-analyzer-config optin.performance.Padding:AllowedPad=2 -verify %s
+// FIXME -Wno-aix-compat added temporarily while the diagnostic is being
+// refined.
+// RUN: %clang_analyze_cc1 -std=c++14 -analyzer-checker=optin.performance 
-analyzer-config optin.performance.Padding:AllowedPad=2 -verify -Wno-aix-compat 
%s
 
 // Make sure that the C cases still work fine, even when compiled as C++.
 #include "padding_c.c"
Index: clang/test/Analysis/padding_c.c
===
--- clang/test/Analysis/padding_c.c
+++ clang/test/Analysis/padding_c.c
@@ -1,4 +1,6 @@
-// RUN: %clang_analyze_cc1 -verify %s \
+// FIXME -Wno-aix-compat added temporarily while the diagnostic is being
+// refined.
+// RUN: %clang_analyze_cc1 -verify -Wno-aix-compat %s \
 // RUN:   -analyzer-checker=optin.performance \
 // RUN:   -analyzer-config optin.performance.Padding:AllowedPad=2
 


Index: clang/test/SemaTemplate/instantiate-attr.cpp
===
--- clang/test/SemaTemplate/instantiate-attr.cpp
+++ clang/test/SemaTemplate/instantiate-attr.cpp
@@ -1,4 +1,7 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// FIXME -Wno-aix-compat added temporarily while the diagnostic is being
+// refined.
+
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-aix-compat %s
 // expected-no-diagnostics
 template 
 struct A {
Index: clang/test/CXX/drs/dr6xx.cpp
===
--- clang/test/CXX/drs/dr6xx.cpp
+++ clang/test/CXX/drs/dr6xx.cpp
@@ -1,8 +1,10 @@
 // RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking
-// RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking
-// RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking
-// RUN: %clang_cc1 -std=c++17 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking
-// RUN: %clang_cc1 -std=c++20 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking
+// FIXME -Wno-aix-compat added temporarily while the diagnostic is being
+// refined.
+// RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking -Wno-aix-compat
+// RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -f

[PATCH] D118199: [AArch64] ACLE feature macro for Armv8.8-A MOPS

2022-02-01 Thread Momchil Velikov via Phabricator via cfe-commits
chill added inline comments.



Comment at: clang/lib/Basic/Targets/AArch64.cpp:229
 MacroBuilder &Builder) const {
+  // FIXME: this does not handle the case where MOPS is disabled using +nomops
+  Builder.defineMacro("__ARM_FEATURE_MOPS", "1");

What's the deal with `"+nomops"` ? This FIXME sort of contradicts with an 
earlier comment


> Add support for +nomops




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118199

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


[PATCH] D118670: [NFC][AIX]Disable failed tests due to aggressive byval alignment warning on AIX

2022-02-01 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added inline comments.



Comment at: clang/test/Analysis/padding_c.c:7
 
 // RUN: not %clang_analyze_cc1 -verify %s \
 // RUN:   -analyzer-checker=core \

Even if it works as-is, might be good to add `-Wno-aix-compat` here too since 
`-verify` is being used.



Comment at: clang/test/CXX/drs/dr6xx.cpp:1
 // RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors -fno-spell-checking
+// FIXME -Wno-aix-compat added temporarily while the diagnostic is being

Same comment (although the part that is affected is guarded for the newer 
language levels).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118670

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


[PATCH] D118199: [AArch64] ACLE feature macro for Armv8.8-A MOPS

2022-02-01 Thread Momchil Velikov via Phabricator via cfe-commits
chill added a comment.

I suppose `clang/test/CodeGen/aarch64-mops.c` needs to be run with `clang 
-march=armv8-a+mops+memtag` (not `clang_cc1`) so it picks up declarations of 
tagging intrinsics from `arm_acle.h`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118199

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


[PATCH] D118670: [NFC][AIX]Disable failed tests due to aggressive byval alignment warning on AIX

2022-02-01 Thread Steven Wan via Phabricator via cfe-commits
stevewan updated this revision to Diff 404951.
stevewan added a comment.

Add the flag to all


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118670

Files:
  clang/test/Analysis/padding_c.c
  clang/test/Analysis/padding_cpp.cpp
  clang/test/CXX/drs/dr6xx.cpp
  clang/test/SemaTemplate/instantiate-attr.cpp


Index: clang/test/SemaTemplate/instantiate-attr.cpp
===
--- clang/test/SemaTemplate/instantiate-attr.cpp
+++ clang/test/SemaTemplate/instantiate-attr.cpp
@@ -1,4 +1,7 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// FIXME -Wno-aix-compat added temporarily while the diagnostic is being
+// refined.
+
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-aix-compat %s
 // expected-no-diagnostics
 template 
 struct A {
Index: clang/test/CXX/drs/dr6xx.cpp
===
--- clang/test/CXX/drs/dr6xx.cpp
+++ clang/test/CXX/drs/dr6xx.cpp
@@ -1,8 +1,10 @@
-// RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors -fno-spell-checking
-// RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors -fno-spell-checking
-// RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors -fno-spell-checking
-// RUN: %clang_cc1 -std=c++17 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors -fno-spell-checking
-// RUN: %clang_cc1 -std=c++20 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors -fno-spell-checking
+// FIXME -Wno-aix-compat added temporarily while the diagnostic is being
+// refined.
+// RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors -fno-spell-checking -Wno-aix-compat
+// RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors -fno-spell-checking -Wno-aix-compat
+// RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors -fno-spell-checking -Wno-aix-compat
+// RUN: %clang_cc1 -std=c++17 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors -fno-spell-checking -Wno-aix-compat
+// RUN: %clang_cc1 -std=c++20 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors -fno-spell-checking -Wno-aix-compat
 
 namespace std {
   struct type_info {};
Index: clang/test/Analysis/padding_cpp.cpp
===
--- clang/test/Analysis/padding_cpp.cpp
+++ clang/test/Analysis/padding_cpp.cpp
@@ -1,4 +1,6 @@
-// RUN: %clang_analyze_cc1 -std=c++14 -analyzer-checker=optin.performance 
-analyzer-config optin.performance.Padding:AllowedPad=2 -verify %s
+// FIXME -Wno-aix-compat added temporarily while the diagnostic is being
+// refined.
+// RUN: %clang_analyze_cc1 -std=c++14 -analyzer-checker=optin.performance 
-analyzer-config optin.performance.Padding:AllowedPad=2 -verify -Wno-aix-compat 
%s
 
 // Make sure that the C cases still work fine, even when compiled as C++.
 #include "padding_c.c"
Index: clang/test/Analysis/padding_c.c
===
--- clang/test/Analysis/padding_c.c
+++ clang/test/Analysis/padding_c.c
@@ -1,8 +1,10 @@
-// RUN: %clang_analyze_cc1 -verify %s \
+// FIXME -Wno-aix-compat added temporarily while the diagnostic is being
+// refined.
+// RUN: %clang_analyze_cc1 -verify -Wno-aix-compat %s \
 // RUN:   -analyzer-checker=optin.performance \
 // RUN:   -analyzer-config optin.performance.Padding:AllowedPad=2
 
-// RUN: not %clang_analyze_cc1 -verify %s \
+// RUN: not %clang_analyze_cc1 -verify -Wno-aix-compat %s \
 // RUN:   -analyzer-checker=core \
 // RUN:   -analyzer-checker=optin.performance.Padding \
 // RUN:   -analyzer-config optin.performance.Padding:AllowedPad=-10 \


Index: clang/test/SemaTemplate/instantiate-attr.cpp
===
--- clang/test/SemaTemplate/instantiate-attr.cpp
+++ clang/test/SemaTemplate/instantiate-attr.cpp
@@ -1,4 +1,7 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// FIXME -Wno-aix-compat added temporarily while the diagnostic is being
+// refined.
+
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-aix-compat %s
 // expected-no-diagnostics
 template 
 struct A {
Index: clang/test/CXX/drs/dr6xx.cpp
===
--- clang/test/CXX/drs/dr6xx.cpp
+++ clang/test/CXX/drs/dr6xx.cpp
@@ -1,8 +1,10 @@
-// RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking
-// RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking
-// RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking
-// RUN: %clang_cc1 -std=c++17 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking
-// RUN: %clang_cc1 -std=c++20 %s -verify -fexceptions 

[PATCH] D118670: [NFC][AIX]Disable failed tests due to aggressive byval alignment warning on AIX

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

LGTM with minor comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118670

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


[clang] 245b8e5 - [NFC][AIX]Disable failed tests due to aggressive byval alignment warning on AIX

2022-02-01 Thread Steven Wan via cfe-commits

Author: Steven Wan
Date: 2022-02-01T11:49:53-05:00
New Revision: 245b8e5691ed9e4483b3e0f807706fe1fb6eaa38

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

LOG: [NFC][AIX]Disable failed tests due to aggressive byval alignment warning 
on AIX

These tests emit unexpected diagnostics on AIX because the byval alignment 
warning is emitted too aggressively. https://reviews.llvm.org/D118350 is 
supposed to provide a proper fix to the problem, but for the time being disable 
the tests to unblock.

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

Added: 


Modified: 
clang/test/Analysis/padding_c.c
clang/test/Analysis/padding_cpp.cpp
clang/test/CXX/drs/dr6xx.cpp
clang/test/SemaTemplate/instantiate-attr.cpp

Removed: 




diff  --git a/clang/test/Analysis/padding_c.c b/clang/test/Analysis/padding_c.c
index 98d3ab1a3e1f1..e01bb7ef73c04 100644
--- a/clang/test/Analysis/padding_c.c
+++ b/clang/test/Analysis/padding_c.c
@@ -1,8 +1,10 @@
-// RUN: %clang_analyze_cc1 -verify %s \
+// FIXME -Wno-aix-compat added temporarily while the diagnostic is being
+// refined.
+// RUN: %clang_analyze_cc1 -verify -Wno-aix-compat %s \
 // RUN:   -analyzer-checker=optin.performance \
 // RUN:   -analyzer-config optin.performance.Padding:AllowedPad=2
 
-// RUN: not %clang_analyze_cc1 -verify %s \
+// RUN: not %clang_analyze_cc1 -verify -Wno-aix-compat %s \
 // RUN:   -analyzer-checker=core \
 // RUN:   -analyzer-checker=optin.performance.Padding \
 // RUN:   -analyzer-config optin.performance.Padding:AllowedPad=-10 \

diff  --git a/clang/test/Analysis/padding_cpp.cpp 
b/clang/test/Analysis/padding_cpp.cpp
index f0e8beacda763..3d4055a3ae472 100644
--- a/clang/test/Analysis/padding_cpp.cpp
+++ b/clang/test/Analysis/padding_cpp.cpp
@@ -1,4 +1,6 @@
-// RUN: %clang_analyze_cc1 -std=c++14 -analyzer-checker=optin.performance 
-analyzer-config optin.performance.Padding:AllowedPad=2 -verify %s
+// FIXME -Wno-aix-compat added temporarily while the diagnostic is being
+// refined.
+// RUN: %clang_analyze_cc1 -std=c++14 -analyzer-checker=optin.performance 
-analyzer-config optin.performance.Padding:AllowedPad=2 -verify -Wno-aix-compat 
%s
 
 // Make sure that the C cases still work fine, even when compiled as C++.
 #include "padding_c.c"

diff  --git a/clang/test/CXX/drs/dr6xx.cpp b/clang/test/CXX/drs/dr6xx.cpp
index ad87c7295cfe8..a9c2ddbf47840 100644
--- a/clang/test/CXX/drs/dr6xx.cpp
+++ b/clang/test/CXX/drs/dr6xx.cpp
@@ -1,8 +1,10 @@
-// RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors -fno-spell-checking
-// RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors -fno-spell-checking
-// RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors -fno-spell-checking
-// RUN: %clang_cc1 -std=c++17 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors -fno-spell-checking
-// RUN: %clang_cc1 -std=c++20 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors -fno-spell-checking
+// FIXME -Wno-aix-compat added temporarily while the diagnostic is being
+// refined.
+// RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors -fno-spell-checking -Wno-aix-compat
+// RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors -fno-spell-checking -Wno-aix-compat
+// RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors -fno-spell-checking -Wno-aix-compat
+// RUN: %clang_cc1 -std=c++17 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors -fno-spell-checking -Wno-aix-compat
+// RUN: %clang_cc1 -std=c++20 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors -fno-spell-checking -Wno-aix-compat
 
 namespace std {
   struct type_info {};

diff  --git a/clang/test/SemaTemplate/instantiate-attr.cpp 
b/clang/test/SemaTemplate/instantiate-attr.cpp
index 1e94614f371da..8cd0b335ffbdd 100644
--- a/clang/test/SemaTemplate/instantiate-attr.cpp
+++ b/clang/test/SemaTemplate/instantiate-attr.cpp
@@ -1,4 +1,7 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// FIXME -Wno-aix-compat added temporarily while the diagnostic is being
+// refined.
+
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-aix-compat %s
 // expected-no-diagnostics
 template 
 struct A {



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


[PATCH] D118670: [NFC][AIX]Disable failed tests due to aggressive byval alignment warning on AIX

2022-02-01 Thread Steven Wan via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG245b8e5691ed: [NFC][AIX]Disable failed tests due to 
aggressive byval alignment warning on AIX (authored by stevewan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118670

Files:
  clang/test/Analysis/padding_c.c
  clang/test/Analysis/padding_cpp.cpp
  clang/test/CXX/drs/dr6xx.cpp
  clang/test/SemaTemplate/instantiate-attr.cpp


Index: clang/test/SemaTemplate/instantiate-attr.cpp
===
--- clang/test/SemaTemplate/instantiate-attr.cpp
+++ clang/test/SemaTemplate/instantiate-attr.cpp
@@ -1,4 +1,7 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// FIXME -Wno-aix-compat added temporarily while the diagnostic is being
+// refined.
+
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-aix-compat %s
 // expected-no-diagnostics
 template 
 struct A {
Index: clang/test/CXX/drs/dr6xx.cpp
===
--- clang/test/CXX/drs/dr6xx.cpp
+++ clang/test/CXX/drs/dr6xx.cpp
@@ -1,8 +1,10 @@
-// RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors -fno-spell-checking
-// RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors -fno-spell-checking
-// RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors -fno-spell-checking
-// RUN: %clang_cc1 -std=c++17 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors -fno-spell-checking
-// RUN: %clang_cc1 -std=c++20 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors -fno-spell-checking
+// FIXME -Wno-aix-compat added temporarily while the diagnostic is being
+// refined.
+// RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors -fno-spell-checking -Wno-aix-compat
+// RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors -fno-spell-checking -Wno-aix-compat
+// RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors -fno-spell-checking -Wno-aix-compat
+// RUN: %clang_cc1 -std=c++17 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors -fno-spell-checking -Wno-aix-compat
+// RUN: %clang_cc1 -std=c++20 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors -fno-spell-checking -Wno-aix-compat
 
 namespace std {
   struct type_info {};
Index: clang/test/Analysis/padding_cpp.cpp
===
--- clang/test/Analysis/padding_cpp.cpp
+++ clang/test/Analysis/padding_cpp.cpp
@@ -1,4 +1,6 @@
-// RUN: %clang_analyze_cc1 -std=c++14 -analyzer-checker=optin.performance 
-analyzer-config optin.performance.Padding:AllowedPad=2 -verify %s
+// FIXME -Wno-aix-compat added temporarily while the diagnostic is being
+// refined.
+// RUN: %clang_analyze_cc1 -std=c++14 -analyzer-checker=optin.performance 
-analyzer-config optin.performance.Padding:AllowedPad=2 -verify -Wno-aix-compat 
%s
 
 // Make sure that the C cases still work fine, even when compiled as C++.
 #include "padding_c.c"
Index: clang/test/Analysis/padding_c.c
===
--- clang/test/Analysis/padding_c.c
+++ clang/test/Analysis/padding_c.c
@@ -1,8 +1,10 @@
-// RUN: %clang_analyze_cc1 -verify %s \
+// FIXME -Wno-aix-compat added temporarily while the diagnostic is being
+// refined.
+// RUN: %clang_analyze_cc1 -verify -Wno-aix-compat %s \
 // RUN:   -analyzer-checker=optin.performance \
 // RUN:   -analyzer-config optin.performance.Padding:AllowedPad=2
 
-// RUN: not %clang_analyze_cc1 -verify %s \
+// RUN: not %clang_analyze_cc1 -verify -Wno-aix-compat %s \
 // RUN:   -analyzer-checker=core \
 // RUN:   -analyzer-checker=optin.performance.Padding \
 // RUN:   -analyzer-config optin.performance.Padding:AllowedPad=-10 \


Index: clang/test/SemaTemplate/instantiate-attr.cpp
===
--- clang/test/SemaTemplate/instantiate-attr.cpp
+++ clang/test/SemaTemplate/instantiate-attr.cpp
@@ -1,4 +1,7 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// FIXME -Wno-aix-compat added temporarily while the diagnostic is being
+// refined.
+
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-aix-compat %s
 // expected-no-diagnostics
 template 
 struct A {
Index: clang/test/CXX/drs/dr6xx.cpp
===
--- clang/test/CXX/drs/dr6xx.cpp
+++ clang/test/CXX/drs/dr6xx.cpp
@@ -1,8 +1,10 @@
-// RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking
-// RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking
-// RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-

[PATCH] D118708: [OpenMP] Add kernel string attribute to kernel function

2022-02-01 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert accepted this revision.
jdoerfert added a comment.
This revision is now accepted and ready to land.

LG, thanks


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118708

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


[PATCH] D118711: [hack] Build a tree of preprocessing directives

2022-02-01 Thread Richard via Phabricator via cfe-commits
LegalizeAdulthood created this revision.
LegalizeAdulthood added a reviewer: ymandel.
Herald added subscribers: carlosgalvezp, kbarton, mgorny, nemanjai.
LegalizeAdulthood requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

This code is disgusting and meant only as an object
of discussion.


https://reviews.llvm.org/D118711

Files:
  clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
  clang-tools-extra/clang-tidy/ClangTidyCheck.h
  clang-tools-extra/clang-tidy/cppcoreguidelines/MacroUsageCheck.cpp
  clang-tools-extra/clang-tidy/utils/CMakeLists.txt
  clang-tools-extra/clang-tidy/utils/PPTree.cpp
  clang-tools-extra/clang-tidy/utils/PPTree.h

Index: clang-tools-extra/clang-tidy/utils/PPTree.h
===
--- /dev/null
+++ clang-tools-extra/clang-tidy/utils/PPTree.h
@@ -0,0 +1,258 @@
+//===-- PPTree.h - clang-tidy -===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PPTREE_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PPTREE_H
+
+#include "clang/Lex/PPCallbacks.h"
+#include "clang/Lex/Token.h"
+#include 
+
+namespace clang {
+namespace tidy {
+namespace utils {
+
+struct PPDirective {
+  virtual ~PPDirective() = default;
+};
+
+using PPDirectiveStorage = std::vector;
+
+class PPDirectiveList {
+public:
+  void add(PPDirective *Dir) { Directives.emplace_back(Dir); }
+
+  ~PPDirectiveList() {
+for (PPDirective *Dir : Directives)
+  delete Dir;
+Directives.clear();
+  }
+
+  PPDirectiveStorage::iterator begin() { return Directives.begin(); }
+  PPDirectiveStorage::iterator end() { return Directives.end(); }
+
+  PPDirectiveStorage::const_iterator begin() const { return Directives.begin(); }
+  PPDirectiveStorage::const_iterator end() const { return Directives.end(); }
+
+  size_t size() const { return Directives.size(); }
+
+private:
+  PPDirectiveStorage Directives;
+};
+
+struct PPInclusion : PPDirective {
+  PPInclusion(SourceLocation HashLoc, Token IncludeTok, StringRef FileName,
+  bool IsAngled, CharSourceRange FilenameRange,
+  const FileEntry *File, StringRef SearchPath,
+  StringRef RelativePath, const Module *Imported,
+  SrcMgr::CharacteristicKind FileType)
+  : HashLoc(HashLoc), IncludeTok(IncludeTok), FileName(FileName.str()),
+IsAngled(IsAngled), FilenameRange(FilenameRange), File(File),
+SearchPath(SearchPath.str()), RelativePath(RelativePath.str()),
+Imported(Imported), FileType(FileType) {}
+
+  SourceLocation HashLoc;
+  Token IncludeTok;
+  std::string FileName;
+  bool IsAngled;
+  CharSourceRange FilenameRange;
+  const FileEntry *File;
+  std::string SearchPath;
+  std::string RelativePath;
+  const Module *Imported;
+  SrcMgr::CharacteristicKind FileType;
+};
+
+struct PPIdent : PPDirective {
+  PPIdent(SourceLocation Loc, StringRef Str) : Loc(Loc), Str(Str.str()) {}
+
+  SourceLocation Loc;
+  std::string Str;
+};
+
+struct PPPragma : PPDirective {
+  PPPragma(SourceLocation Loc, PragmaIntroducerKind Introducer)
+  : Loc(Loc), Introducer(Introducer) {}
+
+  SourceLocation Loc;
+  PragmaIntroducerKind Introducer;
+};
+
+struct PPPragmaComment : PPDirective {
+  PPPragmaComment(SourceLocation Loc, const IdentifierInfo *Kind,
+  StringRef Str) : Loc(Loc), Kind(Kind), Str(Str.str()) {}
+
+  SourceLocation Loc;
+  const IdentifierInfo *Kind;
+  std::string Str;
+};
+
+struct PPPragmaMark : PPDirective {
+  PPPragmaMark(SourceLocation Loc, StringRef Trivia)
+  : Loc(Loc), Trivia(Trivia.str()) {}
+
+  SourceLocation Loc;
+  std::string Trivia;
+};
+
+struct PPPragmaDetectMismatch : PPDirective {
+  PPPragmaDetectMismatch(SourceLocation Loc, StringRef Name, StringRef Value)
+  : Loc(Loc), Name(Name.str()), Value(Value.str()) {}
+
+  SourceLocation Loc;
+  std::string Name;
+  std::string Value;
+};
+
+struct PPPragmaDebug : PPDirective {
+  PPPragmaDebug(SourceLocation Loc, StringRef DebugType)
+  : Loc(Loc), DebugType(DebugType.str()) {}
+
+  SourceLocation Loc;
+  std::string DebugType;
+};
+
+struct PPPragmaMessage : PPDirective {
+  PPPragmaMessage(SourceLocation Loc, StringRef Namespace,
+  PPCallbacks::PragmaMessageKind Kind, StringRef Str)
+  : Loc(Loc), Namespace(Namespace.str()), Kind(Kind), Str(Str.str()) {}
+
+  SourceLocation Loc;
+  std::string Namespace;
+  PPCallbacks::PragmaMessageKind Kind;
+  std::string Str;
+};
+
+struct PPMacroDefined : PPDirective {
+  PPMacroDefined(const Token &MacroNameTok, const MacroDirective *MD) : Name(MacroNameTok), MD(MD) {}
+
+  Token Name;
+  const MacroDirective *MD;
+};

[PATCH] D118706: [clang-format] Correctly parse C99 digraphs: "<:", ":>", "<%", "%>", "%:", "%:%:".

2022-02-01 Thread Owen Pan via Phabricator via cfe-commits
owenpan accepted this revision.
owenpan added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/lib/Format/Format.cpp:3246
+  // Turning on digraphs in standards before C++0x is error-prone, because e.g.
+  // the sequence "<::" will be inconditionally treated as "[:".
+  // Cf. Lexer::LexTokenInternal.

“unconditionally”?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118706

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


[PATCH] D117795: [AArch64] Add some missing strict FP vector lowering

2022-02-01 Thread John Brawn via Phabricator via cfe-commits
john.brawn added inline comments.



Comment at: llvm/lib/Target/AArch64/AArch64ISelLowering.cpp:1484
+  // of the vector comparison instructions.
+  setOperationAction(ISD::STRICT_FSETCCS, VT, Expand);
+  // FIXME: We could potentially make use of the vector comparison instructions

dmgreen wrote:
> Can you split this into a separate patch? I know I sound like a broken 
> record, but it doesn't seem to be related to the converts below.
> 
> Also pre-committing as much of the test that works as possible would cut it 
> down from this patch quite a bit.
Instead of a separate patch just for these two, it would probably make more 
sense to move them into D114946 with the rest of the setOperationAction lines.

On the test, without the changes in this patch it hits an assertion failure so 
as a separate commit before this it wouldn't be able to test anything.


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

https://reviews.llvm.org/D117795

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


[PATCH] D118199: [AArch64] ACLE feature macro for Armv8.8-A MOPS

2022-02-01 Thread Momchil Velikov via Phabricator via cfe-commits
chill added a comment.

In D118199#3287636 , @chill wrote:

> I suppose `clang/test/CodeGen/aarch64-mops.c` needs to be run with `clang 
> -march=armv8-a+mops+memtag` (not `clang_cc1`) so it picks up declarations of 
> tagging intrinsics from `arm_acle.h`.

Uhm, scratch that.

For checking diagnostics, `clang_cc1 --verify`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118199

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


[PATCH] D54943: [clang-tidy] implement const-transformation for cppcoreguidelines-const-correctness

2022-02-01 Thread Richard via Phabricator via cfe-commits
LegalizeAdulthood added inline comments.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-const-correctness-transform-pointer-as-values.cpp:12
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local0' of type 
'double *' can be declared 'const'
+  // CHECK-FIXES: const
+}

JonasToth wrote:
> JonasToth wrote:
> > 0x8000- wrote:
> > > LegalizeAdulthood wrote:
> > > > Shouldn't this validate that the `const` was placed in the correct 
> > > > position?
> > > > e.g. `const double *` is a different meaning from `double *const`
> > > > 
> > > > Apply to all the other `CHECK-FIXES` as well
> > > Can we have the checker merged in first, then we can worry about the 
> > > automatic fixer?
> > the checker is its own utility with its own tests and proper test coverage.
> > yes `const double*` and `double* const` are different and are correctly 
> > inserted, but that is not tested here, but here: 
> > https://github.com/llvm/llvm-project/blob/main/clang-tools-extra/unittests/clang-tidy/AddConstTest.cpp
> > 
> > Similar to the actual `const` analysis. That has its own test-suite 
> > (https://github.com/llvm/llvm-project/blob/main/clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp)
> > 
> > The tests here are concerned with the diagnostics and "real" code. 
> > Afterall, this functionality is too complex to have all of it checked with 
> > these kind of tests.
> > I think the separate testing in specialized unit-tests (as is now) for the 
> > specialized functions is the right approach and the `CHECK-FIXES` are not 
> > necessary in this instance, maybe even bad, because it makes the tests 
> > unclearer.
> sry: The _fixer_ is its own utility ...
> 
> Additionally: The test is run on big projects with transformation (LLVM, some 
> Qt Stuff).
> First everything is transformed and then recompiled. The compiler tells what 
> was incorrectly inserted :)
> 
> Thats part of the testing too.
> The tests here are concerned with the diagnostics and "real" code.

OK, great!  I didn't realize it was covered by unit tests,
which is perfectly fine with me `:)`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D54943

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


[PATCH] D115610: [C++20] [Modules] Don't create multiple global module fragment

2022-02-01 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

Thanks, this looks functionally good to me. I'm happy for this to land with the 
`Sema` member renamed.




Comment at: clang/lib/Sema/SemaModule.cpp:727
+ModuleMap &Map = PP.getHeaderSearchInfo().getModuleMap();
+GlobalModuleFragmentCache = Map.createGlobalModuleFragmentForModuleUnit(
+BeginLoc, getCurrentModule());

If this is supposed to be a cache, we should look for an existing global module 
fragment here rather than always creating a new one. Either this member 
shouldn't be called `...Cache` or we should do a search at this point. (I think 
we do want to support the existence of multiple different global module 
fragments in a single module, for example if we have full information about 
multiple different module interface units for the same module loaded, so I 
think just renaming the member is probably the best way to go).


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

https://reviews.llvm.org/D115610

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


[PATCH] D118070: Add /winsysroot support to lld

2022-02-01 Thread Peter Kasting via Phabricator via cfe-commits
pkasting marked 9 inline comments as done.
pkasting added a comment.

In D118070#3278123 , @thakis wrote:

> Things that can still improve:
>
> 1. This now does way more than just /winsysroot:. It also makes it so that 
> lld-link works in a non-msvc shell by looking up libpaths in either registry 
> or via setup api.

Updated description.

> 2. Some of the new lld-link code still looks (from a distance, might be 
> wrong) like it could be shared more

Did what I think I could, see details in comments.

> 3. Still needs tests.

Added a few basic tests, please review.




Comment at: lld/COFF/Driver.cpp:157
+// on the target architecture.
+static const char *getWindowsSDKArch() {
+  switch (config->machine) {

Found a way to share these.



Comment at: lld/COFF/Driver.cpp:666
+
+if (useUniversalCRT(vsLayout, vcToolChainPath)) {
+  std::string UniversalCRTSdkPath;

thakis wrote:
> Do you think it's possible to get this logic here (this path if ucrt else 
> this other path, etc) shared between the two places? Maybe a getLibPaths() 
> function that's passed arch etc?
The big problem is that in lld this logic is split between the two phases 
(pre-run() and post-run()) and can't easily be moved entirely into the 
post-run() phase.  So we'd only be able to share the logic that is here in the 
pre-run phase (the code that doesn't need the arch), which would make the clang 
code quite cumbersome.

I think it's not worth trying.



Comment at: lld/COFF/Driver.cpp:710
+  if (!windowsSdkLibPath.empty()) {
+if (sdkMajor >= 8) {
+  path::append(windowsSdkLibPath, getWindowsSDKArch());

Found a way to share this.



Comment at: lld/COFF/Driver.cpp:257
+
+  path::append(SDKPath, "Include");
+  Version = getHighestNumericTupleInDirectory(SDKPath);

thakis wrote:
> `Include` seems like the wrong directory to look in in the linker (…i think?)
I think this is OK.  It's not obvious to me that we can change this to a .lib 
check safely, and I think clang and lld should use the same logic to detect 
ucrt.



Comment at: lld/COFF/Driver.cpp:687
 void LinkerDriver::addLibSearchPaths() {
   Optional envOpt = Process::GetEnv("LIB");
   if (!envOpt.hasValue())

thakis wrote:
> thakis wrote:
> > We shouldn't look at `%LIB%` here when `/winsysroot:` is passed.
> Oh I see, this is now no longer called if winsysroot is passed.
Yep, added a test for this too.



Comment at: lld/COFF/SymbolTable.cpp:59
 config->machine = mt;
+driver->addWinSysRootLibSearchPaths();
   } else if (mt != IMAGE_FILE_MACHINE_UNKNOWN && config->machine != mt) {

thakis wrote:
> I suppose this is good enough :)
> 
> If we wanted to get fancy, we could put in code to explicitly detect the case 
> of a .lib file not being found, and addWinSysRootLibSearchPaths() not having 
> been called yet (due to the machine type not yet being know), and then diag 
> something like ".lib not found. you passed /winsysroot:, try passing 
> /machine: too". But I don't think this will ever happen in practice, so I 
> think it's not worth worrying about.
I think this can only happen for defaultlibs?  ...and those get processed after 
we set the machine type now, so there can't be a problem here.  Or at least, I 
couldn't find a way to trigger one in practice -- all my attempts led the 
linker to instead complain "No input files."  So I'm gonna call this N/A, but 
if you think of a command line to trigger it so I can test it, let me know.



Comment at: utils/bazel/llvm-project-overlay/clang/BUILD.bazel:1314
-"lib/Driver/ToolChains/MSVCSetupApi.h",
-],
 ),

thakis wrote:
> (fwiw you don't have to update BUILD.bazel files)
Shrug, it's not hard to do so.  And already done now, so...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118070

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


[PATCH] D111100: enable plugins for clang-tidy

2022-02-01 Thread Jameson Nash via Phabricator via cfe-commits
vtjnash updated this revision to Diff 404993.
vtjnash added a comment.

- Reland "enable plugins for clang-tidy"
- fixup! Reland "enable plugins for clang-tidy": Disable the test if the user 
has disabled support for building it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D00

Files:
  clang-tools-extra/clang-tidy/tool/CMakeLists.txt
  clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/Contributing.rst
  clang-tools-extra/docs/clang-tidy/index.rst
  clang-tools-extra/test/CMakeLists.txt
  clang-tools-extra/test/clang-tidy/CTTestTidyModule.cpp
  clang-tools-extra/test/lit.cfg.py
  clang-tools-extra/test/lit.site.cfg.py.in

Index: clang-tools-extra/test/lit.site.cfg.py.in
===
--- clang-tools-extra/test/lit.site.cfg.py.in
+++ clang-tools-extra/test/lit.site.cfg.py.in
@@ -4,6 +4,7 @@
 
 config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
 config.llvm_libs_dir = "@LLVM_LIBS_DIR@"
+config.llvm_plugin_ext = "@LLVM_PLUGIN_EXT@"
 config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
 config.clang_tools_binary_dir = "@CLANG_TOOLS_BINARY_DIR@"
 config.clang_tools_dir = "@CLANG_TOOLS_DIR@"
@@ -11,6 +12,7 @@
 config.python_executable = "@Python3_EXECUTABLE@"
 config.target_triple = "@TARGET_TRIPLE@"
 config.clang_tidy_staticanalyzer = @CLANG_TIDY_ENABLE_STATIC_ANALYZER@
+config.has_plugins = @LLVM_ENABLE_PLUGINS@ & ~@LLVM_INSTALL_TOOLCHAIN_ONLY@
 
 # Support substitution of the tools and libs dirs with user parameters. This is
 # used when we can't determine the tool dir at configuration time.
Index: clang-tools-extra/test/lit.cfg.py
===
--- clang-tools-extra/test/lit.cfg.py
+++ clang-tools-extra/test/lit.cfg.py
@@ -149,3 +149,9 @@
  "clangd", "benchmarks")
 config.substitutions.append(('%clangd-benchmark-dir',
  '%s' % (clangd_benchmarks_dir)))
+config.substitutions.append(('%llvmshlibdir', config.clang_libs_dir))
+config.substitutions.append(('%pluginext', config.llvm_plugin_ext))
+
+# Plugins (loadable modules)
+if config.has_plugins and config.llvm_plugin_ext:
+config.available_features.add('plugins')
Index: clang-tools-extra/test/clang-tidy/CTTestTidyModule.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/CTTestTidyModule.cpp
@@ -0,0 +1,66 @@
+// REQUIRES: plugins
+// RUN: clang-tidy -checks='-*,mytest*' --list-checks -load %llvmshlibdir/CTTestTidyModule%pluginext -load %llvmshlibdir/LLVMHello%pluginext | FileCheck --check-prefix=CHECK-LIST %s
+// CHECK-LIST: Enabled checks:
+// CHECK-LIST-NEXT:mytest1
+// CHECK-LIST-NEXT:mytest2
+// RUN: clang-tidy -checks='-*,mytest*,misc-definitions-in-headers' -load %llvmshlibdir/CTTestTidyModule%pluginext /dev/null -- -xc 2>&1 | FileCheck %s
+// CHECK: 3 warnings generated.
+// CHECK-NEXT: warning: mytest success [misc-definitions-in-headers,mytest1,mytest2]
+
+#include "clang-tidy/ClangTidy.h"
+#include "clang-tidy/ClangTidyCheck.h"
+#include "clang-tidy/ClangTidyModule.h"
+#include "clang-tidy/ClangTidyModuleRegistry.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang;
+using namespace clang::tidy;
+using namespace clang::ast_matchers;
+
+namespace {
+class MyTestCheck : public ClangTidyCheck {
+
+public:
+  MyTestCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override {
+Finder->addMatcher(translationUnitDecl().bind("tu"), this);
+  }
+
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override {
+auto S = Result.Nodes.getNodeAs("tu");
+if (S)
+  diag("mytest success");
+  }
+
+private:
+};
+
+class CTTestModule : public ClangTidyModule {
+public:
+  void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
+CheckFactories.registerCheck("mytest1");
+CheckFactories.registerCheck("mytest2");
+// intentionally collide with an existing test name, overriding it
+CheckFactories.registerCheck("misc-definitions-in-headers");
+  }
+};
+} // namespace
+
+namespace tidy1 {
+// Register the CTTestTidyModule using this statically initialized variable.
+static ClangTidyModuleRegistry::Add<::CTTestModule>
+X("mytest-module", "Adds my checks.");
+} // namespace tidy1
+
+namespace tidy2 {
+// intentionally collide with an existing test group name, merging with it
+static ClangTidyModuleRegistry::Add<::CTTestModule>
+X("misc-module", "Adds miscellaneous lint checks.");
+} // namespace tidy2
+
+// This anchor is used to force the linker to link in the generated object file
+// and thus register the CTTestModule.
+volatile int CTTe

[PATCH] D111100: enable plugins for clang-tidy

2022-02-01 Thread Jameson Nash via Phabricator via cfe-commits
vtjnash added a comment.

I decided it made the most sense to me to go with option 3, so this should be 
ready to land again.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D00

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


[PATCH] D118070: Make lld-link work in a non-MSVC shell

2022-02-01 Thread Peter Kasting via Phabricator via cfe-commits
pkasting updated this revision to Diff 404994.
pkasting marked 5 inline comments as done.
pkasting retitled this revision from "Add /winsysroot support to lld" to "Make 
lld-link work in a non-MSVC shell".
pkasting edited the summary of this revision.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118070

Files:
  clang/docs/tools/clang-formatted-files.txt
  clang/lib/Driver/ToolChains/MSVC.cpp
  clang/lib/Driver/ToolChains/MSVC.h
  clang/lib/Driver/ToolChains/MSVCSetupApi.h
  lld/COFF/Driver.cpp
  lld/COFF/Driver.h
  lld/COFF/Options.td
  lld/COFF/SymbolTable.cpp
  lld/test/COFF/winsysroot.test
  llvm/include/llvm/Support/MSVCPaths.h
  llvm/include/llvm/Support/MSVCSetupApi.h
  llvm/lib/Support/CMakeLists.txt
  llvm/lib/Support/MSVCPaths.cpp
  llvm/utils/gn/secondary/llvm/lib/Support/BUILD.gn
  utils/bazel/llvm-project-overlay/clang/BUILD.bazel

Index: utils/bazel/llvm-project-overlay/clang/BUILD.bazel
===
--- utils/bazel/llvm-project-overlay/clang/BUILD.bazel
+++ utils/bazel/llvm-project-overlay/clang/BUILD.bazel
@@ -1309,9 +1309,6 @@
 "lib/Driver/ToolChains/Arch/*.cpp",
 "lib/Driver/ToolChains/Arch/*.h",
 ],
-exclude = [
-"lib/Driver/ToolChains/MSVCSetupApi.h",
-],
 ),
 hdrs = glob([
 "include/clang/Driver/*.h",
Index: llvm/utils/gn/secondary/llvm/lib/Support/BUILD.gn
===
--- llvm/utils/gn/secondary/llvm/lib/Support/BUILD.gn
+++ llvm/utils/gn/secondary/llvm/lib/Support/BUILD.gn
@@ -98,6 +98,7 @@
 "MD5.cpp",
 "MSP430AttributeParser.cpp",
 "MSP430Attributes.cpp",
+"MSVCPaths.cpp",
 "ManagedStatic.cpp",
 "MathExtras.cpp",
 "MemAlloc.cpp",
Index: llvm/lib/Support/MSVCPaths.cpp
===
--- /dev/null
+++ llvm/lib/Support/MSVCPaths.cpp
@@ -0,0 +1,707 @@
+//===-- MSVCPaths.cpp - MSVC path-parsing helpers -===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "llvm/Support/MSVCPaths.h"
+#include "llvm/ADT/Optional.h"
+#include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/Triple.h"
+#include "llvm/ADT/Twine.h"
+#include "llvm/Option/Arg.h"
+#include "llvm/Option/ArgList.h"
+#include "llvm/Support/ConvertUTF.h"
+#include "llvm/Support/Host.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/Process.h"
+#include "llvm/Support/Program.h"
+#include "llvm/Support/VersionTuple.h"
+#include "llvm/Support/VirtualFileSystem.h"
+#include 
+
+#ifdef _WIN32
+#define WIN32_LEAN_AND_MEAN
+#define NOGDI
+#ifndef NOMINMAX
+#define NOMINMAX
+#endif
+#include 
+#endif
+
+#ifdef _MSC_VER
+// Don't support SetupApi on MinGW.
+#define USE_MSVC_SETUP_API
+
+// Make sure this comes before MSVCSetupApi.h
+#include 
+
+#include "llvm/Support/COM.h"
+#ifdef __clang__
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wnon-virtual-dtor"
+#endif
+#include "llvm/Support/MSVCSetupApi.h"
+#ifdef __clang__
+#pragma clang diagnostic pop
+#endif
+_COM_SMARTPTR_TYPEDEF(ISetupConfiguration, __uuidof(ISetupConfiguration));
+_COM_SMARTPTR_TYPEDEF(ISetupConfiguration2, __uuidof(ISetupConfiguration2));
+_COM_SMARTPTR_TYPEDEF(ISetupHelper, __uuidof(ISetupHelper));
+_COM_SMARTPTR_TYPEDEF(IEnumSetupInstances, __uuidof(IEnumSetupInstances));
+_COM_SMARTPTR_TYPEDEF(ISetupInstance, __uuidof(ISetupInstance));
+_COM_SMARTPTR_TYPEDEF(ISetupInstance2, __uuidof(ISetupInstance2));
+#endif
+
+static std::string
+getHighestNumericTupleInDirectory(llvm::vfs::FileSystem &VFS,
+  llvm::StringRef Directory) {
+  std::string Highest;
+  llvm::VersionTuple HighestTuple;
+
+  std::error_code EC;
+  for (llvm::vfs::directory_iterator DirIt = VFS.dir_begin(Directory, EC),
+ DirEnd;
+   !EC && DirIt != DirEnd; DirIt.increment(EC)) {
+auto Status = VFS.status(DirIt->path());
+if (!Status || !Status->isDirectory())
+  continue;
+llvm::StringRef CandidateName = llvm::sys::path::filename(DirIt->path());
+llvm::VersionTuple Tuple;
+if (Tuple.tryParse(CandidateName)) // tryParse() returns true on error.
+  continue;
+if (Tuple > HighestTuple) {
+  HighestTuple = Tuple;
+  Highest = CandidateName.str();
+}
+  }
+
+  return Highest;
+}
+
+static bool getWindows10SDKVersionFromPath(llvm::vfs::FileSystem &VFS,
+   const std::string &SDKPath,
+  

[PATCH] D117937: [VFS] Add a "redirecting-with" field to overlays

2022-02-01 Thread Ben Barham via Phabricator via cfe-commits
bnbarham updated this revision to Diff 404999.
bnbarham added a reviewer: nathawes.
bnbarham added a comment.

Noticed one of the unit tests wasn't actually testing the right thing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D117937

Files:
  clang/test/VFS/Inputs/redirect-and-fallthrough.yaml
  clang/test/VFS/Inputs/unknown-redirect.yaml
  clang/test/VFS/fallback.c
  clang/test/VFS/parse-errors.c
  llvm/include/llvm/Support/VirtualFileSystem.h
  llvm/lib/Support/VirtualFileSystem.cpp
  llvm/unittests/Support/VirtualFileSystemTest.cpp

Index: llvm/unittests/Support/VirtualFileSystemTest.cpp
===
--- llvm/unittests/Support/VirtualFileSystemTest.cpp
+++ llvm/unittests/Support/VirtualFileSystemTest.cpp
@@ -1910,7 +1910,25 @@
   Lower);
   EXPECT_EQ(nullptr, FS.get());
 
-  EXPECT_EQ(26, NumDiagnostics);
+  // invalid redirect kind
+  FS = getFromYAMLString("{ 'redirecting-with': 'none', 'roots': [{\n"
+ "  'type': 'directory-remap',\n"
+ "  'name': '//root/A',\n"
+ "  'external-contents': '//root/B' }]}",
+ Lower);
+  EXPECT_EQ(nullptr, FS.get());
+
+  // redirect and fallthrough passed
+  FS = getFromYAMLString("{ 'redirecting-with': 'fallthrough',\n"
+ "  'fallthrough': true,\n"
+ "  'roots': [{\n"
+ "'type': 'directory-remap',\n"
+ "'name': '//root/A',\n"
+ "'external-contents': '//root/B' }]}",
+ Lower);
+  EXPECT_EQ(nullptr, FS.get());
+
+  EXPECT_EQ(28, NumDiagnostics);
 }
 
 TEST_F(VFSFromYAMLTest, UseExternalName) {
@@ -2710,6 +2728,121 @@
   EXPECT_FALSE(FS->exists(_c.path("c")));
 }
 
+TEST_F(VFSFromYAMLTest, RedirectingWith) {
+  IntrusiveRefCntPtr Both(new DummyFileSystem());
+  Both->addDirectory("//root/a");
+  Both->addRegularFile("//root/a/f");
+  Both->addDirectory("//root/b");
+  Both->addRegularFile("//root/b/f");
+
+  IntrusiveRefCntPtr AOnly(new DummyFileSystem());
+  AOnly->addDirectory("//root/a");
+  AOnly->addRegularFile("//root/a/f");
+
+  IntrusiveRefCntPtr BOnly(new DummyFileSystem());
+  BOnly->addDirectory("//root/b");
+  BOnly->addRegularFile("//root/b/f");
+
+  auto BaseStr = std::string("  'roots': [\n"
+ "{\n"
+ "  'type': 'directory-remap',\n"
+ "  'name': '//root/a',\n"
+ "  'external-contents': '//root/b'\n"
+ "}\n"
+ "  ]\n"
+ "}");
+  auto FallthroughStr = "{ 'redirecting-with': 'fallthrough',\n" + BaseStr;
+  auto FallbackStr = "{ 'redirecting-with': 'fallback',\n" + BaseStr;
+  auto RedirectOnlyStr = "{ 'redirecting-with': 'redirect-only',\n" + BaseStr;
+
+  auto ExpectPath = [&](vfs::FileSystem &FS, StringRef Expected,
+StringRef Message) {
+auto AF = FS.openFileForRead("//root/a/f");
+ASSERT_FALSE(AF.getError()) << Message;
+auto AFName = (*AF)->getName();
+ASSERT_FALSE(AFName.getError()) << Message;
+EXPECT_EQ(Expected.str(), AFName.get()) << Message;
+
+auto AS = FS.status("//root/a/f");
+ASSERT_FALSE(AS.getError()) << Message;
+EXPECT_EQ(Expected.str(), AS->getName()) << Message;
+  };
+
+  auto ExpectFailure = [&](vfs::FileSystem &FS, StringRef Message) {
+EXPECT_TRUE(FS.openFileForRead("//root/a/f").getError()) << Message;
+EXPECT_TRUE(FS.status("//root/a/f").getError()) << Message;
+  };
+
+  {
+// `f` in both `a` and `b`
+
+// `fallthrough` tries `external-name` first, so should be `b`
+IntrusiveRefCntPtr Fallthrough =
+getFromYAMLString(FallthroughStr, Both);
+ASSERT_TRUE(Fallthrough.get() != nullptr);
+ExpectPath(*Fallthrough, "//root/b/f", "fallthrough, both exist");
+
+// `fallback` tries the original name first, so should be `a`
+IntrusiveRefCntPtr Fallback =
+getFromYAMLString(FallbackStr, Both);
+ASSERT_TRUE(Fallback.get() != nullptr);
+ExpectPath(*Fallback, "//root/a/f", "fallback, both exist");
+
+// `redirect-only` is the same as `fallthrough` but doesn't try the
+// original on failure, so no change here (ie. `b`)
+IntrusiveRefCntPtr Redirect =
+getFromYAMLString(RedirectOnlyStr, Both);
+ASSERT_TRUE(Redirect.get() != nullptr);
+ExpectPath(*Redirect, "//root/b/f", "redirect-only, both exist");
+  }
+
+  {
+// `f` in `a` only
+
+// Fallthrough to the original path, `a`
+IntrusiveRefCntPtr Fallthrough =
+getFromYAMLString(FallthroughStr, AOnly);
+ASSERT_TRUE(Fallthrough.get() != nullptr);
+ExpectPath(*Fallthrough, "//root/a/f", "fallthrough, a only");
+
+// Original 

[PATCH] D118652: Cleanup header dependencies in LLVMCore

2022-02-01 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay accepted this revision.
MaskRay added a comment.
This revision is now accepted and ready to land.

Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118652

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


[PATCH] D117937: [VFS] Add a "redirecting-with" field to overlays

2022-02-01 Thread Ben Barham via Phabricator via cfe-commits
bnbarham added a comment.

@keith I don't have commit access, would you be able to merge this if you're 
happy with it?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D117937

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


[PATCH] D117931: [Clang] Support `address_space` attribute in `#pragma clang attribute

2022-02-01 Thread Egor Zhdan via Phabricator via cfe-commits
egorzhdan abandoned this revision.
egorzhdan added a comment.

Thanks @aaron.ballman for your feedback. I will probably abandon this change 
until we have a more compelling reason to apply attributes to types via pragmas.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D117931

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


[PATCH] D111100: enable plugins for clang-tidy

2022-02-01 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.

LGTM, I think this approach is worth trying. I agree with you that we're in a 
bit of new territory here regarding the testing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D00

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


[PATCH] D101759: [PowerPC] Scalar IBM MASS library conversion pass

2022-02-01 Thread Bardia Mahjour via Phabricator via cfe-commits
bmahjour accepted this revision.
bmahjour added a comment.
This revision is now accepted and ready to land.

Apart from some minor inline comments this revision addresses all my 
outstanding comments. LGTM.




Comment at: llvm/lib/Target/PowerPC/PPCISelLowering.cpp:17747
+
+SDValue PPCTargetLowering::lowerLibCallType(const char *LibCallFloatName,
+const char *LibCallDoubleName,

[nit] a better name would be `lowerLibCallBasedOnType`



Comment at: 
llvm/test/CodeGen/PowerPC/pow-025-075-intrinsic-scalar-mass-fast.ll:246
+; CHECK-LNX-NEXT:lfs 2, .LCPI4_0@toc@l(3)
+; CHECK-LNX-NEXT:bl __xl_powf_finite
+; CHECK-LNX-NEXT:nop

masoud.ataei wrote:
> bmahjour wrote:
> > How come pow -> sqrt conversion didn't happen here? 
> Honestly, I am not sure why the conversion is not happening in this case. But 
> without this patch we will get `powf` call (the conversion is not happening 
> again). So this is a separate issue that someone needs to look at independent 
> of this patch.
Could you please make a note of this as a todo comment in each test that is 
affected?



Comment at: 
llvm/test/CodeGen/PowerPC/pow-025-075-nointrinsic-scalar-mass-fast.ll:22
+; CHECK-LNX-NEXT:lfs 2, .LCPI0_0@toc@l(3)
+; CHECK-LNX-NEXT:bl __xl_powf_finite
+; CHECK-LNX-NEXT:nop

masoud.ataei wrote:
> bmahjour wrote:
> > so pow->sqrt translation never happens for non-intrinsic `pow`. Is that 
> > expected? If so, are we planning to recognize these patterns inside 
> > PPCGenScalarMASSEntries in the future and do the translation as part of 
> > that transform?
> Correct, pow->sqrt translation is not happening for none intrinsic cases. It 
> is the case independent of this patch. I guess the reason is DAGCombiner only 
> apply this optimization on llvm intrinsics. This is an issue that either we 
> need to handle it in DAGCombiner (same as intrinsic one) or in MASS pass. I 
> feel DAGCombiner is a better option and I think this is also a separate 
> issue. 
Ok, I understand now. We'll have to come back to this later at some point.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101759

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


[PATCH] D118428: [clang-cl] Support the /JMC flag

2022-02-01 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen updated this revision to Diff 405018.
ychen marked 2 inline comments as done.
ychen added a comment.

- address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118428

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/cl-options.c
  llvm/include/llvm/CodeGen/CommandFlags.h
  llvm/include/llvm/CodeGen/Passes.h
  llvm/include/llvm/InitializePasses.h
  llvm/include/llvm/LinkAllPasses.h
  llvm/include/llvm/Target/TargetOptions.h
  llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
  llvm/lib/CodeGen/CMakeLists.txt
  llvm/lib/CodeGen/CodeGen.cpp
  llvm/lib/CodeGen/CommandFlags.cpp
  llvm/lib/CodeGen/JMCInstrumenter.cpp
  llvm/lib/CodeGen/TargetPassConfig.cpp
  llvm/test/CodeGen/X86/jmc-instrument.ll
  llvm/test/Instrumentation/JustMyCode/jmc-instrument-x86.ll
  llvm/test/Instrumentation/JustMyCode/jmc-instrument.ll
  llvm/tools/opt/opt.cpp

Index: llvm/tools/opt/opt.cpp
===
--- llvm/tools/opt/opt.cpp
+++ llvm/tools/opt/opt.cpp
@@ -498,7 +498,8 @@
   "generic-to-nvvm",  "expandmemcmp",
   "loop-reduce",  "lower-amx-type",
   "pre-amx-config",   "lower-amx-intrinsics",
-  "polyhedral-info",  "replace-with-veclib"};
+  "polyhedral-info",  "replace-with-veclib",
+  "jmc-instrument"};
   for (const auto &P : PassNamePrefix)
 if (Pass.startswith(P))
   return true;
@@ -572,6 +573,7 @@
   initializeHardwareLoopsPass(Registry);
   initializeTypePromotionPass(Registry);
   initializeReplaceWithVeclibLegacyPass(Registry);
+  initializeJMCInstrumenterPass(Registry);
 
 #ifdef BUILD_EXAMPLES
   initializeExampleIRTransforms(Registry);
Index: llvm/test/Instrumentation/JustMyCode/jmc-instrument.ll
===
--- /dev/null
+++ llvm/test/Instrumentation/JustMyCode/jmc-instrument.ll
@@ -0,0 +1,120 @@
+; RUN: opt -jmc-instrument -mtriple=x86_64-pc-windows-msvc  -S < %s | FileCheck %s
+; RUN: opt -jmc-instrument -mtriple=aarch64-pc-windows-msvc -S < %s | FileCheck %s
+; RUN: opt -jmc-instrument -mtriple=arm-pc-windows-msvc -S < %s | FileCheck %s
+
+; CHECK: $__JustMyCode_Default = comdat any
+
+; CHECK: @"__7DF23CF5_x@c" = internal unnamed_addr global i8 1, section ".msvcjmc", align 1, !dbg !0
+; CHECK: @"__A85D9D03_x@c" = internal unnamed_addr global i8 1, section ".msvcjmc", align 1, !dbg !5
+; CHECK: @llvm.used = appending global [1 x i8*] [i8* bitcast (void (i8*)* @__JustMyCode_Default to i8*)], section "llvm.metadata"
+
+; CHECK: define void @l1() !dbg !13 {
+; CHECK:   call void @__CheckForDebuggerJustMyCode(i8* noundef @"__7DF23CF5_x@c")
+; CHECK:   ret void
+; CHECK: }
+
+; CHECK: define void @l2() !dbg !17 {
+; CHECK:   call void @__CheckForDebuggerJustMyCode(i8* noundef @"__7DF23CF5_x@c")
+; CHECK:   ret void
+; CHECK: }
+
+; CHECK: define void @w1() !dbg !19 {
+; CHECK:   call void @__CheckForDebuggerJustMyCode(i8* noundef @"__A85D9D03_x@c")
+; CHECK:   ret void
+; CHECK: }
+
+; CHECK: define void @w2() !dbg !20 {
+; CHECK:   call void @__CheckForDebuggerJustMyCode(i8* noundef @"__A85D9D03_x@c")
+; CHECK:   ret void
+; CHECK: }
+
+; CHECK: define void @w3() !dbg !22 {
+; CHECK:   call void @__CheckForDebuggerJustMyCode(i8* noundef @"__A85D9D03_x@c")
+; CHECK:   ret void
+; CHECK: }
+
+; CHECK: define void @w4() !dbg !24 {
+; CHECK:   call void @__CheckForDebuggerJustMyCode(i8* noundef @"__A85D9D03_x@c")
+; CHECK:   ret void
+; CHECK: }
+
+; CHECK: declare void @__CheckForDebuggerJustMyCode(i8* noundef) unnamed_addr
+
+; CHECK: define void @__JustMyCode_Default(i8* noundef %0) unnamed_addr comdat {
+; CHECK:   ret void
+; CHECK: }
+
+; CHECK: !llvm.linker.options = !{!12}
+
+; CHECK: !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
+; CHECK: !1 = distinct !DIGlobalVariable(name: "__7DF23CF5_x@c", scope: !2, file: !3, type: !8, isLocal: true, isDefinition: true)
+; CHECK: !2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !4, splitDebugInlining: false, nameTableKind: None)
+; CHECK: !3 = !DIFile(filename: "a/x.c", directory: "/tmp")
+; CHECK: !4 = !{!0, !5}
+; CHECK: !5 = !DIGlobalVariableExpression(var: !6, expr: !DIExpression())
+; CHECK: !6 = distinct !DIGlobalVariable(name: "__A85D9D03_x@c", scope: !2, file: !7, type: !8, isLocal: true, isDefinition: true)
+; CHECK: !7 = !DIFile(filename: "./x.c", directory: "C:ab")
+; CHECK: !8 = !DIBasicType(name: "unsigned char", size: 8, encoding: DW_ATE_unsigned_char, flags: DIFlagArtificial)
+; CHECK: !9 = !{i32 2, !"CodeView", i32 1}
+; CHECK: !10 = !{i32 2,

[PATCH] D118428: [clang-cl] Support the /JMC flag

2022-02-01 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added inline comments.



Comment at: llvm/lib/CodeGen/CommandFlags.cpp:462
+  static cl::opt EnableJMCInstrument(
+  "enable-jmc-instrument",
+  cl::desc("Instrument functions with a call to 
__CheckForDebuggerJustMyCode"),

hans wrote:
> ychen wrote:
> > hans wrote:
> > > Other "on/off" options don't seem to have "enable" in the name or flag 
> > > spelling, e.g. "-strict-dwarf", not "-enable-strict-dwarf". Maybe this 
> > > should be just "-jmc-instrument" and JMCInstrument?
> > The "-jmc-instrument" is already used by the pass itself (`#define 
> > DEBUG_TYPE "jmc-instrument"`). The `DEBUG_TYPE` one enables `opt 
> > -jmc-instrument`; this makes `llc -enable-jmc-instrument` to run the pass 
> > in IR codegen pipeline.
> > 
> > Just renamed `cl::opt EnableJMCInstrument` to `cl::opt 
> > JMCInstrument`.
> Maybe the fact that -jmc-instrument is used by the IR pass is a hint that 
> there shouldn't be an llc option for this, then? Looking at the other options 
> here, they're all about codegen features, whereas the instrumentation in this 
> patch really happens at a higher level.
There are three kinds of passes (each in a separate pipeline), in the order of 
execution: IR optimization passes, IR codegen passes (some examples are here: 
https://github.com/llvm/llvm-project/blob/1d0244aed78114d5bd03ec4930d7687d6e587f99/llvm/include/llvm/CodeGen/MachinePassRegistry.def#L38-L51
 and 
https://github.com/llvm/llvm-project/blob/1d0244aed78114d5bd03ec4930d7687d6e587f99/llvm/include/llvm/CodeGen/MachinePassRegistry.def#L106-L121)
 and MIR codegen passes. The JMC pass is an IR codegen passes. It runs within 
the codegen phase, but it transforms IR and it is tested using the `opt` tool. 
The llc option is for testing that the pass could be enabled using 
`TargetOptions::JMCInstrument` (clang uses this), the change in 
`llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp` and this option enables LTO+JMC 
with `lld -mllvm -enable-jmc-instrument`. 



Comment at: llvm/lib/CodeGen/JMCInstrumenter.cpp:145
+  LLVMContext &Ctx = M.getContext();
+  bool UseX86FastCall = Triple(M.getTargetTriple()).getArch() == Triple::x86;
+

hans wrote:
> I still worry a bit about the target-specific code here. Normally, IR passes 
> don't have any target-specific knowledge, but ask classes such as 
> TargetTransformInfo for target-specific details, or possibly take them as 
> input to the pass. For example, see llvm/lib/Transforms/CFGuard/CFGuard.cpp
> 
> I'm also not sure that lib/CodeGen/ is the right place for this pass, since 
> most files there seem to be machine-IR passes. Maybe the natural place for 
> this would be lib/Transforms/Instrumentation/? Is there some good pass we can 
> compare this with?
> I still worry a bit about the target-specific code here. Normally, IR passes 
> don't have any target-specific knowledge, but ask classes such as 
> TargetTransformInfo for target-specific details, or possibly take them as 
> input to the pass. For example, see llvm/lib/Transforms/CFGuard/CFGuard.cpp
Understood. `TargetTransformInfo` is mostly for the "IR optimization passes". 
The JMC pass is "IR codegen passes", it is more similar to `CodeGenPrepare` 
pass than any "IR optimization passes". I think we could move the 
target-specific stuff into the `TargetPassConfig` & its derived classes, not in 
this patch, but the following ELF port one. WDYT?



Comment at: llvm/lib/CodeGen/JMCInstrumenter.cpp:147
+
+  auto GetOrCreateCheckFunctionDecl = [&, Decl = FunctionCallee()]() mutable {
+if (Decl)

hans wrote:
> This kind of mutable lambda feels pretty subtle to me. I think something like 
> the below would be more straight-forward.
> 
> ```
> Function *CheckFunction = nullptr;
> for (...) {
>   ...
>   if (!CheckFunction) {
> // Create the decl here.
>   }
> }
> ```
> 
> But if you strongly prefer the lambda, I suppose it's okay.
yep, sounds good.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118428

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


[clang] f6ce456 - [clang] Correctly(?) handle placeholder types in ExprRequirements.

2022-02-01 Thread Arthur O'Dwyer via cfe-commits

Author: Arthur O'Dwyer
Date: 2022-02-01T15:16:17-05:00
New Revision: f6ce456707898f0ae2c70748e896130e1c897960

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

LOG: [clang] Correctly(?) handle placeholder types in ExprRequirements.

Bug #52905 was originally papered over in a different way, but
I believe this is the actually proper fix, or at least closer to
it. We need to detect placeholder types as close to the front-end
as possible, and cause them to fail constraints, rather than letting
them persist into later stages.

Fixes #52905.
Fixes #52909.
Fixes #53075.

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

Added: 
clang/test/SemaTemplate/pr52909.cpp

Modified: 
clang/lib/AST/ASTContext.cpp
clang/lib/Sema/SemaOverload.cpp
clang/lib/Sema/SemaTemplateInstantiate.cpp
clang/lib/Sema/TreeTransform.h
clang/test/SemaTemplate/constraints.cpp

Removed: 




diff  --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 139ea5ee47329..5fa2d46de89b2 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -3370,8 +3370,9 @@ QualType ASTContext::getBlockPointerType(QualType T) 
const {
 /// lvalue reference to the specified type.
 QualType
 ASTContext::getLValueReferenceType(QualType T, bool SpelledAsLValue) const {
-  assert(getCanonicalType(T) != OverloadTy &&
- "Unresolved overloaded function type");
+  assert((!T->isPlaceholderType() ||
+  T->isSpecificPlaceholderType(BuiltinType::UnknownAny)) &&
+ "Unresolved placeholder type");
 
   // Unique pointers, to guarantee there is only one pointer of a particular
   // structure.
@@ -3409,6 +3410,10 @@ ASTContext::getLValueReferenceType(QualType T, bool 
SpelledAsLValue) const {
 /// getRValueReferenceType - Return the uniqued reference to the type for an
 /// rvalue reference to the specified type.
 QualType ASTContext::getRValueReferenceType(QualType T) const {
+  assert((!T->isPlaceholderType() ||
+  T->isSpecificPlaceholderType(BuiltinType::UnknownAny)) &&
+ "Unresolved placeholder type");
+
   // Unique pointers, to guarantee there is only one pointer of a particular
   // structure.
   llvm::FoldingSetNodeID ID;

diff  --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index 483247aaa7c51..3fa192cedfa38 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -14320,7 +14320,8 @@ ExprResult Sema::BuildCallToMemberFunction(Scope *S, 
Expr *MemExprE,
 FoundDecl = MemExpr->getFoundDecl();
 Qualifier = MemExpr->getQualifier();
 UnbridgedCasts.restore();
-  } else if (auto *UnresExpr = dyn_cast(NakedMemExpr)) {
+  } else {
+UnresolvedMemberExpr *UnresExpr = cast(NakedMemExpr);
 Qualifier = UnresExpr->getQualifier();
 
 QualType ObjectType = UnresExpr->getBaseType();
@@ -14433,9 +14434,7 @@ ExprResult Sema::BuildCallToMemberFunction(Scope *S, 
Expr *MemExprE,
 }
 
 MemExpr = cast(MemExprE->IgnoreParens());
-  } else
-// Unimaged NakedMemExpr type.
-return ExprError();
+  }
 
   QualType ResultType = Method->getReturnType();
   ExprValueKind VK = Expr::getValueKindForType(ResultType);

diff  --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp 
b/clang/lib/Sema/SemaTemplateInstantiate.cpp
index 7c6bb4c8a5f80..6de486be8f167 100644
--- a/clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -1943,6 +1943,9 @@ 
TemplateInstantiator::TransformExprRequirement(concepts::ExprRequirement *Req) {
 if (ExprInst.isInvalid())
   return nullptr;
 ExprResult TransExprRes = TransformExpr(E);
+if (!TransExprRes.isInvalid() && !Trap.hasErrorOccurred() &&
+TransExprRes.get()->hasPlaceholderType())
+  TransExprRes = SemaRef.CheckPlaceholderExpr(TransExprRes.get());
 if (TransExprRes.isInvalid() || Trap.hasErrorOccurred())
   TransExpr = createSubstDiag(SemaRef, Info, [&](llvm::raw_ostream &OS) {
 E->printPretty(OS, nullptr, SemaRef.getPrintingPolicy());

diff  --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index e43b3ca968ebb..5c37fcaaea13d 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -12494,6 +12494,8 @@ 
TreeTransform::TransformExprRequirement(concepts::ExprRequirement *Req)
 TransExpr = Req->getExprSubstitutionDiagnostic();
   else {
 ExprResult TransExprRes = getDerived().TransformExpr(Req->getExpr());
+if (TransExprRes.isUsable() && TransExprRes.get()->hasPlaceholderType())
+  TransExprRes = SemaRef.CheckPlaceholderExpr(TransExprRes.get());
 if (TransExprRes.isInvalid())
   return nullptr;
 TransExpr = TransExprRes.get();

diff  --git a/clang/test/SemaTemplate/constraints.cpp 
b/clang/

[PATCH] D118552: [clang] [concepts] Correctly(?) handle placeholder types in ExprRequirements.

2022-02-01 Thread Arthur O'Dwyer via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf6ce45670789: [clang] Correctly(?) handle placeholder types 
in ExprRequirements. (authored by arthur.j.odwyer).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118552

Files:
  clang/lib/AST/ASTContext.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Sema/TreeTransform.h
  clang/test/SemaTemplate/constraints.cpp
  clang/test/SemaTemplate/pr52909.cpp

Index: clang/test/SemaTemplate/pr52909.cpp
===
--- /dev/null
+++ clang/test/SemaTemplate/pr52909.cpp
@@ -0,0 +1,71 @@
+// RUN: %clang_cc1 -std=c++20 -verify %s
+// RUN: %clang_cc1 -std=c++2b -verify %s
+
+namespace PR52905 {
+template  concept C = true;
+
+struct A {
+  int begin();
+  int begin() const;
+};
+
+template 
+concept Beginable = requires (T t) {
+  { t.begin } -> C;
+  // expected-note@-1 {{because 't.begin' would be invalid: reference to non-static member function must be called}}
+};
+
+static_assert(Beginable); // expected-error {{static_assert failed}}
+ // expected-note@-1 {{does not satisfy 'Beginable'}}
+} // namespace PR52905
+
+namespace PR52909a {
+
+template constexpr bool B = true;
+template concept True = B;
+
+template 
+int foo(T t) requires requires { // expected-note {{candidate template ignored: constraints not satisfied}}
+{t.begin} -> True; // expected-note {{because 't.begin' would be invalid: reference to non-static member function must be called}}
+}
+{}
+
+struct A { int begin(); };
+auto x = foo(A()); // expected-error {{no matching function for call to 'foo'}}
+
+} // namespace PR52909a
+
+namespace PR52909b {
+
+template concept True = true;
+
+template concept C = requires {
+{ T::begin } -> True; // expected-note {{because 'T::begin' would be invalid: reference to overloaded function could not be resolved}}
+};
+
+struct A {
+static void begin(int);
+static void begin(double);
+};
+
+static_assert(C); // expected-error {{static_assert failed}}
+  // expected-note@-1 {{because 'PR52909b::A' does not satisfy 'C'}}
+
+} // namespace PR52909b
+
+namespace PR53075 {
+template concept True = true;
+
+template concept C = requires {
+{ &T::f } -> True; // expected-note {{because '&T::f' would be invalid: reference to overloaded function could not be resolved}}
+};
+
+struct S {
+int *f();
+int *f() const;
+};
+
+static_assert(C); // expected-error {{static_assert failed}}
+  // expected-note@-1 {{because 'PR53075::S' does not satisfy 'C'}}
+
+} // namespace PR53075
Index: clang/test/SemaTemplate/constraints.cpp
===
--- clang/test/SemaTemplate/constraints.cpp
+++ clang/test/SemaTemplate/constraints.cpp
@@ -24,35 +24,3 @@
   // FIXME: These diagnostics are excessive.
   static_assert(test == 1); // expected-note 2{{while}} expected-note 2{{during}}
 }
-
-namespace PR52905 {
-// A mock for std::convertible_to. Not complete support.
-template 
-concept convertible_to = __is_convertible_to(_From, _To); // expected-note {{evaluated to false}}
-
-template 
-class A {
-public:
-  using iterator = void **;
-
-  iterator begin();
-  const iterator begin() const;
-};
-
-template 
-concept Beginable1 = requires(T t) {
-  { t.begin }
-  ->convertible_to; // expected-note {{not satisfied}}
-};
-
-static_assert(Beginable1>); // expected-error {{static_assert failed}}
-   // expected-note@-1 {{does not satisfy 'Beginable1'}}
-
-template 
-concept Beginable2 = requires(T t) {
-  { t.begin() }
-  ->convertible_to;
-};
-
-static_assert(Beginable2>);
-} // namespace PR52905
Index: clang/lib/Sema/TreeTransform.h
===
--- clang/lib/Sema/TreeTransform.h
+++ clang/lib/Sema/TreeTransform.h
@@ -12494,6 +12494,8 @@
 TransExpr = Req->getExprSubstitutionDiagnostic();
   else {
 ExprResult TransExprRes = getDerived().TransformExpr(Req->getExpr());
+if (TransExprRes.isUsable() && TransExprRes.get()->hasPlaceholderType())
+  TransExprRes = SemaRef.CheckPlaceholderExpr(TransExprRes.get());
 if (TransExprRes.isInvalid())
   return nullptr;
 TransExpr = TransExprRes.get();
Index: clang/lib/Sema/SemaTemplateInstantiate.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -1943,6 +1943,9 @@
 if (ExprInst.isInvalid())
   return nullptr;
 ExprResult TransExprRes = TransformExpr(E);
+if (!TransExprRes.isInvalid() && !Trap.hasErrorOccurred() &&
+TransExprRes.get()->hasPlaceholderType())
+  TransExprRes = SemaRef.CheckPlaceholderExpr(TransExprRes.ge

[clang] c0185ff - [clang] Don't typo-fix an expression in a SFINAE context.

2022-02-01 Thread Arthur O'Dwyer via cfe-commits

Author: Arthur O'Dwyer
Date: 2022-02-01T15:17:28-05:00
New Revision: c0185ffaec3cb0aa7677b13a898eaa485ef29421

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

LOG: [clang] Don't typo-fix an expression in a SFINAE context.

If this is a SFINAE context, then continuing to look up names
(in particular, to treat a non-function as a function, and then
do ADL) might too-eagerly complete a type that it's not safe to
complete right now. We should just say "okay, that's a substitution
failure" and not do any more work than absolutely required.

Fixes #52970.

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

Added: 
clang/test/SemaTemplate/pr52970.cpp

Modified: 
clang/lib/Sema/Sema.cpp
clang/lib/Sema/SemaExprMember.cpp

Removed: 




diff  --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp
index a5a62276043d..7b57c8da4e9c 100644
--- a/clang/lib/Sema/Sema.cpp
+++ b/clang/lib/Sema/Sema.cpp
@@ -2556,32 +2556,36 @@ bool Sema::tryToRecoverWithCall(ExprResult &E, const 
PartialDiagnostic &PD,
 bool (*IsPlausibleResult)(QualType)) {
   SourceLocation Loc = E.get()->getExprLoc();
   SourceRange Range = E.get()->getSourceRange();
-
-  QualType ZeroArgCallTy;
   UnresolvedSet<4> Overloads;
-  if (tryExprAsCall(*E.get(), ZeroArgCallTy, Overloads) &&
-  !ZeroArgCallTy.isNull() &&
-  (!IsPlausibleResult || IsPlausibleResult(ZeroArgCallTy))) {
-// At this point, we know E is potentially callable with 0
-// arguments and that it returns something of a reasonable type,
-// so we can emit a fixit and carry on pretending that E was
-// actually a CallExpr.
-SourceLocation ParenInsertionLoc = getLocForEndOfToken(Range.getEnd());
-bool IsMV = IsCPUDispatchCPUSpecificMultiVersion(E.get());
-Diag(Loc, PD) << /*zero-arg*/ 1 << IsMV << Range
-  << (IsCallableWithAppend(E.get())
-  ? FixItHint::CreateInsertion(ParenInsertionLoc, "()")
-  : FixItHint());
-if (!IsMV)
-  notePlausibleOverloads(*this, Loc, Overloads, IsPlausibleResult);
-
-// FIXME: Try this before emitting the fixit, and suppress diagnostics
-// while doing so.
-E = BuildCallExpr(nullptr, E.get(), Range.getEnd(), None,
-  Range.getEnd().getLocWithOffset(1));
-return true;
-  }
 
+  // If this is a SFINAE context, don't try anything that might trigger ADL
+  // prematurely.
+  if (!isSFINAEContext()) {
+QualType ZeroArgCallTy;
+if (tryExprAsCall(*E.get(), ZeroArgCallTy, Overloads) &&
+!ZeroArgCallTy.isNull() &&
+(!IsPlausibleResult || IsPlausibleResult(ZeroArgCallTy))) {
+  // At this point, we know E is potentially callable with 0
+  // arguments and that it returns something of a reasonable type,
+  // so we can emit a fixit and carry on pretending that E was
+  // actually a CallExpr.
+  SourceLocation ParenInsertionLoc = getLocForEndOfToken(Range.getEnd());
+  bool IsMV = IsCPUDispatchCPUSpecificMultiVersion(E.get());
+  Diag(Loc, PD) << /*zero-arg*/ 1 << IsMV << Range
+<< (IsCallableWithAppend(E.get())
+? FixItHint::CreateInsertion(ParenInsertionLoc,
+ "()")
+: FixItHint());
+  if (!IsMV)
+notePlausibleOverloads(*this, Loc, Overloads, IsPlausibleResult);
+
+  // FIXME: Try this before emitting the fixit, and suppress diagnostics
+  // while doing so.
+  E = BuildCallExpr(nullptr, E.get(), Range.getEnd(), None,
+Range.getEnd().getLocWithOffset(1));
+  return true;
+}
+  }
   if (!ForceComplain) return false;
 
   bool IsMV = IsCPUDispatchCPUSpecificMultiVersion(E.get());

diff  --git a/clang/lib/Sema/SemaExprMember.cpp 
b/clang/lib/Sema/SemaExprMember.cpp
index f67ef030feb7..dfd93aa4638d 100644
--- a/clang/lib/Sema/SemaExprMember.cpp
+++ b/clang/lib/Sema/SemaExprMember.cpp
@@ -1645,6 +1645,9 @@ static ExprResult LookupMemberExpr(Sema &S, LookupResult 
&R,
   << BaseType << int(IsArrow) << BaseExpr.get()->getSourceRange()
   << FixItHint::CreateReplacement(OpLoc, "->");
 
+  if (S.isSFINAEContext())
+return ExprError();
+
   // Recurse as an -> access.
   IsArrow = true;
   return LookupMemberExpr(S, R, BaseExpr, IsArrow, OpLoc, SS,

diff  --git a/clang/test/SemaTemplate/pr52970.cpp 
b/clang/test/SemaTemplate/pr52970.cpp
new file mode 100644
index ..7585fba41208
--- /dev/null
+++ b/clang/test/SemaTemplate/pr52970.cpp
@@ -0,0 +1,63 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++14 -verify %s
+// RUN: %clang_cc1 -fs

[PATCH] D117603: [clang] Don't typo-fix an expression in a SFINAE context

2022-02-01 Thread Arthur O'Dwyer via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc0185ffaec3c: [clang] Don't typo-fix an expression in a 
SFINAE context. (authored by arthur.j.odwyer).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D117603

Files:
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaExprMember.cpp
  clang/test/SemaTemplate/pr52970.cpp

Index: clang/test/SemaTemplate/pr52970.cpp
===
--- /dev/null
+++ clang/test/SemaTemplate/pr52970.cpp
@@ -0,0 +1,63 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++14 -verify %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++17 -verify %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++20 -verify=cxx20 %s
+// expected-no-diagnostics
+
+struct Incomplete;
+template  struct Holder { T t; };
+
+namespace DotFollowingFunctionName {
+struct Good {
+  struct Nested {
+int b;
+  } a;
+};
+
+struct Bad {
+  Holder a();
+};
+
+template 
+constexpr auto f(T t) -> decltype((t.a.b, true)) { return true; }
+constexpr bool f(...) { return false; }
+
+static_assert(DotFollowingFunctionName::f(Good{}), "");
+static_assert(!DotFollowingFunctionName::f(Bad{}), "");
+
+#if __cplusplus >= 202002L
+template 
+concept C = requires(T t) { t.a.b; };
+  // cxx20-note@-1 {{because 't.a.b' would be invalid: reference to non-static member function must be called}}
+
+static_assert(C);
+static_assert(!C);
+static_assert(C); // cxx20-error {{static_assert failed}}
+  // cxx20-note@-1 {{because 'DotFollowingFunctionName::Bad' does not satisfy 'C'}}
+#endif
+} // namespace DotFollowingFunctionName
+
+namespace DotFollowingPointer {
+struct Good {
+  int begin();
+};
+using Bad = Holder *;
+
+template 
+constexpr auto f(T t) -> decltype((t.begin(), true)) { return true; }
+constexpr bool f(...) { return false; }
+
+static_assert(DotFollowingPointer::f(Good{}), "");
+static_assert(!DotFollowingPointer::f(Bad{}), "");
+
+#if __cplusplus >= 202002L
+template 
+concept C = requires(T t) { t.begin(); };
+  // cxx20-note@-1 {{because 't.begin()' would be invalid: member reference type 'Holder *' is a pointer}}
+
+static_assert(C);
+static_assert(!C);
+static_assert(C); // cxx20-error {{static_assert failed}}
+  // cxx20-note@-1 {{because 'DotFollowingPointer::Bad' (aka 'Holder *') does not satisfy 'C'}}
+#endif
+} // namespace DotFollowingPointer
Index: clang/lib/Sema/SemaExprMember.cpp
===
--- clang/lib/Sema/SemaExprMember.cpp
+++ clang/lib/Sema/SemaExprMember.cpp
@@ -1645,6 +1645,9 @@
   << BaseType << int(IsArrow) << BaseExpr.get()->getSourceRange()
   << FixItHint::CreateReplacement(OpLoc, "->");
 
+  if (S.isSFINAEContext())
+return ExprError();
+
   // Recurse as an -> access.
   IsArrow = true;
   return LookupMemberExpr(S, R, BaseExpr, IsArrow, OpLoc, SS,
Index: clang/lib/Sema/Sema.cpp
===
--- clang/lib/Sema/Sema.cpp
+++ clang/lib/Sema/Sema.cpp
@@ -2556,32 +2556,36 @@
 bool (*IsPlausibleResult)(QualType)) {
   SourceLocation Loc = E.get()->getExprLoc();
   SourceRange Range = E.get()->getSourceRange();
-
-  QualType ZeroArgCallTy;
   UnresolvedSet<4> Overloads;
-  if (tryExprAsCall(*E.get(), ZeroArgCallTy, Overloads) &&
-  !ZeroArgCallTy.isNull() &&
-  (!IsPlausibleResult || IsPlausibleResult(ZeroArgCallTy))) {
-// At this point, we know E is potentially callable with 0
-// arguments and that it returns something of a reasonable type,
-// so we can emit a fixit and carry on pretending that E was
-// actually a CallExpr.
-SourceLocation ParenInsertionLoc = getLocForEndOfToken(Range.getEnd());
-bool IsMV = IsCPUDispatchCPUSpecificMultiVersion(E.get());
-Diag(Loc, PD) << /*zero-arg*/ 1 << IsMV << Range
-  << (IsCallableWithAppend(E.get())
-  ? FixItHint::CreateInsertion(ParenInsertionLoc, "()")
-  : FixItHint());
-if (!IsMV)
-  notePlausibleOverloads(*this, Loc, Overloads, IsPlausibleResult);
-
-// FIXME: Try this before emitting the fixit, and suppress diagnostics
-// while doing so.
-E = BuildCallExpr(nullptr, E.get(), Range.getEnd(), None,
-  Range.getEnd().getLocWithOffset(1));
-return true;
-  }
 
+  // If this is a SFINAE context, don't try anything that might trigger ADL
+  // prematurely.
+  if (!isSFINAEContext()) {
+QualType ZeroArgCallTy;
+if (tryExprAsCall(*E.get(), ZeroArgCallTy, Overloads) &&
+!ZeroArgCallTy.isNull() &&
+(!IsPlausibleResult || IsPlausibleResult(ZeroArgCallTy))) {
+  // At this point, we know E is potentially callable with 0
+  // arguments a

[PATCH] D118706: [clang-format] Correctly parse C99 digraphs: "<:", ":>", "<%", "%>", "%:", "%:%:".

2022-02-01 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks accepted this revision.
HazardyKnusperkeks added a comment.

What the fuck. I know of trigraphs, and that we got rid of them, but these...




Comment at: clang/lib/Format/Format.cpp:3246
+  // Turning on digraphs in standards before C++0x is error-prone, because e.g.
+  // the sequence "<::" will be inconditionally treated as "[:".
+  // Cf. Lexer::LexTokenInternal.

owenpan wrote:
> “unconditionally”?
yeah


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118706

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


[PATCH] D110869: [X86] Implement -fzero-call-used-regs option

2022-02-01 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment.

Hey! Looks like Diff 404763 for an x86 defconfig plus 
CONFIG_ZERO_CALL_USED_REGS=y starts booting! Looks like it panics though trying 
to launch `init`(pid 1) though.

  [0.702163] Run /bin/sh as init process
  [0.702913] Failed to execute /bin/sh (error -22)
  [0.703721] Run /sbin/init as init process
  [0.704454] Starting init: /sbin/init exists but couldn't execute it 
(error -22)
  [0.705702] Run /etc/init as init process
  [0.706390] Run /bin/init as init process
  [0.707037] Run /bin/sh as init process
  [0.707736] Starting init: /bin/sh exists but couldn't execute it (error 
-22)
  [0.708895] Kernel panic - not syncing: No working init found.  Try 
passing init= option to kernel. See Linux Documentation/admin-guide/init.rst 
for guidance.
  [0.711246] CPU: 1 PID: 1 Comm: sh Not tainted 5.16.0-12116-g74e25defe135 
#6
  [0.712426] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 
1.15.0-1 04/01/2014
  [0.713778] Call Trace:
  [0.714188]  
  [0.714578]  dump_stack_lvl+0x65/0x9a
  [0.715190]  panic+0x101/0x295
  [0.715743]  ? _printk+0x54/0x80
  [0.716297]  ? rest_init+0xd0/0xd0
  [0.716882]  kernel_init+0x18b/0x190
  [0.717525]  ret_from_fork+0x22/0x30
  [0.718138]  
  [0.721159] Kernel Offset: 0xe80 from 0x8100 (relocation 
range: 0x8000-0xbfff)
  [0.722977] ---[ end Kernel panic - not syncing: No working init found.  
Try passing init= option to kernel. See Linux 
Documentation/admin-guide/init.rst for guidance. ]---

If I disable `CONFIG_ZERO_CALL_USED_REGS=y`, I can launch userspace just fine. 
(`Error -22` corresponds to `EINVAL` FWIW).  Perhaps some kernel code related 
to launching init (or processes, generally) isn't happy with a zero'd register 
somewhere, or we have another codegen bug.  Either way, that needs to be 
investigated+fixed before merging.  Probably could sprinkle `subdir-ccflags-y 
+= -fzero_call_used_regs=skip` (or whatever) in various Makefiles to pinpoint 
which object file is affected, then take a look at the disassembly from there. 
(or add function attributes to get more fine grained).

It looks like the Kconfig detection for `CONFIG_CC_HAS_ZERO_CALL_USED_REGS` is 
working correctly now. i.e.

  $ ARCH=arm64 make LLVM=1 -j72 defconfig
  $ grep -rn ZERO_CALL_USED_REGS .config
  $ make LLVM=1 -j72 defconfig
  $ grep -rn ZERO_CALL_USED_REGS .config
  4230:CONFIG_CC_HAS_ZERO_CALL_USED_REGS=y
  4231:# CONFIG_ZERO_CALL_USED_REGS is not set

(LGTM)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110869

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


[PATCH] D110869: [X86] Implement -fzero-call-used-regs option

2022-02-01 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added inline comments.



Comment at: llvm/lib/CodeGen/PrologEpilogInserter.cpp:1269
+  const TargetFrameLowering &TFI = *MF.getSubtarget().getFrameLowering();
+  for (auto RestoreBlock : RestoreBlocks)
+TFI.emitZeroCallUsedRegs(RegsToZero, *RestoreBlock);

void wrote:
> nickdesaulniers wrote:
> > ```
> > for (MachineBasicBlock *RestoreBlock : RestoreBlocks)
> > ```
> I prefer `auto` unless absolutely necessary (or to avoid confusion).
What does the style guide say?
https://llvm.org/docs/CodingStandards.html#use-auto-type-deduction-to-make-code-more-readable
> Don’t “almost always” use auto

At the very least you aught to use `auto *` here rather than `auto`.
https://llvm.org/docs/CodingStandards.html#beware-unnecessary-copies-with-auto


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110869

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


  1   2   >