[PATCH] D120331: [clang-tidy][run-clang-tidy.py] Add --config-file= option

2022-03-15 Thread Shreyas via Phabricator via cfe-commits
SAtacker marked an inline comment as done.
SAtacker added a comment.

Gentle reminder
@JonasToth  
@alexfh 
@aaron.ballman  
@njames93   
@LegalizeAdulthood


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120331

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


[PATCH] D121465: WIP: [clang][modules] Do not report declarations without linkage as ambiguous

2022-03-15 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

My concern with this approach is I'm not sure if 
`isEquivalentInternalLinkageDeclaration` is a desired long-term solution for 
anonymous C++ enums. If it is, we can piggy-back on it, otherwise hitching our 
wagon to this train might be undesirable.

Also I need to check the patch again because NonExternal != Internal is not 
easy for my comprehension.




Comment at: clang/test/Modules/ambiguous-anonymous-enum-lookup.m.cpp:9
+#define TEXTUAL_H
+enum { kAnonymousEnumValue = 0 };
+#endif

For enums it is nice to test having a constant that references another constant 
in the same enum. E.g., `kAnonymousEnumAnotherValue = kAnonymousEnumValue + 1`.



Comment at: clang/test/Modules/ambiguous-anonymous-enum-lookup.m.cpp:38
+
+int testReferencingAnonymousEnumConstant() {
+  return kAnonymousEnumValue; // expected-no-diagnostics

Should we test also non-equivalent enums or is it tested somewhere else?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121465

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


[PATCH] D111400: [Clang] Implement P2242R3

2022-03-15 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added inline comments.



Comment at: clang/test/SemaCXX/constant-expression-cxx2b.cpp:101
+
+  auto b = [](int n) constexpr {
+if (!n)

I think a lambda marked `constexpr` and one that isn't has fundamental 
differences in behaviour in relation to this patch. As noted in previous 
comments, the `constexpr` case warns and then allows the lambda to be called in 
constant evaluation. The other case produces no message for the lambda 
definition itself and does not allow the lambda to be called in a `constexpr` 
context (even if the control flow is accepted by C++2b).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111400

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


[PATCH] D121588: [C++20][Modules][Driver][HU 1/N] Initial handling for -xc++-{system,user}-header.

2022-03-15 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

Sorry, I'm pretty ignorant in this area but based on

> The job construction is altered to build a C++20 header unit (rather than a 
> PCH file, as would be the case for other headers).

I want to clarify. The goal is to allow mixing PCH and PCM files, right? I 
haven't double checked and maybe that have changed already but I think `-x 
c++-header` started building .pcm instead of .pch with `-std=c++20`. That's 
where my confusion about mixing PCH and PCM comes from.




Comment at: clang/include/clang/Driver/Types.def:66
 TYPE("c++-header",   CXXHeader,PP_CXXHeader,"hh", 
phases::Preprocess, phases::Precompile)
-TYPE("objective-c++-header-cpp-output", PP_ObjCXXHeader, INVALID, "mii",  
phases::Precompile)
+TYPE("c++-header-unit-cpp-output", PP_CXXHeaderUnit,INVALID,"iih",
phases::Precompile)
+TYPE("c++-header-unit-header",   CXXHUHeader,  PP_CXXHeaderUnit,"hh", 
phases::Preprocess, phases::Precompile)

Sorry, it's not really related to your change but do you have a rule where "ii" 
should go? It's just we have both "mii" and "iim" and I want to make sure it 
should be "iih" and not "hii". I haven't tried to find a pattern here myself, 
asking you first.



Comment at: clang/lib/Frontend/FrontendOptions.cpp:30-31
   .Case("cppm", Language::CXX)
+  .Case("iih", InputKind(Language::CXX).getPreprocessed())
   .Case("iim", InputKind(Language::CXX).getPreprocessed())
   .Case("cl", Language::OpenCL)

Given the other branches in this StringSwitch I would expect `.Cases("iih", 
"iim", InputKind(Language::CXX).getPreprocessed())`. Is there a reason not to 
do that (like differences between iih and iim) or is it accidental?



Comment at: clang/test/Driver/cxx20-header-units-01.cpp:7
+
+// RUN: %clang++ -### -std=c++20 -xc++-header-unit-header 
%S/Inputs/header-unit-01.hh 2>&1 | \
+// RUN:   FileCheck -check-prefix=CHECK-ABS %s -DTDIR=%S/Inputs

What should happen in case of inconsistencies like `%clang++ -### -std=c++20 
-xc++-system-header %S/Inputs/header-unit-01.hh`? Or `-xc++-system-header 
foo.h`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121588

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


[PATCH] D121425: [VFS] Add a new getVFSFromYAMLs API

2022-03-15 Thread Ben Barham via Phabricator via cfe-commits
bnbarham added a comment.

In D121425#3384492 , @dexonsmith 
wrote:

> Can you be more detailed about the overall state at the time of `cat`, which 
> causes it to fail?

Sure. I think there's also some confusion with names here but I'm generally 
trying to use the names as they are used in the overlay YAML or the name of the 
members in RedirectingFS.

"external-contents" is just the path that we're mapping to, so in my example 
above (/a/foo -> bar), "bar" is what I was referring to by "external-contents". 
So let's use that again -

  OverlayFileSystem
RedirectingFileSystem
  /a/foo -> bar
  
RealFileSystem
  /a/bar
  /b/bar

After D121423 , `cd /a` will result in the 
following -

- OverlayFS: CWD set to `/a`
- RedirectingFS and RealFS: CWD unchanged, so let's assume they were `/` at the 
time of creation and that's what they are now

`cat foo` -

- OverlayFS canonicalises to `/a/foo` and passes that to `openFileForRead` in 
RedirectingFS
- RedirectingFS has a `/a/foo` -> `bar` mapping, so it now runs 
`openFileForRead` on its ExternalFS (which is the RealFS)
- RealFS is at `/` and there is no `/bar` and thus fails
- RedirectingFS also fails
- Back in OverlayFS now, and because we failed we now try RealFS with `/a/foo`
- RealFS has no `/a/foo`, it fails
- Back in OverlayFS, all FS have now failed, return a failure

How this used to work really depends on when we're talking about . Prior to 
D121423  the FS would have looked like:

  RedirectingFileSystem
/a/foo -> bar
  ExternalFS
RealFileSystem
  /a/bar
  /b/bar

Prior to Jonas' change, `setCWD` on RedirectingFS would run `setCWD` on 
`ExternalFS`. So `cd /a` would set CWD to `/a` for both RedirectingFS and 
RealFileSystem. Then `cat /a/foo` would give `bar` and `openFileForRead` on 
`ExternalFS` (RealFS) (which has `/a` CWD) would open `/a/bar`.

After Jonas' *and* Keith's change, `setCWD` no longer runs on `ExternalFS` but 
instead the path was canonicalised before sending it along. So `/a/foo` maps to 
`bar` as before, but then it would be canonicalised using `RedirectingFS` CWD 
and thus do an open for `/a/bar` on `ExternalFS`.

In D121425#3384499 , @dexonsmith 
wrote:

> (Would this mean resolving everything in the `.yaml` file eagerly at launch? 
> That sounds a bit scary...)

Yes, depending on what you mean by "resolving". All I mean is "prefix relative 
paths with CWD". The main issue with doing this is that it prohibits 
canonicalising paths to a virtual CWD, since you wouldn't be able to set CWD to 
a virtual path before making the overlay. Perhaps that's what you mean by "a 
bit scary" though.

We currently prefix relative paths with `ExternalContentsPrefixDir` if 
`overlay-relative: true` is set. That path is a combination of CWD + the 
directory to the overlay. This is to handle overlays that have absolute paths 
that we want to remap (specifically for the crash dump use case I believe). But 
if `overlay-relative: false` is set then we just canonicalise the path on 
open/etc.

I just ran a few tests with the frontend though:

- By default, paths come in relative and will become absolute from the 
process-wide CWD
- If `-working-directory` *is* set then paths come in absolute from 
`FileManager` - `setCWD` is never run

I'm not sure if there's a good reason it's done this way or it's just that CWD 
was only added to FileSystem relatively recently, but it does mean that that 
we're actually canonicalising the paths with the process-wide CWD regardless at 
the moment (at least from the frontend). This isn't the case if something was 
to use the API directly, but in that case I'm not sure that using the current 
CWD makes any more sense than using the CWD when the overlay is created. The 
semantics would be less confusing if that was the case (IMO), but again would 
prohibit canonicalising to a virtual CWD.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121425

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


[PATCH] D121441: [PowerPC][NFC] Add atomic alignments and ops tests for powerpc

2022-03-15 Thread Kai Luo via Phabricator via cfe-commits
lkail updated this revision to Diff 415684.
lkail added a comment.

Fix typo; Add `pwr7` and `pwr8` as `-target-cpu`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121441

Files:
  clang/test/CodeGen/PowerPC/atomic-alignment.c
  clang/test/Sema/atomic-ops.c


Index: clang/test/Sema/atomic-ops.c
===
--- clang/test/Sema/atomic-ops.c
+++ clang/test/Sema/atomic-ops.c
@@ -4,6 +4,12 @@
 // RUN:   -fsyntax-only -triple=i686-linux-android -std=c11
 // RUN: %clang_cc1 %s -verify -fgnuc-version=4.2.1 -ffreestanding \
 // RUN:   -fsyntax-only -triple=powerpc64-linux-gnu -std=c11
+// RUN: %clang_cc1 %s -verify -fgnuc-version=4.2.1 -ffreestanding \
+// RUN:   -fsyntax-only -triple=powerpc64-linux-gnu -std=c11 \
+// RUN:   -target-cpu pwr7
+// RUN: %clang_cc1 %s -verify -fgnuc-version=4.2.1 -ffreestanding \
+// RUN:   -fsyntax-only -triple=powerpc64le-linux-gnu -std=c11 \
+// RUN:   -target-cpu pwr8
 
 // Basic parsing/Sema tests for __c11_atomic_*
 
Index: clang/test/CodeGen/PowerPC/atomic-alignment.c
===
--- /dev/null
+++ clang/test/CodeGen/PowerPC/atomic-alignment.c
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 -verify -triple powerpc-unknown-unknown -emit-llvm -o - %s 
| \
+// RUN:   FileCheck %s --check-prefixes=PPC,PPC32
+// RUN: %clang_cc1 -verify -triple powerpc64le-unknown-linux -emit-llvm -o - 
%s | \
+// RUN:   FileCheck %s --check-prefixes=PPC,PPC64
+// RUN: %clang_cc1 -verify -triple powerpc64-unknown-aix -emit-llvm -o - %s | \
+// RUN:   FileCheck %s --check-prefixes=PPC,PPC64
+
+// PPC: @c = global i8 0, align 1{{$}}
+_Atomic(char) c; // expected-no-diagnostics
+
+// PPC: @s = global i16 0, align 2{{$}}
+_Atomic(short) s; // expected-no-diagnostics
+
+// PPC: @i = global i32 0, align 4{{$}}
+_Atomic(int) i; // expected-no-diagnostics
+
+// PPC32: @l = global i32 0, align 4{{$}}
+// PPC64: @l = global i64 0, align 8{{$}}
+_Atomic(long) l; // expected-no-diagnostics
+
+// PPC: @ll = global i64 0, align 8{{$}}
+_Atomic(long long) ll; // expected-no-diagnostics
+
+typedef struct {
+  char x[8];
+} O;
+
+// PPC32: @o = global %struct.O zeroinitializer, align 1{{$}}
+// PPC64: @o = global %struct.O zeroinitializer, align 8{{$}}
+_Atomic(O) o; // expected-no-diagnostics
+
+typedef struct {
+  char x[16];
+} Q;
+
+// PPC: @q = global %struct.Q zeroinitializer, align 1{{$}}
+_Atomic(Q) q; // expected-no-diagnostics


Index: clang/test/Sema/atomic-ops.c
===
--- clang/test/Sema/atomic-ops.c
+++ clang/test/Sema/atomic-ops.c
@@ -4,6 +4,12 @@
 // RUN:   -fsyntax-only -triple=i686-linux-android -std=c11
 // RUN: %clang_cc1 %s -verify -fgnuc-version=4.2.1 -ffreestanding \
 // RUN:   -fsyntax-only -triple=powerpc64-linux-gnu -std=c11
+// RUN: %clang_cc1 %s -verify -fgnuc-version=4.2.1 -ffreestanding \
+// RUN:   -fsyntax-only -triple=powerpc64-linux-gnu -std=c11 \
+// RUN:   -target-cpu pwr7
+// RUN: %clang_cc1 %s -verify -fgnuc-version=4.2.1 -ffreestanding \
+// RUN:   -fsyntax-only -triple=powerpc64le-linux-gnu -std=c11 \
+// RUN:   -target-cpu pwr8
 
 // Basic parsing/Sema tests for __c11_atomic_*
 
Index: clang/test/CodeGen/PowerPC/atomic-alignment.c
===
--- /dev/null
+++ clang/test/CodeGen/PowerPC/atomic-alignment.c
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 -verify -triple powerpc-unknown-unknown -emit-llvm -o - %s | \
+// RUN:   FileCheck %s --check-prefixes=PPC,PPC32
+// RUN: %clang_cc1 -verify -triple powerpc64le-unknown-linux -emit-llvm -o - %s | \
+// RUN:   FileCheck %s --check-prefixes=PPC,PPC64
+// RUN: %clang_cc1 -verify -triple powerpc64-unknown-aix -emit-llvm -o - %s | \
+// RUN:   FileCheck %s --check-prefixes=PPC,PPC64
+
+// PPC: @c = global i8 0, align 1{{$}}
+_Atomic(char) c; // expected-no-diagnostics
+
+// PPC: @s = global i16 0, align 2{{$}}
+_Atomic(short) s; // expected-no-diagnostics
+
+// PPC: @i = global i32 0, align 4{{$}}
+_Atomic(int) i; // expected-no-diagnostics
+
+// PPC32: @l = global i32 0, align 4{{$}}
+// PPC64: @l = global i64 0, align 8{{$}}
+_Atomic(long) l; // expected-no-diagnostics
+
+// PPC: @ll = global i64 0, align 8{{$}}
+_Atomic(long long) ll; // expected-no-diagnostics
+
+typedef struct {
+  char x[8];
+} O;
+
+// PPC32: @o = global %struct.O zeroinitializer, align 1{{$}}
+// PPC64: @o = global %struct.O zeroinitializer, align 8{{$}}
+_Atomic(O) o; // expected-no-diagnostics
+
+typedef struct {
+  char x[16];
+} Q;
+
+// PPC: @q = global %struct.Q zeroinitializer, align 1{{$}}
+_Atomic(Q) q; // expected-no-diagnostics
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D70401: [RISCV] Complete RV32E/ilp32e implementation

2022-03-15 Thread Wang Pengcheng via Phabricator via cfe-commits
pcwang-thead commandeered this revision.
pcwang-thead edited reviewers, added: zixuan-wu; removed: pcwang-thead.
pcwang-thead added a comment.
Herald added a subscriber: arichardson.
Herald added a project: All.

In D70401#3250049 , @khchen wrote:

> 1. please add a check here 
> 
>  and a clang cc1 test for it.
> 2. Have you try to run llvm-test-suite with rv32e config on qemu?



1. Thanks, I may do it later. And here is a question: the comment 

 says `It is illegal to specify 'e' extensions with 'f' and 'd'`.

While ilp32e 

 says:

> The ILP32E calling convention is not compatible with ISAs that have registers 
> that require load and store alignments of more than 32 bits. In particular, 
> this calling convention must not be used with the D ISA extension.

And, the RV32E 
 chapter 
in RISCV ISA manual says:

> RV32E can be combined with all current standard extensions.

If I understand correctly, E can't be combined with D in current specification 
since E must use ILP32E calling convention.

2. I have run llvm-test-suite with rv32e on qemu, and found no major fault for 
current implementation. Some tests are disabled because they can't run on bare 
mental (sees Disabled llvm-test-suite cases ).

There are some failed tests due to floating-point precision, but I saw the same 
result when run with  rv32gc on bare mental. I haven't taken the time to find 
out the reason, but I guess it may be soft-float issues.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70401

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


[PATCH] D121765: [CUDA][HIP] Fix hostness check with -fopenmp

2022-03-15 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.
yaxunl added a reviewer: tra.
Herald added subscribers: carlosgalvezp, guansong.
Herald added a project: All.
yaxunl requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added a subscriber: sstefan1.

CUDA/HIP determines whether a function can be called based on
the device/host attributes of callee and caller. Clang assumes the
caller is CurContext. This is correct in most cases, however, it is
not correct in OpenMP parallel region when CUDA/HIP program
is compiled with -fopenmp. This causes incorrect overloading
resolution and missed diagnostics.

To get the correct caller, clang needs to chase the parent chain
of DeclContext starting from CurContext until a function decl
or a lambda decl is reached. Sema API is adapted to achieve that
and used to determine the caller in hostness check.


https://reviews.llvm.org/D121765

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaCUDA.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/test/CodeGenCUDA/openmp-parallel.cu
  clang/test/SemaCUDA/openmp-parallel.cu

Index: clang/test/SemaCUDA/openmp-parallel.cu
===
--- /dev/null
+++ clang/test/SemaCUDA/openmp-parallel.cu
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fopenmp -fsyntax-only -verify %s
+
+#include "Inputs/cuda.h"
+
+__device__ void foo(int) {} // expected-note {{candidate function not viable: call to __device__ function from __host__ function}}
+// expected-note@-1 {{'foo' declared here}}
+
+int main() {
+  #pragma omp parallel
+  for (int i = 0; i < 100; i++)
+foo(1); // expected-error {{no matching function for call to 'foo'}}
+  
+  auto Lambda = []() {
+#pragma omp parallel
+for (int i = 0; i < 100; i++)
+  foo(1); // expected-error {{reference to __device__ function 'foo' in __host__ __device__ function}}
+};
+  Lambda(); // expected-note {{called by 'main'}}
+}
Index: clang/test/CodeGenCUDA/openmp-parallel.cu
===
--- /dev/null
+++ clang/test/CodeGenCUDA/openmp-parallel.cu
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu \
+// RUN:   -fopenmp -emit-llvm -o -  -x hip %s | FileCheck %s
+
+#include "Inputs/cuda.h"
+
+void foo(double) {}
+__device__ void foo(int) {}
+
+// Check foo resolves to the host function.
+// CHECK-LABLE: define {{.*}}@_Z5test1v
+// CHECK: call void @_Z3food(double noundef 1.00e+00)
+void test1() {
+  #pragma omp parallel
+  for (int i = 0; i < 100; i++)
+foo(1);
+}
+
+// Check foo resolves to the host function.
+// CHECK-LABLE: define {{.*}}@_Z5test2v
+// CHECK: call void @_Z3food(double noundef 1.00e+00)
+void test2() {
+  auto Lambda = []() {
+#pragma omp parallel
+for (int i = 0; i < 100; i++)
+  foo(1);
+  };
+  Lambda();
+}
Index: clang/lib/Sema/SemaOverload.cpp
===
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -6473,7 +6473,7 @@
 
   // (CUDA B.1): Check for invalid calls between targets.
   if (getLangOpts().CUDA)
-if (const FunctionDecl *Caller = dyn_cast(CurContext))
+if (const FunctionDecl *Caller = getCurFunctionDecl(/*AllowLambda=*/true))
   // Skip the check for callers that are implicit members, because in this
   // case we may not yet know what the member's target is; the target is
   // inferred for the member automatically, based on the bases and fields of
@@ -6983,7 +6983,7 @@
 
   // (CUDA B.1): Check for invalid calls between targets.
   if (getLangOpts().CUDA)
-if (const FunctionDecl *Caller = dyn_cast(CurContext))
+if (const FunctionDecl *Caller = getCurFunctionDecl(/*AllowLambda=*/true))
   if (!IsAllowedCUDACall(Caller, Method)) {
 Candidate.Viable = false;
 Candidate.FailureKind = ovl_fail_bad_target;
@@ -9639,7 +9639,7 @@
   // overloading resolution diagnostics.
   if (S.getLangOpts().CUDA && Cand1.Function && Cand2.Function &&
   S.getLangOpts().GPUExcludeWrongSideOverloads) {
-if (FunctionDecl *Caller = dyn_cast(S.CurContext)) {
+if (FunctionDecl *Caller = S.getCurFunctionDecl(/*AllowLambda=*/true)) {
   bool IsCallerImplicitHD = Sema::isCUDAImplicitHostDeviceFunction(Caller);
   bool IsCand1ImplicitHD =
   Sema::isCUDAImplicitHostDeviceFunction(Cand1.Function);
@@ -9922,7 +9922,7 @@
   // If other rules cannot determine which is better, CUDA preference is used
   // to determine which is better.
   if (S.getLangOpts().CUDA && Cand1.Function && Cand2.Function) {
-FunctionDecl *Caller = dyn_cast(S.CurContext);
+FunctionDecl *Caller = S.getCurFunctionDecl(/*AllowLambda=*/true);
 return S.IdentifyCUDAPreference(Caller, Cand1.Function) >
S.IdentifyCUDAPreference(Caller, Cand2.Function);
   }
@@ -10043,7 +10043,7 @@
   // -fgpu-exclude-wrong-side-overloads is on, all candidates are compared
   // 

[PATCH] D121498: let EST_Uninstantiated in FunctionProtoType::canThrow return CT_Dependent

2022-03-15 Thread zhouyizhou via Phabricator via cfe-commits
zhouyizhou updated this revision to Diff 415677.
zhouyizhou edited the summary of this revision.

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

https://reviews.llvm.org/D121498

Files:
  clang/lib/AST/Type.cpp
  clang/test/SemaTemplate/class-template-noexcept.cpp


Index: clang/test/SemaTemplate/class-template-noexcept.cpp
===
--- /dev/null
+++ clang/test/SemaTemplate/class-template-noexcept.cpp
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -verify %s
+// RUN: %clang_cc1 -std=c++11 -verify %s
+// RUN: %clang_cc1 -std=c++17 -verify %s
+// RUN: %clang_cc1 -std=c++1z -verify %s
+#if __cplusplus >= 201703
+// expected-no-diagnostics
+#endif
+class A {
+public:
+  static const char X;
+};
+const char A::X = 0;
+
+template void func() noexcept(U::X);
+
+template
+#if __cplusplus >= 201703
+void foo(void(B...) noexcept(x)) {} 
+#else
+void foo(void(B...) noexcept(x)) {} // expected-note{{candidate template 
ignored}}
+#endif
+
+void bar()
+{
+#if __cplusplus >= 201703
+  foo(func);
+#else
+  foo(func);// expected-error{{no matching function for call}}
+#endif 
+}
+
+
Index: clang/lib/AST/Type.cpp
===
--- clang/lib/AST/Type.cpp
+++ clang/lib/AST/Type.cpp
@@ -3325,9 +3325,10 @@
   switch (getExceptionSpecType()) {
   case EST_Unparsed:
   case EST_Unevaluated:
-  case EST_Uninstantiated:
 llvm_unreachable("should not call this with unresolved exception specs");
 
+  case EST_Uninstantiated:
+return CT_Dependent;
   case EST_DynamicNone:
   case EST_BasicNoexcept:
   case EST_NoexceptTrue:


Index: clang/test/SemaTemplate/class-template-noexcept.cpp
===
--- /dev/null
+++ clang/test/SemaTemplate/class-template-noexcept.cpp
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -verify %s
+// RUN: %clang_cc1 -std=c++11 -verify %s
+// RUN: %clang_cc1 -std=c++17 -verify %s
+// RUN: %clang_cc1 -std=c++1z -verify %s
+#if __cplusplus >= 201703
+// expected-no-diagnostics
+#endif
+class A {
+public:
+  static const char X;
+};
+const char A::X = 0;
+
+template void func() noexcept(U::X);
+
+template
+#if __cplusplus >= 201703
+void foo(void(B...) noexcept(x)) {} 
+#else
+void foo(void(B...) noexcept(x)) {} // expected-note{{candidate template ignored}}
+#endif
+
+void bar()
+{
+#if __cplusplus >= 201703
+  foo(func);
+#else
+  foo(func);	// expected-error{{no matching function for call}}
+#endif	
+}
+
+
Index: clang/lib/AST/Type.cpp
===
--- clang/lib/AST/Type.cpp
+++ clang/lib/AST/Type.cpp
@@ -3325,9 +3325,10 @@
   switch (getExceptionSpecType()) {
   case EST_Unparsed:
   case EST_Unevaluated:
-  case EST_Uninstantiated:
 llvm_unreachable("should not call this with unresolved exception specs");
 
+  case EST_Uninstantiated:
+return CT_Dependent;
   case EST_DynamicNone:
   case EST_BasicNoexcept:
   case EST_NoexceptTrue:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D120540: [Driver] Enable to use C++20 modules standalone by -fcxx-modules

2022-03-15 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added a subscriber: rsmith.
ChuanqiXu added a comment.

@rsmith told me that the ideal situation would combine C++20 modules and clang 
modules together in D113391 

I think the most important thing here is to get in consensus for the module 
status. Here might be some helpful questions for the goal:

- Should C++20 modules and Clang modules be exclusive from each other?
  - If yes, we could take the idea ` -fmodules= {clang, c++20, none...} ` and 
forbid the combination of `-fmodules  -std=c++20`. And we could use variable 
`Modules` to indicate clang modules and `CPlusPlusModules` to indicate c++20 
modules.
- If no, it implies that we could use c++20 modules and clang modules together. 
So the combination of `-fmodules -std=c++20` or even `-fmodules -fcxxmodules` 
makes sense. It implies that we could use the grammar of clang module extension 
or c++20 modules. This is decision from D113391 
. Here are some further questions:
  - Would it be very hard to implement or maintain?
  - We lack a variable to indicate clang modules only. Currently, we couldn't 
use `Modules` to indicate clang modules since `Modules` is true if we turned 
C++20 modules on. `Modules` indicate either clang module or c++20 module is 
enabled. Or we could think it means the common parts of the two features.

The most important technical question might be `Would it be very hard to 
implement or maintain?`. From my experience, I think it is implementable. But I 
**feel** it is not easy to maintain. We don't have the experience since C++20 
modules are not in the state of maintaining now.

I don't have strong opinions for the concrete decision. But I think it is very 
important to get in consensus. @iains @Bigcheese


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120540

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


[PATCH] D121763: [cmake] Provide CURRENT_TOOLS_DIR centrally, replacing CLANG_TOOLS_DIR

2022-03-15 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Trolling for reviewers:
@hokein: this is another -10 lines per test suite!
@thakis: the GN changes seem trivial (no standalone build) but wonder if you 
have opinions
@mgorny: because I don't truly understand the standalone build, and only hope 
I'm getting this right


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121763

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


[PATCH] D121763: [cmake] Provide CURRENT_TOOLS_DIR centrally, replacing CLANG_TOOLS_DIR

2022-03-15 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 415672.
sammccall added a comment.

add gn


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121763

Files:
  clang-tools-extra/clangd/test/CMakeLists.txt
  clang-tools-extra/clangd/test/lit.site.cfg.py.in
  clang-tools-extra/pseudo/test/CMakeLists.txt
  clang-tools-extra/pseudo/test/lit.site.cfg.py.in
  clang-tools-extra/test/CMakeLists.txt
  clang-tools-extra/test/lit.site.cfg.py.in
  clang/test/CMakeLists.txt
  clang/test/lit.site.cfg.py.in
  clang/utils/perf-training/CMakeLists.txt
  clang/utils/perf-training/lit.site.cfg.in
  clang/utils/perf-training/order-files.lit.site.cfg.in
  llvm/cmake/modules/AddLLVM.cmake
  llvm/utils/gn/secondary/clang-tools-extra/clangd/test/BUILD.gn
  llvm/utils/gn/secondary/clang-tools-extra/pseudo/test/BUILD.gn
  llvm/utils/gn/secondary/clang-tools-extra/test/BUILD.gn
  llvm/utils/gn/secondary/clang/test/BUILD.gn

Index: llvm/utils/gn/secondary/clang/test/BUILD.gn
===
--- llvm/utils/gn/secondary/clang/test/BUILD.gn
+++ llvm/utils/gn/secondary/clang/test/BUILD.gn
@@ -48,7 +48,7 @@
 "CLANG_DEFAULT_CXX_STDLIB=",  # Empty string means "default value" here.
 "CLANG_DEFAULT_PIE_ON_LINUX=0",
 "CLANG_PLUGIN_SUPPORT=0",  # FIXME: Analysis/plugins need global -fPIC
-"CLANG_TOOLS_DIR=" + rebase_path("$root_out_dir/bin", dir),
+"CURRENT_TOOLS_DIR=" + rebase_path("$root_out_dir/bin", dir),
 "CLANG_VENDOR_UTI=org.llvm.clang",
 
 # This is only used if LLVM_USE_SANITIZER includes lsan and the host
Index: llvm/utils/gn/secondary/clang-tools-extra/test/BUILD.gn
===
--- llvm/utils/gn/secondary/clang-tools-extra/test/BUILD.gn
+++ llvm/utils/gn/secondary/clang-tools-extra/test/BUILD.gn
@@ -32,7 +32,7 @@
   output = clang_tools_extra_lit_site_cfg_file
 
   extra_values = [
-"CLANG_TOOLS_DIR=" + rebase_path("$root_out_dir/bin"),
+"CURRENT_TOOLS_DIR=" + rebase_path("$root_out_dir/bin"),
 "CLANG_PLUGIN_SUPPORT=0",
 "LLVM_HOST_TRIPLE=$llvm_current_triple",
 "LLVM_INSTALL_TOOLCHAIN_ONLY=0",
Index: llvm/utils/gn/secondary/clang-tools-extra/pseudo/test/BUILD.gn
===
--- llvm/utils/gn/secondary/clang-tools-extra/pseudo/test/BUILD.gn
+++ llvm/utils/gn/secondary/clang-tools-extra/pseudo/test/BUILD.gn
@@ -26,7 +26,7 @@
 "CMAKE_CURRENT_SOURCE_DIR=" +
 rebase_path("//clang-tools-extra/pseudo/test"),
 
-"CLANG_TOOLS_DIR=",
+"CURRENT_TOOLS_DIR=",
 "LLVM_LIT_TOOLS_DIR=",  # Intentionally empty, matches cmake build.
 "LLVM_TOOLS_DIR=" + rebase_path("$root_out_dir/bin"),
 "TARGET_TRIPLE=$llvm_target_triple",
Index: llvm/utils/gn/secondary/clang-tools-extra/clangd/test/BUILD.gn
===
--- llvm/utils/gn/secondary/clang-tools-extra/clangd/test/BUILD.gn
+++ llvm/utils/gn/secondary/clang-tools-extra/clangd/test/BUILD.gn
@@ -29,7 +29,7 @@
 rebase_path("//clang-tools-extra/clangd/test"),
 
 "CLANG_LIBS_DIR=",  # needed only for shared builds
-"CLANG_TOOLS_DIR=",
+"CURRENT_TOOLS_DIR=",
 "CLANGD_ENABLE_REMOTE=0",
 "CLANGD_TIDY_CHECKS=1",
 "LLVM_HOST_TRIPLE=$llvm_current_triple",
Index: llvm/cmake/modules/AddLLVM.cmake
===
--- llvm/cmake/modules/AddLLVM.cmake
+++ llvm/cmake/modules/AddLLVM.cmake
@@ -1630,13 +1630,15 @@
 
   set_llvm_build_mode()
 
-  # The below might not be the build tree but provided binary tree.
+  # For standalone builds of subprojects, these might not be the build tree but
+  # a provided binary tree.
   set(LLVM_SOURCE_DIR ${LLVM_MAIN_SRC_DIR})
   set(LLVM_BINARY_DIR ${LLVM_BINARY_DIR})
   string(REPLACE "${CMAKE_CFG_INTDIR}" "${LLVM_BUILD_MODE}" LLVM_TOOLS_DIR "${LLVM_TOOLS_BINARY_DIR}")
   string(REPLACE "${CMAKE_CFG_INTDIR}" "${LLVM_BUILD_MODE}" LLVM_LIBS_DIR  "${LLVM_LIBRARY_DIR}")
-
-  # SHLIBDIR points the build tree.
+  # Like LLVM_{TOOLS,LIBS}_DIR, but pointing at the build tree.
+  string(REPLACE "${CMAKE_CFG_INTDIR}" "${LLVM_BUILD_MODE}" CURRENT_TOOLS_DIR "${LLVM_RUNTIME_OUTPUT_INTDIR}")
+  string(REPLACE "${CMAKE_CFG_INTDIR}" "${LLVM_BUILD_MODE}" CURRENT_LIBS_DIR  "${LLVM_LIBRARY_OUTPUT_INTDIR}")
   string(REPLACE "${CMAKE_CFG_INTDIR}" "${LLVM_BUILD_MODE}" SHLIBDIR "${LLVM_SHLIB_OUTPUT_INTDIR}")
 
   # FIXME: "ENABLE_SHARED" doesn't make sense, since it is used just for
Index: clang/utils/perf-training/order-files.lit.site.cfg.in
===
--- clang/utils/perf-training/order-files.lit.site.cfg.in
+++ clang/utils/perf-training/order-files.lit.site.cfg.in
@@ -2,7 +2,7 @@
 
 import sys
 
-config.clang_tools_dir = "@CLANG_TOOLS_DIR@"
+config.clang_tools_dir = "@CURRENT_TOOLS_DIR@"
 

[PATCH] D121763: [cmake] Provide CURRENT_TOOLS_DIR centrally, replacing CLANG_TOOLS_DIR

2022-03-15 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added reviewers: hokein, thakis, mgorny.
Herald added subscribers: usaxena95, kadircet, arphaman.
Herald added a project: All.
sammccall requested review of this revision.
Herald added projects: clang, LLVM, clang-tools-extra.
Herald added subscribers: cfe-commits, llvm-commits.

CLANG_TOOLS_DIR holds the the current bin/ directory, maybe with a %(build_mode)
placeholder. It is used to add the just-built binaries to $PATH for lit tests.
In most cases it equals LLVM_TOOLS_DIR, which is used for the same purpose.
But for a standalone build of clang, CLANG_TOOLS_DIR points at the build tree
and LLVM_TOOLS_DIR points at the provided LLVM binaries.

Currently CLANG_TOOLS_DIR is set in clang/test/, clang-tools-extra/test/, and
other things always built with clang. This is a few cryptic lines of CMake in
each place. Meanwhile LLVM_TOOLS_DIR is provided by configure_site_lit_cfg().

This patch moves CLANG_TOOLS_DIR to configure_site_lit_cfg() and renames it:

- there's nothing clang-specific about the value
- it will also replace LLD_TOOLS_DIR, LLDB_TOOLS_DIR etc (not in this patch)

It also defines CURRENT_LIBS_DIR. While I removed the last usage of
CLANG_LIBS_DIR in e4cab4e24d1 
, there 
are LLD_LIBS_DIR usages etc that
may be live, and I'd like to mechanically update them in a followup patch.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D121763

Files:
  clang-tools-extra/clangd/test/CMakeLists.txt
  clang-tools-extra/clangd/test/lit.site.cfg.py.in
  clang-tools-extra/pseudo/test/CMakeLists.txt
  clang-tools-extra/pseudo/test/lit.site.cfg.py.in
  clang-tools-extra/test/CMakeLists.txt
  clang-tools-extra/test/lit.site.cfg.py.in
  clang/test/CMakeLists.txt
  clang/test/lit.site.cfg.py.in
  clang/utils/perf-training/CMakeLists.txt
  clang/utils/perf-training/lit.site.cfg.in
  clang/utils/perf-training/order-files.lit.site.cfg.in
  llvm/cmake/modules/AddLLVM.cmake

Index: llvm/cmake/modules/AddLLVM.cmake
===
--- llvm/cmake/modules/AddLLVM.cmake
+++ llvm/cmake/modules/AddLLVM.cmake
@@ -1630,13 +1630,15 @@
 
   set_llvm_build_mode()
 
-  # The below might not be the build tree but provided binary tree.
+  # For standalone builds of subprojects, these might not be the build tree but
+  # a provided binary tree.
   set(LLVM_SOURCE_DIR ${LLVM_MAIN_SRC_DIR})
   set(LLVM_BINARY_DIR ${LLVM_BINARY_DIR})
   string(REPLACE "${CMAKE_CFG_INTDIR}" "${LLVM_BUILD_MODE}" LLVM_TOOLS_DIR "${LLVM_TOOLS_BINARY_DIR}")
   string(REPLACE "${CMAKE_CFG_INTDIR}" "${LLVM_BUILD_MODE}" LLVM_LIBS_DIR  "${LLVM_LIBRARY_DIR}")
-
-  # SHLIBDIR points the build tree.
+  # Like LLVM_{TOOLS,LIBS}_DIR, but pointing at the build tree.
+  string(REPLACE "${CMAKE_CFG_INTDIR}" "${LLVM_BUILD_MODE}" CURRENT_TOOLS_DIR "${LLVM_RUNTIME_OUTPUT_INTDIR}")
+  string(REPLACE "${CMAKE_CFG_INTDIR}" "${LLVM_BUILD_MODE}" CURRENT_LIBS_DIR  "${LLVM_LIBRARY_OUTPUT_INTDIR}")
   string(REPLACE "${CMAKE_CFG_INTDIR}" "${LLVM_BUILD_MODE}" SHLIBDIR "${LLVM_SHLIB_OUTPUT_INTDIR}")
 
   # FIXME: "ENABLE_SHARED" doesn't make sense, since it is used just for
Index: clang/utils/perf-training/order-files.lit.site.cfg.in
===
--- clang/utils/perf-training/order-files.lit.site.cfg.in
+++ clang/utils/perf-training/order-files.lit.site.cfg.in
@@ -2,7 +2,7 @@
 
 import sys
 
-config.clang_tools_dir = "@CLANG_TOOLS_DIR@"
+config.clang_tools_dir = "@CURRENT_TOOLS_DIR@"
 config.perf_helper_dir = "@CMAKE_CURRENT_SOURCE_DIR@"
 config.test_exec_root = "@CMAKE_CURRENT_BINARY_DIR@"
 config.test_source_root = "@CLANG_PGO_TRAINING_DATA@"
Index: clang/utils/perf-training/lit.site.cfg.in
===
--- clang/utils/perf-training/lit.site.cfg.in
+++ clang/utils/perf-training/lit.site.cfg.in
@@ -2,7 +2,7 @@
 
 import sys
 
-config.clang_tools_dir = "@CLANG_TOOLS_DIR@"
+config.clang_tools_dir = "@CURRENT_TOOLS_DIR@"
 config.perf_helper_dir = "@CMAKE_CURRENT_SOURCE_DIR@"
 config.test_exec_root = "@CMAKE_CURRENT_BINARY_DIR@"
 config.test_source_root = "@CLANG_PGO_TRAINING_DATA@"
Index: clang/utils/perf-training/CMakeLists.txt
===
--- clang/utils/perf-training/CMakeLists.txt
+++ clang/utils/perf-training/CMakeLists.txt
@@ -1,11 +1,3 @@
-if (CMAKE_CFG_INTDIR STREQUAL ".")
-  set(LLVM_BUILD_MODE ".")
-else ()
-  set(LLVM_BUILD_MODE "%(build_mode)s")
-endif ()
-
-string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} CLANG_TOOLS_DIR ${LLVM_RUNTIME_OUTPUT_INTDIR})
-
 set(CLANG_PGO_TRAINING_DATA "${CMAKE_CURRENT_SOURCE_DIR}" CACHE PATH
   "The path to a lit testsuite containing samples for PGO and order file generation"
   )
Index: clang/test/lit.site.cfg.py.in
===
--- 

[PATCH] D121715: [Clang] Fix an unused-but-set-variable warning with volatile variable

2022-03-15 Thread Yonghong Song via Phabricator via cfe-commits
yonghong-song added inline comments.



Comment at: clang/test/Sema/warn-unused-but-set-variables.c:66
+  for (int i = 0; i < 1000; i++)
+j += 1;
+  return;

efriedma wrote:
> The handling of this testcase without your patch seems fine.  Even if the 
> value of j is technically read, it's not "used" in any meaningful way.
> 
> I think the distinguishing factor for the testcase we discussed before is the 
> use of a "volatile".  Volatile is rare, and indicates the user is 
> intentionally doing something unusual, so it probably doesn't make sense to 
> warn.
@eli.friedman Just updated the patch to handle volatile variable only.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121715

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


[PATCH] D121715: [Clang] Fix an unused-but-set-variable warning with volatile variable

2022-03-15 Thread Yonghong Song via Phabricator via cfe-commits
yonghong-song updated this revision to Diff 415665.
yonghong-song retitled this revision from "[Clang] Fix an 
unused-but-set-variable warning with compond assignment" to "[Clang] Fix an 
unused-but-set-variable warning with volatile variable".
yonghong-song edited the summary of this revision.
yonghong-song added a comment.

- only handle volatile variables with component assignment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121715

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/Sema/warn-unused-but-set-variables.c


Index: clang/test/Sema/warn-unused-but-set-variables.c
===
--- clang/test/Sema/warn-unused-but-set-variables.c
+++ clang/test/Sema/warn-unused-but-set-variables.c
@@ -23,10 +23,19 @@
   int a;
   w = (a = 0);
 
+  int j = 0; // expected-warning{{variable 'j' set but not used}}
+  for (int i = 0; i < 1000; i++)
+j += 1;
+
   // Following gcc, warn for a volatile variable.
   volatile int b; // expected-warning{{variable 'b' set but not used}}
   b = 0;
 
+  // volatile variable k is used, no warning.
+  volatile int k = 0;
+  for (int i = 0; i < 1000; i++)
+k += 1;
+
   int x;
   x = 0;
   return x;
Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -7922,6 +7922,7 @@
 static void MaybeDecrementCount(
 Expr *E, llvm::DenseMap ) {
   DeclRefExpr *LHS = nullptr;
+  bool IsComponentAssign = false;
   if (BinaryOperator *BO = dyn_cast(E)) {
 if (BO->getLHS()->getType()->isDependentType() ||
 BO->getRHS()->getType()->isDependentType()) {
@@ -7929,6 +7930,8 @@
 return;
 } else if (!BO->isAssignmentOp())
   return;
+else
+  IsComponentAssign = BO->isCompoundAssignmentOp();
 LHS = dyn_cast(BO->getLHS());
   } else if (CXXOperatorCallExpr *COCE = dyn_cast(E)) {
 if (COCE->getOperator() != OO_Equal)
@@ -7940,6 +7943,10 @@
   VarDecl *VD = dyn_cast(LHS->getDecl());
   if (!VD)
 return;
+  // Don't decrement RefsMinusAssignments if volatile variable with component
+  // assignment (+=, ...) to avoid potential unused-but-set-variable warning.
+  if (IsComponentAssign && VD->getType().isVolatileQualified())
+return;
   auto iter = RefsMinusAssignments.find(VD);
   if (iter == RefsMinusAssignments.end())
 return;
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -2030,6 +2030,7 @@
  "Found a negative number of references to a VarDecl");
   if (iter->getSecond() != 0)
 return;
+
   unsigned DiagID = isa(VD) ? diag::warn_unused_but_set_parameter
  : diag::warn_unused_but_set_variable;
   Diag(VD->getLocation(), DiagID) << VD;


Index: clang/test/Sema/warn-unused-but-set-variables.c
===
--- clang/test/Sema/warn-unused-but-set-variables.c
+++ clang/test/Sema/warn-unused-but-set-variables.c
@@ -23,10 +23,19 @@
   int a;
   w = (a = 0);
 
+  int j = 0; // expected-warning{{variable 'j' set but not used}}
+  for (int i = 0; i < 1000; i++)
+j += 1;
+
   // Following gcc, warn for a volatile variable.
   volatile int b; // expected-warning{{variable 'b' set but not used}}
   b = 0;
 
+  // volatile variable k is used, no warning.
+  volatile int k = 0;
+  for (int i = 0; i < 1000; i++)
+k += 1;
+
   int x;
   x = 0;
   return x;
Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -7922,6 +7922,7 @@
 static void MaybeDecrementCount(
 Expr *E, llvm::DenseMap ) {
   DeclRefExpr *LHS = nullptr;
+  bool IsComponentAssign = false;
   if (BinaryOperator *BO = dyn_cast(E)) {
 if (BO->getLHS()->getType()->isDependentType() ||
 BO->getRHS()->getType()->isDependentType()) {
@@ -7929,6 +7930,8 @@
 return;
 } else if (!BO->isAssignmentOp())
   return;
+else
+  IsComponentAssign = BO->isCompoundAssignmentOp();
 LHS = dyn_cast(BO->getLHS());
   } else if (CXXOperatorCallExpr *COCE = dyn_cast(E)) {
 if (COCE->getOperator() != OO_Equal)
@@ -7940,6 +7943,10 @@
   VarDecl *VD = dyn_cast(LHS->getDecl());
   if (!VD)
 return;
+  // Don't decrement RefsMinusAssignments if volatile variable with component
+  // assignment (+=, ...) to avoid potential unused-but-set-variable warning.
+  if (IsComponentAssign && VD->getType().isVolatileQualified())
+return;
   auto iter = RefsMinusAssignments.find(VD);
   if (iter == RefsMinusAssignments.end())
 return;
Index: clang/lib/Sema/SemaDecl.cpp

[PATCH] D121098: [C++20][Modules][HU 4/5] Handle pre-processed header units.

2022-03-15 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added a comment.

In D121098#3383835 , @iains wrote:

>> I am a little bit confused for the intuition. Couldn't we just import the 
>> pre-processed header? What's the problem? Could you elaborate on this?
>
> We cannot import a pre-processed file; the preprocessed file is still source 
> code, not a CMI.

But if I understand correctly, we are able to import a pre-processed file as a 
header unit. Couldn't we?

For example:

  // cc -E foo.h > foo.preprocessed
  import "foo.preprocessed"
  ...

Is this not acceptable?

> In addition, the pre-processor output for a header unit requires further 
> pre-processing on read.
> This is because a header unit actually preserves some of the pre-processor 
> information [macro definitions] (which would normally be discarded after 
> phase 4).
>
> Header units are identifiable by a name (in common with GCC, we make the name 
> == the path by which the header is specified) -- that name is intentionally 
> not a  legal named module name (neither is it, in general, a legal 
> identifier).

So it doesn't eliminate my confusion. I guess there is some workflows that we 
need to import a preprocessed header as header unit (and we need to find the 
position of original file). Or in what circumstances, do we need to import a 
pre-processed header as header unit?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121098

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


[clang-tools-extra] e4cab4e - [lit] Remove clang_libs_dir

2022-03-15 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2022-03-16T03:03:02+01:00
New Revision: e4cab4e24d17e4a434d0edd6d7d037f0d05ced36

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

LOG: [lit] Remove clang_libs_dir

Seems to have been added accidentally in 58db03a116a197719 and then
copied into clangd by me (but not actually needed).

Added: 


Modified: 
clang-tools-extra/clangd/test/lit.site.cfg.py.in
llvm/utils/lit/lit/llvm/config.py

Removed: 




diff  --git a/clang-tools-extra/clangd/test/lit.site.cfg.py.in 
b/clang-tools-extra/clangd/test/lit.site.cfg.py.in
index 9adc1c9792c1e..43475e83f987d 100644
--- a/clang-tools-extra/clangd/test/lit.site.cfg.py.in
+++ b/clang-tools-extra/clangd/test/lit.site.cfg.py.in
@@ -2,7 +2,6 @@
 
 # Variables needed for common clang config.
 config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
-config.clang_libs_dir = "@CLANG_LIBS_DIR@"
 config.target_triple = "@LLVM_TARGET_TRIPLE@"
 config.host_triple = "@LLVM_HOST_TRIPLE@"
 config.python_executable = "@Python3_EXECUTABLE@"

diff  --git a/llvm/utils/lit/lit/llvm/config.py 
b/llvm/utils/lit/lit/llvm/config.py
index ed208ace5977b..a8e73ce43dc90 100644
--- a/llvm/utils/lit/lit/llvm/config.py
+++ b/llvm/utils/lit/lit/llvm/config.py
@@ -489,7 +489,6 @@ def use_clang(self, additional_tool_dirs=[], 
additional_flags=[],
 
 lib_dir_props = [
 self.config.name.lower() + '_libs_dir',
-'clang_libs_dir',
 'llvm_shlib_dir',
 'llvm_libs_dir',
 ]



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


[PATCH] D119609: [Clang][Sema] Prohibit expression statement in lambda default argument

2022-03-15 Thread Jun Zhang via Phabricator via cfe-commits
junaire added a comment.

Hi @aaron.ballman @erichkeane, I have already left a comment in GCC's Bugzilla, 
but unfortunately there's been no response for almost a week. I'm even not sure 
there's really a bug fix for GCC or not. Can you guys decide how to deal with 
this issue?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119609

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


[PATCH] D121233: [pseudo] Move pseudoparser from clang to clang-tools-extra

2022-03-15 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

In D121233#3384495 , @thakis wrote:

> Is there a reason why this can't be part of clang-tools-extra/test

This was discussed pretty extensively in the review above.
Other projects across LLVM use proj/{lib,include,unittest,test} and it works 
well.
clang-tools-extra isn't a project but rather a set of separate projects (few 
common developers, few changes across them). Mixing the directories of 
different projects doesn't work well.

I want to make it possible to convert more/all of the directories to 
separate-project structure, so I'm working on reducing the amount of 
CMake/lit.cfg boilerplate needed.

> and check-clang-tools?

Yeah, we should add this. The narrower check-clang-pseudo target is essential 
for development though, and creating merged test targets seems to be a 
nontrivial amount of CMake goop, so I had put it in the cmake/lit cleanup pile, 
hoping to get to it soon.

So I can understand better, what is this useful for?
My mental model is: buildbots run check-all, people working on project run 
check-$project, and check-clang-tools is mostly useful if you made a clang 
change and want to test its rdeps.

> Why is this in a directory called "pseudo" instead of "clang-pseudo"? This 
> makes everything fairly self-inconsistent (`pseudo/tool` vs `clang-pseudo` in 
> there, but then also `check-clang-pseudo`) – I found this pretty confusing.

It's in a directory with "clang" in the name, the "clang-" prefix only seems 
necessary in flat namespaces (in `bin/`, cmake targets etc).
Unlike the other directories here, this isn't really a command-line tool, but 
rather a library. The command-line tool is mostly a demo for lit testing. Maybe 
`tool/` isn't the right name for that.

(I think it would be useful to drop the clang- prefixes off the other 
directories here too, but I'm not going to push too hard for that)

> Reading `CMAKE_CURRENT_SOURCE_DIR` in the lit.cfg is fairly unusual. clang's 
> unit tests don't do this, for example.
>
> New lit.cfg input files should use the `path()` abstraction so that relative 
> paths are in the generated lit.cfg output files (which helps for running the 
> tests on a different computer than building them). See 
> a16ba6fea2e554fae465dcaaca1d687d8e83a62e 
>  for an 
> example.

Thanks. I'd seen that but thought clang-tools-extra didn't have this 
requirement/wasn't being tested in this way. I'm a bit reluctant to add these 
without a way to tell if it's doing anything, is there a buildbot to verify 
this or a script to run?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121233

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


[PATCH] D119479: [clang][extract-api] Add global record support

2022-03-15 Thread Zixu Wang via Phabricator via cfe-commits
zixuw updated this revision to Diff 415658.
zixuw added a comment.

- Address reviews
  - Add and handle unconditionally unavailable
  - Delete the default constructor of `APIRecord`
  - Make `APIRecord` abstract for LLVM RTTI
  - Improve `getFormattedText` and `getFormattedLines`
  - Fix wordings in serializer to conform to the SymbolGraph format
  - Remove unnecessary `explicit` keyword
  - Use clang with full version info for the `generator` field
  - Adjust test case
- Make it obvious that the `USR` parameter will be copied in `add*` APIs


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119479

Files:
  clang/include/clang/AST/RawCommentList.h
  clang/include/clang/Frontend/FrontendActions.h
  clang/include/clang/SymbolGraph/API.h
  clang/include/clang/SymbolGraph/AvailabilityInfo.h
  clang/include/clang/SymbolGraph/DeclarationFragments.h
  clang/include/clang/SymbolGraph/FrontendActions.h
  clang/include/clang/SymbolGraph/Serialization.h
  clang/lib/AST/RawCommentList.cpp
  clang/lib/CMakeLists.txt
  clang/lib/Frontend/CMakeLists.txt
  clang/lib/Frontend/ExtractAPIConsumer.cpp
  clang/lib/FrontendTool/CMakeLists.txt
  clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
  clang/lib/SymbolGraph/API.cpp
  clang/lib/SymbolGraph/CMakeLists.txt
  clang/lib/SymbolGraph/DeclarationFragments.cpp
  clang/lib/SymbolGraph/ExtractAPIConsumer.cpp
  clang/lib/SymbolGraph/Serialization.cpp
  clang/test/Driver/extract-api.c
  clang/test/SymbolGraph/global_record.c

Index: clang/test/SymbolGraph/global_record.c
===
--- /dev/null
+++ clang/test/SymbolGraph/global_record.c
@@ -0,0 +1,367 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: sed -e "s@INPUT_DIR@%/t@g" %t/reference.output.json.in >> \
+// RUN: %t/reference.output.json
+// RUN: %clang -extract-api -target arm64-apple-macosx \
+// RUN: %t/input.c -o %t/output.json | FileCheck -allow-empty %s
+// RUN: sed -e "s@\"generator\": \"clang.*\"@\"generator\": \"clang\"@g" \
+// RUN: %t/output.json >> %t/output-normalized.json
+// RUN: diff %t/reference.output.json %t/output-normalized.json
+
+// CHECK-NOT: error:
+// CHECK-NOT: warning:
+
+//--- input.c
+int num;
+
+/**
+ * \brief Add two numbers.
+ * \param [in]  x   A number.
+ * \param [in]  y   Another number.
+ * \param [out] res The result of x + y.
+ */
+void add(const int x, const int y, int *res);
+
+char unavailable __attribute__((unavailable));
+
+//--- reference.output.json.in
+{
+  "metadata": {
+"formatVersion": {
+  "major": 0,
+  "minor": 5,
+  "patch": 3
+},
+"generator": "clang"
+  },
+  "module": {
+"name": "",
+"platform": {
+  "architecture": "arm64",
+  "operatingSystem": {
+"minimumVersion": {
+  "major": 11,
+  "minor": 0,
+  "patch": 0
+},
+"name": "macosx"
+  },
+  "vendor": "apple"
+}
+  },
+  "relationhips": [],
+  "symbols": [
+{
+  "declarationFragments": [
+{
+  "kind": "typeIdentifier",
+  "preciseIdentifier": "c:I",
+  "spelling": "int"
+},
+{
+  "kind": "text",
+  "spelling": " "
+},
+{
+  "kind": "identifier",
+  "spelling": "num"
+}
+  ],
+  "identifier": {
+"interfaceLanguage": "c",
+"precise": "c:@num"
+  },
+  "kind": {
+"displayName": "Global Variable",
+"identifier": "c.var"
+  },
+  "location": {
+"character": 5,
+"line": 1,
+"uri": "file://INPUT_DIR/input.c"
+  },
+  "names": {
+"subHeading": [
+  {
+"kind": "identifier",
+"spelling": "num"
+  }
+],
+"title": "num"
+  }
+},
+{
+  "declarationFragments": [
+{
+  "kind": "typeIdentifier",
+  "preciseIdentifier": "c:v",
+  "spelling": "void"
+},
+{
+  "kind": "text",
+  "spelling": " "
+},
+{
+  "kind": "identifier",
+  "spelling": "add"
+},
+{
+  "kind": "text",
+  "spelling": "("
+},
+{
+  "kind": "keyword",
+  "spelling": "const"
+},
+{
+  "kind": "text",
+  "spelling": " "
+},
+{
+  "kind": "typeIdentifier",
+  "preciseIdentifier": "c:I",
+  "spelling": "int"
+},
+{
+  "kind": "text",
+  "spelling": " "
+},
+{
+  "kind": "internalParam",
+  "spelling": "x"
+},
+{
+  "kind": "text",
+  "spelling": ", "
+},
+{
+  "kind": "keyword",
+  "spelling": "const"
+},
+{
+  "kind": "text",
+  "spelling": " "
+},
+  

[PATCH] D120959: [clang][AST matchers] new hasExpectedReturnType submatcher for ReturnStmts

2022-03-15 Thread Alister Johnson via Phabricator via cfe-commits
ajohnson-uoregon added a comment.

This is our use case: 
https://github.com/ajohnson-uoregon/llvm-project/blob/feature-ajohnson/clang-tools-extra/clang-rewrite/MatcherGenCallback.h#L365
 
I'm not sure if anyone else would want to use this, but it feels like it could 
be generally useful. Now that I know we can define local matchers though we 
could do that instead.

Basically, we want to match based on the declared return type of the function, 
not the actual type of the thing returned, for cases where the thing returned 
is cast to something else. We used it to reimplement part of clang-tidy's 
modernize-use-nullptr check; we needed to get the declared (template) return 
type so we could check if it was a pointer type even though the thing returned 
was an int.

We haven't gotten around to implementing this yet (and the type code is 
actually a little broken), but there are other cases where we might want to 
specifically look for ReturnStmts that return a thing of type X when the 
function says it returns a thing of type Y, in which case we'd be using both 
`hasType()` and `hasExpectedReturnType()` kind of like this:

  returnStmt(allOf(
  hasReturnValue(hasType(X)), 
  hasExpectedReturnType(Y)
  ))


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120959

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


[PATCH] D121425: [VFS] Add a new getVFSFromYAMLs API

2022-03-15 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added a comment.

In D121425#3384479 , @bnbarham wrote:

> In D121425#3384188 , @bnbarham 
> wrote:
>
>> There's two failing tests with this change:
>>
>> - VFSFromYAMLTest.ReturnsExternalPathVFSHit
>> - VFSFromYAMLTest.ReturnsInternalPathVFSHit
>>
>> Apparently we allow relative paths in external-contents *without* specifying 
>> `overlay-relative: true`. In this case the relative paths are resolved based 
>> on the CWD at the time of the operation. Do we really want that? I believe 
>> this wouldn't have worked prior to https://reviews.llvm.org/D109128 as there 
>> was no canonicalising before then as well. @keith was that change 
>> intentional? If we want it then it will *require* setting CWD on each FS in 
>> OverlayFS, which I was really hoping to avoid.
>
> I spoke to Keith offline. This has always worked - it previously worked by 
> `RedirectingFileSystem` setting CWD on `ExternalFS` when `setCWD` was called 
> on it. It's also important to keep supporting as it's used in Bazel 
> (https://github.com/bazelbuild/rules_swift/blob/c1d7d1df6969c2675c7826ecf1202d78016b1753/swift/internal/vfsoverlay.bzl#L41-L55).
>
> I'm hoping I can fix this by resolving the paths when the overlay is created. 
> I'll see if that works (it'll depend on when -working-directory is actually 
> used by the frontend).

(Would this mean resolving everything in the `.yaml` file eagerly at launch? 
That sounds a bit scary...)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121425

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


[PATCH] D121498: let EST_Uninstantiated in FunctionProtoType::canThrow return CT_Dependent

2022-03-15 Thread zhouyizhou via Phabricator via cfe-commits
zhouyizhou updated this revision to Diff 415655.
zhouyizhou edited the summary of this revision.

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

https://reviews.llvm.org/D121498

Files:
  clang/lib/AST/Type.cpp
  clang/test/SemaTemplate/class-template-deduction.cpp


Index: clang/test/SemaTemplate/class-template-deduction.cpp
===
--- /dev/null
+++ clang/test/SemaTemplate/class-template-deduction.cpp
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 -verify %s
+// RUN: %clang_cc1 -std=c++11 -verify %s
+// RUN: %clang_cc1 -std=c++17 -verify %s
+// RUN: %clang_cc1 -std=c++1z -verify %s
+#if __cplusplus >= 201703
+// expected-no-diagnostics
+#endif
+template
+void foo() noexcept(U::X);
+class A {
+public:
+  static const bool X;
+};
+
+const bool A::X = 0;
+
+template
+#if __cplusplus >= 201703
+bool bar(void(B...) noexcept(x)) 
+#else
+bool bar(void(B...) noexcept(x))  // expected-note{{candidate template 
ignored}}
+#endif
+{
+  return x; 
+}
+
+void func()
+{
+#if __cplusplus >= 201703
+  bar(foo);
+#else
+  bar(foo); // expected-error{{no matching function for call}}
+#endif 
+}
+
+
Index: clang/lib/AST/Type.cpp
===
--- clang/lib/AST/Type.cpp
+++ clang/lib/AST/Type.cpp
@@ -3325,9 +3325,10 @@
   switch (getExceptionSpecType()) {
   case EST_Unparsed:
   case EST_Unevaluated:
-  case EST_Uninstantiated:
 llvm_unreachable("should not call this with unresolved exception specs");
 
+  case EST_Uninstantiated:
+return CT_Dependent;
   case EST_DynamicNone:
   case EST_BasicNoexcept:
   case EST_NoexceptTrue:


Index: clang/test/SemaTemplate/class-template-deduction.cpp
===
--- /dev/null
+++ clang/test/SemaTemplate/class-template-deduction.cpp
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 -verify %s
+// RUN: %clang_cc1 -std=c++11 -verify %s
+// RUN: %clang_cc1 -std=c++17 -verify %s
+// RUN: %clang_cc1 -std=c++1z -verify %s
+#if __cplusplus >= 201703
+// expected-no-diagnostics
+#endif
+template
+void foo() noexcept(U::X);
+class A {
+public:
+  static const bool X;
+};
+
+const bool A::X = 0;
+
+template
+#if __cplusplus >= 201703
+bool bar(void(B...) noexcept(x)) 
+#else
+bool bar(void(B...) noexcept(x))  // expected-note{{candidate template ignored}}
+#endif
+{
+  return x; 
+}
+
+void func()
+{
+#if __cplusplus >= 201703
+  bar(foo);
+#else
+  bar(foo);	// expected-error{{no matching function for call}}
+#endif	
+}
+
+
Index: clang/lib/AST/Type.cpp
===
--- clang/lib/AST/Type.cpp
+++ clang/lib/AST/Type.cpp
@@ -3325,9 +3325,10 @@
   switch (getExceptionSpecType()) {
   case EST_Unparsed:
   case EST_Unevaluated:
-  case EST_Uninstantiated:
 llvm_unreachable("should not call this with unresolved exception specs");
 
+  case EST_Uninstantiated:
+return CT_Dependent;
   case EST_DynamicNone:
   case EST_BasicNoexcept:
   case EST_NoexceptTrue:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D121233: [pseudo] Move pseudoparser from clang to clang-tools-extra

2022-03-15 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Is there a reason why this can't be part of clang-tools-extra/test and 
check-clang-tools?

Why is this in a directory called "pseudo" instead of "clang-pseudo"? This 
makes everything fairly self-inconsistent (`pseudo/tool` vs `clang-pseudo` in 
there, but then also `check-clang-pseudo`) – I found this pretty confusing.

Reading `CMAKE_CURRENT_SOURCE_DIR` in the lit.cfg is fairly unusual. clang's 
unit tests don't do this, for example.

New lit.cfg input files should use the `path()` abstraction so that relative 
paths are in the generated lit.cfg output files (which helps for running the 
tests on a different computer than building them). See 
a16ba6fea2e554fae465dcaaca1d687d8e83a62e 
 for an 
example.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121233

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


[PATCH] D121425: [VFS] Add a new getVFSFromYAMLs API

2022-03-15 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added a comment.

In D121425#3384188 , @bnbarham wrote:

> There's two failing tests with this change:
>
> - VFSFromYAMLTest.ReturnsExternalPathVFSHit
> - VFSFromYAMLTest.ReturnsInternalPathVFSHit
>
> Apparently we allow relative paths in external-contents *without* specifying 
> `overlay-relative: true`. In this case the relative paths are resolved based 
> on the CWD at the time of the operation. Do we really want that? I believe 
> this wouldn't have worked prior to https://reviews.llvm.org/D109128 as there 
> was no canonicalising before then as well. @keith was that change 
> intentional? If we want it then it will *require* setting CWD on each FS in 
> OverlayFS, which I was really hoping to avoid.

I'm not sure how external-contents factors into this (shouldn't that just 
affect the observed file path, not whether the lookup succeeds?).

Regardless, here's the testcase again:

  OverlayFileSystem
RedirectingFileSystem
  /a/foo -> bar
  
RealFileSystem
  /a/bar
  /b/bar

I think that should behave like:

  InMemoryFileSystem
/a/bar
/a/foo -> bar (link, with "magic" to sometimes leak path)
/b/bar
  
  cd /a # succeeds
  cat foo # succeeds (get content of /a/bar; report path of /a/bar or /a/foo)
  
  cd /b # succeeds
  cat foo # fails

Is the model correct?

If so, I think these are the things we need to get right (not just for that 
test case):

1. Return error on operations that should fail.
2. Get the right content what `cat` succeeds.
3. Reporting the "right" paths for files that are opened (depends on external 
contents, etc.).
4. Keeping the "view" / state consistent when the underlying filesystems 
changes state.

Does that breakdown make sense?

If so, can you clarify which part is failing? (Not sure if it's (3) or (4)... 
or maybe some (5).)

Or another way in: I don't fully understand why this fails:

>   cd /a
>   cat foo # fails since OverlayFS::setCWD doesn't set CWD on the underlying FS

Can you be more detailed about the overall state at the time of `cat`, which 
causes it to fail?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121425

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


[PATCH] D121736: Lower `@llvm.global_dtors` using `__cxa_atexit` on MachO

2022-03-15 Thread Julian Lettner via Phabricator via cfe-commits
yln added a comment.

It looks like all tests succeed for `x64 debian`:
https://buildkite.com/llvm-project/premerge-checks/builds/83802#c5002be5-e01c-46fc-a767-50fe6f854465


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121736

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


[PATCH] D121425: [VFS] Add a new getVFSFromYAMLs API

2022-03-15 Thread Ben Barham via Phabricator via cfe-commits
bnbarham added a comment.

In D121425#3384188 , @bnbarham wrote:

> There's two failing tests with this change:
>
> - VFSFromYAMLTest.ReturnsExternalPathVFSHit
> - VFSFromYAMLTest.ReturnsInternalPathVFSHit
>
> Apparently we allow relative paths in external-contents *without* specifying 
> `overlay-relative: true`. In this case the relative paths are resolved based 
> on the CWD at the time of the operation. Do we really want that? I believe 
> this wouldn't have worked prior to https://reviews.llvm.org/D109128 as there 
> was no canonicalising before then as well. @keith was that change 
> intentional? If we want it then it will *require* setting CWD on each FS in 
> OverlayFS, which I was really hoping to avoid.

I spoke to Keith offline. This has always worked - it previously worked by 
`RedirectingFileSystem` setting CWD on `ExternalFS` when `setCWD` was called on 
it. It's also important to keep supporting as it's used in Bazel 
(https://github.com/bazelbuild/rules_swift/blob/c1d7d1df6969c2675c7826ecf1202d78016b1753/swift/internal/vfsoverlay.bzl#L41-L55).

I'm hoping I can fix this by resolving the paths when the overlay is created. 
I'll see if that works (it'll depend on when -working-directory is actually 
used by the frontend).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121425

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


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

2022-03-15 Thread Alister Johnson via Phabricator via cfe-commits
ajohnson-uoregon added inline comments.



Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:4452
+/// \endcode
+AST_POLYMORPHIC_MATCHER_P(argumentsGivenCountIs,
+  AST_POLYMORPHIC_SUPPORTED_TYPES(

aaron.ballman wrote:
> I have a preference for `argumentCountAsWrittenIs()` -- we often use "as 
> written" to distinguish syntax from semantics, and in the case of default 
> arguments, the semantics are that the default arguments are treated as if 
> they were given at the call site, so I would expect 
> `argumentsGivenCountIs(2)` to match both calls to `f()`.
Ah that's a good point, and I like that name much better, I will update that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120956

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


[clang-tools-extra] 89cd86b - Reapply [pseudo] Move pseudoparser from clang to clang-tools-extra"

2022-03-15 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2022-03-16T01:10:55+01:00
New Revision: 89cd86bbc58afe7d036bdb2f656dca38b62d8ef0

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

LOG: Reapply [pseudo] Move pseudoparser from clang to clang-tools-extra"

This reverts commit 049f4e4eab19c6e468e029232e94ca71245b0f56.

The problem was a stray dependency in CLANG_TEST_DEPS which caused cmake
to fail if clang-pseudo wasn't built. This is now removed.

Added: 
clang-tools-extra/pseudo/CMakeLists.txt
clang-tools-extra/pseudo/README.md
clang-tools-extra/pseudo/include/clang-pseudo/DirectiveMap.h
clang-tools-extra/pseudo/include/clang-pseudo/Grammar.h
clang-tools-extra/pseudo/include/clang-pseudo/LRGraph.h
clang-tools-extra/pseudo/include/clang-pseudo/LRTable.h
clang-tools-extra/pseudo/include/clang-pseudo/Token.h
clang-tools-extra/pseudo/lib/CMakeLists.txt
clang-tools-extra/pseudo/lib/DirectiveMap.cpp
clang-tools-extra/pseudo/lib/Grammar.cpp
clang-tools-extra/pseudo/lib/GrammarBNF.cpp
clang-tools-extra/pseudo/lib/LRGraph.cpp
clang-tools-extra/pseudo/lib/LRTable.cpp
clang-tools-extra/pseudo/lib/LRTableBuild.cpp
clang-tools-extra/pseudo/lib/Lex.cpp
clang-tools-extra/pseudo/lib/Token.cpp
clang-tools-extra/pseudo/lib/cxx.bnf
clang-tools-extra/pseudo/test/CMakeLists.txt
clang-tools-extra/pseudo/test/Unit/lit.cfg.py
clang-tools-extra/pseudo/test/Unit/lit.site.cfg.py.in
clang-tools-extra/pseudo/test/check-cxx-bnf.test
clang-tools-extra/pseudo/test/lex.c
clang-tools-extra/pseudo/test/lit.cfg.py
clang-tools-extra/pseudo/test/lit.local.cfg
clang-tools-extra/pseudo/test/lit.site.cfg.py.in
clang-tools-extra/pseudo/test/lr-build-basic.test
clang-tools-extra/pseudo/test/lr-build-conflicts.test
clang-tools-extra/pseudo/tool/CMakeLists.txt
clang-tools-extra/pseudo/tool/ClangPseudo.cpp
clang-tools-extra/pseudo/unittests/CMakeLists.txt
clang-tools-extra/pseudo/unittests/DirectiveMapTest.cpp
clang-tools-extra/pseudo/unittests/GrammarTest.cpp
clang-tools-extra/pseudo/unittests/LRTableTest.cpp
clang-tools-extra/pseudo/unittests/TokenTest.cpp

Modified: 
clang-tools-extra/CMakeLists.txt
clang/lib/Tooling/Syntax/CMakeLists.txt
clang/test/CMakeLists.txt
clang/tools/CMakeLists.txt
clang/unittests/Tooling/Syntax/CMakeLists.txt

Removed: 
clang/include/clang/Tooling/Syntax/Pseudo/DirectiveMap.h
clang/include/clang/Tooling/Syntax/Pseudo/Grammar.h
clang/include/clang/Tooling/Syntax/Pseudo/LRGraph.h
clang/include/clang/Tooling/Syntax/Pseudo/LRTable.h
clang/include/clang/Tooling/Syntax/Pseudo/Token.h
clang/lib/Tooling/Syntax/Pseudo/CMakeLists.txt
clang/lib/Tooling/Syntax/Pseudo/DirectiveMap.cpp
clang/lib/Tooling/Syntax/Pseudo/Grammar.cpp
clang/lib/Tooling/Syntax/Pseudo/GrammarBNF.cpp
clang/lib/Tooling/Syntax/Pseudo/LRGraph.cpp
clang/lib/Tooling/Syntax/Pseudo/LRTable.cpp
clang/lib/Tooling/Syntax/Pseudo/LRTableBuild.cpp
clang/lib/Tooling/Syntax/Pseudo/Lex.cpp
clang/lib/Tooling/Syntax/Pseudo/README.md
clang/lib/Tooling/Syntax/Pseudo/Token.cpp
clang/lib/Tooling/Syntax/Pseudo/cxx.bnf
clang/test/Syntax/check-cxx-bnf.test
clang/test/Syntax/lex.c
clang/test/Syntax/lit.local.cfg
clang/test/Syntax/lr-build-basic.test
clang/test/Syntax/lr-build-conflicts.test
clang/tools/clang-pseudo/CMakeLists.txt
clang/tools/clang-pseudo/ClangPseudo.cpp
clang/unittests/Tooling/Syntax/Pseudo/CMakeLists.txt
clang/unittests/Tooling/Syntax/Pseudo/DirectiveMapTest.cpp
clang/unittests/Tooling/Syntax/Pseudo/GrammarTest.cpp
clang/unittests/Tooling/Syntax/Pseudo/LRTableTest.cpp
clang/unittests/Tooling/Syntax/Pseudo/TokenTest.cpp



diff  --git a/clang-tools-extra/CMakeLists.txt 
b/clang-tools-extra/CMakeLists.txt
index 7b8274a97336b..285e5529e6fc6 100644
--- a/clang-tools-extra/CMakeLists.txt
+++ b/clang-tools-extra/CMakeLists.txt
@@ -15,6 +15,7 @@ add_subdirectory(clang-include-fixer)
 add_subdirectory(clang-move)
 add_subdirectory(clang-query)
 add_subdirectory(pp-trace)
+add_subdirectory(pseudo)
 add_subdirectory(tool-template)
 
 # Add the common testsuite after all the tools.

diff  --git a/clang-tools-extra/pseudo/CMakeLists.txt 
b/clang-tools-extra/pseudo/CMakeLists.txt
new file mode 100644
index 0..a10884ad406b9
--- /dev/null
+++ b/clang-tools-extra/pseudo/CMakeLists.txt
@@ -0,0 +1,6 @@
+include_directories(include)
+include_directories(${CMAKE_CURRENT_BINARY_DIR}/include)
+add_subdirectory(lib)
+add_subdirectory(tool)
+add_subdirectory(unittests)
+add_subdirectory(test)

diff  --git a/clang/lib/Tooling/Syntax/Pseudo/README.md 
b/clang-tools-extra/pseudo/README.md
similarity index 100%
rename from 

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

2022-03-15 Thread Alister Johnson via Phabricator via cfe-commits
ajohnson-uoregon added a comment.

This is the same use case as my other patches :) 
https://github.com/ajohnson-uoregon/llvm-project/blob/feature-ajohnson/clang-tools-extra/clang-rewrite/ConstructMatchers.cpp#L545

If there's a function with default arguments, and our user doesn't specify some 
of those defaults when they're writing code for our tool, we want to match only 
the calls in their code that give the same number of arguments, but 
`argumentCountIs()` matches the total *including* default arguments, and we 
need the total *excluding* non-provided default arguments. For example, our 
user might write

  void func(int a = 0, int b = 0);
  
  [[clang::matcher("test")]]
  auto foo(int x) {
func(x);
  }

and we don't want that to match `func()` or `func(x, y)`. When we're doing 
matcher generation, we aren't able to look up the FunctionDecl and see if there 
are defaults (because the function name itself might be a parameter for us), 
and even if we could, adding `cxxDefaultArgExpr()` for all of the missing ones 
is a lot of work that we'd rather not do.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120956

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


[PATCH] D121233: [pseudo] Move pseudoparser from clang to clang-tools-extra

2022-03-15 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Ah I see what happened - there was one incorrect (and unneeded) dependency left 
behind, which caused tests to fail if you *didn't* have clang-tools-extra 
enabled.
Relanding...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121233

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


Re: [PATCH] D121233: [pseudo] Move pseudoparser from clang to clang-tools-extra

2022-03-15 Thread Sam McCall via cfe-commits
Sorry, this broke the world and I wasn't watching it carefully enough.
Reverted in 049f4e4eab19c6e468e029232e94ca71245b0f56, trying to work out
why the tests passed locally.

On Wed, Mar 16, 2022 at 12:48 AM Ron Lieberman via Phabricator <
revi...@reviews.llvm.org> wrote:

> ronlieb added a comment.
>
> Hi Sam
> i think this breaks our amdgpu buildbot
> https://lab.llvm.org/buildbot/#/builders/193/builds/8513
>
> any suggestions?
>
>
> Repository:
>   rG LLVM Github Monorepo
>
> CHANGES SINCE LAST ACTION
>   https://reviews.llvm.org/D121233/new/
>
> https://reviews.llvm.org/D121233
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 049f4e4 - Revert "[pseudo] Move pseudoparser from clang to clang-tools-extra"

2022-03-15 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2022-03-16T01:06:24+01:00
New Revision: 049f4e4eab19c6e468e029232e94ca71245b0f56

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

LOG: Revert "[pseudo] Move pseudoparser from clang to clang-tools-extra"

This reverts commit b97856c4cfe7efb13887d5691002a7aa38440924.

Breaks a bunch of bots:
https://lab.llvm.org/buildbot/#/builders/193/builds/8513

Added: 
clang/include/clang/Tooling/Syntax/Pseudo/DirectiveMap.h
clang/include/clang/Tooling/Syntax/Pseudo/Grammar.h
clang/include/clang/Tooling/Syntax/Pseudo/LRGraph.h
clang/include/clang/Tooling/Syntax/Pseudo/LRTable.h
clang/include/clang/Tooling/Syntax/Pseudo/Token.h
clang/lib/Tooling/Syntax/Pseudo/CMakeLists.txt
clang/lib/Tooling/Syntax/Pseudo/DirectiveMap.cpp
clang/lib/Tooling/Syntax/Pseudo/Grammar.cpp
clang/lib/Tooling/Syntax/Pseudo/GrammarBNF.cpp
clang/lib/Tooling/Syntax/Pseudo/LRGraph.cpp
clang/lib/Tooling/Syntax/Pseudo/LRTable.cpp
clang/lib/Tooling/Syntax/Pseudo/LRTableBuild.cpp
clang/lib/Tooling/Syntax/Pseudo/Lex.cpp
clang/lib/Tooling/Syntax/Pseudo/README.md
clang/lib/Tooling/Syntax/Pseudo/Token.cpp
clang/lib/Tooling/Syntax/Pseudo/cxx.bnf
clang/test/Syntax/check-cxx-bnf.test
clang/test/Syntax/lex.c
clang/test/Syntax/lit.local.cfg
clang/test/Syntax/lr-build-basic.test
clang/test/Syntax/lr-build-conflicts.test
clang/tools/clang-pseudo/CMakeLists.txt
clang/tools/clang-pseudo/ClangPseudo.cpp
clang/unittests/Tooling/Syntax/Pseudo/CMakeLists.txt
clang/unittests/Tooling/Syntax/Pseudo/DirectiveMapTest.cpp
clang/unittests/Tooling/Syntax/Pseudo/GrammarTest.cpp
clang/unittests/Tooling/Syntax/Pseudo/LRTableTest.cpp
clang/unittests/Tooling/Syntax/Pseudo/TokenTest.cpp

Modified: 
clang-tools-extra/CMakeLists.txt
clang/lib/Tooling/Syntax/CMakeLists.txt
clang/tools/CMakeLists.txt
clang/unittests/Tooling/Syntax/CMakeLists.txt

Removed: 
clang-tools-extra/pseudo/CMakeLists.txt
clang-tools-extra/pseudo/README.md
clang-tools-extra/pseudo/include/clang-pseudo/DirectiveMap.h
clang-tools-extra/pseudo/include/clang-pseudo/Grammar.h
clang-tools-extra/pseudo/include/clang-pseudo/LRGraph.h
clang-tools-extra/pseudo/include/clang-pseudo/LRTable.h
clang-tools-extra/pseudo/include/clang-pseudo/Token.h
clang-tools-extra/pseudo/lib/CMakeLists.txt
clang-tools-extra/pseudo/lib/DirectiveMap.cpp
clang-tools-extra/pseudo/lib/Grammar.cpp
clang-tools-extra/pseudo/lib/GrammarBNF.cpp
clang-tools-extra/pseudo/lib/LRGraph.cpp
clang-tools-extra/pseudo/lib/LRTable.cpp
clang-tools-extra/pseudo/lib/LRTableBuild.cpp
clang-tools-extra/pseudo/lib/Lex.cpp
clang-tools-extra/pseudo/lib/Token.cpp
clang-tools-extra/pseudo/lib/cxx.bnf
clang-tools-extra/pseudo/test/CMakeLists.txt
clang-tools-extra/pseudo/test/Unit/lit.cfg.py
clang-tools-extra/pseudo/test/Unit/lit.site.cfg.py.in
clang-tools-extra/pseudo/test/check-cxx-bnf.test
clang-tools-extra/pseudo/test/lex.c
clang-tools-extra/pseudo/test/lit.cfg.py
clang-tools-extra/pseudo/test/lit.local.cfg
clang-tools-extra/pseudo/test/lit.site.cfg.py.in
clang-tools-extra/pseudo/test/lr-build-basic.test
clang-tools-extra/pseudo/test/lr-build-conflicts.test
clang-tools-extra/pseudo/tool/CMakeLists.txt
clang-tools-extra/pseudo/tool/ClangPseudo.cpp
clang-tools-extra/pseudo/unittests/CMakeLists.txt
clang-tools-extra/pseudo/unittests/DirectiveMapTest.cpp
clang-tools-extra/pseudo/unittests/GrammarTest.cpp
clang-tools-extra/pseudo/unittests/LRTableTest.cpp
clang-tools-extra/pseudo/unittests/TokenTest.cpp



diff  --git a/clang-tools-extra/CMakeLists.txt 
b/clang-tools-extra/CMakeLists.txt
index 285e5529e6fc6..7b8274a97336b 100644
--- a/clang-tools-extra/CMakeLists.txt
+++ b/clang-tools-extra/CMakeLists.txt
@@ -15,7 +15,6 @@ add_subdirectory(clang-include-fixer)
 add_subdirectory(clang-move)
 add_subdirectory(clang-query)
 add_subdirectory(pp-trace)
-add_subdirectory(pseudo)
 add_subdirectory(tool-template)
 
 # Add the common testsuite after all the tools.

diff  --git a/clang-tools-extra/pseudo/CMakeLists.txt 
b/clang-tools-extra/pseudo/CMakeLists.txt
deleted file mode 100644
index a10884ad406b9..0
--- a/clang-tools-extra/pseudo/CMakeLists.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-include_directories(include)
-include_directories(${CMAKE_CURRENT_BINARY_DIR}/include)
-add_subdirectory(lib)
-add_subdirectory(tool)
-add_subdirectory(unittests)
-add_subdirectory(test)

diff  --git a/clang-tools-extra/pseudo/test/CMakeLists.txt 
b/clang-tools-extra/pseudo/test/CMakeLists.txt
deleted file mode 100644
index 334acb58d41c2..0
--- 

[PATCH] D120296: [Attr] Fix a btf_type_tag AST generation bug

2022-03-15 Thread Yonghong Song via Phabricator via cfe-commits
yonghong-song updated this revision to Diff 415638.
yonghong-song added a comment.

- change TransformBTFTagAttributedType() implementation with a simple 
llvm_unreachable() message. I tested linux kernel and its selftests/bpf 
compilation with clang and found the only TreeTransformation function is called 
with TransformAutoType() due to __auto_type usage.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120296

Files:
  clang/include/clang-c/Index.h
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/ASTNodeTraverser.h
  clang/include/clang/AST/PropertiesBase.td
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/AST/Type.h
  clang/include/clang/AST/TypeLoc.h
  clang/include/clang/AST/TypeProperties.td
  clang/include/clang/Basic/TypeNodes.td
  clang/include/clang/Serialization/ASTRecordReader.h
  clang/include/clang/Serialization/ASTRecordWriter.h
  clang/include/clang/Serialization/TypeBitCodes.def
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTStructuralEquivalence.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/TypeLoc.cpp
  clang/lib/AST/TypePrinter.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDebugInfo.h
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaType.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/CodeGen/attr-btf_type_tag-similar-type.c
  clang/test/PCH/btf_type_tag_attr.c
  clang/test/Sema/attr-btf_type_tag.c
  clang/tools/libclang/CIndex.cpp
  clang/tools/libclang/CXType.cpp

Index: clang/tools/libclang/CXType.cpp
===
--- clang/tools/libclang/CXType.cpp
+++ clang/tools/libclang/CXType.cpp
@@ -116,6 +116,7 @@
 TKCASE(Elaborated);
 TKCASE(Pipe);
 TKCASE(Attributed);
+TKCASE(BTFTagAttributed);
 TKCASE(Atomic);
 default:
   return CXType_Unexposed;
@@ -136,6 +137,10 @@
 return MakeCXType(ATT->getEquivalentType(), TU);
   }
 }
+if (auto *ATT = T->getAs()) {
+  if (!(TU->ParsingOptions & CXTranslationUnit_IncludeAttributedTypes))
+return MakeCXType(ATT->getWrappedType(), TU);
+}
 // Handle paren types as the original type
 if (auto *PTT = T->getAs()) {
   return MakeCXType(PTT->getInnerType(), TU);
@@ -610,6 +615,7 @@
 TKIND(Elaborated);
 TKIND(Pipe);
 TKIND(Attributed);
+TKIND(BTFTagAttributed);
 TKIND(BFloat16);
 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) TKIND(Id);
 #include "clang/Basic/OpenCLImageTypes.def"
@@ -1051,6 +1057,9 @@
   if (auto *ATT = T->getAs())
 return MakeCXType(ATT->getModifiedType(), GetTU(CT));
 
+  if (auto *ATT = T->getAs())
+return MakeCXType(ATT->getWrappedType(), GetTU(CT));
+
   return MakeCXType(QualType(), GetTU(CT));
 }
 
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -1672,6 +1672,10 @@
   return Visit(TL.getModifiedLoc());
 }
 
+bool CursorVisitor::VisitBTFTagAttributedTypeLoc(BTFTagAttributedTypeLoc TL) {
+  return Visit(TL.getWrappedLoc());
+}
+
 bool CursorVisitor::VisitFunctionTypeLoc(FunctionTypeLoc TL,
  bool SkipResultType) {
   if (!SkipResultType && Visit(TL.getReturnLoc()))
Index: clang/test/Sema/attr-btf_type_tag.c
===
--- clang/test/Sema/attr-btf_type_tag.c
+++ clang/test/Sema/attr-btf_type_tag.c
@@ -23,3 +23,19 @@
 int __tag4 * __tag5 * __tag6 *foo1(struct t __tag1 * __tag2 * __tag3 *a1) {
   return (int __tag4 * __tag5 * __tag6 *)a1[0][0]->d;
 }
+
+// The btf_type_tag attribute will be ignored during _Generic type matching
+int g1 = _Generic((int *)0, int __tag1 *: 0);
+int g2 = _Generic((int __tag1 *)0, int *: 0);
+int g3 = _Generic(0,
+  int __tag1 * : 0, // expected-note {{compatible type 'int  btf_type_tag(tag1)*' (aka 'int *') specified here}}
+  int * : 0, // expected-error {{type 'int *' in generic association compatible with previously specified type 'int  btf_type_tag(tag1)*' (aka 'int *')}}
+  default : 0);
+
+// The btf_type_tag attribute will be ignored during overloadable type matching
+void bar2(int __tag1 *a) __attribute__((overloadable)) { asm volatile (""); } // expected-note {{previous definition is here}}
+void bar2(int *a) __attribute__((overloadable)) { asm volatile (""); } // expected-error {{redefinition of 'bar2'}}
+void foo2(int __tag1 *a, int *b) {
+  bar2(a);
+  bar2(b);
+}
Index: clang/test/PCH/btf_type_tag_attr.c
===
--- /dev/null
+++ clang/test/PCH/btf_type_tag_attr.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -triple aarch64-linux-gnu 

[PATCH] D121748: [clang][Sema] Better support for ObjC++ in Sema::LookupName

2022-03-15 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

Is there a way this can be tested from Clang?
Also, is there a Swift-based test case you have that demonstrates the original 
problem from Swift's clang importer side? I'm curious to see where it manifests 
in Swift.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121748

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


[PATCH] D121758: [clang-format] Add support for formatting Verilog code

2022-03-15 Thread sstwcw via Phabricator via cfe-commits
sstwcw added inline comments.



Comment at: clang/lib/Format/UnwrappedLineParser.cpp:534
 continue;
-  parseBlock(/*MustBeDeclaration=*/false, /*AddLevels=*/1u,
- /*MunchSemi=*/true, /*UnindentWhitesmithBraces=*/false,
- CanContainBracedList,
+  parseBlock(/*Flags=*/CanContainBracedList * 
BLOCK_CAN_CONTAIN_BRACED_LIST,
+ /*AddLevels=*/1u,

One of the people in charge said multiplying with a boolean might trigger 
warnings.  Here I compiled with gcc.  This version doesn't trigger warnings.  
The other way to do it, `CanContainBracedList ? BLOCK_CAN_CONTAIN_BRACED_LIST : 
0`, triggers a warning that I shouldn't mix enum and integer.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121758

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


[PATCH] D121233: [pseudo] Move pseudoparser from clang to clang-tools-extra

2022-03-15 Thread Ron Lieberman via Phabricator via cfe-commits
ronlieb added a comment.

Hi Sam
i think this breaks our amdgpu buildbot
https://lab.llvm.org/buildbot/#/builders/193/builds/8513

any suggestions?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121233

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


[PATCH] D121441: [PowerPC][NFC] Add atomic alignments and ops tests for powerpc

2022-03-15 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added inline comments.



Comment at: clang/test/CodeGen/PowerPC/atomic-alignment.c:1
+// REQUIRES: powerpc-registered-target
+// RUN: %clang_cc1 -verify -triple powerpc-unkonwn-unknown -emit-llvm -o - %s 
| \

I am not sure about having a `CodeGen` test for this when a `-fsyntax-only` 
`Layout` test would do. I believe that also removes the need for 
`powerpc-registered-target`.



Comment at: clang/test/Sema/atomic-ops.c:7-8
 // RUN:   -fsyntax-only -triple=powerpc64-linux-gnu -std=c11
+// RUN: %clang_cc1 %s -verify -fgnuc-version=4.2.1 -ffreestanding \
+// RUN:   -fsyntax-only -triple=powerpc64le-linux-gnu -std=c11
 

Consider testing across the `-mcpu=power7` and `-mcpu=power8` boundary.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121441

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


[PATCH] D121758: [clang-format] Add support for formatting Verilog code

2022-03-15 Thread sstwcw via Phabricator via cfe-commits
sstwcw added a subscriber: svenvh.
sstwcw added a comment.

Do we have people who use Verilog and knows the clang-format code base?  
@svenvh Your email address looks like you work for a hardware company.  If you 
know Verilog would you please have a look at this patch?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121758

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


[PATCH] D63085: Provide a fix-it hint for -Wswitch, which adds missing cases. If there are >3 cases, the inserted text will contain newlines so it will not be shown in console output (but will be appl

2022-03-15 Thread Sergio Martins via Phabricator via cfe-commits
iamsergio added a comment.
Herald added a subscriber: usaxena95.
Herald added a project: All.

I don't think we need to worry about formatting, that's the IDE's job (and 
whatever formatter it uses).
In general, the code that knows how to warn should also be the one that knows 
how to fix it, this looks like a good place to me.

Can we unblock this ? Probably this anymore though.


Repository:
  rC Clang

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

https://reviews.llvm.org/D63085

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


[PATCH] D121757: [clang-format] Take out common code for parsing blocks

2022-03-15 Thread sstwcw via Phabricator via cfe-commits
sstwcw created this revision.
sstwcw added a reviewer: clang-format.
sstwcw added a project: clang-format.
Herald added a project: All.
sstwcw requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D121757

Files:
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/lib/Format/UnwrappedLineParser.h

Index: clang/lib/Format/UnwrappedLineParser.h
===
--- clang/lib/Format/UnwrappedLineParser.h
+++ clang/lib/Format/UnwrappedLineParser.h
@@ -125,6 +125,8 @@
   bool handleCppAttributes();
   FormatToken *parseIfThenElse(IfStmtKind *IfKind, bool KeepBraces = false);
   void parseTryCatch();
+  void parseIndentedBlock(bool BracesAreOptional = true,
+  bool RBraceOnSeparateLine = true);
   void parseForOrWhileLoop();
   void parseDoWhile();
   void parseLabel(bool LeftAlignLabel = false);
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -2713,6 +2713,30 @@
   } while (!eof());
 }
 
+void UnwrappedLineParser::parseIndentedBlock(bool BracesAreOptional,
+ bool RBraceOnSeparateLine) {
+  CompoundStatementIndenter Indenter(this, Style, Line->Level);
+
+  keepAncestorBraces();
+
+  if (FormatTok->is(tok::l_brace)) {
+FormatToken *LeftBrace = FormatTok;
+parseBlock();
+if (BracesAreOptional && Style.RemoveBracesLLVM) {
+  assert(!NestedTooDeep.empty());
+  if (!NestedTooDeep.back())
+markOptionalBraces(LeftBrace);
+}
+if (RBraceOnSeparateLine)
+  addUnwrappedLine();
+  } else {
+parseUnbracedBody();
+  }
+
+  if (Style.RemoveBracesLLVM)
+NestedTooDeep.pop_back();
+}
+
 void UnwrappedLineParser::parseForOrWhileLoop() {
   assert(FormatTok->isOneOf(tok::kw_for, tok::kw_while, TT_ForEachMacro) &&
  "'for', 'while' or foreach macro expected");
@@ -2731,43 +2755,15 @@
 parseParens();
   }
 
-  keepAncestorBraces();
-
-  if (FormatTok->is(tok::l_brace)) {
-FormatToken *LeftBrace = FormatTok;
-CompoundStatementIndenter Indenter(this, Style, Line->Level);
-parseBlock();
-if (Style.RemoveBracesLLVM) {
-  assert(!NestedTooDeep.empty());
-  if (!NestedTooDeep.back())
-markOptionalBraces(LeftBrace);
-}
-addUnwrappedLine();
-  } else {
-parseUnbracedBody();
-  }
-
-  if (Style.RemoveBracesLLVM)
-NestedTooDeep.pop_back();
+  parseIndentedBlock(/*BracesAreOptional=*/true);
 }
 
 void UnwrappedLineParser::parseDoWhile() {
   assert(FormatTok->is(tok::kw_do) && "'do' expected");
   nextToken();
 
-  keepAncestorBraces();
-
-  if (FormatTok->is(tok::l_brace)) {
-CompoundStatementIndenter Indenter(this, Style, Line->Level);
-parseBlock();
-if (Style.BraceWrapping.BeforeWhile)
-  addUnwrappedLine();
-  } else {
-parseUnbracedBody();
-  }
-
-  if (Style.RemoveBracesLLVM)
-NestedTooDeep.pop_back();
+  parseIndentedBlock(/*BracesAreoptional=*/false,
+ /*RBraceOnSeparateLine=*/Style.BraceWrapping.BeforeWhile);
 
   // FIXME: Add error handling.
   if (!FormatTok->is(tok::kw_while)) {
@@ -2840,21 +2836,7 @@
 parseParens();
   }
 
-  keepAncestorBraces();
-
-  if (FormatTok->is(tok::l_brace)) {
-CompoundStatementIndenter Indenter(this, Style, Line->Level);
-parseBlock();
-addUnwrappedLine();
-  } else {
-addUnwrappedLine();
-++Line->Level;
-parseStructuralElement();
---Line->Level;
-  }
-
-  if (Style.RemoveBracesLLVM)
-NestedTooDeep.pop_back();
+  parseIndentedBlock();
 }
 
 // Operators that can follow a C variable.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D121441: [PowerPC][NFC] Add atomic alignments and ops tests for powerpc

2022-03-15 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added inline comments.



Comment at: clang/test/CodeGen/PowerPC/atomic-alignment.c:2-6
+// RUN: %clang_cc1 -verify -triple powerpc-unkonwn-unknown -emit-llvm -o - %s 
| \
+// RUN:   FileCheck %s --check-prefixes=PPC,PPC32
+// RUN: %clang_cc1 -verify -triple powerpc64le-unkonwn-linux -emit-llvm -o - 
%s | \
+// RUN:   FileCheck %s --check-prefixes=PPC,PPC64
+// RUN: %clang_cc1 -verify -triple powerpc64-unkonwn-aix -emit-llvm -o - %s | \

Fix typos: "`unkonwn`"


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121441

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


[PATCH] D121756: [clang-format] Clean up code looking for if statements

2022-03-15 Thread sstwcw via Phabricator via cfe-commits
sstwcw created this revision.
sstwcw added a reviewer: clang-format.
sstwcw added a project: clang-format.
Herald added a project: All.
sstwcw requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Previously several places had code to determine whether the line is an
if / while / for statement.  This commit replaces them with a function
call.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D121756

Files:
  clang/lib/Format/ContinuationIndenter.cpp
  clang/lib/Format/FormatToken.h
  clang/lib/Format/TokenAnnotator.cpp
  clang/lib/Format/UnwrappedLineParser.cpp

Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -2422,8 +2422,10 @@
   } else {
 if (FormatTok->isOneOf(tok::kw_constexpr, tok::identifier))
   nextToken();
-if (FormatTok->is(tok::l_paren))
+if (FormatTok->Tok.is(tok::l_paren)) {
+  FormatTok->setType(TT_ConditionLParen);
   parseParens();
+}
   }
   handleAttributes();
 
@@ -2714,14 +2716,20 @@
 void UnwrappedLineParser::parseForOrWhileLoop() {
   assert(FormatTok->isOneOf(tok::kw_for, tok::kw_while, TT_ForEachMacro) &&
  "'for', 'while' or foreach macro expected");
+  // Those that begin with a for require special treatment because inside the
+  // parentheses is not an expression.
+  bool IsFor = FormatTok->is(tok::kw_for) || FormatTok->is(TT_ForEachMacro);
   nextToken();
   // JS' for await ( ...
   if (Style.isJavaScript() && FormatTok->is(Keywords.kw_await))
 nextToken();
   if (Style.isCpp() && FormatTok->is(tok::kw_co_await))
 nextToken();
-  if (FormatTok->is(tok::l_paren))
+  if (FormatTok->is(tok::l_paren)) {
+if (!IsFor)
+  FormatTok->setType(TT_ConditionLParen);
 parseParens();
+  }
 
   keepAncestorBraces();
 
@@ -2827,8 +2835,10 @@
 void UnwrappedLineParser::parseSwitch() {
   assert(FormatTok->is(tok::kw_switch) && "'switch' expected");
   nextToken();
-  if (FormatTok->is(tok::l_paren))
+  if (FormatTok->is(tok::l_paren)) {
+FormatTok->setType(TT_ConditionLParen);
 parseParens();
+  }
 
   keepAncestorBraces();
 
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -63,13 +63,6 @@
  Left->Previous->MatchingParen->is(TT_LambdaLSquare);
 }
 
-/// Returns \c true if the token is followed by a boolean condition, \c false
-/// otherwise.
-static bool isKeywordWithCondition(const FormatToken ) {
-  return Tok.isOneOf(tok::kw_if, tok::kw_for, tok::kw_while, tok::kw_switch,
- tok::kw_constexpr, tok::kw_catch);
-}
-
 /// A parser that gathers additional information about tokens.
 ///
 /// The \c TokenAnnotator tries to match parenthesis and square brakets and
@@ -130,10 +123,9 @@
 // parameter cases, but should not alter program semantics.
 if (CurrentToken->Next && CurrentToken->Next->is(tok::greater) &&
 Left->ParentBracket != tok::less &&
-(isKeywordWithCondition(*Line.First) ||
- CurrentToken->getStartOfNonWhitespace() ==
- CurrentToken->Next->getStartOfNonWhitespace().getLocWithOffset(
- -1)))
+CurrentToken->getStartOfNonWhitespace() ==
+CurrentToken->Next->getStartOfNonWhitespace().getLocWithOffset(
+-1))
   return false;
 Left->MatchingParen = CurrentToken;
 CurrentToken->MatchingParen = Left;
@@ -257,12 +249,11 @@
   // type X = (...);
   // export type X = (...);
   Contexts.back().IsExpression = false;
-} else if (OpeningParen.Previous &&
-   (OpeningParen.Previous->isOneOf(tok::kw_static_assert,
-   tok::kw_while, tok::l_paren,
-   tok::comma) ||
-OpeningParen.Previous->isIf() ||
-OpeningParen.Previous->is(TT_BinaryOperator))) {
+} else if (OpeningParen.isConditionLParen(/*IncludeSpecial=*/false) ||
+   (OpeningParen.Previous &&
+OpeningParen.Previous->isOneOf(TT_BinaryOperator, tok::l_paren,
+   tok::comma,
+   tok::kw_static_assert))) {
   // static_assert, if and while usually contain expressions.
   Contexts.back().IsExpression = true;
 } else if (Style.isJavaScript() && OpeningParen.Previous &&
@@ -1437,17 +1428,18 @@
 // recovered from an error (e.g. failure to find the matching >).
 if (!CurrentToken->isTypeFinalized() &&
 !CurrentToken->isOneOf(
-TT_LambdaLSquare, TT_LambdaLBrace, TT_AttributeMacro, TT_IfMacro,
-TT_ForEachMacro, 

[PATCH] D121755: [clang-format] Join spaceRequiredBefore and spaceRequiredBetween

2022-03-15 Thread sstwcw via Phabricator via cfe-commits
sstwcw created this revision.
sstwcw added a reviewer: clang-format.
Herald added a project: All.
sstwcw requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

After all these years, having the two functions now serves to confuse
people.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D121755

Files:
  clang/lib/Format/TokenAnnotator.cpp
  clang/lib/Format/TokenAnnotator.h

Index: clang/lib/Format/TokenAnnotator.h
===
--- clang/lib/Format/TokenAnnotator.h
+++ clang/lib/Format/TokenAnnotator.h
@@ -169,9 +169,6 @@
 
   bool spaceRequiredBeforeParens(const FormatToken ) const;
 
-  bool spaceRequiredBetween(const AnnotatedLine , const FormatToken ,
-const FormatToken );
-
   bool spaceRequiredBefore(const AnnotatedLine , const FormatToken );
 
   bool mustBreakBefore(const AnnotatedLine , const FormatToken );
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -3066,9 +3066,411 @@
   return false;
 }
 
-bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine ,
-  const FormatToken ,
-  const FormatToken ) {
+bool TokenAnnotator::spaceRequiredBefore(const AnnotatedLine ,
+ const FormatToken ) {
+  assert(Right.Previous);
+  const FormatToken  = *Right.Previous;
+
+  // If the token is finalized don't touch it (as it could be in a
+  // clang-format-off section).
+  if (Left.Finalized)
+return Right.hasWhitespaceBefore();
+
+  if (Right.Tok.getIdentifierInfo() && Left.Tok.getIdentifierInfo())
+return true; // Never ever merge two identifiers.
+
+  // Leave a space between * and /* to avoid C4138 `comment end` found outside
+  // of comment.
+  if (Left.is(tok::star) && Right.is(tok::comment))
+return true;
+
+  if (Style.isCpp()) {
+// Space between import .
+// or import .;
+if (Left.is(Keywords.kw_import) && Right.isOneOf(tok::less, tok::ellipsis))
+  return true;
+// Space between `module :` and `import :`.
+if (Left.isOneOf(Keywords.kw_module, Keywords.kw_import) &&
+Right.is(TT_ModulePartitionColon))
+  return true;
+// No space between import foo:bar but keep a space between import :bar;
+if (Left.is(tok::identifier) && Right.is(TT_ModulePartitionColon))
+  return false;
+// No space between :bar;
+if (Left.is(TT_ModulePartitionColon) &&
+Right.isOneOf(tok::identifier, tok::kw_private))
+  return false;
+if (Left.is(tok::ellipsis) && Right.is(tok::identifier) &&
+Line.First->is(Keywords.kw_import))
+  return false;
+// Space in __attribute__((attr)) ::type.
+if (Left.is(TT_AttributeParen) && Right.is(tok::coloncolon))
+  return true;
+
+if (Left.is(tok::kw_operator))
+  return Right.is(tok::coloncolon);
+if (Right.is(tok::l_brace) && Right.is(BK_BracedInit) &&
+!Left.opensScope() && Style.SpaceBeforeCpp11BracedList)
+  return true;
+if (Left.is(tok::less) && Left.is(TT_OverloadedOperator) &&
+Right.is(TT_TemplateOpener))
+  return true;
+  } else if (Style.Language == FormatStyle::LK_Proto ||
+ Style.Language == FormatStyle::LK_TextProto) {
+if (Right.is(tok::period) &&
+Left.isOneOf(Keywords.kw_optional, Keywords.kw_required,
+ Keywords.kw_repeated, Keywords.kw_extend))
+  return true;
+if (Right.is(tok::l_paren) &&
+Left.isOneOf(Keywords.kw_returns, Keywords.kw_option))
+  return true;
+if (Right.isOneOf(tok::l_brace, tok::less) && Left.is(TT_SelectorName))
+  return true;
+// Slashes occur in text protocol extension syntax: [type/type] { ... }.
+if (Left.is(tok::slash) || Right.is(tok::slash))
+  return false;
+if (Left.MatchingParen &&
+Left.MatchingParen->is(TT_ProtoExtensionLSquare) &&
+Right.isOneOf(tok::l_brace, tok::less))
+  return !Style.Cpp11BracedListStyle;
+// A percent is probably part of a formatting specification, such as %lld.
+if (Left.is(tok::percent))
+  return false;
+// Preserve the existence of a space before a percent for cases like 0x%04x
+// and "%d %d"
+if (Left.is(tok::numeric_constant) && Right.is(tok::percent))
+  return Right.hasWhitespaceBefore();
+  } else if (Style.isJson()) {
+if (Right.is(tok::colon))
+  return false;
+  } else if (Style.isCSharp()) {
+// Require spaces around '{' and  before '}' unless they appear in
+// interpolated strings. Interpolated strings are merged into a single token
+// so cannot have spaces inserted by this function.
+
+// No space between 'this' and '['
+if (Left.is(tok::kw_this) && 

[PATCH] D121754: [clang-format] Refactor determineStarAmpUsage

2022-03-15 Thread sstwcw via Phabricator via cfe-commits
sstwcw created this revision.
sstwcw added a reviewer: clang-format.
sstwcw added a project: clang-format.
Herald added a project: All.
sstwcw requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

There was some duplicate code in determineStarAmpUsage and
determinePlusMinusCaretUsage


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D121754

Files:
  clang/lib/Format/TokenAnnotator.cpp


Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -2158,12 +2158,7 @@
 if (PrevToken->is(tok::r_paren) && PrevToken->is(TT_TypeDeclarationParen))
   return TT_PointerOrReference;
 
-if (PrevToken->isOneOf(tok::l_paren, tok::l_square, tok::l_brace,
-   tok::comma, tok::semi, tok::kw_return, tok::colon,
-   tok::kw_co_return, tok::kw_co_await,
-   tok::kw_co_yield, tok::equal, tok::kw_delete,
-   tok::kw_sizeof, tok::kw_throw, TT_BinaryOperator,
-   TT_ConditionalExpr, TT_UnaryOperator, 
TT_CastRParen))
+if (determinePlusMinusCaretUsage(Tok) == TT_UnaryOperator)
   return TT_UnaryOperator;
 
 if (NextToken->is(tok::l_square) && NextToken->isNot(TT_LambdaLSquare))
@@ -2210,19 +2205,12 @@
 if (!PrevToken)
   return TT_UnaryOperator;
 
-if (PrevToken->isOneOf(TT_CastRParen, TT_UnaryOperator))
-  // This must be a sequence of leading unary operators.
-  return TT_UnaryOperator;
-
-// Use heuristics to recognize unary operators.
-if (PrevToken->isOneOf(tok::equal, tok::l_paren, tok::comma, tok::l_square,
-   tok::question, tok::colon, tok::kw_return,
-   tok::kw_case, tok::at, tok::l_brace, tok::kw_throw,
-   tok::kw_co_return, tok::kw_co_yield))
-  return TT_UnaryOperator;
-
-// There can't be two consecutive binary operators.
-if (PrevToken->is(TT_BinaryOperator))
+if (PrevToken->isOneOf(
+TT_BinaryOperator, TT_CastRParen, TT_ConditionalExpr,
+TT_UnaryOperator, tok::l_paren, tok::comma, tok::colon, tok::semi,
+tok::equal, tok::question, tok::at, tok::l_square, tok::l_brace,
+tok::kw_case, tok::kw_co_await, tok::kw_co_return, 
tok::kw_co_yield,
+tok::kw_delete, tok::kw_return, tok::kw_sizeof, tok::kw_throw))
   return TT_UnaryOperator;
 
 // Fall back to marking the token as binary operator.


Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -2158,12 +2158,7 @@
 if (PrevToken->is(tok::r_paren) && PrevToken->is(TT_TypeDeclarationParen))
   return TT_PointerOrReference;
 
-if (PrevToken->isOneOf(tok::l_paren, tok::l_square, tok::l_brace,
-   tok::comma, tok::semi, tok::kw_return, tok::colon,
-   tok::kw_co_return, tok::kw_co_await,
-   tok::kw_co_yield, tok::equal, tok::kw_delete,
-   tok::kw_sizeof, tok::kw_throw, TT_BinaryOperator,
-   TT_ConditionalExpr, TT_UnaryOperator, TT_CastRParen))
+if (determinePlusMinusCaretUsage(Tok) == TT_UnaryOperator)
   return TT_UnaryOperator;
 
 if (NextToken->is(tok::l_square) && NextToken->isNot(TT_LambdaLSquare))
@@ -2210,19 +2205,12 @@
 if (!PrevToken)
   return TT_UnaryOperator;
 
-if (PrevToken->isOneOf(TT_CastRParen, TT_UnaryOperator))
-  // This must be a sequence of leading unary operators.
-  return TT_UnaryOperator;
-
-// Use heuristics to recognize unary operators.
-if (PrevToken->isOneOf(tok::equal, tok::l_paren, tok::comma, tok::l_square,
-   tok::question, tok::colon, tok::kw_return,
-   tok::kw_case, tok::at, tok::l_brace, tok::kw_throw,
-   tok::kw_co_return, tok::kw_co_yield))
-  return TT_UnaryOperator;
-
-// There can't be two consecutive binary operators.
-if (PrevToken->is(TT_BinaryOperator))
+if (PrevToken->isOneOf(
+TT_BinaryOperator, TT_CastRParen, TT_ConditionalExpr,
+TT_UnaryOperator, tok::l_paren, tok::comma, tok::colon, tok::semi,
+tok::equal, tok::question, tok::at, tok::l_square, tok::l_brace,
+tok::kw_case, tok::kw_co_await, tok::kw_co_return, tok::kw_co_yield,
+tok::kw_delete, tok::kw_return, tok::kw_sizeof, tok::kw_throw))
   return TT_UnaryOperator;
 
 // Fall back to marking the token as binary operator.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D120952: [clang][AST matchers] adding submatchers under cudaKernelCallExpr to match kernel launch config

2022-03-15 Thread Alister Johnson via Phabricator via cfe-commits
ajohnson-uoregon added a comment.

For the specific argument matchers (`cudaBlockDim()`, `cudaStream()`, etc), I 
agree, I'm not sure if there's any other use cases in tree. I wasn't aware you 
could write local definitions like that, I could definitely do that within my 
project for those.

I would still like to upstream `hasKernelConfig()` though, so it's at least 
possible to match the kernel config without defining a local matcher.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120952

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


[PATCH] D121753: [clang-format] Use a macro for non-C keywords

2022-03-15 Thread sstwcw via Phabricator via cfe-commits
sstwcw created this revision.
sstwcw added a reviewer: clang-format.
sstwcw added a project: clang-format.
Herald added a project: All.
sstwcw requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

We had to add a bunch of keywords for a new language.  Using the old
method, we had to add each keyword in the declaration, initialization,
and maybe in several lists, which turned out to be tiring and
error-prone.  Also we didn't want functions like
`IsJavaScriptIdentifier` to take linear time with respect to the number
of keywords.  In the new version we use a hash table.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D121753

Files:
  clang/lib/Format/FormatToken.h
  clang/lib/Format/UnwrappedLineFormatter.cpp
  clang/lib/Format/UnwrappedLineParser.cpp

Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -1481,8 +1481,8 @@
   }
 }
 if (Style.isCpp() &&
-FormatTok->isOneOf(Keywords.kw_signals, Keywords.kw_qsignals,
-   Keywords.kw_slots, Keywords.kw_qslots)) {
+FormatTok->isOneOf(Keywords.kw_signals, Keywords.kw_Q_SIGNALS,
+   Keywords.kw_slots, Keywords.kw_Q_SLOTS)) {
   nextToken();
   if (FormatTok->is(tok::colon)) {
 nextToken();
@@ -2902,7 +2902,7 @@
   FormatToken *AccessSpecifierCandidate = FormatTok;
   nextToken();
   // Understand Qt's slots.
-  if (FormatTok->isOneOf(Keywords.kw_slots, Keywords.kw_qslots))
+  if (FormatTok->isOneOf(Keywords.kw_slots, Keywords.kw_Q_SLOTS))
 nextToken();
   // Otherwise, we don't know what it is, and we'd better keep the next token.
   if (FormatTok->is(tok::colon)) {
Index: clang/lib/Format/UnwrappedLineFormatter.cpp
===
--- clang/lib/Format/UnwrappedLineFormatter.cpp
+++ clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -112,11 +112,12 @@
   else if (RootToken.isObjCAccessSpecifier())
 return true;
   // Handle Qt signals.
-  else if ((RootToken.isOneOf(Keywords.kw_signals, Keywords.kw_qsignals) &&
+  else if ((RootToken.isOneOf(Keywords.kw_signals, Keywords.kw_Q_SIGNALS) &&
 RootToken.Next && RootToken.Next->is(tok::colon)))
 return true;
   else if (RootToken.Next &&
-   RootToken.Next->isOneOf(Keywords.kw_slots, Keywords.kw_qslots) &&
+   RootToken.Next->isOneOf(Keywords.kw_slots,
+   Keywords.kw_Q_SLOTS) &&
RootToken.Next->Next && RootToken.Next->Next->is(tok::colon))
 return true;
   // Handle malformed access specifier e.g. 'private' without trailing ':'.
Index: clang/lib/Format/FormatToken.h
===
--- clang/lib/Format/FormatToken.h
+++ clang/lib/Format/FormatToken.h
@@ -20,6 +20,7 @@
 #include "clang/Format/Format.h"
 #include "clang/Lex/Lexer.h"
 #include 
+#include 
 #include 
 
 namespace clang {
@@ -880,228 +881,130 @@
 /// Encapsulates keywords that are context sensitive or for languages not
 /// properly supported by Clang's lexer.
 struct AdditionalKeywords {
+#define LIST_ADDITIONAL_KEYWORDS   \
+  /* Context-sensitive */  \
+  KEYWORD(final, 0)\
+  KEYWORD(override, ATTR_JS_KEYWORD | ATTR_CSHARP_KEYWORD) \
+  KEYWORD(in, ATTR_CSHARP_KEYWORD) \
+  KEYWORD(of, 0)   \
+  KEYWORD(CF_CLOSED_ENUM, 0)   \
+  KEYWORD(CF_ENUM, 0)  \
+  KEYWORD(CF_OPTIONS, 0)   \
+  KEYWORD(NS_CLOSED_ENUM, 0)   \
+  KEYWORD(NS_ENUM, 0)  \
+  KEYWORD(NS_OPTIONS, 0)   \
+  /* Javascript */ \
+  KEYWORD(as, ATTR_JS_KEYWORD | ATTR_CSHARP_KEYWORD)   \
+  KEYWORD(async, ATTR_JS_KEYWORD | ATTR_CSHARP_KEYWORD)\
+  KEYWORD(await, ATTR_JS_KEYWORD | ATTR_CSHARP_KEYWORD)\
+  KEYWORD(declare, ATTR_JS_KEYWORD | ATTR_CSHARP_KEYWORD)  \
+  KEYWORD(finally, ATTR_JS_KEYWORD | ATTR_CSHARP_KEYWORD)  \
+  KEYWORD(from, ATTR_JS_KEYWORD | ATTR_CSHARP_KEYWORD) \
+  KEYWORD(function, ATTR_JS_KEYWORD | ATTR_CSHARP_KEYWORD) \
+  

[PATCH] D121749: [clang-format][docs] Regenerate ClangFormatStyleOptions.rst

2022-03-15 Thread sstwcw via Phabricator via cfe-commits
sstwcw added a comment.

Yes.  I probably forgot to generate the doc.  Thank you.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121749

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


[PATCH] D119300: Use-after-dtor detection for trivial base classes.

2022-03-15 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka accepted this revision.
vitalybuka added a comment.
Herald added a project: All.

@eugenis I will prepare google3 and land it?




Comment at: clang/lib/CodeGen/CGClass.cpp:1872
 
   // Ignore trivial destructors.
+  if (BaseClassDecl->hasTrivialDestructor()) {

kda wrote:
> Maybe not "Ignore"?
@kda I assume it's about inconsistent comment about?




Comment at: compiler-rt/test/msan/dtor-base-access.cpp:36
 
+Derived *g;
+

kda wrote:
> maybe in good faith '= nullptr'?
according standard declarations like this are always zero initialized already



Comment at: compiler-rt/test/msan/dtor-base-access.cpp:63
+
+  g->~Derived();
+  // not ok to access everything

kda wrote:
> Is calling destructor preferred to 'delete g'?  Seems like 'delete' would be 
> obvious inversion of 'new' on line 56.
after delete we can't do asserts below, which are the goal


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119300

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


[PATCH] D120272: [CUDA] Add driver support for compiling CUDA with the new driver

2022-03-15 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 updated this revision to Diff 415622.
jhuber6 added a comment.

Fix wrong condition for picking up input.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120272

Files:
  clang/include/clang/Basic/Cuda.h
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/cuda-openmp-driver.cu

Index: clang/test/Driver/cuda-openmp-driver.cu
===
--- /dev/null
+++ clang/test/Driver/cuda-openmp-driver.cu
@@ -0,0 +1,16 @@
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// REQUIRES: nvptx-registered-target
+
+// RUN: %clang -### -target x86_64-linux-gnu -nocudalib -ccc-print-bindings -fgpu-rdc \
+// RUN:-foffload-new-driver --offload-arch=sm_35 --offload-arch=sm_70 %s 2>&1 \
+// RUN: | FileCheck -check-prefix CHECK %s
+
+// CHECK: "nvptx64-nvidia-cuda" - "clang", inputs: ["[[INPUT:.+]]"], output: "[[PTX_SM_35:.+]]"
+// CHECK: "nvptx64-nvidia-cuda" - "NVPTX::Assembler", inputs: ["[[PTX_SM_35]]"], output: "[[CUBIN_SM_35:.+]]"
+// CHECK: "nvptx64-nvidia-cuda" - "NVPTX::Linker", inputs: ["[[CUBIN_SM_35]]", "[[PTX_SM_35]]"], output: "[[FATBIN_SM_35:.+]]"
+// CHECK: "nvptx64-nvidia-cuda" - "clang", inputs: ["[[INPUT]]"], output: "[[PTX_SM_70:.+]]"
+// CHECK: "nvptx64-nvidia-cuda" - "NVPTX::Assembler", inputs: ["[[PTX_SM_70:.+]]"], output: "[[CUBIN_SM_70:.+]]"
+// CHECK: "nvptx64-nvidia-cuda" - "NVPTX::Linker", inputs: ["[[CUBIN_SM_70]]", "[[PTX_SM_70:.+]]"], output: "[[FATBIN_SM_70:.+]]"
+// CHECK: "x86_64-unknown-linux-gnu" - "clang", inputs: ["[[INPUT]]", "[[FATBIN_SM_35]]", "[[FATBIN_SM_70]]"], output: "[[HOST_OBJ:.+]]"
+// CHECK: "x86_64-unknown-linux-gnu" - "Offload::Linker", inputs: ["[[HOST_OBJ]]"], output: "a.out"
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -4391,6 +4391,7 @@
   // one input.
   bool IsCuda = JA.isOffloading(Action::OFK_Cuda);
   bool IsCudaDevice = JA.isDeviceOffloading(Action::OFK_Cuda);
+  bool IsCudaHost = JA.isHostOffloading(Action::OFK_Cuda);
   bool IsHIP = JA.isOffloading(Action::OFK_HIP);
   bool IsHIPDevice = JA.isDeviceOffloading(Action::OFK_HIP);
   bool IsOpenMPDevice = JA.isDeviceOffloading(Action::OFK_OpenMP);
@@ -4414,6 +4415,7 @@
 
   InputInfoList ModuleHeaderInputs;
   InputInfoList OpenMPHostInputs;
+  InputInfoList CudaHostInputs;
   const InputInfo *CudaDeviceInput = nullptr;
   const InputInfo *OpenMPDeviceInput = nullptr;
   for (const InputInfo  : Inputs) {
@@ -4428,6 +4430,9 @@
 << types::getTypeName(Expected);
   }
   ModuleHeaderInputs.push_back(I);
+} else if (IsCudaHost && Args.hasArg(options::OPT_fopenmp_new_driver)) {
+  CudaDeviceInput = 
+  CudaHostInputs.push_back(I);
 } else if ((IsCuda || IsHIP) && !CudaDeviceInput) {
   CudaDeviceInput = 
 } else if (IsOpenMPDevice && !OpenMPDeviceInput) {
@@ -6982,6 +6987,20 @@
   TC->getTripleString() + "." +
   TCArgs.getLastArgValue(options::OPT_march_EQ) + "." + InputName));
 }
+  } else if (IsCudaHost && !CudaHostInputs.empty()) {
+const ToolChain *TC = C.getSingleOffloadToolChain();
+for (const auto  : CudaHostInputs) {
+  assert(InputFile.isFilename() && "Offloading requires a filename");
+  StringRef File =
+  C.getArgs().MakeArgString(TC->getInputFilename(InputFile));
+  StringRef InputName = Clang::getBaseInputStem(Args, Inputs);
+  // The CUDA toolchain should have a bound arch appended to the filename.
+  StringRef Arch = File.rsplit(".").first.rsplit('-').second;
+  CmdArgs.push_back(Args.MakeArgString(
+  "-fembed-offload-object=" + File + "," +
+  Action::GetOffloadKindName(Action::OFK_Cuda) + "." +
+  TC->getTripleString() + "." + Arch + "." + InputName));
+}
   }
 
   if (Triple.isAMDGPU()) {
@@ -8234,14 +8253,17 @@
   ArgStringList CmdArgs;
 
   // Pass the CUDA path to the linker wrapper tool.
-  for (auto  : llvm::make_range(OpenMPTCRange.first, OpenMPTCRange.second)) {
-const ToolChain *TC = I.second;
-if (TC->getTriple().isNVPTX()) {
-  CudaInstallationDetector CudaInstallation(D, TheTriple, Args);
-  if (CudaInstallation.isValid())
-CmdArgs.push_back(Args.MakeArgString(
-"--cuda-path=" + CudaInstallation.getInstallPath()));
-  break;
+  for (Action::OffloadKind Kind : {Action::OFK_Cuda, Action::OFK_OpenMP}) {
+auto TCRange = C.getOffloadToolChains(Kind);
+for (auto  : llvm::make_range(TCRange.first, TCRange.second)) {
+  const ToolChain *TC = I.second;
+  if (TC->getTriple().isNVPTX()) {
+CudaInstallationDetector CudaInstallation(D, TheTriple, Args);
+if (CudaInstallation.isValid())
+  

[PATCH] D121233: [pseudo] Move pseudoparser from clang to clang-tools-extra

2022-03-15 Thread Sam McCall via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb97856c4cfe7: [pseudo] Move pseudoparser from clang to 
clang-tools-extra (authored by sammccall).

Changed prior to commit:
  https://reviews.llvm.org/D121233?vs=415619=415621#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121233

Files:
  clang-tools-extra/CMakeLists.txt
  clang-tools-extra/pseudo/CMakeLists.txt
  clang-tools-extra/pseudo/README.md
  clang-tools-extra/pseudo/include/clang-pseudo/DirectiveMap.h
  clang-tools-extra/pseudo/include/clang-pseudo/Grammar.h
  clang-tools-extra/pseudo/include/clang-pseudo/LRGraph.h
  clang-tools-extra/pseudo/include/clang-pseudo/LRTable.h
  clang-tools-extra/pseudo/include/clang-pseudo/Token.h
  clang-tools-extra/pseudo/lib/CMakeLists.txt
  clang-tools-extra/pseudo/lib/DirectiveMap.cpp
  clang-tools-extra/pseudo/lib/Grammar.cpp
  clang-tools-extra/pseudo/lib/GrammarBNF.cpp
  clang-tools-extra/pseudo/lib/LRGraph.cpp
  clang-tools-extra/pseudo/lib/LRTable.cpp
  clang-tools-extra/pseudo/lib/LRTableBuild.cpp
  clang-tools-extra/pseudo/lib/Lex.cpp
  clang-tools-extra/pseudo/lib/Token.cpp
  clang-tools-extra/pseudo/lib/cxx.bnf
  clang-tools-extra/pseudo/test/CMakeLists.txt
  clang-tools-extra/pseudo/test/Unit/lit.cfg.py
  clang-tools-extra/pseudo/test/Unit/lit.site.cfg.py.in
  clang-tools-extra/pseudo/test/check-cxx-bnf.test
  clang-tools-extra/pseudo/test/lex.c
  clang-tools-extra/pseudo/test/lit.cfg.py
  clang-tools-extra/pseudo/test/lit.local.cfg
  clang-tools-extra/pseudo/test/lit.site.cfg.py.in
  clang-tools-extra/pseudo/test/lr-build-basic.test
  clang-tools-extra/pseudo/test/lr-build-conflicts.test
  clang-tools-extra/pseudo/tool/CMakeLists.txt
  clang-tools-extra/pseudo/tool/ClangPseudo.cpp
  clang-tools-extra/pseudo/unittests/CMakeLists.txt
  clang-tools-extra/pseudo/unittests/DirectiveMapTest.cpp
  clang-tools-extra/pseudo/unittests/GrammarTest.cpp
  clang-tools-extra/pseudo/unittests/LRTableTest.cpp
  clang-tools-extra/pseudo/unittests/TokenTest.cpp
  clang/include/clang/Tooling/Syntax/Pseudo/DirectiveMap.h
  clang/include/clang/Tooling/Syntax/Pseudo/Grammar.h
  clang/include/clang/Tooling/Syntax/Pseudo/LRGraph.h
  clang/include/clang/Tooling/Syntax/Pseudo/LRTable.h
  clang/include/clang/Tooling/Syntax/Pseudo/Token.h
  clang/lib/Tooling/Syntax/CMakeLists.txt
  clang/lib/Tooling/Syntax/Pseudo/CMakeLists.txt
  clang/lib/Tooling/Syntax/Pseudo/DirectiveMap.cpp
  clang/lib/Tooling/Syntax/Pseudo/Grammar.cpp
  clang/lib/Tooling/Syntax/Pseudo/GrammarBNF.cpp
  clang/lib/Tooling/Syntax/Pseudo/LRGraph.cpp
  clang/lib/Tooling/Syntax/Pseudo/LRTable.cpp
  clang/lib/Tooling/Syntax/Pseudo/LRTableBuild.cpp
  clang/lib/Tooling/Syntax/Pseudo/Lex.cpp
  clang/lib/Tooling/Syntax/Pseudo/README.md
  clang/lib/Tooling/Syntax/Pseudo/Token.cpp
  clang/lib/Tooling/Syntax/Pseudo/cxx.bnf
  clang/test/Syntax/check-cxx-bnf.test
  clang/test/Syntax/lex.c
  clang/test/Syntax/lit.local.cfg
  clang/test/Syntax/lr-build-basic.test
  clang/test/Syntax/lr-build-conflicts.test
  clang/tools/CMakeLists.txt
  clang/tools/clang-pseudo/CMakeLists.txt
  clang/tools/clang-pseudo/ClangPseudo.cpp
  clang/unittests/Tooling/Syntax/CMakeLists.txt
  clang/unittests/Tooling/Syntax/Pseudo/CMakeLists.txt
  clang/unittests/Tooling/Syntax/Pseudo/DirectiveMapTest.cpp
  clang/unittests/Tooling/Syntax/Pseudo/GrammarTest.cpp
  clang/unittests/Tooling/Syntax/Pseudo/LRTableTest.cpp
  clang/unittests/Tooling/Syntax/Pseudo/TokenTest.cpp

Index: clang/unittests/Tooling/Syntax/CMakeLists.txt
===
--- clang/unittests/Tooling/Syntax/CMakeLists.txt
+++ clang/unittests/Tooling/Syntax/CMakeLists.txt
@@ -28,5 +28,3 @@
   PRIVATE
   LLVMTestingSupport
 )
-
-add_subdirectory(Pseudo)
Index: clang/tools/CMakeLists.txt
===
--- clang/tools/CMakeLists.txt
+++ clang/tools/CMakeLists.txt
@@ -14,7 +14,6 @@
 add_clang_subdirectory(clang-offload-wrapper)
 add_clang_subdirectory(clang-scan-deps)
 add_clang_subdirectory(clang-repl)
-add_clang_subdirectory(clang-pseudo)
 
 add_clang_subdirectory(c-index-test)
 
Index: clang/test/Syntax/lit.local.cfg
===
--- clang/test/Syntax/lit.local.cfg
+++ /dev/null
@@ -1,4 +0,0 @@
-cxx_bnf_file = os.path.join(config.clang_src_dir, 'lib', 'Tooling', 'Syntax',
-'Pseudo', 'cxx.bnf')
-config.substitutions.append(('%cxx-bnf-file',
- '%s' % (cxx_bnf_file)))
Index: clang/lib/Tooling/Syntax/CMakeLists.txt
===
--- clang/lib/Tooling/Syntax/CMakeLists.txt
+++ clang/lib/Tooling/Syntax/CMakeLists.txt
@@ -19,5 +19,3 @@
   DEPENDS
   omp_gen
   )
-
-add_subdirectory(Pseudo)
Index: 

[clang-tools-extra] b97856c - [pseudo] Move pseudoparser from clang to clang-tools-extra

2022-03-15 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2022-03-16T00:14:11+01:00
New Revision: b97856c4cfe7efb13887d5691002a7aa38440924

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

LOG: [pseudo] Move pseudoparser from clang to clang-tools-extra

This should make clearer that:
 - it's not part of clang proper
 - there's no expectation to update it along with clang (beyond green tests)
 - clang should not depend on it

This is intended to be expose a library, so unlike other tools has a split
between include/ and lib/.

The main renames are:
  clang/lib/Tooling/Syntax/Pseudo/*   => clang-tools-extra/pseudo/lib/*
  clang/include/clang/Tooling/Syntax/Pseudo/* => 
clang-tools-extra/pseudo/include/clang-pseudo/*
  clang/tools/clang/pseudo/*  => clang-tools-extra/pseudo/tool/*
  clang/test/Syntax/* => clang-tools-extra/pseudo/test/*
  clang/unittests/Tooling/Syntax/Pseudo/* => 
clang-tools-extra/pseudo/unittests/*
  #include "clang/Tooling/Syntax/Pseudo/*"=> #include "clang-pseudo/*"
  namespace clang::syntax::pseudo => namespace clang::pseudo
  check-clang => check-clang-pseudo
  clangToolingSyntaxPseudo=> clangPseudo
The clang-pseudo and ClangPseudoTests binaries are not renamed.

See discussion around:
https://discourse.llvm.org/t/rfc-a-c-pseudo-parser-for-tooling/59217/50

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

Added: 
clang-tools-extra/pseudo/CMakeLists.txt
clang-tools-extra/pseudo/README.md
clang-tools-extra/pseudo/include/clang-pseudo/DirectiveMap.h
clang-tools-extra/pseudo/include/clang-pseudo/Grammar.h
clang-tools-extra/pseudo/include/clang-pseudo/LRGraph.h
clang-tools-extra/pseudo/include/clang-pseudo/LRTable.h
clang-tools-extra/pseudo/include/clang-pseudo/Token.h
clang-tools-extra/pseudo/lib/CMakeLists.txt
clang-tools-extra/pseudo/lib/DirectiveMap.cpp
clang-tools-extra/pseudo/lib/Grammar.cpp
clang-tools-extra/pseudo/lib/GrammarBNF.cpp
clang-tools-extra/pseudo/lib/LRGraph.cpp
clang-tools-extra/pseudo/lib/LRTable.cpp
clang-tools-extra/pseudo/lib/LRTableBuild.cpp
clang-tools-extra/pseudo/lib/Lex.cpp
clang-tools-extra/pseudo/lib/Token.cpp
clang-tools-extra/pseudo/lib/cxx.bnf
clang-tools-extra/pseudo/test/CMakeLists.txt
clang-tools-extra/pseudo/test/Unit/lit.cfg.py
clang-tools-extra/pseudo/test/Unit/lit.site.cfg.py.in
clang-tools-extra/pseudo/test/check-cxx-bnf.test
clang-tools-extra/pseudo/test/lex.c
clang-tools-extra/pseudo/test/lit.cfg.py
clang-tools-extra/pseudo/test/lit.local.cfg
clang-tools-extra/pseudo/test/lit.site.cfg.py.in
clang-tools-extra/pseudo/test/lr-build-basic.test
clang-tools-extra/pseudo/test/lr-build-conflicts.test
clang-tools-extra/pseudo/tool/CMakeLists.txt
clang-tools-extra/pseudo/tool/ClangPseudo.cpp
clang-tools-extra/pseudo/unittests/CMakeLists.txt
clang-tools-extra/pseudo/unittests/DirectiveMapTest.cpp
clang-tools-extra/pseudo/unittests/GrammarTest.cpp
clang-tools-extra/pseudo/unittests/LRTableTest.cpp
clang-tools-extra/pseudo/unittests/TokenTest.cpp

Modified: 
clang-tools-extra/CMakeLists.txt
clang/lib/Tooling/Syntax/CMakeLists.txt
clang/tools/CMakeLists.txt
clang/unittests/Tooling/Syntax/CMakeLists.txt

Removed: 
clang/include/clang/Tooling/Syntax/Pseudo/DirectiveMap.h
clang/include/clang/Tooling/Syntax/Pseudo/Grammar.h
clang/include/clang/Tooling/Syntax/Pseudo/LRGraph.h
clang/include/clang/Tooling/Syntax/Pseudo/LRTable.h
clang/include/clang/Tooling/Syntax/Pseudo/Token.h
clang/lib/Tooling/Syntax/Pseudo/CMakeLists.txt
clang/lib/Tooling/Syntax/Pseudo/DirectiveMap.cpp
clang/lib/Tooling/Syntax/Pseudo/Grammar.cpp
clang/lib/Tooling/Syntax/Pseudo/GrammarBNF.cpp
clang/lib/Tooling/Syntax/Pseudo/LRGraph.cpp
clang/lib/Tooling/Syntax/Pseudo/LRTable.cpp
clang/lib/Tooling/Syntax/Pseudo/LRTableBuild.cpp
clang/lib/Tooling/Syntax/Pseudo/Lex.cpp
clang/lib/Tooling/Syntax/Pseudo/README.md
clang/lib/Tooling/Syntax/Pseudo/Token.cpp
clang/lib/Tooling/Syntax/Pseudo/cxx.bnf
clang/test/Syntax/check-cxx-bnf.test
clang/test/Syntax/lex.c
clang/test/Syntax/lit.local.cfg
clang/test/Syntax/lr-build-basic.test
clang/test/Syntax/lr-build-conflicts.test
clang/tools/clang-pseudo/CMakeLists.txt
clang/tools/clang-pseudo/ClangPseudo.cpp
clang/unittests/Tooling/Syntax/Pseudo/CMakeLists.txt
clang/unittests/Tooling/Syntax/Pseudo/DirectiveMapTest.cpp
clang/unittests/Tooling/Syntax/Pseudo/GrammarTest.cpp
clang/unittests/Tooling/Syntax/Pseudo/LRTableTest.cpp
clang/unittests/Tooling/Syntax/Pseudo/TokenTest.cpp



diff  --git 

[PATCH] D121425: [VFS] Add a new getVFSFromYAMLs API

2022-03-15 Thread Ben Barham via Phabricator via cfe-commits
bnbarham added a comment.

There's two failing tests with this change:

- VFSFromYAMLTest.ReturnsExternalPathVFSHit
- VFSFromYAMLTest.ReturnsInternalPathVFSHit

Apparently we allow relative paths in external-contents *without* specifying 
`overlay-relative: true`. In this case the relative paths are resolved based on 
the CWD at the time of the operation. Do we really want that? I believe this 
wouldn't have worked prior to https://reviews.llvm.org/D109128 as there was no 
canonicalising before then as well. @keith was that change intentional? If we 
want it then it will *require* setting CWD on each FS in OverlayFS, which I was 
really hoping to avoid.

To give the concrete case:

  OverlayFileSystem
RedirectingFileSystem
  /a/foo -> bar
RealFileSystem
  /a/bar
  /b/bar
  
  cd /a
  cat foo # /a/bar
  
  cd /b # would fail previously since it doesn't exist in RedirectingFS but 
would still setCWD for RealFS
  cat foo # and thus return /a/bar since RedirectingFS is still in /a

This now fails completely because OverlayFS doesn't setCWD on the underlying 
filesystems. So RedirectingFS has the CWD of whatever ExternalFS was at 
creation. In D121424  it will fail because 
there's no longer any canonicalise after mapping the path in RedirectingFS (I 
assumed this was unintentional and missed the test case).

If we want to allow this then I think we'll need to go with the previous plan 
for OverlayFS, ie. keep track of filesystems that setCWD failed on and don't 
call them at all until they succeed again. That then doesn't allow certain 
cases that the current method allows.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121425

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


[PATCH] D121233: [pseudo] Move pseudoparser from clang to clang-tools-extra

2022-03-15 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 415619.
sammccall marked 4 inline comments as done.
sammccall added a comment.

Rebase and restore conventional test/Unit suite


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121233

Files:
  clang-tools-extra/CMakeLists.txt
  clang-tools-extra/pseudo/CMakeLists.txt
  clang-tools-extra/pseudo/README.md
  clang-tools-extra/pseudo/include/clang-pseudo/DirectiveMap.h
  clang-tools-extra/pseudo/include/clang-pseudo/Grammar.h
  clang-tools-extra/pseudo/include/clang-pseudo/LRGraph.h
  clang-tools-extra/pseudo/include/clang-pseudo/LRTable.h
  clang-tools-extra/pseudo/include/clang-pseudo/Token.h
  clang-tools-extra/pseudo/lib/CMakeLists.txt
  clang-tools-extra/pseudo/lib/DirectiveMap.cpp
  clang-tools-extra/pseudo/lib/Grammar.cpp
  clang-tools-extra/pseudo/lib/GrammarBNF.cpp
  clang-tools-extra/pseudo/lib/LRGraph.cpp
  clang-tools-extra/pseudo/lib/LRTable.cpp
  clang-tools-extra/pseudo/lib/LRTableBuild.cpp
  clang-tools-extra/pseudo/lib/Lex.cpp
  clang-tools-extra/pseudo/lib/Token.cpp
  clang-tools-extra/pseudo/lib/cxx.bnf
  clang-tools-extra/pseudo/test/CMakeLists.txt
  clang-tools-extra/pseudo/test/Unit/lit.cfg.py
  clang-tools-extra/pseudo/test/Unit/lit.site.cfg.py.in
  clang-tools-extra/pseudo/test/check-cxx-bnf.test
  clang-tools-extra/pseudo/test/lex.c
  clang-tools-extra/pseudo/test/lit.cfg.py
  clang-tools-extra/pseudo/test/lit.local.cfg
  clang-tools-extra/pseudo/test/lit.site.cfg.py.in
  clang-tools-extra/pseudo/test/lr-build-basic.test
  clang-tools-extra/pseudo/test/lr-build-conflicts.test
  clang-tools-extra/pseudo/tool/CMakeLists.txt
  clang-tools-extra/pseudo/tool/ClangPseudo.cpp
  clang-tools-extra/pseudo/unittests/CMakeLists.txt
  clang-tools-extra/pseudo/unittests/DirectiveMapTest.cpp
  clang-tools-extra/pseudo/unittests/GrammarTest.cpp
  clang-tools-extra/pseudo/unittests/LRTableTest.cpp
  clang-tools-extra/pseudo/unittests/TokenTest.cpp
  clang/include/clang/Tooling/Syntax/Pseudo/DirectiveMap.h
  clang/include/clang/Tooling/Syntax/Pseudo/Grammar.h
  clang/include/clang/Tooling/Syntax/Pseudo/LRGraph.h
  clang/include/clang/Tooling/Syntax/Pseudo/LRTable.h
  clang/include/clang/Tooling/Syntax/Pseudo/Token.h
  clang/lib/Tooling/Syntax/CMakeLists.txt
  clang/lib/Tooling/Syntax/Pseudo/CMakeLists.txt
  clang/lib/Tooling/Syntax/Pseudo/DirectiveMap.cpp
  clang/lib/Tooling/Syntax/Pseudo/Grammar.cpp
  clang/lib/Tooling/Syntax/Pseudo/GrammarBNF.cpp
  clang/lib/Tooling/Syntax/Pseudo/LRGraph.cpp
  clang/lib/Tooling/Syntax/Pseudo/LRTable.cpp
  clang/lib/Tooling/Syntax/Pseudo/LRTableBuild.cpp
  clang/lib/Tooling/Syntax/Pseudo/Lex.cpp
  clang/lib/Tooling/Syntax/Pseudo/README.md
  clang/lib/Tooling/Syntax/Pseudo/Token.cpp
  clang/lib/Tooling/Syntax/Pseudo/cxx.bnf
  clang/test/Syntax/check-cxx-bnf.test
  clang/test/Syntax/lex.c
  clang/test/Syntax/lit.local.cfg
  clang/test/Syntax/lr-build-basic.test
  clang/test/Syntax/lr-build-conflicts.test
  clang/tools/CMakeLists.txt
  clang/tools/clang-pseudo/CMakeLists.txt
  clang/tools/clang-pseudo/ClangPseudo.cpp
  clang/unittests/Tooling/Syntax/CMakeLists.txt
  clang/unittests/Tooling/Syntax/Pseudo/CMakeLists.txt
  clang/unittests/Tooling/Syntax/Pseudo/DirectiveMapTest.cpp
  clang/unittests/Tooling/Syntax/Pseudo/GrammarTest.cpp
  clang/unittests/Tooling/Syntax/Pseudo/LRTableTest.cpp
  clang/unittests/Tooling/Syntax/Pseudo/TokenTest.cpp

Index: clang/unittests/Tooling/Syntax/CMakeLists.txt
===
--- clang/unittests/Tooling/Syntax/CMakeLists.txt
+++ clang/unittests/Tooling/Syntax/CMakeLists.txt
@@ -28,5 +28,3 @@
   PRIVATE
   LLVMTestingSupport
 )
-
-add_subdirectory(Pseudo)
Index: clang/tools/CMakeLists.txt
===
--- clang/tools/CMakeLists.txt
+++ clang/tools/CMakeLists.txt
@@ -14,7 +14,6 @@
 add_clang_subdirectory(clang-offload-wrapper)
 add_clang_subdirectory(clang-scan-deps)
 add_clang_subdirectory(clang-repl)
-add_clang_subdirectory(clang-pseudo)
 
 add_clang_subdirectory(c-index-test)
 
Index: clang/test/Syntax/lit.local.cfg
===
--- clang/test/Syntax/lit.local.cfg
+++ /dev/null
@@ -1,4 +0,0 @@
-cxx_bnf_file = os.path.join(config.clang_src_dir, 'lib', 'Tooling', 'Syntax',
-'Pseudo', 'cxx.bnf')
-config.substitutions.append(('%cxx-bnf-file',
- '%s' % (cxx_bnf_file)))
Index: clang/lib/Tooling/Syntax/CMakeLists.txt
===
--- clang/lib/Tooling/Syntax/CMakeLists.txt
+++ clang/lib/Tooling/Syntax/CMakeLists.txt
@@ -19,5 +19,3 @@
   DEPENDS
   omp_gen
   )
-
-add_subdirectory(Pseudo)
Index: clang-tools-extra/pseudo/unittests/TokenTest.cpp
===
--- 

[PATCH] D121749: [clang-format][docs] Regenerate ClangFormatStyleOptions.rst

2022-03-15 Thread Krystian Kuzniarek via Phabricator via cfe-commits
kuzkry added a comment.

@sstwcw, I think you must have forgotten to regenerate the rst file :) I added 
you as a reviewer to this revision.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121749

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


[PATCH] D121426: [VFS] Update uses of getVFSFromYAML to use the new getVFSFromYAMLs API

2022-03-15 Thread Ben Barham via Phabricator via cfe-commits
bnbarham marked an inline comment as done.
bnbarham added a comment.

Merged into D121425  instead.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121426

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


[PATCH] D121425: [VFS] Add a new getVFSFromYAMLs API

2022-03-15 Thread Ben Barham via Phabricator via cfe-commits
bnbarham updated this revision to Diff 415615.
bnbarham edited the summary of this revision.
bnbarham added a comment.
Herald added subscribers: cfe-commits, lldb-commits, carlosgalvezp.
Herald added projects: clang, LLDB, clang-tools-extra.

Re-order to be before D121424  and merge with 
D121426 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121425

Files:
  clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/VFS/Inputs/vfsroot.yaml
  clang/test/VFS/directory.c
  clang/test/VFS/multiple-overlays.c
  clang/test/VFS/vfsroot-with-overlay.c
  lldb/source/Commands/CommandObjectReproducer.cpp
  llvm/include/llvm/Support/VirtualFileSystem.h
  llvm/lib/Support/VirtualFileSystem.cpp
  llvm/tools/dsymutil/Reproducer.cpp
  llvm/tools/dsymutil/Reproducer.h
  llvm/unittests/Support/VirtualFileSystemTest.cpp

Index: llvm/unittests/Support/VirtualFileSystemTest.cpp
===
--- llvm/unittests/Support/VirtualFileSystemTest.cpp
+++ llvm/unittests/Support/VirtualFileSystemTest.cpp
@@ -14,6 +14,7 @@
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/SourceMgr.h"
+#include "llvm/Testing/Support/Error.h"
 #include "llvm/Testing/Support/SupportHelpers.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
@@ -2571,7 +2572,7 @@
 }
 
 TEST_F(VFSFromYAMLTest, WorkingDirectory) {
-  IntrusiveRefCntPtr Lower(new DummyFileSystem());
+  IntrusiveRefCntPtr Lower(new ErrorDummyFileSystem());
   Lower->addDirectory("//root/");
   Lower->addDirectory("//root/foo");
   Lower->addRegularFile("//root/foo/a");
@@ -2593,6 +2594,7 @@
   "}",
   Lower);
   ASSERT_NE(FS.get(), nullptr);
+
   std::error_code EC = FS->setCurrentWorkingDirectory("//root/bar");
   ASSERT_FALSE(EC);
 
@@ -2621,6 +2623,14 @@
   ASSERT_TRUE(WorkingDir);
   EXPECT_EQ(*WorkingDir, "//root/");
 
+  Status = FS->status("bar/a");
+  ASSERT_FALSE(Status.getError());
+  EXPECT_TRUE(Status->exists());
+
+  Status = FS->status("foo/a");
+  ASSERT_FALSE(Status.getError());
+  EXPECT_TRUE(Status->exists());
+
   EC = FS->setCurrentWorkingDirectory("bar");
   ASSERT_FALSE(EC);
   WorkingDir = FS->getCurrentWorkingDirectory();
@@ -2710,43 +2720,6 @@
   EXPECT_TRUE(Status->exists());
 }
 
-TEST_F(VFSFromYAMLTest, WorkingDirectoryFallthroughInvalid) {
-  IntrusiveRefCntPtr Lower(new ErrorDummyFileSystem());
-  Lower->addDirectory("//root/");
-  Lower->addDirectory("//root/foo");
-  Lower->addRegularFile("//root/foo/a");
-  Lower->addRegularFile("//root/foo/b");
-  Lower->addRegularFile("//root/c");
-  IntrusiveRefCntPtr FS = getFromYAMLString(
-  "{ 'use-external-names': false,\n"
-  "  'roots': [\n"
-  "{\n"
-  "  'type': 'directory',\n"
-  "  'name': '//root/bar',\n"
-  "  'contents': [ {\n"
-  "  'type': 'file',\n"
-  "  'name': 'a',\n"
-  "  'external-contents': '//root/foo/a'\n"
-  "}\n"
-  "  ]\n"
-  "}\n"
-  "]\n"
-  "}",
-  Lower);
-  ASSERT_NE(FS.get(), nullptr);
-  std::error_code EC = FS->setCurrentWorkingDirectory("//root/");
-  ASSERT_FALSE(EC);
-  ASSERT_NE(FS.get(), nullptr);
-
-  llvm::ErrorOr Status = FS->status("bar/a");
-  ASSERT_FALSE(Status.getError());
-  EXPECT_TRUE(Status->exists());
-
-  Status = FS->status("foo/a");
-  ASSERT_FALSE(Status.getError());
-  EXPECT_TRUE(Status->exists());
-}
-
 TEST_F(VFSFromYAMLTest, VirtualWorkingDirectory) {
   IntrusiveRefCntPtr Lower(new ErrorDummyFileSystem());
   Lower->addDirectory("//root/");
@@ -3207,3 +3180,168 @@
 "  DummyFileSystem (RecursiveContents)\n",
 Output);
 }
+
+static std::unique_ptr
+getVFSOrNull(ArrayRef YAMLOverlays,
+ IntrusiveRefCntPtr ExternalFS) {
+  SmallVector OverlayRefs;
+  for (const auto  : YAMLOverlays) {
+OverlayRefs.emplace_back(Overlay, "");
+  }
+
+  auto ExpectedFS = vfs::getVFSFromYAMLs(OverlayRefs, ExternalFS);
+  if (auto Err = ExpectedFS.takeError()) {
+consumeError(std::move(Err));
+return nullptr;
+  }
+  return std::move(*ExpectedFS);
+}
+
+static std::string createSimpleOverlay(StringRef RedirectKind, StringRef From,
+   StringRef To) {
+  return ("{\n"
+  "  'version': 0,\n"
+  "  'redirecting-with': '" +
+  RedirectKind +
+  "'\n"
+  "  'roots': [\n"
+  " {\n"
+  "   'type': 'directory-remap',\n"
+  "   'name': '" +
+  From +
+  "',\n"
+  "   'external-contents': '" +
+  To +
+  "',\n"
+  "   }]\n"
+  " }"
+  "  ]")
+  .str();
+}
+
+// Make sure that overlays are not transitive. Given A -> 

[PATCH] D121749: [clang-format][docs] Regenerate ClangFormatStyleOptions.rst

2022-03-15 Thread Krystian Kuzniarek via Phabricator via cfe-commits
kuzkry created this revision.
kuzkry added reviewers: sstwcw, MyDeveloperDay.
kuzkry added a project: clang-format.
Herald added a project: All.
kuzkry requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Misalignment of clang/docs/ClangFormatStyleOptions.rst and
clang/include/clang/Format/Format.h was introduced in c24b3db45 
.

Regenerated with:
python clang/docs/tools/dump_format_style.py


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D121749

Files:
  clang/docs/ClangFormatStyleOptions.rst

Index: clang/docs/ClangFormatStyleOptions.rst
===
--- clang/docs/ClangFormatStyleOptions.rst
+++ clang/docs/ClangFormatStyleOptions.rst
@@ -358,8 +358,8 @@
   /* A comment. */
   double e = 4;
 
-  * ``bool AlignCompound`` Only for ``AlignConsecutiveAssignments``.  Whether compound
-assignments like ``+=`` are aligned along with ``=``.
+  * ``bool AlignCompound`` Only for ``AlignConsecutiveAssignments``.  Whether compound assignments
+like ``+=`` are aligned along with ``=``.
 
 .. code-block:: c++
 
@@ -371,10 +371,9 @@
   a &= 2;
   bbb = 2;
 
-  * ``bool PadOperators`` Only for ``AlignConsecutiveAssignments``.  Whether short
-assignment operators are left-padded to the same length as long
-ones in order to put all assignment operators to the right of
-the left hand side.
+  * ``bool PadOperators`` Only for ``AlignConsecutiveAssignments``.  Whether short assignment
+operators are left-padded to the same length as long ones in order to
+put all assignment operators to the right of the left hand side.
 
 .. code-block:: c++
 
@@ -482,8 +481,8 @@
   /* A comment. */
   double e = 4;
 
-  * ``bool AlignCompound`` Only for ``AlignConsecutiveAssignments``.  Whether compound
-assignments like ``+=`` are aligned along with ``=``.
+  * ``bool AlignCompound`` Only for ``AlignConsecutiveAssignments``.  Whether compound assignments
+like ``+=`` are aligned along with ``=``.
 
 .. code-block:: c++
 
@@ -495,10 +494,9 @@
   a &= 2;
   bbb = 2;
 
-  * ``bool PadOperators`` Only for ``AlignConsecutiveAssignments``.  Whether short
-assignment operators are left-padded to the same length as long
-ones in order to put all assignment operators to the right of
-the left hand side.
+  * ``bool PadOperators`` Only for ``AlignConsecutiveAssignments``.  Whether short assignment
+operators are left-padded to the same length as long ones in order to
+put all assignment operators to the right of the left hand side.
 
 .. code-block:: c++
 
@@ -606,8 +604,8 @@
   /* A comment. */
   double e = 4;
 
-  * ``bool AlignCompound`` Only for ``AlignConsecutiveAssignments``.  Whether compound
-assignments like ``+=`` are aligned along with ``=``.
+  * ``bool AlignCompound`` Only for ``AlignConsecutiveAssignments``.  Whether compound assignments
+like ``+=`` are aligned along with ``=``.
 
 .. code-block:: c++
 
@@ -619,10 +617,9 @@
   a &= 2;
   bbb = 2;
 
-  * ``bool PadOperators`` Only for ``AlignConsecutiveAssignments``.  Whether short
-assignment operators are left-padded to the same length as long
-ones in order to put all assignment operators to the right of
-the left hand side.
+  * ``bool PadOperators`` Only for ``AlignConsecutiveAssignments``.  Whether short assignment
+operators are left-padded to the same length as long ones in order to
+put all assignment operators to the right of the left hand side.
 
 .. code-block:: c++
 
@@ -731,8 +728,8 @@
   /* A comment. */
   double e = 4;
 
-  * ``bool AlignCompound`` Only for ``AlignConsecutiveAssignments``.  Whether compound
-assignments like ``+=`` are aligned along with ``=``.
+  * ``bool AlignCompound`` Only for ``AlignConsecutiveAssignments``.  Whether compound assignments
+like ``+=`` are aligned along with ``=``.
 
 .. code-block:: c++
 
@@ -744,10 +741,9 @@
   a &= 2;
   bbb = 2;
 
-  * ``bool PadOperators`` Only for ``AlignConsecutiveAssignments``.  Whether short
-assignment operators are left-padded to the same length as long
-ones in order to put all assignment operators to the right of
-the left hand side.
+  * ``bool PadOperators`` Only for ``AlignConsecutiveAssignments``.  Whether short assignment
+operators are left-padded to the same length as long ones in order to
+put all assignment operators to the right of the left hand side.
 
 .. code-block:: c++
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D121748: [clang][Sema] Better support for ObjC++ in Sema::LookupName

2022-03-15 Thread Alex Langford via Phabricator via cfe-commits
bulbazord added a comment.

I'm not quite sure the best way to test this. Looks like `Sema::LookupName` 
isn't currently directly tested. I've run the test suite and did not find any 
new failing tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121748

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


[PATCH] D121748: [clang][Sema] Better support for ObjC++ in Sema::LookupName

2022-03-15 Thread Alex Langford via Phabricator via cfe-commits
bulbazord created this revision.
bulbazord added a reviewer: arphaman.
Herald added a project: All.
bulbazord requested review of this revision.
Herald added a project: clang.

`Sema::LookupName` essentially has two possible code paths based on what
language is currently being used. The predicate selecting the code path
is whether or not C++ is being used. In this scenario, the `Scope`
argument that is being passed needs to be not `nullptr` in order to
succeed. In the C/ObjC case, the `Scope` argument can potentially be
`nullptr` and still succeed. In the case where the `Scope` argument is
`nullptr` and you are dealing with Objective-C++ while looking up an
Objective-C name, you will fail where you otherwise should succeed.

This was surfaced when working on Swift/C++ interop. Swift passes
`nullptr` for the `Scope` when looking up some Objective-C name with the
experimental C++ interop option enabled resulting in a failure.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D121748

Files:
  clang/lib/Sema/SemaLookup.cpp


Index: clang/lib/Sema/SemaLookup.cpp
===
--- clang/lib/Sema/SemaLookup.cpp
+++ clang/lib/Sema/SemaLookup.cpp
@@ -1937,7 +1937,10 @@
 
   LookupNameKind NameKind = R.getLookupKind();
 
-  if (!getLangOpts().CPlusPlus) {
+  if (!getLangOpts().CPlusPlus || getLangOpts().ObjC) {
+// In the case of Objective-C++, try C++ unqualified name lookup first.
+if (getLangOpts().CPlusPlus && CppLookupName(R, S))
+  return true;
 // Unqualified name lookup in C/Objective-C is purely lexical, so
 // search in the declarations attached to the name.
 if (NameKind == Sema::LookupRedeclarationWithLinkage) {


Index: clang/lib/Sema/SemaLookup.cpp
===
--- clang/lib/Sema/SemaLookup.cpp
+++ clang/lib/Sema/SemaLookup.cpp
@@ -1937,7 +1937,10 @@
 
   LookupNameKind NameKind = R.getLookupKind();
 
-  if (!getLangOpts().CPlusPlus) {
+  if (!getLangOpts().CPlusPlus || getLangOpts().ObjC) {
+// In the case of Objective-C++, try C++ unqualified name lookup first.
+if (getLangOpts().CPlusPlus && CppLookupName(R, S))
+  return true;
 // Unqualified name lookup in C/Objective-C is purely lexical, so
 // search in the declarations attached to the name.
 if (NameKind == Sema::LookupRedeclarationWithLinkage) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D121746: Use lit_config.substitute instead of foo % lit_config.params everywhere

2022-03-15 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: hokein.
Herald added a reviewer: bollu.
Herald added subscribers: ayermolo, sdasgup3, wenzhicui, wrengr, Chia-hungDuan, 
dcaballe, cota, teijeong, rdzhabarov, tatianashp, msifontes, jurahul, Kayjukh, 
grosul1, Joonsoo, liufengdb, aartbik, mgester, arpith-jacob, antiagainst, 
shauheen, rriddle, mehdi_amini, delcypher.
Herald added a reviewer: sscalpone.
Herald added a reviewer: rafauler.
Herald added a reviewer: Amir.
Herald added a reviewer: maksfb.
Herald added projects: Flang, All.
sammccall requested review of this revision.
Herald added subscribers: llvm-commits, lldb-commits, Sanitizers, cfe-commits, 
yota9, stephenneuendorffer, nicolasvasilache, jdoerfert.
Herald added projects: clang, Sanitizers, LLDB, MLIR, LLVM.

This mechanically applies the same changes from D121427 
 everywhere.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D121746

Files:
  bolt/test/Unit/lit.site.cfg.py.in
  bolt/test/lit.site.cfg.py.in
  clang/test/Unit/lit.site.cfg.py.in
  clang/test/lit.site.cfg.py.in
  clang/utils/perf-training/lit.site.cfg.in
  clang/utils/perf-training/order-files.lit.site.cfg.in
  compiler-rt/test/lit.common.configured.in
  compiler-rt/unittests/lit.common.unit.configured.in
  cross-project-tests/lit.site.cfg.py.in
  flang/test/NonGtestUnit/lit.site.cfg.py.in
  flang/test/Unit/lit.site.cfg.py.in
  flang/test/lit.site.cfg.py.in
  lld/test/Unit/lit.site.cfg.py.in
  lld/test/lit.site.cfg.py.in
  lldb/test/API/lit.site.cfg.py.in
  lldb/test/Shell/lit.site.cfg.py.in
  lldb/test/Unit/lit.site.cfg.py.in
  lldb/test/lit.site.cfg.py.in
  llvm/test/Unit/lit.site.cfg.py.in
  llvm/test/lit.site.cfg.py.in
  llvm/utils/lit/tests/lit.site.cfg.in
  mlir/examples/standalone/test/lit.site.cfg.py.in
  mlir/test/Unit/lit.site.cfg.py.in
  mlir/test/lit.site.cfg.py.in
  polly/test/Unit/lit.site.cfg.in
  polly/test/lit.site.cfg.in

Index: polly/test/lit.site.cfg.in
===
--- polly/test/lit.site.cfg.in
+++ polly/test/lit.site.cfg.in
@@ -2,8 +2,8 @@
 
 config.llvm_src_root = "@LLVM_SOURCE_DIR@"
 config.llvm_obj_root = "@LLVM_BINARY_DIR@"
-config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
-config.llvm_libs_dir = "@LLVM_LIBS_DIR@"
+config.llvm_tools_dir = lit_config.substitute("@LLVM_TOOLS_DIR@")
+config.llvm_libs_dir = lit_config.substitute("@LLVM_LIBS_DIR@")
 config.polly_obj_root = "@POLLY_BINARY_DIR@"
 config.polly_lib_dir = "@POLLY_LIB_DIR@"
 config.target_triple = "@LLVM_TARGET_TRIPLE@"
@@ -21,16 +21,6 @@
 for arch in config.targets_to_build.split():
 config.available_features.add(arch.lower() + '-registered-target')
 
-# Support substitution of the tools and libs dirs with user parameters. This is
-# used when we can't determine the tool dir at configuration time.
-try:
-config.llvm_tools_dir = config.llvm_tools_dir % lit_config.params
-config.llvm_libs_dir = config.llvm_libs_dir % lit_config.params
-except KeyError:
-e = sys.exc_info()[1]
-key, = e.args
-lit_config.fatal("unable to find %r parameter, use '--param=%s=VALUE'" % (key,key))
-
 # excludes: A list of directories to exclude from the testsuite. The 'Inputs'
 # subdirectories contain auxiliary inputs for various tests in their parent
 # directories.
Index: polly/test/Unit/lit.site.cfg.in
===
--- polly/test/Unit/lit.site.cfg.in
+++ polly/test/Unit/lit.site.cfg.in
@@ -4,9 +4,9 @@
 
 config.llvm_src_root = "@LLVM_SOURCE_DIR@"
 config.llvm_obj_root = "@LLVM_BINARY_DIR@"
-config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
-config.llvm_libs_dir = "@LLVM_LIBS_DIR@"
-config.llvm_build_mode = "@LLVM_BUILD_MODE@"
+config.llvm_tools_dir = lit_config.substitute("@LLVM_TOOLS_DIR@")
+config.llvm_libs_dir = lit_config.substitute("@LLVM_LIBS_DIR@")
+config.llvm_build_mode = lit_config.substitute("@LLVM_BUILD_MODE@")
 config.polly_obj_root = "@POLLY_BINARY_DIR@"
 config.polly_lib_dir = "@POLLY_LIB_DIR@"
 config.enable_shared = @ENABLE_SHARED@
@@ -16,17 +16,5 @@
 config.llvm_polly_link_into_tools = "@LLVM_POLLY_LINK_INTO_TOOLS@"
 config.has_unittests = @POLLY_GTEST_AVAIL@
 
-# Support substitution of the tools_dir, libs_dirs, and build_mode with user
-# parameters. This is used when we can't determine the tool dir at
-# configuration time.
-try:
-config.llvm_tools_dir = config.llvm_tools_dir % lit_config.params
-config.llvm_libs_dir = config.llvm_libs_dir % lit_config.params
-config.llvm_build_mode = config.llvm_build_mode % lit_config.params
-except KeyError:
-e = sys.exc_info()[1]
-key, = e.args
-lit_config.fatal("unable to find %r parameter, use '--param=%s=VALUE'" % (key,key))
-
 # Let the main config do the real work.
 lit_config.load_config(config, "@POLLY_SOURCE_DIR@/test/Unit/lit.cfg")
Index: mlir/test/lit.site.cfg.py.in
===
--- 

[PATCH] D121498: let EST_Uninstantiated in FunctionProtoType::canThrow return CT_Dependent

2022-03-15 Thread zhouyizhou via Phabricator via cfe-commits
zhouyizhou updated this revision to Diff 415601.
zhouyizhou edited the summary of this revision.

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

https://reviews.llvm.org/D121498

Files:
  clang/lib/AST/Type.cpp
  clang/test/SemaTemplate/class-template-deduction.cpp


Index: clang/test/SemaTemplate/class-template-deduction.cpp
===
--- /dev/null
+++ clang/test/SemaTemplate/class-template-deduction.cpp
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 -verify %s
+// RUN: %clang_cc1 -std=c++11 -verify %s
+// RUN: %clang_cc1 -std=c++17 -verify %s
+// RUN: %clang_cc1 -std=c++1z -verify %s
+#if __cplusplus >= 201703
+// expected-no-diagnostics
+#endif
+template
+void foo() noexcept(T::value);
+struct S {
+  static const bool value;
+};
+
+const bool S::value = 0;
+
+template
+#if __cplusplus >= 201703
+constexpr bool is_noexcept_function(void(Args...) noexcept(is_noexcept)) {
+#else
+constexpr bool is_noexcept_function(void(Args...) noexcept(is_noexcept)) { // 
expected-note{{candidate template ignored}}
+#endif 
+  return is_noexcept; 
+}
+
+void fn()
+{
+#if __cplusplus >= 201703
+  is_noexcept_function(foo);
+#else
+  is_noexcept_function(foo);// expected-error{{no matching function 
for call}}
+#endif 
+
+
+}
+
+
Index: clang/lib/AST/Type.cpp
===
--- clang/lib/AST/Type.cpp
+++ clang/lib/AST/Type.cpp
@@ -3325,9 +3325,10 @@
   switch (getExceptionSpecType()) {
   case EST_Unparsed:
   case EST_Unevaluated:
-  case EST_Uninstantiated:
 llvm_unreachable("should not call this with unresolved exception specs");
 
+  case EST_Uninstantiated:
+return CT_Dependent;
   case EST_DynamicNone:
   case EST_BasicNoexcept:
   case EST_NoexceptTrue:


Index: clang/test/SemaTemplate/class-template-deduction.cpp
===
--- /dev/null
+++ clang/test/SemaTemplate/class-template-deduction.cpp
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 -verify %s
+// RUN: %clang_cc1 -std=c++11 -verify %s
+// RUN: %clang_cc1 -std=c++17 -verify %s
+// RUN: %clang_cc1 -std=c++1z -verify %s
+#if __cplusplus >= 201703
+// expected-no-diagnostics
+#endif
+template
+void foo() noexcept(T::value);
+struct S {
+  static const bool value;
+};
+
+const bool S::value = 0;
+
+template
+#if __cplusplus >= 201703
+constexpr bool is_noexcept_function(void(Args...) noexcept(is_noexcept)) {
+#else
+constexpr bool is_noexcept_function(void(Args...) noexcept(is_noexcept)) { // expected-note{{candidate template ignored}}
+#endif	
+  return is_noexcept; 
+}
+
+void fn()
+{
+#if __cplusplus >= 201703
+  is_noexcept_function(foo);
+#else
+  is_noexcept_function(foo);	// expected-error{{no matching function for call}}
+#endif	
+
+
+}
+
+
Index: clang/lib/AST/Type.cpp
===
--- clang/lib/AST/Type.cpp
+++ clang/lib/AST/Type.cpp
@@ -3325,9 +3325,10 @@
   switch (getExceptionSpecType()) {
   case EST_Unparsed:
   case EST_Unevaluated:
-  case EST_Uninstantiated:
 llvm_unreachable("should not call this with unresolved exception specs");
 
+  case EST_Uninstantiated:
+return CT_Dependent;
   case EST_DynamicNone:
   case EST_BasicNoexcept:
   case EST_NoexceptTrue:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D121712: [clangd] Track time spent in filesystem ops during preamble builds

2022-03-15 Thread Trass3r via Phabricator via cfe-commits
Trass3r added a comment.

Hmm just a few curious questions from the sidelines.
Why a "custom system" instead of something -ftime-trace based?
How much overhead does this introduce, esp. for normal use-cases?
What's the gain? The information is very coarse and general-purpose system 
profiling tools should give you much better information regarding file system 
perf.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121712

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


[PATCH] D121497: Lex: add support for `{,u}i128` Microsoft extension

2022-03-15 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd added a comment.

This was something that I was hitting an issue with.  In particular, it was a 
module build for a module which pulled in intsafe.h.  Now, given that it is a 
preprocessor macro, it would stand to reason that it will normally be dropped 
and thus won't matter if the frontend doesn't actually support a 128-bit type.  
However, with a module, we would attempt to process the expression.  I do admit 
it is on a slightly more tenuous ground as Microsoft may somehow do something 
different.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121497

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


[PATCH] D116635: Add warning to detect when calls passing arguments are made to functions without prototypes.

2022-03-15 Thread Dan Liew via Phabricator via cfe-commits
delcypher abandoned this revision.
delcypher added inline comments.
Herald added a project: All.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:5529
+def warn_call_function_without_prototype : Warning<
+  "calling function %0 with arguments when function has no prototype">, 
InGroup<
+  DiagGroup<"strict-calls-without-prototype">>, DefaultIgnore;

aaron.ballman wrote:
> delcypher wrote:
> > aaron.ballman wrote:
> > > delcypher wrote:
> > > > aaron.ballman wrote:
> > > > > delcypher wrote:
> > > > > > aaron.ballman wrote:
> > > > > > > This diagnostic doesn't tell me what's wrong with the code (and 
> > > > > > > in fact, there's very possibly nothing wrong with the code 
> > > > > > > whatsoever). Further, why does calling a function *with no 
> > > > > > > arguments* matter when it has no prototype? I would imagine this 
> > > > > > > should flag any call to a function without a prototype given that 
> > > > > > > the function without a prototype may still expect arguments. e.g.,
> > > > > > > ```
> > > > > > > // Header.h
> > > > > > > int f();
> > > > > > > 
> > > > > > > // Source.c
> > > > > > > int f(a) int a; { ... }
> > > > > > > 
> > > > > > > // Caller.c
> > > > > > > #include "Header.h"
> > > > > > > 
> > > > > > > int main() {
> > > > > > >   return f();
> > > > > > > }
> > > > > > > ```
> > > > > > > I think the diagnostic text should be updated to something more 
> > > > > > > like `cannot verify %0 is being called with the correct number or 
> > > > > > > %plural{1:type|:types}1 of arguments because it was declared 
> > > > > > > without a prototype` (or something along those lines that 
> > > > > > > explains what's wrong with the code).
> > > > > > @aaron.ballman  Thanks for the helpful feedback.
> > > > > > 
> > > > > > > This diagnostic doesn't tell me what's wrong with the code (and 
> > > > > > > in fact, there's very possibly nothing wrong with the code 
> > > > > > > whatsoever).
> > > > > > 
> > > > > > That's a fair criticism.  I think the diagnostic message you 
> > > > > > suggest is a lot more helpful so I'll go for something like that.
> > > > > > 
> > > > > > > Further, why does calling a function *with no arguments* matter 
> > > > > > > when it has no prototype?
> > > > > > 
> > > > > > The reason was to avoid the warning being noisy. E.g. I didn't the 
> > > > > > warning to fire in this situation.
> > > > > > 
> > > > > > ```
> > > > > > // Header.h
> > > > > > int f(); // The user forgot to put `void` between parentheses
> > > > > > 
> > > > > > // Source.c
> > > > > > int f(void) { ... }
> > > > > > 
> > > > > > // Caller.c
> > > > > > #include "Header.h"
> > > > > > 
> > > > > > int main() {
> > > > > >   return f();
> > > > > > }
> > > > > > ```
> > > > > > 
> > > > > > Forgetting to put `void` in the declaration of `f()` is a pretty 
> > > > > > common thing to do because a lot of people read `int f()` as 
> > > > > > declaring a function that takes no arguments (it does in C++ but 
> > > > > > not in C).
> > > > > > 
> > > > > > I don't want the warning to be noisy because I was planning on 
> > > > > > switching it on by default in open source and in a downstream 
> > > > > > use-case make it an error.
> > > > > > 
> > > > > > How about this as a compromise? Split the warning into two separate 
> > > > > > warnings
> > > > > > 
> > > > > > * `strict-call-without-prototype` -  Warns on calls to functions 
> > > > > > without a prototype when no arguments are passed. Not enabled by 
> > > > > > default
> > > > > > * `call-without-prototype` -Warns on calls to functions without a 
> > > > > > prototype when arguments are passed.  Enable this by default.
> > > > > > 
> > > > > > Alternatively we could enable both by default. That would still 
> > > > > > allow me to make `call-without-prototype` an error and 
> > > > > > `strict-call-without-prototype` not be an error for my downstream 
> > > > > > use-case.
> > > > > > 
> > > > > > Thoughts?
> > > > > > Forgetting to put void in the declaration of f() is a pretty common 
> > > > > > thing to do because a lot of people read int f() as declaring a 
> > > > > > function that takes no arguments (it does in C++ but not in C).
> > > > > 
> > > > > Yup, and this is exactly why I think we *should* be warning. That is 
> > > > > a function without a prototype, so the code is very brittle and 
> > > > > dangerous at the call site. The fact that the call site *currently* 
> > > > > is correct doesn't mean it's *intentionally* correct. e.g.,
> > > > > ```
> > > > > // Header.h
> > > > > int f(); // No prototype
> > > > > 
> > > > > // Source.c
> > > > > int f(int a, int b) { return 0; } // Has a prototype, no diagnostic
> > > > > 
> > > > > // OtherSource.c
> > > > > #include "Header.h"
> > > > > 
> > > > > int main() {
> > > > >   return f(); // No diagnostic with this patch, but still have the UB.
> > > > > }
> > > > > ```
> > > > > 
> > > > > > I don't want the warning to be 

[clang-tools-extra] 2b69eb4 - [clang-tools-extra] Reuse llvm_config.use_clang() to set up test environment

2022-03-15 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2022-03-15T22:14:24+01:00
New Revision: 2b69eb4a7d1d1e6829081aa677cd52ad8eef2d5b

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

LOG: [clang-tools-extra] Reuse llvm_config.use_clang() to set up test 
environment

This replaces a bunch of duplicate logic to set up environment variables
and a few substitutions.

It does a little more than we were doing previously:
 - searching for clang and setting up substitutions for it
 - setting up some substitutions for target triples, which are
   potentially useful but not actually used

clangd has been happily using this for its tests for a while.

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

Added: 


Modified: 
clang-tools-extra/test/lit.cfg.py
clang-tools-extra/test/lit.site.cfg.py.in

Removed: 




diff  --git a/clang-tools-extra/test/lit.cfg.py 
b/clang-tools-extra/test/lit.cfg.py
index 1c16cc73c7446..f8fdfbd0a9205 100644
--- a/clang-tools-extra/test/lit.cfg.py
+++ b/clang-tools-extra/test/lit.cfg.py
@@ -1,13 +1,9 @@
 # -*- Python -*-
 
 import os
-import platform
-import re
 import shlex
-import subprocess
 
 import lit.formats
-import lit.util
 
 from lit.llvm import llvm_config
 
@@ -33,43 +29,8 @@
 # test_exec_root: The root path where tests should be run.
 config.test_exec_root = os.path.join(config.clang_tools_binary_dir, 'test')
 
-# Clear some environment variables that might affect Clang.
-#
-# This first set of vars are read by Clang, but shouldn't affect tests
-# that aren't specifically looking for these features, or are required
-# simply to run the tests at all.
-#
-# FIXME: Should we have a tool that enforces this?
-
-# safe_env_vars = ('TMPDIR', 'TEMP', 'TMP', 'USERPROFILE', 'PWD',
-#  'MACOSX_DEPLOYMENT_TARGET', 'IPHONEOS_DEPLOYMENT_TARGET',
-#  'IOS_SIMULATOR_DEPLOYMENT_TARGET',
-#  'VCINSTALLDIR', 'VC100COMNTOOLS', 'VC90COMNTOOLS',
-#  'VC80COMNTOOLS')
-possibly_dangerous_env_vars = ['COMPILER_PATH', 'RC_DEBUG_OPTIONS',
-   'CINDEXTEST_PREAMBLE_FILE', 'LIBRARY_PATH',
-   'CPATH', 'C_INCLUDE_PATH', 'CPLUS_INCLUDE_PATH',
-   'OBJC_INCLUDE_PATH', 'OBJCPLUS_INCLUDE_PATH',
-   'LIBCLANG_TIMING', 'LIBCLANG_OBJTRACKING',
-   'LIBCLANG_LOGGING', 'LIBCLANG_BGPRIO_INDEX',
-   'LIBCLANG_BGPRIO_EDIT', 'LIBCLANG_NOTHREADS',
-   'LIBCLANG_RESOURCE_USAGE',
-   'LIBCLANG_CODE_COMPLETION_LOGGING']
-# Clang/Win32 may refer to %INCLUDE%. vsvarsall.bat sets it.
-if platform.system() != 'Windows':
-possibly_dangerous_env_vars.append('INCLUDE')
-for name in possibly_dangerous_env_vars:
-  if name in config.environment:
-del config.environment[name]
-
-# Tweak the PATH to include the tools dir and the scripts dir.
-path = os.path.pathsep.join((
-config.clang_tools_dir, config.llvm_tools_dir, 
config.environment['PATH']))
-config.environment['PATH'] = path
-
-path = os.path.pathsep.join((config.clang_libs_dir, config.llvm_libs_dir,
-  config.environment.get('LD_LIBRARY_PATH','')))
-config.environment['LD_LIBRARY_PATH'] = path
+# Tools need the same environment setup as clang (we don't need clang itself).
+llvm_config.use_clang(required = False)
 
 if config.clang_tidy_staticanalyzer:
 config.available_features.add('static-analyzer')
@@ -91,9 +52,6 @@
 ('%run_clang_tidy',
  '%s %s' % (python_exec, run_clang_tidy)) )
 
-config.substitutions.append(('%llvmshlibdir', config.clang_libs_dir))
-config.substitutions.append(('%pluginext', config.llvm_plugin_ext))
-
 # Plugins (loadable modules)
 if config.has_plugins and config.llvm_plugin_ext:
 config.available_features.add('plugins')

diff  --git a/clang-tools-extra/test/lit.site.cfg.py.in 
b/clang-tools-extra/test/lit.site.cfg.py.in
index 26bd50dd3ca4d..a784e12efe819 100644
--- a/clang-tools-extra/test/lit.site.cfg.py.in
+++ b/clang-tools-extra/test/lit.site.cfg.py.in
@@ -5,9 +5,11 @@ import sys
 config.llvm_plugin_ext = "@LLVM_PLUGIN_EXT@"
 config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
 config.clang_tools_binary_dir = "@CLANG_TOOLS_BINARY_DIR@"
-config.clang_libs_dir = "@SHLIBDIR@"
+config.clang_tools_dir = "@CLANG_TOOLS_DIR@"
+config.llvm_shlib_dir = "@SHLIBDIR@"
 config.python_executable = "@Python3_EXECUTABLE@"
 config.target_triple = "@LLVM_TARGET_TRIPLE@"
+config.host_triple = "@LLVM_HOST_TRIPLE@"
 config.clang_tidy_staticanalyzer = @CLANG_TIDY_ENABLE_STATIC_ANALYZER@
 config.has_plugins = @CLANG_PLUGIN_SUPPORT@ & ~@LLVM_INSTALL_TOOLCHAIN_ONLY@
 # Support substitution of the tools and libs dirs with user 

[PATCH] D121422: [clang-tools-extra] Reuse llvm_config.use_clang() to set up test environment

2022-03-15 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2b69eb4a7d1d: [clang-tools-extra] Reuse 
llvm_config.use_clang() to set up test environment (authored by sammccall).

Changed prior to commit:
  https://reviews.llvm.org/D121422?vs=414514=415581#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121422

Files:
  clang-tools-extra/test/lit.cfg.py
  clang-tools-extra/test/lit.site.cfg.py.in


Index: clang-tools-extra/test/lit.site.cfg.py.in
===
--- clang-tools-extra/test/lit.site.cfg.py.in
+++ clang-tools-extra/test/lit.site.cfg.py.in
@@ -5,9 +5,11 @@
 config.llvm_plugin_ext = "@LLVM_PLUGIN_EXT@"
 config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
 config.clang_tools_binary_dir = "@CLANG_TOOLS_BINARY_DIR@"
-config.clang_libs_dir = "@SHLIBDIR@"
+config.clang_tools_dir = "@CLANG_TOOLS_DIR@"
+config.llvm_shlib_dir = "@SHLIBDIR@"
 config.python_executable = "@Python3_EXECUTABLE@"
 config.target_triple = "@LLVM_TARGET_TRIPLE@"
+config.host_triple = "@LLVM_HOST_TRIPLE@"
 config.clang_tidy_staticanalyzer = @CLANG_TIDY_ENABLE_STATIC_ANALYZER@
 config.has_plugins = @CLANG_PLUGIN_SUPPORT@ & ~@LLVM_INSTALL_TOOLCHAIN_ONLY@
 # Support substitution of the tools and libs dirs with user parameters. This is
Index: clang-tools-extra/test/lit.cfg.py
===
--- clang-tools-extra/test/lit.cfg.py
+++ clang-tools-extra/test/lit.cfg.py
@@ -1,13 +1,9 @@
 # -*- Python -*-
 
 import os
-import platform
-import re
 import shlex
-import subprocess
 
 import lit.formats
-import lit.util
 
 from lit.llvm import llvm_config
 
@@ -33,43 +29,8 @@
 # test_exec_root: The root path where tests should be run.
 config.test_exec_root = os.path.join(config.clang_tools_binary_dir, 'test')
 
-# Clear some environment variables that might affect Clang.
-#
-# This first set of vars are read by Clang, but shouldn't affect tests
-# that aren't specifically looking for these features, or are required
-# simply to run the tests at all.
-#
-# FIXME: Should we have a tool that enforces this?
-
-# safe_env_vars = ('TMPDIR', 'TEMP', 'TMP', 'USERPROFILE', 'PWD',
-#  'MACOSX_DEPLOYMENT_TARGET', 'IPHONEOS_DEPLOYMENT_TARGET',
-#  'IOS_SIMULATOR_DEPLOYMENT_TARGET',
-#  'VCINSTALLDIR', 'VC100COMNTOOLS', 'VC90COMNTOOLS',
-#  'VC80COMNTOOLS')
-possibly_dangerous_env_vars = ['COMPILER_PATH', 'RC_DEBUG_OPTIONS',
-   'CINDEXTEST_PREAMBLE_FILE', 'LIBRARY_PATH',
-   'CPATH', 'C_INCLUDE_PATH', 'CPLUS_INCLUDE_PATH',
-   'OBJC_INCLUDE_PATH', 'OBJCPLUS_INCLUDE_PATH',
-   'LIBCLANG_TIMING', 'LIBCLANG_OBJTRACKING',
-   'LIBCLANG_LOGGING', 'LIBCLANG_BGPRIO_INDEX',
-   'LIBCLANG_BGPRIO_EDIT', 'LIBCLANG_NOTHREADS',
-   'LIBCLANG_RESOURCE_USAGE',
-   'LIBCLANG_CODE_COMPLETION_LOGGING']
-# Clang/Win32 may refer to %INCLUDE%. vsvarsall.bat sets it.
-if platform.system() != 'Windows':
-possibly_dangerous_env_vars.append('INCLUDE')
-for name in possibly_dangerous_env_vars:
-  if name in config.environment:
-del config.environment[name]
-
-# Tweak the PATH to include the tools dir and the scripts dir.
-path = os.path.pathsep.join((
-config.clang_tools_dir, config.llvm_tools_dir, 
config.environment['PATH']))
-config.environment['PATH'] = path
-
-path = os.path.pathsep.join((config.clang_libs_dir, config.llvm_libs_dir,
-  config.environment.get('LD_LIBRARY_PATH','')))
-config.environment['LD_LIBRARY_PATH'] = path
+# Tools need the same environment setup as clang (we don't need clang itself).
+llvm_config.use_clang(required = False)
 
 if config.clang_tidy_staticanalyzer:
 config.available_features.add('static-analyzer')
@@ -91,9 +52,6 @@
 ('%run_clang_tidy',
  '%s %s' % (python_exec, run_clang_tidy)) )
 
-config.substitutions.append(('%llvmshlibdir', config.clang_libs_dir))
-config.substitutions.append(('%pluginext', config.llvm_plugin_ext))
-
 # Plugins (loadable modules)
 if config.has_plugins and config.llvm_plugin_ext:
 config.available_features.add('plugins')


Index: clang-tools-extra/test/lit.site.cfg.py.in
===
--- clang-tools-extra/test/lit.site.cfg.py.in
+++ clang-tools-extra/test/lit.site.cfg.py.in
@@ -5,9 +5,11 @@
 config.llvm_plugin_ext = "@LLVM_PLUGIN_EXT@"
 config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
 config.clang_tools_binary_dir = "@CLANG_TOOLS_BINARY_DIR@"
-config.clang_libs_dir = "@SHLIBDIR@"
+config.clang_tools_dir = "@CLANG_TOOLS_DIR@"
+config.llvm_shlib_dir = "@SHLIBDIR@"
 config.python_executable = 

[PATCH] D121098: [C++20][Modules][HU 4/5] Handle pre-processed header units.

2022-03-15 Thread Iain Sandoe via Phabricator via cfe-commits
iains added a comment.

In D121098#3378375 , @ChuanqiXu wrote:

> It lacks tests. This is not NFC, right?

Right, (there are tests with the next patch which introduces the mechanism for 
producing the pre-processed output) 
but, I will find a suitable one for this...

> ---
>
> I am a little bit confused for the intuition. Couldn't we just import the 
> pre-processed header? What's the problem? Could you elaborate on this?

We cannot import a pre-processed file; the preprocessed file is still source 
code, not a CMI.

In addition, the pre-processor output for a header unit requires further 
pre-processing on read.
This is because a header unit actually preserves some of the pre-processor 
information [macro definitions] (which would normally be discarded after phase 
4).

Header units are identifiable by a name (in common with GCC, we make the name 
== the path by which the header is specified) -- that name is intentionally not 
a  legal named module name (neither is it, in general, a legal identifier).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121098

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


[clang] 1bb13b3 - Fix sphinx build because of indentation

2022-03-15 Thread Aleksandr Platonov via cfe-commits

Author: Aleksandr Platonov
Date: 2022-03-16T00:11:56+03:00
New Revision: 1bb13b3f4956370afc01a8a9315dabed8c09a2cd

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

LOG: Fix sphinx build because of indentation

Added: 


Modified: 
clang/docs/ReleaseNotes.rst

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index ed79b647ed794..a0e3cabe89a9a 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -95,6 +95,7 @@ Attribute Changes in Clang
   This fixes `Issue 53805 
`_.
 
 - Improved namespace attributes handling:
+
   - Handle GNU attributes before a namespace identifier and subsequent
 attributes of 
diff erent kinds.
   - Emit error on GNU attributes for a nested namespace definition.



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


[PATCH] D121427: [lit] add lit_config.substitute to interpolate lit_config.params

2022-03-15 Thread Sam McCall via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGfa1019fa1843: [lit] add lit_config.substitute to interpolate 
lit_config.params (authored by sammccall).

Changed prior to commit:
  https://reviews.llvm.org/D121427?vs=414522=415576#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121427

Files:
  clang-tools-extra/clangd/test/lit.site.cfg.py.in
  clang-tools-extra/test/lit.site.cfg.py.in
  llvm/utils/lit/lit/LitConfig.py


Index: llvm/utils/lit/lit/LitConfig.py
===
--- llvm/utils/lit/lit/LitConfig.py
+++ llvm/utils/lit/lit/LitConfig.py
@@ -175,6 +175,15 @@
 # output.
 sys.stderr.flush()
 
+def substitute(self, string):
+"""substitute - Interpolate params into a string"""
+try:
+  return string % self.params
+except KeyError as e:
+  key, = e.args
+  self.fatal("unable to find %r parameter, use '--param=%s=VALUE'" % (
+  key,key))
+
 def note(self, message):
 if not self.quiet:
 self._write_message('note', message)
Index: clang-tools-extra/test/lit.site.cfg.py.in
===
--- clang-tools-extra/test/lit.site.cfg.py.in
+++ clang-tools-extra/test/lit.site.cfg.py.in
@@ -2,28 +2,19 @@
 
 import sys
 
-config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
-config.llvm_libs_dir = "@LLVM_LIBS_DIR@"
 config.llvm_plugin_ext = "@LLVM_PLUGIN_EXT@"
 config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
 config.clang_tools_binary_dir = "@CLANG_TOOLS_BINARY_DIR@"
-config.clang_tools_dir = "@CLANG_TOOLS_DIR@"
 config.clang_libs_dir = "@SHLIBDIR@"
 config.python_executable = "@Python3_EXECUTABLE@"
 config.target_triple = "@LLVM_TARGET_TRIPLE@"
 config.clang_tidy_staticanalyzer = @CLANG_TIDY_ENABLE_STATIC_ANALYZER@
 config.has_plugins = @CLANG_PLUGIN_SUPPORT@ & ~@LLVM_INSTALL_TOOLCHAIN_ONLY@
-
 # Support substitution of the tools and libs dirs with user parameters. This is
 # used when we can't determine the tool dir at configuration time.
-try:
-config.clang_tools_dir = config.clang_tools_dir % lit_config.params
-config.llvm_tools_dir = config.llvm_tools_dir % lit_config.params
-config.llvm_libs_dir = config.llvm_libs_dir % lit_config.params
-except KeyError:
-e = sys.exc_info()[1]
-key, = e.args
-lit_config.fatal("unable to find %r parameter, use '--param=%s=VALUE'" % 
(key,key))
+config.llvm_tools_dir = lit_config.substitute("@LLVM_TOOLS_DIR@")
+config.llvm_libs_dir = lit_config.substitute("@LLVM_LIBS_DIR@")
+config.clang_tools_dir = lit_config.substitute("@CLANG_TOOLS_DIR@")
 
 import lit.llvm
 lit.llvm.initialize(lit_config, config)
Index: clang-tools-extra/clangd/test/lit.site.cfg.py.in
===
--- clang-tools-extra/clangd/test/lit.site.cfg.py.in
+++ clang-tools-extra/clangd/test/lit.site.cfg.py.in
@@ -2,24 +2,15 @@
 
 # Variables needed for common clang config.
 config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
-config.clang_tools_dir = "@CLANG_TOOLS_DIR@"
-config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
 config.clang_libs_dir = "@CLANG_LIBS_DIR@"
-config.llvm_libs_dir = "@LLVM_LIBS_DIR@"
 config.target_triple = "@LLVM_TARGET_TRIPLE@"
 config.host_triple = "@LLVM_HOST_TRIPLE@"
 config.python_executable = "@Python3_EXECUTABLE@"
-
 # Support substitution of the tools and libs dirs with user parameters. This is
 # used when we can't determine the tool dir at configuration time.
-try:
-config.clang_tools_dir = config.clang_tools_dir % lit_config.params
-config.llvm_tools_dir = config.llvm_tools_dir % lit_config.params
-config.llvm_libs_dir = config.llvm_libs_dir % lit_config.params
-except KeyError:
-e = sys.exc_info()[1]
-key, = e.args
-lit_config.fatal("unable to find %r parameter, use '--param=%s=VALUE'" % 
(key,key))
+config.clang_tools_dir = lit_config.substitute("@CLANG_TOOLS_DIR@")
+config.llvm_tools_dir = lit_config.substitute("@LLVM_TOOLS_DIR@")
+config.llvm_libs_dir = lit_config.substitute("@LLVM_LIBS_DIR@")
 
 config.clangd_source_dir = "@CMAKE_CURRENT_SOURCE_DIR@/.."
 config.clangd_binary_dir = "@CMAKE_CURRENT_BINARY_DIR@/.."


Index: llvm/utils/lit/lit/LitConfig.py
===
--- llvm/utils/lit/lit/LitConfig.py
+++ llvm/utils/lit/lit/LitConfig.py
@@ -175,6 +175,15 @@
 # output.
 sys.stderr.flush()
 
+def substitute(self, string):
+"""substitute - Interpolate params into a string"""
+try:
+  return string % self.params
+except KeyError as e:
+  key, = e.args
+  self.fatal("unable to find %r parameter, use '--param=%s=VALUE'" % (
+  key,key))
+
 def note(self, message):
 

[clang-tools-extra] fa1019f - [lit] add lit_config.substitute to interpolate lit_config.params

2022-03-15 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2022-03-15T22:09:43+01:00
New Revision: fa1019fa184344a9ba57e56c8ae6c52e65b5f05c

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

LOG: [lit] add lit_config.substitute to interpolate lit_config.params

A version of this logic appears in ~every lit.site.cfg.in (28 copies total).
This patch just removes two, but I'll update the rest of llvm-project next.

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

Added: 


Modified: 
clang-tools-extra/clangd/test/lit.site.cfg.py.in
clang-tools-extra/test/lit.site.cfg.py.in
llvm/utils/lit/lit/LitConfig.py

Removed: 




diff  --git a/clang-tools-extra/clangd/test/lit.site.cfg.py.in 
b/clang-tools-extra/clangd/test/lit.site.cfg.py.in
index 2b294eaa5ae5a..9adc1c9792c1e 100644
--- a/clang-tools-extra/clangd/test/lit.site.cfg.py.in
+++ b/clang-tools-extra/clangd/test/lit.site.cfg.py.in
@@ -2,24 +2,15 @@
 
 # Variables needed for common clang config.
 config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
-config.clang_tools_dir = "@CLANG_TOOLS_DIR@"
-config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
 config.clang_libs_dir = "@CLANG_LIBS_DIR@"
-config.llvm_libs_dir = "@LLVM_LIBS_DIR@"
 config.target_triple = "@LLVM_TARGET_TRIPLE@"
 config.host_triple = "@LLVM_HOST_TRIPLE@"
 config.python_executable = "@Python3_EXECUTABLE@"
-
 # Support substitution of the tools and libs dirs with user parameters. This is
 # used when we can't determine the tool dir at configuration time.
-try:
-config.clang_tools_dir = config.clang_tools_dir % lit_config.params
-config.llvm_tools_dir = config.llvm_tools_dir % lit_config.params
-config.llvm_libs_dir = config.llvm_libs_dir % lit_config.params
-except KeyError:
-e = sys.exc_info()[1]
-key, = e.args
-lit_config.fatal("unable to find %r parameter, use '--param=%s=VALUE'" % 
(key,key))
+config.clang_tools_dir = lit_config.substitute("@CLANG_TOOLS_DIR@")
+config.llvm_tools_dir = lit_config.substitute("@LLVM_TOOLS_DIR@")
+config.llvm_libs_dir = lit_config.substitute("@LLVM_LIBS_DIR@")
 
 config.clangd_source_dir = "@CMAKE_CURRENT_SOURCE_DIR@/.."
 config.clangd_binary_dir = "@CMAKE_CURRENT_BINARY_DIR@/.."

diff  --git a/clang-tools-extra/test/lit.site.cfg.py.in 
b/clang-tools-extra/test/lit.site.cfg.py.in
index 59357f6cad06b..26bd50dd3ca4d 100644
--- a/clang-tools-extra/test/lit.site.cfg.py.in
+++ b/clang-tools-extra/test/lit.site.cfg.py.in
@@ -2,28 +2,19 @@
 
 import sys
 
-config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
-config.llvm_libs_dir = "@LLVM_LIBS_DIR@"
 config.llvm_plugin_ext = "@LLVM_PLUGIN_EXT@"
 config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
 config.clang_tools_binary_dir = "@CLANG_TOOLS_BINARY_DIR@"
-config.clang_tools_dir = "@CLANG_TOOLS_DIR@"
 config.clang_libs_dir = "@SHLIBDIR@"
 config.python_executable = "@Python3_EXECUTABLE@"
 config.target_triple = "@LLVM_TARGET_TRIPLE@"
 config.clang_tidy_staticanalyzer = @CLANG_TIDY_ENABLE_STATIC_ANALYZER@
 config.has_plugins = @CLANG_PLUGIN_SUPPORT@ & ~@LLVM_INSTALL_TOOLCHAIN_ONLY@
-
 # Support substitution of the tools and libs dirs with user parameters. This is
 # used when we can't determine the tool dir at configuration time.
-try:
-config.clang_tools_dir = config.clang_tools_dir % lit_config.params
-config.llvm_tools_dir = config.llvm_tools_dir % lit_config.params
-config.llvm_libs_dir = config.llvm_libs_dir % lit_config.params
-except KeyError:
-e = sys.exc_info()[1]
-key, = e.args
-lit_config.fatal("unable to find %r parameter, use '--param=%s=VALUE'" % 
(key,key))
+config.llvm_tools_dir = lit_config.substitute("@LLVM_TOOLS_DIR@")
+config.llvm_libs_dir = lit_config.substitute("@LLVM_LIBS_DIR@")
+config.clang_tools_dir = lit_config.substitute("@CLANG_TOOLS_DIR@")
 
 import lit.llvm
 lit.llvm.initialize(lit_config, config)

diff  --git a/llvm/utils/lit/lit/LitConfig.py b/llvm/utils/lit/lit/LitConfig.py
index 38b7a18c6a583..34d0e90149af1 100644
--- a/llvm/utils/lit/lit/LitConfig.py
+++ b/llvm/utils/lit/lit/LitConfig.py
@@ -175,6 +175,15 @@ def _write_message(self, kind, message):
 # output.
 sys.stderr.flush()
 
+def substitute(self, string):
+"""substitute - Interpolate params into a string"""
+try:
+  return string % self.params
+except KeyError as e:
+  key, = e.args
+  self.fatal("unable to find %r parameter, use '--param=%s=VALUE'" % (
+  key,key))
+
 def note(self, message):
 if not self.quiet:
 self._write_message('note', message)



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


[PATCH] D111400: [Clang] Implement P2242R3

2022-03-15 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 415574.
cor3ntin added a comment.

Formatting


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111400

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticASTKinds.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/AST/ExprConstant.cpp
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/dtor.cpp
  clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3-2b.cpp
  clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3.cpp
  clang/test/Lexer/cxx-features.cpp
  clang/test/SemaCXX/constant-expression-cxx14.cpp
  clang/test/SemaCXX/constant-expression-cxx2b.cpp
  clang/www/cxx_status.html

Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1361,7 +1361,7 @@
 
   Non-literal variables (and labels and gotos) in constexpr functions
   https://wg21.link/P2242R3;>P2242R3
-  No
+  Clang 15
 
 
   Character encoding of diagnostic text
Index: clang/test/SemaCXX/constant-expression-cxx2b.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/constant-expression-cxx2b.cpp
@@ -0,0 +1,121 @@
+// RUN: %clang_cc1 -std=c++2b -fsyntax-only -verify %s -fcxx-exceptions -triple=x86_64-linux-gnu -Wpre-c++2b-compat
+
+constexpr int f(int n) {  // expected-error {{constexpr function never produces a constant expression}}
+  static const int m = n; // expected-warning {{definition of a static variable in a constexpr function is incompatible with C++ standards before C++2b}} \
+  // expected-note {{control flows through the declaration of a static variable}}
+  return m;
+}
+constexpr int g(int n) {// expected-error {{constexpr function never produces a constant expression}}
+  thread_local const int m = n; // expected-warning {{definition of a thread_local variable in a constexpr function is incompatible with C++ standards before C++2b}} \
+// expected-note {{control flows through the declaration of a thread_local variable}}
+  return m;
+}
+
+constexpr int h(int n) {  // expected-error {{constexpr function never produces a constant expression}}
+  static const int m = n; // expected-warning {{definition of a static variable in a constexpr function is incompatible with C++ standards before C++2b}} \
+  // expected-note {{control flows through the declaration of a static variable}}
+  return  - 
+}
+constexpr int i(int n) {// expected-error {{constexpr function never produces a constant expression}}
+  thread_local const int m = n; // expected-warning {{definition of a thread_local variable in a constexpr function is incompatible with C++ standards before C++2b}} \
+// expected-note {{control flows through the declaration of a thread_local variable}}
+  return  - 
+}
+
+constexpr int j(int n) {
+  if (!n)
+return 0;
+  static const int m = n; // expected-warning{{definition of a static variable in a constexpr function is incompatible with C++ standards before C++2b}}
+  return m;
+}
+
+constexpr int k(int n) {
+  if (!n)
+return 0;
+  thread_local const int m = n; // expected-warning{{definition of a thread_local variable in a constexpr function is incompatible with C++ standards before C++2b}}
+
+  return m;
+}
+
+constexpr int j_evaluated(int n) {
+  if (!n)
+return 0;
+  static const int m = n; // expected-warning{{definition of a static variable in a constexpr function is incompatible with C++ standards before C++2b}} \
+  // expected-note {{control flows through the declaration of a static variable}}
+  return m;
+}
+
+constexpr int je = j_evaluated(1); // expected-error {{constexpr variable 'je' must be initialized by a constant expression}}  \
+   // expected-note {{in call}}
+
+constexpr int k_evaluated(int n) {
+  if (!n)
+return 0;
+  thread_local const int m = n; // expected-warning{{definition of a thread_local variable in a constexpr function is incompatible with C++ standards before C++2b}} \
+// expected-note {{control flows through the declaration of a thread_local variable}}
+
+  return m;
+}
+
+constexpr int ke = k_evaluated(1); // expected-error {{constexpr variable 'ke' must be initialized by a constant expression}} \
+   // expected-note {{in call}}
+
+constexpr int static_constexpr() { // expected-error {{constexpr function never produces a constant expression}}
+  static constexpr int m = 42; // expected-warning {{definition of a static variable in a constexpr function is incompatible with C++ standards before C++2b}} \
+  

[PATCH] D111400: [Clang] Implement P2242R3

2022-03-15 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 415573.
cor3ntin added a comment.

- Add tests in lambdas
- Do not allow static constexpr:

I can't think of a scenario in which that would
be problematic *today*, but I agree it would be 
non-conforming and should be discussed.
For example it would affect https://wg21.link/p0596.

I removed that, and added tests to check it is correctly
ill-formed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111400

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticASTKinds.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/AST/ExprConstant.cpp
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/dtor.cpp
  clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3-2b.cpp
  clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3.cpp
  clang/test/Lexer/cxx-features.cpp
  clang/test/SemaCXX/constant-expression-cxx14.cpp
  clang/test/SemaCXX/constant-expression-cxx2b.cpp
  clang/www/cxx_status.html

Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1361,7 +1361,7 @@
 
   Non-literal variables (and labels and gotos) in constexpr functions
   https://wg21.link/P2242R3;>P2242R3
-  No
+  Clang 15
 
 
   Character encoding of diagnostic text
Index: clang/test/SemaCXX/constant-expression-cxx2b.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/constant-expression-cxx2b.cpp
@@ -0,0 +1,120 @@
+// RUN: %clang_cc1 -std=c++2b -fsyntax-only -verify %s -fcxx-exceptions -triple=x86_64-linux-gnu -Wpre-c++2b-compat
+
+constexpr int f(int n) {  // expected-error {{constexpr function never produces a constant expression}}
+  static const int m = n; // expected-warning {{definition of a static variable in a constexpr function is incompatible with C++ standards before C++2b}} \
+  // expected-note {{control flows through the declaration of a static variable}}
+  return m;
+}
+constexpr int g(int n) {// expected-error {{constexpr function never produces a constant expression}}
+  thread_local const int m = n; // expected-warning {{definition of a thread_local variable in a constexpr function is incompatible with C++ standards before C++2b}} \
+// expected-note {{control flows through the declaration of a thread_local variable}}
+  return m;
+}
+
+constexpr int h(int n) {  // expected-error {{constexpr function never produces a constant expression}}
+  static const int m = n; // expected-warning {{definition of a static variable in a constexpr function is incompatible with C++ standards before C++2b}} \
+  // expected-note {{control flows through the declaration of a static variable}}
+  return  - 
+}
+constexpr int i(int n) {// expected-error {{constexpr function never produces a constant expression}}
+  thread_local const int m = n; // expected-warning {{definition of a thread_local variable in a constexpr function is incompatible with C++ standards before C++2b}} \
+// expected-note {{control flows through the declaration of a thread_local variable}}
+  return  - 
+}
+
+constexpr int j(int n) {
+  if (!n)
+return 0;
+  static const int m = n; // expected-warning{{definition of a static variable in a constexpr function is incompatible with C++ standards before C++2b}}
+  return m;
+}
+
+constexpr int k(int n) {
+  if (!n)
+return 0;
+  thread_local const int m = n; // expected-warning{{definition of a thread_local variable in a constexpr function is incompatible with C++ standards before C++2b}}
+
+  return m;
+}
+
+constexpr int j_evaluated(int n) {
+  if (!n)
+return 0;
+  static const int m = n; // expected-warning{{definition of a static variable in a constexpr function is incompatible with C++ standards before C++2b}} \
+  // expected-note {{control flows through the declaration of a static variable}}
+  return m;
+}
+
+constexpr int je = j_evaluated(1); // expected-error {{constexpr variable 'je' must be initialized by a constant expression}}  \
+   // expected-note {{in call}}
+
+constexpr int k_evaluated(int n) {
+  if (!n)
+return 0;
+  thread_local const int m = n; // expected-warning{{definition of a thread_local variable in a constexpr function is incompatible with C++ standards before C++2b}} \
+// expected-note {{control flows through the declaration of a thread_local variable}}
+
+  return m;
+}
+
+constexpr int ke = k_evaluated(1); // expected-error {{constexpr variable 'ke' must be initialized by a constant expression}} \
+   // expected-note {{in 

[PATCH] D121736: Lower `@llvm.global_dtors` using `__cxa_atexit` on MachO

2022-03-15 Thread Julian Lettner via Phabricator via cfe-commits
yln added a comment.

Hi @Orlando and @RKSimon, would you be able to confirm that this version avoids 
the previous `opt: Unknown command line argument '-lower-global-dtors'` error?

Lit invocation:
`env LIT_FILTER='dtor' ninja check-llvm`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121736

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


[PATCH] D111587: re-land: [clang] Fix absolute file paths with -fdebug-prefix-map

2022-03-15 Thread Keith Smiley via Phabricator via cfe-commits
keith abandoned this revision.
keith added a comment.

There were 2 competing revisions for this bug fix, I landed 
https://reviews.llvm.org/D121663 instead since it sounds like having an empty 
`directory` is more correct in this case


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111587

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


[PATCH] D121327: Lower `@llvm.global_dtors` using `__cxa_atexit` on MachO

2022-03-15 Thread Julian Lettner via Phabricator via cfe-commits
yln added a comment.

New revision here: D121736 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121327

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


[PATCH] D121663: reland: [clang] Don't append the working directory to absolute paths

2022-03-15 Thread Keith Smiley via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa2db7d5e9c52: reland: [clang] Dont append the working 
directory to absolute paths (authored by keith).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121663

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGen/debug-prefix-map.c


Index: clang/test/CodeGen/debug-prefix-map.c
===
--- clang/test/CodeGen/debug-prefix-map.c
+++ clang/test/CodeGen/debug-prefix-map.c
@@ -6,6 +6,9 @@
 // RUN: %clang -g 
-fdebug-prefix-map=%p=%{fs-src-root}UNLIKELY_PATH%{fs-sep}empty -S -c %s 
-emit-llvm -o - | FileCheck %s
 // RUN: %clang -g 
-ffile-prefix-map=%p=%{fs-src-root}UNLIKELY_PATH%{fs-sep}empty -S -c %s 
-emit-llvm -o - | FileCheck %s
 
+// RUN: %clang -g -fdebug-prefix-map=%p=./UNLIKELY_PATH/empty -S -c %s 
-emit-llvm -o - | FileCheck %s --check-prefix=CHECK-REL
+// RUN: %clang -g -ffile-prefix-map=%p=./UNLIKELY_PATH/empty -S -c %s 
-emit-llvm -o - | FileCheck %s --check-prefix=CHECK-REL
+
 #include "Inputs/stdio.h"
 
 int main(int argc, char **argv) {
@@ -40,3 +43,7 @@
 // CHECK-COMPILATION-DIR: !DIFile(filename: "{{.*}}Inputs{{/|}}stdio.h", 
directory: "{{/|.:}}UNLIKELY_PATH{{/|}}empty")
 // CHECK-COMPILATION-DIR-NOT: !DIFile(filename:
 // CHECK-SYSROOT: !DICompileUnit({{.*}}sysroot: 
"{{/|.:}}UNLIKELY_PATH{{/|}}empty"
+
+// CHECK-REL: !DIFile(filename: "./UNLIKELY_PATH/empty{{/|}}{{.*}}",
+// CHECK-REL: !DIFile(filename: 
"./UNLIKELY_PATH/empty{{/|}}{{.*}}Inputs/stdio.h",
+// CHECK-REL-SAME:directory: ""
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -444,7 +444,8 @@
   File = FileBuf;
 }
   } else {
-Dir = CurDir;
+if (!llvm::sys::path::is_absolute(FileName))
+  Dir = CurDir;
 File = RemappedFile;
   }
   llvm::DIFile *F = DBuilder.createFile(File, Dir, CSInfo, Source);


Index: clang/test/CodeGen/debug-prefix-map.c
===
--- clang/test/CodeGen/debug-prefix-map.c
+++ clang/test/CodeGen/debug-prefix-map.c
@@ -6,6 +6,9 @@
 // RUN: %clang -g -fdebug-prefix-map=%p=%{fs-src-root}UNLIKELY_PATH%{fs-sep}empty -S -c %s -emit-llvm -o - | FileCheck %s
 // RUN: %clang -g -ffile-prefix-map=%p=%{fs-src-root}UNLIKELY_PATH%{fs-sep}empty -S -c %s -emit-llvm -o - | FileCheck %s
 
+// RUN: %clang -g -fdebug-prefix-map=%p=./UNLIKELY_PATH/empty -S -c %s -emit-llvm -o - | FileCheck %s --check-prefix=CHECK-REL
+// RUN: %clang -g -ffile-prefix-map=%p=./UNLIKELY_PATH/empty -S -c %s -emit-llvm -o - | FileCheck %s --check-prefix=CHECK-REL
+
 #include "Inputs/stdio.h"
 
 int main(int argc, char **argv) {
@@ -40,3 +43,7 @@
 // CHECK-COMPILATION-DIR: !DIFile(filename: "{{.*}}Inputs{{/|}}stdio.h", directory: "{{/|.:}}UNLIKELY_PATH{{/|}}empty")
 // CHECK-COMPILATION-DIR-NOT: !DIFile(filename:
 // CHECK-SYSROOT: !DICompileUnit({{.*}}sysroot: "{{/|.:}}UNLIKELY_PATH{{/|}}empty"
+
+// CHECK-REL: !DIFile(filename: "./UNLIKELY_PATH/empty{{/|}}{{.*}}",
+// CHECK-REL: !DIFile(filename: "./UNLIKELY_PATH/empty{{/|}}{{.*}}Inputs/stdio.h",
+// CHECK-REL-SAME:directory: ""
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -444,7 +444,8 @@
   File = FileBuf;
 }
   } else {
-Dir = CurDir;
+if (!llvm::sys::path::is_absolute(FileName))
+  Dir = CurDir;
 File = RemappedFile;
   }
   llvm::DIFile *F = DBuilder.createFile(File, Dir, CSInfo, Source);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D121596: [clang-format] Fix crash with ObjC Blocks

2022-03-15 Thread Björn Schäpers via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1db8112311c7: [clang-format] Fix crash with ObjC Blocks 
(authored by HazardyKnusperkeks).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121596

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


Index: clang/unittests/Format/TokenAnnotatorTest.cpp
===
--- clang/unittests/Format/TokenAnnotatorTest.cpp
+++ clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -644,6 +644,22 @@
   EXPECT_TOKEN(Tokens[4], tok::r_brace, TT_InlineASMBrace);
 }
 
+TEST_F(TokenAnnotatorTest, UnderstandsObjCBlock) {
+  auto Tokens = annotate("int (^)() = ^ ()\n"
+ "  external_source_symbol() { //\n"
+ "  return 1;\n"
+ "};");
+  ASSERT_EQ(Tokens.size(), 21u) << Tokens;
+  EXPECT_TOKEN(Tokens[1], tok::l_paren, TT_ObjCBlockLParen);
+  EXPECT_TOKEN(Tokens[13], tok::l_brace, TT_ObjCBlockLBrace);
+
+  Tokens = annotate("int *p = ^int*(){ //\n"
+"  return nullptr;\n"
+"}();");
+  ASSERT_EQ(Tokens.size(), 19u) << Tokens;
+  EXPECT_TOKEN(Tokens[9], tok::l_brace, TT_ObjCBlockLBrace);
+}
+
 } // namespace
 } // namespace format
 } // namespace clang
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -783,7 +783,7 @@
 OpeningBrace.ParentBracket = Contexts.back().ContextKind;
 
 if (Contexts.back().CaretFound)
-  OpeningBrace.setType(TT_ObjCBlockLBrace);
+  OpeningBrace.overwriteFixedType(TT_ObjCBlockLBrace);
 Contexts.back().CaretFound = false;
 
 ScopedContextCreator ContextCreator(*this, tok::l_brace, 1);


Index: clang/unittests/Format/TokenAnnotatorTest.cpp
===
--- clang/unittests/Format/TokenAnnotatorTest.cpp
+++ clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -644,6 +644,22 @@
   EXPECT_TOKEN(Tokens[4], tok::r_brace, TT_InlineASMBrace);
 }
 
+TEST_F(TokenAnnotatorTest, UnderstandsObjCBlock) {
+  auto Tokens = annotate("int (^)() = ^ ()\n"
+ "  external_source_symbol() { //\n"
+ "  return 1;\n"
+ "};");
+  ASSERT_EQ(Tokens.size(), 21u) << Tokens;
+  EXPECT_TOKEN(Tokens[1], tok::l_paren, TT_ObjCBlockLParen);
+  EXPECT_TOKEN(Tokens[13], tok::l_brace, TT_ObjCBlockLBrace);
+
+  Tokens = annotate("int *p = ^int*(){ //\n"
+"  return nullptr;\n"
+"}();");
+  ASSERT_EQ(Tokens.size(), 19u) << Tokens;
+  EXPECT_TOKEN(Tokens[9], tok::l_brace, TT_ObjCBlockLBrace);
+}
+
 } // namespace
 } // namespace format
 } // namespace clang
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -783,7 +783,7 @@
 OpeningBrace.ParentBracket = Contexts.back().ContextKind;
 
 if (Contexts.back().CaretFound)
-  OpeningBrace.setType(TT_ObjCBlockLBrace);
+  OpeningBrace.overwriteFixedType(TT_ObjCBlockLBrace);
 Contexts.back().CaretFound = false;
 
 ScopedContextCreator ContextCreator(*this, tok::l_brace, 1);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] a2db7d5 - reland: [clang] Don't append the working directory to absolute paths

2022-03-15 Thread Keith Smiley via cfe-commits

Author: Keith Smiley
Date: 2022-03-15T13:42:35-07:00
New Revision: a2db7d5e9c52804544363ea819de174bfaa7ecdd

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

LOG: reland: [clang] Don't append the working directory to absolute paths

This fixes a bug that happens when using -fdebug-prefix-map to remap an
absolute path to a relative path. Since the path was absolute before
remapping, it is safe to assume that concatenating the remapped working
directory would be wrong.

This was originally submitted as https://reviews.llvm.org/D113718, but
reverted because when testing with dwarf 5 enabled, the tests were too
strict.

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

Added: 


Modified: 
clang/lib/CodeGen/CGDebugInfo.cpp
clang/test/CodeGen/debug-prefix-map.c

Removed: 




diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index 06501b34cbaef..0286d0e876f9d 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -444,7 +444,8 @@ CGDebugInfo::createFile(StringRef FileName,
   File = FileBuf;
 }
   } else {
-Dir = CurDir;
+if (!llvm::sys::path::is_absolute(FileName))
+  Dir = CurDir;
 File = RemappedFile;
   }
   llvm::DIFile *F = DBuilder.createFile(File, Dir, CSInfo, Source);

diff  --git a/clang/test/CodeGen/debug-prefix-map.c 
b/clang/test/CodeGen/debug-prefix-map.c
index fb2c1d39a1522..f604f1643ba02 100644
--- a/clang/test/CodeGen/debug-prefix-map.c
+++ b/clang/test/CodeGen/debug-prefix-map.c
@@ -6,6 +6,9 @@
 // RUN: %clang -g 
-fdebug-prefix-map=%p=%{fs-src-root}UNLIKELY_PATH%{fs-sep}empty -S -c %s 
-emit-llvm -o - | FileCheck %s
 // RUN: %clang -g 
-ffile-prefix-map=%p=%{fs-src-root}UNLIKELY_PATH%{fs-sep}empty -S -c %s 
-emit-llvm -o - | FileCheck %s
 
+// RUN: %clang -g -fdebug-prefix-map=%p=./UNLIKELY_PATH/empty -S -c %s 
-emit-llvm -o - | FileCheck %s --check-prefix=CHECK-REL
+// RUN: %clang -g -ffile-prefix-map=%p=./UNLIKELY_PATH/empty -S -c %s 
-emit-llvm -o - | FileCheck %s --check-prefix=CHECK-REL
+
 #include "Inputs/stdio.h"
 
 int main(int argc, char **argv) {
@@ -40,3 +43,7 @@ void test_rewrite_includes(void) {
 // CHECK-COMPILATION-DIR: !DIFile(filename: "{{.*}}Inputs{{/|}}stdio.h", 
directory: "{{/|.:}}UNLIKELY_PATH{{/|}}empty")
 // CHECK-COMPILATION-DIR-NOT: !DIFile(filename:
 // CHECK-SYSROOT: !DICompileUnit({{.*}}sysroot: 
"{{/|.:}}UNLIKELY_PATH{{/|}}empty"
+
+// CHECK-REL: !DIFile(filename: "./UNLIKELY_PATH/empty{{/|}}{{.*}}",
+// CHECK-REL: !DIFile(filename: 
"./UNLIKELY_PATH/empty{{/|}}{{.*}}Inputs/stdio.h",
+// CHECK-REL-SAME:directory: ""



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


[clang] 1db8112 - [clang-format] Fix crash with ObjC Blocks

2022-03-15 Thread Björn Schäpers via cfe-commits

Author: Björn Schäpers
Date: 2022-03-15T21:41:57+01:00
New Revision: 1db8112311c7f3c1d39c3b62637ac26055ad9d8f

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

LOG: [clang-format] Fix crash with ObjC Blocks

Fixes https://github.com/llvm/llvm-project/issues/54367
Fixes https://github.com/llvm/llvm-project/issues/54368

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

Added: 


Modified: 
clang/lib/Format/TokenAnnotator.cpp
clang/unittests/Format/TokenAnnotatorTest.cpp

Removed: 




diff  --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index f0a17af677016..848f69afca7c3 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -783,7 +783,7 @@ class AnnotatingParser {
 OpeningBrace.ParentBracket = Contexts.back().ContextKind;
 
 if (Contexts.back().CaretFound)
-  OpeningBrace.setType(TT_ObjCBlockLBrace);
+  OpeningBrace.overwriteFixedType(TT_ObjCBlockLBrace);
 Contexts.back().CaretFound = false;
 
 ScopedContextCreator ContextCreator(*this, tok::l_brace, 1);

diff  --git a/clang/unittests/Format/TokenAnnotatorTest.cpp 
b/clang/unittests/Format/TokenAnnotatorTest.cpp
index cc624d0760d12..ac0802f837173 100644
--- a/clang/unittests/Format/TokenAnnotatorTest.cpp
+++ b/clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -644,6 +644,22 @@ TEST_F(TokenAnnotatorTest, UnderstandsAsm) {
   EXPECT_TOKEN(Tokens[4], tok::r_brace, TT_InlineASMBrace);
 }
 
+TEST_F(TokenAnnotatorTest, UnderstandsObjCBlock) {
+  auto Tokens = annotate("int (^)() = ^ ()\n"
+ "  external_source_symbol() { //\n"
+ "  return 1;\n"
+ "};");
+  ASSERT_EQ(Tokens.size(), 21u) << Tokens;
+  EXPECT_TOKEN(Tokens[1], tok::l_paren, TT_ObjCBlockLParen);
+  EXPECT_TOKEN(Tokens[13], tok::l_brace, TT_ObjCBlockLBrace);
+
+  Tokens = annotate("int *p = ^int*(){ //\n"
+"  return nullptr;\n"
+"}();");
+  ASSERT_EQ(Tokens.size(), 19u) << Tokens;
+  EXPECT_TOKEN(Tokens[9], tok::l_brace, TT_ObjCBlockLBrace);
+}
+
 } // namespace
 } // namespace format
 } // namespace clang



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


[PATCH] D121441: [PowerPC][NFC] Add atomic alignments and ops tests for powerpc

2022-03-15 Thread Jinsong Ji via Phabricator via cfe-commits
jsji accepted this revision as: jsji.
jsji added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121441

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


[PATCH] D121736: Lower `@llvm.global_dtors` using `__cxa_atexit` on MachO

2022-03-15 Thread Julian Lettner via Phabricator via cfe-commits
yln created this revision.
yln added reviewers: Orlando, RKSimon.
Herald added subscribers: asb, ormris, pengfei, sunfish, hiraditya, 
jgravelle-google, sbc100, mgorny, dschuff.
Herald added a project: All.
yln requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, aheejin.
Herald added projects: clang, LLVM.

For MachO, lower `@llvm.global_dtors` into `@llvm_global_ctors` with
`__cxa_atexit` calls to avoid emitting the deprecated `__mod_term_func`.

Reuse the existing `WebAssemblyLowerGlobalDtors.cpp` to accomplish this.

Enable fallback to the old behavior via Clang driver flag
(`-fregister-global-dtors-with-atexit`) or llc / code generation flag
(`-lower-global-dtors-via-cxa-atexit`).  This escape hatch will be
removed in the future.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D121736

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  llvm/docs/Passes.rst
  llvm/include/llvm/CodeGen/CommandFlags.h
  llvm/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h
  llvm/include/llvm/InitializePasses.h
  llvm/include/llvm/LinkAllPasses.h
  llvm/include/llvm/Target/TargetOptions.h
  llvm/include/llvm/Transforms/Instrumentation/AddressSanitizerOptions.h
  llvm/include/llvm/Transforms/Utils.h
  llvm/include/llvm/Transforms/Utils/LowerGlobalDtors.h
  llvm/lib/CodeGen/CodeGen.cpp
  llvm/lib/CodeGen/CommandFlags.cpp
  llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
  llvm/lib/CodeGen/TargetPassConfig.cpp
  llvm/lib/Passes/PassBuilder.cpp
  llvm/lib/Passes/PassRegistry.def
  llvm/lib/Target/WebAssembly/CMakeLists.txt
  llvm/lib/Target/WebAssembly/WebAssembly.h
  llvm/lib/Target/WebAssembly/WebAssemblyLowerGlobalDtors.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
  llvm/lib/Transforms/Utils/CMakeLists.txt
  llvm/lib/Transforms/Utils/LowerGlobalDtors.cpp
  llvm/lib/Transforms/Utils/Utils.cpp
  llvm/test/CodeGen/ARM/ctors_dtors.ll
  llvm/test/CodeGen/X86/2011-08-29-InitOrder.ll
  llvm/test/Transforms/LowerGlobalDestructors/lower-global-dtors.ll

Index: llvm/test/Transforms/LowerGlobalDestructors/lower-global-dtors.ll
===
--- /dev/null
+++ llvm/test/Transforms/LowerGlobalDestructors/lower-global-dtors.ll
@@ -0,0 +1,156 @@
+; RUN: opt-lower-global-dtors -S < %s | FileCheck %s --implicit-check-not=llvm.global_dtors
+; RUN: opt -passes=lower-global-dtors -S < %s | FileCheck %s --implicit-check-not=llvm.global_dtors
+
+; Test that @llvm.global_dtors is properly lowered into @llvm.global_ctors,
+; grouping dtor calls by priority and associated symbol.
+
+declare void @orig_ctor()
+declare void @orig_dtor0()
+declare void @orig_dtor1a()
+declare void @orig_dtor1b()
+declare void @orig_dtor1c0()
+declare void @orig_dtor1c1a()
+declare void @orig_dtor1c1b()
+declare void @orig_dtor1c2a()
+declare void @orig_dtor1c2b()
+declare void @orig_dtor1c3()
+declare void @orig_dtor1d()
+declare void @orig_dtor65535()
+declare void @orig_dtor65535c0()
+declare void @after_the_null()
+
+@associatedc0 = external global i8
+@associatedc1 = external global i8
+@associatedc2 = global i8 42
+@associatedc3 = global i8 84
+
+@llvm.global_ctors = appending global
+[1 x { i32, void ()*, i8* }]
+[
+  { i32, void ()*, i8* } { i32 200, void ()* @orig_ctor, i8* null }
+]
+
+@llvm.global_dtors = appending global
+[14 x { i32, void ()*, i8* }]
+[
+  { i32, void ()*, i8* } { i32 0, void ()* @orig_dtor0, i8* null },
+  { i32, void ()*, i8* } { i32 1, void ()* @orig_dtor1a, i8* null },
+  { i32, void ()*, i8* } { i32 1, void ()* @orig_dtor1b, i8* null },
+  { i32, void ()*, i8* } { i32 1, void ()* @orig_dtor1c0, i8* @associatedc0 },
+  { i32, void ()*, i8* } { i32 1, void ()* @orig_dtor1c1a, i8* @associatedc1 },
+  { i32, void ()*, i8* } { i32 1, void ()* @orig_dtor1c1b, i8* @associatedc1 },
+  { i32, void ()*, i8* } { i32 1, void ()* @orig_dtor1c2a, i8* @associatedc2 },
+  { i32, void ()*, i8* } { i32 1, void ()* @orig_dtor1c2b, i8* @associatedc2 },
+  { i32, void ()*, i8* } { i32 1, void ()* @orig_dtor1c3, i8* @associatedc3 },
+  { i32, void ()*, i8* } { i32 1, void ()* @orig_dtor1d, i8* null },
+  { i32, void ()*, i8* } { i32 65535, void ()* @orig_dtor65535c0, i8* @associatedc0 },
+  { i32, void ()*, i8* } { i32 65535, void ()* @orig_dtor65535, i8* null },
+  { i32, void ()*, i8* } { i32 65535, void ()* null, i8* null },
+  { i32, void ()*, i8* } { i32 65535, void ()* @after_the_null, i8* null }
+]
+
+; CHECK: @associatedc0 = external global i8
+; CHECK: @associatedc1 = external global i8
+; CHECK: @associatedc2 = global i8 42
+; CHECK: @associatedc3 = global i8 84
+; CHECK: @__dso_handle = extern_weak hidden constant i8
+
+; CHECK-LABEL: @llvm.global_ctors = appending global [10 x { i32, void ()*, i8* }] [
+; CHECK-SAME:  { i32, void ()*, i8* } { i32 200, void ()* @orig_ctor, i8* null },
+; CHECK-SAME:  { i32, void ()*, i8* } { i32 0, void ()* @register_call_dtors.0, i8* null },
+; CHECK-SAME:  { i32, void ()*, i8* } 

[PATCH] D111587: re-land: [clang] Fix absolute file paths with -fdebug-prefix-map

2022-03-15 Thread Keith Smiley via Phabricator via cfe-commits
keith added a comment.

You're right it's version 5 not 4, maybe the issue is that some platforms (like 
macOS) are defaulting to 4 intentionally for now? I guess I thought 6 because 
passing 6 also reproduces, but I didn't also try 5.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111587

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


[PATCH] D121327: Lower `@llvm.global_dtors` using `__cxa_atexit` on MachO

2022-03-15 Thread Julian Lettner via Phabricator via cfe-commits
yln added a comment.

Hi @Orlando and @RKSimon!

Thanks for pointing out the test failure and reverting the change.  I see this 
failure:

  : 'RUN: at line 1';   
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/bin/opt
-lower-global-dtors -S < 
/home/buildbot/buildbot-root/llvm-project/llvm/test/Transforms/LowerGlobalDestructors/lower-global-dtors.ll
 | 
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/bin/FileCheck
 
/home/buildbot/buildbot-root/llvm-project/llvm/test/Transforms/LowerGlobalDestructors/lower-global-dtors.ll
 --implicit-check-not=llvm.global_dtors
  : 'RUN: at line 2';   
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/bin/opt 
-passes=lower-global-dtors -S < 
/home/buildbot/buildbot-root/llvm-project/llvm/test/Transforms/LowerGlobalDestructors/lower-global-dtors.ll
 | 
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/bin/FileCheck
 
/home/buildbot/buildbot-root/llvm-project/llvm/test/Transforms/LowerGlobalDestructors/lower-global-dtors.ll
 --implicit-check-not=llvm.global_dtors
  --
  Exit Code: 2
  Command Output (stderr):
  --
  opt: Unknown command line argument '-lower-global-dtors'.  Try: 
'/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/bin/opt 
--help'
  opt: Did you mean '--join-globalcopies'?

This looks like my changes are not sufficiently registering the pass for `opt` 
on every platform, but so far I haven't found anything that is obviously 
wrong/missing.  Do you know who I can reach out to help me with "pass 
registration"?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121327

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


[PATCH] D121733: Clean pathnames in FileManager.

2022-03-15 Thread Paul Pluzhnikov via Phabricator via cfe-commits
ppluzhnikov created this revision.
Herald added subscribers: dexonsmith, arphaman.
Herald added a project: All.
ppluzhnikov requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This reduces visual noise ("./foo.h" -> "foo.h") in error messages.

Fix all tests which fail as a result.

This also fixes a class of failures when __FILE__ is used in modules, and
the module specifies 'textual header "foo.h"' but Clang has "./foo.h"
included elsewhere.

Finally this should fix Windows failure from https://reviews.llvm.org/D121658


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D121733

Files:
  clang/bindings/python/tests/cindex/test_translation_unit.py
  clang/lib/Basic/FileManager.cpp
  clang/test/Frontend/dependency-gen.c
  clang/test/Index/skip-parsed-bodies/compile_commands.json
  clang/test/Modules/filename.cpp
  clang/unittests/Lex/HeaderSearchTest.cpp
  clang/unittests/Tooling/Syntax/TokensTest.cpp
  clang/unittests/Tooling/TransformerTest.cpp

Index: clang/unittests/Tooling/TransformerTest.cpp
===
--- clang/unittests/Tooling/TransformerTest.cpp
+++ clang/unittests/Tooling/TransformerTest.cpp
@@ -1593,21 +1593,22 @@
   return L.getFilePath() < R.getFilePath();
 });
 
-  ASSERT_EQ(Changes[0].getFilePath(), "./input.h");
-  EXPECT_THAT(Changes[0].getInsertedHeaders(), IsEmpty());
-  EXPECT_THAT(Changes[0].getRemovedHeaders(), IsEmpty());
+  const auto _h = Changes[1];
+  ASSERT_EQ(change_h.getFilePath(), "input.h");
+  EXPECT_THAT(change_h.getInsertedHeaders(), IsEmpty());
+  EXPECT_THAT(change_h.getRemovedHeaders(), IsEmpty());
   llvm::Expected UpdatedCode =
-  clang::tooling::applyAllReplacements(Header,
-   Changes[0].getReplacements());
+  clang::tooling::applyAllReplacements(Header, change_h.getReplacements());
   ASSERT_TRUE(static_cast(UpdatedCode))
   << "Could not update code: " << llvm::toString(UpdatedCode.takeError());
   EXPECT_EQ(format(*UpdatedCode), "");
 
-  ASSERT_EQ(Changes[1].getFilePath(), "input.cc");
-  EXPECT_THAT(Changes[1].getInsertedHeaders(), IsEmpty());
-  EXPECT_THAT(Changes[1].getRemovedHeaders(), IsEmpty());
-  UpdatedCode = clang::tooling::applyAllReplacements(
-  Source, Changes[1].getReplacements());
+  const auto _cc = Changes[0];
+  ASSERT_EQ(change_cc.getFilePath(), "input.cc");
+  EXPECT_THAT(change_cc.getInsertedHeaders(), IsEmpty());
+  EXPECT_THAT(change_cc.getRemovedHeaders(), IsEmpty());
+  UpdatedCode =
+  clang::tooling::applyAllReplacements(Source, change_cc.getReplacements());
   ASSERT_TRUE(static_cast(UpdatedCode))
   << "Could not update code: " << llvm::toString(UpdatedCode.takeError());
   EXPECT_EQ(format(*UpdatedCode), format("#include \"input.h\"\n"));
@@ -1630,7 +1631,7 @@
   {{"input.h", Header}}));
 
   ASSERT_EQ(Changes.size(), 1U);
-  ASSERT_EQ(Changes[0].getFilePath(), "./input.h");
+  ASSERT_EQ(Changes[0].getFilePath(), "input.h");
   EXPECT_THAT(Changes[0].getInsertedHeaders(), ElementsAre("header.h"));
   EXPECT_THAT(Changes[0].getRemovedHeaders(), IsEmpty());
   llvm::Expected UpdatedCode =
@@ -1679,7 +1680,7 @@
   ResultOf([](const AtomicChange ) { return C.getFilePath(); },
"input.cc"),
   ResultOf([](const AtomicChange ) { return C.getFilePath(); },
-   "./input.h";
+   "input.h";
 }
 
 } // namespace
Index: clang/unittests/Tooling/Syntax/TokensTest.cpp
===
--- clang/unittests/Tooling/Syntax/TokensTest.cpp
+++ clang/unittests/Tooling/Syntax/TokensTest.cpp
@@ -292,7 +292,7 @@
   {"int main() {}",
R"(expanded tokens:
   int main ( ) { }
-file './input.cpp'
+file 'input.cpp'
   spelled tokens:
 int main ( ) { }
   no mappings.
@@ -301,7 +301,7 @@
   {"\t\n  int\t\n  main\t\n  (\t\n  )\t\n{\t\n  }\t\n",
R"(expanded tokens:
   int main ( ) { }
-file './input.cpp'
+file 'input.cpp'
   spelled tokens:
 int main ( ) { }
   no mappings.
@@ -313,7 +313,7 @@
   )cpp",
R"(expanded tokens:
   
-file './input.cpp'
+file 'input.cpp'
   spelled tokens:
 # pragma GCC visibility push ( public ) # pragma GCC visibility pop
   mappings:
@@ -322,7 +322,7 @@
   // Empty files should not crash.
   {R"cpp()cpp", R"(expanded tokens:
   
-file './input.cpp'
+file 'input.cpp'
   spelled tokens:
 
   no mappings.
@@ -336,7 +336,7 @@
 )cpp",
   R"(expanded tokens:
   a
-file './input.cpp'
+file 'input.cpp'
   spelled tokens:
 a # define MACRO ( ) A # B
   mappings:
@@ -401,7 +401,7 @@
   std::string Expected =
   "expanded tokens:\n"
   "  int a ;\n"
-  "file './input.cpp'\n"
+  "file 'input.cpp'\n"
   "  spelled tokens:\n"
   "# define FOO a # include \"unresolved_file.h\" # undef FOO "
   "# ifdef X # 

[PATCH] D121646: [Concepts] Fix an assertion failure while diagnosing constrained function candidates

2022-03-15 Thread Erich Keane via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGbc7034c1ecfb: [Concepts] Fix an assertion failure while 
diagnosing constrained (authored by royjacobson, committed by erichkeane).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121646

Files:
  clang/lib/Sema/SemaOverload.cpp
  clang/test/SemaTemplate/concepts.cpp


Index: clang/test/SemaTemplate/concepts.cpp
===
--- clang/test/SemaTemplate/concepts.cpp
+++ clang/test/SemaTemplate/concepts.cpp
@@ -208,3 +208,17 @@
 return (int*)nullptr; // FIXME: should error
   }
 }
+
+namespace PR54379 {
+template 
+struct A {
+  static void f() requires (N == 0) { return; } // expected-note {{candidate 
template ignored: constraints not satisfied}} expected-note {{evaluated to 
false}}
+  static void f() requires (N == 1) { return; } // expected-note {{candidate 
template ignored: constraints not satisfied}} expected-note {{evaluated to 
false}}
+};
+void (*f1)() = A<2>::f; // expected-error {{address of overloaded function 'f' 
does not match required type}}
+
+struct B {
+  template  static void f() requires (N2 == 0) { return; }  // 
expected-note {{candidate template ignored: constraints not satisfied [with N2 
= 1]}} expected-note {{evaluated to false}}
+};
+void (*f2)() = B::f; // expected-error {{address of overloaded function 'f' 
does not match required type}}
+}
Index: clang/lib/Sema/SemaOverload.cpp
===
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -10256,10 +10256,19 @@
   return false;
 if (!Satisfaction.IsSatisfied) {
   if (Complain) {
-if (InOverloadResolution)
+if (InOverloadResolution) {
+  SmallString<128> TemplateArgString;
+  if (FunctionTemplateDecl *FunTmpl = FD->getPrimaryTemplate()) {
+TemplateArgString += " ";
+TemplateArgString += S.getTemplateArgumentBindingsText(
+FunTmpl->getTemplateParameters(),
+*FD->getTemplateSpecializationArgs());
+  }
+
   S.Diag(FD->getBeginLoc(),
- diag::note_ovl_candidate_unsatisfied_constraints);
-else
+ diag::note_ovl_candidate_unsatisfied_constraints)
+  << TemplateArgString;
+} else
   S.Diag(Loc, diag::err_addrof_function_constraints_not_satisfied)
   << FD;
 S.DiagnoseUnsatisfiedConstraint(Satisfaction);


Index: clang/test/SemaTemplate/concepts.cpp
===
--- clang/test/SemaTemplate/concepts.cpp
+++ clang/test/SemaTemplate/concepts.cpp
@@ -208,3 +208,17 @@
 return (int*)nullptr; // FIXME: should error
   }
 }
+
+namespace PR54379 {
+template 
+struct A {
+  static void f() requires (N == 0) { return; } // expected-note {{candidate template ignored: constraints not satisfied}} expected-note {{evaluated to false}}
+  static void f() requires (N == 1) { return; } // expected-note {{candidate template ignored: constraints not satisfied}} expected-note {{evaluated to false}}
+};
+void (*f1)() = A<2>::f; // expected-error {{address of overloaded function 'f' does not match required type}}
+
+struct B {
+  template  static void f() requires (N2 == 0) { return; }  // expected-note {{candidate template ignored: constraints not satisfied [with N2 = 1]}} expected-note {{evaluated to false}}
+};
+void (*f2)() = B::f; // expected-error {{address of overloaded function 'f' does not match required type}}
+}
Index: clang/lib/Sema/SemaOverload.cpp
===
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -10256,10 +10256,19 @@
   return false;
 if (!Satisfaction.IsSatisfied) {
   if (Complain) {
-if (InOverloadResolution)
+if (InOverloadResolution) {
+  SmallString<128> TemplateArgString;
+  if (FunctionTemplateDecl *FunTmpl = FD->getPrimaryTemplate()) {
+TemplateArgString += " ";
+TemplateArgString += S.getTemplateArgumentBindingsText(
+FunTmpl->getTemplateParameters(),
+*FD->getTemplateSpecializationArgs());
+  }
+
   S.Diag(FD->getBeginLoc(),
- diag::note_ovl_candidate_unsatisfied_constraints);
-else
+ diag::note_ovl_candidate_unsatisfied_constraints)
+  << TemplateArgString;
+} else
   S.Diag(Loc, diag::err_addrof_function_constraints_not_satisfied)
   << FD;
 S.DiagnoseUnsatisfiedConstraint(Satisfaction);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] bc7034c - [Concepts] Fix an assertion failure while diagnosing constrained

2022-03-15 Thread Erich Keane via cfe-commits

Author: Roy Jacobson
Date: 2022-03-15T13:11:32-07:00
New Revision: bc7034c1ecfbe942bc55ed054fca856c5ab90dc8

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

LOG: [Concepts] Fix an assertion failure while diagnosing constrained
function candidates

See: https://github.com/llvm/llvm-project/issues/54379

I tried to see if I can reuse ResolveAddressOfOverloadedFunction for
explicit function instantiation and so I managed to hit this ICE.

Bug was the diagnostic required an argument (%0) and specific code path
didn't pass an argument.

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

Added: 


Modified: 
clang/lib/Sema/SemaOverload.cpp
clang/test/SemaTemplate/concepts.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index 767074bdbd15f..fb071eee7c06c 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -10256,10 +10256,19 @@ static bool checkAddressOfFunctionIsAvailable(Sema 
, const FunctionDecl *FD,
   return false;
 if (!Satisfaction.IsSatisfied) {
   if (Complain) {
-if (InOverloadResolution)
+if (InOverloadResolution) {
+  SmallString<128> TemplateArgString;
+  if (FunctionTemplateDecl *FunTmpl = FD->getPrimaryTemplate()) {
+TemplateArgString += " ";
+TemplateArgString += S.getTemplateArgumentBindingsText(
+FunTmpl->getTemplateParameters(),
+*FD->getTemplateSpecializationArgs());
+  }
+
   S.Diag(FD->getBeginLoc(),
- diag::note_ovl_candidate_unsatisfied_constraints);
-else
+ diag::note_ovl_candidate_unsatisfied_constraints)
+  << TemplateArgString;
+} else
   S.Diag(Loc, diag::err_addrof_function_constraints_not_satisfied)
   << FD;
 S.DiagnoseUnsatisfiedConstraint(Satisfaction);

diff  --git a/clang/test/SemaTemplate/concepts.cpp 
b/clang/test/SemaTemplate/concepts.cpp
index 20af504883566..132761b2d68ae 100644
--- a/clang/test/SemaTemplate/concepts.cpp
+++ b/clang/test/SemaTemplate/concepts.cpp
@@ -208,3 +208,17 @@ namespace PR53911 {
 return (int*)nullptr; // FIXME: should error
   }
 }
+
+namespace PR54379 {
+template 
+struct A {
+  static void f() requires (N == 0) { return; } // expected-note {{candidate 
template ignored: constraints not satisfied}} expected-note {{evaluated to 
false}}
+  static void f() requires (N == 1) { return; } // expected-note {{candidate 
template ignored: constraints not satisfied}} expected-note {{evaluated to 
false}}
+};
+void (*f1)() = A<2>::f; // expected-error {{address of overloaded function 'f' 
does not match required type}}
+
+struct B {
+  template  static void f() requires (N2 == 0) { return; }  // 
expected-note {{candidate template ignored: constraints not satisfied [with N2 
= 1]}} expected-note {{evaluated to false}}
+};
+void (*f2)() = B::f; // expected-error {{address of overloaded function 'f' 
does not match required type}}
+}



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


[PATCH] D121370: [clang-format] SortIncludes should support "@import" lines in Objective-C

2022-03-15 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added a comment.

Some test with a main header and blocks would be nice.




Comment at: clang/lib/Format/Format.cpp:2779
 /*CheckMainHeader=*/!MainIncludeFound && FirstIncludeBlock);
-int Priority = Categories.getSortIncludePriority(
-IncludeName, !MainIncludeFound && FirstIncludeBlock);
+int Priority = WithSemicolon ? INT_MAX
+ : Categories.getSortIncludePriority(

I don't know about the others, but I prefer C++: `std::numeric_limits`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121370

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


[PATCH] D121646: [Concepts] Fix an assertion failure while diagnosing constrained function candidates

2022-03-15 Thread Roy Jacobson via Phabricator via cfe-commits
royjacobson added a comment.

In D121646#3382243 , @erichkeane 
wrote:

> In D121646#3380902 , @royjacobson 
> wrote:
>
>> In D121646#3380893 , @erichkeane 
>> wrote:
>>
>>> This seems acceptable to me. Though, I wonder if 
>>> `getTemplateArgumentBindingsText` should produce the leading space, that 
>>> way we could just pass the result of it directly, rather than have to 
>>> create a SmallString everywhere.  WDYT?
>>
>> There are other places (outside SemaOverload) that use this function and 
>> don't need a space, though.
>> I thought about just putting the space in the diagnostic itself, but then 
>> sometimes you don't get template arguments and it fails.
>
> I see.  I was hoping that wasn't the case!  OK, LGTM.  Let me know if you 
> need me to commit this for you.

Yes, thank you :)
(with author as "Roy Jacobson ")


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121646

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


[PATCH] D121295: [clang][deps] Modules don't contribute to search path usage

2022-03-15 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith accepted this revision.
dexonsmith added a comment.
This revision is now accepted and ready to land.

Nice! LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121295

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


[PATCH] D121685: [clang][deps] NFC: Use range-based for loop instead of iterators

2022-03-15 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith accepted this revision.
dexonsmith added a comment.
This revision is now accepted and ready to land.

LGTM. (Not sure if you were waiting for review, but I think it's fine to push 
this kind of thing after checking the tests pass.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121685

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


[PATCH] D121533: [clang][deps] Fix traversal of precompiled dependencies

2022-03-15 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith accepted this revision.
dexonsmith added a comment.
This revision is now accepted and ready to land.

LGTM, with another comment inline (up to you whether to do something with it).




Comment at: clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp:92
+  // List of module files to be processed.
+  llvm::SmallVector Worklist{PrebuiltModuleFilename.str()};
+  PrebuiltModuleListener Listener(ModuleFiles, InputFiles, VisitInputFiles,

These filenames will usually be longer than `std::string`'s small storage, 
requiring separate heap allocations for each filename. Can the worklist just 
point at the stable pointer `StringMapEntry*`, where a filename 
copy and heap allocation has already been made? (This has also has a nice side 
effect of handling 3x as many worklist items before needing to allocate, since 
the element size goes from 24B to 8B.)



Comment at: clang/test/ClangScanDeps/modules-pch-dangling.c:11
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+

`split-file` makes this so-called "unwieldy" testcase amazingly easy to read!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121533

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


[PATCH] D121550: [clang-format] Fix crash on invalid requires expression

2022-03-15 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added a comment.

In D121550#3381903 , @owenpan wrote:

> Nvm. See https://github.com/llvm/llvm-project/issues/54384.

Phew. I thought I needed a fix for the fix, for the fix, for the fix.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121550

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


[PATCH] D121245: [clang][parser] Allow GNU attributes before namespace identifier

2022-03-15 Thread Aleksandr Platonov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8bd00557e3f4: [clang][parser] Allow GNU attributes before 
namespace identifier (authored by ArcsinX).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121245

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/test/Parser/namespace-attributes.cpp

Index: clang/test/Parser/namespace-attributes.cpp
===
--- /dev/null
+++ clang/test/Parser/namespace-attributes.cpp
@@ -0,0 +1,41 @@
+// RUN: %clang_cc1 -std=c++17 -verify %s
+
+namespace __attribute__(()) A
+{
+}
+
+namespace A __attribute__(())
+{
+}
+
+namespace __attribute__(()) [[]] A
+{
+}
+
+namespace [[]] __attribute__(()) A
+{
+}
+
+namespace A __attribute__(()) [[]]
+{
+}
+
+namespace A [[]] __attribute__(())
+{
+}
+
+namespace [[]] A __attribute__(())
+{
+}
+
+namespace __attribute__(()) A [[]]
+{
+}
+
+namespace A::B __attribute__(()) // expected-error{{attributes cannot be specified on a nested namespace definition}}
+{
+}
+
+namespace __attribute__(()) A::B // expected-error{{attributes cannot be specified on a nested namespace definition}}
+{
+}
Index: clang/lib/Parse/ParseDeclCXX.cpp
===
--- clang/lib/Parse/ParseDeclCXX.cpp
+++ clang/lib/Parse/ParseDeclCXX.cpp
@@ -74,15 +74,27 @@
   SourceLocation FirstNestedInlineLoc;
 
   ParsedAttributesWithRange attrs(AttrFactory);
-  SourceLocation attrLoc;
-  if (getLangOpts().CPlusPlus11 && isCXX11AttributeSpecifier()) {
-Diag(Tok.getLocation(), getLangOpts().CPlusPlus17
-? diag::warn_cxx14_compat_ns_enum_attribute
-: diag::ext_ns_enum_attribute)
-  << 0 /*namespace*/;
-attrLoc = Tok.getLocation();
-ParseCXX11Attributes(attrs);
-  }
+
+  auto ReadAttributes = [&] {
+bool MoreToParse;
+do {
+  MoreToParse = false;
+  if (Tok.is(tok::kw___attribute)) {
+ParseGNUAttributes(attrs);
+MoreToParse = true;
+  }
+  if (getLangOpts().CPlusPlus11 && isCXX11AttributeSpecifier()) {
+Diag(Tok.getLocation(), getLangOpts().CPlusPlus17
+? diag::warn_cxx14_compat_ns_enum_attribute
+: diag::ext_ns_enum_attribute)
+<< 0 /*namespace*/;
+ParseCXX11Attributes(attrs);
+MoreToParse = true;
+  }
+} while (MoreToParse);
+  };
+
+  ReadAttributes();
 
   if (Tok.is(tok::identifier)) {
 Ident = Tok.getIdentifierInfo();
@@ -108,16 +120,14 @@
 }
   }
 
+  ReadAttributes();
+
+  SourceLocation attrLoc = attrs.Range.getBegin();
+
   // A nested namespace definition cannot have attributes.
   if (!ExtraNSs.empty() && attrLoc.isValid())
 Diag(attrLoc, diag::err_unexpected_nested_namespace_attribute);
 
-  // Read label attributes, if present.
-  if (Tok.is(tok::kw___attribute)) {
-attrLoc = Tok.getLocation();
-ParseGNUAttributes(attrs);
-  }
-
   if (Tok.is(tok::equal)) {
 if (!Ident) {
   Diag(Tok, diag::err_expected) << tok::identifier;
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -94,6 +94,11 @@
   locations a declaration attribute may appear.
   This fixes `Issue 53805 `_.
 
+- Improved namespace attributes handling:
+  - Handle GNU attributes before a namespace identifier and subsequent
+attributes of different kinds.
+  - Emit error on GNU attributes for a nested namespace definition.
+
 Windows Support
 ---
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 8bd0055 - [clang][parser] Allow GNU attributes before namespace identifier

2022-03-15 Thread Aleksandr Platonov via cfe-commits

Author: Aleksandr Platonov
Date: 2022-03-15T22:30:22+03:00
New Revision: 8bd00557e3f43b46a96cf0e357d5e65624c85a2b

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

LOG: [clang][parser] Allow GNU attributes before namespace identifier

GCC supports:
- `namespace  identifier`
- `namespace identifier `

But clang supports only `namespace identifier ` and diagnostics 
for `namespace  identifier` case looks unclear:
Code:
```
namespace __attribute__((visibility("hidden"))) A
{
}
```
Diags:
```
test.cpp:1:49: error: expected identifier or '{'
namespace __attribute__((visibility("hidden"))) A
^
test.cpp:1:49: error: C++ requires a type specifier for all declarations
test.cpp:3:2: error: expected ';' after top level declarator
}
```

This patch adds support for `namespace  identifier` and also 
forbids gnu attributes for nested namespaces (this already done for C++ 
attributes).

Reviewed By: aaron.ballman

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

Added: 
clang/test/Parser/namespace-attributes.cpp

Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/Parse/ParseDeclCXX.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 2422c8f2cba7a..ed79b647ed794 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -94,6 +94,11 @@ Attribute Changes in Clang
   locations a declaration attribute may appear.
   This fixes `Issue 53805 
`_.
 
+- Improved namespace attributes handling:
+  - Handle GNU attributes before a namespace identifier and subsequent
+attributes of 
diff erent kinds.
+  - Emit error on GNU attributes for a nested namespace definition.
+
 Windows Support
 ---
 

diff  --git a/clang/lib/Parse/ParseDeclCXX.cpp 
b/clang/lib/Parse/ParseDeclCXX.cpp
index 4ac3baba0d689..77fc504ebe462 100644
--- a/clang/lib/Parse/ParseDeclCXX.cpp
+++ b/clang/lib/Parse/ParseDeclCXX.cpp
@@ -74,15 +74,27 @@ Parser::DeclGroupPtrTy 
Parser::ParseNamespace(DeclaratorContext Context,
   SourceLocation FirstNestedInlineLoc;
 
   ParsedAttributesWithRange attrs(AttrFactory);
-  SourceLocation attrLoc;
-  if (getLangOpts().CPlusPlus11 && isCXX11AttributeSpecifier()) {
-Diag(Tok.getLocation(), getLangOpts().CPlusPlus17
-? diag::warn_cxx14_compat_ns_enum_attribute
-: diag::ext_ns_enum_attribute)
-  << 0 /*namespace*/;
-attrLoc = Tok.getLocation();
-ParseCXX11Attributes(attrs);
-  }
+
+  auto ReadAttributes = [&] {
+bool MoreToParse;
+do {
+  MoreToParse = false;
+  if (Tok.is(tok::kw___attribute)) {
+ParseGNUAttributes(attrs);
+MoreToParse = true;
+  }
+  if (getLangOpts().CPlusPlus11 && isCXX11AttributeSpecifier()) {
+Diag(Tok.getLocation(), getLangOpts().CPlusPlus17
+? diag::warn_cxx14_compat_ns_enum_attribute
+: diag::ext_ns_enum_attribute)
+<< 0 /*namespace*/;
+ParseCXX11Attributes(attrs);
+MoreToParse = true;
+  }
+} while (MoreToParse);
+  };
+
+  ReadAttributes();
 
   if (Tok.is(tok::identifier)) {
 Ident = Tok.getIdentifierInfo();
@@ -108,16 +120,14 @@ Parser::DeclGroupPtrTy 
Parser::ParseNamespace(DeclaratorContext Context,
 }
   }
 
+  ReadAttributes();
+
+  SourceLocation attrLoc = attrs.Range.getBegin();
+
   // A nested namespace definition cannot have attributes.
   if (!ExtraNSs.empty() && attrLoc.isValid())
 Diag(attrLoc, diag::err_unexpected_nested_namespace_attribute);
 
-  // Read label attributes, if present.
-  if (Tok.is(tok::kw___attribute)) {
-attrLoc = Tok.getLocation();
-ParseGNUAttributes(attrs);
-  }
-
   if (Tok.is(tok::equal)) {
 if (!Ident) {
   Diag(Tok, diag::err_expected) << tok::identifier;

diff  --git a/clang/test/Parser/namespace-attributes.cpp 
b/clang/test/Parser/namespace-attributes.cpp
new file mode 100644
index 0..9f925b742dfeb
--- /dev/null
+++ b/clang/test/Parser/namespace-attributes.cpp
@@ -0,0 +1,41 @@
+// RUN: %clang_cc1 -std=c++17 -verify %s
+
+namespace __attribute__(()) A
+{
+}
+
+namespace A __attribute__(())
+{
+}
+
+namespace __attribute__(()) [[]] A
+{
+}
+
+namespace [[]] __attribute__(()) A
+{
+}
+
+namespace A __attribute__(()) [[]]
+{
+}
+
+namespace A [[]] __attribute__(())
+{
+}
+
+namespace [[]] A __attribute__(())
+{
+}
+
+namespace __attribute__(()) A [[]]
+{
+}
+
+namespace A::B __attribute__(()) // expected-error{{attributes cannot be 
specified on a nested namespace definition}}
+{
+}
+
+namespace __attribute__(()) A::B // expected-error{{attributes cannot be 
specified on a nested 

[PATCH] D121709: [NFC][AIX] Disable precompiled module file test on AIX

2022-03-15 Thread Jake Egan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd1873d395d57: [NFC][AIX] Disable precompiled module file 
test on AIX (authored by Jake-Egan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121709

Files:
  clang/test/ClangScanDeps/modules-no-undeclared-includes.c


Index: clang/test/ClangScanDeps/modules-no-undeclared-includes.c
===
--- clang/test/ClangScanDeps/modules-no-undeclared-includes.c
+++ clang/test/ClangScanDeps/modules-no-undeclared-includes.c
@@ -1,3 +1,7 @@
+// Unsupported on AIX because we don't support the requisite "__clangast"
+// section in XCOFF yet.
+// UNSUPPORTED: aix
+
 // RUN: rm -rf %t && mkdir %t
 // RUN: split-file %s %t
 


Index: clang/test/ClangScanDeps/modules-no-undeclared-includes.c
===
--- clang/test/ClangScanDeps/modules-no-undeclared-includes.c
+++ clang/test/ClangScanDeps/modules-no-undeclared-includes.c
@@ -1,3 +1,7 @@
+// Unsupported on AIX because we don't support the requisite "__clangast"
+// section in XCOFF yet.
+// UNSUPPORTED: aix
+
 // RUN: rm -rf %t && mkdir %t
 // RUN: split-file %s %t
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] d1873d3 - [NFC][AIX] Disable precompiled module file test on AIX

2022-03-15 Thread Jake Egan via cfe-commits

Author: Jake Egan
Date: 2022-03-15T15:16:15-04:00
New Revision: d1873d395d5799fe7344d08de7f2b01e53697eca

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

LOG: [NFC][AIX] Disable precompiled module file test on AIX

This patch follows the same reasoning as D114481. The PCH reader looks for 
`__clangast` section in the precompiled module file, which is not present in 
the file on AIX and not supported in XCOFF yet.

Reviewed By: daltenty

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

Added: 


Modified: 
clang/test/ClangScanDeps/modules-no-undeclared-includes.c

Removed: 




diff  --git a/clang/test/ClangScanDeps/modules-no-undeclared-includes.c 
b/clang/test/ClangScanDeps/modules-no-undeclared-includes.c
index 72f39223cffc1..d88b32b6506be 100644
--- a/clang/test/ClangScanDeps/modules-no-undeclared-includes.c
+++ b/clang/test/ClangScanDeps/modules-no-undeclared-includes.c
@@ -1,3 +1,7 @@
+// Unsupported on AIX because we don't support the requisite "__clangast"
+// section in XCOFF yet.
+// UNSUPPORTED: aix
+
 // RUN: rm -rf %t && mkdir %t
 // RUN: split-file %s %t
 



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


[PATCH] D121412: Complete the list of single-underscore keywords for MSVC compat.

2022-03-15 Thread Eli Friedman via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5791e28f3016: Complete the list of single-underscore 
keywords for MSVC compat. (authored by efriedma).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121412

Files:
  clang/include/clang/Basic/TokenKinds.def


Index: clang/include/clang/Basic/TokenKinds.def
===
--- clang/include/clang/Basic/TokenKinds.def
+++ clang/include/clang/Basic/TokenKinds.def
@@ -676,24 +676,39 @@
 KEYWORD(__virtual_inheritance , KEYMS)
 KEYWORD(__interface   , KEYMS)
 ALIAS("__int8"   , char   , KEYMS)
-ALIAS("_int8", char   , KEYMS)
 ALIAS("__int16"  , short  , KEYMS)
-ALIAS("_int16"   , short  , KEYMS)
 ALIAS("__int32"  , int, KEYMS)
-ALIAS("_int32"   , int, KEYMS)
-ALIAS("_int64"   , __int64, KEYMS)
 ALIAS("__wchar_t", wchar_t, KEYMS)
-ALIAS("_asm" , asm, KEYMS)
-ALIAS("_alignof" , __alignof  , KEYMS)
 ALIAS("__builtin_alignof", __alignof  , KEYMS)
-ALIAS("_cdecl"   , __cdecl, KEYMS | KEYBORLAND)
-ALIAS("_fastcall", __fastcall , KEYMS | KEYBORLAND)
-ALIAS("_stdcall" , __stdcall  , KEYMS | KEYBORLAND)
-ALIAS("_thiscall", __thiscall , KEYMS)
-ALIAS("_vectorcall"  , __vectorcall, KEYMS)
-ALIAS("_uuidof"  , __uuidof   , KEYMS | KEYBORLAND)
-ALIAS("_inline"  , inline , KEYMS)
-ALIAS("_declspec", __declspec , KEYMS)
+
+// Microsoft single-underscore prefixed aliases for double-underscore prefixed
+// keywords.
+ALIAS("_asm" , asm  , KEYMS)
+ALIAS("_alignof" , __alignof, KEYMS)
+ALIAS("_cdecl"   , __cdecl  , KEYMS | KEYBORLAND)
+ALIAS("_declspec", __declspec   , KEYMS)
+ALIAS("_fastcall", __fastcall   , KEYMS | KEYBORLAND)
+ALIAS("_finally" , __finally, KEYMSCOMPAT)
+ALIAS("_forceinline" , __forceinline, KEYMSCOMPAT)
+ALIAS("_inline"  , inline   , KEYMS)
+ALIAS("_int8", char , KEYMS)
+ALIAS("_int16"   , short, KEYMS)
+ALIAS("_int32"   , int  , KEYMS)
+ALIAS("_int64"   , __int64  , KEYMS)
+ALIAS("_leave"   , __leave  , KEYMSCOMPAT)
+ALIAS("_multiple_inheritance", __multiple_inheritance, KEYMSCOMPAT)
+ALIAS("_ptr32"   , __ptr32  , KEYMSCOMPAT)
+ALIAS("_ptr64"   , __ptr64  , KEYMSCOMPAT)
+ALIAS("_restrict", restrict , KEYMSCOMPAT)
+ALIAS("_stdcall" , __stdcall, KEYMS | KEYBORLAND)
+ALIAS("_thiscall", __thiscall   , KEYMS)
+ALIAS("_try" , __try, KEYMSCOMPAT)
+ALIAS("_vectorcall"  , __vectorcall , KEYMS)
+ALIAS("_unaligned"   , __unaligned  , KEYMSCOMPAT)
+ALIAS("_uptr", __uptr   , KEYMSCOMPAT)
+ALIAS("_uuidof"  , __uuidof , KEYMS | KEYBORLAND)
+ALIAS("_virtual_inheritance", __virtual_inheritance, KEYMSCOMPAT)
+ALIAS("_w64" , __w64, KEYMSCOMPAT)
 
 // Borland Extensions which should be disabled in strict conformance mode.
 ALIAS("_pascal"  , __pascal   , KEYBORLAND)


Index: clang/include/clang/Basic/TokenKinds.def
===
--- clang/include/clang/Basic/TokenKinds.def
+++ clang/include/clang/Basic/TokenKinds.def
@@ -676,24 +676,39 @@
 KEYWORD(__virtual_inheritance , KEYMS)
 KEYWORD(__interface   , KEYMS)
 ALIAS("__int8"   , char   , KEYMS)
-ALIAS("_int8", char   , KEYMS)
 ALIAS("__int16"  , short  , KEYMS)
-ALIAS("_int16"   , short  , KEYMS)
 ALIAS("__int32"  , int, KEYMS)
-ALIAS("_int32"   , int, KEYMS)
-ALIAS("_int64"   , __int64, KEYMS)
 ALIAS("__wchar_t", wchar_t, KEYMS)
-ALIAS("_asm" , asm, KEYMS)
-ALIAS("_alignof" , __alignof  , KEYMS)
 ALIAS("__builtin_alignof", __alignof  , KEYMS)
-ALIAS("_cdecl"   , __cdecl, KEYMS | KEYBORLAND)
-ALIAS("_fastcall", __fastcall , KEYMS | KEYBORLAND)
-ALIAS("_stdcall" , __stdcall  , KEYMS | KEYBORLAND)
-ALIAS("_thiscall", __thiscall , KEYMS)
-ALIAS("_vectorcall"  , __vectorcall, KEYMS)
-ALIAS("_uuidof"  , __uuidof   , KEYMS | KEYBORLAND)
-ALIAS("_inline"  , inline , KEYMS)
-ALIAS("_declspec", __declspec , KEYMS)
+
+// Microsoft single-underscore prefixed aliases for double-underscore prefixed
+// keywords.
+ALIAS("_asm" , asm  , KEYMS)
+ALIAS("_alignof" , __alignof, KEYMS)
+ALIAS("_cdecl"   , __cdecl  , KEYMS | KEYBORLAND)
+ALIAS("_declspec", __declspec   , KEYMS)
+ALIAS("_fastcall", __fastcall   , KEYMS 

[clang] 5791e28 - Complete the list of single-underscore keywords for MSVC compat.

2022-03-15 Thread Eli Friedman via cfe-commits

Author: Eli Friedman
Date: 2022-03-15T11:58:40-07:00
New Revision: 5791e28f30168a5a930c1f869529b03b95405afe

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

LOG: Complete the list of single-underscore keywords for MSVC compat.

List derived from https://docs.microsoft.com/en-us/cpp/cpp/keywords-cpp
. Not that this is something we really want to encourage, but some of
these show up in practice, so I figured I should just complete the list.

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

Added: 


Modified: 
clang/include/clang/Basic/TokenKinds.def

Removed: 




diff  --git a/clang/include/clang/Basic/TokenKinds.def 
b/clang/include/clang/Basic/TokenKinds.def
index b9d5cd76d51d6..1d2082717bf97 100644
--- a/clang/include/clang/Basic/TokenKinds.def
+++ b/clang/include/clang/Basic/TokenKinds.def
@@ -676,24 +676,39 @@ KEYWORD(__multiple_inheritance, KEYMS)
 KEYWORD(__virtual_inheritance , KEYMS)
 KEYWORD(__interface   , KEYMS)
 ALIAS("__int8"   , char   , KEYMS)
-ALIAS("_int8", char   , KEYMS)
 ALIAS("__int16"  , short  , KEYMS)
-ALIAS("_int16"   , short  , KEYMS)
 ALIAS("__int32"  , int, KEYMS)
-ALIAS("_int32"   , int, KEYMS)
-ALIAS("_int64"   , __int64, KEYMS)
 ALIAS("__wchar_t", wchar_t, KEYMS)
-ALIAS("_asm" , asm, KEYMS)
-ALIAS("_alignof" , __alignof  , KEYMS)
 ALIAS("__builtin_alignof", __alignof  , KEYMS)
-ALIAS("_cdecl"   , __cdecl, KEYMS | KEYBORLAND)
-ALIAS("_fastcall", __fastcall , KEYMS | KEYBORLAND)
-ALIAS("_stdcall" , __stdcall  , KEYMS | KEYBORLAND)
-ALIAS("_thiscall", __thiscall , KEYMS)
-ALIAS("_vectorcall"  , __vectorcall, KEYMS)
-ALIAS("_uuidof"  , __uuidof   , KEYMS | KEYBORLAND)
-ALIAS("_inline"  , inline , KEYMS)
-ALIAS("_declspec", __declspec , KEYMS)
+
+// Microsoft single-underscore prefixed aliases for double-underscore prefixed
+// keywords.
+ALIAS("_asm" , asm  , KEYMS)
+ALIAS("_alignof" , __alignof, KEYMS)
+ALIAS("_cdecl"   , __cdecl  , KEYMS | KEYBORLAND)
+ALIAS("_declspec", __declspec   , KEYMS)
+ALIAS("_fastcall", __fastcall   , KEYMS | KEYBORLAND)
+ALIAS("_finally" , __finally, KEYMSCOMPAT)
+ALIAS("_forceinline" , __forceinline, KEYMSCOMPAT)
+ALIAS("_inline"  , inline   , KEYMS)
+ALIAS("_int8", char , KEYMS)
+ALIAS("_int16"   , short, KEYMS)
+ALIAS("_int32"   , int  , KEYMS)
+ALIAS("_int64"   , __int64  , KEYMS)
+ALIAS("_leave"   , __leave  , KEYMSCOMPAT)
+ALIAS("_multiple_inheritance", __multiple_inheritance, KEYMSCOMPAT)
+ALIAS("_ptr32"   , __ptr32  , KEYMSCOMPAT)
+ALIAS("_ptr64"   , __ptr64  , KEYMSCOMPAT)
+ALIAS("_restrict", restrict , KEYMSCOMPAT)
+ALIAS("_stdcall" , __stdcall, KEYMS | KEYBORLAND)
+ALIAS("_thiscall", __thiscall   , KEYMS)
+ALIAS("_try" , __try, KEYMSCOMPAT)
+ALIAS("_vectorcall"  , __vectorcall , KEYMS)
+ALIAS("_unaligned"   , __unaligned  , KEYMSCOMPAT)
+ALIAS("_uptr", __uptr   , KEYMSCOMPAT)
+ALIAS("_uuidof"  , __uuidof , KEYMS | KEYBORLAND)
+ALIAS("_virtual_inheritance", __virtual_inheritance, KEYMSCOMPAT)
+ALIAS("_w64" , __w64, KEYMSCOMPAT)
 
 // Borland Extensions which should be disabled in strict conformance mode.
 ALIAS("_pascal"  , __pascal   , KEYBORLAND)



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


[PATCH] D121723: [clang] CWG 2354: prohibit alignas for enums

2022-03-15 Thread Vlad Serebrennikov via Phabricator via cfe-commits
Endill added inline comments.



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:4291
 //   declared with the register storage class specifier. An
 //   alignment-specifier may also be applied to the declaration of a class
 //   or enumeration type.

erichkeane wrote:
> Can you add a comment up near here updating this?  
Like this? I can also quote the same paragraph from C++20, where this DR is 
already applied.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121723

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


  1   2   3   >