[PATCH] D115907: [misexpect] Re-implement MisExpect Diagnostics

2022-03-28 Thread Tanya Lattner via Phabricator via cfe-commits
tonic added a comment.

This is breaking the docs build with the following warning: 
"MisExpect.rst:document isn't included in any toctree." By default, docs 
warnings are treated as errors. Can you fix this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115907

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


[PATCH] D122271: [Clang] -Wunused-but-set-variable warning - handle also pre/post unary operators

2022-03-28 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added a comment.

In D122271#3413193 , @uabelho wrote:

> Hi,
>
> I noticed these to warning when compiling libunwind/src/UnwindLevel1.c with 
> this patch:
>
>   00:22:48 
> /repo/bbiswjenk/fem2s10-eiffel176/workspace/llvm/sdk_1_20_ki_dev_test/libunwind/src/UnwindLevel1.c:175:12:
>  warning: variable 'framesWalked' set but not used [-Wunused-but-set-variable]
>   00:22:48   unsigned framesWalked = 1;
>   00:22:48^
>   00:22:48 
> /repo/bbiswjenk/fem2s10-eiffel176/workspace/llvm/sdk_1_20_ki_dev_test/libunwind/src/UnwindLevel1.c:293:12:
>  warning: variable 'framesWalked' set but not used [-Wunused-but-set-variable]
>   00:22:48   unsigned framesWalked = 1;
>   00:22:48^
>   00:22:48 2 warnings generated.



In D122271#3413193 , @uabelho wrote:

> Hi,
>
> I noticed these to warning when compiling libunwind/src/UnwindLevel1.c with 
> this patch:
>
>   00:22:48 
> /repo/bbiswjenk/fem2s10-eiffel176/workspace/llvm/sdk_1_20_ki_dev_test/libunwind/src/UnwindLevel1.c:175:12:
>  warning: variable 'framesWalked' set but not used [-Wunused-but-set-variable]
>   00:22:48   unsigned framesWalked = 1;
>   00:22:48^
>   00:22:48 
> /repo/bbiswjenk/fem2s10-eiffel176/workspace/llvm/sdk_1_20_ki_dev_test/libunwind/src/UnwindLevel1.c:293:12:
>  warning: variable 'framesWalked' set but not used [-Wunused-but-set-variable]
>   00:22:48   unsigned framesWalked = 1;
>   00:22:48^
>   00:22:48 2 warnings generated.

A warning was improved so fires more often.

Clearly, sometimes in __unw_phase2_resume, “fn” is ignored (so passed 
framesWalked is throw away as well). I see nothing wrong to warn here.

(void)framesWalked; will silence it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122271

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


[PATCH] D122554: [clangd] Handle tabs in getIncrementalChangesAfterNewline()

2022-03-28 Thread Nathan Ridge 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 rG9325e97a3599: [clangd] Handle tabs in 
getIncrementalChangesAfterNewline() (authored by nridge).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122554

Files:
  clang-tools-extra/clangd/Format.cpp
  clang-tools-extra/clangd/unittests/FormatTests.cpp

Index: clang-tools-extra/clangd/unittests/FormatTests.cpp
===
--- clang-tools-extra/clangd/unittests/FormatTests.cpp
+++ clang-tools-extra/clangd/unittests/FormatTests.cpp
@@ -19,13 +19,11 @@
 namespace clangd {
 namespace {
 
-std::string afterTyped(llvm::StringRef CodeWithCursor,
-   llvm::StringRef Typed) {
+std::string afterTyped(llvm::StringRef CodeWithCursor, llvm::StringRef Typed,
+   clang::format::FormatStyle Style) {
   Annotations Code(CodeWithCursor);
   unsigned Cursor = llvm::cantFail(positionToOffset(Code.code(), Code.point()));
-  auto Changes =
-  formatIncremental(Code.code(), Cursor, Typed,
-format::getGoogleStyle(format::FormatStyle::LK_Cpp));
+  auto Changes = formatIncremental(Code.code(), Cursor, Typed, Style);
   tooling::Replacements Merged;
   for (const auto& R : Changes)
 if (llvm::Error E = Merged.add(R))
@@ -38,11 +36,15 @@
 }
 
 // We can't pass raw strings directly to EXPECT_EQ because of gcc bugs.
-void expectAfterNewline(const char *Before, const char *After) {
-  EXPECT_EQ(After, afterTyped(Before, "\n")) << Before;
+void expectAfterNewline(const char *Before, const char *After,
+format::FormatStyle Style = format::getGoogleStyle(
+format::FormatStyle::LK_Cpp)) {
+  EXPECT_EQ(After, afterTyped(Before, "\n", Style)) << Before;
 }
-void expectAfter(const char *Typed, const char *Before, const char *After) {
-  EXPECT_EQ(After, afterTyped(Before, Typed)) << Before;
+void expectAfter(const char *Typed, const char *Before, const char *After,
+ format::FormatStyle Style =
+ format::getGoogleStyle(format::FormatStyle::LK_Cpp)) {
+  EXPECT_EQ(After, afterTyped(Before, Typed, Style)) << Before;
 }
 
 TEST(FormatIncremental, SplitComment) {
@@ -131,7 +133,7 @@
 ^
 }
 )cpp",
-   R"cpp(
+ R"cpp(
 void foo() {
   if (x)
 return;  // All spelled tokens are accounted for.
@@ -139,6 +141,17 @@
   ^
 }
 )cpp");
+
+  // Handle tab character in leading indentation
+  format::FormatStyle TabStyle =
+  format::getGoogleStyle(format::FormatStyle::LK_Cpp);
+  TabStyle.UseTab = format::FormatStyle::UT_Always;
+  TabStyle.TabWidth = 4;
+  TabStyle.IndentWidth = 4;
+  // Do not use raw strings, otherwise '\t' will be interpreted literally.
+  expectAfterNewline("void foo() {\n\t// this comment was\n^split\n}\n",
+ "void foo() {\n\t// this comment was\n\t// ^split\n}\n",
+ TabStyle);
 }
 
 TEST(FormatIncremental, Indentation) {
Index: clang-tools-extra/clangd/Format.cpp
===
--- clang-tools-extra/clangd/Format.cpp
+++ clang-tools-extra/clangd/Format.cpp
@@ -116,12 +116,41 @@
   std::string CursorPlaceholder;
 };
 
+// The two functions below, columnWidth() and columnWidthWithTabs(), were
+// adapted from similar functions in clang/lib/Format/Encoding.h.
+// FIXME: Move those functions to clang/include/clang/Format.h and reuse them?
+
+// Helper function for columnWidthWithTabs().
+inline unsigned columnWidth(StringRef Text) {
+  int ContentWidth = llvm::sys::unicode::columnWidthUTF8(Text);
+  if (ContentWidth < 0)
+return Text.size(); // fallback for unprintable characters
+  return ContentWidth;
+}
+
+// Returns the number of columns required to display the \p Text on a terminal
+// with the \p TabWidth.
+inline unsigned columnWidthWithTabs(StringRef Text, unsigned TabWidth) {
+  unsigned TotalWidth = 0;
+  StringRef Tail = Text;
+  for (;;) {
+StringRef::size_type TabPos = Tail.find('\t');
+if (TabPos == StringRef::npos)
+  return TotalWidth + columnWidth(Tail);
+TotalWidth += columnWidth(Tail.substr(0, TabPos));
+if (TabWidth)
+  TotalWidth += TabWidth - TotalWidth % TabWidth;
+Tail = Tail.substr(TabPos + 1);
+  }
+}
+
 // After a newline:
 //  - we continue any line-comment that was split
 //  - we format the old line in addition to the cursor
 //  - we represent the cursor with a line comment to preserve the newline
 IncrementalChanges getIncrementalChangesAfterNewline(llvm::StringRef Code,
- unsigned Cursor) {
+ unsigned Cursor,
+ unsigned TabWidth) {
   

[clang-tools-extra] 9325e97 - [clangd] Handle tabs in getIncrementalChangesAfterNewline()

2022-03-28 Thread Nathan Ridge via cfe-commits

Author: Nathan Ridge
Date: 2022-03-29T01:43:09-04:00
New Revision: 9325e97a3599929a52bef3e5c8e403c98f9428ba

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

LOG: [clangd] Handle tabs in getIncrementalChangesAfterNewline()

Tabs are not handled by columnWidthUTF8() (they are considered
non-printable) so require additional logic to handle.

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

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

Added: 


Modified: 
clang-tools-extra/clangd/Format.cpp
clang-tools-extra/clangd/unittests/FormatTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/Format.cpp 
b/clang-tools-extra/clangd/Format.cpp
index bb492dbdbd3bd..c3e92636d1957 100644
--- a/clang-tools-extra/clangd/Format.cpp
+++ b/clang-tools-extra/clangd/Format.cpp
@@ -116,12 +116,41 @@ struct IncrementalChanges {
   std::string CursorPlaceholder;
 };
 
+// The two functions below, columnWidth() and columnWidthWithTabs(), were
+// adapted from similar functions in clang/lib/Format/Encoding.h.
+// FIXME: Move those functions to clang/include/clang/Format.h and reuse them?
+
+// Helper function for columnWidthWithTabs().
+inline unsigned columnWidth(StringRef Text) {
+  int ContentWidth = llvm::sys::unicode::columnWidthUTF8(Text);
+  if (ContentWidth < 0)
+return Text.size(); // fallback for unprintable characters
+  return ContentWidth;
+}
+
+// Returns the number of columns required to display the \p Text on a terminal
+// with the \p TabWidth.
+inline unsigned columnWidthWithTabs(StringRef Text, unsigned TabWidth) {
+  unsigned TotalWidth = 0;
+  StringRef Tail = Text;
+  for (;;) {
+StringRef::size_type TabPos = Tail.find('\t');
+if (TabPos == StringRef::npos)
+  return TotalWidth + columnWidth(Tail);
+TotalWidth += columnWidth(Tail.substr(0, TabPos));
+if (TabWidth)
+  TotalWidth += TabWidth - TotalWidth % TabWidth;
+Tail = Tail.substr(TabPos + 1);
+  }
+}
+
 // After a newline:
 //  - we continue any line-comment that was split
 //  - we format the old line in addition to the cursor
 //  - we represent the cursor with a line comment to preserve the newline
 IncrementalChanges getIncrementalChangesAfterNewline(llvm::StringRef Code,
- unsigned Cursor) {
+ unsigned Cursor,
+ unsigned TabWidth) {
   IncrementalChanges Result;
   // Before newline, code looked like:
   //leading^trailing
@@ -152,12 +181,12 @@ IncrementalChanges 
getIncrementalChangesAfterNewline(llvm::StringRef Code,
   if (!CommentMarker.empty() &&
   (NewLineIsComment || !commentMarker(NextLine).empty() ||
(!TrailingTrim.empty() && !TrailingTrim.startswith("//" {
-using llvm::sys::unicode::columnWidthUTF8;
 // We indent the new comment to match the previous one.
 StringRef PreComment =
 Leading.take_front(CommentMarker.data() - Leading.data());
 std::string IndentAndComment =
-(std::string(columnWidthUTF8(PreComment), ' ') + CommentMarker + " ")
+(std::string(columnWidthWithTabs(PreComment, TabWidth), ' ') +
+ CommentMarker + " ")
 .str();
 cantFail(
 Result.Changes.add(replacement(Code, Indentation, IndentAndComment)));
@@ -191,10 +220,11 @@ IncrementalChanges 
getIncrementalChangesAfterNewline(llvm::StringRef Code,
 }
 
 IncrementalChanges getIncrementalChanges(llvm::StringRef Code, unsigned Cursor,
- llvm::StringRef InsertedText) {
+ llvm::StringRef InsertedText,
+ unsigned TabWidth) {
   IncrementalChanges Result;
   if (InsertedText == "\n")
-return getIncrementalChangesAfterNewline(Code, Cursor);
+return getIncrementalChangesAfterNewline(Code, Cursor, TabWidth);
 
   Result.CursorPlaceholder = " /**/";
   return Result;
@@ -246,8 +276,8 @@ split(const tooling::Replacements , unsigned 
OldCursor,
 std::vector
 formatIncremental(llvm::StringRef OriginalCode, unsigned OriginalCursor,
   llvm::StringRef InsertedText, format::FormatStyle Style) {
-  IncrementalChanges Incremental =
-  getIncrementalChanges(OriginalCode, OriginalCursor, InsertedText);
+  IncrementalChanges Incremental = getIncrementalChanges(
+  OriginalCode, OriginalCursor, InsertedText, Style.TabWidth);
   // Never *remove* lines in response to pressing enter! This annoys users.
   if (InsertedText == "\n") {
 Style.MaxEmptyLinesToKeep = 1000;

diff  --git a/clang-tools-extra/clangd/unittests/FormatTests.cpp 
b/clang-tools-extra/clangd/unittests/FormatTests.cpp
index 0eb217eeb5e37..f7384a1bc63c9 

[PATCH] D122554: [clangd] Handle tabs in getIncrementalChangesAfterNewline()

2022-03-28 Thread Nathan Ridge via Phabricator via cfe-commits
nridge updated this revision to Diff 418789.
nridge added a comment.

address review comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122554

Files:
  clang-tools-extra/clangd/Format.cpp
  clang-tools-extra/clangd/unittests/FormatTests.cpp

Index: clang-tools-extra/clangd/unittests/FormatTests.cpp
===
--- clang-tools-extra/clangd/unittests/FormatTests.cpp
+++ clang-tools-extra/clangd/unittests/FormatTests.cpp
@@ -20,13 +20,11 @@
 namespace clangd {
 namespace {
 
-std::string afterTyped(llvm::StringRef CodeWithCursor,
-   llvm::StringRef Typed) {
+std::string afterTyped(llvm::StringRef CodeWithCursor, llvm::StringRef Typed,
+   clang::format::FormatStyle Style) {
   Annotations Code(CodeWithCursor);
   unsigned Cursor = llvm::cantFail(positionToOffset(Code.code(), Code.point()));
-  auto Changes =
-  formatIncremental(Code.code(), Cursor, Typed,
-format::getGoogleStyle(format::FormatStyle::LK_Cpp));
+  auto Changes = formatIncremental(Code.code(), Cursor, Typed, Style);
   tooling::Replacements Merged;
   for (const auto& R : Changes)
 if (llvm::Error E = Merged.add(R))
@@ -39,11 +37,15 @@
 }
 
 // We can't pass raw strings directly to EXPECT_EQ because of gcc bugs.
-void expectAfterNewline(const char *Before, const char *After) {
-  EXPECT_EQ(After, afterTyped(Before, "\n")) << Before;
+void expectAfterNewline(const char *Before, const char *After,
+format::FormatStyle Style = format::getGoogleStyle(
+format::FormatStyle::LK_Cpp)) {
+  EXPECT_EQ(After, afterTyped(Before, "\n", Style)) << Before;
 }
-void expectAfter(const char *Typed, const char *Before, const char *After) {
-  EXPECT_EQ(After, afterTyped(Before, Typed)) << Before;
+void expectAfter(const char *Typed, const char *Before, const char *After,
+ format::FormatStyle Style =
+ format::getGoogleStyle(format::FormatStyle::LK_Cpp)) {
+  EXPECT_EQ(After, afterTyped(Before, Typed, Style)) << Before;
 }
 
 TEST(FormatIncremental, SplitComment) {
@@ -132,7 +134,7 @@
 ^
 }
 )cpp",
-   R"cpp(
+ R"cpp(
 void foo() {
   if (x)
 return;  // All spelled tokens are accounted for.
@@ -140,6 +142,17 @@
   ^
 }
 )cpp");
+
+  // Handle tab character in leading indentation
+  format::FormatStyle TabStyle =
+  format::getGoogleStyle(format::FormatStyle::LK_Cpp);
+  TabStyle.UseTab = format::FormatStyle::UT_Always;
+  TabStyle.TabWidth = 4;
+  TabStyle.IndentWidth = 4;
+  // Do not use raw strings, otherwise '\t' will be interpreted literally.
+  expectAfterNewline("void foo() {\n\t// this comment was\n^split\n}\n",
+ "void foo() {\n\t// this comment was\n\t// ^split\n}\n",
+ TabStyle);
 }
 
 TEST(FormatIncremental, Indentation) {
Index: clang-tools-extra/clangd/Format.cpp
===
--- clang-tools-extra/clangd/Format.cpp
+++ clang-tools-extra/clangd/Format.cpp
@@ -117,12 +117,41 @@
   std::string CursorPlaceholder;
 };
 
+// The two functions below, columnWidth() and columnWidthWithTabs(), were
+// adapted from similar functions in clang/lib/Format/Encoding.h.
+// FIXME: Move those functions to clang/include/clang/Format.h and reuse them?
+
+// Helper function for columnWidthWithTabs().
+inline unsigned columnWidth(StringRef Text) {
+  int ContentWidth = llvm::sys::unicode::columnWidthUTF8(Text);
+  if (ContentWidth < 0)
+return Text.size(); // fallback for unprintable characters
+  return ContentWidth;
+}
+
+// Returns the number of columns required to display the \p Text on a terminal
+// with the \p TabWidth.
+inline unsigned columnWidthWithTabs(StringRef Text, unsigned TabWidth) {
+  unsigned TotalWidth = 0;
+  StringRef Tail = Text;
+  for (;;) {
+StringRef::size_type TabPos = Tail.find('\t');
+if (TabPos == StringRef::npos)
+  return TotalWidth + columnWidth(Tail);
+TotalWidth += columnWidth(Tail.substr(0, TabPos));
+if (TabWidth)
+  TotalWidth += TabWidth - TotalWidth % TabWidth;
+Tail = Tail.substr(TabPos + 1);
+  }
+}
+
 // After a newline:
 //  - we continue any line-comment that was split
 //  - we format the old line in addition to the cursor
 //  - we represent the cursor with a line comment to preserve the newline
 IncrementalChanges getIncrementalChangesAfterNewline(llvm::StringRef Code,
- unsigned Cursor) {
+ unsigned Cursor,
+ unsigned TabWidth) {
   IncrementalChanges Result;
   // Before newline, code looked like:
   //leading^trailing
@@ -153,12 +182,12 @@
   if (!CommentMarker.empty() &&
   

[PATCH] D122271: [Clang] -Wunused-but-set-variable warning - handle also pre/post unary operators

2022-03-28 Thread Mikael Holmén via Phabricator via cfe-commits
uabelho added a comment.

Hi,

I noticed these to warning when compiling libunwind/src/UnwindLevel1.c with 
this patch:

  00:22:48 
/repo/bbiswjenk/fem2s10-eiffel176/workspace/llvm/sdk_1_20_ki_dev_test/libunwind/src/UnwindLevel1.c:175:12:
 warning: variable 'framesWalked' set but not used [-Wunused-but-set-variable]
  00:22:48   unsigned framesWalked = 1;
  00:22:48^
  00:22:48 
/repo/bbiswjenk/fem2s10-eiffel176/workspace/llvm/sdk_1_20_ki_dev_test/libunwind/src/UnwindLevel1.c:293:12:
 warning: variable 'framesWalked' set but not used [-Wunused-but-set-variable]
  00:22:48   unsigned framesWalked = 1;
  00:22:48^
  00:22:48 2 warnings generated.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122271

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


[PATCH] D122629: [RISCV] Add index check for vset/vget

2022-03-28 Thread Wang Pengcheng via Phabricator via cfe-commits
pcwang-thead created this revision.
pcwang-thead added reviewers: luismarques, asb, craig.topper, khchen.
Herald added subscribers: sunshaoce, VincentWu, luke957, StephenFan, vkmr, 
frasercrmck, evandro, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, 
jocewei, PkmX, arphaman, the_o, brucehoult, MartinMosbeck, rogfer01, 
edward-jones, zzheng, jrtc27, kito-cheng, niosHD, sabuasal, simoncook, 
johnrusso, rbar, arichardson.
Herald added a project: All.
pcwang-thead requested review of this revision.
Herald added subscribers: cfe-commits, eopXD, MaskRay.
Herald added a project: clang.

Index of vset/vget must be a constant integer and be
located in right range.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D122629

Files:
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/RISCV/rvv-intrinsics/vget-index-out-of-range.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vset-index-out-of-range.c

Index: clang/test/CodeGen/RISCV/rvv-intrinsics/vset-index-out-of-range.c
===
--- /dev/null
+++ clang/test/CodeGen/RISCV/rvv-intrinsics/vset-index-out-of-range.c
@@ -0,0 +1,341 @@
+// REQUIRES: riscv-registered-target
+// RUN: %clang_cc1 -triple riscv64 -target-feature +f -target-feature +d \
+// RUN:   -target-feature +v -target-feature +zfh -target-feature +experimental-zvfh \
+// RUN:   -fsyntax-only -verify %s
+
+#include 
+
+vint8m1_t test_vset_v_index_not_constant(vint8m2_t dest, vint8m1_t val, int index) {
+  // expected-error@+1 {{argument to 'vset_v_i8m1_i8m2' must be a constant integer}}
+  return vset_v_i8m1_i8m2(dest, index, val);
+}
+
+vint8m2_t test_vset_v_i8m1_i8m2(vint8m2_t dest, vint8m1_t val) {
+  // expected-error@+1 {{argument value 2 is outside the valid range [0, 1]}}
+  return vset_v_i8m1_i8m2(dest, 2, val);
+}
+
+vint8m4_t test_vset_v_i8m1_i8m4(vint8m4_t dest, vint8m1_t val) {
+  // expected-error@+1 {{argument value 4 is outside the valid range [0, 3]}}
+  return vset_v_i8m1_i8m4(dest, 4, val);
+}
+
+vint8m4_t test_vset_v_i8m2_i8m4(vint8m4_t dest, vint8m2_t val) {
+  // expected-error@+1 {{argument value 2 is outside the valid range [0, 1]}}
+  return vset_v_i8m2_i8m4(dest, 2, val);
+}
+
+vint8m8_t test_vset_v_i8m1_i8m8(vint8m8_t dest, vint8m1_t val) {
+  // expected-error@+1 {{argument value 8 is outside the valid range [0, 7]}}
+  return vset_v_i8m1_i8m8(dest, 8, val);
+}
+
+vint8m8_t test_vset_v_i8m2_i8m8(vint8m8_t dest, vint8m2_t val) {
+  // expected-error@+1 {{argument value 4 is outside the valid range [0, 3]}}
+  return vset_v_i8m2_i8m8(dest, 4, val);
+}
+
+vint8m8_t test_vset_v_i8m4_i8m8(vint8m8_t dest, vint8m4_t val) {
+  // expected-error@+1 {{argument value 2 is outside the valid range [0, 1]}}
+  return vset_v_i8m4_i8m8(dest, 2, val);
+}
+
+vint16m2_t test_vset_v_i16m1_i16m2(vint16m2_t dest, vint16m1_t val) {
+  // expected-error@+1 {{argument value 2 is outside the valid range [0, 1]}}
+  return vset_v_i16m1_i16m2(dest, 2, val);
+}
+
+vint16m4_t test_vset_v_i16m1_i16m4(vint16m4_t dest, vint16m1_t val) {
+  // expected-error@+1 {{argument value 4 is outside the valid range [0, 3]}}
+  return vset_v_i16m1_i16m4(dest, 4, val);
+}
+
+vint16m4_t test_vset_v_i16m2_i16m4(vint16m4_t dest, vint16m2_t val) {
+  // expected-error@+1 {{argument value 2 is outside the valid range [0, 1]}}
+  return vset_v_i16m2_i16m4(dest, 2, val);
+}
+
+vint16m8_t test_vset_v_i16m1_i16m8(vint16m8_t dest, vint16m1_t val) {
+  // expected-error@+1 {{argument value 8 is outside the valid range [0, 7]}}
+  return vset_v_i16m1_i16m8(dest, 8, val);
+}
+
+vint16m8_t test_vset_v_i16m2_i16m8(vint16m8_t dest, vint16m2_t val) {
+  // expected-error@+1 {{argument value 4 is outside the valid range [0, 3]}}
+  return vset_v_i16m2_i16m8(dest, 4, val);
+}
+
+vint16m8_t test_vset_v_i16m4_i16m8(vint16m8_t dest, vint16m4_t val) {
+  // expected-error@+1 {{argument value 2 is outside the valid range [0, 1]}}
+  return vset_v_i16m4_i16m8(dest, 2, val);
+}
+
+vint32m2_t test_vset_v_i32m1_i32m2(vint32m2_t dest, vint32m1_t val) {
+  // expected-error@+1 {{argument value 2 is outside the valid range [0, 1]}}
+  return vset_v_i32m1_i32m2(dest, 2, val);
+}
+
+vint32m4_t test_vset_v_i32m1_i32m4(vint32m4_t dest, vint32m1_t val) {
+  // expected-error@+1 {{argument value 4 is outside the valid range [0, 3]}}
+  return vset_v_i32m1_i32m4(dest, 4, val);
+}
+
+vint32m4_t test_vset_v_i32m2_i32m4(vint32m4_t dest, vint32m2_t val) {
+  // expected-error@+1 {{argument value 2 is outside the valid range [0, 1]}}
+  return vset_v_i32m2_i32m4(dest, 2, val);
+}
+
+vint32m8_t test_vset_v_i32m1_i32m8(vint32m8_t dest, vint32m1_t val) {
+  // expected-error@+1 {{argument value 8 is outside the valid range [0, 7]}}
+  return vset_v_i32m1_i32m8(dest, 8, val);
+}
+
+vint32m8_t test_vset_v_i32m2_i32m8(vint32m8_t dest, vint32m2_t val) {
+  // expected-error@+1 {{argument value 4 is outside the valid range [0, 3]}}
+  return vset_v_i32m2_i32m8(dest, 4, val);
+}
+
+vint32m8_t 

[PATCH] D122524: [Driver][AVR] Emit proper warnings for different options

2022-03-28 Thread Ben Shi 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 rG50de68bc2ffc: [Driver][AVR] Emit proper warnings for 
different options (authored by benshi001).

Changed prior to commit:
  https://reviews.llvm.org/D122524?vs=418764=418775#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122524

Files:
  clang/lib/Driver/ToolChains/AVR.cpp
  clang/test/Driver/avr-toolchain.c


Index: clang/test/Driver/avr-toolchain.c
===
--- clang/test/Driver/avr-toolchain.c
+++ clang/test/Driver/avr-toolchain.c
@@ -36,10 +36,25 @@
 // RUN: %clang %s -### --target=avr --sysroot=%S/Inputs/basic_avr_tree 2>&1 
-nostdlibinc | FileCheck --check-prefix=NOSTDINC %s
 // NOSTDINC-NOT: "-internal-isystem" {{".*avr/include"}}
 
-// RUN: %clang -### --target=avr --sysroot=%S/Inputs/basic_avr_tree %s 2>&1 | 
FileCheck --check-prefix=WARN_STDLIB %s
-// RUN: %clang -### --target=avr --sysroot=%S/Inputs/basic_avr_tree 
-mmcu=atmega328 %s 2>&1 | FileCheck --check-prefix=NOWARN_STDLIB %s
-// RUN: %clang -### --target=avr --sysroot=%S/Inputs/basic_avr_tree -c %s 2>&1 
| FileCheck --check-prefix=NOWARN_STDLIB %s
-
-// WARN_STDLIB: warning: no target microcontroller specified on command line, 
cannot link standard libraries, please pass -mmcu=
-// WARN_STDLIB: warning: standard library not linked and so no interrupt 
vector table or compiler runtime routines will be linked
-// NOWARN_STDLIB-NOT: warning:
+// RUN: %clang -### --target=avr --sysroot=%S/Inputs/basic_avr_tree 
-mmcu=atmega328 %s 2>&1 | FileCheck --check-prefix=NOWARN %s
+// RUN: %clang -### --target=avr --sysroot=%S/Inputs/basic_avr_tree 
-mmcu=atmega328 -S %s 2>&1 | FileCheck --check-prefix=NOWARN %s
+// RUN: %clang -### --target=avr --sysroot=%S/Inputs/ -mmcu=atmega328 -S %s 
2>&1 | FileCheck --check-prefix=NOWARN %s
+// NOWARN-NOT: warning:
+
+// RUN: %clang -### --target=avr --sysroot=%S/Inputs/basic_avr_tree -S %s 2>&1 
| FileCheck --check-prefixes=NOMCU,LINKA %s
+// RUN: %clang -### --target=avr --sysroot=%S/Inputs/ -S %s 2>&1 | FileCheck 
--check-prefixes=NOMCU,LINKA %s
+// RUN: %clang -### --target=avr --sysroot=%S/Inputs/basic_avr_tree %s 2>&1 | 
FileCheck --check-prefixes=NOMCU,LINKB %s
+// NOMCU: warning: no target microcontroller specified on command line, cannot 
link standard libraries, please pass -mmcu=
+// LINKB: warning: standard library not linked and so no interrupt vector 
table or compiler runtime routines will be linked
+// LINKB: warning: support for passing the data section address to the linker 
for microcontroller '' is not implemented
+// NOMCU-NOT: warning: {{.*}} avr-gcc
+// NOMCU-NOT: warning: {{.*}} avr-libc
+// LINKA-NOT: warning: {{.*}} interrupt vector
+// LINKA-NOT: warning: {{.*}} data section address
+
+// RUN: %clang -### --target=avr --sysroot=%S/Inputs/ -mmcu=atmega328 %s 2>&1 
| FileCheck --check-prefixes=NOGCC %s
+// NOGCC: warning: no avr-gcc installation can be found on the system, cannot 
link standard libraries
+// NOGCC: warning: standard library not linked and so no interrupt vector 
table or compiler runtime routines will be linked
+// NOGCC-NOT: warning: {{.*}} microcontroller
+// NOGCC-NOT: warning: {{.*}} avr-libc
+// NOGCC-NOT: warning: {{.*}} data section address
Index: clang/lib/Driver/ToolChains/AVR.cpp
===
--- clang/lib/Driver/ToolChains/AVR.cpp
+++ clang/lib/Driver/ToolChains/AVR.cpp
@@ -369,16 +369,17 @@
 : Generic_ELF(D, Triple, Args) {
   GCCInstallation.init(Triple, Args);
 
+  std::string CPU = getCPUName(D, Args, Triple);
+  if (CPU.empty())
+D.Diag(diag::warn_drv_avr_mcu_not_specified);
+
   // Only add default libraries if the user hasn't explicitly opted out.
   if (!Args.hasArg(options::OPT_nostdlib) &&
-  !Args.hasArg(options::OPT_nodefaultlibs)) {
-if (GCCInstallation.isValid()) {
-  GCCInstallPath = GCCInstallation.getInstallPath();
-  std::string GCCParentPath(GCCInstallation.getParentLibPath());
-  getProgramPaths().push_back(GCCParentPath + "/../bin");
-} else {
-  D.Diag(diag::warn_drv_avr_gcc_not_found);
-}
+  !Args.hasArg(options::OPT_nodefaultlibs) &&
+  GCCInstallation.isValid()) {
+GCCInstallPath = GCCInstallation.getInstallPath();
+std::string GCCParentPath(GCCInstallation.getParentLibPath());
+getProgramPaths().push_back(GCCParentPath + "/../bin");
   }
 }
 
@@ -448,22 +449,22 @@
   bool LinkStdlib = false;
   if (!Args.hasArg(options::OPT_nostdlib) &&
   !Args.hasArg(options::OPT_nodefaultlibs)) {
-if (CPU.empty()) {
-  // We cannot link any standard libraries without an MCU specified.
-  D.Diag(diag::warn_drv_avr_mcu_not_specified);
-} else {
-  Optional FamilyName = GetMCUFamilyName(CPU);
-  Optional AVRLibcRoot = 

[clang] 50de68b - [Driver][AVR] Emit proper warnings for different options

2022-03-28 Thread Ben Shi via cfe-commits

Author: Ben Shi
Date: 2022-03-29T12:05:21+08:00
New Revision: 50de68bc2ffc8f6825fb5445ec179a68aa6ad219

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

LOG: [Driver][AVR] Emit proper warnings for different options

Reviewed By: MaskRay

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/AVR.cpp
clang/test/Driver/avr-toolchain.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/AVR.cpp 
b/clang/lib/Driver/ToolChains/AVR.cpp
index 8ca8525e454b4..466fc3b20569e 100644
--- a/clang/lib/Driver/ToolChains/AVR.cpp
+++ b/clang/lib/Driver/ToolChains/AVR.cpp
@@ -369,16 +369,17 @@ AVRToolChain::AVRToolChain(const Driver , const 
llvm::Triple ,
 : Generic_ELF(D, Triple, Args) {
   GCCInstallation.init(Triple, Args);
 
+  std::string CPU = getCPUName(D, Args, Triple);
+  if (CPU.empty())
+D.Diag(diag::warn_drv_avr_mcu_not_specified);
+
   // Only add default libraries if the user hasn't explicitly opted out.
   if (!Args.hasArg(options::OPT_nostdlib) &&
-  !Args.hasArg(options::OPT_nodefaultlibs)) {
-if (GCCInstallation.isValid()) {
-  GCCInstallPath = GCCInstallation.getInstallPath();
-  std::string GCCParentPath(GCCInstallation.getParentLibPath());
-  getProgramPaths().push_back(GCCParentPath + "/../bin");
-} else {
-  D.Diag(diag::warn_drv_avr_gcc_not_found);
-}
+  !Args.hasArg(options::OPT_nodefaultlibs) &&
+  GCCInstallation.isValid()) {
+GCCInstallPath = GCCInstallation.getInstallPath();
+std::string GCCParentPath(GCCInstallation.getParentLibPath());
+getProgramPaths().push_back(GCCParentPath + "/../bin");
   }
 }
 
@@ -448,22 +449,22 @@ void AVR::Linker::ConstructJob(Compilation , const 
JobAction ,
   bool LinkStdlib = false;
   if (!Args.hasArg(options::OPT_nostdlib) &&
   !Args.hasArg(options::OPT_nodefaultlibs)) {
-if (CPU.empty()) {
-  // We cannot link any standard libraries without an MCU specified.
-  D.Diag(diag::warn_drv_avr_mcu_not_specified);
-} else {
-  Optional FamilyName = GetMCUFamilyName(CPU);
-  Optional AVRLibcRoot = TC.findAVRLibcInstallation();
+if (!CPU.empty()) {
+Optional FamilyName = GetMCUFamilyName(CPU);
+Optional AVRLibcRoot = TC.findAVRLibcInstallation();
 
   if (!FamilyName) {
 // We do not have an entry for this CPU in the family
 // mapping table yet.
 D.Diag(diag::warn_drv_avr_family_linking_stdlibs_not_implemented)
 << CPU;
+  } else if (TC.getGCCInstallPath().empty()) {
+// We can not link since there is no avr-ld.
+D.Diag(diag::warn_drv_avr_gcc_not_found);
   } else if (!AVRLibcRoot) {
 // No avr-libc found and so no runtime linked.
 D.Diag(diag::warn_drv_avr_libc_not_found);
-  } else if (!TC.getGCCInstallPath().empty()) {
+  } else {
 std::string SubPath = GetMCUSubPath(CPU);
 CmdArgs.push_back(
 Args.MakeArgString(Twine("-L") + *AVRLibcRoot + "/lib/" + 
SubPath));

diff  --git a/clang/test/Driver/avr-toolchain.c 
b/clang/test/Driver/avr-toolchain.c
index 8bd8f91192f28..89226a6bd929c 100644
--- a/clang/test/Driver/avr-toolchain.c
+++ b/clang/test/Driver/avr-toolchain.c
@@ -36,10 +36,25 @@
 // RUN: %clang %s -### --target=avr --sysroot=%S/Inputs/basic_avr_tree 2>&1 
-nostdlibinc | FileCheck --check-prefix=NOSTDINC %s
 // NOSTDINC-NOT: "-internal-isystem" {{".*avr/include"}}
 
-// RUN: %clang -### --target=avr --sysroot=%S/Inputs/basic_avr_tree %s 2>&1 | 
FileCheck --check-prefix=WARN_STDLIB %s
-// RUN: %clang -### --target=avr --sysroot=%S/Inputs/basic_avr_tree 
-mmcu=atmega328 %s 2>&1 | FileCheck --check-prefix=NOWARN_STDLIB %s
-// RUN: %clang -### --target=avr --sysroot=%S/Inputs/basic_avr_tree -c %s 2>&1 
| FileCheck --check-prefix=NOWARN_STDLIB %s
-
-// WARN_STDLIB: warning: no target microcontroller specified on command line, 
cannot link standard libraries, please pass -mmcu=
-// WARN_STDLIB: warning: standard library not linked and so no interrupt 
vector table or compiler runtime routines will be linked
-// NOWARN_STDLIB-NOT: warning:
+// RUN: %clang -### --target=avr --sysroot=%S/Inputs/basic_avr_tree 
-mmcu=atmega328 %s 2>&1 | FileCheck --check-prefix=NOWARN %s
+// RUN: %clang -### --target=avr --sysroot=%S/Inputs/basic_avr_tree 
-mmcu=atmega328 -S %s 2>&1 | FileCheck --check-prefix=NOWARN %s
+// RUN: %clang -### --target=avr --sysroot=%S/Inputs/ -mmcu=atmega328 -S %s 
2>&1 | FileCheck --check-prefix=NOWARN %s
+// NOWARN-NOT: warning:
+
+// RUN: %clang -### --target=avr --sysroot=%S/Inputs/basic_avr_tree -S %s 2>&1 
| FileCheck --check-prefixes=NOMCU,LINKA %s
+// RUN: %clang -### --target=avr --sysroot=%S/Inputs/ -S %s 2>&1 | FileCheck 

[PATCH] D122524: [Driver][AVR] Emit proper warnings for different options

2022-03-28 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/lib/Driver/ToolChains/AVR.cpp:477
 
 if (!LinkStdlib)
   D.Diag(diag::warn_drv_avr_stdlib_not_linked);

benshi001 wrote:
> We should not merge the above two `if`, due to this check.
> 
> So I will keep my orginal form when committing. 
OK. If we decide that empty -mpu will report a warning, reporting an additional 
warn_drv_avr_stdlib_not_linked may or may not be necessary, but I'm happy to 
defer that decision to you.


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

https://reviews.llvm.org/D122524

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


[PATCH] D122524: [Driver][AVR] Emit proper warnings for different options

2022-03-28 Thread Ben Shi via Phabricator via cfe-commits
benshi001 marked an inline comment as done.
benshi001 added inline comments.



Comment at: clang/lib/Driver/ToolChains/AVR.cpp:477
 
 if (!LinkStdlib)
   D.Diag(diag::warn_drv_avr_stdlib_not_linked);

We should not merge the above two `if`, due to this check.

So I will keep my orginal form when committing. 


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

https://reviews.llvm.org/D122524

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


[PATCH] D122524: [Driver][AVR] Emit proper warnings for different options

2022-03-28 Thread Ben Shi via Phabricator via cfe-commits
benshi001 marked an inline comment as done.
benshi001 added inline comments.



Comment at: clang/lib/Driver/ToolChains/AVR.cpp:451
   if (!Args.hasArg(options::OPT_nostdlib) &&
   !Args.hasArg(options::OPT_nodefaultlibs)) {
+if (!CPU.empty()) {

MaskRay wrote:
> The two if can be combined.
I will do it when committing.


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

https://reviews.llvm.org/D122524

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


[PATCH] D120639: [RISCV] Pass -mno-relax to assembler when -fno-integrated-as specified

2022-03-28 Thread luxufan via Phabricator via cfe-commits
StephenFan updated this revision to Diff 418774.
StephenFan added a comment.
Herald added a subscriber: sunshaoce.

Address @MaskRay 's comments.

1. explicit default-argument to avoid error-prone
2. change riscv64 test to test the case when `-mno-relax -mrelax` specified.

Is the change of riscv64 test match your requirements?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120639

Files:
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/test/Driver/riscv-gnutools.c


Index: clang/test/Driver/riscv-gnutools.c
===
--- clang/test/Driver/riscv-gnutools.c
+++ clang/test/Driver/riscv-gnutools.c
@@ -16,9 +16,14 @@
 // RUN: %clang -target riscv32 --gcc-toolchain=%S/Inputs/basic_riscv32_tree 
-fno-integrated-as %s -### -c -march=rv32g \
 // RUN: 2>&1 | FileCheck -check-prefix=CHECK-RV32G-ILP32D %s
 
+// Check -mno-relax is passed when -fno-integrated-as specified
+// RUN: %clang -target riscv32-unknown-elf 
--gcc-toolchain=%S/Inputs/basic_riscv32_tree -mno-relax -fno-integrated-as %s 
-### -c \
+// RUN: 2>&1 | FileCheck -check-prefix=CHECK-RV32-NO-RELAX %s
+
 // CHECK-RV32IMAC-ILP32: "{{.*}}as{{(.exe)?}}" "-mabi" "ilp32" "-march" 
"rv32imac"
 // CHECK-RV32IMAFDC-ILP32D: "{{.*}}as{{(.exe)?}}" "-mabi" "ilp32d" "-march" 
"rv32imafdc"
 // CHECK-RV32G-ILP32D: "{{.*}}as{{(.exe)?}}" "-mabi" "ilp32d" "-march" "rv32g"
+// CHECK-RV32-NO-RELAX: "{{.*}}as{{(.exe)?}}" "{{.*}}" "-mno-relax"
 
 
 // 64-bit checks
@@ -35,6 +40,12 @@
 // RUN: %clang -target riscv64 --gcc-toolchain=%S/Inputs/basic_riscv64_tree 
-fno-integrated-as %s -### -c -march=rv64g \
 // RUN: 2>&1 | FileCheck -check-prefix=CHECK-RV64G-LP64D %s
 
+// Check -mno-relax is not passed when -fno-integrated-as specified
+// RUN: %clang -target riscv64-unknown-elf 
--gcc-toolchain=%S/Inputs/basic_riscv64_tree -mno-relax -mrelax 
-fno-integrated-as %s -### -c \
+// RUN: 2>&1 | FileCheck -check-prefix=CHECK-RV64-RELAX %s
+
 // CHECK-RV64IMAC-LP64: "{{.*}}as{{(.exe)?}}" "-mabi" "lp64" "-march" 
"rv64imac"
 // CHECK-RV64IMAFDC-LP64D: "{{.*}}as{{(.exe)?}}" "-mabi" "lp64d" "-march" 
"rv64imafdc"
 // CHECK-RV64G-LP64D: "{{.*}}as{{(.exe)?}}" "-mabi" "lp64d" "-march" "rv64g"
+// CHECK-RV64-RELAX: "{{.*}}as{{(.exe)?}}"
+// CHECK-RV64-RELAX-NOT: "-mno-relax"
Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -761,6 +761,8 @@
 StringRef MArchName = riscv::getRISCVArch(Args, 
getToolChain().getTriple());
 CmdArgs.push_back("-march");
 CmdArgs.push_back(MArchName.data());
+if (!Args.hasFlag(options::OPT_mrelax, options::OPT_mno_relax, true))
+  CmdArgs.push_back("-mno-relax");
 break;
   }
   case llvm::Triple::sparc:


Index: clang/test/Driver/riscv-gnutools.c
===
--- clang/test/Driver/riscv-gnutools.c
+++ clang/test/Driver/riscv-gnutools.c
@@ -16,9 +16,14 @@
 // RUN: %clang -target riscv32 --gcc-toolchain=%S/Inputs/basic_riscv32_tree -fno-integrated-as %s -### -c -march=rv32g \
 // RUN: 2>&1 | FileCheck -check-prefix=CHECK-RV32G-ILP32D %s
 
+// Check -mno-relax is passed when -fno-integrated-as specified
+// RUN: %clang -target riscv32-unknown-elf --gcc-toolchain=%S/Inputs/basic_riscv32_tree -mno-relax -fno-integrated-as %s -### -c \
+// RUN: 2>&1 | FileCheck -check-prefix=CHECK-RV32-NO-RELAX %s
+
 // CHECK-RV32IMAC-ILP32: "{{.*}}as{{(.exe)?}}" "-mabi" "ilp32" "-march" "rv32imac"
 // CHECK-RV32IMAFDC-ILP32D: "{{.*}}as{{(.exe)?}}" "-mabi" "ilp32d" "-march" "rv32imafdc"
 // CHECK-RV32G-ILP32D: "{{.*}}as{{(.exe)?}}" "-mabi" "ilp32d" "-march" "rv32g"
+// CHECK-RV32-NO-RELAX: "{{.*}}as{{(.exe)?}}" "{{.*}}" "-mno-relax"
 
 
 // 64-bit checks
@@ -35,6 +40,12 @@
 // RUN: %clang -target riscv64 --gcc-toolchain=%S/Inputs/basic_riscv64_tree -fno-integrated-as %s -### -c -march=rv64g \
 // RUN: 2>&1 | FileCheck -check-prefix=CHECK-RV64G-LP64D %s
 
+// Check -mno-relax is not passed when -fno-integrated-as specified
+// RUN: %clang -target riscv64-unknown-elf --gcc-toolchain=%S/Inputs/basic_riscv64_tree -mno-relax -mrelax -fno-integrated-as %s -### -c \
+// RUN: 2>&1 | FileCheck -check-prefix=CHECK-RV64-RELAX %s
+
 // CHECK-RV64IMAC-LP64: "{{.*}}as{{(.exe)?}}" "-mabi" "lp64" "-march" "rv64imac"
 // CHECK-RV64IMAFDC-LP64D: "{{.*}}as{{(.exe)?}}" "-mabi" "lp64d" "-march" "rv64imafdc"
 // CHECK-RV64G-LP64D: "{{.*}}as{{(.exe)?}}" "-mabi" "lp64d" "-march" "rv64g"
+// CHECK-RV64-RELAX: "{{.*}}as{{(.exe)?}}"
+// CHECK-RV64-RELAX-NOT: "-mno-relax"
Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -761,6 +761,8 @@
 StringRef MArchName = riscv::getRISCVArch(Args, 

[PATCH] D122524: [Driver][AVR] Emit proper warnings for different options

2022-03-28 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay accepted this revision.
MaskRay added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/lib/Driver/ToolChains/AVR.cpp:451
   if (!Args.hasArg(options::OPT_nostdlib) &&
   !Args.hasArg(options::OPT_nodefaultlibs)) {
+if (!CPU.empty()) {

The two if can be combined.


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

https://reviews.llvm.org/D122524

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


[PATCH] D122104: [X86][regcall] Support passing / returning structures

2022-03-28 Thread Phoebe Wang via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGcd26190a10fc: [X86][regcall] Support passing / returning 
structures (authored by pengfei).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122104

Files:
  clang/include/clang/CodeGen/CGFunctionInfo.h
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGen/X86/x86_64-arguments.c
  clang/test/CodeGen/aarch64-neon-tbl.c
  clang/test/CodeGen/regcall2.c

Index: clang/test/CodeGen/regcall2.c
===
--- /dev/null
+++ clang/test/CodeGen/regcall2.c
@@ -0,0 +1,28 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -emit-llvm %s -o - -ffreestanding -target-feature +avx512vl -triple=x86_64-pc-win32 | FileCheck %s --check-prefix=Win
+// RUN: %clang_cc1 -emit-llvm %s -o - -ffreestanding -target-feature +avx512vl -triple=x86_64-pc-linux-gnu | FileCheck %s --check-prefix=Lin
+
+#include 
+
+typedef struct {
+  __m512d r1[4];
+  __m512 r2[4];
+} __sVector;
+__sVector A;
+
+__sVector __regcall foo(int a) {
+  return A;
+}
+
+double __regcall bar(__sVector a) {
+  return a.r1[0][4];
+}
+
+// FIXME: Do we need to change for Windows?
+// Win: define dso_local x86_regcallcc void @__regcall3__foo(%struct.__sVector* noalias sret(%struct.__sVector) align 64 %agg.result, i32 noundef %a) #0
+// Win: define dso_local x86_regcallcc double @__regcall3__bar(%struct.__sVector* noundef %a) #0
+// Win: attributes #0 = { noinline nounwind optnone "frame-pointer"="none" "min-legal-vector-width"="0" "no-builtins" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+avx,+avx2,+avx512f,+avx512vl,+crc32,+cx8,+f16c,+fma,+mmx,+popcnt,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87,+xsave" }
+
+// Lin: define dso_local x86_regcallcc %struct.__sVector @__regcall3__foo(i32 noundef %a) #0
+// Lin: define dso_local x86_regcallcc double @__regcall3__bar([4 x <8 x double>] %a.coerce0, [4 x <16 x float>] %a.coerce1) #0
+// Lin: attributes #0 = { noinline nounwind optnone "frame-pointer"="none" "min-legal-vector-width"="512" "no-builtins" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+avx,+avx2,+avx512f,+avx512vl,+crc32,+cx8,+f16c,+fma,+mmx,+popcnt,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87,+xsave" }
Index: clang/test/CodeGen/aarch64-neon-tbl.c
===
--- clang/test/CodeGen/aarch64-neon-tbl.c
+++ clang/test/CodeGen/aarch64-neon-tbl.c
@@ -42,7 +42,7 @@
   return vtbl2_s8(a, b);
 }
 
-// CHECK-LABEL: define{{.*}} <8 x i8> @test_vqtbl2_s8([2 x <16 x i8>] %a.coerce, <8 x i8> noundef %b) #0 {
+// CHECK-LABEL: define{{.*}} <8 x i8> @test_vqtbl2_s8([2 x <16 x i8>] %a.coerce, <8 x i8> noundef %b) #1 {
 // CHECK:   [[__P0_I:%.*]] = alloca %struct.int8x16x2_t, align 16
 // CHECK:   [[A:%.*]] = alloca %struct.int8x16x2_t, align 16
 // CHECK:   [[COERCE_DIVE:%.*]] = getelementptr inbounds %struct.int8x16x2_t, %struct.int8x16x2_t* [[A]], i32 0, i32 0
@@ -89,7 +89,7 @@
   return vtbl3_s8(a, b);
 }
 
-// CHECK-LABEL: define{{.*}} <8 x i8> @test_vqtbl3_s8([3 x <16 x i8>] %a.coerce, <8 x i8> noundef %b) #0 {
+// CHECK-LABEL: define{{.*}} <8 x i8> @test_vqtbl3_s8([3 x <16 x i8>] %a.coerce, <8 x i8> noundef %b) #1 {
 // CHECK:   [[__P0_I:%.*]] = alloca %struct.int8x16x3_t, align 16
 // CHECK:   [[A:%.*]] = alloca %struct.int8x16x3_t, align 16
 // CHECK:   [[COERCE_DIVE:%.*]] = getelementptr inbounds %struct.int8x16x3_t, %struct.int8x16x3_t* [[A]], i32 0, i32 0
@@ -142,7 +142,7 @@
   return vtbl4_s8(a, b);
 }
 
-// CHECK-LABEL: define{{.*}} <8 x i8> @test_vqtbl4_s8([4 x <16 x i8>] %a.coerce, <8 x i8> noundef %b) #0 {
+// CHECK-LABEL: define{{.*}} <8 x i8> @test_vqtbl4_s8([4 x <16 x i8>] %a.coerce, <8 x i8> noundef %b) #1 {
 // CHECK:   [[__P0_I:%.*]] = alloca %struct.int8x16x4_t, align 16
 // CHECK:   [[A:%.*]] = alloca %struct.int8x16x4_t, align 16
 // CHECK:   [[COERCE_DIVE:%.*]] = getelementptr inbounds %struct.int8x16x4_t, %struct.int8x16x4_t* [[A]], i32 0, i32 0
@@ -352,7 +352,7 @@
   return vqtbx1_s8(a, b, c);
 }
 
-// CHECK-LABEL: define{{.*}} <8 x i8> @test_vqtbx2_s8(<8 x i8> noundef %a, [2 x <16 x i8>] %b.coerce, <8 x i8> noundef %c) #0 {
+// CHECK-LABEL: define{{.*}} <8 x i8> @test_vqtbx2_s8(<8 x i8> noundef %a, [2 x <16 x i8>] %b.coerce, <8 x i8> noundef %c) #1 {
 // CHECK:   [[__P1_I:%.*]] = alloca %struct.int8x16x2_t, align 16
 // CHECK:   [[B:%.*]] = alloca %struct.int8x16x2_t, align 16
 // CHECK:   [[COERCE_DIVE:%.*]] = getelementptr inbounds %struct.int8x16x2_t, %struct.int8x16x2_t* [[B]], i32 0, i32 0
@@ -373,7 +373,7 @@
   return vqtbx2_s8(a, b, c);
 }
 
-// CHECK-LABEL: define{{.*}} <8 x i8> @test_vqtbx3_s8(<8 x i8> noundef %a, [3 x <16 x i8>] %b.coerce, <8 x i8> noundef %c) #0 {

[clang] cd26190 - [X86][regcall] Support passing / returning structures

2022-03-28 Thread Phoebe Wang via cfe-commits

Author: Phoebe Wang
Date: 2022-03-29T11:29:57+08:00
New Revision: cd26190a10fceb6e1472fabcd9e1736f62f078c4

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

LOG: [X86][regcall] Support passing / returning structures

Currently, the regcall calling conversion in Clang doesn't match with
ICC when passing / returning structures. https://godbolt.org/z/axxKMKrW7

This patch tries to fix the problem to match with ICC.

Reviewed By: LuoYuanke

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

Added: 
clang/test/CodeGen/regcall2.c

Modified: 
clang/include/clang/CodeGen/CGFunctionInfo.h
clang/lib/CodeGen/CGCall.cpp
clang/lib/CodeGen/CodeGenFunction.cpp
clang/lib/CodeGen/TargetInfo.cpp
clang/test/CodeGen/X86/x86_64-arguments.c
clang/test/CodeGen/aarch64-neon-tbl.c

Removed: 




diff  --git a/clang/include/clang/CodeGen/CGFunctionInfo.h 
b/clang/include/clang/CodeGen/CGFunctionInfo.h
index cd6c7e2e31287..288097b0dc897 100644
--- a/clang/include/clang/CodeGen/CGFunctionInfo.h
+++ b/clang/include/clang/CodeGen/CGFunctionInfo.h
@@ -586,6 +586,9 @@ class CGFunctionInfo final
   /// Whether this function has nocf_check attribute.
   unsigned NoCfCheck : 1;
 
+  /// Log 2 of the maximum vector width.
+  unsigned MaxVectorWidth : 4;
+
   RequiredArgs Required;
 
   /// The struct representing all arguments passed in memory.  Only used when
@@ -731,6 +734,17 @@ class CGFunctionInfo final
 ArgStructAlign = Align.getQuantity();
   }
 
+  /// Return the maximum vector width in the arguments.
+  unsigned getMaxVectorWidth() const {
+return MaxVectorWidth ? 1U << (MaxVectorWidth - 1) : 0;
+  }
+
+  /// Set the maximum vector width in the arguments.
+  void setMaxVectorWidth(unsigned Width) {
+assert(llvm::isPowerOf2_32(Width) && "Expected power of 2 vector");
+MaxVectorWidth = llvm::countTrailingZeros(Width) + 1;
+  }
+
   void Profile(llvm::FoldingSetNodeID ) {
 ID.AddInteger(getASTCallingConvention());
 ID.AddBoolean(InstanceMethod);

diff  --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index 6cfc3c56c165b..e2ffd57dcbd0e 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -833,6 +833,7 @@ CGFunctionInfo *CGFunctionInfo::create(unsigned llvmCC,
   FI->NumArgs = argTypes.size();
   FI->HasExtParameterInfos = !paramInfos.empty();
   FI->getArgsBuffer()[0].type = resultType;
+  FI->MaxVectorWidth = 0;
   for (unsigned i = 0, e = argTypes.size(); i != e; ++i)
 FI->getArgsBuffer()[i + 1].type = argTypes[i];
   for (unsigned i = 0, e = paramInfos.size(); i != e; ++i)
@@ -4668,6 +4669,19 @@ class AllocAlignAttrEmitter final
 
 } // namespace
 
+static unsigned getMaxVectorWidth(const llvm::Type *Ty) {
+  if (auto *VT = dyn_cast(Ty))
+return VT->getPrimitiveSizeInBits().getKnownMinSize();
+  if (auto *AT = dyn_cast(Ty))
+return getMaxVectorWidth(AT->getElementType());
+
+  unsigned MaxVectorWidth = 0;
+  if (auto *ST = dyn_cast(Ty))
+for (auto *I : ST->elements())
+  MaxVectorWidth = std::max(MaxVectorWidth, getMaxVectorWidth(I));
+  return MaxVectorWidth;
+}
+
 RValue CodeGenFunction::EmitCall(const CGFunctionInfo ,
  const CGCallee ,
  ReturnValueSlot ReturnValue,
@@ -5221,12 +5235,9 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo 
,
 #endif
 
   // Update the largest vector width if any arguments have vector types.
-  for (unsigned i = 0; i < IRCallArgs.size(); ++i) {
-if (auto *VT = dyn_cast(IRCallArgs[i]->getType()))
-  LargestVectorWidth =
-  std::max((uint64_t)LargestVectorWidth,
-   VT->getPrimitiveSizeInBits().getKnownMinSize());
-  }
+  for (unsigned i = 0; i < IRCallArgs.size(); ++i)
+LargestVectorWidth = std::max(LargestVectorWidth,
+  getMaxVectorWidth(IRCallArgs[i]->getType()));
 
   // Compute the calling convention and attributes.
   unsigned CallingConv;
@@ -5348,10 +5359,8 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo 
,
 CI->setName("call");
 
   // Update largest vector width from the return type.
-  if (auto *VT = dyn_cast(CI->getType()))
-LargestVectorWidth =
-std::max((uint64_t)LargestVectorWidth,
- VT->getPrimitiveSizeInBits().getKnownMinSize());
+  LargestVectorWidth =
+  std::max(LargestVectorWidth, getMaxVectorWidth(CI->getType()));
 
   // Insert instrumentation or attach profile metadata at indirect call sites.
   // For more details, see the comment before the definition of

diff  --git a/clang/lib/CodeGen/CodeGenFunction.cpp 
b/clang/lib/CodeGen/CodeGenFunction.cpp
index 15719d12eafeb..aadf081654925 100644
--- a/clang/lib/CodeGen/CodeGenFunction.cpp
+++ 

[PATCH] D122588: [RISCV] Make PATH empty when testing --gcc-toolchain is multilib_riscv_elf_sdk

2022-03-28 Thread luxufan via Phabricator via cfe-commits
StephenFan updated this revision to Diff 418771.
StephenFan added a comment.
Herald added a subscriber: sunshaoce.

Address @MaskRay 's comments

Change log:

1. Update test in riscv32-toolchain.c
2. Make system-windows UNSUPPORTED


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122588

Files:
  clang/test/Driver/riscv32-toolchain.c
  clang/test/Driver/riscv64-toolchain.c


Index: clang/test/Driver/riscv64-toolchain.c
===
--- clang/test/Driver/riscv64-toolchain.c
+++ clang/test/Driver/riscv64-toolchain.c
@@ -1,3 +1,4 @@
+// UNSUPPORTED: system-windows
 // A basic clang -cc1 command-line, and simple environment check.
 
 // RUN: %clang %s -### -no-canonical-prefixes --target=riscv64 \
@@ -104,7 +105,7 @@
 // C-RV64-LINUX-MULTI-LP64D: 
"-L{{.*}}/Inputs/multilib_riscv_linux_sdk/sysroot/lib64/lp64d"
 // C-RV64-LINUX-MULTI-LP64D: 
"-L{{.*}}/Inputs/multilib_riscv_linux_sdk/sysroot/usr/lib64/lp64d"
 
-// RUN: %clang %s -### -fuse-ld=ld \
+// RUN: env "PATH=" %clang %s -### -fuse-ld=ld \
 // RUN:   --target=riscv64-unknown-elf --rtlib=platform --sysroot= \
 // RUN:   -march=rv64imac -mabi=lp64\
 // RUN:   --gcc-toolchain=%S/Inputs/multilib_riscv_elf_sdk 2>&1 \
@@ -119,7 +120,7 @@
 // C-RV64IMAC-BAREMETAL-MULTI-LP64: "--start-group" "-lc" "-lgloss" 
"--end-group" "-lgcc"
 // C-RV64IMAC-BAREMETAL-MULTI-LP64: 
"{{.*}}/Inputs/multilib_riscv_elf_sdk/lib/gcc/riscv64-unknown-elf/8.2.0/rv64imac/lp64{{/|}}crtend.o"
 
-// RUN: %clang %s -### -fuse-ld=ld \
+// RUN: env "PATH=" %clang %s -### -fuse-ld=ld \
 // RUN:   --target=riscv64-unknown-elf --rtlib=platform --sysroot= \
 // RUN:   -march=rv64imafdc -mabi=lp64d \
 // RUN:   --gcc-toolchain=%S/Inputs/multilib_riscv_elf_sdk 2>&1 \
Index: clang/test/Driver/riscv32-toolchain.c
===
--- clang/test/Driver/riscv32-toolchain.c
+++ clang/test/Driver/riscv32-toolchain.c
@@ -1,3 +1,4 @@
+// UNSUPPORTED: system-windows
 // A basic clang -cc1 command-line, and simple environment check.
 
 // RUN: %clang %s -### -no-canonical-prefixes --target=riscv32 \
@@ -74,7 +75,7 @@
 // CXX-RV32-BAREMETAL-NOSYSROOT-ILP32: "-lstdc++" "--start-group" "-lc" 
"-lgloss" "--end-group" "-lgcc"
 // CXX-RV32-BAREMETAL-NOSYSROOT-ILP32: 
"{{.*}}/Inputs/basic_riscv32_tree/lib/gcc/riscv32-unknown-elf/8.0.1{{/|}}crtend.o"
 
-// RUN: %clang %s -### -fuse-ld=ld -no-pie \
+// RUN: env "PATH=" %clang %s -### -fuse-ld=ld -no-pie \
 // RUN:   --target=riscv32-unknown-linux-gnu --rtlib=platform -mabi=ilp32 \
 // RUN:   --gcc-toolchain=%S/Inputs/multilib_riscv_linux_sdk \
 // RUN:   --sysroot=%S/Inputs/multilib_riscv_linux_sdk/sysroot 2>&1 \
@@ -89,7 +90,7 @@
 // C-RV32-LINUX-MULTI-ILP32: 
"-L{{.*}}/Inputs/multilib_riscv_linux_sdk/sysroot/lib32/ilp32"
 // C-RV32-LINUX-MULTI-ILP32: 
"-L{{.*}}/Inputs/multilib_riscv_linux_sdk/sysroot/usr/lib32/ilp32"
 
-// RUN: %clang %s -### -fuse-ld=ld -no-pie \
+// RUN: env "PATH=" %clang %s -### -fuse-ld=ld -no-pie \
 // RUN:   --target=riscv32-unknown-linux-gnu --rtlib=platform -march=rv32imafd 
\
 // RUN:   --gcc-toolchain=%S/Inputs/multilib_riscv_linux_sdk \
 // RUN:   --sysroot=%S/Inputs/multilib_riscv_linux_sdk/sysroot 2>&1 \
@@ -104,7 +105,7 @@
 // C-RV32-LINUX-MULTI-ILP32D: 
"-L{{.*}}/Inputs/multilib_riscv_linux_sdk/sysroot/lib32/ilp32d"
 // C-RV32-LINUX-MULTI-ILP32D: 
"-L{{.*}}/Inputs/multilib_riscv_linux_sdk/sysroot/usr/lib32/ilp32d"
 
-// RUN: %clang %s -### -fuse-ld=ld \
+// RUN: env "PATH=" %clang %s -### -fuse-ld=ld \
 // RUN:   --target=riscv32-unknown-elf --rtlib=platform --sysroot= \
 // RUN:   --gcc-toolchain=%S/Inputs/multilib_riscv_elf_sdk 2>&1 \
 // RUN:   | FileCheck -check-prefix=C-RV32I-BAREMETAL-MULTI-ILP32 %s
@@ -118,7 +119,7 @@
 // C-RV32I-BAREMETAL-MULTI-ILP32: "--start-group" "-lc" "-lgloss" 
"--end-group" "-lgcc"
 // C-RV32I-BAREMETAL-MULTI-ILP32: 
"{{.*}}/Inputs/multilib_riscv_elf_sdk/lib/gcc/riscv64-unknown-elf/8.2.0/rv32imac/ilp32{{/|}}crtend.o"
 
-// RUN: %clang %s -### -fuse-ld=ld \
+// RUN: env "PATH=" %clang %s -### -fuse-ld=ld \
 // RUN:   --target=riscv32-unknown-elf --rtlib=platform --sysroot= \
 // RUN:   -march=rv32im -mabi=ilp32\
 // RUN:   --gcc-toolchain=%S/Inputs/multilib_riscv_elf_sdk 2>&1 \
@@ -133,7 +134,7 @@
 // C-RV32IM-BAREMETAL-MULTI-ILP32: "--start-group" "-lc" "-lgloss" 
"--end-group" "-lgcc"
 // C-RV32IM-BAREMETAL-MULTI-ILP32: 
"{{.*}}/Inputs/multilib_riscv_elf_sdk/lib/gcc/riscv64-unknown-elf/8.2.0/rv32im/ilp32{{/|}}crtend.o"
 
-// RUN: %clang %s -### -fuse-ld=ld \
+// RUN: env "PATH=" %clang %s -### -fuse-ld=ld \
 // RUN:   --target=riscv32-unknown-elf --rtlib=platform --sysroot= \
 // RUN:   -march=rv32iac -mabi=ilp32\
 // RUN:   --gcc-toolchain=%S/Inputs/multilib_riscv_elf_sdk 2>&1 \
@@ -148,7 +149,7 @@
 // C-RV32IAC-BAREMETAL-MULTI-ILP32: "--start-group" "-lc" "-lgloss" 
"--end-group" "-lgcc"
 // 

[PATCH] D122524: [Driver][AVR] Emit proper warnings for different options

2022-03-28 Thread Ben Shi via Phabricator via cfe-commits
benshi001 added a comment.

In D122524#3411879 , @MaskRay wrote:

> In D122524#3411872 , @benshi001 
> wrote:
>
>> In D122524#3410542 , @MaskRay 
>> wrote:
>>
>>> I think it is excessive to add so many RUN lines. I do not understand much 
>>> about AVR -mcpu. That said, I created D122553 
>>>  for what I think should be done for the 
>>> `-c/-S/-fsyntax-only` condition. More tests would just be excessive.
>>>
>>> You may adjust the patch to do the rest cleanups/fixes.
>>
>> I have made some changes based on your https://reviews.llvm.org/D122553, it 
>> seems you have reverted. I suggest you recommit, since I have fixed the 
>> failures of lacking avr-gcc.
>
> I did not specify --sysroot so the new tests failed on systems without 
> avr-gcc. Relanded.

I have made some changes based on your code:

1. We should always warn if there is no mmcu specified, since its info 
(instruction set version) is used by the llvm backend.
2. We need no warn no avr-gcc if `-S`/`-c` is specified, since the 
compiling stage need neither avr-gcc nor avr-libc.

Thanks for your way to avoid checking so many `-c`/`-S`/`-fsyntax-only`/... 
conditions.


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

https://reviews.llvm.org/D122524

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


[PATCH] D122524: [Driver][AVR] Emit proper warnings for different options

2022-03-28 Thread Ben Shi via Phabricator via cfe-commits
benshi001 updated this revision to Diff 418764.
benshi001 retitled this revision from "[clang][AVR] Emit proper warnings" to 
"[Driver][AVR] Emit proper warnings for different options".

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

https://reviews.llvm.org/D122524

Files:
  clang/lib/Driver/ToolChains/AVR.cpp
  clang/test/Driver/avr-toolchain.c


Index: clang/test/Driver/avr-toolchain.c
===
--- clang/test/Driver/avr-toolchain.c
+++ clang/test/Driver/avr-toolchain.c
@@ -36,10 +36,25 @@
 // RUN: %clang %s -### --target=avr --sysroot=%S/Inputs/basic_avr_tree 2>&1 
-nostdlibinc | FileCheck --check-prefix=NOSTDINC %s
 // NOSTDINC-NOT: "-internal-isystem" {{".*avr/include"}}
 
-// RUN: %clang -### --target=avr --sysroot=%S/Inputs/basic_avr_tree %s 2>&1 | 
FileCheck --check-prefix=WARN_STDLIB %s
-// RUN: %clang -### --target=avr --sysroot=%S/Inputs/basic_avr_tree 
-mmcu=atmega328 %s 2>&1 | FileCheck --check-prefix=NOWARN_STDLIB %s
-// RUN: %clang -### --target=avr --sysroot=%S/Inputs/basic_avr_tree -c %s 2>&1 
| FileCheck --check-prefix=NOWARN_STDLIB %s
-
-// WARN_STDLIB: warning: no target microcontroller specified on command line, 
cannot link standard libraries, please pass -mmcu=
-// WARN_STDLIB: warning: standard library not linked and so no interrupt 
vector table or compiler runtime routines will be linked
-// NOWARN_STDLIB-NOT: warning:
+// RUN: %clang -### --target=avr --sysroot=%S/Inputs/basic_avr_tree 
-mmcu=atmega328 %s 2>&1 | FileCheck --check-prefix=NOWARN %s
+// RUN: %clang -### --target=avr --sysroot=%S/Inputs/basic_avr_tree 
-mmcu=atmega328 -S %s 2>&1 | FileCheck --check-prefix=NOWARN %s
+// RUN: %clang -### --target=avr --sysroot=%S/Inputs/ -mmcu=atmega328 -S %s 
2>&1 | FileCheck --check-prefix=NOWARN %s
+// NOWARN-NOT: warning:
+
+// RUN: %clang -### --target=avr --sysroot=%S/Inputs/basic_avr_tree -S %s 2>&1 
| FileCheck --check-prefixes=NOMCU,LINKA %s
+// RUN: %clang -### --target=avr --sysroot=%S/Inputs/ -S %s 2>&1 | FileCheck 
--check-prefixes=NOMCU,LINKA %s
+// RUN: %clang -### --target=avr --sysroot=%S/Inputs/basic_avr_tree %s 2>&1 | 
FileCheck --check-prefixes=NOMCU,LINKB %s
+// NOMCU: warning: no target microcontroller specified on command line, cannot 
link standard libraries, please pass -mmcu=
+// LINKB: warning: standard library not linked and so no interrupt vector 
table or compiler runtime routines will be linked
+// LINKB: warning: support for passing the data section address to the linker 
for microcontroller '' is not implemented
+// NOMCU-NOT: warning: {{.*}} avr-gcc
+// NOMCU-NOT: warning: {{.*}} avr-libc
+// LINKA-NOT: warning: {{.*}} interrupt vector
+// LINKA-NOT: warning: {{.*}} data section address
+
+// RUN: %clang -### --target=avr --sysroot=%S/Inputs/ -mmcu=atmega328 %s 2>&1 
| FileCheck --check-prefixes=NOGCC %s
+// NOGCC: warning: no avr-gcc installation can be found on the system, cannot 
link standard libraries
+// NOGCC: warning: standard library not linked and so no interrupt vector 
table or compiler runtime routines will be linked
+// NOGCC-NOT: warning: {{.*}} microcontroller
+// NOGCC-NOT: warning: {{.*}} avr-libc
+// NOGCC-NOT: warning: {{.*}} data section address
Index: clang/lib/Driver/ToolChains/AVR.cpp
===
--- clang/lib/Driver/ToolChains/AVR.cpp
+++ clang/lib/Driver/ToolChains/AVR.cpp
@@ -369,16 +369,17 @@
 : Generic_ELF(D, Triple, Args) {
   GCCInstallation.init(Triple, Args);
 
+  std::string CPU = getCPUName(D, Args, Triple);
+  if (CPU.empty())
+D.Diag(diag::warn_drv_avr_mcu_not_specified);
+
   // Only add default libraries if the user hasn't explicitly opted out.
   if (!Args.hasArg(options::OPT_nostdlib) &&
-  !Args.hasArg(options::OPT_nodefaultlibs)) {
-if (GCCInstallation.isValid()) {
-  GCCInstallPath = GCCInstallation.getInstallPath();
-  std::string GCCParentPath(GCCInstallation.getParentLibPath());
-  getProgramPaths().push_back(GCCParentPath + "/../bin");
-} else {
-  D.Diag(diag::warn_drv_avr_gcc_not_found);
-}
+  !Args.hasArg(options::OPT_nodefaultlibs) &&
+  GCCInstallation.isValid()) {
+GCCInstallPath = GCCInstallation.getInstallPath();
+std::string GCCParentPath(GCCInstallation.getParentLibPath());
+getProgramPaths().push_back(GCCParentPath + "/../bin");
   }
 }
 
@@ -448,10 +449,7 @@
   bool LinkStdlib = false;
   if (!Args.hasArg(options::OPT_nostdlib) &&
   !Args.hasArg(options::OPT_nodefaultlibs)) {
-if (CPU.empty()) {
-  // We cannot link any standard libraries without an MCU specified.
-  D.Diag(diag::warn_drv_avr_mcu_not_specified);
-} else {
+if (!CPU.empty()) {
   Optional FamilyName = GetMCUFamilyName(CPU);
   Optional AVRLibcRoot = TC.findAVRLibcInstallation();
 
@@ -460,10 +458,13 @@
 // mapping table yet.
 

[PATCH] D122627: [HLSL] Fix MSFT Attribute parsing, add numthreads

2022-03-28 Thread Greg Roth via Phabricator via cfe-commits
pow2clk added a comment.

Looks good. I made a comment about the CS 4.0 thing, but that can be addressed 
when more thorough examination of the requested shader models comes around.




Comment at: clang/lib/Sema/SemaDeclAttr.cpp:6857
+  uint32_t ThreadMax = 1024;
+  if (SMVersion.getMajor() <= 4) {
+ZMax = 1;

As we discussed, compute shaders didn't actually exist pre-4.0 and I don't know 
that we'll ever seek to do anything with a 4.0 shader model except convert it 
to a higher version and issue a notification, but that handling is clearly not 
the intent of this change. So it's fine with me. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122627

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


[PATCH] D122620: [clang][DR] Test and mark DR1479 as complete

2022-03-28 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu accepted this revision.
ChuanqiXu 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/D122620/new/

https://reviews.llvm.org/D122620

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


[PATCH] D122564: [RISCV] [NFC] add some tests for overloaded intrinsics of FP16

2022-03-28 Thread Chenbing.Zheng 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 rGd9ef6ad05ff3: [RISCV] [NFC] add some tests for overloaded 
intrinsics of FP16 (authored by Chenbing.Zheng).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122564

Files:
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vle.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vlse.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vse.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vsse.c

Index: clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vsse.c
===
--- clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vsse.c
+++ clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vsse.c
@@ -1,7 +1,7 @@
 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
 // REQUIRES: riscv-registered-target
-// RUN: %clang_cc1 -triple riscv64 -target-feature +f -target-feature +d -target-feature +v \
-// RUN:   -disable-O0-optnone -emit-llvm %s -o - | opt -S -mem2reg | FileCheck --check-prefix=CHECK-RV64 %s
+// RUN: %clang_cc1 -triple riscv64 -target-feature +f -target-feature +d -target-feature +v -target-feature +zfh \
+// RUN:   -target-feature +experimental-zvfh -disable-O0-optnone -emit-llvm %s -o - | opt -S -mem2reg | FileCheck --check-prefix=CHECK-RV64 %s
 
 #include 
 
@@ -1170,3 +1170,123 @@
vfloat64m8_t value, size_t vl) {
   return vsse64(mask, base, bstride, value, vl);
 }
+
+// CHECK-RV64-LABEL: @test_vsse16_v_f16mf4(
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = bitcast half* [[BASE:%.*]] to *
+// CHECK-RV64-NEXT:call void @llvm.riscv.vsse.nxv1f16.i64( [[VALUE:%.*]], * [[TMP0]], i64 [[BSTRIDE:%.*]], i64 [[VL:%.*]])
+// CHECK-RV64-NEXT:ret void
+//
+void test_vsse16_v_f16mf4(_Float16 *base, ptrdiff_t bstride, vfloat16mf4_t value, size_t vl) {
+  return vsse16(base, bstride, value, vl);
+}
+
+// CHECK-RV64-LABEL: @test_vsse16_v_f16mf2(
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = bitcast half* [[BASE:%.*]] to *
+// CHECK-RV64-NEXT:call void @llvm.riscv.vsse.nxv2f16.i64( [[VALUE:%.*]], * [[TMP0]], i64 [[BSTRIDE:%.*]], i64 [[VL:%.*]])
+// CHECK-RV64-NEXT:ret void
+//
+void test_vsse16_v_f16mf2(_Float16 *base, ptrdiff_t bstride, vfloat16mf2_t value, size_t vl) {
+  return vsse16(base, bstride, value, vl);
+}
+
+// CHECK-RV64-LABEL: @test_vsse16_v_f16m1(
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = bitcast half* [[BASE:%.*]] to *
+// CHECK-RV64-NEXT:call void @llvm.riscv.vsse.nxv4f16.i64( [[VALUE:%.*]], * [[TMP0]], i64 [[BSTRIDE:%.*]], i64 [[VL:%.*]])
+// CHECK-RV64-NEXT:ret void
+//
+void test_vsse16_v_f16m1(_Float16 *base, ptrdiff_t bstride, vfloat16m1_t value, size_t vl) {
+  return vsse16(base, bstride, value, vl);
+}
+
+// CHECK-RV64-LABEL: @test_vsse16_v_f16m2(
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = bitcast half* [[BASE:%.*]] to *
+// CHECK-RV64-NEXT:call void @llvm.riscv.vsse.nxv8f16.i64( [[VALUE:%.*]], * [[TMP0]], i64 [[BSTRIDE:%.*]], i64 [[VL:%.*]])
+// CHECK-RV64-NEXT:ret void
+//
+void test_vsse16_v_f16m2(_Float16 *base, ptrdiff_t bstride, vfloat16m2_t value, size_t vl) {
+  return vsse16(base, bstride, value, vl);
+}
+
+// CHECK-RV64-LABEL: @test_vsse16_v_f16m4(
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = bitcast half* [[BASE:%.*]] to *
+// CHECK-RV64-NEXT:call void @llvm.riscv.vsse.nxv16f16.i64( [[VALUE:%.*]], * [[TMP0]], i64 [[BSTRIDE:%.*]], i64 [[VL:%.*]])
+// CHECK-RV64-NEXT:ret void
+//
+void test_vsse16_v_f16m4(_Float16 *base, ptrdiff_t bstride, vfloat16m4_t value, size_t vl) {
+  return vsse16(base, bstride, value, vl);
+}
+
+// CHECK-RV64-LABEL: @test_vsse16_v_f16m8(
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = bitcast half* [[BASE:%.*]] to *
+// CHECK-RV64-NEXT:call void @llvm.riscv.vsse.nxv32f16.i64( [[VALUE:%.*]], * [[TMP0]], i64 [[BSTRIDE:%.*]], i64 [[VL:%.*]])
+// CHECK-RV64-NEXT:ret void
+//
+void test_vsse16_v_f16m8(_Float16 *base, ptrdiff_t bstride, vfloat16m8_t value, size_t vl) {
+  return vsse16(base, bstride, value, vl);
+}
+
+// CHECK-RV64-LABEL: @test_vsse16_v_f16mf4_m(
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = bitcast half* [[BASE:%.*]] to *
+// CHECK-RV64-NEXT:call void @llvm.riscv.vsse.mask.nxv1f16.i64( [[VALUE:%.*]], * [[TMP0]], i64 [[BSTRIDE:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]])
+// CHECK-RV64-NEXT:ret void
+//
+void test_vsse16_v_f16mf4_m(vbool64_t mask, _Float16 *base, ptrdiff_t bstride, vfloat16mf4_t value, size_t vl) {
+  return vsse16(mask, base, bstride, value, vl);
+}
+
+// CHECK-RV64-LABEL: @test_vsse16_v_f16mf2_m(
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = bitcast 

[clang] d9ef6ad - [RISCV] [NFC] add some tests for overloaded intrinsics of FP16

2022-03-28 Thread Chenbing Zheng via cfe-commits

Author: Chenbing Zheng
Date: 2022-03-29T10:00:20+08:00
New Revision: d9ef6ad05ff3cc4504a08d08c6cbd669b9ba764e

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

LOG: [RISCV] [NFC] add some tests for overloaded intrinsics of FP16

Reviewed By: craig.topper

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

Added: 


Modified: 
clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vle.c
clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vlse.c
clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vse.c
clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vsse.c

Removed: 




diff  --git a/clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vle.c 
b/clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vle.c
index 60a3b74918b86..6a3e615a83ab1 100644
--- a/clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vle.c
+++ b/clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vle.c
@@ -1,7 +1,7 @@
 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
 // REQUIRES: riscv-registered-target
-// RUN: %clang_cc1 -triple riscv64 -target-feature +f -target-feature +d 
-target-feature +v \
-// RUN:   -disable-O0-optnone -emit-llvm %s -o - | opt -S -mem2reg | FileCheck 
--check-prefix=CHECK-RV64 %s
+// RUN: %clang_cc1 -triple riscv64 -target-feature +f -target-feature +d 
-target-feature +v -target-feature +zfh \
+// RUN:-target-feature +experimental-zvfh -disable-O0-optnone -emit-llvm 
%s -o - | opt -S -mem2reg | FileCheck --check-prefix=CHECK-RV64 %s
 
 #include 
 
@@ -534,3 +534,63 @@ vfloat64m4_t test_vle64_v_f64m4_m(vbool16_t mask, 
vfloat64m4_t maskedoff, const
 vfloat64m8_t test_vle64_v_f64m8_m(vbool8_t mask, vfloat64m8_t maskedoff, const 
double *base, size_t vl) {
   return vle64(mask, maskedoff, base, vl);
 }
+
+// CHECK-RV64-LABEL: @test_vle16_v_f16mf4_m(
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = bitcast half* [[BASE:%.*]] to *
+// CHECK-RV64-NEXT:[[TMP1:%.*]] = call  
@llvm.riscv.vle.mask.nxv1f16.i64( [[MASKEDOFF:%.*]], * [[TMP0]],  [[MASK:%.*]], i64 [[VL:%.*]], i64 0)
+// CHECK-RV64-NEXT:ret  [[TMP1]]
+//
+vfloat16mf4_t test_vle16_v_f16mf4_m(vbool64_t mask, vfloat16mf4_t maskedoff, 
const _Float16 *base, size_t vl) {
+  return vle16(mask, maskedoff, base, vl);
+}
+
+// CHECK-RV64-LABEL: @test_vle16_v_f16mf2_m(
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = bitcast half* [[BASE:%.*]] to *
+// CHECK-RV64-NEXT:[[TMP1:%.*]] = call  
@llvm.riscv.vle.mask.nxv2f16.i64( [[MASKEDOFF:%.*]], * [[TMP0]],  [[MASK:%.*]], i64 [[VL:%.*]], i64 0)
+// CHECK-RV64-NEXT:ret  [[TMP1]]
+//
+vfloat16mf2_t test_vle16_v_f16mf2_m(vbool32_t mask, vfloat16mf2_t maskedoff, 
const _Float16 *base, size_t vl) {
+  return vle16(mask, maskedoff, base, vl);
+}
+
+// CHECK-RV64-LABEL: @test_vle16_v_f16m1_m(
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = bitcast half* [[BASE:%.*]] to *
+// CHECK-RV64-NEXT:[[TMP1:%.*]] = call  
@llvm.riscv.vle.mask.nxv4f16.i64( [[MASKEDOFF:%.*]], * [[TMP0]],  [[MASK:%.*]], i64 [[VL:%.*]], i64 0)
+// CHECK-RV64-NEXT:ret  [[TMP1]]
+//
+vfloat16m1_t test_vle16_v_f16m1_m(vbool16_t mask, vfloat16m1_t maskedoff, 
const _Float16 *base, size_t vl) {
+  return vle16(mask, maskedoff, base, vl);
+}
+
+// CHECK-RV64-LABEL: @test_vle16_v_f16m2_m(
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = bitcast half* [[BASE:%.*]] to *
+// CHECK-RV64-NEXT:[[TMP1:%.*]] = call  
@llvm.riscv.vle.mask.nxv8f16.i64( [[MASKEDOFF:%.*]], * [[TMP0]],  [[MASK:%.*]], i64 [[VL:%.*]], i64 0)
+// CHECK-RV64-NEXT:ret  [[TMP1]]
+//
+vfloat16m2_t test_vle16_v_f16m2_m(vbool8_t mask, vfloat16m2_t maskedoff, const 
_Float16 *base, size_t vl) {
+  return vle16(mask, maskedoff, base, vl);
+}
+
+// CHECK-RV64-LABEL: @test_vle16_v_f16m4_m(
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = bitcast half* [[BASE:%.*]] to *
+// CHECK-RV64-NEXT:[[TMP1:%.*]] = call  
@llvm.riscv.vle.mask.nxv16f16.i64( [[MASKEDOFF:%.*]], 
* [[TMP0]],  [[MASK:%.*]], i64 
[[VL:%.*]], i64 0)
+// CHECK-RV64-NEXT:ret  [[TMP1]]
+//
+vfloat16m4_t test_vle16_v_f16m4_m(vbool4_t mask, vfloat16m4_t maskedoff, const 
_Float16 *base, size_t vl) {
+  return vle16(mask, maskedoff, base, vl);
+}
+
+// CHECK-RV64-LABEL: @test_vle16_v_f16m8_m(
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = bitcast half* [[BASE:%.*]] to *
+// CHECK-RV64-NEXT:[[TMP1:%.*]] = call  
@llvm.riscv.vle.mask.nxv32f16.i64( [[MASKEDOFF:%.*]], 
* [[TMP0]],  [[MASK:%.*]], i64 
[[VL:%.*]], i64 0)
+// CHECK-RV64-NEXT:ret  [[TMP1]]
+//
+vfloat16m8_t test_vle16_v_f16m8_m(vbool2_t mask, vfloat16m8_t maskedoff, const 
_Float16 *base, size_t vl) {
+  return vle16(mask, maskedoff, base, vl);
+}

diff  --git 

[PATCH] D112647: [clang-apply-replacements] Correctly handle relative paths

2022-03-28 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added inline comments.
Herald added a project: All.



Comment at: 
clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp:178
 }
+SM.getFileManager().getFileSystemOpts().WorkingDir = PrevWorkingDir;
   };

This looks incorrect.

The FileManager is not designed to have the working directory change and it's 
not sound to change/restore it. This is because it caches the meaning of every 
relative-path lookup.

Consider:
```
/dir1/file1.h
/dir2/file1.h
/dir2/file2.h
```
if you do:
```
FM.WorkingDir = "/dir1";
FM.getFile("file1.h"); // returns /dir1/file1.h
FM.WorkingDir = "/dir2";
FM.getFile("file1.h"); // returns /dir1/file1.h !!!
FM.getFile("file2.h"); // returns /dir2/file2.h
```

See also the comment at https://reviews.llvm.org/D122549#3412965.

I don't know anything about clang-apply-replacements, but I have a couple of 
ideas for handling this correctly:
- Change the FileManager so that it's constructed with the working directory 
set to the build directory (don't save+restore, just make it correct from the 
start).
- If there are multiple concepts of a "build directory", use a different 
FileManager for each one.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112647

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


[PATCH] D122627: [HLSL] Fix MSFT Attribute parsing, add numthreads

2022-03-28 Thread Chris Bieneman via Phabricator via cfe-commits
beanz created this revision.
beanz added reviewers: aaron.ballman, rnk, jdoerfert, MaskRay, rsmith.
Herald added a subscriber: StephenFan.
Herald added a project: All.
beanz requested review of this revision.
Herald added a subscriber: sstefan1.
Herald added a project: clang.

HLSL uses Microsoft-style attributes `[attr]`, which clang mostly
ignores. For HLSL we need to handle known Microsoft attributes, and to
maintain C/C++ as-is we ignore unknown attributes.

To utilize this new code path, this change adds the HLSL `numthreads`
attribute.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D122627

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Parse/Parser.h
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/SemaHLSL/lit.local.cfg
  clang/test/SemaHLSL/num_threads.hlsl

Index: clang/test/SemaHLSL/num_threads.hlsl
===
--- /dev/null
+++ clang/test/SemaHLSL/num_threads.hlsl
@@ -0,0 +1,49 @@
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -x hlsl -ast-dump -o - %s | FileCheck %s 
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-mesh -x hlsl -ast-dump -o - %s | FileCheck %s 
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-amplification -x hlsl -ast-dump -o - %s | FileCheck %s 
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-library -x hlsl -ast-dump -o - %s | FileCheck %s 
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-pixel -x hlsl -ast-dump -o - %s -verify
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-vertex -x hlsl -ast-dump -o - %s -verify
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-hull -x hlsl -ast-dump -o - %s -verify
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-domain -x hlsl -ast-dump -o - %s -verify
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -x hlsl -ast-dump -o - %s -DFAIL -verify
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel5.0-compute -x hlsl -ast-dump -o - %s -DFAIL -verify
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel4.0-compute -x hlsl -ast-dump -o - %s -DFAIL -verify
+
+#if __SHADER_TARGET_STAGE == __SHADER_STAGE_COMPUTE || __SHADER_TARGET_STAGE == __SHADER_STAGE_MESH || __SHADER_TARGET_STAGE == __SHADER_STAGE_AMPLIFICATION || __SHADER_TARGET_STAGE == __SHADER_STAGE_LIBRARY
+#ifdef FAIL
+#if __SHADER_TARGET_MAJOR == 6
+// expected-error@+1 {{'numthreads' attribute requires an integer constant}}
+[numthreads("1",2,3)]
+// expected-error@+1 {{argument 'X' to numthreads attribute cannot exceed 1024}}
+[numthreads(-1,2,3)]
+// expected-error@+1 {{argument 'Y' to numthreads attribute cannot exceed 1024}}
+[numthreads(1,-2,3)]
+// expected-error@+1 {{argument 'Z' to numthreads attribute cannot exceed 1024}}
+[numthreads(1,2,-3)]
+// expected-error@+1 {{total number of threads cannot exceed 1024}}
+[numthreads(1024,1024,1024)]
+#elif __SHADER_TARGET_MAJOR == 5
+// expected-error@+1 {{argument 'Z' to numthreads attribute cannot exceed 64}}
+[numthreads(1,2,68)]
+#else
+// expected-error@+1 {{argument 'Z' to numthreads attribute cannot exceed 1}}
+[numthreads(1,2,2)]
+// expected-error@+1 {{total number of threads cannot exceed 768}}
+[numthreads(1024,1,1)]
+#endif
+#endif
+// CHECK: HLSLNumThreadsAttr 0x{{[0-9a-fA-F]+}}  1 2 1
+[numthreads(1,2,1)]
+int entry() {
+ return 1;
+}
+#else
+// expected-error-re@+1 {{attribute 'numthreads' is unsupported in {{[A-Za-z]+}} shaders, requires Compute, Amplification, Mesh or Library}}
+[numthreads(1,1,1)]
+int entry() {
+ return 1;
+}
+#endif
+
+
Index: clang/test/SemaHLSL/lit.local.cfg
===
--- /dev/null
+++ clang/test/SemaHLSL/lit.local.cfg
@@ -0,0 +1 @@
+config.suffixes = ['.hlsl']
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -24,6 +24,7 @@
 #include "clang/AST/Type.h"
 #include "clang/Basic/CharInfo.h"
 #include "clang/Basic/DarwinSDKInfo.h"
+#include "clang/Basic/LangOptions.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/TargetBuiltins.h"
@@ -6836,6 +6837,64 @@
 D->addAttr(UA);
 }
 
+static void handleHLSLNumThreadsAttr(Sema , Decl *D, const ParsedAttr ) {
+  using llvm::Triple;
+  Triple Target = S.Context.getTargetInfo().getTriple();
+  if (!llvm::is_contained(Target.getEnvironment(),
+  {Triple::Compute, Triple::Mesh, Triple::Amplification,
+   Triple::Library})) {
+uint32_t Pipeline =
+(uint32_t)S.Context.getTargetInfo().getTriple().getEnvironment() -
+(uint32_t)llvm::Triple::Pixel;
+S.Diag(AL.getLoc(), diag::err_hlsl_attr_unsupported_in_stage)
+<< AL << Pipeline << "Compute, Amplification, Mesh or Library";
+return;
+  }
+
+  

[PATCH] D122549: [VFS] RedirectingFileSystem only replace path if not already mapped

2022-03-28 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added inline comments.



Comment at: clang/lib/Basic/FileManager.cpp:273
 
-  if (Status.getName() == Filename) {
+  if (!Status.IsVFSMapped) {
 // The name matches. Set the FileEntry.

bnbarham wrote:
> bnbarham wrote:
> > dexonsmith wrote:
> > > An incremental patch you could try would be:
> > > ```
> > > lang=c++
> > > if (Status.getName() == Filename || !Status.IsVFSMapped)
> > > ```
> > > ... dropping all the other changes.
> > > 
> > > This limits the redirection hack to only apply when a RedirectingFS is 
> > > involved (leaving until later the fine-tuning of when `IsVFSMapped` gets 
> > > set). If this smaller change still causes a test failure, it might be 
> > > easier to reason about why / how to fix it / be sure that the fix is 
> > > sound.
> > > 
> > > Eventually we might want something like:
> > > ```
> > > lang=c++
> > > if (!Status.IsVFSMapped) {
> > >   assert(Status.getName() == Filename);
> > > ```
> > > I imagine that's not going to succeed yet due to the CWD behaviour in the 
> > > VFSes, but as a speculative patch it might help track down whatever the 
> > > problem is.
> > That assertion currently won't succeed for any relative path, since 
> > `getStatValue` does the absolute pathing for relative paths. So 
> > `Status.getName()` is guaranteed to be different to `Filename` in that case.
> > 
> > Possibly even more odd is that the failing test passes locally on MacOSX. 
> > I'll try the suggestion above and see if they fail again.
> Actually, thinking about this a bit more - the failing test doesn't use an 
> overlay at all, so changing to the above wouldn't help at all.
The test was added in 8188484daa4195a2c8b5253765036fa2c6da7263 / 
https://reviews.llvm.org/D112647, with a change to do:
```
+auto PrevWorkingDir = SM.getFileManager().getFileSystemOpts().WorkingDir;
+if (BuildDir)
+  SM.getFileManager().getFileSystemOpts().WorkingDir = 
std::move(*BuildDir);
 if (auto Entry = SM.getFileManager().getFile(R.getFilePath())) {
   if (SourceTU) {
 auto  = DiagReplacements[*Entry];
@@ -170,18 +175,19 @@ groupReplacements(const TUReplacements , const 
TUDiagnostics ,
   errs() << "Described file '" << R.getFilePath()
  << "' doesn't exist. Ignoring...\n";
 }
+SM.getFileManager().getFileSystemOpts().WorkingDir = PrevWorkingDir;
```

This looks incredibly suspicious. Changing the working directory mid-stream on 
the FileManager isn't sound. Consider:
```
/dir1/file1.h
/dir2/file1.h
/dir2/file2.h
```
if you do:
```
FM.WorkingDir = "/dir1";
FM.getFile("file1.h"); // returns /dir1/file1.h
FM.WorkingDir = "/dir2";
FM.getFile("file1.h"); // returns /dir1/file1.h !!!
FM.getFile("file2.h"); // returns /dir2/file2.h
```

That doesn't explain why it's not reproducing locally for you, though.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122549

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


[PATCH] D122544: Utilize comparison operation implemented in APInt

2022-03-28 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert added a comment.

Note that `__int128_t` is not available everywhere, generally only on 64-bit 
platforms.




Comment at: 
clang-tools-extra/test/clang-tidy/checkers/bugprone-sizeof-expression.cpp:175
 // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: suspicious usage of sizeof 
pointer 'sizeof(T)/sizeof(T)'
-int Test3() { return Foo<42>() + Bar(); }
+template <__int128_t N> 
+bool Baz() { return sizeof(A) < N; }

This causes test failures on 32-bit architectures:
```
/home/tcwg-buildbot/worker/clang-armv7-2stage/stage2/tools/clang/tools/extra/test/clang-tidy/checkers/Output/bugprone-sizeof-expression.cpp.tmp.cpp:175:11:
 error: unknown type name '__int128_t' [clang-diagnostic-error]
template <__int128_t N> 
  ^
```

It's probably best to wrap this in `#ifdef __SIZEOF_INT128__` lest we disable 
the entire test on the affected platforms.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122544

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


[PATCH] D122549: [VFS] RedirectingFileSystem only replace path if not already mapped

2022-03-28 Thread Ben Barham via Phabricator via cfe-commits
bnbarham added inline comments.



Comment at: clang/lib/Basic/FileManager.cpp:273
 
-  if (Status.getName() == Filename) {
+  if (!Status.IsVFSMapped) {
 // The name matches. Set the FileEntry.

bnbarham wrote:
> dexonsmith wrote:
> > An incremental patch you could try would be:
> > ```
> > lang=c++
> > if (Status.getName() == Filename || !Status.IsVFSMapped)
> > ```
> > ... dropping all the other changes.
> > 
> > This limits the redirection hack to only apply when a RedirectingFS is 
> > involved (leaving until later the fine-tuning of when `IsVFSMapped` gets 
> > set). If this smaller change still causes a test failure, it might be 
> > easier to reason about why / how to fix it / be sure that the fix is sound.
> > 
> > Eventually we might want something like:
> > ```
> > lang=c++
> > if (!Status.IsVFSMapped) {
> >   assert(Status.getName() == Filename);
> > ```
> > I imagine that's not going to succeed yet due to the CWD behaviour in the 
> > VFSes, but as a speculative patch it might help track down whatever the 
> > problem is.
> That assertion currently won't succeed for any relative path, since 
> `getStatValue` does the absolute pathing for relative paths. So 
> `Status.getName()` is guaranteed to be different to `Filename` in that case.
> 
> Possibly even more odd is that the failing test passes locally on MacOSX. 
> I'll try the suggestion above and see if they fail again.
Actually, thinking about this a bit more - the failing test doesn't use an 
overlay at all, so changing to the above wouldn't help at all.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122549

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


[PATCH] D122513: [analyzer] Fix "RhsLoc and LhsLoc bitwidth must be same"

2022-03-28 Thread Vince Bridgers via Phabricator via cfe-commits
vabridgers updated this revision to Diff 418749.
vabridgers added a comment.

Come up with a more principaled fix, thanks @NoQ :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122513

Files:
  clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
  clang/test/Analysis/addrspace-null.c


Index: clang/test/Analysis/addrspace-null.c
===
--- /dev/null
+++ clang/test/Analysis/addrspace-null.c
@@ -0,0 +1,47 @@
+// RUN: %clang_analyze_cc1 -triple amdgcn-unknown-unknown \
+// RUN: -analyze -analyzer-checker=core -DAMDGCN_TRIPLE \
+// RUN: -analyze -analyzer-checker=debug.ExprInspection \
+// RUN: -Wno-implicit-int -Wno-int-conversion -verify %s
+//
+// RUN: %clang_analyze_cc1 -triple amdgcn-unknown-unknown \
+// RUN: -analyze -analyzer-checker=core -DDEFAULT_TRIPLE \
+// RUN: -analyze -analyzer-checker=debug.ExprInspection \
+// RUN: -Wno-implicit-int -Wno-int-conversion -verify %s
+
+// From https://llvm.org/docs/AMDGPUUsage.html#address-spaces,
+// select address space 3 (local), since the pointer size is
+// different than Generic.
+
+// expected-no-diagnostics
+
+#define DEVICE __attribute__((address_space(3)))
+
+#if defined(AMDGCN)
+// this crashes
+int fn1() {
+  int val = 0;
+  DEVICE int *dptr = val;
+  return dptr == (void *)0;
+}
+
+// does not crash
+int fn2() {
+  int val = 0;
+  DEVICE int *dptr = val;
+  return dptr == (DEVICE void *)0;
+}
+
+// this crashes
+int fn3() {
+  int val = 0;
+  int *dptr = val;
+  return dptr == (DEVICE void *)0;
+}
+#endif
+
+// does not crash
+int fn4() {
+  int val = 0;
+  int *dptr = val;
+  return dptr == (void *)0;
+}
Index: clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
===
--- clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
+++ clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
@@ -682,8 +682,11 @@
   }
 
   // Pointer to any pointer.
-  if (Loc::isLocType(CastTy))
-return V;
+  if (Loc::isLocType(CastTy)) {
+llvm::APSInt Value = V.getValue();
+BasicVals.getAPSIntType(CastTy).apply(Value);
+return loc::ConcreteInt(BasicVals.getValue(Value));
+  }
 
   // Pointer to whatever else.
   return UnknownVal();


Index: clang/test/Analysis/addrspace-null.c
===
--- /dev/null
+++ clang/test/Analysis/addrspace-null.c
@@ -0,0 +1,47 @@
+// RUN: %clang_analyze_cc1 -triple amdgcn-unknown-unknown \
+// RUN: -analyze -analyzer-checker=core -DAMDGCN_TRIPLE \
+// RUN: -analyze -analyzer-checker=debug.ExprInspection \
+// RUN: -Wno-implicit-int -Wno-int-conversion -verify %s
+//
+// RUN: %clang_analyze_cc1 -triple amdgcn-unknown-unknown \
+// RUN: -analyze -analyzer-checker=core -DDEFAULT_TRIPLE \
+// RUN: -analyze -analyzer-checker=debug.ExprInspection \
+// RUN: -Wno-implicit-int -Wno-int-conversion -verify %s
+
+// From https://llvm.org/docs/AMDGPUUsage.html#address-spaces,
+// select address space 3 (local), since the pointer size is
+// different than Generic.
+
+// expected-no-diagnostics
+
+#define DEVICE __attribute__((address_space(3)))
+
+#if defined(AMDGCN)
+// this crashes
+int fn1() {
+  int val = 0;
+  DEVICE int *dptr = val;
+  return dptr == (void *)0;
+}
+
+// does not crash
+int fn2() {
+  int val = 0;
+  DEVICE int *dptr = val;
+  return dptr == (DEVICE void *)0;
+}
+
+// this crashes
+int fn3() {
+  int val = 0;
+  int *dptr = val;
+  return dptr == (DEVICE void *)0;
+}
+#endif
+
+// does not crash
+int fn4() {
+  int val = 0;
+  int *dptr = val;
+  return dptr == (void *)0;
+}
Index: clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
===
--- clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
+++ clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
@@ -682,8 +682,11 @@
   }
 
   // Pointer to any pointer.
-  if (Loc::isLocType(CastTy))
-return V;
+  if (Loc::isLocType(CastTy)) {
+llvm::APSInt Value = V.getValue();
+BasicVals.getAPSIntType(CastTy).apply(Value);
+return loc::ConcreteInt(BasicVals.getValue(Value));
+  }
 
   // Pointer to whatever else.
   return UnknownVal();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D122611: [clang][extract-api] Add support for macros

2022-03-28 Thread Zixu Wang via Phabricator via cfe-commits
zixuw added inline comments.



Comment at: 
clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h:22
 #include "clang/ExtractAPI/Serialization/SerializerBase.h"
+#include "clang/Lex/PreprocessingRecord.h"
 #include "llvm/Support/JSON.h"

Why do we need this include?



Comment at: clang/lib/ExtractAPI/API.cpp:32
+RecordTy *
+addTopLevelRecord(MapVector> ,
+  StringRef Name, CtorArgsTy &&...CtorArgs) {

Does it make sense to just directly make the `*RecordMap` types in `APISet` as 
a `template using`?



Comment at: clang/lib/ExtractAPI/ExtractAPIConsumer.cpp:446-457
+void ExtractAPIAction::EndSourceFileAction() {
+  if (!OS)
+return;
+
+  // Setup a SymbolGraphSerializer to write out collected API information in
+  // the Symbol Graph format.
+  // FIXME: Make the kind of APISerializer configurable.

Worth moving this change and the `APISet` move and relevant structural changes 
into its own patch, as mentioned in D122446.



Comment at: clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp:17
 #include "clang/ExtractAPI/API.h"
+#include "clang/Lex/PreprocessingRecord.h"
 #include "llvm/Support/JSON.h"

Why do we need this include?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122611

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


[PATCH] D122511: [clang][extract-api] Add Objective-C protocol support

2022-03-28 Thread Zixu Wang via Phabricator via cfe-commits
zixuw added inline comments.



Comment at: clang/lib/ExtractAPI/ExtractAPIConsumer.cpp:269
+// Collect symbol information.
+StringRef Name = Decl->getName();
+StringRef USR = API.recordUSR(Decl);

dang wrote:
> I think we should be recording this in StringAllocator
Same reply and concern in D122446


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122511

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


[PATCH] D122511: [clang][extract-api] Add Objective-C protocol support

2022-03-28 Thread Zixu Wang via Phabricator via cfe-commits
zixuw updated this revision to Diff 418744.
zixuw marked 2 inline comments as done.
zixuw added a comment.

Rebase upstream changes in D122446 :

- Move the change of the `objc_interface.m` test to D122446 
.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122511

Files:
  clang/include/clang/ExtractAPI/API.h
  clang/include/clang/ExtractAPI/DeclarationFragments.h
  clang/lib/ExtractAPI/API.cpp
  clang/lib/ExtractAPI/DeclarationFragments.cpp
  clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
  clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
  clang/test/ExtractAPI/objc_protocol.m

Index: clang/test/ExtractAPI/objc_protocol.m
===
--- /dev/null
+++ clang/test/ExtractAPI/objc_protocol.m
@@ -0,0 +1,146 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: sed -e "s@INPUT_DIR@%/t@g" %t/reference.output.json.in >> \
+// RUN: %t/reference.output.json
+// RUN: %clang -extract-api -x objective-c-header -target arm64-apple-macosx \
+// RUN: %t/input.h -o %t/output.json | FileCheck -allow-empty %s
+
+// Generator version is not consistent across test runs, normalize it.
+// RUN: sed -e "s@\"generator\": \".*\"@\"generator\": \"?\"@g" \
+// RUN: %t/output.json >> %t/output-normalized.json
+// RUN: diff %t/reference.output.json %t/output-normalized.json
+
+// CHECK-NOT: error:
+// CHECK-NOT: warning:
+
+//--- input.h
+@protocol Protocol
+@end
+
+@protocol AnotherProtocol 
+@end
+
+//--- reference.output.json.in
+{
+  "metadata": {
+"formatVersion": {
+  "major": 0,
+  "minor": 5,
+  "patch": 3
+},
+"generator": "?"
+  },
+  "module": {
+"name": "",
+"platform": {
+  "architecture": "arm64",
+  "operatingSystem": {
+"minimumVersion": {
+  "major": 11,
+  "minor": 0,
+  "patch": 0
+},
+"name": "macosx"
+  },
+  "vendor": "apple"
+}
+  },
+  "relationhips": [
+{
+  "kind": "conformsTo",
+  "source": "c:objc(pl)AnotherProtocol",
+  "target": "c:objc(pl)Protocol"
+}
+  ],
+  "symbols": [
+{
+  "declarationFragments": [
+{
+  "kind": "keyword",
+  "spelling": "@protocol"
+},
+{
+  "kind": "text",
+  "spelling": " "
+},
+{
+  "kind": "identifier",
+  "spelling": "Protocol"
+}
+  ],
+  "identifier": {
+"interfaceLanguage": "objective-c",
+"precise": "c:objc(pl)Protocol"
+  },
+  "kind": {
+"displayName": "Protocol",
+"identifier": "objective-c.protocol"
+  },
+  "location": {
+"character": 11,
+"line": 1,
+"uri": "file://INPUT_DIR/input.h"
+  },
+  "names": {
+"subHeading": [
+  {
+"kind": "identifier",
+"spelling": "Protocol"
+  }
+],
+"title": "Protocol"
+  }
+},
+{
+  "declarationFragments": [
+{
+  "kind": "keyword",
+  "spelling": "@protocol"
+},
+{
+  "kind": "text",
+  "spelling": " "
+},
+{
+  "kind": "identifier",
+  "spelling": "AnotherProtocol"
+},
+{
+  "kind": "text",
+  "spelling": " <"
+},
+{
+  "kind": "typeIdentifier",
+  "preciseIdentifier": "c:objc(pl)Protocol",
+  "spelling": "Protocol"
+},
+{
+  "kind": "text",
+  "spelling": ">"
+}
+  ],
+  "identifier": {
+"interfaceLanguage": "objective-c",
+"precise": "c:objc(pl)AnotherProtocol"
+  },
+  "kind": {
+"displayName": "Protocol",
+"identifier": "objective-c.protocol"
+  },
+  "location": {
+"character": 11,
+"line": 4,
+"uri": "file://INPUT_DIR/input.h"
+  },
+  "names": {
+"subHeading": [
+  {
+"kind": "identifier",
+"spelling": "AnotherProtocol"
+  }
+],
+"title": "AnotherProtocol"
+  }
+}
+  ]
+}
Index: clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
===
--- clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
+++ clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
@@ -392,6 +392,10 @@
 Kind["identifier"] = AddLangPrefix("class");
 Kind["displayName"] = "Class";
 break;
+  case APIRecord::RK_ObjCProtocol:
+Kind["identifier"] = AddLangPrefix("protocol");
+Kind["displayName"] = "Protocol";
+break;
   }
 
   return Kind;
@@ -592,6 +596,10 @@
   for (const auto  : API.getObjCInterfaces())
 serializeObjCContainerRecord(*ObjCInterface.second);
 
+  // Serialize Objective-C 

[clang] a427e18 - [docs][misexpect][NFC] Fix malformed table in docs

2022-03-28 Thread Paul Kirth via cfe-commits

Author: Paul Kirth
Date: 2022-03-29T00:14:07Z
New Revision: a427e18896dee3cd00d5f565cfb9d7d2f26ebcec

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

LOG: [docs][misexpect][NFC] Fix malformed table in docs

Reviewed By: abrachet

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

Added: 


Modified: 
clang/docs/MisExpect.rst
llvm/docs/MisExpect.rst

Removed: 




diff  --git a/clang/docs/MisExpect.rst b/clang/docs/MisExpect.rst
index c3c8e97cb050c..29eb1269b8982 100644
--- a/clang/docs/MisExpect.rst
+++ b/clang/docs/MisExpect.rst
@@ -64,7 +64,7 @@ Sampling. MisExpect Diagnostics are compatible with all 
Profiling formats.
 
++--+
 | Profile Type   | Description 
 |
 
++==+
-| Frontend   | Profiling instrumentation added during compilation by the 
frontend, i.e. ``clang``|
+| Frontend   | Profiling instrumentation added during compilation by the 
frontend, i.e. ``clang``   |
 
++--+
 | IR | Profiling instrumentation added during by the LLVM backend  
 |
 
++--+

diff  --git a/llvm/docs/MisExpect.rst b/llvm/docs/MisExpect.rst
index b4b6e2c5336dc..a9e6f8cc7006d 100644
--- a/llvm/docs/MisExpect.rst
+++ b/llvm/docs/MisExpect.rst
@@ -62,7 +62,7 @@ Sampling. MisExpect Diagnostics are compatible with all 
Profiling formats.
 
++--+
 | Profile Type   | Description 
 |
 
++==+
-| Frontend   | Profiling instrumentation added during compilation by the 
frontend, i.e. ``clang``|
+| Frontend   | Profiling instrumentation added during compilation by the 
frontend, i.e. ``clang``   |
 
++--+
 | IR | Profiling instrumentation added during by the LLVM backend  
 |
 
++--+



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


[PATCH] D122623: [docs][misexpect][NFC] Fix malformed table in docs

2022-03-28 Thread Paul Kirth 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 rGa427e18896de: [docs][misexpect][NFC] Fix malformed table in 
docs (authored by paulkirth).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122623

Files:
  clang/docs/MisExpect.rst
  llvm/docs/MisExpect.rst


Index: llvm/docs/MisExpect.rst
===
--- llvm/docs/MisExpect.rst
+++ llvm/docs/MisExpect.rst
@@ -62,7 +62,7 @@
 
++--+
 | Profile Type   | Description 
 |
 
++==+
-| Frontend   | Profiling instrumentation added during compilation by the 
frontend, i.e. ``clang``|
+| Frontend   | Profiling instrumentation added during compilation by the 
frontend, i.e. ``clang``   |
 
++--+
 | IR | Profiling instrumentation added during by the LLVM backend  
 |
 
++--+
Index: clang/docs/MisExpect.rst
===
--- clang/docs/MisExpect.rst
+++ clang/docs/MisExpect.rst
@@ -64,7 +64,7 @@
 
++--+
 | Profile Type   | Description 
 |
 
++==+
-| Frontend   | Profiling instrumentation added during compilation by the 
frontend, i.e. ``clang``|
+| Frontend   | Profiling instrumentation added during compilation by the 
frontend, i.e. ``clang``   |
 
++--+
 | IR | Profiling instrumentation added during by the LLVM backend  
 |
 
++--+


Index: llvm/docs/MisExpect.rst
===
--- llvm/docs/MisExpect.rst
+++ llvm/docs/MisExpect.rst
@@ -62,7 +62,7 @@
 ++--+
 | Profile Type   | Description  |
 ++==+
-| Frontend   | Profiling instrumentation added during compilation by the frontend, i.e. ``clang``|
+| Frontend   | Profiling instrumentation added during compilation by the frontend, i.e. ``clang``   |
 ++--+
 | IR | Profiling instrumentation added during by the LLVM backend   |
 ++--+
Index: clang/docs/MisExpect.rst
===
--- clang/docs/MisExpect.rst
+++ clang/docs/MisExpect.rst
@@ -64,7 +64,7 @@
 ++--+
 | Profile Type   | Description  |
 ++==+
-| Frontend   | Profiling instrumentation added during compilation by the frontend, i.e. ``clang``|
+| Frontend   | Profiling instrumentation added during compilation by the frontend, i.e. ``clang``   |
 ++--+
 | IR | Profiling instrumentation added during by the LLVM backend   |
 ++--+
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D122446: [clang][extract-api] Add Objective-C interface support

2022-03-28 Thread Zixu Wang via Phabricator via cfe-commits
zixuw added inline comments.



Comment at: clang/lib/ExtractAPI/ExtractAPIConsumer.cpp:245
+if (const auto *SuperClassDecl = Decl->getSuperClass()) {
+  SuperClass.Name = SuperClassDecl->getObjCRuntimeNameAsString();
+  SuperClass.USR = API.recordUSR(SuperClassDecl);

dang wrote:
> Shouldn't we be recording this string in the StringAllocator for reuse later. 
> I have a patch in progress for macro support that will do the serialization 
> once the AST isn't available anymore so we really shouldn't be taking in 
> StringRefs for stuff in the AST.
Right but that only makes sense once we kill the AST before serialization 
right? I mean I'm happy to wrap these in `copyString` now if we know for sure 
that we're doing that in a later patch. But it feels beyond the scope of this 
particular patch. Especially that we'd also need to go through the previous 
code to copy the names of global records, enums, etc. anyway.

I feel like that the change to surface `APISet` and punt serialization should 
be separated out from the macro change. And we can wrap all the name strings in 
that patch so that it's a meaningful atomic commit.



Comment at: clang/lib/ExtractAPI/ExtractAPIConsumer.cpp:455
+for (const auto *Protocol : Protocols)
+  Container->Protocols.emplace_back(Protocol->getName(),
+API.recordUSR(Protocol));

dang wrote:
> I think we need to allocate these string in the StringAllocator.
Same as above.



Comment at: clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp:375
+  case APIRecord::RK_ObjCIvar:
+Kind["identifier"] = AddLangPrefix("ivar");
+Kind["displayName"] = "Instance Variable";

dang wrote:
> this should probably be more explicit to keep in line with how things are 
> currently done. Maybe something like "instance.variable"
Right, naming completely new things here so worth the discussion.
To keep in line with the current convention, I don't see instance methods 
having an `instance.` prefix. It's just `method` as opposed to `type.method`.
Also global variable is just `var`, if we really need to add the `instance.` 
prefix (which I still don't think makes much sense for the above reason), 
wouldn't it be `instance.var`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122446

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


[PATCH] D122446: [clang][extract-api] Add Objective-C interface support

2022-03-28 Thread Zixu Wang via Phabricator via cfe-commits
zixuw updated this revision to Diff 418738.
zixuw marked 4 inline comments as done.
zixuw added a comment.

- Address review comments:
  - Use template to reuse logic for building function signatures for 
FunctionDecl and ObjCMethodDecl.
- Move the change of `objc_interface.m` test in this patch from D12251 
.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122446

Files:
  clang/include/clang/ExtractAPI/API.h
  clang/include/clang/ExtractAPI/DeclarationFragments.h
  clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h
  clang/lib/ExtractAPI/API.cpp
  clang/lib/ExtractAPI/DeclarationFragments.cpp
  clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
  clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
  clang/test/ExtractAPI/objc_interface.m

Index: clang/test/ExtractAPI/objc_interface.m
===
--- /dev/null
+++ clang/test/ExtractAPI/objc_interface.m
@@ -0,0 +1,402 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: sed -e "s@INPUT_DIR@%/t@g" %t/reference.output.json.in >> \
+// RUN: %t/reference.output.json
+// RUN: %clang -extract-api -x objective-c-header -target arm64-apple-macosx \
+// RUN: %t/input.h -o %t/output.json | FileCheck -allow-empty %s
+
+// Generator version is not consistent across test runs, normalize it.
+// RUN: sed -e "s@\"generator\": \".*\"@\"generator\": \"?\"@g" \
+// RUN: %t/output.json >> %t/output-normalized.json
+// RUN: diff %t/reference.output.json %t/output-normalized.json
+
+// CHECK-NOT: error:
+// CHECK-NOT: warning:
+
+//--- input.h
+@protocol Protocol;
+
+@interface Super 
+@property(readonly, getter=getProperty) unsigned Property;
++ (id)getWithProperty:(unsigned) Property;
+@end
+
+@interface Derived : Super {
+  char Ivar;
+}
+- (char)getIvar;
+@end
+
+//--- reference.output.json.in
+{
+  "metadata": {
+"formatVersion": {
+  "major": 0,
+  "minor": 5,
+  "patch": 3
+},
+"generator": "?"
+  },
+  "module": {
+"name": "",
+"platform": {
+  "architecture": "arm64",
+  "operatingSystem": {
+"minimumVersion": {
+  "major": 11,
+  "minor": 0,
+  "patch": 0
+},
+"name": "macosx"
+  },
+  "vendor": "apple"
+}
+  },
+  "relationhips": [
+{
+  "kind": "memberOf",
+  "source": "c:objc(cs)Super(cm)getWithProperty:",
+  "target": "c:objc(cs)Super"
+},
+{
+  "kind": "memberOf",
+  "source": "c:objc(cs)Super(py)Property",
+  "target": "c:objc(cs)Super"
+},
+{
+  "kind": "conformsTo",
+  "source": "c:objc(cs)Super",
+  "target": "c:objc(pl)Protocol"
+},
+{
+  "kind": "memberOf",
+  "source": "c:objc(cs)Derived@Ivar",
+  "target": "c:objc(cs)Derived"
+},
+{
+  "kind": "memberOf",
+  "source": "c:objc(cs)Derived(im)getIvar",
+  "target": "c:objc(cs)Derived"
+},
+{
+  "kind": "inheritsFrom",
+  "source": "c:objc(cs)Derived",
+  "target": "c:objc(cs)Super"
+}
+  ],
+  "symbols": [
+{
+  "declarationFragments": [
+{
+  "kind": "keyword",
+  "spelling": "@interface"
+},
+{
+  "kind": "text",
+  "spelling": " "
+},
+{
+  "kind": "identifier",
+  "spelling": "Super"
+}
+  ],
+  "identifier": {
+"interfaceLanguage": "objective-c",
+"precise": "c:objc(cs)Super"
+  },
+  "kind": {
+"displayName": "Class",
+"identifier": "objective-c.class"
+  },
+  "location": {
+"character": 12,
+"line": 3,
+"uri": "file://INPUT_DIR/input.h"
+  },
+  "names": {
+"subHeading": [
+  {
+"kind": "identifier",
+"spelling": "Super"
+  }
+],
+"title": "Super"
+  }
+},
+{
+  "declarationFragments": [
+{
+  "kind": "text",
+  "spelling": "+ ("
+},
+{
+  "kind": "keyword",
+  "spelling": "id"
+},
+{
+  "kind": "text",
+  "spelling": ")"
+},
+{
+  "kind": "identifier",
+  "spelling": "getWithProperty"
+},
+{
+  "kind": "text",
+  "spelling": ":"
+},
+{
+  "kind": "text",
+  "spelling": "("
+},
+{
+  "kind": "typeIdentifier",
+  "preciseIdentifier": "c:i",
+  "spelling": "unsigned int"
+},
+{
+  "kind": "text",
+  "spelling": ")"
+},
+{
+  "kind": "internalParam",
+  "spelling": "Property"
+}
+  ],
+  "identifier": {
+"interfaceLanguage": "objective-c",
+"precise": "c:objc(cs)Super(cm)getWithProperty:"
+  },
+  

[PATCH] D122513: [analyzer] Fix "RhsLoc and LhsLoc bitwidth must be same"

2022-03-28 Thread Vince Bridgers via Phabricator via cfe-commits
vabridgers added a comment.

I think I got it, looks like we're losing the width information at line 685, 
686 below.

Looks like I need to adjust the bitwidth of V before returning.

clang/lib/StaticAnalyzer/Core/SValBuilder.cpp

  671 SVal SValBuilder::evalCastSubKind(loc::ConcreteInt V, QualType CastTy,
  672   QualType OriginalTy) {
  673   // Pointer to bool.
  674   if (CastTy->isBooleanType())
  675 return makeTruthVal(V.getValue().getBoolValue(), CastTy);
  676 
  677   // Pointer to integer.
  678   if (CastTy->isIntegralOrEnumerationType()) {
  679 llvm::APSInt Value = V.getValue();
  680 BasicVals.getAPSIntType(CastTy).apply(Value);
  681 return makeIntVal(Value);
  682   }
  683 
  684   // Pointer to any pointer.
  685   if (Loc::isLocType(CastTy))
  686 return V;
  687 
  688   // Pointer to whatever else.
  689   return UnknownVal();
  690 }



  Breakpoint 8, clang::ento::SValBuilder::evalCastSubKind (this=0xff34500, 
V=..., CastTy=..., OriginalTy=...)
  at  /clang/lib/StaticAnalyzer/Core/SValBuilder.cpp:674
  674 if (CastTy->isBooleanType())
  (gdb) next
  678 if (CastTy->isIntegralOrEnumerationType()) {
  (gdb) 
  685 if (Loc::isLocType(CastTy))
  (gdb) p V
  $25 = { = { = 
{ = { = {Data = 
0xff37cf0, 
Kind = 2}, }, }, }, 
}
  (gdb) p V.dump()
  0 (Loc)$26 = void
  (gdb) p CastTy.dump()
  PointerType 0xfede460 '__attribute__((address_space(3))) int *'
  `-QualType 0xfede418 '__attribute__((address_space(3))) int' 
__attribute__((address_space(3)))
`-BuiltinType 0xfedd640 'int'
  $27 = void


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122513

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


[PATCH] D122623: [docs][misexpect] Fix malformed table in docs

2022-03-28 Thread Paul Kirth via Phabricator via cfe-commits
paulkirth updated this revision to Diff 418735.
paulkirth added a comment.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

update table in clang docs too


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122623

Files:
  clang/docs/MisExpect.rst
  llvm/docs/MisExpect.rst


Index: llvm/docs/MisExpect.rst
===
--- llvm/docs/MisExpect.rst
+++ llvm/docs/MisExpect.rst
@@ -62,7 +62,7 @@
 
++--+
 | Profile Type   | Description 
 |
 
++==+
-| Frontend   | Profiling instrumentation added during compilation by the 
frontend, i.e. ``clang``|
+| Frontend   | Profiling instrumentation added during compilation by the 
frontend, i.e. ``clang``   |
 
++--+
 | IR | Profiling instrumentation added during by the LLVM backend  
 |
 
++--+
Index: clang/docs/MisExpect.rst
===
--- clang/docs/MisExpect.rst
+++ clang/docs/MisExpect.rst
@@ -64,7 +64,7 @@
 
++--+
 | Profile Type   | Description 
 |
 
++==+
-| Frontend   | Profiling instrumentation added during compilation by the 
frontend, i.e. ``clang``|
+| Frontend   | Profiling instrumentation added during compilation by the 
frontend, i.e. ``clang``   |
 
++--+
 | IR | Profiling instrumentation added during by the LLVM backend  
 |
 
++--+


Index: llvm/docs/MisExpect.rst
===
--- llvm/docs/MisExpect.rst
+++ llvm/docs/MisExpect.rst
@@ -62,7 +62,7 @@
 ++--+
 | Profile Type   | Description  |
 ++==+
-| Frontend   | Profiling instrumentation added during compilation by the frontend, i.e. ``clang``|
+| Frontend   | Profiling instrumentation added during compilation by the frontend, i.e. ``clang``   |
 ++--+
 | IR | Profiling instrumentation added during by the LLVM backend   |
 ++--+
Index: clang/docs/MisExpect.rst
===
--- clang/docs/MisExpect.rst
+++ clang/docs/MisExpect.rst
@@ -64,7 +64,7 @@
 ++--+
 | Profile Type   | Description  |
 ++==+
-| Frontend   | Profiling instrumentation added during compilation by the frontend, i.e. ``clang``|
+| Frontend   | Profiling instrumentation added during compilation by the frontend, i.e. ``clang``   |
 ++--+
 | IR | Profiling instrumentation added during by the LLVM backend   |
 ++--+
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D118525: [modules] Merge ObjC interface ivars with anonymous types.

2022-03-28 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a reviewer: benlangmuir.
vsapsai added a subscriber: benlangmuir.
vsapsai added a comment.

I've run clang with this change on a bunch of code (especially Objective-C 
code) and there were no regressions.

Also adding @benlangmuir to reviewers as people mentioned he was doing some 
work in this area earlier.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118525

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


[PATCH] D122613: [Driver] Make -moutline-atomics default for aarch64-fuchsia targets

2022-03-28 Thread Roland McGrath 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 rG1a963d3278c2: [Driver] Make -moutline-atomics default for 
aarch64-fuchsia targets (authored by mcgrathr).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122613

Files:
  clang/lib/Driver/ToolChains/Fuchsia.h
  clang/test/Driver/fuchsia.c


Index: clang/test/Driver/fuchsia.c
===
--- clang/test/Driver/fuchsia.c
+++ clang/test/Driver/fuchsia.c
@@ -34,6 +34,7 @@
 // CHECK-AARCH64: "-fsanitize=shadow-call-stack"
 // CHECK-X86_64: "-fsanitize=safe-stack"
 // CHECK: "-stack-protector" "2"
+// CHECK-AARCH64: "-target-feature" "+outline-atomics"
 // CHECK-NOT: "-fcommon"
 // CHECK: {{.*}}ld.lld{{.*}}" "-z" "max-page-size=4096" "-z" "now" "-z" 
"rodynamic" "-z" "separate-loadable-segments" "-z" "rel" 
"--pack-dyn-relocs=relr"
 // CHECK: "--sysroot=[[SYSROOT]]"
Index: clang/lib/Driver/ToolChains/Fuchsia.h
===
--- clang/lib/Driver/ToolChains/Fuchsia.h
+++ clang/lib/Driver/ToolChains/Fuchsia.h
@@ -75,24 +75,27 @@
 
   RuntimeLibType
   GetRuntimeLibType(const llvm::opt::ArgList ) const override;
-  CXXStdlibType
-  GetCXXStdlibType(const llvm::opt::ArgList ) const override;
+  CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList ) const 
override;
+
+  bool IsAArch64OutlineAtomicsDefault(
+  const llvm::opt::ArgList ) const override {
+return true;
+  }
 
-  void addClangTargetOptions(const llvm::opt::ArgList ,
- llvm::opt::ArgStringList ,
- Action::OffloadKind DeviceOffloadKind) const 
override;
+  void
+  addClangTargetOptions(const llvm::opt::ArgList ,
+llvm::opt::ArgStringList ,
+Action::OffloadKind DeviceOffloadKind) const override;
   void
   AddClangSystemIncludeArgs(const llvm::opt::ArgList ,
 llvm::opt::ArgStringList ) const override;
-  void
-  AddClangCXXStdlibIncludeArgs(const llvm::opt::ArgList ,
-   llvm::opt::ArgStringList ) const 
override;
+  void AddClangCXXStdlibIncludeArgs(
+  const llvm::opt::ArgList ,
+  llvm::opt::ArgStringList ) const override;
   void AddCXXStdlibLibArgs(const llvm::opt::ArgList ,
llvm::opt::ArgStringList ) const override;
 
-  const char *getDefaultLinker() const override {
-return "ld.lld";
-  }
+  const char *getDefaultLinker() const override { return "ld.lld"; }
 
 protected:
   Tool *buildLinker() const override;


Index: clang/test/Driver/fuchsia.c
===
--- clang/test/Driver/fuchsia.c
+++ clang/test/Driver/fuchsia.c
@@ -34,6 +34,7 @@
 // CHECK-AARCH64: "-fsanitize=shadow-call-stack"
 // CHECK-X86_64: "-fsanitize=safe-stack"
 // CHECK: "-stack-protector" "2"
+// CHECK-AARCH64: "-target-feature" "+outline-atomics"
 // CHECK-NOT: "-fcommon"
 // CHECK: {{.*}}ld.lld{{.*}}" "-z" "max-page-size=4096" "-z" "now" "-z" "rodynamic" "-z" "separate-loadable-segments" "-z" "rel" "--pack-dyn-relocs=relr"
 // CHECK: "--sysroot=[[SYSROOT]]"
Index: clang/lib/Driver/ToolChains/Fuchsia.h
===
--- clang/lib/Driver/ToolChains/Fuchsia.h
+++ clang/lib/Driver/ToolChains/Fuchsia.h
@@ -75,24 +75,27 @@
 
   RuntimeLibType
   GetRuntimeLibType(const llvm::opt::ArgList ) const override;
-  CXXStdlibType
-  GetCXXStdlibType(const llvm::opt::ArgList ) const override;
+  CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList ) const override;
+
+  bool IsAArch64OutlineAtomicsDefault(
+  const llvm::opt::ArgList ) const override {
+return true;
+  }
 
-  void addClangTargetOptions(const llvm::opt::ArgList ,
- llvm::opt::ArgStringList ,
- Action::OffloadKind DeviceOffloadKind) const override;
+  void
+  addClangTargetOptions(const llvm::opt::ArgList ,
+llvm::opt::ArgStringList ,
+Action::OffloadKind DeviceOffloadKind) const override;
   void
   AddClangSystemIncludeArgs(const llvm::opt::ArgList ,
 llvm::opt::ArgStringList ) const override;
-  void
-  AddClangCXXStdlibIncludeArgs(const llvm::opt::ArgList ,
-   llvm::opt::ArgStringList ) const override;
+  void AddClangCXXStdlibIncludeArgs(
+  const llvm::opt::ArgList ,
+  llvm::opt::ArgStringList ) const override;
   void AddCXXStdlibLibArgs(const llvm::opt::ArgList ,
llvm::opt::ArgStringList ) const override;
 
-  const char *getDefaultLinker() const override {
-return "ld.lld";
-  }
+  const char *getDefaultLinker() const override { return "ld.lld"; }
 
 

[clang] 1a963d3 - [Driver] Make -moutline-atomics default for aarch64-fuchsia targets

2022-03-28 Thread Roland McGrath via cfe-commits

Author: Roland McGrath
Date: 2022-03-28T16:51:55-07:00
New Revision: 1a963d3278c2daab7e12125371442cd129c09954

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

LOG: [Driver] Make -moutline-atomics default for aarch64-fuchsia targets

This makes Fuchsia consistent with Linux on AArch64.

Reviewed By: abrachet

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/Fuchsia.h
clang/test/Driver/fuchsia.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Fuchsia.h 
b/clang/lib/Driver/ToolChains/Fuchsia.h
index c0e69df228219..f9f3bbfa9fbfe 100644
--- a/clang/lib/Driver/ToolChains/Fuchsia.h
+++ b/clang/lib/Driver/ToolChains/Fuchsia.h
@@ -75,24 +75,27 @@ class LLVM_LIBRARY_VISIBILITY Fuchsia : public ToolChain {
 
   RuntimeLibType
   GetRuntimeLibType(const llvm::opt::ArgList ) const override;
-  CXXStdlibType
-  GetCXXStdlibType(const llvm::opt::ArgList ) const override;
+  CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList ) const 
override;
+
+  bool IsAArch64OutlineAtomicsDefault(
+  const llvm::opt::ArgList ) const override {
+return true;
+  }
 
-  void addClangTargetOptions(const llvm::opt::ArgList ,
- llvm::opt::ArgStringList ,
- Action::OffloadKind DeviceOffloadKind) const 
override;
+  void
+  addClangTargetOptions(const llvm::opt::ArgList ,
+llvm::opt::ArgStringList ,
+Action::OffloadKind DeviceOffloadKind) const override;
   void
   AddClangSystemIncludeArgs(const llvm::opt::ArgList ,
 llvm::opt::ArgStringList ) const override;
-  void
-  AddClangCXXStdlibIncludeArgs(const llvm::opt::ArgList ,
-   llvm::opt::ArgStringList ) const 
override;
+  void AddClangCXXStdlibIncludeArgs(
+  const llvm::opt::ArgList ,
+  llvm::opt::ArgStringList ) const override;
   void AddCXXStdlibLibArgs(const llvm::opt::ArgList ,
llvm::opt::ArgStringList ) const override;
 
-  const char *getDefaultLinker() const override {
-return "ld.lld";
-  }
+  const char *getDefaultLinker() const override { return "ld.lld"; }
 
 protected:
   Tool *buildLinker() const override;

diff  --git a/clang/test/Driver/fuchsia.c b/clang/test/Driver/fuchsia.c
index 3e8d7211a4e96..888f6b1a2c4b7 100644
--- a/clang/test/Driver/fuchsia.c
+++ b/clang/test/Driver/fuchsia.c
@@ -34,6 +34,7 @@
 // CHECK-AARCH64: "-fsanitize=shadow-call-stack"
 // CHECK-X86_64: "-fsanitize=safe-stack"
 // CHECK: "-stack-protector" "2"
+// CHECK-AARCH64: "-target-feature" "+outline-atomics"
 // CHECK-NOT: "-fcommon"
 // CHECK: {{.*}}ld.lld{{.*}}" "-z" "max-page-size=4096" "-z" "now" "-z" 
"rodynamic" "-z" "separate-loadable-segments" "-z" "rel" 
"--pack-dyn-relocs=relr"
 // CHECK: "--sysroot=[[SYSROOT]]"



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


[PATCH] D115907: [misexpect] Re-implement MisExpect Diagnostics

2022-03-28 Thread Paul Kirth via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2add3fbd976d: [misexpect] Re-implement MisExpect Diagnostics 
(authored by paulkirth).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115907

Files:
  clang/docs/MisExpect.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Basic/DiagnosticFrontendKinds.td
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/CodeGen/CodeGenAction.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Profile/Inputs/misexpect-branch-nonconst-expect-arg.proftext
  clang/test/Profile/Inputs/misexpect-branch.proftext
  clang/test/Profile/Inputs/misexpect-switch-default-only.proftext
  clang/test/Profile/Inputs/misexpect-switch-default.proftext
  clang/test/Profile/Inputs/misexpect-switch-nonconst.proftext
  clang/test/Profile/Inputs/misexpect-switch.proftext
  clang/test/Profile/misexpect-branch-cold.c
  clang/test/Profile/misexpect-branch-nonconst-expected-val.c
  clang/test/Profile/misexpect-branch-unpredictable.c
  clang/test/Profile/misexpect-branch.c
  clang/test/Profile/misexpect-switch-default.c
  clang/test/Profile/misexpect-switch-nonconst.c
  clang/test/Profile/misexpect-switch-only-default-case.c
  clang/test/Profile/misexpect-switch.c
  llvm/docs/MisExpect.rst
  llvm/include/llvm/IR/DiagnosticInfo.h
  llvm/include/llvm/IR/LLVMContext.h
  llvm/include/llvm/Target/TargetOptions.h
  llvm/include/llvm/Transforms/Utils/MisExpect.h
  llvm/lib/IR/DiagnosticInfo.cpp
  llvm/lib/IR/LLVMContext.cpp
  llvm/lib/IR/LLVMContextImpl.h
  llvm/lib/Transforms/IPO/SampleProfile.cpp
  llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
  llvm/lib/Transforms/Scalar/LowerExpectIntrinsic.cpp
  llvm/lib/Transforms/Utils/CMakeLists.txt
  llvm/lib/Transforms/Utils/MisExpect.cpp
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-branch-correct.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-branch-threshold.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-branch.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-switch-correct.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-switch.proftext
  llvm/test/Transforms/PGOProfile/misexpect-branch-correct.ll
  llvm/test/Transforms/PGOProfile/misexpect-branch-stripped.ll
  llvm/test/Transforms/PGOProfile/misexpect-branch-unpredictable.ll
  llvm/test/Transforms/PGOProfile/misexpect-branch.ll
  llvm/test/Transforms/PGOProfile/misexpect-switch-default.ll
  llvm/test/Transforms/PGOProfile/misexpect-switch.ll

Index: llvm/test/Transforms/PGOProfile/misexpect-switch.ll
===
--- /dev/null
+++ llvm/test/Transforms/PGOProfile/misexpect-switch.ll
@@ -0,0 +1,285 @@
+; Test misexpect diagnostics handle swich statements, and report source locations correctly
+
+; RUN: llvm-profdata merge %S/Inputs/misexpect-switch.proftext -o %t.profdata
+; RUN: llvm-profdata merge %S/Inputs/misexpect-switch-correct.proftext -o %t.c.profdata
+
+; RUN: opt < %s -passes="function(lower-expect),pgo-instr-use" -pgo-test-profile-file=%t.profdata -pgo-warn-misexpect -S 2>&1 | FileCheck %s --check-prefix=WARNING
+; RUN: opt < %s -passes="function(lower-expect),pgo-instr-use" -pgo-test-profile-file=%t.profdata -pass-remarks=misexpect -S 2>&1 | FileCheck %s --check-prefix=REMARK
+; RUN: opt < %s -passes="function(lower-expect),pgo-instr-use" -pgo-test-profile-file=%t.profdata -pgo-warn-misexpect -pass-remarks=misexpect -S 2>&1 | FileCheck %s --check-prefix=BOTH
+; RUN: opt < %s -passes="function(lower-expect),pgo-instr-use" -pgo-test-profile-file=%t.profdata -S 2>&1 | FileCheck %s --check-prefix=DISABLED
+
+; RUN: opt < %s -passes="function(lower-expect),pgo-instr-use" -pgo-test-profile-file=%t.c.profdata -pgo-warn-misexpect -pass-remarks=misexpect -S 2>&1 | FileCheck %s --check-prefix=CORRECT
+
+; WARNING-DAG: warning: misexpect-switch.c:26:30: 0.00%
+; WARNING-NOT: remark: misexpect-switch.c:26:30: Potential performance regression from use of the llvm.expect intrinsic: Annotation was correct on 0.00% (0 / 8112) of profiled executions.
+
+; REMARK-NOT: warning: misexpect-switch.c:26:30: 0.00%
+; REMARK-DAG: remark: misexpect-switch.c:26:30: Potential performance regression from use of the llvm.expect intrinsic: Annotation was correct on 0.00% (0 / 8112) of profiled executions.
+
+; BOTH-DAG: warning: misexpect-switch.c:26:30: 0.00%
+; BOTH-DAG: remark: misexpect-switch.c:26:30: Potential performance regression from use of the llvm.expect intrinsic: Annotation was correct on 0.00% (0 / 8112) of profiled executions.
+
+; DISABLED-NOT: warning: misexpect-switch.c:26:30: 0.00%
+; DISABLED-NOT: remark: 

[PATCH] D122513: [analyzer] Fix "RhsLoc and LhsLoc bitwidth must be same"

2022-03-28 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

`getSVal` is probably not at fault, it simply retrieves the value it was 
previously told to put there, it doesn't care what the value is. You probably 
want to look at `ExprEngine::VisitCast()`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122513

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


[PATCH] D115907: [misexpect] Re-implement MisExpect Diagnostics

2022-03-28 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson added a comment.

In D115907#3412685 , @paulkirth wrote:

> @tejohnson thanks for pointing me to the document. I knew it had something to 
> do w/ CC1 but missed that this was well documented.

I was equally unaware of the documentation of this until you asked and I tried 
to come up with a reasonable explanation for you =)

> Is there anything else that needs to be done, or do you think this is good to 
> land again?

lgtm


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115907

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


[PATCH] D122495: [clang][extract-api] Use correct language info from inputs

2022-03-28 Thread Zixu Wang via Phabricator via cfe-commits
zixuw updated this revision to Diff 418724.
zixuw marked an inline comment as done.
zixuw added a comment.

Address review issues.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122495

Files:
  clang/include/clang/ExtractAPI/API.h
  clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
  clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
  clang/test/ExtractAPI/language.c

Index: clang/test/ExtractAPI/language.c
===
--- /dev/null
+++ clang/test/ExtractAPI/language.c
@@ -0,0 +1,166 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: sed -e "s@INPUT_DIR@%/t@g" %t/c.reference.output.json.in >> \
+// RUN: %t/c.reference.output.json
+// RUN: sed -e "s@INPUT_DIR@%/t@g" %t/objc.reference.output.json.in >> \
+// RUN: %t/objc.reference.output.json
+
+// RUN: %clang -extract-api -x c-header -target arm64-apple-macosx \
+// RUN: %t/c.h -o %t/c.output.json | FileCheck -allow-empty %s
+// RUN: %clang -extract-api -x objective-c-header -target arm64-apple-macosx \
+// RUN: %t/objc.h -o %t/objc.output.json | FileCheck -allow-empty %s
+
+// Generator version is not consistent across test runs, normalize it.
+// RUN: sed -e "s@\"generator\": \".*\"@\"generator\": \"?\"@g" \
+// RUN: %t/c.output.json >> %t/c.output-normalized.json
+// RUN: sed -e "s@\"generator\": \".*\"@\"generator\": \"?\"@g" \
+// RUN: %t/objc.output.json >> %t/objc.output-normalized.json
+
+// RUN: diff %t/c.reference.output.json %t/c.output-normalized.json
+// RUN: diff %t/objc.reference.output.json %t/objc.output-normalized.json
+
+// CHECK-NOT: error:
+// CHECK-NOT: warning:
+
+//--- c.h
+char c;
+
+//--- objc.h
+char objc;
+
+//--- c.reference.output.json.in
+{
+  "metadata": {
+"formatVersion": {
+  "major": 0,
+  "minor": 5,
+  "patch": 3
+},
+"generator": "?"
+  },
+  "module": {
+"name": "",
+"platform": {
+  "architecture": "arm64",
+  "operatingSystem": {
+"minimumVersion": {
+  "major": 11,
+  "minor": 0,
+  "patch": 0
+},
+"name": "macosx"
+  },
+  "vendor": "apple"
+}
+  },
+  "relationhips": [],
+  "symbols": [
+{
+  "declarationFragments": [
+{
+  "kind": "typeIdentifier",
+  "preciseIdentifier": "c:C",
+  "spelling": "char"
+},
+{
+  "kind": "text",
+  "spelling": " "
+},
+{
+  "kind": "identifier",
+  "spelling": "c"
+}
+  ],
+  "identifier": {
+"interfaceLanguage": "c",
+"precise": "c:@c"
+  },
+  "kind": {
+"displayName": "Global Variable",
+"identifier": "c.var"
+  },
+  "location": {
+"character": 6,
+"line": 1,
+"uri": "file://INPUT_DIR/c.h"
+  },
+  "names": {
+"subHeading": [
+  {
+"kind": "identifier",
+"spelling": "c"
+  }
+],
+"title": "c"
+  }
+}
+  ]
+}
+//--- objc.reference.output.json.in
+{
+  "metadata": {
+"formatVersion": {
+  "major": 0,
+  "minor": 5,
+  "patch": 3
+},
+"generator": "?"
+  },
+  "module": {
+"name": "",
+"platform": {
+  "architecture": "arm64",
+  "operatingSystem": {
+"minimumVersion": {
+  "major": 11,
+  "minor": 0,
+  "patch": 0
+},
+"name": "macosx"
+  },
+  "vendor": "apple"
+}
+  },
+  "relationhips": [],
+  "symbols": [
+{
+  "declarationFragments": [
+{
+  "kind": "typeIdentifier",
+  "preciseIdentifier": "c:C",
+  "spelling": "char"
+},
+{
+  "kind": "text",
+  "spelling": " "
+},
+{
+  "kind": "identifier",
+  "spelling": "objc"
+}
+  ],
+  "identifier": {
+"interfaceLanguage": "objective-c",
+"precise": "c:@objc"
+  },
+  "kind": {
+"displayName": "Global Variable",
+"identifier": "objective-c.var"
+  },
+  "location": {
+"character": 6,
+"line": 1,
+"uri": "file://INPUT_DIR/objc.h"
+  },
+  "names": {
+"subHeading": [
+  {
+"kind": "identifier",
+"spelling": "objc"
+  }
+],
+"title": "objc"
+  }
+}
+  ]
+}
Index: clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
===
--- clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
+++ clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
@@ -151,11 +151,9 @@
   return Availbility;
 }
 
-/// Get the short language name string for interface language references.
-StringRef getLanguageName(const LangOptions ) {
-  auto LanguageKind =
-  

[PATCH] D122495: [clang][extract-api] Use correct language info from inputs

2022-03-28 Thread Zixu Wang via Phabricator via cfe-commits
zixuw marked 2 inline comments as done.
zixuw added inline comments.



Comment at: clang/include/clang/ExtractAPI/API.h:312
 
-  /// Get the language options used to parse the APIs.
-  const LangOptions () const { return LangOpts; }
+  /// Get the language by the APIs.
+  Language getLanguage() const { return Lang; }

dang wrote:
> Nit: "by" isn't great here, maybe something along the lines of "Get the 
> language the APIs are defined in."
Whops! Missed a 'used' while moving the change from the other patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122495

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


[PATCH] D122549: [VFS] RedirectingFileSystem only replace path if not already mapped

2022-03-28 Thread Ben Barham via Phabricator via cfe-commits
bnbarham marked 4 inline comments as done.
bnbarham added inline comments.



Comment at: clang/lib/Basic/FileManager.cpp:273
 
-  if (Status.getName() == Filename) {
+  if (!Status.IsVFSMapped) {
 // The name matches. Set the FileEntry.

dexonsmith wrote:
> An incremental patch you could try would be:
> ```
> lang=c++
> if (Status.getName() == Filename || !Status.IsVFSMapped)
> ```
> ... dropping all the other changes.
> 
> This limits the redirection hack to only apply when a RedirectingFS is 
> involved (leaving until later the fine-tuning of when `IsVFSMapped` gets 
> set). If this smaller change still causes a test failure, it might be easier 
> to reason about why / how to fix it / be sure that the fix is sound.
> 
> Eventually we might want something like:
> ```
> lang=c++
> if (!Status.IsVFSMapped) {
>   assert(Status.getName() == Filename);
> ```
> I imagine that's not going to succeed yet due to the CWD behaviour in the 
> VFSes, but as a speculative patch it might help track down whatever the 
> problem is.
That assertion currently won't succeed for any relative path, since 
`getStatValue` does the absolute pathing for relative paths. So 
`Status.getName()` is guaranteed to be different to `Filename` in that case.

Possibly even more odd is that the failing test passes locally on MacOSX. I'll 
try the suggestion above and see if they fail again.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122549

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


[PATCH] D122549: [VFS] RedirectingFileSystem only replace path if not already mapped

2022-03-28 Thread Ben Barham via Phabricator via cfe-commits
bnbarham updated this revision to Diff 418721.
bnbarham edited the summary of this revision.
bnbarham added a comment.

Rename `IsVFSMapped` as suggested by Duncan. Update comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122549

Files:
  clang/lib/Basic/FileManager.cpp
  clang/test/VFS/external-names-multi-overlay.c
  llvm/include/llvm/Support/VirtualFileSystem.h
  llvm/lib/Support/VirtualFileSystem.cpp
  llvm/unittests/Support/VirtualFileSystemTest.cpp

Index: llvm/unittests/Support/VirtualFileSystemTest.cpp
===
--- llvm/unittests/Support/VirtualFileSystemTest.cpp
+++ llvm/unittests/Support/VirtualFileSystemTest.cpp
@@ -1442,12 +1442,12 @@
   ErrorOr S = O->status("//root/file1");
   ASSERT_FALSE(S.getError());
   EXPECT_EQ("//root/foo/bar/a", S->getName());
-  EXPECT_TRUE(S->IsVFSMapped);
+  EXPECT_TRUE(S->ExposesExternalVFSPath);
 
   ErrorOr SLower = O->status("//root/foo/bar/a");
   EXPECT_EQ("//root/foo/bar/a", SLower->getName());
   EXPECT_TRUE(S->equivalent(*SLower));
-  EXPECT_FALSE(SLower->IsVFSMapped);
+  EXPECT_FALSE(SLower->ExposesExternalVFSPath);
 
   // file after opening
   auto OpenedF = O->openFileForRead("//root/file1");
@@ -1455,7 +1455,7 @@
   auto OpenedS = (*OpenedF)->status();
   ASSERT_FALSE(OpenedS.getError());
   EXPECT_EQ("//root/foo/bar/a", OpenedS->getName());
-  EXPECT_TRUE(OpenedS->IsVFSMapped);
+  EXPECT_TRUE(OpenedS->ExposesExternalVFSPath);
 
   // directory
   S = O->status("//root/");
@@ -1467,27 +1467,27 @@
   S = O->status("//root/mappeddir");
   ASSERT_FALSE(S.getError());
   EXPECT_TRUE(S->isDirectory());
-  EXPECT_TRUE(S->IsVFSMapped);
+  EXPECT_TRUE(S->ExposesExternalVFSPath);
   EXPECT_TRUE(S->equivalent(*O->status("//root/foo/bar")));
 
   SLower = O->status("//root/foo/bar");
   EXPECT_EQ("//root/foo/bar", SLower->getName());
   EXPECT_TRUE(S->equivalent(*SLower));
-  EXPECT_FALSE(SLower->IsVFSMapped);
+  EXPECT_FALSE(SLower->ExposesExternalVFSPath);
 
   // file in remapped directory
   S = O->status("//root/mappeddir/a");
   ASSERT_FALSE(S.getError());
-  ASSERT_FALSE(S->isDirectory());
-  ASSERT_TRUE(S->IsVFSMapped);
-  ASSERT_EQ("//root/foo/bar/a", S->getName());
+  EXPECT_FALSE(S->isDirectory());
+  EXPECT_TRUE(S->ExposesExternalVFSPath);
+  EXPECT_EQ("//root/foo/bar/a", S->getName());
 
   // file in remapped directory, with use-external-name=false
   S = O->status("//root/mappeddir2/a");
   ASSERT_FALSE(S.getError());
-  ASSERT_FALSE(S->isDirectory());
-  ASSERT_TRUE(S->IsVFSMapped);
-  ASSERT_EQ("//root/mappeddir2/a", S->getName());
+  EXPECT_FALSE(S->isDirectory());
+  EXPECT_FALSE(S->ExposesExternalVFSPath);
+  EXPECT_EQ("//root/mappeddir2/a", S->getName());
 
   // file contents in remapped directory
   OpenedF = O->openFileForRead("//root/mappeddir/a");
@@ -1495,7 +1495,7 @@
   OpenedS = (*OpenedF)->status();
   ASSERT_FALSE(OpenedS.getError());
   EXPECT_EQ("//root/foo/bar/a", OpenedS->getName());
-  EXPECT_TRUE(OpenedS->IsVFSMapped);
+  EXPECT_TRUE(OpenedS->ExposesExternalVFSPath);
 
   // file contents in remapped directory, with use-external-name=false
   OpenedF = O->openFileForRead("//root/mappeddir2/a");
@@ -1503,7 +1503,7 @@
   OpenedS = (*OpenedF)->status();
   ASSERT_FALSE(OpenedS.getError());
   EXPECT_EQ("//root/mappeddir2/a", OpenedS->getName());
-  EXPECT_TRUE(OpenedS->IsVFSMapped);
+  EXPECT_FALSE(OpenedS->ExposesExternalVFSPath);
 
   // broken mapping
   EXPECT_EQ(O->status("//root/file2").getError(),
@@ -1535,12 +1535,12 @@
   ErrorOr S = O->status("//mappedroot/a");
   ASSERT_FALSE(S.getError());
   EXPECT_EQ("//root/foo/bar/a", S->getName());
-  EXPECT_TRUE(S->IsVFSMapped);
+  EXPECT_TRUE(S->ExposesExternalVFSPath);
 
   ErrorOr SLower = O->status("//root/foo/bar/a");
   EXPECT_EQ("//root/foo/bar/a", SLower->getName());
   EXPECT_TRUE(S->equivalent(*SLower));
-  EXPECT_FALSE(SLower->IsVFSMapped);
+  EXPECT_FALSE(SLower->ExposesExternalVFSPath);
 
   // file after opening
   auto OpenedF = O->openFileForRead("//mappedroot/a");
@@ -1548,7 +1548,7 @@
   auto OpenedS = (*OpenedF)->status();
   ASSERT_FALSE(OpenedS.getError());
   EXPECT_EQ("//root/foo/bar/a", OpenedS->getName());
-  EXPECT_TRUE(OpenedS->IsVFSMapped);
+  EXPECT_TRUE(OpenedS->ExposesExternalVFSPath);
 
   EXPECT_EQ(0, NumDiagnostics);
 }
@@ -1696,12 +1696,12 @@
   auto OpenedS = (*OpenedF)->status();
   ASSERT_FALSE(OpenedS.getError());
   EXPECT_EQ("a", OpenedS->getName());
-  EXPECT_FALSE(OpenedS->IsVFSMapped);
+  EXPECT_FALSE(OpenedS->ExposesExternalVFSPath);
 
   auto DirectS = RemappedFS->status("a");
   ASSERT_FALSE(DirectS.getError());
   EXPECT_EQ("a", DirectS->getName());
-  EXPECT_FALSE(DirectS->IsVFSMapped);
+  EXPECT_FALSE(DirectS->ExposesExternalVFSPath);
 
   EXPECT_EQ(0, NumDiagnostics);
 }
@@ -1736,12 +1736,12 @@
   auto OpenedS = (*OpenedF)->status();
   ASSERT_FALSE(OpenedS.getError());
   

[PATCH] D115907: [misexpect] Re-implement MisExpect Diagnostics

2022-03-28 Thread Paul Kirth via Phabricator via cfe-commits
paulkirth added a comment.

@tejohnson thanks for pointing me to the document. I knew it had something to 
do w/ CC1 but missed that this was well documented.

Is there anything else that needs to be done, or do you think this is good to 
land again?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115907

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


Re: [clang] abe997b - [CMake][Fuchsia] Switch to lld on Apple platforms

2022-03-28 Thread David Blaikie via cfe-commits
Neat!

On Tue, Mar 22, 2022 at 1:07 AM Petr Hosek via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

>
> Author: Petr Hosek
> Date: 2022-03-22T01:06:30-07:00
> New Revision: abe997bb2dd61188784954ae866352740629985d
>
> URL:
> https://github.com/llvm/llvm-project/commit/abe997bb2dd61188784954ae866352740629985d
> DIFF:
> https://github.com/llvm/llvm-project/commit/abe997bb2dd61188784954ae866352740629985d.diff
>
> LOG: [CMake][Fuchsia] Switch to lld on Apple platforms
>
> lld Mach-O backend supports all our use cases now.
>
> Differential Revision: https://reviews.llvm.org/D122047
>
> Added:
>
>
> Modified:
> clang/cmake/caches/Fuchsia-stage2.cmake
> clang/cmake/caches/Fuchsia.cmake
>
> Removed:
>
>
>
>
> 
> diff  --git a/clang/cmake/caches/Fuchsia-stage2.cmake
> b/clang/cmake/caches/Fuchsia-stage2.cmake
> index d64229bd572eb..df15aa65cc9d2 100644
> --- a/clang/cmake/caches/Fuchsia-stage2.cmake
> +++ b/clang/cmake/caches/Fuchsia-stage2.cmake
> @@ -9,10 +9,7 @@ set(LLVM_ENABLE_RUNTIMES
> "compiler-rt;libcxx;libcxxabi;libunwind" CACHE STRING "
>
>  set(LLVM_ENABLE_BACKTRACES OFF CACHE BOOL "")
>  set(LLVM_ENABLE_DIA_SDK OFF CACHE BOOL "")
> -if(NOT APPLE)
> -  # TODO: Remove this once we switch to ld64.lld.
> -  set(LLVM_ENABLE_LLD ON CACHE BOOL "")
> -endif()
> +set(LLVM_ENABLE_LLD ON CACHE BOOL "")
>  set(LLVM_ENABLE_LTO ON CACHE BOOL "")
>  set(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR ON CACHE BOOL "")
>  set(LLVM_ENABLE_LIBCXX ON CACHE BOOL "")
> @@ -31,11 +28,8 @@ if(WIN32)
>  endif()
>
>  set(CLANG_DEFAULT_CXX_STDLIB libc++ CACHE STRING "")
> -if(NOT APPLE)
> -  # TODO: Remove this once we switch to ld64.lld.
> -  set(CLANG_DEFAULT_LINKER lld CACHE STRING "")
> -  set(CLANG_DEFAULT_OBJCOPY llvm-objcopy CACHE STRING "")
> -endif()
> +set(CLANG_DEFAULT_LINKER lld CACHE STRING "")
> +set(CLANG_DEFAULT_OBJCOPY llvm-objcopy CACHE STRING "")
>  set(CLANG_DEFAULT_RTLIB compiler-rt CACHE STRING "")
>  set(CLANG_ENABLE_ARCMT OFF CACHE BOOL "")
>  set(CLANG_ENABLE_STATIC_ANALYZER ON CACHE BOOL "")
>
> diff  --git a/clang/cmake/caches/Fuchsia.cmake
> b/clang/cmake/caches/Fuchsia.cmake
> index 8e9e44d5917ed..bf2ea1802963d 100644
> --- a/clang/cmake/caches/Fuchsia.cmake
> +++ b/clang/cmake/caches/Fuchsia.cmake
> @@ -22,11 +22,8 @@ if(WIN32)
>  endif()
>
>  set(CLANG_DEFAULT_CXX_STDLIB libc++ CACHE STRING "")
> -if(NOT APPLE)
> -  # TODO: Remove this once we switch to ld64.lld.
> -  set(CLANG_DEFAULT_LINKER lld CACHE STRING "")
> -  set(CLANG_DEFAULT_OBJCOPY llvm-objcopy CACHE STRING "")
> -endif()
> +set(CLANG_DEFAULT_LINKER lld CACHE STRING "")
> +set(CLANG_DEFAULT_OBJCOPY llvm-objcopy CACHE STRING "")
>  set(CLANG_DEFAULT_RTLIB compiler-rt CACHE STRING "")
>  set(CLANG_ENABLE_ARCMT OFF CACHE BOOL "")
>  set(CLANG_ENABLE_STATIC_ANALYZER OFF CACHE BOOL "")
> @@ -112,11 +109,8 @@ if(UNIX)
>set(BOOTSTRAP_CMAKE_EXE_LINKER_FLAGS "-ldl -lpthread" CACHE STRING "")
>  endif()
>
> +set(BOOTSTRAP_LLVM_ENABLE_LLD ON CACHE BOOL "")
>  set(BOOTSTRAP_LLVM_ENABLE_LTO ON CACHE BOOL "")
> -if(NOT APPLE)
> -  # TODO: Remove this once we switch to ld64.lld.
> -  set(BOOTSTRAP_LLVM_ENABLE_LLD ON CACHE BOOL "")
> -endif()
>
>  set(CLANG_BOOTSTRAP_TARGETS
>check-all
>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D120159: [Clang] Implement __builtin_source_location.

2022-03-28 Thread James Y Knight 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 rGd61487490022: [Clang] Implement __builtin_source_location. 
(authored by jyknight).

Changed prior to commit:
  https://reviews.llvm.org/D120159?vs=412087=418718#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120159

Files:
  clang/docs/LanguageExtensions.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/AST/Expr.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/AST/Stmt.h
  clang/include/clang/Basic/DeclNodes.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/TokenKinds.def
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/DeclBase.cpp
  clang/lib/AST/DeclCXX.cpp
  clang/lib/AST/Expr.cpp
  clang/lib/AST/ExprClassification.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/CodeGen/CGExprConstant.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/lib/Parse/ParseExpr.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTCommon.cpp
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/lib/Serialization/ASTWriterDecl.cpp
  clang/test/CodeGenCXX/builtin-source-location.cpp
  clang/test/SemaCXX/source_location.cpp
  clang/test/SemaCXX/source_location_err.cpp
  clang/tools/libclang/CIndex.cpp

Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -6478,6 +6478,7 @@
   case Decl::Binding:
   case Decl::MSProperty:
   case Decl::MSGuid:
+  case Decl::UnnamedGlobalConstant:
   case Decl::TemplateParamObject:
   case Decl::IndirectField:
   case Decl::ObjCIvar:
Index: clang/test/SemaCXX/source_location_err.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/source_location_err.cpp
@@ -0,0 +1,105 @@
+// RUN: %clang_cc1 -std=c++1z -fcxx-exceptions -fexceptions -verify -DTEST=1 %s
+// RUN: %clang_cc1 -std=c++1z -fcxx-exceptions -fexceptions -verify -DTEST=2 %s
+// RUN: %clang_cc1 -std=c++1z -fcxx-exceptions -fexceptions -verify -DTEST=3 %s
+// RUN: %clang_cc1 -std=c++1z -fcxx-exceptions -fexceptions -verify -DTEST=4 %s
+// RUN: %clang_cc1 -std=c++1z -fcxx-exceptions -fexceptions -verify -DTEST=5 %s
+
+#if TEST == 1
+auto test1a = __builtin_source_location(); // expected-error {{'std::source_location::__impl' was not found}}
+
+namespace std {
+inline namespace NS {
+  struct source_location;
+}
+}
+
+auto test1b = __builtin_source_location(); // expected-error {{'std::source_location::__impl' was not found}}
+
+namespace std {
+inline namespace NS {
+  struct source_location {
+struct __impl;
+  };
+}
+}
+auto test1c = __builtin_source_location(); // expected-error {{'std::source_location::__impl' was not found}}
+
+#elif TEST == 2
+auto test2a = __builtin_source_location(); // expected-error {{'std::source_location::__impl' was not found}}
+
+namespace std {
+inline namespace NS {
+struct source_location {
+  struct __impl { int x; };
+};
+}
+}
+auto test2b = __builtin_source_location(); // expected-error {{'std::source_location::__impl' must be standard-layout and have only two 'const char *' fields '_M_file_name' and '_M_function_name', and two integral fields '_M_line' and '_M_column'}}
+
+#elif TEST == 3
+namespace std {
+struct source_location {
+  struct __impl {
+int other_member;
+char _M_line;
+const char *_M_file_name;
+char _M_column;
+const char *_M_function_name;
+  };
+};
+}
+auto test3 = __builtin_source_location(); // expected-error {{'std::source_location::__impl' must be standard-layout and have only two 'const char *' fields '_M_file_name' and '_M_function_name', and two integral fields '_M_line' and '_M_column'}}
+
+#elif TEST == 4
+namespace std {
+struct source_location {
+  struct parent {};
+  struct __impl : public parent {
+char _M_line;
+const char *_M_file_name;
+char _M_column;
+const char *_M_function_name;
+  };
+};
+}
+auto test4 = __builtin_source_location(); // expected-error {{'std::source_location::__impl' must be standard-layout and have only two 'const char *' fields '_M_file_name' and '_M_function_name', and two integral fields '_M_line' and '_M_column'}}
+
+
+#elif TEST == 5
+namespace std {
+struct source_location {
+  struct __impl {
+signed char _M_line; // odd integral type to choose, but ok!
+const char *_M_file_name;
+signed char _M_column;
+const 

[clang] d614874 - [Clang] Implement __builtin_source_location.

2022-03-28 Thread James Y Knight via cfe-commits

Author: James Y Knight
Date: 2022-03-28T18:29:02-04:00
New Revision: d61487490022aaacc34249475fac3e208c7d767e

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

LOG: [Clang] Implement __builtin_source_location.

This builtin returns the address of a global instance of the
`std::source_location::__impl` type, which must be defined (with an
appropriate shape) before calling the builtin.

It will be used to implement std::source_location in libc++ in a
future change. The builtin is compatible with GCC's implementation,
and libstdc++'s usage. An intentional divergence is that GCC declares
the builtin's return type to be `const void*` (for
ease-of-implementation reasons), while Clang uses the actual type,
`const std::source_location::__impl*`.

In order to support this new functionality, I've also added a new
'UnnamedGlobalConstantDecl'. This artificial Decl is modeled after
MSGuidDecl, and is used to represent a generic concept of an lvalue
constant with global scope, deduplicated by its value. It's possible
that MSGuidDecl itself, or some of the other similar sorts of things
in Clang might be able to be refactored onto this more-generic
concept, but there's enough special-case weirdness in MSGuidDecl that
I gave up attempting to share code there, at least for now.

Finally, for compatibility with libstdc++'s  header,
I've added a second exception to the "cannot cast from void* to T* in
constant evaluation" rule. This seems a bit distasteful, but feels
like the best available option.

Reviewers: aaron.ballman, erichkeane

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

Added: 
clang/test/SemaCXX/source_location_err.cpp

Modified: 
clang/docs/LanguageExtensions.rst
clang/docs/ReleaseNotes.rst
clang/include/clang/AST/ASTContext.h
clang/include/clang/AST/DeclCXX.h
clang/include/clang/AST/Expr.h
clang/include/clang/AST/RecursiveASTVisitor.h
clang/include/clang/AST/Stmt.h
clang/include/clang/Basic/DeclNodes.td
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Basic/TokenKinds.def
clang/include/clang/Sema/Sema.h
clang/include/clang/Serialization/ASTBitCodes.h
clang/lib/AST/ASTContext.cpp
clang/lib/AST/ASTImporter.cpp
clang/lib/AST/DeclBase.cpp
clang/lib/AST/DeclCXX.cpp
clang/lib/AST/Expr.cpp
clang/lib/AST/ExprClassification.cpp
clang/lib/AST/ExprConstant.cpp
clang/lib/CodeGen/CGDecl.cpp
clang/lib/CodeGen/CGExprConstant.cpp
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/CodeGen/CodeGenModule.h
clang/lib/Parse/ParseExpr.cpp
clang/lib/Sema/Sema.cpp
clang/lib/Sema/SemaExpr.cpp
clang/lib/Sema/SemaTemplate.cpp
clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
clang/lib/Sema/TreeTransform.h
clang/lib/Serialization/ASTCommon.cpp
clang/lib/Serialization/ASTReaderDecl.cpp
clang/lib/Serialization/ASTWriterDecl.cpp
clang/test/CodeGenCXX/builtin-source-location.cpp
clang/test/SemaCXX/source_location.cpp
clang/tools/libclang/CIndex.cpp

Removed: 




diff  --git a/clang/docs/LanguageExtensions.rst 
b/clang/docs/LanguageExtensions.rst
index 45fb8efaf8b01..0391102fb222c 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -3377,10 +3377,9 @@ as the first argument to the intrinsic.
 Source location builtins
 
 
-Clang provides experimental builtins to support C++ standard library 
implementation
-of ``std::experimental::source_location`` as specified in  
http://wg21.link/N4600.
-With the exception of ``__builtin_COLUMN``, these builtins are also 
implemented by
-GCC.
+Clang provides builtins to support C++ standard library implementation
+of ``std::source_location`` as specified in C++20.  With the exception
+of ``__builtin_COLUMN``, these builtins are also implemented by GCC.
 
 **Syntax**:
 
@@ -3390,6 +3389,7 @@ GCC.
   const char *__builtin_FUNCTION();
   unsigned__builtin_LINE();
   unsigned__builtin_COLUMN(); // Clang only
+  const std::source_location::__impl *__builtin_source_location();
 
 **Example of use**:
 
@@ -3416,9 +3416,11 @@ GCC.
 
 **Description**:
 
-The builtins ``__builtin_LINE``, ``__builtin_FUNCTION``, and 
``__builtin_FILE`` return
-the values, at the "invocation point", for ``__LINE__``, ``__FUNCTION__``, and
-``__FILE__`` respectively. These builtins are constant expressions.
+The builtins ``__builtin_LINE``, ``__builtin_FUNCTION``, and ``__builtin_FILE``
+return the values, at the "invocation point", for ``__LINE__``,
+``__FUNCTION__``, and ``__FILE__`` respectively. ``__builtin_COLUMN`` similarly
+returns the column, though there is no corresponding macro. These builtins are
+constant expressions.
 
 When the builtins appear as part of a default 

[PATCH] D122620: [clang][DR] Test and mark DR1479 as complete

2022-03-28 Thread Markus Böck via Phabricator via cfe-commits
zero9178 created this revision.
zero9178 added a reviewer: clang-language-wg.
Herald added a project: All.
zero9178 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

DR: http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1479

Clang has implemented this DR as far back as I could go on compiler explorer 
(3.0). This patch simply adds a test case and needed comments for the update 
script to mark it as complete.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D122620

Files:
  clang/test/CXX/drs/dr14xx.cpp
  clang/www/cxx_dr_status.html


Index: clang/www/cxx_dr_status.html
===
--- clang/www/cxx_dr_status.html
+++ clang/www/cxx_dr_status.html
@@ -8688,7 +8688,7 @@
 https://wg21.link/cwg1479;>1479
 CD3
 Literal operators and default arguments
-Unknown
+Yes
   
   
 https://wg21.link/cwg1480;>1480
Index: clang/test/CXX/drs/dr14xx.cpp
===
--- clang/test/CXX/drs/dr14xx.cpp
+++ clang/test/CXX/drs/dr14xx.cpp
@@ -463,6 +463,10 @@
 #endif
 } // dr1467
 
+namespace dr1479 { // dr1479: yes
+  int operator"" _a(const char*, std::size_t = 0); // expected-error {{literal 
operator cannot have a default argument}}
+}
+
 namespace dr1490 {  // dr1490: 3.7 c++11
   // List-initialization from a string literal
 


Index: clang/www/cxx_dr_status.html
===
--- clang/www/cxx_dr_status.html
+++ clang/www/cxx_dr_status.html
@@ -8688,7 +8688,7 @@
 https://wg21.link/cwg1479;>1479
 CD3
 Literal operators and default arguments
-Unknown
+Yes
   
   
 https://wg21.link/cwg1480;>1480
Index: clang/test/CXX/drs/dr14xx.cpp
===
--- clang/test/CXX/drs/dr14xx.cpp
+++ clang/test/CXX/drs/dr14xx.cpp
@@ -463,6 +463,10 @@
 #endif
 } // dr1467
 
+namespace dr1479 { // dr1479: yes
+  int operator"" _a(const char*, std::size_t = 0); // expected-error {{literal operator cannot have a default argument}}
+}
+
 namespace dr1490 {  // dr1490: 3.7 c++11
   // List-initialization from a string literal
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D122343: Support ObjC Method call in enforce_tcb checks

2022-03-28 Thread Artem Dergachev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc8048c7c42ff: [attributes] Generalize attribute 
enforce_tcb to Objective-C methods. (authored by pdherbemont, 
committed by dergachev.a).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122343

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaChecking.cpp
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/Sema/attr-enforce-tcb-errors.m
  clang/test/Sema/attr-enforce-tcb.m

Index: clang/test/Sema/attr-enforce-tcb.m
===
--- /dev/null
+++ clang/test/Sema/attr-enforce-tcb.m
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+#define PLACE_IN_TCB(NAME) __attribute__((enforce_tcb(NAME)))
+#define PLACE_IN_TCB_LEAF(NAME) __attribute__((enforce_tcb_leaf(NAME)))
+
+__attribute__((objc_root_class))
+@interface AClass
+@property(readonly) id propertyNotInAnyTCB;
+@end
+
+@implementation AClass
+- (void)inTCBFoo PLACE_IN_TCB("foo") {
+  [self notInAnyTCB]; // expected-warning{{calling 'notInAnyTCB' is a violation of trusted computing base 'foo'}}
+}
+- (void)inTCBFooAsLeaf PLACE_IN_TCB_LEAF("foo") {
+  [self notInAnyTCB]; // no-warning
+}
+- (void)notInAnyTCB {
+}
++ (void)classMethodNotInAnyTCB {
+}
++ (void)classMethodInTCBFoo PLACE_IN_TCB("foo") {
+  [self inTCBFoo];   // no-warning
+  [self inTCBFooAsLeaf]; // no-warning
+  [self notInAnyTCB];// expected-warning{{calling 'notInAnyTCB' is a violation of trusted computing base 'foo'}}
+}
+@end
+
+PLACE_IN_TCB("foo")
+void call_objc_method(AClass *object) {
+  [object inTCBFoo];// no-warning
+  [object inTCBFooAsLeaf];  // no-warning
+  [object notInAnyTCB]; // expected-warning{{calling 'notInAnyTCB' is a violation of trusted computing base 'foo'}}
+  [AClass classMethodNotInAnyTCB];  // expected-warning{{calling 'classMethodNotInAnyTCB' is a violation of trusted computing base 'foo'}}
+  [AClass classMethodInTCBFoo]; // no-warning
+  (void)object.propertyNotInAnyTCB; // expected-warning{{calling 'propertyNotInAnyTCB' is a violation of trusted computing base 'foo'}}
+}
Index: clang/test/Sema/attr-enforce-tcb-errors.m
===
--- /dev/null
+++ clang/test/Sema/attr-enforce-tcb-errors.m
@@ -0,0 +1,100 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+int foo();
+
+__attribute__((objc_root_class))
+@interface AClass
+- (void)bothTCBAndTCBLeafOnSeparateRedeclarations __attribute__((enforce_tcb("x"))); // expected-note{{conflicting attribute is here}}
+
+- (void)bothTCBAndTCBLeafOnSeparateRedeclarationsOppositeOrder __attribute__((enforce_tcb_leaf("x"))); // expected-note{{conflicting attribute is here}}
+
+- (void)bothTCBAndTCBLeafButDifferentIdentifiersOnSeparateRedeclarations __attribute__((enforce_tcb("x")));
+
+- (void)bothTCBAndTCBLeafButDifferentIdentifiersOnSeparateRedeclarationsOppositeOrder __attribute__((enforce_tcb_leaf("x")));
+
+- (void)onInterfaceOnly __attribute__((enforce_tcb("test")));
+@end
+
+@interface AClass (NoImplementation)
+- (void)noArguments __attribute__((enforce_tcb)); // expected-error{{'enforce_tcb' attribute takes one argument}}
+
+- (void)tooManyArguments __attribute__((enforce_tcb("test", 12))); // expected-error{{'enforce_tcb' attribute takes one argument}}
+
+- (void)wrongArgumentType __attribute__((enforce_tcb(12))); // expected-error{{'enforce_tcb' attribute requires a string}}
+
+- (void)noArgumentsLeaf __attribute__((enforce_tcb_leaf)); // expected-error{{'enforce_tcb_leaf' attribute takes one argument}}
+
+- (void)tooManyArgumentsLeaf __attribute__((enforce_tcb_leaf("test", 12))); // expected-error{{'enforce_tcb_leaf' attribute takes one argument}}
+
+- (void)wrongArgumentTypeLeaf __attribute__((enforce_tcb_leaf(12))); // expected-error{{'enforce_tcb_leaf' attribute requires a string}}
+@end
+
+@implementation AClass
+- (void)onInterfaceOnly {
+  foo(); // expected-warning{{calling 'foo' is a violation of trusted computing base 'test'}}
+}
+
+- (void)bothTCBAndTCBLeaf
+__attribute__((enforce_tcb("x")))
+__attribute__((enforce_tcb_leaf("x"))) // expected-error{{attributes 'enforce_tcb_leaf("x")' and 'enforce_tcb("x")' are mutually exclusive}}
+{
+  foo(); // no-warning
+}
+
+- (void)bothTCBAndTCBLeafOnSeparateRedeclarations
+__attribute__((enforce_tcb_leaf("x"))) // expected-error{{attributes 'enforce_tcb_leaf("x")' and 'enforce_tcb("x")' are mutually exclusive}}
+{
+  // Error recovery: no need to emit a warning when we didn't
+  // figure out our attributes to begin with.
+  foo(); // no-warning
+}
+
+- (void)bothTCBAndTCBLeafOppositeOrder
+__attribute__((enforce_tcb_leaf("x")))
+

[clang] c8048c7 - [attributes] Generalize attribute 'enforce_tcb' to Objective-C methods.

2022-03-28 Thread Artem Dergachev via cfe-commits

Author: Pierre d'Herbemont
Date: 2022-03-28T15:08:47-07:00
New Revision: c8048c7c42ffd1731149b0abe15b9081dd27c789

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

LOG: [attributes] Generalize attribute 'enforce_tcb' to Objective-C methods.

Calling an ObjC method from a C function marked with the 'enforce_tcb'
attribute did not produce a warning. Now it does, and on top of that
Objective-C methods can participate in TCBs themselves.

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

Added: 
clang/test/Sema/attr-enforce-tcb-errors.m
clang/test/Sema/attr-enforce-tcb.m

Modified: 
clang/include/clang/Basic/Attr.td
clang/include/clang/Sema/Sema.h
clang/lib/Sema/SemaChecking.cpp
clang/test/Misc/pragma-attribute-supported-attributes-list.test

Removed: 




diff  --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index a35b2fcbc4fb5..f7ef3bf42ec2f 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -3915,7 +3915,7 @@ def Builtin : InheritableAttr {
 
 def EnforceTCB : InheritableAttr {
   let Spellings = [Clang<"enforce_tcb">];
-  let Subjects = SubjectList<[Function]>;
+  let Subjects = SubjectList<[Function, ObjCMethod]>;
   let Args = [StringArgument<"TCBName">];
   let Documentation = [EnforceTCBDocs];
   bit InheritEvenIfAlreadyPresent = 1;
@@ -3923,7 +3923,7 @@ def EnforceTCB : InheritableAttr {
 
 def EnforceTCBLeaf : InheritableAttr {
   let Spellings = [Clang<"enforce_tcb_leaf">];
-  let Subjects = SubjectList<[Function]>;
+  let Subjects = SubjectList<[Function, ObjCMethod]>;
   let Args = [StringArgument<"TCBName">];
   let Documentation = [EnforceTCBLeafDocs];
   bit InheritEvenIfAlreadyPresent = 1;

diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 53ac1d011d9e1..379e120e3a117 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -12988,7 +12988,8 @@ class Sema final {
   /// attempts to add itself into the container
   void CheckObjCCircularContainer(ObjCMessageExpr *Message);
 
-  void CheckTCBEnforcement(const CallExpr *TheCall, const FunctionDecl 
*Callee);
+  void CheckTCBEnforcement(const SourceLocation CallExprLoc,
+   const NamedDecl *Callee);
 
   void AnalyzeDeleteExprMismatch(const CXXDeleteExpr *DE);
   void AnalyzeDeleteExprMismatch(FieldDecl *Field, SourceLocation DeleteLoc,

diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index e02104b4699e1..14e82e54eacb3 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -5497,7 +5497,9 @@ bool Sema::CheckFunctionCall(FunctionDecl *FDecl, 
CallExpr *TheCall,
   if (!FnInfo)
 return false;
 
-  CheckTCBEnforcement(TheCall, FDecl);
+  // Enforce TCB except for builtin calls, which are always allowed.
+  if (FDecl->getBuiltinID() == 0)
+CheckTCBEnforcement(TheCall->getExprLoc(), FDecl);
 
   CheckAbsoluteValueFunction(TheCall, FDecl);
   CheckMaxUnsignedZero(TheCall, FDecl);
@@ -5537,6 +5539,8 @@ bool Sema::CheckObjCMethodCall(ObjCMethodDecl *Method, 
SourceLocation lbrac,
 /*IsMemberFunction=*/false, lbrac, Method->getSourceRange(),
 CallType);
 
+  CheckTCBEnforcement(lbrac, Method);
+
   return false;
 }
 
@@ -17359,13 +17363,11 @@ ExprResult 
Sema::SemaBuiltinMatrixColumnMajorStore(CallExpr *TheCall,
 /// CheckTCBEnforcement - Enforces that every function in a named TCB only
 /// directly calls other functions in the same TCB as marked by the enforce_tcb
 /// and enforce_tcb_leaf attributes.
-void Sema::CheckTCBEnforcement(const CallExpr *TheCall,
-   const FunctionDecl *Callee) {
-  const FunctionDecl *Caller = getCurFunctionDecl();
+void Sema::CheckTCBEnforcement(const SourceLocation CallExprLoc,
+   const NamedDecl *Callee) {
+  const NamedDecl *Caller = getCurFunctionOrMethodDecl();
 
-  // Calls to builtins are not enforced.
-  if (!Caller || !Caller->hasAttr() ||
-  Callee->getBuiltinID() != 0)
+  if (!Caller || !Caller->hasAttr())
 return;
 
   // Search through the enforce_tcb and enforce_tcb_leaf attributes to find
@@ -17383,9 +17385,8 @@ void Sema::CheckTCBEnforcement(const CallExpr *TheCall,
   [&](const auto *A) {
 StringRef CallerTCB = A->getTCBName();
 if (CalleeTCBs.count(CallerTCB) == 0) {
-  this->Diag(TheCall->getExprLoc(),
- diag::warn_tcb_enforcement_violation) << Callee
-   << CallerTCB;
+  this->Diag(CallExprLoc, diag::warn_tcb_enforcement_violation)
+  << Callee << CallerTCB;
 }
   });
 }

diff  --git 

[PATCH] D122370: Split up large test files under clang/test/CodeGen/RISCV

2022-03-28 Thread Brandon Wu via Phabricator via cfe-commits
4vtomat added a comment.

In D122370#3412522 , @luismarques 
wrote:

> What's the timeout value that is being exceeded?

I guess it’s 60 seconds?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122370

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


[PATCH] D122535: [clang-tidy] Never consider assignments as equivalent in `misc-redundant-expression` check

2022-03-28 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM; can you add a release note when you land?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122535

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


[PATCH] D122544: Utilize comparison operation implemented in APInt

2022-03-28 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D122544#3412568 , @SimplyDanny 
wrote:

> In D122544#3411226 , @aaron.ballman 
> wrote:
>
>> LGTM! Can you also add a release note for the fix?
>>
>> I'm happy to land this on your behalf if you'd prefer, but given that you've 
>> had several quality commits already, you might want to consider asking for 
>> your commit privileges: 
>> https://llvm.org/docs/DeveloperPolicy.html#obtaining-commit-access.
>
> Thank you for the review and the recommendation to become a committer! I have 
> just been granted the privileges and have landed the change on the main 
> branch including a mention of the fix in the release notes. I hope this is 
> all right.

Congrats!

I double-checked the commit and everything looks correct to me. Thanks for the 
fix!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122544

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


[PATCH] D120949: [clang][AST matchers] adding attributedStmt AST matcher

2022-03-28 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Can you also add a release note for the changes?




Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:7800
+  attr::Kind, AttrKind) {
+  return llvm::any_of(Node.getAttrs(),
+  [&](const Attr *A) { return A->getKind() == AttrKind; });

Well this is awkward. :-D There's no way to check for whether the node has 
attributes for both kinds of nodes, but decl nodes requires that check; but 
there's no range-based for loop (or other iterator interface) that's the same 
on both nodes either.

I think you're going to need to add a class to `ASTMatchersInternal.h` to 
dispatch to the correct implementation for this query. You can look at how 
`HasSizeMatcher` is implemented and used to get an idea.



Comment at: clang/lib/AST/DeclBase.cpp:909
 const AttrVec ::getAttrs() const {
-  assert(HasAttrs && "No attrs to get!");
   return getASTContext().getDeclAttrs(this);

I don't think it's valid to remove this assert (looking at the git blame for 
this and `ASTContext::getDeclAttrs()` shows this has all been the same for the 
past 12 years).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120949

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


[PATCH] D122513: [analyzer] Fix "RhsLoc and LhsLoc bitwidth must be same"

2022-03-28 Thread Vince Bridgers via Phabricator via cfe-commits
vabridgers added a comment.

Ahhh, gotcha. I'll run that down and report back. Thanks !


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122513

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


[PATCH] D122546: Let clang-repl link privately against Clang components

2022-03-28 Thread Aaron Puchert via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1721d52a6206: Let clang-repl link privately against Clang 
components (authored by aaronpuchert).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122546

Files:
  clang/tools/clang-repl/CMakeLists.txt


Index: clang/tools/clang-repl/CMakeLists.txt
===
--- clang/tools/clang-repl/CMakeLists.txt
+++ clang/tools/clang-repl/CMakeLists.txt
@@ -11,7 +11,7 @@
   ClangRepl.cpp
   )
 
-clang_target_link_libraries(clang-repl PUBLIC
+clang_target_link_libraries(clang-repl PRIVATE
   clangBasic
   clangFrontend
   clangInterpreter


Index: clang/tools/clang-repl/CMakeLists.txt
===
--- clang/tools/clang-repl/CMakeLists.txt
+++ clang/tools/clang-repl/CMakeLists.txt
@@ -11,7 +11,7 @@
   ClangRepl.cpp
   )
 
-clang_target_link_libraries(clang-repl PUBLIC
+clang_target_link_libraries(clang-repl PRIVATE
   clangBasic
   clangFrontend
   clangInterpreter
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 1721d52 - Let clang-repl link privately against Clang components

2022-03-28 Thread Aaron Puchert via cfe-commits

Author: Aaron Puchert
Date: 2022-03-28T23:53:53+02:00
New Revision: 1721d52a62067b8a5ceec58b417b2c73ad870b13

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

LOG: Let clang-repl link privately against Clang components

First of all, this is the convention: all other tools have their
dependencies private. While it does not have an effect on linking
(there is no linking against executables), it does have an effect
on exporting: having the targets private allows installing the tools
without the libraries in a statically linked build, or a build against
libclang-cpp.so.

Reviewed By: v.g.vassilev

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

Added: 


Modified: 
clang/tools/clang-repl/CMakeLists.txt

Removed: 




diff  --git a/clang/tools/clang-repl/CMakeLists.txt 
b/clang/tools/clang-repl/CMakeLists.txt
index 30e3b2be9ed37..b51a18c10cdca 100644
--- a/clang/tools/clang-repl/CMakeLists.txt
+++ b/clang/tools/clang-repl/CMakeLists.txt
@@ -11,7 +11,7 @@ add_clang_tool(clang-repl
   ClangRepl.cpp
   )
 
-clang_target_link_libraries(clang-repl PUBLIC
+clang_target_link_libraries(clang-repl PRIVATE
   clangBasic
   clangFrontend
   clangInterpreter



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


[PATCH] D120662: [clang-offload-bundler] add -input/-output options

2022-03-28 Thread Siu Chi Chan via Phabricator via cfe-commits
scchan updated this revision to Diff 418711.
scchan added a comment.

update the clang-offload-bundler-asserts-on test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120662

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Driver/ToolChains/HIPUtility.cpp
  clang/test/Driver/clang-offload-bundler-asserts-on.c
  clang/test/Driver/clang-offload-bundler.c
  clang/test/Driver/fat-archive-unbundle-ext.c
  clang/test/Driver/fat_archive_amdgpu.cpp
  clang/test/Driver/fat_archive_nvptx.cpp
  clang/test/Driver/hip-device-compile.hip
  clang/test/Driver/hip-link-bundle-archive.hip
  clang/test/Driver/hip-link-save-temps.hip
  clang/test/Driver/hip-output-file-name.hip
  clang/test/Driver/hip-rdc-device-only.hip
  clang/test/Driver/hip-save-temps.hip
  clang/test/Driver/hip-toolchain-device-only.hip
  clang/test/Driver/hip-toolchain-no-rdc.hip
  clang/test/Driver/hip-toolchain-rdc-separate.hip
  clang/test/Driver/hip-toolchain-rdc-static-lib.hip
  clang/test/Driver/hip-toolchain-rdc.hip
  clang/test/Driver/hip-unbundle-preproc.hip
  clang/test/Driver/hipspv-toolchain-rdc.hip
  clang/test/Driver/hipspv-toolchain.hip
  clang/test/Driver/openmp-offload-gpu.c
  clang/test/Driver/openmp-offload.c
  clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp

Index: clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
===
--- clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
+++ clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
@@ -62,15 +62,26 @@
 // and -help) will be hidden.
 static cl::OptionCategory
 ClangOffloadBundlerCategory("clang-offload-bundler options");
-
 static cl::list
-InputFileNames("inputs", cl::CommaSeparated, cl::OneOrMore,
-   cl::desc("[,...]"),
+InputFileNames("input", cl::ZeroOrMore,
+   cl::desc("Input file."
+" Can be specified multiple times "
+"for multiple input files."),
+   cl::cat(ClangOffloadBundlerCategory));
+static cl::list
+InputFileNamesDeprecatedOpt("inputs", cl::CommaSeparated, cl::ZeroOrMore,
+   cl::desc("[,...] (deprecated)"),
cl::cat(ClangOffloadBundlerCategory));
 static cl::list
-OutputFileNames("outputs", cl::CommaSeparated,
-cl::desc("[,...]"),
+OutputFileNames("output", cl::ZeroOrMore,
+cl::desc("Output file."
+" Can be specified multiple times "
+"for multiple output files."),
 cl::cat(ClangOffloadBundlerCategory));
+static cl::list
+OutputFileNamesDeprecatedOpt("outputs", cl::CommaSeparated, cl::ZeroOrMore,
+cl::desc("[,...] (deprecated)"),
+cl::cat(ClangOffloadBundlerCategory));
 static cl::list
 TargetNames("targets", cl::CommaSeparated,
 cl::desc("[-,...]"),
@@ -1384,6 +1395,36 @@
 }
   };
 
+  auto warningOS = [argv]() -> raw_ostream & {
+return WithColor::warning(errs(), StringRef(argv[0]));
+  };
+
+  if (InputFileNames.getNumOccurrences() != 0 &&
+  InputFileNamesDeprecatedOpt.getNumOccurrences() != 0) {
+  reportError(createStringError(
+errc::invalid_argument,
+"-inputs and -input cannot be used together, use only -input instead"));
+  }
+  if (InputFileNamesDeprecatedOpt.size()) {
+warningOS() << "-inputs is deprecated, use -input instead\n";
+// temporary hack to support -inputs
+std::vector& s = InputFileNames;
+s.insert(s.end(), InputFileNamesDeprecatedOpt.begin(), InputFileNamesDeprecatedOpt.end());
+  }
+
+  if (OutputFileNames.getNumOccurrences() != 0 &&
+  OutputFileNamesDeprecatedOpt.getNumOccurrences() != 0) {
+  reportError(createStringError(
+errc::invalid_argument,
+"-outputs and -output cannot be used together, use only -output instead"));
+  }
+  if (OutputFileNamesDeprecatedOpt.size()) {
+warningOS() << "-outputs is deprecated, use -output instead\n";
+// temporary hack to support -outputs
+std::vector& s = OutputFileNames;
+s.insert(s.end(), OutputFileNamesDeprecatedOpt.begin(), OutputFileNamesDeprecatedOpt.end());
+  }
+
   if (ListBundleIDs) {
 if (Unbundle) {
   reportError(
@@ -1410,7 +1451,7 @@
   if (OutputFileNames.getNumOccurrences() == 0) {
 reportError(createStringError(
 errc::invalid_argument,
-"for the --outputs option: must be specified at least once!"));
+"no output file specified!"));
   }
   if (TargetNames.getNumOccurrences() == 0) {
 reportError(createStringError(
Index: clang/test/Driver/openmp-offload.c
===
--- clang/test/Driver/openmp-offload.c
+++ clang/test/Driver/openmp-offload.c
@@ -464,14 +464,14 @@
 // Create host object and bundle.
 

[PATCH] D122544: Utilize comparison operation implemented in APInt

2022-03-28 Thread Danny Mösch via Phabricator via cfe-commits
SimplyDanny added a comment.

In D122544#3411226 , @aaron.ballman 
wrote:

> LGTM! Can you also add a release note for the fix?
>
> I'm happy to land this on your behalf if you'd prefer, but given that you've 
> had several quality commits already, you might want to consider asking for 
> your commit privileges: 
> https://llvm.org/docs/DeveloperPolicy.html#obtaining-commit-access.

Thank you for the review and the recommendation to become a committer! I have 
just been granted the privileges and have landed the change on the main branch 
including a mention of the fix in the release notes. I hope this is all right.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122544

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


[PATCH] D120956: [clang][AST matchers] new AST matcher argumentCountAsWrittenIs(n) that checks the actual number of arguments given in a function call

2022-03-28 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In addition to tests, please also add a release note.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120956

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


[PATCH] D120662: [clang-offload-bundler] add -input/-output options

2022-03-28 Thread Siu Chi Chan via Phabricator via cfe-commits
scchan updated this revision to Diff 418710.
scchan added a comment.
Herald added a subscriber: MaskRay.
Herald added a project: All.

fix lit test failures on Windows, rebased


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120662

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Driver/ToolChains/HIPUtility.cpp
  clang/test/Driver/clang-offload-bundler-asserts-on.c
  clang/test/Driver/clang-offload-bundler.c
  clang/test/Driver/fat-archive-unbundle-ext.c
  clang/test/Driver/fat_archive_amdgpu.cpp
  clang/test/Driver/fat_archive_nvptx.cpp
  clang/test/Driver/hip-device-compile.hip
  clang/test/Driver/hip-link-bundle-archive.hip
  clang/test/Driver/hip-link-save-temps.hip
  clang/test/Driver/hip-output-file-name.hip
  clang/test/Driver/hip-rdc-device-only.hip
  clang/test/Driver/hip-save-temps.hip
  clang/test/Driver/hip-toolchain-device-only.hip
  clang/test/Driver/hip-toolchain-no-rdc.hip
  clang/test/Driver/hip-toolchain-rdc-separate.hip
  clang/test/Driver/hip-toolchain-rdc-static-lib.hip
  clang/test/Driver/hip-toolchain-rdc.hip
  clang/test/Driver/hip-unbundle-preproc.hip
  clang/test/Driver/hipspv-toolchain-rdc.hip
  clang/test/Driver/hipspv-toolchain.hip
  clang/test/Driver/openmp-offload-gpu.c
  clang/test/Driver/openmp-offload.c
  clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp

Index: clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
===
--- clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
+++ clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
@@ -62,15 +62,26 @@
 // and -help) will be hidden.
 static cl::OptionCategory
 ClangOffloadBundlerCategory("clang-offload-bundler options");
-
 static cl::list
-InputFileNames("inputs", cl::CommaSeparated, cl::OneOrMore,
-   cl::desc("[,...]"),
+InputFileNames("input", cl::ZeroOrMore,
+   cl::desc("Input file."
+" Can be specified multiple times "
+"for multiple input files."),
+   cl::cat(ClangOffloadBundlerCategory));
+static cl::list
+InputFileNamesDeprecatedOpt("inputs", cl::CommaSeparated, cl::ZeroOrMore,
+   cl::desc("[,...] (deprecated)"),
cl::cat(ClangOffloadBundlerCategory));
 static cl::list
-OutputFileNames("outputs", cl::CommaSeparated,
-cl::desc("[,...]"),
+OutputFileNames("output", cl::ZeroOrMore,
+cl::desc("Output file."
+" Can be specified multiple times "
+"for multiple output files."),
 cl::cat(ClangOffloadBundlerCategory));
+static cl::list
+OutputFileNamesDeprecatedOpt("outputs", cl::CommaSeparated, cl::ZeroOrMore,
+cl::desc("[,...] (deprecated)"),
+cl::cat(ClangOffloadBundlerCategory));
 static cl::list
 TargetNames("targets", cl::CommaSeparated,
 cl::desc("[-,...]"),
@@ -1384,6 +1395,36 @@
 }
   };
 
+  auto warningOS = [argv]() -> raw_ostream & {
+return WithColor::warning(errs(), StringRef(argv[0]));
+  };
+
+  if (InputFileNames.getNumOccurrences() != 0 &&
+  InputFileNamesDeprecatedOpt.getNumOccurrences() != 0) {
+  reportError(createStringError(
+errc::invalid_argument,
+"-inputs and -input cannot be used together, use only -input instead"));
+  }
+  if (InputFileNamesDeprecatedOpt.size()) {
+warningOS() << "-inputs is deprecated, use -input instead\n";
+// temporary hack to support -inputs
+std::vector& s = InputFileNames;
+s.insert(s.end(), InputFileNamesDeprecatedOpt.begin(), InputFileNamesDeprecatedOpt.end());
+  }
+
+  if (OutputFileNames.getNumOccurrences() != 0 &&
+  OutputFileNamesDeprecatedOpt.getNumOccurrences() != 0) {
+  reportError(createStringError(
+errc::invalid_argument,
+"-outputs and -output cannot be used together, use only -output instead"));
+  }
+  if (OutputFileNamesDeprecatedOpt.size()) {
+warningOS() << "-outputs is deprecated, use -output instead\n";
+// temporary hack to support -outputs
+std::vector& s = OutputFileNames;
+s.insert(s.end(), OutputFileNamesDeprecatedOpt.begin(), OutputFileNamesDeprecatedOpt.end());
+  }
+
   if (ListBundleIDs) {
 if (Unbundle) {
   reportError(
@@ -1410,7 +1451,7 @@
   if (OutputFileNames.getNumOccurrences() == 0) {
 reportError(createStringError(
 errc::invalid_argument,
-"for the --outputs option: must be specified at least once!"));
+"no output file specified!"));
   }
   if (TargetNames.getNumOccurrences() == 0) {
 reportError(createStringError(
Index: clang/test/Driver/openmp-offload.c
===
--- clang/test/Driver/openmp-offload.c
+++ clang/test/Driver/openmp-offload.c

[clang-tools-extra] ff60af9 - [clang-tidy] Utilize comparison operation implemented in APInt

2022-03-28 Thread Danny Mösch via cfe-commits

Author: Danny Mösch
Date: 2022-03-28T23:32:58+02:00
New Revision: ff60af91ac0bbab12dd5ff5dc9b78bc1636f2d86

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

LOG: [clang-tidy] Utilize comparison operation implemented in APInt

This is a fix for #53963.

Reviewed By: aaron.ballman

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp
clang-tools-extra/docs/ReleaseNotes.rst
clang-tools-extra/test/clang-tidy/checkers/bugprone-sizeof-expression.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp
index 5bdf01c098dc6..4c537afd3347b 100644
--- a/clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp
@@ -20,7 +20,7 @@ namespace bugprone {
 namespace {
 
 AST_MATCHER_P(IntegerLiteral, isBiggerThan, unsigned, N) {
-  return Node.getValue().getZExtValue() > N;
+  return Node.getValue().ugt(N);
 }
 
 AST_MATCHER_P2(Expr, hasSizeOfDescendant, int, Depth,

diff  --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index 2d144aae75e65..729bb3bbd7365 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -122,6 +122,9 @@ Changes in existing checks
 - Fixed a false positive in :doc:`misc-redundant-expression 
`
   involving overloaded comparison operators.
 
+- Fixed a crash in :doc:`bugprone-sizeof-expression 
` when
+  `sizeof(...)` is compared agains a `__int128_t`.
+
 Removed checks
 ^^
 

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/bugprone-sizeof-expression.cpp 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone-sizeof-expression.cpp
index 21d4532294aaf..605243cf7a782 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/bugprone-sizeof-expression.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/bugprone-sizeof-expression.cpp
@@ -172,7 +172,10 @@ int Foo() { int A[T]; return sizeof(T); }
 template 
 int Bar() { T A[5]; return sizeof(A[0]) / sizeof(T); }
 // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: suspicious usage of sizeof 
pointer 'sizeof(T)/sizeof(T)'
-int Test3() { return Foo<42>() + Bar(); }
+template <__int128_t N> 
+bool Baz() { return sizeof(A) < N; }
+// CHECK-MESSAGES: :[[@LINE-1]]:21: warning: suspicious comparison of 
'sizeof(expr)' to a constant
+int Test3() { return Foo<42>() + Bar() + Baz<-1>(); }
 
 static const char* kABC = "abc";
 static const wchar_t* kDEF = L"def";



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


[PATCH] D122544: Utilize comparison operation implemented in APInt

2022-03-28 Thread Danny Mösch via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGff60af91ac0b: [clang-tidy] Utilize comparison operation 
implemented in APInt (authored by SimplyDanny).

Changed prior to commit:
  https://reviews.llvm.org/D122544?vs=418450=418709#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122544

Files:
  clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/test/clang-tidy/checkers/bugprone-sizeof-expression.cpp


Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-sizeof-expression.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-sizeof-expression.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-sizeof-expression.cpp
@@ -172,7 +172,10 @@
 template 
 int Bar() { T A[5]; return sizeof(A[0]) / sizeof(T); }
 // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: suspicious usage of sizeof 
pointer 'sizeof(T)/sizeof(T)'
-int Test3() { return Foo<42>() + Bar(); }
+template <__int128_t N> 
+bool Baz() { return sizeof(A) < N; }
+// CHECK-MESSAGES: :[[@LINE-1]]:21: warning: suspicious comparison of 
'sizeof(expr)' to a constant
+int Test3() { return Foo<42>() + Bar() + Baz<-1>(); }
 
 static const char* kABC = "abc";
 static const wchar_t* kDEF = L"def";
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -122,6 +122,9 @@
 - Fixed a false positive in :doc:`misc-redundant-expression 
`
   involving overloaded comparison operators.
 
+- Fixed a crash in :doc:`bugprone-sizeof-expression 
` when
+  `sizeof(...)` is compared agains a `__int128_t`.
+
 Removed checks
 ^^
 
Index: clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp
===
--- clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp
@@ -20,7 +20,7 @@
 namespace {
 
 AST_MATCHER_P(IntegerLiteral, isBiggerThan, unsigned, N) {
-  return Node.getValue().getZExtValue() > N;
+  return Node.getValue().ugt(N);
 }
 
 AST_MATCHER_P2(Expr, hasSizeOfDescendant, int, Depth,


Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-sizeof-expression.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-sizeof-expression.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-sizeof-expression.cpp
@@ -172,7 +172,10 @@
 template 
 int Bar() { T A[5]; return sizeof(A[0]) / sizeof(T); }
 // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: suspicious usage of sizeof pointer 'sizeof(T)/sizeof(T)'
-int Test3() { return Foo<42>() + Bar(); }
+template <__int128_t N> 
+bool Baz() { return sizeof(A) < N; }
+// CHECK-MESSAGES: :[[@LINE-1]]:21: warning: suspicious comparison of 'sizeof(expr)' to a constant
+int Test3() { return Foo<42>() + Bar() + Baz<-1>(); }
 
 static const char* kABC = "abc";
 static const wchar_t* kDEF = L"def";
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -122,6 +122,9 @@
 - Fixed a false positive in :doc:`misc-redundant-expression `
   involving overloaded comparison operators.
 
+- Fixed a crash in :doc:`bugprone-sizeof-expression ` when
+  `sizeof(...)` is compared agains a `__int128_t`.
+
 Removed checks
 ^^
 
Index: clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp
===
--- clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp
@@ -20,7 +20,7 @@
 namespace {
 
 AST_MATCHER_P(IntegerLiteral, isBiggerThan, unsigned, N) {
-  return Node.getValue().getZExtValue() > N;
+  return Node.getValue().ugt(N);
 }
 
 AST_MATCHER_P2(Expr, hasSizeOfDescendant, int, Depth,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D122529: [ASTMatchers] Output currently matching node on crash

2022-03-28 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122529

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


[PATCH] D122548: [clang-format] Don't format qualifiers in PPDirective

2022-03-28 Thread Owen Pan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGeee536dd3185: [clang-format] Dont format qualifiers in 
PPDirective (authored by owenpan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122548

Files:
  clang/lib/Format/QualifierAlignmentFixer.cpp
  clang/unittests/Format/QualifierFixerTest.cpp


Index: clang/unittests/Format/QualifierFixerTest.cpp
===
--- clang/unittests/Format/QualifierFixerTest.cpp
+++ clang/unittests/Format/QualifierFixerTest.cpp
@@ -815,6 +815,7 @@
   ReplacementCount = 0;
   EXPECT_EQ(ReplacementCount, 0);
   verifyFormat("static const uint32 foo[] = {0, 31};", Style);
+  verifyFormat("#define MACRO static const", Style);
   EXPECT_EQ(ReplacementCount, 0);
 }
 
Index: clang/lib/Format/QualifierAlignmentFixer.cpp
===
--- clang/lib/Format/QualifierAlignmentFixer.cpp
+++ clang/lib/Format/QualifierAlignmentFixer.cpp
@@ -407,6 +407,8 @@
   assert(QualifierToken != tok::identifier && "Unrecognised Qualifier");
 
   for (AnnotatedLine *Line : AnnotatedLines) {
+if (Line->InPPDirective)
+  continue;
 FormatToken *First = Line->First;
 assert(First);
 if (First->Finalized)


Index: clang/unittests/Format/QualifierFixerTest.cpp
===
--- clang/unittests/Format/QualifierFixerTest.cpp
+++ clang/unittests/Format/QualifierFixerTest.cpp
@@ -815,6 +815,7 @@
   ReplacementCount = 0;
   EXPECT_EQ(ReplacementCount, 0);
   verifyFormat("static const uint32 foo[] = {0, 31};", Style);
+  verifyFormat("#define MACRO static const", Style);
   EXPECT_EQ(ReplacementCount, 0);
 }
 
Index: clang/lib/Format/QualifierAlignmentFixer.cpp
===
--- clang/lib/Format/QualifierAlignmentFixer.cpp
+++ clang/lib/Format/QualifierAlignmentFixer.cpp
@@ -407,6 +407,8 @@
   assert(QualifierToken != tok::identifier && "Unrecognised Qualifier");
 
   for (AnnotatedLine *Line : AnnotatedLines) {
+if (Line->InPPDirective)
+  continue;
 FormatToken *First = Line->First;
 assert(First);
 if (First->Finalized)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] eee536d - [clang-format] Don't format qualifiers in PPDirective

2022-03-28 Thread via cfe-commits

Author: owenca
Date: 2022-03-28T14:28:14-07:00
New Revision: eee536dd31859058dba8a0d17d3b5f61d530d3bc

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

LOG: [clang-format] Don't format qualifiers in PPDirective

Fixes #54513

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

Added: 


Modified: 
clang/lib/Format/QualifierAlignmentFixer.cpp
clang/unittests/Format/QualifierFixerTest.cpp

Removed: 




diff  --git a/clang/lib/Format/QualifierAlignmentFixer.cpp 
b/clang/lib/Format/QualifierAlignmentFixer.cpp
index 74802026690ef..fc37f18c790a4 100644
--- a/clang/lib/Format/QualifierAlignmentFixer.cpp
+++ b/clang/lib/Format/QualifierAlignmentFixer.cpp
@@ -407,6 +407,8 @@ LeftRightQualifierAlignmentFixer::analyze(
   assert(QualifierToken != tok::identifier && "Unrecognised Qualifier");
 
   for (AnnotatedLine *Line : AnnotatedLines) {
+if (Line->InPPDirective)
+  continue;
 FormatToken *First = Line->First;
 assert(First);
 if (First->Finalized)

diff  --git a/clang/unittests/Format/QualifierFixerTest.cpp 
b/clang/unittests/Format/QualifierFixerTest.cpp
index 167a30ec09d3f..cd796f48cb568 100755
--- a/clang/unittests/Format/QualifierFixerTest.cpp
+++ b/clang/unittests/Format/QualifierFixerTest.cpp
@@ -815,6 +815,7 @@ TEST_F(QualifierFixerTest, NoOpQualifierReplacements) {
   ReplacementCount = 0;
   EXPECT_EQ(ReplacementCount, 0);
   verifyFormat("static const uint32 foo[] = {0, 31};", Style);
+  verifyFormat("#define MACRO static const", Style);
   EXPECT_EQ(ReplacementCount, 0);
 }
 



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


[PATCH] D122613: [Driver] Make -moutline-atomics default for aarch64-fuchsia targets

2022-03-28 Thread Alex Brachet via Phabricator via cfe-commits
abrachet accepted this revision.
abrachet added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/lib/Driver/ToolChains/Fuchsia.h:81
+  bool IsAArch64OutlineAtomicsDefault(
+  const llvm::opt::ArgList ) const override {
+return true;




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122613

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


[PATCH] D122370: Split up large test files under clang/test/CodeGen/RISCV

2022-03-28 Thread Luís Marques via Phabricator via cfe-commits
luismarques added a comment.

What's the timeout value that is being exceeded?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122370

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


[PATCH] D122155: Add warning when eval-method is set in the presence of value unsafe floating-point calculations.

2022-03-28 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticFrontendKinds.td:52-53
+def err_incompatible_fp_eval_method_options : Error<
+"option 'ffp-eval-method' cannot be used with"
+" %select{option 'fapprox-func'|option 'mreassociate'|option 
'freciprocal'}0.">;
+





Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:6479-6481
+  "%select{'#pragma clang fp eval_method'|option 'ffp-eval-method'}0 cannot be 
used when"
+  " %select{option 'fapprox_func'|option 'mreassociate'|option 
'freciprocal'|option 'ffp-eval-method'|'#pragma clang fp reassociate'}1"
+  " is enabled.">;





Comment at: clang/test/Sema/eval-method-with-unsafe-math.c:52
+
+// CHECK-FE-FUNC: (frontend): option 'ffp-eval-method' cannot be used with 
option 'fapprox-func'.
+// CHECK-FE-ASSOC: (frontend): option 'ffp-eval-method' cannot be used with 
option 'mreassociate'.

Can you split the driver tests into their own file in the `Driver` directory?


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

https://reviews.llvm.org/D122155

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


[clang] d394f9f - Add HLSL Language Option and Preprocessor

2022-03-28 Thread Chris Bieneman via cfe-commits

Author: Chris Bieneman
Date: 2022-03-28T16:16:17-05:00
New Revision: d394f9f8970d758cb39151328dd3040ba7f414ae

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

LOG: Add HLSL Language Option and Preprocessor

Bringing in HLSL as a language as well as language options for each of
the HLSL language standards.

While the HLSL language is unimplemented, this patch adds the
HLSL-specific preprocessor defines which enables testing of the command
line options through the driver.

Reviewed By: pete, rnk

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

Added: 
clang/test/Preprocessor/predefined-macros-hlsl.c

Modified: 
clang/include/clang/Basic/LangOptions.def
clang/include/clang/Basic/LangOptions.h
clang/include/clang/Basic/LangStandard.h
clang/include/clang/Basic/LangStandards.def
clang/include/clang/Driver/Types.def
clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/lib/Frontend/FrontendActions.cpp
clang/lib/Frontend/InitPreprocessor.cpp
clang/test/Driver/lit.local.cfg
clang/test/lit.cfg.py
llvm/lib/Support/Triple.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/LangOptions.def 
b/clang/include/clang/Basic/LangOptions.def
index 05b9691142998..d5f8dd9ab5c04 100644
--- a/clang/include/clang/Basic/LangOptions.def
+++ b/clang/include/clang/Basic/LangOptions.def
@@ -251,6 +251,9 @@ LANGOPT(OpenMPNoThreadState  , 1, 0, "Assume that no thread 
in a parallel region
 LANGOPT(OpenMPOffloadMandatory  , 1, 0, "Assert that offloading is mandatory 
and do not create a host fallback.")
 LANGOPT(RenderScript  , 1, 0, "RenderScript")
 
+LANGOPT(HLSL, 1, 0, "HLSL")
+ENUM_LANGOPT(HLSLVersion, HLSLLangStd, 16, HLSL_Unset, "HLSL Version")
+
 LANGOPT(CUDAIsDevice  , 1, 0, "compiling for CUDA device")
 LANGOPT(CUDAAllowVariadicFunctions, 1, 0, "allowing variadic functions in CUDA 
device code")
 LANGOPT(CUDAHostDeviceConstexpr, 1, 1, "treating unattributed constexpr 
functions as __host__ __device__")

diff  --git a/clang/include/clang/Basic/LangOptions.h 
b/clang/include/clang/Basic/LangOptions.h
index 96fd6049efeca..f5a2fd8461674 100644
--- a/clang/include/clang/Basic/LangOptions.h
+++ b/clang/include/clang/Basic/LangOptions.h
@@ -53,6 +53,26 @@ class LangOptionsBase {
 /// members used to implement virtual inheritance.
 enum class MSVtorDispMode { Never, ForVBaseOverride, ForVFTable };
 
+/// Shader programs run in specific pipeline stages.
+enum class ShaderStage {
+  Pixel = 0,
+  Vertex,
+  Geometry,
+  Hull,
+  Domain,
+  Compute,
+  Library,
+  RayGeneration,
+  Intersection,
+  AnyHit,
+  ClosestHit,
+  Miss,
+  Callable,
+  Mesh,
+  Amplification,
+  Invalid,
+};
+
 /// Keeps track of the various options that can be
 /// enabled, which controls the dialect of C or C++ that is accepted.
 class LangOptions : public LangOptionsBase {
@@ -140,6 +160,16 @@ class LangOptions : public LangOptionsBase {
 SYCL_Default = SYCL_2020
   };
 
+  enum HLSLLangStd {
+HLSL_Unset = 0,
+HLSL_2015 = 2015,
+HLSL_2016 = 2016,
+HLSL_2017 = 2017,
+HLSL_2018 = 2018,
+HLSL_2021 = 2021,
+HLSL_202x = 2029,
+  };
+
   /// Clang versions with 
diff erent platform ABI conformance.
   enum class ClangABI {
 /// Attempt to be ABI-compatible with code generated by Clang 3.8.x

diff  --git a/clang/include/clang/Basic/LangStandard.h 
b/clang/include/clang/Basic/LangStandard.h
index b0785409628c4..fdfd2e7773a87 100644
--- a/clang/include/clang/Basic/LangStandard.h
+++ b/clang/include/clang/Basic/LangStandard.h
@@ -36,6 +36,7 @@ enum class Language : uint8_t {
   CUDA,
   RenderScript,
   HIP,
+  HLSL,
   ///@}
 };
 
@@ -55,7 +56,8 @@ enum LangFeatures {
   GNUMode = (1 << 12),
   HexFloat = (1 << 13),
   ImplicitInt = (1 << 14),
-  OpenCL = (1 << 15)
+  OpenCL = (1 << 15),
+  HLSL = (1 << 16)
 };
 
 /// LangStandard - Information about the properties of a particular language

diff  --git a/clang/include/clang/Basic/LangStandards.def 
b/clang/include/clang/Basic/LangStandards.def
index 6056cfd65bbbf..d0e777b23b94f 100644
--- a/clang/include/clang/Basic/LangStandards.def
+++ b/clang/include/clang/Basic/LangStandards.def
@@ -209,6 +209,36 @@ LANGSTANDARD(cuda, "cuda", CUDA, "NVIDIA CUDA(tm)",
 LANGSTANDARD(hip, "hip", HIP, "HIP",
  LineComment | CPlusPlus | CPlusPlus11 | CPlusPlus14 | Digraphs)
 
+// HLSL
+LANGSTANDARD(hlsl, "hlsl",
+ HLSL, "High Level Shader Language",
+ LineComment | HLSL | CPlusPlus )
+
+LANGSTANDARD(hlsl2015, "hlsl2015",
+ HLSL, "High Level Shader Language 2015",
+ LineComment | HLSL | CPlusPlus )
+
+LANGSTANDARD(hlsl2016, "hlsl2016",
+ HLSL, "High Level Shader Language 2016",
+

[PATCH] D122087: Add HLSL Language Option and Preprocessor

2022-03-28 Thread Chris Bieneman 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 rGd394f9f8970d: Add HLSL Language Option and Preprocessor 
(authored by beanz).
Herald added subscribers: llvm-commits, hiraditya.
Herald added a reviewer: dang.
Herald added a project: LLVM.

Changed prior to commit:
  https://reviews.llvm.org/D122087?vs=416744=418703#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122087

Files:
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Basic/LangOptions.h
  clang/include/clang/Basic/LangStandard.h
  clang/include/clang/Basic/LangStandards.def
  clang/include/clang/Driver/Types.def
  clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Frontend/FrontendActions.cpp
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/test/Driver/lit.local.cfg
  clang/test/Preprocessor/predefined-macros-hlsl.c
  clang/test/lit.cfg.py
  llvm/lib/Support/Triple.cpp

Index: llvm/lib/Support/Triple.cpp
===
--- llvm/lib/Support/Triple.cpp
+++ llvm/lib/Support/Triple.cpp
@@ -1888,3 +1888,17 @@
 return Version;
   }
 }
+
+// HLSL triple environment orders are relied on in the front end
+static_assert(Triple::Vertex - Triple::Pixel == 1,
+  "incorrect HLSL stage order");
+static_assert(Triple::Geometry - Triple::Pixel == 2,
+  "incorrect HLSL stage order");
+static_assert(Triple::Hull - Triple::Pixel == 3,
+  "incorrect HLSL stage order");
+static_assert(Triple::Domain - Triple::Pixel == 4,
+  "incorrect HLSL stage order");
+static_assert(Triple::Compute - Triple::Pixel == 5,
+  "incorrect HLSL stage order");
+static_assert(Triple::Library - Triple::Pixel == 6,
+  "incorrect HLSL stage order");
Index: clang/test/lit.cfg.py
===
--- clang/test/lit.cfg.py
+++ clang/test/lit.cfg.py
@@ -25,7 +25,7 @@
 config.test_format = lit.formats.ShTest(not llvm_config.use_lit_shell)
 
 # suffixes: A list of file extensions to treat as test files.
-config.suffixes = ['.c', '.cpp', '.i', '.cppm', '.m', '.mm', '.cu', '.hip',
+config.suffixes = ['.c', '.cpp', '.i', '.cppm', '.m', '.mm', '.cu', '.hip', '.hlsl',
'.ll', '.cl', '.clcpp', '.s', '.S', '.modulemap', '.test', '.rs', '.ifs', '.rc']
 
 # excludes: A list of directories to exclude from the testsuite. The 'Inputs'
Index: clang/test/Preprocessor/predefined-macros-hlsl.c
===
--- /dev/null
+++ clang/test/Preprocessor/predefined-macros-hlsl.c
@@ -0,0 +1,48 @@
+// RUN: %clang_cc1 %s -E -dM -o - -x hlsl -triple dxil-pc-shadermodel6.0-amplification | FileCheck -match-full-lines %s --check-prefixes=CHECK,AMPLIFICATION
+// RUN: %clang_cc1 %s -E -dM -o - -x hlsl -triple dxil-pc-shadermodel6.0-compute | FileCheck -match-full-lines %s --check-prefixes=CHECK,COMPUTE
+// RUN: %clang_cc1 %s -E -dM -o - -x hlsl -triple dxil-pc-shadermodel6.0-domain | FileCheck -match-full-lines %s --check-prefixes=CHECK,DOMAIN
+// RUN: %clang_cc1 %s -E -dM -o - -x hlsl -triple dxil-pc-shadermodel6.0-geometry | FileCheck -match-full-lines %s --check-prefixes=CHECK,GEOMETRY
+// RUN: %clang_cc1 %s -E -dM -o - -x hlsl -triple dxil-pc-shadermodel6.0-hull | FileCheck -match-full-lines %s --check-prefixes=CHECK,HULL
+// RUN: %clang_cc1 %s -E -dM -o - -x hlsl -triple dxil-pc-shadermodel6.0-library | FileCheck -match-full-lines %s --check-prefixes=CHECK,LIBRARY
+// RUN: %clang_cc1 %s -E -dM -o - -x hlsl -triple dxil-pc-shadermodel6.0-mesh | FileCheck -match-full-lines %s --check-prefixes=CHECK,MESH
+// RUN: %clang_cc1 %s -E -dM -o - -x hlsl -triple dxil-pc-shadermodel6.0-pixel | FileCheck -match-full-lines %s --check-prefixes=CHECK,PIXEL
+// RUN: %clang_cc1 %s -E -dM -o - -x hlsl -triple dxil-pc-shadermodel6.0-vertex | FileCheck -match-full-lines %s --check-prefixes=CHECK,VERTEX
+
+// CHECK: #define __HLSL_VERSION 2021
+// CHECK: #define __SHADER_STAGE_AMPLIFICATION 14
+// CHECK: #define __SHADER_STAGE_COMPUTE 5
+// CHECK: #define __SHADER_STAGE_DOMAIN 4
+// CHECK: #define __SHADER_STAGE_GEOMETRY 2
+// CHECK: #define __SHADER_STAGE_HULL 3
+// CHECK: #define __SHADER_STAGE_LIBRARY 6
+// CHECK: #define __SHADER_STAGE_MESH 13
+// CHECK: #define __SHADER_STAGE_PIXEL 0
+// CHECK: #define __SHADER_STAGE_VERTEX 1
+
+// AMPLIFICATION: #define __SHADER_TARGET_STAGE 14
+// COMPUTE: #define __SHADER_TARGET_STAGE 5
+// DOMAIN: #define __SHADER_TARGET_STAGE 4
+// GEOMETRY: #define __SHADER_TARGET_STAGE 2
+// HULL: #define __SHADER_TARGET_STAGE 3
+// LIBRARY: #define __SHADER_TARGET_STAGE 6
+// MESH: #define __SHADER_TARGET_STAGE 13
+// PIXEL: #define __SHADER_TARGET_STAGE 0
+// VERTEX: #define __SHADER_TARGET_STAGE 1
+

[PATCH] D122611: [clang][extract-api] Add support for macros

2022-03-28 Thread Zixu Wang via Phabricator via cfe-commits
zixuw added a comment.

Still going through the declaration fragments builder and 
`ExtractAPIVisitor/Consumer/Action` changes, but it seems that the patch needs 
a rebase onto the latest main right now as it's missing several already landed 
changes.




Comment at: clang/include/clang/ExtractAPI/API.h:117
 
-  GlobalRecord(GVKind Kind, StringRef Name, StringRef USR, PresumedLoc Loc,
+  GlobalRecord(StringRef Name, GVKind Kind, StringRef USR, PresumedLoc Loc,
const AvailabilityInfo , LinkageInfo Linkage,

Now that we are re-ordering it, would it look more organized if we push `GVKind 
Kind` further down so that the two `StringRef`s could be adjacent, and we also 
keep a common list of arguments (`Name, USR, Loc, Availability, ..., 
SubHeading`) the same across all kinds of records upfront? So maybe push to the 
end after `SubHeading` and before `Signature`.



Comment at: clang/include/clang/ExtractAPI/API.h:117
 
-  GlobalRecord(GVKind Kind, StringRef Name, StringRef USR, PresumedLoc Loc,
+  GlobalRecord(StringRef Name, GVKind Kind, StringRef USR, PresumedLoc Loc,
const AvailabilityInfo , LinkageInfo Linkage,

zixuw wrote:
> Now that we are re-ordering it, would it look more organized if we push 
> `GVKind Kind` further down so that the two `StringRef`s could be adjacent, 
> and we also keep a common list of arguments (`Name, USR, Loc, Availability, 
> ..., SubHeading`) the same across all kinds of records upfront? So maybe push 
> to the end after `SubHeading` and before `Signature`.
Also it seems that it becomes a requirement for the `*Record` c'tors that 
`Name` should be the first parameter in order to use the `addTopLevelRecord` 
template, though that's hidden in an anonymous namespace in the implementation 
file.
How can we communicate or document this clearly for future extensions?



Comment at: clang/include/clang/ExtractAPI/API.h:195
+  MacroDefinitionRecord(StringRef Name, StringRef USR, PresumedLoc Loc,
+DeclarationFragments DeclarationFragments)
+  : APIRecord(RK_MacroDefinition, Name, USR, Loc, AvailabilityInfo(),

Don't we also need sub-headings for macros?



Comment at: clang/include/clang/ExtractAPI/API.h:201
+return Record->getKind() == RK_MacroDefinition;
+  }
+};

Need out-of-line virtual anchor as this struct inherits a virtual table.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122611

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


[PATCH] D122613: [Driver] Make -moutline-atomics default for aarch64-fuchsia targets

2022-03-28 Thread Roland McGrath via Phabricator via cfe-commits
mcgrathr created this revision.
mcgrathr added reviewers: phosek, abrachet.
Herald added a subscriber: kristof.beyls.
Herald added a project: All.
mcgrathr requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay.
Herald added a project: clang.

This makes Fuchsia consistent with Linux on AArch64.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D122613

Files:
  clang/lib/Driver/ToolChains/Fuchsia.h
  clang/test/Driver/fuchsia.c


Index: clang/test/Driver/fuchsia.c
===
--- clang/test/Driver/fuchsia.c
+++ clang/test/Driver/fuchsia.c
@@ -34,6 +34,7 @@
 // CHECK-AARCH64: "-fsanitize=shadow-call-stack"
 // CHECK-X86_64: "-fsanitize=safe-stack"
 // CHECK: "-stack-protector" "2"
+// CHECK-AARCH64: "-target-feature" "+outline-atomics"
 // CHECK-NOT: "-fcommon"
 // CHECK: {{.*}}ld.lld{{.*}}" "-z" "max-page-size=4096" "-z" "now" "-z" 
"rodynamic" "-z" "separate-loadable-segments" "-z" "rel" 
"--pack-dyn-relocs=relr"
 // CHECK: "--sysroot=[[SYSROOT]]"
Index: clang/lib/Driver/ToolChains/Fuchsia.h
===
--- clang/lib/Driver/ToolChains/Fuchsia.h
+++ clang/lib/Driver/ToolChains/Fuchsia.h
@@ -75,24 +75,27 @@
 
   RuntimeLibType
   GetRuntimeLibType(const llvm::opt::ArgList ) const override;
-  CXXStdlibType
-  GetCXXStdlibType(const llvm::opt::ArgList ) const override;
+  CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList ) const 
override;
+
+  bool IsAArch64OutlineAtomicsDefault(
+  const llvm::opt::ArgList ) const override {
+return true;
+  }
 
-  void addClangTargetOptions(const llvm::opt::ArgList ,
- llvm::opt::ArgStringList ,
- Action::OffloadKind DeviceOffloadKind) const 
override;
+  void
+  addClangTargetOptions(const llvm::opt::ArgList ,
+llvm::opt::ArgStringList ,
+Action::OffloadKind DeviceOffloadKind) const override;
   void
   AddClangSystemIncludeArgs(const llvm::opt::ArgList ,
 llvm::opt::ArgStringList ) const override;
-  void
-  AddClangCXXStdlibIncludeArgs(const llvm::opt::ArgList ,
-   llvm::opt::ArgStringList ) const 
override;
+  void AddClangCXXStdlibIncludeArgs(
+  const llvm::opt::ArgList ,
+  llvm::opt::ArgStringList ) const override;
   void AddCXXStdlibLibArgs(const llvm::opt::ArgList ,
llvm::opt::ArgStringList ) const override;
 
-  const char *getDefaultLinker() const override {
-return "ld.lld";
-  }
+  const char *getDefaultLinker() const override { return "ld.lld"; }
 
 protected:
   Tool *buildLinker() const override;


Index: clang/test/Driver/fuchsia.c
===
--- clang/test/Driver/fuchsia.c
+++ clang/test/Driver/fuchsia.c
@@ -34,6 +34,7 @@
 // CHECK-AARCH64: "-fsanitize=shadow-call-stack"
 // CHECK-X86_64: "-fsanitize=safe-stack"
 // CHECK: "-stack-protector" "2"
+// CHECK-AARCH64: "-target-feature" "+outline-atomics"
 // CHECK-NOT: "-fcommon"
 // CHECK: {{.*}}ld.lld{{.*}}" "-z" "max-page-size=4096" "-z" "now" "-z" "rodynamic" "-z" "separate-loadable-segments" "-z" "rel" "--pack-dyn-relocs=relr"
 // CHECK: "--sysroot=[[SYSROOT]]"
Index: clang/lib/Driver/ToolChains/Fuchsia.h
===
--- clang/lib/Driver/ToolChains/Fuchsia.h
+++ clang/lib/Driver/ToolChains/Fuchsia.h
@@ -75,24 +75,27 @@
 
   RuntimeLibType
   GetRuntimeLibType(const llvm::opt::ArgList ) const override;
-  CXXStdlibType
-  GetCXXStdlibType(const llvm::opt::ArgList ) const override;
+  CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList ) const override;
+
+  bool IsAArch64OutlineAtomicsDefault(
+  const llvm::opt::ArgList ) const override {
+return true;
+  }
 
-  void addClangTargetOptions(const llvm::opt::ArgList ,
- llvm::opt::ArgStringList ,
- Action::OffloadKind DeviceOffloadKind) const override;
+  void
+  addClangTargetOptions(const llvm::opt::ArgList ,
+llvm::opt::ArgStringList ,
+Action::OffloadKind DeviceOffloadKind) const override;
   void
   AddClangSystemIncludeArgs(const llvm::opt::ArgList ,
 llvm::opt::ArgStringList ) const override;
-  void
-  AddClangCXXStdlibIncludeArgs(const llvm::opt::ArgList ,
-   llvm::opt::ArgStringList ) const override;
+  void AddClangCXXStdlibIncludeArgs(
+  const llvm::opt::ArgList ,
+  llvm::opt::ArgStringList ) const override;
   void AddCXXStdlibLibArgs(const llvm::opt::ArgList ,
llvm::opt::ArgStringList ) const override;
 
-  const char *getDefaultLinker() const override {
-return "ld.lld";
-  }
+  const char *getDefaultLinker() const override { return "ld.lld"; }
 
 

[PATCH] D122446: [clang][extract-api] Add Objective-C interface support

2022-03-28 Thread Daniel Grumberg via Phabricator via cfe-commits
dang added inline comments.



Comment at: clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp:375
+  case APIRecord::RK_ObjCIvar:
+Kind["identifier"] = AddLangPrefix("ivar");
+Kind["displayName"] = "Instance Variable";

this should probably be more explicit to keep in line with how things are 
currently done. Maybe something like "instance.variable"


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122446

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


[clang] 577827c - [flang][driver] Make --version and -version consistent with clang

2022-03-28 Thread Emil Kieri via cfe-commits

Author: Emil Kieri
Date: 2022-03-28T22:53:17+02:00
New Revision: 577827cbbf1033612d6ce15169f33ee5709abbfc

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

LOG: [flang][driver] Make --version and -version consistent with clang

This patch makes -version valid, and --version invalid, for
flang-new -fc1. The invocation
  flang-new --version
remains valid. This behaviour is consistent with clang
(and with clang -cc1 and clang -cc1as).

Previously, flang-new -fc1 accepted --version (as per Options.td), but
the frontend driver acutally checks for -version. As a result,
  flang-new -fc1 --version
triggered no action, emitted no message, and stalled waiting for
standard input.

Fixes #51438

Reviewed By: PeteSteinfeld, awarzynski

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

Added: 


Modified: 
clang/include/clang/Driver/Options.td
flang/test/Driver/driver-help.f90
flang/test/Driver/driver-version.f90

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index ac2f479f159eb..8c488f254b1ec 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -4205,7 +4205,7 @@ def _serialize_diags : Separate<["-", "--"], 
"serialize-diagnostics">, Flags<[No
   HelpText<"Serialize compiler diagnostics to a file">;
 // We give --version 
diff erent semantics from -version.
 def _version : Flag<["--"], "version">,
-  Flags<[CoreOption, FC1Option, FlangOption]>,
+  Flags<[CoreOption, FlangOption]>,
   HelpText<"Print version information">;
 def _signed_char : Flag<["--"], "signed-char">, Alias;
 def _std : Separate<["--"], "std">, Alias;
@@ -5749,11 +5749,16 @@ def aligned_alloc_unavailable : Flag<["-"], 
"faligned-alloc-unavailable">,
 // Language Options
 
//===--===//
 
-let Flags = [CC1Option, CC1AsOption, NoDriverOption] in {
+let Flags = [CC1Option, CC1AsOption, FC1Option, NoDriverOption] in {
 
 def version : Flag<["-"], "version">,
   HelpText<"Print the compiler version">,
   MarshallingInfoFlag>;
+
+} // let Flags = [CC1Option, CC1AsOption, FC1Option, NoDriverOption]
+
+let Flags = [CC1Option, CC1AsOption, NoDriverOption] in {
+
 def main_file_name : Separate<["-"], "main-file-name">,
   HelpText<"Main file name to use for debug info and source if missing">,
   MarshallingInfoString>;

diff  --git a/flang/test/Driver/driver-help.f90 
b/flang/test/Driver/driver-help.f90
index 16cc6c428082b..e020fa3801fd9 100644
--- a/flang/test/Driver/driver-help.f90
+++ b/flang/test/Driver/driver-help.f90
@@ -135,7 +135,7 @@
 ! HELP-FC1-NEXT: -test-io   Run the InputOuputTest action. Use for 
development and testing only.
 ! HELP-FC1-NEXT: -triple Specify target triple (e.g. 
i686-apple-darwin9)
 ! HELP-FC1-NEXT: -U  Undefine macro 
-! HELP-FC1-NEXT: --version  Print version information
+! HELP-FC1-NEXT: -version   Print the compiler version
 ! HELP-FC1-NEXT: -WEnable the specified warning
 
 !---

diff  --git a/flang/test/Driver/driver-version.f90 
b/flang/test/Driver/driver-version.f90
index c3569be12a1a0..e38a1e58b60bd 100644
--- a/flang/test/Driver/driver-version.f90
+++ b/flang/test/Driver/driver-version.f90
@@ -2,15 +2,21 @@
 !---
 ! RUN LINES
 !---
-! RUN: %flang --version 2>&1 | FileCheck %s
+! RUN: %flang --version 2>&1 | FileCheck %s --check-prefix=VERSION
 ! RUN: not %flang --versions 2>&1 | FileCheck %s --check-prefix=ERROR
+! RUN: %flang_fc1 -version 2>&1 | FileCheck %s --check-prefix=VERSION-FC1
+! RUN: not %flang_fc1 --version 2>&1 | FileCheck %s --check-prefix=ERROR-FC1
 
 !---
 ! EXPECTED OUTPUT
 !---
-! CHECK: flang-new version
-! CHECK-NEXT: Target:
-! CHECK-NEXT: Thread model:
-! CHECK-NEXT: InstalledDir:
+! VERSION: flang-new version
+! VERSION-NEXT: Target:
+! VERSION-NEXT: Thread model:
+! VERSION-NEXT: InstalledDir:
 
 ! ERROR: flang-new: error: unsupported option '--versions'; did you mean 
'--version'?
+
+! VERSION-FC1: LLVM version
+
+! ERROR-FC1: error: unknown argument '--version'; did you mean '-version'?



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


[PATCH] D122542: [flang][driver] Make --version and -version consistent with clang

2022-03-28 Thread Emil Kieri via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
ekieri marked an inline comment as done.
Closed by commit rG577827cbbf10: [flang][driver] Make --version and -version 
consistent with clang (authored by ekieri).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122542

Files:
  clang/include/clang/Driver/Options.td
  flang/test/Driver/driver-help.f90
  flang/test/Driver/driver-version.f90


Index: flang/test/Driver/driver-version.f90
===
--- flang/test/Driver/driver-version.f90
+++ flang/test/Driver/driver-version.f90
@@ -2,15 +2,21 @@
 !---
 ! RUN LINES
 !---
-! RUN: %flang --version 2>&1 | FileCheck %s
+! RUN: %flang --version 2>&1 | FileCheck %s --check-prefix=VERSION
 ! RUN: not %flang --versions 2>&1 | FileCheck %s --check-prefix=ERROR
+! RUN: %flang_fc1 -version 2>&1 | FileCheck %s --check-prefix=VERSION-FC1
+! RUN: not %flang_fc1 --version 2>&1 | FileCheck %s --check-prefix=ERROR-FC1
 
 !---
 ! EXPECTED OUTPUT
 !---
-! CHECK: flang-new version
-! CHECK-NEXT: Target:
-! CHECK-NEXT: Thread model:
-! CHECK-NEXT: InstalledDir:
+! VERSION: flang-new version
+! VERSION-NEXT: Target:
+! VERSION-NEXT: Thread model:
+! VERSION-NEXT: InstalledDir:
 
 ! ERROR: flang-new: error: unsupported option '--versions'; did you mean 
'--version'?
+
+! VERSION-FC1: LLVM version
+
+! ERROR-FC1: error: unknown argument '--version'; did you mean '-version'?
Index: flang/test/Driver/driver-help.f90
===
--- flang/test/Driver/driver-help.f90
+++ flang/test/Driver/driver-help.f90
@@ -135,7 +135,7 @@
 ! HELP-FC1-NEXT: -test-io   Run the InputOuputTest action. Use for 
development and testing only.
 ! HELP-FC1-NEXT: -triple Specify target triple (e.g. 
i686-apple-darwin9)
 ! HELP-FC1-NEXT: -U  Undefine macro 
-! HELP-FC1-NEXT: --version  Print version information
+! HELP-FC1-NEXT: -version   Print the compiler version
 ! HELP-FC1-NEXT: -WEnable the specified warning
 
 !---
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -4205,7 +4205,7 @@
   HelpText<"Serialize compiler diagnostics to a file">;
 // We give --version different semantics from -version.
 def _version : Flag<["--"], "version">,
-  Flags<[CoreOption, FC1Option, FlangOption]>,
+  Flags<[CoreOption, FlangOption]>,
   HelpText<"Print version information">;
 def _signed_char : Flag<["--"], "signed-char">, Alias;
 def _std : Separate<["--"], "std">, Alias;
@@ -5749,11 +5749,16 @@
 // Language Options
 
//===--===//
 
-let Flags = [CC1Option, CC1AsOption, NoDriverOption] in {
+let Flags = [CC1Option, CC1AsOption, FC1Option, NoDriverOption] in {
 
 def version : Flag<["-"], "version">,
   HelpText<"Print the compiler version">,
   MarshallingInfoFlag>;
+
+} // let Flags = [CC1Option, CC1AsOption, FC1Option, NoDriverOption]
+
+let Flags = [CC1Option, CC1AsOption, NoDriverOption] in {
+
 def main_file_name : Separate<["-"], "main-file-name">,
   HelpText<"Main file name to use for debug info and source if missing">,
   MarshallingInfoString>;


Index: flang/test/Driver/driver-version.f90
===
--- flang/test/Driver/driver-version.f90
+++ flang/test/Driver/driver-version.f90
@@ -2,15 +2,21 @@
 !---
 ! RUN LINES
 !---
-! RUN: %flang --version 2>&1 | FileCheck %s
+! RUN: %flang --version 2>&1 | FileCheck %s --check-prefix=VERSION
 ! RUN: not %flang --versions 2>&1 | FileCheck %s --check-prefix=ERROR
+! RUN: %flang_fc1 -version 2>&1 | FileCheck %s --check-prefix=VERSION-FC1
+! RUN: not %flang_fc1 --version 2>&1 | FileCheck %s --check-prefix=ERROR-FC1
 
 !---
 ! EXPECTED OUTPUT
 !---
-! CHECK: flang-new version
-! CHECK-NEXT: Target:
-! CHECK-NEXT: Thread model:
-! CHECK-NEXT: InstalledDir:
+! VERSION: flang-new version
+! VERSION-NEXT: Target:
+! VERSION-NEXT: Thread model:
+! VERSION-NEXT: InstalledDir:
 
 ! ERROR: flang-new: error: unsupported option '--versions'; did you mean '--version'?
+
+! VERSION-FC1: LLVM version
+
+! ERROR-FC1: error: unknown argument '--version'; did you mean '-version'?
Index: flang/test/Driver/driver-help.f90
===
--- flang/test/Driver/driver-help.f90
+++ flang/test/Driver/driver-help.f90
@@ -135,7 +135,7 @@
 ! HELP-FC1-NEXT: -test-io   Run the InputOuputTest action. Use for development and testing only.
 ! HELP-FC1-NEXT: 

[PATCH] D122611: [clang][extract-api] Add support for macros

2022-03-28 Thread Daniel Grumberg via Phabricator via cfe-commits
dang created this revision.
dang added reviewers: zixuw, ributzka, QuietMisdreavus.
Herald added a project: All.
dang requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

To achieve this we hook into the preprocessor during the
ExtractAPIAction and record definitions for macros that don't get
undefined during preprocessing.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D122611

Files:
  clang/include/clang/ExtractAPI/API.h
  clang/include/clang/ExtractAPI/DeclarationFragments.h
  clang/include/clang/ExtractAPI/FrontendActions.h
  clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h
  clang/lib/ExtractAPI/API.cpp
  clang/lib/ExtractAPI/DeclarationFragments.cpp
  clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
  clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
  clang/test/ExtractAPI/macro_undefined.c
  clang/test/ExtractAPI/macros.c

Index: clang/test/ExtractAPI/macros.c
===
--- /dev/null
+++ clang/test/ExtractAPI/macros.c
@@ -0,0 +1,308 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: sed -e "s@INPUT_DIR@%/t@g" %t/reference.output.json.in >> \
+// RUN: %t/reference.output.json
+// RUN: %clang -extract-api --product-name=Macros -target arm64-apple-macosx \
+// RUN: -x objective-c-header %t/input.h -o %t/output.json | FileCheck -allow-empty %s
+
+// Generator version is not consistent across test runs, normalize it.
+// RUN: sed -e "s@\"generator\": \".*\"@\"generator\": \"?\"@g" \
+// RUN: %t/output.json >> %t/output-normalized.json
+// RUN: diff %t/reference.output.json %t/output-normalized.json
+
+// CHECK-NOT: error:
+// CHECK-NOT: warning:
+
+//--- input.h
+#define HELLO 1
+#define WORLD 2
+#define MACRO_FUN(x) x x
+#define FUN(x, y, z) x + y + z
+#define FUNC99(x, ...)
+#define FUNGNU(x...)
+
+//--- reference.output.json.in
+{
+  "metadata": {
+"formatVersion": {
+  "major": 0,
+  "minor": 5,
+  "patch": 3
+},
+"generator": "?"
+  },
+  "module": {
+"name": "Macros",
+"platform": {
+  "architecture": "arm64",
+  "operatingSystem": {
+"minimumVersion": {
+  "major": 11,
+  "minor": 0,
+  "patch": 0
+},
+"name": "macosx"
+  },
+  "vendor": "apple"
+}
+  },
+  "relationhips": [],
+  "symbols": [
+{
+  "declarationFragments": [
+{
+  "kind": "keyword",
+  "spelling": "#define"
+},
+{
+  "kind": "text",
+  "spelling": " "
+},
+{
+  "kind": "identifier",
+  "spelling": "HELLO"
+}
+  ],
+  "identifier": {
+"interfaceLanguage": "c",
+"precise": "c:input.h@8@macro@HELLO"
+  },
+  "kind": {
+"displayName": "Macro",
+"identifier": "c.macro"
+  },
+  "location": {
+"character": 9,
+"line": 1,
+"uri": "file://INPUT_DIR/input.h"
+  },
+  "names": {
+"title": "HELLO"
+  }
+},
+{
+  "declarationFragments": [
+{
+  "kind": "keyword",
+  "spelling": "#define"
+},
+{
+  "kind": "text",
+  "spelling": " "
+},
+{
+  "kind": "identifier",
+  "spelling": "WORLD"
+}
+  ],
+  "identifier": {
+"interfaceLanguage": "c",
+"precise": "c:input.h@24@macro@WORLD"
+  },
+  "kind": {
+"displayName": "Macro",
+"identifier": "c.macro"
+  },
+  "location": {
+"character": 9,
+"line": 2,
+"uri": "file://INPUT_DIR/input.h"
+  },
+  "names": {
+"title": "WORLD"
+  }
+},
+{
+  "declarationFragments": [
+{
+  "kind": "keyword",
+  "spelling": "#define"
+},
+{
+  "kind": "text",
+  "spelling": " "
+},
+{
+  "kind": "identifier",
+  "spelling": "MACRO_FUN"
+},
+{
+  "kind": "text",
+  "spelling": "("
+},
+{
+  "kind": "internalParam",
+  "spelling": "x"
+},
+{
+  "kind": "text",
+  "spelling": ")"
+}
+  ],
+  "identifier": {
+"interfaceLanguage": "c",
+"precise": "c:input.h@40@macro@MACRO_FUN"
+  },
+  "kind": {
+"displayName": "Macro",
+"identifier": "c.macro"
+  },
+  "location": {
+"character": 9,
+"line": 3,
+"uri": "file://INPUT_DIR/input.h"
+  },
+  "names": {
+"title": "MACRO_FUN"
+  }
+},
+{
+  "declarationFragments": [
+{
+  "kind": "keyword",
+  "spelling": "#define"
+},
+{
+  "kind": "text",
+  "spelling": " "
+},
+{
+  "kind": "identifier",
+  "spelling": "FUN"
+  

[PATCH] D122511: [clang][extract-api] Add Objective-C protocol support

2022-03-28 Thread Daniel Grumberg via Phabricator via cfe-commits
dang added inline comments.



Comment at: clang/lib/ExtractAPI/ExtractAPIConsumer.cpp:269
+// Collect symbol information.
+StringRef Name = Decl->getName();
+StringRef USR = API.recordUSR(Decl);

I think we should be recording this in StringAllocator



Comment at: clang/test/ExtractAPI/objc_interface.m:17
 //--- input.h
-@protocol Protocol
-@end
+@protocol Protocol;
 

Should this be done in the interfaces patch?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122511

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


[PATCH] D122446: [clang][extract-api] Add Objective-C interface support

2022-03-28 Thread Daniel Grumberg via Phabricator via cfe-commits
dang added inline comments.



Comment at: clang/lib/ExtractAPI/DeclarationFragments.cpp:624-660
 FunctionSignature
 DeclarationFragmentsBuilder::getFunctionSignature(const FunctionDecl *Func) {
   FunctionSignature Signature;
 
   for (const auto *Param : Func->parameters()) {
 StringRef Name = Param->getName();
 DeclarationFragments Fragments = getFragmentsForParam(Param);

If I am not mistaken, these do the same thing but need separate overloads 
because the types don't share a common super class. If this is true we should 
still remove the duplication here. There are two ways of doing this AFAIK:
1. Have a template helper function that does the work and call it from both 
overloads
2. Create a "union" type that contains either of the two alternatives and 
delegates the method calls appropriately.



Comment at: clang/lib/ExtractAPI/ExtractAPIConsumer.cpp:245
+if (const auto *SuperClassDecl = Decl->getSuperClass()) {
+  SuperClass.Name = SuperClassDecl->getObjCRuntimeNameAsString();
+  SuperClass.USR = API.recordUSR(SuperClassDecl);

Shouldn't we be recording this string in the StringAllocator for reuse later. I 
have a patch in progress for macro support that will do the serialization once 
the AST isn't available anymore so we really shouldn't be taking in StringRefs 
for stuff in the AST.



Comment at: clang/lib/ExtractAPI/ExtractAPIConsumer.cpp:455
+for (const auto *Protocol : Protocols)
+  Container->Protocols.emplace_back(Protocol->getName(),
+API.recordUSR(Protocol));

I think we need to allocate these string in the StringAllocator.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122446

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


[PATCH] D122513: [analyzer] Fix "RhsLoc and LhsLoc bitwidth must be same"

2022-03-28 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

I mean, regardless of whether we need to report a warning or an error against 
this code, the AST says that the RHS type and the LHS type are the same. This 
means that the same should have applied to our SVals that represent LHS and 
RHS, rendering `std::max(APSIntType(LHSValue), APSIntType(RHSValue))` 
redundant. So I suspect that the problem is not that we're not `std::max`ing 
hard enough, the problem is that our values weren't correct in the first place, 
so I think you need to take a look at the transfer function corresponding to 
statement

  ImplicitCastExpr 0x118f2040  
'__attribute__((address_space(3))) int *' 

...and see why didn't it cause the type of the SVal to be updated with the 
address space attribute.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122513

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


[PATCH] D122547: [clang] Make Driver tests pass when running with temp dir containing "crt"

2022-03-28 Thread Nico Weber via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG67aea3b65cc5: [clang] Make Driver tests pass when running 
with temp dir containing crt (authored by thakis).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122547

Files:
  clang/test/Driver/dragonfly.c
  clang/test/Driver/freebsd.c
  clang/test/Driver/fuchsia.c
  clang/test/Driver/linux-cross.cpp
  clang/test/Driver/netbsd.c
  clang/test/Driver/openbsd.c


Index: clang/test/Driver/openbsd.c
===
--- clang/test/Driver/openbsd.c
+++ clang/test/Driver/openbsd.c
@@ -38,7 +38,7 @@
 // RUN:   | FileCheck --check-prefix=CHECK-MIPS64EL-LD %s
 // CHECK-LD-R: "-r"
 // CHECK-LD-R-NOT: "-l
-// CHECK-LD-R-NOT: crt{{[^.]+}}.o
+// CHECK-LD-R-NOT: crt{{[^./]+}}.o
 // CHECK-LD-S: clang{{.*}}" "-cc1" "-triple" "i686-pc-openbsd"
 // CHECK-LD-S: ld{{.*}}" "-e" "__start" "--eh-frame-hdr" "-Bdynamic" 
"-dynamic-linker" "{{.*}}ld.so" "-o" "a.out" "{{.*}}crt0.o" "{{.*}}crtbegin.o" 
"-L{{.*}}" "-s" "{{.*}}.o" "-lcompiler_rt" "-lc" "-lcompiler_rt" 
"{{.*}}crtend.o"
 // CHECK-LD-T: clang{{.*}}" "-cc1" "-triple" "i686-pc-openbsd"
Index: clang/test/Driver/netbsd.c
===
--- clang/test/Driver/netbsd.c
+++ clang/test/Driver/netbsd.c
@@ -474,4 +474,4 @@
 // RUN: | FileCheck -check-prefix=RELOCATABLE %s
 // RELOCATABLE: "-r"
 // RELOCATABLE-NOT: "-l
-// RELOCATABLE-NOT: crt{{[^.]+}}.o
+// RELOCATABLE-NOT: crt{{[^./]+}}.o
Index: clang/test/Driver/linux-cross.cpp
===
--- clang/test/Driver/linux-cross.cpp
+++ clang/test/Driver/linux-cross.cpp
@@ -220,4 +220,4 @@
 // RELOCATABLE:  "-L
 // RELOCATABLE-SAME: {{^}}[[SYSROOT]]/usr/lib/gcc/x86_64-linux-gnu/10"
 // RELOCATABLE-NOT:  "-l
-// RELOCATABLE-NOT:  crt{{[^.]+}}.o
+// RELOCATABLE-NOT:  crt{{[^./]+}}.o
Index: clang/test/Driver/fuchsia.c
===
--- clang/test/Driver/fuchsia.c
+++ clang/test/Driver/fuchsia.c
@@ -73,7 +73,7 @@
 // CHECK-RELOCATABLE-NOT: "--build-id"
 // CHECK-RELOCATABLE: "-r"
 // CHECK-RELOCATABLE-NOT: "-l
-// CHECK-RELOCATABLE-NOT: crt{{[^.]+}}.o
+// CHECK-RELOCATABLE-NOT: crt{{[^./]+}}.o
 
 // RUN: %clang %s -### --target=x86_64-unknown-fuchsia -nodefaultlibs 
-fuse-ld=lld 2>&1 \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
Index: clang/test/Driver/freebsd.c
===
--- clang/test/Driver/freebsd.c
+++ clang/test/Driver/freebsd.c
@@ -211,4 +211,4 @@
 // RUN:   --sysroot=%S/Inputs/basic_freebsd64_tree 2>&1 | FileCheck %s 
--check-prefix=RELOCATABLE
 // RELOCATABLE: "-r"
 // RELOCATABLE-NOT: "-l
-// RELOCATABLE-NOT: crt{{[^.]+}}.o
+// RELOCATABLE-NOT: crt{{[^./]+}}.o
Index: clang/test/Driver/dragonfly.c
===
--- clang/test/Driver/dragonfly.c
+++ clang/test/Driver/dragonfly.c
@@ -9,4 +9,4 @@
 // RUN:   2>&1 | FileCheck %s --check-prefix=RELOCATABLE
 // RELOCATABLE: "-r"
 // RELOCATABLE-NOT: "-l
-// RELOCATABLE-NOT: {{.*}}crt{{[^.]+}}.o
+// RELOCATABLE-NOT: {{.*}}crt{{[^./]+}}.o


Index: clang/test/Driver/openbsd.c
===
--- clang/test/Driver/openbsd.c
+++ clang/test/Driver/openbsd.c
@@ -38,7 +38,7 @@
 // RUN:   | FileCheck --check-prefix=CHECK-MIPS64EL-LD %s
 // CHECK-LD-R: "-r"
 // CHECK-LD-R-NOT: "-l
-// CHECK-LD-R-NOT: crt{{[^.]+}}.o
+// CHECK-LD-R-NOT: crt{{[^./]+}}.o
 // CHECK-LD-S: clang{{.*}}" "-cc1" "-triple" "i686-pc-openbsd"
 // CHECK-LD-S: ld{{.*}}" "-e" "__start" "--eh-frame-hdr" "-Bdynamic" "-dynamic-linker" "{{.*}}ld.so" "-o" "a.out" "{{.*}}crt0.o" "{{.*}}crtbegin.o" "-L{{.*}}" "-s" "{{.*}}.o" "-lcompiler_rt" "-lc" "-lcompiler_rt" "{{.*}}crtend.o"
 // CHECK-LD-T: clang{{.*}}" "-cc1" "-triple" "i686-pc-openbsd"
Index: clang/test/Driver/netbsd.c
===
--- clang/test/Driver/netbsd.c
+++ clang/test/Driver/netbsd.c
@@ -474,4 +474,4 @@
 // RUN: | FileCheck -check-prefix=RELOCATABLE %s
 // RELOCATABLE: "-r"
 // RELOCATABLE-NOT: "-l
-// RELOCATABLE-NOT: crt{{[^.]+}}.o
+// RELOCATABLE-NOT: crt{{[^./]+}}.o
Index: clang/test/Driver/linux-cross.cpp
===
--- clang/test/Driver/linux-cross.cpp
+++ clang/test/Driver/linux-cross.cpp
@@ -220,4 +220,4 @@
 // RELOCATABLE:  "-L
 // RELOCATABLE-SAME: {{^}}[[SYSROOT]]/usr/lib/gcc/x86_64-linux-gnu/10"
 // RELOCATABLE-NOT:  "-l
-// RELOCATABLE-NOT:  crt{{[^.]+}}.o
+// RELOCATABLE-NOT:  crt{{[^./]+}}.o
Index: clang/test/Driver/fuchsia.c
===
--- 

[clang] 67aea3b - [clang] Make Driver tests pass when running with temp dir containing "crt"

2022-03-28 Thread Nico Weber via cfe-commits

Author: Nico Weber
Date: 2022-03-28T16:06:43-04:00
New Revision: 67aea3b65cc5417a06712a22a2dfb5f3f7f43eff

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

LOG: [clang] Make Driver tests pass when running with temp dir containing "crt"

In a recent run, temp files got created in /tmp/lit-tmp-2wcrtcx1/foo-xxx.o.
Since the tmp path contained "crt", this made a few tests fail:
http://45.33.8.238/linux/72221/step_7.txt

Not allowing '/' as path of the file name prevents this.

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

Added: 


Modified: 
clang/test/Driver/dragonfly.c
clang/test/Driver/freebsd.c
clang/test/Driver/fuchsia.c
clang/test/Driver/linux-cross.cpp
clang/test/Driver/netbsd.c
clang/test/Driver/openbsd.c

Removed: 




diff  --git a/clang/test/Driver/dragonfly.c b/clang/test/Driver/dragonfly.c
index 6c6d1909fe1b0..683f8797aa621 100644
--- a/clang/test/Driver/dragonfly.c
+++ b/clang/test/Driver/dragonfly.c
@@ -9,4 +9,4 @@
 // RUN:   2>&1 | FileCheck %s --check-prefix=RELOCATABLE
 // RELOCATABLE: "-r"
 // RELOCATABLE-NOT: "-l
-// RELOCATABLE-NOT: {{.*}}crt{{[^.]+}}.o
+// RELOCATABLE-NOT: {{.*}}crt{{[^./]+}}.o

diff  --git a/clang/test/Driver/freebsd.c b/clang/test/Driver/freebsd.c
index 06eb8880f577b..dc0b0bb99b820 100644
--- a/clang/test/Driver/freebsd.c
+++ b/clang/test/Driver/freebsd.c
@@ -211,4 +211,4 @@
 // RUN:   --sysroot=%S/Inputs/basic_freebsd64_tree 2>&1 | FileCheck %s 
--check-prefix=RELOCATABLE
 // RELOCATABLE: "-r"
 // RELOCATABLE-NOT: "-l
-// RELOCATABLE-NOT: crt{{[^.]+}}.o
+// RELOCATABLE-NOT: crt{{[^./]+}}.o

diff  --git a/clang/test/Driver/fuchsia.c b/clang/test/Driver/fuchsia.c
index fdf7f4ef3f11b..3e8d7211a4e96 100644
--- a/clang/test/Driver/fuchsia.c
+++ b/clang/test/Driver/fuchsia.c
@@ -73,7 +73,7 @@
 // CHECK-RELOCATABLE-NOT: "--build-id"
 // CHECK-RELOCATABLE: "-r"
 // CHECK-RELOCATABLE-NOT: "-l
-// CHECK-RELOCATABLE-NOT: crt{{[^.]+}}.o
+// CHECK-RELOCATABLE-NOT: crt{{[^./]+}}.o
 
 // RUN: %clang %s -### --target=x86_64-unknown-fuchsia -nodefaultlibs 
-fuse-ld=lld 2>&1 \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \

diff  --git a/clang/test/Driver/linux-cross.cpp 
b/clang/test/Driver/linux-cross.cpp
index 20d069112acf2..c989ca80938d8 100644
--- a/clang/test/Driver/linux-cross.cpp
+++ b/clang/test/Driver/linux-cross.cpp
@@ -220,4 +220,4 @@
 // RELOCATABLE:  "-L
 // RELOCATABLE-SAME: {{^}}[[SYSROOT]]/usr/lib/gcc/x86_64-linux-gnu/10"
 // RELOCATABLE-NOT:  "-l
-// RELOCATABLE-NOT:  crt{{[^.]+}}.o
+// RELOCATABLE-NOT:  crt{{[^./]+}}.o

diff  --git a/clang/test/Driver/netbsd.c b/clang/test/Driver/netbsd.c
index b549b3cde9b5a..e429729b71c7c 100644
--- a/clang/test/Driver/netbsd.c
+++ b/clang/test/Driver/netbsd.c
@@ -474,4 +474,4 @@
 // RUN: | FileCheck -check-prefix=RELOCATABLE %s
 // RELOCATABLE: "-r"
 // RELOCATABLE-NOT: "-l
-// RELOCATABLE-NOT: crt{{[^.]+}}.o
+// RELOCATABLE-NOT: crt{{[^./]+}}.o

diff  --git a/clang/test/Driver/openbsd.c b/clang/test/Driver/openbsd.c
index 594f90ab3a386..5290b4811fa45 100644
--- a/clang/test/Driver/openbsd.c
+++ b/clang/test/Driver/openbsd.c
@@ -38,7 +38,7 @@
 // RUN:   | FileCheck --check-prefix=CHECK-MIPS64EL-LD %s
 // CHECK-LD-R: "-r"
 // CHECK-LD-R-NOT: "-l
-// CHECK-LD-R-NOT: crt{{[^.]+}}.o
+// CHECK-LD-R-NOT: crt{{[^./]+}}.o
 // CHECK-LD-S: clang{{.*}}" "-cc1" "-triple" "i686-pc-openbsd"
 // CHECK-LD-S: ld{{.*}}" "-e" "__start" "--eh-frame-hdr" "-Bdynamic" 
"-dynamic-linker" "{{.*}}ld.so" "-o" "a.out" "{{.*}}crt0.o" "{{.*}}crtbegin.o" 
"-L{{.*}}" "-s" "{{.*}}.o" "-lcompiler_rt" "-lc" "-lcompiler_rt" 
"{{.*}}crtend.o"
 // CHECK-LD-T: clang{{.*}}" "-cc1" "-triple" "i686-pc-openbsd"



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


[PATCH] D121637: [PowerPC] Fix EmitPPCBuiltinExpr to emit arguments once

2022-03-28 Thread Quinn Pham via Phabricator via cfe-commits
quinnp added inline comments.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:15208
-  for (unsigned i = 0, e = E->getNumArgs(); i != e; i++) {
-if (E->getArg(i)->getType()->isArrayType())
-  Ops.push_back(EmitArrayToPointerDecay(E->getArg(i)).getPointer());

amyk wrote:
> A question I have is do we not need to consider 
> this/`EmitArrayToPointerDecay()` anymore? Was this not used for anything?
Thanks for your comment! I could not find any builtins that used this case in 
the loop for emitting their arguments and did not see any failures when I 
removed it. I am going to look into this now and verify whether or not this is 
needed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121637

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


[PATCH] D122085: Add clang DirectX target support

2022-03-28 Thread Chris Bieneman 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 rGc5e54e275241: Add clang DirectX target support (authored by 
beanz).
Herald added a subscriber: StephenFan.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122085

Files:
  clang/lib/Basic/CMakeLists.txt
  clang/lib/Basic/Targets.cpp
  clang/lib/Basic/Targets/DirectX.cpp
  clang/lib/Basic/Targets/DirectX.h
  clang/test/CodeGenHLSL/basic-target.c
  clang/test/CodeGenHLSL/lit.local.cfg

Index: clang/test/CodeGenHLSL/lit.local.cfg
===
--- /dev/null
+++ clang/test/CodeGenHLSL/lit.local.cfg
@@ -0,0 +1 @@
+config.suffixes = ['.c', '.hlsl']
Index: clang/test/CodeGenHLSL/basic-target.c
===
--- /dev/null
+++ clang/test/CodeGenHLSL/basic-target.c
@@ -0,0 +1,10 @@
+// RUN: %clang -target dxil-pc-shadermodel6.0-pixel -S -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang -target dxil-pc-shadermodel6.0-vertex -S -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang -target dxil-pc-shadermodel6.0-compute -S -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang -target dxil-pc-shadermodel6.0-library -S -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang -target dxil-pc-shadermodel6.0-hull -S -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang -target dxil-pc-shadermodel6.0-domain -S -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang -target dxil-pc-shadermodel6.0-geometry -S -emit-llvm -o - %s | FileCheck %s
+
+// CHECK: target datalayout = "e-m:e-p:32:32-i1:32-i8:8-i16:16-i32:32-i64:64-f16:16-f32:32-f64:64-n8:16:32:64"
+// CHECK: target triple = "dxil-pc-shadermodel6.0-{{[a-z]+}}"
Index: clang/lib/Basic/Targets/DirectX.h
===
--- /dev/null
+++ clang/lib/Basic/Targets/DirectX.h
@@ -0,0 +1,92 @@
+//===--- DirectX.h - Declare DirectX target feature support -*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file declares DXIL TargetInfo objects.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_LIB_BASIC_TARGETS_DIRECTX_H
+#define LLVM_CLANG_LIB_BASIC_TARGETS_DIRECTX_H
+#include "clang/Basic/TargetInfo.h"
+#include "clang/Basic/TargetOptions.h"
+#include "llvm/ADT/Triple.h"
+#include "llvm/Support/Compiler.h"
+
+namespace clang {
+namespace targets {
+
+static const unsigned DirectXAddrSpaceMap[] = {
+0, // Default
+1, // opencl_global
+3, // opencl_local
+2, // opencl_constant
+0, // opencl_private
+4, // opencl_generic
+5, // opencl_global_device
+6, // opencl_global_host
+0, // cuda_device
+0, // cuda_constant
+0, // cuda_shared
+// SYCL address space values for this map are dummy
+0, // sycl_global
+0, // sycl_global_device
+0, // sycl_global_host
+0, // sycl_local
+0, // sycl_private
+0, // ptr32_sptr
+0, // ptr32_uptr
+0  // ptr64
+};
+
+class LLVM_LIBRARY_VISIBILITY DirectXTargetInfo : public TargetInfo {
+public:
+  DirectXTargetInfo(const llvm::Triple , const TargetOptions &)
+  : TargetInfo(Triple) {
+TLSSupported = false;
+VLASupported = false;
+LongWidth = LongAlign = 64;
+AddrSpaceMap = 
+UseAddrSpaceMapMangling = true;
+HasLegalHalfType = true;
+HasFloat16 = true;
+NoAsmVariants = true;
+resetDataLayout("e-m:e-p:32:32-i1:32-i8:8-i16:16-i32:32-i64:64-f16:16-f32:"
+"32-f64:64-n8:16:32:64");
+  }
+
+  void getTargetDefines(const LangOptions ,
+MacroBuilder ) const override;
+
+  bool hasFeature(StringRef Feature) const override {
+return Feature == "directx";
+  }
+
+  ArrayRef getTargetBuiltins() const override { return None; }
+
+  const char *getClobbers() const override { return ""; }
+
+  ArrayRef getGCCRegNames() const override { return None; }
+
+  bool validateAsmConstraint(const char *,
+ TargetInfo::ConstraintInfo ) const override {
+return true;
+  }
+
+  ArrayRef getGCCRegAliases() const override {
+return None;
+  }
+
+  BuiltinVaListKind getBuiltinVaListKind() const override {
+return TargetInfo::VoidPtrBuiltinVaList;
+  }
+};
+
+} // namespace targets
+} // namespace clang
+
+#endif // LLVM_CLANG_LIB_BASIC_TARGETS_DIRECTX_H
Index: clang/lib/Basic/Targets/DirectX.cpp
===
--- /dev/null
+++ clang/lib/Basic/Targets/DirectX.cpp
@@ -0,0 +1,22 @@
+//===--- DirectX.cpp - Implement DirectX target feature 

[clang] c5e54e2 - Add clang DirectX target support

2022-03-28 Thread Chris Bieneman via cfe-commits

Author: Chris Bieneman
Date: 2022-03-28T15:00:50-05:00
New Revision: c5e54e275241f0575ed0c9fe5c8c65299dd0bd0f

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

LOG: Add clang DirectX target support

This change adds a stub DirectX target for clang to enable targeting
dxil targets.

Reviewed By: pete

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

Added: 
clang/lib/Basic/Targets/DirectX.cpp
clang/lib/Basic/Targets/DirectX.h
clang/test/CodeGenHLSL/basic-target.c
clang/test/CodeGenHLSL/lit.local.cfg

Modified: 
clang/lib/Basic/CMakeLists.txt
clang/lib/Basic/Targets.cpp

Removed: 




diff  --git a/clang/lib/Basic/CMakeLists.txt b/clang/lib/Basic/CMakeLists.txt
index 40de9433a4dde..12ed97b99b45f 100644
--- a/clang/lib/Basic/CMakeLists.txt
+++ b/clang/lib/Basic/CMakeLists.txt
@@ -75,6 +75,7 @@ add_clang_library(clangBasic
   Targets/ARM.cpp
   Targets/AVR.cpp
   Targets/BPF.cpp
+  Targets/DirectX.cpp
   Targets/Hexagon.cpp
   Targets/Lanai.cpp
   Targets/Le64.cpp

diff  --git a/clang/lib/Basic/Targets.cpp b/clang/lib/Basic/Targets.cpp
index ff8dad2db0da2..641345452cfe3 100644
--- a/clang/lib/Basic/Targets.cpp
+++ b/clang/lib/Basic/Targets.cpp
@@ -19,6 +19,7 @@
 #include "Targets/ARM.h"
 #include "Targets/AVR.h"
 #include "Targets/BPF.h"
+#include "Targets/DirectX.h"
 #include "Targets/Hexagon.h"
 #include "Targets/Lanai.h"
 #include "Targets/Le64.h"
@@ -649,6 +650,8 @@ TargetInfo *AllocateTarget(const llvm::Triple ,
 return nullptr;
 }
 
+  case llvm::Triple::dxil:
+return new DirectXTargetInfo(Triple,Opts);
   case llvm::Triple::renderscript32:
 return new LinuxTargetInfo(Triple, Opts);
   case llvm::Triple::renderscript64:

diff  --git a/clang/lib/Basic/Targets/DirectX.cpp 
b/clang/lib/Basic/Targets/DirectX.cpp
new file mode 100644
index 0..0dd27e6e93b33
--- /dev/null
+++ b/clang/lib/Basic/Targets/DirectX.cpp
@@ -0,0 +1,22 @@
+//===--- DirectX.cpp - Implement DirectX target feature support 
---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file implements DirectX TargetInfo objects.
+//
+//===--===//
+
+#include "DirectX.h"
+#include "Targets.h"
+
+using namespace clang;
+using namespace clang::targets;
+
+void DirectXTargetInfo::getTargetDefines(const LangOptions ,
+ MacroBuilder ) const {
+  DefineStd(Builder, "DIRECTX", Opts);
+}

diff  --git a/clang/lib/Basic/Targets/DirectX.h 
b/clang/lib/Basic/Targets/DirectX.h
new file mode 100644
index 0..90ef1dfa55c89
--- /dev/null
+++ b/clang/lib/Basic/Targets/DirectX.h
@@ -0,0 +1,92 @@
+//===--- DirectX.h - Declare DirectX target feature support -*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file declares DXIL TargetInfo objects.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_LIB_BASIC_TARGETS_DIRECTX_H
+#define LLVM_CLANG_LIB_BASIC_TARGETS_DIRECTX_H
+#include "clang/Basic/TargetInfo.h"
+#include "clang/Basic/TargetOptions.h"
+#include "llvm/ADT/Triple.h"
+#include "llvm/Support/Compiler.h"
+
+namespace clang {
+namespace targets {
+
+static const unsigned DirectXAddrSpaceMap[] = {
+0, // Default
+1, // opencl_global
+3, // opencl_local
+2, // opencl_constant
+0, // opencl_private
+4, // opencl_generic
+5, // opencl_global_device
+6, // opencl_global_host
+0, // cuda_device
+0, // cuda_constant
+0, // cuda_shared
+// SYCL address space values for this map are dummy
+0, // sycl_global
+0, // sycl_global_device
+0, // sycl_global_host
+0, // sycl_local
+0, // sycl_private
+0, // ptr32_sptr
+0, // ptr32_uptr
+0  // ptr64
+};
+
+class LLVM_LIBRARY_VISIBILITY DirectXTargetInfo : public TargetInfo {
+public:
+  DirectXTargetInfo(const llvm::Triple , const TargetOptions &)
+  : TargetInfo(Triple) {
+TLSSupported = false;
+VLASupported = false;
+LongWidth = LongAlign = 64;
+AddrSpaceMap = 
+UseAddrSpaceMapMangling = true;
+HasLegalHalfType = true;
+HasFloat16 = true;
+NoAsmVariants = true;
+

[PATCH] D122608: Fix behavior of ifuncs with 'used' extern "C" static functions

2022-03-28 Thread Erich Keane via Phabricator via cfe-commits
erichkeane updated this revision to Diff 418682.
erichkeane marked an inline comment as done.
erichkeane added a comment.

Do the two comment fixups aaron suggested.


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

https://reviews.llvm.org/D122608

Files:
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGenCXX/externc-ifunc-resolver.cpp
  clang/test/SemaCXX/externc-ifunc-resolver.cpp

Index: clang/test/SemaCXX/externc-ifunc-resolver.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/externc-ifunc-resolver.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -emit-llvm-only -verify %s
+
+extern "C" {
+  __attribute__((used)) static void *resolve_foo() { return 0; }
+  namespace NS {
+__attribute__((used)) static void *resolve_foo() { return 0; }
+  }
+  __attribute__((ifunc("resolve_foo"))) void foo(); // expected-error{{ifunc must point to a defined function}}
+}
+
Index: clang/test/CodeGenCXX/externc-ifunc-resolver.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/externc-ifunc-resolver.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -o - %s | FileCheck %s
+
+extern "C" {
+  __attribute__((used)) static void *resolve_foo() { return 0; }
+  __attribute__((ifunc("resolve_foo"))) void foo();
+}
+
+// CHECK: @resolve_foo = internal alias i8* (), i8* ()* @_ZL11resolve_foov
+// CHECK: @foo = ifunc void (), bitcast (i8* ()* @_ZL11resolve_foov to void ()* ()*)
+// CHECK: define internal noundef i8* @_ZL11resolve_foov()
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -507,7 +507,6 @@
   EmitVTablesOpportunistically();
   applyGlobalValReplacements();
   applyReplacements();
-  checkAliases();
   emitMultiVersionFunctions();
   EmitCXXGlobalInitFunc();
   EmitCXXGlobalCleanUpFunc();
@@ -539,6 +538,7 @@
   EmitCtorList(GlobalDtors, "llvm.global_dtors");
   EmitGlobalAnnotations();
   EmitStaticExternCAliases();
+  checkAliases();
   EmitDeferredUnusedCoverageMappings();
   CodeGenPGO(*this).setValueProfilingFlag(getModule());
   if (CoverageMapping)
@@ -6315,6 +6315,27 @@
   GlobalMetadata->addOperand(llvm::MDNode::get(CGM.getLLVMContext(), Ops));
 }
 
+/// If all uses of the GV are from an IFunc resolver, which can happen when the
+/// IFunc resolver is a static-function, but the name ends up being different,
+/// return the IFunc so it can have its resolver replaced with the correct
+/// 'alias' from EmitStaticExternCAliases.
+static llvm::GlobalIFunc *getIFuncFromResolver(llvm::GlobalValue *GV) {
+  // If there is more than 1 use, I don't really know what we can do.
+  // EmitStaticExternCAliases won't be able to do anything, and the ifunc
+  // diagnostic will have to catch this.
+  if (!GV || std::distance(GV->use_begin(), GV->use_end()) != 1)
+return nullptr;
+
+  llvm::User *U = GV->use_begin()->getUser();
+  if (auto *IFunc = dyn_cast_or_null(U)) {
+assert(IFunc->getResolver() == GV && "Didn't find the resolver use?");
+assert(GV->isDeclaration() && isa(GV) &&
+   "Resolver is defined or not a function?");
+return IFunc;
+  }
+  return nullptr;
+}
+
 /// For each function which is declared within an extern "C" region and marked
 /// as 'used', but has internal linkage, create an alias from the unmangled
 /// name to the mangled name if possible. People expect to be able to refer
@@ -6326,8 +6347,35 @@
   for (auto  : StaticExternCValues) {
 IdentifierInfo *Name = I.first;
 llvm::GlobalValue *Val = I.second;
-if (Val && !getModule().getNamedValue(Name->getName()))
-  addCompilerUsedGlobal(llvm::GlobalAlias::create(Name->getName(), Val));
+llvm::GlobalValue *ExistingElem =
+getModule().getNamedValue(Name->getName());
+llvm::GlobalIFunc *IFunc = getIFuncFromResolver(ExistingElem);
+
+if (Val && (!ExistingElem || IFunc)) {
+  // If the IFunc refers to this existing element we have to delete it
+  // FIRST, otherwise the 'name' of the new element will be wrong.
+  llvm::Type *ResolverTy = nullptr;
+  if (IFunc) {
+ResolverTy = IFunc->getResolverFunction()->getFunctionType();
+IFunc->setResolver(nullptr);
+assert(ExistingElem && "Got IFunc without an existing element?");
+ExistingElem->eraseFromParent();
+  }
+
+  auto *Alias = llvm::GlobalAlias::create(Name->getName(), Val);
+  addCompilerUsedGlobal(Alias);
+
+  // Make sure we 'fix up' the IFunc's resolver. Despite it having been the
+  // 'right' name, we have to make sure we reassign the resolver to the
+  // original static function, since IFuncs aren't allowed to refer to the
+  // alias directly. So, we have to de-alias it here. We have to make sure
+  // the correct bitcasts happen, so we have to re-look up the 

[PATCH] D122608: Fix behavior of ifuncs with 'used' extern "C" static functions

2022-03-28 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a reviewer: rjmccall.
aaron.ballman added a subscriber: rjmccall.
aaron.ballman added a comment.

CodeGen is not my wheelhouse, so I've added @rjmccall in case he spots 
something I've missed. This seems reasonable to me though.




Comment at: clang/lib/CodeGen/CodeGenModule.cpp:6318
 
+/// IF all uses of the GV are from an IFunc resolver, which can happen when the
+/// IFunc resolver is a static-function, but the name ends up being different,





Comment at: clang/lib/CodeGen/CodeGenModule.cpp:6371
+  // original static function, since IFuncs aren't allowed to refer to the
+  // alias directly.  SO, we have to de-alias it here.  We have to make 
sure
+  // the correct bitcasts happen, so we have to re-look up the function.




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

https://reviews.llvm.org/D122608

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


[PATCH] D122378: [doc] Rely on tblgen to dump supported options value when generating doc

2022-03-28 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM, thank you for this!


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

https://reviews.llvm.org/D122378

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


[PATCH] D122425: Pass -disable-llvm-passes to avoid running llvm passes

2022-03-28 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added a comment.

Sorry, I didn't notice you left a comment until after committing the patch. I 
agree that `-O1` can be removed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122425

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


[PATCH] D122573: [TBAA] Emit distinct TBAA tags for pointers with different depths,types.

2022-03-28 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

I'm a little skeptical about making TBAA more aggressive.  In most situations, 
we're probably talking about tiny performance gains, and currently there's no 
good way to check whether a codebase suffers from type punning issues (either 
with compile-time analysis or runtime instrumentation).  Probably LLVM itself 
does, but we have no way of knowing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122573

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


[PATCH] D122425: Pass -disable-llvm-passes to avoid running llvm passes

2022-03-28 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added a comment.

You should answer any review comments before any commit.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122425

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


[clang] a621b0a - [clang][NFC] Remove unused parameter in `Sema::ActOnDuplicateDefinition`.

2022-03-28 Thread Volodymyr Sapsai via cfe-commits

Author: Volodymyr Sapsai
Date: 2022-03-28T12:07:28-07:00
New Revision: a621b0af9cd03bce079a2a6f4d72a6471ca1bb85

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

LOG: [clang][NFC] Remove unused parameter in `Sema::ActOnDuplicateDefinition`.

Added: 


Modified: 
clang/include/clang/Sema/Sema.h
clang/lib/Parse/ParseDecl.cpp
clang/lib/Parse/ParseDeclCXX.cpp
clang/lib/Sema/SemaDecl.cpp

Removed: 




diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 817df4e108433..53ac1d011d9e1 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -3254,8 +3254,7 @@ class Sema final {
   /// Perform ODR-like check for C/ObjC when merging tag types from modules.
   /// Differently from C++, actually parse the body and reject / error out
   /// in case of a structural mismatch.
-  bool ActOnDuplicateDefinition(DeclSpec , Decl *Prev,
-SkipBodyInfo );
+  bool ActOnDuplicateDefinition(Decl *Prev, SkipBodyInfo );
 
   typedef void *SkippedDefinitionContext;
 

diff  --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index c0fb7e0df1b61..f07758197205f 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -4870,7 +4870,7 @@ void Parser::ParseEnumSpecifier(SourceLocation StartLoc, 
DeclSpec ,
 Decl *D = SkipBody.CheckSameAsPrevious ? SkipBody.New : TagDecl;
 ParseEnumBody(StartLoc, D);
 if (SkipBody.CheckSameAsPrevious &&
-!Actions.ActOnDuplicateDefinition(DS, TagDecl, SkipBody)) {
+!Actions.ActOnDuplicateDefinition(TagDecl, SkipBody)) {
   DS.SetTypeSpecError();
   return;
 }

diff  --git a/clang/lib/Parse/ParseDeclCXX.cpp 
b/clang/lib/Parse/ParseDeclCXX.cpp
index 1bb43f56422d7..342ee896bee18 100644
--- a/clang/lib/Parse/ParseDeclCXX.cpp
+++ b/clang/lib/Parse/ParseDeclCXX.cpp
@@ -2049,8 +2049,7 @@ void Parser::ParseClassSpecifier(tok::TokenKind 
TagTokKind,
   // Parse the definition body.
   ParseStructUnionBody(StartLoc, TagType, cast(D));
   if (SkipBody.CheckSameAsPrevious &&
-  !Actions.ActOnDuplicateDefinition(DS, TagOrTempResult.get(),
-SkipBody)) {
+  !Actions.ActOnDuplicateDefinition(TagOrTempResult.get(), SkipBody)) {
 DS.SetTypeSpecError();
 return;
   }

diff  --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 4051ab29fb26f..298d4fc17617b 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -16703,8 +16703,7 @@ void Sema::ActOnTagStartDefinition(Scope *S, Decl 
*TagD) {
   AddPushedVisibilityAttribute(Tag);
 }
 
-bool Sema::ActOnDuplicateDefinition(DeclSpec , Decl *Prev,
-SkipBodyInfo ) {
+bool Sema::ActOnDuplicateDefinition(Decl *Prev, SkipBodyInfo ) {
   if (!hasStructuralCompatLayout(Prev, SkipBody.New))
 return false;
 



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


[PATCH] D122608: Fix behavior of ifuncs with 'used' extern "C" static functions

2022-03-28 Thread Erich Keane via Phabricator via cfe-commits
erichkeane created this revision.
erichkeane added reviewers: tahonermann, aaron.ballman, cor3ntin.
Herald added a project: All.
erichkeane requested review of this revision.

We expect that `extern "C"` static functions to be usable in things like
inline assembly, as well as ifuncs:
See the bug report here: https://github.com/llvm/llvm-project/issues/54549

However, we were diagnosing this as 'not defined', because the
ifunc's attempt to look up its resolver would generate a declared IR
function.

Additionally, as background, the way we allow these static extern "C"
functions to work in inline assembly is by making an alias with the C
mangling in MOST situations to the version we emit with
internal-linkage/mangling.

The problem here was multi-fold: First- We generated the alias after the
ifunc was checked, so the function by that name didn't exist yet.
Second, the ifunc's generation caused a symbol to exist under the name
of the alias already (the declared function above), which suppressed the
alias generation.

This patch fixes all of this by moving the checking of ifuncs/CFE aliases
until AFTER we have generated the extern-C alias.  Then, it does a
'fixup' around the GlobalIFunc to make sure we correct the reference.


https://reviews.llvm.org/D122608

Files:
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGenCXX/externc-ifunc-resolver.cpp
  clang/test/SemaCXX/externc-ifunc-resolver.cpp

Index: clang/test/SemaCXX/externc-ifunc-resolver.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/externc-ifunc-resolver.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -emit-llvm-only -verify %s
+
+extern "C" {
+  __attribute__((used)) static void *resolve_foo() { return 0; }
+  namespace NS {
+__attribute__((used)) static void *resolve_foo() { return 0; }
+  }
+  __attribute__((ifunc("resolve_foo"))) void foo(); // expected-error{{ifunc must point to a defined function}}
+}
+
Index: clang/test/CodeGenCXX/externc-ifunc-resolver.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/externc-ifunc-resolver.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -o - %s | FileCheck %s
+
+extern "C" {
+  __attribute__((used)) static void *resolve_foo() { return 0; }
+  __attribute__((ifunc("resolve_foo"))) void foo();
+}
+
+// CHECK: @resolve_foo = internal alias i8* (), i8* ()* @_ZL11resolve_foov
+// CHECK: @foo = ifunc void (), bitcast (i8* ()* @_ZL11resolve_foov to void ()* ()*)
+// CHECK: define internal noundef i8* @_ZL11resolve_foov()
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -507,7 +507,6 @@
   EmitVTablesOpportunistically();
   applyGlobalValReplacements();
   applyReplacements();
-  checkAliases();
   emitMultiVersionFunctions();
   EmitCXXGlobalInitFunc();
   EmitCXXGlobalCleanUpFunc();
@@ -539,6 +538,7 @@
   EmitCtorList(GlobalDtors, "llvm.global_dtors");
   EmitGlobalAnnotations();
   EmitStaticExternCAliases();
+  checkAliases();
   EmitDeferredUnusedCoverageMappings();
   CodeGenPGO(*this).setValueProfilingFlag(getModule());
   if (CoverageMapping)
@@ -6315,6 +6315,27 @@
   GlobalMetadata->addOperand(llvm::MDNode::get(CGM.getLLVMContext(), Ops));
 }
 
+/// IF all uses of the GV are from an IFunc resolver, which can happen when the
+/// IFunc resolver is a static-function, but the name ends up being different,
+/// return the IFunc so it can have its resolver replaced with the correct
+/// 'alias' from EmitStaticExternCAliases.
+static llvm::GlobalIFunc *getIFuncFromResolver(llvm::GlobalValue *GV) {
+  // If there is more than 1 use, I don't really know what we can do.
+  // EmitStaticExternCAliases won't be able to do anything, and the ifunc
+  // diagnostic will have to catch this.
+  if (!GV || std::distance(GV->use_begin(), GV->use_end()) != 1)
+return nullptr;
+
+  llvm::User *U = GV->use_begin()->getUser();
+  if (auto *IFunc = dyn_cast_or_null(U)) {
+assert(IFunc->getResolver() == GV && "Didn't find the resolver use?");
+assert(GV->isDeclaration() && isa(GV) &&
+   "Resolver is defined or not a function?");
+return IFunc;
+  }
+  return nullptr;
+}
+
 /// For each function which is declared within an extern "C" region and marked
 /// as 'used', but has internal linkage, create an alias from the unmangled
 /// name to the mangled name if possible. People expect to be able to refer
@@ -6326,8 +6347,35 @@
   for (auto  : StaticExternCValues) {
 IdentifierInfo *Name = I.first;
 llvm::GlobalValue *Val = I.second;
-if (Val && !getModule().getNamedValue(Name->getName()))
-  addCompilerUsedGlobal(llvm::GlobalAlias::create(Name->getName(), Val));
+llvm::GlobalValue *ExistingElem =
+getModule().getNamedValue(Name->getName());
+llvm::GlobalIFunc *IFunc = 

[PATCH] D122542: [flang][driver] Make --version and -version consistent with clang

2022-03-28 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski added inline comments.



Comment at: clang/include/clang/Driver/Options.td:5756
+
+}
+

ekieri wrote:
> awarzynski wrote:
> > [nit] IMHO this file lacks comments, hence the suggestion :) 
> Sure!
> 
> On the topic of this file's structure, I found the nested "let Flags" quite 
> confusing -- Setting "Flags" inside "def version" does not work, as it would 
> be overwritten by the outer "let Flags" on line 4820. But that is a different 
> patch.
> On the topic of this file's structure, I found the nested "let Flags" quite 
> confusing -- Setting "Flags" inside "def version" does not work, as it would 
> be overwritten by the outer "let Flags" on line 4820. But that is a different 
> patch.

Fixing that is high on my TODO list, just never high enough :( Happy to review 
if you get a chance to prepare something! ;-) 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122542

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


[PATCH] D122586: Fix template instantiation of UDLs

2022-03-28 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman closed this revision.
aaron.ballman added a comment.

Thanks for the reviews! I've commit in ca844ab01c3f9410ceca967c09f809400950beae 
.


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

https://reviews.llvm.org/D122586

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


  1   2   3   >