[clang] [openmp] [Libomp] Place generated OpenMP headers into build resource directory (PR #88007)

2024-04-08 Thread Shilei Tian via cfe-commits


@@ -10,12 +10,19 @@
 
 include(ExtendPath)
 
+# The generated headers will be placed in clang's resource directory if 
present.
+if(${OPENMP_STANDALONE_BUILD})
+  set(LIBOMP_HEADERS_INTDIR ${CMAKE_CURRENT_BINARY_DIR})
+else()
+  set(LIBOMP_HEADERS_INTDIR ${LLVM_BINARY_DIR}/${LIBOMP_HEADERS_INSTALL_PATH})

shiltian wrote:

oh "intermediate"

https://github.com/llvm/llvm-project/pull/88007
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [openmp] [Libomp] Place generated OpenMP headers into build resource directory (PR #88007)

2024-04-08 Thread Joseph Huber via cfe-commits


@@ -10,12 +10,19 @@
 
 include(ExtendPath)
 
+# The generated headers will be placed in clang's resource directory if 
present.
+if(${OPENMP_STANDALONE_BUILD})
+  set(LIBOMP_HEADERS_INTDIR ${CMAKE_CURRENT_BINARY_DIR})
+else()
+  set(LIBOMP_HEADERS_INTDIR ${LLVM_BINARY_DIR}/${LIBOMP_HEADERS_INSTALL_PATH})

jhuber6 wrote:

Done to match `LLVM_RUNTIME_OUTPUT_INTDIR` conceptually, It's just intermediate 
directory. I.e. not where it's being installed, but where it's stored in the 
build.

https://github.com/llvm/llvm-project/pull/88007
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [openmp] [Libomp] Place generated OpenMP headers into build resource directory (PR #88007)

2024-04-08 Thread Shilei Tian via cfe-commits


@@ -10,12 +10,19 @@
 
 include(ExtendPath)
 
+# The generated headers will be placed in clang's resource directory if 
present.
+if(${OPENMP_STANDALONE_BUILD})
+  set(LIBOMP_HEADERS_INTDIR ${CMAKE_CURRENT_BINARY_DIR})
+else()
+  set(LIBOMP_HEADERS_INTDIR ${LLVM_BINARY_DIR}/${LIBOMP_HEADERS_INSTALL_PATH})

shiltian wrote:

Is it `INSTDIR` or `INTDIR`? What does `INTDIR` mean?

https://github.com/llvm/llvm-project/pull/88007
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [NFC][OpenMP] Split nesting_of_regions test (PR #87842)

2024-04-08 Thread Mike Rice via cfe-commits

https://github.com/mikerice1969 closed 
https://github.com/llvm/llvm-project/pull/87842
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] aa6a089 - [NFC][OpenMP] Split nesting_of_regions test (#87842)

2024-04-08 Thread via cfe-commits

Author: Mike Rice
Date: 2024-04-08T12:53:30-07:00
New Revision: aa6a089c367e024921bae050b8999a7bc4d58f76

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

LOG: [NFC][OpenMP] Split nesting_of_regions test (#87842)

This test is the bottleneck for OpenMP lit tests, running about twice as
long as the others. Break it into five tests based on run lines with the
same version.

Added: 
clang/test/OpenMP/Inputs/nesting_of_regions.cpp
clang/test/OpenMP/nesting_of_regions_45.cpp
clang/test/OpenMP/nesting_of_regions_50.cpp
clang/test/OpenMP/nesting_of_regions_51.cpp
clang/test/OpenMP/nesting_of_regions_simd_45.cpp
clang/test/OpenMP/nesting_of_regions_simd_50.cpp

Modified: 


Removed: 
clang/test/OpenMP/nesting_of_regions.cpp



diff  --git a/clang/test/OpenMP/nesting_of_regions.cpp 
b/clang/test/OpenMP/Inputs/nesting_of_regions.cpp
similarity index 99%
rename from clang/test/OpenMP/nesting_of_regions.cpp
rename to clang/test/OpenMP/Inputs/nesting_of_regions.cpp
index 9442fb20647d0f..e671f9b0cf4123 100644
--- a/clang/test/OpenMP/nesting_of_regions.cpp
+++ b/clang/test/OpenMP/Inputs/nesting_of_regions.cpp
@@ -1,15 +1,3 @@
-// RUN: %clang_cc1 -fsyntax-only -fopenmp -fopenmp-version=45 
-fno-openmp-extensions -verify=expected,omp45,omp45warn,omp %s
-// RUN: %clang_cc1 -fsyntax-only -fopenmp -fno-openmp-extensions 
-verify=expected,omp50,omp %s
-// RUN: %clang_cc1 -fsyntax-only -fopenmp -fopenmp-extensions 
-verify=expected,omp50 %s
-// RUN: %clang_cc1 -fsyntax-only -fopenmp -fopenmp-version=45 
-verify=expected,omp45,omp -fno-openmp-extensions -Wno-openmp %s
-// RUN: %clang_cc1 -fsyntax-only -fopenmp -fopenmp-version=45 
-verify=expected,omp45,omp -fno-openmp-extensions -Wno-source-uses-openmp %s
-// RUN: %clang_cc1 -fsyntax-only -fopenmp -fopenmp-version=51 
-verify=expected,omp51,omp -fno-openmp-extensions -Wno-source-uses-openmp %s
-
-// RUN: %clang_cc1 -fsyntax-only -fopenmp-simd -fopenmp-version=45 
-fno-openmp-extensions -verify=expected,omp45,omp45warn,omp %s
-// RUN: %clang_cc1 -fsyntax-only -fopenmp-simd -verify=expected,omp50,omp 
-fno-openmp-extensions %s
-// RUN: %clang_cc1 -fsyntax-only -fopenmp-simd -fopenmp-version=51 
-verify=expected,omp51,omp -fno-openmp-extensions %s
-// SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
-
 void bar();
 
 template 
@@ -19577,4 +19565,3 @@ void foo() {
 
   return foo();
 }
-

diff  --git a/clang/test/OpenMP/nesting_of_regions_45.cpp 
b/clang/test/OpenMP/nesting_of_regions_45.cpp
new file mode 100644
index 00..d5870ec36486e7
--- /dev/null
+++ b/clang/test/OpenMP/nesting_of_regions_45.cpp
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -fsyntax-only -fopenmp -fopenmp-version=45 
-fno-openmp-extensions -verify=expected,omp45,omp45warn,omp %s
+// RUN: %clang_cc1 -fsyntax-only -fopenmp -fopenmp-version=45 
-verify=expected,omp45,omp -fno-openmp-extensions -Wno-openmp %s
+
+#include "Inputs/nesting_of_regions.cpp"

diff  --git a/clang/test/OpenMP/nesting_of_regions_50.cpp 
b/clang/test/OpenMP/nesting_of_regions_50.cpp
new file mode 100644
index 00..f2061553a80463
--- /dev/null
+++ b/clang/test/OpenMP/nesting_of_regions_50.cpp
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -fsyntax-only -fopenmp -fno-openmp-extensions 
-verify=expected,omp50,omp %s
+// RUN: %clang_cc1 -fsyntax-only -fopenmp -fopenmp-extensions 
-verify=expected,omp50 %s
+
+#include "Inputs/nesting_of_regions.cpp"

diff  --git a/clang/test/OpenMP/nesting_of_regions_51.cpp 
b/clang/test/OpenMP/nesting_of_regions_51.cpp
new file mode 100644
index 00..856489b042821c
--- /dev/null
+++ b/clang/test/OpenMP/nesting_of_regions_51.cpp
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -fsyntax-only -fopenmp-simd -fopenmp-version=51 
-verify=expected,omp51,omp -fno-openmp-extensions %s
+// RUN: %clang_cc1 -fsyntax-only -fopenmp -fopenmp-version=51 
-verify=expected,omp51,omp -fno-openmp-extensions -Wno-source-uses-openmp %s
+
+#include "Inputs/nesting_of_regions.cpp"

diff  --git a/clang/test/OpenMP/nesting_of_regions_simd_45.cpp 
b/clang/test/OpenMP/nesting_of_regions_simd_45.cpp
new file mode 100644
index 00..fb0d8bbfe3e486
--- /dev/null
+++ b/clang/test/OpenMP/nesting_of_regions_simd_45.cpp
@@ -0,0 +1,3 @@
+// RUN: %clang_cc1 -fsyntax-only -fopenmp-simd -fopenmp-version=45 
-fno-openmp-extensions -verify=expected,omp45,omp45warn,omp %s
+
+#include "Inputs/nesting_of_regions.cpp"

diff  --git a/clang/test/OpenMP/nesting_of_regions_simd_50.cpp 
b/clang/test/OpenMP/nesting_of_regions_simd_50.cpp
new file mode 100644
index 00..ba87ba38e74a64
--- /dev/null
+++ b/clang/test/OpenMP/nesting_of_regions_simd_50.cpp
@@ -0,0 +1,3 @@
+// RUN: %clang_cc1 -fsyntax-only -fopenmp-simd -verify=expected,omp50,omp 
-fno-openmp-extensions %s
+
+#include 

[clang] Add handling of the `-nostdlibinc` option to ccc-analyzer (PR #88017)

2024-04-08 Thread Artem Dergachev via cfe-commits

haoNoQ wrote:

I never realized that scan-build makes a "short list" of flags to pass through 
and throws away the rest. This is terrifying. It only works because most 
compiler flags are recognized because they're prefixed with `-f`, `-W`, etc.; 
but it's fascinating that it even works.

This may be testable; we've recently started adding tests for scan-build. But 
you'll have to see how `-nostdlibinc` is tested in general, and then see if you 
can combine the two tricks.

https://github.com/llvm/llvm-project/pull/88017
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] demangle function names in trace files (PR #87626)

2024-04-08 Thread via cfe-commits

https://github.com/Trass3r updated 
https://github.com/llvm/llvm-project/pull/87626

>From 4bbe58d6027081adfe446a09c6c837542fa196f3 Mon Sep 17 00:00:00 2001
From: Andreas Hollandt 
Date: Tue, 4 Oct 2022 12:05:39 +0200
Subject: [PATCH 1/2] demangle OptFunction trace names

This improves consistency in the trace files as other entries are demangled too.
Fixes #45901.
---
 clang/test/Driver/ftime-trace-sections.py| 15 +--
 llvm/lib/IR/LegacyPassManager.cpp|  4 +++-
 llvm/lib/Passes/CMakeLists.txt   |  1 +
 llvm/lib/Passes/StandardInstrumentations.cpp |  3 ++-
 4 files changed, 19 insertions(+), 4 deletions(-)
 mode change 100644 => 100755 clang/test/Driver/ftime-trace-sections.py

diff --git a/clang/test/Driver/ftime-trace-sections.py 
b/clang/test/Driver/ftime-trace-sections.py
old mode 100644
new mode 100755
index 02afa4ac54eb7b..eeb3aa24131a39
--- a/clang/test/Driver/ftime-trace-sections.py
+++ b/clang/test/Driver/ftime-trace-sections.py
@@ -19,9 +19,12 @@ def is_before(range1, range2):
 
 log_contents = json.loads(sys.stdin.read())
 events = log_contents["traceEvents"]
-codegens = [event for event in events if event["name"] == "CodeGen Function"]
+
+instants  = [event for event in events if event["name"] == 
"InstantiateFunction"]
+codegens  = [event for event in events if event["name"] == "CodeGen Function"]
+opts  = [event for event in events if event["name"] == "OptFunction"]
 frontends = [event for event in events if event["name"] == "Frontend"]
-backends = [event for event in events if event["name"] == "Backend"]
+backends  = [event for event in events if event["name"] == "Backend"]
 
 beginning_of_time = log_contents["beginningOfTime"] / 100
 seconds_since_epoch = time.time()
@@ -48,3 +51,11 @@ def is_before(range1, range2):
 ]
 ):
 sys.exit("Not all Frontend section are before all Backend sections!")
+
+# Check that entries for foo exist and are in a demangled form.
+if not any(e for e in instants if "foo" in e["args"]["detail"]):
+sys.exit("Missing Instantiate entry for foo!")
+if not any(e for e in codegens if "foo" in e["args"]["detail"]):
+sys.exit("Missing CodeGen entry for foo!")
+if not any(e for e in opts if "foo" in e["args"]["detail"]):
+sys.exit("Missing Optimize entry for foo!")
diff --git a/llvm/lib/IR/LegacyPassManager.cpp 
b/llvm/lib/IR/LegacyPassManager.cpp
index 953f21ce740590..9e3578954418ad 100644
--- a/llvm/lib/IR/LegacyPassManager.cpp
+++ b/llvm/lib/IR/LegacyPassManager.cpp
@@ -12,6 +12,7 @@
 
 #include "llvm/IR/LegacyPassManager.h"
 #include "llvm/ADT/MapVector.h"
+#include "llvm/Demangle/Demangle.h"
 #include "llvm/IR/DiagnosticInfo.h"
 #include "llvm/IR/IRPrintingPasses.h"
 #include "llvm/IR/LLVMContext.h"
@@ -1421,7 +1422,8 @@ bool FPPassManager::runOnFunction(Function ) {
 
   // Store name outside of loop to avoid redundant calls.
   const StringRef Name = F.getName();
-  llvm::TimeTraceScope FunctionScope("OptFunction", Name);
+  llvm::TimeTraceScope FunctionScope(
+  "OptFunction", []() { return demangle(F.getName().str()); });
 
   for (unsigned Index = 0; Index < getNumContainedPasses(); ++Index) {
 FunctionPass *FP = getContainedPass(Index);
diff --git a/llvm/lib/Passes/CMakeLists.txt b/llvm/lib/Passes/CMakeLists.txt
index 6425f4934b2103..b5224327d79216 100644
--- a/llvm/lib/Passes/CMakeLists.txt
+++ b/llvm/lib/Passes/CMakeLists.txt
@@ -21,6 +21,7 @@ add_llvm_component_library(LLVMPasses
   CodeGen
   Core
   Coroutines
+  Demangle
   HipStdPar
   IPO
   InstCombine
diff --git a/llvm/lib/Passes/StandardInstrumentations.cpp 
b/llvm/lib/Passes/StandardInstrumentations.cpp
index 697988b3fc7c0b..df7ee9b1024ce1 100644
--- a/llvm/lib/Passes/StandardInstrumentations.cpp
+++ b/llvm/lib/Passes/StandardInstrumentations.cpp
@@ -20,6 +20,7 @@
 #include "llvm/Analysis/LazyCallGraph.h"
 #include "llvm/Analysis/LoopInfo.h"
 #include "llvm/CodeGen/MachineFunction.h"
+#include "llvm/Demangle/Demangle.h"
 #include "llvm/IR/Constants.h"
 #include "llvm/IR/Function.h"
 #include "llvm/IR/Module.h"
@@ -1495,7 +1496,7 @@ void TimeProfilingPassesHandler::registerCallbacks(
 }
 
 void TimeProfilingPassesHandler::runBeforePass(StringRef PassID, Any IR) {
-  timeTraceProfilerBegin(PassID, getIRName(IR));
+  timeTraceProfilerBegin(PassID, demangle(getIRName(IR)));
 }
 
 void TimeProfilingPassesHandler::runAfterPass() { timeTraceProfilerEnd(); }

>From aef8e2f793dad442dd6bd30b73a2d52e05d3ff6a Mon Sep 17 00:00:00 2001
From: Andreas Hollandt 
Date: Mon, 8 Apr 2024 21:32:24 +0200
Subject: [PATCH 2/2] add demangled parameter to getIRName

---
 llvm/lib/Passes/StandardInstrumentations.cpp | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/llvm/lib/Passes/StandardInstrumentations.cpp 
b/llvm/lib/Passes/StandardInstrumentations.cpp
index df7ee9b1024ce1..0faf865cd013c8 100644
--- a/llvm/lib/Passes/StandardInstrumentations.cpp
+++ b/llvm/lib/Passes/StandardInstrumentations.cpp
@@ -216,12 +216,12 @@ void 

[clang] Add handling of the `-nostdlibinc` option to ccc-analyzer (PR #88017)

2024-04-08 Thread Artem Dergachev via cfe-commits

https://github.com/haoNoQ approved this pull request.


https://github.com/llvm/llvm-project/pull/88017
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] Fix "[clang][UBSan] Add implicit conversion check for bitfields" (PR #87761)

2024-04-08 Thread Vitaly Buka via cfe-commits

https://github.com/vitalybuka closed 
https://github.com/llvm/llvm-project/pull/87761
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [openmp] [Libomp] Place generated OpenMP headers into build resource directory (PR #88007)

2024-04-08 Thread Joseph Huber via cfe-commits


@@ -16,4 +16,12 @@ typedef unsigned __INTPTR_TYPE__ uintptr_t;
 #error Every target should have __INTPTR_TYPE__
 #endif
 
+#ifdef __INTPTR_MAX__
+#define  INTPTR_MAX__INTPTR_MAX__
+#endif
+
+#ifdef __UINTPTR_MAX__
+#define UINTPTR_MAX   __UINTPTR_MAX__
+#endif
+

jhuber6 wrote:

Alternatively we could just delete this `stdint.h` altogether, because this 
only happens because it's using this one instead. But I assume that we override 
the regular `stdint.h` to reduce the number of live definitions in tests or 
something.

https://github.com/llvm/llvm-project/pull/88007
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [openmp] [Libomp] Place generated OpenMP headers into build resource directory (PR #88007)

2024-04-08 Thread Joseph Huber via cfe-commits

https://github.com/jhuber6 edited 
https://github.com/llvm/llvm-project/pull/88007
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [openmp] [Libomp] Place generated OpenMP headers into build resource directory (PR #88007)

2024-04-08 Thread Joseph Huber via cfe-commits


@@ -16,4 +16,12 @@ typedef unsigned __INTPTR_TYPE__ uintptr_t;
 #error Every target should have __INTPTR_TYPE__
 #endif
 
+#ifdef __INTPTR_MAX__
+#define  INTPTR_MAX__INTPTR_MAX__
+#endif
+
+#ifdef __UINTPTR_MAX__
+#define UINTPTR_MAX   __UINTPTR_MAX__
+#endif
+

jhuber6 wrote:

yes

https://github.com/llvm/llvm-project/pull/88007
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [openmp] [Libomp] Place generated OpenMP headers into build resource directory (PR #88007)

2024-04-08 Thread Jan Patrick Lehr via cfe-commits


@@ -16,4 +16,12 @@ typedef unsigned __INTPTR_TYPE__ uintptr_t;
 #error Every target should have __INTPTR_TYPE__
 #endif
 
+#ifdef __INTPTR_MAX__
+#define  INTPTR_MAX__INTPTR_MAX__
+#endif
+
+#ifdef __UINTPTR_MAX__
+#define UINTPTR_MAX   __UINTPTR_MAX__
+#endif
+

jplehr wrote:

Are these changes required to make this work?

https://github.com/llvm/llvm-project/pull/88007
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [openmp] [Libomp] Place generated OpenMP headers into build resource directory (PR #88007)

2024-04-08 Thread Jan Patrick Lehr via cfe-commits

https://github.com/jplehr commented:

The changes seem reasonable to me.

https://github.com/llvm/llvm-project/pull/88007
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [openmp] [Libomp] Place generated OpenMP headers into build resource directory (PR #88007)

2024-04-08 Thread Jan Patrick Lehr via cfe-commits

https://github.com/jplehr edited https://github.com/llvm/llvm-project/pull/88007
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang]Treat arguments to builtin type traits as template type arguments (PR #87132)

2024-04-08 Thread via cfe-commits

https://github.com/fahadnayyar approved this pull request.

LGTM!

https://github.com/llvm/llvm-project/pull/87132
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [openmp] [Libomp] Place generated OpenMP headers into build resource directory (PR #88007)

2024-04-08 Thread Joseph Huber via cfe-commits

jhuber6 wrote:

> IIRC there is a case where `omp.h` as well as other headers are installed 
> into clang's directory.

These are currently installed into clang's directory, this patch just puts it 
in the resource directory for the build.

https://github.com/llvm/llvm-project/pull/88007
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-tidy] Allow renaming macro arguments (PR #87792)

2024-04-08 Thread Carlos Galvez via cfe-commits

carlosgalvezp wrote:

> the user may not have the ability to change the definition of the macro to be 
> able to appease the check

My understanding of this PR is that the user would only need to change what 
they pass into the macro, not the macro itself, or? E.g.

```cpp
-MY_MACRO(foo)
+MY_MACRO(g_foo)
```

https://github.com/llvm/llvm-project/pull/87792
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [openmp] [Libomp] Place generated OpenMP headers into build resource directory (PR #88007)

2024-04-08 Thread Joseph Huber via cfe-commits


@@ -10,12 +10,19 @@
 
 include(ExtendPath)
 
+# The generated headers will be placed in clang's resource directory if 
present.
+if(${OPENMP_STANDALONE_BUILD})
+  set(LIBOMP_HEADERS_INTDIR ${CMAKE_CURRENT_BINARY_DIR})
+else()
+  set(LIBOMP_HEADERS_INTDIR ${LLVM_BINARY_DIR}/${LIBOMP_HEADERS_INSTALL_PATH})

jhuber6 wrote:

LLVM is always built, I don't think it's possible to turn it off. Everything 
goes through `cmake ../llvm` so it will be set when that CMake runs.

https://github.com/llvm/llvm-project/pull/88007
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [openmp] [Libomp] Place generated OpenMP headers into build resource directory (PR #88007)

2024-04-08 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Joseph Huber (jhuber6)


Changes

Summary:
These headers are a part of the compiler's resource directory once
installed. However, they are currently placed in the binary directory
temporarily. This makes it more difficult to use the compiler out of the
build directory and will cause issues when moving to `liboffload`. This
patch changes the logic to write these instead to the copmiler's
resource directory inside of the build tree.

NOTE: This doesn't change the Fortran headers, I don't know enough about
those and it won't use the same directory.


---
Full diff: https://github.com/llvm/llvm-project/pull/88007.diff


2 Files Affected:

- (modified) clang/test/Headers/Inputs/include/stdint.h (+8) 
- (modified) openmp/runtime/src/CMakeLists.txt (+16-9) 


``diff
diff --git a/clang/test/Headers/Inputs/include/stdint.h 
b/clang/test/Headers/Inputs/include/stdint.h
index 5bf26a7b67b066..67b27b8dfc7b92 100644
--- a/clang/test/Headers/Inputs/include/stdint.h
+++ b/clang/test/Headers/Inputs/include/stdint.h
@@ -16,4 +16,12 @@ typedef unsigned __INTPTR_TYPE__ uintptr_t;
 #error Every target should have __INTPTR_TYPE__
 #endif
 
+#ifdef __INTPTR_MAX__
+#define  INTPTR_MAX__INTPTR_MAX__
+#endif
+
+#ifdef __UINTPTR_MAX__
+#define UINTPTR_MAX   __UINTPTR_MAX__
+#endif
+
 #endif /* STDINT_H */
diff --git a/openmp/runtime/src/CMakeLists.txt 
b/openmp/runtime/src/CMakeLists.txt
index f05bcabb441742..000d02c33dc093 100644
--- a/openmp/runtime/src/CMakeLists.txt
+++ b/openmp/runtime/src/CMakeLists.txt
@@ -10,12 +10,19 @@
 
 include(ExtendPath)
 
+# The generated headers will be placed in clang's resource directory if 
present.
+if(${OPENMP_STANDALONE_BUILD})
+  set(LIBOMP_HEADERS_INTDIR ${CMAKE_CURRENT_BINARY_DIR})
+else()
+  set(LIBOMP_HEADERS_INTDIR ${LLVM_BINARY_DIR}/${LIBOMP_HEADERS_INSTALL_PATH})
+endif()
+
 # Configure omp.h, kmp_config.h and omp-tools.h if necessary
-configure_file(${LIBOMP_INC_DIR}/omp.h.var omp.h @ONLY)
-configure_file(${LIBOMP_INC_DIR}/ompx.h.var ompx.h @ONLY)
-configure_file(kmp_config.h.cmake kmp_config.h @ONLY)
+configure_file(${LIBOMP_INC_DIR}/omp.h.var ${LIBOMP_HEADERS_INTDIR}/omp.h 
@ONLY)
+configure_file(${LIBOMP_INC_DIR}/ompx.h.var ${LIBOMP_HEADERS_INTDIR}/ompx.h 
@ONLY)
+configure_file(kmp_config.h.cmake ${LIBOMP_HEADERS_INTDIR}/kmp_config.h @ONLY)
 if(${LIBOMP_OMPT_SUPPORT})
-  configure_file(${LIBOMP_INC_DIR}/omp-tools.h.var omp-tools.h @ONLY)
+  configure_file(${LIBOMP_INC_DIR}/omp-tools.h.var 
${LIBOMP_HEADERS_INTDIR}/omp-tools.h @ONLY)
 endif()
 
 # Generate message catalog files: kmp_i18n_id.inc and kmp_i18n_default.inc
@@ -419,15 +426,15 @@ else()
 endif()
 install(
   FILES
-  ${CMAKE_CURRENT_BINARY_DIR}/omp.h
-  ${CMAKE_CURRENT_BINARY_DIR}/ompx.h
+  ${LIBOMP_HEADERS_INTDIR}/omp.h
+  ${LIBOMP_HEADERS_INTDIR}/ompx.h
   DESTINATION ${LIBOMP_HEADERS_INSTALL_PATH}
 )
 if(${LIBOMP_OMPT_SUPPORT})
-  install(FILES ${CMAKE_CURRENT_BINARY_DIR}/omp-tools.h DESTINATION 
${LIBOMP_HEADERS_INSTALL_PATH})
+  install(FILES ${LIBOMP_HEADERS_INTDIR}/omp-tools.h DESTINATION 
${LIBOMP_HEADERS_INSTALL_PATH})
   # install under legacy name ompt.h
-  install(FILES ${CMAKE_CURRENT_BINARY_DIR}/omp-tools.h DESTINATION 
${LIBOMP_HEADERS_INSTALL_PATH} RENAME ompt.h)
-  set(LIBOMP_OMP_TOOLS_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR} PARENT_SCOPE)
+  install(FILES ${LIBOMP_HEADERS_INTDIR}/omp-tools.h DESTINATION 
${LIBOMP_HEADERS_INSTALL_PATH} RENAME ompt.h)
+  set(LIBOMP_OMP_TOOLS_INCLUDE_DIR ${LIBOMP_HEADERS_INTDIR} PARENT_SCOPE)
 endif()
 if(${BUILD_FORTRAN_MODULES})
   set (destination ${LIBOMP_HEADERS_INSTALL_PATH})

``




https://github.com/llvm/llvm-project/pull/88007
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [openmp] [Libomp] Place generated OpenMP headers into build resource directory (PR #88007)

2024-04-08 Thread Joseph Huber via cfe-commits

https://github.com/jhuber6 updated 
https://github.com/llvm/llvm-project/pull/88007

>From 0dbfd89b69197df8201b772b88654810e689cced Mon Sep 17 00:00:00 2001
From: Joseph Huber 
Date: Mon, 8 Apr 2024 10:01:06 -0500
Subject: [PATCH] [Libomp] Place generated OpenMP headers into build resource
 directory

Summary:
These headers are a part of the compiler's resource directory once
installed. However, they are currently placed in the binary directory
temporarily. This makes it more difficult to use the compiler out of the
build directory and will cause issues when moving to `liboffload`. This
patch changes the logic to write these instead to the copmiler's
resource directory inside of the build tree.

NOTE: This doesn't change the Fortran headers, I don't know enough about
those and it won't use the same directory.
---
 clang/test/Headers/Inputs/include/stdint.h |  8 +++
 openmp/runtime/src/CMakeLists.txt  | 25 ++
 2 files changed, 24 insertions(+), 9 deletions(-)

diff --git a/clang/test/Headers/Inputs/include/stdint.h 
b/clang/test/Headers/Inputs/include/stdint.h
index 5bf26a7b67b066..67b27b8dfc7b92 100644
--- a/clang/test/Headers/Inputs/include/stdint.h
+++ b/clang/test/Headers/Inputs/include/stdint.h
@@ -16,4 +16,12 @@ typedef unsigned __INTPTR_TYPE__ uintptr_t;
 #error Every target should have __INTPTR_TYPE__
 #endif
 
+#ifdef __INTPTR_MAX__
+#define  INTPTR_MAX__INTPTR_MAX__
+#endif
+
+#ifdef __UINTPTR_MAX__
+#define UINTPTR_MAX   __UINTPTR_MAX__
+#endif
+
 #endif /* STDINT_H */
diff --git a/openmp/runtime/src/CMakeLists.txt 
b/openmp/runtime/src/CMakeLists.txt
index f05bcabb441742..000d02c33dc093 100644
--- a/openmp/runtime/src/CMakeLists.txt
+++ b/openmp/runtime/src/CMakeLists.txt
@@ -10,12 +10,19 @@
 
 include(ExtendPath)
 
+# The generated headers will be placed in clang's resource directory if 
present.
+if(${OPENMP_STANDALONE_BUILD})
+  set(LIBOMP_HEADERS_INTDIR ${CMAKE_CURRENT_BINARY_DIR})
+else()
+  set(LIBOMP_HEADERS_INTDIR ${LLVM_BINARY_DIR}/${LIBOMP_HEADERS_INSTALL_PATH})
+endif()
+
 # Configure omp.h, kmp_config.h and omp-tools.h if necessary
-configure_file(${LIBOMP_INC_DIR}/omp.h.var omp.h @ONLY)
-configure_file(${LIBOMP_INC_DIR}/ompx.h.var ompx.h @ONLY)
-configure_file(kmp_config.h.cmake kmp_config.h @ONLY)
+configure_file(${LIBOMP_INC_DIR}/omp.h.var ${LIBOMP_HEADERS_INTDIR}/omp.h 
@ONLY)
+configure_file(${LIBOMP_INC_DIR}/ompx.h.var ${LIBOMP_HEADERS_INTDIR}/ompx.h 
@ONLY)
+configure_file(kmp_config.h.cmake ${LIBOMP_HEADERS_INTDIR}/kmp_config.h @ONLY)
 if(${LIBOMP_OMPT_SUPPORT})
-  configure_file(${LIBOMP_INC_DIR}/omp-tools.h.var omp-tools.h @ONLY)
+  configure_file(${LIBOMP_INC_DIR}/omp-tools.h.var 
${LIBOMP_HEADERS_INTDIR}/omp-tools.h @ONLY)
 endif()
 
 # Generate message catalog files: kmp_i18n_id.inc and kmp_i18n_default.inc
@@ -419,15 +426,15 @@ else()
 endif()
 install(
   FILES
-  ${CMAKE_CURRENT_BINARY_DIR}/omp.h
-  ${CMAKE_CURRENT_BINARY_DIR}/ompx.h
+  ${LIBOMP_HEADERS_INTDIR}/omp.h
+  ${LIBOMP_HEADERS_INTDIR}/ompx.h
   DESTINATION ${LIBOMP_HEADERS_INSTALL_PATH}
 )
 if(${LIBOMP_OMPT_SUPPORT})
-  install(FILES ${CMAKE_CURRENT_BINARY_DIR}/omp-tools.h DESTINATION 
${LIBOMP_HEADERS_INSTALL_PATH})
+  install(FILES ${LIBOMP_HEADERS_INTDIR}/omp-tools.h DESTINATION 
${LIBOMP_HEADERS_INSTALL_PATH})
   # install under legacy name ompt.h
-  install(FILES ${CMAKE_CURRENT_BINARY_DIR}/omp-tools.h DESTINATION 
${LIBOMP_HEADERS_INSTALL_PATH} RENAME ompt.h)
-  set(LIBOMP_OMP_TOOLS_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR} PARENT_SCOPE)
+  install(FILES ${LIBOMP_HEADERS_INTDIR}/omp-tools.h DESTINATION 
${LIBOMP_HEADERS_INSTALL_PATH} RENAME ompt.h)
+  set(LIBOMP_OMP_TOOLS_INCLUDE_DIR ${LIBOMP_HEADERS_INTDIR} PARENT_SCOPE)
 endif()
 if(${BUILD_FORTRAN_MODULES})
   set (destination ${LIBOMP_HEADERS_INSTALL_PATH})

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


[clang] [NFC][OpenMP] Split nesting_of_regions test (PR #87842)

2024-04-08 Thread Alexey Bataev via cfe-commits

https://github.com/alexey-bataev approved this pull request.

LG

https://github.com/llvm/llvm-project/pull/87842
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] Revert "[AArch64] Add support for -ffixed-x30" (PR #88019)

2024-04-08 Thread Fangrui Song via cfe-commits

https://github.com/MaskRay approved this pull request.


https://github.com/llvm/llvm-project/pull/88019
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Reject incomplete types in `__is_layout_compatible()` (PR #87869)

2024-04-08 Thread Vlad Serebrennikov via cfe-commits

https://github.com/Endilll closed 
https://github.com/llvm/llvm-project/pull/87869
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] fd2ffc1 - [clang] Reject incomplete types in `__is_layout_compatible()` (#87869)

2024-04-08 Thread via cfe-commits

Author: Vlad Serebrennikov
Date: 2024-04-08T22:37:48+04:00
New Revision: fd2ffc1cbf51a75884369ec9253f47ae2fdba83c

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

LOG: [clang] Reject incomplete types in `__is_layout_compatible()` (#87869)

This is a follow-up to #81506. As discussed in #87737, we're rejecting
incomplete types, save for exceptions listed in the C++ standard (`void`
and arrays of unknown bound). Note that arrays of unknown bound of
incomplete types are accepted.

Since we're happy with the current behavior of this intrinsic for
flexible array members
(https://github.com/llvm/llvm-project/pull/87737#discussion_r1553652570),
I added a couple of tests for that as well.

Added: 


Modified: 
clang/lib/Sema/SemaExprCXX.cpp
clang/test/SemaCXX/type-traits.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index cfb5c6b6f28337..901c3c4d00cfb4 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -6025,6 +6025,11 @@ static bool EvaluateBinaryTypeTrait(Sema , 
TypeTrait BTT, QualType LhsT,
 return false;
   }
   case BTT_IsLayoutCompatible: {
+if (!LhsT->isVoidType() && !LhsT->isIncompleteArrayType())
+  Self.RequireCompleteType(KeyLoc, LhsT, diag::err_incomplete_type);
+if (!RhsT->isVoidType() && !RhsT->isIncompleteArrayType())
+  Self.RequireCompleteType(KeyLoc, RhsT, diag::err_incomplete_type);
+
 if (LhsT->isVariableArrayType() || RhsT->isVariableArrayType())
   Self.Diag(KeyLoc, diag::err_vla_unsupported)
   << 1 << tok::kw___is_layout_compatible;

diff  --git a/clang/test/SemaCXX/type-traits.cpp 
b/clang/test/SemaCXX/type-traits.cpp
index e99ad11666e54c..e29763714341e7 100644
--- a/clang/test/SemaCXX/type-traits.cpp
+++ b/clang/test/SemaCXX/type-traits.cpp
@@ -1622,7 +1622,7 @@ enum class EnumClassLayout {};
 enum EnumForward : int;
 enum class EnumClassForward;
 
-struct CStructIncomplete;
+struct CStructIncomplete; // #CStructIncomplete
 
 struct CStructNested {
   int a;
@@ -1719,6 +1719,20 @@ struct StructWithAnonUnion3 {
   } u;
 };
 
+struct CStructWithArrayAtTheEnd {
+  int a;
+  int b[4];
+};
+
+struct CStructWithFMA {
+  int c;
+  int d[];
+};
+
+struct CStructWithFMA2 {
+  int e;
+  int f[];
+};
 
 void is_layout_compatible(int n)
 {
@@ -1800,15 +1814,28 @@ void is_layout_compatible(int n)
   static_assert(__is_layout_compatible(EnumLayout, EnumClassLayout));
   static_assert(__is_layout_compatible(EnumForward, EnumForward));
   static_assert(__is_layout_compatible(EnumForward, EnumClassForward));
-  // Layout compatibility for enums might be relaxed in the future. See 
https://github.com/cplusplus/CWG/issues/39#issuecomment-1184791364
+  static_assert(__is_layout_compatible(CStructIncomplete, CStructIncomplete));
+  // expected-error@-1 {{incomplete type 'CStructIncomplete' where a complete 
type is required}}
+  //   expected-note@#CStructIncomplete {{forward declaration of 
'CStructIncomplete'}}
+  // expected-error@-3 {{incomplete type 'CStructIncomplete' where a complete 
type is required}}
+  //   expected-note@#CStructIncomplete {{forward declaration of 
'CStructIncomplete'}}
+  static_assert(!__is_layout_compatible(CStruct, CStructIncomplete));
+  // expected-error@-1 {{incomplete type 'CStructIncomplete' where a complete 
type is required}}
+  //   expected-note@#CStructIncomplete {{forward declaration of 
'CStructIncomplete'}}
+  static_assert(__is_layout_compatible(CStructIncomplete[2], 
CStructIncomplete[2]));
+  // expected-error@-1 {{incomplete type 'CStructIncomplete[2]' where a 
complete type is required}}
+  //   expected-note@#CStructIncomplete {{forward declaration of 
'CStructIncomplete'}}
+  // expected-error@-3 {{incomplete type 'CStructIncomplete[2]' where a 
complete type is required}}
+  //   expected-note@#CStructIncomplete {{forward declaration of 
'CStructIncomplete'}}
+  static_assert(__is_layout_compatible(CStructIncomplete[], 
CStructIncomplete[]));
+  static_assert(!__is_layout_compatible(CStructWithArrayAtTheEnd, 
CStructWithFMA));
+  static_assert(__is_layout_compatible(CStructWithFMA, CStructWithFMA));
+  static_assert(__is_layout_compatible(CStructWithFMA, CStructWithFMA2));
+  // Layout compatibility rules for enums might be relaxed in the future. See 
https://github.com/cplusplus/CWG/issues/39#issuecomment-1184791364
   static_assert(!__is_layout_compatible(EnumLayout, int));
   static_assert(!__is_layout_compatible(EnumClassLayout, int));
   static_assert(!__is_layout_compatible(EnumForward, int));
   static_assert(!__is_layout_compatible(EnumClassForward, int));
-  // FIXME: the following should be rejected (array of unknown bound and void 
are the only allowed incomplete types)
-  

[clang] 125c9cf - [clang] Add test for CWG593 (#87752)

2024-04-08 Thread via cfe-commits

Author: Vlad Serebrennikov
Date: 2024-04-08T22:36:41+04:00
New Revision: 125c9cf1b2f5d1b33884ddcd33ce983b2e927d2f

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

LOG: [clang] Add test for CWG593 (#87752)

[CWG593](https://cplusplus.github.io/CWG/issues/593.html) "Falling off
the end of a destructor's function-try-block handler". As usual with CWG
issues resolved as NAD, we test for status-quo confirmed by CWG.

Added: 
clang/test/CXX/drs/dr593.cpp

Modified: 
clang/test/CXX/drs/dr5xx.cpp
clang/www/cxx_dr_status.html

Removed: 




diff  --git a/clang/test/CXX/drs/dr593.cpp b/clang/test/CXX/drs/dr593.cpp
new file mode 100644
index 00..4998af966ebb90
--- /dev/null
+++ b/clang/test/CXX/drs/dr593.cpp
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -std=c++98 %s -triple x86_64-linux-gnu -emit-llvm -o - 
-fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s 
--check-prefixes CHECK
+// RUN: %clang_cc1 -std=c++11 %s -triple x86_64-linux-gnu -emit-llvm -o - 
-fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s 
--check-prefixes CHECK
+// RUN: %clang_cc1 -std=c++14 %s -triple x86_64-linux-gnu -emit-llvm -o - 
-fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s 
--check-prefixes CHECK
+// RUN: %clang_cc1 -std=c++17 %s -triple x86_64-linux-gnu -emit-llvm -o - 
-fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s 
--check-prefixes CHECK
+// RUN: %clang_cc1 -std=c++20 %s -triple x86_64-linux-gnu -emit-llvm -o - 
-fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s 
--check-prefixes CHECK
+// RUN: %clang_cc1 -std=c++23 %s -triple x86_64-linux-gnu -emit-llvm -o - 
-fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s 
--check-prefixes CHECK
+// RUN: %clang_cc1 -std=c++2c %s -triple x86_64-linux-gnu -emit-llvm -o - 
-fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s 
--check-prefixes CHECK
+
+#if __cplusplus == 199711L
+#define NOTHROW throw()
+#else
+#define NOTHROW noexcept(true)
+#endif
+
+namespace dr593 { // dr593: 2.8
+
+void f();
+void fence() NOTHROW;
+
+struct A {
+  ~A() try {
+f();
+  } catch (...) {
+fence();
+  }
+};
+
+void g() {
+  A();
+}
+
+} // namespace dr593
+
+// CHECK:  call void @dr593::fence()()
+// CHECK-NEXT: invoke void @__cxa_rethrow()

diff  --git a/clang/test/CXX/drs/dr5xx.cpp b/clang/test/CXX/drs/dr5xx.cpp
index 426b368b390ae6..0ea306a041167b 100644
--- a/clang/test/CXX/drs/dr5xx.cpp
+++ b/clang/test/CXX/drs/dr5xx.cpp
@@ -1098,7 +1098,7 @@ namespace dr591 { // dr591: no
 }
 
 // dr592: na
-// dr593 needs an IRGen test.
+// dr593 is in dr593.cpp
 // dr594: na
 
 namespace dr595 { // dr595: dup 1330

diff  --git a/clang/www/cxx_dr_status.html b/clang/www/cxx_dr_status.html
index df0ab414d9a0e6..6daa5ad2d1316d 100755
--- a/clang/www/cxx_dr_status.html
+++ b/clang/www/cxx_dr_status.html
@@ -3600,7 +3600,7 @@ C++ defect report implementation 
status
 https://cplusplus.github.io/CWG/issues/593.html;>593
 NAD
 Falling off the end of a destructor's function-try-block 
handler
-Unknown
+Clang 2.8
   
   
 https://cplusplus.github.io/CWG/issues/594.html;>594



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


[clang] [clang] Add test for CWG593 (PR #87752)

2024-04-08 Thread Vlad Serebrennikov via cfe-commits

https://github.com/Endilll closed 
https://github.com/llvm/llvm-project/pull/87752
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] Fix "[clang][UBSan] Add implicit conversion check for bitfields" (PR #87761)

2024-04-08 Thread Vitaly Buka via cfe-commits

vitalybuka wrote:

I'll land after presubmit checks


https://github.com/llvm/llvm-project/pull/87761
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] Fix "[clang][UBSan] Add implicit conversion check for bitfields" (PR #87761)

2024-04-08 Thread Vitaly Buka via cfe-commits

https://github.com/vitalybuka approved this pull request.


https://github.com/llvm/llvm-project/pull/87761
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Extend lifetime of temporaries in mem-default-init for P2718R0 (PR #86960)

2024-04-08 Thread Eli Friedman via cfe-commits


@@ -1230,11 +1230,26 @@ CodeGenFunction::EmitCXXForRangeStmt(const 
CXXForRangeStmt ,
   JumpDest LoopExit = getJumpDestInCurrentScope("for.end");
 
   LexicalScope ForScope(*this, S.getSourceRange());
+  const DeclStmt *RangeDS = cast(S.getRangeStmt());
+  const VarDecl *RangeVar = cast(RangeDS->getSingleDecl());
+  if (getLangOpts().CPlusPlus23)

efriedma-quic wrote:

`for (auto & : B{A()}) {}` currently works correctly, as far as I know (where 
B is a class with a member of type `const A&`).  And if I'm understanding 
correctly, `for (auto & : B{}) {}` is supposed to be semantically equivalent. 
 If the AST is significantly different, you should be addressing that in Sema, 
I think.

https://github.com/llvm/llvm-project/pull/86960
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] Fix "[clang][UBSan] Add implicit conversion check for bitfields" (PR #87761)

2024-04-08 Thread Vitaly Buka via cfe-commits

https://github.com/vitalybuka commented:

Fail i386
```
  UBSan-AddressSanitizer-i386 :: 
TestCases/ImplicitConversion/bitfield-conversion.c
  UBSan-Standalone-i386 :: TestCases/ImplicitConversion/bitfield-conversion.c
```

https://github.com/llvm/llvm-project/pull/87761
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Add handling of the `-nostdlibinc` option to ccc-analyzer (PR #88017)

2024-04-08 Thread Gábor Horváth via cfe-commits

https://github.com/Xazax-hun approved this pull request.


https://github.com/llvm/llvm-project/pull/88017
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Add test for CWG593 (PR #87752)

2024-04-08 Thread Erich Keane via cfe-commits

https://github.com/erichkeane approved this pull request.

I hte this behavior, but it is to standard.  

https://github.com/llvm/llvm-project/pull/87752
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][dataflow] Propagate locations from result objects to initializers. (PR #87320)

2024-04-08 Thread Gábor Horváth via cfe-commits


@@ -385,6 +390,187 @@ getFieldsGlobalsAndFuncs(const Stmt , FieldSet ,
   }
 }
 
+namespace {
+
+// Visitor that builds a map from record prvalues to result objects.
+// This traverses the body of the function to be analyzed; for each result
+// object that it encounters, it propagates the storage location of the result
+// object to all record prvalues that can initialize it.
+class ResultObjectVisitor : public RecursiveASTVisitor {
+public:
+  // `ResultObjectMap` will be filled with a map from record prvalues to result
+  // object. If the function being analyzed returns a record by value,
+  // `LocForRecordReturnVal` is the location to which this record should be
+  // written; otherwise, it is null.
+  explicit ResultObjectVisitor(
+  llvm::DenseMap ,
+  RecordStorageLocation *LocForRecordReturnVal,
+  DataflowAnalysisContext )
+  : ResultObjectMap(ResultObjectMap),
+LocForRecordReturnVal(LocForRecordReturnVal), DACtx(DACtx) {}
+
+  bool shouldVisitImplicitCode() { return true; }
+
+  bool shouldVisitLambdaBody() const { return false; }
+
+  // Traverse all member and base initializers of `Ctor`. This function is not
+  // called by `RecursiveASTVisitor`; it should be called manually if we are
+  // analyzing a constructor. `ThisPointeeLoc` is the storage location that
+  // `this` points to.
+  void TraverseConstructorInits(const CXXConstructorDecl *Ctor,
+RecordStorageLocation *ThisPointeeLoc) {
+assert(ThisPointeeLoc != nullptr);
+for (const CXXCtorInitializer *Init : Ctor->inits()) {
+  Expr *InitExpr = Init->getInit();
+  if (FieldDecl *Field = Init->getMember();
+  Field != nullptr && Field->getType()->isRecordType()) {
+PropagateResultObject(InitExpr, cast(
+ThisPointeeLoc->getChild(*Field)));
+  } else if (Init->getBaseClass()) {
+PropagateResultObject(InitExpr, ThisPointeeLoc);
+  }
+
+  // Ensure that any result objects within `InitExpr` (e.g. temporaries)
+  // are also propagated to the prvalues that initialize them.
+  TraverseStmt(InitExpr);
+
+  // If this is a `CXXDefaultInitExpr`, also propagate any result objects
+  // within the default expression.
+  if (auto *DefaultInit = dyn_cast(InitExpr))
+TraverseStmt(DefaultInit->getExpr());
+}
+  }
+
+  bool TraverseBindingDecl(BindingDecl *BD) {
+// `RecursiveASTVisitor` doesn't traverse holding variables for
+// `BindingDecl`s by itself, so we need to tell it to.
+if (VarDecl *HoldingVar = BD->getHoldingVar())
+  TraverseDecl(HoldingVar);
+return RecursiveASTVisitor::TraverseBindingDecl(BD);
+  }
+
+  bool VisitVarDecl(VarDecl *VD) {
+if (VD->getType()->isRecordType() && VD->hasInit())
+  PropagateResultObject(
+  VD->getInit(),
+  (DACtx.getStableStorageLocation(*VD)));
+return true;
+  }
+
+  bool VisitMaterializeTemporaryExpr(MaterializeTemporaryExpr *MTE) {
+if (MTE->getType()->isRecordType())
+  PropagateResultObject(
+  MTE->getSubExpr(),
+  (DACtx.getStableStorageLocation(*MTE)));
+return true;
+  }
+
+  bool VisitReturnStmt(ReturnStmt *Return) {
+Expr *RetValue = Return->getRetValue();
+if (RetValue != nullptr && RetValue->getType()->isRecordType() &&
+RetValue->isPRValue())
+  PropagateResultObject(RetValue, LocForRecordReturnVal);
+return true;
+  }
+
+  bool VisitExpr(Expr *E) {
+// Clang's AST can have record-type prvalues without a result object -- for
+// example as full-expressions contained in a compound statement or as
+// arguments of call expressions. We notice this if we get here and a
+// storage location has not yet been associated with `E`. In this case,
+// treat this as if it was a `MaterializeTemporaryExpr`.
+if (E->isPRValue() && E->getType()->isRecordType() &&
+!ResultObjectMap.contains(E))
+  PropagateResultObject(
+  E, (DACtx.getStableStorageLocation(*E)));
+return true;
+  }
+
+  // Assigns `Loc` as the result object location of `E`, then propagates the
+  // location to all lower-level prvalues that initialize the same object as
+  // `E` (or one of its base classes or member variables).
+  void PropagateResultObject(Expr *E, RecordStorageLocation *Loc) {
+if (!E->isPRValue() || !E->getType()->isRecordType()) {
+  assert(false);
+  // Ensure we don't propagate the result object if we hit this in a
+  // release build.
+  return;
+}
+
+ResultObjectMap[E] = Loc;
+
+// The following AST node kinds are "original initializers": They are the
+// lowest-level AST node that initializes a given object, and nothing
+// below them can initialize the same object (or part of it).
+if (isa(E) || isa(E) || isa(E) ||
+isa(E) || isa(E) ||
+isa(E)) {
+  return;
+}
+
+if (auto *InitList = dyn_cast(E)) {
+ 

[clang] [clang][dataflow] Propagate locations from result objects to initializers. (PR #87320)

2024-04-08 Thread Gábor Horváth via cfe-commits


@@ -556,6 +763,10 @@ void Environment::pushCallInternal(const FunctionDecl 
*FuncDecl,
 const VarDecl *Param = *ParamIt;
 setStorageLocation(*Param, createObject(*Param, Args[ArgIndex]));
   }
+
+  ResultObjectMap = std::make_shared(

Xazax-hun wrote:

I wonder if this is something that we might want to get cached. That being 
said, we'd probably want to benchmark first. 

https://github.com/llvm/llvm-project/pull/87320
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][dataflow] Propagate locations from result objects to initializers. (PR #87320)

2024-04-08 Thread Gábor Horváth via cfe-commits

https://github.com/Xazax-hun commented:

I know it is not exactly what we need, but I found 
`Expr::skipRValueSubobjectAdjustments` in the compiler. I think it might be a 
good idea to take a look just in case there is something we forgot to cover, 
and maybe in the future we could look for factoring out some common code. 

https://github.com/llvm/llvm-project/pull/87320
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][dataflow] Propagate locations from result objects to initializers. (PR #87320)

2024-04-08 Thread Gábor Horváth via cfe-commits


@@ -385,6 +390,187 @@ getFieldsGlobalsAndFuncs(const Stmt , FieldSet ,
   }
 }
 
+namespace {
+
+// Visitor that builds a map from record prvalues to result objects.
+// This traverses the body of the function to be analyzed; for each result
+// object that it encounters, it propagates the storage location of the result
+// object to all record prvalues that can initialize it.
+class ResultObjectVisitor : public RecursiveASTVisitor {
+public:
+  // `ResultObjectMap` will be filled with a map from record prvalues to result
+  // object. If the function being analyzed returns a record by value,
+  // `LocForRecordReturnVal` is the location to which this record should be
+  // written; otherwise, it is null.
+  explicit ResultObjectVisitor(
+  llvm::DenseMap ,
+  RecordStorageLocation *LocForRecordReturnVal,
+  DataflowAnalysisContext )
+  : ResultObjectMap(ResultObjectMap),
+LocForRecordReturnVal(LocForRecordReturnVal), DACtx(DACtx) {}
+
+  bool shouldVisitImplicitCode() { return true; }
+
+  bool shouldVisitLambdaBody() const { return false; }
+
+  // Traverse all member and base initializers of `Ctor`. This function is not
+  // called by `RecursiveASTVisitor`; it should be called manually if we are
+  // analyzing a constructor. `ThisPointeeLoc` is the storage location that
+  // `this` points to.
+  void TraverseConstructorInits(const CXXConstructorDecl *Ctor,
+RecordStorageLocation *ThisPointeeLoc) {
+assert(ThisPointeeLoc != nullptr);
+for (const CXXCtorInitializer *Init : Ctor->inits()) {
+  Expr *InitExpr = Init->getInit();
+  if (FieldDecl *Field = Init->getMember();
+  Field != nullptr && Field->getType()->isRecordType()) {
+PropagateResultObject(InitExpr, cast(
+ThisPointeeLoc->getChild(*Field)));
+  } else if (Init->getBaseClass()) {
+PropagateResultObject(InitExpr, ThisPointeeLoc);
+  }
+
+  // Ensure that any result objects within `InitExpr` (e.g. temporaries)
+  // are also propagated to the prvalues that initialize them.
+  TraverseStmt(InitExpr);
+
+  // If this is a `CXXDefaultInitExpr`, also propagate any result objects
+  // within the default expression.
+  if (auto *DefaultInit = dyn_cast(InitExpr))
+TraverseStmt(DefaultInit->getExpr());
+}
+  }
+
+  bool TraverseBindingDecl(BindingDecl *BD) {
+// `RecursiveASTVisitor` doesn't traverse holding variables for
+// `BindingDecl`s by itself, so we need to tell it to.
+if (VarDecl *HoldingVar = BD->getHoldingVar())
+  TraverseDecl(HoldingVar);
+return RecursiveASTVisitor::TraverseBindingDecl(BD);
+  }
+
+  bool VisitVarDecl(VarDecl *VD) {
+if (VD->getType()->isRecordType() && VD->hasInit())
+  PropagateResultObject(
+  VD->getInit(),
+  (DACtx.getStableStorageLocation(*VD)));
+return true;
+  }
+
+  bool VisitMaterializeTemporaryExpr(MaterializeTemporaryExpr *MTE) {
+if (MTE->getType()->isRecordType())
+  PropagateResultObject(
+  MTE->getSubExpr(),
+  (DACtx.getStableStorageLocation(*MTE)));
+return true;
+  }
+
+  bool VisitReturnStmt(ReturnStmt *Return) {
+Expr *RetValue = Return->getRetValue();
+if (RetValue != nullptr && RetValue->getType()->isRecordType() &&
+RetValue->isPRValue())
+  PropagateResultObject(RetValue, LocForRecordReturnVal);
+return true;
+  }
+
+  bool VisitExpr(Expr *E) {
+// Clang's AST can have record-type prvalues without a result object -- for
+// example as full-expressions contained in a compound statement or as
+// arguments of call expressions. We notice this if we get here and a
+// storage location has not yet been associated with `E`. In this case,
+// treat this as if it was a `MaterializeTemporaryExpr`.
+if (E->isPRValue() && E->getType()->isRecordType() &&
+!ResultObjectMap.contains(E))
+  PropagateResultObject(
+  E, (DACtx.getStableStorageLocation(*E)));
+return true;
+  }
+
+  // Assigns `Loc` as the result object location of `E`, then propagates the
+  // location to all lower-level prvalues that initialize the same object as
+  // `E` (or one of its base classes or member variables).
+  void PropagateResultObject(Expr *E, RecordStorageLocation *Loc) {
+if (!E->isPRValue() || !E->getType()->isRecordType()) {
+  assert(false);
+  // Ensure we don't propagate the result object if we hit this in a
+  // release build.
+  return;
+}
+
+ResultObjectMap[E] = Loc;
+
+// The following AST node kinds are "original initializers": They are the
+// lowest-level AST node that initializes a given object, and nothing
+// below them can initialize the same object (or part of it).
+if (isa(E) || isa(E) || isa(E) ||
+isa(E) || isa(E) ||
+isa(E)) {
+  return;
+}
+
+if (auto *InitList = dyn_cast(E)) {
+ 

[clang] [clang][dataflow] Propagate locations from result objects to initializers. (PR #87320)

2024-04-08 Thread Gábor Horváth via cfe-commits

https://github.com/Xazax-hun edited 
https://github.com/llvm/llvm-project/pull/87320
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Add CodeGen tests for CWG 6xx issues (PR #87876)

2024-04-08 Thread Vlad Serebrennikov via cfe-commits

https://github.com/Endilll closed 
https://github.com/llvm/llvm-project/pull/87876
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 93e2a9a - [clang] Add CodeGen tests for CWG 6xx issues (#87876)

2024-04-08 Thread via cfe-commits

Author: Vlad Serebrennikov
Date: 2024-04-08T21:55:53+04:00
New Revision: 93e2a9ab1b28e1b89d30b89dc2d5bb6f8cc66dc9

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

LOG: [clang] Add CodeGen tests for CWG 6xx issues (#87876)

This patch covers
[CWG605](https://cplusplus.github.io/CWG/issues/605.html) "Linkage of
explicit specializations",
[CWG650](https://cplusplus.github.io/CWG/issues/650.html) "Order of
destruction for temporaries bound to the returned value of a function",
[CWG653](https://cplusplus.github.io/CWG/issues/653.html) "Copy
assignment of unions",
[CWG658](https://cplusplus.github.io/CWG/issues/658.html) "Defining
`reinterpret_cast` for pointer types",
[CWG661](https://cplusplus.github.io/CWG/issues/661.html) "Semantics of
arithmetic comparisons",
[CWG672](https://cplusplus.github.io/CWG/issues/672.html) "Sequencing of
initialization in _new-expression_s".

[CWG624](https://cplusplus.github.io/CWG/issues/624.html) "Overflow in
calculating size of allocation" and
[CWG668](https://cplusplus.github.io/CWG/issues/668.html) "Throwing an
exception from the destructor of a local static object" are marked as
requiring libc++abi tests.

Added: 
clang/test/CXX/drs/dr605.cpp
clang/test/CXX/drs/dr650.cpp
clang/test/CXX/drs/dr653.cpp
clang/test/CXX/drs/dr658.cpp
clang/test/CXX/drs/dr661.cpp
clang/test/CXX/drs/dr672.cpp

Modified: 
clang/test/CXX/drs/dr6xx.cpp
clang/www/cxx_dr_status.html

Removed: 




diff  --git a/clang/test/CXX/drs/dr605.cpp b/clang/test/CXX/drs/dr605.cpp
new file mode 100644
index 00..6c212d8dabc06c
--- /dev/null
+++ b/clang/test/CXX/drs/dr605.cpp
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -std=c++98 %s -triple x86_64-linux-gnu -emit-llvm -o - 
-fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s 
--check-prefixes CHECK
+// RUN: %clang_cc1 -std=c++11 %s -triple x86_64-linux-gnu -emit-llvm -o - 
-fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s 
--check-prefixes CHECK
+// RUN: %clang_cc1 -std=c++14 %s -triple x86_64-linux-gnu -emit-llvm -o - 
-fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s 
--check-prefixes CHECK
+// RUN: %clang_cc1 -std=c++17 %s -triple x86_64-linux-gnu -emit-llvm -o - 
-fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s 
--check-prefixes CHECK
+// RUN: %clang_cc1 -std=c++20 %s -triple x86_64-linux-gnu -emit-llvm -o - 
-fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s 
--check-prefixes CHECK
+// RUN: %clang_cc1 -std=c++23 %s -triple x86_64-linux-gnu -emit-llvm -o - 
-fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s 
--check-prefixes CHECK
+// RUN: %clang_cc1 -std=c++2c %s -triple x86_64-linux-gnu -emit-llvm -o - 
-fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s 
--check-prefixes CHECK
+
+namespace dr605 { // dr605: 2.7
+
+template 
+static T f(T t) {}
+
+template <>
+int f(int t) {}
+
+void g(int a) {
+  f(a);
+}
+
+} // namespace dr605
+
+// CHECK: define internal {{.*}} i32 @int dr605::f(int)

diff  --git a/clang/test/CXX/drs/dr650.cpp b/clang/test/CXX/drs/dr650.cpp
new file mode 100644
index 00..715b4fdf04a7f0
--- /dev/null
+++ b/clang/test/CXX/drs/dr650.cpp
@@ -0,0 +1,40 @@
+// RUN: %clang_cc1 -std=c++98 %s -triple x86_64-linux-gnu -emit-llvm -o - 
-fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s 
--check-prefixes CHECK
+// RUN: %clang_cc1 -std=c++11 %s -triple x86_64-linux-gnu -emit-llvm -o - 
-fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s 
--check-prefixes CHECK
+// RUN: %clang_cc1 -std=c++14 %s -triple x86_64-linux-gnu -emit-llvm -o - 
-fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s 
--check-prefixes CHECK
+// RUN: %clang_cc1 -std=c++17 %s -triple x86_64-linux-gnu -emit-llvm -o - 
-fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s 
--check-prefixes CHECK
+// RUN: %clang_cc1 -std=c++20 %s -triple x86_64-linux-gnu -emit-llvm -o - 
-fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s 
--check-prefixes CHECK
+// RUN: %clang_cc1 -std=c++23 %s -triple x86_64-linux-gnu -emit-llvm -o - 
-fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s 
--check-prefixes CHECK
+// RUN: %clang_cc1 -std=c++2c %s -triple x86_64-linux-gnu -emit-llvm -o - 
-fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s 
--check-prefixes CHECK
+
+#if __cplusplus == 199711L
+#define NOTHROW throw()
+#else
+#define NOTHROW noexcept(true)
+#endif
+
+namespace dr650 { // dr650: 2.8
+
+struct Q {
+  ~Q() NOTHROW;
+};
+
+struct R {

[clang-tools-extra] [clang-tidy] Ignore non-forwarded arguments if they are unnamed (PR #87832)

2024-04-08 Thread Danny Mösch via cfe-commits

https://github.com/SimplyDanny updated 
https://github.com/llvm/llvm-project/pull/87832

From 229e1cb251139a32fc2e944b8d0f4d402987820f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Danny=20M=C3=B6sch?= 
Date: Fri, 5 Apr 2024 23:41:50 +0200
Subject: [PATCH 1/5] [clang-tidy] Ignore non-forwarded arguments if they are
 unnamed

---
 .../cppcoreguidelines/MissingStdForwardCheck.cpp  | 15 +--
 clang-tools-extra/docs/ReleaseNotes.rst   |  4 
 .../cppcoreguidelines/missing-std-forward.cpp |  3 +++
 3 files changed, 16 insertions(+), 6 deletions(-)

diff --git 
a/clang-tools-extra/clang-tidy/cppcoreguidelines/MissingStdForwardCheck.cpp 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/MissingStdForwardCheck.cpp
index 87fd8adf997082..6817bcb24c8112 100644
--- a/clang-tools-extra/clang-tidy/cppcoreguidelines/MissingStdForwardCheck.cpp
+++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/MissingStdForwardCheck.cpp
@@ -79,6 +79,8 @@ AST_MATCHER_P(LambdaExpr, hasCaptureDefaultKind, 
LambdaCaptureDefault, Kind) {
   return Node.getCaptureDefault() == Kind;
 }
 
+AST_MATCHER(ParmVarDecl, hasAnyName) { return !Node.getName().empty(); }
+
 } // namespace
 
 void MissingStdForwardCheck::registerMatchers(MatchFinder *Finder) {
@@ -125,12 +127,13 @@ void MissingStdForwardCheck::registerMatchers(MatchFinder 
*Finder) {
hasAncestor(expr(hasUnevaluatedContext());
 
   Finder->addMatcher(
-  parmVarDecl(parmVarDecl().bind("param"), isTemplateTypeParameter(),
-  hasAncestor(functionDecl().bind("func")),
-  hasAncestor(functionDecl(
-  isDefinition(), equalsBoundNode("func"), ToParam,
-  unless(anyOf(isDeleted(), hasDescendant(std::move(
-ForwardCallMatcher))),
+  parmVarDecl(
+  parmVarDecl().bind("param"), hasAnyName(), isTemplateTypeParameter(),
+  hasAncestor(functionDecl().bind("func")),
+  hasAncestor(functionDecl(
+  isDefinition(), equalsBoundNode("func"), ToParam,
+  unless(anyOf(isDeleted(),
+   hasDescendant(std::move(ForwardCallMatcher))),
   this);
 }
 
diff --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index bdd53f06e7e2f8..51143bfce927dd 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -182,6 +182,10 @@ Changes in existing checks
   giving false positives for deleted functions and fix false negative when some
   parameters are forwarded, but other aren't.
 
+- Improved :doc:`cppcoreguidelines-missing-std-forward
+  ` check by ignoring
+  parameters without a name (unused arguments).
+
 - Improved :doc:`cppcoreguidelines-owning-memory
   ` check to properly handle
   return type in lambdas and in nested functions.
diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/missing-std-forward.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/missing-std-forward.cpp
index 9a50eabf619bd5..c435a0e023ba0b 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/missing-std-forward.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/missing-std-forward.cpp
@@ -198,3 +198,6 @@ struct S {
 };
 
 } // namespace deleted_functions
+
+template
+void unused_argument(F&&) {}

From 563d454a3843e94bc7a1ef466c672aff4d9f24c6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Danny=20M=C3=B6sch?= 
Date: Sat, 6 Apr 2024 16:51:36 +0200
Subject: [PATCH 2/5] Merge entries in release notes

---
 clang-tools-extra/docs/ReleaseNotes.rst | 9 +++--
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index 51143bfce927dd..a7193e90c38da2 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -179,12 +179,9 @@ Changes in existing checks
 
 - Improved :doc:`cppcoreguidelines-missing-std-forward
   ` check by no longer
-  giving false positives for deleted functions and fix false negative when some
-  parameters are forwarded, but other aren't.
-
-- Improved :doc:`cppcoreguidelines-missing-std-forward
-  ` check by ignoring
-  parameters without a name (unused arguments).
+  giving false positives for deleted functions, by fixing false negatives when 
only
+  a few parameters are forwarded and by ignoring parameters without a name 
(unused
+  arguments).
 
 - Improved :doc:`cppcoreguidelines-owning-memory
   ` check to properly handle

From a0f8a9074e2b33d3dfcf92179d79b8c907dde7b8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Danny=20M=C3=B6sch?= 
Date: Sun, 7 Apr 2024 13:49:41 +0200
Subject: [PATCH 3/5] Check identifier instead of name

---
 .../cppcoreguidelines/MissingStdForwardCheck.cpp   | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git 

[clang] [PAC][clang] Define `PointerAuthQualifier` and `PointerAuthenticationMode` (PR #84384)

2024-04-08 Thread John McCall via cfe-commits

rjmccall wrote:

It'll be tested in a follow-up commit which actually adds parsing and Sema 
support for these as qualifiers.  That should be sufficient rather than adding 
a whole unit-test apparatus.  Daniil is just trying to avoid landing this in a 
single massive commit.

https://github.com/llvm/llvm-project/pull/84384
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Add CodeGen tests for CWG 6xx issues (PR #87876)

2024-04-08 Thread Erich Keane via cfe-commits


@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -std=c++98 %s -triple x86_64-linux-gnu -emit-llvm -o - 
-fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s 
--check-prefixes CHECK
+// RUN: %clang_cc1 -std=c++11 %s -triple x86_64-linux-gnu -emit-llvm -o - 
-fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s 
--check-prefixes CHECK
+// RUN: %clang_cc1 -std=c++14 %s -triple x86_64-linux-gnu -emit-llvm -o - 
-fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s 
--check-prefixes CHECK
+// RUN: %clang_cc1 -std=c++17 %s -triple x86_64-linux-gnu -emit-llvm -o - 
-fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s 
--check-prefixes CHECK
+// RUN: %clang_cc1 -std=c++20 %s -triple x86_64-linux-gnu -emit-llvm -o - 
-fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s 
--check-prefixes CHECK
+// RUN: %clang_cc1 -std=c++23 %s -triple x86_64-linux-gnu -emit-llvm -o - 
-fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s 
--check-prefixes CHECK
+// RUN: %clang_cc1 -std=c++2c %s -triple x86_64-linux-gnu -emit-llvm -o - 
-fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s 
--check-prefixes CHECK
+
+namespace dr653 { // dr653: 2.7
+
+union U {
+  int a;
+  float b;
+};
+
+void f(U u) {
+  U v;
+  v = u;

erichkeane wrote:

NVM on this.

https://github.com/llvm/llvm-project/pull/87876
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Add CodeGen tests for CWG 6xx issues (PR #87876)

2024-04-08 Thread Erich Keane via cfe-commits

https://github.com/erichkeane approved this pull request.


https://github.com/llvm/llvm-project/pull/87876
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Add CodeGen tests for CWG 6xx issues (PR #87876)

2024-04-08 Thread Erich Keane via cfe-commits

https://github.com/erichkeane edited 
https://github.com/llvm/llvm-project/pull/87876
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [mlir] [OpenMP] Migrate GPU Reductions CodeGen from Clang to OMPIRBuilder (PR #80343)

2024-04-08 Thread Akash Banerjee via cfe-commits

TIFitis wrote:

@jsjodin @jdoerfert Hi, this patch has been sitting for a while now. Would be 
great to get it reviewed and accepted. Thanks.

https://github.com/llvm/llvm-project/pull/80343
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] Revert "[AArch64] Add support for -ffixed-x30" (PR #88019)

2024-04-08 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-backend-aarch64

Author: Eli Friedman (efriedma-quic)


Changes

This reverts commit e770153865c53c4fd72a68f23acff33c24e42a08.

This wasn't reviewed, and the functionality in question was intentionally 
rejected the last time it was discussed in https://reviews.llvm.org/D56305 .

---
Full diff: https://github.com/llvm/llvm-project/pull/88019.diff


4 Files Affected:

- (modified) clang/lib/Driver/ToolChains/Arch/AArch64.cpp (-3) 
- (modified) clang/test/Driver/aarch64-fixed-x-register.c (-4) 
- (modified) llvm/lib/Target/AArch64/AArch64.td (+1-1) 
- (modified) llvm/test/CodeGen/AArch64/arm64-platform-reg.ll (+1-6) 


``diff
diff --git a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp 
b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
index 3e6e29584df3ac..2cd2b35ee51bc6 100644
--- a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
@@ -402,9 +402,6 @@ void aarch64::getAArch64TargetFeatures(const Driver ,
   if (Args.hasArg(options::OPT_ffixed_x28))
 Features.push_back("+reserve-x28");
 
-  if (Args.hasArg(options::OPT_ffixed_x30))
-Features.push_back("+reserve-x30");
-
   if (Args.hasArg(options::OPT_fcall_saved_x8))
 Features.push_back("+call-saved-x8");
 
diff --git a/clang/test/Driver/aarch64-fixed-x-register.c 
b/clang/test/Driver/aarch64-fixed-x-register.c
index 29024fde412543..7fc3e3e61105df 100644
--- a/clang/test/Driver/aarch64-fixed-x-register.c
+++ b/clang/test/Driver/aarch64-fixed-x-register.c
@@ -94,10 +94,6 @@
 // RUN: FileCheck --check-prefix=CHECK-FIXED-X28 < %t %s
 // CHECK-FIXED-X28: "-target-feature" "+reserve-x28"
 
-// RUN: %clang --target=aarch64-none-gnu -ffixed-x30 -### %s 2> %t
-// RUN: FileCheck --check-prefix=CHECK-FIXED-X30 < %t %s
-// CHECK-FIXED-X30: "-target-feature" "+reserve-x30"
-
 // Test multiple of reserve-x# options together.
 // RUN: %clang --target=aarch64-none-gnu \
 // RUN: -ffixed-x1 \
diff --git a/llvm/lib/Target/AArch64/AArch64.td 
b/llvm/lib/Target/AArch64/AArch64.td
index 3af427d526f80c..741c97a3dc009b 100644
--- a/llvm/lib/Target/AArch64/AArch64.td
+++ b/llvm/lib/Target/AArch64/AArch64.td
@@ -212,7 +212,7 @@ def FeatureStrictAlign : SubtargetFeature<"strict-align",
   "Disallow all unaligned memory "
   "access">;
 
-foreach i = {1-7,9-15,18,20-28,30} in
+foreach i = {1-7,9-15,18,20-28} in
 def FeatureReserveX#i : SubtargetFeature<"reserve-x"#i, 
"ReserveXRegister["#i#"]", "true",
  "Reserve X"#i#", making it 
unavailable "
  "as a GPR">;
diff --git a/llvm/test/CodeGen/AArch64/arm64-platform-reg.ll 
b/llvm/test/CodeGen/AArch64/arm64-platform-reg.ll
index c598306c2de301..3df2ef7aa59fc8 100644
--- a/llvm/test/CodeGen/AArch64/arm64-platform-reg.ll
+++ b/llvm/test/CodeGen/AArch64/arm64-platform-reg.ll
@@ -34,7 +34,6 @@
 ; RUN: llc -mtriple=arm64-linux-gnu -mattr=+reserve-x26 -o - %s | FileCheck %s 
--check-prefixes=CHECK-RESERVE,CHECK-RESERVE-X26
 ; RUN: llc -mtriple=arm64-linux-gnu -mattr=+reserve-x27 -o - %s | FileCheck %s 
--check-prefixes=CHECK-RESERVE,CHECK-RESERVE-X27
 ; RUN: llc -mtriple=arm64-linux-gnu -mattr=+reserve-x28 -o - %s | FileCheck %s 
--check-prefixes=CHECK-RESERVE,CHECK-RESERVE-X28
-; RUN: llc -mtriple=arm64-linux-gnu -mattr=+reserve-x30 -o - %s | FileCheck %s 
--check-prefixes=CHECK-RESERVE,CHECK-RESERVE-X30
 
 ; Test multiple of reserve-x# options together.
 ; RUN: llc -mtriple=arm64-linux-gnu \
@@ -73,7 +72,6 @@
 ; RUN: -mattr=+reserve-x26 \
 ; RUN: -mattr=+reserve-x27 \
 ; RUN: -mattr=+reserve-x28 \
-; RUN: -mattr=+reserve-x30 \
 ; RUN: -reserve-regs-for-regalloc=X8,X16,X17,X19 \
 ; RUN: -o - %s | FileCheck %s \
 ; RUN: --check-prefix=CHECK-RESERVE \
@@ -104,8 +102,7 @@
 ; RUN: --check-prefix=CHECK-RESERVE-X25 \
 ; RUN: --check-prefix=CHECK-RESERVE-X26 \
 ; RUN: --check-prefix=CHECK-RESERVE-X27 \
-; RUN: --check-prefix=CHECK-RESERVE-X28 \
-; RUN: --check-prefix=CHECK-RESERVE-X30
+; RUN: --check-prefix=CHECK-RESERVE-X28
 
 ; x18 is reserved as a platform register on Darwin but not on other
 ; systems. Create loads of register pressure and make sure this is respected.
@@ -152,7 +149,6 @@ define void @keep_live() {
 ; CHECK-RESERVE-X26-NOT: ldr x26
 ; CHECK-RESERVE-X27-NOT: ldr x27
 ; CHECK-RESERVE-X28-NOT: ldr x28
-; CHECK-RESERVE-X30-NOT: ldr x30
 ; CHECK-RESERVE: Spill
 ; CHECK-RESERVE-NOT: ldr fp
 ; CHECK-RESERVE-X1-NOT: ldr x1,
@@ -182,7 +178,6 @@ define void @keep_live() {
 ; CHECK-RESERVE-X26-NOT: ldr x26
 ; CHECK-RESERVE-X27-NOT: ldr x27
 ; CHECK-RESERVE-X28-NOT: ldr x28
-; CHECK-RESERVE-X30-NOT: ldr x30
 ; CHECK-RESERVE: ret
   ret void
 }

``




https://github.com/llvm/llvm-project/pull/88019
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] Revert "[AArch64] Add support for -ffixed-x30" (PR #88019)

2024-04-08 Thread Eli Friedman via cfe-commits

https://github.com/efriedma-quic created 
https://github.com/llvm/llvm-project/pull/88019

This reverts commit e770153865c53c4fd72a68f23acff33c24e42a08.

This wasn't reviewed, and the functionality in question was intentionally 
rejected the last time it was discussed in https://reviews.llvm.org/D56305 .

>From 0c22674600ec68918afe5eb30a4df0922a3d5e75 Mon Sep 17 00:00:00 2001
From: Eli Friedman 
Date: Mon, 8 Apr 2024 10:31:15 -0700
Subject: [PATCH] Revert "[AArch64] Add support for -ffixed-x30"

This reverts commit e770153865c53c4fd72a68f23acff33c24e42a08.

This wasn't reviewed, and the functionality in question was
intentionally rejected the last time it was discussed in
https://reviews.llvm.org/D56305 .
---
 clang/lib/Driver/ToolChains/Arch/AArch64.cpp| 3 ---
 clang/test/Driver/aarch64-fixed-x-register.c| 4 
 llvm/lib/Target/AArch64/AArch64.td  | 2 +-
 llvm/test/CodeGen/AArch64/arm64-platform-reg.ll | 7 +--
 4 files changed, 2 insertions(+), 14 deletions(-)

diff --git a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp 
b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
index 3e6e29584df3ac..2cd2b35ee51bc6 100644
--- a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
@@ -402,9 +402,6 @@ void aarch64::getAArch64TargetFeatures(const Driver ,
   if (Args.hasArg(options::OPT_ffixed_x28))
 Features.push_back("+reserve-x28");
 
-  if (Args.hasArg(options::OPT_ffixed_x30))
-Features.push_back("+reserve-x30");
-
   if (Args.hasArg(options::OPT_fcall_saved_x8))
 Features.push_back("+call-saved-x8");
 
diff --git a/clang/test/Driver/aarch64-fixed-x-register.c 
b/clang/test/Driver/aarch64-fixed-x-register.c
index 29024fde412543..7fc3e3e61105df 100644
--- a/clang/test/Driver/aarch64-fixed-x-register.c
+++ b/clang/test/Driver/aarch64-fixed-x-register.c
@@ -94,10 +94,6 @@
 // RUN: FileCheck --check-prefix=CHECK-FIXED-X28 < %t %s
 // CHECK-FIXED-X28: "-target-feature" "+reserve-x28"
 
-// RUN: %clang --target=aarch64-none-gnu -ffixed-x30 -### %s 2> %t
-// RUN: FileCheck --check-prefix=CHECK-FIXED-X30 < %t %s
-// CHECK-FIXED-X30: "-target-feature" "+reserve-x30"
-
 // Test multiple of reserve-x# options together.
 // RUN: %clang --target=aarch64-none-gnu \
 // RUN: -ffixed-x1 \
diff --git a/llvm/lib/Target/AArch64/AArch64.td 
b/llvm/lib/Target/AArch64/AArch64.td
index 3af427d526f80c..741c97a3dc009b 100644
--- a/llvm/lib/Target/AArch64/AArch64.td
+++ b/llvm/lib/Target/AArch64/AArch64.td
@@ -212,7 +212,7 @@ def FeatureStrictAlign : SubtargetFeature<"strict-align",
   "Disallow all unaligned memory "
   "access">;
 
-foreach i = {1-7,9-15,18,20-28,30} in
+foreach i = {1-7,9-15,18,20-28} in
 def FeatureReserveX#i : SubtargetFeature<"reserve-x"#i, 
"ReserveXRegister["#i#"]", "true",
  "Reserve X"#i#", making it 
unavailable "
  "as a GPR">;
diff --git a/llvm/test/CodeGen/AArch64/arm64-platform-reg.ll 
b/llvm/test/CodeGen/AArch64/arm64-platform-reg.ll
index c598306c2de301..3df2ef7aa59fc8 100644
--- a/llvm/test/CodeGen/AArch64/arm64-platform-reg.ll
+++ b/llvm/test/CodeGen/AArch64/arm64-platform-reg.ll
@@ -34,7 +34,6 @@
 ; RUN: llc -mtriple=arm64-linux-gnu -mattr=+reserve-x26 -o - %s | FileCheck %s 
--check-prefixes=CHECK-RESERVE,CHECK-RESERVE-X26
 ; RUN: llc -mtriple=arm64-linux-gnu -mattr=+reserve-x27 -o - %s | FileCheck %s 
--check-prefixes=CHECK-RESERVE,CHECK-RESERVE-X27
 ; RUN: llc -mtriple=arm64-linux-gnu -mattr=+reserve-x28 -o - %s | FileCheck %s 
--check-prefixes=CHECK-RESERVE,CHECK-RESERVE-X28
-; RUN: llc -mtriple=arm64-linux-gnu -mattr=+reserve-x30 -o - %s | FileCheck %s 
--check-prefixes=CHECK-RESERVE,CHECK-RESERVE-X30
 
 ; Test multiple of reserve-x# options together.
 ; RUN: llc -mtriple=arm64-linux-gnu \
@@ -73,7 +72,6 @@
 ; RUN: -mattr=+reserve-x26 \
 ; RUN: -mattr=+reserve-x27 \
 ; RUN: -mattr=+reserve-x28 \
-; RUN: -mattr=+reserve-x30 \
 ; RUN: -reserve-regs-for-regalloc=X8,X16,X17,X19 \
 ; RUN: -o - %s | FileCheck %s \
 ; RUN: --check-prefix=CHECK-RESERVE \
@@ -104,8 +102,7 @@
 ; RUN: --check-prefix=CHECK-RESERVE-X25 \
 ; RUN: --check-prefix=CHECK-RESERVE-X26 \
 ; RUN: --check-prefix=CHECK-RESERVE-X27 \
-; RUN: --check-prefix=CHECK-RESERVE-X28 \
-; RUN: --check-prefix=CHECK-RESERVE-X30
+; RUN: --check-prefix=CHECK-RESERVE-X28
 
 ; x18 is reserved as a platform register on Darwin but not on other
 ; systems. Create loads of register pressure and make sure this is respected.
@@ -152,7 +149,6 @@ define void @keep_live() {
 ; CHECK-RESERVE-X26-NOT: ldr x26
 ; CHECK-RESERVE-X27-NOT: ldr x27
 ; CHECK-RESERVE-X28-NOT: ldr x28
-; CHECK-RESERVE-X30-NOT: ldr x30
 ; CHECK-RESERVE: Spill
 ; CHECK-RESERVE-NOT: ldr fp
 ; CHECK-RESERVE-X1-NOT: ldr x1,
@@ -182,7 +178,6 @@ define void @keep_live() {
 ; CHECK-RESERVE-X26-NOT: ldr x26
 ; CHECK-RESERVE-X27-NOT: ldr x27
 ; 

[clang] Add handling of the `-nostdlibinc` option to ccc-analyzer (PR #88017)

2024-04-08 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Ziqing Luo (ziqingluo-90)


Changes

Compiler options recognizable to ccc-analyzer are stored in maps.  An option 
missing in the map will be dropped by ccc-analyzer.  This causes a build error 
in one of our projects that only happens in scan-build but not regular build, 
because ccc-analyzer do not recognize `-nostdlibinc`.

This commit adds the option to the map.

---
Full diff: https://github.com/llvm/llvm-project/pull/88017.diff


1 Files Affected:

- (modified) clang/tools/scan-build/libexec/ccc-analyzer (+1) 


``diff
diff --git a/clang/tools/scan-build/libexec/ccc-analyzer 
b/clang/tools/scan-build/libexec/ccc-analyzer
index 60796a543fcd06..c5588814e8f0de 100755
--- a/clang/tools/scan-build/libexec/ccc-analyzer
+++ b/clang/tools/scan-build/libexec/ccc-analyzer
@@ -361,6 +361,7 @@ sub Analyze {
 
 my %CompileOptionMap = (
   '-nostdinc' => 0,
+  '-nostdlibinc' => 0,
   '-include' => 1,
   '-idirafter' => 1,
   '-imacros' => 1,

``




https://github.com/llvm/llvm-project/pull/88017
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Add handling of the `-nostdlibinc` option to ccc-analyzer (PR #88017)

2024-04-08 Thread Ziqing Luo via cfe-commits

https://github.com/ziqingluo-90 created 
https://github.com/llvm/llvm-project/pull/88017

Compiler options recognizable to ccc-analyzer are stored in maps.  An option 
missing in the map will be dropped by ccc-analyzer.  This causes a build error 
in one of our projects that only happens in scan-build but not regular build, 
because ccc-analyzer do not recognize `-nostdlibinc`.

This commit adds the option to the map.

>From 188398778993244223638e8433efe2ce703772dd Mon Sep 17 00:00:00 2001
From: ziqingluo-90 
Date: Mon, 8 Apr 2024 10:25:43 -0700
Subject: [PATCH] Add handling of the `-nostdlibinc` option to ccc-analyzer

Compiler options recognizable to ccc-analyzer are stored in maps.  An
option missing in the map will be dropped by ccc-analyzer.  This
causes a build error in one of our projects that only happens in
scan-build but not regular build, because ccc-analyzer do not
recognize `-nostdlibinc`.

This commit adds the option to the map.

rdar://126082053
---
 clang/tools/scan-build/libexec/ccc-analyzer | 1 +
 1 file changed, 1 insertion(+)

diff --git a/clang/tools/scan-build/libexec/ccc-analyzer 
b/clang/tools/scan-build/libexec/ccc-analyzer
index 60796a543fcd06..c5588814e8f0de 100755
--- a/clang/tools/scan-build/libexec/ccc-analyzer
+++ b/clang/tools/scan-build/libexec/ccc-analyzer
@@ -361,6 +361,7 @@ sub Analyze {
 
 my %CompileOptionMap = (
   '-nostdinc' => 0,
+  '-nostdlibinc' => 0,
   '-include' => 1,
   '-idirafter' => 1,
   '-imacros' => 1,

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


[clang] [clang] Introduce `SemaHLSL` (PR #87912)

2024-04-08 Thread Vlad Serebrennikov via cfe-commits

https://github.com/Endilll closed 
https://github.com/llvm/llvm-project/pull/87912
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] d345f6a - [clang] Introduce `SemaHLSL` (#87912)

2024-04-08 Thread via cfe-commits

Author: Vlad Serebrennikov
Date: 2024-04-08T21:32:38+04:00
New Revision: d345f6a25343f926f55e70b442dfa507ba31b597

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

LOG: [clang] Introduce `SemaHLSL` (#87912)

This patch introduces `SemaHLSL` class, and moves some HLSL-related
functions there. No functional changes intended.

Removing "HLSL" from function names inside `SemaHLSL` is left for a
subsequent PR by HLSL contributors, if they deem that desirable.

This is a part of the effort to split `Sema` into smaller manageable
parts, and follows the example of OpenACC. See #82217, #84184, #87634
for additional context.

Added: 
clang/include/clang/Sema/SemaHLSL.h

Modified: 
clang/include/clang/Sema/Sema.h
clang/lib/Parse/ParseHLSL.cpp
clang/lib/Sema/Sema.cpp
clang/lib/Sema/SemaHLSL.cpp

Removed: 




diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 56d66a4486e0e7..3fe2b6dd422a54 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -182,6 +182,7 @@ class Preprocessor;
 class PseudoDestructorTypeStorage;
 class PseudoObjectExpr;
 class QualType;
+class SemaHLSL;
 class SemaOpenACC;
 class StandardConversionSequence;
 class Stmt;
@@ -465,9 +466,8 @@ class Sema final : public SemaBase {
   // 36. FixIt Helpers (SemaFixItUtils.cpp)
   // 37. Name Lookup for RISC-V Vector Intrinsic (SemaRISCVVectorLookup.cpp)
   // 38. CUDA (SemaCUDA.cpp)
-  // 39. HLSL Constructs (SemaHLSL.cpp)
-  // 40. OpenMP Directives and Clauses (SemaOpenMP.cpp)
-  // 41. SYCL Constructs (SemaSYCL.cpp)
+  // 39. OpenMP Directives and Clauses (SemaOpenMP.cpp)
+  // 40. SYCL Constructs (SemaSYCL.cpp)
 
   /// \name Semantic Analysis
   /// Implementations are in Sema.cpp
@@ -964,6 +964,11 @@ class Sema final : public SemaBase {
   /// CurContext - This is the current declaration context of parsing.
   DeclContext *CurContext;
 
+  SemaHLSL () {
+assert(HLSLPtr);
+return *HLSLPtr;
+  }
+
   SemaOpenACC () {
 assert(OpenACCPtr);
 return *OpenACCPtr;
@@ -999,6 +1004,7 @@ class Sema final : public SemaBase {
 
   mutable IdentifierInfo *Ident_super;
 
+  std::unique_ptr HLSLPtr;
   std::unique_ptr OpenACCPtr;
 
   ///@}
@@ -1967,6 +1973,11 @@ class Sema final : public SemaBase {
   bool CheckFunctionCall(FunctionDecl *FDecl, CallExpr *TheCall,
  const FunctionProtoType *Proto);
 
+  bool BuiltinVectorMath(CallExpr *TheCall, QualType );
+  bool BuiltinVectorToScalarMath(CallExpr *TheCall);
+
+  bool CheckHLSLBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall);
+
 private:
   void CheckArrayAccess(const Expr *BaseExpr, const Expr *IndexExpr,
 const ArraySubscriptExpr *ASE = nullptr,
@@ -13145,29 +13156,6 @@ class Sema final : public SemaBase {
   //
   //
 
-  /// \name HLSL Constructs
-  /// Implementations are in SemaHLSL.cpp
-  ///@{
-
-public:
-  Decl *ActOnStartHLSLBuffer(Scope *BufferScope, bool CBuffer,
- SourceLocation KwLoc, IdentifierInfo *Ident,
- SourceLocation IdentLoc, SourceLocation LBrace);
-  void ActOnFinishHLSLBuffer(Decl *Dcl, SourceLocation RBrace);
-
-  bool CheckHLSLBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall);
-
-  bool BuiltinVectorMath(CallExpr *TheCall, QualType );
-  bool BuiltinVectorToScalarMath(CallExpr *TheCall);
-
-  ///@}
-
-  //
-  //
-  // -
-  //
-  //
-
   /// \name OpenMP Directives and Clauses
   /// Implementations are in SemaOpenMP.cpp
   ///@{

diff  --git a/clang/include/clang/Sema/SemaHLSL.h 
b/clang/include/clang/Sema/SemaHLSL.h
new file mode 100644
index 00..acc675963c23a5
--- /dev/null
+++ b/clang/include/clang/Sema/SemaHLSL.h
@@ -0,0 +1,37 @@
+//===- SemaHLSL.h - Semantic Analysis for HLSL constructs 
-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+/// \file
+/// This file declares semantic analysis for HLSL constructs.
+///
+//===--===//
+
+#ifndef LLVM_CLANG_SEMA_SEMAHLSL_H
+#define LLVM_CLANG_SEMA_SEMAHLSL_H
+
+#include "clang/AST/DeclBase.h"
+#include "clang/AST/Expr.h"
+#include "clang/Basic/IdentifierTable.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Sema/Scope.h"
+#include "clang/Sema/SemaBase.h"
+
+namespace clang {
+
+class SemaHLSL : public SemaBase {
+public:
+  SemaHLSL(Sema );
+
+  Decl 

[clang] [clang] Introduce `SemaHLSL` (PR #87912)

2024-04-08 Thread Aaron Ballman via cfe-commits

https://github.com/AaronBallman approved this pull request.

LGTM!

https://github.com/llvm/llvm-project/pull/87912
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang]Treat arguments to builtin type traits as template type arguments (PR #87132)

2024-04-08 Thread Amirreza Ashouri via cfe-commits

AMP999 wrote:

@fahadnayyar, does this PR address llvm#86997?

https://github.com/llvm/llvm-project/pull/87132
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [AST][RecoveryExpr] Fix a crash on c89/c90 invalid InitListExpr (#88008) (PR #88014)

2024-04-08 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Ding Fei (danix800)


Changes

Use refactored `CheckForConstantInitializer()` to skip checking expr with error.

---
Full diff: https://github.com/llvm/llvm-project/pull/88014.diff


4 Files Affected:

- (modified) clang/include/clang/Sema/Sema.h (+1-1) 
- (modified) clang/lib/Sema/SemaDecl.cpp (+11-17) 
- (modified) clang/lib/Sema/SemaExpr.cpp (+2-1) 
- (added) clang/test/Sema/recover-expr-gh88008-nocrash.c (+11) 


``diff
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 56d66a4486e0e7..452ccdda868b55 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -3391,7 +3391,7 @@ class Sema final : public SemaBase {
   bool ConstexprSupported, bool CLinkageMayDiffer);
 
   /// type checking declaration initializers (C99 6.7.8)
-  bool CheckForConstantInitializer(Expr *e, QualType t);
+  bool CheckForConstantInitializer(Expr *Init, unsigned DiagID);
 
   QualType deduceVarTypeFromInitializer(VarDecl *VDecl, DeclarationName Name,
 QualType Type, TypeSourceInfo *TSI,
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index c790dab72dd721..a516cff166fd67 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -12769,7 +12769,7 @@ void Sema::DiagnoseHLSLAttrStageMismatch(
   << (AllowedStages.size() != 1) << join(StageStrings, ", ");
 }
 
-bool Sema::CheckForConstantInitializer(Expr *Init, QualType DclT) {
+bool Sema::CheckForConstantInitializer(Expr *Init, unsigned DiagID) {
   // FIXME: Need strict checking.  In C89, we need to check for
   // any assignment, increment, decrement, function-calls, or
   // commas outside of a sizeof.  In C99, it's the same list,
@@ -12787,8 +12787,7 @@ bool Sema::CheckForConstantInitializer(Expr *Init, 
QualType DclT) {
   const Expr *Culprit;
   if (Init->isConstantInitializer(Context, false, ))
 return false;
-  Diag(Culprit->getExprLoc(), diag::err_init_element_not_constant)
-<< Culprit->getSourceRange();
+  Diag(Culprit->getExprLoc(), DiagID) << Culprit->getSourceRange();
   return true;
 }
 
@@ -13906,29 +13905,24 @@ void Sema::AddInitializerToDecl(Decl *RealDecl, Expr 
*Init, bool DirectInit) {
 // OpenCL v1.2 s6.5.3: __constant locals must be constant-initialized.
 // This is true even in C++ for OpenCL.
 } else if (VDecl->getType().getAddressSpace() == LangAS::opencl_constant) {
-  CheckForConstantInitializer(Init, DclT);
+  CheckForConstantInitializer(Init, diag::err_init_element_not_constant);
 
-// Otherwise, C++ does not restrict the initializer.
+  // Otherwise, C++ does not restrict the initializer.
 } else if (getLangOpts().CPlusPlus) {
   // do nothing
 
 // C99 6.7.8p4: All the expressions in an initializer for an object that 
has
 // static storage duration shall be constant expressions or string 
literals.
 } else if (VDecl->getStorageClass() == SC_Static) {
-  CheckForConstantInitializer(Init, DclT);
+  CheckForConstantInitializer(Init, diag::err_init_element_not_constant);
 
-// C89 is stricter than C99 for aggregate initializers.
-// C89 6.5.7p3: All the expressions [...] in an initializer list
-// for an object that has aggregate or union type shall be
-// constant expressions.
+  // C89 is stricter than C99 for aggregate initializers.
+  // C89 6.5.7p3: All the expressions [...] in an initializer list
+  // for an object that has aggregate or union type shall be
+  // constant expressions.
 } else if (!getLangOpts().C99 && VDecl->getType()->isAggregateType() &&
isa(Init)) {
-  const Expr *Culprit;
-  if (!Init->isConstantInitializer(Context, false, )) {
-Diag(Culprit->getExprLoc(),
- diag::ext_aggregate_init_not_constant)
-  << Culprit->getSourceRange();
-  }
+  CheckForConstantInitializer(Init, diag::ext_aggregate_init_not_constant);
 }
 
 if (auto *E = dyn_cast(Init))
@@ -14061,7 +14055,7 @@ void Sema::AddInitializerToDecl(Decl *RealDecl, Expr 
*Init, bool DirectInit) {
 // Avoid duplicate diagnostics for constexpr variables.
 if (!getLangOpts().CPlusPlus && !VDecl->isInvalidDecl() &&
 !VDecl->isConstexpr())
-  CheckForConstantInitializer(Init, DclT);
+  CheckForConstantInitializer(Init, diag::err_init_element_not_constant);
   }
 
   QualType InitType = Init->getType();
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 8db4fffeecfe35..2016d2eb08e0ff 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -7898,7 +7898,8 @@ Sema::BuildCompoundLiteralExpr(SourceLocation LParenLoc, 
TypeSourceInfo *TInfo,
 if (!LiteralExpr->isTypeDependent() &&
 !LiteralExpr->isValueDependent() &&
 !literalType->isDependentType()) // C99 6.5.2.5p3
-  if (CheckForConstantInitializer(LiteralExpr, 

[clang] [AST][RecoveryExpr] Fix a crash on c89/c90 invalid InitListExpr (#88008) (PR #88014)

2024-04-08 Thread Ding Fei via cfe-commits

https://github.com/danix800 created 
https://github.com/llvm/llvm-project/pull/88014

Use refactored `CheckForConstantInitializer()` to skip checking expr with error.

>From fbd0780923d40b0d8290280731239a722a7af7a9 Mon Sep 17 00:00:00 2001
From: dingfei 
Date: Tue, 9 Apr 2024 00:26:03 +0800
Subject: [PATCH] [AST][RecoveryExpr] Fix a crash on c89/c90 invalid
 InitListExpr (#88008)

Use refactored CheckForConstantInitializer() to skip checking expr with error.
---
 clang/include/clang/Sema/Sema.h   |  2 +-
 clang/lib/Sema/SemaDecl.cpp   | 28 ---
 clang/lib/Sema/SemaExpr.cpp   |  3 +-
 .../test/Sema/recover-expr-gh88008-nocrash.c  | 11 
 4 files changed, 25 insertions(+), 19 deletions(-)
 create mode 100644 clang/test/Sema/recover-expr-gh88008-nocrash.c

diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 56d66a4486e0e7..452ccdda868b55 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -3391,7 +3391,7 @@ class Sema final : public SemaBase {
   bool ConstexprSupported, bool CLinkageMayDiffer);
 
   /// type checking declaration initializers (C99 6.7.8)
-  bool CheckForConstantInitializer(Expr *e, QualType t);
+  bool CheckForConstantInitializer(Expr *Init, unsigned DiagID);
 
   QualType deduceVarTypeFromInitializer(VarDecl *VDecl, DeclarationName Name,
 QualType Type, TypeSourceInfo *TSI,
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index c790dab72dd721..a516cff166fd67 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -12769,7 +12769,7 @@ void Sema::DiagnoseHLSLAttrStageMismatch(
   << (AllowedStages.size() != 1) << join(StageStrings, ", ");
 }
 
-bool Sema::CheckForConstantInitializer(Expr *Init, QualType DclT) {
+bool Sema::CheckForConstantInitializer(Expr *Init, unsigned DiagID) {
   // FIXME: Need strict checking.  In C89, we need to check for
   // any assignment, increment, decrement, function-calls, or
   // commas outside of a sizeof.  In C99, it's the same list,
@@ -12787,8 +12787,7 @@ bool Sema::CheckForConstantInitializer(Expr *Init, 
QualType DclT) {
   const Expr *Culprit;
   if (Init->isConstantInitializer(Context, false, ))
 return false;
-  Diag(Culprit->getExprLoc(), diag::err_init_element_not_constant)
-<< Culprit->getSourceRange();
+  Diag(Culprit->getExprLoc(), DiagID) << Culprit->getSourceRange();
   return true;
 }
 
@@ -13906,29 +13905,24 @@ void Sema::AddInitializerToDecl(Decl *RealDecl, Expr 
*Init, bool DirectInit) {
 // OpenCL v1.2 s6.5.3: __constant locals must be constant-initialized.
 // This is true even in C++ for OpenCL.
 } else if (VDecl->getType().getAddressSpace() == LangAS::opencl_constant) {
-  CheckForConstantInitializer(Init, DclT);
+  CheckForConstantInitializer(Init, diag::err_init_element_not_constant);
 
-// Otherwise, C++ does not restrict the initializer.
+  // Otherwise, C++ does not restrict the initializer.
 } else if (getLangOpts().CPlusPlus) {
   // do nothing
 
 // C99 6.7.8p4: All the expressions in an initializer for an object that 
has
 // static storage duration shall be constant expressions or string 
literals.
 } else if (VDecl->getStorageClass() == SC_Static) {
-  CheckForConstantInitializer(Init, DclT);
+  CheckForConstantInitializer(Init, diag::err_init_element_not_constant);
 
-// C89 is stricter than C99 for aggregate initializers.
-// C89 6.5.7p3: All the expressions [...] in an initializer list
-// for an object that has aggregate or union type shall be
-// constant expressions.
+  // C89 is stricter than C99 for aggregate initializers.
+  // C89 6.5.7p3: All the expressions [...] in an initializer list
+  // for an object that has aggregate or union type shall be
+  // constant expressions.
 } else if (!getLangOpts().C99 && VDecl->getType()->isAggregateType() &&
isa(Init)) {
-  const Expr *Culprit;
-  if (!Init->isConstantInitializer(Context, false, )) {
-Diag(Culprit->getExprLoc(),
- diag::ext_aggregate_init_not_constant)
-  << Culprit->getSourceRange();
-  }
+  CheckForConstantInitializer(Init, diag::ext_aggregate_init_not_constant);
 }
 
 if (auto *E = dyn_cast(Init))
@@ -14061,7 +14055,7 @@ void Sema::AddInitializerToDecl(Decl *RealDecl, Expr 
*Init, bool DirectInit) {
 // Avoid duplicate diagnostics for constexpr variables.
 if (!getLangOpts().CPlusPlus && !VDecl->isInvalidDecl() &&
 !VDecl->isConstexpr())
-  CheckForConstantInitializer(Init, DclT);
+  CheckForConstantInitializer(Init, diag::err_init_element_not_constant);
   }
 
   QualType InitType = Init->getType();
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 8db4fffeecfe35..2016d2eb08e0ff 100644
--- a/clang/lib/Sema/SemaExpr.cpp

[clang] Rework the printing of attributes (PR #87281)

2024-04-08 Thread Vassil Vassilev via cfe-commits

vgvassilev wrote:

In https://github.com/llvm/llvm-project/issues/87151 is more context.

https://github.com/llvm/llvm-project/pull/87281
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Rework the printing of attributes (PR #87281)

2024-04-08 Thread Erich Keane via cfe-commits

erichkeane wrote:

> > > @erichkeane, thank you. What's the process of including this in the next 
> > > release?
> > 
> > 
> > After CI is complete, you can click "Squash and Merge" below (if you 
> > cannot, let us know and someone can do it for you), and it'll be included 
> > in the 19.1 release this summer.
> 
> I have commit access. I want this to be part of the 18.x releases as that 
> breaks our downstream clients.

Ah, hmm... I am not sure this qualifies for inclusion in the current release 
branch.  Perhaps @AaronBallman can comment here.

https://github.com/llvm/llvm-project/pull/87281
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Rework the printing of attributes (PR #87281)

2024-04-08 Thread Vassil Vassilev via cfe-commits

vgvassilev wrote:

> > @erichkeane, thank you. What's the process of including this in the next 
> > release?
> 
> After CI is complete, you can click "Squash and Merge" below (if you cannot, 
> let us know and someone can do it for you), and it'll be included in the 19.1 
> release this summer.

I have commit access. I want this to be part of the 18.x releases as that 
breaks our downstream clients.

https://github.com/llvm/llvm-project/pull/87281
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Rework the printing of attributes (PR #87281)

2024-04-08 Thread Erich Keane via cfe-commits

erichkeane wrote:

> @erichkeane, thank you. What's the process of including this in the next 
> release?

After CI is complete, you can click "Squash and Merge" below (if you cannot, 
let us know and someone can do it for you), and it'll be included in the 19.1 
release this summer.

https://github.com/llvm/llvm-project/pull/87281
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Doc][HLSL] Add documentation for root signature. (PR #83933)

2024-04-08 Thread Xiang Li via cfe-commits

https://github.com/python3kgae closed 
https://github.com/llvm/llvm-project/pull/83933
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Doc][HLSL] Add documentation for root signature. (PR #83933)

2024-04-08 Thread Xiang Li via cfe-commits

python3kgae wrote:

> I think we need to break this PR up into different parts going to different 
> places.
> 
> Documenting the RootSignature grammar and usage in the Clang docs makes sense.
> 
> I think documentation of the RootSignature binary format probably should live 
> with the DirectX backend docs, since the code to generate the binary encoding 
> should live in LLVM.
> 
> The last part of the document here about the implementation I think we should 
> remove from this PR and bring that discussion over to 
> https://github.com/microsoft/hlsl-specs. There are a lot of parts of the 
> design that I'm not convinced are correct or lack appropriate detail for me 
> to understand.
> 
> To @damyanp's point I think the discussion thread here has gotten long enough 
> to be unwieldy. Rather than merging an incomplete document to Clang's docs, I 
> think it would be better for us to iterate on the design outside the LLVM 
> source tree and return to LLVM with a design we have a higher level of 
> confidence in.
> 
> @python3kgae can you strip PR down to just the first parts that document Root 
> Signatures and take the implementation discussion over to hlsl-specs?

Created https://github.com/microsoft/hlsl-specs/pull/193


https://github.com/llvm/llvm-project/pull/83933
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Rework the printing of attributes (PR #87281)

2024-04-08 Thread Vassil Vassilev via cfe-commits

vgvassilev wrote:

@erichkeane, thank you. What's the process of including this in the next 
release?

https://github.com/llvm/llvm-project/pull/87281
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Rework the printing of attributes (PR #87281)

2024-04-08 Thread Vassil Vassilev via cfe-commits

https://github.com/vgvassilev updated 
https://github.com/llvm/llvm-project/pull/87281

>From 94f1c8653903cc3db55abd641c68a9dd11f05df3 Mon Sep 17 00:00:00 2001
From: Vassil Vassilev 
Date: Mon, 1 Apr 2024 15:01:33 +
Subject: [PATCH 1/5] Revert "Remove extra switch from  0323938d"

This reverts commit 6c0b9e35761738726aded3b399db89eb0a86f82b.
---
 clang/lib/AST/DeclPrinter.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/clang/lib/AST/DeclPrinter.cpp b/clang/lib/AST/DeclPrinter.cpp
index edbcdfe4d55bc9..1ab74c71d0fd49 100644
--- a/clang/lib/AST/DeclPrinter.cpp
+++ b/clang/lib/AST/DeclPrinter.cpp
@@ -277,6 +277,7 @@ static bool canPrintOnLeftSide(const Attr *A) {
 }
 
 static bool mustPrintOnLeftSide(attr::Kind kind) {
+  switch (kind) {
 #ifdef CLANG_ATTR_LIST_PrintOnLeft
   switch (kind) {
   CLANG_ATTR_LIST_PrintOnLeft

>From 871f5b06e0da167c4cf50d336bdc38f0eb684b6b Mon Sep 17 00:00:00 2001
From: Vassil Vassilev 
Date: Mon, 1 Apr 2024 15:01:44 +
Subject: [PATCH 2/5] Revert "Fix warning in MSVC"

This reverts commit 0323938d3c7a1a48b60a7dea8ec7300e98b4a931.
---
 clang/lib/AST/DeclPrinter.cpp | 20 +++-
 clang/utils/TableGen/ClangAttrEmitter.cpp | 11 +--
 2 files changed, 4 insertions(+), 27 deletions(-)

diff --git a/clang/lib/AST/DeclPrinter.cpp b/clang/lib/AST/DeclPrinter.cpp
index 1ab74c71d0fd49..c2e0edd5f1f12c 100644
--- a/clang/lib/AST/DeclPrinter.cpp
+++ b/clang/lib/AST/DeclPrinter.cpp
@@ -250,23 +250,13 @@ raw_ostream& DeclPrinter::Indent(unsigned Indentation) {
   return Out;
 }
 
-// For CLANG_ATTR_LIST_CanPrintOnLeft macro.
-#include "clang/Basic/AttrLeftSideCanPrintList.inc"
-
-// For CLANG_ATTR_LIST_PrintOnLeft macro.
-#include "clang/Basic/AttrLeftSideMustPrintList.inc"
-
 static bool canPrintOnLeftSide(attr::Kind kind) {
-#ifdef CLANG_ATTR_LIST_CanPrintOnLeft
   switch (kind) {
-  CLANG_ATTR_LIST_CanPrintOnLeft
+#include "clang/Basic/AttrLeftSideCanPrintList.inc"
 return true;
   default:
 return false;
   }
-#else
-  return false;
-#endif
 }
 
 static bool canPrintOnLeftSide(const Attr *A) {
@@ -278,16 +268,11 @@ static bool canPrintOnLeftSide(const Attr *A) {
 
 static bool mustPrintOnLeftSide(attr::Kind kind) {
   switch (kind) {
-#ifdef CLANG_ATTR_LIST_PrintOnLeft
-  switch (kind) {
-  CLANG_ATTR_LIST_PrintOnLeft
+#include "clang/Basic/AttrLeftSideMustPrintList.inc"
 return true;
   default:
 return false;
   }
-#else
-  return false;
-#endif
 }
 
 static bool mustPrintOnLeftSide(const Attr *A) {
@@ -329,6 +314,7 @@ void DeclPrinter::prettyPrintAttributes(Decl *D, 
llvm::raw_ostream ,
VD->getInitStyle() == VarDecl::CallInit)
   AttrLoc = AttrPrintLoc::Left;
   }
+
   // Only print the side matches the user requested.
   if ((Loc & AttrLoc) != AttrPrintLoc::None)
 A->printPretty(Out, Policy);
diff --git a/clang/utils/TableGen/ClangAttrEmitter.cpp 
b/clang/utils/TableGen/ClangAttrEmitter.cpp
index eb5c34d15693d7..985cc1aee579e9 100644
--- a/clang/utils/TableGen/ClangAttrEmitter.cpp
+++ b/clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -3327,8 +3327,6 @@ void EmitClangAttrPrintList(const std::string , 
RecordKeeper ,
 
   std::vector Attrs = Records.getAllDerivedDefinitions("Attr");
   std::vector PragmaAttrs;
-  bool first = false;
-
   for (auto *Attr : Attrs) {
 if (!Attr->getValueAsBit("ASTNode"))
   continue;
@@ -3336,15 +3334,8 @@ void EmitClangAttrPrintList(const std::string 
, RecordKeeper ,
 if (!Attr->getValueAsBit(FieldName))
   continue;
 
-if (!first) {
-  first = true;
-  OS << "#define CLANG_ATTR_LIST_" << FieldName;
-}
-
-OS << " \\\n case attr::" << Attr->getName() << ":";
+OS << "case attr::" << Attr->getName() << ":\n";
   }
-
-  OS << '\n';
 }
 
 // Emits the enumeration list for attributes.

>From e7e2e90da2a9644b0ca8a4c5c464c75a35f019a5 Mon Sep 17 00:00:00 2001
From: Vassil Vassilev 
Date: Mon, 1 Apr 2024 15:11:28 +
Subject: [PATCH 3/5] Revert "Fix ast print of variables with attributes"

This reverts commit 46f3ade5083b8bfce55c78a21086a487eaac6f99.
---
 clang/include/clang/Basic/Attr.td|  14 +-
 clang/include/clang/Basic/CMakeLists.txt |  10 --
 clang/lib/AST/DeclPrinter.cpp| 137 +++
 clang/test/AST/ast-print-attr-knr.c  |  17 ---
 clang/test/AST/ast-print-attr.c  |   6 -
 clang/test/AST/ast-print-method-decl.cpp |   2 +-
 clang/test/AST/ast-print-pragmas.cpp |   4 +-
 clang/test/Analysis/blocks.mm|   2 +-
 clang/test/OpenMP/assumes_codegen.cpp|  22 +--
 clang/test/OpenMP/assumes_print.cpp  |   6 +-
 clang/test/OpenMP/assumes_template_print.cpp |  20 +--
 clang/test/OpenMP/declare_simd_ast_print.cpp |   4 +-
 clang/test/Sema/attr-print.c |   3 +-
 clang/test/SemaCXX/attr-print.cpp|   3 +-
 clang/test/SemaCXX/cxx11-attr-print.cpp  |   7 +-
 

[clang] Rework the printing of attributes (PR #87281)

2024-04-08 Thread Vassil Vassilev via cfe-commits

https://github.com/vgvassilev updated 
https://github.com/llvm/llvm-project/pull/87281

>From 94f1c8653903cc3db55abd641c68a9dd11f05df3 Mon Sep 17 00:00:00 2001
From: Vassil Vassilev 
Date: Mon, 1 Apr 2024 15:01:33 +
Subject: [PATCH 1/5] Revert "Remove extra switch from  0323938d"

This reverts commit 6c0b9e35761738726aded3b399db89eb0a86f82b.
---
 clang/lib/AST/DeclPrinter.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/clang/lib/AST/DeclPrinter.cpp b/clang/lib/AST/DeclPrinter.cpp
index edbcdfe4d55bc9..1ab74c71d0fd49 100644
--- a/clang/lib/AST/DeclPrinter.cpp
+++ b/clang/lib/AST/DeclPrinter.cpp
@@ -277,6 +277,7 @@ static bool canPrintOnLeftSide(const Attr *A) {
 }
 
 static bool mustPrintOnLeftSide(attr::Kind kind) {
+  switch (kind) {
 #ifdef CLANG_ATTR_LIST_PrintOnLeft
   switch (kind) {
   CLANG_ATTR_LIST_PrintOnLeft

>From 871f5b06e0da167c4cf50d336bdc38f0eb684b6b Mon Sep 17 00:00:00 2001
From: Vassil Vassilev 
Date: Mon, 1 Apr 2024 15:01:44 +
Subject: [PATCH 2/5] Revert "Fix warning in MSVC"

This reverts commit 0323938d3c7a1a48b60a7dea8ec7300e98b4a931.
---
 clang/lib/AST/DeclPrinter.cpp | 20 +++-
 clang/utils/TableGen/ClangAttrEmitter.cpp | 11 +--
 2 files changed, 4 insertions(+), 27 deletions(-)

diff --git a/clang/lib/AST/DeclPrinter.cpp b/clang/lib/AST/DeclPrinter.cpp
index 1ab74c71d0fd49..c2e0edd5f1f12c 100644
--- a/clang/lib/AST/DeclPrinter.cpp
+++ b/clang/lib/AST/DeclPrinter.cpp
@@ -250,23 +250,13 @@ raw_ostream& DeclPrinter::Indent(unsigned Indentation) {
   return Out;
 }
 
-// For CLANG_ATTR_LIST_CanPrintOnLeft macro.
-#include "clang/Basic/AttrLeftSideCanPrintList.inc"
-
-// For CLANG_ATTR_LIST_PrintOnLeft macro.
-#include "clang/Basic/AttrLeftSideMustPrintList.inc"
-
 static bool canPrintOnLeftSide(attr::Kind kind) {
-#ifdef CLANG_ATTR_LIST_CanPrintOnLeft
   switch (kind) {
-  CLANG_ATTR_LIST_CanPrintOnLeft
+#include "clang/Basic/AttrLeftSideCanPrintList.inc"
 return true;
   default:
 return false;
   }
-#else
-  return false;
-#endif
 }
 
 static bool canPrintOnLeftSide(const Attr *A) {
@@ -278,16 +268,11 @@ static bool canPrintOnLeftSide(const Attr *A) {
 
 static bool mustPrintOnLeftSide(attr::Kind kind) {
   switch (kind) {
-#ifdef CLANG_ATTR_LIST_PrintOnLeft
-  switch (kind) {
-  CLANG_ATTR_LIST_PrintOnLeft
+#include "clang/Basic/AttrLeftSideMustPrintList.inc"
 return true;
   default:
 return false;
   }
-#else
-  return false;
-#endif
 }
 
 static bool mustPrintOnLeftSide(const Attr *A) {
@@ -329,6 +314,7 @@ void DeclPrinter::prettyPrintAttributes(Decl *D, 
llvm::raw_ostream ,
VD->getInitStyle() == VarDecl::CallInit)
   AttrLoc = AttrPrintLoc::Left;
   }
+
   // Only print the side matches the user requested.
   if ((Loc & AttrLoc) != AttrPrintLoc::None)
 A->printPretty(Out, Policy);
diff --git a/clang/utils/TableGen/ClangAttrEmitter.cpp 
b/clang/utils/TableGen/ClangAttrEmitter.cpp
index eb5c34d15693d7..985cc1aee579e9 100644
--- a/clang/utils/TableGen/ClangAttrEmitter.cpp
+++ b/clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -3327,8 +3327,6 @@ void EmitClangAttrPrintList(const std::string , 
RecordKeeper ,
 
   std::vector Attrs = Records.getAllDerivedDefinitions("Attr");
   std::vector PragmaAttrs;
-  bool first = false;
-
   for (auto *Attr : Attrs) {
 if (!Attr->getValueAsBit("ASTNode"))
   continue;
@@ -3336,15 +3334,8 @@ void EmitClangAttrPrintList(const std::string 
, RecordKeeper ,
 if (!Attr->getValueAsBit(FieldName))
   continue;
 
-if (!first) {
-  first = true;
-  OS << "#define CLANG_ATTR_LIST_" << FieldName;
-}
-
-OS << " \\\n case attr::" << Attr->getName() << ":";
+OS << "case attr::" << Attr->getName() << ":\n";
   }
-
-  OS << '\n';
 }
 
 // Emits the enumeration list for attributes.

>From e7e2e90da2a9644b0ca8a4c5c464c75a35f019a5 Mon Sep 17 00:00:00 2001
From: Vassil Vassilev 
Date: Mon, 1 Apr 2024 15:11:28 +
Subject: [PATCH 3/5] Revert "Fix ast print of variables with attributes"

This reverts commit 46f3ade5083b8bfce55c78a21086a487eaac6f99.
---
 clang/include/clang/Basic/Attr.td|  14 +-
 clang/include/clang/Basic/CMakeLists.txt |  10 --
 clang/lib/AST/DeclPrinter.cpp| 137 +++
 clang/test/AST/ast-print-attr-knr.c  |  17 ---
 clang/test/AST/ast-print-attr.c  |   6 -
 clang/test/AST/ast-print-method-decl.cpp |   2 +-
 clang/test/AST/ast-print-pragmas.cpp |   4 +-
 clang/test/Analysis/blocks.mm|   2 +-
 clang/test/OpenMP/assumes_codegen.cpp|  22 +--
 clang/test/OpenMP/assumes_print.cpp  |   6 +-
 clang/test/OpenMP/assumes_template_print.cpp |  20 +--
 clang/test/OpenMP/declare_simd_ast_print.cpp |   4 +-
 clang/test/Sema/attr-print.c |   3 +-
 clang/test/SemaCXX/attr-print.cpp|   3 +-
 clang/test/SemaCXX/cxx11-attr-print.cpp  |   7 +-
 

[clang] Rework the printing of attributes (PR #87281)

2024-04-08 Thread Vassil Vassilev via cfe-commits

https://github.com/vgvassilev updated 
https://github.com/llvm/llvm-project/pull/87281

>From 94f1c8653903cc3db55abd641c68a9dd11f05df3 Mon Sep 17 00:00:00 2001
From: Vassil Vassilev 
Date: Mon, 1 Apr 2024 15:01:33 +
Subject: [PATCH 01/11] Revert "Remove extra switch from  0323938d"

This reverts commit 6c0b9e35761738726aded3b399db89eb0a86f82b.
---
 clang/lib/AST/DeclPrinter.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/clang/lib/AST/DeclPrinter.cpp b/clang/lib/AST/DeclPrinter.cpp
index edbcdfe4d55bc9..1ab74c71d0fd49 100644
--- a/clang/lib/AST/DeclPrinter.cpp
+++ b/clang/lib/AST/DeclPrinter.cpp
@@ -277,6 +277,7 @@ static bool canPrintOnLeftSide(const Attr *A) {
 }
 
 static bool mustPrintOnLeftSide(attr::Kind kind) {
+  switch (kind) {
 #ifdef CLANG_ATTR_LIST_PrintOnLeft
   switch (kind) {
   CLANG_ATTR_LIST_PrintOnLeft

>From 871f5b06e0da167c4cf50d336bdc38f0eb684b6b Mon Sep 17 00:00:00 2001
From: Vassil Vassilev 
Date: Mon, 1 Apr 2024 15:01:44 +
Subject: [PATCH 02/11] Revert "Fix warning in MSVC"

This reverts commit 0323938d3c7a1a48b60a7dea8ec7300e98b4a931.
---
 clang/lib/AST/DeclPrinter.cpp | 20 +++-
 clang/utils/TableGen/ClangAttrEmitter.cpp | 11 +--
 2 files changed, 4 insertions(+), 27 deletions(-)

diff --git a/clang/lib/AST/DeclPrinter.cpp b/clang/lib/AST/DeclPrinter.cpp
index 1ab74c71d0fd49..c2e0edd5f1f12c 100644
--- a/clang/lib/AST/DeclPrinter.cpp
+++ b/clang/lib/AST/DeclPrinter.cpp
@@ -250,23 +250,13 @@ raw_ostream& DeclPrinter::Indent(unsigned Indentation) {
   return Out;
 }
 
-// For CLANG_ATTR_LIST_CanPrintOnLeft macro.
-#include "clang/Basic/AttrLeftSideCanPrintList.inc"
-
-// For CLANG_ATTR_LIST_PrintOnLeft macro.
-#include "clang/Basic/AttrLeftSideMustPrintList.inc"
-
 static bool canPrintOnLeftSide(attr::Kind kind) {
-#ifdef CLANG_ATTR_LIST_CanPrintOnLeft
   switch (kind) {
-  CLANG_ATTR_LIST_CanPrintOnLeft
+#include "clang/Basic/AttrLeftSideCanPrintList.inc"
 return true;
   default:
 return false;
   }
-#else
-  return false;
-#endif
 }
 
 static bool canPrintOnLeftSide(const Attr *A) {
@@ -278,16 +268,11 @@ static bool canPrintOnLeftSide(const Attr *A) {
 
 static bool mustPrintOnLeftSide(attr::Kind kind) {
   switch (kind) {
-#ifdef CLANG_ATTR_LIST_PrintOnLeft
-  switch (kind) {
-  CLANG_ATTR_LIST_PrintOnLeft
+#include "clang/Basic/AttrLeftSideMustPrintList.inc"
 return true;
   default:
 return false;
   }
-#else
-  return false;
-#endif
 }
 
 static bool mustPrintOnLeftSide(const Attr *A) {
@@ -329,6 +314,7 @@ void DeclPrinter::prettyPrintAttributes(Decl *D, 
llvm::raw_ostream ,
VD->getInitStyle() == VarDecl::CallInit)
   AttrLoc = AttrPrintLoc::Left;
   }
+
   // Only print the side matches the user requested.
   if ((Loc & AttrLoc) != AttrPrintLoc::None)
 A->printPretty(Out, Policy);
diff --git a/clang/utils/TableGen/ClangAttrEmitter.cpp 
b/clang/utils/TableGen/ClangAttrEmitter.cpp
index eb5c34d15693d7..985cc1aee579e9 100644
--- a/clang/utils/TableGen/ClangAttrEmitter.cpp
+++ b/clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -3327,8 +3327,6 @@ void EmitClangAttrPrintList(const std::string , 
RecordKeeper ,
 
   std::vector Attrs = Records.getAllDerivedDefinitions("Attr");
   std::vector PragmaAttrs;
-  bool first = false;
-
   for (auto *Attr : Attrs) {
 if (!Attr->getValueAsBit("ASTNode"))
   continue;
@@ -3336,15 +3334,8 @@ void EmitClangAttrPrintList(const std::string 
, RecordKeeper ,
 if (!Attr->getValueAsBit(FieldName))
   continue;
 
-if (!first) {
-  first = true;
-  OS << "#define CLANG_ATTR_LIST_" << FieldName;
-}
-
-OS << " \\\n case attr::" << Attr->getName() << ":";
+OS << "case attr::" << Attr->getName() << ":\n";
   }
-
-  OS << '\n';
 }
 
 // Emits the enumeration list for attributes.

>From e7e2e90da2a9644b0ca8a4c5c464c75a35f019a5 Mon Sep 17 00:00:00 2001
From: Vassil Vassilev 
Date: Mon, 1 Apr 2024 15:11:28 +
Subject: [PATCH 03/11] Revert "Fix ast print of variables with attributes"

This reverts commit 46f3ade5083b8bfce55c78a21086a487eaac6f99.
---
 clang/include/clang/Basic/Attr.td|  14 +-
 clang/include/clang/Basic/CMakeLists.txt |  10 --
 clang/lib/AST/DeclPrinter.cpp| 137 +++
 clang/test/AST/ast-print-attr-knr.c  |  17 ---
 clang/test/AST/ast-print-attr.c  |   6 -
 clang/test/AST/ast-print-method-decl.cpp |   2 +-
 clang/test/AST/ast-print-pragmas.cpp |   4 +-
 clang/test/Analysis/blocks.mm|   2 +-
 clang/test/OpenMP/assumes_codegen.cpp|  22 +--
 clang/test/OpenMP/assumes_print.cpp  |   6 +-
 clang/test/OpenMP/assumes_template_print.cpp |  20 +--
 clang/test/OpenMP/declare_simd_ast_print.cpp |   4 +-
 clang/test/Sema/attr-print.c |   3 +-
 clang/test/SemaCXX/attr-print.cpp|   3 +-
 clang/test/SemaCXX/cxx11-attr-print.cpp  |   7 +-
 

[clang] Rework the printing of attributes (PR #87281)

2024-04-08 Thread Vassil Vassilev via cfe-commits

https://github.com/vgvassilev updated 
https://github.com/llvm/llvm-project/pull/87281

>From 94f1c8653903cc3db55abd641c68a9dd11f05df3 Mon Sep 17 00:00:00 2001
From: Vassil Vassilev 
Date: Mon, 1 Apr 2024 15:01:33 +
Subject: [PATCH 01/10] Revert "Remove extra switch from  0323938d"

This reverts commit 6c0b9e35761738726aded3b399db89eb0a86f82b.
---
 clang/lib/AST/DeclPrinter.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/clang/lib/AST/DeclPrinter.cpp b/clang/lib/AST/DeclPrinter.cpp
index edbcdfe4d55bc9..1ab74c71d0fd49 100644
--- a/clang/lib/AST/DeclPrinter.cpp
+++ b/clang/lib/AST/DeclPrinter.cpp
@@ -277,6 +277,7 @@ static bool canPrintOnLeftSide(const Attr *A) {
 }
 
 static bool mustPrintOnLeftSide(attr::Kind kind) {
+  switch (kind) {
 #ifdef CLANG_ATTR_LIST_PrintOnLeft
   switch (kind) {
   CLANG_ATTR_LIST_PrintOnLeft

>From 871f5b06e0da167c4cf50d336bdc38f0eb684b6b Mon Sep 17 00:00:00 2001
From: Vassil Vassilev 
Date: Mon, 1 Apr 2024 15:01:44 +
Subject: [PATCH 02/10] Revert "Fix warning in MSVC"

This reverts commit 0323938d3c7a1a48b60a7dea8ec7300e98b4a931.
---
 clang/lib/AST/DeclPrinter.cpp | 20 +++-
 clang/utils/TableGen/ClangAttrEmitter.cpp | 11 +--
 2 files changed, 4 insertions(+), 27 deletions(-)

diff --git a/clang/lib/AST/DeclPrinter.cpp b/clang/lib/AST/DeclPrinter.cpp
index 1ab74c71d0fd49..c2e0edd5f1f12c 100644
--- a/clang/lib/AST/DeclPrinter.cpp
+++ b/clang/lib/AST/DeclPrinter.cpp
@@ -250,23 +250,13 @@ raw_ostream& DeclPrinter::Indent(unsigned Indentation) {
   return Out;
 }
 
-// For CLANG_ATTR_LIST_CanPrintOnLeft macro.
-#include "clang/Basic/AttrLeftSideCanPrintList.inc"
-
-// For CLANG_ATTR_LIST_PrintOnLeft macro.
-#include "clang/Basic/AttrLeftSideMustPrintList.inc"
-
 static bool canPrintOnLeftSide(attr::Kind kind) {
-#ifdef CLANG_ATTR_LIST_CanPrintOnLeft
   switch (kind) {
-  CLANG_ATTR_LIST_CanPrintOnLeft
+#include "clang/Basic/AttrLeftSideCanPrintList.inc"
 return true;
   default:
 return false;
   }
-#else
-  return false;
-#endif
 }
 
 static bool canPrintOnLeftSide(const Attr *A) {
@@ -278,16 +268,11 @@ static bool canPrintOnLeftSide(const Attr *A) {
 
 static bool mustPrintOnLeftSide(attr::Kind kind) {
   switch (kind) {
-#ifdef CLANG_ATTR_LIST_PrintOnLeft
-  switch (kind) {
-  CLANG_ATTR_LIST_PrintOnLeft
+#include "clang/Basic/AttrLeftSideMustPrintList.inc"
 return true;
   default:
 return false;
   }
-#else
-  return false;
-#endif
 }
 
 static bool mustPrintOnLeftSide(const Attr *A) {
@@ -329,6 +314,7 @@ void DeclPrinter::prettyPrintAttributes(Decl *D, 
llvm::raw_ostream ,
VD->getInitStyle() == VarDecl::CallInit)
   AttrLoc = AttrPrintLoc::Left;
   }
+
   // Only print the side matches the user requested.
   if ((Loc & AttrLoc) != AttrPrintLoc::None)
 A->printPretty(Out, Policy);
diff --git a/clang/utils/TableGen/ClangAttrEmitter.cpp 
b/clang/utils/TableGen/ClangAttrEmitter.cpp
index eb5c34d15693d7..985cc1aee579e9 100644
--- a/clang/utils/TableGen/ClangAttrEmitter.cpp
+++ b/clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -3327,8 +3327,6 @@ void EmitClangAttrPrintList(const std::string , 
RecordKeeper ,
 
   std::vector Attrs = Records.getAllDerivedDefinitions("Attr");
   std::vector PragmaAttrs;
-  bool first = false;
-
   for (auto *Attr : Attrs) {
 if (!Attr->getValueAsBit("ASTNode"))
   continue;
@@ -3336,15 +3334,8 @@ void EmitClangAttrPrintList(const std::string 
, RecordKeeper ,
 if (!Attr->getValueAsBit(FieldName))
   continue;
 
-if (!first) {
-  first = true;
-  OS << "#define CLANG_ATTR_LIST_" << FieldName;
-}
-
-OS << " \\\n case attr::" << Attr->getName() << ":";
+OS << "case attr::" << Attr->getName() << ":\n";
   }
-
-  OS << '\n';
 }
 
 // Emits the enumeration list for attributes.

>From e7e2e90da2a9644b0ca8a4c5c464c75a35f019a5 Mon Sep 17 00:00:00 2001
From: Vassil Vassilev 
Date: Mon, 1 Apr 2024 15:11:28 +
Subject: [PATCH 03/10] Revert "Fix ast print of variables with attributes"

This reverts commit 46f3ade5083b8bfce55c78a21086a487eaac6f99.
---
 clang/include/clang/Basic/Attr.td|  14 +-
 clang/include/clang/Basic/CMakeLists.txt |  10 --
 clang/lib/AST/DeclPrinter.cpp| 137 +++
 clang/test/AST/ast-print-attr-knr.c  |  17 ---
 clang/test/AST/ast-print-attr.c  |   6 -
 clang/test/AST/ast-print-method-decl.cpp |   2 +-
 clang/test/AST/ast-print-pragmas.cpp |   4 +-
 clang/test/Analysis/blocks.mm|   2 +-
 clang/test/OpenMP/assumes_codegen.cpp|  22 +--
 clang/test/OpenMP/assumes_print.cpp  |   6 +-
 clang/test/OpenMP/assumes_template_print.cpp |  20 +--
 clang/test/OpenMP/declare_simd_ast_print.cpp |   4 +-
 clang/test/Sema/attr-print.c |   3 +-
 clang/test/SemaCXX/attr-print.cpp|   3 +-
 clang/test/SemaCXX/cxx11-attr-print.cpp  |   7 +-
 

[clang] Rework the printing of attributes (PR #87281)

2024-04-08 Thread Erich Keane via cfe-commits


@@ -250,87 +238,47 @@ raw_ostream& DeclPrinter::Indent(unsigned Indentation) {
   return Out;
 }
 
-// For CLANG_ATTR_LIST_CanPrintOnLeft macro.
-#include "clang/Basic/AttrLeftSideCanPrintList.inc"
+static DeclPrinter::AttrPosAsWritten getPosAsWritten(const Attr *A,
+ const Decl *D) {
+  SourceLocation ALoc = A->getLoc();
+  SourceLocation DLoc = D->getLocation();
+  const ASTContext  = D->getASTContext();
+  if (ALoc.isInvalid() || DLoc.isInvalid())
+return DeclPrinter::AttrPosAsWritten::Unknown;
 
-// For CLANG_ATTR_LIST_PrintOnLeft macro.
-#include "clang/Basic/AttrLeftSideMustPrintList.inc"
+  if (C.getSourceManager().isBeforeInTranslationUnit(ALoc, DLoc))
+return DeclPrinter::AttrPosAsWritten::Left;
 
-static bool canPrintOnLeftSide(attr::Kind kind) {
-#ifdef CLANG_ATTR_LIST_CanPrintOnLeft
-  switch (kind) {
-  CLANG_ATTR_LIST_CanPrintOnLeft
-return true;
-  default:
-return false;
-  }
-#else
-  return false;
-#endif
-}
-
-static bool canPrintOnLeftSide(const Attr *A) {
-  if (A->isStandardAttributeSyntax())
-return false;
-
-  return canPrintOnLeftSide(A->getKind());
+  return DeclPrinter::AttrPosAsWritten::Right;
 }
 
-static bool mustPrintOnLeftSide(attr::Kind kind) {
-#ifdef CLANG_ATTR_LIST_PrintOnLeft
-  switch (kind) {
-  CLANG_ATTR_LIST_PrintOnLeft
-return true;
-  default:
-return false;
-  }
-#else
-  return false;
-#endif
-}
-
-static bool mustPrintOnLeftSide(const Attr *A) {
-  if (A->isDeclspecAttribute())
-return true;
-
-  return mustPrintOnLeftSide(A->getKind());
-}
-
-void DeclPrinter::prettyPrintAttributes(Decl *D, llvm::raw_ostream ,
-AttrPrintLoc Loc) {
+void DeclPrinter::prettyPrintAttributes(const Decl *D,
+AttrPosAsWritten Pos /*=Default*/) {
   if (Policy.PolishForDeclaration)
 return;
 
   if (D->hasAttrs()) {
-AttrVec  = D->getAttrs();
+const AttrVec  = D->getAttrs();

erichkeane wrote:

I see that, it does what I want, yes.

https://github.com/llvm/llvm-project/pull/87281
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Rework the printing of attributes (PR #87281)

2024-04-08 Thread Erich Keane via cfe-commits


@@ -250,87 +238,50 @@ raw_ostream& DeclPrinter::Indent(unsigned Indentation) {
   return Out;
 }
 
-// For CLANG_ATTR_LIST_CanPrintOnLeft macro.
-#include "clang/Basic/AttrLeftSideCanPrintList.inc"
+static DeclPrinter::AttrPosAsWritten getPosAsWritten(const Attr *A,
+ const Decl *D) {
+  SourceLocation ALoc = A->getLoc();
+  SourceLocation DLoc = D->getLocation();
+  const ASTContext  = D->getASTContext();
+  if (ALoc.isInvalid() || DLoc.isInvalid())
+return DeclPrinter::AttrPosAsWritten::Unknown;
 
-// For CLANG_ATTR_LIST_PrintOnLeft macro.
-#include "clang/Basic/AttrLeftSideMustPrintList.inc"
+  if (C.getSourceManager().isBeforeInTranslationUnit(ALoc, DLoc))
+return DeclPrinter::AttrPosAsWritten::Left;
 
-static bool canPrintOnLeftSide(attr::Kind kind) {
-#ifdef CLANG_ATTR_LIST_CanPrintOnLeft
-  switch (kind) {
-  CLANG_ATTR_LIST_CanPrintOnLeft
-return true;
-  default:
-return false;
-  }
-#else
-  return false;
-#endif
-}
-
-static bool canPrintOnLeftSide(const Attr *A) {
-  if (A->isStandardAttributeSyntax())
-return false;
-
-  return canPrintOnLeftSide(A->getKind());
+  return DeclPrinter::AttrPosAsWritten::Right;
 }
 
-static bool mustPrintOnLeftSide(attr::Kind kind) {
-#ifdef CLANG_ATTR_LIST_PrintOnLeft
-  switch (kind) {
-  CLANG_ATTR_LIST_PrintOnLeft
-return true;
-  default:
-return false;
-  }
-#else
-  return false;
-#endif
-}
-
-static bool mustPrintOnLeftSide(const Attr *A) {
-  if (A->isDeclspecAttribute())
-return true;
-
-  return mustPrintOnLeftSide(A->getKind());
-}
-
-void DeclPrinter::prettyPrintAttributes(Decl *D, llvm::raw_ostream ,
-AttrPrintLoc Loc) {
+void DeclPrinter::prettyPrintAttributes(const Decl *D,
+AttrPosAsWritten Pos /*=Default*/) {
   if (Policy.PolishForDeclaration)
 return;
 
   if (D->hasAttrs()) {
-AttrVec  = D->getAttrs();
+assert(Pos != AttrPosAsWritten::Unknown && "Use Default");
+const AttrVec  = D->getAttrs();
 for (auto *A : Attrs) {
   if (A->isInherited() || A->isImplicit())
 continue;
-
-  AttrPrintLoc AttrLoc = AttrPrintLoc::Right;
-  if (mustPrintOnLeftSide(A)) {
-// If we must always print on left side (e.g. declspec), then mark as
-// so.
-AttrLoc = AttrPrintLoc::Left;
-  } else if (canPrintOnLeftSide(A)) {
-// For functions with body defined we print the attributes on the left
-// side so that GCC accept our dumps as well.
-if (const FunctionDecl *FD = dyn_cast(D);
-FD && FD->isThisDeclarationADefinition())
-  // In case Decl is a function with a body, then attrs should be print
-  // on the left side.
-  AttrLoc = AttrPrintLoc::Left;
-
-  // In case it is a variable declaration with a ctor, then allow
-  // printing on the left side for readbility.
-else if (const VarDecl *VD = dyn_cast(D);
-   VD && VD->getInit() &&
-   VD->getInitStyle() == VarDecl::CallInit)
-  AttrLoc = AttrPrintLoc::Left;
+  switch (A->getKind()) {
+#define ATTR(X)
+#define PRAGMA_SPELLING_ATTR(X) case attr::X:
+#include "clang/Basic/AttrList.inc"
+break;
+  default:
+AttrPosAsWritten APos = getPosAsWritten(A, D);
+// Might trigger on programatically created attributes with no source

erichkeane wrote:

```suggestion
// Might trigger on programatically created attributes or declarations 
with no source
```

https://github.com/llvm/llvm-project/pull/87281
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Rework the printing of attributes (PR #87281)

2024-04-08 Thread Erich Keane via cfe-commits


@@ -250,87 +238,50 @@ raw_ostream& DeclPrinter::Indent(unsigned Indentation) {
   return Out;
 }
 
-// For CLANG_ATTR_LIST_CanPrintOnLeft macro.
-#include "clang/Basic/AttrLeftSideCanPrintList.inc"
+static DeclPrinter::AttrPosAsWritten getPosAsWritten(const Attr *A,
+ const Decl *D) {
+  SourceLocation ALoc = A->getLoc();
+  SourceLocation DLoc = D->getLocation();
+  const ASTContext  = D->getASTContext();
+  if (ALoc.isInvalid() || DLoc.isInvalid())
+return DeclPrinter::AttrPosAsWritten::Unknown;
 
-// For CLANG_ATTR_LIST_PrintOnLeft macro.
-#include "clang/Basic/AttrLeftSideMustPrintList.inc"
+  if (C.getSourceManager().isBeforeInTranslationUnit(ALoc, DLoc))
+return DeclPrinter::AttrPosAsWritten::Left;
 
-static bool canPrintOnLeftSide(attr::Kind kind) {
-#ifdef CLANG_ATTR_LIST_CanPrintOnLeft
-  switch (kind) {
-  CLANG_ATTR_LIST_CanPrintOnLeft
-return true;
-  default:
-return false;
-  }
-#else
-  return false;
-#endif
-}
-
-static bool canPrintOnLeftSide(const Attr *A) {
-  if (A->isStandardAttributeSyntax())
-return false;
-
-  return canPrintOnLeftSide(A->getKind());
+  return DeclPrinter::AttrPosAsWritten::Right;
 }
 
-static bool mustPrintOnLeftSide(attr::Kind kind) {
-#ifdef CLANG_ATTR_LIST_PrintOnLeft
-  switch (kind) {
-  CLANG_ATTR_LIST_PrintOnLeft
-return true;
-  default:
-return false;
-  }
-#else
-  return false;
-#endif
-}
-
-static bool mustPrintOnLeftSide(const Attr *A) {
-  if (A->isDeclspecAttribute())
-return true;
-
-  return mustPrintOnLeftSide(A->getKind());
-}
-
-void DeclPrinter::prettyPrintAttributes(Decl *D, llvm::raw_ostream ,
-AttrPrintLoc Loc) {
+void DeclPrinter::prettyPrintAttributes(const Decl *D,
+AttrPosAsWritten Pos /*=Default*/) {
   if (Policy.PolishForDeclaration)
 return;
 
   if (D->hasAttrs()) {
-AttrVec  = D->getAttrs();
+assert(Pos != AttrPosAsWritten::Unknown && "Use Default");
+const AttrVec  = D->getAttrs();
 for (auto *A : Attrs) {
   if (A->isInherited() || A->isImplicit())
 continue;
-
-  AttrPrintLoc AttrLoc = AttrPrintLoc::Right;
-  if (mustPrintOnLeftSide(A)) {
-// If we must always print on left side (e.g. declspec), then mark as
-// so.
-AttrLoc = AttrPrintLoc::Left;
-  } else if (canPrintOnLeftSide(A)) {
-// For functions with body defined we print the attributes on the left
-// side so that GCC accept our dumps as well.
-if (const FunctionDecl *FD = dyn_cast(D);
-FD && FD->isThisDeclarationADefinition())
-  // In case Decl is a function with a body, then attrs should be print
-  // on the left side.
-  AttrLoc = AttrPrintLoc::Left;
-
-  // In case it is a variable declaration with a ctor, then allow
-  // printing on the left side for readbility.
-else if (const VarDecl *VD = dyn_cast(D);
-   VD && VD->getInit() &&
-   VD->getInitStyle() == VarDecl::CallInit)
-  AttrLoc = AttrPrintLoc::Left;
+  switch (A->getKind()) {
+#define ATTR(X)
+#define PRAGMA_SPELLING_ATTR(X) case attr::X:
+#include "clang/Basic/AttrList.inc"
+break;
+  default:
+AttrPosAsWritten APos = getPosAsWritten(A, D);
+// Might trigger on programatically created attributes with no source
+// locations.
+assert(APos != AttrPosAsWritten::Unknown && "Implicit attribute!");

erichkeane wrote:

```suggestion
assert(APos != AttrPosAsWritten::Unknown &&  "Invalid source location 
for attribute or decl.");
assert(APos !=AttrPosAsWritten::Default && "Default not a valid for an 
attribute location");
```

https://github.com/llvm/llvm-project/pull/87281
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Rework the printing of attributes (PR #87281)

2024-04-08 Thread Erich Keane via cfe-commits

https://github.com/erichkeane edited 
https://github.com/llvm/llvm-project/pull/87281
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Rework the printing of attributes (PR #87281)

2024-04-08 Thread Erich Keane via cfe-commits

https://github.com/erichkeane approved this pull request.


https://github.com/llvm/llvm-project/pull/87281
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Rework the printing of attributes (PR #87281)

2024-04-08 Thread Vassil Vassilev via cfe-commits


@@ -250,87 +238,47 @@ raw_ostream& DeclPrinter::Indent(unsigned Indentation) {
   return Out;
 }
 
-// For CLANG_ATTR_LIST_CanPrintOnLeft macro.
-#include "clang/Basic/AttrLeftSideCanPrintList.inc"
+static DeclPrinter::AttrPosAsWritten getPosAsWritten(const Attr *A,
+ const Decl *D) {
+  SourceLocation ALoc = A->getLoc();
+  SourceLocation DLoc = D->getLocation();
+  const ASTContext  = D->getASTContext();
+  if (ALoc.isInvalid() || DLoc.isInvalid())
+return DeclPrinter::AttrPosAsWritten::Unknown;
 
-// For CLANG_ATTR_LIST_PrintOnLeft macro.
-#include "clang/Basic/AttrLeftSideMustPrintList.inc"
+  if (C.getSourceManager().isBeforeInTranslationUnit(ALoc, DLoc))
+return DeclPrinter::AttrPosAsWritten::Left;
 
-static bool canPrintOnLeftSide(attr::Kind kind) {
-#ifdef CLANG_ATTR_LIST_CanPrintOnLeft
-  switch (kind) {
-  CLANG_ATTR_LIST_CanPrintOnLeft
-return true;
-  default:
-return false;
-  }
-#else
-  return false;
-#endif
-}
-
-static bool canPrintOnLeftSide(const Attr *A) {
-  if (A->isStandardAttributeSyntax())
-return false;
-
-  return canPrintOnLeftSide(A->getKind());
+  return DeclPrinter::AttrPosAsWritten::Right;
 }
 
-static bool mustPrintOnLeftSide(attr::Kind kind) {
-#ifdef CLANG_ATTR_LIST_PrintOnLeft
-  switch (kind) {
-  CLANG_ATTR_LIST_PrintOnLeft
-return true;
-  default:
-return false;
-  }
-#else
-  return false;
-#endif
-}
-
-static bool mustPrintOnLeftSide(const Attr *A) {
-  if (A->isDeclspecAttribute())
-return true;
-
-  return mustPrintOnLeftSide(A->getKind());
-}
-
-void DeclPrinter::prettyPrintAttributes(Decl *D, llvm::raw_ostream ,
-AttrPrintLoc Loc) {
+void DeclPrinter::prettyPrintAttributes(const Decl *D,
+AttrPosAsWritten Pos /*=Default*/) {
   if (Policy.PolishForDeclaration)
 return;
 
   if (D->hasAttrs()) {
-AttrVec  = D->getAttrs();
+const AttrVec  = D->getAttrs();

vgvassilev wrote:

I added an assert in the if-stmt. Is that what you meant?

https://github.com/llvm/llvm-project/pull/87281
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Rework the printing of attributes (PR #87281)

2024-04-08 Thread Vassil Vassilev via cfe-commits


@@ -250,87 +238,47 @@ raw_ostream& DeclPrinter::Indent(unsigned Indentation) {
   return Out;
 }
 
-// For CLANG_ATTR_LIST_CanPrintOnLeft macro.
-#include "clang/Basic/AttrLeftSideCanPrintList.inc"
+static DeclPrinter::AttrPosAsWritten getPosAsWritten(const Attr *A,
+ const Decl *D) {
+  SourceLocation ALoc = A->getLoc();
+  SourceLocation DLoc = D->getLocation();
+  const ASTContext  = D->getASTContext();
+  if (ALoc.isInvalid() || DLoc.isInvalid())
+return DeclPrinter::AttrPosAsWritten::Unknown;
 
-// For CLANG_ATTR_LIST_PrintOnLeft macro.
-#include "clang/Basic/AttrLeftSideMustPrintList.inc"
+  if (C.getSourceManager().isBeforeInTranslationUnit(ALoc, DLoc))
+return DeclPrinter::AttrPosAsWritten::Left;
 
-static bool canPrintOnLeftSide(attr::Kind kind) {
-#ifdef CLANG_ATTR_LIST_CanPrintOnLeft
-  switch (kind) {
-  CLANG_ATTR_LIST_CanPrintOnLeft
-return true;
-  default:
-return false;
-  }
-#else
-  return false;
-#endif
-}
-
-static bool canPrintOnLeftSide(const Attr *A) {
-  if (A->isStandardAttributeSyntax())
-return false;
-
-  return canPrintOnLeftSide(A->getKind());
+  return DeclPrinter::AttrPosAsWritten::Right;
 }
 
-static bool mustPrintOnLeftSide(attr::Kind kind) {
-#ifdef CLANG_ATTR_LIST_PrintOnLeft
-  switch (kind) {
-  CLANG_ATTR_LIST_PrintOnLeft
-return true;
-  default:
-return false;
-  }
-#else
-  return false;
-#endif
-}
-
-static bool mustPrintOnLeftSide(const Attr *A) {
-  if (A->isDeclspecAttribute())
-return true;
-
-  return mustPrintOnLeftSide(A->getKind());
-}
-
-void DeclPrinter::prettyPrintAttributes(Decl *D, llvm::raw_ostream ,
-AttrPrintLoc Loc) {
+void DeclPrinter::prettyPrintAttributes(const Decl *D,
+AttrPosAsWritten Pos /*=Default*/) {
   if (Policy.PolishForDeclaration)
 return;
 
   if (D->hasAttrs()) {
-AttrVec  = D->getAttrs();
+const AttrVec  = D->getAttrs();
 for (auto *A : Attrs) {
   if (A->isInherited() || A->isImplicit())
 continue;
-
-  AttrPrintLoc AttrLoc = AttrPrintLoc::Right;
-  if (mustPrintOnLeftSide(A)) {
-// If we must always print on left side (e.g. declspec), then mark as
-// so.
-AttrLoc = AttrPrintLoc::Left;
-  } else if (canPrintOnLeftSide(A)) {
-// For functions with body defined we print the attributes on the left
-// side so that GCC accept our dumps as well.
-if (const FunctionDecl *FD = dyn_cast(D);
-FD && FD->isThisDeclarationADefinition())
-  // In case Decl is a function with a body, then attrs should be print
-  // on the left side.
-  AttrLoc = AttrPrintLoc::Left;
-
-  // In case it is a variable declaration with a ctor, then allow
-  // printing on the left side for readbility.
-else if (const VarDecl *VD = dyn_cast(D);
-   VD && VD->getInit() &&
-   VD->getInitStyle() == VarDecl::CallInit)
-  AttrLoc = AttrPrintLoc::Left;
+  switch (A->getKind()) {
+#define ATTR(X)
+#define PRAGMA_SPELLING_ATTR(X) case attr::X:
+#include "clang/Basic/AttrList.inc"
+break;
+  default:
+AttrPosAsWritten APos = getPosAsWritten(A, D);
+assert(APos != AttrPosAsWritten::Unknown && "Implicit attribute!");

vgvassilev wrote:

Comment added.

https://github.com/llvm/llvm-project/pull/87281
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Rework the printing of attributes (PR #87281)

2024-04-08 Thread Vassil Vassilev via cfe-commits

https://github.com/vgvassilev updated 
https://github.com/llvm/llvm-project/pull/87281

>From 94f1c8653903cc3db55abd641c68a9dd11f05df3 Mon Sep 17 00:00:00 2001
From: Vassil Vassilev 
Date: Mon, 1 Apr 2024 15:01:33 +
Subject: [PATCH 1/9] Revert "Remove extra switch from  0323938d"

This reverts commit 6c0b9e35761738726aded3b399db89eb0a86f82b.
---
 clang/lib/AST/DeclPrinter.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/clang/lib/AST/DeclPrinter.cpp b/clang/lib/AST/DeclPrinter.cpp
index edbcdfe4d55bc9..1ab74c71d0fd49 100644
--- a/clang/lib/AST/DeclPrinter.cpp
+++ b/clang/lib/AST/DeclPrinter.cpp
@@ -277,6 +277,7 @@ static bool canPrintOnLeftSide(const Attr *A) {
 }
 
 static bool mustPrintOnLeftSide(attr::Kind kind) {
+  switch (kind) {
 #ifdef CLANG_ATTR_LIST_PrintOnLeft
   switch (kind) {
   CLANG_ATTR_LIST_PrintOnLeft

>From 871f5b06e0da167c4cf50d336bdc38f0eb684b6b Mon Sep 17 00:00:00 2001
From: Vassil Vassilev 
Date: Mon, 1 Apr 2024 15:01:44 +
Subject: [PATCH 2/9] Revert "Fix warning in MSVC"

This reverts commit 0323938d3c7a1a48b60a7dea8ec7300e98b4a931.
---
 clang/lib/AST/DeclPrinter.cpp | 20 +++-
 clang/utils/TableGen/ClangAttrEmitter.cpp | 11 +--
 2 files changed, 4 insertions(+), 27 deletions(-)

diff --git a/clang/lib/AST/DeclPrinter.cpp b/clang/lib/AST/DeclPrinter.cpp
index 1ab74c71d0fd49..c2e0edd5f1f12c 100644
--- a/clang/lib/AST/DeclPrinter.cpp
+++ b/clang/lib/AST/DeclPrinter.cpp
@@ -250,23 +250,13 @@ raw_ostream& DeclPrinter::Indent(unsigned Indentation) {
   return Out;
 }
 
-// For CLANG_ATTR_LIST_CanPrintOnLeft macro.
-#include "clang/Basic/AttrLeftSideCanPrintList.inc"
-
-// For CLANG_ATTR_LIST_PrintOnLeft macro.
-#include "clang/Basic/AttrLeftSideMustPrintList.inc"
-
 static bool canPrintOnLeftSide(attr::Kind kind) {
-#ifdef CLANG_ATTR_LIST_CanPrintOnLeft
   switch (kind) {
-  CLANG_ATTR_LIST_CanPrintOnLeft
+#include "clang/Basic/AttrLeftSideCanPrintList.inc"
 return true;
   default:
 return false;
   }
-#else
-  return false;
-#endif
 }
 
 static bool canPrintOnLeftSide(const Attr *A) {
@@ -278,16 +268,11 @@ static bool canPrintOnLeftSide(const Attr *A) {
 
 static bool mustPrintOnLeftSide(attr::Kind kind) {
   switch (kind) {
-#ifdef CLANG_ATTR_LIST_PrintOnLeft
-  switch (kind) {
-  CLANG_ATTR_LIST_PrintOnLeft
+#include "clang/Basic/AttrLeftSideMustPrintList.inc"
 return true;
   default:
 return false;
   }
-#else
-  return false;
-#endif
 }
 
 static bool mustPrintOnLeftSide(const Attr *A) {
@@ -329,6 +314,7 @@ void DeclPrinter::prettyPrintAttributes(Decl *D, 
llvm::raw_ostream ,
VD->getInitStyle() == VarDecl::CallInit)
   AttrLoc = AttrPrintLoc::Left;
   }
+
   // Only print the side matches the user requested.
   if ((Loc & AttrLoc) != AttrPrintLoc::None)
 A->printPretty(Out, Policy);
diff --git a/clang/utils/TableGen/ClangAttrEmitter.cpp 
b/clang/utils/TableGen/ClangAttrEmitter.cpp
index eb5c34d15693d7..985cc1aee579e9 100644
--- a/clang/utils/TableGen/ClangAttrEmitter.cpp
+++ b/clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -3327,8 +3327,6 @@ void EmitClangAttrPrintList(const std::string , 
RecordKeeper ,
 
   std::vector Attrs = Records.getAllDerivedDefinitions("Attr");
   std::vector PragmaAttrs;
-  bool first = false;
-
   for (auto *Attr : Attrs) {
 if (!Attr->getValueAsBit("ASTNode"))
   continue;
@@ -3336,15 +3334,8 @@ void EmitClangAttrPrintList(const std::string 
, RecordKeeper ,
 if (!Attr->getValueAsBit(FieldName))
   continue;
 
-if (!first) {
-  first = true;
-  OS << "#define CLANG_ATTR_LIST_" << FieldName;
-}
-
-OS << " \\\n case attr::" << Attr->getName() << ":";
+OS << "case attr::" << Attr->getName() << ":\n";
   }
-
-  OS << '\n';
 }
 
 // Emits the enumeration list for attributes.

>From e7e2e90da2a9644b0ca8a4c5c464c75a35f019a5 Mon Sep 17 00:00:00 2001
From: Vassil Vassilev 
Date: Mon, 1 Apr 2024 15:11:28 +
Subject: [PATCH 3/9] Revert "Fix ast print of variables with attributes"

This reverts commit 46f3ade5083b8bfce55c78a21086a487eaac6f99.
---
 clang/include/clang/Basic/Attr.td|  14 +-
 clang/include/clang/Basic/CMakeLists.txt |  10 --
 clang/lib/AST/DeclPrinter.cpp| 137 +++
 clang/test/AST/ast-print-attr-knr.c  |  17 ---
 clang/test/AST/ast-print-attr.c  |   6 -
 clang/test/AST/ast-print-method-decl.cpp |   2 +-
 clang/test/AST/ast-print-pragmas.cpp |   4 +-
 clang/test/Analysis/blocks.mm|   2 +-
 clang/test/OpenMP/assumes_codegen.cpp|  22 +--
 clang/test/OpenMP/assumes_print.cpp  |   6 +-
 clang/test/OpenMP/assumes_template_print.cpp |  20 +--
 clang/test/OpenMP/declare_simd_ast_print.cpp |   4 +-
 clang/test/Sema/attr-print.c |   3 +-
 clang/test/SemaCXX/attr-print.cpp|   3 +-
 clang/test/SemaCXX/cxx11-attr-print.cpp  |   7 +-
 

[clang] [clang-tools-extra] [clang][modules] Do not resolve `HeaderFileInfo` externally in `ASTWriter` (PR #87848)

2024-04-08 Thread via cfe-commits

llvmbot wrote:



@llvm/pr-subscribers-clang

@llvm/pr-subscribers-clangd

Author: Jan Svoboda (jansvoboda11)


Changes

Clang uses the `HeaderFileInfo` struct to track bits of information on header 
files, which gets used throughout the compiler. We also use this to compute the 
set of affecting module maps in `ASTWriter` and in the end serialize the 
information into the `HEADER_SEARCH_TABLE` record of a PCM file, allowing 
clients to learn about headers from the module. In doing so, Clang asks for 
existing `HeaderFileInfo` for all known `FileEntries`. Note that this asks the 
loaded PCM files for the information they have on each header file in question. 
This seems unnecessary: we only want to serialize information on header files 
that either belong to the current module or that got included textually. Loaded 
PCM files can't provide us with any useful information.

For explicit modules with lazy loading (using `-fmodule-map-file=path` 
with `-fmodule-file=name=path`) the compiler knows about header 
files listed in the module map files on the command-line. This can be a large 
number.

Asking for existing `HeaderFileInfo` can trigger deserialization of 
`HEADER_SEARCH_TABLE` from loaded PCM files. Keys of the on-disk hash table 
consist of the header file size and modification time. However, with explicit 
modules Clang zeroes out the modification time. Moreover, if you import lots of 
modules, some of their header files end up having identical sizes. This means 
lots of hash collisions that can only be resolved by running the serialized 
filename through `FileManager` and comparing equality of the `FileEntry`. This 
ends up being super expensive, essentially re-stating lots of the transitively 
loaded SDK header files.

This patch cleans up the API for getting `HeaderFileInfo` and makes sure 
`ASTWriter` uses the version that doesn't ask loaded PCM files for more 
information. This removes the excessive stat traffic coming from `ASTWriter` 
hopefully without changing observable behavior.

---
Full diff: https://github.com/llvm/llvm-project/pull/87848.diff


5 Files Affected:

- (modified) clang-tools-extra/clangd/index/SymbolCollector.cpp (+1-1) 
- (modified) clang/include/clang/Lex/HeaderSearch.h (+13-11) 
- (modified) clang/lib/Lex/HeaderSearch.cpp (+42-35) 
- (modified) clang/lib/Serialization/ASTWriter.cpp (+4-7) 
- (added) clang/test/Modules/foo.c (+48) 


``diff
diff --git a/clang-tools-extra/clangd/index/SymbolCollector.cpp 
b/clang-tools-extra/clangd/index/SymbolCollector.cpp
index 85b8fc549b016e..5c4e2150cf3123 100644
--- a/clang-tools-extra/clangd/index/SymbolCollector.cpp
+++ b/clang-tools-extra/clangd/index/SymbolCollector.cpp
@@ -409,7 +409,7 @@ class SymbolCollector::HeaderFileURICache {
 // Framework headers are spelled as , not
 // "path/FrameworkName.framework/Headers/Foo.h".
 auto  = PP->getHeaderSearchInfo();
-if (const auto *HFI = HS.getExistingFileInfo(*FE, /*WantExternal*/ false))
+if (const auto *HFI = HS.getExistingFileInfo(*FE))
   if (!HFI->Framework.empty())
 if (auto Spelling =
 getFrameworkHeaderIncludeSpelling(*FE, HFI->Framework, HS))
diff --git a/clang/include/clang/Lex/HeaderSearch.h 
b/clang/include/clang/Lex/HeaderSearch.h
index 705dcfa8aacc3f..b8724e9aa3c92e 100644
--- a/clang/include/clang/Lex/HeaderSearch.h
+++ b/clang/include/clang/Lex/HeaderSearch.h
@@ -529,14 +529,15 @@ class HeaderSearch {
   /// Return whether the specified file is a normal header,
   /// a system header, or a C++ friendly system header.
   SrcMgr::CharacteristicKind getFileDirFlavor(FileEntryRef File) {
-return (SrcMgr::CharacteristicKind)getFileInfo(File).DirInfo;
+if (const HeaderFileInfo *HFI = getExistingFileInfo(File))
+  return (SrcMgr::CharacteristicKind)HFI->DirInfo;
+return (SrcMgr::CharacteristicKind)HeaderFileInfo().DirInfo;
   }
 
   /// Mark the specified file as a "once only" file due to
   /// \#pragma once.
   void MarkFileIncludeOnce(FileEntryRef File) {
-HeaderFileInfo  = getFileInfo(File);
-FI.isPragmaOnce = true;
+getFileInfo(File).isPragmaOnce = true;
   }
 
   /// Mark the specified file as a system header, e.g. due to
@@ -816,16 +817,17 @@ class HeaderSearch {
 
   unsigned header_file_size() const { return FileInfo.size(); }
 
-  /// Return the HeaderFileInfo structure for the specified FileEntry,
-  /// in preparation for updating it in some way.
+  /// Return the HeaderFileInfo structure for the specified FileEntry, in
+  /// preparation for updating it in some way.
   HeaderFileInfo (FileEntryRef FE);
 
-  /// Return the HeaderFileInfo structure for the specified FileEntry,
-  /// if it has ever been filled in.
-  /// \param WantExternal Whether the caller wants purely-external header file
-  ///info (where \p External is true).
-  const HeaderFileInfo *getExistingFileInfo(FileEntryRef FE,
-bool WantExternal = true) const;
+  

[clang] [clang-tools-extra] [clang][modules] Do not resolve `HeaderFileInfo` externally in `ASTWriter` (PR #87848)

2024-04-08 Thread Jan Svoboda via cfe-commits

https://github.com/jansvoboda11 ready_for_review 
https://github.com/llvm/llvm-project/pull/87848
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] [clang][modules] Do not resolve `HeaderFileInfo` externally in `ASTWriter` (PR #87848)

2024-04-08 Thread Jan Svoboda via cfe-commits

https://github.com/jansvoboda11 edited 
https://github.com/llvm/llvm-project/pull/87848
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][dataflow] Propagate locations from result objects to initializers. (PR #87320)

2024-04-08 Thread Gábor Horváth via cfe-commits


@@ -688,22 +689,45 @@ class Environment {
   /// and functions referenced in `FuncDecl`. `FuncDecl` must have a body.
   void initFieldsGlobalsAndFuncs(const FunctionDecl *FuncDecl);
 
+  static PrValueToResultObject
+  buildResultObjectMap(DataflowAnalysisContext *DACtx,
+   const FunctionDecl *FuncDecl,
+   RecordStorageLocation *ThisPointeeLoc,
+   RecordStorageLocation *LocForRecordReturnVal);
+
   // `DACtx` is not null and not owned by this object.
   DataflowAnalysisContext *DACtx;
 
-  // FIXME: move the fields `CallStack`, `ReturnVal`, `ReturnLoc` and
-  // `ThisPointeeLoc` into a separate call-context object, shared between
-  // environments in the same call.
+  // FIXME: move the fields `CallStack`, `ResultObjectMap`, `ReturnVal`,
+  // `ReturnLoc` and `ThisPointeeLoc` into a separate call-context object,
+  // shared between environments in the same call.
   // https://github.com/llvm/llvm-project/issues/59005
 
   // `DeclContext` of the block being analysed if provided.
   std::vector CallStack;
 
-  // Value returned by the function (if it has non-reference return type).
+  // Maps from prvalues of record type to their result objects. Shared between
+  // all environments for the same function.
+  // FIXME: It's somewhat unsatisfactory that we have to use a `shared_ptr`
+  // here, though the cost is acceptable: The overhead of a `shared_ptr` is
+  // incurred when it is copied, and this happens only relatively rarely (when
+  // we fork the environment). The need for a `shared_ptr` will go away once we
+  // introduce a shared call-context object (see above).
+  std::shared_ptr ResultObjectMap;

Xazax-hun wrote:

> we should create a call-context object

Ah, ok. +1, I like this approach. 

https://github.com/llvm/llvm-project/pull/87320
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-format] Remove trailing newlines in TableGen formatting test. (PR #87983)

2024-04-08 Thread Owen Pan via cfe-commits

https://github.com/owenca approved this pull request.


https://github.com/llvm/llvm-project/pull/87983
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][modules] Only compute affecting module maps with implicit search (PR #87849)

2024-04-08 Thread Ben Langmuir via cfe-commits

https://github.com/benlangmuir approved this pull request.


https://github.com/llvm/llvm-project/pull/87849
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Match against all plugins when parsing microsoft attributes (PR #86426)

2024-04-08 Thread via cfe-commits

https://github.com/apache-hb updated 
https://github.com/llvm/llvm-project/pull/86426

>From 245a21512d8658225b17b91b8af4764f54084e01 Mon Sep 17 00:00:00 2001
From: Elliot <35050275+apache...@users.noreply.github.com>
Date: Sun, 24 Mar 2024 03:03:47 -0400
Subject: [PATCH 1/8] Match against all plugins when parsing microsoft
 attributes

fixes #86422
---
 clang/lib/Parse/ParseDeclCXX.cpp | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp
index 63fe678cbb29e2..d05b3a455f7f63 100644
--- a/clang/lib/Parse/ParseDeclCXX.cpp
+++ b/clang/lib/Parse/ParseDeclCXX.cpp
@@ -5061,11 +5061,12 @@ void Parser::ParseMicrosoftAttributes(ParsedAttributes 
) {
 IdentifierInfo *II = Tok.getIdentifierInfo();
 SourceLocation NameLoc = Tok.getLocation();
 ConsumeToken();
-ParsedAttr::Kind AttrKind =
-ParsedAttr::getParsedKind(II, nullptr, ParsedAttr::AS_Microsoft);
+
 // For HLSL we want to handle all attributes, but for MSVC compat, we
 // silently ignore unknown Microsoft attributes.
-if (getLangOpts().HLSL || AttrKind != ParsedAttr::UnknownAttribute) {
+AttributeCommonInfo Info{II, NameLoc, 
AttributeCommonInfo::Form::Microsoft()};
+const ParsedAttrInfo& AttrInfo = ParsedAttrInfo::get(Info);
+if (getLangOpts().HLSL || 
AttrInfo.hasSpelling(AttributeCommonInfo::AS_Microsoft, II->getName())) {
   bool AttrParsed = false;
   if (Tok.is(tok::l_paren)) {
 CachedTokens OpenMPTokens;

>From 4e47899a9fb17dec5931007b5025f6ce97dbe3eb Mon Sep 17 00:00:00 2001
From: Elliot <35050275+apache...@users.noreply.github.com>
Date: Sun, 24 Mar 2024 03:05:54 -0400
Subject: [PATCH 2/8] Apply formatting

---
 clang/lib/Parse/ParseDeclCXX.cpp | 9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp
index d05b3a455f7f63..856ac11f7bb839 100644
--- a/clang/lib/Parse/ParseDeclCXX.cpp
+++ b/clang/lib/Parse/ParseDeclCXX.cpp
@@ -5064,9 +5064,12 @@ void Parser::ParseMicrosoftAttributes(ParsedAttributes 
) {
 
 // For HLSL we want to handle all attributes, but for MSVC compat, we
 // silently ignore unknown Microsoft attributes.
-AttributeCommonInfo Info{II, NameLoc, 
AttributeCommonInfo::Form::Microsoft()};
-const ParsedAttrInfo& AttrInfo = ParsedAttrInfo::get(Info);
-if (getLangOpts().HLSL || 
AttrInfo.hasSpelling(AttributeCommonInfo::AS_Microsoft, II->getName())) {
+AttributeCommonInfo Info{II, NameLoc,
+ AttributeCommonInfo::Form::Microsoft()};
+const ParsedAttrInfo  = ParsedAttrInfo::get(Info);
+if (getLangOpts().HLSL ||
+AttrInfo.hasSpelling(AttributeCommonInfo::AS_Microsoft,
+ II->getName())) {
   bool AttrParsed = false;
   if (Tok.is(tok::l_paren)) {
 CachedTokens OpenMPTokens;

>From 8adb5bc07dd23afac4f66f6658a4197fb97f058f Mon Sep 17 00:00:00 2001
From: Elliot <35050275+apache...@users.noreply.github.com>
Date: Mon, 25 Mar 2024 13:37:00 -0400
Subject: [PATCH 3/8] use hasAttribute instead of ParsedAttrInfo::get

---
 clang/lib/Parse/ParseDeclCXX.cpp | 9 +++--
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp
index 856ac11f7bb839..619f7f88bfdbfe 100644
--- a/clang/lib/Parse/ParseDeclCXX.cpp
+++ b/clang/lib/Parse/ParseDeclCXX.cpp
@@ -5064,12 +5064,9 @@ void Parser::ParseMicrosoftAttributes(ParsedAttributes 
) {
 
 // For HLSL we want to handle all attributes, but for MSVC compat, we
 // silently ignore unknown Microsoft attributes.
-AttributeCommonInfo Info{II, NameLoc,
- AttributeCommonInfo::Form::Microsoft()};
-const ParsedAttrInfo  = ParsedAttrInfo::get(Info);
-if (getLangOpts().HLSL ||
-AttrInfo.hasSpelling(AttributeCommonInfo::AS_Microsoft,
- II->getName())) {
+int Attr = hasAttribute(AttributeCommonInfo::Syntax::AS_Microsoft, 
nullptr,
+II, getTargetInfo(), getLangOpts());
+if (getLangOpts().HLSL || Attr != 0) {
   bool AttrParsed = false;
   if (Tok.is(tok::l_paren)) {
 CachedTokens OpenMPTokens;

>From b3f297eec02643452a8815d7d62b1b5a0f07760b Mon Sep 17 00:00:00 2001
From: Elliot <35050275+apache...@users.noreply.github.com>
Date: Mon, 25 Mar 2024 13:54:27 -0400
Subject: [PATCH 4/8] Update ReleaseNotes.rst

---
 clang/docs/ReleaseNotes.rst | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 8054d90fc70f93..df73abb12e89fa 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -345,6 +345,9 @@ Bug Fixes to Compiler Builtins
 

[clang] [llvm] [RISCV] Zimop/Zcmop are ratified (PR #87966)

2024-04-08 Thread Craig Topper via cfe-commits


@@ -271,12 +271,6 @@ The primary goal of experimental support is to assist in 
the process of ratifica
 ``experimental-ztso``
   LLVM implements the `v0.1 proposed specification 
`__
 (see Chapter 25).  The mapping from the C/C++ memory model to Ztso has not yet 
been ratified in any standards document.  There are multiple possible mappings, 
and they are *not* mutually ABI compatible.  The mapping LLVM implements is ABI 
compatible with the default WMO mapping.  This mapping may change and there is 
*explicitly* no ABI stability offered while the extension remains in 
experimental status.  User beware.
 
-``experimental-zimop``

topperc wrote:

These need to be added to the non-experimental list earlier in this file.

https://github.com/llvm/llvm-project/pull/87966
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][modules] Only compute affecting module maps with implicit search (PR #87849)

2024-04-08 Thread Jan Svoboda via cfe-commits

jansvoboda11 wrote:

CC @ilyakuteev

https://github.com/llvm/llvm-project/pull/87849
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][modules] Only compute affecting module maps with implicit search (PR #87849)

2024-04-08 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-modules

Author: Jan Svoboda (jansvoboda11)


Changes

When writing out a PCM, we compute the set of module maps that did affect the 
compilation and we strip the rest to make the output independent of them. The 
most common way to read a module map that is not affecting is with implicit 
module map search. The other option is to pass a bunch of unnecessary 
`-fmodule-map-file=path` arguments on the command-line, in which case 
the client should probably not give those to Clang anyway.

This makes serialization of explicit modules faster, mostly due to reduced file 
system traffic.

---
Full diff: https://github.com/llvm/llvm-project/pull/87849.diff


1 Files Affected:

- (modified) clang/lib/Serialization/ASTWriter.cpp (+17-4) 


``diff
diff --git a/clang/lib/Serialization/ASTWriter.cpp 
b/clang/lib/Serialization/ASTWriter.cpp
index ba6a8a5e16e4e7..e1e22017595518 100644
--- a/clang/lib/Serialization/ASTWriter.cpp
+++ b/clang/lib/Serialization/ASTWriter.cpp
@@ -161,8 +161,13 @@ static TypeCode getTypeCodeForTypeClass(Type::TypeClass 
id) {
 
 namespace {
 
-std::set GetAffectingModuleMaps(const Preprocessor ,
-   Module *RootModule) {
+std::optional>
+GetAffectingModuleMaps(const Preprocessor , Module *RootModule) {
+  // Without implicit module map search, there's no good reason to know about
+  // any module maps that are not affecting.
+  if (!PP.getHeaderSearchInfo().getHeaderSearchOpts().ImplicitModuleMaps)
+return std::nullopt;
+
   SmallVector ModulesToProcess{RootModule};
 
   const HeaderSearch  = PP.getHeaderSearchInfo();
@@ -4733,8 +4738,16 @@ void ASTWriter::computeNonAffectingInputFiles() {
 if (!Cache->OrigEntry)
   continue;
 
-if (!isModuleMap(File.getFileCharacteristic()) ||
-llvm::is_contained(AffectingModuleMaps, *Cache->OrigEntry))
+// Don't prune anything other than module maps.
+if (!isModuleMap(File.getFileCharacteristic()))
+  continue;
+
+// Don't prune module maps if all are guaranteed to be affecting.
+if (!AffectingModuleMaps)
+  continue;
+
+// Don't prune module maps that are affecting.
+if (llvm::is_contained(*AffectingModuleMaps, *Cache->OrigEntry))
   continue;
 
 IsSLocAffecting[I] = false;

``




https://github.com/llvm/llvm-project/pull/87849
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][modules] Only compute affecting module maps with implicit search (PR #87849)

2024-04-08 Thread Jan Svoboda via cfe-commits

https://github.com/jansvoboda11 edited 
https://github.com/llvm/llvm-project/pull/87849
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][modules] Only compute affecting module maps with implicit search (PR #87849)

2024-04-08 Thread Jan Svoboda via cfe-commits

https://github.com/jansvoboda11 ready_for_review 
https://github.com/llvm/llvm-project/pull/87849
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Doc][HLSL] Add documentation for root signature. (PR #83933)

2024-04-08 Thread Chris B via cfe-commits

https://github.com/llvm-beanz requested changes to this pull request.

I think we need to break this PR up into different parts going to different 
places.

Documenting the RootSignature grammar and usage in the Clang docs makes sense.

I think documentation of the RootSignature binary format probably should live 
with the DirectX backend docs, since the code to generate the binary encoding 
should live in LLVM.

The last part of the document here about the implementation I think we should 
remove from this PR and bring that discussion over to 
https://github.com/microsoft/hlsl-specs. There are a lot of parts of the design 
that I'm not convinced are correct or lack appropriate detail for me to 
understand.

To @damyanp's point I think the discussion thread here has gotten long enough 
to be unwieldy. Rather than merging an incomplete document to Clang's docs, I 
think it would be better for us to iterate on the design outside the LLVM 
source tree and return to LLVM with a design we have a higher level of 
confidence in.

@python3kgae can you strip PR down to just the first parts that document Root 
Signatures and take the implementation discussion over to hlsl-specs?

https://github.com/llvm/llvm-project/pull/83933
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] [clang][modules] Do not resolve `HeaderFileInfo` externally in `ASTWriter` (PR #87848)

2024-04-08 Thread Jan Svoboda via cfe-commits

https://github.com/jansvoboda11 updated 
https://github.com/llvm/llvm-project/pull/87848

>From ee56548604be9473f33cd809c901886f37a3d8e9 Mon Sep 17 00:00:00 2001
From: Jan Svoboda 
Date: Fri, 5 Apr 2024 15:12:39 -0700
Subject: [PATCH 1/3] [clang][modules] Do not resolve `HeaderFileInfo`
 externally in `ASTWriter`

---
 clang/include/clang/Lex/HeaderSearch.h | 24 
 clang/lib/Lex/HeaderSearch.cpp | 76 ++
 clang/lib/Serialization/ASTWriter.cpp  | 11 ++--
 clang/test/Modules/foo.c   | 48 
 4 files changed, 107 insertions(+), 52 deletions(-)
 create mode 100644 clang/test/Modules/foo.c

diff --git a/clang/include/clang/Lex/HeaderSearch.h 
b/clang/include/clang/Lex/HeaderSearch.h
index 705dcfa8aacc3f..b8724e9aa3c92e 100644
--- a/clang/include/clang/Lex/HeaderSearch.h
+++ b/clang/include/clang/Lex/HeaderSearch.h
@@ -529,14 +529,15 @@ class HeaderSearch {
   /// Return whether the specified file is a normal header,
   /// a system header, or a C++ friendly system header.
   SrcMgr::CharacteristicKind getFileDirFlavor(FileEntryRef File) {
-return (SrcMgr::CharacteristicKind)getFileInfo(File).DirInfo;
+if (const HeaderFileInfo *HFI = getExistingFileInfo(File))
+  return (SrcMgr::CharacteristicKind)HFI->DirInfo;
+return (SrcMgr::CharacteristicKind)HeaderFileInfo().DirInfo;
   }
 
   /// Mark the specified file as a "once only" file due to
   /// \#pragma once.
   void MarkFileIncludeOnce(FileEntryRef File) {
-HeaderFileInfo  = getFileInfo(File);
-FI.isPragmaOnce = true;
+getFileInfo(File).isPragmaOnce = true;
   }
 
   /// Mark the specified file as a system header, e.g. due to
@@ -816,16 +817,17 @@ class HeaderSearch {
 
   unsigned header_file_size() const { return FileInfo.size(); }
 
-  /// Return the HeaderFileInfo structure for the specified FileEntry,
-  /// in preparation for updating it in some way.
+  /// Return the HeaderFileInfo structure for the specified FileEntry, in
+  /// preparation for updating it in some way.
   HeaderFileInfo (FileEntryRef FE);
 
-  /// Return the HeaderFileInfo structure for the specified FileEntry,
-  /// if it has ever been filled in.
-  /// \param WantExternal Whether the caller wants purely-external header file
-  ///info (where \p External is true).
-  const HeaderFileInfo *getExistingFileInfo(FileEntryRef FE,
-bool WantExternal = true) const;
+  /// Return the HeaderFileInfo structure for the specified FileEntry, if it 
has
+  /// ever been filled in (either locally or externally).
+  const HeaderFileInfo *getExistingFileInfo(FileEntryRef FE) const;
+
+  /// Return the headerFileInfo structure for the specified FileEntry, if it 
has
+  /// ever been filled in locally.
+  const HeaderFileInfo *getExistingLocalFileInfo(FileEntryRef FE) const;
 
   SearchDirIterator search_dir_begin() { return {*this, 0}; }
   SearchDirIterator search_dir_end() { return {*this, SearchDirs.size()}; }
diff --git a/clang/lib/Lex/HeaderSearch.cpp b/clang/lib/Lex/HeaderSearch.cpp
index fcc2b56df166b8..55274f32528e65 100644
--- a/clang/lib/Lex/HeaderSearch.cpp
+++ b/clang/lib/Lex/HeaderSearch.cpp
@@ -947,9 +947,13 @@ OptionalFileEntryRef HeaderSearch::LookupFile(
   // If we have no includer, that means we're processing a #include
   // from a module build. We should treat this as a system header if we're
   // building a [system] module.
-  bool IncluderIsSystemHeader =
-  Includer ? getFileInfo(*Includer).DirInfo != SrcMgr::C_User :
-  BuildSystemModule;
+  bool IncluderIsSystemHeader = [&]() {
+if (!Includer)
+  return BuildSystemModule;
+const HeaderFileInfo *HFI = getExistingFileInfo(*Includer);
+assert(HFI && "includer without file info");
+return HFI->DirInfo != SrcMgr::C_User;
+  }();
   if (OptionalFileEntryRef FE = getFileAndSuggestModule(
   TmpDir, IncludeLoc, IncluderAndDir.second, 
IncluderIsSystemHeader,
   RequestingModule, SuggestedModule)) {
@@ -964,10 +968,11 @@ OptionalFileEntryRef HeaderSearch::LookupFile(
 // Note that we only use one of FromHFI/ToHFI at once, due to potential
 // reallocation of the underlying vector potentially making the first
 // reference binding dangling.
-HeaderFileInfo  = getFileInfo(*Includer);
-unsigned DirInfo = FromHFI.DirInfo;
-bool IndexHeaderMapHeader = FromHFI.IndexHeaderMapHeader;
-StringRef Framework = FromHFI.Framework;
+const HeaderFileInfo *FromHFI = getExistingFileInfo(*Includer);
+assert(FromHFI && "includer without file info");
+unsigned DirInfo = FromHFI->DirInfo;
+bool IndexHeaderMapHeader = FromHFI->IndexHeaderMapHeader;
+StringRef Framework = FromHFI->Framework;
 
 HeaderFileInfo  = getFileInfo(*FE);
 ToHFI.DirInfo = DirInfo;
@@ -1154,10 +1159,12 @@ OptionalFileEntryRef 

[clang] Fix/interp init list unnamed bitfields (PR #87799)

2024-04-08 Thread via cfe-commits


@@ -0,0 +1,114 @@
+// UNSUPPORTED: asserts
+// REQUIRES: asserts
+// ^ this attempts to say "don't actually run this test", because it's broken

sethp wrote:

Sounds good, I'll take a look at it when I get a chance.

https://github.com/llvm/llvm-project/pull/87799
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [analyzer] Variant checker bindings (PR #87886)

2024-04-08 Thread via cfe-commits


@@ -206,23 +221,42 @@ class StdVariantChecker : public Checker {
 if (!ThisMemRegion)
   return;
 
+// Get the first type alternative of the std::variant instance.
+assert((ThisSVal.getType(C.getASTContext())->isPointerType() ||
+ThisSVal.getType(C.getASTContext())->isReferenceType()) &&

NagyDonat wrote:

Why do we need to allow references here? Is this connected to the freshly 
introduced "explicit object parameter" feature?

https://github.com/llvm/llvm-project/pull/87886
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [analyzer] Variant checker bindings (PR #87886)

2024-04-08 Thread via cfe-commits


@@ -2261,6 +2261,8 @@ void ExprEngine::Visit(const Stmt *S, ExplodedNode *Pred,
   Bldr.takeNodes(Pred);
   const auto *C = cast(S);
   ExplodedNodeSet dstExpr;
+  // Point of interes: maybe my cast somehow will not get visited or will

NagyDonat wrote:

```suggestion
  // Point of interest: maybe my cast somehow will not get visited or will
```
Just a typo.

https://github.com/llvm/llvm-project/pull/87886
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [analyzer] Variant checker bindings (PR #87886)

2024-04-08 Thread via cfe-commits


@@ -286,6 +332,21 @@ class StdVariantChecker : public Checker {
 C.emitReport(std::move(R));
 return true;
   }
+
+  // TODO Implement modeling of std::variant's emplace method.
+  // Currently when this method call is encountered we just
+  // stop the modeling of that std::variant instance.
+  bool handleStdVariantEmplaceCall(const CallEvent ,

NagyDonat wrote:

I think it would be good to rename this function to "discardInfoAboutInstance" 
or something similar. I see that you added a "TODO: implement the modeling", 
which is enough to alert the reader, but my first impression was still "why is 
this obsolete comment left there? -- that function _does_ handle the emplace 
call...". 

https://github.com/llvm/llvm-project/pull/87886
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [analyzer] Variant checker bindings (PR #87886)

2024-04-08 Thread via cfe-commits


@@ -206,23 +221,42 @@ class StdVariantChecker : public Checker {
 if (!ThisMemRegion)
   return;
 
+// Get the first type alternative of the std::variant instance.
+assert((ThisSVal.getType(C.getASTContext())->isPointerType() ||
+ThisSVal.getType(C.getASTContext())->isReferenceType()) &&
+   "The This SVal must be a pointer!");

NagyDonat wrote:

```suggestion
   "The SVal representation of 'this' must be a pointer!");
```
Instead of capitalizing `this` (which deviates from its canonical style), use 
apostrophes to clarify that you're using it as the C++ keyword.

https://github.com/llvm/llvm-project/pull/87886
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [analyzer] Variant checker bindings (PR #87886)

2024-04-08 Thread via cfe-commits


@@ -231,16 +265,22 @@ class StdVariantChecker : public Checker {
 // Get the mem region of the argument std::variant and look up the type
 // information that we know about it.
 const MemRegion *ArgMemRegion = Call.getArgSVal(0).getAsRegion();
-const QualType *StoredType = State->get(ArgMemRegion);
-if (!StoredType)
+const SVal *StoredSVal = State->get(ArgMemRegion);
+if (!StoredSVal)
+  return false;
+
+QualType RefStoredType = StoredSVal->getType(C.getASTContext());
+
+if (RefStoredType->getPointeeType().isNull())
   return false;
+QualType StoredType = RefStoredType->getPointeeType();

NagyDonat wrote:

```suggestion
QualType StoredType = RefStoredType->getPointeeType();
if (StoredType.isNull())
  return false;
```

https://github.com/llvm/llvm-project/pull/87886
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [analyzer] Variant checker bindings (PR #87886)

2024-04-08 Thread via cfe-commits

https://github.com/NagyDonat edited 
https://github.com/llvm/llvm-project/pull/87886
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [analyzer] Variant checker bindings (PR #87886)

2024-04-08 Thread via cfe-commits


@@ -51,27 +47,29 @@ removeInformationStoredForDeadInstances(const CallEvent 
,
 }
 
 template 
-void handleConstructorAndAssignment(const CallEvent , CheckerContext ,
+bool handleConstructorAndAssignment(const CallEvent , CheckerContext ,
 SVal ThisSVal) {
   ProgramStateRef State = Call.getState();
 
   if (!State)
-return;
+return false;
 
   auto ArgSVal = Call.getArgSVal(0);
   const auto *ThisRegion = ThisSVal.getAsRegion();
   const auto *ArgMemRegion = ArgSVal.getAsRegion();
+  if (!ArgMemRegion)
+return false;
 
   // Make changes to the state according to type of constructor/assignment
   bool IsCopy = isCopyConstructorCall(Call) || isCopyAssignmentCall(Call);
   bool IsMove = isMoveConstructorCall(Call) || isMoveAssignmentCall(Call);
   // First we handle copy and move operations
   if (IsCopy || IsMove) {
-const QualType *OtherQType = State->get(ArgMemRegion);
-
+// const QualType *OtherQType = State->get(ArgMemRegion);

NagyDonat wrote:

```suggestion
```
Remove this comment -- it seems to be an accidental leftover.

https://github.com/llvm/llvm-project/pull/87886
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [analyzer] Variant checker bindings (PR #87886)

2024-04-08 Thread via cfe-commits


@@ -265,16 +305,22 @@ class StdVariantChecker : public Checker {
 }
 
 QualType RetrievedCanonicalType = RetrievedType.getCanonicalType();
-QualType StoredCanonicalType = StoredType->getCanonicalType();
-if (RetrievedCanonicalType == StoredCanonicalType)
+QualType StoredCanonicalType = StoredType.getCanonicalType();
+if (RetrievedCanonicalType.isNull() || StoredType.isNull())

NagyDonat wrote:

At this point the case where `StoredType.isNull()` is already ruled out. Either 
delete that check or replace it with `StoredCanonicalType.isNull()` if you 
think that is needed.

https://github.com/llvm/llvm-project/pull/87886
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [analyzer] Variant checker bindings (PR #87886)

2024-04-08 Thread via cfe-commits

https://github.com/NagyDonat commented:

Thanks for working on this checker and improving its behavior!

I started a review of this commit, but I didn't get too far yet; I'll continue 
reviewing on the next days. So far I read the code under `Checkers/`and added 
some minor stylistic remarks, but I didn't read the `Core/` changes and the 
test yet and I didn't think about the theoretical soundness of the logic that 
you introduce.

https://github.com/llvm/llvm-project/pull/87886
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [RISCV] Disallow target attribute use in multiversioning (PR #85899)

2024-04-08 Thread Craig Topper via cfe-commits

https://github.com/topperc approved this pull request.

LGTM

https://github.com/llvm/llvm-project/pull/85899
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


<    1   2   3   4   >