[PATCH] D103286: [clang-format] Add PPIndentWidth option

2021-05-28 Thread Gerhard Gappmeier via Phabricator via cfe-commits
gergap updated this revision to Diff 348453.
gergap added a comment.

fixing test issues


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103286

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/lib/Format/UnwrappedLineFormatter.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -3431,6 +3431,21 @@
   verifyFormat("a\f\\");
 }
 
+TEST_F(FormatTest, IndentsPPDirectiveWithPPIndentWidth) {
+  FormatStyle style = getChromiumStyle(FormatStyle::LK_Cpp);
+  style.IndentWidth = 4;
+  style.PPIndentWidth = 1;
+  style.IndentPPDirectives = FormatStyle::PPDIS_AfterHash;
+
+  verifyFormat("#ifdef __linux__\n"
+   "# define FOO\n"
+   "#endif\n"
+   "void foo() {\n"
+   "int x = 0;\n"
+   "}\n",
+   style);
+}
+
 TEST_F(FormatTest, IndentsPPDirectiveInReducedSpace) {
   verifyFormat("#define A(BB)", getLLVMStyleWithColumns(13));
   verifyFormat("#define A( \\\nBB)", getLLVMStyleWithColumns(12));
@@ -4080,6 +4095,7 @@
 FormatStyle Tabbed = Style;
 Tabbed.UseTab = FormatStyle::UT_Always;
 Tabbed.IndentWidth = 8;
+Tabbed.PPIndentWidth = 8;
 Tabbed.TabWidth = 8;
 verifyFormat("#ifdef _WIN32\n"
  "#\tdefine A 0\n"
@@ -12182,6 +12198,7 @@
 TEST_F(FormatTest, ConfigurableUseOfTab) {
   FormatStyle Tab = getLLVMStyleWithColumns(42);
   Tab.IndentWidth = 8;
+  Tab.PPIndentWidth = 8;
   Tab.UseTab = FormatStyle::UT_Always;
   Tab.AlignEscapedNewlines = FormatStyle::ENAS_Left;
 
@@ -12228,6 +12245,7 @@
 
   Tab.TabWidth = 4;
   Tab.IndentWidth = 4;
+  Tab.PPIndentWidth = 4;
   verifyFormat("class TabWidth4Indent4 {\n"
"\tvoid f() {\n"
"\t\tsomeFunction(parameter1,\n"
@@ -12248,6 +12266,7 @@
 
   Tab.TabWidth = 8;
   Tab.IndentWidth = 8;
+  Tab.PPIndentWidth = 8;
   EXPECT_EQ("/*\n"
 "\t  a\t\tcomment\n"
 "\t  in multiple lines\n"
@@ -12410,6 +12429,7 @@
   Tab.UseTab = FormatStyle::UT_ForContinuationAndIndentation;
   Tab.TabWidth = 8;
   Tab.IndentWidth = 8;
+  Tab.PPIndentWidth = 8;
   EXPECT_EQ("if ( && // q\n"
 "bb) // w\n"
 "\t;",
@@ -12447,6 +12467,7 @@
Tab);
   Tab.TabWidth = 4;
   Tab.IndentWidth = 4;
+  Tab.PPIndentWidth = 4;
   verifyFormat("class TabWidth4Indent4 {\n"
"\tvoid f() {\n"
"\t\tsomeFunction(parameter1,\n"
@@ -12465,6 +12486,7 @@
Tab);
   Tab.TabWidth = 8;
   Tab.IndentWidth = 8;
+  Tab.PPIndentWidth = 8;
   EXPECT_EQ("/*\n"
 "\t  a\t\tcomment\n"
 "\t  in multiple lines\n"
@@ -12649,6 +12671,7 @@
   Tab.UseTab = FormatStyle::UT_AlignWithSpaces;
   Tab.TabWidth = 8;
   Tab.IndentWidth = 8;
+  Tab.PPIndentWidth = 8;
   EXPECT_EQ("if ( && // q\n"
 "bb) // w\n"
 "\t;",
Index: clang/lib/Format/UnwrappedLineFormatter.cpp
===
--- clang/lib/Format/UnwrappedLineFormatter.cpp
+++ clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -57,7 +57,7 @@
 while (IndentForLevel.size() <= Line.Level)
   IndentForLevel.push_back(-1);
 if (Line.InPPDirective) {
-  Indent = Line.Level * Style.IndentWidth + AdditionalIndent;
+  Indent = Line.Level * Style.PPIndentWidth + AdditionalIndent;
 } else {
   IndentForLevel.resize(Line.Level + 1);
   Indent = getIndent(IndentForLevel, Line.Level);
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -664,6 +664,7 @@
 IO.mapOptional("PenaltyIndentedWhitespace",
Style.PenaltyIndentedWhitespace);
 IO.mapOptional("PointerAlignment", Style.PointerAlignment);
+IO.mapOptional("PPIndentWidth", Style.PPIndentWidth);
 IO.mapOptional("RawStringFormats", Style.RawStringFormats);
 IO.mapOptional("ReflowComments", Style.ReflowComments);
 IO.mapOptional("ShortNamespaceLines", Style.ShortNamespaceLines);
@@ -1021,6 +1022,7 @@
   LLVMStyle.IndentRequires = false;
   LLVMStyle.IndentWrappedFunctionNames = false;
   LLVMStyle.IndentWidth = 2;
+  LLVMStyle.PPIndentWidth = 2; // default to old value
   LLVMStyle.InsertTrailingCommas = FormatStyle::TCS_None;
   LLVMStyle.JavaScriptQuotes = FormatStyle::JSQS_Leave;
   LLVMStyle.JavaScriptWrapImports = true;
@@ -1263,6 +1265,7 @@
 ChromiumStyle.BreakAfterJavaFieldAnnotations = true;
 ChromiumStyle.ContinuationIndentWidth = 8;
 ChromiumStyle.IndentWidth = 4;
+ChromiumStyle.PPIndentWidth = 4; //

[PATCH] D102517: [clang] Add support for the "abstract" contextual keyword of MSVC

2021-05-28 Thread Abbas Sabra via Phabricator via cfe-commits
AbbasSabra added a comment.

Thanks for the review! Can you take care of merging the patch? I don't have 
access.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102517

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


[PATCH] D102873: [clang] [MinGW] Fix gcc version detection/picking

2021-05-28 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

Also @mati865 FYI, phabricator has this odd behaviour, that if you press 
"accept" but don't write a textual message, the notification mail only gets 
sent to the person receivers but not to the mailing list - so readers of the 
list will only see the original messages and then e.g. when the patch is pushed 
with no messages inbetween, it can seem a bit puzzling. So it's usually good to 
fill it out with a plain "LGTM" message or something if accepting a review.




Comment at: clang/test/Driver/mingw-sysroot.cpp:21
 // RUN: env "PATH=%T/testroot-gcc/bin:%PATH%" %clang -target 
x86_64-w64-mingw32 -rtlib=platform -stdlib=libstdc++ --sysroot="" -c -### %s 
2>&1 | FileCheck -check-prefix=CHECK_TESTROOT_GCC %s
-// CHECK_TESTROOT_GCC: 
"{{.*}}/testroot-gcc{{/|}}lib{{/|}}gcc{{/|}}x86_64-w64-mingw32{{/|}}5.3-posix{{/|}}include{{/|}}c++"
-// CHECK_TESTROOT_GCC: 
"{{.*}}/testroot-gcc{{/|}}lib{{/|}}gcc{{/|}}x86_64-w64-mingw32{{/|}}5.3-posix{{/|}}include{{/|}}c++{{/|}}x86_64-w64-mingw32"
-// CHECK_TESTROOT_GCC: 
"{{.*}}/testroot-gcc{{/|}}lib{{/|}}gcc{{/|}}x86_64-w64-mingw32{{/|}}5.3-posix{{/|}}include{{/|}}c++{{/|}}backward"
+// CHECK_TESTROOT_GCC: 
"{{.*}}/testroot-gcc{{/|}}lib{{/|}}gcc{{/|}}x86_64-w64-mingw32{{/|}}10.2-posix{{/|}}include{{/|}}c++"
+// CHECK_TESTROOT_GCC: 
"{{.*}}/testroot-gcc{{/|}}lib{{/|}}gcc{{/|}}x86_64-w64-mingw32{{/|}}10.2-posix{{/|}}include{{/|}}c++{{/|}}x86_64-w64-mingw32"

MaskRay wrote:
> You may want to the adopt the `-SAME: {{^}} ` scheme I used in linux-cross.cpp
> 
> It can make sure the include paths are consecutive.
Thanks! Note for reference - I had to change the pattern `{{.*}}` into 
`{{[^"]*}}` (or better, `[[SYSROOT:[^"]+]]` as in linux-cross.cpp) for this to 
work properly, otherwise that wildcard can end up capturing the 
`"-internal-isystem"` which we want to spell out, if we want to force them to 
be consecutive. And not all of these are entirely consecutive, so the last one 
ends up without `-SAME`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102873

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


[PATCH] D103245: [clang-format] Fix PointerAlignmentRight with AlignConsecutiveDeclarations

2021-05-28 Thread Gerhard Gappmeier via Phabricator via cfe-commits
gergap updated this revision to Diff 348463.
gergap added a comment.

rebased on latest main and squashed the two commits


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103245

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
@@ -14881,6 +14881,7 @@
   FormatStyle Alignment = getLLVMStyle();
   Alignment.AlignConsecutiveMacros = FormatStyle::ACS_Consecutive;
   Alignment.AlignConsecutiveDeclarations = FormatStyle::ACS_None;
+  Alignment.PointerAlignment = FormatStyle::PAS_Right;
   verifyFormat("float const a = 5;\n"
"int oneTwoThree = 123;",
Alignment);
@@ -14916,8 +14917,8 @@
   verifyFormat("int  oneTwoThree{0}; // comment\n"
"unsigned oneTwo; // comment",
Alignment);
-  verifyFormat("unsigned int *  a;\n"
-   "int *   b;\n"
+  verifyFormat("unsigned int   *a;\n"
+   "int*b;\n"
"unsigned int Const *c;\n"
"unsigned int const *d;\n"
"unsigned int Const &e;\n"
@@ -15039,9 +15040,11 @@
"  doublebar();\n"
"};\n",
Alignment);
+
+  // PAS_RIGHT
   EXPECT_EQ("void SomeFunction(int parameter = 0) {\n"
 "  int const i   = 1;\n"
-"  int * j   = 2;\n"
+"  int  *j   = 2;\n"
 "  int   big = 1;\n"
 "\n"
 "  unsigned oneTwoThree = 123;\n"
@@ -15062,6 +15065,140 @@
"int ll=1;\n"
"}",
Alignment));
+  EXPECT_EQ("void SomeFunction(int parameter = 0) {\n"
+"  int const i   = 1;\n"
+"  int **j   = 2, ***k;\n"
+"  int  &k   = i;\n"
+"  int &&l   = i + j;\n"
+"  int   big = 1;\n"
+"\n"
+"  unsigned oneTwoThree = 123;\n"
+"  int  oneTwo  = 12;\n"
+"  method();\n"
+"  float k  = 2;\n"
+"  int   ll = 1;\n"
+"}",
+format("void SomeFunction(int parameter= 0) {\n"
+   " int const  i= 1;\n"
+   "  int **j=2,***k;\n"
+   "int &k=i;\n"
+   "int &&l=i+j;\n"
+   " int big  =  1;\n"
+   "\n"
+   "unsigned oneTwoThree  =123;\n"
+   "int oneTwo = 12;\n"
+   "  method();\n"
+   "float k= 2;\n"
+   "int ll=1;\n"
+   "}",
+   Alignment));
+
+  // PAS_LEFT
+  FormatStyle AlignmentLeft = Alignment;
+  AlignmentLeft.PointerAlignment = FormatStyle::PAS_Left;
+  EXPECT_EQ("void SomeFunction(int parameter = 0) {\n"
+"  int const i   = 1;\n"
+"  int*  j   = 2;\n"
+"  int   big = 1;\n"
+"\n"
+"  unsigned oneTwoThree = 123;\n"
+"  int  oneTwo  = 12;\n"
+"  method();\n"
+"  float k  = 2;\n"
+"  int   ll = 1;\n"
+"}",
+format("void SomeFunction(int parameter= 0) {\n"
+   " int const  i= 1;\n"
+   "  int *j=2;\n"
+   " int big  =  1;\n"
+   "\n"
+   "unsigned oneTwoThree  =123;\n"
+   "int oneTwo = 12;\n"
+   "  method();\n"
+   "float k= 2;\n"
+   "int ll=1;\n"
+   "}",
+   AlignmentLeft));
+  EXPECT_EQ("void SomeFunction(int parameter = 0) {\n"
+"  int const i   = 1;\n"
+"  int** j   = 2;\n"
+"  int&  k   = i;\n"
+"  int&& l   = i + j;\n"
+"  int   big = 1;\n"
+"\n"
+"  unsigned oneTwoThree = 123;\n"
+"  int  oneTwo  = 12;\n"
+"  method();\n"
+"  float k  = 2;\n"
+"  int   ll = 1;\n"
+"}",
+format("void SomeFunction(int parameter= 0) {\n"
+   " int const  i= 1;\n"
+   "  int **j=2;\n"
+   "int &k=i;\n"
+   "int &&l=i+j;\n"
+   " int big  =  1;\n"
+   "\n"
+   "unsigned oneTwoThree  =123;\n"
+   "int oneTwo = 12;\n"
+   "  method();\n"
+   "float k= 2;\n"
+   "int ll=1;\n"
+   "}",
+   AlignmentLeft));
+  // PAS_MIDDLE
+  Form

[PATCH] D102873: [clang] [MinGW] Fix gcc version detection/picking

2021-05-28 Thread Mateusz Mikuła via Phabricator via cfe-commits
mati865 added a comment.

Ah, so that explains why everyone sends LGTM text.
I'll try to remember it next time.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102873

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


[clang] f59cd8a - [clang] [MinGW] Fix gcc version detection/picking

2021-05-28 Thread Martin Storsjö via cfe-commits

Author: Martin Storsjö
Date: 2021-05-28T11:44:20+03:00
New Revision: f59cd8a4a606643e7248cecc239e0d229feb3320

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

LOG: [clang] [MinGW] Fix gcc version detection/picking

Actually compare each version to the version of the last chosen one.

There's no guarantee that the added test case does showcase the
previous issue (it depends on the order that directory entries
are returned when iterating), but with the issue fixed it should behave
deterministically in any case.

Also improve the match patterns in the mingw-sysroot.cpp test a bit.

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

Added: 

clang/test/Driver/Inputs/mingw_ubuntu_posix_tree/usr/lib/gcc/x86_64-w64-mingw32/10.2-posix/include-fixed/.keep

clang/test/Driver/Inputs/mingw_ubuntu_posix_tree/usr/lib/gcc/x86_64-w64-mingw32/10.2-posix/include/c++/backward/.keep

clang/test/Driver/Inputs/mingw_ubuntu_posix_tree/usr/lib/gcc/x86_64-w64-mingw32/10.2-posix/include/c++/x86_64-w64-mingw32/.keep

Modified: 
clang/lib/Driver/ToolChains/MinGW.cpp
clang/test/Driver/mingw-sysroot.cpp
clang/test/Driver/mingw.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/MinGW.cpp 
b/clang/lib/Driver/ToolChains/MinGW.cpp
index f6cead412236..4ebcdf6a9445 100644
--- a/clang/lib/Driver/ToolChains/MinGW.cpp
+++ b/clang/lib/Driver/ToolChains/MinGW.cpp
@@ -338,6 +338,7 @@ static bool findGccVersion(StringRef LibDir, std::string 
&GccLibDir,
   continue;
 if (CandidateVersion <= Version)
   continue;
+Version = CandidateVersion;
 Ver = std::string(VersionText);
 GccLibDir = LI->path();
   }

diff  --git 
a/clang/test/Driver/Inputs/mingw_ubuntu_posix_tree/usr/lib/gcc/x86_64-w64-mingw32/10.2-posix/include-fixed/.keep
 
b/clang/test/Driver/Inputs/mingw_ubuntu_posix_tree/usr/lib/gcc/x86_64-w64-mingw32/10.2-posix/include-fixed/.keep
new file mode 100644
index ..e69de29bb2d1

diff  --git 
a/clang/test/Driver/Inputs/mingw_ubuntu_posix_tree/usr/lib/gcc/x86_64-w64-mingw32/10.2-posix/include/c++/backward/.keep
 
b/clang/test/Driver/Inputs/mingw_ubuntu_posix_tree/usr/lib/gcc/x86_64-w64-mingw32/10.2-posix/include/c++/backward/.keep
new file mode 100644
index ..e69de29bb2d1

diff  --git 
a/clang/test/Driver/Inputs/mingw_ubuntu_posix_tree/usr/lib/gcc/x86_64-w64-mingw32/10.2-posix/include/c++/x86_64-w64-mingw32/.keep
 
b/clang/test/Driver/Inputs/mingw_ubuntu_posix_tree/usr/lib/gcc/x86_64-w64-mingw32/10.2-posix/include/c++/x86_64-w64-mingw32/.keep
new file mode 100644
index ..e69de29bb2d1

diff  --git a/clang/test/Driver/mingw-sysroot.cpp 
b/clang/test/Driver/mingw-sysroot.cpp
index 63f970fb1e10..8a2fb7d373a8 100644
--- a/clang/test/Driver/mingw-sysroot.cpp
+++ b/clang/test/Driver/mingw-sysroot.cpp
@@ -18,17 +18,17 @@
 // sysroot:
 
 // RUN: env "PATH=%T/testroot-gcc/bin:%PATH%" %clang -target 
x86_64-w64-mingw32 -rtlib=platform -stdlib=libstdc++ --sysroot="" -c -### %s 
2>&1 | FileCheck -check-prefix=CHECK_TESTROOT_GCC %s
-// CHECK_TESTROOT_GCC: 
"{{.*}}/testroot-gcc{{/|}}lib{{/|}}gcc{{/|}}x86_64-w64-mingw32{{/|}}5.3-posix{{/|}}include{{/|}}c++"
-// CHECK_TESTROOT_GCC: 
"{{.*}}/testroot-gcc{{/|}}lib{{/|}}gcc{{/|}}x86_64-w64-mingw32{{/|}}5.3-posix{{/|}}include{{/|}}c++{{/|}}x86_64-w64-mingw32"
-// CHECK_TESTROOT_GCC: 
"{{.*}}/testroot-gcc{{/|}}lib{{/|}}gcc{{/|}}x86_64-w64-mingw32{{/|}}5.3-posix{{/|}}include{{/|}}c++{{/|}}backward"
-// CHECK_TESTROOT_GCC: 
"{{.*}}/testroot-gcc{{/|}}x86_64-w64-mingw32{{/|}}include"
+// CHECK_TESTROOT_GCC: "-internal-isystem" 
"[[BASE:[^"]+]]/testroot-gcc{{/|}}lib{{/|}}gcc{{/|}}x86_64-w64-mingw32{{/|}}10.2-posix{{/|}}include{{/|}}c++"
+// CHECK_TESTROOT_GCC-SAME: {{^}} "-internal-isystem" 
"[[BASE]]/testroot-gcc{{/|}}lib{{/|}}gcc{{/|}}x86_64-w64-mingw32{{/|}}10.2-posix{{/|}}include{{/|}}c++{{/|}}x86_64-w64-mingw32"
+// CHECK_TESTROOT_GCC-SAME: {{^}} "-internal-isystem" 
"[[BASE]]/testroot-gcc{{/|}}lib{{/|}}gcc{{/|}}x86_64-w64-mingw32{{/|}}10.2-posix{{/|}}include{{/|}}c++{{/|}}backward"
+// CHECK_TESTROOT_GCC: "-internal-isystem" 
"[[BASE]]/testroot-gcc{{/|}}x86_64-w64-mingw32{{/|}}include"
 
 
 // If there's a matching sysroot next to the clang binary itself, prefer that
 // over a gcc in the path:
 
 // RUN: env "PATH=%T/testroot-gcc/bin:%PATH%" 
%T/testroot-clang/bin/x86_64-w64-mingw32-clang -target x86_64-w64-mingw32 
-rtlib=compiler-rt -stdlib=libstdc++ --sysroot="" -c -### %s 2>&1 | FileCheck 
-check-prefix=CHECK_TESTROOT_CLANG %s
-// CHECK_TESTROOT_CLANG: 
"{{.*}}/testroot-clang{{/|}}x86_64-w64-mingw32{{/|}}include"

[PATCH] D102873: [clang] [MinGW] Fix gcc version detection/picking

2021-05-28 Thread Martin Storsjö via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf59cd8a4a606: [clang] [MinGW] Fix gcc version 
detection/picking (authored by mstorsjo).

Changed prior to commit:
  https://reviews.llvm.org/D102873?vs=346850&id=348464#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102873

Files:
  clang/lib/Driver/ToolChains/MinGW.cpp
  
clang/test/Driver/Inputs/mingw_ubuntu_posix_tree/usr/lib/gcc/x86_64-w64-mingw32/10.2-posix/include-fixed/.keep
  
clang/test/Driver/Inputs/mingw_ubuntu_posix_tree/usr/lib/gcc/x86_64-w64-mingw32/10.2-posix/include/c++/backward/.keep
  
clang/test/Driver/Inputs/mingw_ubuntu_posix_tree/usr/lib/gcc/x86_64-w64-mingw32/10.2-posix/include/c++/x86_64-w64-mingw32/.keep
  clang/test/Driver/mingw-sysroot.cpp
  clang/test/Driver/mingw.cpp

Index: clang/test/Driver/mingw.cpp
===
--- clang/test/Driver/mingw.cpp
+++ clang/test/Driver/mingw.cpp
@@ -1,61 +1,61 @@
 // RUN: %clang -target i686-windows-gnu -rtlib=platform -c -### --sysroot=%S/Inputs/mingw_clang_tree/mingw32 %s 2>&1 | FileCheck -check-prefix=CHECK_MINGW_CLANG_TREE %s
-// CHECK_MINGW_CLANG_TREE: "{{.*}}/Inputs/mingw_clang_tree/mingw32{{/|}}i686-w64-mingw32{{/|}}include"
-// CHECK_MINGW_CLANG_TREE: "{{.*}}/Inputs/mingw_clang_tree/mingw32{{/|}}include"
+// CHECK_MINGW_CLANG_TREE: "[[BASE:[^"]+]]/Inputs/mingw_clang_tree/mingw32{{/|}}i686-w64-mingw32{{/|}}include"
+// CHECK_MINGW_CLANG_TREE: "[[BASE]]/Inputs/mingw_clang_tree/mingw32{{/|}}include"
 
 
 // RUN: %clang -target i686-windows-gnu -rtlib=platform -stdlib=libc++ -c -### --sysroot=%S/Inputs/mingw_clang_tree/mingw32 %s 2>&1 | FileCheck -check-prefix=CHECK_MINGW_CLANG_TREE_LIBCXX %s
-// CHECK_MINGW_CLANG_TREE_LIBCXX: "{{.*}}/Inputs/mingw_clang_tree/mingw32{{/|}}i686-w64-mingw32{{/|}}include{{/|}}c++{{/|}}v1"
+// CHECK_MINGW_CLANG_TREE_LIBCXX: "[[BASE:[^"]+]]/Inputs/mingw_clang_tree/mingw32{{/|}}i686-w64-mingw32{{/|}}include{{/|}}c++{{/|}}v1"
 
 
 // RUN: %clang -target i686-pc-windows-gnu -rtlib=platform -stdlib=libstdc++ -c -### --sysroot=%S/Inputs/mingw_mingw_org_tree/mingw %s 2>&1 | FileCheck -check-prefix=CHECK_MINGW_ORG_TREE %s
-// CHECK_MINGW_ORG_TREE: "{{.*}}/Inputs/mingw_mingw_org_tree/mingw{{/|}}lib{{/|}}gcc{{/|}}mingw32{{/|}}4.8.1{{/|}}include{{/|}}c++"
-// CHECK_MINGW_ORG_TREE: "{{.*}}/Inputs/mingw_mingw_org_tree/mingw{{/|}}lib{{/|}}gcc{{/|}}mingw32{{/|}}4.8.1{{/|}}include{{/|}}c++{{/|}}mingw32"
-// CHECK_MINGW_ORG_TREE: "{{.*}}{{/|}}Inputs/mingw_mingw_org_tree/mingw{{/|}}lib{{/|}}gcc{{/|}}mingw32{{/|}}4.8.1{{/|}}include{{/|}}c++{{/|}}backward"
-// CHECK_MINGW_ORG_TREE: "{{.*}}/Inputs/mingw_mingw_org_tree/mingw{{/|}}mingw32{{/|}}include"
-// CHECK_MINGW_ORG_TREE: {{.*}}/Inputs/mingw_mingw_org_tree/mingw{{/|}}include
+// CHECK_MINGW_ORG_TREE: "[[BASE:[^"]+]]/Inputs/mingw_mingw_org_tree/mingw{{/|}}lib{{/|}}gcc{{/|}}mingw32{{/|}}4.8.1{{/|}}include{{/|}}c++"
+// CHECK_MINGW_ORG_TREE: "[[BASE]]/Inputs/mingw_mingw_org_tree/mingw{{/|}}lib{{/|}}gcc{{/|}}mingw32{{/|}}4.8.1{{/|}}include{{/|}}c++{{/|}}mingw32"
+// CHECK_MINGW_ORG_TREE: "[[BASE]]/Inputs/mingw_mingw_org_tree/mingw{{/|}}lib{{/|}}gcc{{/|}}mingw32{{/|}}4.8.1{{/|}}include{{/|}}c++{{/|}}backward"
+// CHECK_MINGW_ORG_TREE: "[[BASE]]/Inputs/mingw_mingw_org_tree/mingw{{/|}}mingw32{{/|}}include"
+// CHECK_MINGW_ORG_TREE: "[[BASE]]/Inputs/mingw_mingw_org_tree/mingw{{/|}}include"
 
 
 // RUN: %clang -target i686-pc-windows-gnu -rtlib=platform -stdlib=libstdc++ -c -### --sysroot=%S/Inputs/mingw_mingw_builds_tree/mingw32 %s 2>&1 | FileCheck -check-prefix=CHECK_MINGW_BUILDS_TREE %s
-// CHECK_MINGW_BUILDS_TREE: "{{.*}}/Inputs/mingw_mingw_builds_tree/mingw32{{/|}}i686-w64-mingw32{{/|}}include{{/|}}c++"
-// CHECK_MINGW_BUILDS_TREE: "{{.*}}/Inputs/mingw_mingw_builds_tree/mingw32{{/|}}i686-w64-mingw32{{/|}}include{{/|}}c++{{/|}}i686-w64-mingw32"
-// CHECK_MINGW_BUILDS_TREE: "{{.*}}/Inputs/mingw_mingw_builds_tree/mingw32{{/|}}i686-w64-mingw32{{/|}}include{{/|}}c++{{/|}}backward"
-// CHECK_MINGW_BUILDS_TREE: "{{.*}}/Inputs/mingw_mingw_builds_tree/mingw32{{/|}}i686-w64-mingw32{{/|}}include"
+// CHECK_MINGW_BUILDS_TREE: "[[BASE:[^"]+]]/Inputs/mingw_mingw_builds_tree/mingw32{{/|}}i686-w64-mingw32{{/|}}include{{/|}}c++"
+// CHECK_MINGW_BUILDS_TREE: "[[BASE]]/Inputs/mingw_mingw_builds_tree/mingw32{{/|}}i686-w64-mingw32{{/|}}include{{/|}}c++{{/|}}i686-w64-mingw32"
+// CHECK_MINGW_BUILDS_TREE: "[[BASE]]/Inputs/mingw_mingw_builds_tree/mingw32{{/|}}i686-w64-mingw32{{/|}}include{{/|}}c++{{/|}}backward"
+// CHECK_MINGW_BUILDS_TREE

[PATCH] D101140: [WebAssembly][CodeGen] IR support for WebAssembly local variables

2021-05-28 Thread Andy Wingo via Phabricator via cfe-commits
wingo added inline comments.



Comment at: llvm/test/CodeGen/WebAssembly/ir-locals.ll:17-20
+ ; The DAG combiner infers that %reloaded is the same as %arg and
+ ; ultimately causes "local.get 0" to be emitted instead of
+ ; "local.get 1".
+ ; CHECK-NEXT: local.get 0

tlively wrote:
> It might be good to get the value from an external function call rather than 
> from an argument to prevent this transformation from happening.
Tx for feedback.  Actually it doesn't really matter where the value comes from; 
store-to-load forwarding happens regardless.  If it came from a call it would 
be allocated a local via the explicit locals pass, as a value with more than 
one use.

However I was able to inhibit this transformation with an opaque call, so I'll 
do that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101140

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


[PATCH] D101140: [WebAssembly][CodeGen] IR support for WebAssembly local variables

2021-05-28 Thread Andy Wingo via Phabricator via cfe-commits
wingo updated this revision to Diff 348467.
wingo added a comment.

Adapt test to insert compiler barrier.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101140

Files:
  llvm/include/llvm/CodeGen/MIRYamlMapping.h
  llvm/include/llvm/CodeGen/TargetFrameLowering.h
  llvm/lib/Target/WebAssembly/Utils/WebAssemblyUtilities.cpp
  llvm/lib/Target/WebAssembly/Utils/WebAssemblyUtilities.h
  llvm/lib/Target/WebAssembly/WebAssemblyExplicitLocals.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyFrameLowering.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyFrameLowering.h
  llvm/lib/Target/WebAssembly/WebAssemblyISD.def
  llvm/lib/Target/WebAssembly/WebAssemblyISelDAGToDAG.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyInstrInfo.td
  llvm/test/CodeGen/WebAssembly/ir-locals-stackid.ll
  llvm/test/CodeGen/WebAssembly/ir-locals.ll

Index: llvm/test/CodeGen/WebAssembly/ir-locals.ll
===
--- /dev/null
+++ llvm/test/CodeGen/WebAssembly/ir-locals.ll
@@ -0,0 +1,87 @@
+; RUN: llc < %s --mtriple=wasm32-unknown-unknown -asm-verbose=false | FileCheck %s
+
+%i32_cell = type i32 addrspace(1)*
+%i64_cell = type i64 addrspace(1)*
+%f32_cell = type float addrspace(1)*
+%f64_cell = type double addrspace(1)*
+
+; We have a set of tests in which we set a local and then reload the
+; local.  If the load immediately follows the set, the DAG combiner will
+; infer that the reloaded value is the same value that was set, which
+; isn't what we want to test.  To inhibit this optimization, we include
+; an opaque call between the store and the load.
+declare void @inhibit_store_to_load_forwarding()
+
+define i32 @ir_local_i32(i32 %arg) {
+ ; CHECK-LABEL: ir_local_i32:
+ ; CHECK-NEXT: .functype ir_local_i32 (i32) -> (i32)
+ %retval = alloca i32, addrspace(1)
+ ; CHECK-NEXT: .local i32
+ store i32 %arg, %i32_cell %retval
+ ; CHECK-NEXT: local.get 0
+ ; CHECK-NEXT: local.set 1
+ call void @inhibit_store_to_load_forwarding()
+ ; CHECK-NEXT: call inhibit_store_to_load_forwarding
+ %reloaded = load i32, %i32_cell %retval
+ ; CHECK-NEXT: local.get 1
+ ret i32 %reloaded
+ ; CHECK-NEXT: end_function
+}
+
+define i64 @ir_local_i64(i64 %arg) {
+ ; CHECK-LABEL: ir_local_i64:
+ ; CHECK-NEXT: .functype ir_local_i64 (i64) -> (i64)
+ %retval = alloca i64, addrspace(1)
+ ; CHECK-NEXT: .local i64
+ store i64 %arg, %i64_cell %retval
+ ; CHECK-NEXT: local.get 0
+ ; CHECK-NEXT: local.set 1
+ call void @inhibit_store_to_load_forwarding()
+ ; CHECK-NEXT: call inhibit_store_to_load_forwarding
+ %reloaded = load i64, %i64_cell %retval
+ ; See note in ir_local_i32.
+ ; CHECK-NEXT: local.get 1
+ ret i64 %reloaded
+ ; CHECK-NEXT: end_function
+}
+
+define float @ir_local_f32(float %arg) {
+ ; CHECK-LABEL: ir_local_f32:
+ ; CHECK-NEXT: .functype ir_local_f32 (f32) -> (f32)
+ %retval = alloca float, addrspace(1)
+ ; CHECK-NEXT: .local f32
+ store float %arg, %f32_cell %retval
+ ; CHECK-NEXT: local.get 0
+ ; CHECK-NEXT: local.set 1
+ call void @inhibit_store_to_load_forwarding()
+ ; CHECK-NEXT: call inhibit_store_to_load_forwarding
+ %reloaded = load float, %f32_cell %retval
+ ; CHECK-NEXT: local.get 1
+ ; CHECK-NEXT: end_function
+ ret float %reloaded
+}
+
+define double @ir_local_f64(double %arg) {
+ ; CHECK-LABEL: ir_local_f64:
+ ; CHECK-NEXT: .functype ir_local_f64 (f64) -> (f64)
+ %retval = alloca double, addrspace(1)
+ ; CHECK-NEXT: .local f64
+ store double %arg, %f64_cell %retval
+ ; CHECK-NEXT: local.get 0
+ ; CHECK-NEXT: local.set 1
+ call void @inhibit_store_to_load_forwarding()
+ ; CHECK-NEXT: call inhibit_store_to_load_forwarding
+ %reloaded = load double, %f64_cell %retval
+ ; CHECK-NEXT: local.get 1
+ ; CHECK-NEXT: end_function
+ ret double %reloaded
+}
+
+define void @ir_unreferenced_local() {
+ ; CHECK-LABEL: ir_unreferenced_local:
+ ; CHECK-NEXT: .functype ir_unreferenced_local () -> ()
+ %unused = alloca i32, addrspace(1)
+ ; CHECK-NEXT: .local i32
+ ret void
+ ; CHECK-NEXT: end_function
+}
Index: llvm/test/CodeGen/WebAssembly/ir-locals-stackid.ll
===
--- /dev/null
+++ llvm/test/CodeGen/WebAssembly/ir-locals-stackid.ll
@@ -0,0 +1,22 @@
+; RUN: llc -mtriple=wasm32-unknown-unknown -asm-verbose=false < %s | FileCheck %s --check-prefix=CHECKCG
+; RUN: llc -mtriple=wasm32-unknown-unknown -stop-after=finalize-isel < %s | FileCheck %s --check-prefix=CHECKISEL
+
+%f32_cell = type float addrspace(1)*
+
+; CHECKISEL-LABEL: name: ir_local_f32
+; CHECKISEL:   stack:
+; CHECKISEL:   id: 0, name: retval, type: default, offset: 1, size: 1, alignment: 4,
+; CHECKISEL-NEXT:  stack-id: wasm-local
+
+; CHECKCG-LABEL: ir_local_f32:
+; CHECKCG-NEXT: .functype ir_local_f32 (f32) -> (f32)
+; CHECKCG-NEXT: .local f32
+; CHECKCG-NEXT: local.get 0
+; CHECKCG-NEXT: local.set 1
+
+define float @ir_local_f32(float %arg

[PATCH] D101140: [WebAssembly][CodeGen] IR support for WebAssembly local variables

2021-05-28 Thread Andy Wingo 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 rG00ecf18979e3: [WebAssembly][CodeGen] IR support for 
WebAssembly local variables (authored by wingo).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101140

Files:
  llvm/include/llvm/CodeGen/MIRYamlMapping.h
  llvm/include/llvm/CodeGen/TargetFrameLowering.h
  llvm/lib/Target/WebAssembly/Utils/WebAssemblyUtilities.cpp
  llvm/lib/Target/WebAssembly/Utils/WebAssemblyUtilities.h
  llvm/lib/Target/WebAssembly/WebAssemblyExplicitLocals.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyFrameLowering.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyFrameLowering.h
  llvm/lib/Target/WebAssembly/WebAssemblyISD.def
  llvm/lib/Target/WebAssembly/WebAssemblyISelDAGToDAG.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyInstrInfo.td
  llvm/test/CodeGen/WebAssembly/ir-locals-stackid.ll
  llvm/test/CodeGen/WebAssembly/ir-locals.ll

Index: llvm/test/CodeGen/WebAssembly/ir-locals.ll
===
--- /dev/null
+++ llvm/test/CodeGen/WebAssembly/ir-locals.ll
@@ -0,0 +1,87 @@
+; RUN: llc < %s --mtriple=wasm32-unknown-unknown -asm-verbose=false | FileCheck %s
+
+%i32_cell = type i32 addrspace(1)*
+%i64_cell = type i64 addrspace(1)*
+%f32_cell = type float addrspace(1)*
+%f64_cell = type double addrspace(1)*
+
+; We have a set of tests in which we set a local and then reload the
+; local.  If the load immediately follows the set, the DAG combiner will
+; infer that the reloaded value is the same value that was set, which
+; isn't what we want to test.  To inhibit this optimization, we include
+; an opaque call between the store and the load.
+declare void @inhibit_store_to_load_forwarding()
+
+define i32 @ir_local_i32(i32 %arg) {
+ ; CHECK-LABEL: ir_local_i32:
+ ; CHECK-NEXT: .functype ir_local_i32 (i32) -> (i32)
+ %retval = alloca i32, addrspace(1)
+ ; CHECK-NEXT: .local i32
+ store i32 %arg, %i32_cell %retval
+ ; CHECK-NEXT: local.get 0
+ ; CHECK-NEXT: local.set 1
+ call void @inhibit_store_to_load_forwarding()
+ ; CHECK-NEXT: call inhibit_store_to_load_forwarding
+ %reloaded = load i32, %i32_cell %retval
+ ; CHECK-NEXT: local.get 1
+ ret i32 %reloaded
+ ; CHECK-NEXT: end_function
+}
+
+define i64 @ir_local_i64(i64 %arg) {
+ ; CHECK-LABEL: ir_local_i64:
+ ; CHECK-NEXT: .functype ir_local_i64 (i64) -> (i64)
+ %retval = alloca i64, addrspace(1)
+ ; CHECK-NEXT: .local i64
+ store i64 %arg, %i64_cell %retval
+ ; CHECK-NEXT: local.get 0
+ ; CHECK-NEXT: local.set 1
+ call void @inhibit_store_to_load_forwarding()
+ ; CHECK-NEXT: call inhibit_store_to_load_forwarding
+ %reloaded = load i64, %i64_cell %retval
+ ; See note in ir_local_i32.
+ ; CHECK-NEXT: local.get 1
+ ret i64 %reloaded
+ ; CHECK-NEXT: end_function
+}
+
+define float @ir_local_f32(float %arg) {
+ ; CHECK-LABEL: ir_local_f32:
+ ; CHECK-NEXT: .functype ir_local_f32 (f32) -> (f32)
+ %retval = alloca float, addrspace(1)
+ ; CHECK-NEXT: .local f32
+ store float %arg, %f32_cell %retval
+ ; CHECK-NEXT: local.get 0
+ ; CHECK-NEXT: local.set 1
+ call void @inhibit_store_to_load_forwarding()
+ ; CHECK-NEXT: call inhibit_store_to_load_forwarding
+ %reloaded = load float, %f32_cell %retval
+ ; CHECK-NEXT: local.get 1
+ ; CHECK-NEXT: end_function
+ ret float %reloaded
+}
+
+define double @ir_local_f64(double %arg) {
+ ; CHECK-LABEL: ir_local_f64:
+ ; CHECK-NEXT: .functype ir_local_f64 (f64) -> (f64)
+ %retval = alloca double, addrspace(1)
+ ; CHECK-NEXT: .local f64
+ store double %arg, %f64_cell %retval
+ ; CHECK-NEXT: local.get 0
+ ; CHECK-NEXT: local.set 1
+ call void @inhibit_store_to_load_forwarding()
+ ; CHECK-NEXT: call inhibit_store_to_load_forwarding
+ %reloaded = load double, %f64_cell %retval
+ ; CHECK-NEXT: local.get 1
+ ; CHECK-NEXT: end_function
+ ret double %reloaded
+}
+
+define void @ir_unreferenced_local() {
+ ; CHECK-LABEL: ir_unreferenced_local:
+ ; CHECK-NEXT: .functype ir_unreferenced_local () -> ()
+ %unused = alloca i32, addrspace(1)
+ ; CHECK-NEXT: .local i32
+ ret void
+ ; CHECK-NEXT: end_function
+}
Index: llvm/test/CodeGen/WebAssembly/ir-locals-stackid.ll
===
--- /dev/null
+++ llvm/test/CodeGen/WebAssembly/ir-locals-stackid.ll
@@ -0,0 +1,22 @@
+; RUN: llc -mtriple=wasm32-unknown-unknown -asm-verbose=false < %s | FileCheck %s --check-prefix=CHECKCG
+; RUN: llc -mtriple=wasm32-unknown-unknown -stop-after=finalize-isel < %s | FileCheck %s --check-prefix=CHECKISEL
+
+%f32_cell = type float addrspace(1)*
+
+; CHECKISEL-LABEL: name: ir_local_f32
+; CHECKISEL:   stack:
+; CHECKISEL:   id: 0, name: retval, type: default, offset: 1, size: 1, alignment: 4,
+; CHECKISEL-NEXT:  stack-id: wasm-local
+
+; CHECKCG-LABEL: ir_local_f32:
+; CHECKCG-NEXT: .functype ir_local_f3

[PATCH] D92639: [analyzer] Add control flow arrows to the analyzer's HTML reports

2021-05-28 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko updated this revision to Diff 348479.
vsavchenko added a comment.

Fix IE issue and rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92639

Files:
  clang/include/clang/Analysis/PathDiagnostic.h
  clang/lib/Rewrite/HTMLRewrite.cpp
  clang/lib/StaticAnalyzer/Core/BugReporter.cpp
  clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
  clang/test/Analysis/html_diagnostics/control-arrows.cpp

Index: clang/test/Analysis/html_diagnostics/control-arrows.cpp
===
--- /dev/null
+++ clang/test/Analysis/html_diagnostics/control-arrows.cpp
@@ -0,0 +1,27 @@
+// RUN: rm -fR %t
+// RUN: mkdir %t
+// RUN: %clang_analyze_cc1 -analyzer-checker=core \
+// RUN:-analyzer-output=html -o %t -verify %s
+// RUN: cat %t/report-*.html | FileCheck %s
+
+int dereference(int *x) {
+  return *x; // expected-warning{{Dereference of null pointer (loaded from variable 'x')}}
+}
+
+int foobar(bool cond, int *x) {
+  if (cond)
+x = 0;
+  return dereference(x);
+}
+
+// CHECK:  
+// CHECK-NOT:  
+// CHECK:
+// CHECK-NEXT: 
+//
+// Except for arrows we still want to have grey bubbles with control notes.
+// CHECK:  2
+// CHECK-SAME:   Taking true branch
Index: clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
===
--- clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
+++ clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
@@ -27,6 +27,7 @@
 #include "clang/Rewrite/Core/Rewriter.h"
 #include "clang/StaticAnalyzer/Core/PathDiagnosticConsumers.h"
 #include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/Sequence.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/iterator_range.h"
@@ -77,60 +78,78 @@
   void FlushDiagnosticsImpl(std::vector &Diags,
 FilesMade *filesMade) override;
 
-  StringRef getName() const override {
-return "HTMLDiagnostics";
-  }
+  StringRef getName() const override { return "HTMLDiagnostics"; }
 
   bool supportsCrossFileDiagnostics() const override {
 return SupportsCrossFileDiagnostics;
   }
 
-  unsigned ProcessMacroPiece(raw_ostream &os,
- const PathDiagnosticMacroPiece& P,
+  unsigned ProcessMacroPiece(raw_ostream &os, const PathDiagnosticMacroPiece &P,
  unsigned num);
 
+  unsigned ProcessControlFlowPiece(Rewriter &R, FileID BugFileID,
+   const PathDiagnosticControlFlowPiece &P,
+   unsigned Number);
+
   void HandlePiece(Rewriter &R, FileID BugFileID, const PathDiagnosticPiece &P,
const std::vector &PopUpRanges, unsigned num,
unsigned max);
 
-  void HighlightRange(Rewriter& R, FileID BugFileID, SourceRange Range,
+  void HighlightRange(Rewriter &R, FileID BugFileID, SourceRange Range,
   const char *HighlightStart = "",
   const char *HighlightEnd = "");
 
-  void ReportDiag(const PathDiagnostic& D,
-  FilesMade *filesMade);
+  void ReportDiag(const PathDiagnostic &D, FilesMade *filesMade);
 
   // Generate the full HTML report
-  std::string GenerateHTML(const PathDiagnostic& D, Rewriter &R,
-   const SourceManager& SMgr, const PathPieces& path,
+  std::string GenerateHTML(const PathDiagnostic &D, Rewriter &R,
+   const SourceManager &SMgr, const PathPieces &path,
const char *declName);
 
   // Add HTML header/footers to file specified by FID
-  void FinalizeHTML(const PathDiagnostic& D, Rewriter &R,
-const SourceManager& SMgr, const PathPieces& path,
+  void FinalizeHTML(const PathDiagnostic &D, Rewriter &R,
+const SourceManager &SMgr, const PathPieces &path,
 FileID FID, const FileEntry *Entry, const char *declName);
 
   // Rewrite the file specified by FID with HTML formatting.
-  void RewriteFile(Rewriter &R, const PathPieces& path, FileID FID);
+  void RewriteFile(Rewriter &R, const PathPieces &path, FileID FID);
 
+  PathGenerationScheme getGenerationScheme() const override {
+return Everything;
+  }
 
 private:
+  void addArrowSVGs(Rewriter &R, FileID BugFileID, unsigned NumberOfArrows);
+
   /// \return Javascript for displaying shortcuts help;
   StringRef showHelpJavascript();
 
   /// \return Javascript for navigating the HTML report using j/k keys.
   StringRef generateKeyboardNavigationJavascript();
 
+  /// \return Javascript for drawing control-flow arrows.
+  StringRef generateArrowDrawingJavascript();
+
   /// \return JavaScript for an option to only show relevant lines.
-  std::string showRelevantLinesJavascript(
-const PathDiagnostic &D, const PathPieces &path);
+  std::string showRe

[PATCH] D92928: [analyzer] Highlight arrows for currently selected event

2021-05-28 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko updated this revision to Diff 348480.
vsavchenko added a comment.
Herald added a subscriber: manas.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92928

Files:
  clang/lib/Rewrite/HTMLRewrite.cpp
  clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
  clang/test/Analysis/html_diagnostics/control-arrows.cpp

Index: clang/test/Analysis/html_diagnostics/control-arrows.cpp
===
--- clang/test/Analysis/html_diagnostics/control-arrows.cpp
+++ clang/test/Analysis/html_diagnostics/control-arrows.cpp
@@ -16,10 +16,13 @@
 
 // CHECK:  
-// CHECK-NOT:  
+// CHECK-COUNT-9:  
+// CHECK-NOT:  
 // CHECK:
 // CHECK-NEXT: 
+// CHECK-NEXT: 
+// CHECK-NEXT: const arrowIndices = [ 9,8,6,5,3,2,0 ]
+// CHECK-NEXT: 
 //
 // Except for arrows we still want to have grey bubbles with control notes.
 // CHECK:   {
+  using Base = std::vector;
+
+public:
+  ArrowMap(unsigned Size) : Base(Size, 0) {}
+  unsigned getTotalNumberOfArrows() const { return at(0); }
+};
+
+llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const ArrowMap &Indices) {
+  OS << "[ ";
+  llvm::interleave(Indices, OS, ",");
+  return OS << " ]";
+}
+
 } // namespace
 
 void ento::createHTMLDiagnosticConsumer(
@@ -761,6 +779,7 @@
   unsigned NumberOfArrows = 0;
   // Stores the count of the regular piece indices.
   std::map IndexMap;
+  ArrowMap ArrowIndices(TotalRegularPieces + 1);
 
   // Stores the different ranges where we have reported something.
   std::vector PopUpRanges;
@@ -779,13 +798,30 @@
 } else if (isArrowPiece(Piece)) {
   NumberOfArrows = ProcessControlFlowPiece(
   R, FID, cast(Piece), NumberOfArrows);
+  ArrowIndices[NumRegularPieces] = NumberOfArrows;
 
 } else {
   HandlePiece(R, FID, Piece, PopUpRanges, NumRegularPieces,
   TotalRegularPieces);
   --NumRegularPieces;
+  ArrowIndices[NumRegularPieces] = ArrowIndices[NumRegularPieces + 1];
 }
   }
+  ArrowIndices[0] = NumberOfArrows;
+
+  // At this point ArrowIndices represent the following data structure:
+  //   [a_0, a_1, ..., a_N]
+  // where N is the number of events in the path.
+  //
+  // Then for every event with index i \in [0, N - 1], we can say that
+  // arrows with indices \in [a_(i+1), a_i) correspond to that event.
+  // We can say that because arrows with these indices appeared in the
+  // path in between the i-th and the (i+1)-th events.
+  assert(ArrowIndices.back() == 0 &&
+ "No arrows should be after the last event");
+  // This assertion also guarantees that all indices in are <= NumberOfArrows.
+  assert(llvm::is_sorted(ArrowIndices, std::greater()) &&
+ "Incorrect arrow indices map");
 
   // Secondary indexing if we are having multiple pop-ups between two notes.
   // (e.g. [(13) 'a' is 'true'];  [(13.1) 'b' is 'false'];  [(13.2) 'c' is...)
@@ -819,7 +855,7 @@
   html::EscapeText(R, FID);
   html::AddLineNumbers(R, FID);
 
-  addArrowSVGs(R, FID, NumberOfArrows);
+  addArrowSVGs(R, FID, ArrowIndices);
 
   // If we have a preprocessor, relex the file and syntax highlight.
   // We might not have a preprocessor if we come from a deserialized AST file,
@@ -1088,7 +1124,7 @@
 }
 
 void HTMLDiagnostics::addArrowSVGs(Rewriter &R, FileID BugFileID,
-   unsigned NumberOfArrows) {
+   const ArrowMap &ArrowIndices) {
   std::string S;
   llvm::raw_string_ostream OS(S);
 
@@ -1103,27 +1139,52 @@
   pointer-events: none;
   overflow: visible
   }
+  .arrow {
+  stroke-opacity: 0.2;
+  stroke-width: 1;
+  marker-end: url(#arrowhead);
+  }
+
+  .arrow.selected {
+  stroke-opacity: 0.6;
+  stroke-width: 2;
+  marker-end: url(#arrowheadSelected);
+  }
+
+  .arrowhead {
+  orient: auto;
+  stroke: none;
+  opacity: 0.6;
+  fill: blue;
+  }
 
 http://www.w3.org/2000/svg";>
   
-
+
+  
+
+
   
 
   
-  
+  
 )<<<";
 
-  for (unsigned Index : llvm::seq(0u, NumberOfArrows)) {
-OS << "\n";
+  for (unsigned Index : llvm::seq(0u, ArrowIndices.getTotalNumberOfArrows())) {
+OS << "\n";
   }
 
   OS << R"<<<(
   
 
-)<<<";
+
+const arrowIndices = )<<<";
+
+  OS << ArrowIndices << "\n\n";
 
   R.InsertTextBefore(R.getSourceMgr().getLocForStartOfFile(BugFileID),
  OS.str());
@@ -1220,7 +1281,7 @@
 });
 
 var findNum = function() {
-var s = document.querySelector(".selected");
+var s = document.querySelector(".msg.selected");
 if (!s || s.id == "EndPath") {
 return 0;
 }
@@ -1235,6 +1296,7 @@
 el.classList.add("selected");
 window.scrollBy(0, el.getBoundingClientRect().top -
 (window.innerHeight / 2));
+highlightArrowsForSelectedEvent();
 }
 
 var move = function(num, up, numItem

[PATCH] D92639: [analyzer] Add control flow arrows to the analyzer's HTML reports

2021-05-28 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko added a comment.

In D92639#2785057 , @ASDenysPetrov 
wrote:

> @vsavchenko How about this?

Yep, thanks for reminding!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92639

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


[PATCH] D74265: [clang-format] Improve handling of C# attributes

2021-05-28 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

This issue seems to have caused a regression 
https://bugs.llvm.org/show_bug.cgi?id=50515, I understand we removed the rule 
because it was too aggressive, now its not aggressive enough.

I'm going to try and find some sort of compromise so we can gravitate to a 
solution that can work for both.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74265

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


[PATCH] D103307: [clang-format] successive C# attributes cause line breaking issues

2021-05-28 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay created this revision.
MyDeveloperDay added reviewers: jbcoe, krasimir, HazardyKnusperkeks, curdeius.
MyDeveloperDay added projects: clang, clang-format.
MyDeveloperDay requested review of this revision.

D74265: [clang-format] Improve handling of C# attributes 
 reduced the aggressiveness of line breaking 
following C# attributes, however this change removed any support for attributes 
on properties, causing significant ugliness to be introduced.

This revision goes some way to addressing that by re-introducing the more 
aggressive check to `mustBreakBefore()`, but constraining it to the most common 
cases where we use properties which should not impact the "caller info 
attributes"  or the "[In , Out]" decorations that are normally put on pinvoke

It does not address my additional concerns of the original change regarding 
multiple C# attributes, as these are somewhat incorrectly handled by virtue of 
the fact its not recognising the second attribute as an attribute at all. But 
instead thinking its an array.

The purpose of this revision is to get back to where we were for the most 
common of cases as a stepping stone to resolving this. However D74265: 
[clang-format] Improve handling of C# attributes 
 has broken a lot of C# code and this revision 
will go someway alone to addressing the majority.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D103307

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


Index: clang/unittests/Format/FormatTestCSharp.cpp
===
--- clang/unittests/Format/FormatTestCSharp.cpp
+++ clang/unittests/Format/FormatTestCSharp.cpp
@@ -247,6 +247,16 @@
   verifyFormat("[TestMethod]\n"
"public string Host { set; get; }");
 
+  // Adjacent attributes caused line wrapping issues
+  verifyFormat("[JsonProperty(\"foo\")]\n"
+   "public string Foo { set; get; }\n"
+   "[JsonProperty(\"bar\")]\n"
+   "public string Bar { set; get; }\n"
+   "[JsonProperty(\"bar\")]\n"
+   "protected string Bar { set; get; }\n"
+   "[JsonProperty(\"bar\")]\n"
+   "internal string Bar { set; get; }");
+
   verifyFormat("[TestMethod(\"start\", HelpText = \"Starts the server "
"listening on provided host\")]\n"
"public string Host { set; get; }");
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -3520,6 +3520,13 @@
   return false;
 if (Right.is(TT_CSharpGenericTypeConstraint))
   return true;
+
+// Break after C# [...] and before public/protected/private/internal.
+if (Left.is(TT_AttributeSquare) && Left.is(tok::r_square) &&
+(Right.isAccessSpecifier(/*ColonRequired=*/false) ||
+ Right.is(Keywords.kw_internal)))
+  return true;
+
   } else if (Style.Language == FormatStyle::LK_JavaScript) {
 // FIXME: This might apply to other languages and token kinds.
 if (Right.is(tok::string_literal) && Left.is(tok::plus) && Left.Previous &&


Index: clang/unittests/Format/FormatTestCSharp.cpp
===
--- clang/unittests/Format/FormatTestCSharp.cpp
+++ clang/unittests/Format/FormatTestCSharp.cpp
@@ -247,6 +247,16 @@
   verifyFormat("[TestMethod]\n"
"public string Host { set; get; }");
 
+  // Adjacent attributes caused line wrapping issues
+  verifyFormat("[JsonProperty(\"foo\")]\n"
+   "public string Foo { set; get; }\n"
+   "[JsonProperty(\"bar\")]\n"
+   "public string Bar { set; get; }\n"
+   "[JsonProperty(\"bar\")]\n"
+   "protected string Bar { set; get; }\n"
+   "[JsonProperty(\"bar\")]\n"
+   "internal string Bar { set; get; }");
+
   verifyFormat("[TestMethod(\"start\", HelpText = \"Starts the server "
"listening on provided host\")]\n"
"public string Host { set; get; }");
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -3520,6 +3520,13 @@
   return false;
 if (Right.is(TT_CSharpGenericTypeConstraint))
   return true;
+
+// Break after C# [...] and before public/protected/private/internal.
+if (Left.is(TT_AttributeSquare) && Left.is(tok::r_square) &&
+(Right.isAccessSpecifier(/*ColonRequired=*/false) ||
+ Right.is(Keywords.kw_internal)))
+  return true;
+
   } else if (Style.Language == FormatStyle::LK_JavaScript) {
 // FIXME: This might apply to other languages and token kinds.
 if (Right.is(tok::string_literal) &

[PATCH] D74265: [clang-format] Improve handling of C# attributes

2021-05-28 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

The second property in a class is putting the property on the same line

  [XmlIgnore] 
  public string property1 { get; set; }
  
  [XmlIgnore] public string property2{ get; set; }

as are all successive properties

Multiple properites are also not getting broken unless they are the first 
property

  [XmlIgnore] 
  [ScriptIgnore] 
  public string property1 { get; set; }
  
  [XmlIgnore] [ScriptIgnore] public string property2{ get; set; }

Ideally we want this all the time.

  [XmlIgnore] 
  [ScriptIgnore] 
  public string Url { get; set; }

In the original change @jbcoe  I think you were trying to fix the case where 
`void MethodA([In][Out] ref...` got broken, I presume into

  void MethodA([In]
 [Out] ref

Part of the problem although not a solution was that the `[` of the `[Out]` 
isn't even actually seen as an TT_AttributeSquare but instead as a 
TT_ArraySubscriptLSquare

  AnnotatedTokens(L=1):
   M=0 C=0 T=Unknown S=1 F=0 B=0 BK=0 P=0 Name=void L=4 PPK=2 FakeLParens= 
FakeRParens=0 II=0x1c0f418 Text='void'
   M=0 C=1 T=StartOfName S=1 F=0 B=0 BK=0 P=1020 Name=identifier L=15 PPK=2 
FakeLParens= FakeRParens=0 II=0x1c38cb0 Text='myFunction'
   M=0 C=0 T=Unknown S=0 F=0 B=0 BK=0 P=23 Name=l_paren L=16 PPK=2 FakeLParens= 
FakeRParens=0 II=0x0 Text='('
   M=0 C=1 T=AttributeSquare S=0 F=0 B=0 BK=0 P=140 Name=l_square L=17 PPK=2 
FakeLParens= FakeRParens=0 II=0x0 Text='['
   M=0 C=0 T=Unknown S=0 F=0 B=0 BK=0 P=79 Name=identifier L=19 PPK=2 
FakeLParens= FakeRParens=0 II=0x1c38cd0 Text='In'
   M=0 C=0 T=AttributeSquare S=0 F=0 B=0 BK=0 P=63 Name=r_square L=20 PPK=2 
FakeLParens= FakeRParens=0 II=0x0 Text=']'
   M=0 C=0 T=ArraySubscriptLSquare S=0 F=0 B=0 BK=0 P=240 Name=l_square L=21 
PPK=2 FakeLParens= FakeRParens=0 II=0x0 Text='['
   M=0 C=0 T=Unknown S=0 F=0 B=0 BK=0 P=259 Name=identifier L=24 PPK=2 
FakeLParens= FakeRParens=0 II=0x1c38cf0 Text='Out'
   M=0 C=0 T=Unknown S=0 F=0 B=0 BK=0 P=243 Name=r_square L=25 PPK=2 
FakeLParens= FakeRParens=0 II=0x0 Text=']'
   M=0 C=0 T=Unknown S=1 F=0 B=0 BK=0 P=43 Name=identifier L=27 PPK=2 
FakeLParens= FakeRParens=0 II=0x1c38d10 Text='a'
   M=0 C=0 T=Unknown S=0 F=0 B=0 BK=0 P=43 Name=r_paren L=28 PPK=2 FakeLParens= 
FakeRParens=0 II=0x0 Text=')'

That I think you move the handling of the newlines to the parsing rather than 
in the canBreakBefore/mustBreakBefore (i.e. you wrap the lines when you see it 
on the function)

But of course a property isn't a function and so this is why its not being 
handled correctly. Going from the overly aggressive to the the parsing model 
regressed the behaviour for properties with attributes (which is very common if 
you use Newtonsoft.Json)

See D103307: [clang-format] successive C# attributes cause line breaking issues 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74265

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


[PATCH] D103307: [clang-format] successive C# attributes cause line breaking issues

2021-05-28 Thread Jonathan B Coe via Phabricator via cfe-commits
jbcoe accepted this revision.
jbcoe added a comment.
This revision is now accepted and ready to land.

Thanks for this!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103307

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


[PATCH] D92639: [analyzer] Add control flow arrows to the analyzer's HTML reports

2021-05-28 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov accepted this revision.
ASDenysPetrov added a comment.
This revision is now accepted and ready to land.

OK, then. Let's land it!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92639

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


[PATCH] D92639: [analyzer] Add control flow arrows to the analyzer's HTML reports

2021-05-28 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko added a comment.

In D92639#2786648 , @ASDenysPetrov 
wrote:

> OK, then. Let's land it!

Can you please take a look at D92928  as well?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92639

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


[PATCH] D103307: [clang-format] successive C# attributes cause line breaking issues

2021-05-28 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

In D103307#2786645 , @jbcoe wrote:

> Thanks for this!

I tried to handle the multiple attributes using the "parsing technique" you 
used, instead of the "mustBreaking technique" but every time I do this I end up 
putting a newline after every array!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103307

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


[PATCH] D101140: [WebAssembly][CodeGen] IR support for WebAssembly local variables

2021-05-28 Thread Andy Wingo via Phabricator via cfe-commits
wingo updated this revision to Diff 348493.
wingo added a comment.
Herald added subscribers: foad, frasercrmck, kerbowa, luismarques, apazos, 
sameer.abuasal, s.egerton, Jim, jocewei, PkmX, the_o, brucehoult, 
MartinMosbeck, rogfer01, edward-jones, zzheng, MaskRay, jrtc27, niosHD, 
sabuasal, simoncook, johnrusso, rbar, asb, nhaehnle, jvesely, arsenm.

Fix build for RISC-V and AMDGPU.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101140

Files:
  llvm/include/llvm/CodeGen/MIRYamlMapping.h
  llvm/include/llvm/CodeGen/TargetFrameLowering.h
  llvm/lib/Target/AMDGPU/SIFrameLowering.cpp
  llvm/lib/Target/RISCV/RISCVFrameLowering.cpp
  llvm/lib/Target/WebAssembly/Utils/WebAssemblyUtilities.cpp
  llvm/lib/Target/WebAssembly/Utils/WebAssemblyUtilities.h
  llvm/lib/Target/WebAssembly/WebAssemblyExplicitLocals.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyFrameLowering.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyFrameLowering.h
  llvm/lib/Target/WebAssembly/WebAssemblyISD.def
  llvm/lib/Target/WebAssembly/WebAssemblyISelDAGToDAG.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyInstrInfo.td
  llvm/test/CodeGen/WebAssembly/ir-locals-stackid.ll
  llvm/test/CodeGen/WebAssembly/ir-locals.ll

Index: llvm/test/CodeGen/WebAssembly/ir-locals.ll
===
--- /dev/null
+++ llvm/test/CodeGen/WebAssembly/ir-locals.ll
@@ -0,0 +1,87 @@
+; RUN: llc < %s --mtriple=wasm32-unknown-unknown -asm-verbose=false | FileCheck %s
+
+%i32_cell = type i32 addrspace(1)*
+%i64_cell = type i64 addrspace(1)*
+%f32_cell = type float addrspace(1)*
+%f64_cell = type double addrspace(1)*
+
+; We have a set of tests in which we set a local and then reload the
+; local.  If the load immediately follows the set, the DAG combiner will
+; infer that the reloaded value is the same value that was set, which
+; isn't what we want to test.  To inhibit this optimization, we include
+; an opaque call between the store and the load.
+declare void @inhibit_store_to_load_forwarding()
+
+define i32 @ir_local_i32(i32 %arg) {
+ ; CHECK-LABEL: ir_local_i32:
+ ; CHECK-NEXT: .functype ir_local_i32 (i32) -> (i32)
+ %retval = alloca i32, addrspace(1)
+ ; CHECK-NEXT: .local i32
+ store i32 %arg, %i32_cell %retval
+ ; CHECK-NEXT: local.get 0
+ ; CHECK-NEXT: local.set 1
+ call void @inhibit_store_to_load_forwarding()
+ ; CHECK-NEXT: call inhibit_store_to_load_forwarding
+ %reloaded = load i32, %i32_cell %retval
+ ; CHECK-NEXT: local.get 1
+ ret i32 %reloaded
+ ; CHECK-NEXT: end_function
+}
+
+define i64 @ir_local_i64(i64 %arg) {
+ ; CHECK-LABEL: ir_local_i64:
+ ; CHECK-NEXT: .functype ir_local_i64 (i64) -> (i64)
+ %retval = alloca i64, addrspace(1)
+ ; CHECK-NEXT: .local i64
+ store i64 %arg, %i64_cell %retval
+ ; CHECK-NEXT: local.get 0
+ ; CHECK-NEXT: local.set 1
+ call void @inhibit_store_to_load_forwarding()
+ ; CHECK-NEXT: call inhibit_store_to_load_forwarding
+ %reloaded = load i64, %i64_cell %retval
+ ; See note in ir_local_i32.
+ ; CHECK-NEXT: local.get 1
+ ret i64 %reloaded
+ ; CHECK-NEXT: end_function
+}
+
+define float @ir_local_f32(float %arg) {
+ ; CHECK-LABEL: ir_local_f32:
+ ; CHECK-NEXT: .functype ir_local_f32 (f32) -> (f32)
+ %retval = alloca float, addrspace(1)
+ ; CHECK-NEXT: .local f32
+ store float %arg, %f32_cell %retval
+ ; CHECK-NEXT: local.get 0
+ ; CHECK-NEXT: local.set 1
+ call void @inhibit_store_to_load_forwarding()
+ ; CHECK-NEXT: call inhibit_store_to_load_forwarding
+ %reloaded = load float, %f32_cell %retval
+ ; CHECK-NEXT: local.get 1
+ ; CHECK-NEXT: end_function
+ ret float %reloaded
+}
+
+define double @ir_local_f64(double %arg) {
+ ; CHECK-LABEL: ir_local_f64:
+ ; CHECK-NEXT: .functype ir_local_f64 (f64) -> (f64)
+ %retval = alloca double, addrspace(1)
+ ; CHECK-NEXT: .local f64
+ store double %arg, %f64_cell %retval
+ ; CHECK-NEXT: local.get 0
+ ; CHECK-NEXT: local.set 1
+ call void @inhibit_store_to_load_forwarding()
+ ; CHECK-NEXT: call inhibit_store_to_load_forwarding
+ %reloaded = load double, %f64_cell %retval
+ ; CHECK-NEXT: local.get 1
+ ; CHECK-NEXT: end_function
+ ret double %reloaded
+}
+
+define void @ir_unreferenced_local() {
+ ; CHECK-LABEL: ir_unreferenced_local:
+ ; CHECK-NEXT: .functype ir_unreferenced_local () -> ()
+ %unused = alloca i32, addrspace(1)
+ ; CHECK-NEXT: .local i32
+ ret void
+ ; CHECK-NEXT: end_function
+}
Index: llvm/test/CodeGen/WebAssembly/ir-locals-stackid.ll
===
--- /dev/null
+++ llvm/test/CodeGen/WebAssembly/ir-locals-stackid.ll
@@ -0,0 +1,22 @@
+; RUN: llc -mtriple=wasm32-unknown-unknown -asm-verbose=false < %s | FileCheck %s --check-prefix=CHECKCG
+; RUN: llc -mtriple=wasm32-unknown-unknown -stop-after=finalize-isel < %s | FileCheck %s --check-prefix=CHECKISEL
+
+%f32_cell = type float addrspace(1)*
+
+; CHECKISEL-LABEL: name: ir_local_f32
+

[clang] e94fada - SwiftAsync: add Clang attribute to apply the LLVM `swiftasync` one.

2021-05-28 Thread Tim Northover via cfe-commits

Author: Tim Northover
Date: 2021-05-28T12:31:12+01:00
New Revision: e94fada045fe88787a414e3307412c1cc3a1b259

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

LOG: SwiftAsync: add Clang attribute to apply the LLVM `swiftasync` one.

Expected to be used by Swift runtime developers.

Added: 


Modified: 
clang/include/clang/AST/Attr.h
clang/include/clang/Basic/Attr.td
clang/include/clang/Basic/AttrDocs.td
clang/include/clang/Basic/Specifiers.h
clang/lib/AST/ItaniumMangle.cpp
clang/lib/AST/TypePrinter.cpp
clang/lib/CodeGen/CGCall.cpp
clang/lib/Sema/SemaDeclAttr.cpp
clang/lib/Sema/SemaType.cpp
clang/test/CodeGen/arm-swiftcall.c
clang/test/Misc/pragma-attribute-supported-attributes-list.test
clang/test/Sema/attr-swiftcall.c

Removed: 




diff  --git a/clang/include/clang/AST/Attr.h b/clang/include/clang/AST/Attr.h
index e453733ab92c..dbfecc125049 100644
--- a/clang/include/clang/AST/Attr.h
+++ b/clang/include/clang/AST/Attr.h
@@ -208,6 +208,8 @@ class ParameterABIAttr : public InheritableParamAttr {
 switch (getKind()) {
 case attr::SwiftContext:
   return ParameterABI::SwiftContext;
+case attr::SwiftAsyncContext:
+  return ParameterABI::SwiftAsyncContext;
 case attr::SwiftErrorResult:
   return ParameterABI::SwiftErrorResult;
 case attr::SwiftIndirectResult:

diff  --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 6a3945315393..5bfcec732907 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -2457,6 +2457,11 @@ def SwiftContext : ParameterABIAttr {
   let Documentation = [SwiftContextDocs];
 }
 
+def SwiftAsyncContext : ParameterABIAttr {
+  let Spellings = [Clang<"swift_async_context">];
+  let Documentation = [SwiftAsyncContextDocs];
+}
+
 def SwiftErrorResult : ParameterABIAttr {
   let Spellings = [Clang<"swift_error_result">];
   let Documentation = [SwiftErrorResultDocs];

diff  --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index e9ee45d91dc5..cdbbb38573da 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -4529,6 +4529,19 @@ A context parameter must have pointer or reference type.
   }];
 }
 
+def SwiftAsyncContextDocs : Documentation {
+  let Category = DocCatVariable;
+  let Content = [{
+The ``swift_async_context`` attribute marks a parameter as having the
+special asynchronous context-parameter ABI treatment.
+
+This treatment generally passes the context value in a special register
+which is normally callee-preserved.
+
+A context parameter must have pointer or reference type.
+  }];
+}
+
 def SwiftErrorResultDocs : Documentation {
   let Category = DocCatVariable;
   let Content = [{

diff  --git a/clang/include/clang/Basic/Specifiers.h 
b/clang/include/clang/Basic/Specifiers.h
index 07d8177b8ab2..148421ea1124 100644
--- a/clang/include/clang/Basic/Specifiers.h
+++ b/clang/include/clang/Basic/Specifiers.h
@@ -344,7 +344,12 @@ namespace clang {
 /// This parameter (which must have pointer type) uses the special
 /// Swift context-pointer ABI treatment.  There can be at
 /// most one parameter on a given function that uses this treatment.
-SwiftContext
+SwiftContext,
+
+/// This parameter (which must have pointer type) uses the special
+/// Swift asynchronous context-pointer ABI treatment.  There can be at
+/// most one parameter on a given function that uses this treatment.
+SwiftAsyncContext,
   };
 
   /// Assigned inheritance model for a class in the MS C++ ABI. Must match 
order

diff  --git a/clang/lib/AST/ItaniumMangle.cpp b/clang/lib/AST/ItaniumMangle.cpp
index 94e404a5f38a..b5b9cd753519 100644
--- a/clang/lib/AST/ItaniumMangle.cpp
+++ b/clang/lib/AST/ItaniumMangle.cpp
@@ -3140,6 +3140,7 @@ 
CXXNameMangler::mangleExtParameterInfo(FunctionProtoType::ExtParameterInfo PI) {
 
   // All of these start with "swift", so they come before "ns_consumed".
   case ParameterABI::SwiftContext:
+  case ParameterABI::SwiftAsyncContext:
   case ParameterABI::SwiftErrorResult:
   case ParameterABI::SwiftIndirectResult:
 mangleVendorQualifier(getParameterABISpelling(PI.getABI()));

diff  --git a/clang/lib/AST/TypePrinter.cpp b/clang/lib/AST/TypePrinter.cpp
index b2ce28e0ae1e..720cab917a22 100644
--- a/clang/lib/AST/TypePrinter.cpp
+++ b/clang/lib/AST/TypePrinter.cpp
@@ -846,6 +846,8 @@ StringRef clang::getParameterABISpelling(ParameterABI ABI) {
 llvm_unreachable("asking for spelling of ordinary parameter ABI");
   case ParameterABI::SwiftContext:
 return "swift_context";
+  case ParameterABI::SwiftAsyncContext:
+return "swift_async_context";
   case ParameterABI::SwiftErrorResult:
 return "s

[PATCH] D95228: Add swift_async_context parameter attribute mapping to IR equivalent

2021-05-28 Thread Tim Northover via Phabricator via cfe-commits
t.p.northover closed this revision.
t.p.northover marked an inline comment as done.
t.p.northover added a comment.

Thanks, committed as e94fada045fe 
 with the 
extra tests.




Comment at: clang/include/clang/Basic/AttrDocs.td:4404
+
+A context parameter must have pointer or reference type.
+  }];

aaron.ballman wrote:
> Should we specify whether pointer to members or ObjC object pointers are fine 
> (given that those are both somewhat "odd" pointer types)? Function pointers?
> 
> (We may want to clarify this in the other docs in a follow-up if we think 
> this is unclear.)
I don't think either of those are banned, but it's kind of a "play silly games 
win silly prizes" situation.


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

https://reviews.llvm.org/D95228

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


[clang] 5bccdde - [Matrix] Move C++ matrix cast checks to TryStaticCast.

2021-05-28 Thread Florian Hahn via cfe-commits

Author: Florian Hahn
Date: 2021-05-28T13:00:28+01:00
New Revision: 5bccdde070d29fb83aec69c498285b4c8914f8d1

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

LOG: [Matrix] Move C++ matrix cast checks to TryStaticCast.

At the moment, the matrix support in CheckCXXCStyleCast (added in
D101696) breaks function-style constructor calls that take a
single matrix value, because it is treated as matrix cast.

Instead, unify the C++ matrix cast handling by moving the logic to
TryStaticCast and only handle the case where both types are matrix
types. Otherwise, fall back to the generic mis-match detection.

Suggested by @rjmccall

Reviewed By: SaurabhJha

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

Added: 


Modified: 
clang/lib/Sema/SemaCast.cpp
clang/test/CodeGenCXX/matrix-casts.cpp
clang/test/SemaCXX/matrix-casts.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaCast.cpp b/clang/lib/Sema/SemaCast.cpp
index 439b128e90ea4..943880c22376b 100644
--- a/clang/lib/Sema/SemaCast.cpp
+++ b/clang/lib/Sema/SemaCast.cpp
@@ -1179,13 +1179,6 @@ void CastOperation::CheckStaticCast() {
   return;
   }
 
-  if (DestType->getAs() ||
-  SrcExpr.get()->getType()->getAs()) {
-if (Self.CheckMatrixCast(OpRange, DestType, SrcExpr.get()->getType(), 
Kind))
-  SrcExpr = ExprError();
-return;
-  }
-
   // This test is outside everything else because it's the only case where
   // a non-lvalue-reference target type does not lead to decay.
   // C++ 5.2.9p4: Any expression can be explicitly converted to type "cv void".
@@ -1452,6 +1445,14 @@ static TryCastResult TryStaticCast(Sema &Self, 
ExprResult &SrcExpr,
   DestPointer->getPointeeType()->getAs())
msg = diag::err_bad_cxx_cast_unrelated_class;
 
+  if (SrcType->isMatrixType() && DestType->isMatrixType()) {
+if (Self.CheckMatrixCast(OpRange, DestType, SrcType, Kind)) {
+  SrcExpr = ExprError();
+  return TC_Failed;
+}
+return TC_Success;
+  }
+
   // We tried everything. Everything! Nothing works! :-(
   return TC_NotApplicable;
 }
@@ -2665,13 +2666,6 @@ void CastOperation::CheckCXXCStyleCast(bool 
FunctionalStyle,
   return;
   }
 
-  if (DestType->getAs() ||
-  SrcExpr.get()->getType()->getAs()) {
-if (Self.CheckMatrixCast(OpRange, DestType, SrcExpr.get()->getType(), 
Kind))
-  SrcExpr = ExprError();
-return;
-  }
-
   // AltiVec vector initialization with a single literal.
   if (const VectorType *vecTy = DestType->getAs())
 if (vecTy->getVectorKind() == VectorType::AltiVecVector

diff  --git a/clang/test/CodeGenCXX/matrix-casts.cpp 
b/clang/test/CodeGenCXX/matrix-casts.cpp
index fea585bb0ba29..1bf751ee81b03 100644
--- a/clang/test/CodeGenCXX/matrix-casts.cpp
+++ b/clang/test/CodeGenCXX/matrix-casts.cpp
@@ -341,3 +341,33 @@ void CastIntToUnsignedLongIntStaticCast() {
   matrix_5_5 u;
   u = static_cast>(i);
 }
+
+class Foo {
+  int x[10];
+
+public:
+  Foo(matrix_5_5 x);
+};
+
+Foo class_constructor_matrix_ty(matrix_5_5 m) {
+  // CHECK-LABEL: define void 
@_Z27class_constructor_matrix_tyu11matrix_typeILm5ELm5EiE(%class.Foo* noalias 
sret(%class.Foo) align 4 %agg.result, <25 x i32> %m)
+  // CHECK: [[M:%.*]]  = load <25 x i32>, <25 x i32>* {{.*}}, align 4
+  // CHECK-NEXT:call void @_ZN3FooC1Eu11matrix_typeILm5ELm5EiE(%class.Foo* 
nonnull align 4 dereferenceable(40) %agg.result, <25 x i32> [[M]])
+  // CHECK-NEXT:ret void
+
+  return Foo(m);
+}
+
+struct Bar {
+  float x[10];
+  Bar(matrix_4_4 x);
+};
+
+Bar struct_constructor_matrix_ty(matrix_4_4 m) {
+  // CHECK-LABEL: define void 
@_Z28struct_constructor_matrix_tyu11matrix_typeILm4ELm4EfE(%struct.Bar* noalias 
sret(%struct.Bar) align 4 %agg.result, <16 x float> %m)
+  // CHECK: [[M:%.*]] = load <16 x float>, <16 x float>* {{.*}}, align 
4
+  // CHECK-NEXT:call void 
@_ZN3BarC1Eu11matrix_typeILm4ELm4EfE(%struct.Bar* nonnull align 4 
dereferenceable(40) %agg.result, <16 x float> [[M]])
+  // CHECK-NEXT:ret void
+
+  return Bar(m);
+}

diff  --git a/clang/test/SemaCXX/matrix-casts.cpp 
b/clang/test/SemaCXX/matrix-casts.cpp
index 33ba24913bac5..c0f3df1ae8106 100644
--- a/clang/test/SemaCXX/matrix-casts.cpp
+++ b/clang/test/SemaCXX/matrix-casts.cpp
@@ -26,23 +26,16 @@ void f1() {
   m2 = m1; // expected-error {{assigning to 'matrix_4_4' from 
incompatible type 'matrix_4_4'}}
   m3 = (matrix_4_4)m2;
   (matrix_5_5)m3; // expected-error {{conversion between matrix types 
'matrix_5_5' (aka 'int __attribute__\
-((matrix_type(5, 5)))') and 'matrix_4_4' (aka 'short 
__attribute__((matrix_type(4, 4)))') of 
diff erent size is not\
- allowed}}
-
-  (int)m3;// expected-error {{conversion between matrix type 
'matrix_4_4' (aka 'short __attribute__\
-((matrix_type(4, 4)))') an

[PATCH] D103163: [Matrix] Skip matrix casts checks for class or struct types in C++.

2021-05-28 Thread Florian Hahn 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 rG5bccdde070d2: [Matrix] Move C++ matrix cast checks to 
TryStaticCast. (authored by fhahn).

Changed prior to commit:
  https://reviews.llvm.org/D103163?vs=348360&id=348496#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103163

Files:
  clang/lib/Sema/SemaCast.cpp
  clang/test/CodeGenCXX/matrix-casts.cpp
  clang/test/SemaCXX/matrix-casts.cpp

Index: clang/test/SemaCXX/matrix-casts.cpp
===
--- clang/test/SemaCXX/matrix-casts.cpp
+++ clang/test/SemaCXX/matrix-casts.cpp
@@ -26,23 +26,16 @@
   m2 = m1; // expected-error {{assigning to 'matrix_4_4' from incompatible type 'matrix_4_4'}}
   m3 = (matrix_4_4)m2;
   (matrix_5_5)m3; // expected-error {{conversion between matrix types 'matrix_5_5' (aka 'int __attribute__\
-((matrix_type(5, 5)))') and 'matrix_4_4' (aka 'short __attribute__((matrix_type(4, 4)))') of different size is not\
- allowed}}
-
-  (int)m3;// expected-error {{conversion between matrix type 'matrix_4_4' (aka 'short __attribute__\
-((matrix_type(4, 4)))') and incompatible type 'int' is not allowed}}
-  (matrix_4_4)i; // expected-error {{conversion between matrix type 'matrix_4_4' (aka 'int __attribute__\
-((matrix_type(4, 4)))') and incompatible type 'int' is not allowed}}
-
-  (vec) m2;// expected-error {{conversion between matrix type 'matrix_4_4' (aka 'int __attribute__\
-((matrix_type(4, 4)))') and incompatible type 'vec' (vector of 1 'int' value) is not allowed}}
-  (matrix_4_4)v; // expected-error {{conversion between matrix type 'matrix_4_4' (aka 'char __attribute__\
-((matrix_type(4, 4)))') and incompatible type 'vec' (vector of 1 'int' value) is not allowed}}
-
-  (test_struct *)m1;// expected-error {{conversion between matrix type 'matrix_4_4' (aka 'char __attribute__\
-((matrix_type(4, 4)))') and incompatible type 'test_struct *' is not allowed}}'
-  (matrix_5_5)s; // expected-error {{conversion between matrix type 'matrix_5_5' (aka 'float __attribute__\
-((matrix_type(5, 5)))') and incompatible type 'test_struct *' is not allowed}}'
+((matrix_type(5, 5)))') and 'short __attribute__((matrix_type(4, 4)))' of different size is not allowed}}
+
+  (int)m3;// expected-error {{C-style cast from 'matrix_4_4' (aka 'short __attribute__((matrix_type(4, 4)))') to 'int' is not allowed}}
+  (matrix_4_4)i; // expected-error {{C-style cast from 'int' to 'matrix_4_4' (aka 'int __attribute__((matrix_type(4, 4)))') is not allowed}}
+
+  (vec) m2;// expected-error {{C-style cast from 'matrix_4_4' (aka 'int __attribute__((matrix_type(4, 4)))') to 'vec' (vector of 1 'int' value) is not allowed}}
+  (matrix_4_4)v; // expected-error {{C-style cast from 'vec' (vector of 1 'int' value) to 'matrix_4_4' (aka 'char __attribute__((matrix_type(4, 4)))') is not allowed}}
+
+  (test_struct *)m1;// expected-error {{cannot cast from type 'matrix_4_4' (aka 'char __attribute__((matrix_type(4, 4)))') to pointer type 'test_struct *'}}
+  (matrix_5_5)s; // expected-error {{C-style cast from 'test_struct *' to 'matrix_5_5' (aka 'float __attribute__((matrix_type(5, 5)))') is not allowed}}
 }
 
 void f2() {
@@ -57,23 +50,16 @@
   m2 = static_cast>(m1);
   m3 = static_cast>(m2);
   static_cast>(m3); // expected-error {{conversion between matrix types 'matrix_5_5' (aka 'int __attribute__\
-((matrix_type(5, 5)))') and 'matrix_4_4' (aka 'short __attribute__((matrix_type(4, 4)))') of different size is not\
- allowed}}
-
-  static_cast(m3);// expected-error {{conversion between matrix type 'matrix_4_4' (aka 'short __attribute__\
-((matrix_type(4, 4)))') and incompatible type 'int' is not allowed}}
-  static_cast>(i); // expected-error {{conversion between matrix type 'matrix_4_4' (aka 'int __attribute__\
-((matrix_type(4, 4)))') and incompatible type 'int' is not allowed}}
-
-  static_cast(m2); // expected-error {{conversion between matrix type 'matrix_4_4' (aka 'int __attribute__\
-((matrix_type(4, 4)))') and incompatible type 'vec' (vector of 1 'int' value) is not allowed}}
-  static_cast>(v); // expected-error {{conversion between matrix type 'matrix_4_4' (aka 'char __attribute__\
-((matrix_type(4, 4)))') and incompatible type 'vec' (vector of 1 'int' value) is not allowed}}
-
-  static_cast(m1);// expected-error {{conversion between matrix type 'matrix_4_4' (aka 'char __attribute__\
-((matrix_type(4, 4)))') and incompatible type 'test_struct *' is not allowed}}'
-  static_cast>(s); // expected-error {{conversion between matrix type 'matrix_5_5' (aka 'float __attribute__\
-((matrix_type(5, 5)))') and incompatible type 'test_struct *' is not allowed}}'
+((matrix_type(5, 5)))') and 'short __attribute__((matrix_type(4, 4)))' of different size is not allow

[PATCH] D103307: [clang-format] successive C# attributes cause line breaking issues

2021-05-28 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay updated this revision to Diff 348495.
MyDeveloperDay added a comment.

Add additional unit test, and an additional check to ensure multiple attributes 
are broken, while @jbcoe this looks very similar to the original rule, the 
original rule actually had an || in the expression and not an &&, this I 
believe caused and issue where the adjacent [] [] caused an issue because we 
were breaking on an attribute and and array. By virtue of the fact the  
attributes are not correctly identified. Which concerns me a little,

`void myFunction([In][Out] int a)`

  M=0 C=1 T=AttributeSquare S=0 F=0 B=0 BK=0 P=140 Name=l_square L=17 PPK=2 
FakeLParens= FakeRParens=0 II=0x0 Text='['
  M=0 C=0 T=Unknown S=0 F=0 B=0 BK=0 P=79 Name=identifier L=19 PPK=2 
FakeLParens= FakeRParens=0 II=0x25b3990 Text='In'
  M=0 C=0 T=AttributeSquare S=0 F=0 B=0 BK=0 P=63 Name=r_square L=20 PPK=2 
FakeLParens= FakeRParens=0 II=0x0 Text=']'
  M=0 C=0 T=*ArraySubscriptLSquare* S=0 F=0 B=0 BK=0 P=240 Name=l_square L=21 
PPK=2 FakeLParens= FakeRParens=0 II=0x0 Text='['
  M=0 C=0 T=Unknown S=0 F=0 B=0 BK=0 P=259 Name=identifier L=24 PPK=2 
FakeLParens= FakeRParens=0 II=0x25b39b0 Text='Out'
  M=0 C=0 T=Unknown S=0 F=0 B=0 BK=0 P=243 Name=r_square L=25 PPK=2 
FakeLParens= FakeRParens=0 II=0x0 Text=']'

but this subsequent change seems to handle the cases where 2 attributes are 
decorating a property (for the most part)

  M=0 C=0 T=AttributeSquare S=0 F=0 B=0 BK=0 P=43 Name=r_square L=11 PPK=2 
FakeLParens= FakeRParens=0 II=0x0 Text=']'
  M=1 C=1 T=AttributeSquare S=1 F=0 B=0 BK=0 P=220 Name=l_square L=131 PPK=2 
FakeLParens= FakeRParens=0 II=0x0 Text='['

My view is that `[In][Out]` should/could possibly be written as `[In , Out]` to 
avoid the error that at least your review seemed to want to be fixing.

And I think that using attributes on properties is perhaps more likely to be 
pervasive though out C# code than having them on pinvoke.

This update, adds a few more tests to try and uncover attitional places I would 
have expect this to break, (it doesn't) but I want to have more protection from 
the tests

>From my tests I see one place where I see an issue, And seemingly for some 
>reason this completely messes up even identifying that the attributes are 
>themselves attributes. This is definitely a common problem. But the addition 
>of either public/private/internal/protected immediately fixes that and I 
>personally consider that a C# best practice anyway.

  [JsonProperty("gender")] string gender { get; set; }
  
  
   M=0 C=0 T=ArraySubscriptLSquare S=1 F=0 B=0 BK=0 P=0 Name=l_square L=1 PPK=2 
FakeLParens= FakeRParens=0 II=0x0 Text='['
   M=0 C=0 T=Unknown S=0 F=0 B=0 BK=0 P=239 Name=identifier L=13 PPK=2 
FakeLParens= FakeRParens=0 II=0x25b37f0 Text='JsonProperty'
   M=0 C=0 T=Unknown S=0 F=0 B=0 BK=0 P=223 Name=l_paren L=14 PPK=2 
FakeLParens= FakeRParens=0 II=0x0 Text='('
   M=0 C=1 T=Unknown S=0 F=0 B=0 BK=0 P=259 Name=string_literal L=22 PPK=2 
FakeLParens= FakeRParens=0 II=0x0 Text='"gender"'
   M=0 C=0 T=Unknown S=0 F=0 B=0 BK=0 P=243 Name=r_paren L=23 PPK=2 
FakeLParens= FakeRParens=0 II=0x0 Text=')'
   M=0 C=0 T=Unknown S=0 F=0 B=0 BK=0 P=223 Name=r_square L=24 PPK=2 
FakeLParens= FakeRParens=0 II=0x0 Text=']'
   M=0 C=0 T=Unknown S=1 F=0 B=0 BK=0 P=23 Name=identifier L=31 PPK=2 
FakeLParens= FakeRParens=0 II=0x25b3418 Text='string'
   M=0 C=1 T=StartOfName S=1 F=0 B=0 BK=0 P=220 Name=identifier L=38 PPK=2 
FakeLParens= FakeRParens=0 II=0x25b3830 Text='gender'
   M=0 C=0 T=Unknown S=1 F=0 B=0 BK=0 P=23 Name=l_brace L=40 PPK=2 FakeLParens= 
FakeRParens=0 II=0x0 Text='{'
   M=0 C=1 T=Unknown S=1 F=0 B=0 BK=0 P=59 Name=identifier L=44 PPK=2 
FakeLParens=0/ FakeRParens=0 II=0x25b2df0 Text='get'
   M=0 C=0 T=Unknown S=0 F=0 B=0 BK=0 P=43 Name=semi L=45 PPK=2 FakeLParens= 
FakeRParens=0 II=0x0 Text=';'
   M=0 C=1 T=Unknown S=1 F=0 B=0 BK=0 P=40 Name=identifier L=49 PPK=2 
FakeLParens= FakeRParens=0 II=0x25b2eb8 Text='set'
   M=0 C=0 T=Unknown S=0 F=0 B=0 BK=0 P=43 Name=semi L=50 PPK=2 FakeLParens= 
FakeRParens=1 II=0x0 Text=';'
   M=0 C=0 T=Unknown S=1 F=0 B=0 BK=0 P=40 Name=r_brace L=52 PPK=2 FakeLParens= 
FakeRParens=0 II=0x0 Text='}'

If we are in agreement that this doesn't revert your intended changes, I'd like 
to commit this change as an interim step. I'd really like at least these aspect 
resolved before the 13 branch out.


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

https://reviews.llvm.org/D103307

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


Index: clang/unittests/Format/FormatTestCSharp.cpp
===
--- clang/unittests/Format/FormatTestCSharp.cpp
+++ clang/unittests/Format/FormatTestCSharp.cpp
@@ -247,6 +247,37 @@
   verifyFormat("[TestMethod]\n"
"public string Host { set; get; }");
 
+  // Adjacent properties should not cause line wrapping issues
+  verifyFormat("

[clang] b76df32 - [clang] NFC: Replace std::pair by a struct in InitHeaderSearch

2021-05-28 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2021-05-28T14:06:25+02:00
New Revision: b76df3235cd05d11baea67ae684f9f1fd883b76d

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

LOG: [clang] NFC: Replace std::pair by a struct in InitHeaderSearch

This patch replaces a `std::pair` by a proper struct in `InitHeaderSearch`. 
This will be useful in a follow-up: D102923.

Reviewed By: dexonsmith

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

Added: 


Modified: 
clang/lib/Frontend/InitHeaderSearch.cpp

Removed: 




diff  --git a/clang/lib/Frontend/InitHeaderSearch.cpp 
b/clang/lib/Frontend/InitHeaderSearch.cpp
index bc31445d6d08e..ba9f96384f819 100644
--- a/clang/lib/Frontend/InitHeaderSearch.cpp
+++ b/clang/lib/Frontend/InitHeaderSearch.cpp
@@ -32,14 +32,20 @@ using namespace clang;
 using namespace clang::frontend;
 
 namespace {
+/// Holds information about a single DirectoryLookup object.
+struct DirectoryLookupInfo {
+  IncludeDirGroup Group;
+  DirectoryLookup Lookup;
+
+  DirectoryLookupInfo(IncludeDirGroup Group, DirectoryLookup Lookup)
+  : Group(Group), Lookup(Lookup) {}
+};
 
 /// InitHeaderSearch - This class makes it easier to set the search paths of
 ///  a HeaderSearch object. InitHeaderSearch stores several search path lists
 ///  internally, which can be sent to a HeaderSearch object in one swoop.
 class InitHeaderSearch {
-  std::vector > IncludePath;
-  typedef std::vector >::const_iterator path_iterator;
+  std::vector IncludePath;
   std::vector > SystemHeaderPrefixes;
   HeaderSearch &Headers;
   bool Verbose;
@@ -154,8 +160,7 @@ bool InitHeaderSearch::AddUnmappedPath(const Twine &Path, 
IncludeDirGroup Group,
 
   // If the directory exists, add it.
   if (auto DE = FM.getOptionalDirectoryRef(MappedPathStr)) {
-IncludePath.push_back(
-  std::make_pair(Group, DirectoryLookup(*DE, Type, isFramework)));
+IncludePath.emplace_back(Group, DirectoryLookup(*DE, Type, isFramework));
 return true;
   }
 
@@ -165,9 +170,8 @@ bool InitHeaderSearch::AddUnmappedPath(const Twine &Path, 
IncludeDirGroup Group,
 if (auto FE = FM.getFile(MappedPathStr)) {
   if (const HeaderMap *HM = Headers.CreateHeaderMap(*FE)) {
 // It is a headermap, add it to the search path.
-IncludePath.push_back(
-  std::make_pair(Group,
- DirectoryLookup(HM, Type, Group == IndexHeaderMap)));
+IncludePath.emplace_back(
+Group, DirectoryLookup(HM, Type, Group == IndexHeaderMap));
 return true;
   }
 }
@@ -558,32 +562,32 @@ void InitHeaderSearch::Realize(const LangOptions &Lang) {
 
   // Quoted arguments go first.
   for (auto &Include : IncludePath)
-if (Include.first == Quoted)
-  SearchList.push_back(Include.second);
+if (Include.Group == Quoted)
+  SearchList.push_back(Include.Lookup);
 
   // Deduplicate and remember index.
   RemoveDuplicates(SearchList, 0, Verbose);
   unsigned NumQuoted = SearchList.size();
 
   for (auto &Include : IncludePath)
-if (Include.first == Angled || Include.first == IndexHeaderMap)
-  SearchList.push_back(Include.second);
+if (Include.Group == Angled || Include.Group == IndexHeaderMap)
+  SearchList.push_back(Include.Lookup);
 
   RemoveDuplicates(SearchList, NumQuoted, Verbose);
   unsigned NumAngled = SearchList.size();
 
   for (auto &Include : IncludePath)
-if (Include.first == System || Include.first == ExternCSystem ||
-(!Lang.ObjC && !Lang.CPlusPlus && Include.first == CSystem) ||
+if (Include.Group == System || Include.Group == ExternCSystem ||
+(!Lang.ObjC && !Lang.CPlusPlus && Include.Group == CSystem) ||
 (/*FIXME !Lang.ObjC && */ Lang.CPlusPlus &&
- Include.first == CXXSystem) ||
-(Lang.ObjC && !Lang.CPlusPlus && Include.first == ObjCSystem) ||
-(Lang.ObjC && Lang.CPlusPlus && Include.first == ObjCXXSystem))
-  SearchList.push_back(Include.second);
+ Include.Group == CXXSystem) ||
+(Lang.ObjC && !Lang.CPlusPlus && Include.Group == ObjCSystem) ||
+(Lang.ObjC && Lang.CPlusPlus && Include.Group == ObjCXXSystem))
+  SearchList.push_back(Include.Lookup);
 
   for (auto &Include : IncludePath)
-if (Include.first == After)
-  SearchList.push_back(Include.second);
+if (Include.Group == After)
+  SearchList.push_back(Include.Lookup);
 
   // Remove duplicates across both the Angled and System directories.  GCC does
   // this and failing to remove duplicates across these two groups breaks



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


[PATCH] D102924: [clang] NFC: Replace std::pair by a struct in InitHeaderSearch

2021-05-28 Thread Jan Svoboda via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb76df3235cd0: [clang] NFC: Replace std::pair by a struct in 
InitHeaderSearch (authored by jansvoboda11).

Changed prior to commit:
  https://reviews.llvm.org/D102924?vs=347045&id=348498#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102924

Files:
  clang/lib/Frontend/InitHeaderSearch.cpp


Index: clang/lib/Frontend/InitHeaderSearch.cpp
===
--- clang/lib/Frontend/InitHeaderSearch.cpp
+++ clang/lib/Frontend/InitHeaderSearch.cpp
@@ -32,14 +32,20 @@
 using namespace clang::frontend;
 
 namespace {
+/// Holds information about a single DirectoryLookup object.
+struct DirectoryLookupInfo {
+  IncludeDirGroup Group;
+  DirectoryLookup Lookup;
+
+  DirectoryLookupInfo(IncludeDirGroup Group, DirectoryLookup Lookup)
+  : Group(Group), Lookup(Lookup) {}
+};
 
 /// InitHeaderSearch - This class makes it easier to set the search paths of
 ///  a HeaderSearch object. InitHeaderSearch stores several search path lists
 ///  internally, which can be sent to a HeaderSearch object in one swoop.
 class InitHeaderSearch {
-  std::vector > IncludePath;
-  typedef std::vector >::const_iterator path_iterator;
+  std::vector IncludePath;
   std::vector > SystemHeaderPrefixes;
   HeaderSearch &Headers;
   bool Verbose;
@@ -154,8 +160,7 @@
 
   // If the directory exists, add it.
   if (auto DE = FM.getOptionalDirectoryRef(MappedPathStr)) {
-IncludePath.push_back(
-  std::make_pair(Group, DirectoryLookup(*DE, Type, isFramework)));
+IncludePath.emplace_back(Group, DirectoryLookup(*DE, Type, isFramework));
 return true;
   }
 
@@ -165,9 +170,8 @@
 if (auto FE = FM.getFile(MappedPathStr)) {
   if (const HeaderMap *HM = Headers.CreateHeaderMap(*FE)) {
 // It is a headermap, add it to the search path.
-IncludePath.push_back(
-  std::make_pair(Group,
- DirectoryLookup(HM, Type, Group == IndexHeaderMap)));
+IncludePath.emplace_back(
+Group, DirectoryLookup(HM, Type, Group == IndexHeaderMap));
 return true;
   }
 }
@@ -558,32 +562,32 @@
 
   // Quoted arguments go first.
   for (auto &Include : IncludePath)
-if (Include.first == Quoted)
-  SearchList.push_back(Include.second);
+if (Include.Group == Quoted)
+  SearchList.push_back(Include.Lookup);
 
   // Deduplicate and remember index.
   RemoveDuplicates(SearchList, 0, Verbose);
   unsigned NumQuoted = SearchList.size();
 
   for (auto &Include : IncludePath)
-if (Include.first == Angled || Include.first == IndexHeaderMap)
-  SearchList.push_back(Include.second);
+if (Include.Group == Angled || Include.Group == IndexHeaderMap)
+  SearchList.push_back(Include.Lookup);
 
   RemoveDuplicates(SearchList, NumQuoted, Verbose);
   unsigned NumAngled = SearchList.size();
 
   for (auto &Include : IncludePath)
-if (Include.first == System || Include.first == ExternCSystem ||
-(!Lang.ObjC && !Lang.CPlusPlus && Include.first == CSystem) ||
+if (Include.Group == System || Include.Group == ExternCSystem ||
+(!Lang.ObjC && !Lang.CPlusPlus && Include.Group == CSystem) ||
 (/*FIXME !Lang.ObjC && */ Lang.CPlusPlus &&
- Include.first == CXXSystem) ||
-(Lang.ObjC && !Lang.CPlusPlus && Include.first == ObjCSystem) ||
-(Lang.ObjC && Lang.CPlusPlus && Include.first == ObjCXXSystem))
-  SearchList.push_back(Include.second);
+ Include.Group == CXXSystem) ||
+(Lang.ObjC && !Lang.CPlusPlus && Include.Group == ObjCSystem) ||
+(Lang.ObjC && Lang.CPlusPlus && Include.Group == ObjCXXSystem))
+  SearchList.push_back(Include.Lookup);
 
   for (auto &Include : IncludePath)
-if (Include.first == After)
-  SearchList.push_back(Include.second);
+if (Include.Group == After)
+  SearchList.push_back(Include.Lookup);
 
   // Remove duplicates across both the Angled and System directories.  GCC does
   // this and failing to remove duplicates across these two groups breaks


Index: clang/lib/Frontend/InitHeaderSearch.cpp
===
--- clang/lib/Frontend/InitHeaderSearch.cpp
+++ clang/lib/Frontend/InitHeaderSearch.cpp
@@ -32,14 +32,20 @@
 using namespace clang::frontend;
 
 namespace {
+/// Holds information about a single DirectoryLookup object.
+struct DirectoryLookupInfo {
+  IncludeDirGroup Group;
+  DirectoryLookup Lookup;
+
+  DirectoryLookupInfo(IncludeDirGroup Group, DirectoryLookup Lookup)
+  : Group(Group), Lookup(Lookup) {}
+};
 
 /// InitHeaderSearch - This class makes it easier to set the search paths of
 ///  a HeaderSearch object. InitHeaderSearch stores several search path lists
 ///  internally, which can be sent to a HeaderSearch object in one swoop.
 class InitHea

[PATCH] D103204: [clang-format] New BreakInheritanceList style AfterComma

2021-05-28 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay accepted this revision.
MyDeveloperDay added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103204

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


[PATCH] D101140: [WebAssembly][CodeGen] IR support for WebAssembly local variables

2021-05-28 Thread Jessica Clarke via Phabricator via cfe-commits
jrtc27 added a comment.

Is it just me or does having a backend-specific type in target-independent code 
feel wrong? It feels like there should be a space for target-specific 
TargetStackIDs...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101140

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


[PATCH] D91628: [SystemZ][NFC] Group SystemZ tests in SystemZ folder

2021-05-28 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan added a comment.

In D91628#2762190 , @MaskRay wrote:

> .ll -> .s tests should be placed in llvm/test/CodeGen/SystemZ, not in clang

Sorry for the late reply, I was on vacation. Is there a specific test you are 
referring to? All the testcases I moved in this commit already existed in 
clang/test/CodeGen and all seem to start with `.c` or `.cpp`, not `.ll`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91628

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


[PATCH] D103131: support debug info for alias variable

2021-05-28 Thread kamlesh kumar via Phabricator via cfe-commits
kamleshbhalui updated this revision to Diff 348501.
kamleshbhalui added a comment.

matching gcc behavior


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103131

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDebugInfo.h
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGen/debug-info-alias.c


Index: clang/test/CodeGen/debug-info-alias.c
===
--- /dev/null
+++ clang/test/CodeGen/debug-info-alias.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited -triple 
x86_64-linux-unknown %s -o - | FileCheck %s
+
+// CHECK: !DIGlobalVariable(name: "newname"
+
+int oldname = 1;
+extern int newname __attribute__((alias("oldname")));
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -4927,6 +4927,12 @@
   setTLSMode(GA, *VD);
 
   SetCommonAttributes(GD, GA);
+
+  // Emit global alias debug information.
+  if (const auto *VD = dyn_cast(D)) {
+if (CGDebugInfo *DI = getModuleDebugInfo())
+  DI->EmitGlobalAlias(VD);
+  }
 }
 
 void CodeGenModule::emitIFuncDefinition(GlobalDecl GD) {
Index: clang/lib/CodeGen/CGDebugInfo.h
===
--- clang/lib/CodeGen/CGDebugInfo.h
+++ clang/lib/CodeGen/CGDebugInfo.h
@@ -493,6 +493,9 @@
   /// Emit information about an external variable.
   void EmitExternalVariable(llvm::GlobalVariable *GV, const VarDecl *Decl);
 
+  /// Emit information about global alias.
+  void EmitGlobalAlias(const VarDecl *Decl);
+
   /// Emit C++ using directive.
   void EmitUsingDirective(const UsingDirectiveDecl &UD);
 
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -4945,6 +4945,20 @@
   Var->addDebugInfo(GVE);
 }
 
+void CGDebugInfo::EmitGlobalAlias(const VarDecl *D) {
+  if (!CGM.getCodeGenOpts().hasReducedDebugInfo())
+return;
+
+  llvm::DIFile *Unit = getOrCreateFile(D->getLocation());
+  StringRef Name = D->getName();
+  llvm::DIType *Ty = getOrCreateType(D->getType(), Unit);
+  llvm::DIScope *DContext = getDeclContextDescriptor(D);
+  auto Loc = getLineNumber(D->getLocation());
+  DBuilder.createGlobalVariableExpression(
+  DContext, Name, StringRef(), Unit, Loc, Ty,
+  !D->hasExternalFormalLinkage());
+}
+
 llvm::DIScope *CGDebugInfo::getCurrentContextDescriptor(const Decl *D) {
   if (!LexicalBlockStack.empty())
 return LexicalBlockStack.back();


Index: clang/test/CodeGen/debug-info-alias.c
===
--- /dev/null
+++ clang/test/CodeGen/debug-info-alias.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited -triple x86_64-linux-unknown %s -o - | FileCheck %s
+
+// CHECK: !DIGlobalVariable(name: "newname"
+
+int oldname = 1;
+extern int newname __attribute__((alias("oldname")));
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -4927,6 +4927,12 @@
   setTLSMode(GA, *VD);
 
   SetCommonAttributes(GD, GA);
+
+  // Emit global alias debug information.
+  if (const auto *VD = dyn_cast(D)) {
+if (CGDebugInfo *DI = getModuleDebugInfo())
+  DI->EmitGlobalAlias(VD);
+  }
 }
 
 void CodeGenModule::emitIFuncDefinition(GlobalDecl GD) {
Index: clang/lib/CodeGen/CGDebugInfo.h
===
--- clang/lib/CodeGen/CGDebugInfo.h
+++ clang/lib/CodeGen/CGDebugInfo.h
@@ -493,6 +493,9 @@
   /// Emit information about an external variable.
   void EmitExternalVariable(llvm::GlobalVariable *GV, const VarDecl *Decl);
 
+  /// Emit information about global alias.
+  void EmitGlobalAlias(const VarDecl *Decl);
+
   /// Emit C++ using directive.
   void EmitUsingDirective(const UsingDirectiveDecl &UD);
 
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -4945,6 +4945,20 @@
   Var->addDebugInfo(GVE);
 }
 
+void CGDebugInfo::EmitGlobalAlias(const VarDecl *D) {
+  if (!CGM.getCodeGenOpts().hasReducedDebugInfo())
+return;
+
+  llvm::DIFile *Unit = getOrCreateFile(D->getLocation());
+  StringRef Name = D->getName();
+  llvm::DIType *Ty = getOrCreateType(D->getType(), Unit);
+  llvm::DIScope *DContext = getDeclContextDescriptor(D);
+  auto Loc = getLineNumber(D->getLocation());
+  DBuilder.createGlobalVariableExpression(
+  DContext, Name, StringRef(), Unit, Loc, Ty,
+  !D->hasExternalFormalLinkage());
+}
+
 llvm::DIScope *CGDebugInfo::getCurrentContextDe

[PATCH] D101921: [MC] Make it possible for targets to define their own MCObjectFileInfo

2021-05-28 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added subscribers: compnerd, dblaikie.
MaskRay added a comment.

Because of `new MCObjectFileInfo`, we cannot use a forward declaration 
(incomplete class) to replace `#include "llvm/MC/MCObjectFileInfo.h"` in 
`TargetRegistry.h`.

I thought about moving `TargetRegistry.{h,cpp}` from Support to Target. 
However, it doesn't work because Bitcode/Object call 
`TargetRegistry::lookupTarget` and Bitcode/Object are lower than Target.

@compnerd @dblaikie @mehdi_amini Do you have suggestions on fixing the layering?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101921

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


[PATCH] D103125: [Clang][WIP] Allow renaming of "clang"

2021-05-28 Thread Nemanja Ivanovic via Phabricator via cfe-commits
nemanjai abandoned this revision.
nemanjai added a comment.

Thanks everyone for providing feedback on this. I posted this to gauge interest 
in the community for such a change. As it appears, the consensus seems to be 
that this isn't desired so I will abandon this change and vendors will continue 
with their homegrown solutions to this problem.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103125

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


[PATCH] D103313: [RISCV][Clang] Implement support for zmmul-experimental

2021-05-28 Thread ksyx via Phabricator via cfe-commits
ksyx created this revision.
ksyx added reviewers: asb, craig.topper, luismarques, jrtc27, kito-cheng, 
rsmith, shiva0217.
Herald added subscribers: vkmr, frasercrmck, evandro, apazos, sameer.abuasal, 
s.egerton, Jim, benna, psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, 
rogfer01, edward-jones, zzheng, niosHD, sabuasal, simoncook, johnrusso, rbar, 
hiraditya.
ksyx requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, MaskRay.
Herald added projects: clang, LLVM.

This patch implements recently merged extension Zmmul 
, a subextension of M 
(Integer Multiplication and Division) consisting only multiplication part of it.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D103313

Files:
  clang/lib/Basic/Targets/RISCV.cpp
  clang/lib/Basic/Targets/RISCV.h
  clang/lib/Driver/ToolChains/Arch/RISCV.cpp
  llvm/lib/Target/RISCV/RISCV.td
  llvm/lib/Target/RISCV/RISCVISelLowering.cpp
  llvm/lib/Target/RISCV/RISCVInstrInfoM.td
  llvm/lib/Target/RISCV/RISCVSubtarget.h
  llvm/test/CodeGen/RISCV/zmmul.ll
  llvm/test/MC/RISCV/rv32i-invalid.s
  llvm/test/MC/RISCV/rv32zmmul-invaild.s
  llvm/test/MC/RISCV/rv32zmmul-valid.s
  llvm/test/MC/RISCV/rv64zmmul-invalid.s
  llvm/test/MC/RISCV/rv64zmmul-valid.s

Index: llvm/test/MC/RISCV/rv64zmmul-valid.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rv64zmmul-valid.s
@@ -0,0 +1,5 @@
+# RUN: llvm-mc %s -triple=riscv64 -mattr=+experimental-zmmul -riscv-no-aliases 2>&1 \
+# RUN:  | FileCheck -check-prefixes=CHECK-INST %s
+
+# CHECK-INST: mulw ra, sp, gp
+mulw ra, sp, gp
Index: llvm/test/MC/RISCV/rv64zmmul-invalid.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rv64zmmul-invalid.s
@@ -0,0 +1,14 @@
+# RUN: not llvm-mc %s -triple=riscv64 -mattr=+experimental-zmmul -riscv-no-aliases 2>&1 \
+# RUN:  | FileCheck -check-prefixes=CHECK-ERROR %s
+
+# CHECK-ERROR: 5:1: error: instruction requires the following: 'M' (Integer Multiplication and Division)
+divw tp, t0, t1
+
+# CHECK-ERROR: 8:1: error: instruction requires the following: 'M' (Integer Multiplication and Division)
+divuw t2, s0, s2
+
+# CHECK-ERROR: 11:1: error: instruction requires the following: 'M' (Integer Multiplication and Division)
+remw a0, a1, a2
+
+# CHECK-ERROR: 14:1: error: instruction requires the following: 'M' (Integer Multiplication and Division)
+remuw a3, a4, a5
Index: llvm/test/MC/RISCV/rv32zmmul-valid.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rv32zmmul-valid.s
@@ -0,0 +1,14 @@
+# RUN: llvm-mc %s -triple=riscv32 -mattr=+experimental-zmmul -riscv-no-aliases 2>&1 \
+# RUN:  | FileCheck -check-prefixes=CHECK-INST %s
+
+# CHECK-INST: mul a4, ra, s0
+mul a4, ra, s0
+
+# CHECK-INST: mulh ra, zero, zero
+mulh x1, x0, x0
+
+# CHECK-INST: mulhsu t0, t2, t1
+mulhsu t0, t2, t1
+
+# CHECK-INST: mulhu a5, a4, a3
+mulhu a5, a4, a3
Index: llvm/test/MC/RISCV/rv32zmmul-invaild.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rv32zmmul-invaild.s
@@ -0,0 +1,14 @@
+# RUN: not llvm-mc %s -triple=riscv32 -mattr=+experimental-zmmul -riscv-no-aliases 2>&1 \
+# RUN:  | FileCheck -check-prefixes=CHECK-ERROR %s
+
+# CHECK-ERROR: 5:1: error: instruction requires the following: 'M' (Integer Multiplication and Division)
+div s0, s0, s0
+
+# CHECK-ERROR: 8:1: error: instruction requires the following: 'M' (Integer Multiplication and Division)
+divu gp, a0, a1
+
+# CHECK-ERROR: 11:1: error: instruction requires the following: 'M' (Integer Multiplication and Division)
+rem s2, s2, s8
+
+# CHECK-ERROR: 14:1: error: instruction requires the following: 'M' (Integer Multiplication and Division)
+remu x18, x18, x24
Index: llvm/test/MC/RISCV/rv32i-invalid.s
===
--- llvm/test/MC/RISCV/rv32i-invalid.s
+++ llvm/test/MC/RISCV/rv32i-invalid.s
@@ -169,7 +169,7 @@
 xor s2, s2 # CHECK: :[[@LINE]]:1: error: too few operands for instruction
 
 # Instruction not in the base ISA
-mul a4, ra, s0 # CHECK: :[[@LINE]]:1: error: instruction requires the following: 'M' (Integer Multiplication and Division)
+div a4, ra, s0 # CHECK: :[[@LINE]]:1: error: instruction requires the following: 'M' (Integer Multiplication and Division)
 amomaxu.w s5, s4, (s3) # CHECK: :[[@LINE]]:1: error: instruction requires the following: 'A' (Atomic Instructions)
 fadd.s ft0, ft1, ft2 # CHECK: :[[@LINE]]:1: error: instruction requires the following: 'F' (Single-Precision Floating-Point)
 fadd.h ft0, ft1, ft2 # CHECK: :[[@LINE]]:1: error: instruction requires the following: 'Zfh' (Half-Precision Floating-Point)
Index: llvm/test/CodeGen/RISCV/zmmul.ll
===
--- /dev/null
+++ llvm/test/CodeGen/RISCV/zmmul.ll
@@ -0,0 +1,41 @@
+;

[PATCH] D101140: [WebAssembly][CodeGen] IR support for WebAssembly local variables

2021-05-28 Thread Andy Wingo via Phabricator via cfe-commits
wingo added a comment.

In D101140#2786777 , @jrtc27 wrote:

> Is it just me or does having a backend-specific type in target-independent 
> code feel wrong? It feels like there should be a space for target-specific 
> TargetStackIDs...

Hoo, good question.  More support for target-specific handling of stack IDs 
would be great.  However in this case the concept is not purely wasm-specific; 
I can imagine other targets that might have a similar treatment of locals (if 
we had a .net target, or a jvm target, or so).  The idea is that there is a 
separate stack consisting of named locals that may not be addressable by 
pointers to main memory.  In earlier drafts of this patch the name was more 
generic ("Object", then "Managed") but you know, our words in this area are 
quite overloaded.  So instead I went with something quite specific (WasmLocal) 
to avoid the general question -- but I do think the concept is not specific, 
even if it doesn't apply to any other target currently in tree.  WDYT?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101140

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


[PATCH] D103314: [Analyzer][solver] Simplify existing constraints when a new constraint is added

2021-05-28 Thread Gabor Marton via Phabricator via cfe-commits
martong created this revision.
martong added reviewers: vsavchenko, NoQ, steakhal.
Herald added subscribers: ASDenysPetrov, gamesh411, dkrupp, donat.nagy, 
Szelethus, mikhail.ramalho, a.sidorin, rnkovacs, szepet, baloghadamsoftware, 
xazax.hun, whisperity.
Herald added a reviewer: Szelethus.
martong requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Update `setConstraint` to simplify existing constraints (and adding the
simplified constraint) when a new constraint is added. In this patch we just
simply iterate over all existing constraints and try to simplfy them with
simplifySVal. This solves the simplest problematic cases where we have two
symbols in the tree, e.g.:

  int test_rhs_further_constrained(int x, int y) {
if (x + y != 0)
  return 0;
if (y != 0)
  return 0;
clang_analyzer_eval(x + y == 0); // expected-warning{{TRUE}}
clang_analyzer_eval(y == 0); // expected-warning{{TRUE}}
return 0;
  }

This patch is the first step of a sequence of patches, and not intended to be
commited as a standalone change. The sequence of patches (and the plan) is
described here: https://reviews.llvm.org/D102696#2784624


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D103314

Files:
  clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
  clang/test/Analysis/find-binop-constraints.cpp

Index: clang/test/Analysis/find-binop-constraints.cpp
===
--- /dev/null
+++ clang/test/Analysis/find-binop-constraints.cpp
@@ -0,0 +1,115 @@
+// RUN: %clang_analyze_cc1 %s \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=debug.ExprInspection \
+// RUN:   -analyzer-config eagerly-assume=false \
+// RUN:   -verify
+
+void clang_analyzer_eval(bool);
+
+int test_legacy_behavior(int x, int y) {
+  if (y != 0)
+return 0;
+  if (x + y != 0)
+return 0;
+  clang_analyzer_eval(x + y == 0); // expected-warning{{TRUE}}
+  clang_analyzer_eval(y == 0); // expected-warning{{TRUE}}
+  return y / (x + y);  // expected-warning{{Division by zero}}
+}
+
+int test_rhs_further_constrained(int x, int y) {
+  if (x + y != 0)
+return 0;
+  if (y != 0)
+return 0;
+  clang_analyzer_eval(x + y == 0); // expected-warning{{TRUE}}
+  clang_analyzer_eval(y == 0); // expected-warning{{TRUE}}
+  return 0;
+}
+
+int test_lhs_further_constrained(int x, int y) {
+  if (x + y != 0)
+return 0;
+  if (x != 0)
+return 0;
+  clang_analyzer_eval(x + y == 0); // expected-warning{{TRUE}}
+  clang_analyzer_eval(x == 0); // expected-warning{{TRUE}}
+  return 0;
+}
+
+int test_lhs_and_rhs_further_constrained(int x, int y) {
+  if (x % y != 1)
+return 0;
+  if (x != 1)
+return 0;
+  if (y != 2)
+return 0;
+  clang_analyzer_eval(x % y == 1); // expected-warning{{TRUE}}
+  clang_analyzer_eval(y == 2); // expected-warning{{TRUE}}
+  return 0;
+}
+
+int test_commutativity(int x, int y) {
+  if (x + y != 0)
+return 0;
+  if (y != 0)
+return 0;
+  clang_analyzer_eval(y + x == 0); // expected-warning{{TRUE}}
+  clang_analyzer_eval(y == 0); // expected-warning{{TRUE}}
+  return 0;
+}
+
+int test_binop_when_height_is_2_r(int a, int x, int y, int z) {
+  switch (a) {
+  case 1: {
+if (x + y + z != 0)
+  return 0;
+if (z != 0)
+  return 0;
+clang_analyzer_eval(x + y + z == 0); // expected-warning{{TRUE}}
+clang_analyzer_eval(z == 0); // expected-warning{{TRUE}}
+break;
+  }
+  case 2: {
+if (x + y + z != 0)
+  return 0;
+if (y != 0)
+  return 0;
+clang_analyzer_eval(x + y + z == 0); // expected-warning{{TRUE}}
+clang_analyzer_eval(y == 0); // expected-warning{{TRUE}}
+break;
+  }
+  case 3: {
+if (x + y + z != 0)
+  return 0;
+if (x != 0)
+  return 0;
+clang_analyzer_eval(x + y + z == 0); // expected-warning{{TRUE}}
+clang_analyzer_eval(x == 0); // expected-warning{{TRUE}}
+break;
+  }
+  case 4: {
+if (x + y + z != 0)
+  return 0;
+if (x + y != 0)
+  return 0;
+clang_analyzer_eval(x + y + z == 0); // expected-warning{{TRUE}}
+clang_analyzer_eval(x + y == 0); // expected-warning{{TRUE}}
+break;
+  }
+  case 5: {
+if (z != 0)
+  return 0;
+if (x + y + z != 0)
+  return 0;
+clang_analyzer_eval(x + y + z == 0); // expected-warning{{TRUE}}
+if (y != 0)
+  return 0;
+clang_analyzer_eval(y == 0); // expected-warning{{TRUE}}
+clang_analyzer_eval(z == 0); // expected-warning{{TRUE}}
+clang_analyzer_eval(x + y + z == 0); // expected-warning{{TRUE}}
+break;
+  }
+
+  }
+  return 0;
+}
Index: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -515,6 +515

[PATCH] D101140: [WebAssembly][CodeGen] IR support for WebAssembly local variables

2021-05-28 Thread Jessica Clarke via Phabricator via cfe-commits
jrtc27 added a comment.

In D101140#2786844 , @wingo wrote:

> In D101140#2786777 , @jrtc27 wrote:
>
>> Is it just me or does having a backend-specific type in target-independent 
>> code feel wrong? It feels like there should be a space for target-specific 
>> TargetStackIDs...
>
> Hoo, good question.  More support for target-specific handling of stack IDs 
> would be great.  However in this case the concept is not purely 
> wasm-specific; I can imagine other targets that might have a similar 
> treatment of locals (if we had a .net target, or a jvm target, or so).  The 
> idea is that there is a separate stack consisting of named locals that may 
> not be addressable by pointers to main memory.  In earlier drafts of this 
> patch the name was more generic ("Object", then "Managed") but you know, our 
> words in this area are quite overloaded.  So instead I went with something 
> quite specific (WasmLocal) to avoid the general question -- but I do think 
> the concept is not specific, even if it doesn't apply to any other target 
> currently in tree.  WDYT?

Well, except all the logic for it is in the backend, only the parser and the 
definition are in target-independent code, so even if another backend were to 
reuse it it would have its own completely separate logic for it, and thus 
there's no benefit to reusing a shared name for the thing over each target 
defining its own? Or would some of the code in the wasm backend be refactored 
out into CodeGen?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101140

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


[PATCH] D103317: [Analyzer][engine][solver] Simplify complex constraints

2021-05-28 Thread Gabor Marton via Phabricator via cfe-commits
martong created this revision.
martong added reviewers: vsavchenko, NoQ, steakhal.
Herald added subscribers: manas, ASDenysPetrov, gamesh411, dkrupp, donat.nagy, 
Szelethus, mikhail.ramalho, a.sidorin, rnkovacs, szepet, baloghadamsoftware, 
xazax.hun, whisperity.
Herald added a reviewer: Szelethus.
martong requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Add the capability to simplify more complex constraints where there are 3
symbols in the tree. In this change I extend simplifySVal to query constraints
of children sub-symbols in a symbol tree. (The constraint for the parent is
asked in `getKnownValue`.) This change makes the following cases to pass
(notice the 3rd check in each test-case).

This patch is the second step of a sequence of patches, and not intended to be
commited as a standalone change. The sequence of patches (and the plan) is
described here: https://reviews.llvm.org/D102696#2784624

  int test_left_tree_constrained(int x, int y, int z) {
if (x + y + z != 0)
  return 0;
if (x + y != 0)
  return 0;
clang_analyzer_eval(x + y + z == 0); // expected-warning{{TRUE}}
clang_analyzer_eval(x + y == 0); // expected-warning{{TRUE}}
clang_analyzer_eval(z == 0); // expected-warning{{TRUE}}
x = y = z = 1;
return 0;
  }


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D103317

Files:
  clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
  clang/test/Analysis/simplify-complex-constraints.cpp

Index: clang/test/Analysis/simplify-complex-constraints.cpp
===
--- /dev/null
+++ clang/test/Analysis/simplify-complex-constraints.cpp
@@ -0,0 +1,33 @@
+// RUN: %clang_analyze_cc1 %s \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=debug.ExprInspection \
+// RUN:   -analyzer-config eagerly-assume=false \
+// RUN:   -verify
+
+// Here we test whether the analyzer is capable to simplify existing
+// constraints based on newly added constraints on a sub-expression.
+
+void clang_analyzer_eval(bool);
+
+int test_left_tree_constrained(int x, int y, int z) {
+  if (x + y + z != 0)
+return 0;
+  if (x + y != 0)
+return 0;
+  clang_analyzer_eval(x + y + z == 0); // expected-warning{{TRUE}}
+  clang_analyzer_eval(x + y == 0); // expected-warning{{TRUE}}
+  clang_analyzer_eval(z == 0); // expected-warning{{TRUE}}
+  x = y = z = 1;
+  return 0;
+}
+
+int test_right_tree_constrained(int x, int y, int z) {
+  if (x + (y + z) != 0)
+return 0;
+  if (y + z != 0)
+return 0;
+  clang_analyzer_eval(x + y + z == 0); // expected-warning{{TRUE}}
+  clang_analyzer_eval(y + z == 0); // expected-warning{{TRUE}}
+  clang_analyzer_eval(x == 0); // expected-warning{{TRUE}}
+  return 0;
+}
Index: clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
===
--- clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
+++ clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
@@ -1107,7 +1107,6 @@
   if (SymbolRef Sym = V.getAsSymbol())
 return state->getConstraintManager().getSymVal(state, Sym);
 
-  // FIXME: Add support for SymExprs.
   return nullptr;
 }
 
@@ -1139,6 +1138,15 @@
   return cache(Sym, SVB.makeSymbolVal(Sym));
 }
 
+SVal getConst(SymbolRef Sym) {
+  const llvm::APSInt *Const =
+  State->getConstraintManager().getSymVal(State, Sym);
+  if (Const)
+return Loc::isLocType(Sym->getType()) ? (SVal)SVB.makeIntLocVal(*Const)
+  : (SVal)SVB.makeIntVal(*Const);
+  return SVal();
+}
+
   public:
 Simplifier(ProgramStateRef State)
 : State(State), SVB(State->getStateManager().getSValBuilder()) {}
@@ -1152,15 +1160,16 @@
   return SVB.makeSymbolVal(S);
 }
 
-// TODO: Support SymbolCast. Support IntSymExpr when/if we actually
-// start producing them.
+// TODO: Support SymbolCast.
 
 SVal VisitSymIntExpr(const SymIntExpr *S) {
   auto I = Cached.find(S);
   if (I != Cached.end())
 return I->second;
 
-  SVal LHS = Visit(S->getLHS());
+  SVal LHS = getConst(S->getLHS());
+  if (LHS.isUndef())
+LHS = Visit(S->getLHS());
   if (isUnchanged(S->getLHS(), LHS))
 return skip(S);
 
@@ -1187,6 +1196,22 @@
   S, SVB.evalBinOp(State, S->getOpcode(), LHS, RHS, S->getType()));
 }
 
+SVal VisitIntSymExpr(const IntSymExpr *S) {
+  auto I = Cached.find(S);
+  if (I != Cached.end())
+return I->second;
+
+  SVal RHS = getConst(S->getRHS());
+  if (RHS.isUndef())
+RHS = Visit(S->getRHS());
+  if (isUnchanged(S->getRHS(), RHS))
+return skip(S);
+
+  SVal LHS = SVB.makeIntVal(S->getLHS());
+  return cache(
+  S, SVB.evalBinOp(State, S->getOpcode(), LHS, RHS, S->getType()));
+}
+
 SVal VisitSymSymExpr(const SymSymExpr 

[PATCH] D102696: [Analyzer] Find constraints that are directly attached to a BinOp

2021-05-28 Thread Gabor Marton via Phabricator via cfe-commits
martong abandoned this revision.
martong added a comment.

Abandoning in favor of
https://reviews.llvm.org/D103314
https://reviews.llvm.org/D103317


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102696

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


[PATCH] D103314: [Analyzer][solver] Simplify existing constraints when a new constraint is added

2021-05-28 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko requested changes to this revision.
vsavchenko added a comment.
This revision now requires changes to proceed.

Hey, great job! This is really something that we need, but it's implemented not 
really correctly.
I tried to cover it in the inline comment.




Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:1562-1578
+ConstraintMap CM = getConstraintMap(State);
+for (auto const &C : CM) {
+  const SymbolRef &ParentSym = C.first;
+  SValBuilder &SVB = getSValBuilder();
+
+  SVal SimplifiedParentVal =
+  SVB.simplifySVal(State, SVB.makeSymbolVal(ParentSym));

I tried to cover it in the comment to another patch.  This solution includes a 
lot of extra work and it will lose equality/disequality information for 
simplified expressions, and I think it's safe to say that if `a == b` then 
`simplify(a) == b`.

Let's start with `getConstraintMap`.  It is a completely artificial data 
structure (and function) that exists for Z3 refutation.  It's not what we keep 
in the state and it has a lot of duplicated constraints.  If we have an 
equivalence class `{a, b, c, d, e, f}`, we store only one constraint for all of 
them (thus when we update the class, or one of the members receives a new 
constraint, we can update all of them).  `getConstraintMap` returns a map where 
`a`, `b`, `c`, `d`, `e`, and `f` are mapped to the same constraint.  It's not 
**super** bad, but it's extra work constructing this map and then processing it.

Another, and more important aspect is that when you `setConstraint`, you lose 
information that this symbol is equal/disequal to other symbols.  One example 
here would be a situation where `x + y == z`, and we find out that `y == 0`, we 
should update equivalence class `{x + y, z}` to be a class `{x, z}`.  In order 
to do this, you need to update two maps: `ClassMap` (it's mapping `x + y` to 
`{x + y, z}`) and `ClassMembers` (it's mapping `{x + y, z}` to `x + y` and `z`).

Similar example can be made with `x + y != z`, but updating `ClassMap` and 
`ClassMembers` will fix it.  And you don't even need to touch the actual 
mapping with the actual constraints.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103314

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


[PATCH] D103314: [Analyzer][solver] Simplify existing constraints when a new constraint is added

2021-05-28 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

Thanks Valeriy for the quick review and guidance! I am planning to do the 
changes and continue next week :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103314

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


[PATCH] D102923: [clang][lex] Remark for used header search paths

2021-05-28 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 updated this revision to Diff 348518.
jansvoboda11 added a comment.

Fix naming of new functions/variables


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102923

Files:
  clang/include/clang/Basic/DiagnosticLexKinds.td
  clang/include/clang/Lex/HeaderSearch.h
  clang/lib/Frontend/InitHeaderSearch.cpp
  clang/lib/Lex/HeaderSearch.cpp
  clang/test/Preprocessor/Inputs/header-search-user-entries/a/a.h
  clang/test/Preprocessor/Inputs/header-search-user-entries/a_next/a.h
  clang/test/Preprocessor/Inputs/header-search-user-entries/b/b.h
  clang/test/Preprocessor/Inputs/header-search-user-entries/d/d.h
  clang/test/Preprocessor/header-search-user-entries.c

Index: clang/test/Preprocessor/header-search-user-entries.c
===
--- /dev/null
+++ clang/test/Preprocessor/header-search-user-entries.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -fsyntax-only %s -Rinclude-header-search-usage \
+// RUN:   -I%S/Inputs/header-search-user-entries/a -I%S/Inputs/header-search-user-entries/a_next \
+// RUN:   -I%S/Inputs/header-search-user-entries/b -I%S/Inputs/header-search-user-entries/c \
+// RUN:   -I%S/Inputs/header-search-user-entries/d 2>&1 | FileCheck %s
+
+#include "a.h"
+#include "d.h"
+
+// CHECK: remark: user-provided search path used: '{{.*}}/header-search-user-entries/a'
+// CHECK: remark: user-provided search path used: '{{.*}}/header-search-user-entries/a_next'
+// CHECK: remark: user-provided search path used: '{{.*}}/header-search-user-entries/d'
Index: clang/test/Preprocessor/Inputs/header-search-user-entries/a/a.h
===
--- /dev/null
+++ clang/test/Preprocessor/Inputs/header-search-user-entries/a/a.h
@@ -0,0 +1 @@
+#include_next "a.h"
Index: clang/lib/Lex/HeaderSearch.cpp
===
--- clang/lib/Lex/HeaderSearch.cpp
+++ clang/lib/Lex/HeaderSearch.cpp
@@ -108,6 +108,20 @@
<< NumSubFrameworkLookups << " subframework lookups.\n";
 }
 
+std::vector HeaderSearch::computeUserEntryUsage() const {
+  std::vector UserEntryUsage(HSOpts->UserEntries.size());
+  for (unsigned I = 0, E = SearchDirsUsage.size(); I < E; ++I) {
+// Check whether this DirectoryLookup has been successfully used.
+if (SearchDirsUsage[I]) {
+  auto UserEntryIdxIt = SearchDirToHSEntry.find(I);
+  // Check whether this DirectoryLookup maps to a HeaderSearch::UserEntry.
+  if (UserEntryIdxIt != SearchDirToHSEntry.end())
+UserEntryUsage[UserEntryIdxIt->second] = true;
+}
+  }
+  return UserEntryUsage;
+}
+
 /// CreateHeaderMap - This method returns a HeaderMap for the specified
 /// FileEntry, uniquing them through the 'HeaderMaps' datastructure.
 const HeaderMap *HeaderSearch::CreateHeaderMap(const FileEntry *FE) {
@@ -649,6 +663,17 @@
   return None;
 }
 
+void HeaderSearch::cacheLookupSuccess(LookupFileCacheInfo &CacheLookup,
+  unsigned HitIdx) {
+  CacheLookup.HitIdx = HitIdx;
+  SearchDirsUsage[HitIdx] = true;
+
+  auto UserEntryIdxIt = SearchDirToHSEntry.find(HitIdx);
+  if (UserEntryIdxIt != SearchDirToHSEntry.end())
+Diags.Report(diag::remark_pp_include_header_search_usage)
+<< HSOpts->UserEntries[UserEntryIdxIt->second].Path;
+}
+
 void HeaderSearch::setTarget(const TargetInfo &Target) {
   ModMap.setTarget(Target);
 }
@@ -987,7 +1012,7 @@
   &File->getFileEntry(), isAngled, FoundByHeaderMap);
 
 // Remember this location for the next lookup we do.
-CacheLookup.HitIdx = i;
+cacheLookupSuccess(CacheLookup, i);
 return File;
   }
 
@@ -1017,8 +1042,8 @@
 return MSFE;
   }
 
-  LookupFileCacheInfo &CacheLookup = LookupFileCache[Filename];
-  CacheLookup.HitIdx = LookupFileCache[ScratchFilename].HitIdx;
+  cacheLookupSuccess(LookupFileCache[Filename],
+ LookupFileCache[ScratchFilename].HitIdx);
   // FIXME: SuggestedModule.
   return File;
 }
Index: clang/lib/Frontend/InitHeaderSearch.cpp
===
--- clang/lib/Frontend/InitHeaderSearch.cpp
+++ clang/lib/Frontend/InitHeaderSearch.cpp
@@ -36,9 +36,11 @@
 struct DirectoryLookupInfo {
   IncludeDirGroup Group;
   DirectoryLookup Lookup;
+  Optional UserEntryIdx;
 
-  DirectoryLookupInfo(IncludeDirGroup Group, DirectoryLookup Lookup)
-  : Group(Group), Lookup(Lookup) {}
+  DirectoryLookupInfo(IncludeDirGroup Group, DirectoryLookup Lookup,
+  Optional UserEntryIdx)
+  : Group(Group), Lookup(Lookup), UserEntryIdx(UserEntryIdx) {}
 };
 
 /// InitHeaderSearch - This class makes it easier to set the search paths of
@@ -60,13 +62,15 @@
   /// AddPath - Add the specified path to the specified group list, prefixing
   /// the sysroot if used.
   /// Returns true if the path 

[PATCH] D103317: [Analyzer][engine][solver] Simplify complex constraints

2021-05-28 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko added a comment.

Looking great, thanks!
I have a couple of notes below.




Comment at: clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp:1155-1156
 
-// TODO: Support SymbolCast. Support IntSymExpr when/if we actually
-// start producing them.
 

Do we actually produce them?



Comment at: clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp:1170-1172
+  SVal LHS = getConst(S->getLHS());
+  if (LHS.isUndef())
+LHS = Visit(S->getLHS());

It seems like a very common pattern now: 
```
SVal Const = getConst(Expr);
if (Const.isUndef())
  return Visit(Expr);
return Const;
```

At least we can make a function out of this, so we don't repeat this pattern 
over and over.
But I was thinking more radically to actually replace `Visit` with this, what 
do you think?



Comment at: clang/test/Analysis/simplify-complex-constraints.cpp:25-27
+  if (x + (y + z) != 0)
+return 0;
+  if (y + z != 0)

Since it's not really specific to addition, maybe we can have tests for other 
operators?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103317

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


[PATCH] D102923: [clang][lex] Remark for used header search paths

2021-05-28 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added a comment.

In D102923#2781386 , @Bigcheese wrote:

> I also wonder how we should handle other things that are found via include 
> paths such as module maps.

That's a good point. The logic for module map lookup is more complex than 
header lookup, so I'd be keen to tackle that in a follow-up patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102923

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


[PATCH] D102696: [Analyzer] Find constraints that are directly attached to a BinOp

2021-05-28 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko added a comment.

Oh, wow. Great plan! I'd like to participate. 😊
I have a few comments:

> Alright, I see your point. I agree that solving the problem of "$a +$b +$c
> constrained and then $a + $c got constrained" requires canonicalization.

That was actually not an example for canonicalization, but rather that 
`ParentMap` will exponentially explode due to the number of combinations of 
sub-expressions if we want to make it useful for all cases.
If we do want to do something with situations like this `ParentMap` should be 
re-thought.

> 1. Update `setConstraint` to simplify existing constraints (and adding the
>
> simplified constraint) when a new constraint is added. In this step we'd just
> simply iterate over all existing constraints and would try to simplfy them 
> with
> `simplifySVal`

I like this one!  So, to be more specific: If we add a constraint `Sym -> C`, 
where `C` is a constant, we can try to simplify other constrained symbols, 
where `Sym` is a sub-expression.
I want to add that now (because of me 😅) we do not store constraints as a map 
`Sym -> RangeSet`, it's a bit trickier.
We have a few mappings: `Sym -> EquivalenceClass` (member-to-class 
relationship), `EquivalenceClass -> RangeSet`, `EquivalenceClass -> {Sym}` 
(class-to-members relationship), and `EquivalenceClass -> {EquivalenceClass}` 
(to track disequalities). 
It means that we will need to replace `Sym` with its simplified version in `Sym 
-> EquivalenceClass` and `EquivalenceClass -> {Sym}`.
Not that it is impossible or something, but it makes it a bit harder as it has 
more moving pieces.

> 2. Add the capability to simplify more complex constraints, where there are 3
>
> symbols in the tree. In this change I suggest the extension and overhaul of
> `simplifySVal`. This change would make the following cases to pass (notice the
> 3rd check in each test-case).

This sounds great, but we we do need to think about performance, so we should 
discuss how do we plan to implement such an extension.

> 3. Add canonical trees to the solver. The way we should do this is to build
>
> "flat" sub-trees of associative operands. E.g. `b + a + c` becomes `+(a, b, 
> c)`,
> i.e. a tree with a root and 3 children [1]. The ordering of the children
> could be done by their addresses (`Stmt *`) and we could simply store them in 
> an
> array. Probably we'll need a new mapping: SymbolRef -> CanonicalTree.

I think that flattening is a good idea (and it is widespread in other solvers), 
but "flat" sub-tree (aka non-binary tree).
However, it is useful ONLY if we can efficiently support `isSubsetOf` predicate 
(specifically) for cases like `+(a, b, c)` and `+(a, c)`.

I don't think that `Sym -> Canonical` is a good idea.  The main goal of 
canonicalization is to compact potentially exponential number of equivalent 
ways of spelling the same symbolic expression and have a single representation 
for it.
So, it means that we expect that `Canonicalization(Sym)` will be called for 
multiple `Sym`s producing identical results.  This way `Sym -> Canonical` is 
simply a cache for `Canonicalization` (i.e. maybe shouldn't even be associated 
with a state).

> Then, we check each existing constraints' canonical tree to check
> whether the newly constrained expression is a sub-expression of that.

I'm worried about performance implications of this.

> 4. Extend 3) with `-` and `/`. `lhs - rhs` becomes a `lhs + (-rhs)` and `lhs 
> /rhs`
>
> is substituted wit `lhs * (1/rhs)`.

Is it true for bit-vectors though?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102696

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


[PATCH] D102696: [Analyzer] Find constraints that are directly attached to a BinOp

2021-05-28 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko added a comment.

I just noticed that I simply forgot to click submit yesterday 😩


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102696

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


[PATCH] D103319: [analyzer] Use Optional as a return type of StoreManager::castRegion

2021-05-28 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov created this revision.
ASDenysPetrov added reviewers: steakhal, NoQ.
ASDenysPetrov added a project: clang.
Herald added subscribers: manas, martong, dkrupp, donat.nagy, Szelethus, 
mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, xazax.hun.
ASDenysPetrov requested review of this revision.
Herald added a subscriber: cfe-commits.

Make StoreManager::castRegion function usage safier. Replace `const MemRegion 
*` with `Optional`. Simplified one of related test cases due 
to suggestions in D101635 .


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D103319

Files:
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/Store.h
  clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
  clang/lib/StaticAnalyzer/Core/Store.cpp

Index: clang/lib/StaticAnalyzer/Core/Store.cpp
===
--- clang/lib/StaticAnalyzer/Core/Store.cpp
+++ clang/lib/StaticAnalyzer/Core/Store.cpp
@@ -71,7 +71,8 @@
   return MRMgr.getElementRegion(T, idx, R, Ctx);
 }
 
-const MemRegion *StoreManager::castRegion(const MemRegion *R, QualType CastToTy) {
+Optional StoreManager::castRegion(const MemRegion *R,
+ QualType CastToTy) {
   ASTContext &Ctx = StateMgr.getContext();
 
   // Handle casts to Objective-C objects.
@@ -88,7 +89,7 @@
 
 // We don't know what to make of it.  Return a NULL region, which
 // will be interpreted as UnknownVal.
-return nullptr;
+return None;
   }
 
   // Now assume we are casting from pointer to pointer. Other cases should
@@ -168,7 +169,7 @@
   // If we cannot compute a raw offset, throw up our hands and return
   // a NULL MemRegion*.
   if (!baseR)
-return nullptr;
+return None;
 
   CharUnits off = rawOff.getOffset();
 
Index: clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
===
--- clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
+++ clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
@@ -753,16 +753,16 @@
 if (const auto *SR = dyn_cast(R)) {
   QualType SRTy = SR->getSymbol()->getType();
   if (!hasSameUnqualifiedPointeeType(SRTy, CastTy)) {
-R = StateMgr.getStoreManager().castRegion(SR, CastTy);
-return loc::MemRegionVal(R);
+if (auto OptR = StateMgr.getStoreManager().castRegion(SR, CastTy))
+  return loc::MemRegionVal(*OptR);
   }
 }
   }
   // Next fixes pointer dereference using type different from its initial
   // one. See PR37503 and PR49007 for details.
   if (const auto *ER = dyn_cast(R)) {
-if ((R = StateMgr.getStoreManager().castRegion(ER, CastTy)))
-  return loc::MemRegionVal(R);
+if (auto OptR = StateMgr.getStoreManager().castRegion(ER, CastTy))
+  return loc::MemRegionVal(*OptR);
   }
 
   return V;
@@ -807,8 +807,8 @@
 
 // Get the result of casting a region to a different type.
 const MemRegion *R = V.getRegion();
-if ((R = StateMgr.getStoreManager().castRegion(R, CastTy)))
-  return loc::MemRegionVal(R);
+if (auto OptR = StateMgr.getStoreManager().castRegion(R, CastTy))
+  return loc::MemRegionVal(*OptR);
   }
 
   // Pointer to whatever else.
@@ -873,8 +873,8 @@
   if (!IsUnknownOriginalType && Loc::isLocType(CastTy) &&
   OriginalTy->isIntegralOrEnumerationType()) {
 if (const MemRegion *R = L.getAsRegion())
-  if ((R = StateMgr.getStoreManager().castRegion(R, CastTy)))
-return loc::MemRegionVal(R);
+  if (auto OptR = StateMgr.getStoreManager().castRegion(R, CastTy))
+return loc::MemRegionVal(*OptR);
 return L;
   }
 
@@ -890,8 +890,8 @@
   // Delegate to store manager to get the result of casting a region to a
   // different type. If the MemRegion* returned is NULL, this expression
   // Evaluates to UnknownVal.
-  if ((R = StateMgr.getStoreManager().castRegion(R, CastTy)))
-return loc::MemRegionVal(R);
+  if (auto OptR = StateMgr.getStoreManager().castRegion(R, CastTy))
+return loc::MemRegionVal(*OptR);
 }
   } else {
 if (Loc::isLocType(CastTy)) {
Index: clang/include/clang/StaticAnalyzer/Core/PathSensitive/Store.h
===
--- clang/include/clang/StaticAnalyzer/Core/PathSensitive/Store.h
+++ clang/include/clang/StaticAnalyzer/Core/PathSensitive/Store.h
@@ -181,7 +181,8 @@
   /// castRegion - Used by ExprEngine::VisitCast to handle casts from
   ///  a MemRegion* to a specific location type.  'R' is the region being
   ///  casted and 'CastToTy' the result type of the cast.
-  const MemRegion *castRegion(const MemRegion *region, QualType CastToTy);
+  Optional castRegion(const MemRegion *region,
+ QualType CastToTy);
 
   virtual StoreRef removeDeadBindings(Store store, const St

[PATCH] D101635: [analyzer] Fix assertion in SVals.h

2021-05-28 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment.
Herald added a subscriber: manas.

@steakhal, @NoQ 
Thanks for your replies. I've made a patch according your suggestions D103319 
.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101635

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


[PATCH] D103319: [analyzer] Use Optional as a return type of StoreManager::castRegion

2021-05-28 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov updated this revision to Diff 348524.
ASDenysPetrov added a comment.

Added a simplified test case.


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

https://reviews.llvm.org/D103319

Files:
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/Store.h
  clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
  clang/lib/StaticAnalyzer/Core/Store.cpp
  clang/test/Analysis/casts.c

Index: clang/test/Analysis/casts.c
===
--- clang/test/Analysis/casts.c
+++ clang/test/Analysis/casts.c
@@ -251,18 +251,9 @@
 ;
 }
 
-// See PR50179.
-// Just don't crash.
-typedef struct taskS {
-  void *pJob;
-} taskS;
-
-typedef struct workS {
-  taskS *pTaskList;
-} workS;
-
-void *getTaskJob(unsigned jobId, workS *pWork, unsigned taskId) {
-  const taskS *pTask = pWork->pTaskList + taskId;
-  taskS task = *pTask;
-  return task.pJob;
+// PR50179.
+struct S {};
+void symbolic_offset(S *ptr, int i) {
+  const S *pS = ptr + i;
+  S s = *pS; // no-crash
 }
Index: clang/lib/StaticAnalyzer/Core/Store.cpp
===
--- clang/lib/StaticAnalyzer/Core/Store.cpp
+++ clang/lib/StaticAnalyzer/Core/Store.cpp
@@ -71,7 +71,8 @@
   return MRMgr.getElementRegion(T, idx, R, Ctx);
 }
 
-const MemRegion *StoreManager::castRegion(const MemRegion *R, QualType CastToTy) {
+Optional StoreManager::castRegion(const MemRegion *R,
+ QualType CastToTy) {
   ASTContext &Ctx = StateMgr.getContext();
 
   // Handle casts to Objective-C objects.
@@ -88,7 +89,7 @@
 
 // We don't know what to make of it.  Return a NULL region, which
 // will be interpreted as UnknownVal.
-return nullptr;
+return None;
   }
 
   // Now assume we are casting from pointer to pointer. Other cases should
@@ -168,7 +169,7 @@
   // If we cannot compute a raw offset, throw up our hands and return
   // a NULL MemRegion*.
   if (!baseR)
-return nullptr;
+return None;
 
   CharUnits off = rawOff.getOffset();
 
Index: clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
===
--- clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
+++ clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
@@ -753,16 +753,16 @@
 if (const auto *SR = dyn_cast(R)) {
   QualType SRTy = SR->getSymbol()->getType();
   if (!hasSameUnqualifiedPointeeType(SRTy, CastTy)) {
-R = StateMgr.getStoreManager().castRegion(SR, CastTy);
-return loc::MemRegionVal(R);
+if (auto OptR = StateMgr.getStoreManager().castRegion(SR, CastTy))
+  return loc::MemRegionVal(*OptR);
   }
 }
   }
   // Next fixes pointer dereference using type different from its initial
   // one. See PR37503 and PR49007 for details.
   if (const auto *ER = dyn_cast(R)) {
-if ((R = StateMgr.getStoreManager().castRegion(ER, CastTy)))
-  return loc::MemRegionVal(R);
+if (auto OptR = StateMgr.getStoreManager().castRegion(ER, CastTy))
+  return loc::MemRegionVal(*OptR);
   }
 
   return V;
@@ -807,8 +807,8 @@
 
 // Get the result of casting a region to a different type.
 const MemRegion *R = V.getRegion();
-if ((R = StateMgr.getStoreManager().castRegion(R, CastTy)))
-  return loc::MemRegionVal(R);
+if (auto OptR = StateMgr.getStoreManager().castRegion(R, CastTy))
+  return loc::MemRegionVal(*OptR);
   }
 
   // Pointer to whatever else.
@@ -873,8 +873,8 @@
   if (!IsUnknownOriginalType && Loc::isLocType(CastTy) &&
   OriginalTy->isIntegralOrEnumerationType()) {
 if (const MemRegion *R = L.getAsRegion())
-  if ((R = StateMgr.getStoreManager().castRegion(R, CastTy)))
-return loc::MemRegionVal(R);
+  if (auto OptR = StateMgr.getStoreManager().castRegion(R, CastTy))
+return loc::MemRegionVal(*OptR);
 return L;
   }
 
@@ -890,8 +890,8 @@
   // Delegate to store manager to get the result of casting a region to a
   // different type. If the MemRegion* returned is NULL, this expression
   // Evaluates to UnknownVal.
-  if ((R = StateMgr.getStoreManager().castRegion(R, CastTy)))
-return loc::MemRegionVal(R);
+  if (auto OptR = StateMgr.getStoreManager().castRegion(R, CastTy))
+return loc::MemRegionVal(*OptR);
 }
   } else {
 if (Loc::isLocType(CastTy)) {
Index: clang/include/clang/StaticAnalyzer/Core/PathSensitive/Store.h
===
--- clang/include/clang/StaticAnalyzer/Core/PathSensitive/Store.h
+++ clang/include/clang/StaticAnalyzer/Core/PathSensitive/Store.h
@@ -181,7 +181,8 @@
   /// castRegion - Used by ExprEngine::VisitCast to handle casts from
   ///  a MemRegion* to a specific location type.  'R' is the region being
   ///  casted and 'CastToTy' the result type of the cast.

[PATCH] D99901: [Driver][test] Test intended target only

2021-05-28 Thread Ted Woodward via Phabricator via cfe-commits
ted added a comment.

Why would we not want to support this on other targets, like Arm?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99901

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


[PATCH] D102839: [RISCV][Clang] Add -mno-div option to disable hardware int division

2021-05-28 Thread ksyx via Phabricator via cfe-commits
ksyx updated this revision to Diff 348525.
ksyx added a comment.

split `Zmmul` implementation and `-mno-div` implementation


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

https://reviews.llvm.org/D102839

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Arch/RISCV.cpp
  clang/test/Driver/riscv-no-div.c


Index: clang/test/Driver/riscv-no-div.c
===
--- /dev/null
+++ clang/test/Driver/riscv-no-div.c
@@ -0,0 +1,30 @@
+// RUN: %clang -target riscv32-unknown-elf %s -mno-div -S -o - 2>&1 \
+// RUN:   | not FileCheck -check-prefix=CHECK-DIV %s
+
+// RUN: %clang -target riscv64-unknown-elf %s -mno-div -S -o - 2>&1 \
+// RUN:   | not FileCheck -check-prefix=CHECK-DIV %s
+
+// RUN: %clang -target riscv32-unknown-elf %s -mno-div -S -o - 2>&1 \
+// RUN:   | not FileCheck -check-prefix=CHECK-REM %s
+
+// RUN: %clang -target riscv64-unknown-elf %s -mno-div -S -o - 2>&1 \
+// RUN:   | not FileCheck -check-prefix=CHECK-REM %s
+
+// RUN: %clang -target riscv32-unknown-elf %s -mno-div -S -o - 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-MUL %s
+
+// RUN: %clang -target riscv64-unknown-elf %s -mno-div -S -o - 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-MUL %s
+
+// RUN: %clang -target riscv32-unknown-elf %s -S -o - 2>&1 \
+// RUN:   | FileCheck -check-prefixes=CHECK-MUL,CHECK-DIV,CHECK-REM %s
+
+// RUN: %clang -target riscv64-unknown-elf %s -S -o - 2>&1 \
+// RUN:   | FileCheck -check-prefixes=CHECK-MUL,CHECK-DIV,CHECK-REM %s
+
+int foo(int x, int y) {
+  // CHECK-DIV: div{{w?}} a{{[0-9]}}, a{{[0-9]}}, a{{[0-9]}}
+  // CHECK-REM: rem{{w?}} a{{[0-9]}}, a{{[0-9]}}, a{{[0-9]}}
+  // CHECK-MUL: mul{{w?}} a{{[0-9]}}, a{{[0-9]}}, a{{[0-9]}}
+  return (x / y) * (x % y);
+}
Index: clang/lib/Driver/ToolChains/Arch/RISCV.cpp
===
--- clang/lib/Driver/ToolChains/Arch/RISCV.cpp
+++ clang/lib/Driver/ToolChains/Arch/RISCV.cpp
@@ -572,6 +572,15 @@
   // Now add any that the user explicitly requested on the command line,
   // which may override the defaults.
   handleTargetFeaturesGroup(Args, Features, 
options::OPT_m_riscv_Features_Group);
+
+  bool noDiv = Args.hasFlag(options::OPT_mno_div, options::OPT_mdiv, false);
+  for (auto &Feature : Features) {
+if (noDiv && (Feature == "+m" || Feature == "-div")) {
+  Feature = "+experimental-zmmul";
+} else if (Feature == "+div") {
+  Feature = "+m";
+}
+  }
 }
 
 StringRef riscv::getRISCVABI(const ArgList &Args, const llvm::Triple &Triple) {
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -3146,6 +3146,10 @@
   HelpText<"Enable using library calls for save and restore">;
 def mno_save_restore : Flag<["-"], "mno-save-restore">, 
Group,
   HelpText<"Disable using library calls for save and restore">;
+def mno_div : Flag<["-"], "mno-div">, Group,
+  HelpText<"Disable integer division instructions in M extension">;
+def mdiv : Flag<["-"], "mdiv">, Group,
+  HelpText<"Enable integer division instructions in M extension">;
 def mcmodel_EQ_medlow : Flag<["-"], "mcmodel=medlow">, 
Group,
   Flags<[CC1Option]>, Alias, AliasArgs<["small"]>,
   HelpText<"Equivalent to -mcmodel=small, compatible with RISC-V gcc.">;


Index: clang/test/Driver/riscv-no-div.c
===
--- /dev/null
+++ clang/test/Driver/riscv-no-div.c
@@ -0,0 +1,30 @@
+// RUN: %clang -target riscv32-unknown-elf %s -mno-div -S -o - 2>&1 \
+// RUN:   | not FileCheck -check-prefix=CHECK-DIV %s
+
+// RUN: %clang -target riscv64-unknown-elf %s -mno-div -S -o - 2>&1 \
+// RUN:   | not FileCheck -check-prefix=CHECK-DIV %s
+
+// RUN: %clang -target riscv32-unknown-elf %s -mno-div -S -o - 2>&1 \
+// RUN:   | not FileCheck -check-prefix=CHECK-REM %s
+
+// RUN: %clang -target riscv64-unknown-elf %s -mno-div -S -o - 2>&1 \
+// RUN:   | not FileCheck -check-prefix=CHECK-REM %s
+
+// RUN: %clang -target riscv32-unknown-elf %s -mno-div -S -o - 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-MUL %s
+
+// RUN: %clang -target riscv64-unknown-elf %s -mno-div -S -o - 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-MUL %s
+
+// RUN: %clang -target riscv32-unknown-elf %s -S -o - 2>&1 \
+// RUN:   | FileCheck -check-prefixes=CHECK-MUL,CHECK-DIV,CHECK-REM %s
+
+// RUN: %clang -target riscv64-unknown-elf %s -S -o - 2>&1 \
+// RUN:   | FileCheck -check-prefixes=CHECK-MUL,CHECK-DIV,CHECK-REM %s
+
+int foo(int x, int y) {
+  // CHECK-DIV: div{{w?}} a{{[0-9]}}, a{{[0-9]}}, a{{[0-9]}}
+  // CHECK-REM: rem{{w?}} a{{[0-9]}}, a{{[0-9]}}, a{{[0-9]}}
+  // CHECK-MUL: mul{{w?}} a{{[0-9]}}, a{{[0-9]}}, a{{[0-9]}}
+  return (x / y) * (x % y);
+}
Index: clang/lib/Driver/ToolChains/Arch/RISCV.cpp
===
-

[PATCH] D103314: [Analyzer][solver] Simplify existing constraints when a new constraint is added

2021-05-28 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko added inline comments.



Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:1561
+  return nullptr;
+
+ConstraintMap CM = getConstraintMap(State);

Also I think we can introduce a simple, but efficient optimization of kicking 
off the simplification process only when `Constraint` is a constant.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103314

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


[PATCH] D99901: [Driver][test] Test intended target only

2021-05-28 Thread Jinsong Ji via Phabricator via cfe-commits
jsji added a comment.

In D99901#2787034 , @ted wrote:

> Why would we not want to support this on other targets, like Arm? Fixes for 
> AIX shouldn't impact other things.

Feel free to update the triple to include arm , as long as the tests focus on 
gnu tool chain only.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99901

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


[PATCH] D102782: Add support for Warning Flag "-Wstack-usage="

2021-05-28 Thread Ryan Santhirarajan via Phabricator via cfe-commits
rsanthir.quic updated this revision to Diff 348531.
rsanthir.quic added a comment.

rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102782

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Frontend/backend-stack-usage-diagnostic.c


Index: clang/test/Frontend/backend-stack-usage-diagnostic.c
===
--- /dev/null
+++ clang/test/Frontend/backend-stack-usage-diagnostic.c
@@ -0,0 +1,17 @@
+// RUN: %clang -Wstack-usage=0 -o /dev/null -c %s 2> %t.err
+// RUN: FileCheck < %t.err %s --check-prefix=WARN
+// RUN: %clang -Wno-stack-usage= -w -o /dev/null -c %s 2> %t.err
+// RUN: FileCheck < %t.err %s --check-prefix=IGNORE --allow-empty
+// RUN: %clang -Wstack-usage=0 -w -o /dev/null -c %s 2> %t.err
+// RUN: FileCheck < %t.err %s --check-prefix=IGNORE --allow-empty
+// RUN: %clang -Wstack-usage=3 -o /dev/null -c %s 2> %t.err
+// RUN: FileCheck < %t.err %s --check-prefix=WARN
+// RUN: %clang -Wstack-usage=100 -o /dev/null -c %s 2> %t.err
+// RUN: FileCheck < %t.err %s --check-prefix=IGNORE --allow-empty
+
+// WARN: warning: stack frame size of {{[0-9]+}} bytes in function 
'test_square'
+// IGNORE-NOT:  stack frame size of {{[0-9]+}} bytes in function 'test_square'
+int test_square(int num) {
+  return num * num;
+}
+
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -4762,12 +4762,14 @@
   D.Diag(diag::err_aix_default_altivec_abi);
   }
 
-  if (Arg *A = Args.getLastArg(options::OPT_Wframe_larger_than_EQ)) {
-StringRef v = A->getValue();
-CmdArgs.push_back("-mllvm");
-CmdArgs.push_back(Args.MakeArgString("-warn-stack-size=" + v));
-A->claim();
-  }
+  if (Args.hasFlag(options::OPT_Wframe_larger_than_EQ,
+   options::OPT_Wno_frame_larger_than_EQ, false))
+if (Arg *A = Args.getLastArg(options::OPT_Wframe_larger_than_EQ)) {
+  StringRef v = A->getValue();
+  CmdArgs.push_back("-mllvm");
+  CmdArgs.push_back(Args.MakeArgString("-warn-stack-size=" + v));
+  A->claim();
+}
 
   if (!Args.hasFlag(options::OPT_fjump_tables, options::OPT_fno_jump_tables,
 true))
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2500,6 +2500,11 @@
 def Wlarger_than_EQ : Joined<["-"], "Wlarger-than=">, 
Group;
 def Wlarger_than_ : Joined<["-"], "Wlarger-than-">, Alias;
 def Wframe_larger_than_EQ : Joined<["-"], "Wframe-larger-than=">, 
Group, Flags<[NoXarchOption]>;
+def Wno_frame_larger_than_EQ : Joined<["-"], "Wnoframe-larger-than=">, 
Group, Flags<[NoXarchOption]>;
+def Wstack_stack_usage_EQ : Joined<["-"], "Wstack-usage=">, 
Flags<[NoXarchOption]>,
+  Alias;
+def Wno_stack_stack_usage_EQ : Joined<["-"], "Wno-stack-usage=">, 
Flags<[NoXarchOption]>,
+  Alias;
 
 def : Flag<["-"], "fterminated-vtables">, Alias;
 defm threadsafe_statics : BoolFOption<"threadsafe-statics",


Index: clang/test/Frontend/backend-stack-usage-diagnostic.c
===
--- /dev/null
+++ clang/test/Frontend/backend-stack-usage-diagnostic.c
@@ -0,0 +1,17 @@
+// RUN: %clang -Wstack-usage=0 -o /dev/null -c %s 2> %t.err
+// RUN: FileCheck < %t.err %s --check-prefix=WARN
+// RUN: %clang -Wno-stack-usage= -w -o /dev/null -c %s 2> %t.err
+// RUN: FileCheck < %t.err %s --check-prefix=IGNORE --allow-empty
+// RUN: %clang -Wstack-usage=0 -w -o /dev/null -c %s 2> %t.err
+// RUN: FileCheck < %t.err %s --check-prefix=IGNORE --allow-empty
+// RUN: %clang -Wstack-usage=3 -o /dev/null -c %s 2> %t.err
+// RUN: FileCheck < %t.err %s --check-prefix=WARN
+// RUN: %clang -Wstack-usage=100 -o /dev/null -c %s 2> %t.err
+// RUN: FileCheck < %t.err %s --check-prefix=IGNORE --allow-empty
+
+// WARN: warning: stack frame size of {{[0-9]+}} bytes in function 'test_square'
+// IGNORE-NOT:  stack frame size of {{[0-9]+}} bytes in function 'test_square'
+int test_square(int num) {
+  return num * num;
+}
+
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -4762,12 +4762,14 @@
   D.Diag(diag::err_aix_default_altivec_abi);
   }
 
-  if (Arg *A = Args.getLastArg(options::OPT_Wframe_larger_than_EQ)) {
-StringRef v = A->getValue();
-CmdArgs.push_back("-mllvm");
-CmdArgs.push_back(Args.MakeArgString("-warn-stack-size=" + v));
-A->claim();
-  }
+  if (Args.hasFlag(options::OPT_Wframe_larger_than_EQ,
+   options::OPT_Wno_frame_larger_than_EQ, false))
+if (Arg *A = Args.getLastArg(options::OPT

[PATCH] D99901: [Driver][test] Test intended target only

2021-05-28 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added inline comments.



Comment at: clang/test/Driver/nostdincxx.cpp:4
 // RUN: not %clangxx -nostdlibinc %s 2>&1 | FileCheck %s
-// RUN: not %clangxx -fsyntax-only -nostdinc -nostdinc++ %s 2>&1 | FileCheck 
/dev/null --implicit-check-not=-Wunused-command-line-argument
+// RUN: not %clangxx -target unknown-unknown-gnu -fsyntax-only -nostdinc 
-nostdinc++ %s 2>&1 | FileCheck /dev/null 
--implicit-check-not=-Wunused-command-line-argument
 // CHECK: file not found

jsji wrote:
> MaskRay wrote:
> > `error: unknown target triple 'unknown-unknown-hurd-gnu', please use 
> > -triple or -arch`
> > 
> > Perhaps this should UNSUPPORTED aix if aix does not support -nostdinc++.
> No, AIX does support `-nostdinc++`, we don't want to unsupport this whole test
I believe the original fix was meant to be generally applicable but 
unintentionally applied in only a limited fashion. Ideally, the test would have 
been left as-is and the various toolchains changed similarly.

That is:
```
$ clang -nostdinc -nostdinc++ -xc++ /dev/null -fsyntax-only
clang-13: warning: argument unused during compilation: '-nostdinc++' 
[-Wunused-command-line-argument]
```

should not happen. I guess a way forward is to first make the change for AIX 
(and update the test to check on AIX) and then to commit a separate NFCI commit 
to apply the test broadly to see if anyone finds the test to be failing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99901

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


[PATCH] D91630: [Parse] Add parsing support for C++ attributes on using-declarations

2021-05-28 Thread Louis Dionne via Phabricator via cfe-commits
ldionne updated this revision to Diff 348547.
ldionne marked 3 inline comments as done.
ldionne added a comment.

Apply review comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91630

Files:
  clang/docs/LanguageExtensions.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/Features.def
  clang/include/clang/Parse/Parser.h
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/Parser/cxx0x-attributes.cpp
  clang/test/SemaCXX/cxx11-attributes-on-using-declaration.cpp

Index: clang/test/SemaCXX/cxx11-attributes-on-using-declaration.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/cxx11-attributes-on-using-declaration.cpp
@@ -0,0 +1,42 @@
+// RUN: %clang_cc1 -pedantic -triple x86_64-apple-macos11 -std=c++20 -fsyntax-only -verify %s
+
+static_assert(__has_extension(cxx_attributes_on_using_declarations), "");
+
+namespace NS { typedef int x; }
+
+[[clang::annotate("foo")]] using NS::x; // expected-warning{{ISO C++ does not allow an attribute list to appear here}}
+
+
+[[deprecated]] using NS::x;// expected-warning {{'deprecated' currently has no effect on using-declarations}} expected-warning{{ISO C++ does not allow}}
+using NS::x [[deprecated]];// expected-warning {{'deprecated' currently has no effect on using-declarations}} expected-warning{{ISO C++ does not allow}}
+using NS::x __attribute__((deprecated));   // expected-warning {{'deprecated' currently has no effect on using-declarations}}
+using NS::x __attribute__((availability(macos,introduced=1))); // expected-warning {{'availability' currently has no effect on using-declarations}}
+
+[[clang::availability(macos,introduced=1)]] using NS::x; // expected-warning {{'availability' currently has no effect on using-declarations}} expected-warning{{ISO C++ does not allow}}
+
+// expected-warning@+1 3 {{ISO C++ does not allow an attribute list to appear here}}
+[[clang::annotate("A")]] using NS::x [[clang::annotate("Y")]], NS::x [[clang::annotate("Z")]];
+
+template 
+struct S : T {
+  [[deprecated]] using typename T::x; // expected-warning{{ISO C++ does not allow}} expected-warning {{'deprecated' currently has no effect on using-declarations}}
+  [[deprecated]] using T::y;  // expected-warning{{ISO C++ does not allow}} expected-warning {{'deprecated' currently has no effect on using-declarations}}
+
+  using typename T::z [[deprecated]]; // expected-warning{{ISO C++ does not allow}} expected-warning {{'deprecated' currently has no effect on using-declarations}}
+  using T::a [[deprecated]];  // expected-warning{{ISO C++ does not allow}} expected-warning {{'deprecated' currently has no effect on using-declarations}}
+};
+
+struct Base {};
+
+template 
+struct DepBase1 : B {
+  using B::B [[]];
+
+};
+template 
+struct DepBase2 : B {
+  using B::B __attribute__(());
+};
+
+DepBase1 db1;
+DepBase2 db2;
Index: clang/test/Parser/cxx0x-attributes.cpp
===
--- clang/test/Parser/cxx0x-attributes.cpp
+++ clang/test/Parser/cxx0x-attributes.cpp
@@ -131,12 +131,12 @@
 [[]] static_assert(true, ""); //expected-error {{an attribute list cannot appear here}}
 [[]] asm(""); // expected-error {{an attribute list cannot appear here}}
 
-[[]] using ns::i; // expected-error {{an attribute list cannot appear here}}
+[[]] using ns::i;
 [[unknown]] using namespace ns; // expected-warning {{unknown attribute 'unknown' ignored}}
 [[noreturn]] using namespace ns; // expected-error {{'noreturn' attribute only applies to functions}}
 namespace [[]] ns2 {} // expected-warning {{attributes on a namespace declaration are a C++17 extension}}
 
-using [[]] alignas(4) [[]] ns::i; // expected-error {{an attribute list cannot appear here}}
+using[[]] alignas(4)[[]] ns::i;  // expected-error {{an attribute list cannot appear here}} expected-error {{'alignas' attribute only applies to variables, data members and tag types}} expected-warning {{ISO C++}}
 using [[]] alignas(4) [[]] foobar = int; // expected-error {{an attribute list cannot appear here}} expected-error {{'alignas' attribute only applies to}}
 
 void bad_attributes_in_do_while() {
@@ -157,7 +157,16 @@
 [[]] using T = int; // expected-error {{an attribute list cannot appear here}}
 using T [[]] = int; // ok
 template using U [[]] = T;
-using ns::i [[]]; // expected-error {{an attribute list cannot appear here}}
+using ns::i [[]];
+using ns::i [[]], ns::i [[]]; // expected-warning {{use of multiple declarators in a single using declaration is a C++17 extension}}
+struct using_in_struct_base {
+  typedef int i, 

[clang] dc67299 - [clang][Parse] Add parsing support for C++ attributes on using-declarations

2021-05-28 Thread Louis Dionne via cfe-commits

Author: Erik Pilkington
Date: 2021-05-28T12:00:33-04:00
New Revision: dc672999a9b12a156991891dc400308b52d569ba

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

LOG: [clang][Parse] Add parsing support for C++ attributes on using-declarations

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

Added: 
clang/test/SemaCXX/cxx11-attributes-on-using-declaration.cpp

Modified: 
clang/docs/LanguageExtensions.rst
clang/docs/ReleaseNotes.rst
clang/include/clang/Basic/DiagnosticParseKinds.td
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Basic/Features.def
clang/include/clang/Parse/Parser.h
clang/lib/Parse/ParseDecl.cpp
clang/lib/Parse/ParseDeclCXX.cpp
clang/lib/Sema/SemaDeclAttr.cpp
clang/lib/Sema/SemaDeclCXX.cpp
clang/test/Parser/cxx0x-attributes.cpp

Removed: 




diff  --git a/clang/docs/LanguageExtensions.rst 
b/clang/docs/LanguageExtensions.rst
index 129e73345b2a2..c60b8b39e1c9e 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -632,6 +632,20 @@ Attributes on the ``enum`` declaration do not apply to 
individual enumerators.
 
 Query for this feature with ``__has_extension(enumerator_attributes)``.
 
+C++11 Attributes on using-declarations
+==
+
+Clang allows C++-style ``[[]]`` attributes to be written on using-declarations.
+For instance:
+
+.. code-block:: c++
+
+  [[clang::using_if_exists]] using foo::bar;
+  using foo::baz [[clang::using_if_exists]];
+
+You can test for support for this extension with
+``__has_extension(cxx_attributes_on_using_declarations)``.
+
 'User-Specified' System Frameworks
 ==
 

diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 81609fa6efdfd..b43300ad66461 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -113,6 +113,9 @@ Attribute Changes in Clang
 
 - ...
 
+- Added support for C++11-style ``[[]]`` attributes on using-declarations, as a
+  clang extension.
+
 Windows Support
 ---
 

diff  --git a/clang/include/clang/Basic/DiagnosticParseKinds.td 
b/clang/include/clang/Basic/DiagnosticParseKinds.td
index 97cb7020f3452..6d5d08e5fbad1 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -693,6 +693,9 @@ def ext_using_attribute_ns : ExtWarn<
 def err_using_attribute_ns_conflict : Error<
   "attribute with scope specifier cannot follow default scope specifier">;
 def err_attributes_not_allowed : Error<"an attribute list cannot appear here">;
+def ext_cxx11_attr_placement : ExtWarn<
+  "ISO C++ does not allow an attribute list to appear here">,
+  InGroup>;
 def err_attributes_misplaced : Error<"misplaced attributes; expected 
attributes here">;
 def err_l_square_l_square_not_attribute : Error<
   "C++11 only allows consecutive left square brackets when "

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 4b653b8b47370..80130c2584fe5 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -3957,6 +3957,9 @@ def warn_attribute_sentinel_named_arguments : Warning<
 def warn_attribute_sentinel_not_variadic : Warning<
   "'sentinel' attribute only supported for variadic 
%select{functions|blocks}0">,
   InGroup;
+def warn_deprecated_ignored_on_using : Warning<
+  "%0 currently has no effect on a using declaration">,
+  InGroup;
 def err_attribute_sentinel_less_than_zero : Error<
   "'sentinel' parameter 1 less than zero">;
 def err_attribute_sentinel_not_zero_or_one : Error<

diff  --git a/clang/include/clang/Basic/Features.def 
b/clang/include/clang/Basic/Features.def
index a7a5e06a937e0..592e3e33baf1a 100644
--- a/clang/include/clang/Basic/Features.def
+++ b/clang/include/clang/Basic/Features.def
@@ -259,6 +259,7 @@ EXTENSION(gnu_asm, LangOpts.GNUAsm)
 EXTENSION(gnu_asm_goto_with_outputs, LangOpts.GNUAsm)
 EXTENSION(matrix_types, LangOpts.MatrixTypes)
 EXTENSION(matrix_types_scalar_division, true)
+EXTENSION(cxx_attributes_on_using_declarations, LangOpts.CPlusPlus11)
 
 FEATURE(cxx_abi_relative_vtable, LangOpts.CPlusPlus && 
LangOpts.RelativeCXXABIVTables)
 

diff  --git a/clang/include/clang/Parse/Parser.h 
b/clang/include/clang/Parse/Parser.h
index e3e6509b025e5..cb618d172c5b1 100644
--- a/clang/include/clang/Parse/Parser.h
+++ b/clang/include/clang/Parse/Parser.h
@@ -2634,6 +2634,10 @@ class Parser : public CodeCompletionHandler {
   /// locations where attributes are not allowed.
   void DiagnoseAndSkipCXX11Attributes();
 
+  /// Emit warnings for C++11 and C2x attributes that are in a position that
+  /// clang accep

[PATCH] D91630: [Parse] Add parsing support for C++ attributes on using-declarations

2021-05-28 Thread Louis Dionne 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 rGdc672999a9b1: [clang][Parse] Add parsing support for C++ 
attributes on using-declarations (authored by erik.pilkington, committed by 
ldionne).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91630

Files:
  clang/docs/LanguageExtensions.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/Features.def
  clang/include/clang/Parse/Parser.h
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/Parser/cxx0x-attributes.cpp
  clang/test/SemaCXX/cxx11-attributes-on-using-declaration.cpp

Index: clang/test/SemaCXX/cxx11-attributes-on-using-declaration.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/cxx11-attributes-on-using-declaration.cpp
@@ -0,0 +1,42 @@
+// RUN: %clang_cc1 -pedantic -triple x86_64-apple-macos11 -std=c++20 -fsyntax-only -verify %s
+
+static_assert(__has_extension(cxx_attributes_on_using_declarations), "");
+
+namespace NS { typedef int x; }
+
+[[clang::annotate("foo")]] using NS::x; // expected-warning{{ISO C++ does not allow an attribute list to appear here}}
+
+
+[[deprecated]] using NS::x;// expected-warning {{'deprecated' currently has no effect on using-declarations}} expected-warning{{ISO C++ does not allow}}
+using NS::x [[deprecated]];// expected-warning {{'deprecated' currently has no effect on using-declarations}} expected-warning{{ISO C++ does not allow}}
+using NS::x __attribute__((deprecated));   // expected-warning {{'deprecated' currently has no effect on using-declarations}}
+using NS::x __attribute__((availability(macos,introduced=1))); // expected-warning {{'availability' currently has no effect on using-declarations}}
+
+[[clang::availability(macos,introduced=1)]] using NS::x; // expected-warning {{'availability' currently has no effect on using-declarations}} expected-warning{{ISO C++ does not allow}}
+
+// expected-warning@+1 3 {{ISO C++ does not allow an attribute list to appear here}}
+[[clang::annotate("A")]] using NS::x [[clang::annotate("Y")]], NS::x [[clang::annotate("Z")]];
+
+template 
+struct S : T {
+  [[deprecated]] using typename T::x; // expected-warning{{ISO C++ does not allow}} expected-warning {{'deprecated' currently has no effect on using-declarations}}
+  [[deprecated]] using T::y;  // expected-warning{{ISO C++ does not allow}} expected-warning {{'deprecated' currently has no effect on using-declarations}}
+
+  using typename T::z [[deprecated]]; // expected-warning{{ISO C++ does not allow}} expected-warning {{'deprecated' currently has no effect on using-declarations}}
+  using T::a [[deprecated]];  // expected-warning{{ISO C++ does not allow}} expected-warning {{'deprecated' currently has no effect on using-declarations}}
+};
+
+struct Base {};
+
+template 
+struct DepBase1 : B {
+  using B::B [[]];
+
+};
+template 
+struct DepBase2 : B {
+  using B::B __attribute__(());
+};
+
+DepBase1 db1;
+DepBase2 db2;
Index: clang/test/Parser/cxx0x-attributes.cpp
===
--- clang/test/Parser/cxx0x-attributes.cpp
+++ clang/test/Parser/cxx0x-attributes.cpp
@@ -131,12 +131,12 @@
 [[]] static_assert(true, ""); //expected-error {{an attribute list cannot appear here}}
 [[]] asm(""); // expected-error {{an attribute list cannot appear here}}
 
-[[]] using ns::i; // expected-error {{an attribute list cannot appear here}}
+[[]] using ns::i;
 [[unknown]] using namespace ns; // expected-warning {{unknown attribute 'unknown' ignored}}
 [[noreturn]] using namespace ns; // expected-error {{'noreturn' attribute only applies to functions}}
 namespace [[]] ns2 {} // expected-warning {{attributes on a namespace declaration are a C++17 extension}}
 
-using [[]] alignas(4) [[]] ns::i; // expected-error {{an attribute list cannot appear here}}
+using[[]] alignas(4)[[]] ns::i;  // expected-error {{an attribute list cannot appear here}} expected-error {{'alignas' attribute only applies to variables, data members and tag types}} expected-warning {{ISO C++}}
 using [[]] alignas(4) [[]] foobar = int; // expected-error {{an attribute list cannot appear here}} expected-error {{'alignas' attribute only applies to}}
 
 void bad_attributes_in_do_while() {
@@ -157,7 +157,16 @@
 [[]] using T = int; // expected-error {{an attribute list cannot appear here}}
 using T [[]] = int; // ok
 template using U [[]] = T;
-using ns::i [[]]; // expected-error {{an attribute list cannot appear here}}
+using ns::i [[]];
+using ns::i [[]], ns::i [[

[PATCH] D91630: [Parse] Add parsing support for C++ attributes on using-declarations

2021-05-28 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Looks like this breaks tests http://45.33.8.238/linux/47752/step_7.txt


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91630

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


[PATCH] D103313: [RISCV][Clang] Implement support for zmmul-experimental

2021-05-28 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

Do we need to add this to RISCVTargetStreamer::emitTargetAttributes?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103313

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


[PATCH] D103319: [analyzer] Use Optional as a return type of StoreManager::castRegion

2021-05-28 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov updated this revision to Diff 348554.
ASDenysPetrov added a comment.

Fixed syntax complains which caused a test fail.


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

https://reviews.llvm.org/D103319

Files:
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/Store.h
  clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
  clang/lib/StaticAnalyzer/Core/Store.cpp
  clang/test/Analysis/casts.c

Index: clang/test/Analysis/casts.c
===
--- clang/test/Analysis/casts.c
+++ clang/test/Analysis/casts.c
@@ -251,18 +251,9 @@
 ;
 }
 
-// See PR50179.
-// Just don't crash.
-typedef struct taskS {
-  void *pJob;
-} taskS;
-
-typedef struct workS {
-  taskS *pTaskList;
-} workS;
-
-void *getTaskJob(unsigned jobId, workS *pWork, unsigned taskId) {
-  const taskS *pTask = pWork->pTaskList + taskId;
-  taskS task = *pTask;
-  return task.pJob;
+// PR50179.
+struct S {};
+void symbolic_offset(struct S *ptr, int i) {
+  const struct S *pS = ptr + i;
+  struct S s = *pS; // no-crash
 }
Index: clang/lib/StaticAnalyzer/Core/Store.cpp
===
--- clang/lib/StaticAnalyzer/Core/Store.cpp
+++ clang/lib/StaticAnalyzer/Core/Store.cpp
@@ -71,7 +71,8 @@
   return MRMgr.getElementRegion(T, idx, R, Ctx);
 }
 
-const MemRegion *StoreManager::castRegion(const MemRegion *R, QualType CastToTy) {
+Optional StoreManager::castRegion(const MemRegion *R,
+ QualType CastToTy) {
   ASTContext &Ctx = StateMgr.getContext();
 
   // Handle casts to Objective-C objects.
@@ -88,7 +89,7 @@
 
 // We don't know what to make of it.  Return a NULL region, which
 // will be interpreted as UnknownVal.
-return nullptr;
+return None;
   }
 
   // Now assume we are casting from pointer to pointer. Other cases should
@@ -168,7 +169,7 @@
   // If we cannot compute a raw offset, throw up our hands and return
   // a NULL MemRegion*.
   if (!baseR)
-return nullptr;
+return None;
 
   CharUnits off = rawOff.getOffset();
 
Index: clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
===
--- clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
+++ clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
@@ -753,16 +753,16 @@
 if (const auto *SR = dyn_cast(R)) {
   QualType SRTy = SR->getSymbol()->getType();
   if (!hasSameUnqualifiedPointeeType(SRTy, CastTy)) {
-R = StateMgr.getStoreManager().castRegion(SR, CastTy);
-return loc::MemRegionVal(R);
+if (auto OptR = StateMgr.getStoreManager().castRegion(SR, CastTy))
+  return loc::MemRegionVal(*OptR);
   }
 }
   }
   // Next fixes pointer dereference using type different from its initial
   // one. See PR37503 and PR49007 for details.
   if (const auto *ER = dyn_cast(R)) {
-if ((R = StateMgr.getStoreManager().castRegion(ER, CastTy)))
-  return loc::MemRegionVal(R);
+if (auto OptR = StateMgr.getStoreManager().castRegion(ER, CastTy))
+  return loc::MemRegionVal(*OptR);
   }
 
   return V;
@@ -807,8 +807,8 @@
 
 // Get the result of casting a region to a different type.
 const MemRegion *R = V.getRegion();
-if ((R = StateMgr.getStoreManager().castRegion(R, CastTy)))
-  return loc::MemRegionVal(R);
+if (auto OptR = StateMgr.getStoreManager().castRegion(R, CastTy))
+  return loc::MemRegionVal(*OptR);
   }
 
   // Pointer to whatever else.
@@ -873,8 +873,8 @@
   if (!IsUnknownOriginalType && Loc::isLocType(CastTy) &&
   OriginalTy->isIntegralOrEnumerationType()) {
 if (const MemRegion *R = L.getAsRegion())
-  if ((R = StateMgr.getStoreManager().castRegion(R, CastTy)))
-return loc::MemRegionVal(R);
+  if (auto OptR = StateMgr.getStoreManager().castRegion(R, CastTy))
+return loc::MemRegionVal(*OptR);
 return L;
   }
 
@@ -890,8 +890,8 @@
   // Delegate to store manager to get the result of casting a region to a
   // different type. If the MemRegion* returned is NULL, this expression
   // Evaluates to UnknownVal.
-  if ((R = StateMgr.getStoreManager().castRegion(R, CastTy)))
-return loc::MemRegionVal(R);
+  if (auto OptR = StateMgr.getStoreManager().castRegion(R, CastTy))
+return loc::MemRegionVal(*OptR);
 }
   } else {
 if (Loc::isLocType(CastTy)) {
Index: clang/include/clang/StaticAnalyzer/Core/PathSensitive/Store.h
===
--- clang/include/clang/StaticAnalyzer/Core/PathSensitive/Store.h
+++ clang/include/clang/StaticAnalyzer/Core/PathSensitive/Store.h
@@ -181,7 +181,8 @@
   /// castRegion - Used by ExprEngine::VisitCast to handle casts from
   ///  a MemRegion* to a specific location type.  'R' is the region being
   ///  casted and 

[PATCH] D103313: [RISCV][Clang] Implement support for zmmul-experimental

2021-05-28 Thread Jessica Clarke via Phabricator via cfe-commits
jrtc27 added a comment.

In D103313#2787316 , @craig.topper 
wrote:

> Do we need to add this to RISCVTargetStreamer::emitTargetAttributes?

Yes, that, but also RISCVAsmParser::parseDirectiveAttribute and 
ELFObjectFileBase::getRISCVFeatures, though it seems that last one has been a 
bit neglected.




Comment at: clang/lib/Basic/Targets/RISCV.cpp:294-295
   HasM = true;
+else if (Feature == "+experimental-zmmul")
+  HasZmmul = true;
 else if (Feature == "+a")

These are supposed to be (approximately) sorted in terms of their canonical 
ordering. I don't know where Zmmul is proposed to go relative to the other 
Zfoo's, but it belongs down somewhere in there, I guess alphabetical if we 
don't know any better, not up here with the single-letter extensions.



Comment at: llvm/lib/Target/RISCV/RISCVSubtarget.h:38
   bool HasStdExtM = false;
+  bool HasStdExtZmmul = false;
   bool HasStdExtA = false;

Ditto



Comment at: llvm/lib/Target/RISCV/RISCVSubtarget.h:106
   bool hasStdExtM() const { return HasStdExtM; }
+  bool hasStdExtZmmul() const { return HasStdExtZmmul; }
   bool hasStdExtA() const { return HasStdExtA; }

Ditto


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103313

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


[PATCH] D103313: [RISCV][Clang] Implement support for zmmul-experimental

2021-05-28 Thread Jessica Clarke via Phabricator via cfe-commits
jrtc27 added a comment.

In D103313#2787326 , @jrtc27 wrote:

> In D103313#2787316 , @craig.topper 
> wrote:
>
>> Do we need to add this to RISCVTargetStreamer::emitTargetAttributes?
>
> Yes, that, but also RISCVAsmParser::parseDirectiveAttribute and 
> ELFObjectFileBase::getRISCVFeatures, though it seems that last one has been a 
> bit neglected.

(we really need to cut down on how many places parse/produce arch strings...)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103313

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


[PATCH] D102689: [C++4OpenCL] Allow address space conversion in reinterpret_cast

2021-05-28 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/lib/Sema/SemaCast.cpp:2359
 
-  if (SrcType == DestType) {
+  if (SrcType == Self.Context.removeAddrSpaceQualType(DestType)) {
 // C++ 5.2.10p2 has a note that mentions that, subject to all other

I think the upshot of the conversation Richard and I just had is that there's a 
bug here for all qualifiers; that is, `reinterpret_cast(5)` should 
be allowed.  Probably the right thing to do is to strip qualifiers from 
DestType in the CastOperation constructor when the type is not a class or an 
array.  Richard, do you agree?  This isn't strictly implied by the C++ wording 
since the semantic analysis of the cast is logically prior to the introduction 
of a qualifier pr-value expression.


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

https://reviews.llvm.org/D102689

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


[PATCH] D102782: Add support for Warning Flag "-Wstack-usage="

2021-05-28 Thread Ryan Santhirarajan via Phabricator via cfe-commits
rsanthir.quic updated this revision to Diff 348555.
rsanthir.quic added a comment.

Updated test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102782

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Frontend/backend-stack-usage-diagnostic.c


Index: clang/test/Frontend/backend-stack-usage-diagnostic.c
===
--- /dev/null
+++ clang/test/Frontend/backend-stack-usage-diagnostic.c
@@ -0,0 +1,21 @@
+// RUN: %clang -Wstack-usage=0 -o /dev/null -c %s 2> %t.err
+// RUN: FileCheck < %t.err %s --check-prefix=WARN
+
+// RUN: %clang -Wstack-usage=0 -Wno-stack-usage= -o /dev/null -c %s 2> %t.err
+// RUN: FileCheck < %t.err %s --check-prefix=IGNORE --allow-empty
+
+// RUN: %clang -Wstack-usage=0 -w -o /dev/null -c %s 2> %t.err
+// RUN: FileCheck < %t.err %s --check-prefix=IGNORE --allow-empty
+
+// RUN: %clang -Wstack-usage=3 -o /dev/null -c %s 2> %t.err
+// RUN: FileCheck < %t.err %s --check-prefix=WARN
+
+// RUN: %clang -Wstack-usage=100 -o /dev/null -c %s 2> %t.err
+// RUN: FileCheck < %t.err %s --check-prefix=IGNORE --allow-empty
+
+// WARN: warning: stack frame size of {{[0-9]+}} bytes in function 
'test_square'
+// IGNORE-NOT:  stack frame size of {{[0-9]+}} bytes in function 'test_square'
+int test_square(int num) {
+  return num * num;
+}
+
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -4762,12 +4762,14 @@
   D.Diag(diag::err_aix_default_altivec_abi);
   }
 
-  if (Arg *A = Args.getLastArg(options::OPT_Wframe_larger_than_EQ)) {
-StringRef v = A->getValue();
-CmdArgs.push_back("-mllvm");
-CmdArgs.push_back(Args.MakeArgString("-warn-stack-size=" + v));
-A->claim();
-  }
+  if (Args.hasFlag(options::OPT_Wframe_larger_than_EQ,
+   options::OPT_Wno_frame_larger_than_EQ, false))
+if (Arg *A = Args.getLastArg(options::OPT_Wframe_larger_than_EQ)) {
+  StringRef v = A->getValue();
+  CmdArgs.push_back("-mllvm");
+  CmdArgs.push_back(Args.MakeArgString("-warn-stack-size=" + v));
+  A->claim();
+}
 
   if (!Args.hasFlag(options::OPT_fjump_tables, options::OPT_fno_jump_tables,
 true))
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2500,6 +2500,11 @@
 def Wlarger_than_EQ : Joined<["-"], "Wlarger-than=">, 
Group;
 def Wlarger_than_ : Joined<["-"], "Wlarger-than-">, Alias;
 def Wframe_larger_than_EQ : Joined<["-"], "Wframe-larger-than=">, 
Group, Flags<[NoXarchOption]>;
+def Wno_frame_larger_than_EQ : Joined<["-"], "Wnoframe-larger-than=">, 
Group, Flags<[NoXarchOption]>;
+def Wstack_stack_usage_EQ : Joined<["-"], "Wstack-usage=">, 
Flags<[NoXarchOption]>,
+  Alias;
+def Wno_stack_stack_usage_EQ : Joined<["-"], "Wno-stack-usage=">, 
Flags<[NoXarchOption]>,
+  Alias;
 
 def : Flag<["-"], "fterminated-vtables">, Alias;
 defm threadsafe_statics : BoolFOption<"threadsafe-statics",


Index: clang/test/Frontend/backend-stack-usage-diagnostic.c
===
--- /dev/null
+++ clang/test/Frontend/backend-stack-usage-diagnostic.c
@@ -0,0 +1,21 @@
+// RUN: %clang -Wstack-usage=0 -o /dev/null -c %s 2> %t.err
+// RUN: FileCheck < %t.err %s --check-prefix=WARN
+
+// RUN: %clang -Wstack-usage=0 -Wno-stack-usage= -o /dev/null -c %s 2> %t.err
+// RUN: FileCheck < %t.err %s --check-prefix=IGNORE --allow-empty
+
+// RUN: %clang -Wstack-usage=0 -w -o /dev/null -c %s 2> %t.err
+// RUN: FileCheck < %t.err %s --check-prefix=IGNORE --allow-empty
+
+// RUN: %clang -Wstack-usage=3 -o /dev/null -c %s 2> %t.err
+// RUN: FileCheck < %t.err %s --check-prefix=WARN
+
+// RUN: %clang -Wstack-usage=100 -o /dev/null -c %s 2> %t.err
+// RUN: FileCheck < %t.err %s --check-prefix=IGNORE --allow-empty
+
+// WARN: warning: stack frame size of {{[0-9]+}} bytes in function 'test_square'
+// IGNORE-NOT:  stack frame size of {{[0-9]+}} bytes in function 'test_square'
+int test_square(int num) {
+  return num * num;
+}
+
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -4762,12 +4762,14 @@
   D.Diag(diag::err_aix_default_altivec_abi);
   }
 
-  if (Arg *A = Args.getLastArg(options::OPT_Wframe_larger_than_EQ)) {
-StringRef v = A->getValue();
-CmdArgs.push_back("-mllvm");
-CmdArgs.push_back(Args.MakeArgString("-warn-stack-size=" + v));
-A->claim();
-  }
+  if (Args.hasFlag(options::OPT_Wframe_larger_than_EQ,
+   options::OPT_Wno_frame_larger_than_EQ, false)

[PATCH] D103131: support debug info for alias variable

2021-05-28 Thread Paul Robinson via Phabricator via cfe-commits
probinson added inline comments.



Comment at: clang/lib/CodeGen/CGDebugInfo.cpp:4957
+  auto Loc = getLineNumber(D->getLocation());
+  DBuilder.createGlobalVariableExpression(
+  DContext, Name, StringRef(), Unit, Loc, Ty,

I wasn't saying that gcc did the right thing!  Quite the opposite, I think the 
imported declaration is preferable, and I believe @dblaikie also thought it 
would be okay.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103131

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


[clang] f63adf5 - Revert "[clang][Parse] Add parsing support for C++ attributes on using-declarations"

2021-05-28 Thread Nico Weber via cfe-commits

Author: Nico Weber
Date: 2021-05-28T14:49:18-04:00
New Revision: f63adf5b67f7a25b15f81d3a1a207aba4f226dc4

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

LOG: Revert "[clang][Parse] Add parsing support for C++ attributes on 
using-declarations"

This reverts commit dc672999a9b12a156991891dc400308b52d569ba.
Breaks check-clang everywhere, see https://reviews.llvm.org/D91630

Added: 


Modified: 
clang/docs/LanguageExtensions.rst
clang/docs/ReleaseNotes.rst
clang/include/clang/Basic/DiagnosticParseKinds.td
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Basic/Features.def
clang/include/clang/Parse/Parser.h
clang/lib/Parse/ParseDecl.cpp
clang/lib/Parse/ParseDeclCXX.cpp
clang/lib/Sema/SemaDeclAttr.cpp
clang/lib/Sema/SemaDeclCXX.cpp
clang/test/Parser/cxx0x-attributes.cpp

Removed: 
clang/test/SemaCXX/cxx11-attributes-on-using-declaration.cpp



diff  --git a/clang/docs/LanguageExtensions.rst 
b/clang/docs/LanguageExtensions.rst
index c60b8b39e1c9e..129e73345b2a2 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -632,20 +632,6 @@ Attributes on the ``enum`` declaration do not apply to 
individual enumerators.
 
 Query for this feature with ``__has_extension(enumerator_attributes)``.
 
-C++11 Attributes on using-declarations
-==
-
-Clang allows C++-style ``[[]]`` attributes to be written on using-declarations.
-For instance:
-
-.. code-block:: c++
-
-  [[clang::using_if_exists]] using foo::bar;
-  using foo::baz [[clang::using_if_exists]];
-
-You can test for support for this extension with
-``__has_extension(cxx_attributes_on_using_declarations)``.
-
 'User-Specified' System Frameworks
 ==
 

diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index b43300ad66461..81609fa6efdfd 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -113,9 +113,6 @@ Attribute Changes in Clang
 
 - ...
 
-- Added support for C++11-style ``[[]]`` attributes on using-declarations, as a
-  clang extension.
-
 Windows Support
 ---
 

diff  --git a/clang/include/clang/Basic/DiagnosticParseKinds.td 
b/clang/include/clang/Basic/DiagnosticParseKinds.td
index 6d5d08e5fbad1..97cb7020f3452 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -693,9 +693,6 @@ def ext_using_attribute_ns : ExtWarn<
 def err_using_attribute_ns_conflict : Error<
   "attribute with scope specifier cannot follow default scope specifier">;
 def err_attributes_not_allowed : Error<"an attribute list cannot appear here">;
-def ext_cxx11_attr_placement : ExtWarn<
-  "ISO C++ does not allow an attribute list to appear here">,
-  InGroup>;
 def err_attributes_misplaced : Error<"misplaced attributes; expected 
attributes here">;
 def err_l_square_l_square_not_attribute : Error<
   "C++11 only allows consecutive left square brackets when "

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 80130c2584fe5..4b653b8b47370 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -3957,9 +3957,6 @@ def warn_attribute_sentinel_named_arguments : Warning<
 def warn_attribute_sentinel_not_variadic : Warning<
   "'sentinel' attribute only supported for variadic 
%select{functions|blocks}0">,
   InGroup;
-def warn_deprecated_ignored_on_using : Warning<
-  "%0 currently has no effect on a using declaration">,
-  InGroup;
 def err_attribute_sentinel_less_than_zero : Error<
   "'sentinel' parameter 1 less than zero">;
 def err_attribute_sentinel_not_zero_or_one : Error<

diff  --git a/clang/include/clang/Basic/Features.def 
b/clang/include/clang/Basic/Features.def
index 592e3e33baf1a..a7a5e06a937e0 100644
--- a/clang/include/clang/Basic/Features.def
+++ b/clang/include/clang/Basic/Features.def
@@ -259,7 +259,6 @@ EXTENSION(gnu_asm, LangOpts.GNUAsm)
 EXTENSION(gnu_asm_goto_with_outputs, LangOpts.GNUAsm)
 EXTENSION(matrix_types, LangOpts.MatrixTypes)
 EXTENSION(matrix_types_scalar_division, true)
-EXTENSION(cxx_attributes_on_using_declarations, LangOpts.CPlusPlus11)
 
 FEATURE(cxx_abi_relative_vtable, LangOpts.CPlusPlus && 
LangOpts.RelativeCXXABIVTables)
 

diff  --git a/clang/include/clang/Parse/Parser.h 
b/clang/include/clang/Parse/Parser.h
index cb618d172c5b1..e3e6509b025e5 100644
--- a/clang/include/clang/Parse/Parser.h
+++ b/clang/include/clang/Parse/Parser.h
@@ -2634,10 +2634,6 @@ class Parser : public CodeCompletionHandler {
   /// locations where attributes are not allowed.
   void DiagnoseAndSkipCXX11Attributes();
 
-  /// Emit warni

[PATCH] D91630: [Parse] Add parsing support for C++ attributes on using-declarations

2021-05-28 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

This is breaking check-clang everywhere, eg 
https://lab.llvm.org/buildbot/#/builders/109/builds/15757

Please run tests before landing, or failing that watch the bots after 
committing.

Reverted in f63adf5b67f7a25b15f81d3a1a207aba4f226dc4 for now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91630

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


[PATCH] D102782: Add support for Warning Flag "-Wstack-usage="

2021-05-28 Thread Ryan Santhirarajan via Phabricator via cfe-commits
rsanthir.quic updated this revision to Diff 348563.
rsanthir.quic added a comment.

Updated test and aligned negative flag with gcc


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102782

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Frontend/backend-stack-usage-diagnostic.c


Index: clang/test/Frontend/backend-stack-usage-diagnostic.c
===
--- /dev/null
+++ clang/test/Frontend/backend-stack-usage-diagnostic.c
@@ -0,0 +1,24 @@
+// RUN: %clang -Wstack-usage=0 -o /dev/null -c %s 2> %t.err
+// RUN: FileCheck < %t.err %s --check-prefix=WARN
+
+// RUN: %clang -Wno-stack-usage -Wstack-usage=0 -o /dev/null -c %s 2> %t.err
+// RUN: FileCheck < %t.err %s --check-prefix=WARN
+
+// RUN: %clang -Wstack-usage=0 -Wno-stack-usage -o /dev/null -c %s 2> %t.err
+// RUN: FileCheck < %t.err %s --check-prefix=IGNORE --allow-empty
+
+// RUN: %clang -Wstack-usage=0 -w -o /dev/null -c %s 2> %t.err
+// RUN: FileCheck < %t.err %s --check-prefix=IGNORE --allow-empty
+
+// RUN: %clang -Wstack-usage=3 -o /dev/null -c %s 2> %t.err
+// RUN: FileCheck < %t.err %s --check-prefix=WARN
+
+// RUN: %clang -Wstack-usage=100 -o /dev/null -c %s 2> %t.err
+// RUN: FileCheck < %t.err %s --check-prefix=IGNORE --allow-empty
+
+// WARN: warning: stack frame size of {{[0-9]+}} bytes in function 
'test_square'
+// IGNORE-NOT:  stack frame size of {{[0-9]+}} bytes in function 'test_square'
+int test_square(int num) {
+  return num * num;
+}
+
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -4762,12 +4762,14 @@
   D.Diag(diag::err_aix_default_altivec_abi);
   }
 
-  if (Arg *A = Args.getLastArg(options::OPT_Wframe_larger_than_EQ)) {
-StringRef v = A->getValue();
-CmdArgs.push_back("-mllvm");
-CmdArgs.push_back(Args.MakeArgString("-warn-stack-size=" + v));
-A->claim();
-  }
+  if (Args.hasFlag(options::OPT_Wframe_larger_than_EQ,
+   options::OPT_Wno_frame_larger_than, false))
+if (Arg *A = Args.getLastArg(options::OPT_Wframe_larger_than_EQ)) {
+  StringRef v = A->getValue();
+  CmdArgs.push_back("-mllvm");
+  CmdArgs.push_back(Args.MakeArgString("-warn-stack-size=" + v));
+  A->claim();
+}
 
   if (!Args.hasFlag(options::OPT_fjump_tables, options::OPT_fno_jump_tables,
 true))
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2500,6 +2500,11 @@
 def Wlarger_than_EQ : Joined<["-"], "Wlarger-than=">, 
Group;
 def Wlarger_than_ : Joined<["-"], "Wlarger-than-">, Alias;
 def Wframe_larger_than_EQ : Joined<["-"], "Wframe-larger-than=">, 
Group, Flags<[NoXarchOption]>;
+def Wno_frame_larger_than : Joined<["-"], "Wno-frame-larger-than">, 
Group, Flags<[NoXarchOption]>;
+def Wstack_stack_usage_EQ : Joined<["-"], "Wstack-usage=">, 
Flags<[NoXarchOption]>,
+  Alias;
+def Wno_stack_stack_usage : Joined<["-"], "Wno-stack-usage">, 
Flags<[NoXarchOption]>,
+  Alias;
 
 def : Flag<["-"], "fterminated-vtables">, Alias;
 defm threadsafe_statics : BoolFOption<"threadsafe-statics",


Index: clang/test/Frontend/backend-stack-usage-diagnostic.c
===
--- /dev/null
+++ clang/test/Frontend/backend-stack-usage-diagnostic.c
@@ -0,0 +1,24 @@
+// RUN: %clang -Wstack-usage=0 -o /dev/null -c %s 2> %t.err
+// RUN: FileCheck < %t.err %s --check-prefix=WARN
+
+// RUN: %clang -Wno-stack-usage -Wstack-usage=0 -o /dev/null -c %s 2> %t.err
+// RUN: FileCheck < %t.err %s --check-prefix=WARN
+
+// RUN: %clang -Wstack-usage=0 -Wno-stack-usage -o /dev/null -c %s 2> %t.err
+// RUN: FileCheck < %t.err %s --check-prefix=IGNORE --allow-empty
+
+// RUN: %clang -Wstack-usage=0 -w -o /dev/null -c %s 2> %t.err
+// RUN: FileCheck < %t.err %s --check-prefix=IGNORE --allow-empty
+
+// RUN: %clang -Wstack-usage=3 -o /dev/null -c %s 2> %t.err
+// RUN: FileCheck < %t.err %s --check-prefix=WARN
+
+// RUN: %clang -Wstack-usage=100 -o /dev/null -c %s 2> %t.err
+// RUN: FileCheck < %t.err %s --check-prefix=IGNORE --allow-empty
+
+// WARN: warning: stack frame size of {{[0-9]+}} bytes in function 'test_square'
+// IGNORE-NOT:  stack frame size of {{[0-9]+}} bytes in function 'test_square'
+int test_square(int num) {
+  return num * num;
+}
+
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -4762,12 +4762,14 @@
   D.Diag(diag::err_aix_default_altivec_abi);
   }
 
-  if (Arg *A = Args.getLastArg(options::OPT_Wframe_larger_than_EQ

[PATCH] D91630: [Parse] Add parsing support for C++ attributes on using-declarations

2021-05-28 Thread Matthew Voss via Phabricator via cfe-commits
ormris added a comment.

This is also failing on several build bots: 
https://lab.llvm.org/buildbot/#/builders/139/builds/4812

Since it's been failing for a few hours, I'd like to revert this in the near 
future to unclog our internal CI and the buildbots.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91630

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


[PATCH] D102706: [clang-format] Add new LambdaBodyIndentation option

2021-05-28 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks accepted this revision.
HazardyKnusperkeks added a comment.
This revision is now accepted and ready to land.

LGTM, but please wait for more responses.


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

https://reviews.llvm.org/D102706

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


[PATCH] D103204: [clang-format] New BreakInheritanceList style AfterComma

2021-05-28 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius accepted this revision.
curdeius added a comment.

LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103204

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


[PATCH] D103245: [clang-format] Fix PointerAlignmentRight with AlignConsecutiveDeclarations

2021-05-28 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added a comment.

Looks quite solid for me.




Comment at: clang/lib/Format/WhitespaceManager.cpp:265
 static void
-AlignTokenSequence(unsigned Start, unsigned End, unsigned Column, F &&Matches,
+AlignTokenSequence(const FormatStyle &Style, unsigned Start, unsigned End,
+   unsigned Column, F &&Matches,

I don't know if we should insert the `Style`, maybe just the `PointerAlignment`?



Comment at: clang/lib/Format/WhitespaceManager.cpp:369
 assert(Shift >= 0);
+if (Shift == 0)
+  continue;

This is unrelated, isn't it?

If it is, I would like a separate commit. Otherwise an explanation why it is 
now mandatory and does not infer with the other alignments.



Comment at: clang/lib/Format/WhitespaceManager.cpp:382
+   Changes[previous].Tok->getType() == TT_PointerOrReference;
+   previous--) {
+Changes[previous + 1].Spaces -= Shift;

I like prefix better than postfix. :)



Comment at: clang/unittests/Format/FormatTest.cpp:14884
   Alignment.AlignConsecutiveDeclarations = FormatStyle::ACS_None;
+  Alignment.PointerAlignment = FormatStyle::PAS_Right;
   verifyFormat("float const a = 5;\n"

Why change this?



Comment at: clang/unittests/Format/FormatTest.cpp:15045
+  // PAS_RIGHT
   EXPECT_EQ("void SomeFunction(int parameter = 0) {\n"
 "  int const i   = 1;\n"

I don't know why this is `EXPECT_EQ` instead of `verifyFormat`, but I know 
someone who will request that. :)

You should change that here and use that for your following tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103245

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


[clang] 8702c6d - [clang-format] [docs] Regenerate style options documentation.

2021-05-28 Thread Marek Kurdej via cfe-commits

Author: Marek Kurdej
Date: 2021-05-28T21:48:36+02:00
New Revision: 8702c6da162b6db962c8155195d79f1e002bc481

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

LOG: [clang-format] [docs] Regenerate style options documentation.

Forgotten in commits fce8c10b, 9363aa90, 8d93d7ff.

Added: 


Modified: 
clang/docs/ClangFormatStyleOptions.rst

Removed: 




diff  --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index 986963c8ce67c..459887705d4ec 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -773,7 +773,7 @@ the configuration (without a prefix: ``Auto``).
 
 
 **AllowShortIfStatementsOnASingleLine** (``ShortIfStyle``)
-  If ``true``, ``if (a) return;`` can be put on a single line.
+  Dependent on the value, ``if (a) return;`` can be put on a single line.
 
   Possible values:
 
@@ -783,28 +783,67 @@ the configuration (without a prefix: ``Auto``).
 .. code-block:: c++
 
   if (a)
-return ;
+return;
+
+  if (b)
+return;
+  else
+return;
+
+  if (c)
+return;
   else {
 return;
   }
 
   * ``SIS_WithoutElse`` (in configuration: ``WithoutElse``)
-Without else put short ifs on the same line only if
-the else is not a compound statement.
+Put short ifs on the same line only if there is no else statement.
 
 .. code-block:: c++
 
   if (a) return;
+
+  if (b)
+return;
   else
 return;
 
-  * ``SIS_Always`` (in configuration: ``Always``)
-Always put short ifs on the same line if
-the else is not a compound statement or not.
+  if (c)
+return;
+  else {
+return;
+  }
+
+  * ``SIS_OnlyFirstIf`` (in configuration: ``OnlyFirstIf``)
+Put short ifs, but not else ifs nor else statements, on the same line.
 
 .. code-block:: c++
 
   if (a) return;
+
+  if (b) return;
+  else if (b)
+return;
+  else
+return;
+
+  if (c) return;
+  else {
+return;
+  }
+
+  * ``SIS_AllIfsAndElse`` (in configuration: ``AllIfsAndElse``)
+Always put short ifs, else ifs and else statements on the same
+line.
+
+.. code-block:: c++
+
+  if (a) return;
+
+  if (b) return;
+  else return;
+
+  if (c) return;
   else {
 return;
   }
@@ -2176,8 +2215,11 @@ the configuration (without a prefix: ``Auto``).
   private:
 
   protected:
+
   };
 
+
+
 **EmptyLineBeforeAccessModifier** (``EmptyLineBeforeAccessModifierStyle``)
   Defines in which cases to put empty line before access modifiers.
 
@@ -2245,6 +2287,8 @@ the configuration (without a prefix: ``Auto``).
   protected:
   };
 
+
+
 **ExperimentalAutoDetectBinPacking** (``bool``)
   If ``true``, clang-format detects whether function calls and
   definitions are formatted with one parameter per line.
@@ -3441,15 +3485,32 @@ the configuration (without a prefix: ``Auto``).
} // foo
  }
 
-**SpacesInAngles** (``bool``)
-  If ``true``, spaces will be inserted after ``<`` and before ``>``
-  in template argument lists.
+**SpacesInAngles** (``SpacesInAnglesStyle``)
+  The SpacesInAnglesStyle to use for template argument lists.
+
+  Possible values:
+
+  * ``SIAS_Never`` (in configuration: ``Never``)
+Remove spaces after ``<`` and before ``>``.
+
+.. code-block:: c++
+
+   static_cast(arg);
+   std::function fct;
+
+  * ``SIAS_Always`` (in configuration: ``Always``)
+Add spaces after ``<`` and before ``>``.
+
+.. code-block:: c++
+
+   static_cast< int >(arg);
+   std::function< void(int) > fct;
+
+  * ``SIAS_Leave`` (in configuration: ``Leave``)
+Keep a single space after ``<`` and before ``>`` if any spaces were
+present. Option ``Standard: Cpp03`` takes precedence.
 
-  .. code-block:: c++
 
- true:  false:
- static_cast< int >(arg);   vs. static_cast(arg);
- std::function< void(int) > fct;std::function fct;
 
 **SpacesInCStyleCastParentheses** (``bool``)
   If ``true``, spaces may be inserted into C style casts.



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


[PATCH] D101344: [clang-format] Add `SpacesInAngles: Leave` option to keep spacing inside angle brackets as is.

2021-05-28 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius added a comment.

In D101344#2775517 , @MyDeveloperDay 
wrote:

> Whoops, We forgot to regenerate ClangFormatStyleOptions.rst here following 
> the change to Format.h

Thansks for noticing. Just fixed this and D100727 
 in rG8702c6da 
.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101344

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


[PATCH] D103245: [clang-format] Fix PointerAlignmentRight with AlignConsecutiveDeclarations

2021-05-28 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius added a comment.

Seems really nice. Just some nits & question.
Thanks for resuscitating the other review!

Please mention https://llvm.org/PR27353 in the description and update it after 
landing.




Comment at: clang/lib/Format/WhitespaceManager.cpp:379
+Changes[i].Spaces != 0) {
+  for (int previous = i - 1;
+   previous >= 0 &&

Nit: `previous` -> `Previous`. Or `PreviousIndex`?



Comment at: clang/unittests/Format/FormatTest.cpp:15044
+
+  // PAS_RIGHT
   EXPECT_EQ("void SomeFunction(int parameter = 0) {\n"

Nit: please match the case with the option, i.e. `PAS_Right`.



Comment at: clang/unittests/Format/FormatTest.cpp:15068
Alignment));
+  EXPECT_EQ("void SomeFunction(int parameter = 0) {\n"
+"  int const i   = 1;\n"

Is there a reason why we don't use `verifyFormat` in these tests?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103245

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


[PATCH] D103307: [clang-format] successive C# attributes cause line breaking issues

2021-05-28 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius accepted this revision.
curdeius added a comment.

LGTM.




Comment at: clang/lib/Format/TokenAnnotator.cpp:3529
+  return true;
+// Break between ] and [ but only when its really 2 attributes.
+if (Left.is(TT_AttributeSquare) && Right.is(TT_AttributeSquare) &&

Nit.


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

https://reviews.llvm.org/D103307

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


[PATCH] D102730: [clang-format] Support custom If macros

2021-05-28 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius added a comment.

Thanks for working on this!
Looks pretty nice, but please clang-format the changes and add some more test 
cases (cf. inline comment).

Concerning the lexer part, I wouldn't do anything cleaner.




Comment at: clang/unittests/Format/FormatTest.cpp:19719
+  verifyFormat("MYIF( a )\n  return;\nelse MYIF( b )\n  return;", Spaces);
+  verifyFormat("MYIF( a )\n  return;\nelse\n  return;", Spaces);
 }

Please add a test to see the interaction with 
`AllowShortIfStatementsOnASingleLine`, and maybe `BreakBeforeBraces`, 
`BraceWrappingAfterControlStatementStyle`, `SpacesInConditionalStatement`.


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

https://reviews.llvm.org/D102730

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


[PATCH] D102923: [clang][lex] Remark for used header search paths

2021-05-28 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith requested changes to this revision.
dexonsmith added a comment.
This revision now requires changes to proceed.

Thanks for your patience! I thought I already looked at this last week.

This is looking close. Comments mostly inline, but a high level point: I think 
this should report system search paths.

In D102923#2787001 , @jansvoboda11 
wrote:

> In D102923#2781386 , @Bigcheese 
> wrote:
>
>> I also wonder how we should handle other things that are found via include 
>> paths such as module maps.
>
> That's a good point. The logic for module map lookup is more complex than 
> header lookup, so I'd be keen to tackle that in a follow-up patch.

Yup, seems like something that could be added as a follow up (although probably 
using the same remark). Is there a good place to leave behind a FIXME?




Comment at: clang/include/clang/Basic/DiagnosticLexKinds.td:427
+def remark_pp_include_header_search_usage : Remark<
+  "user-provided search path used: '%0'">,
+  InGroup>;

I suggest, more simply, "search path used:" (drop the "user-provided"). If you 
think it's useful for information purposes to know whether it was a user or 
system search path, I'd suggest using a select (in that case, maybe you want to 
add an optional "framework" descriptor, and/or "header map" when applicable, 
etc.).



Comment at: clang/include/clang/Basic/DiagnosticLexKinds.td:428
+  "user-provided search path used: '%0'">,
+  InGroup>;
 def err_pp_file_not_found_angled_include_not_fatal : Error<

I think it'd be better to define a DiagGroup in 
clang/include/clang/Basic/DiagnosticGroups.td and use it here.

It might be nice for it to be more general, and not refer to headers, so we can 
reuse it for module maps, and/or potentially other remarks. Maybe, 
`-Rsearch-paths`?



Comment at: clang/include/clang/Lex/HeaderSearch.h:164-165
 
+  /// Mapping from SearchDir to HeaderSearchOptions::Entry indices.
+  llvm::DenseMap SearchDirToHSEntry;
+

I think this can just be a vector of `unsigned`, since the key is densely 
packed and counting from 0. You can use `~0U` for a sentinel for the 
non-entries. Maybe it's not too important though.



Comment at: clang/lib/Frontend/InitHeaderSearch.cpp:581-583
+// Check whether this DirectoryLookup maps to a HeaderSearch::UserEntry.
+if (Infos[I].UserEntryIdx)
+  LookupsToUserEntries.insert({I, *Infos[I].UserEntryIdx});

I don't see why we'd want to filter out system includes.
- Users sometimes manually configure "system" search paths, and this remark is 
fairly special-purpose, so I'm not sure the distinction is interesting to 
preserve.
- This remark is already going to be "noisy" and hit a few times on essentially 
every compilation. Adding the system paths that get hit won't change that much.
- The motivation for the patch is to test the logic for detecting which search 
paths are used in isolation from the 
canonicalize-explicit-module-build-commands logic in clang-scan-deps. We need 
to know that the logic works for system search paths as well.



Comment at: clang/test/Preprocessor/header-search-user-entries.c:1-4
+// RUN: %clang_cc1 -fsyntax-only %s -Rinclude-header-search-usage \
+// RUN:   -I%S/Inputs/header-search-user-entries/a 
-I%S/Inputs/header-search-user-entries/a_next \
+// RUN:   -I%S/Inputs/header-search-user-entries/b 
-I%S/Inputs/header-search-user-entries/c \
+// RUN:   -I%S/Inputs/header-search-user-entries/d 2>&1 | FileCheck %s

Can we use `-verify` here? Or does that not work for remarks?



Comment at: clang/test/Preprocessor/header-search-user-entries.c:9-11
+// CHECK: remark: user-provided search path used: 
'{{.*}}/header-search-user-entries/a'
+// CHECK: remark: user-provided search path used: 
'{{.*}}/header-search-user-entries/a_next'
+// CHECK: remark: user-provided search path used: 
'{{.*}}/header-search-user-entries/d'

If `-verify` doesn't work (hopefully it does), I think you'll need to add some 
`CHECK-NOT` / `CHECK-NEXT` / etc. or else you're not testing for the absence of 
other diagnostics.

Please also test:
- Framework search path (used vs. not used)
- System search path (used vs. not used)
- One search path described relative to `-isysroot` (used vs. not used)
- Header map (matched and used vs. matched but not used vs. not matched -- for 
the middle case, I'm not sure what result we actually want)
- A path only used via `#if __has_include()` (when it's not followed by an 
`#include` or `#import`)
- A path only used via ObjC's `#import`

If one of them doesn't work and it's complex enough to separate into a follow 
up, I think that'd be fine, but please find somewhere to leave a FIXME.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://

[PATCH] D101630: [HIP] Fix device-only compilation

2021-05-28 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In D101630#202 , @tra wrote:

> In D101630#2777346 , @yaxunl wrote:
>
>> In D101630#2748513 , @tra wrote:
>>
>>> How about this:
>>> If the user explicitly specified `--cuda-host-only` or 
>>> `--cuda-device-only`, then by default only allow producing the natural 
>>> output format, unless a bundled output is requested by an option. This 
>>> should keep existing users working.
>>> If the compilation is done without explicitly requested sub-compilation(s), 
>>> then bundle the output by default. This should keep the GPU-unaware tools 
>>> like ccache happy as they would always get the single output they expect.
>>>
>>> WDYT?
>>
>> `--cuda-host-only` always have one output, therefore there is no point of 
>> bundle its output. We only need to decide the proper behavior of 
>> `--cuda-device-only`.
>
> It still fits my proposal of requiring a single sub-compilation and not 
> bundling the output.
> The point was that such behavior is consistent regardless of whether we're 
> compiling CUDA or HIP for the host or for device.
>
>> How about keeping the original default behavior of not bundling if users do 
>> not specify output file, 
>> whereas bundle the output if users specifying output file.
>
> I think it will make things worse. Compiler output should not change 
> depending on whether `-o` is used.
>
>> Since specifying output file indicates users  requesting one output. 
>> -f[no-]hip-bundle-device-output override the default behavior.
>
> I disagree. When user specifies the output, the intent is to specify the 
> **location** of the outputs, not its contents or format.
>
> Telling compiler to produce a different output format should not depend on 
> specifying (or not) the output location.
>
> I think our options are:
>
> - Always bundle --cuda-device-only outputs by default. This is consistent for 
> HIP compilation, but deviates from CUDA, which can't do bundling. Also, 
> single-target subcompilation deviates from both CUDA and regular C++ 
> compilation, which is what most users would be familiar with and which would 
> probably be the most sensible default for a single sub-compilation. It can be 
> overridden with an option, but it goes against the principle that it's 
> specialized use case that should need extra options. The most common use case 
> should not need them.
>
> - Only bundle multiple sub-compilations' output by default. This would 
> preserve the sensible single sub-compilation behavior. The downside is that 
> it makes the output format depend on whether compiler ends up doing one or 
> many sub-compilations. E.g. `--offload-arch=A -S` would produce ASM and 
> `--offload-arch=A --offload-arch=B -S` would produce a bundle. If the user 
> can't control some of the compiler options, Such approach would make output 
> format unpredictable. E.g. passing `--offload-arch=foo` to compiler on 
> godbolt would all of a sudden produce bundled output instead of assembly text 
> or a sensible error message that you're trying to produce multiple outputs.
>
> - Keep the current behavior (insist on single sub-compilation) as the 
> default, allow overriding it for HIP with the flag. IMO that's the most 
> consistent option and I still think it's the one most suitable to keep as the 
> default.
>
> I can see the benefit of always bundling for HIP, but I also believe that 
> keeping things simple, consistent and predictable is important. Considering 
> that we're tinkering in a relatively obscure niche of the compiler, it 
> probably does not matter all that much, but it should not stop us from trying 
> to figure out the best approach in a principled way.
>
> I think we could benefit from a second opinion on which approach would make 
> more sense for clang. 
> Summoning @jdoerfert and @echristo.

How does nvcc --genco behave when there are multiple GPU arch's? Does it output 
a fat binary containing multiple ISA's? Also, does it support device-only 
compilation for intermediate outputs?


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

https://reviews.llvm.org/D101630

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


[clang] 577fea4 - [CGAtomic] Delete outdated code comparing success/failure ordering for cmpxchg.

2021-05-28 Thread Eli Friedman via cfe-commits

Author: Eli Friedman
Date: 2021-05-28T15:36:01-07:00
New Revision: 577fea4e1a13319adf2b660f57bf570195a7f78d

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

LOG: [CGAtomic] Delete outdated code comparing success/failure ordering for 
cmpxchg.

This doesn't actually have any effect: we only call this code with
SequentiallyConsistent orderings.  But delete it anyway for consistency
with other recent changes.

Added: 


Modified: 
clang/lib/CodeGen/CGAtomic.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGAtomic.cpp b/clang/lib/CodeGen/CGAtomic.cpp
index cc85375f08dd..e5c5e5babf23 100644
--- a/clang/lib/CodeGen/CGAtomic.cpp
+++ b/clang/lib/CodeGen/CGAtomic.cpp
@@ -1730,11 +1730,6 @@ AtomicInfo::EmitAtomicCompareExchangeLibcall(llvm::Value 
*ExpectedAddr,
 std::pair AtomicInfo::EmitAtomicCompareExchange(
 RValue Expected, RValue Desired, llvm::AtomicOrdering Success,
 llvm::AtomicOrdering Failure, bool IsWeak) {
-  if (isStrongerThan(Failure, Success))
-// Don't assert on undefined behavior "failure argument shall be no 
stronger
-// than the success argument".
-Failure = llvm::AtomicCmpXchgInst::getStrongestFailureOrdering(Success);
-
   // Check whether we should use a library call.
   if (shouldUseLibcall()) {
 // Produce a source address.



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


[clang] 09b75f4 - [clang-format] New BreakInheritanceList style AfterComma

2021-05-28 Thread Zhihao Yuan via cfe-commits

Author: Zhihao Yuan
Date: 2021-05-28T18:24:00-05:00
New Revision: 09b75f480d1d578d48307fd7f3b024b66a75712f

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

LOG: [clang-format] New BreakInheritanceList style AfterComma

This inheritance list style has been widely adopted by Symantec,
a division of Broadcom Inc. It breaks after the commas that
separate the base-specifiers:

class Derived : public Base1,
private Base2
{
};

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

Added: 


Modified: 
clang/docs/ClangFormatStyleOptions.rst
clang/docs/ReleaseNotes.rst
clang/include/clang/Format/Format.h
clang/lib/Format/Format.cpp
clang/lib/Format/TokenAnnotator.cpp
clang/unittests/Format/FormatTest.cpp

Removed: 




diff  --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index 459887705d4ec..bbe2807c2e23a 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -2038,6 +2038,15 @@ the configuration (without a prefix: ``Auto``).
Base2
{};
 
+  * ``BILS_AfterComma`` (in configuration: ``AfterComma``)
+Break inheritance list only after the commas.
+
+.. code-block:: c++
+
+   class Foo : Base1,
+   Base2
+   {};
+
 
 
 **BreakStringLiterals** (``bool``)

diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 81609fa6efdfd..cbf0f9b0e2c49 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -250,6 +250,9 @@ clang-format
   accepts ``AllIfsAndElse`` value that allows to put "else if" and "else" short
   statements on a single line. (Fixes https://llvm.org/PR50019.)
 
+- Option ``BreakInheritanceList`` gets a new style, ``AfterComma``. It breaks
+  only after the commas that separate the base-specifiers.
+
 - ``git-clang-format`` no longer formats changes to symbolic links. (Fixes
   https://llvm.org/PR46992.)
 

diff  --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index 4392b4aa4b43a..c30e357b5d0dd 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -1829,7 +1829,14 @@ struct FormatStyle {
 ///Base2
 ///{};
 /// \endcode
-BILS_AfterColon
+BILS_AfterColon,
+/// Break inheritance list only after the commas.
+/// \code
+///class Foo : Base1,
+///Base2
+///{};
+/// \endcode
+BILS_AfterComma,
   };
 
   /// The inheritance list style to use.

diff  --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index c50786c9d2f7a..c85ecd970ff15 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -240,6 +240,7 @@ struct 
ScalarEnumerationTraits {
 IO.enumCase(Value, "BeforeColon", FormatStyle::BILS_BeforeColon);
 IO.enumCase(Value, "BeforeComma", FormatStyle::BILS_BeforeComma);
 IO.enumCase(Value, "AfterColon", FormatStyle::BILS_AfterColon);
+IO.enumCase(Value, "AfterComma", FormatStyle::BILS_AfterComma);
   }
 };
 

diff  --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index d1aa3e422b5a8..daa624000ff6d 100755
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -3639,6 +3639,9 @@ bool TokenAnnotator::mustBreakBefore(const AnnotatedLine 
&Line,
   if (Style.BreakInheritanceList == FormatStyle::BILS_BeforeComma &&
   Right.is(TT_InheritanceComma))
 return true;
+  if (Style.BreakInheritanceList == FormatStyle::BILS_AfterComma &&
+  Left.is(TT_InheritanceComma))
+return true;
   if (Right.is(tok::string_literal) && Right.TokenText.startswith("R\""))
 // Multiline raw string literals are special wrt. line breaks. The author
 // has made a deliberate choice and might have aligned the contents of the

diff  --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index cf3e7b1df3900..efabaabf6e7f5 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -2290,6 +2290,28 @@ TEST_F(FormatTest, BreakInheritanceStyle) {
"public aaa< // break\n"
"> {};",
StyleWithInheritanceBreakAfterColon);
+
+  FormatStyle StyleWithInheritanceBreakAfterComma = getLLVMStyle();
+  StyleWithInheritanceBreakAfterComma.BreakInheritanceList =
+  FormatStyle::BILS_AfterComma;
+  verifyFormat("class MyClass : public X {};",
+   StyleWithInheritanceBreakAfterComma);
+  verifyFormat("class MyClass : public X,\n"
+   "public Y {};",
+   StyleWithInheritanceBreakAfterComma);
+  verifyForm

[PATCH] D103204: [clang-format] New BreakInheritanceList style AfterComma

2021-05-28 Thread Zhihao Yuan 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 rG09b75f480d1d: [clang-format] New BreakInheritanceList style 
AfterComma (authored by lichray).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103204

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -2290,6 +2290,28 @@
"public aaa< // break\n"
"> {};",
StyleWithInheritanceBreakAfterColon);
+
+  FormatStyle StyleWithInheritanceBreakAfterComma = getLLVMStyle();
+  StyleWithInheritanceBreakAfterComma.BreakInheritanceList =
+  FormatStyle::BILS_AfterComma;
+  verifyFormat("class MyClass : public X {};",
+   StyleWithInheritanceBreakAfterComma);
+  verifyFormat("class MyClass : public X,\n"
+   "public Y {};",
+   StyleWithInheritanceBreakAfterComma);
+  verifyFormat(
+  "class AA : public BB,\n"
+  "   public CC "
+  "{};",
+  StyleWithInheritanceBreakAfterComma);
+  verifyFormat("struct a : public aaa< // break\n"
+   "   > {};",
+   StyleWithInheritanceBreakAfterComma);
+  verifyFormat("class AAA\n"
+   ": public OnceBreak,\n"
+   "  public AlwaysBreak,\n"
+   "  EvenBasesFitInOneLine {};",
+   StyleWithInheritanceBreakAfterComma);
 }
 
 TEST_F(FormatTest, FormatsVariableDeclarationsAfterStructOrClass) {
@@ -5585,6 +5607,12 @@
   "  public aa,\n"
   "  public bb {};",
   Style);
+  Style.BreakInheritanceList = FormatStyle::BILS_AfterComma;
+  verifyFormat(
+  "class SomeClass\n"
+  "  : public aa,\n"
+  "public bb {};",
+  Style);
 }
 
 #ifndef EXPENSIVE_CHECKS
@@ -13505,6 +13533,12 @@
"}\n"
"}",
InheritanceStyle);
+  InheritanceStyle.BreakInheritanceList = FormatStyle::BILS_AfterComma;
+  verifyFormat("class Foo\n"
+   ": public aa,\n"
+   "  public bb {\n"
+   "}",
+   InheritanceStyle);
   InheritanceStyle.BreakInheritanceList = FormatStyle::BILS_AfterColon;
   verifyFormat("class Foo:\n"
"public aa,\n"
@@ -16843,6 +16877,8 @@
   BreakConstructorInitializers, FormatStyle::BCIS_BeforeComma);
 
   Style.BreakInheritanceList = FormatStyle::BILS_BeforeColon;
+  CHECK_PARSE("BreakInheritanceList: AfterComma", BreakInheritanceList,
+  FormatStyle::BILS_AfterComma);
   CHECK_PARSE("BreakInheritanceList: BeforeComma", BreakInheritanceList,
   FormatStyle::BILS_BeforeComma);
   CHECK_PARSE("BreakInheritanceList: AfterColon", BreakInheritanceList,
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -3639,6 +3639,9 @@
   if (Style.BreakInheritanceList == FormatStyle::BILS_BeforeComma &&
   Right.is(TT_InheritanceComma))
 return true;
+  if (Style.BreakInheritanceList == FormatStyle::BILS_AfterComma &&
+  Left.is(TT_InheritanceComma))
+return true;
   if (Right.is(tok::string_literal) && Right.TokenText.startswith("R\""))
 // Multiline raw string literals are special wrt. line breaks. The author
 // has made a deliberate choice and might have aligned the contents of the
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -240,6 +240,7 @@
 IO.enumCase(Value, "BeforeColon", FormatStyle::BILS_BeforeColon);
 IO.enumCase(Value, "BeforeComma", FormatStyle::BILS_BeforeComma);
 IO.enumCase(Value, "AfterColon", FormatStyle::BILS_AfterColon);
+IO.enumCase(Value, "AfterComma", FormatStyle::BILS_AfterComma);
   }
 };
 
Index: clang/include/clang/Format/Format.h
=

[PATCH] D103131: support debug info for alias variable

2021-05-28 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added inline comments.



Comment at: clang/lib/CodeGen/CGDebugInfo.cpp:4957
+  auto Loc = getLineNumber(D->getLocation());
+  DBuilder.createGlobalVariableExpression(
+  DContext, Name, StringRef(), Unit, Loc, Ty,

probinson wrote:
> I wasn't saying that gcc did the right thing!  Quite the opposite, I think 
> the imported declaration is preferable, and I believe @dblaikie also thought 
> it would be okay.
Mixed feelings - somewhat in favor of "do the thing that's probably already 
fairly tested/known to work" (GCC's thing). But open to the idea that that 
approach has problems, for sure.

Though I'm still not sure about the status of this aspect, for instance:

> How's this work if the alias target isn't declared in the source - but in 
> inline assembly instead? (I guess GCC probably handles that OK, but the Clang 
> strategy here might not cope with it)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103131

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


[PATCH] D103313: [RISCV][Clang] Implement support for zmmul-experimental

2021-05-28 Thread ksyx via Phabricator via cfe-commits
ksyx updated this revision to Diff 348608.
ksyx marked an inline comment as done.
ksyx added a comment.

- Move down zmmul lines to fit the ordering
- Add Zmmul into parseDirectiveAttribute


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

https://reviews.llvm.org/D103313

Files:
  clang/lib/Basic/Targets/RISCV.cpp
  clang/lib/Basic/Targets/RISCV.h
  clang/lib/Driver/ToolChains/Arch/RISCV.cpp
  llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
  llvm/lib/Target/RISCV/RISCV.td
  llvm/lib/Target/RISCV/RISCVISelLowering.cpp
  llvm/lib/Target/RISCV/RISCVInstrInfoM.td
  llvm/lib/Target/RISCV/RISCVSubtarget.h
  llvm/test/CodeGen/RISCV/zmmul.ll
  llvm/test/MC/RISCV/rv32i-invalid.s
  llvm/test/MC/RISCV/rv32zmmul-invaild.s
  llvm/test/MC/RISCV/rv32zmmul-valid.s
  llvm/test/MC/RISCV/rv64zmmul-invalid.s
  llvm/test/MC/RISCV/rv64zmmul-valid.s

Index: llvm/test/MC/RISCV/rv64zmmul-valid.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rv64zmmul-valid.s
@@ -0,0 +1,5 @@
+# RUN: llvm-mc %s -triple=riscv64 -mattr=+experimental-zmmul -riscv-no-aliases 2>&1 \
+# RUN:  | FileCheck -check-prefixes=CHECK-INST %s
+
+# CHECK-INST: mulw ra, sp, gp
+mulw ra, sp, gp
Index: llvm/test/MC/RISCV/rv64zmmul-invalid.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rv64zmmul-invalid.s
@@ -0,0 +1,14 @@
+# RUN: not llvm-mc %s -triple=riscv64 -mattr=+experimental-zmmul -riscv-no-aliases 2>&1 \
+# RUN:  | FileCheck -check-prefixes=CHECK-ERROR %s
+
+# CHECK-ERROR: 5:1: error: instruction requires the following: 'M' (Integer Multiplication and Division)
+divw tp, t0, t1
+
+# CHECK-ERROR: 8:1: error: instruction requires the following: 'M' (Integer Multiplication and Division)
+divuw t2, s0, s2
+
+# CHECK-ERROR: 11:1: error: instruction requires the following: 'M' (Integer Multiplication and Division)
+remw a0, a1, a2
+
+# CHECK-ERROR: 14:1: error: instruction requires the following: 'M' (Integer Multiplication and Division)
+remuw a3, a4, a5
Index: llvm/test/MC/RISCV/rv32zmmul-valid.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rv32zmmul-valid.s
@@ -0,0 +1,14 @@
+# RUN: llvm-mc %s -triple=riscv32 -mattr=+experimental-zmmul -riscv-no-aliases 2>&1 \
+# RUN:  | FileCheck -check-prefixes=CHECK-INST %s
+
+# CHECK-INST: mul a4, ra, s0
+mul a4, ra, s0
+
+# CHECK-INST: mulh ra, zero, zero
+mulh x1, x0, x0
+
+# CHECK-INST: mulhsu t0, t2, t1
+mulhsu t0, t2, t1
+
+# CHECK-INST: mulhu a5, a4, a3
+mulhu a5, a4, a3
Index: llvm/test/MC/RISCV/rv32zmmul-invaild.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rv32zmmul-invaild.s
@@ -0,0 +1,14 @@
+# RUN: not llvm-mc %s -triple=riscv32 -mattr=+experimental-zmmul -riscv-no-aliases 2>&1 \
+# RUN:  | FileCheck -check-prefixes=CHECK-ERROR %s
+
+# CHECK-ERROR: 5:1: error: instruction requires the following: 'M' (Integer Multiplication and Division)
+div s0, s0, s0
+
+# CHECK-ERROR: 8:1: error: instruction requires the following: 'M' (Integer Multiplication and Division)
+divu gp, a0, a1
+
+# CHECK-ERROR: 11:1: error: instruction requires the following: 'M' (Integer Multiplication and Division)
+rem s2, s2, s8
+
+# CHECK-ERROR: 14:1: error: instruction requires the following: 'M' (Integer Multiplication and Division)
+remu x18, x18, x24
Index: llvm/test/MC/RISCV/rv32i-invalid.s
===
--- llvm/test/MC/RISCV/rv32i-invalid.s
+++ llvm/test/MC/RISCV/rv32i-invalid.s
@@ -169,7 +169,7 @@
 xor s2, s2 # CHECK: :[[@LINE]]:1: error: too few operands for instruction
 
 # Instruction not in the base ISA
-mul a4, ra, s0 # CHECK: :[[@LINE]]:1: error: instruction requires the following: 'M' (Integer Multiplication and Division)
+div a4, ra, s0 # CHECK: :[[@LINE]]:1: error: instruction requires the following: 'M' (Integer Multiplication and Division)
 amomaxu.w s5, s4, (s3) # CHECK: :[[@LINE]]:1: error: instruction requires the following: 'A' (Atomic Instructions)
 fadd.s ft0, ft1, ft2 # CHECK: :[[@LINE]]:1: error: instruction requires the following: 'F' (Single-Precision Floating-Point)
 fadd.h ft0, ft1, ft2 # CHECK: :[[@LINE]]:1: error: instruction requires the following: 'Zfh' (Half-Precision Floating-Point)
Index: llvm/test/CodeGen/RISCV/zmmul.ll
===
--- /dev/null
+++ llvm/test/CodeGen/RISCV/zmmul.ll
@@ -0,0 +1,41 @@
+; RUN: llc -mtriple=riscv32 -mattr=+experimental-zmmul -verify-machineinstrs < %s \
+; RUN:  | not FileCheck -check-prefix=CHECK-DIV %s
+; RUN: llc -mtriple=riscv64 -mattr=+experimental-zmmul -verify-machineinstrs < %s \
+; RUN:  | not FileCheck -check-prefix=CHECK-DIV %s
+; RUN: llc -mtriple=riscv32 -mattr=+experimental-zmmul -verify-machineinstrs < %s \
+; RUN:  | not FileCheck -check-prefix=CHECK-REM %s
+; RUN: llc -mtriple=riscv64 -mattr=+exper

[PATCH] D103313: [RISCV][Clang] Implement support for zmmul-experimental

2021-05-28 Thread ksyx via Phabricator via cfe-commits
ksyx added a comment.

I have took a look into `ELFObjectFile.cpp` but I am not sure what work I need 
to do there since it seems other Z* extensions are not being handled there.




Comment at: llvm/lib/Target/RISCV/RISCVSubtarget.h:38
   bool HasStdExtM = false;
+  bool HasStdExtZmmul = false;
   bool HasStdExtA = false;

jrtc27 wrote:
> Ditto
The pattern here seems to be that Z* extensions is following its parent their 
parent extensions, should we follow it? (See B and V)


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

https://reviews.llvm.org/D103313

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


[PATCH] D103313: [RISCV][Clang] Implement support for zmmul-experimental

2021-05-28 Thread ksyx via Phabricator via cfe-commits
ksyx added inline comments.



Comment at: llvm/lib/Target/RISCV/RISCVSubtarget.h:38
   bool HasStdExtM = false;
+  bool HasStdExtZmmul = false;
   bool HasStdExtA = false;

ksyx wrote:
> jrtc27 wrote:
> > Ditto
> The pattern here seems to be that Z* extensions is following its parent their 
> parent extensions, should we follow it? (See B and V)
But for Zfh it is not following HasStdExtF 🤔 


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

https://reviews.llvm.org/D103313

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


[PATCH] D103131: support debug info for alias variable

2021-05-28 Thread kamlesh kumar via Phabricator via cfe-commits
kamleshbhalui added a comment.

$cat test.h
int oldname;

$cat test.c

#include "test.h"
int oldname;
__asm__  (

  "movq oldname, %rsp\n\t"

);

extern int newname __attribute__((alias("oldname")));

debug info from gcc:

test.o: file format elf64-x86-64

.debug_info contents:
0x: Compile Unit: length = 0x0044, format = DWARF32, version = 
0x0005, unit_type = DW_UT_compile, abbr_offset = 0x, addr_size = 0x08 (next 
unit at 0x0048)

0x000c: DW_TAG_compile_unit

  DW_AT_producer("GNU C17 12.0.0 20210529 (experimental) -g")
  DW_AT_language(DW_LANG_C11)
  DW_AT_name("test.c")
  DW_AT_comp_dir("/folk/kkumar/tcgcc/build/")
  DW_AT_stmt_list   (0x)

0x001e:   DW_TAG_variable

  DW_AT_name  ("oldname")
  DW_AT_decl_file ("test.h")
  DW_AT_decl_line (1)
  DW_AT_decl_column   (0x05)
  DW_AT_type  (0x0034 "int")
  DW_AT_external  (true)
  DW_AT_location  (DW_OP_addr 0x0)

0x0034:   DW_TAG_base_type

  DW_AT_byte_size (0x04)
  DW_AT_encoding  (DW_ATE_signed)
  DW_AT_name  ("int")

0x003b:   DW_TAG_variable

  DW_AT_name  ("newname")
  DW_AT_decl_file ("test.c")
  DW_AT_decl_line (7)
  DW_AT_decl_column   (0x0c)
  DW_AT_type  (0x0034 "int")
  DW_AT_external  (true)

0x0047:   NULL

debug info from clang:

test1.o:file format elf64-x86-64

.debug_info contents:
0x: Compile Unit: length = 0x0042, format = DWARF32, version = 
0x0004, abbr_offset = 0x, addr_size = 0x08 (next unit at 0x0046)

0x000b: DW_TAG_compile_unit

  DW_AT_producer("clang version 13.0.0 
(g...@github.com:llvm/llvm-project.git 
b22ff948a94edc7573d226fe404a77b9a7380398)")
  DW_AT_language(DW_LANG_C99)
  DW_AT_name("test.c")
  DW_AT_stmt_list   (0x)
  DW_AT_comp_dir("/folk/kkumar/tcgcc/build")

0x001e:   DW_TAG_variable

  DW_AT_name  ("newname")
  DW_AT_type  (0x0029 "int")
  DW_AT_external  (true)
  DW_AT_decl_file ("test.c")
  DW_AT_decl_line (7)

0x0029:   DW_TAG_base_type

  DW_AT_name  ("int")
  DW_AT_encoding  (DW_ATE_signed)
  DW_AT_byte_size (0x04)

0x0030:   DW_TAG_variable

  DW_AT_name  ("oldname")
  DW_AT_type  (0x0029 "int")
  DW_AT_external  (true)
  DW_AT_decl_file ("test.c")
  DW_AT_decl_line (2)
  DW_AT_location  (DW_OP_addr 0x0)

0x0045:   NULL

so debug info looks same to me in gcc and clang .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103131

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


[PATCH] D103319: [analyzer] Use Optional as a return type of StoreManager::castRegion

2021-05-28 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added a comment.
This revision is now accepted and ready to land.

Looks great, thanks!

I guess another option is to put `loc::MemRegionVal()` inside `castRegion()`. 
This way the return type `Optional` unambigously tells that 
the region is always non-null if present (protected by the assertion in the 
constructor of `loc::MemRegionVal`).


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

https://reviews.llvm.org/D103319

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