[PATCH] D157813: [VE][Clang] Change to enable VPU flag by default

2023-08-14 Thread Kazushi Marukawa via Phabricator via cfe-commits
kaz7 added reviewers: MaskRay, jdoerfert, awarzynski.
kaz7 added a comment.

I randamly added reviewrs who review code related to feature flags and features 
group in clang.  I appreciate if some of you guys have a time to check this 
patch too.  Thank you so much.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157813

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


[PATCH] D146054: [RISCV] Add --print-supported-extensions support

2023-08-14 Thread Brandon Wu via Phabricator via cfe-commits
4vtomat updated this revision to Diff 550185.
4vtomat added a comment.

1. Apply clang-format for this patch
2. Replace FileCheck --implicit-check-not=warning: with %clang -Werror


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146054

Files:
  clang/include/clang/Driver/Options.td
  clang/include/clang/Frontend/FrontendOptions.h
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/print-supported-extensions.c
  clang/tools/driver/cc1_main.cpp
  llvm/include/llvm/Support/RISCVISAInfo.h
  llvm/lib/Support/RISCVISAInfo.cpp

Index: llvm/lib/Support/RISCVISAInfo.cpp
===
--- llvm/lib/Support/RISCVISAInfo.cpp
+++ llvm/lib/Support/RISCVISAInfo.cpp
@@ -208,6 +208,29 @@
 #endif
 }
 
+void llvm::riscvExtensionsHelp() {
+  outs() << "All available -march extensions for RISC-V\n\n";
+  outs() << '\t' << left_justify("Name", 20) << "Version\n";
+
+  RISCVISAInfo::OrderedExtensionMap ExtMap;
+  for (const auto  : SupportedExtensions)
+ExtMap[E.Name] = {E.Version.Major, E.Version.Minor};
+  for (const auto  : ExtMap)
+outs() << format("\t%-20s%d.%d\n", E.first.c_str(), E.second.MajorVersion,
+ E.second.MinorVersion);
+
+  outs() << "\nExperimental extensions\n";
+  ExtMap.clear();
+  for (const auto  : SupportedExperimentalExtensions)
+ExtMap[E.Name] = {E.Version.Major, E.Version.Minor};
+  for (const auto  : ExtMap)
+outs() << format("\t%-20s%d.%d\n", E.first.c_str(), E.second.MajorVersion,
+ E.second.MinorVersion);
+
+  outs() << "\nUse -march to specify the target's extension.\n"
+"For example, clang -march=rv32i_v1p0\n";
+}
+
 static bool stripExperimentalPrefix(StringRef ) {
   return Ext.consume_front("experimental-");
 }
Index: llvm/include/llvm/Support/RISCVISAInfo.h
===
--- llvm/include/llvm/Support/RISCVISAInfo.h
+++ llvm/include/llvm/Support/RISCVISAInfo.h
@@ -22,6 +22,8 @@
   unsigned MinorVersion;
 };
 
+void riscvExtensionsHelp();
+
 class RISCVISAInfo {
 public:
   RISCVISAInfo(const RISCVISAInfo &) = delete;
Index: clang/tools/driver/cc1_main.cpp
===
--- clang/tools/driver/cc1_main.cpp
+++ clang/tools/driver/cc1_main.cpp
@@ -38,6 +38,7 @@
 #include "llvm/Support/ManagedStatic.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Process.h"
+#include "llvm/Support/RISCVISAInfo.h"
 #include "llvm/Support/Signals.h"
 #include "llvm/Support/TargetSelect.h"
 #include "llvm/Support/TimeProfiler.h"
@@ -221,6 +222,10 @@
   if (Clang->getFrontendOpts().PrintSupportedCPUs)
 return PrintSupportedCPUs(Clang->getTargetOpts().Triple);
 
+  // --print-supported-extensions takes priority over the actual compilation.
+  if (Clang->getFrontendOpts().PrintSupportedExtensions)
+return llvm::riscvExtensionsHelp(), 0;
+
   // Infer the builtin include path if unspecified.
   if (Clang->getHeaderSearchOpts().UseBuiltinIncludes &&
   Clang->getHeaderSearchOpts().ResourceDir.empty())
Index: clang/test/Driver/print-supported-extensions.c
===
--- /dev/null
+++ clang/test/Driver/print-supported-extensions.c
@@ -0,0 +1,129 @@
+/// Test that --print-supported-extensions lists supported extensions.
+
+// REQUIRES: riscv-registered-target
+
+// RUN: %clang -Werror --target=riscv64 --print-supported-extensions 2>&1 | \
+// RUN:   FileCheck --strict-whitespace --match-full-lines %s
+
+//   CHECK:Target: riscv64
+//   CHECK:All available -march extensions for RISC-V
+//   CHECK:	NameVersion
+//  CHECK-NEXT:	i   2.1
+//  CHECK-NEXT:	e   2.0
+//  CHECK-NEXT:	m   2.0
+//  CHECK-NEXT:	a   2.1
+//  CHECK-NEXT:	f   2.2
+//  CHECK-NEXT:	d   2.2
+//  CHECK-NEXT:	c   2.0
+//  CHECK-NEXT:	v   1.0
+//  CHECK-NEXT:	h   1.0
+//  CHECK-NEXT:	zicbom  1.0
+//  CHECK-NEXT:	zicbop  1.0
+//  CHECK-NEXT:	zicboz  1.0
+//  CHECK-NEXT:	zicntr  1.0
+//  CHECK-NEXT:	zicsr   2.0
+//  CHECK-NEXT:	zifencei2.0
+//  CHECK-NEXT:	zihintpause 2.0
+//  CHECK-NEXT:	zihpm   1.0
+//  CHECK-NEXT:	zmmul   1.0
+//  CHECK-NEXT:	zawrs   1.0
+//  CHECK-NEXT:	zfh 1.0
+//  CHECK-NEXT:	zfhmin  1.0
+//  CHECK-NEXT:	zfinx   1.0
+//  CHECK-NEXT:	zdinx   1.0
+//  CHECK-NEXT:	zca 1.0
+//  CHECK-NEXT:	zcb 1.0
+//  CHECK-NEXT:	zcd 1.0
+//  CHECK-NEXT:	zce 1.0
+//  CHECK-NEXT:	zcf 1.0
+//  CHECK-NEXT:	zcmp1.0
+//  CHECK-NEXT:	zcmt

[PATCH] D157833: [C++20] [Coroutines] Mark await_suspend as noinline if the awaiter is not empty

2023-08-14 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu marked 4 inline comments as done.
ChuanqiXu added a comment.

Address comments. Thanks for reviewing.




Comment at: clang/lib/CodeGen/CGCall.cpp:5496
+  // execution of the await_suspend. To achieve this, we need to prevent the
+  // await_suspend get inlined before CoroSplit pass.
+  //

rjmccall wrote:
> Suggestion:
> 
> > The `await_suspend` call performed by `co_await` is essentially asynchronous
> > to the execution of the coroutine.  Inlining it normally into an unsplit 
> > coroutine
> > can cause miscompilation because the coroutine CFG misrepresents the true
> > control flow of the program: things that happen in the `await_suspend` are 
> > not
> > guaranteed to happen prior to the resumption of the coroutine, and things 
> > that
> > happen after the resumption of the coroutine (including its exit and the
> > potential deallocation of the coroutine frame) are not guaranteed to happen
> > only after the end of `await_suspend`.
> >
> > The short-term solution to this problem is to mark the call as uninlinable.
> > But we don't want to do this if the call is known to be trivial, which is 
> > very
> > common.
> 
> We don't need to get into the long-term solution here, but I'd suggest a 
> pattern
> like:
> 
> ```
>   call @llvm.coro.await_suspend(token %suspend, ptr %awaiter, ptr 
> @awaitSuspendFn)
> ```
> 
> and then we just replace that with the normal call during function splitting. 
>  I guess we'd have to make sure we did everything right with the return 
> values and exceptions, which might be a pain.  But it does have the really 
> nice property that we could move all of this "is it trivial" analysis into 
> the LLVM passes: if we decide that it's safe to inline the function before 
> splitting (e.g. `awaitSuspendFn` doesn't contain any uses of `this`), then 
> the optimization is as simple as doing the replacement in CoroEarly instead 
> of after splitting.
Got it. The proposed long term solution looks pretty good indeed.



Comment at: clang/lib/CodeGen/CGCall.cpp:5504
+  // pass.
+  if (inSuspendBlock() && maySuspendLeakCoroutineHandle())
+Attrs = Attrs.addFnAttribute(getLLVMContext(), llvm::Attribute::NoInline);

nit: I thought to simplify this to `maySuspendLeakCoroutineHandle()`. But I 
feel the current combination reads better. I read it as "we are in a suspend 
block and it may leak the coroutine handle". I just feel it has better 
readability.



Comment at: clang/lib/CodeGen/CGCoroutine.cpp:165
+// to give users better user experience. It doesn't matter with the
+// correctness but 1 byte memory overhead.
+#ifdef NDEBUG

rjmccall wrote:
> I'm sorry, but I'm really confused about what you're doing here.  In general, 
> we really don't want compiler behavior to change based on whether we're 
> running a release version of the compiler.  And this would be disabling the 
> optimization completely in release builds?
> 
> Are you maybe trying to check whether we're doing an unoptimized build of the 
> *program*?  That's `CodeGenOpts.OptimizationLevel == 0`.
> I'm sorry, but I'm really confused about what you're doing here. In general, 
> we really don't want compiler behavior to change based on whether we're 
> running a release version of the compiler. And this would be disabling the 
> optimization completely in release builds?

I was trying to generate the better code at much as I can. But as your advice 
shows, it is clearly much better to do the analysis in the middle end. So let's 
try to improve it in the middle end and leave it as is in the frontend.

> Are you maybe trying to check whether we're doing an unoptimized build of the 
> *program*? That's CodeGenOpts.OptimizationLevel == 0.

Given now it is pretty simple, I think we can omit the check.



Comment at: clang/lib/CodeGen/CodeGenFunction.h:351
 
+  bool maySuspendLeakCoroutineHandle() const {
+return isCoroutine() && CurCoro.MaySuspendLeak;

rjmccall wrote:
> (1) I'd prefer that we use the term "escape" over "leak" here.
> (2) None of these bugs require us to escape the coroutine handle.
> 
> Maybe `mustPreventInliningOfAwaitSuspend`?  It's not really a general 
> property.
Used the term `escaped` instead of `leak`.

> (2) None of these bugs require us to escape the coroutine handle.

I feel like from the perspective of coroutine itself, it looks like the 
coroutine handle escapes from the coroutine by await_suspend. So I feel this 
may not be a bad name. Also as the above comments shows, we'd like to improve 
this in the middle end finally, so these names would be removed in the end of 
the day too. 


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

https://reviews.llvm.org/D157833

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


[PATCH] D157833: [C++20] [Coroutines] Mark await_suspend as noinline if the awaiter is not empty

2023-08-14 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu updated this revision to Diff 550181.
ChuanqiXu added a comment.

Address comments:

- Remove the complicated TypeVisitor, use the simple 
`getNonReferenceType()->getAsCXXRecordDecl()` form instead.
- Reword `*leak*` to `*escape*`.
- Use the suggested comments.


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

https://reviews.llvm.org/D157833

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGCoroutine.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/test/CodeGenCoroutines/coro-awaiter-noinline-suspend.cpp
  clang/test/CodeGenCoroutines/pr56301.cpp

Index: clang/test/CodeGenCoroutines/pr56301.cpp
===
--- /dev/null
+++ clang/test/CodeGenCoroutines/pr56301.cpp
@@ -0,0 +1,85 @@
+// An end-to-end test to make sure things get processed correctly.
+// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -emit-llvm -o - %s -O3 | \
+// RUN: FileCheck %s
+
+#include "Inputs/coroutine.h"
+
+struct SomeAwaitable {
+  // Resume the supplied handle once the awaitable becomes ready,
+  // returning a handle that should be resumed now for the sake of symmetric transfer.
+  // If the awaitable is already ready, return an empty handle without doing anything.
+  //
+  // Defined in another translation unit. Note that this may contain
+  // code that synchronizees with another thread.
+  std::coroutine_handle<> Register(std::coroutine_handle<>);
+};
+
+// Defined in another translation unit.
+void DidntSuspend();
+
+struct Awaiter {
+  SomeAwaitable&& awaitable;
+  bool suspended;
+
+  bool await_ready() { return false; }
+
+  std::coroutine_handle<> await_suspend(const std::coroutine_handle<> h) {
+// Assume we will suspend unless proven otherwise below. We must do
+// this *before* calling Register, since we may be destroyed by another
+// thread asynchronously as soon as we have registered.
+suspended = true;
+
+// Attempt to hand off responsibility for resuming/destroying the coroutine.
+const auto to_resume = awaitable.Register(h);
+
+if (!to_resume) {
+  // The awaitable is already ready. In this case we know that Register didn't
+  // hand off responsibility for the coroutine. So record the fact that we didn't
+  // actually suspend, and tell the compiler to resume us inline.
+  suspended = false;
+  return h;
+}
+
+// Resume whatever Register wants us to resume.
+return to_resume;
+  }
+
+  void await_resume() {
+// If we didn't suspend, make note of that fact.
+if (!suspended) {
+  DidntSuspend();
+}
+  }
+};
+
+struct MyTask{
+  struct promise_type {
+MyTask get_return_object() { return {}; }
+std::suspend_never initial_suspend() { return {}; }
+std::suspend_always final_suspend() noexcept { return {}; }
+void unhandled_exception();
+
+Awaiter await_transform(SomeAwaitable&& awaitable) {
+  return Awaiter{static_cast(awaitable)};
+}
+  };
+};
+
+MyTask FooBar() {
+  co_await SomeAwaitable();
+}
+
+// CHECK-LABEL: @_Z6FooBarv
+// CHECK: %[[to_resume:.*]] = {{.*}}call ptr @_ZN13SomeAwaitable8RegisterESt16coroutine_handleIvE
+// CHECK-NEXT: %[[to_bool:.*]] = icmp eq ptr %[[to_resume]], null
+// CHECK-NEXT: br i1 %[[to_bool]], label %[[then:.*]], label %[[else:.*]]
+
+// CHECK: [[then]]:
+// We only access the coroutine frame conditionally as the sources did.
+// CHECK:   store i8 0,
+// CHECK-NEXT: br label %[[else]]
+
+// CHECK: [[else]]:
+// No more access to the coroutine frame until suspended.
+// CHECK-NOT: store
+// CHECK: }
Index: clang/test/CodeGenCoroutines/coro-awaiter-noinline-suspend.cpp
===
--- /dev/null
+++ clang/test/CodeGenCoroutines/coro-awaiter-noinline-suspend.cpp
@@ -0,0 +1,207 @@
+// Tests that we can mark await-suspend as noinline correctly.
+//
+// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -emit-llvm -o - %s \
+// RUN: -disable-llvm-passes | FileCheck %s
+
+#include "Inputs/coroutine.h"
+
+struct Task {
+  struct promise_type {
+struct FinalAwaiter {
+  bool await_ready() const noexcept { return false; }
+  template 
+  std::coroutine_handle<> await_suspend(std::coroutine_handle h) noexcept {
+return h.promise().continuation;
+  }
+  void await_resume() noexcept {}
+};
+
+Task get_return_object() noexcept {
+  return std::coroutine_handle::from_promise(*this);
+}
+
+std::suspend_always initial_suspend() noexcept { return {}; }
+FinalAwaiter final_suspend() noexcept { return {}; }
+void unhandled_exception() noexcept {}
+void return_void() noexcept {}
+
+std::coroutine_handle<> continuation;
+  };
+
+  Task(std::coroutine_handle handle);
+  ~Task();
+
+private:
+  std::coroutine_handle handle;
+};
+
+struct StatefulAwaiter {
+int value;
+bool await_ready() const noexcept { return false; }
+   

[PATCH] D146054: [RISCV] Add --print-supported-extensions support

2023-08-14 Thread Brandon Wu via Phabricator via cfe-commits
4vtomat marked 2 inline comments as done.
4vtomat added a comment.

In D146054#4586067 , @MaskRay wrote:

> I think the best place to test `RISCVISAInfo.cpp` is 
> `llvm/unittests/Support/RISCVISAInfoTest.cpp`.
>
> `clang/test/Driver/print-supported-extensions.c` can test just a few lines 
> (there will be some overlap with the testing in 
> `llvm/unittests/Support/RISCVISAInfoTest.cpp`), so that changes to RISC-V 
> extensions will generally not require updates to 
> `clang/test/Driver/print-supported-extensions.c`

The goal of this patch is to list the supported extensions and their versions 
by providing an option, so I guess 
`clang/test/Driver/print-supported-extensions.c` aims differently with 
`llvm/unittests/Support/RISCVISAInfoTest.cpp` which is testing the 
functionalities in `RISCVISAInfoTest.cpp`.
`clang/test/Driver/print-supported-extensions.c` only tracks the extensions 
added and the their version changes and `riscvExtensionsHelp` in 
`llvm/lib/Support/RISCVISAInfo.cpp` doesn't have any input or output as well as 
any side effect, it only reads `SupportedExtensions` and 
`SupportedExperimentalExtensions` and dump the information.
So I think `clang/test/Driver/print-supported-extensions.c` is enough for this 
patch?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146054

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


[PATCH] D157777: [ASTMatcher] Add matcher for 'MacroQualifiedType'

2023-08-14 Thread Ding Fei via Phabricator via cfe-commits
danix800 updated this revision to Diff 550178.
danix800 added a comment.

1. Improve matcher description
2. Add a counter-example for test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D15

Files:
  clang/docs/LibASTMatchersReference.html
  clang/docs/ReleaseNotes.rst
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/lib/ASTMatchers/ASTMatchersInternal.cpp
  clang/lib/ASTMatchers/Dynamic/Registry.cpp
  clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp

Index: clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
@@ -1838,6 +1838,20 @@
 namesType(typedefType()));
 }
 
+TEST_P(ASTMatchersTest, MacroQualifiedType) {
+  EXPECT_TRUE(matches(
+  R"(
+#define CDECL __attribute__((cdecl))
+typedef void (CDECL *X)();
+  )",
+  typedefDecl(hasType(pointerType(pointee(macroQualifiedType()));
+  EXPECT_TRUE(notMatches(
+  R"(
+typedef void (__attribute__((cdecl)) *Y)();
+  )",
+  typedefDecl(hasType(pointerType(pointee(macroQualifiedType()));
+}
+
 TEST_P(ASTMatchersTest, TemplateSpecializationType) {
   if (!GetParam().isCXX()) {
 return;
Index: clang/lib/ASTMatchers/Dynamic/Registry.cpp
===
--- clang/lib/ASTMatchers/Dynamic/Registry.cpp
+++ clang/lib/ASTMatchers/Dynamic/Registry.cpp
@@ -485,6 +485,7 @@
   REGISTER_MATCHER(lambdaCapture);
   REGISTER_MATCHER(lambdaExpr);
   REGISTER_MATCHER(linkageSpecDecl);
+  REGISTER_MATCHER(macroQualifiedType);
   REGISTER_MATCHER(materializeTemporaryExpr);
   REGISTER_MATCHER(member);
   REGISTER_MATCHER(memberExpr);
Index: clang/lib/ASTMatchers/ASTMatchersInternal.cpp
===
--- clang/lib/ASTMatchers/ASTMatchersInternal.cpp
+++ clang/lib/ASTMatchers/ASTMatchersInternal.cpp
@@ -1058,6 +1058,7 @@
 const AstTypeMatcher functionProtoType;
 const AstTypeMatcher parenType;
 const AstTypeMatcher blockPointerType;
+const AstTypeMatcher macroQualifiedType;
 const AstTypeMatcher memberPointerType;
 const AstTypeMatcher pointerType;
 const AstTypeMatcher objcObjectPointerType;
Index: clang/include/clang/ASTMatchers/ASTMatchers.h
===
--- clang/include/clang/ASTMatchers/ASTMatchers.h
+++ clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -7258,6 +7258,18 @@
 ///   matches "typedef int X"
 extern const AstTypeMatcher typedefType;
 
+/// Matches qualified types when the qualifier is applied via a macro.
+///
+/// Given
+/// \code
+///   #define CDECL __attribute__((cdecl))
+///   typedef void (CDECL *X)();
+///   typedef void (__attribute__((cdecl)) *Y)();
+/// \endcode
+/// macroQualifiedType()
+///   matches the type of the typedef declaration of \c X but not \c Y.
+extern const AstTypeMatcher macroQualifiedType;
+
 /// Matches enum types.
 ///
 /// Given
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -249,6 +249,7 @@
 
 - Add ``convertVectorExpr``.
 - Add ``dependentSizedExtVectorType``.
+- Add ``macroQualifiedType``.
 
 clang-format
 
Index: clang/docs/LibASTMatchersReference.html
===
--- clang/docs/LibASTMatchersReference.html
+++ clang/docs/LibASTMatchersReference.html
@@ -2648,6 +2648,18 @@
 
 
 
+Matcherhttps://clang.llvm.org/doxygen/classclang_1_1Type.html;>TypemacroQualifiedTypeMatcherhttps://clang.llvm.org/doxygen/classclang_1_1MacroQualifiedType.html;>MacroQualifiedType...
+Matches qualified types when the qualifier is applied via a macro.
+
+Given
+  #define CDECL __attribute__((cdecl))
+  typedef void (CDECL *X)();
+  typedef void (__attribute__((cdecl)) *Y)();
+macroQualifiedType()
+  matches the type of the typedef declaration of X but not Y.
+
+
+
 Matcherhttps://clang.llvm.org/doxygen/classclang_1_1Type.html;>TypememberPointerTypeMatcherhttps://clang.llvm.org/doxygen/classclang_1_1MemberPointerType.html;>MemberPointerType...
 Matches member pointer types.
 Given
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D157777: [ASTMatcher] Add matcher for 'MacroQualifiedType'

2023-08-14 Thread Ding Fei via Phabricator via cfe-commits
danix800 added inline comments.



Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:7261
 
+/// Matches macro qualified types.
+///

aaron.ballman wrote:
> How about: Matches qualified types when the qualifier is applied via a macro.
> 
> and then a second example like:
> ```
> int * const qual_ptr;
> 
> #define nonnull _Nonnull
> int * const nonnull macro_qual_ptr;
> ```
> where we match `macro_qual_ptr` but not `qual_ptr`.
> How about: Matches qualified types when the qualifier is applied via a macro.

Forgive my broken English!  :-)

> and then a second example like:
> ```
> int * const qual_ptr;
> 
> #define nonnull _Nonnull
> int * const nonnull macro_qual_ptr;
> ```
> where we match `macro_qual_ptr` but not `qual_ptr`.

Thanks for reminding me of the counter-example, it's critical for better test 
coverage.

I'll pertain to the original one but with counter-example appended, because the 
macro
`nonnull` in this case will not generate a `MacroQualifiedType` for 
`macro_qual_ptr`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D15

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


[PATCH] D157933: [OpenMP 5.1] Parsing and Sema support for `scope` construct

2023-08-14 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

In D157933#4587164 , @mdfazlay wrote:

> In D157933#4586816 , @ABataev wrote:
>
>> Need to add the tests (and the checks, if required) for the nesting of the 
>> regions
>
> I think I have the nesting of regions checks in //scope_messages.cpp//. Do 
> you prefer to have those checks in //nesting_of_regions.cpp// file?

Yes, extend this one


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157933

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


[PATCH] D157933: [OpenMP 5.1] Parsing and Sema support for `scope` construct

2023-08-14 Thread Fazlay Rabbi via Phabricator via cfe-commits
mdfazlay added a comment.

In D157933#4586816 , @ABataev wrote:

> Need to add the tests (and the checks, if required) for the nesting of the 
> regions

I think I have the nesting of regions checks in //scope_messages.cpp//. Do you 
prefer to have those checks in //nesting_of_regions.cpp// file?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157933

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


[PATCH] D126586: [InstrProf][WIP] Implement boolean counters in coverage

2023-08-14 Thread Gulfem Savrun Yeniceri via Phabricator via cfe-commits
gulfem updated this revision to Diff 550163.
gulfem added a comment.

- Extend the prototype by implementing the rest of the control-flow statements
- Rename the prototype to single byte counters to be consistent with the single 
byte coverage used in PGO


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126586

Files:
  clang/lib/CodeGen/CGExprAgg.cpp
  clang/lib/CodeGen/CGExprComplex.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/CodeGen/CGStmt.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenPGO.cpp
  clang/lib/CodeGen/CodeGenPGO.h
  clang/lib/CodeGen/CoverageMappingGen.cpp
  clang/test/CoverageMapping/single-byte-counters.cpp

Index: clang/test/CoverageMapping/single-byte-counters.cpp
===
--- /dev/null
+++ clang/test/CoverageMapping/single-byte-counters.cpp
@@ -0,0 +1,169 @@
+// RUN: %clang_cc1 -mllvm -emptyline-comment-coverage=false -mllvm -enable-single-byte-coverage=true -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name single-byte-counters.cpp %s | FileCheck %s
+
+// CHECK: testIf
+int testIf(int x) { // CHECK-NEXT: File 0, [[@LINE]]:19 -> [[@LINE+10]]:2 = #0
+// CHECK-NEXT: File 0, [[@LINE+5]]:7 -> [[@LINE+5]]:13 = #0
+// CHECK-NEXT: Gap,File 0, [[@LINE+4]]:14 -> [[@LINE+5]]:5 = #2
+// CHECK-NEXT: File 0, [[@LINE+4]]:5 -> [[@LINE+4]]:16 = #2
+// CHECK-NEXT: File 0, [[@LINE+5]]:3 -> [[@LINE+5]]:16 = #1
+  int result = 0;
+  if (x == 0)
+result = -1;
+
+  return result;
+}
+
+// CHECK-NEXT: testIfElse
+int testIfElse(int x) { // CHECK-NEXT: File 0, [[@LINE]]:23 -> [[@LINE+13]]:2 = #0
+// CHECK-NEXT: File 0, [[@LINE+7]]:7 -> [[@LINE+7]]:12 = #0
+// CHECK-NEXT: Gap,File 0, [[@LINE+6]]:13 -> [[@LINE+7]]:5 = #2
+// CHECK-NEXT: File 0, [[@LINE+6]]:5 -> [[@LINE+6]]:15 = #2
+// CHECK-NEXT: Gap,File 0, [[@LINE+5]]:16 -> [[@LINE+7]]:5 = #3
+// CHECK-NEXT: File 0, [[@LINE+6]]:5 -> [[@LINE+6]]:19 = #3
+// CHECK-NEXT: File 0, [[@LINE+6]]:3 -> [[@LINE+6]]:16 = #1
+  int result = 0;
+  if (x < 0)
+result = 0;
+  else
+result = x * x;
+  return result;
+}
+
+// CHECK-NEXT: testIfElseReturn
+int testIfElseReturn(int x) { // CHECK-NEXT: File 0, [[@LINE]]:29 -> [[@LINE+14]]:2 = #0
+  // CHECK-NEXT: File 0, [[@LINE+8]]:7 -> [[@LINE+8]]:12 = #0
+  // CHECK-NEXT: Gap,File 0, [[@LINE+7]]:13 -> [[@LINE+8]]:5 = #2
+  // CHECK-NEXT: File 0, [[@LINE+7]]:5 -> [[@LINE+7]]:19 = #2
+  // CHECK-NEXT: Gap,File 0, [[@LINE+6]]:20 -> [[@LINE+8]]:5 = #3
+  // CHECK-NEXT: File 0, [[@LINE+7]]:5 -> [[@LINE+7]]:13 = #3
+  // CHECK-NEXT: Gap,File 0, [[@LINE+6]]:14 -> [[@LINE+7]]:3 = #1
+  // CHECK-NEXT: File 0, [[@LINE+6]]:3 -> [[@LINE+6]]:16 = #1
+  int result = 0;
+  if (x > 0)
+result = x * x;
+  else
+return 0;
+  return result;
+}
+
+// CHECK-NEXT: testSwitch
+int testSwitch(int x) { // CHECK-NEXT: File 0, [[@LINE]]:23 -> [[@LINE+22]]:2 = #0
+// CHECK-NEXT: Gap,File 0, [[@LINE+9]]:14 -> [[@LINE+17]]:15 = 0
+// CHECK-NEXT: File 0, [[@LINE+9]]:3 -> [[@LINE+11]]:10 = #2
+// CHECK-NEXT: Gap,File 0, [[@LINE+10]]:11 -> [[@LINE+11]]:3 = 0
+// CHECK-NEXT: File 0, [[@LINE+10]]:3 -> [[@LINE+12]]:10 = #3
+// CHECK-NEXT: Gap,File 0, [[@LINE+11]]:11 -> [[@LINE+12]]:3 = 0
+// CHECK-NEXT: File 0, [[@LINE+11]]:3 -> [[@LINE+12]]:15 = #4
+// CHECK-NEXT: Gap,File 0, [[@LINE+12]]:4 -> [[@LINE+14]]:3 = #1
+// CHECK-NEXT: File 0, [[@LINE+13]]:3 -> [[@LINE+13]]:16 = #1
+  int result;
+  switch (x) {
+  case 1:
+result = 1;
+break;
+  case 2:
+result = 2;
+break;
+  default:
+result = 0;
+  }
+
+  return result;
+}
+
+// CHECK-NEXT: testWhile
+int testWhile() { // CHECK-NEXT: File 0, [[@LINE]]:17 -> [[@LINE+13]]:2 = #0
+  // CHECK-NEXT: File 0, [[@LINE+6]]:10 -> [[@LINE+6]]:16 = #2
+  // CHECK-NEXT: Gap,File 0, [[@LINE+5]]:17 -> [[@LINE+5]]:18 = #3
+  // CHECK-NEXT: File 0, [[@LINE+4]]:18 -> [[@LINE+7]]:4 = #3
+  // CHECK-NEXT: File 0, [[@LINE+8]]:3 -> [[@LINE+8]]:13 = #1
+  int i = 0;
+  int sum = 0;
+  while (i < 10) {
+sum += i;
+i++;
+  }
+
+  return sum;
+}
+
+// CHECK-NEXT: testContinue
+int testContinue() { // CHECK-NEXT: File 0, [[@LINE]]:20 

[PATCH] D157944: [InstrProf] Single byte counters in coverage

2023-08-14 Thread Gulfem Savrun Yeniceri via Phabricator via cfe-commits
gulfem created this revision.
Herald added subscribers: wlei, ellis, wenlei.
Herald added a project: All.
gulfem requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This patch inserts 1-byte counters instead of an 8-byte counters
into llvm profiles for source-based code coverage. The origial idea
was proposed as "block-cov" for PGO, and this patch repurposes that
idea for coverage: https://groups.google.com/g/llvm-dev/c/r03Z6JoN7d4

The current 8-byte counters mechanism add counters to minimal regions,
and infer the counters in the remaining regions via adding or
subtracting counters. For example, it infers the counter in the `if.else`
region by subtracting the counters between `if.entry` and `if.then` regions
in an if statement. Whenever there is a control-flow merge, it adds
the counters from all the incoming regions. However, we are not going to be
able to infer counters by subtracting two execution counts when using
single-byte counters. Therefore, this patch conservatively inserts additional
counters for the cases where we need to add or subtract counters.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D157944

Files:
  clang/lib/CodeGen/CGExprAgg.cpp
  clang/lib/CodeGen/CGExprComplex.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/CodeGen/CGStmt.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenPGO.cpp
  clang/lib/CodeGen/CodeGenPGO.h
  clang/lib/CodeGen/CoverageMappingGen.cpp
  clang/test/CoverageMapping/single-byte-counters.cpp

Index: clang/test/CoverageMapping/single-byte-counters.cpp
===
--- /dev/null
+++ clang/test/CoverageMapping/single-byte-counters.cpp
@@ -0,0 +1,169 @@
+// RUN: %clang_cc1 -mllvm -emptyline-comment-coverage=false -mllvm -enable-single-byte-coverage=true -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name single-byte-counters.cpp %s | FileCheck %s
+
+// CHECK: testIf
+int testIf(int x) { // CHECK-NEXT: File 0, [[@LINE]]:19 -> [[@LINE+10]]:2 = #0
+// CHECK-NEXT: File 0, [[@LINE+5]]:7 -> [[@LINE+5]]:13 = #0
+// CHECK-NEXT: Gap,File 0, [[@LINE+4]]:14 -> [[@LINE+5]]:5 = #2
+// CHECK-NEXT: File 0, [[@LINE+4]]:5 -> [[@LINE+4]]:16 = #2
+// CHECK-NEXT: File 0, [[@LINE+5]]:3 -> [[@LINE+5]]:16 = #1
+  int result = 0;
+  if (x == 0)
+result = -1;
+
+  return result;
+}
+
+// CHECK-NEXT: testIfElse
+int testIfElse(int x) { // CHECK-NEXT: File 0, [[@LINE]]:23 -> [[@LINE+13]]:2 = #0
+// CHECK-NEXT: File 0, [[@LINE+7]]:7 -> [[@LINE+7]]:12 = #0
+// CHECK-NEXT: Gap,File 0, [[@LINE+6]]:13 -> [[@LINE+7]]:5 = #2
+// CHECK-NEXT: File 0, [[@LINE+6]]:5 -> [[@LINE+6]]:15 = #2
+// CHECK-NEXT: Gap,File 0, [[@LINE+5]]:16 -> [[@LINE+7]]:5 = #3
+// CHECK-NEXT: File 0, [[@LINE+6]]:5 -> [[@LINE+6]]:19 = #3
+// CHECK-NEXT: File 0, [[@LINE+6]]:3 -> [[@LINE+6]]:16 = #1
+  int result = 0;
+  if (x < 0)
+result = 0;
+  else
+result = x * x;
+  return result;
+}
+
+// CHECK-NEXT: testIfElseReturn
+int testIfElseReturn(int x) { // CHECK-NEXT: File 0, [[@LINE]]:29 -> [[@LINE+14]]:2 = #0
+  // CHECK-NEXT: File 0, [[@LINE+8]]:7 -> [[@LINE+8]]:12 = #0
+  // CHECK-NEXT: Gap,File 0, [[@LINE+7]]:13 -> [[@LINE+8]]:5 = #2
+  // CHECK-NEXT: File 0, [[@LINE+7]]:5 -> [[@LINE+7]]:19 = #2
+  // CHECK-NEXT: Gap,File 0, [[@LINE+6]]:20 -> [[@LINE+8]]:5 = #3
+  // CHECK-NEXT: File 0, [[@LINE+7]]:5 -> [[@LINE+7]]:13 = #3
+  // CHECK-NEXT: Gap,File 0, [[@LINE+6]]:14 -> [[@LINE+7]]:3 = #1
+  // CHECK-NEXT: File 0, [[@LINE+6]]:3 -> [[@LINE+6]]:16 = #1
+  int result = 0;
+  if (x > 0)
+result = x * x;
+  else
+return 0;
+  return result;
+}
+
+// CHECK-NEXT: testSwitch
+int testSwitch(int x) { // CHECK-NEXT: File 0, [[@LINE]]:23 -> [[@LINE+22]]:2 = #0
+// CHECK-NEXT: Gap,File 0, [[@LINE+9]]:14 -> [[@LINE+17]]:15 = 0
+// CHECK-NEXT: File 0, [[@LINE+9]]:3 -> [[@LINE+11]]:10 = #2
+// CHECK-NEXT: Gap,File 0, [[@LINE+10]]:11 -> [[@LINE+11]]:3 = 0
+// CHECK-NEXT: File 0, [[@LINE+10]]:3 -> [[@LINE+12]]:10 = #3
+// CHECK-NEXT: Gap,File 0, [[@LINE+11]]:11 -> [[@LINE+12]]:3 = 0
+// CHECK-NEXT: File 0, [[@LINE+11]]:3 -> [[@LINE+12]]:15 = #4
+// CHECK-NEXT: Gap,File 0, [[@LINE+12]]:4 -> [[@LINE+14]]:3 = #1
+// CHECK-NEXT: File 0, 

[PATCH] D157691: [ASTImporter] Remove extranous FunctionTemplateDecl introduced by templated friend

2023-08-14 Thread Ding Fei via Phabricator via cfe-commits
danix800 updated this revision to Diff 550160.
danix800 added a comment.

1. Add unit testcase
2. Use better API


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157691

Files:
  clang/lib/AST/ASTImporter.cpp
  clang/test/Import/templated-friend/Inputs/T.cpp
  clang/test/Import/templated-friend/test.cpp
  clang/unittests/AST/ASTImporterTest.cpp


Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -5634,6 +5634,42 @@
   EXPECT_EQ(Imported->getPreviousDecl(), Friend);
 }
 
+TEST_P(ImportFriendFunctionTemplates, ImportFriendFunctionInsideClassTemplate) 
{
+  Decl *From, *To;
+  std::tie(From, To) = getImportedDecl(R"(
+  template  struct X {
+template  friend void f();
+  };
+)",
+   Lang_CXX03, "", Lang_CXX03, "X");
+
+  auto *FromFriend = FirstDeclMatcher().match(From, friendDecl());
+  auto *ToFriend = FirstDeclMatcher().match(To, friendDecl());
+
+  EXPECT_TRUE(FromFriend ==
+  LastDeclMatcher().match(From, friendDecl()));
+  EXPECT_TRUE(ToFriend ==
+  LastDeclMatcher().match(To, friendDecl()));
+
+  auto *FromDecl = FromFriend->getFriendDecl();
+  auto *FromDC = FromFriend->getDeclContext();
+  auto *FromLexicalDC = FromFriend->getLexicalDeclContext();
+
+  EXPECT_TRUE(FromDC->containsDecl(FromFriend));
+  EXPECT_FALSE(FromDC->containsDecl(FromDecl));
+  EXPECT_TRUE(FromLexicalDC->containsDecl(FromFriend));
+  EXPECT_FALSE(FromLexicalDC->containsDecl(FromDecl));
+
+  auto *ToDecl = ToFriend->getFriendDecl();
+  auto *ToDC = ToFriend->getDeclContext();
+  auto *ToLexicalDC = ToFriend->getLexicalDeclContext();
+
+  EXPECT_TRUE(ToDC->containsDecl(ToFriend));
+  EXPECT_FALSE(ToDC->containsDecl(ToDecl));
+  EXPECT_TRUE(ToLexicalDC->containsDecl(ToFriend));
+  EXPECT_FALSE(ToLexicalDC->containsDecl(ToDecl));
+}
+
 struct ASTImporterWithFakeErrors : ASTImporter {
   using ASTImporter::ASTImporter;
   bool returnWithErrorInTest() override { return true; }
Index: clang/test/Import/templated-friend/test.cpp
===
--- /dev/null
+++ clang/test/Import/templated-friend/test.cpp
@@ -0,0 +1,5 @@
+// RUN: clang-import-test -import %S/Inputs/T.cpp -expression %s
+
+void expr() {
+  A a;
+}
Index: clang/test/Import/templated-friend/Inputs/T.cpp
===
--- /dev/null
+++ clang/test/Import/templated-friend/Inputs/T.cpp
@@ -0,0 +1,3 @@
+template  struct A {
+  template  friend void f();
+};
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -6447,7 +6447,7 @@
 
   ToFunc->setAccess(D->getAccess());
   ToFunc->setLexicalDeclContext(LexicalDC);
-  LexicalDC->addDeclInternal(ToFunc);
+  addDeclToContexts(D, ToFunc);
 
   ASTImporterLookupTable *LT = Importer.SharedState->getLookupTable();
   if (LT && !OldParamDC.empty()) {


Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -5634,6 +5634,42 @@
   EXPECT_EQ(Imported->getPreviousDecl(), Friend);
 }
 
+TEST_P(ImportFriendFunctionTemplates, ImportFriendFunctionInsideClassTemplate) {
+  Decl *From, *To;
+  std::tie(From, To) = getImportedDecl(R"(
+  template  struct X {
+template  friend void f();
+  };
+)",
+   Lang_CXX03, "", Lang_CXX03, "X");
+
+  auto *FromFriend = FirstDeclMatcher().match(From, friendDecl());
+  auto *ToFriend = FirstDeclMatcher().match(To, friendDecl());
+
+  EXPECT_TRUE(FromFriend ==
+  LastDeclMatcher().match(From, friendDecl()));
+  EXPECT_TRUE(ToFriend ==
+  LastDeclMatcher().match(To, friendDecl()));
+
+  auto *FromDecl = FromFriend->getFriendDecl();
+  auto *FromDC = FromFriend->getDeclContext();
+  auto *FromLexicalDC = FromFriend->getLexicalDeclContext();
+
+  EXPECT_TRUE(FromDC->containsDecl(FromFriend));
+  EXPECT_FALSE(FromDC->containsDecl(FromDecl));
+  EXPECT_TRUE(FromLexicalDC->containsDecl(FromFriend));
+  EXPECT_FALSE(FromLexicalDC->containsDecl(FromDecl));
+
+  auto *ToDecl = ToFriend->getFriendDecl();
+  auto *ToDC = ToFriend->getDeclContext();
+  auto *ToLexicalDC = ToFriend->getLexicalDeclContext();
+
+  EXPECT_TRUE(ToDC->containsDecl(ToFriend));
+  EXPECT_FALSE(ToDC->containsDecl(ToDecl));
+  EXPECT_TRUE(ToLexicalDC->containsDecl(ToFriend));
+  EXPECT_FALSE(ToLexicalDC->containsDecl(ToDecl));
+}
+
 struct ASTImporterWithFakeErrors : ASTImporter {
   using ASTImporter::ASTImporter;
   bool returnWithErrorInTest() override { return true; }
Index: 

[PATCH] D157829: [clang-tidy] Added a new option to lambda-function-name to ignore warnings in macro expansion

2023-08-14 Thread Félix-Antoine Constantin via Phabricator via cfe-commits
felix642 updated this revision to Diff 550159.
felix642 added a comment.

Updated commit message


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157829

Files:
  clang-tools-extra/clang-tidy/bugprone/LambdaFunctionNameCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/LambdaFunctionNameCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/bugprone/lambda-function-name.rst
  clang-tools-extra/test/clang-tidy/checkers/bugprone/lambda-function-name.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone/lambda-function-name.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone/lambda-function-name.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone/lambda-function-name.cpp
@@ -1,4 +1,6 @@
-// RUN: %check_clang_tidy %s bugprone-lambda-function-name %t
+// RUN: %check_clang_tidy -check-suffixes=,NO-CONFIG %s bugprone-lambda-function-name %t
+// RUN: %check_clang_tidy %s bugprone-lambda-function-name %t -- -config="{CheckOptions: [{key: bugprone-lambda-function-name.IgnoreMacros, value: true}]}" --
+
 
 void Foo(const char* a, const char* b, int c) {}
 
@@ -12,11 +14,11 @@
   [] { __FUNCTION__; }();
   // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: inside a lambda, '__FUNCTION__' expands to the name of the function call operator; consider capturing the name of the enclosing function explicitly [bugprone-lambda-function-name]
   [] { FUNC_MACRO; }();
-  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: inside a lambda, '__func__' expands to the name of the function call operator; consider capturing the name of the enclosing function explicitly [bugprone-lambda-function-name]
+  // CHECK-MESSAGES-NO-CONFIG: :[[@LINE-1]]:8: warning: inside a lambda, '__func__' expands to the name of the function call operator; consider capturing the name of the enclosing function explicitly [bugprone-lambda-function-name]
   [] { FUNCTION_MACRO; }();
-  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: inside a lambda, '__FUNCTION__' expands to the name of the function call operator; consider capturing the name of the enclosing function explicitly [bugprone-lambda-function-name]
+  // CHECK-MESSAGES-NO-CONFIG: :[[@LINE-1]]:8: warning: inside a lambda, '__FUNCTION__' expands to the name of the function call operator; consider capturing the name of the enclosing function explicitly [bugprone-lambda-function-name]
   [] { EMBED_IN_ANOTHER_MACRO1; }();
-  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: inside a lambda, '__func__' expands to the name of the function call operator; consider capturing the name of the enclosing function explicitly [bugprone-lambda-function-name]
+  // CHECK-MESSAGES-NO-CONFIG: :[[@LINE-1]]:8: warning: inside a lambda, '__func__' expands to the name of the function call operator; consider capturing the name of the enclosing function explicitly [bugprone-lambda-function-name]
 }
 
 #define FUNC_MACRO_WITH_FILE_AND_LINE Foo(__func__, __FILE__, __LINE__)
Index: clang-tools-extra/docs/clang-tidy/checks/bugprone/lambda-function-name.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/bugprone/lambda-function-name.rst
+++ clang-tools-extra/docs/clang-tidy/checks/bugprone/lambda-function-name.rst
@@ -25,3 +25,11 @@
 
   Called from FancyFunction
   Now called from FancyFunction
+
+Options
+---
+
+.. option::  IgnoreMacros
+
+  The value `true` specifies that attempting to get the name of a function from
+  within a macro should not be diagnosed. The default value is `false`.
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -173,6 +173,10 @@
   `, so that it does not warn
   on macros starting with underscore and lowercase letter.
 
+- Improved :doc:`bugprone-lambda-function-name
+  ` check by adding option
+  `IgnoreMacros` to ignore warnings in macros.
+
 - Improved :doc:`cppcoreguidelines-avoid-non-const-global-variables
   ` check
   to ignore ``static`` variables declared within the scope of
Index: clang-tools-extra/clang-tidy/bugprone/LambdaFunctionNameCheck.h
===
--- clang-tools-extra/clang-tidy/bugprone/LambdaFunctionNameCheck.h
+++ clang-tools-extra/clang-tidy/bugprone/LambdaFunctionNameCheck.h
@@ -31,8 +31,9 @@
   };
   using SourceRangeSet = std::set;
 
-  LambdaFunctionNameCheck(StringRef Name, ClangTidyContext *Context)
-  : ClangTidyCheck(Name, Context) {}
+  LambdaFunctionNameCheck(StringRef Name, ClangTidyContext *Context);
+
+  void storeOptions(ClangTidyOptions::OptionMap ) override;
   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
   void registerPPCallbacks(const SourceManager , Preprocessor 

[PATCH] D157829: [clang-tidy] Added a new option to lambda-function-name to ignore warnings in macro expansion

2023-08-14 Thread Félix-Antoine Constantin via Phabricator via cfe-commits
felix642 updated this revision to Diff 550156.
felix642 added a comment.

Code review

Move constructor to cpp file
Added store options


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157829

Files:
  clang-tools-extra/clang-tidy/bugprone/LambdaFunctionNameCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/LambdaFunctionNameCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/bugprone/lambda-function-name.rst
  clang-tools-extra/test/clang-tidy/checkers/bugprone/lambda-function-name.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone/lambda-function-name.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone/lambda-function-name.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone/lambda-function-name.cpp
@@ -1,4 +1,6 @@
-// RUN: %check_clang_tidy %s bugprone-lambda-function-name %t
+// RUN: %check_clang_tidy -check-suffixes=,NO-CONFIG %s bugprone-lambda-function-name %t
+// RUN: %check_clang_tidy %s bugprone-lambda-function-name %t -- -config="{CheckOptions: [{key: bugprone-lambda-function-name.IgnoreMacros, value: true}]}" --
+
 
 void Foo(const char* a, const char* b, int c) {}
 
@@ -12,11 +14,11 @@
   [] { __FUNCTION__; }();
   // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: inside a lambda, '__FUNCTION__' expands to the name of the function call operator; consider capturing the name of the enclosing function explicitly [bugprone-lambda-function-name]
   [] { FUNC_MACRO; }();
-  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: inside a lambda, '__func__' expands to the name of the function call operator; consider capturing the name of the enclosing function explicitly [bugprone-lambda-function-name]
+  // CHECK-MESSAGES-NO-CONFIG: :[[@LINE-1]]:8: warning: inside a lambda, '__func__' expands to the name of the function call operator; consider capturing the name of the enclosing function explicitly [bugprone-lambda-function-name]
   [] { FUNCTION_MACRO; }();
-  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: inside a lambda, '__FUNCTION__' expands to the name of the function call operator; consider capturing the name of the enclosing function explicitly [bugprone-lambda-function-name]
+  // CHECK-MESSAGES-NO-CONFIG: :[[@LINE-1]]:8: warning: inside a lambda, '__FUNCTION__' expands to the name of the function call operator; consider capturing the name of the enclosing function explicitly [bugprone-lambda-function-name]
   [] { EMBED_IN_ANOTHER_MACRO1; }();
-  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: inside a lambda, '__func__' expands to the name of the function call operator; consider capturing the name of the enclosing function explicitly [bugprone-lambda-function-name]
+  // CHECK-MESSAGES-NO-CONFIG: :[[@LINE-1]]:8: warning: inside a lambda, '__func__' expands to the name of the function call operator; consider capturing the name of the enclosing function explicitly [bugprone-lambda-function-name]
 }
 
 #define FUNC_MACRO_WITH_FILE_AND_LINE Foo(__func__, __FILE__, __LINE__)
Index: clang-tools-extra/docs/clang-tidy/checks/bugprone/lambda-function-name.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/bugprone/lambda-function-name.rst
+++ clang-tools-extra/docs/clang-tidy/checks/bugprone/lambda-function-name.rst
@@ -25,3 +25,11 @@
 
   Called from FancyFunction
   Now called from FancyFunction
+
+Options
+---
+
+.. option::  IgnoreMacros
+
+  The value `true` specifies that attempting to get the name of a function from
+  within a macro should not be diagnosed. The default value is `false`.
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -173,6 +173,10 @@
   `, so that it does not warn
   on macros starting with underscore and lowercase letter.
 
+- Improved :doc:`bugprone-lambda-function-name
+  ` check by adding option
+  `IgnoreMacros` to ignore warnings in macros.
+
 - Improved :doc:`cppcoreguidelines-avoid-non-const-global-variables
   ` check
   to ignore ``static`` variables declared within the scope of
Index: clang-tools-extra/clang-tidy/bugprone/LambdaFunctionNameCheck.h
===
--- clang-tools-extra/clang-tidy/bugprone/LambdaFunctionNameCheck.h
+++ clang-tools-extra/clang-tidy/bugprone/LambdaFunctionNameCheck.h
@@ -31,8 +31,9 @@
   };
   using SourceRangeSet = std::set;
 
-  LambdaFunctionNameCheck(StringRef Name, ClangTidyContext *Context)
-  : ClangTidyCheck(Name, Context) {}
+  LambdaFunctionNameCheck(StringRef Name, ClangTidyContext *Context);
+
+  void storeOptions(ClangTidyOptions::OptionMap ) override;
   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
   void 

[PATCH] D157808: [clang] Add missing field to VisibilityAttr json AST dump

2023-08-14 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Hello, one of the many dump commits broke tests on macOS: 
http://45.33.8.238/macm1/67030/step_7.txt

Please take a look and revert for now if it takes a while to fix.

Also, consider spreading out commits a bit so that if one breaks something, 
it's easily to see which one it was.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157808

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


[PATCH] D157149: [Option] Add "Visibility" field and clone the OptTable APIs to use it

2023-08-14 Thread Justin Bogner via Phabricator via cfe-commits
bogner added inline comments.



Comment at: llvm/include/llvm/Option/OptParser.td:153
 class Flags flags> { list Flags = flags; }
+class Vis vis> { list Vis = vis; }
 class Group { OptionGroup Group = group; }

phosek wrote:
> Would it be possible to spell this out in full, that is `Visibility` rather 
> than `Vis`? It's more consistent with all other attributes and improves 
> readability in my opinion.
Sure, I can change it. I went with brevity thinking that it would help 
readability, especially in clang's Options.td, but I'm fairly okay with either 
way.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157149

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


[PATCH] D156237: Complete the implementation of P2361 Unevaluated string literals

2023-08-14 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added a comment.

Thanks, @cor3ntin, for addressing my feedback. I am not familiar enough with 
various aspects of it to approve it, but I see Aaron has already approved it 
and I think all comments have been addressed.
I also appreciate that the patch helps towards making the internally-used 
encoding less exposed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156237

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


[PATCH] D157738: [OpenMP] Emit offloading entries for indirect target variables

2023-08-14 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 updated this revision to Diff 550140.
jhuber6 added a comment.

Address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157738

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.h
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/OpenMP/target_indirect_codegen.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp

Index: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
===
--- llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -5525,9 +5525,10 @@
 
 void OpenMPIRBuilder::createOffloadEntry(Constant *ID, Constant *Addr,
  uint64_t Size, int32_t Flags,
- GlobalValue::LinkageTypes) {
+ GlobalValue::LinkageTypes,
+ StringRef Name) {
   if (!Config.isGPU()) {
-emitOffloadingEntry(ID, Addr->getName(), Size, Flags);
+emitOffloadingEntry(ID, Name.empty() ? Addr->getName() : Name, Size, Flags);
 return;
   }
   // TODO: Add support for global variables on the device after declare target
@@ -5687,13 +5688,20 @@
 
   // Hidden or internal symbols on the device are not externally visible.
   // We should not attempt to register them by creating an offloading
-  // entry.
+  // entry. Indirect variables are handled separately on the device.
   if (auto *GV = dyn_cast(CE->getAddress()))
-if (GV->hasLocalLinkage() || GV->hasHiddenVisibility())
+if ((GV->hasLocalLinkage() || GV->hasHiddenVisibility()) &&
+Flags != OffloadEntriesInfoManager::OMPTargetGlobalVarEntryIndirect)
   continue;
 
-  createOffloadEntry(CE->getAddress(), CE->getAddress(), CE->getVarSize(),
- Flags, CE->getLinkage());
+  // Indirect globals need to use a special name that doesn't match the name
+  // of the associated host global.
+  if (Flags == OffloadEntriesInfoManager::OMPTargetGlobalVarEntryIndirect)
+createOffloadEntry(CE->getAddress(), CE->getAddress(), CE->getVarSize(),
+   Flags, CE->getLinkage(), CE->getVarName());
+  else
+createOffloadEntry(CE->getAddress(), CE->getAddress(), CE->getVarSize(),
+   Flags, CE->getLinkage());
 
 } else {
   llvm_unreachable("Unsupported entry kind.");
@@ -6038,8 +6046,13 @@
   }
   return;
 }
-OffloadEntriesDeviceGlobalVar.try_emplace(VarName, OffloadingEntriesNum,
-  Addr, VarSize, Flags, Linkage);
+if (Flags == OffloadEntriesInfoManager::OMPTargetGlobalVarEntryIndirect)
+  OffloadEntriesDeviceGlobalVar.try_emplace(VarName, OffloadingEntriesNum,
+Addr, VarSize, Flags, Linkage,
+VarName.str());
+else
+  OffloadEntriesDeviceGlobalVar.try_emplace(
+  VarName, OffloadingEntriesNum, Addr, VarSize, Flags, Linkage, "");
 ++OffloadingEntriesNum;
   }
 }
Index: llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
===
--- llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
+++ llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
@@ -326,6 +326,8 @@
 OMPTargetGlobalVarEntryEnter = 0x2,
 /// Mark the entry as having no declare target entry kind.
 OMPTargetGlobalVarEntryNone = 0x3,
+/// Mark the entry as a declare target indirect global.
+OMPTargetGlobalVarEntryIndirect = 0x4,
   };
 
   /// Kind of device clause for declare target variables
@@ -349,6 +351,7 @@
 /// Type of the global variable.
 int64_t VarSize;
 GlobalValue::LinkageTypes Linkage;
+const std::string VarName;
 
   public:
 OffloadEntryInfoDeviceGlobalVar()
@@ -359,13 +362,15 @@
 explicit OffloadEntryInfoDeviceGlobalVar(unsigned Order, Constant *Addr,
  int64_t VarSize,
  OMPTargetGlobalVarEntryKind Flags,
- GlobalValue::LinkageTypes Linkage)
+ GlobalValue::LinkageTypes Linkage,
+ const std::string )
 : OffloadEntryInfo(OffloadingEntryInfoDeviceGlobalVar, Order, Flags),
-  VarSize(VarSize), Linkage(Linkage) {
+  VarSize(VarSize), Linkage(Linkage), VarName(VarName) {
   setAddress(Addr);
 }
 
 int64_t getVarSize() const { return VarSize; }
+StringRef getVarName() const { return VarName; }
 void setVarSize(int64_t Size) { VarSize = Size; }
 GlobalValue::LinkageTypes getLinkage() const { return Linkage; }
   

[PATCH] D157149: [Option] Add "Visibility" field and clone the OptTable APIs to use it

2023-08-14 Thread Petr Hosek via Phabricator via cfe-commits
phosek added inline comments.



Comment at: llvm/include/llvm/Option/OptParser.td:153
 class Flags flags> { list Flags = flags; }
+class Vis vis> { list Vis = vis; }
 class Group { OptionGroup Group = group; }

Would it be possible to spell this out in full, that is `Visibility` rather 
than `Vis`? It's more consistent with all other attributes and improves 
readability in my opinion.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157149

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


[PATCH] D157750: Properly handle -fsplit-machine-functions for fatbinary compilation

2023-08-14 Thread Han Shen via Phabricator via cfe-commits
shenhan marked an inline comment as done.
shenhan added inline comments.



Comment at: llvm/lib/CodeGen/TargetPassConfig.cpp:1281-1282
+else
+  WithColor::warning()
+  << "-fsplit-machine-functions is only valid for X86.\n";
   }

arsenm wrote:
> shenhan wrote:
> > arsenm wrote:
> > > You cannot spam warnings here. The other instance of printing here looks 
> > > like a new addition and should be removed
> > Thanks. Do you suggest moving the warnings to the underlying pass? 
> > (Although that means we create passes that only issue warnings.)
> Move it to the pass, and use a backend remark, not directly print to the 
> console (e.g. DiagnosticInfoUnsupported)
Thanks, created DiagnosticInfoMachineFunctionSplit and moved the warning to MFS 
pass.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157750

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


[PATCH] D157750: Properly handle -fsplit-machine-functions for fatbinary compilation

2023-08-14 Thread Han Shen via Phabricator via cfe-commits
shenhan updated this revision to Diff 550137.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157750

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/fsplit-machine-functions.c
  llvm/include/llvm/IR/DiagnosticInfo.h
  llvm/lib/CodeGen/MachineFunctionSplitter.cpp
  llvm/lib/IR/DiagnosticInfo.cpp

Index: llvm/lib/IR/DiagnosticInfo.cpp
===
--- llvm/lib/IR/DiagnosticInfo.cpp
+++ llvm/lib/IR/DiagnosticInfo.cpp
@@ -449,3 +449,7 @@
   if (!getNote().empty())
 DP << ": " << getNote();
 }
+
+void DiagnosticInfoMachineFunctionSplit::print(DiagnosticPrinter ) const {
+  DP << "-fsplit-machine-functions is not valid for " << TargetTriple;
+}
Index: llvm/lib/CodeGen/MachineFunctionSplitter.cpp
===
--- llvm/lib/CodeGen/MachineFunctionSplitter.cpp
+++ llvm/lib/CodeGen/MachineFunctionSplitter.cpp
@@ -35,9 +35,11 @@
 #include "llvm/CodeGen/MachineFunctionPass.h"
 #include "llvm/CodeGen/MachineModuleInfo.h"
 #include "llvm/CodeGen/Passes.h"
+#include "llvm/IR/DiagnosticInfo.h"
 #include "llvm/IR/Function.h"
 #include "llvm/InitializePasses.h"
 #include "llvm/Support/CommandLine.h"
+#include "llvm/TargetParser/Triple.h"
 #include 
 
 using namespace llvm;
@@ -82,6 +84,11 @@
   void getAnalysisUsage(AnalysisUsage ) const override;
 
   bool runOnMachineFunction(MachineFunction ) override;
+
+  bool doInitialization(Module &) override;
+
+private:
+  bool UnsupportedTriple = false;
 };
 } // end anonymous namespace
 
@@ -127,7 +134,20 @@
   return (*Count < ColdCountThreshold);
 }
 
+bool MachineFunctionSplitter::doInitialization(Module ) {
+  StringRef TripleStr = M.getTargetTriple();
+  if (!Triple(TripleStr).isX86()) {
+UnsupportedTriple = true;
+M.getContext().diagnose(
+DiagnosticInfoMachineFunctionSplit(TripleStr, DS_Warning));
+return false;
+  }
+  return MachineFunctionPass::doInitialization(M);
+}
+
 bool MachineFunctionSplitter::runOnMachineFunction(MachineFunction ) {
+  if (UnsupportedTriple)
+return false;
   // We target functions with profile data. Static information in the form
   // of exception handling code may be split to cold if user passes the
   // mfs-split-ehcode flag.
Index: llvm/include/llvm/IR/DiagnosticInfo.h
===
--- llvm/include/llvm/IR/DiagnosticInfo.h
+++ llvm/include/llvm/IR/DiagnosticInfo.h
@@ -86,6 +86,7 @@
   DK_SrcMgr,
   DK_DontCall,
   DK_MisExpect,
+  DK_MachineFunctionSplit,
   DK_FirstPluginKind // Must be last value to work with
  // getNextAvailablePluginDiagnosticKind
 };
@@ -1117,6 +1118,20 @@
   }
 };
 
+class DiagnosticInfoMachineFunctionSplit : public DiagnosticInfo {
+  StringRef TargetTriple;
+
+public:
+  DiagnosticInfoMachineFunctionSplit(StringRef TargetTriple,
+ DiagnosticSeverity DS)
+  : DiagnosticInfo(DK_MachineFunctionSplit, DS),
+TargetTriple(TargetTriple) {}
+  void print(DiagnosticPrinter ) const override;
+  static bool classof(const DiagnosticInfo *DI) {
+return DI->getKind() == DK_MachineFunctionSplit;
+  }
+};
+
 } // end namespace llvm
 
 #endif // LLVM_IR_DIAGNOSTICINFO_H
Index: clang/test/Driver/fsplit-machine-functions.c
===
--- clang/test/Driver/fsplit-machine-functions.c
+++ clang/test/Driver/fsplit-machine-functions.c
@@ -1,8 +1,8 @@
 // RUN: %clang -### -target x86_64 -fprofile-use=default.profdata -fsplit-machine-functions %s -c 2>&1 | FileCheck -check-prefix=CHECK-OPT %s
 // RUN: %clang -### -target x86_64 -fsplit-machine-functions %s -c 2>&1 | FileCheck -check-prefix=CHECK-OPT %s
 // RUN: %clang -### -target x86_64 -fprofile-use=default.profdata -fsplit-machine-functions -fno-split-machine-functions %s -c 2>&1 | FileCheck -check-prefix=CHECK-NOOPT %s
-// RUN: not %clang -c -target arm-unknown-linux -fsplit-machine-functions %s 2>&1 | FileCheck -check-prefix=CHECK-TRIPLE %s
+// RUN: %clang -c -target arm-unknown-linux -fsplit-machine-functions %s 2>&1 | FileCheck -check-prefix=CHECK-TRIPLE %s
 
 // CHECK-OPT:   "-fsplit-machine-functions"
 // CHECK-NOOPT-NOT: "-fsplit-machine-functions"
-// CHECK-TRIPLE:error: unsupported option '-fsplit-machine-functions' for target
+// CHECK-TRIPLE:warning: -fsplit-machine-functions is only valid for X86.
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5859,14 +5859,15 @@
 
   if (Arg *A = Args.getLastArg(options::OPT_fsplit_machine_functions,
options::OPT_fno_split_machine_functions)) {
-// This codegen pass is 

[PATCH] D157781: [clang] Add cleanup_function field to CleanupAttr json AST dump

2023-08-14 Thread Paul Kirth via Phabricator via cfe-commits
paulkirth added a comment.

Hi, we're seeing a test failure in our CI after this stack. Not exactly sure 
which commit though.

You can find the failing bot here:
https://luci-milo.appspot.com/ui/p/fuchsia/builders/toolchain.ci/clang-linux-x64-rbe/b8772753421607483249/overview

Some test output from Clang :: AST/ast-dump-stmt-json.cpp:

  Script:
  --
  : 'RUN: at line 1';   /b/s/w/ir/x/w/llvm_build/bin/clang -cc1 
-internal-isystem /b/s/w/ir/x/w/llvm_build/lib/clang/18/include -nostdsysteminc 
-std=c++2a -triple x86_64-linux-gnu -fcxx-exceptions -ast-dump=json 
/b/s/w/ir/x/w/llvm-llvm-project/clang/test/AST/ast-dump-stmt-json.cpp | 
/b/s/w/ir/x/w/llvm_build/bin/FileCheck 
/b/s/w/ir/x/w/llvm-llvm-project/clang/test/AST/ast-dump-stmt-json.cpp
  --
  Exit Code: 1
  
  Command Output (stderr):
  --
  
/b/s/w/ir/x/w/llvm-llvm-project/clang/test/AST/ast-dump-stmt-json.cpp:1471:16: 
error: CHECK-NEXT: is not on the line after the previous match
  // CHECK-NEXT: },
 ^
  :1555:2: note: 'next' match was here
   },
   ^
  :1553:18: note: previous match ended here
   "implicit": true,
   ^
  :1554:1: note: non-matching line after previous match is here
   "visibility": "default"
  ^
  
  Input file: 
  Check file: 
/b/s/w/ir/x/w/llvm-llvm-project/clang/test/AST/ast-dump-stmt-json.cpp
  
  -dump-input=help explains the following input dump.
  
  Input was:
  <<
 .
 .
 .
  1550:  "begin": {}, 
  1551:  "end": {} 
  1552:  }, 
  1553:  "implicit": true, 
  1554:  "visibility": "default" 
  1555:  }, 
  next:1471  !~  error: match on wrong line
  1556:  { 
  1557:  "id": "0x558ee63a5d00", 
  1558:  "kind": "ReturnsNonNullAttr", 
  1559:  "range": { 
  1560:  "begin": {}, 
 .
 .
 .
  >>
  
  --


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157781

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


[PATCH] D157150: [Driver] Update BoolOption to handle Visibility. NFC

2023-08-14 Thread Justin Bogner via Phabricator via cfe-commits
bogner updated this revision to Diff 550125.
bogner edited the summary of this revision.
bogner added a comment.

Rebase on top of "DefaultVis" naming


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157150

Files:
  clang/include/clang/Driver/Options.h
  clang/include/clang/Driver/Options.td

Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -79,6 +79,23 @@
 // target will lead to an err_drv_unsupported_opt_for_target error.
 def TargetSpecific : OptionFlag;
 
+// Indicates that this warning is ignored, but accepted with a warning for
+// GCC compatibility.
+class IgnoredGCCCompat : Flags<[HelpHidden]> {}
+
+class TargetSpecific : Flags<[TargetSpecific]> {}
+
+/
+// Visibility
+
+// We prefer the name "ClangOption" here rather than "Default" to make
+// it clear that these options will be visible in the clang driver (as
+// opposed to clang -cc1, the CL driver, or the flang driver).
+defvar ClangOption = DefaultVis;
+
+/
+// Docs
+
 // A short name to show in documentation. The name will be interpreted as rST.
 class DocName { string DocName = name; }
 
@@ -89,12 +106,6 @@
 // documentation.
 class DocFlatten { bit DocFlatten = 1; }
 
-// Indicates that this warning is ignored, but accepted with a warning for
-// GCC compatibility.
-class IgnoredGCCCompat : Flags<[HelpHidden]> {}
-
-class TargetSpecific : Flags<[TargetSpecific]> {}
-
 /
 // Groups
 
@@ -381,7 +392,8 @@
 
 // Definition of single command line flag. This is an implementation detail, use
 // SetTrueBy or SetFalseBy instead.
-class FlagDef option_flags,
+class FlagDef option_flags, list option_vis,
   string help, list implied_by_expressions = []> {
   // The polarity. Besides spelling, this also decides whether the TableGen
   // record will be prefixed with "no_".
@@ -390,9 +402,12 @@
   // The value assigned to key path when the flag is present on command line.
   bit Value = value;
 
-  // OptionFlags that control visibility of the flag in different tools.
+  // OptionFlags in different tools.
   list OptionFlags = option_flags;
 
+  // OptionVisibility flags for different tools.
+  list OptionVis = option_vis;
+
   // The help text associated with the flag.
   string Help = help;
 
@@ -401,8 +416,11 @@
 }
 
 // Additional information to be appended to both positive and negative flag.
-class BothFlags option_flags, string help = ""> {
+class BothFlags option_flags,
+list option_vis = [ClangOption],
+string help = ""> {
   list OptionFlags = option_flags;
+  list OptionVis = option_vis;
   string Help = help;
 }
 
@@ -411,23 +429,26 @@
   FlagDef Result
 = FlagDef;
 }
 
 // Definition of the command line flag with positive spelling, e.g. "-ffoo".
-class PosFlag flags = [], string help = "",
-  list implied_by_expressions = []>
-  : FlagDef {}
+class PosFlag flags = [], list vis = [],
+  string help = "", list implied_by_expressions = []>
+  : FlagDef {}
 
 // Definition of the command line flag with negative spelling, e.g. "-fno-foo".
-class NegFlag flags = [], string help = "",
-  list implied_by_expressions = []>
-  : FlagDef {}
+class NegFlag flags = [], list vis = [],
+  string help = "", list implied_by_expressions = []>
+  : FlagDef {}
 
 // Expanded FlagDef that's convenient for creation of TableGen records.
 class FlagDefExpanded
-  : FlagDef {
+  : FlagDef {
   // Name of the TableGen record.
   string RecordName = prefix # !if(flag.Polarity, "", "no_") # name;
 
@@ -445,7 +466,8 @@
 class MarshalledFlagRec
-  : Flag<["-"], flag.Spelling>, Flags, HelpText,
+  : Flag<["-"], flag.Spelling>, Flags, Vis,
+HelpText,
 MarshallingInfoBooleanFlag,
 ImpliedByAnyOf {}
@@ -459,7 +481,7 @@
 multiclass BoolOption> {
+  BothFlags suffix = BothFlags<[]>> {
   defvar flag1 = FlagDefExpanded.Result, prefix,
  NAME, spelling_base>;
 
@@ -490,7 +512,7 @@
 /// CompilerInvocation.
 multiclass BoolFOption> {
+   BothFlags both = BothFlags<[]>> {
   defm NAME : BoolOption<"f", flag_base, kpm, default, flag1, flag2, both>,
   Group;
 }
@@ -501,7 +523,7 @@
 // CompilerInvocation.
 multiclass BoolGOption> {
+   BothFlags both = BothFlags<[]>> {
   defm NAME : BoolOption<"g", flag_base, kpm, default, flag1, flag2, both>,
   Group;
 }
@@ -509,7 +531,7 @@
 // Works like BoolOption except without marshalling
 multiclass BoolOptionWithoutMarshalling> {
+BothFlags suffix = BothFlags<[]>> {
   defvar flag1 = FlagDefExpanded.Result, prefix,
  NAME, spelling_base>;
 
@@ -531,11 +553,11 @@
   defvar implied = 

[PATCH] D157925: [MachineOutliner][LTO] Enable outlining of linkonceodr functions on all targets.

2023-08-14 Thread Jon Roelofs 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 rG1a135bceb66b: [MachineOutliner][LTO] Enable outlining of 
linkonceodr functions on all targets. (authored by jroelofs).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157925

Files:
  clang/lib/Driver/ToolChains/Darwin.cpp
  clang/test/Driver/darwin-ld.c


Index: clang/test/Driver/darwin-ld.c
===
--- clang/test/Driver/darwin-ld.c
+++ clang/test/Driver/darwin-ld.c
@@ -358,11 +358,31 @@
 // Check that we can pass the outliner down to the linker.
 // RUN: env IPHONEOS_DEPLOYMENT_TARGET=7.0 \
 // RUN:   %clang -target arm64-apple-darwin -moutline -### %t.o 2> %t.log
-// RUN: FileCheck -check-prefix=MOUTLINE %s < %t.log
-// MOUTLINE: {{ld(.exe)?"}}
-// MOUTLINE-SAME: "-mllvm" "-enable-machine-outliner" "-mllvm" 
"-enable-linkonceodr-outlining"
+// RUN: FileCheck -check-prefix=ARM64-MOUTLINE %s < %t.log
+// ARM64-MOUTLINE: {{ld(.exe)?"}}
+// ARM64-MOUTLINE-SAME: "-mllvm" "-enable-machine-outliner" "-mllvm" 
"-enable-linkonceodr-outlining"
+// RUN: env IPHONEOS_DEPLOYMENT_TARGET=7.0 \
+// RUN:   %clang -target arm64e-apple-darwin -moutline -### %t.o 2> %t.log
+// RUN: FileCheck -check-prefix=ARM64E-MOUTLINE %s < %t.log
+// ARM64E-MOUTLINE: {{ld(.exe)?"}}
+// ARM64E-MOUTLINE-SAME: "-mllvm" "-enable-linkonceodr-outlining"
+// RUN: env IPHONEOS_DEPLOYMENT_TARGET=7.0 \
+// RUN:   %clang -target armv7em-apple-darwin -moutline -### %t.o 2> %t.log
+// RUN: FileCheck -check-prefix=ARMV7EM-MOUTLINE %s < %t.log
+// ARMV7EM-MOUTLINE: {{ld(.exe)?"}}
+// ARMV7EM-MOUTLINE-SAME: "-mllvm" "-enable-linkonceodr-outlining"
 // RUN: env IPHONEOS_DEPLOYMENT_TARGET=7.0 \
 // RUN:   %clang -target arm64-apple-darwin -mno-outline -### %t.o 2> %t.log
-// RUN: FileCheck -check-prefix=MNO_OUTLINE %s < %t.log
-// MNO_OUTLINE: {{ld(.exe)?"}}
-// MNO_OUTLINE-SAME: "-mllvm" "-enable-machine-outliner=never"
+// RUN: FileCheck -check-prefix=ARM64-MNO_OUTLINE %s < %t.log
+// ARM64-MNO_OUTLINE: {{ld(.exe)?"}}
+// ARM64-MNO_OUTLINE-SAME: "-mllvm" "-enable-machine-outliner=never" "-mllvm" 
"-enable-linkonceodr-outlining"
+// RUN: env IPHONEOS_DEPLOYMENT_TARGET=7.0 \
+// RUN:   %clang -target arm64e-apple-darwin -mno-outline -### %t.o 2> %t.log
+// RUN: FileCheck -check-prefix=ARM64E-MNO_OUTLINE %s < %t.log
+// ARM64E-MNO_OUTLINE: {{ld(.exe)?"}}
+// ARM64E-MNO_OUTLINE-SAME: "-mllvm" "-enable-machine-outliner=never" "-mllvm" 
"-enable-linkonceodr-outlining"
+// RUN: env IPHONEOS_DEPLOYMENT_TARGET=7.0 \
+// RUN:   %clang -target armv7em-apple-darwin -mno-outline -### %t.o 2> %t.log
+// RUN: FileCheck -check-prefix=ARMV7EM-MNO_OUTLINE %s < %t.log
+// ARMV7EM-MNO_OUTLINE: {{ld(.exe)?"}}
+// ARMV7EM-MNO_OUTLINE-SAME: "-mllvm" "-enable-machine-outliner=never" 
"-mllvm" "-enable-linkonceodr-outlining"
\ No newline at end of file
Index: clang/lib/Driver/ToolChains/Darwin.cpp
===
--- clang/lib/Driver/ToolChains/Darwin.cpp
+++ clang/lib/Driver/ToolChains/Darwin.cpp
@@ -615,10 +615,6 @@
   if (getMachOToolChain().getMachOArchName(Args) == "arm64") {
 CmdArgs.push_back("-mllvm");
 CmdArgs.push_back("-enable-machine-outliner");
-
-// Outline from linkonceodr functions by default in LTO.
-CmdArgs.push_back("-mllvm");
-CmdArgs.push_back("-enable-linkonceodr-outlining");
   }
 } else {
   // Disable all outlining behaviour if we have mno-outline. We need to do
@@ -629,6 +625,12 @@
 }
   }
 
+  // Outline from linkonceodr functions by default in LTO, whenever the 
outliner
+  // is enabled.  Note that the target may enable the machine outliner
+  // independently of -moutline.
+  CmdArgs.push_back("-mllvm");
+  CmdArgs.push_back("-enable-linkonceodr-outlining");
+
   // Setup statistics file output.
   SmallString<128> StatsFile =
   getStatsFileName(Args, Output, Inputs[0], getToolChain().getDriver());


Index: clang/test/Driver/darwin-ld.c
===
--- clang/test/Driver/darwin-ld.c
+++ clang/test/Driver/darwin-ld.c
@@ -358,11 +358,31 @@
 // Check that we can pass the outliner down to the linker.
 // RUN: env IPHONEOS_DEPLOYMENT_TARGET=7.0 \
 // RUN:   %clang -target arm64-apple-darwin -moutline -### %t.o 2> %t.log
-// RUN: FileCheck -check-prefix=MOUTLINE %s < %t.log
-// MOUTLINE: {{ld(.exe)?"}}
-// MOUTLINE-SAME: "-mllvm" "-enable-machine-outliner" "-mllvm" "-enable-linkonceodr-outlining"
+// RUN: FileCheck -check-prefix=ARM64-MOUTLINE %s < %t.log
+// ARM64-MOUTLINE: {{ld(.exe)?"}}
+// ARM64-MOUTLINE-SAME: "-mllvm" "-enable-machine-outliner" "-mllvm" "-enable-linkonceodr-outlining"
+// RUN: env IPHONEOS_DEPLOYMENT_TARGET=7.0 \
+// RUN:   %clang -target arm64e-apple-darwin -moutline -### 

[clang] 1a135bc - [MachineOutliner][LTO] Enable outlining of linkonceodr functions on all targets.

2023-08-14 Thread Jon Roelofs via cfe-commits

Author: Jon Roelofs
Date: 2023-08-14T16:22:48-07:00
New Revision: 1a135bceb66b2d448ba4363af2f8626b6e4110bd

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

LOG: [MachineOutliner][LTO] Enable outlining of linkonceodr functions on all 
targets.

... that have the outliner enabled.

Differential revision: https://reviews.llvm.org/D157925

Added: 


Modified: 
clang/lib/Driver/ToolChains/Darwin.cpp
clang/test/Driver/darwin-ld.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Darwin.cpp 
b/clang/lib/Driver/ToolChains/Darwin.cpp
index 239fbf21d77f5a..1b785eae42bc4b 100644
--- a/clang/lib/Driver/ToolChains/Darwin.cpp
+++ b/clang/lib/Driver/ToolChains/Darwin.cpp
@@ -615,10 +615,6 @@ void darwin::Linker::ConstructJob(Compilation , const 
JobAction ,
   if (getMachOToolChain().getMachOArchName(Args) == "arm64") {
 CmdArgs.push_back("-mllvm");
 CmdArgs.push_back("-enable-machine-outliner");
-
-// Outline from linkonceodr functions by default in LTO.
-CmdArgs.push_back("-mllvm");
-CmdArgs.push_back("-enable-linkonceodr-outlining");
   }
 } else {
   // Disable all outlining behaviour if we have mno-outline. We need to do
@@ -629,6 +625,12 @@ void darwin::Linker::ConstructJob(Compilation , const 
JobAction ,
 }
   }
 
+  // Outline from linkonceodr functions by default in LTO, whenever the 
outliner
+  // is enabled.  Note that the target may enable the machine outliner
+  // independently of -moutline.
+  CmdArgs.push_back("-mllvm");
+  CmdArgs.push_back("-enable-linkonceodr-outlining");
+
   // Setup statistics file output.
   SmallString<128> StatsFile =
   getStatsFileName(Args, Output, Inputs[0], getToolChain().getDriver());

diff  --git a/clang/test/Driver/darwin-ld.c b/clang/test/Driver/darwin-ld.c
index b8d0a9a9b25af9..b835b1f876beb5 100644
--- a/clang/test/Driver/darwin-ld.c
+++ b/clang/test/Driver/darwin-ld.c
@@ -358,11 +358,31 @@
 // Check that we can pass the outliner down to the linker.
 // RUN: env IPHONEOS_DEPLOYMENT_TARGET=7.0 \
 // RUN:   %clang -target arm64-apple-darwin -moutline -### %t.o 2> %t.log
-// RUN: FileCheck -check-prefix=MOUTLINE %s < %t.log
-// MOUTLINE: {{ld(.exe)?"}}
-// MOUTLINE-SAME: "-mllvm" "-enable-machine-outliner" "-mllvm" 
"-enable-linkonceodr-outlining"
+// RUN: FileCheck -check-prefix=ARM64-MOUTLINE %s < %t.log
+// ARM64-MOUTLINE: {{ld(.exe)?"}}
+// ARM64-MOUTLINE-SAME: "-mllvm" "-enable-machine-outliner" "-mllvm" 
"-enable-linkonceodr-outlining"
+// RUN: env IPHONEOS_DEPLOYMENT_TARGET=7.0 \
+// RUN:   %clang -target arm64e-apple-darwin -moutline -### %t.o 2> %t.log
+// RUN: FileCheck -check-prefix=ARM64E-MOUTLINE %s < %t.log
+// ARM64E-MOUTLINE: {{ld(.exe)?"}}
+// ARM64E-MOUTLINE-SAME: "-mllvm" "-enable-linkonceodr-outlining"
+// RUN: env IPHONEOS_DEPLOYMENT_TARGET=7.0 \
+// RUN:   %clang -target armv7em-apple-darwin -moutline -### %t.o 2> %t.log
+// RUN: FileCheck -check-prefix=ARMV7EM-MOUTLINE %s < %t.log
+// ARMV7EM-MOUTLINE: {{ld(.exe)?"}}
+// ARMV7EM-MOUTLINE-SAME: "-mllvm" "-enable-linkonceodr-outlining"
 // RUN: env IPHONEOS_DEPLOYMENT_TARGET=7.0 \
 // RUN:   %clang -target arm64-apple-darwin -mno-outline -### %t.o 2> %t.log
-// RUN: FileCheck -check-prefix=MNO_OUTLINE %s < %t.log
-// MNO_OUTLINE: {{ld(.exe)?"}}
-// MNO_OUTLINE-SAME: "-mllvm" "-enable-machine-outliner=never"
+// RUN: FileCheck -check-prefix=ARM64-MNO_OUTLINE %s < %t.log
+// ARM64-MNO_OUTLINE: {{ld(.exe)?"}}
+// ARM64-MNO_OUTLINE-SAME: "-mllvm" "-enable-machine-outliner=never" "-mllvm" 
"-enable-linkonceodr-outlining"
+// RUN: env IPHONEOS_DEPLOYMENT_TARGET=7.0 \
+// RUN:   %clang -target arm64e-apple-darwin -mno-outline -### %t.o 2> %t.log
+// RUN: FileCheck -check-prefix=ARM64E-MNO_OUTLINE %s < %t.log
+// ARM64E-MNO_OUTLINE: {{ld(.exe)?"}}
+// ARM64E-MNO_OUTLINE-SAME: "-mllvm" "-enable-machine-outliner=never" "-mllvm" 
"-enable-linkonceodr-outlining"
+// RUN: env IPHONEOS_DEPLOYMENT_TARGET=7.0 \
+// RUN:   %clang -target armv7em-apple-darwin -mno-outline -### %t.o 2> %t.log
+// RUN: FileCheck -check-prefix=ARMV7EM-MNO_OUTLINE %s < %t.log
+// ARMV7EM-MNO_OUTLINE: {{ld(.exe)?"}}
+// ARMV7EM-MNO_OUTLINE-SAME: "-mllvm" "-enable-machine-outliner=never" 
"-mllvm" "-enable-linkonceodr-outlining"
\ No newline at end of file



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


[clang] b7e1d26 - Revert "[clang] Add missing field to VisibilityAttr json AST dump"

2023-08-14 Thread Douglas Yung via cfe-commits

Author: Douglas Yung
Date: 2023-08-14T16:15:30-07:00
New Revision: b7e1d26f841c7ef3db46d30239c179a1e1b4d156

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

LOG: Revert "[clang] Add missing field to VisibilityAttr json AST dump"

This reverts commit 2107d87c5a9103ffc4c0f76fc00ab203603f9df1.

Change is causing test failures on many bots:
- https://lab.llvm.org/buildbot/#/builders/164/builds/42180
- https://lab.llvm.org/buildbot/#/builders/188/builds/33880
- https://lab.llvm.org/buildbot/#/builders/245/builds/12558
- https://lab.llvm.org/buildbot/#/builders/258/builds/5404
- https://lab.llvm.org/buildbot/#/builders/249/builds/8049
- https://lab.llvm.org/buildbot/#/builders/230/builds/17170
- https://lab.llvm.org/buildbot/#/builders/91/builds/17108
- https://lab.llvm.org/buildbot/#/builders/109/builds/71264
- https://lab.llvm.org/buildbot/#/builders/139/builds/47461
- https://lab.llvm.org/buildbot/#/builders/216/builds/25598
- https://lab.llvm.org/buildbot/#/builders/36/builds/36549
- https://lab.llvm.org/buildbot/#/builders/247/builds/7747

Added: 


Modified: 
clang/include/clang/AST/JSONNodeDumper.h
clang/lib/AST/JSONNodeDumper.cpp
clang/test/AST/ast-dump-attr-json.cpp

Removed: 




diff  --git a/clang/include/clang/AST/JSONNodeDumper.h 
b/clang/include/clang/AST/JSONNodeDumper.h
index 03c903069ad877..089c0e97a90472 100644
--- a/clang/include/clang/AST/JSONNodeDumper.h
+++ b/clang/include/clang/AST/JSONNodeDumper.h
@@ -213,7 +213,6 @@ class JSONNodeDumper
   void VisitDeprecatedAttr(const DeprecatedAttr *DA);
   void VisitUnavailableAttr(const UnavailableAttr *UA);
   void VisitSectionAttr(const SectionAttr *SA);
-  void VisitVisibilityAttr(const VisibilityAttr *VA);
 
   void VisitTypedefType(const TypedefType *TT);
   void VisitUsingType(const UsingType *TT);

diff  --git a/clang/lib/AST/JSONNodeDumper.cpp 
b/clang/lib/AST/JSONNodeDumper.cpp
index 134938a1ef19a0..ec5661d1d6944d 100644
--- a/clang/lib/AST/JSONNodeDumper.cpp
+++ b/clang/lib/AST/JSONNodeDumper.cpp
@@ -554,11 +554,6 @@ void JSONNodeDumper::VisitSectionAttr(const SectionAttr 
*SA) {
   JOS.attribute("section_name", SA->getName());
 }
 
-void JSONNodeDumper::VisitVisibilityAttr(const VisibilityAttr *VA) {
-  JOS.attribute("visibility", VisibilityAttr::ConvertVisibilityTypeToStr(
-  VA->getVisibility()));
-}
-
 void JSONNodeDumper::VisitTypedefType(const TypedefType *TT) {
   JOS.attribute("decl", createBareDeclRef(TT->getDecl()));
   if (!TT->typeMatchesDecl())

diff  --git a/clang/test/AST/ast-dump-attr-json.cpp 
b/clang/test/AST/ast-dump-attr-json.cpp
index 0eb930b851a15e..a9679695e954f1 100644
--- a/clang/test/AST/ast-dump-attr-json.cpp
+++ b/clang/test/AST/ast-dump-attr-json.cpp
@@ -17,9 +17,6 @@ __attribute__((unavailable("reason"))) int unavailable_var1;
 
 __attribute__ ((section ("SECTION_NAME"))) int section_var;
 
-__attribute__ ((visibility ("hidden"))) int visibility_var;
-
-
 // NOTE: CHECK lines have been autogenerated by gen_ast_dump_json_test.py
 // using --filters=VarDecl
 
@@ -432,50 +429,3 @@ __attribute__ ((visibility ("hidden"))) int visibility_var;
 // CHECK-NEXT:   }
 // CHECK-NEXT:  ]
 // CHECK-NEXT: }
-
-
-// CHECK-NOT: {{^}}Dumping
-// CHECK:  "kind": "VarDecl",
-// CHECK-NEXT:  "loc": {
-// CHECK-NEXT:   "offset": 651,
-// CHECK-NEXT:   "line": 20,
-// CHECK-NEXT:   "col": 45,
-// CHECK-NEXT:   "tokLen": 14
-// CHECK-NEXT:  },
-// CHECK-NEXT:  "range": {
-// CHECK-NEXT:   "begin": {
-// CHECK-NEXT:"offset": 607,
-// CHECK-NEXT:"col": 1,
-// CHECK-NEXT:"tokLen": 13
-// CHECK-NEXT:   },
-// CHECK-NEXT:   "end": {
-// CHECK-NEXT:"offset": 651,
-// CHECK-NEXT:"col": 45,
-// CHECK-NEXT:"tokLen": 14
-// CHECK-NEXT:   }
-// CHECK-NEXT:  },
-// CHECK-NEXT:  "name": "visibility_var",
-// CHECK-NEXT:  "mangledName": "visibility_var",
-// CHECK-NEXT:  "type": {
-// CHECK-NEXT:   "qualType": "int"
-// CHECK-NEXT:  },
-// CHECK-NEXT:  "inner": [
-// CHECK-NEXT:   {
-// CHECK-NEXT:"id": "0x{{.*}}",
-// CHECK-NEXT:"kind": "VisibilityAttr",
-// CHECK-NEXT:"range": {
-// CHECK-NEXT: "begin": {
-// CHECK-NEXT:  "offset": 623,
-// CHECK-NEXT:  "col": 17,
-// CHECK-NEXT:  "tokLen": 10
-// CHECK-NEXT: },
-// CHECK-NEXT: "end": {
-// CHECK-NEXT:  "offset": 643,
-// CHECK-NEXT:  "col": 37,
-// CHECK-NEXT:  "tokLen": 1
-// CHECK-NEXT: }
-// CHECK-NEXT:},
-// CHECK-NEXT:"visibility": "hidden"
-// CHECK-NEXT:   }
-// CHECK-NEXT:  ]
-// CHECK-NEXT: }



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


[clang] 4ac4d4a - Revert "[clang] Add missing field to TLSModelAttr json AST dump"

2023-08-14 Thread Douglas Yung via cfe-commits

Author: Douglas Yung
Date: 2023-08-14T16:14:28-07:00
New Revision: 4ac4d4a9777e47324766aef80cfd094d06b460ec

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

LOG: Revert "[clang] Add missing field to TLSModelAttr json AST dump"

This reverts commit 2105c32b32bf3360f524f1f3a1e5af605821eff8.

Reverting this follow-up commit as a prior commit (2107d87) is causing build 
bot test failures.

Added: 


Modified: 
clang/include/clang/AST/JSONNodeDumper.h
clang/lib/AST/JSONNodeDumper.cpp
clang/test/AST/ast-dump-attr-json.cpp

Removed: 




diff  --git a/clang/include/clang/AST/JSONNodeDumper.h 
b/clang/include/clang/AST/JSONNodeDumper.h
index 0ce272df8df65b..03c903069ad877 100644
--- a/clang/include/clang/AST/JSONNodeDumper.h
+++ b/clang/include/clang/AST/JSONNodeDumper.h
@@ -214,7 +214,6 @@ class JSONNodeDumper
   void VisitUnavailableAttr(const UnavailableAttr *UA);
   void VisitSectionAttr(const SectionAttr *SA);
   void VisitVisibilityAttr(const VisibilityAttr *VA);
-  void VisitTLSModelAttr(const TLSModelAttr *TA);
 
   void VisitTypedefType(const TypedefType *TT);
   void VisitUsingType(const UsingType *TT);

diff  --git a/clang/lib/AST/JSONNodeDumper.cpp 
b/clang/lib/AST/JSONNodeDumper.cpp
index 139dfce41e914c..134938a1ef19a0 100644
--- a/clang/lib/AST/JSONNodeDumper.cpp
+++ b/clang/lib/AST/JSONNodeDumper.cpp
@@ -559,10 +559,6 @@ void JSONNodeDumper::VisitVisibilityAttr(const 
VisibilityAttr *VA) {
   VA->getVisibility()));
 }
 
-void JSONNodeDumper::VisitTLSModelAttr(const TLSModelAttr *TA) {
-  JOS.attribute("tls_model", TA->getModel());
-}
-
 void JSONNodeDumper::VisitTypedefType(const TypedefType *TT) {
   JOS.attribute("decl", createBareDeclRef(TT->getDecl()));
   if (!TT->typeMatchesDecl())

diff  --git a/clang/test/AST/ast-dump-attr-json.cpp 
b/clang/test/AST/ast-dump-attr-json.cpp
index 24a5ff08887870..0eb930b851a15e 100644
--- a/clang/test/AST/ast-dump-attr-json.cpp
+++ b/clang/test/AST/ast-dump-attr-json.cpp
@@ -19,7 +19,6 @@ __attribute__ ((section ("SECTION_NAME"))) int section_var;
 
 __attribute__ ((visibility ("hidden"))) int visibility_var;
 
-__thread __attribute__ ((tls_model ("local-exec"))) int tls_model_var;
 
 // NOTE: CHECK lines have been autogenerated by gen_ast_dump_json_test.py
 // using --filters=VarDecl
@@ -480,51 +479,3 @@ __thread __attribute__ ((tls_model ("local-exec"))) int 
tls_model_var;
 // CHECK-NEXT:   }
 // CHECK-NEXT:  ]
 // CHECK-NEXT: }
-
-
-// CHECK-NOT: {{^}}Dumping
-// CHECK:  "kind": "VarDecl",
-// CHECK-NEXT:  "loc": {
-// CHECK-NEXT:   "offset": 724,
-// CHECK-NEXT:   "line": 22,
-// CHECK-NEXT:   "col": 57,
-// CHECK-NEXT:   "tokLen": 13
-// CHECK-NEXT:  },
-// CHECK-NEXT:  "range": {
-// CHECK-NEXT:   "begin": {
-// CHECK-NEXT:"offset": 668,
-// CHECK-NEXT:"col": 1,
-// CHECK-NEXT:"tokLen": 8
-// CHECK-NEXT:   },
-// CHECK-NEXT:   "end": {
-// CHECK-NEXT:"offset": 724,
-// CHECK-NEXT:"col": 57,
-// CHECK-NEXT:"tokLen": 13
-// CHECK-NEXT:   }
-// CHECK-NEXT:  },
-// CHECK-NEXT:  "name": "tls_model_var",
-// CHECK-NEXT:  "mangledName": "tls_model_var",
-// CHECK-NEXT:  "type": {
-// CHECK-NEXT:   "qualType": "int"
-// CHECK-NEXT:  },
-// CHECK-NEXT:  "tls": "static",
-// CHECK-NEXT:  "inner": [
-// CHECK-NEXT:   {
-// CHECK-NEXT:"id": "0x{{.*}}",
-// CHECK-NEXT:"kind": "TLSModelAttr",
-// CHECK-NEXT:"range": {
-// CHECK-NEXT: "begin": {
-// CHECK-NEXT:  "offset": 693,
-// CHECK-NEXT:  "col": 26,
-// CHECK-NEXT:  "tokLen": 9
-// CHECK-NEXT: },
-// CHECK-NEXT: "end": {
-// CHECK-NEXT:  "offset": 716,
-// CHECK-NEXT:  "col": 49,
-// CHECK-NEXT:  "tokLen": 1
-// CHECK-NEXT: }
-// CHECK-NEXT:},
-// CHECK-NEXT:"tls_model": "local-exec"
-// CHECK-NEXT:   }
-// CHECK-NEXT:  ]
-// CHECK-NEXT: }



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


[PATCH] D157793: [Headers] Add missing __need_ macros to stdarg.h

2023-08-14 Thread Ian Anderson via Phabricator via cfe-commits
iana added inline comments.



Comment at: clang/test/Headers/stdarg.c:34
+__va_copy(g, v);
+va_copy(g, v); // c89-error{{implicit}} c89-note{{va_copy}} 
c99-no-diagnostics
+}

aaron.ballman wrote:
> You should spell out these diagnostics, and I think `c99-no-diagnostics` 
> should be placed up by the RUN lines so it's more obvious that we expect no 
> diagnostics in C99 mode.
> 
> Actually, this file should perhaps be split into two files as they're testing 
> different things. (I was tripped up seeing no-diagnostics but we have 
> `c99-error` entries above, that's when I realized the split file was being 
> used differently in the RUN lines which is a bit novel.) But I'm not certain 
> I fully understand what your comment means about why we're using split file 
> in the first place, so I might be missing something.
It's only trying to test what including  gets you by default. The 
first chunk is to prove that nothing is provided via built-ins or anything like 
if you don't include anything. The second chunk shows that you get the expected 
declarations in each standard mode if you include  with no `__need_` 
macros.

The problem is this.
```
va_copy(g, v); // The first time you get: implicitly declaring library function 
'va_copy'

va_copy(g, v); // But now the compiler has decided that va_copy has a 
declaration, so you don't get any diagnostics even though va_copy doesn't have 
its real declaration, I think the compiler assumes 'int va_copy(int, int)' or 
something like that.
```

Maybe we don't need to test the include-nothing case both here and 
stdargneeds.c?

D157757 has the same problem for `offsetof` but since it uses C23 also, the 
diagnostics get repeated.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157793

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


[PATCH] D157793: [Headers] Add missing __need_ macros to stdarg.h

2023-08-14 Thread Ian Anderson via Phabricator via cfe-commits
iana updated this revision to Diff 550121.
iana marked 4 inline comments as done.
iana added a comment.

Review feedback


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157793

Files:
  clang/lib/Headers/stdarg.h
  clang/test/Headers/stdarg.c
  clang/test/Headers/stdargneeds.c

Index: clang/test/Headers/stdargneeds.c
===
--- /dev/null
+++ clang/test/Headers/stdargneeds.c
@@ -0,0 +1,91 @@
+// RUN: split-file %s %t
+// RUN: %clang_cc1 -fsyntax-only -verify -Werror=implicit-function-declaration -std=c89 %t/stdargneeds0.c
+// RUN: %clang_cc1 -fsyntax-only -verify -Werror=implicit-function-declaration -std=c89 %t/stdargneeds1.c
+// RUN: %clang_cc1 -fsyntax-only -verify -Werror=implicit-function-declaration -std=c89 %t/stdargneeds2.c
+// RUN: %clang_cc1 -fsyntax-only -verify -Werror=implicit-function-declaration -std=c89 %t/stdargneeds3.c
+// RUN: %clang_cc1 -fsyntax-only -verify -Werror=implicit-function-declaration -std=c89 %t/stdargneeds4.c
+// RUN: %clang_cc1 -fsyntax-only -verify -Werror=implicit-function-declaration -std=c89 %t/stdargneeds5.c
+
+// Split the file so that the "implicitly declaring library function" errors get repeated.
+// Use C89 to verify that __need_ can be used to get types that wouldn't normally be available.
+
+//--- stdargneeds0.c
+static void f(int p, ...) {
+__gnuc_va_list g; // expected-error{{undeclared identifier '__gnuc_va_list'}}
+va_list v; // expected-error{{undeclared identifier 'va_list'}}
+va_start(v, p); // expected-error{{implicitly declaring library function 'va_start'}} expected-note{{include the header  or explicitly provide a declaration for 'va_start'}} expected-error{{undeclared identifier 'v'}}
+int i = va_arg(v, int); // expected-error{{implicit declaration of function 'va_arg'}} expected-error{{expected expression}} expected-error{{use of undeclared identifier 'v'}}
+va_end(v); // expected-error{{implicitly declaring library function 'va_end'}} expected-note{{include the header  or explicitly provide a declaration for 'va_end'}} expected-error{{undeclared identifier 'v'}}
+__va_copy(g, v); // expected-error{{implicit declaration of function '__va_copy'}} expected-error{{use of undeclared identifier 'g'}} expected-error{{use of undeclared identifier 'v'}}
+va_copy(g, v); // expected-error{{implicitly declaring library function 'va_copy'}} expected-note{{include the header  or explicitly provide a declaration for 'va_copy'}} expected-error{{use of undeclared identifier 'g'}} expected-error{{use of undeclared identifier 'v'}}
+}
+
+//--- stdargneeds1.c
+#define __need___va_list
+#include 
+static void f(int p, ...) {
+__gnuc_va_list g;
+va_list v; // expected-error{{undeclared identifier}}
+va_start(v, p); // expected-error{{implicitly declaring library function}} expected-note{{provide a declaration}} expected-error{{undeclared identifier}}
+int i = va_arg(v, int); // expected-error{{implicit declaration of function}} expected-error{{expected expression}} expected-error{{undeclared identifier}}
+va_end(v); // expected-error{{implicitly declaring library function}} expected-note{{provide a declaration}} expected-error{{undeclared identifier}}
+__va_copy(g, v); // expected-error{{implicit declaration of function}} expected-error{{undeclared identifier}}
+va_copy(g, v); // expected-error{{implicitly declaring library function}} expected-note{{provide a declaration}} expected-error{{undeclared identifier}}
+}
+
+//--- stdargneeds2.c
+#define __need_va_list
+#include 
+static void f(int p, ...) {
+__gnuc_va_list g; // expected-error{{undeclared identifier}}
+va_list v;
+va_start(v, p); // expected-error{{implicitly declaring library function}} expected-note{{provide a declaration}}
+int i = va_arg(v, int); // expected-error{{implicit declaration of function}} expected-error{{expected expression}}
+va_end(v); // expected-error{{implicitly declaring library function}} expected-note{{provide a declaration}}
+__va_copy(g, v); // expected-error{{implicit declaration of function}} expected-error{{undeclared identifier}}
+va_copy(g, v); // expected-error{{implicitly declaring library function}} expected-note{{provide a declaration}} expected-error{{undeclared identifier}}
+}
+
+//--- stdargneeds3.c
+#define __need_va_list
+#define __need_va_arg
+#include 
+static void f(int p, ...) {
+__gnuc_va_list g; // expected-error{{undeclared identifier}}
+va_list v;
+va_start(v, p);
+int i = va_arg(v, int);
+va_end(v);
+__va_copy(g, v); // expected-error{{implicit declaration of function}} expected-error{{undeclared identifier}}
+va_copy(g, v); // expected-error{{implicitly declaring library function}} expected-note{{provide a declaration}} expected-error{{undeclared identifier}}
+}
+
+//--- stdargneeds4.c
+#define 

[PATCH] D157933: [OpenMP 5.1] Parsing and Sema support for `scope` construct

2023-08-14 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

Need to add the tests (and the checks, if required) for the nesting of the 
regions


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157933

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


[PATCH] D157925: [MachineOutliner][LTO] Enable outlining of linkonceodr functions on all targets.

2023-08-14 Thread David Tellenbach via Phabricator via cfe-commits
tellenbach accepted this revision.
tellenbach 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/D157925/new/

https://reviews.llvm.org/D157925

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


[PATCH] D157933: [OpenMP 5.1] Parsing and Sema support for `scope` construct

2023-08-14 Thread Fazlay Rabbi via Phabricator via cfe-commits
mdfazlay created this revision.
mdfazlay added reviewers: ABataev, jyu2, mikerice.
Herald added subscribers: steakhal, martong, arphaman, guansong, yaxunl.
Herald added a reviewer: NoQ.
Herald added a project: All.
mdfazlay requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: llvm-commits, cfe-commits, jplehr, sstefan1.
Herald added projects: clang, LLVM.

//#pragma omp scope [clause[ [,] clause] ... ]//
structured-block

where clause is one of the following:

private(list)
reduction([reduction-modifier ,] reduction-identifier : list)
nowait

Reference:
(1) OpenMP 5.1 Specification - Section 2.9 (Page 106)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D157933

Files:
  clang/include/clang-c/Index.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/AST/StmtOpenMP.h
  clang/include/clang/Basic/StmtNodes.td
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/lib/AST/StmtOpenMP.cpp
  clang/lib/AST/StmtPrinter.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/Basic/OpenMPKinds.cpp
  clang/lib/CodeGen/CGStmt.cpp
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Sema/SemaExceptionSpec.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
  clang/test/OpenMP/scope_ast_print.cpp
  clang/test/OpenMP/scope_messages.cpp
  clang/tools/libclang/CIndex.cpp
  clang/tools/libclang/CXCursor.cpp
  llvm/include/llvm/Frontend/OpenMP/OMP.td

Index: llvm/include/llvm/Frontend/OpenMP/OMP.td
===
--- llvm/include/llvm/Frontend/OpenMP/OMP.td
+++ llvm/include/llvm/Frontend/OpenMP/OMP.td
@@ -1979,6 +1979,15 @@
 def OMP_EndAssumes : Directive<"end assumes"> {}
 def OMP_BeginDeclareVariant : Directive<"begin declare variant"> {}
 def OMP_EndDeclareVariant : Directive<"end declare variant"> {}
+def OMP_scope : Directive<"scope"> {
+  let allowedClauses = [
+VersionedClause,
+VersionedClause,
+  ];
+  let allowedOnceClauses = [
+VersionedClause
+  ];
+}
 def OMP_ParallelWorkshare : Directive<"parallel workshare"> {
   let allowedClauses = [
 VersionedClause,
Index: clang/tools/libclang/CXCursor.cpp
===
--- clang/tools/libclang/CXCursor.cpp
+++ clang/tools/libclang/CXCursor.cpp
@@ -680,6 +680,9 @@
   case Stmt::OMPSectionDirectiveClass:
 K = CXCursor_OMPSectionDirective;
 break;
+  case Stmt::OMPScopeDirectiveClass:
+K = CXCursor_OMPScopeDirective;
+break;
   case Stmt::OMPSingleDirectiveClass:
 K = CXCursor_OMPSingleDirective;
 break;
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -5889,6 +5889,8 @@
 return cxstring::createRef("OMPSectionsDirective");
   case CXCursor_OMPSectionDirective:
 return cxstring::createRef("OMPSectionDirective");
+  case CXCursor_OMPScopeDirective:
+return cxstring::createRef("OMPScopeDirective");
   case CXCursor_OMPSingleDirective:
 return cxstring::createRef("OMPSingleDirective");
   case CXCursor_OMPMasterDirective:
Index: clang/test/OpenMP/scope_messages.cpp
===
--- /dev/null
+++ clang/test/OpenMP/scope_messages.cpp
@@ -0,0 +1,192 @@
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=51 %s -verify=expected,omp51
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=51 %s -verify=expected,omp51
+
+void test1()
+{
+  int var1;
+  int var2;
+  int var3 = 1;
+
+  // expected-error@+1 {{directive '#pragma omp scope' cannot contain more than one 'nowait' clause}} //omp51-error@+1{{unexpected OpenMP clause 'firstprivate' in directive '#pragma omp scope'}}
+  #pragma omp scope private(var1) firstprivate(var3) nowait nowait
+  { var1 = 123; ++var2; var3 = 2;}
+}
+
+void bar();
+
+void test2() {
+#pragma omp for
+  for (int i = 0; i < 10; ++i) {
+#pragma omp scope // expected-error {{region cannot be closely nested inside 'for' region}}
+bar();
+  }
+
+#pragma omp for simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp scope // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+bar();
+  }
+
+#pragma omp sections
+  {
+#pragma omp scope // expected-error {{region cannot be closely nested inside 'sections' region}}
+bar();
+  }
+
+#pragma omp sections
+  {
+#pragma omp section
+{
+#pragma omp scope // expected-error {{region cannot be closely nested inside 'section' region}}
+  bar();
+}
+  }
+
+#pragma omp single
+  {
+#pragma omp scope // expected-error {{region cannot be closely nested inside 'single' region}}
+bar();
+  }
+
+#pragma omp master
+  {
+#pragma omp scope // expected-error {{region cannot be closely nested inside 'master' 

[PATCH] D157738: [OpenMP] Emit offloading entries for indirect target variables

2023-08-14 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 marked an inline comment as done.
jhuber6 added inline comments.



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:1996-1997
+llvm::GlobalValue *GV) {
+  std::optional ActiveAttr =
+  OMPDeclareTargetDeclAttr::getActiveAttr(FD);
+

arsenm wrote:
> not a huge fan of std::optional
This is pretty far entrenched in the Clang handling for this attribute so I 
don't intend to change it here.



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:2022
+  OMPBuilder.OffloadInfoManager.registerDeviceGlobalVarEntryInfo(
+  Name, Addr, CGM.getContext().getTypeSize(CGM.getContext().VoidPtrTy) / 8,
+  llvm::OffloadEntriesInfoManager::OMPTargetGlobalVarEntryIndirect,

arsenm wrote:
> isn't there a store size?
Yeah I can use that instead.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157738

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


[PATCH] D156726: Make globals with mutable members non-constant, even in custom sections

2023-08-14 Thread David Blaikie 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 rG19f2b68095fe: Make globals with mutable members 
non-constant, even in custom sections (authored by dblaikie).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156726

Files:
  clang/include/clang/AST/Type.h
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/AST/Type.cpp
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/CodeGen/CGDeclCXX.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGExprConstant.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/lib/CodeGen/Targets/AMDGPU.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/test/CodeGenCXX/sections.cpp
  clang/test/SemaCXX/attr-section.cpp

Index: clang/test/SemaCXX/attr-section.cpp
===
--- clang/test/SemaCXX/attr-section.cpp
+++ clang/test/SemaCXX/attr-section.cpp
@@ -48,3 +48,24 @@
 const int const_global_var __attribute__((section("template_fn1"))) = 42;   // expected-error {{'const_global_var' causes a section type conflict with 'template_fn1'}}
 int mut_global_var __attribute__((section("template_fn2"))) = 42;   // expected-note {{declared here}}
 template  __attribute__((section("template_fn2"))) void template_fn2() {} // expected-error {{'template_fn2' causes a section type conflict with 'mut_global_var'}}
+
+namespace mutable_member {
+struct t1 {
+  mutable int i;
+};
+extern const t1 v1;
+__attribute__((section("mutable_member"))) const t1 v1{};
+extern int i;
+__attribute__((section("mutable_member"))) int i{};
+} // namespace mutable_member
+
+namespace non_trivial_ctor {
+struct t1 {
+  t1();
+  constexpr t1(int) { }
+};
+extern const t1 v1;
+__attribute__((section("non_trivial_ctor"))) const t1 v1; // expected-note {{declared here}}
+extern const t1 v2;
+__attribute__((section("non_trivial_ctor"))) const t1 v2{3}; // expected-error {{'v2' causes a section type conflict with 'v1'}}
+} // namespace non_trivial_ctor
Index: clang/test/CodeGenCXX/sections.cpp
===
--- clang/test/CodeGenCXX/sections.cpp
+++ clang/test/CodeGenCXX/sections.cpp
@@ -1,12 +1,36 @@
-// RUN: %clang_cc1 -emit-llvm -triple i686-pc-win32 -fms-extensions -o - %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -triple i686-pc-win32 -fms-extensions -verify -o - %s | FileCheck %s
 
 extern "C" {
 
+struct Mutable {
+mutable int i = 3;
+};
+extern const Mutable mutable_default_section;
+const Mutable mutable_default_section;
+struct Normal {
+  int i = 2;
+};
+extern const Normal normal_default_section;
+const Normal normal_default_section;
 #pragma const_seg(".my_const")
 #pragma bss_seg(".my_bss")
 int D = 1;
 #pragma data_seg(".data")
 int a = 1;
+extern const Mutable mutable_custom_section;
+const Mutable mutable_custom_section; // expected-warning {{`#pragma const_seg` for section ".my_const" will not apply to 'mutable_custom_section' due to the presence of a mutable field}}
+extern const Normal normal_custom_section;
+const Normal normal_custom_section;
+struct NonTrivialDtor {
+  ~NonTrivialDtor();
+};
+extern const NonTrivialDtor non_trivial_dtor_custom_section;
+const NonTrivialDtor non_trivial_dtor_custom_section; // expected-warning {{`#pragma const_seg` for section ".my_const" will not apply to 'non_trivial_dtor_custom_section' due to the presence of a non-trivial destructor}}
+struct NonTrivialCtor {
+  NonTrivialCtor();
+};
+extern const NonTrivialCtor non_trivial_ctor_custom_section;
+const NonTrivialCtor non_trivial_ctor_custom_section; // expected-warning {{`#pragma const_seg` for section ".my_const" will not apply to 'non_trivial_ctor_custom_section' due to the presence of a non-trivial constructor}}
 #pragma data_seg(push, label, ".data2")
 extern const int b;
 const int b = 1;
@@ -74,10 +98,19 @@
 #pragma section("short_section", short)
 // Pragma section ignores "short".
 __declspec(allocate("short_section")) short short_var = 42;
+
+struct t2 { t2(); };
+extern const t2 non_trivial_ctor;
+__declspec(allocate("non_trivial_ctor_section")) const t2 non_trivial_ctor_var;
 }
 
+
+//CHECK: @mutable_default_section = dso_local global %struct.Mutable { i32 3 }, align 4{{$}}
+//CHECK: @normal_default_section = dso_local constant %struct.Normal { i32 2 }, align 4{{$}}
 //CHECK: @D = dso_local global i32 1
 //CHECK: @a = dso_local global i32 1, section ".data"
+//CHECK: @mutable_custom_section = dso_local global %struct.Mutable { i32 3 }, section ".data", align 4
+//CHECK: @normal_custom_section = dso_local constant %struct.Normal { i32 2 }, section ".my_const", align 4
 //CHECK: @b = dso_local constant i32 1, section ".my_const"
 //CHECK: @[[MYSTR:.*]] = {{.*}} unnamed_addr constant [11 x i8] c"my 

[clang] 19f2b68 - Make globals with mutable members non-constant, even in custom sections

2023-08-14 Thread David Blaikie via cfe-commits

Author: David Blaikie
Date: 2023-08-14T22:25:42Z
New Revision: 19f2b68095fe727e40079b7c6380b36b6462e691

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

LOG: Make globals with mutable members non-constant, even in custom sections

Turned out we were making overly simple assumptions about which sections (& 
section flags) would be used when emitting a global into a custom section. This 
lead to sections with read-only flags being used for globals of struct types 
with mutable members.

Fixed by porting the codegen function with the more nuanced handling/checking 
for mutable members out of codegen for use in the sema code that does this 
initial checking/mapping to section flags.

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

Added: 


Modified: 
clang/include/clang/AST/Type.h
clang/include/clang/Basic/DiagnosticGroups.td
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/AST/Type.cpp
clang/lib/CodeGen/CGDecl.cpp
clang/lib/CodeGen/CGDeclCXX.cpp
clang/lib/CodeGen/CGExpr.cpp
clang/lib/CodeGen/CGExprConstant.cpp
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/CodeGen/CodeGenModule.h
clang/lib/CodeGen/Targets/AMDGPU.cpp
clang/lib/Sema/SemaDecl.cpp
clang/test/CodeGenCXX/sections.cpp
clang/test/SemaCXX/attr-section.cpp

Removed: 




diff  --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index 82a68e332765e8..ed424ffb748014 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -817,6 +817,26 @@ class QualType {
   /// Determine whether this type is const-qualified.
   bool isConstQualified() const;
 
+  enum class NonConstantStorageReason {
+MutableField,
+NonConstNonReferenceType,
+NonTrivialCtor,
+NonTrivialDtor,
+  };
+  /// Determine whether instances of this type can be placed in immutable
+  /// storage.
+  /// If ExcludeCtor is true, the duration when the object's constructor runs
+  /// will not be considered. The caller will need to verify that the object is
+  /// not written to during its construction. ExcludeDtor works similarly.
+  std::optional
+  isNonConstantStorage(const ASTContext , bool ExcludeCtor,
+   bool ExcludeDtor);
+
+  bool isConstantStorage(const ASTContext , bool ExcludeCtor,
+ bool ExcludeDtor) {
+return !isNonConstantStorage(Ctx, ExcludeCtor, ExcludeDtor);
+  }
+
   /// Determine whether this particular QualType instance has the
   /// "restrict" qualifier set, without looking through typedefs that may have
   /// added "restrict" at a 
diff erent level.

diff  --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index 990f223f755490..6f8386cd10922f 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -446,6 +446,7 @@ def IgnoredQualifiers : DiagGroup<"ignored-qualifiers", 
[IgnoredReferenceQualifi
 def : DiagGroup<"import">;
 def GNUIncludeNext : DiagGroup<"gnu-include-next">;
 def IncompatibleMSStruct : DiagGroup<"incompatible-ms-struct">;
+def IncompatibleMSPragmaSection : DiagGroup<"incompatible-ms-pragma-section">;
 def IncompatiblePointerTypesDiscardsQualifiers
   : DiagGroup<"incompatible-pointer-types-discards-qualifiers">;
 def IncompatibleFunctionPointerTypes

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 95f8f0247d4b78..935fad819b82a4 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -996,6 +996,9 @@ def warn_cxx_ms_struct :
 def err_pragma_pack_identifer_not_supported : Error<
   "specifying an identifier within `#pragma pack` is not supported on this 
target">;
 def err_section_conflict : Error<"%0 causes a section type conflict with %1">;
+def warn_section_msvc_compat : Warning<"`#pragma const_seg` for section %1 
will"
+  " not apply to %0 due to the presence of a %select{mutable 
field||non-trivial constructor|non-trivial destructor}2">,
+  InGroup;
 def err_no_base_classes : Error<"invalid use of '__super', %0 has no base 
classes">;
 def err_invalid_super_scope : Error<"invalid use of '__super', "
   "this keyword can only be used inside class or member function scope">;

diff  --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp
index b3fd6fc3d823e2..e023cb46b9bb85 100644
--- a/clang/lib/AST/Type.cpp
+++ b/clang/lib/AST/Type.cpp
@@ -112,6 +112,25 @@ bool QualType::isConstant(QualType T, const ASTContext 
) {
   return T.getAddressSpace() == LangAS::opencl_constant;
 }
 
+std::optional
+QualType::isNonConstantStorage(const ASTContext , bool ExcludeCtor,
+bool 

[PATCH] D74094: Reapply: [IRGen] Emit lifetime intrinsics around temporary aggregate argument allocas

2023-08-14 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment.

In D74094#4566543 , @nickdesaulniers 
wrote:

> Hi @lei can you please help us retest this version of this patch that 
> previously broke your multistage build?
> https://reviews.llvm.org/rGfafc6e4fdf3673dcf557d6c8ae0c0a4bb3184402#890444

ping @lei


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74094

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


[PATCH] D157808: [clang] Add missing field to VisibilityAttr json AST dump

2023-08-14 Thread Douglas Yung via Phabricator via cfe-commits
dyung added a comment.

Hi @serge-sans-paille, your change is causing the test you modified, 
`clang/test/AST/ast-dump-attr-json.cpp` to fail. Can you take a look?

https://lab.llvm.org/buildbot/#/builders/139/builds/47461
https://lab.llvm.org/buildbot/#/builders/109/builds/71264


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157808

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


[PATCH] D157738: [OpenMP] Emit offloading entries for indirect target variables

2023-08-14 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a comment.

Ok, I'm really sure this needs to be reflected in the type system.  for 
some target foo gets to be larger than 8 bytes and we use a different calling 
convention for it. Otherwise however we carve this the type erasure is going to 
make unrelated calls acquire the dynamic search overhead.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157738

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


[PATCH] D157925: [MachineOutliner][LTO] Enable outlining of linkonceodr functions on all targets.

2023-08-14 Thread Jon Roelofs via Phabricator via cfe-commits
jroelofs created this revision.
jroelofs added reviewers: aemerson, tellenbach.
Herald added subscribers: ormris, inglorion.
Herald added a project: All.
jroelofs requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay.
Herald added a project: clang.

... that have the outliner enabled.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D157925

Files:
  clang/lib/Driver/ToolChains/Darwin.cpp
  clang/test/Driver/darwin-ld.c


Index: clang/test/Driver/darwin-ld.c
===
--- clang/test/Driver/darwin-ld.c
+++ clang/test/Driver/darwin-ld.c
@@ -358,11 +358,31 @@
 // Check that we can pass the outliner down to the linker.
 // RUN: env IPHONEOS_DEPLOYMENT_TARGET=7.0 \
 // RUN:   %clang -target arm64-apple-darwin -moutline -### %t.o 2> %t.log
-// RUN: FileCheck -check-prefix=MOUTLINE %s < %t.log
-// MOUTLINE: {{ld(.exe)?"}}
-// MOUTLINE-SAME: "-mllvm" "-enable-machine-outliner" "-mllvm" 
"-enable-linkonceodr-outlining"
+// RUN: FileCheck -check-prefix=ARM64-MOUTLINE %s < %t.log
+// ARM64-MOUTLINE: {{ld(.exe)?"}}
+// ARM64-MOUTLINE-SAME: "-mllvm" "-enable-machine-outliner" "-mllvm" 
"-enable-linkonceodr-outlining"
+// RUN: env IPHONEOS_DEPLOYMENT_TARGET=7.0 \
+// RUN:   %clang -target arm64e-apple-darwin -moutline -### %t.o 2> %t.log
+// RUN: FileCheck -check-prefix=ARM64E-MOUTLINE %s < %t.log
+// ARM64E-MOUTLINE: {{ld(.exe)?"}}
+// ARM64E-MOUTLINE-SAME: "-mllvm" "-enable-linkonceodr-outlining"
+// RUN: env IPHONEOS_DEPLOYMENT_TARGET=7.0 \
+// RUN:   %clang -target armv7em-apple-darwin -moutline -### %t.o 2> %t.log
+// RUN: FileCheck -check-prefix=ARMV7EM-MOUTLINE %s < %t.log
+// ARMV7EM-MOUTLINE: {{ld(.exe)?"}}
+// ARMV7EM-MOUTLINE-SAME: "-mllvm" "-enable-linkonceodr-outlining"
 // RUN: env IPHONEOS_DEPLOYMENT_TARGET=7.0 \
 // RUN:   %clang -target arm64-apple-darwin -mno-outline -### %t.o 2> %t.log
-// RUN: FileCheck -check-prefix=MNO_OUTLINE %s < %t.log
-// MNO_OUTLINE: {{ld(.exe)?"}}
-// MNO_OUTLINE-SAME: "-mllvm" "-enable-machine-outliner=never"
+// RUN: FileCheck -check-prefix=ARM64-MNO_OUTLINE %s < %t.log
+// ARM64-MNO_OUTLINE: {{ld(.exe)?"}}
+// ARM64-MNO_OUTLINE-SAME: "-mllvm" "-enable-machine-outliner=never" "-mllvm" 
"-enable-linkonceodr-outlining"
+// RUN: env IPHONEOS_DEPLOYMENT_TARGET=7.0 \
+// RUN:   %clang -target arm64e-apple-darwin -mno-outline -### %t.o 2> %t.log
+// RUN: FileCheck -check-prefix=ARM64E-MNO_OUTLINE %s < %t.log
+// ARM64E-MNO_OUTLINE: {{ld(.exe)?"}}
+// ARM64E-MNO_OUTLINE-SAME: "-mllvm" "-enable-machine-outliner=never" "-mllvm" 
"-enable-linkonceodr-outlining"
+// RUN: env IPHONEOS_DEPLOYMENT_TARGET=7.0 \
+// RUN:   %clang -target armv7em-apple-darwin -mno-outline -### %t.o 2> %t.log
+// RUN: FileCheck -check-prefix=ARMV7EM-MNO_OUTLINE %s < %t.log
+// ARMV7EM-MNO_OUTLINE: {{ld(.exe)?"}}
+// ARMV7EM-MNO_OUTLINE-SAME: "-mllvm" "-enable-machine-outliner=never" 
"-mllvm" "-enable-linkonceodr-outlining"
\ No newline at end of file
Index: clang/lib/Driver/ToolChains/Darwin.cpp
===
--- clang/lib/Driver/ToolChains/Darwin.cpp
+++ clang/lib/Driver/ToolChains/Darwin.cpp
@@ -615,10 +615,6 @@
   if (getMachOToolChain().getMachOArchName(Args) == "arm64") {
 CmdArgs.push_back("-mllvm");
 CmdArgs.push_back("-enable-machine-outliner");
-
-// Outline from linkonceodr functions by default in LTO.
-CmdArgs.push_back("-mllvm");
-CmdArgs.push_back("-enable-linkonceodr-outlining");
   }
 } else {
   // Disable all outlining behaviour if we have mno-outline. We need to do
@@ -629,6 +625,12 @@
 }
   }
 
+  // Outline from linkonceodr functions by default in LTO, whenever the 
outliner
+  // is enabled.  Note that the target may enable the machine outliner
+  // independently of -moutline.
+  CmdArgs.push_back("-mllvm");
+  CmdArgs.push_back("-enable-linkonceodr-outlining");
+
   // Setup statistics file output.
   SmallString<128> StatsFile =
   getStatsFileName(Args, Output, Inputs[0], getToolChain().getDriver());


Index: clang/test/Driver/darwin-ld.c
===
--- clang/test/Driver/darwin-ld.c
+++ clang/test/Driver/darwin-ld.c
@@ -358,11 +358,31 @@
 // Check that we can pass the outliner down to the linker.
 // RUN: env IPHONEOS_DEPLOYMENT_TARGET=7.0 \
 // RUN:   %clang -target arm64-apple-darwin -moutline -### %t.o 2> %t.log
-// RUN: FileCheck -check-prefix=MOUTLINE %s < %t.log
-// MOUTLINE: {{ld(.exe)?"}}
-// MOUTLINE-SAME: "-mllvm" "-enable-machine-outliner" "-mllvm" "-enable-linkonceodr-outlining"
+// RUN: FileCheck -check-prefix=ARM64-MOUTLINE %s < %t.log
+// ARM64-MOUTLINE: {{ld(.exe)?"}}
+// ARM64-MOUTLINE-SAME: "-mllvm" "-enable-machine-outliner" "-mllvm" "-enable-linkonceodr-outlining"
+// RUN: env IPHONEOS_DEPLOYMENT_TARGET=7.0 \
+// RUN:   %clang -target arm64e-apple-darwin -moutline -### %t.o 2> %t.log
+// 

[PATCH] D157332: [clang] Make init for empty no_unique_address fields a no-op write

2023-08-14 Thread Eli Friedman via Phabricator via cfe-commits
efriedma accepted this revision.
efriedma added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157332

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


[PATCH] D157738: [OpenMP] Emit offloading entries for indirect target variables

2023-08-14 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added inline comments.



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:1996-1997
+llvm::GlobalValue *GV) {
+  std::optional ActiveAttr =
+  OMPDeclareTargetDeclAttr::getActiveAttr(FD);
+

not a huge fan of std::optional



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:2017
+/*isConstant=*/true,
+llvm::GlobalValue::ExternalLinkage, GV, 
Name);
+Addr->setVisibility(llvm::GlobalValue::ProtectedVisibility);

target global address space



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:2022
+  OMPBuilder.OffloadInfoManager.registerDeviceGlobalVarEntryInfo(
+  Name, Addr, CGM.getContext().getTypeSize(CGM.getContext().VoidPtrTy) / 8,
+  llvm::OffloadEntriesInfoManager::OMPTargetGlobalVarEntryIndirect,

isn't there a store size?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157738

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


[PATCH] D157738: [OpenMP] Emit offloading entries for indirect target variables

2023-08-14 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a comment.

If calling an indirect function pointer on the GPU requires a table lookup 
(keyed by host function addresses, which I didn't think we knew at GPU compile 
time), and we cannot distinguish indirect function pointers from function 
pointers, then this feature must send _every_ indirect call on the GPU through 
the table search in case it hits in the table and then branch on the value if 
it doesn't.

So if we have a few indirect openmp functions and then we call a function which 
makes indirect calls of a function pointer which happened to be unrelated to 
this feature, it's going to search that table anyway. Say qsort on a 
non-inlined comparison function.

This feature, as I understand it so far, therefore induces a global slowdown on 
every call to an unknown function. Slow function calls are a bad thing.

What am I missing?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157738

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


[PATCH] D157738: [OpenMP] Emit offloading entries for indirect target variables

2023-08-14 Thread Ravi Narayanaswamy via Phabricator via cfe-commits
RaviNarayanaswamy added a comment.

In D157738#4586465 , @JonChesterfield 
wrote:

>> calling device functions via their associated host pointer
>
> What does this mean? Defining a function foo such that the host and each 
> individual target each have their own machine code for it, such that  on 
> the host can be copied over to the target and then invoked to mean call the 
> function on the local target with the same name?
>
> If so, calling through the pointer  on the GPU doing a logarithmic search 
> through a table to choose a function address to branch to sounds like 
> something that will codegen into very slow code. Does it do that search on 
> every call?
>
> Is there an ambition to have  on the host and  on the (each) target 
> return the same value, in the pointer equality sense?
>
> Searching the linked spec for indirect finds the following
>
>> If the indirect clause is present and invoked-by-fptr evaluates to true, any 
>> procedures that appear in a to clause on the directive may be called with an 
>> indirect device invocation. If the indirect clause is present and 
>> invoked-by-fptr does not evaluate to true, any procedures that appear in a 
>> to clause on the directive may not be called with an indirect device 
>> invocation. Unless otherwise specified by an indirect clause, procedures may 
>> not be called with an indirect device invocation.
>
> Which tells me that the indirect clause means procedures can be called with 
> an indirect device invocation. Searching for the expression "indirect device 
> invocation" finds that paragraph and nothing else. So... where does the spec 
> say what this thing is?

Only indirect calls on the device will do a search the table.  The spec does 
not say how it should be implemented.  One could do the  translation at the 
target region when it is mapped on the host but this  will not handle all the  
cases.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157738

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


[PATCH] D157452: [RFC][Clang][Codegen] `std::type_info` needs special care with explicit address spaces

2023-08-14 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

The path of least resistance here is that IRGen should just insert conversions 
from the global AS to the default AS as part of evaluating `typeid`.  I haven't 
looked at it closely, but that seems to be what this patch is doing.

However, `std::type_info` is an interesting special case in that we actually 
know statically that all objects of that type will be allocated in the global 
AS, so there's really no reason to pass around pointers in the default AS; 
`std::type_info *` should just default to being in the global AS.  It'd be a 
non-trivial feature in supported of a somewhat uncommonly-used C++ feature, and 
I can't tell how best to spend your time, *but*... if you're so inclined, I 
think it would make a somewhat compelling feature to be able to declare a 
default AS for a class type, which your target could then adopt in the C++ std 
headers.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157452

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


[PATCH] D156726: Make globals with mutable members non-constant, even in custom sections

2023-08-14 Thread Eli Friedman via Phabricator via cfe-commits
efriedma accepted this revision.
efriedma added a comment.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156726

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


[PATCH] D156726: Make globals with mutable members non-constant, even in custom sections

2023-08-14 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added inline comments.



Comment at: clang/lib/Sema/SemaDecl.cpp:14254
 int SectionFlags = ASTContext::PSF_Read;
-if (var->getType().isConstQualified()) {
-  if (HasConstInit)

rnk wrote:
> efriedma wrote:
> > dblaikie wrote:
> > > efriedma wrote:
> > > > dblaikie wrote:
> > > > > rnk wrote:
> > > > > > rsmith wrote:
> > > > > > > efriedma wrote:
> > > > > > > > rnk wrote:
> > > > > > > > > I think this is not compatible with MSVC. MSVC uses simple 
> > > > > > > > > logic, it doesn't look for mutable: 
> > > > > > > > > https://gcc.godbolt.org/z/sj6d4saxx
> > > > > > > > > 
> > > > > > > > > The const mutable struct appears in the myrdata section in 
> > > > > > > > > that example.
> > > > > > > > > 
> > > > > > > > > I think the solution is to separate the flag logic from the 
> > > > > > > > > pragma stack selection logic, which has to remain 
> > > > > > > > > MSVC-compatible.
> > > > > > > > MSVC apparently looks at whether the variable is marked 
> > > > > > > > "const", and nothing else; it doesn't look at mutable, it 
> > > > > > > > doesn't look at whether the variable has a constant 
> > > > > > > > initializer.  So the current code isn't right either; if we're 
> > > > > > > > trying to implement MSVC-compatible logic, we shouldn't check 
> > > > > > > > HasConstInit.
> > > > > > > > 
> > > > > > > > That said, I'm not sure how precisely/in what modes we want to 
> > > > > > > > precisely emulate MSVC.  Probably anything we do here will be 
> > > > > > > > confusing.
> > > > > > > We should at least issue a warning if the sensible logic and the 
> > > > > > > MSVC-compatible calculation differ. @rnk, do you know how 
> > > > > > > important it is to follow the MSVC semantics in this regard?
> > > > > > I think it depends on whether you think that users are primarily 
> > > > > > using these pragmas to override the default rdata/bss/data sections 
> > > > > > without any care about precisely what goes where, or if they are 
> > > > > > using them to do something finer grained.
> > > > > > 
> > > > > > If I had to guess, I'd say it's more likely the former, given that 
> > > > > > `__declspec(allocate)` and `#pragma(section)` exist to handle cases 
> > > > > > where users are putting specific globals into specific sections.
> > > > > > 
> > > > > > Which, if we follow Richard's suggestion, would mean warning when 
> > > > > > we put a global marked `const` into a writable section when 
> > > > > > `ConstSegStack` is non-empty. That seems reasonable. 
> > > > > > `-Wmicrosoft-const-seg` for the new warning group?
> > > > > Does the MSVC situation only apply to custom sections? (presumably 
> > > > > when not customizing the section, MSVC gets it right and can support 
> > > > > a const global with a runtime initializer, mutable member, or 
> > > > > mutating dtor?)
> > > > > 
> > > > > I think this code still needs to be modified, since this is the code 
> > > > > that drives the error about incompatible sections. So it'll need to 
> > > > > behave differently depending on the target platform?
> > > > Yes, the MSVC situation is specifically if you specify `#pragma 
> > > > const_seg`; without the pragma, it does what you'd expect.
> > > Went with the "let's do the thing that the user probably wants, but isn't 
> > > what MSVC does, and warn when that difference comes up" - if that's OK 
> > > with everyone.
> > > 
> > > (always open to wordsmithing the warning - and if we want to, can go to 
> > > the extra layer and specifically diagnose which reason (mutable members, 
> > > non-const init) - and I can't quite figure out the best phrasing to say 
> > > "we're putting it in section X insetad of section Y, because Z, but 
> > > Microsoft would use X because A" or something... it's all a bit of a 
> > > mouthful)
> > Describing which reason actually applies would make the warning a lot 
> > easier to read.
> That is true, but I think very few people will see this diagnostic. I'm not 
> sure it's worth the added code complexity to implement that improvement.
Updated with a specific diagnosis. Phrasing still feels a bit awkward/I'm open 
to wordsmithing suggestions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156726

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


[PATCH] D156726: Make globals with mutable members non-constant, even in custom sections

2023-08-14 Thread David Blaikie via Phabricator via cfe-commits
dblaikie updated this revision to Diff 550097.
dblaikie added a comment.

Diagnose specific reasons


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156726

Files:
  clang/include/clang/AST/Type.h
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/AST/Type.cpp
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/CodeGen/CGDeclCXX.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGExprConstant.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/lib/CodeGen/Targets/AMDGPU.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/test/CodeGenCXX/sections.cpp
  clang/test/SemaCXX/attr-section.cpp

Index: clang/test/SemaCXX/attr-section.cpp
===
--- clang/test/SemaCXX/attr-section.cpp
+++ clang/test/SemaCXX/attr-section.cpp
@@ -48,3 +48,24 @@
 const int const_global_var __attribute__((section("template_fn1"))) = 42;   // expected-error {{'const_global_var' causes a section type conflict with 'template_fn1'}}
 int mut_global_var __attribute__((section("template_fn2"))) = 42;   // expected-note {{declared here}}
 template  __attribute__((section("template_fn2"))) void template_fn2() {} // expected-error {{'template_fn2' causes a section type conflict with 'mut_global_var'}}
+
+namespace mutable_member {
+struct t1 {
+  mutable int i;
+};
+extern const t1 v1;
+__attribute__((section("mutable_member"))) const t1 v1{};
+extern int i;
+__attribute__((section("mutable_member"))) int i{};
+} // namespace mutable_member
+
+namespace non_trivial_ctor {
+struct t1 {
+  t1();
+  constexpr t1(int) { }
+};
+extern const t1 v1;
+__attribute__((section("non_trivial_ctor"))) const t1 v1; // expected-note {{declared here}}
+extern const t1 v2;
+__attribute__((section("non_trivial_ctor"))) const t1 v2{3}; // expected-error {{'v2' causes a section type conflict with 'v1'}}
+} // namespace non_trivial_ctor
Index: clang/test/CodeGenCXX/sections.cpp
===
--- clang/test/CodeGenCXX/sections.cpp
+++ clang/test/CodeGenCXX/sections.cpp
@@ -1,12 +1,36 @@
-// RUN: %clang_cc1 -emit-llvm -triple i686-pc-win32 -fms-extensions -o - %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -triple i686-pc-win32 -fms-extensions -verify -o - %s | FileCheck %s
 
 extern "C" {
 
+struct Mutable {
+mutable int i = 3;
+};
+extern const Mutable mutable_default_section;
+const Mutable mutable_default_section;
+struct Normal {
+  int i = 2;
+};
+extern const Normal normal_default_section;
+const Normal normal_default_section;
 #pragma const_seg(".my_const")
 #pragma bss_seg(".my_bss")
 int D = 1;
 #pragma data_seg(".data")
 int a = 1;
+extern const Mutable mutable_custom_section;
+const Mutable mutable_custom_section; // expected-warning {{`#pragma const_seg` for section ".my_const" will not apply to 'mutable_custom_section' due to the presence of a mutable field}}
+extern const Normal normal_custom_section;
+const Normal normal_custom_section;
+struct NonTrivialDtor {
+  ~NonTrivialDtor();
+};
+extern const NonTrivialDtor non_trivial_dtor_custom_section;
+const NonTrivialDtor non_trivial_dtor_custom_section; // expected-warning {{`#pragma const_seg` for section ".my_const" will not apply to 'non_trivial_dtor_custom_section' due to the presence of a non-trivial destructor}}
+struct NonTrivialCtor {
+  NonTrivialCtor();
+};
+extern const NonTrivialCtor non_trivial_ctor_custom_section;
+const NonTrivialCtor non_trivial_ctor_custom_section; // expected-warning {{`#pragma const_seg` for section ".my_const" will not apply to 'non_trivial_ctor_custom_section' due to the presence of a non-trivial constructor}}
 #pragma data_seg(push, label, ".data2")
 extern const int b;
 const int b = 1;
@@ -74,10 +98,19 @@
 #pragma section("short_section", short)
 // Pragma section ignores "short".
 __declspec(allocate("short_section")) short short_var = 42;
+
+struct t2 { t2(); };
+extern const t2 non_trivial_ctor;
+__declspec(allocate("non_trivial_ctor_section")) const t2 non_trivial_ctor_var;
 }
 
+
+//CHECK: @mutable_default_section = dso_local global %struct.Mutable { i32 3 }, align 4{{$}}
+//CHECK: @normal_default_section = dso_local constant %struct.Normal { i32 2 }, align 4{{$}}
 //CHECK: @D = dso_local global i32 1
 //CHECK: @a = dso_local global i32 1, section ".data"
+//CHECK: @mutable_custom_section = dso_local global %struct.Mutable { i32 3 }, section ".data", align 4
+//CHECK: @normal_custom_section = dso_local constant %struct.Normal { i32 2 }, section ".my_const", align 4
 //CHECK: @b = dso_local constant i32 1, section ".my_const"
 //CHECK: @[[MYSTR:.*]] = {{.*}} unnamed_addr constant [11 x i8] c"my string!\00"
 //CHECK: @s = dso_local global ptr @[[MYSTR]], section ".data2"
@@ -96,6 +129,7 @@
 //CHECK: @implicitly_read_write = dso_local global i32 42, section 

[PATCH] D156821: [CodeGen] [ubsan] Respect integer overflow handling in abs builtin

2023-08-14 Thread Eli Friedman via Phabricator via cfe-commits
efriedma accepted this revision.
efriedma added a comment.
This revision is now accepted and ready to land.

LGTM


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

https://reviews.llvm.org/D156821

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


[PATCH] D157738: [OpenMP] Emit offloading entries for indirect target variables

2023-08-14 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added a comment.

In D157738#4586465 , @JonChesterfield 
wrote:

>> calling device functions via their associated host pointer
>
> What does this mean? Defining a function foo such that the host and each 
> individual target each have their own machine code for it, such that  on 
> the host can be copied over to the target and then invoked to mean call the 
> function on the local target with the same name?
>
> If so, calling through the pointer  on the GPU doing a logarithmic search 
> through a table to choose a function address to branch to sounds like 
> something that will codegen into very slow code. Does it do that search on 
> every call?
>
> Is there an ambition to have  on the host and  on the target return 
> the same value, in the pointer equality sense?

That's exactly what it means, the mapping is only done for targets with 
`indirect` declared on them. The indirect calls themselves, I think @jdoerfert 
is implementing some specialization? He just asked me to implement this since 
it's related to copying of virtual classes to the device.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157738

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


[PATCH] D157738: [OpenMP] Emit offloading entries for indirect target variables

2023-08-14 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a comment.

> calling device functions via their associated host pointer

What does this mean? Defining a function foo such that the host and each 
individual target each have their own machine code for it, such that  can 
be copied over to the target and then invoked to mean call the function on the 
local target with the same name?

If so, calling through the pointer  on the GPU doing a logarithmic search 
through a table to choose a function address to branch to sounds like something 
that will codegen into very slow code. Does it do that search on every call?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157738

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


[PATCH] D157757: [Headers] Replace __need_STDDEF_H_misc with specific __need_ macros

2023-08-14 Thread Ian Anderson via Phabricator via cfe-commits
iana marked an inline comment as done.
iana added inline comments.



Comment at: clang/lib/Headers/stddef.h:16
+defined(__need_wint_t) ||  
\
+(defined(__STDC_WANT_LIB_EXT1__) && __STDC_WANT_LIB_EXT1__ >= 1)
 

aaron.ballman wrote:
> C23 K.3.1.1p2: The functions, macros, and types declared or defined in K.3 
> and its subclauses are declared and defined by their respective headers if 
> __STDC_WANT_LIB_EXT1__ is defined as a macro which expands to the integer 
> constant 1 at the point in the source file where the appropriate header is 
> first included.
> 
> So I don't think this should be `>= 1`. Same below. (Though I notice we seem 
> to do this in other places, so perhaps that's more of a general cleanup we 
> should make?)
`>=1` is what stddef.h was already doing, so I'd vote do this later as general 
cleanup.



Comment at: clang/test/Headers/stddef.c:1-3
+// RUN: %clang_cc1 -fsyntax-only -triple x86_64-apple-macosx10.9.0 -verify=c99 
-std=c99 %s
+// RUN: %clang_cc1 -fsyntax-only -triple x86_64-apple-macosx10.9.0 -verify=c11 
-std=c11 %s
+// RUN: %clang_cc1 -fsyntax-only -triple x86_64-apple-macosx10.9.0 -verify=c23 
-std=c23 %s

aaron.ballman wrote:
> Are the triples necessary? Better if we can remove them.
They shouldn't be, I just copied them from stddefneeds.cpp, let me try getting 
rid of them



Comment at: clang/test/Headers/stddef.c:7
+
+ptrdiff_t p0; // c99-error{{unknown}} c11-error{{unknown}} c23-error{{unknown}}
+size_t s0; // c99-error{{unknown}} c11-error{{unknown}} c23-error{{unknown}}

aaron.ballman wrote:
> At least one of these `unknown` errors should be fully spelled out (the rest 
> can then be assumed to be the same wording as the long-form).
Let me know how this looks, I can just fully expand all of them if you prefer. 
I was going by stddefneeds.cpp as an example.



Comment at: clang/test/Headers/stddefneeds.c:1-2
+// RUN: %clang_cc1 -fsyntax-only -triple x86_64-apple-macosx10.9.0 -verify=c99 
-std=c99 %s
+// RUN: %clang_cc1 -fsyntax-only -triple x86_64-apple-macosx10.9.0 -verify=c23 
-std=c23 %s
+

aaron.ballman wrote:
> Do we need the triples?
Looks like no.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157757

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


[PATCH] D157757: [Headers] Replace __need_STDDEF_H_misc with specific __need_ macros

2023-08-14 Thread Ian Anderson via Phabricator via cfe-commits
iana updated this revision to Diff 550091.
iana marked 3 inline comments as done.
iana added a comment.

Review fixes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157757

Files:
  clang/lib/Headers/stddef.h
  clang/test/Headers/stddef.c
  clang/test/Headers/stddefneeds.c

Index: clang/test/Headers/stddefneeds.c
===
--- /dev/null
+++ clang/test/Headers/stddefneeds.c
@@ -0,0 +1,169 @@
+// RUN: %clang_cc1 -fsyntax-only -verify=c99 -std=c99 %s
+// RUN: %clang_cc1 -fsyntax-only -verify=c23 -std=c23 %s
+
+// Use C99 to verify that __need_ can be used to get types that wouldn't normally be available.
+
+struct astruct { char member; };
+
+ptrdiff_t p0; // c99-error{{unknown type name 'ptrdiff_t'}} c23-error{{unknown type}}
+size_t s0; // c99-error{{unknown type name 'size_t'}} c23-error{{unknown type}}
+rsize_t r0; // c99-error{{unknown type name 'rsize_t'}} c23-error{{unknown type}}
+wchar_t wc0; // c99-error{{unknown type name 'wchar_t'}} c23-error{{unknown type}}
+void *v0 = NULL; // c99-error{{use of undeclared identifier 'NULL'}} c23-error{{undeclared identifier}}
+nullptr_t n0; // c99-error{{unknown type name 'nullptr_t'}} c23-error{{unknown type}}
+static void f0(void) { unreachable(); } // c99-error{{call to undeclared function 'unreachable'}} c23-error{{undeclared identifier 'unreachable'}}
+max_align_t m0; // c99-error{{unknown type name 'max_align_t'}} c23-error{{unknown type}}
+size_t o0 = offsetof(struct astruct, member); // c99-error{{unknown type name 'size_t'}} c99-error{{call to undeclared function 'offsetof'}} c99-error{{expected expression}} c99-error{{use of undeclared identifier 'member'}} \
+ c23-error{{unknown type name 'size_t'}} c23-error{{undeclared identifier 'offsetof'}} c23-error{{expected expression}} c23-error{{use of undeclared identifier 'member'}}
+wint_t wi0; // c99-error{{unknown type name 'wint_t'}} c23-error{{unknown type}}
+
+#define __need_ptrdiff_t
+#include 
+
+ptrdiff_t p1;
+size_t s1; // c99-error{{unknown type}} c23-error{{unknown type}}
+rsize_t r1; // c99-error{{unknown type}} c23-error{{unknown type}}
+wchar_t wc1; // c99-error{{unknown type}} c23-error{{unknown type}}
+void *v1 = NULL; // c99-error{{undeclared identifier}} c23-error{{undeclared identifier}}
+nullptr_t n1; // c99-error{{unknown type}} c23-error{{unknown type}}
+static void f1(void) { unreachable(); } // c99-error{{undeclared function}} c23-error{{undeclared identifier}}
+max_align_t m1; // c99-error{{unknown type}} c23-error{{unknown type}}
+size_t o1 = offsetof(struct astruct, member); // c99-error{{unknown type}} c99-error{{expected expression}} c99-error{{undeclared identifier}} \
+ c23-error{{unknown type}} c23-error{{undeclared identifier}} c23-error{{expected expression}} c23-error{{undeclared identifier}}
+wint_t wi1; // c99-error{{unknown type}} c23-error{{unknown type}}
+
+#define __need_size_t
+#include 
+
+ptrdiff_t p2;
+size_t s2;
+rsize_t r2; // c99-error{{unknown type}} c23-error{{unknown type}}
+// c99-note@stddef.h:*{{'size_t' declared here}} c23-note@stddef.h:*{{'size_t' declared here}}
+wchar_t wc2; // c99-error{{unknown type}} c23-error{{unknown type}}
+void *v2 = NULL; // c99-error{{undeclared identifier}} c23-error{{undeclared identifier}}
+nullptr_t n2; // c99-error{{unknown type}} c23-error{{unknown type}}
+static void f2(void) { unreachable(); } // c99-error{{undeclared function}} c23-error{{undeclared identifier}}
+max_align_t m2; // c99-error{{unknown type}} c23-error{{unknown type}}
+size_t o2 = offsetof(struct astruct, member); // c99-error{{expected expression}} c99-error{{undeclared identifier}} \
+ c23-error{{undeclared identifier}} c23-error{{expected expression}} c23-error{{undeclared identifier}}
+wint_t wi2; // c99-error{{unknown type}} c23-error{{unknown type}}
+
+#define __need_rsize_t
+#include 
+
+ptrdiff_t p3;
+size_t s3;
+rsize_t r3;
+wchar_t wc3; // c99-error{{unknown type}} c23-error{{unknown type}}
+void *v3 = NULL; // c99-error{{undeclared identifier}} c23-error{{undeclared identifier}}
+nullptr_t n3; // c99-error{{unknown type}} c23-error{{unknown type}}
+static void f3(void) { unreachable(); } // c99-error{{undeclared function}} c23-error{{undeclared identifier}}
+max_align_t m3; // c99-error{{unknown type}} c23-error{{unknown type}}
+size_t o3 = offsetof(struct astruct, member); // c99-error{{expected expression}} c99-error{{undeclared identifier}} \
+ c23-error{{undeclared identifier}} c23-error{{expected expression}} c23-error{{undeclared identifier}}
+wint_t wi3; // c99-error{{unknown type}} c23-error{{unknown type}}
+
+#define __need_wchar_t
+#include 
+
+ptrdiff_t p4;
+size_t s4;
+rsize_t r4;

[PATCH] D157362: [RISCV] Add MC layer support for Zicfilp.

2023-08-14 Thread Yeting Kuo via Phabricator via cfe-commits
fakepaper56 updated this revision to Diff 550089.
fakepaper56 added a comment.

Address comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157362

Files:
  clang/test/Preprocessor/riscv-target-features.c
  llvm/docs/RISCVUsage.rst
  llvm/lib/Support/RISCVISAInfo.cpp
  llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
  llvm/lib/Target/RISCV/RISCVFeatures.td
  llvm/lib/Target/RISCV/RISCVInstrInfo.td
  llvm/test/CodeGen/RISCV/attributes.ll
  llvm/test/MC/RISCV/attribute-arch.s
  llvm/test/MC/RISCV/zicfilp-invalid.s
  llvm/test/MC/RISCV/zicfilp-valid.s

Index: llvm/test/MC/RISCV/zicfilp-valid.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/zicfilp-valid.s
@@ -0,0 +1,21 @@
+# RUN: llvm-mc %s -triple=riscv32 -mattr=+experimental-zicfilp -riscv-no-aliases -show-encoding \
+# RUN: | FileCheck -check-prefixes=CHECK-ASM %s
+# RUN: llvm-mc %s -triple=riscv64 -mattr=+experimental-zicfilp -riscv-no-aliases -show-encoding \
+# RUN: | FileCheck -check-prefixes=CHECK-ASM %s
+# RUN: llvm-mc -filetype=obj -triple=riscv32 -mattr=+experimental-zicfilp < %s \
+# RUN: | llvm-objdump --mattr=+experimental-zicfilp -d -r - \
+# RUN: | FileCheck --check-prefix=CHECK-ASM-AND-OBJ %s
+# RUN: llvm-mc -filetype=obj -triple=riscv64 -mattr=+experimental-zicfilp < %s \
+# RUN: | llvm-objdump --mattr=+experimental-zicfilp -d -r - \
+# RUN: | FileCheck --check-prefix=CHECK-ASM-AND-OBJ %s
+#
+# RUN: not llvm-mc -triple riscv32 -riscv-no-aliases -show-encoding < %s 2>&1 \
+# RUN: | FileCheck -check-prefixes=CHECK-NO-EXT %s
+# RUN: not llvm-mc -triple riscv64 -riscv-no-aliases -show-encoding < %s 2>&1 \
+# RUN: | FileCheck -check-prefixes=CHECK-NO-EXT %s
+
+# CHECK-ASM-AND-OBJ: lpad 22
+# CHECK-ASM: auipc zero, 22
+# CHECK-ASM: encoding: [0x17,0x60,0x01,0x00]
+# CHECK-NO-EXT: instruction requires the following: 'Zicfilp' (Landing pad)
+lpad 22
Index: llvm/test/MC/RISCV/zicfilp-invalid.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/zicfilp-invalid.s
@@ -0,0 +1,7 @@
+# RUN: not llvm-mc -triple riscv32 -mattr=+experimental-zicfilp -riscv-no-aliases -show-encoding < %s 2>&1 \
+# RUN: | FileCheck -check-prefixes=CHECK-NO-EXT %s
+# RUN: not llvm-mc -triple riscv64 -mattr=+experimental-zicfilp -riscv-no-aliases -show-encoding < %s 2>&1 \
+# RUN: | FileCheck -check-prefixes=CHECK-NO-EXT %s
+
+# CHECK-NO-EXT: immediate must be an integer in the range [0, 1048575]
+lpad 1048576
Index: llvm/test/MC/RISCV/attribute-arch.s
===
--- llvm/test/MC/RISCV/attribute-arch.s
+++ llvm/test/MC/RISCV/attribute-arch.s
@@ -299,3 +299,6 @@
 
 .attribute arch, "rv32i_xcvbi"
 # CHECK: attribute  5, "rv32i2p1_xcvbi1p0"
+
+.attribute arch, "rv32i_zicfilp0p2"
+# CHECK: attribute  5, "rv32i2p1_zicfilp0p2"
Index: llvm/test/CodeGen/RISCV/attributes.ll
===
--- llvm/test/CodeGen/RISCV/attributes.ll
+++ llvm/test/CodeGen/RISCV/attributes.ll
@@ -86,6 +86,7 @@
 ; RUN: llc -mtriple=riscv32 -mattr=+experimental-zvfbfmin %s -o - | FileCheck --check-prefixes=CHECK,RV32ZVFBFMIN %s
 ; RUN: llc -mtriple=riscv32 -mattr=+experimental-zvfbfwma %s -o - | FileCheck --check-prefixes=CHECK,RV32ZVFBFWMA %s
 ; RUN: llc -mtriple=riscv32 -mattr=+experimental-zacas %s -o - | FileCheck --check-prefix=RV32ZACAS %s
+; RUN: llc -mtriple=riscv32 -mattr=+experimental-zicfilp %s -o - | FileCheck --check-prefix=RV32ZICFILP %s
 
 ; RUN: llc -mtriple=riscv64 %s -o - | FileCheck %s
 ; RUN: llc -mtriple=riscv64 -mattr=+m %s -o - | FileCheck --check-prefixes=CHECK,RV64M %s
@@ -174,6 +175,7 @@
 ; RUN: llc -mtriple=riscv64 -mattr=+experimental-zvfbfmin %s -o - | FileCheck --check-prefixes=CHECK,RV64ZVFBFMIN %s
 ; RUN: llc -mtriple=riscv64 -mattr=+experimental-zvfbfwma %s -o - | FileCheck --check-prefixes=CHECK,RV64ZVFBFWMA %s
 ; RUN: llc -mtriple=riscv64 -mattr=+experimental-zacas %s -o - | FileCheck --check-prefix=RV64ZACAS %s
+; RUN: llc -mtriple=riscv64 -mattr=+experimental-zicfilp %s -o - | FileCheck --check-prefix=RV64ZICFILP %s
 
 ; CHECK: .attribute 4, 16
 
@@ -262,6 +264,7 @@
 ; RV32ZVFBFMIN: .attribute 5, "rv32i2p1_f2p2_zicsr2p0_zfbfmin0p8_zve32f1p0_zve32x1p0_zvfbfmin0p8_zvl32b1p0"
 ; RV32ZVFBFWMA: .attribute 5, "rv32i2p1_f2p2_zicsr2p0_zfbfmin0p8_zve32f1p0_zve32x1p0_zvfbfmin0p8_zvfbfwma0p8_zvl32b1p0"
 ; RV32ZACAS: .attribute 5, "rv32i2p1_a2p1_zacas1p0"
+; RV32ZICFILP: .attribute 5, "rv32i2p1_zicfilp0p2"
 
 ; RV64M: .attribute 5, "rv64i2p1_m2p0"
 ; RV64ZMMUL: .attribute 5, "rv64i2p1_zmmul1p0"
@@ -349,6 +352,7 @@
 ; RV64ZVFBFMIN: .attribute 5, "rv64i2p1_f2p2_zicsr2p0_zfbfmin0p8_zve32f1p0_zve32x1p0_zvfbfmin0p8_zvl32b1p0"
 ; RV64ZVFBFWMA: .attribute 5, 

[PATCH] D157917: clang/HIP: Use abs builtins instead of implementing them

2023-08-14 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm created this revision.
arsenm added reviewers: yaxunl, AlexVlx, JonChesterfield, jhuber6, doru1004.
Herald added a project: All.
arsenm requested review of this revision.
Herald added a subscriber: wdng.

InstCombine already put these back together so there's no visible
change in the -O1 test for the header.


https://reviews.llvm.org/D157917

Files:
  clang/lib/Headers/__clang_hip_math.h


Index: clang/lib/Headers/__clang_hip_math.h
===
--- clang/lib/Headers/__clang_hip_math.h
+++ clang/lib/Headers/__clang_hip_math.h
@@ -315,18 +315,15 @@
 #if defined(__cplusplus)
 __DEVICE__
 int abs(int __x) {
-  int __sgn = __x >> (sizeof(int) * CHAR_BIT - 1);
-  return (__x ^ __sgn) - __sgn;
+  return __builtin_abs(__x);
 }
 __DEVICE__
 long labs(long __x) {
-  long __sgn = __x >> (sizeof(long) * CHAR_BIT - 1);
-  return (__x ^ __sgn) - __sgn;
+  return __builtin_labs(__x);
 }
 __DEVICE__
 long long llabs(long long __x) {
-  long long __sgn = __x >> (sizeof(long long) * CHAR_BIT - 1);
-  return (__x ^ __sgn) - __sgn;
+  return __builtin_llabs(__x);
 }
 #endif
 


Index: clang/lib/Headers/__clang_hip_math.h
===
--- clang/lib/Headers/__clang_hip_math.h
+++ clang/lib/Headers/__clang_hip_math.h
@@ -315,18 +315,15 @@
 #if defined(__cplusplus)
 __DEVICE__
 int abs(int __x) {
-  int __sgn = __x >> (sizeof(int) * CHAR_BIT - 1);
-  return (__x ^ __sgn) - __sgn;
+  return __builtin_abs(__x);
 }
 __DEVICE__
 long labs(long __x) {
-  long __sgn = __x >> (sizeof(long) * CHAR_BIT - 1);
-  return (__x ^ __sgn) - __sgn;
+  return __builtin_labs(__x);
 }
 __DEVICE__
 long long llabs(long long __x) {
-  long long __sgn = __x >> (sizeof(long long) * CHAR_BIT - 1);
-  return (__x ^ __sgn) - __sgn;
+  return __builtin_llabs(__x);
 }
 #endif
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D152793: [RISCV] Add MC layer support for Zicfiss.

2023-08-14 Thread Yeting Kuo via Phabricator via cfe-commits
fakepaper56 updated this revision to Diff 550083.
fakepaper56 added a comment.

Update docs/RISCVUsage.rst to move zicfiss to experimental extension.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152793

Files:
  clang/test/Preprocessor/riscv-target-features.c
  llvm/docs/RISCVUsage.rst
  llvm/lib/Support/RISCVISAInfo.cpp
  llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
  llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h
  llvm/lib/Target/RISCV/RISCVFeatures.td
  llvm/lib/Target/RISCV/RISCVInstrInfo.td
  llvm/lib/Target/RISCV/RISCVInstrInfoZicfiss.td
  llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp
  llvm/lib/Target/RISCV/RISCVRegisterInfo.td
  llvm/test/MC/RISCV/attribute-arch.s
  llvm/test/MC/RISCV/zicfiss-invalid.s
  llvm/test/MC/RISCV/zicfiss-valid.s

Index: llvm/test/MC/RISCV/zicfiss-valid.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/zicfiss-valid.s
@@ -0,0 +1,110 @@
+# RUN: llvm-mc %s -triple=riscv32 -mattr=+experimental-zicfiss,+c -riscv-no-aliases -show-encoding \
+# RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s
+# RUN: llvm-mc %s -triple=riscv64 -mattr=+experimental-zicfiss,+c -riscv-no-aliases -show-encoding \
+# RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s
+# RUN: llvm-mc -filetype=obj -triple=riscv32 -mattr=+experimental-zicfiss,+c < %s \
+# RUN: | llvm-objdump --mattr=+experimental-zicfiss -M no-aliases -d -r - \
+# RUN: | FileCheck --check-prefix=CHECK-ASM-AND-OBJ %s
+# RUN: llvm-mc -filetype=obj -triple=riscv64 -mattr=+experimental-zicfiss,+c < %s \
+# RUN: | llvm-objdump --mattr=+experimental-zicfiss -M no-aliases -d -r - \
+# RUN: | FileCheck --check-prefix=CHECK-ASM-AND-OBJ %s
+#
+# RUN: not llvm-mc -triple riscv32 -riscv-no-aliases -show-encoding < %s 2>&1 \
+# RUN: | FileCheck -check-prefixes=CHECK-NO-EXT %s
+# RUN: not llvm-mc -triple riscv64 -riscv-no-aliases -show-encoding < %s 2>&1 \
+# RUN: | FileCheck -check-prefixes=CHECK-NO-EXT %s
+
+# CHECK-ASM-AND-OBJ: ssload ra
+# CHECK-ASM: encoding: [0xf3,0x40,0xc0,0x81]
+# CHECK-NO-EXT: error: instruction requires the following: 'Zicfiss' (Shadow stack)
+ssload x1
+
+# CHECK-ASM-AND-OBJ: ssload ra
+# CHECK-ASM: encoding: [0xf3,0x40,0xc0,0x81]
+# CHECK-NO-EXT: error: instruction requires the following: 'Zicfiss' (Shadow stack)
+ssload ra
+
+# CHECK-ASM-AND-OBJ: ssload t0
+# CHECK-ASM: encoding: [0xf3,0x42,0xc0,0x81]
+# CHECK-NO-EXT: error: instruction requires the following: 'Zicfiss' (Shadow stack)
+ssload x5
+
+# CHECK-ASM-AND-OBJ: ssload t0
+# CHECK-ASM: encoding: [0xf3,0x42,0xc0,0x81]
+# CHECK-NO-EXT: error: instruction requires the following: 'Zicfiss' (Shadow stack)
+ssload t0
+
+# CHECK-ASM-AND-OBJ: sspopchk ra
+# CHECK-ASM: encoding: [0x73,0xc0,0xc0,0x81]
+# CHECK-NO-EXT: error: instruction requires the following: 'Zicfiss' (Shadow stack)
+sspopchk x1
+
+# CHECK-ASM-AND-OBJ: sspopchk ra
+# CHECK-ASM: encoding: [0x73,0xc0,0xc0,0x81]
+# CHECK-NO-EXT: error: instruction requires the following: 'Zicfiss' (Shadow stack)
+sspopchk ra
+
+# CHECK-ASM-AND-OBJ: sspopchk t0
+# CHECK-ASM: encoding: [0x73,0xc0,0xc2,0x81]
+# CHECK-NO-EXT: error: instruction requires the following: 'Zicfiss' (Shadow stack)
+sspopchk x5
+
+# CHECK-ASM-AND-OBJ: sspopchk t0
+# CHECK-ASM: encoding: [0x73,0xc0,0xc2,0x81]
+# CHECK-NO-EXT: error: instruction requires the following: 'Zicfiss' (Shadow stack)
+sspopchk t0
+
+# CHECK-ASM-AND-OBJ: sspinc 4
+# CHECK-ASM: encoding: [0x73,0x40,0xd2,0x81]
+# CHECK-NO-EXT: error: instruction requires the following: 'Zicfiss' (Shadow stack)
+sspinc 4
+
+# CHECK-ASM-AND-OBJ: sspush ra
+# CHECK-ASM: encoding: [0x73,0x40,0x10,0x8a]
+# CHECK-NO-EXT: error: instruction requires the following: 'Zicfiss' (Shadow stack)
+sspush x1
+
+# CHECK-ASM-AND-OBJ: sspush ra
+# CHECK-ASM: encoding: [0x73,0x40,0x10,0x8a]
+# CHECK-NO-EXT: error: instruction requires the following: 'Zicfiss' (Shadow stack)
+sspush ra
+
+# check-asm-and-obj: sspush t0
+# check-asm: encoding: [0x73,0x40,0x50,0x8a]
+# check-no-ext: error: instruction requires the following: 'Zicfiss' (Shadow stack)
+sspush x5
+
+# check-asm-and-obj: sspush t0
+# check-asm: encoding: [0x73,0x40,0x50,0x8a]
+# check-no-ext: error: instruction requires the following: 'Zicfiss' (Shadow stack)
+sspush t0
+
+# CHECK-ASM-AND-OBJ: ssprr ra
+# CHECK-ASM: encoding: [0xf3,0x40,0x00,0x86]
+# CHECK-NO-EXT: error: instruction requires the following: 'Zicfiss' (Shadow stack)
+ssprr ra
+
+# CHECK-ASM-AND-OBJ: ssamoswap t0, zero, (a0)
+# CHECK-ASM: encoding: [0xf3,0x42,0x05,0x82]
+# CHECK-NO-EXT: error: instruction requires the following: 'Zicfiss' (Shadow stack)
+ssamoswap t0, x0, (a0)
+
+# CHECK-ASM-AND-OBJ: c.sspush ra
+# CHECK-ASM: encoding: [0x81,0x60]
+# CHECK-NO-EXT: error: instruction requires the following: 'C' (Compressed 

[PATCH] D157814: [clang] Add missing field to TLSModelAttr json AST dump

2023-08-14 Thread serge 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 rG2105c32b32bf: [clang] Add missing field to TLSModelAttr json 
AST dump (authored by serge-sans-paille).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157814

Files:
  clang/include/clang/AST/JSONNodeDumper.h
  clang/lib/AST/JSONNodeDumper.cpp
  clang/test/AST/ast-dump-attr-json.cpp


Index: clang/test/AST/ast-dump-attr-json.cpp
===
--- clang/test/AST/ast-dump-attr-json.cpp
+++ clang/test/AST/ast-dump-attr-json.cpp
@@ -19,6 +19,7 @@
 
 __attribute__ ((visibility ("hidden"))) int visibility_var;
 
+__thread __attribute__ ((tls_model ("local-exec"))) int tls_model_var;
 
 // NOTE: CHECK lines have been autogenerated by gen_ast_dump_json_test.py
 // using --filters=VarDecl
@@ -479,3 +480,51 @@
 // CHECK-NEXT:   }
 // CHECK-NEXT:  ]
 // CHECK-NEXT: }
+
+
+// CHECK-NOT: {{^}}Dumping
+// CHECK:  "kind": "VarDecl",
+// CHECK-NEXT:  "loc": {
+// CHECK-NEXT:   "offset": 724,
+// CHECK-NEXT:   "line": 22,
+// CHECK-NEXT:   "col": 57,
+// CHECK-NEXT:   "tokLen": 13
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "range": {
+// CHECK-NEXT:   "begin": {
+// CHECK-NEXT:"offset": 668,
+// CHECK-NEXT:"col": 1,
+// CHECK-NEXT:"tokLen": 8
+// CHECK-NEXT:   },
+// CHECK-NEXT:   "end": {
+// CHECK-NEXT:"offset": 724,
+// CHECK-NEXT:"col": 57,
+// CHECK-NEXT:"tokLen": 13
+// CHECK-NEXT:   }
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "name": "tls_model_var",
+// CHECK-NEXT:  "mangledName": "tls_model_var",
+// CHECK-NEXT:  "type": {
+// CHECK-NEXT:   "qualType": "int"
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "tls": "static",
+// CHECK-NEXT:  "inner": [
+// CHECK-NEXT:   {
+// CHECK-NEXT:"id": "0x{{.*}}",
+// CHECK-NEXT:"kind": "TLSModelAttr",
+// CHECK-NEXT:"range": {
+// CHECK-NEXT: "begin": {
+// CHECK-NEXT:  "offset": 693,
+// CHECK-NEXT:  "col": 26,
+// CHECK-NEXT:  "tokLen": 9
+// CHECK-NEXT: },
+// CHECK-NEXT: "end": {
+// CHECK-NEXT:  "offset": 716,
+// CHECK-NEXT:  "col": 49,
+// CHECK-NEXT:  "tokLen": 1
+// CHECK-NEXT: }
+// CHECK-NEXT:},
+// CHECK-NEXT:"tls_model": "local-exec"
+// CHECK-NEXT:   }
+// CHECK-NEXT:  ]
+// CHECK-NEXT: }
Index: clang/lib/AST/JSONNodeDumper.cpp
===
--- clang/lib/AST/JSONNodeDumper.cpp
+++ clang/lib/AST/JSONNodeDumper.cpp
@@ -559,6 +559,10 @@
   VA->getVisibility()));
 }
 
+void JSONNodeDumper::VisitTLSModelAttr(const TLSModelAttr *TA) {
+  JOS.attribute("tls_model", TA->getModel());
+}
+
 void JSONNodeDumper::VisitTypedefType(const TypedefType *TT) {
   JOS.attribute("decl", createBareDeclRef(TT->getDecl()));
   if (!TT->typeMatchesDecl())
Index: clang/include/clang/AST/JSONNodeDumper.h
===
--- clang/include/clang/AST/JSONNodeDumper.h
+++ clang/include/clang/AST/JSONNodeDumper.h
@@ -214,6 +214,7 @@
   void VisitUnavailableAttr(const UnavailableAttr *UA);
   void VisitSectionAttr(const SectionAttr *SA);
   void VisitVisibilityAttr(const VisibilityAttr *VA);
+  void VisitTLSModelAttr(const TLSModelAttr *TA);
 
   void VisitTypedefType(const TypedefType *TT);
   void VisitUsingType(const UsingType *TT);


Index: clang/test/AST/ast-dump-attr-json.cpp
===
--- clang/test/AST/ast-dump-attr-json.cpp
+++ clang/test/AST/ast-dump-attr-json.cpp
@@ -19,6 +19,7 @@
 
 __attribute__ ((visibility ("hidden"))) int visibility_var;
 
+__thread __attribute__ ((tls_model ("local-exec"))) int tls_model_var;
 
 // NOTE: CHECK lines have been autogenerated by gen_ast_dump_json_test.py
 // using --filters=VarDecl
@@ -479,3 +480,51 @@
 // CHECK-NEXT:   }
 // CHECK-NEXT:  ]
 // CHECK-NEXT: }
+
+
+// CHECK-NOT: {{^}}Dumping
+// CHECK:  "kind": "VarDecl",
+// CHECK-NEXT:  "loc": {
+// CHECK-NEXT:   "offset": 724,
+// CHECK-NEXT:   "line": 22,
+// CHECK-NEXT:   "col": 57,
+// CHECK-NEXT:   "tokLen": 13
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "range": {
+// CHECK-NEXT:   "begin": {
+// CHECK-NEXT:"offset": 668,
+// CHECK-NEXT:"col": 1,
+// CHECK-NEXT:"tokLen": 8
+// CHECK-NEXT:   },
+// CHECK-NEXT:   "end": {
+// CHECK-NEXT:"offset": 724,
+// CHECK-NEXT:"col": 57,
+// CHECK-NEXT:"tokLen": 13
+// CHECK-NEXT:   }
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "name": "tls_model_var",
+// CHECK-NEXT:  "mangledName": "tls_model_var",
+// CHECK-NEXT:  "type": {
+// CHECK-NEXT:   "qualType": "int"
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "tls": "static",
+// CHECK-NEXT:  "inner": [
+// CHECK-NEXT:   {
+// CHECK-NEXT:"id": "0x{{.*}}",
+// CHECK-NEXT:"kind": "TLSModelAttr",
+// CHECK-NEXT:"range": {
+// CHECK-NEXT: "begin": {
+// 

[PATCH] D157808: [clang] Add missing field to VisibilityAttr json AST dump

2023-08-14 Thread serge 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 rG2107d87c5a91: [clang] Add missing field to VisibilityAttr 
json AST dump (authored by serge-sans-paille).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157808

Files:
  clang/include/clang/AST/JSONNodeDumper.h
  clang/lib/AST/JSONNodeDumper.cpp
  clang/test/AST/ast-dump-attr-json.cpp


Index: clang/test/AST/ast-dump-attr-json.cpp
===
--- clang/test/AST/ast-dump-attr-json.cpp
+++ clang/test/AST/ast-dump-attr-json.cpp
@@ -17,6 +17,9 @@
 
 __attribute__ ((section ("SECTION_NAME"))) int section_var;
 
+__attribute__ ((visibility ("hidden"))) int visibility_var;
+
+
 // NOTE: CHECK lines have been autogenerated by gen_ast_dump_json_test.py
 // using --filters=VarDecl
 
@@ -429,3 +432,50 @@
 // CHECK-NEXT:   }
 // CHECK-NEXT:  ]
 // CHECK-NEXT: }
+
+
+// CHECK-NOT: {{^}}Dumping
+// CHECK:  "kind": "VarDecl",
+// CHECK-NEXT:  "loc": {
+// CHECK-NEXT:   "offset": 651,
+// CHECK-NEXT:   "line": 20,
+// CHECK-NEXT:   "col": 45,
+// CHECK-NEXT:   "tokLen": 14
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "range": {
+// CHECK-NEXT:   "begin": {
+// CHECK-NEXT:"offset": 607,
+// CHECK-NEXT:"col": 1,
+// CHECK-NEXT:"tokLen": 13
+// CHECK-NEXT:   },
+// CHECK-NEXT:   "end": {
+// CHECK-NEXT:"offset": 651,
+// CHECK-NEXT:"col": 45,
+// CHECK-NEXT:"tokLen": 14
+// CHECK-NEXT:   }
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "name": "visibility_var",
+// CHECK-NEXT:  "mangledName": "visibility_var",
+// CHECK-NEXT:  "type": {
+// CHECK-NEXT:   "qualType": "int"
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "inner": [
+// CHECK-NEXT:   {
+// CHECK-NEXT:"id": "0x{{.*}}",
+// CHECK-NEXT:"kind": "VisibilityAttr",
+// CHECK-NEXT:"range": {
+// CHECK-NEXT: "begin": {
+// CHECK-NEXT:  "offset": 623,
+// CHECK-NEXT:  "col": 17,
+// CHECK-NEXT:  "tokLen": 10
+// CHECK-NEXT: },
+// CHECK-NEXT: "end": {
+// CHECK-NEXT:  "offset": 643,
+// CHECK-NEXT:  "col": 37,
+// CHECK-NEXT:  "tokLen": 1
+// CHECK-NEXT: }
+// CHECK-NEXT:},
+// CHECK-NEXT:"visibility": "hidden"
+// CHECK-NEXT:   }
+// CHECK-NEXT:  ]
+// CHECK-NEXT: }
Index: clang/lib/AST/JSONNodeDumper.cpp
===
--- clang/lib/AST/JSONNodeDumper.cpp
+++ clang/lib/AST/JSONNodeDumper.cpp
@@ -554,6 +554,11 @@
   JOS.attribute("section_name", SA->getName());
 }
 
+void JSONNodeDumper::VisitVisibilityAttr(const VisibilityAttr *VA) {
+  JOS.attribute("visibility", VisibilityAttr::ConvertVisibilityTypeToStr(
+  VA->getVisibility()));
+}
+
 void JSONNodeDumper::VisitTypedefType(const TypedefType *TT) {
   JOS.attribute("decl", createBareDeclRef(TT->getDecl()));
   if (!TT->typeMatchesDecl())
Index: clang/include/clang/AST/JSONNodeDumper.h
===
--- clang/include/clang/AST/JSONNodeDumper.h
+++ clang/include/clang/AST/JSONNodeDumper.h
@@ -213,6 +213,7 @@
   void VisitDeprecatedAttr(const DeprecatedAttr *DA);
   void VisitUnavailableAttr(const UnavailableAttr *UA);
   void VisitSectionAttr(const SectionAttr *SA);
+  void VisitVisibilityAttr(const VisibilityAttr *VA);
 
   void VisitTypedefType(const TypedefType *TT);
   void VisitUsingType(const UsingType *TT);


Index: clang/test/AST/ast-dump-attr-json.cpp
===
--- clang/test/AST/ast-dump-attr-json.cpp
+++ clang/test/AST/ast-dump-attr-json.cpp
@@ -17,6 +17,9 @@
 
 __attribute__ ((section ("SECTION_NAME"))) int section_var;
 
+__attribute__ ((visibility ("hidden"))) int visibility_var;
+
+
 // NOTE: CHECK lines have been autogenerated by gen_ast_dump_json_test.py
 // using --filters=VarDecl
 
@@ -429,3 +432,50 @@
 // CHECK-NEXT:   }
 // CHECK-NEXT:  ]
 // CHECK-NEXT: }
+
+
+// CHECK-NOT: {{^}}Dumping
+// CHECK:  "kind": "VarDecl",
+// CHECK-NEXT:  "loc": {
+// CHECK-NEXT:   "offset": 651,
+// CHECK-NEXT:   "line": 20,
+// CHECK-NEXT:   "col": 45,
+// CHECK-NEXT:   "tokLen": 14
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "range": {
+// CHECK-NEXT:   "begin": {
+// CHECK-NEXT:"offset": 607,
+// CHECK-NEXT:"col": 1,
+// CHECK-NEXT:"tokLen": 13
+// CHECK-NEXT:   },
+// CHECK-NEXT:   "end": {
+// CHECK-NEXT:"offset": 651,
+// CHECK-NEXT:"col": 45,
+// CHECK-NEXT:"tokLen": 14
+// CHECK-NEXT:   }
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "name": "visibility_var",
+// CHECK-NEXT:  "mangledName": "visibility_var",
+// CHECK-NEXT:  "type": {
+// CHECK-NEXT:   "qualType": "int"
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "inner": [
+// CHECK-NEXT:   {
+// CHECK-NEXT:"id": "0x{{.*}}",
+// CHECK-NEXT:"kind": "VisibilityAttr",
+// CHECK-NEXT:"range": {
+// CHECK-NEXT: 

[PATCH] D152793: [RISCV] Add MC layer support for Zicfiss.

2023-08-14 Thread Yeting Kuo via Phabricator via cfe-commits
fakepaper56 updated this revision to Diff 550079.
fakepaper56 added a comment.

Update docs/RISCVUsage.rst.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152793

Files:
  clang/test/Preprocessor/riscv-target-features.c
  llvm/docs/RISCVUsage.rst
  llvm/lib/Support/RISCVISAInfo.cpp
  llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
  llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h
  llvm/lib/Target/RISCV/RISCVFeatures.td
  llvm/lib/Target/RISCV/RISCVInstrInfo.td
  llvm/lib/Target/RISCV/RISCVInstrInfoZicfiss.td
  llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp
  llvm/lib/Target/RISCV/RISCVRegisterInfo.td
  llvm/test/MC/RISCV/attribute-arch.s
  llvm/test/MC/RISCV/zicfiss-invalid.s
  llvm/test/MC/RISCV/zicfiss-valid.s

Index: llvm/test/MC/RISCV/zicfiss-valid.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/zicfiss-valid.s
@@ -0,0 +1,110 @@
+# RUN: llvm-mc %s -triple=riscv32 -mattr=+experimental-zicfiss,+c -riscv-no-aliases -show-encoding \
+# RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s
+# RUN: llvm-mc %s -triple=riscv64 -mattr=+experimental-zicfiss,+c -riscv-no-aliases -show-encoding \
+# RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s
+# RUN: llvm-mc -filetype=obj -triple=riscv32 -mattr=+experimental-zicfiss,+c < %s \
+# RUN: | llvm-objdump --mattr=+experimental-zicfiss -M no-aliases -d -r - \
+# RUN: | FileCheck --check-prefix=CHECK-ASM-AND-OBJ %s
+# RUN: llvm-mc -filetype=obj -triple=riscv64 -mattr=+experimental-zicfiss,+c < %s \
+# RUN: | llvm-objdump --mattr=+experimental-zicfiss -M no-aliases -d -r - \
+# RUN: | FileCheck --check-prefix=CHECK-ASM-AND-OBJ %s
+#
+# RUN: not llvm-mc -triple riscv32 -riscv-no-aliases -show-encoding < %s 2>&1 \
+# RUN: | FileCheck -check-prefixes=CHECK-NO-EXT %s
+# RUN: not llvm-mc -triple riscv64 -riscv-no-aliases -show-encoding < %s 2>&1 \
+# RUN: | FileCheck -check-prefixes=CHECK-NO-EXT %s
+
+# CHECK-ASM-AND-OBJ: ssload ra
+# CHECK-ASM: encoding: [0xf3,0x40,0xc0,0x81]
+# CHECK-NO-EXT: error: instruction requires the following: 'Zicfiss' (Shadow stack)
+ssload x1
+
+# CHECK-ASM-AND-OBJ: ssload ra
+# CHECK-ASM: encoding: [0xf3,0x40,0xc0,0x81]
+# CHECK-NO-EXT: error: instruction requires the following: 'Zicfiss' (Shadow stack)
+ssload ra
+
+# CHECK-ASM-AND-OBJ: ssload t0
+# CHECK-ASM: encoding: [0xf3,0x42,0xc0,0x81]
+# CHECK-NO-EXT: error: instruction requires the following: 'Zicfiss' (Shadow stack)
+ssload x5
+
+# CHECK-ASM-AND-OBJ: ssload t0
+# CHECK-ASM: encoding: [0xf3,0x42,0xc0,0x81]
+# CHECK-NO-EXT: error: instruction requires the following: 'Zicfiss' (Shadow stack)
+ssload t0
+
+# CHECK-ASM-AND-OBJ: sspopchk ra
+# CHECK-ASM: encoding: [0x73,0xc0,0xc0,0x81]
+# CHECK-NO-EXT: error: instruction requires the following: 'Zicfiss' (Shadow stack)
+sspopchk x1
+
+# CHECK-ASM-AND-OBJ: sspopchk ra
+# CHECK-ASM: encoding: [0x73,0xc0,0xc0,0x81]
+# CHECK-NO-EXT: error: instruction requires the following: 'Zicfiss' (Shadow stack)
+sspopchk ra
+
+# CHECK-ASM-AND-OBJ: sspopchk t0
+# CHECK-ASM: encoding: [0x73,0xc0,0xc2,0x81]
+# CHECK-NO-EXT: error: instruction requires the following: 'Zicfiss' (Shadow stack)
+sspopchk x5
+
+# CHECK-ASM-AND-OBJ: sspopchk t0
+# CHECK-ASM: encoding: [0x73,0xc0,0xc2,0x81]
+# CHECK-NO-EXT: error: instruction requires the following: 'Zicfiss' (Shadow stack)
+sspopchk t0
+
+# CHECK-ASM-AND-OBJ: sspinc 4
+# CHECK-ASM: encoding: [0x73,0x40,0xd2,0x81]
+# CHECK-NO-EXT: error: instruction requires the following: 'Zicfiss' (Shadow stack)
+sspinc 4
+
+# CHECK-ASM-AND-OBJ: sspush ra
+# CHECK-ASM: encoding: [0x73,0x40,0x10,0x8a]
+# CHECK-NO-EXT: error: instruction requires the following: 'Zicfiss' (Shadow stack)
+sspush x1
+
+# CHECK-ASM-AND-OBJ: sspush ra
+# CHECK-ASM: encoding: [0x73,0x40,0x10,0x8a]
+# CHECK-NO-EXT: error: instruction requires the following: 'Zicfiss' (Shadow stack)
+sspush ra
+
+# check-asm-and-obj: sspush t0
+# check-asm: encoding: [0x73,0x40,0x50,0x8a]
+# check-no-ext: error: instruction requires the following: 'Zicfiss' (Shadow stack)
+sspush x5
+
+# check-asm-and-obj: sspush t0
+# check-asm: encoding: [0x73,0x40,0x50,0x8a]
+# check-no-ext: error: instruction requires the following: 'Zicfiss' (Shadow stack)
+sspush t0
+
+# CHECK-ASM-AND-OBJ: ssprr ra
+# CHECK-ASM: encoding: [0xf3,0x40,0x00,0x86]
+# CHECK-NO-EXT: error: instruction requires the following: 'Zicfiss' (Shadow stack)
+ssprr ra
+
+# CHECK-ASM-AND-OBJ: ssamoswap t0, zero, (a0)
+# CHECK-ASM: encoding: [0xf3,0x42,0x05,0x82]
+# CHECK-NO-EXT: error: instruction requires the following: 'Zicfiss' (Shadow stack)
+ssamoswap t0, x0, (a0)
+
+# CHECK-ASM-AND-OBJ: c.sspush ra
+# CHECK-ASM: encoding: [0x81,0x60]
+# CHECK-NO-EXT: error: instruction requires the following: 'C' (Compressed Instructions), 'Zicfiss' (Shadow stack)

[PATCH] D157795: [clang] Add missing field to SectionAttr json AST dump

2023-08-14 Thread serge 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 rG4cf7666b8f09: [clang] Add missing field to SectionAttr json 
AST dump (authored by serge-sans-paille).

Changed prior to commit:
  https://reviews.llvm.org/D157795?vs=549646=550078#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157795

Files:
  clang/include/clang/AST/JSONNodeDumper.h
  clang/lib/AST/JSONNodeDumper.cpp
  clang/test/AST/ast-dump-attr-json.cpp


Index: clang/test/AST/ast-dump-attr-json.cpp
===
--- clang/test/AST/ast-dump-attr-json.cpp
+++ clang/test/AST/ast-dump-attr-json.cpp
@@ -15,6 +15,8 @@
 __attribute__((unavailable)) int unavailable_var0;
 __attribute__((unavailable("reason"))) int unavailable_var1;
 
+__attribute__ ((section ("SECTION_NAME"))) int section_var;
+
 // NOTE: CHECK lines have been autogenerated by gen_ast_dump_json_test.py
 // using --filters=VarDecl
 
@@ -380,3 +382,50 @@
 // CHECK-NEXT:   }
 // CHECK-NEXT:  ]
 // CHECK-NEXT: }
+
+
+// CHECK-NOT: {{^}}Dumping
+// CHECK:  "kind": "VarDecl",
+// CHECK-NEXT:  "loc": {
+// CHECK-NEXT:   "offset": 593,
+// CHECK-NEXT:   "line": 18,
+// CHECK-NEXT:   "col": 48,
+// CHECK-NEXT:   "tokLen": 11
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "range": {
+// CHECK-NEXT:   "begin": {
+// CHECK-NEXT:"offset": 546,
+// CHECK-NEXT:"col": 1,
+// CHECK-NEXT:"tokLen": 13
+// CHECK-NEXT:   },
+// CHECK-NEXT:   "end": {
+// CHECK-NEXT:"offset": 593,
+// CHECK-NEXT:"col": 48,
+// CHECK-NEXT:"tokLen": 11
+// CHECK-NEXT:   }
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "name": "section_var",
+// CHECK-NEXT:  "mangledName": "section_var",
+// CHECK-NEXT:  "type": {
+// CHECK-NEXT:   "qualType": "int"
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "inner": [
+// CHECK-NEXT:   {
+// CHECK-NEXT:"id": "0x{{.*}}",
+// CHECK-NEXT:"kind": "SectionAttr",
+// CHECK-NEXT:"range": {
+// CHECK-NEXT: "begin": {
+// CHECK-NEXT:  "offset": 562,
+// CHECK-NEXT:  "col": 17,
+// CHECK-NEXT:  "tokLen": 7
+// CHECK-NEXT: },
+// CHECK-NEXT: "end": {
+// CHECK-NEXT:  "offset": 585,
+// CHECK-NEXT:  "col": 40,
+// CHECK-NEXT:  "tokLen": 1
+// CHECK-NEXT: }
+// CHECK-NEXT:},
+// CHECK-NEXT:"section_name": "SECTION_NAME"
+// CHECK-NEXT:   }
+// CHECK-NEXT:  ]
+// CHECK-NEXT: }
Index: clang/lib/AST/JSONNodeDumper.cpp
===
--- clang/lib/AST/JSONNodeDumper.cpp
+++ clang/lib/AST/JSONNodeDumper.cpp
@@ -550,6 +550,10 @@
 JOS.attribute("message", UA->getMessage());
 }
 
+void JSONNodeDumper::VisitSectionAttr(const SectionAttr *SA) {
+  JOS.attribute("section_name", SA->getName());
+}
+
 void JSONNodeDumper::VisitTypedefType(const TypedefType *TT) {
   JOS.attribute("decl", createBareDeclRef(TT->getDecl()));
   if (!TT->typeMatchesDecl())
Index: clang/include/clang/AST/JSONNodeDumper.h
===
--- clang/include/clang/AST/JSONNodeDumper.h
+++ clang/include/clang/AST/JSONNodeDumper.h
@@ -212,6 +212,7 @@
   void VisitCleanupAttr(const CleanupAttr *CA);
   void VisitDeprecatedAttr(const DeprecatedAttr *DA);
   void VisitUnavailableAttr(const UnavailableAttr *UA);
+  void VisitSectionAttr(const SectionAttr *SA);
 
   void VisitTypedefType(const TypedefType *TT);
   void VisitUsingType(const UsingType *TT);


Index: clang/test/AST/ast-dump-attr-json.cpp
===
--- clang/test/AST/ast-dump-attr-json.cpp
+++ clang/test/AST/ast-dump-attr-json.cpp
@@ -15,6 +15,8 @@
 __attribute__((unavailable)) int unavailable_var0;
 __attribute__((unavailable("reason"))) int unavailable_var1;
 
+__attribute__ ((section ("SECTION_NAME"))) int section_var;
+
 // NOTE: CHECK lines have been autogenerated by gen_ast_dump_json_test.py
 // using --filters=VarDecl
 
@@ -380,3 +382,50 @@
 // CHECK-NEXT:   }
 // CHECK-NEXT:  ]
 // CHECK-NEXT: }
+
+
+// CHECK-NOT: {{^}}Dumping
+// CHECK:  "kind": "VarDecl",
+// CHECK-NEXT:  "loc": {
+// CHECK-NEXT:   "offset": 593,
+// CHECK-NEXT:   "line": 18,
+// CHECK-NEXT:   "col": 48,
+// CHECK-NEXT:   "tokLen": 11
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "range": {
+// CHECK-NEXT:   "begin": {
+// CHECK-NEXT:"offset": 546,
+// CHECK-NEXT:"col": 1,
+// CHECK-NEXT:"tokLen": 13
+// CHECK-NEXT:   },
+// CHECK-NEXT:   "end": {
+// CHECK-NEXT:"offset": 593,
+// CHECK-NEXT:"col": 48,
+// CHECK-NEXT:"tokLen": 11
+// CHECK-NEXT:   }
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "name": "section_var",
+// CHECK-NEXT:  "mangledName": "section_var",
+// CHECK-NEXT:  "type": {
+// CHECK-NEXT:   "qualType": "int"
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "inner": [
+// CHECK-NEXT:   {
+// CHECK-NEXT:"id": "0x{{.*}}",
+// CHECK-NEXT:

[PATCH] D157783: [clang] Add rmissing fields to DeprecatedAttr and UnavailableAttr json AST dump

2023-08-14 Thread serge 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 rG3dadc290b210: [clang] Add missing fields to DeprecatedAttr 
and Unavailable json AST dump (authored by serge-sans-paille).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157783

Files:
  clang/include/clang/AST/JSONNodeDumper.h
  clang/lib/AST/JSONNodeDumper.cpp
  clang/test/AST/ast-dump-attr-json.cpp

Index: clang/test/AST/ast-dump-attr-json.cpp
===
--- clang/test/AST/ast-dump-attr-json.cpp
+++ clang/test/AST/ast-dump-attr-json.cpp
@@ -8,6 +8,13 @@
   __attribute__((cleanup(cleanup_function))) int var;
 }
 
+__attribute__((deprecated)) int deprecated_var0;
+__attribute__((deprecated("reason"))) int deprecated_var1;
+__attribute__((deprecated("reason", "replacement"))) int deprecated_var2;
+
+__attribute__((unavailable)) int unavailable_var0;
+__attribute__((unavailable("reason"))) int unavailable_var1;
+
 // NOTE: CHECK lines have been autogenerated by gen_ast_dump_json_test.py
 // using --filters=VarDecl
 
@@ -139,3 +146,237 @@
 // CHECK-NEXT:   }
 // CHECK-NEXT:  ]
 // CHECK-NEXT: }
+
+
+// CHECK-NOT: {{^}}Dumping
+// CHECK:  "kind": "VarDecl",
+// CHECK-NEXT:  "loc": {
+// CHECK-NEXT:   "offset": 282,
+// CHECK-NEXT:   "line": 11,
+// CHECK-NEXT:   "col": 33,
+// CHECK-NEXT:   "tokLen": 15
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "range": {
+// CHECK-NEXT:   "begin": {
+// CHECK-NEXT:"offset": 250,
+// CHECK-NEXT:"col": 1,
+// CHECK-NEXT:"tokLen": 13
+// CHECK-NEXT:   },
+// CHECK-NEXT:   "end": {
+// CHECK-NEXT:"offset": 282,
+// CHECK-NEXT:"col": 33,
+// CHECK-NEXT:"tokLen": 15
+// CHECK-NEXT:   }
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "name": "deprecated_var0",
+// CHECK-NEXT:  "mangledName": "deprecated_var0",
+// CHECK-NEXT:  "type": {
+// CHECK-NEXT:   "qualType": "int"
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "inner": [
+// CHECK-NEXT:   {
+// CHECK-NEXT:"id": "0x{{.*}}",
+// CHECK-NEXT:"kind": "DeprecatedAttr",
+// CHECK-NEXT:"range": {
+// CHECK-NEXT: "begin": {
+// CHECK-NEXT:  "offset": 265,
+// CHECK-NEXT:  "col": 16,
+// CHECK-NEXT:  "tokLen": 10
+// CHECK-NEXT: },
+// CHECK-NEXT: "end": {
+// CHECK-NEXT:  "offset": 265,
+// CHECK-NEXT:  "col": 16,
+// CHECK-NEXT:  "tokLen": 10
+// CHECK-NEXT: }
+// CHECK-NEXT:}
+// CHECK-NEXT:   }
+// CHECK-NEXT:  ]
+// CHECK-NEXT: }
+
+
+// CHECK-NOT: {{^}}Dumping
+// CHECK:  "kind": "VarDecl",
+// CHECK-NEXT:  "loc": {
+// CHECK-NEXT:   "offset": 341,
+// CHECK-NEXT:   "line": 12,
+// CHECK-NEXT:   "col": 43,
+// CHECK-NEXT:   "tokLen": 15
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "range": {
+// CHECK-NEXT:   "begin": {
+// CHECK-NEXT:"offset": 299,
+// CHECK-NEXT:"col": 1,
+// CHECK-NEXT:"tokLen": 13
+// CHECK-NEXT:   },
+// CHECK-NEXT:   "end": {
+// CHECK-NEXT:"offset": 341,
+// CHECK-NEXT:"col": 43,
+// CHECK-NEXT:"tokLen": 15
+// CHECK-NEXT:   }
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "name": "deprecated_var1",
+// CHECK-NEXT:  "mangledName": "deprecated_var1",
+// CHECK-NEXT:  "type": {
+// CHECK-NEXT:   "qualType": "int"
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "inner": [
+// CHECK-NEXT:   {
+// CHECK-NEXT:"id": "0x{{.*}}",
+// CHECK-NEXT:"kind": "DeprecatedAttr",
+// CHECK-NEXT:"range": {
+// CHECK-NEXT: "begin": {
+// CHECK-NEXT:  "offset": 314,
+// CHECK-NEXT:  "col": 16,
+// CHECK-NEXT:  "tokLen": 10
+// CHECK-NEXT: },
+// CHECK-NEXT: "end": {
+// CHECK-NEXT:  "offset": 333,
+// CHECK-NEXT:  "col": 35,
+// CHECK-NEXT:  "tokLen": 1
+// CHECK-NEXT: }
+// CHECK-NEXT:},
+// CHECK-NEXT:"message": "reason"
+// CHECK-NEXT:   }
+// CHECK-NEXT:  ]
+// CHECK-NEXT: }
+
+
+// CHECK-NOT: {{^}}Dumping
+// CHECK:  "kind": "VarDecl",
+// CHECK-NEXT:  "loc": {
+// CHECK-NEXT:   "offset": 415,
+// CHECK-NEXT:   "line": 13,
+// CHECK-NEXT:   "col": 58,
+// CHECK-NEXT:   "tokLen": 15
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "range": {
+// CHECK-NEXT:   "begin": {
+// CHECK-NEXT:"offset": 358,
+// CHECK-NEXT:"col": 1,
+// CHECK-NEXT:"tokLen": 13
+// CHECK-NEXT:   },
+// CHECK-NEXT:   "end": {
+// CHECK-NEXT:"offset": 415,
+// CHECK-NEXT:"col": 58,
+// CHECK-NEXT:"tokLen": 15
+// CHECK-NEXT:   }
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "name": "deprecated_var2",
+// CHECK-NEXT:  "mangledName": "deprecated_var2",
+// CHECK-NEXT:  "type": {
+// CHECK-NEXT:   "qualType": "int"
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "inner": [
+// CHECK-NEXT:   {
+// CHECK-NEXT:"id": "0x{{.*}}",
+// CHECK-NEXT:"kind": "DeprecatedAttr",
+// CHECK-NEXT:"range": {
+// CHECK-NEXT: "begin": {
+// CHECK-NEXT:  "offset": 373,
+// CHECK-NEXT:  "col": 16,
+// CHECK-NEXT:  "tokLen": 10
+// CHECK-NEXT: },
+// 

[PATCH] D157781: [clang] Add cleanup_function field to CleanupAttr json AST dump

2023-08-14 Thread serge 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 rG903e530bb898: [clang] Add cleanup_function field to 
CleanupAttr json AST dump (authored by serge-sans-paille).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157781

Files:
  clang/include/clang/AST/JSONNodeDumper.h
  clang/lib/AST/JSONNodeDumper.cpp
  clang/test/AST/ast-dump-attr-json.cpp

Index: clang/test/AST/ast-dump-attr-json.cpp
===
--- clang/test/AST/ast-dump-attr-json.cpp
+++ clang/test/AST/ast-dump-attr-json.cpp
@@ -3,6 +3,11 @@
 int global_decl;
 extern __attribute__((alias("global_decl"))) int global_alias;
 
+void cleanup_function(int*);
+void some() {
+  __attribute__((cleanup(cleanup_function))) int var;
+}
+
 // NOTE: CHECK lines have been autogenerated by gen_ast_dump_json_test.py
 // using --filters=VarDecl
 
@@ -78,7 +83,59 @@
 // CHECK-NEXT:  "tokLen": 1
 // CHECK-NEXT: }
 // CHECK-NEXT:},
-// CHECK-NEXT:"decl": "global_decl"
+// CHECK-NEXT:"aliasee": "global_decl"
+// CHECK-NEXT:   }
+// CHECK-NEXT:  ]
+// CHECK-NEXT: }
+
+
+// CHECK-NOT: {{^}}Dumping
+// CHECK:  "kind": "VarDecl",
+// CHECK-NEXT:  "loc": {
+// CHECK-NEXT:   "offset": 242,
+// CHECK-NEXT:   "col": 50,
+// CHECK-NEXT:   "tokLen": 3
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "range": {
+// CHECK-NEXT:   "begin": {
+// CHECK-NEXT:"offset": 195,
+// CHECK-NEXT:"col": 3,
+// CHECK-NEXT:"tokLen": 13
+// CHECK-NEXT:   },
+// CHECK-NEXT:   "end": {
+// CHECK-NEXT:"offset": 242,
+// CHECK-NEXT:"col": 50,
+// CHECK-NEXT:"tokLen": 3
+// CHECK-NEXT:   }
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "name": "var",
+// CHECK-NEXT:  "type": {
+// CHECK-NEXT:   "qualType": "int"
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "inner": [
+// CHECK-NEXT:   {
+// CHECK-NEXT:"id": "0x{{.*}}",
+// CHECK-NEXT:"kind": "CleanupAttr",
+// CHECK-NEXT:"range": {
+// CHECK-NEXT: "begin": {
+// CHECK-NEXT:  "offset": 210,
+// CHECK-NEXT:  "col": 18,
+// CHECK-NEXT:  "tokLen": 7
+// CHECK-NEXT: },
+// CHECK-NEXT: "end": {
+// CHECK-NEXT:  "offset": 234,
+// CHECK-NEXT:  "col": 42,
+// CHECK-NEXT:  "tokLen": 1
+// CHECK-NEXT: }
+// CHECK-NEXT:},
+// CHECK-NEXT:"cleanup_function": {
+// CHECK-NEXT: "id": "0x{{.*}}",
+// CHECK-NEXT: "kind": "FunctionDecl",
+// CHECK-NEXT: "name": "cleanup_function",
+// CHECK-NEXT: "type": {
+// CHECK-NEXT:  "qualType": "void (int *)"
+// CHECK-NEXT: }
+// CHECK-NEXT:}
 // CHECK-NEXT:   }
 // CHECK-NEXT:  ]
 // CHECK-NEXT: }
Index: clang/lib/AST/JSONNodeDumper.cpp
===
--- clang/lib/AST/JSONNodeDumper.cpp
+++ clang/lib/AST/JSONNodeDumper.cpp
@@ -534,6 +534,10 @@
   JOS.attribute("aliasee", AA->getAliasee());
 }
 
+void JSONNodeDumper::VisitCleanupAttr(const CleanupAttr *CA) {
+  JOS.attribute("cleanup_function", createBareDeclRef(CA->getFunctionDecl()));
+}
+
 void JSONNodeDumper::VisitTypedefType(const TypedefType *TT) {
   JOS.attribute("decl", createBareDeclRef(TT->getDecl()));
   if (!TT->typeMatchesDecl())
Index: clang/include/clang/AST/JSONNodeDumper.h
===
--- clang/include/clang/AST/JSONNodeDumper.h
+++ clang/include/clang/AST/JSONNodeDumper.h
@@ -209,6 +209,7 @@
   void Visit(const APValue , QualType Ty);
 
   void VisitAliasAttr(const AliasAttr *AA);
+  void VisitCleanupAttr(const CleanupAttr *CA);
 
   void VisitTypedefType(const TypedefType *TT);
   void VisitUsingType(const UsingType *TT);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D157775: [clang] Add aliasee field to AliasAttr json AST dump

2023-08-14 Thread serge 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 rG11f3286585ce: [clang] Add aliasee field to AliasAttr json 
AST dump (authored by serge-sans-paille).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157775

Files:
  clang/include/clang/AST/JSONNodeDumper.h
  clang/lib/AST/JSONNodeDumper.cpp
  clang/test/AST/ast-dump-attr-json.cpp

Index: clang/test/AST/ast-dump-attr-json.cpp
===
--- /dev/null
+++ clang/test/AST/ast-dump-attr-json.cpp
@@ -0,0 +1,84 @@
+// RUN: %clang_cc1 -Wdocumentation -ast-dump=json %s | FileCheck %s
+
+int global_decl;
+extern __attribute__((alias("global_decl"))) int global_alias;
+
+// NOTE: CHECK lines have been autogenerated by gen_ast_dump_json_test.py
+// using --filters=VarDecl
+
+
+// CHECK-NOT: {{^}}Dumping
+// CHECK:  "kind": "VarDecl",
+// CHECK-NEXT:  "loc": {
+// CHECK-NEXT:   "offset": 73,
+// CHECK-NEXT:   "file": "{{.*}}",
+// CHECK-NEXT:   "line": 3,
+// CHECK-NEXT:   "col": 5,
+// CHECK-NEXT:   "tokLen": 11
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "range": {
+// CHECK-NEXT:   "begin": {
+// CHECK-NEXT:"offset": 69,
+// CHECK-NEXT:"col": 1,
+// CHECK-NEXT:"tokLen": 3
+// CHECK-NEXT:   },
+// CHECK-NEXT:   "end": {
+// CHECK-NEXT:"offset": 73,
+// CHECK-NEXT:"col": 5,
+// CHECK-NEXT:"tokLen": 11
+// CHECK-NEXT:   }
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "name": "global_decl",
+// CHECK-NEXT:  "mangledName": "global_decl",
+// CHECK-NEXT:  "type": {
+// CHECK-NEXT:   "qualType": "int"
+// CHECK-NEXT:  }
+// CHECK-NEXT: }
+
+
+// CHECK-NOT: {{^}}Dumping
+// CHECK:  "kind": "VarDecl",
+// CHECK-NEXT:  "loc": {
+// CHECK-NEXT:   "offset": 135,
+// CHECK-NEXT:   "line": 4,
+// CHECK-NEXT:   "col": 50,
+// CHECK-NEXT:   "tokLen": 12
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "range": {
+// CHECK-NEXT:   "begin": {
+// CHECK-NEXT:"offset": 86,
+// CHECK-NEXT:"col": 1,
+// CHECK-NEXT:"tokLen": 6
+// CHECK-NEXT:   },
+// CHECK-NEXT:   "end": {
+// CHECK-NEXT:"offset": 135,
+// CHECK-NEXT:"col": 50,
+// CHECK-NEXT:"tokLen": 12
+// CHECK-NEXT:   }
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "name": "global_alias",
+// CHECK-NEXT:  "mangledName": "global_alias",
+// CHECK-NEXT:  "type": {
+// CHECK-NEXT:   "qualType": "int"
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "storageClass": "extern",
+// CHECK-NEXT:  "inner": [
+// CHECK-NEXT:   {
+// CHECK-NEXT:"id": "0x{{.*}}",
+// CHECK-NEXT:"kind": "AliasAttr",
+// CHECK-NEXT:"range": {
+// CHECK-NEXT: "begin": {
+// CHECK-NEXT:  "offset": 108,
+// CHECK-NEXT:  "col": 23,
+// CHECK-NEXT:  "tokLen": 5
+// CHECK-NEXT: },
+// CHECK-NEXT: "end": {
+// CHECK-NEXT:  "offset": 127,
+// CHECK-NEXT:  "col": 42,
+// CHECK-NEXT:  "tokLen": 1
+// CHECK-NEXT: }
+// CHECK-NEXT:},
+// CHECK-NEXT:"decl": "global_decl"
+// CHECK-NEXT:   }
+// CHECK-NEXT:  ]
+// CHECK-NEXT: }
Index: clang/lib/AST/JSONNodeDumper.cpp
===
--- clang/lib/AST/JSONNodeDumper.cpp
+++ clang/lib/AST/JSONNodeDumper.cpp
@@ -530,6 +530,10 @@
   return Ret;
 }
 
+void JSONNodeDumper::VisitAliasAttr(const AliasAttr *AA) {
+  JOS.attribute("aliasee", AA->getAliasee());
+}
+
 void JSONNodeDumper::VisitTypedefType(const TypedefType *TT) {
   JOS.attribute("decl", createBareDeclRef(TT->getDecl()));
   if (!TT->typeMatchesDecl())
Index: clang/include/clang/AST/JSONNodeDumper.h
===
--- clang/include/clang/AST/JSONNodeDumper.h
+++ clang/include/clang/AST/JSONNodeDumper.h
@@ -208,6 +208,8 @@
   void Visit(const concepts::Requirement *R);
   void Visit(const APValue , QualType Ty);
 
+  void VisitAliasAttr(const AliasAttr *AA);
+
   void VisitTypedefType(const TypedefType *TT);
   void VisitUsingType(const UsingType *TT);
   void VisitFunctionType(const FunctionType *T);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 2105c32 - [clang] Add missing field to TLSModelAttr json AST dump

2023-08-14 Thread via cfe-commits

Author: serge-sans-paille
Date: 2023-08-14T22:59:45+02:00
New Revision: 2105c32b32bf3360f524f1f3a1e5af605821eff8

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

LOG: [clang] Add missing field to TLSModelAttr json AST dump

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

Added: 


Modified: 
clang/include/clang/AST/JSONNodeDumper.h
clang/lib/AST/JSONNodeDumper.cpp
clang/test/AST/ast-dump-attr-json.cpp

Removed: 




diff  --git a/clang/include/clang/AST/JSONNodeDumper.h 
b/clang/include/clang/AST/JSONNodeDumper.h
index 03c903069ad877..0ce272df8df65b 100644
--- a/clang/include/clang/AST/JSONNodeDumper.h
+++ b/clang/include/clang/AST/JSONNodeDumper.h
@@ -214,6 +214,7 @@ class JSONNodeDumper
   void VisitUnavailableAttr(const UnavailableAttr *UA);
   void VisitSectionAttr(const SectionAttr *SA);
   void VisitVisibilityAttr(const VisibilityAttr *VA);
+  void VisitTLSModelAttr(const TLSModelAttr *TA);
 
   void VisitTypedefType(const TypedefType *TT);
   void VisitUsingType(const UsingType *TT);

diff  --git a/clang/lib/AST/JSONNodeDumper.cpp 
b/clang/lib/AST/JSONNodeDumper.cpp
index 134938a1ef19a0..139dfce41e914c 100644
--- a/clang/lib/AST/JSONNodeDumper.cpp
+++ b/clang/lib/AST/JSONNodeDumper.cpp
@@ -559,6 +559,10 @@ void JSONNodeDumper::VisitVisibilityAttr(const 
VisibilityAttr *VA) {
   VA->getVisibility()));
 }
 
+void JSONNodeDumper::VisitTLSModelAttr(const TLSModelAttr *TA) {
+  JOS.attribute("tls_model", TA->getModel());
+}
+
 void JSONNodeDumper::VisitTypedefType(const TypedefType *TT) {
   JOS.attribute("decl", createBareDeclRef(TT->getDecl()));
   if (!TT->typeMatchesDecl())

diff  --git a/clang/test/AST/ast-dump-attr-json.cpp 
b/clang/test/AST/ast-dump-attr-json.cpp
index 0eb930b851a15e..24a5ff08887870 100644
--- a/clang/test/AST/ast-dump-attr-json.cpp
+++ b/clang/test/AST/ast-dump-attr-json.cpp
@@ -19,6 +19,7 @@ __attribute__ ((section ("SECTION_NAME"))) int section_var;
 
 __attribute__ ((visibility ("hidden"))) int visibility_var;
 
+__thread __attribute__ ((tls_model ("local-exec"))) int tls_model_var;
 
 // NOTE: CHECK lines have been autogenerated by gen_ast_dump_json_test.py
 // using --filters=VarDecl
@@ -479,3 +480,51 @@ __attribute__ ((visibility ("hidden"))) int visibility_var;
 // CHECK-NEXT:   }
 // CHECK-NEXT:  ]
 // CHECK-NEXT: }
+
+
+// CHECK-NOT: {{^}}Dumping
+// CHECK:  "kind": "VarDecl",
+// CHECK-NEXT:  "loc": {
+// CHECK-NEXT:   "offset": 724,
+// CHECK-NEXT:   "line": 22,
+// CHECK-NEXT:   "col": 57,
+// CHECK-NEXT:   "tokLen": 13
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "range": {
+// CHECK-NEXT:   "begin": {
+// CHECK-NEXT:"offset": 668,
+// CHECK-NEXT:"col": 1,
+// CHECK-NEXT:"tokLen": 8
+// CHECK-NEXT:   },
+// CHECK-NEXT:   "end": {
+// CHECK-NEXT:"offset": 724,
+// CHECK-NEXT:"col": 57,
+// CHECK-NEXT:"tokLen": 13
+// CHECK-NEXT:   }
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "name": "tls_model_var",
+// CHECK-NEXT:  "mangledName": "tls_model_var",
+// CHECK-NEXT:  "type": {
+// CHECK-NEXT:   "qualType": "int"
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "tls": "static",
+// CHECK-NEXT:  "inner": [
+// CHECK-NEXT:   {
+// CHECK-NEXT:"id": "0x{{.*}}",
+// CHECK-NEXT:"kind": "TLSModelAttr",
+// CHECK-NEXT:"range": {
+// CHECK-NEXT: "begin": {
+// CHECK-NEXT:  "offset": 693,
+// CHECK-NEXT:  "col": 26,
+// CHECK-NEXT:  "tokLen": 9
+// CHECK-NEXT: },
+// CHECK-NEXT: "end": {
+// CHECK-NEXT:  "offset": 716,
+// CHECK-NEXT:  "col": 49,
+// CHECK-NEXT:  "tokLen": 1
+// CHECK-NEXT: }
+// CHECK-NEXT:},
+// CHECK-NEXT:"tls_model": "local-exec"
+// CHECK-NEXT:   }
+// CHECK-NEXT:  ]
+// CHECK-NEXT: }



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


[clang] 2107d87 - [clang] Add missing field to VisibilityAttr json AST dump

2023-08-14 Thread via cfe-commits

Author: serge-sans-paille
Date: 2023-08-14T22:59:45+02:00
New Revision: 2107d87c5a9103ffc4c0f76fc00ab203603f9df1

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

LOG: [clang] Add missing field to VisibilityAttr json AST dump

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

Added: 


Modified: 
clang/include/clang/AST/JSONNodeDumper.h
clang/lib/AST/JSONNodeDumper.cpp
clang/test/AST/ast-dump-attr-json.cpp

Removed: 




diff  --git a/clang/include/clang/AST/JSONNodeDumper.h 
b/clang/include/clang/AST/JSONNodeDumper.h
index 089c0e97a90472..03c903069ad877 100644
--- a/clang/include/clang/AST/JSONNodeDumper.h
+++ b/clang/include/clang/AST/JSONNodeDumper.h
@@ -213,6 +213,7 @@ class JSONNodeDumper
   void VisitDeprecatedAttr(const DeprecatedAttr *DA);
   void VisitUnavailableAttr(const UnavailableAttr *UA);
   void VisitSectionAttr(const SectionAttr *SA);
+  void VisitVisibilityAttr(const VisibilityAttr *VA);
 
   void VisitTypedefType(const TypedefType *TT);
   void VisitUsingType(const UsingType *TT);

diff  --git a/clang/lib/AST/JSONNodeDumper.cpp 
b/clang/lib/AST/JSONNodeDumper.cpp
index ec5661d1d6944d..134938a1ef19a0 100644
--- a/clang/lib/AST/JSONNodeDumper.cpp
+++ b/clang/lib/AST/JSONNodeDumper.cpp
@@ -554,6 +554,11 @@ void JSONNodeDumper::VisitSectionAttr(const SectionAttr 
*SA) {
   JOS.attribute("section_name", SA->getName());
 }
 
+void JSONNodeDumper::VisitVisibilityAttr(const VisibilityAttr *VA) {
+  JOS.attribute("visibility", VisibilityAttr::ConvertVisibilityTypeToStr(
+  VA->getVisibility()));
+}
+
 void JSONNodeDumper::VisitTypedefType(const TypedefType *TT) {
   JOS.attribute("decl", createBareDeclRef(TT->getDecl()));
   if (!TT->typeMatchesDecl())

diff  --git a/clang/test/AST/ast-dump-attr-json.cpp 
b/clang/test/AST/ast-dump-attr-json.cpp
index a9679695e954f1..0eb930b851a15e 100644
--- a/clang/test/AST/ast-dump-attr-json.cpp
+++ b/clang/test/AST/ast-dump-attr-json.cpp
@@ -17,6 +17,9 @@ __attribute__((unavailable("reason"))) int unavailable_var1;
 
 __attribute__ ((section ("SECTION_NAME"))) int section_var;
 
+__attribute__ ((visibility ("hidden"))) int visibility_var;
+
+
 // NOTE: CHECK lines have been autogenerated by gen_ast_dump_json_test.py
 // using --filters=VarDecl
 
@@ -429,3 +432,50 @@ __attribute__ ((section ("SECTION_NAME"))) int section_var;
 // CHECK-NEXT:   }
 // CHECK-NEXT:  ]
 // CHECK-NEXT: }
+
+
+// CHECK-NOT: {{^}}Dumping
+// CHECK:  "kind": "VarDecl",
+// CHECK-NEXT:  "loc": {
+// CHECK-NEXT:   "offset": 651,
+// CHECK-NEXT:   "line": 20,
+// CHECK-NEXT:   "col": 45,
+// CHECK-NEXT:   "tokLen": 14
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "range": {
+// CHECK-NEXT:   "begin": {
+// CHECK-NEXT:"offset": 607,
+// CHECK-NEXT:"col": 1,
+// CHECK-NEXT:"tokLen": 13
+// CHECK-NEXT:   },
+// CHECK-NEXT:   "end": {
+// CHECK-NEXT:"offset": 651,
+// CHECK-NEXT:"col": 45,
+// CHECK-NEXT:"tokLen": 14
+// CHECK-NEXT:   }
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "name": "visibility_var",
+// CHECK-NEXT:  "mangledName": "visibility_var",
+// CHECK-NEXT:  "type": {
+// CHECK-NEXT:   "qualType": "int"
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "inner": [
+// CHECK-NEXT:   {
+// CHECK-NEXT:"id": "0x{{.*}}",
+// CHECK-NEXT:"kind": "VisibilityAttr",
+// CHECK-NEXT:"range": {
+// CHECK-NEXT: "begin": {
+// CHECK-NEXT:  "offset": 623,
+// CHECK-NEXT:  "col": 17,
+// CHECK-NEXT:  "tokLen": 10
+// CHECK-NEXT: },
+// CHECK-NEXT: "end": {
+// CHECK-NEXT:  "offset": 643,
+// CHECK-NEXT:  "col": 37,
+// CHECK-NEXT:  "tokLen": 1
+// CHECK-NEXT: }
+// CHECK-NEXT:},
+// CHECK-NEXT:"visibility": "hidden"
+// CHECK-NEXT:   }
+// CHECK-NEXT:  ]
+// CHECK-NEXT: }



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


[clang] 4cf7666 - [clang] Add missing field to SectionAttr json AST dump

2023-08-14 Thread via cfe-commits

Author: serge-sans-paille
Date: 2023-08-14T22:59:45+02:00
New Revision: 4cf7666b8f0962a21ab06769254391f633f07d1d

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

LOG: [clang] Add missing field to SectionAttr json AST dump

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

Added: 


Modified: 
clang/include/clang/AST/JSONNodeDumper.h
clang/lib/AST/JSONNodeDumper.cpp
clang/test/AST/ast-dump-attr-json.cpp

Removed: 




diff  --git a/clang/include/clang/AST/JSONNodeDumper.h 
b/clang/include/clang/AST/JSONNodeDumper.h
index 99ec1c3bc96668..089c0e97a90472 100644
--- a/clang/include/clang/AST/JSONNodeDumper.h
+++ b/clang/include/clang/AST/JSONNodeDumper.h
@@ -212,6 +212,7 @@ class JSONNodeDumper
   void VisitCleanupAttr(const CleanupAttr *CA);
   void VisitDeprecatedAttr(const DeprecatedAttr *DA);
   void VisitUnavailableAttr(const UnavailableAttr *UA);
+  void VisitSectionAttr(const SectionAttr *SA);
 
   void VisitTypedefType(const TypedefType *TT);
   void VisitUsingType(const UsingType *TT);

diff  --git a/clang/lib/AST/JSONNodeDumper.cpp 
b/clang/lib/AST/JSONNodeDumper.cpp
index 28f9b3163db9d4..ec5661d1d6944d 100644
--- a/clang/lib/AST/JSONNodeDumper.cpp
+++ b/clang/lib/AST/JSONNodeDumper.cpp
@@ -550,6 +550,10 @@ void JSONNodeDumper::VisitUnavailableAttr(const 
UnavailableAttr *UA) {
 JOS.attribute("message", UA->getMessage());
 }
 
+void JSONNodeDumper::VisitSectionAttr(const SectionAttr *SA) {
+  JOS.attribute("section_name", SA->getName());
+}
+
 void JSONNodeDumper::VisitTypedefType(const TypedefType *TT) {
   JOS.attribute("decl", createBareDeclRef(TT->getDecl()));
   if (!TT->typeMatchesDecl())

diff  --git a/clang/test/AST/ast-dump-attr-json.cpp 
b/clang/test/AST/ast-dump-attr-json.cpp
index 845dd72c5431b9..a9679695e954f1 100644
--- a/clang/test/AST/ast-dump-attr-json.cpp
+++ b/clang/test/AST/ast-dump-attr-json.cpp
@@ -15,6 +15,8 @@ __attribute__((deprecated("reason", "replacement"))) int 
deprecated_var2;
 __attribute__((unavailable)) int unavailable_var0;
 __attribute__((unavailable("reason"))) int unavailable_var1;
 
+__attribute__ ((section ("SECTION_NAME"))) int section_var;
+
 // NOTE: CHECK lines have been autogenerated by gen_ast_dump_json_test.py
 // using --filters=VarDecl
 
@@ -380,3 +382,50 @@ __attribute__((unavailable("reason"))) int 
unavailable_var1;
 // CHECK-NEXT:   }
 // CHECK-NEXT:  ]
 // CHECK-NEXT: }
+
+
+// CHECK-NOT: {{^}}Dumping
+// CHECK:  "kind": "VarDecl",
+// CHECK-NEXT:  "loc": {
+// CHECK-NEXT:   "offset": 593,
+// CHECK-NEXT:   "line": 18,
+// CHECK-NEXT:   "col": 48,
+// CHECK-NEXT:   "tokLen": 11
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "range": {
+// CHECK-NEXT:   "begin": {
+// CHECK-NEXT:"offset": 546,
+// CHECK-NEXT:"col": 1,
+// CHECK-NEXT:"tokLen": 13
+// CHECK-NEXT:   },
+// CHECK-NEXT:   "end": {
+// CHECK-NEXT:"offset": 593,
+// CHECK-NEXT:"col": 48,
+// CHECK-NEXT:"tokLen": 11
+// CHECK-NEXT:   }
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "name": "section_var",
+// CHECK-NEXT:  "mangledName": "section_var",
+// CHECK-NEXT:  "type": {
+// CHECK-NEXT:   "qualType": "int"
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "inner": [
+// CHECK-NEXT:   {
+// CHECK-NEXT:"id": "0x{{.*}}",
+// CHECK-NEXT:"kind": "SectionAttr",
+// CHECK-NEXT:"range": {
+// CHECK-NEXT: "begin": {
+// CHECK-NEXT:  "offset": 562,
+// CHECK-NEXT:  "col": 17,
+// CHECK-NEXT:  "tokLen": 7
+// CHECK-NEXT: },
+// CHECK-NEXT: "end": {
+// CHECK-NEXT:  "offset": 585,
+// CHECK-NEXT:  "col": 40,
+// CHECK-NEXT:  "tokLen": 1
+// CHECK-NEXT: }
+// CHECK-NEXT:},
+// CHECK-NEXT:"section_name": "SECTION_NAME"
+// CHECK-NEXT:   }
+// CHECK-NEXT:  ]
+// CHECK-NEXT: }



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


[clang] 3dadc29 - [clang] Add missing fields to DeprecatedAttr and Unavailable json AST dump

2023-08-14 Thread via cfe-commits

Author: serge-sans-paille
Date: 2023-08-14T22:59:45+02:00
New Revision: 3dadc290b21018d528bd6e46d8d596e1dbb68f3d

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

LOG: [clang] Add missing fields to DeprecatedAttr and Unavailable json AST dump

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

Added: 


Modified: 
clang/include/clang/AST/JSONNodeDumper.h
clang/lib/AST/JSONNodeDumper.cpp
clang/test/AST/ast-dump-attr-json.cpp

Removed: 




diff  --git a/clang/include/clang/AST/JSONNodeDumper.h 
b/clang/include/clang/AST/JSONNodeDumper.h
index c86dbf4d9e5558..99ec1c3bc96668 100644
--- a/clang/include/clang/AST/JSONNodeDumper.h
+++ b/clang/include/clang/AST/JSONNodeDumper.h
@@ -210,6 +210,8 @@ class JSONNodeDumper
 
   void VisitAliasAttr(const AliasAttr *AA);
   void VisitCleanupAttr(const CleanupAttr *CA);
+  void VisitDeprecatedAttr(const DeprecatedAttr *DA);
+  void VisitUnavailableAttr(const UnavailableAttr *UA);
 
   void VisitTypedefType(const TypedefType *TT);
   void VisitUsingType(const UsingType *TT);

diff  --git a/clang/lib/AST/JSONNodeDumper.cpp 
b/clang/lib/AST/JSONNodeDumper.cpp
index a7ca34623d6089..28f9b3163db9d4 100644
--- a/clang/lib/AST/JSONNodeDumper.cpp
+++ b/clang/lib/AST/JSONNodeDumper.cpp
@@ -538,6 +538,18 @@ void JSONNodeDumper::VisitCleanupAttr(const CleanupAttr 
*CA) {
   JOS.attribute("cleanup_function", createBareDeclRef(CA->getFunctionDecl()));
 }
 
+void JSONNodeDumper::VisitDeprecatedAttr(const DeprecatedAttr *DA) {
+  if (!DA->getMessage().empty())
+JOS.attribute("message", DA->getMessage());
+  if (!DA->getReplacement().empty())
+JOS.attribute("replacement", DA->getReplacement());
+}
+
+void JSONNodeDumper::VisitUnavailableAttr(const UnavailableAttr *UA) {
+  if (!UA->getMessage().empty())
+JOS.attribute("message", UA->getMessage());
+}
+
 void JSONNodeDumper::VisitTypedefType(const TypedefType *TT) {
   JOS.attribute("decl", createBareDeclRef(TT->getDecl()));
   if (!TT->typeMatchesDecl())

diff  --git a/clang/test/AST/ast-dump-attr-json.cpp 
b/clang/test/AST/ast-dump-attr-json.cpp
index adac50af0890a0..845dd72c5431b9 100644
--- a/clang/test/AST/ast-dump-attr-json.cpp
+++ b/clang/test/AST/ast-dump-attr-json.cpp
@@ -8,6 +8,13 @@ void some() {
   __attribute__((cleanup(cleanup_function))) int var;
 }
 
+__attribute__((deprecated)) int deprecated_var0;
+__attribute__((deprecated("reason"))) int deprecated_var1;
+__attribute__((deprecated("reason", "replacement"))) int deprecated_var2;
+
+__attribute__((unavailable)) int unavailable_var0;
+__attribute__((unavailable("reason"))) int unavailable_var1;
+
 // NOTE: CHECK lines have been autogenerated by gen_ast_dump_json_test.py
 // using --filters=VarDecl
 
@@ -139,3 +146,237 @@ void some() {
 // CHECK-NEXT:   }
 // CHECK-NEXT:  ]
 // CHECK-NEXT: }
+
+
+// CHECK-NOT: {{^}}Dumping
+// CHECK:  "kind": "VarDecl",
+// CHECK-NEXT:  "loc": {
+// CHECK-NEXT:   "offset": 282,
+// CHECK-NEXT:   "line": 11,
+// CHECK-NEXT:   "col": 33,
+// CHECK-NEXT:   "tokLen": 15
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "range": {
+// CHECK-NEXT:   "begin": {
+// CHECK-NEXT:"offset": 250,
+// CHECK-NEXT:"col": 1,
+// CHECK-NEXT:"tokLen": 13
+// CHECK-NEXT:   },
+// CHECK-NEXT:   "end": {
+// CHECK-NEXT:"offset": 282,
+// CHECK-NEXT:"col": 33,
+// CHECK-NEXT:"tokLen": 15
+// CHECK-NEXT:   }
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "name": "deprecated_var0",
+// CHECK-NEXT:  "mangledName": "deprecated_var0",
+// CHECK-NEXT:  "type": {
+// CHECK-NEXT:   "qualType": "int"
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "inner": [
+// CHECK-NEXT:   {
+// CHECK-NEXT:"id": "0x{{.*}}",
+// CHECK-NEXT:"kind": "DeprecatedAttr",
+// CHECK-NEXT:"range": {
+// CHECK-NEXT: "begin": {
+// CHECK-NEXT:  "offset": 265,
+// CHECK-NEXT:  "col": 16,
+// CHECK-NEXT:  "tokLen": 10
+// CHECK-NEXT: },
+// CHECK-NEXT: "end": {
+// CHECK-NEXT:  "offset": 265,
+// CHECK-NEXT:  "col": 16,
+// CHECK-NEXT:  "tokLen": 10
+// CHECK-NEXT: }
+// CHECK-NEXT:}
+// CHECK-NEXT:   }
+// CHECK-NEXT:  ]
+// CHECK-NEXT: }
+
+
+// CHECK-NOT: {{^}}Dumping
+// CHECK:  "kind": "VarDecl",
+// CHECK-NEXT:  "loc": {
+// CHECK-NEXT:   "offset": 341,
+// CHECK-NEXT:   "line": 12,
+// CHECK-NEXT:   "col": 43,
+// CHECK-NEXT:   "tokLen": 15
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "range": {
+// CHECK-NEXT:   "begin": {
+// CHECK-NEXT:"offset": 299,
+// CHECK-NEXT:"col": 1,
+// CHECK-NEXT:"tokLen": 13
+// CHECK-NEXT:   },
+// CHECK-NEXT:   "end": {
+// CHECK-NEXT:"offset": 341,
+// CHECK-NEXT:"col": 43,
+// CHECK-NEXT:"tokLen": 15
+// CHECK-NEXT:   }
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "name": "deprecated_var1",
+// CHECK-NEXT:  "mangledName": "deprecated_var1",
+// 

[clang] 903e530 - [clang] Add cleanup_function field to CleanupAttr json AST dump

2023-08-14 Thread via cfe-commits

Author: serge-sans-paille
Date: 2023-08-14T22:59:45+02:00
New Revision: 903e530bb8980a3c30ea5eb98d2ec1cd61d94b57

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

LOG: [clang] Add cleanup_function field to CleanupAttr json AST dump

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

Added: 


Modified: 
clang/include/clang/AST/JSONNodeDumper.h
clang/lib/AST/JSONNodeDumper.cpp
clang/test/AST/ast-dump-attr-json.cpp

Removed: 




diff  --git a/clang/include/clang/AST/JSONNodeDumper.h 
b/clang/include/clang/AST/JSONNodeDumper.h
index c465137187cba4..c86dbf4d9e5558 100644
--- a/clang/include/clang/AST/JSONNodeDumper.h
+++ b/clang/include/clang/AST/JSONNodeDumper.h
@@ -209,6 +209,7 @@ class JSONNodeDumper
   void Visit(const APValue , QualType Ty);
 
   void VisitAliasAttr(const AliasAttr *AA);
+  void VisitCleanupAttr(const CleanupAttr *CA);
 
   void VisitTypedefType(const TypedefType *TT);
   void VisitUsingType(const UsingType *TT);

diff  --git a/clang/lib/AST/JSONNodeDumper.cpp 
b/clang/lib/AST/JSONNodeDumper.cpp
index 318e7d22db4567..a7ca34623d6089 100644
--- a/clang/lib/AST/JSONNodeDumper.cpp
+++ b/clang/lib/AST/JSONNodeDumper.cpp
@@ -534,6 +534,10 @@ void JSONNodeDumper::VisitAliasAttr(const AliasAttr *AA) {
   JOS.attribute("aliasee", AA->getAliasee());
 }
 
+void JSONNodeDumper::VisitCleanupAttr(const CleanupAttr *CA) {
+  JOS.attribute("cleanup_function", createBareDeclRef(CA->getFunctionDecl()));
+}
+
 void JSONNodeDumper::VisitTypedefType(const TypedefType *TT) {
   JOS.attribute("decl", createBareDeclRef(TT->getDecl()));
   if (!TT->typeMatchesDecl())

diff  --git a/clang/test/AST/ast-dump-attr-json.cpp 
b/clang/test/AST/ast-dump-attr-json.cpp
index 40a49e0cab9490..adac50af0890a0 100644
--- a/clang/test/AST/ast-dump-attr-json.cpp
+++ b/clang/test/AST/ast-dump-attr-json.cpp
@@ -3,6 +3,11 @@
 int global_decl;
 extern __attribute__((alias("global_decl"))) int global_alias;
 
+void cleanup_function(int*);
+void some() {
+  __attribute__((cleanup(cleanup_function))) int var;
+}
+
 // NOTE: CHECK lines have been autogenerated by gen_ast_dump_json_test.py
 // using --filters=VarDecl
 
@@ -78,7 +83,59 @@ extern __attribute__((alias("global_decl"))) int 
global_alias;
 // CHECK-NEXT:  "tokLen": 1
 // CHECK-NEXT: }
 // CHECK-NEXT:},
-// CHECK-NEXT:"decl": "global_decl"
+// CHECK-NEXT:"aliasee": "global_decl"
+// CHECK-NEXT:   }
+// CHECK-NEXT:  ]
+// CHECK-NEXT: }
+
+
+// CHECK-NOT: {{^}}Dumping
+// CHECK:  "kind": "VarDecl",
+// CHECK-NEXT:  "loc": {
+// CHECK-NEXT:   "offset": 242,
+// CHECK-NEXT:   "col": 50,
+// CHECK-NEXT:   "tokLen": 3
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "range": {
+// CHECK-NEXT:   "begin": {
+// CHECK-NEXT:"offset": 195,
+// CHECK-NEXT:"col": 3,
+// CHECK-NEXT:"tokLen": 13
+// CHECK-NEXT:   },
+// CHECK-NEXT:   "end": {
+// CHECK-NEXT:"offset": 242,
+// CHECK-NEXT:"col": 50,
+// CHECK-NEXT:"tokLen": 3
+// CHECK-NEXT:   }
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "name": "var",
+// CHECK-NEXT:  "type": {
+// CHECK-NEXT:   "qualType": "int"
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "inner": [
+// CHECK-NEXT:   {
+// CHECK-NEXT:"id": "0x{{.*}}",
+// CHECK-NEXT:"kind": "CleanupAttr",
+// CHECK-NEXT:"range": {
+// CHECK-NEXT: "begin": {
+// CHECK-NEXT:  "offset": 210,
+// CHECK-NEXT:  "col": 18,
+// CHECK-NEXT:  "tokLen": 7
+// CHECK-NEXT: },
+// CHECK-NEXT: "end": {
+// CHECK-NEXT:  "offset": 234,
+// CHECK-NEXT:  "col": 42,
+// CHECK-NEXT:  "tokLen": 1
+// CHECK-NEXT: }
+// CHECK-NEXT:},
+// CHECK-NEXT:"cleanup_function": {
+// CHECK-NEXT: "id": "0x{{.*}}",
+// CHECK-NEXT: "kind": "FunctionDecl",
+// CHECK-NEXT: "name": "cleanup_function",
+// CHECK-NEXT: "type": {
+// CHECK-NEXT:  "qualType": "void (int *)"
+// CHECK-NEXT: }
+// CHECK-NEXT:}
 // CHECK-NEXT:   }
 // CHECK-NEXT:  ]
 // CHECK-NEXT: }



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


[clang] 11f3286 - [clang] Add aliasee field to AliasAttr json AST dump

2023-08-14 Thread via cfe-commits

Author: serge-sans-paille
Date: 2023-08-14T22:59:40+02:00
New Revision: 11f3286585ce86df8107617536226dea24e74d94

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

LOG: [clang] Add aliasee field to AliasAttr json AST dump

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

Added: 
clang/test/AST/ast-dump-attr-json.cpp

Modified: 
clang/include/clang/AST/JSONNodeDumper.h
clang/lib/AST/JSONNodeDumper.cpp

Removed: 




diff  --git a/clang/include/clang/AST/JSONNodeDumper.h 
b/clang/include/clang/AST/JSONNodeDumper.h
index 5e2756f2a20317..c465137187cba4 100644
--- a/clang/include/clang/AST/JSONNodeDumper.h
+++ b/clang/include/clang/AST/JSONNodeDumper.h
@@ -208,6 +208,8 @@ class JSONNodeDumper
   void Visit(const concepts::Requirement *R);
   void Visit(const APValue , QualType Ty);
 
+  void VisitAliasAttr(const AliasAttr *AA);
+
   void VisitTypedefType(const TypedefType *TT);
   void VisitUsingType(const UsingType *TT);
   void VisitFunctionType(const FunctionType *T);

diff  --git a/clang/lib/AST/JSONNodeDumper.cpp 
b/clang/lib/AST/JSONNodeDumper.cpp
index 958b0e6cf2ef6c..318e7d22db4567 100644
--- a/clang/lib/AST/JSONNodeDumper.cpp
+++ b/clang/lib/AST/JSONNodeDumper.cpp
@@ -530,6 +530,10 @@ JSONNodeDumper::createCXXBaseSpecifier(const 
CXXBaseSpecifier ) {
   return Ret;
 }
 
+void JSONNodeDumper::VisitAliasAttr(const AliasAttr *AA) {
+  JOS.attribute("aliasee", AA->getAliasee());
+}
+
 void JSONNodeDumper::VisitTypedefType(const TypedefType *TT) {
   JOS.attribute("decl", createBareDeclRef(TT->getDecl()));
   if (!TT->typeMatchesDecl())

diff  --git a/clang/test/AST/ast-dump-attr-json.cpp 
b/clang/test/AST/ast-dump-attr-json.cpp
new file mode 100644
index 00..40a49e0cab9490
--- /dev/null
+++ b/clang/test/AST/ast-dump-attr-json.cpp
@@ -0,0 +1,84 @@
+// RUN: %clang_cc1 -Wdocumentation -ast-dump=json %s | FileCheck %s
+
+int global_decl;
+extern __attribute__((alias("global_decl"))) int global_alias;
+
+// NOTE: CHECK lines have been autogenerated by gen_ast_dump_json_test.py
+// using --filters=VarDecl
+
+
+// CHECK-NOT: {{^}}Dumping
+// CHECK:  "kind": "VarDecl",
+// CHECK-NEXT:  "loc": {
+// CHECK-NEXT:   "offset": 73,
+// CHECK-NEXT:   "file": "{{.*}}",
+// CHECK-NEXT:   "line": 3,
+// CHECK-NEXT:   "col": 5,
+// CHECK-NEXT:   "tokLen": 11
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "range": {
+// CHECK-NEXT:   "begin": {
+// CHECK-NEXT:"offset": 69,
+// CHECK-NEXT:"col": 1,
+// CHECK-NEXT:"tokLen": 3
+// CHECK-NEXT:   },
+// CHECK-NEXT:   "end": {
+// CHECK-NEXT:"offset": 73,
+// CHECK-NEXT:"col": 5,
+// CHECK-NEXT:"tokLen": 11
+// CHECK-NEXT:   }
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "name": "global_decl",
+// CHECK-NEXT:  "mangledName": "global_decl",
+// CHECK-NEXT:  "type": {
+// CHECK-NEXT:   "qualType": "int"
+// CHECK-NEXT:  }
+// CHECK-NEXT: }
+
+
+// CHECK-NOT: {{^}}Dumping
+// CHECK:  "kind": "VarDecl",
+// CHECK-NEXT:  "loc": {
+// CHECK-NEXT:   "offset": 135,
+// CHECK-NEXT:   "line": 4,
+// CHECK-NEXT:   "col": 50,
+// CHECK-NEXT:   "tokLen": 12
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "range": {
+// CHECK-NEXT:   "begin": {
+// CHECK-NEXT:"offset": 86,
+// CHECK-NEXT:"col": 1,
+// CHECK-NEXT:"tokLen": 6
+// CHECK-NEXT:   },
+// CHECK-NEXT:   "end": {
+// CHECK-NEXT:"offset": 135,
+// CHECK-NEXT:"col": 50,
+// CHECK-NEXT:"tokLen": 12
+// CHECK-NEXT:   }
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "name": "global_alias",
+// CHECK-NEXT:  "mangledName": "global_alias",
+// CHECK-NEXT:  "type": {
+// CHECK-NEXT:   "qualType": "int"
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "storageClass": "extern",
+// CHECK-NEXT:  "inner": [
+// CHECK-NEXT:   {
+// CHECK-NEXT:"id": "0x{{.*}}",
+// CHECK-NEXT:"kind": "AliasAttr",
+// CHECK-NEXT:"range": {
+// CHECK-NEXT: "begin": {
+// CHECK-NEXT:  "offset": 108,
+// CHECK-NEXT:  "col": 23,
+// CHECK-NEXT:  "tokLen": 5
+// CHECK-NEXT: },
+// CHECK-NEXT: "end": {
+// CHECK-NEXT:  "offset": 127,
+// CHECK-NEXT:  "col": 42,
+// CHECK-NEXT:  "tokLen": 1
+// CHECK-NEXT: }
+// CHECK-NEXT:},
+// CHECK-NEXT:"decl": "global_decl"
+// CHECK-NEXT:   }
+// CHECK-NEXT:  ]
+// CHECK-NEXT: }



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


[PATCH] D157497: feat: Migrate isArch16Bit

2023-08-14 Thread Alex Langford via Phabricator via cfe-commits
bulbazord added a comment.

In D157497#4586165 , @MaskRay wrote:

> In D157497#4584621 , @Pivnoy wrote:
>
>> This discussion was the main motivation for this change.
>> https://discourse.llvm.org/t/rfc-refactor-triple-related-classes/70410/11
>> As a result, Triple should become a data class, and its dependencies such as 
>> Architecture, Operating System etc. represent in the form of interfaces that 
>> can be implemented for the necessary instances.
>
> FWIW I still don't see advantages by switching to the new 
> `llvm::TripleUtils::isArch32Bit` style. How is it better than the current way?

+1
What advantages does this approach bring? I re-read the RFC in the discourse 
link you posted and I'm still not sure why this approach is desirable. Happy to 
discuss further either on this PR or in the discourse thread.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157497

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


[PATCH] D157904: Improve reliability of CompilationDatabaseTest

2023-08-14 Thread Ellis Hoag 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 rG9e11d6850a5a: Improve reliability of CompilationDatabaseTest 
(authored by ellis).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157904

Files:
  clang/unittests/Tooling/CompilationDatabaseTest.cpp


Index: clang/unittests/Tooling/CompilationDatabaseTest.cpp
===
--- clang/unittests/Tooling/CompilationDatabaseTest.cpp
+++ clang/unittests/Tooling/CompilationDatabaseTest.cpp
@@ -6,9 +6,6 @@
 //
 
//===--===//
 
-#include "clang/AST/DeclCXX.h"
-#include "clang/AST/DeclGroup.h"
-#include "clang/Frontend/FrontendAction.h"
 #include "clang/Tooling/CompilationDatabase.h"
 #include "clang/Tooling/FileMatchTrie.h"
 #include "clang/Tooling/JSONCompilationDatabase.h"
@@ -24,6 +21,8 @@
 
 using testing::ElementsAre;
 using testing::EndsWith;
+using testing::IsEmpty;
+using testing::UnorderedElementsAreArray;
 
 static void expectFailure(StringRef JSONDatabase, StringRef Explanation) {
   std::string ErrorMessage;
@@ -83,8 +82,8 @@
 
 TEST(JSONCompilationDatabase, GetAllFiles) {
   std::string ErrorMessage;
-  EXPECT_EQ(std::vector(),
-getAllFiles("[]", ErrorMessage, JSONCommandLineSyntax::Gnu))
+  EXPECT_THAT(getAllFiles("[]", ErrorMessage, JSONCommandLineSyntax::Gnu),
+  IsEmpty())
   << ErrorMessage;
 
   std::vector expected_files;
@@ -97,8 +96,7 @@
   expected_files.push_back(std::string(PathStorage.str()));
   llvm::sys::path::native("//net/file1", PathStorage);
   expected_files.push_back(std::string(PathStorage.str()));
-  EXPECT_EQ(expected_files,
-getAllFiles(R"json(
+  EXPECT_THAT(getAllFiles(R"json(
 [
   {
 "directory": "//net/dir",
@@ -121,7 +119,8 @@
 "file": "//net/dir/foo/../file3"
   }
 ])json",
-ErrorMessage, JSONCommandLineSyntax::Gnu))
+  ErrorMessage, JSONCommandLineSyntax::Gnu),
+  UnorderedElementsAreArray(expected_files))
   << ErrorMessage;
 }
 
@@ -550,7 +549,7 @@
   CommandLine.push_back("two");
   FixedCompilationDatabase Database(".", CommandLine);
 
-  EXPECT_EQ(0ul, Database.getAllFiles().size());
+  EXPECT_THAT(Database.getAllFiles(), IsEmpty());
 }
 
 TEST(FixedCompilationDatabase, GetAllCompileCommands) {


Index: clang/unittests/Tooling/CompilationDatabaseTest.cpp
===
--- clang/unittests/Tooling/CompilationDatabaseTest.cpp
+++ clang/unittests/Tooling/CompilationDatabaseTest.cpp
@@ -6,9 +6,6 @@
 //
 //===--===//
 
-#include "clang/AST/DeclCXX.h"
-#include "clang/AST/DeclGroup.h"
-#include "clang/Frontend/FrontendAction.h"
 #include "clang/Tooling/CompilationDatabase.h"
 #include "clang/Tooling/FileMatchTrie.h"
 #include "clang/Tooling/JSONCompilationDatabase.h"
@@ -24,6 +21,8 @@
 
 using testing::ElementsAre;
 using testing::EndsWith;
+using testing::IsEmpty;
+using testing::UnorderedElementsAreArray;
 
 static void expectFailure(StringRef JSONDatabase, StringRef Explanation) {
   std::string ErrorMessage;
@@ -83,8 +82,8 @@
 
 TEST(JSONCompilationDatabase, GetAllFiles) {
   std::string ErrorMessage;
-  EXPECT_EQ(std::vector(),
-getAllFiles("[]", ErrorMessage, JSONCommandLineSyntax::Gnu))
+  EXPECT_THAT(getAllFiles("[]", ErrorMessage, JSONCommandLineSyntax::Gnu),
+  IsEmpty())
   << ErrorMessage;
 
   std::vector expected_files;
@@ -97,8 +96,7 @@
   expected_files.push_back(std::string(PathStorage.str()));
   llvm::sys::path::native("//net/file1", PathStorage);
   expected_files.push_back(std::string(PathStorage.str()));
-  EXPECT_EQ(expected_files,
-getAllFiles(R"json(
+  EXPECT_THAT(getAllFiles(R"json(
 [
   {
 "directory": "//net/dir",
@@ -121,7 +119,8 @@
 "file": "//net/dir/foo/../file3"
   }
 ])json",
-ErrorMessage, JSONCommandLineSyntax::Gnu))
+  ErrorMessage, JSONCommandLineSyntax::Gnu),
+  UnorderedElementsAreArray(expected_files))
   << ErrorMessage;
 }
 
@@ -550,7 +549,7 @@
   CommandLine.push_back("two");
   FixedCompilationDatabase Database(".", CommandLine);
 
-  EXPECT_EQ(0ul, Database.getAllFiles().size());
+  EXPECT_THAT(Database.getAllFiles(), IsEmpty());
 }
 
 TEST(FixedCompilationDatabase, GetAllCompileCommands) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 9e11d68 - Improve reliability of CompilationDatabaseTest

2023-08-14 Thread Ellis Hoag via cfe-commits

Author: Ellis Hoag
Date: 2023-08-14T13:46:21-07:00
New Revision: 9e11d6850a5a5a3518f300769724a5c13d2e6ec6

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

LOG: Improve reliability of CompilationDatabaseTest

We've seen `CompilationDatabaseTest.cpp` fail because the order of the files 
returned by `getAllFiles()` was in a different order than expected. Use 
`UnorderedElementsAreArray()` to handle different file orders.

Reviewed By: kadircet

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

Added: 


Modified: 
clang/unittests/Tooling/CompilationDatabaseTest.cpp

Removed: 




diff  --git a/clang/unittests/Tooling/CompilationDatabaseTest.cpp 
b/clang/unittests/Tooling/CompilationDatabaseTest.cpp
index ee91af7a631fe0..5173d472486bfc 100644
--- a/clang/unittests/Tooling/CompilationDatabaseTest.cpp
+++ b/clang/unittests/Tooling/CompilationDatabaseTest.cpp
@@ -6,9 +6,6 @@
 //
 
//===--===//
 
-#include "clang/AST/DeclCXX.h"
-#include "clang/AST/DeclGroup.h"
-#include "clang/Frontend/FrontendAction.h"
 #include "clang/Tooling/CompilationDatabase.h"
 #include "clang/Tooling/FileMatchTrie.h"
 #include "clang/Tooling/JSONCompilationDatabase.h"
@@ -24,6 +21,8 @@ namespace tooling {
 
 using testing::ElementsAre;
 using testing::EndsWith;
+using testing::IsEmpty;
+using testing::UnorderedElementsAreArray;
 
 static void expectFailure(StringRef JSONDatabase, StringRef Explanation) {
   std::string ErrorMessage;
@@ -83,8 +82,8 @@ getAllCompileCommands(JSONCommandLineSyntax Syntax, StringRef 
JSONDatabase,
 
 TEST(JSONCompilationDatabase, GetAllFiles) {
   std::string ErrorMessage;
-  EXPECT_EQ(std::vector(),
-getAllFiles("[]", ErrorMessage, JSONCommandLineSyntax::Gnu))
+  EXPECT_THAT(getAllFiles("[]", ErrorMessage, JSONCommandLineSyntax::Gnu),
+  IsEmpty())
   << ErrorMessage;
 
   std::vector expected_files;
@@ -97,8 +96,7 @@ TEST(JSONCompilationDatabase, GetAllFiles) {
   expected_files.push_back(std::string(PathStorage.str()));
   llvm::sys::path::native("//net/file1", PathStorage);
   expected_files.push_back(std::string(PathStorage.str()));
-  EXPECT_EQ(expected_files,
-getAllFiles(R"json(
+  EXPECT_THAT(getAllFiles(R"json(
 [
   {
 "directory": "//net/dir",
@@ -121,7 +119,8 @@ TEST(JSONCompilationDatabase, GetAllFiles) {
 "file": "//net/dir/foo/../file3"
   }
 ])json",
-ErrorMessage, JSONCommandLineSyntax::Gnu))
+  ErrorMessage, JSONCommandLineSyntax::Gnu),
+  UnorderedElementsAreArray(expected_files))
   << ErrorMessage;
 }
 
@@ -550,7 +549,7 @@ TEST(FixedCompilationDatabase, GetAllFiles) {
   CommandLine.push_back("two");
   FixedCompilationDatabase Database(".", CommandLine);
 
-  EXPECT_EQ(0ul, Database.getAllFiles().size());
+  EXPECT_THAT(Database.getAllFiles(), IsEmpty());
 }
 
 TEST(FixedCompilationDatabase, GetAllCompileCommands) {



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


[PATCH] D126864: [clang] Introduce -fstrict-flex-arrays= for stricter handling of flexible arrays

2023-08-14 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

RecordDecl::hasFlexibleArrayMember() is supposed to reflect the standard's 
definition of a flexible array member, which only includes incomplete arrays.  
The places that care about other array members use separate checks.  We 
wouldn't want to accidentally extend the non-standard treatment of arrays with 
fixed bound to other places.

I think there was an effort to try to refactor uses of StrictFlexArrays to a 
centralized helper, but I don't remember what happened to it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126864

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


[PATCH] D157374: [clang-tidy] Ignore decltype in misc-redundant-expression

2023-08-14 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp accepted this revision.
carlosgalvezp 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/D157374/new/

https://reviews.llvm.org/D157374

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


[PATCH] D157326: [clang-tidy] Fix handling of out-of-line functions in readability-static-accessed-through-instance

2023-08-14 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp accepted this revision.
carlosgalvezp 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/D157326/new/

https://reviews.llvm.org/D157326

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


[clang] 4e3b894 - Revert "[Option] Add "Visibility" field and clone the OptTable APIs to use it"

2023-08-14 Thread Justin Bogner via cfe-commits

Author: Justin Bogner
Date: 2023-08-14T13:31:02-07:00
New Revision: 4e3b89483a6922d3f48670bb1c50a37f342918c6

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

LOG: Revert "[Option] Add "Visibility" field and clone the OptTable APIs to use 
it"

this is failing on bots, reverting to investigate.

This reverts commit a16104e6da6f36f3d72dbf53d10ba56495a0d65a.

Added: 


Modified: 
clang-tools-extra/clangd/CompileCommands.cpp
clang/lib/Frontend/CompilerInvocation.cpp
lld/MachO/DriverUtils.cpp
lld/MinGW/Driver.cpp
lld/wasm/Driver.cpp
llvm/include/llvm/Option/OptParser.td
llvm/include/llvm/Option/OptTable.h
llvm/include/llvm/Option/Option.h
llvm/lib/ExecutionEngine/JITLink/COFFDirectiveParser.cpp
llvm/lib/Option/OptTable.cpp
llvm/lib/ToolDrivers/llvm-dlltool/DlltoolDriver.cpp
llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp
llvm/tools/dsymutil/dsymutil.cpp
llvm/tools/llvm-cvtres/llvm-cvtres.cpp
llvm/tools/llvm-cxxfilt/llvm-cxxfilt.cpp
llvm/tools/llvm-debuginfod/llvm-debuginfod.cpp
llvm/tools/llvm-dwarfutil/llvm-dwarfutil.cpp
llvm/tools/llvm-dwp/llvm-dwp.cpp
llvm/tools/llvm-lipo/llvm-lipo.cpp
llvm/tools/llvm-mt/llvm-mt.cpp
llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
llvm/tools/llvm-rc/llvm-rc.cpp
llvm/tools/llvm-strings/llvm-strings.cpp
llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp
llvm/tools/llvm-tli-checker/llvm-tli-checker.cpp
llvm/unittests/Option/OptionMarshallingTest.cpp
llvm/unittests/Option/OptionParsingTest.cpp
llvm/unittests/Option/Opts.td
llvm/utils/TableGen/OptParserEmitter.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/CompileCommands.cpp 
b/clang-tools-extra/clangd/CompileCommands.cpp
index 3fce1b8bcb490c..00f4c4ca9fef0a 100644
--- a/clang-tools-extra/clangd/CompileCommands.cpp
+++ b/clang-tools-extra/clangd/CompileCommands.cpp
@@ -494,7 +494,7 @@ llvm::ArrayRef 
ArgStripper::rulesFor(llvm::StringRef Arg) {
   static constexpr llvm::ArrayRef NAME(   
\
   NAME##_init, std::size(NAME##_init) - 1);
 #define OPTION(PREFIX, PREFIXED_NAME, ID, KIND, GROUP, ALIAS, ALIASARGS,   
\
-   FLAGS, VISIBILITY, PARAM, HELP, METAVAR, VALUES)
\
+   FLAGS, PARAM, HELP, METAVAR, VALUES)
\
   Prefixes[DriverID::OPT_##ID] = PREFIX;
 #include "clang/Driver/Options.inc"
 #undef OPTION
@@ -506,7 +506,7 @@ llvm::ArrayRef 
ArgStripper::rulesFor(llvm::StringRef Arg) {
   const void *AliasArgs;
 } AliasTable[] = {
 #define OPTION(PREFIX, PREFIXED_NAME, ID, KIND, GROUP, ALIAS, ALIASARGS,   
\
-   FLAGS, VISIBILITY, PARAM, HELP, METAVAR, VALUES)
\
+   FLAGS, PARAM, HELP, METAVAR, VALUES)
\
   {DriverID::OPT_##ID, DriverID::OPT_##ALIAS, ALIASARGS},
 #include "clang/Driver/Options.inc"
 #undef OPTION

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index 0d7a497cbd42af..87190093767b05 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -423,9 +423,9 @@ static T extractMaskValue(T KeyPath) {
 
 #define PARSE_OPTION_WITH_MARSHALLING( 
\
 ARGS, DIAGS, PREFIX_TYPE, SPELLING, ID, KIND, GROUP, ALIAS, ALIASARGS, 
\
-FLAGS, VISIBILITY, PARAM, HELPTEXT, METAVAR, VALUES, SHOULD_PARSE, 
\
-ALWAYS_EMIT, KEYPATH, DEFAULT_VALUE, IMPLIED_CHECK, IMPLIED_VALUE, 
\
-NORMALIZER, DENORMALIZER, MERGER, EXTRACTOR, TABLE_INDEX)  
\
+FLAGS, PARAM, HELPTEXT, METAVAR, VALUES, SHOULD_PARSE, ALWAYS_EMIT,
\
+KEYPATH, DEFAULT_VALUE, IMPLIED_CHECK, IMPLIED_VALUE, NORMALIZER,  
\
+DENORMALIZER, MERGER, EXTRACTOR, TABLE_INDEX)  
\
   if ((FLAGS)::CC1Option) {
\
 KEYPATH = MERGER(KEYPATH, DEFAULT_VALUE);  
\
 if (IMPLIED_CHECK) 
\
@@ -440,9 +440,9 @@ static T extractMaskValue(T KeyPath) {
 // with lifetime extension of the reference.
 #define GENERATE_OPTION_WITH_MARSHALLING(  
\
 CONSUMER, PREFIX_TYPE, SPELLING, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, 
\
-VISIBILKITY, PARAM, HELPTEXT, METAVAR, VALUES, SHOULD_PARSE, ALWAYS_EMIT,  
\
-KEYPATH, DEFAULT_VALUE, IMPLIED_CHECK, IMPLIED_VALUE, NORMALIZER,  
\
-DENORMALIZER, MERGER, EXTRACTOR, TABLE_INDEX)  
\
+PARAM, HELPTEXT, METAVAR, VALUES, SHOULD_PARSE, ALWAYS_EMIT, KEYPATH,  
\
+DEFAULT_VALUE, IMPLIED_CHECK, 

[PATCH] D157280: [PGO] Enable `-fprofile-update` for `-fprofile-generate`

2023-08-14 Thread Qiongsi Wu via Phabricator via cfe-commits
qiongsiwu1 updated this revision to Diff 550067.
qiongsiwu1 added a comment.

Fixing method parameter name format.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157280

Files:
  clang/docs/UsersManual.rst
  clang/lib/CodeGen/BackendUtil.cpp
  clang/test/CodeGen/tsan-instrprof-atomic.c
  llvm/include/llvm/Passes/PassBuilder.h
  llvm/include/llvm/Support/PGOOptions.h
  llvm/lib/Passes/PassBuilderPipelines.cpp
  llvm/lib/Support/PGOOptions.cpp

Index: llvm/lib/Support/PGOOptions.cpp
===
--- llvm/lib/Support/PGOOptions.cpp
+++ llvm/lib/Support/PGOOptions.cpp
@@ -16,13 +16,14 @@
std::string MemoryProfile,
IntrusiveRefCntPtr FS, PGOAction Action,
CSPGOAction CSAction, bool DebugInfoForProfiling,
-   bool PseudoProbeForProfiling)
+   bool PseudoProbeForProfiling, bool AtomicCounterUpdate)
 : ProfileFile(ProfileFile), CSProfileGenFile(CSProfileGenFile),
   ProfileRemappingFile(ProfileRemappingFile), MemoryProfile(MemoryProfile),
   Action(Action), CSAction(CSAction),
   DebugInfoForProfiling(DebugInfoForProfiling ||
 (Action == SampleUse && !PseudoProbeForProfiling)),
-  PseudoProbeForProfiling(PseudoProbeForProfiling), FS(std::move(FS)) {
+  PseudoProbeForProfiling(PseudoProbeForProfiling),
+  AtomicCounterUpdate(AtomicCounterUpdate), FS(std::move(FS)) {
   // Note, we do allow ProfileFile.empty() for Action=IRUse LTO can
   // callback with IRUse action without ProfileFile.
 
Index: llvm/lib/Passes/PassBuilderPipelines.cpp
===
--- llvm/lib/Passes/PassBuilderPipelines.cpp
+++ llvm/lib/Passes/PassBuilderPipelines.cpp
@@ -724,7 +724,8 @@
 
 void PassBuilder::addPGOInstrPasses(ModulePassManager ,
 OptimizationLevel Level, bool RunProfileGen,
-bool IsCS, std::string ProfileFile,
+bool IsCS, bool AtomicCounterUpdate,
+std::string ProfileFile,
 std::string ProfileRemappingFile,
 ThinOrFullLTOPhase LTOPhase,
 IntrusiveRefCntPtr FS) {
@@ -793,13 +794,14 @@
   // Do counter promotion at Level greater than O0.
   Options.DoCounterPromotion = true;
   Options.UseBFIInPromotion = IsCS;
+  Options.Atomic = AtomicCounterUpdate;
   MPM.addPass(InstrProfiling(Options, IsCS));
 }
 
 void PassBuilder::addPGOInstrPassesForO0(
 ModulePassManager , bool RunProfileGen, bool IsCS,
-std::string ProfileFile, std::string ProfileRemappingFile,
-IntrusiveRefCntPtr FS) {
+bool AtomicCounterUpdate, std::string ProfileFile,
+std::string ProfileRemappingFile, IntrusiveRefCntPtr FS) {
   if (!RunProfileGen) {
 assert(!ProfileFile.empty() && "Profile use expecting a profile file!");
 MPM.addPass(
@@ -819,6 +821,7 @@
   // Do not do counter promotion at O0.
   Options.DoCounterPromotion = false;
   Options.UseBFIInPromotion = IsCS;
+  Options.Atomic = AtomicCounterUpdate;
   MPM.addPass(InstrProfiling(Options, IsCS));
 }
 
@@ -1093,9 +1096,10 @@
   (PGOOpt->Action == PGOOptions::IRInstr ||
PGOOpt->Action == PGOOptions::IRUse)) {
 addPGOInstrPasses(MPM, Level,
-  /* RunProfileGen */ PGOOpt->Action == PGOOptions::IRInstr,
-  /* IsCS */ false, PGOOpt->ProfileFile,
-  PGOOpt->ProfileRemappingFile, Phase, PGOOpt->FS);
+  /*RunProfileGen=*/PGOOpt->Action == PGOOptions::IRInstr,
+  /*IsCS=*/false, PGOOpt->AtomicCounterUpdate,
+  PGOOpt->ProfileFile, PGOOpt->ProfileRemappingFile, Phase,
+  PGOOpt->FS);
 MPM.addPass(PGOIndirectCallPromotion(false, false));
   }
   if (PGOOpt && Phase != ThinOrFullLTOPhase::ThinLTOPostLink &&
@@ -1306,13 +1310,15 @@
   // instrumentation is after all the inlines are done.
   if (!LTOPreLink && PGOOpt) {
 if (PGOOpt->CSAction == PGOOptions::CSIRInstr)
-  addPGOInstrPasses(MPM, Level, /* RunProfileGen */ true,
-/* IsCS */ true, PGOOpt->CSProfileGenFile,
-PGOOpt->ProfileRemappingFile, LTOPhase, PGOOpt->FS);
+  addPGOInstrPasses(MPM, Level, /*RunProfileGen=*/true,
+/*IsCS=*/true, PGOOpt->AtomicCounterUpdate,
+PGOOpt->CSProfileGenFile, PGOOpt->ProfileRemappingFile,
+LTOPhase, PGOOpt->FS);
 else if (PGOOpt->CSAction == PGOOptions::CSIRUse)
-  addPGOInstrPasses(MPM, Level, /* RunProfileGen */ false,
-/* IsCS */ true, PGOOpt->ProfileFile,
-   

[PATCH] D157149: [Option] Add "Visibility" field and clone the OptTable APIs to use it

2023-08-14 Thread Justin Bogner 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 rGa16104e6da6f: [Option] Add Visibility field and 
clone the OptTable APIs to use it (authored by bogner).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157149

Files:
  clang-tools-extra/clangd/CompileCommands.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  lld/MachO/DriverUtils.cpp
  lld/MinGW/Driver.cpp
  lld/wasm/Driver.cpp
  llvm/include/llvm/Option/OptParser.td
  llvm/include/llvm/Option/OptTable.h
  llvm/include/llvm/Option/Option.h
  llvm/lib/ExecutionEngine/JITLink/COFFDirectiveParser.cpp
  llvm/lib/Option/OptTable.cpp
  llvm/lib/ToolDrivers/llvm-dlltool/DlltoolDriver.cpp
  llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp
  llvm/tools/dsymutil/dsymutil.cpp
  llvm/tools/llvm-cvtres/llvm-cvtres.cpp
  llvm/tools/llvm-cxxfilt/llvm-cxxfilt.cpp
  llvm/tools/llvm-debuginfod/llvm-debuginfod.cpp
  llvm/tools/llvm-dwarfutil/llvm-dwarfutil.cpp
  llvm/tools/llvm-dwp/llvm-dwp.cpp
  llvm/tools/llvm-lipo/llvm-lipo.cpp
  llvm/tools/llvm-mt/llvm-mt.cpp
  llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
  llvm/tools/llvm-rc/llvm-rc.cpp
  llvm/tools/llvm-strings/llvm-strings.cpp
  llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp
  llvm/tools/llvm-tli-checker/llvm-tli-checker.cpp
  llvm/unittests/Option/OptionMarshallingTest.cpp
  llvm/unittests/Option/OptionParsingTest.cpp
  llvm/unittests/Option/Opts.td
  llvm/utils/TableGen/OptParserEmitter.cpp

Index: llvm/utils/TableGen/OptParserEmitter.cpp
===
--- llvm/utils/TableGen/OptParserEmitter.cpp
+++ llvm/utils/TableGen/OptParserEmitter.cpp
@@ -302,7 +302,7 @@
   OS << "INVALID";
 
 // The other option arguments (unused for groups).
-OS << ", INVALID, nullptr, 0, 0";
+OS << ", INVALID, nullptr, 0, 0, 0";
 
 // The option help text.
 if (!isa(R.getValueInit("HelpText"))) {
@@ -340,8 +340,10 @@
 // The containing option group (if any).
 OS << ", ";
 const ListInit *GroupFlags = nullptr;
+const ListInit *GroupVis = nullptr;
 if (const DefInit *DI = dyn_cast(R.getValueInit("Group"))) {
   GroupFlags = DI->getDef()->getValueAsListInit("Flags");
+  GroupVis = DI->getDef()->getValueAsListInit("Vis");
   OS << getOptionName(*DI->getDef());
 } else
   OS << "INVALID";
@@ -368,7 +370,7 @@
   OS << "\"";
 }
 
-// The option flags.
+// "Flags" for the option, such as HelpHidden and Render*
 OS << ", ";
 int NumFlags = 0;
 const ListInit *LI = R.getValueAsListInit("Flags");
@@ -382,6 +384,21 @@
 if (NumFlags == 0)
   OS << '0';
 
+// Option visibility, for sharing options between drivers.
+OS << ", ";
+int NumVisFlags = 0;
+LI = R.getValueAsListInit("Vis");
+for (Init *I : *LI)
+  OS << (NumVisFlags++ ? " | " : "")
+ << cast(I)->getDef()->getName();
+if (GroupVis) {
+  for (Init *I : *GroupVis)
+OS << (NumVisFlags++ ? " | " : "")
+   << cast(I)->getDef()->getName();
+}
+if (NumVisFlags == 0)
+  OS << '0';
+
 // The option parameter field.
 OS << ", " << R.getValueAsInt("NumArgs");
 
Index: llvm/unittests/Option/Opts.td
===
--- llvm/unittests/Option/Opts.td
+++ llvm/unittests/Option/Opts.td
@@ -4,6 +4,8 @@
 def OptFlag2 : OptionFlag;
 def OptFlag3 : OptionFlag;
 
+def SubtoolVis : OptionVisibility;
+
 def A : Flag<["-"], "A">, HelpText<"The A option">, Flags<[OptFlag1]>;
 def AB : Flag<["-"], "AB">;
 def B : Joined<["-"], "B">, HelpText<"The B option">, MetaVarName<"B">, Flags<[OptFlag2]>;
@@ -35,6 +37,8 @@
 def Cramb : Joined<["/"], "cramb:">, HelpText<"The cramb option">, MetaVarName<"CRAMB">, Flags<[OptFlag1]>;
 def Doopf1 : Flag<["-"], "doopf1">, HelpText<"The doopf1 option">, Flags<[OptFlag1]>;
 def Doopf2 : Flag<["-"], "doopf2">, HelpText<"The doopf2 option">, Flags<[OptFlag2]>;
+def Xyzzy1 : Flag<["-"], "xyzzy1">, HelpText<"The xyzzy1 option">, Vis<[SubtoolVis]>;
+def Xyzzy2 : Flag<["-"], "xyzzy2">, HelpText<"The xyzzy2 option">, Vis<[Default]>;
 def Ermgh : Joined<["--"], "ermgh">, HelpText<"The ermgh option">, MetaVarName<"ERMGH">, Flags<[OptFlag1]>;
 def Fjormp : Flag<["--"], "fjormp">, HelpText<"The fjormp option">, Flags<[OptFlag1]>;
 
@@ -43,6 +47,9 @@
 def Blurmpq : Flag<["--"], "blurmp">;
 def Blurmpq_eq : Flag<["--"], "blurmp=">;
 
+def Q : Flag<["-"], "Q">, Vis<[SubtoolVis]>;
+def R : Flag<["-"], "R">, Vis<[Default, SubtoolVis]>;
+
 class XOpts : KeyPathAndMacro<"X->", base> {}
 
 def marshalled_flag_d : Flag<["-"], "marshalled-flag-d">,
Index: llvm/unittests/Option/OptionParsingTest.cpp
===
--- llvm/unittests/Option/OptionParsingTest.cpp
+++ llvm/unittests/Option/OptionParsingTest.cpp

[clang] a16104e - [Option] Add "Visibility" field and clone the OptTable APIs to use it

2023-08-14 Thread Justin Bogner via cfe-commits

Author: Justin Bogner
Date: 2023-08-14T13:24:54-07:00
New Revision: a16104e6da6f36f3d72dbf53d10ba56495a0d65a

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

LOG: [Option] Add "Visibility" field and clone the OptTable APIs to use it

This splits OptTable's "Flags" field into "Flags" and "Visibility",
updates the places where we instantiate Option tables, and adds
variants of the OptTable APIs that use Visibility mask instead of
Include/Exclude flags.

We need to do this to clean up a bunch of complexity in the clang
driver's option handling - there's a whole slew of flags like
CoreOption, NoDriverOption, and FlangOnlyOption there today to try to
handle all of the permutations of flags that the various drivers need,
but it really doesn't scale well, as can be seen by things like the
somewhat recently introduced CLDXCOption.

Instead, we'll provide an additive model for visibility that's
separate from the other flags. For things like "HelpHidden", which is
used as a "subtractive" modifier for option visibility, we leave that
in "Flags" and handle it as a special case.

Note that we don't actually update the users of the Include/Exclude
APIs here or change the flags that exist in clang at all - that will
come in a follow up that refactors clang's Options.td to use the
increased flexibility this change allows.

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

Added: 


Modified: 
clang-tools-extra/clangd/CompileCommands.cpp
clang/lib/Frontend/CompilerInvocation.cpp
lld/MachO/DriverUtils.cpp
lld/MinGW/Driver.cpp
lld/wasm/Driver.cpp
llvm/include/llvm/Option/OptParser.td
llvm/include/llvm/Option/OptTable.h
llvm/include/llvm/Option/Option.h
llvm/lib/ExecutionEngine/JITLink/COFFDirectiveParser.cpp
llvm/lib/Option/OptTable.cpp
llvm/lib/ToolDrivers/llvm-dlltool/DlltoolDriver.cpp
llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp
llvm/tools/dsymutil/dsymutil.cpp
llvm/tools/llvm-cvtres/llvm-cvtres.cpp
llvm/tools/llvm-cxxfilt/llvm-cxxfilt.cpp
llvm/tools/llvm-debuginfod/llvm-debuginfod.cpp
llvm/tools/llvm-dwarfutil/llvm-dwarfutil.cpp
llvm/tools/llvm-dwp/llvm-dwp.cpp
llvm/tools/llvm-lipo/llvm-lipo.cpp
llvm/tools/llvm-mt/llvm-mt.cpp
llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
llvm/tools/llvm-rc/llvm-rc.cpp
llvm/tools/llvm-strings/llvm-strings.cpp
llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp
llvm/tools/llvm-tli-checker/llvm-tli-checker.cpp
llvm/unittests/Option/OptionMarshallingTest.cpp
llvm/unittests/Option/OptionParsingTest.cpp
llvm/unittests/Option/Opts.td
llvm/utils/TableGen/OptParserEmitter.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/CompileCommands.cpp 
b/clang-tools-extra/clangd/CompileCommands.cpp
index 00f4c4ca9fef0a..3fce1b8bcb490c 100644
--- a/clang-tools-extra/clangd/CompileCommands.cpp
+++ b/clang-tools-extra/clangd/CompileCommands.cpp
@@ -494,7 +494,7 @@ llvm::ArrayRef 
ArgStripper::rulesFor(llvm::StringRef Arg) {
   static constexpr llvm::ArrayRef NAME(   
\
   NAME##_init, std::size(NAME##_init) - 1);
 #define OPTION(PREFIX, PREFIXED_NAME, ID, KIND, GROUP, ALIAS, ALIASARGS,   
\
-   FLAGS, PARAM, HELP, METAVAR, VALUES)
\
+   FLAGS, VISIBILITY, PARAM, HELP, METAVAR, VALUES)
\
   Prefixes[DriverID::OPT_##ID] = PREFIX;
 #include "clang/Driver/Options.inc"
 #undef OPTION
@@ -506,7 +506,7 @@ llvm::ArrayRef 
ArgStripper::rulesFor(llvm::StringRef Arg) {
   const void *AliasArgs;
 } AliasTable[] = {
 #define OPTION(PREFIX, PREFIXED_NAME, ID, KIND, GROUP, ALIAS, ALIASARGS,   
\
-   FLAGS, PARAM, HELP, METAVAR, VALUES)
\
+   FLAGS, VISIBILITY, PARAM, HELP, METAVAR, VALUES)
\
   {DriverID::OPT_##ID, DriverID::OPT_##ALIAS, ALIASARGS},
 #include "clang/Driver/Options.inc"
 #undef OPTION

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index 87190093767b05..0d7a497cbd42af 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -423,9 +423,9 @@ static T extractMaskValue(T KeyPath) {
 
 #define PARSE_OPTION_WITH_MARSHALLING( 
\
 ARGS, DIAGS, PREFIX_TYPE, SPELLING, ID, KIND, GROUP, ALIAS, ALIASARGS, 
\
-FLAGS, PARAM, HELPTEXT, METAVAR, VALUES, SHOULD_PARSE, ALWAYS_EMIT,
\
-KEYPATH, DEFAULT_VALUE, IMPLIED_CHECK, IMPLIED_VALUE, NORMALIZER,  
\
-DENORMALIZER, MERGER, EXTRACTOR, TABLE_INDEX)  
\
+FLAGS, VISIBILITY, PARAM, HELPTEXT, METAVAR, VALUES, SHOULD_PARSE, 
\
+ALWAYS_EMIT, 

[PATCH] D155610: [Clang][Sema] Fix display of characters on static assertion failure

2023-08-14 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added inline comments.



Comment at: clang/lib/Sema/SemaDeclCXX.cpp:16876
+  // other types.
+  if (CodePoint <= UCHAR_MAX) {
+StringRef Escaped = escapeCStyle(CodePoint);

cor3ntin wrote:
> hubert.reinterpretcast wrote:
> > For types other than `Char_S`, `Char_U`, and `Char8`, this fails to treat 
> > the C1 Controls and Latin-1 Supplement characters as Unicode code points. 
> > It looks like test coverage for these cases are missing.
> `escapeCStyle` is one of the things that assume ASCII / UTF, but yes, we 
> might as well reduce to 0x7F just to avoid unnecessary work
> `escapeCStyle` is one of the things that assume ASCII / UTF, but yes, we 
> might as well reduce to 0x7F just to avoid unnecessary work

I meant (with a `signed char` type to trigger the assertion):
```
:1:28: note: expression evaluates to ''' (0xA2) == '' (0xA2)'
1 | static_assert(u"\u00a2"[0] == '');
  |   ~^
```

should be:
```
:1:28: note: expression evaluates to ''¢' (0xA2) == '' (0xA2)'
1 | static_assert(u"\u00a2"[0] == '');
  |   ~^
```



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

https://reviews.llvm.org/D155610

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


[PATCH] D157868: [clang] Use RecoveryExprs for broken defaultargs, instead of OpaqueValueExprs

2023-08-14 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.

Still LG once you're happy




Comment at: clang/include/clang/Sema/Sema.h:3026
+  void ActOnParamDefaultArgumentError(Decl *param, SourceLocation EqualLoc,
+  ExprResult DefaultArg);
   ExprResult ConvertParamDefaultArgument(ParmVarDecl *Param, Expr *DefaultArg,

kadircet wrote:
> sammccall wrote:
> > nit: Nullable `ExprResult*` since there are only two states?
> > Extra get() in some callers, but less mysterious
> i guess you meant `Expr*` ?
Yes, sorry!



Comment at: clang/lib/Parse/ParseCXXInlineMethods.cpp:400
   if (DefArgResult.isInvalid()) {
-Actions.ActOnParamDefaultArgumentError(Param, EqualLoc);
+Actions.ActOnParamDefaultArgumentError(Param, EqualLoc, DefArgResult);
   } else {

kadircet wrote:
> sammccall wrote:
> > DefArgResult is never anything here. I'd probably find 
> > `/*DefaultArg=*/nullptr` more obvious
> maybe i am missing something, but "invalid" doesn't mean "unusable".
ActionResult can be pointer-and-valid, null-and-valid, or null-and-invalid.

So invalid does indeed mean unusable ("usable" means pointer-and-valid).

Its documentation strongly suggests an ActionResult can be pointer-and-invalid, 
but good luck constructing one :-)



Comment at: clang/test/AST/ast-dump-default-arg-recovery.cpp:6
+//  CHECK: -ParmVarDecl {{.*}}  col:14 invalid arg 'int' 
cinit
+// CHECK-NEXT:   -RecoveryExpr {{.*}}  'int' contains-errors

Can you also check the contents (there should be a declrefexpr at least)?

Preserving this internal structure is important for clangd, the recoveryexpr 
alone doesn't help much.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157868

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


[PATCH] D155610: [Clang][Sema] Fix display of characters on static assertion failure

2023-08-14 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added a comment.

In D155610#4586213 , 
@abhina.sreeskantharajan wrote:

> I've discussed offline with @hubert.reinterpretcast and agree with him that 
> with the addition of fexec-charset support, the set of characters deemed 
> printable will not be accurate when other encodings are used. This will be 
> similar to the printf/scanf format string validation issue I mentioned in my 
> RFC and would require us to reverse the conversion or keep the original 
> string around to check if the character is printable. I don't think we have 
> finalized a solution on how to handle these issues yet.

Furthermore, it is reasonable for the scope of the current patch to focus on 
producing UTF-8 (or UTF-16 for Windows) output to the "terminal".


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

https://reviews.llvm.org/D155610

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


[PATCH] D157149: [Option] Add "Visibility" field and clone the OptTable APIs to use it

2023-08-14 Thread Chris Bieneman via Phabricator via cfe-commits
beanz accepted this revision.
beanz added a comment.

LGTM. This is definitely an improvement over the awfulness we were doing. 
Thanks @bogner!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157149

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


[PATCH] D157885: [NFC][Clang] Fix static analyzer concern about null value derefence

2023-08-14 Thread Elizabeth Andrews via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc70dab026d37: [NFC][Clang] Fix static analyzer concern about 
null value dereference (authored by eandrews).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157885

Files:
  clang/lib/Serialization/ASTReaderDecl.cpp


Index: clang/lib/Serialization/ASTReaderDecl.cpp
===
--- clang/lib/Serialization/ASTReaderDecl.cpp
+++ clang/lib/Serialization/ASTReaderDecl.cpp
@@ -4459,7 +4459,9 @@
   if (auto *VTSD = dyn_cast(D)) {
 VTSD->setPointOfInstantiation(POI);
   } else if (auto *VD = dyn_cast(D)) {
-VD->getMemberSpecializationInfo()->setPointOfInstantiation(POI);
+MemberSpecializationInfo *MSInfo = VD->getMemberSpecializationInfo();
+assert(MSInfo && "No member specialization information");
+MSInfo->setPointOfInstantiation(POI);
   } else {
 auto *FD = cast(D);
 if (auto *FTSInfo = FD->TemplateOrSpecialization


Index: clang/lib/Serialization/ASTReaderDecl.cpp
===
--- clang/lib/Serialization/ASTReaderDecl.cpp
+++ clang/lib/Serialization/ASTReaderDecl.cpp
@@ -4459,7 +4459,9 @@
   if (auto *VTSD = dyn_cast(D)) {
 VTSD->setPointOfInstantiation(POI);
   } else if (auto *VD = dyn_cast(D)) {
-VD->getMemberSpecializationInfo()->setPointOfInstantiation(POI);
+MemberSpecializationInfo *MSInfo = VD->getMemberSpecializationInfo();
+assert(MSInfo && "No member specialization information");
+MSInfo->setPointOfInstantiation(POI);
   } else {
 auto *FD = cast(D);
 if (auto *FTSInfo = FD->TemplateOrSpecialization
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] c70dab0 - [NFC][Clang] Fix static analyzer concern about null value dereference

2023-08-14 Thread Elizabeth Andrews via cfe-commits

Author: Elizabeth Andrews
Date: 2023-08-14T13:07:24-07:00
New Revision: c70dab026d377736c1281d3c8005bb5e578ec8b3

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

LOG: [NFC][Clang] Fix static analyzer concern about null value dereference

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

Added: 


Modified: 
clang/lib/Serialization/ASTReaderDecl.cpp

Removed: 




diff  --git a/clang/lib/Serialization/ASTReaderDecl.cpp 
b/clang/lib/Serialization/ASTReaderDecl.cpp
index c8cbee14be4f02..15e88a9be44ad0 100644
--- a/clang/lib/Serialization/ASTReaderDecl.cpp
+++ b/clang/lib/Serialization/ASTReaderDecl.cpp
@@ -4459,7 +4459,9 @@ void ASTDeclReader::UpdateDecl(Decl *D,
   if (auto *VTSD = dyn_cast(D)) {
 VTSD->setPointOfInstantiation(POI);
   } else if (auto *VD = dyn_cast(D)) {
-VD->getMemberSpecializationInfo()->setPointOfInstantiation(POI);
+MemberSpecializationInfo *MSInfo = VD->getMemberSpecializationInfo();
+assert(MSInfo && "No member specialization information");
+MSInfo->setPointOfInstantiation(POI);
   } else {
 auto *FD = cast(D);
 if (auto *FTSInfo = FD->TemplateOrSpecialization



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


[PATCH] D155081: Specify the developer policy around links to external resources

2023-08-14 Thread Chris Lattner via Phabricator via cfe-commits
lattner accepted this revision.
lattner added a comment.
This revision is now accepted and ready to land.

Looks like a great improvement to the policy, thank you all for sorting through 
this!


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

https://reviews.llvm.org/D155081

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


[PATCH] D155610: [Clang][Sema] Fix display of characters on static assertion failure

2023-08-14 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan added a comment.

I've discussed offline with @hubert.reinterpretcast and agree with him that 
with the addition of fexec-charset support, the set of characters deemed 
printable will not be accurate when other encodings are used. This will be 
similar to the printf/scanf format string validation issue I mentioned in my 
RFC and would require us to reverse the conversion or keep the original string 
around to check if the character is printable. I don't think we have finalized 
a solution on how to handle these issues yet.


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

https://reviews.llvm.org/D155610

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


[PATCH] D157905: [include-cleaner] Filter references to identity macros

2023-08-14 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added inline comments.
This revision is now accepted and ready to land.



Comment at: clang-tools-extra/include-cleaner/lib/Analysis.cpp:37
+namespace {
+bool shouldSkipMacro(const Macro ) {
+  static const auto *MacroNamesToIgnore = new llvm::StringSet<>{

shouldIgnoreMacroReference would better distinguish vs macro definition



Comment at: clang-tools-extra/include-cleaner/lib/Analysis.cpp:43
+  // This results in surprising behavior from users point of view (we
+  // generate a usage of stdio.h, in places unrelated to standard library).
+  // FIXME: Also eliminate the false positives by treating declarations

Comment nit: I'm having trouble imagining cases that are actually*unrelated* to 
the stdlib.

If `stderr` is an impl-defined macro, then the only way to use the name to 
refer to something else is if it's not defined (inside ifndef stderr, or if you 
can be sure your TU doesn't include stdio first). Seems implausible...

That said I feel like we've had this conversation before and I've just 
forgotten the details.



Comment at: clang-tools-extra/include-cleaner/lib/Analysis.cpp:44
+  // generate a usage of stdio.h, in places unrelated to standard library).
+  // FIXME: Also eliminate the false positives by treating declarations
+  // resulting from these expansions as used.

Nit: "false positives" is a little unclear: positives for this function are 
negatives for walkAST and could be either for diagnostics.

Also, I think you mean *references* rather than declarations?



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157905

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


[PATCH] D157888: [NFC][Clang] Fix static analyzer concern about null value dereference

2023-08-14 Thread Elizabeth Andrews via Phabricator via cfe-commits
eandrews added a comment.

In D157888#4586126 , @steakhal wrote:

> Hmm. I guess the assertion is to silence some tool. And I think actually that 
> function might very well also return null in some cases.
> Why do you think it cannot or at least should not return null in your 
> context? I couldn't infer this from the context, neither from the description 
> of this patch.
>
> Without that, I would prefer an if to guard the code, instead of asserting 
> this.

`createBegin()` has a call to `getValidSourceLocation()` which dereferences 
this Statement. So in this context Statement cannot be null.

> If getStmtForDiagnostics() in general, never returns null, then shouldn't we 
> mark the API with an appropriate attribute?

`getStmtForDiagnostics()` explicitly returns `nullptr` when none of the cases 
for `ProgramPoint` listed in the function are met. So I am not sure if we can 
just assume this function should never return null.


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

https://reviews.llvm.org/D157888

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


[PATCH] D157913: [WIP][Coverage] Allow Clang coverage to be used with debug info correlation.

2023-08-14 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu created this revision.
Herald added subscribers: Enna1, hiraditya.
Herald added a project: All.
zequanwu requested review of this revision.
Herald added projects: clang, Sanitizers, LLVM.
Herald added subscribers: llvm-commits, Sanitizers, cfe-commits.

Debug info correlation is an option in InstrProfiling pass, which is used by
both IR instrumentation and front-end instrumentation. So, Clang coverage can
also benefits the binary size saving from it.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D157913

Files:
  clang/lib/CodeGen/CoverageMappingGen.cpp
  clang/test/CodeGen/coverage-debug-info-correlate.c
  compiler-rt/test/profile/Darwin/coverage-debug-info-correlate.c
  compiler-rt/test/profile/Linux/coverage-debug-info-correlate.c
  llvm/include/llvm/ProfileData/Coverage/CoverageMappingReader.h
  llvm/lib/ProfileData/Coverage/CoverageMapping.cpp
  llvm/lib/ProfileData/Coverage/CoverageMappingReader.cpp

Index: llvm/lib/ProfileData/Coverage/CoverageMappingReader.cpp
===
--- llvm/lib/ProfileData/Coverage/CoverageMappingReader.cpp
+++ llvm/lib/ProfileData/Coverage/CoverageMappingReader.cpp
@@ -25,6 +25,7 @@
 #include "llvm/Object/MachOUniversal.h"
 #include "llvm/Object/ObjectFile.h"
 #include "llvm/ProfileData/InstrProf.h"
+#include "llvm/ProfileData/InstrProfReader.h"
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/Compression.h"
 #include "llvm/Support/Debug.h"
@@ -953,7 +954,8 @@
 }
 
 static Expected>
-loadBinaryFormat(std::unique_ptr Bin, StringRef Arch,
+loadBinaryFormat(std::unique_ptr Bin,
+ IndexedInstrProfReader , StringRef Arch,
  StringRef CompilationDir = "",
  object::BuildIDRef *BinaryID = nullptr) {
   std::unique_ptr OF;
@@ -982,11 +984,20 @@
 
   // Look for the sections that we are interested in.
   auto ObjFormat = OF->getTripleObjectFormat();
+  InstrProfSymtab ProfileNames;
   auto NamesSection =
   lookupSections(*OF, getInstrProfSectionName(IPSK_name, ObjFormat,
  /*AddSegmentInfo=*/false));
-  if (auto E = NamesSection.takeError())
-return std::move(E);
+  if (auto E = NamesSection.takeError()) {
+consumeError(std::move(E));
+ProfileNames = ProfileReader.getSymtab();
+  } else {
+std::vector NamesSectionRefs = *NamesSection;
+if (NamesSectionRefs.size() != 1)
+  return make_error(coveragemap_error::malformed);
+if (Error E = ProfileNames.create(NamesSectionRefs.back()))
+  return std::move(E);
+  }
   auto CoverageSection =
   lookupSections(*OF, getInstrProfSectionName(IPSK_covmap, ObjFormat,
   /*AddSegmentInfo=*/false));
@@ -1000,13 +1011,6 @@
 return CoverageMappingOrErr.takeError();
   StringRef CoverageMapping = CoverageMappingOrErr.get();
 
-  InstrProfSymtab ProfileNames;
-  std::vector NamesSectionRefs = *NamesSection;
-  if (NamesSectionRefs.size() != 1)
-return make_error(coveragemap_error::malformed);
-  if (Error E = ProfileNames.create(NamesSectionRefs.back()))
-return std::move(E);
-
   // Look for the coverage records section (Version4 only).
   auto CoverageRecordsSections =
   lookupSections(*OF, getInstrProfSectionName(IPSK_covfun, ObjFormat,
@@ -1076,7 +1080,8 @@
 
 Expected>>
 BinaryCoverageReader::create(
-MemoryBufferRef ObjectBuffer, StringRef Arch,
+MemoryBufferRef ObjectBuffer, IndexedInstrProfReader ,
+StringRef Arch,
 SmallVectorImpl> ,
 StringRef CompilationDir, SmallVectorImpl *BinaryIDs) {
   std::vector> Readers;
@@ -1117,8 +1122,8 @@
   }
 
   return BinaryCoverageReader::create(
-  ArchiveOrErr.get()->getMemoryBufferRef(), Arch, ObjectFileBuffers,
-  CompilationDir, BinaryIDs);
+  ArchiveOrErr.get()->getMemoryBufferRef(), ProfileReader, Arch,
+  ObjectFileBuffers, CompilationDir, BinaryIDs);
 }
   }
 
@@ -1131,8 +1136,8 @@
 return ChildBufOrErr.takeError();
 
   auto ChildReadersOrErr = BinaryCoverageReader::create(
-  ChildBufOrErr.get(), Arch, ObjectFileBuffers, CompilationDir,
-  BinaryIDs);
+  ChildBufOrErr.get(), ProfileReader, Arch, ObjectFileBuffers,
+  CompilationDir, BinaryIDs);
   if (!ChildReadersOrErr)
 return ChildReadersOrErr.takeError();
   for (auto  : ChildReadersOrErr.get())
@@ -1152,8 +1157,9 @@
   }
 
   object::BuildIDRef BinaryID;
-  auto ReaderOrErr = loadBinaryFormat(std::move(Bin), Arch, CompilationDir,
-  BinaryIDs ?  : nullptr);
+  auto ReaderOrErr =
+  loadBinaryFormat(std::move(Bin), ProfileReader, Arch, CompilationDir,
+   BinaryIDs ?  : nullptr);
   if (!ReaderOrErr)
 return ReaderOrErr.takeError();
   Readers.push_back(std::move(ReaderOrErr.get()));
Index: llvm/lib/ProfileData/Coverage/CoverageMapping.cpp

[PATCH] D157149: [Option] Add "Visibility" field and clone the OptTable APIs to use it

2023-08-14 Thread Justin Bogner via Phabricator via cfe-commits
bogner updated this revision to Diff 550055.
bogner edited the summary of this revision.
bogner added a comment.

Update comment wording to be less ambiguous about flags vs visibility


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157149

Files:
  clang-tools-extra/clangd/CompileCommands.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  lld/MachO/DriverUtils.cpp
  lld/MinGW/Driver.cpp
  lld/wasm/Driver.cpp
  llvm/include/llvm/Option/OptParser.td
  llvm/include/llvm/Option/OptTable.h
  llvm/include/llvm/Option/Option.h
  llvm/lib/ExecutionEngine/JITLink/COFFDirectiveParser.cpp
  llvm/lib/Option/OptTable.cpp
  llvm/lib/ToolDrivers/llvm-dlltool/DlltoolDriver.cpp
  llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp
  llvm/tools/dsymutil/dsymutil.cpp
  llvm/tools/llvm-cvtres/llvm-cvtres.cpp
  llvm/tools/llvm-cxxfilt/llvm-cxxfilt.cpp
  llvm/tools/llvm-debuginfod/llvm-debuginfod.cpp
  llvm/tools/llvm-dwarfutil/llvm-dwarfutil.cpp
  llvm/tools/llvm-dwp/llvm-dwp.cpp
  llvm/tools/llvm-lipo/llvm-lipo.cpp
  llvm/tools/llvm-mt/llvm-mt.cpp
  llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
  llvm/tools/llvm-rc/llvm-rc.cpp
  llvm/tools/llvm-strings/llvm-strings.cpp
  llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp
  llvm/tools/llvm-tli-checker/llvm-tli-checker.cpp
  llvm/unittests/Option/OptionMarshallingTest.cpp
  llvm/unittests/Option/OptionParsingTest.cpp
  llvm/unittests/Option/Opts.td
  llvm/utils/TableGen/OptParserEmitter.cpp

Index: llvm/utils/TableGen/OptParserEmitter.cpp
===
--- llvm/utils/TableGen/OptParserEmitter.cpp
+++ llvm/utils/TableGen/OptParserEmitter.cpp
@@ -302,7 +302,7 @@
   OS << "INVALID";
 
 // The other option arguments (unused for groups).
-OS << ", INVALID, nullptr, 0, 0";
+OS << ", INVALID, nullptr, 0, 0, 0";
 
 // The option help text.
 if (!isa(R.getValueInit("HelpText"))) {
@@ -340,8 +340,10 @@
 // The containing option group (if any).
 OS << ", ";
 const ListInit *GroupFlags = nullptr;
+const ListInit *GroupVis = nullptr;
 if (const DefInit *DI = dyn_cast(R.getValueInit("Group"))) {
   GroupFlags = DI->getDef()->getValueAsListInit("Flags");
+  GroupVis = DI->getDef()->getValueAsListInit("Vis");
   OS << getOptionName(*DI->getDef());
 } else
   OS << "INVALID";
@@ -368,7 +370,7 @@
   OS << "\"";
 }
 
-// The option flags.
+// "Flags" for the option, such as HelpHidden and Render*
 OS << ", ";
 int NumFlags = 0;
 const ListInit *LI = R.getValueAsListInit("Flags");
@@ -382,6 +384,21 @@
 if (NumFlags == 0)
   OS << '0';
 
+// Option visibility, for sharing options between drivers.
+OS << ", ";
+int NumVisFlags = 0;
+LI = R.getValueAsListInit("Vis");
+for (Init *I : *LI)
+  OS << (NumVisFlags++ ? " | " : "")
+ << cast(I)->getDef()->getName();
+if (GroupVis) {
+  for (Init *I : *GroupVis)
+OS << (NumVisFlags++ ? " | " : "")
+   << cast(I)->getDef()->getName();
+}
+if (NumVisFlags == 0)
+  OS << '0';
+
 // The option parameter field.
 OS << ", " << R.getValueAsInt("NumArgs");
 
Index: llvm/unittests/Option/Opts.td
===
--- llvm/unittests/Option/Opts.td
+++ llvm/unittests/Option/Opts.td
@@ -4,6 +4,8 @@
 def OptFlag2 : OptionFlag;
 def OptFlag3 : OptionFlag;
 
+def SubtoolVis : OptionVisibility;
+
 def A : Flag<["-"], "A">, HelpText<"The A option">, Flags<[OptFlag1]>;
 def AB : Flag<["-"], "AB">;
 def B : Joined<["-"], "B">, HelpText<"The B option">, MetaVarName<"B">, Flags<[OptFlag2]>;
@@ -35,6 +37,8 @@
 def Cramb : Joined<["/"], "cramb:">, HelpText<"The cramb option">, MetaVarName<"CRAMB">, Flags<[OptFlag1]>;
 def Doopf1 : Flag<["-"], "doopf1">, HelpText<"The doopf1 option">, Flags<[OptFlag1]>;
 def Doopf2 : Flag<["-"], "doopf2">, HelpText<"The doopf2 option">, Flags<[OptFlag2]>;
+def Xyzzy1 : Flag<["-"], "xyzzy1">, HelpText<"The xyzzy1 option">, Vis<[SubtoolVis]>;
+def Xyzzy2 : Flag<["-"], "xyzzy2">, HelpText<"The xyzzy2 option">, Vis<[Default]>;
 def Ermgh : Joined<["--"], "ermgh">, HelpText<"The ermgh option">, MetaVarName<"ERMGH">, Flags<[OptFlag1]>;
 def Fjormp : Flag<["--"], "fjormp">, HelpText<"The fjormp option">, Flags<[OptFlag1]>;
 
@@ -43,6 +47,9 @@
 def Blurmpq : Flag<["--"], "blurmp">;
 def Blurmpq_eq : Flag<["--"], "blurmp=">;
 
+def Q : Flag<["-"], "Q">, Vis<[SubtoolVis]>;
+def R : Flag<["-"], "R">, Vis<[Default, SubtoolVis]>;
+
 class XOpts : KeyPathAndMacro<"X->", base> {}
 
 def marshalled_flag_d : Flag<["-"], "marshalled-flag-d">,
Index: llvm/unittests/Option/OptionParsingTest.cpp
===
--- llvm/unittests/Option/OptionParsingTest.cpp
+++ llvm/unittests/Option/OptionParsingTest.cpp
@@ -44,6 +44,10 @@
   OptFlag3 = (1 << 6)
 };
 
+enum 

[PATCH] D157497: feat: Migrate isArch16Bit

2023-08-14 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

In D157497#4584621 , @Pivnoy wrote:

> This discussion was the main motivation for this change.
> https://discourse.llvm.org/t/rfc-refactor-triple-related-classes/70410/11
> As a result, Triple should become a data class, and its dependencies such as 
> Architecture, Operating System etc. represent in the form of interfaces that 
> can be implemented for the necessary instances.

FWIW I still don't see advantages by switching to the new 
`llvm::TripleUtils::isArch32Bit` style. How is it better than the current way?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157497

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


[PATCH] D157794: [Driver] Make /Zi and /Z7 aliases of -g rather than handling them specially

2023-08-14 Thread Justin Bogner 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 rGf58330cbe445: [Driver] Make /Zi and /Z7 aliases of -g rather 
than handling them specially (authored by bogner).

Changed prior to commit:
  https://reviews.llvm.org/D157794?vs=549643=550053#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157794

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/Clang.h
  clang/test/Driver/cl-options.c
  clang/test/Driver/working-directory.c

Index: clang/test/Driver/working-directory.c
===
--- clang/test/Driver/working-directory.c
+++ clang/test/Driver/working-directory.c
@@ -6,6 +6,6 @@
 
 // CHECK_NO_FILE: no such file or directory: 'no_such_file.cpp'
 
+// CHECK_WORKS: "-fdebug-compilation-dir={{[^"]+}}test{{/|}}Driver{{/|}}Inputs"
 // CHECK_WORKS: "-coverage-notes-file" "{{[^"]+}}test{{/|}}Driver{{/|}}Inputs{{/|}}pchfile.gcno"
 // CHECK_WORKS: "-working-directory" "{{[^"]+}}test{{/|}}Driver{{/|}}Inputs"
-// CHECK_WORKS: "-fdebug-compilation-dir={{[^"]+}}test{{/|}}Driver{{/|}}Inputs"
Index: clang/test/Driver/cl-options.c
===
--- clang/test/Driver/cl-options.c
+++ clang/test/Driver/cl-options.c
@@ -564,16 +564,10 @@
 // RUN: %clang_cl /Brepro /Brepro- /c '-###' -- %s 2>&1 | FileCheck -check-prefix=Brepro_ %s
 // Brepro_: "-mincremental-linker-compatible"
 
-// This test was super sneaky: "/Z7" means "line-tables", but "-gdwarf" occurs
-// later on the command line, so it should win. Interestingly the cc1 arguments
-// came out right, but had wrong semantics, because an invariant assumed by
-// CompilerInvocation was violated: it expects that at most one of {gdwarfN,
-// line-tables-only} appear. If you assume that, then you can safely use
-// Args.hasArg to test whether a boolean flag is present without caring
-// where it appeared. And for this test, it appeared to the left of -gdwarf
-// which made it "win". This test could not detect that bug.
+// If We specify both /Z7 and -gdwarf we should get dwarf, not codeview.
 // RUN: %clang_cl /Z7 -gdwarf /c -### -- %s 2>&1 | FileCheck -check-prefix=Z7_gdwarf %s
-// Z7_gdwarf: "-gcodeview"
+// RUN: %clang_cl -gdwarf /Z7 /c -### -- %s 2>&1 | FileCheck -check-prefix=Z7_gdwarf %s
+// Z7_gdwarf-NOT: "-gcodeview"
 // Z7_gdwarf: "-debug-info-kind=constructor"
 // Z7_gdwarf: "-dwarf-version=
 
Index: clang/lib/Driver/ToolChains/Clang.h
===
--- clang/lib/Driver/ToolChains/Clang.h
+++ clang/lib/Driver/ToolChains/Clang.h
@@ -90,9 +90,7 @@
  RewriteKind rewrite) const;
 
   void AddClangCLArgs(const llvm::opt::ArgList , types::ID InputType,
-  llvm::opt::ArgStringList ,
-  llvm::codegenoptions::DebugInfoKind *DebugInfoKind,
-  bool *EmitCodeView) const;
+  llvm::opt::ArgStringList ) const;
 
   mutable std::unique_ptr CompilationDatabase = nullptr;
   void DumpCompilationDatabase(Compilation , StringRef Filename,
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -4204,8 +4204,8 @@
 
 static void
 renderDebugOptions(const ToolChain , const Driver , const llvm::Triple ,
-   const ArgList , bool EmitCodeView, bool IRInput,
-   ArgStringList ,
+   const ArgList , bool IRInput, ArgStringList ,
+   const InputInfo ,
llvm::codegenoptions::DebugInfoKind ,
DwarfFissionKind ) {
   if (Args.hasFlag(options::OPT_fdebug_info_for_profiling,
@@ -4282,6 +4282,7 @@
   if (const Arg *A = getDwarfNArg(Args))
 EmitDwarf = checkDebugInfoOption(A, Args, D, TC);
 
+  bool EmitCodeView = false;
   if (const Arg *A = Args.getLastArg(options::OPT_gcodeview))
 EmitCodeView = checkDebugInfoOption(A, Args, D, TC);
 
@@ -4518,6 +4519,33 @@
 
   renderDwarfFormat(D, T, Args, CmdArgs, EffectiveDWARFVersion);
   RenderDebugInfoCompressionArgs(Args, CmdArgs, D, TC);
+
+  // This controls whether or not we perform JustMyCode instrumentation.
+  if (Args.hasFlag(options::OPT_fjmc, options::OPT_fno_jmc, false)) {
+if (TC.getTriple().isOSBinFormatELF() || D.IsCLMode()) {
+  if (DebugInfoKind >= llvm::codegenoptions::DebugInfoConstructor)
+CmdArgs.push_back("-fjmc");
+  else if (D.IsCLMode())
+D.Diag(clang::diag::warn_drv_jmc_requires_debuginfo) << "/JMC"
+ << "'/Zi', '/Z7'";
+  else
+

[clang] f58330c - [Driver] Make /Zi and /Z7 aliases of -g rather than handling them specially

2023-08-14 Thread Justin Bogner via cfe-commits

Author: Justin Bogner
Date: 2023-08-14T12:27:13-07:00
New Revision: f58330cbe44598eb2de0cca3b812f67fea0a71ca

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

LOG: [Driver] Make /Zi and /Z7 aliases of -g rather than handling them specially

The -g flag has been selecting whether to emit dwarf or codeview based
on the target ABI since 2018, so simply aliasing these flags does the
right thing for clang-cl.

This moves some code from Clang::ConstructJob to renderDebugOptions to
make things a little clearer now that we don't need to keep track of
whether we're doing codeview or not in multiple places, and also
combines the duplicate handling of the cl vs clang handling of jmc
flags as a result.

This is mostly NFC, but some -cc1 flags may be rendered in a slightly
different order because of the code that was moved around.

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

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Driver/ToolChains/Clang.h
clang/test/Driver/cl-options.c
clang/test/Driver/working-directory.c

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 8af5a110605846..86d2bafa6b612e 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -7182,7 +7182,7 @@ def _SLASH_Zc_wchar_t : CLFlag<"Zc:wchar_t">,
   HelpText<"Enable C++ builtin type wchar_t (default)">;
 def _SLASH_Zc_wchar_t_ : CLFlag<"Zc:wchar_t-">,
   HelpText<"Disable C++ builtin type wchar_t">;
-def _SLASH_Z7 : CLFlag<"Z7">,
+def _SLASH_Z7 : CLFlag<"Z7">, Alias,
   HelpText<"Enable CodeView debug information in object files">;
 def _SLASH_ZH_MD5 : CLFlag<"ZH:MD5">,
   HelpText<"Use MD5 for file checksums in debug info (default)">,
@@ -7193,7 +7193,7 @@ def _SLASH_ZH_SHA1 : CLFlag<"ZH:SHA1">,
 def _SLASH_ZH_SHA_256 : CLFlag<"ZH:SHA_256">,
   HelpText<"Use SHA256 for file checksums in debug info">,
   Alias, AliasArgs<["sha256"]>;
-def _SLASH_Zi : CLFlag<"Zi">, Alias<_SLASH_Z7>,
+def _SLASH_Zi : CLFlag<"Zi">, Alias,
   HelpText<"Like /Z7">;
 def _SLASH_Zp : CLJoined<"Zp">,
   HelpText<"Set default maximum struct packing alignment">,
@@ -7261,9 +7261,9 @@ def _SLASH_GX_ : CLFlag<"GX-">,
 def _SLASH_imsvc : CLJoinedOrSeparate<"imsvc">,
   HelpText<"Add  to system include search path, as if in %INCLUDE%">,
   MetaVarName<"">;
-def _SLASH_JMC : CLFlag<"JMC">,
+def _SLASH_JMC : CLFlag<"JMC">, Alias,
   HelpText<"Enable just-my-code debugging">;
-def _SLASH_JMC_ : CLFlag<"JMC-">,
+def _SLASH_JMC_ : CLFlag<"JMC-">, Alias,
   HelpText<"Disable just-my-code debugging (default)">;
 def _SLASH_LD : CLFlag<"LD">, HelpText<"Create DLL">;
 def _SLASH_LDd : CLFlag<"LDd">, HelpText<"Create debug DLL">;

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 00f2d7140db5d5..be3c92162f5bf0 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -4204,8 +4204,8 @@ static void renderDwarfFormat(const Driver , const 
llvm::Triple ,
 
 static void
 renderDebugOptions(const ToolChain , const Driver , const llvm::Triple ,
-   const ArgList , bool EmitCodeView, bool IRInput,
-   ArgStringList ,
+   const ArgList , bool IRInput, ArgStringList ,
+   const InputInfo ,
llvm::codegenoptions::DebugInfoKind ,
DwarfFissionKind ) {
   if (Args.hasFlag(options::OPT_fdebug_info_for_profiling,
@@ -4282,6 +4282,7 @@ renderDebugOptions(const ToolChain , const Driver , 
const llvm::Triple ,
   if (const Arg *A = getDwarfNArg(Args))
 EmitDwarf = checkDebugInfoOption(A, Args, D, TC);
 
+  bool EmitCodeView = false;
   if (const Arg *A = Args.getLastArg(options::OPT_gcodeview))
 EmitCodeView = checkDebugInfoOption(A, Args, D, TC);
 
@@ -4518,6 +4519,33 @@ renderDebugOptions(const ToolChain , const Driver , 
const llvm::Triple ,
 
   renderDwarfFormat(D, T, Args, CmdArgs, EffectiveDWARFVersion);
   RenderDebugInfoCompressionArgs(Args, CmdArgs, D, TC);
+
+  // This controls whether or not we perform JustMyCode instrumentation.
+  if (Args.hasFlag(options::OPT_fjmc, options::OPT_fno_jmc, false)) {
+if (TC.getTriple().isOSBinFormatELF() || D.IsCLMode()) {
+  if (DebugInfoKind >= llvm::codegenoptions::DebugInfoConstructor)
+CmdArgs.push_back("-fjmc");
+  else if (D.IsCLMode())
+D.Diag(clang::diag::warn_drv_jmc_requires_debuginfo) << "/JMC"
+ << "'/Zi', '/Z7'";
+  else
+D.Diag(clang::diag::warn_drv_jmc_requires_debuginfo) << "-fjmc"
+ 

[PATCH] D156320: [Flang][Driver] Add support for Rpass and related options

2023-08-14 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski added a comment.

Thanks for the updates - this is looking really good! A few more suggestions 
and then I'll scan the whole thing again (sorry, there's been quite a lot of 
code going back and forth).




Comment at: flang/lib/Frontend/CompilerInvocation.cpp:1024
 
+  // add the remark option requested i.e. pass, pass-missed or pass-analysis.
+  // This will be used later during processing warnings and remarks to give





Comment at: flang/lib/Frontend/FrontendActions.cpp:976-1011
+  void
+  optimizationRemarkHandler(const llvm::DiagnosticInfoOptimizationBase ) {
+if (d.isPassed()) {
+  // Optimization remarks are active only if the -Rpass flag has a regular
+  // expression that matches the name of the pass name in \p d.
+  if (codeGenOpts.OptimizationRemark.patternMatches(d.getPassName()))
+emitOptimizationMessage(





Comment at: flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:117
+
+void processWarningOptions(clang::DiagnosticsEngine ,
+   const clang::DiagnosticOptions ,

?



Comment at: flang/test/Driver/optimization-remark.f90:53
+end program forttest
\ No newline at end of file


FIXME


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156320

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


[PATCH] D157149: [Option] Add "Visibility" field and clone the OptTable APIs to use it

2023-08-14 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay accepted this revision.
MaskRay added subscribers: python3kgae, beanz.
MaskRay added a comment.
This revision is now accepted and ready to land.

> ... but it really doesn't scale well, as can be seen by things like the 
> somewhat recently introduced CLDXCOption.

FYI @beanz @python3kgae D128462 




Comment at: llvm/utils/TableGen/OptParserEmitter.cpp:387
 
+// The option visibility flags.
+OS << ", ";

If we make "flags" & "visibility", it's best not to use "visibility flags" to 
add possible confusion to readers.

This also applies to this sentence in the summary `... the only "subtractive" 
visibility flag be "HelpHidden"`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157149

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


[PATCH] D157750: Properly handle -fsplit-machine-functions for fatbinary compilation

2023-08-14 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: clang/test/Driver/fsplit-machine-functions-with-cuda-nvptx.c:9
+
+// Check that -fsplit-machine-functions is passed to both x86 and cuda 
compilation and does not cause driver error.
+// MFS2: -fsplit-machine-functions

shenhan wrote:
> tra wrote:
> > shenhan wrote:
> > > tra wrote:
> > > > We will still see a warning, right? So, for someone compiling with 
> > > > `-Werror` that's going to be a problem.
> > > > 
> > > > Also, if the warning is issued from the top-level driver, we may not 
> > > > even be able to suppress it when we disable splitting on GPU side with 
> > > > `-Xarch_device -fno-split-machine-functions`.
> > > > 
> > > > 
> > > > We will still see a warning, right?
> > > Yes, there still will be a warning. We've discussed it and we think that 
> > > pass -fsplit-machine-functions in this case is not a proper usage and a 
> > > warning is warranted, and it is not good that skip doing split silently 
> > > while uses explicitly ask for it.
> > > 
> > > > Also, if the warning is issued from the top-level driver
> > > The warning will not be issued from the top-level driver, it will be 
> > > issued when configuring optimization passes.
> > > So:
> > > 
> > > 
> > >   - -fsplit-machine-functions -Xarch_device -fno-split-machine-functions
> > > Will enable MFS for host, disable MFS for gpus and without any warnings.
> > > 
> > >   - -Xarch_host -fsplit-machine-functions
> > > The same as the above
> > > 
> > >   - -Xarch_host -fsplit-machine-functions -Xarch_device 
> > > -fno-split-machine-functions
> > > The same as the above
> > > 
> > > We've discussed it and we think that pass -fsplit-machine-functions in 
> > > this case is not a proper usage and a warning is warranted, and it is not 
> > > good that skip doing split silently while uses explicitly ask for it.
> > 
> > I would agree with that assertion if we were talking exclusively about CUDA 
> > compilation.
> > However, a common real world use pattern is that the flags are set globally 
> > for all C++ compilations, and then CUDA compilations within the project 
> > need to do whatever they need to to keep things working. The original user 
> > intent was for the option to affect the host compilation. There's no 
> > inherent assumption that it will do anything useful for the GPU.
> > 
> > In number of similar cases in the past we did settle on silently ignoring 
> > some top-level flags that we do expect to encounter in real projects, but 
> > which made no sense for the GPU. E.g. sanitizers. If the project is built 
> > w/ sanitizer enabled, the idea is to sanitize the host code, The GPU code 
> > continues to be built w/o sanitizer enabled. 
> > 
> > Anyways, as long as we have a way to deal with it it's not a big deal one 
> > way or another.
> > 
> > > -fsplit-machine-functions -Xarch_device -fno-split-machine-functions
> > > Will enable MFS for host, disable MFS for gpus and without any warnings.
> > 
> > OK. This will work.
> > 
> > 
> > In number of similar cases in the past we did settle on silently ignoring 
> > some top-level flags that we do expect to encounter in real projects, but 
> > which made no sense for the GPU. E.g. sanitizers. If the project is built 
> > w/ sanitizer enabled, the idea is to sanitize the host code, The GPU code 
> > continues to be built w/o sanitizer enabled.
> 
> Can I understand it this way - if the compiler is **only** building for CPUs, 
> then silently ignore any optimization flags is not a good behavior. If the 
> compiler is building CPUs and GPUs, it is still not a good behavior to 
> silently ignore optimization flags for CPUs, but it is probably ok to 
> silently ignore optimization flags for GPUs.
> 
> > OK. This will work.
> Thanks for confirming.
>  it is probably ok to silently ignore optimization flags for GPUs.

In this case, yes. 

I think the most consistent way to handle the situation is to keep the warning 
in place at cc1 compiler level, but change the driver behavior (and document 
it) so that it does not pass the splitting options to offloading 
sub-compilations. This way we'll do the sensible thing for the most common use 
case, yet would still warn if the user tries to enable the splitting where they 
should not (e.g. by using `-Xclang -fsplit-machine-functions` during CUDA 
compilation)






Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157750

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


[PATCH] D157794: [Driver] Make /Zi and /Z7 aliases of -g rather than handling them specially

2023-08-14 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added inline comments.



Comment at: clang/test/Driver/cl-options.c:567
 
-// This test was super sneaky: "/Z7" means "line-tables", but "-gdwarf" occurs
-// later on the command line, so it should win. Interestingly the cc1 arguments
-// came out right, but had wrong semantics, because an invariant assumed by
-// CompilerInvocation was violated: it expects that at most one of {gdwarfN,
-// line-tables-only} appear. If you assume that, then you can safely use
-// Args.hasArg to test whether a boolean flag is present without caring
-// where it appeared. And for this test, it appeared to the left of -gdwarf
-// which made it "win". This test could not detect that bug.
+// If We specify both /Z7 and -gdwarf we should get dwarf, not codeview.
 // RUN: %clang_cl /Z7 -gdwarf /c -### -- %s 2>&1 | FileCheck 
-check-prefix=Z7_gdwarf %s

smeenai wrote:
> bogner wrote:
> > smeenai wrote:
> > > bogner wrote:
> > > > rnk wrote:
> > > > > I think Meta folks depend on a mode that emits both codeview and 
> > > > > DWARF. +@smeenai
> > > > Hopefully if that's the case there's a better test somewhere than this 
> > > > one that discusses in detail how `/Z7` is an alias for 
> > > > `-gline-tables-only`, which hasn't been true since 2017.
> > > Thanks for the headers up :) We don't depend on that mode any more 
> > > though, so no problems on our end.
> > Also note that this change does not affect what happens if we specify both 
> > `-gcodeview` and `-gdwarf` together. That continues to pass both 
> > `-gcodeview` and `-dwarf-version=...` to `clang -cc1`. However, I don't see 
> > any tests that actually check that behaviour, so if that is a mode that's 
> > useful to keep working we definitely have some gaps there.
> > 
> > This change means that if you want to ask `-cc1` for dwarf *and* codeview 
> > with `/Z7` or `/Zi`, you'll need to specify `-gdwarf` and `-gcodeview` now. 
> > This matches how you would get both sets of options to render with `-g`, 
> > which I think makes sense.
> Yeah, that sounds good. IIRC when we were using the joint codeview + DWARF 
> mode it was with the gcc-style Clang driver and not clang-cl, and we passed 
> `-gdwarf -gcodeview` or similar to enable it anyway. We don't need that 
> anymore though; @mstorsjo would know if there's anything on the MinGW side 
> that cares for it.
I'm not aware of mingw usecases of using both codeview and DWARF at the same 
time - I've occasionally mentioned that I know some people do use that, but I 
haven't actually guided anybody into doing it.

For mingw, as long as `-g -gcodeview` on the driver level generates codeview 
(and not DWARF) like it used to, mingw should be fine.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157794

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


[PATCH] D157554: [NFC][Clang] Fix static analyzer concern about null pointer dereference

2023-08-14 Thread Elizabeth Andrews via Phabricator via cfe-commits
eandrews added a comment.

Thanks for the reviews!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157554

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


[PATCH] D157554: [NFC][Clang] Fix static analyzer concern about null pointer dereference

2023-08-14 Thread Elizabeth Andrews via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc4ada13e4b3e: [NFC][Clang] Fix static analyzer concern about 
null value dereference (authored by eandrews).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157554

Files:
  clang/lib/Sema/SemaExprCXX.cpp


Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -9072,8 +9072,10 @@
 MultiLevelTemplateArgumentList MLTAL(Param, TAL.asArray(),
  /*Final=*/false);
 MLTAL.addOuterRetainedLevels(TPL->getDepth());
-Expr *IDC = Param->getTypeConstraint()->getImmediatelyDeclaredConstraint();
-ExprResult Constraint = SubstExpr(IDC, MLTAL);
+const TypeConstraint *TC = Param->getTypeConstraint();
+assert(TC && "Type Constraint cannot be null here");
+ExprResult Constraint =
+SubstExpr(TC->getImmediatelyDeclaredConstraint(), MLTAL);
 if (Constraint.isInvalid()) {
   Status = concepts::ExprRequirement::SS_ExprSubstitutionFailure;
 } else {


Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -9072,8 +9072,10 @@
 MultiLevelTemplateArgumentList MLTAL(Param, TAL.asArray(),
  /*Final=*/false);
 MLTAL.addOuterRetainedLevels(TPL->getDepth());
-Expr *IDC = Param->getTypeConstraint()->getImmediatelyDeclaredConstraint();
-ExprResult Constraint = SubstExpr(IDC, MLTAL);
+const TypeConstraint *TC = Param->getTypeConstraint();
+assert(TC && "Type Constraint cannot be null here");
+ExprResult Constraint =
+SubstExpr(TC->getImmediatelyDeclaredConstraint(), MLTAL);
 if (Constraint.isInvalid()) {
   Status = concepts::ExprRequirement::SS_ExprSubstitutionFailure;
 } else {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D157280: [PGO] Enable `-fprofile-update` for `-fprofile-generate`

2023-08-14 Thread Qiongsi Wu via Phabricator via cfe-commits
qiongsiwu1 added inline comments.



Comment at: llvm/lib/Passes/PassBuilderPipelines.cpp:1797
   addPGOInstrPasses(MPM, Level, /* RunProfileGen */ true,
-/* IsCS */ true, PGOOpt->CSProfileGenFile,
-PGOOpt->ProfileRemappingFile,
+/* IsCS */ true, PGOOpt->AtomicCounterUpdate,
+PGOOpt->CSProfileGenFile, PGOOpt->ProfileRemappingFile,

MaskRay wrote:
> qiongsiwu1 wrote:
> > MaskRay wrote:
> > > The canonical way to specify the parameter name is `/*IsCS=*/true`
> > Ah thanks for pointing it out! Let me fix it in a later NFC patch if that 
> > is OK. There are quite a few changes required and they would make the 
> > actual feature harder to see. 
> I think it's better to fix the argument style while you are modifying it. 
> Otherwise, there may not be not much value to do a batch change for this file.
> I think it's better to fix the argument style while you are modifying it. 
> Otherwise, there may not be not much value to do a batch change for this file.

Ok sounds good. I will fix the comments relevant to this patch. Thanks! 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157280

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


  1   2   3   >