[PATCH] D146463: [CodeGen][RISCV] Change Shadow Call Stack Register to X3

2023-04-05 Thread Alex Bradbury via Phabricator via cfe-commits
asb added a comment.

In D146463#4247050 , @paulkirth wrote:

> @asb, @craig.topper, @jrtc27  Are there any remaining considerations for us 
> here? From the discussions in psABI and sig-toolchain, I think we have a 
> consensus that this is the approach we'll be taking for RISC-V. We'd prefer 
> to correct this ASAP, so as to prevent future incompatibility/continuing to 
> use a non-standard register.

It looks like we have strong consensus here. Could you update the patch to add 
a release note about this change please? (I guess it might merit inclusion in 
both the LLVM and the Clang release notes).

The RFC to check nobody downstream is concerned about changing the SCS register 
has been up for a week and a half with no concerns. You might consider leaving 
merging this until Monday to give it a full 2 week period, but I'm not opposed 
to going ahead before that. With the level of agreement we have it's hard to 
imagine changing direction and we want to change this default anyway - if 
there's a downstream user who needs to continue supporting the old SCS register 
then the logical path of action would be to add a new compiler option to enable 
that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146463

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


[PATCH] D147525: [X86] Add AMX_COMPLEX to Graniterapids

2023-04-05 Thread Freddy, Ye via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG847abddedca9: [X86] Add AMX_COMPLEX to Graniterapids 
(authored by FreddyYe).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147525

Files:
  clang/lib/Basic/Targets/X86.cpp
  clang/lib/Headers/immintrin.h
  clang/test/Preprocessor/predefined-arch-macros.c
  clang/test/Preprocessor/x86_target_features.c
  llvm/lib/Target/X86/X86.td
  llvm/lib/TargetParser/X86TargetParser.cpp


Index: llvm/lib/TargetParser/X86TargetParser.cpp
===
--- llvm/lib/TargetParser/X86TargetParser.cpp
+++ llvm/lib/TargetParser/X86TargetParser.cpp
@@ -208,7 +208,8 @@
 FeatureSERIALIZE | FeatureSHSTK | FeatureTSXLDTRK | FeatureUINTR |
 FeatureWAITPKG;
 constexpr FeatureBitset FeaturesGraniteRapids =
-FeaturesSapphireRapids | FeatureAMX_FP16 | FeaturePREFETCHI;
+FeaturesSapphireRapids | FeatureAMX_FP16 | FeaturePREFETCHI |
+FeatureAMX_COMPLEX;
 
 // Intel Atom processors.
 // Bonnell has feature parity with Core2 and adds MOVBE.
Index: llvm/lib/Target/X86/X86.td
===
--- llvm/lib/Target/X86/X86.td
+++ llvm/lib/Target/X86/X86.td
@@ -1054,7 +1054,8 @@
 
   // Graniterapids
   list GNRAdditionalFeatures = [FeatureAMXFP16,
-  FeaturePREFETCHI];
+  FeaturePREFETCHI,
+  FeatureAMXCOMPLEX];
   list GNRFeatures =
 !listconcat(SPRFeatures, GNRAdditionalFeatures);
 
Index: clang/test/Preprocessor/x86_target_features.c
===
--- clang/test/Preprocessor/x86_target_features.c
+++ clang/test/Preprocessor/x86_target_features.c
@@ -562,14 +562,14 @@
 // RUN: %clang -target x86_64-unknown-linux-gnu -march=x86-64 -mamx-complex -x 
c \
 // RUN: -E -dM -o - %s | FileCheck  -check-prefix=AMX-COMPLEX %s
 
-// AMX-COMPLEX: #define __AMXCOMPLEX__ 1
+// AMX-COMPLEX: #define __AMX_COMPLEX__ 1
 
 // RUN: %clang -target x86_64-unknown-linux-gnu -march=x86-64 -mno-amx-complex 
-x c \
 // RUN: -E -dM -o - %s | FileCheck  -check-prefix=NO-AMX-COMPLEX %s
 // RUN: %clang -target x86_64-unknown-linux-gnu -march=x86-64 -mamx-complex 
-mno-amx-tile \
 // RUN: -x c -E -dM -o - %s | FileCheck  -check-prefix=NO-AMX-COMPLEX %s
 
-// NO-AMX-COMPLEX-NOT: #define __AMXCOMPLEX__ 1
+// NO-AMX-COMPLEX-NOT: #define __AMX_COMPLEX__ 1
 
 // RUN: %clang -target i386-unknown-unknown -march=atom -mavxvnni -x c -E -dM 
-o - %s | FileCheck -match-full-lines --check-prefix=AVXVNNI %s
 
Index: clang/test/Preprocessor/predefined-arch-macros.c
===
--- clang/test/Preprocessor/predefined-arch-macros.c
+++ clang/test/Preprocessor/predefined-arch-macros.c
@@ -1798,6 +1798,7 @@
 // RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_GNR_M32
 // CHECK_GNR_M32: #define __AES__ 1
 // CHECK_GNR_M32: #define __AMX_BF16__ 1
+// CHECK_GNR_M32: #define __AMX_COMPLEX__ 1
 // CHECK_GNR_M32: #define __AMX_FP16__ 1
 // CHECK_GNR_M32: #define __AMX_INT8__ 1
 // CHECK_GNR_M32: #define __AMX_TILE__ 1
@@ -1872,6 +1873,7 @@
 // RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_GNR_M64
 // CHECK_GNR_M64: #define __AES__ 1
 // CHECK_GNR_M64: #define __AMX_BF16__ 1
+// CHECK_GNR_M64: #define __AMX_COMPLEX__ 1
 // CHECK_GNR_M64: #define __AMX_FP16__ 1
 // CHECK_GNR_M64: #define __AMX_INT8__ 1
 // CHECK_GNR_M64: #define __AMX_TILE__ 1
Index: clang/lib/Headers/immintrin.h
===
--- clang/lib/Headers/immintrin.h
+++ clang/lib/Headers/immintrin.h
@@ -626,7 +626,7 @@
 #endif
 
 #if !(defined(_MSC_VER) || defined(__SCE__)) || __has_feature(modules) ||  
\
-defined(__AMXCOMPLEX__)
+defined(__AMX_COMPLEX__)
 #include 
 #endif
 
Index: clang/lib/Basic/Targets/X86.cpp
===
--- clang/lib/Basic/Targets/X86.cpp
+++ clang/lib/Basic/Targets/X86.cpp
@@ -802,7 +802,7 @@
   if (HasAMXFP16)
 Builder.defineMacro("__AMX_FP16__");
   if (HasAMXCOMPLEX)
-Builder.defineMacro("__AMXCOMPLEX__");
+Builder.defineMacro("__AMX_COMPLEX__");
   if (HasCMPCCXADD)
 Builder.defineMacro("__CMPCCXADD__");
   if (HasRAOINT)


Index: llvm/lib/TargetParser/X86TargetParser.cpp
===
--- llvm/lib/TargetParser/X86TargetParser.cpp
+++ llvm/lib/TargetParser/X86TargetParser.cpp
@@ -208,7 +208,8 @@
 FeatureSERIALIZE | FeatureSHSTK | FeatureTSXLDTRK | FeatureUINTR |
 FeatureWAITPKG;
 constexpr FeatureBitset FeaturesGraniteRapids =
-FeaturesSapphireRapids | FeatureAMX_FP16 | FeaturePREFETCHI;
+FeaturesSapphireRapids | FeatureAMX_FP16 

[clang] 847abdd - [X86] Add AMX_COMPLEX to Graniterapids

2023-04-05 Thread Freddy Ye via cfe-commits

Author: Freddy Ye
Date: 2023-04-06T13:19:44+08:00
New Revision: 847abddedca9ed2934e0c2386662ccb04ba4d298

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

LOG: [X86] Add AMX_COMPLEX to Graniterapids

This patch also rename __AMXCOMPLEX__ to __AMX_COMPLEX__

Reviewed By: skan, xiangzhangllvm

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

Added: 


Modified: 
clang/lib/Basic/Targets/X86.cpp
clang/lib/Headers/immintrin.h
clang/test/Preprocessor/predefined-arch-macros.c
clang/test/Preprocessor/x86_target_features.c
llvm/lib/Target/X86/X86.td
llvm/lib/TargetParser/X86TargetParser.cpp

Removed: 




diff  --git a/clang/lib/Basic/Targets/X86.cpp b/clang/lib/Basic/Targets/X86.cpp
index 0cffc76d3f2ce..a997614a65a86 100644
--- a/clang/lib/Basic/Targets/X86.cpp
+++ b/clang/lib/Basic/Targets/X86.cpp
@@ -802,7 +802,7 @@ void X86TargetInfo::getTargetDefines(const LangOptions 
,
   if (HasAMXFP16)
 Builder.defineMacro("__AMX_FP16__");
   if (HasAMXCOMPLEX)
-Builder.defineMacro("__AMXCOMPLEX__");
+Builder.defineMacro("__AMX_COMPLEX__");
   if (HasCMPCCXADD)
 Builder.defineMacro("__CMPCCXADD__");
   if (HasRAOINT)

diff  --git a/clang/lib/Headers/immintrin.h b/clang/lib/Headers/immintrin.h
index d382ec88f30f7..dff4da2465d27 100644
--- a/clang/lib/Headers/immintrin.h
+++ b/clang/lib/Headers/immintrin.h
@@ -626,7 +626,7 @@ _storebe_i64(void * __P, long long __D) {
 #endif
 
 #if !(defined(_MSC_VER) || defined(__SCE__)) || __has_feature(modules) ||  
\
-defined(__AMXCOMPLEX__)
+defined(__AMX_COMPLEX__)
 #include 
 #endif
 

diff  --git a/clang/test/Preprocessor/predefined-arch-macros.c 
b/clang/test/Preprocessor/predefined-arch-macros.c
index a64e5afa7aac3..fd84ea174856a 100644
--- a/clang/test/Preprocessor/predefined-arch-macros.c
+++ b/clang/test/Preprocessor/predefined-arch-macros.c
@@ -1798,6 +1798,7 @@
 // RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_GNR_M32
 // CHECK_GNR_M32: #define __AES__ 1
 // CHECK_GNR_M32: #define __AMX_BF16__ 1
+// CHECK_GNR_M32: #define __AMX_COMPLEX__ 1
 // CHECK_GNR_M32: #define __AMX_FP16__ 1
 // CHECK_GNR_M32: #define __AMX_INT8__ 1
 // CHECK_GNR_M32: #define __AMX_TILE__ 1
@@ -1872,6 +1873,7 @@
 // RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_GNR_M64
 // CHECK_GNR_M64: #define __AES__ 1
 // CHECK_GNR_M64: #define __AMX_BF16__ 1
+// CHECK_GNR_M64: #define __AMX_COMPLEX__ 1
 // CHECK_GNR_M64: #define __AMX_FP16__ 1
 // CHECK_GNR_M64: #define __AMX_INT8__ 1
 // CHECK_GNR_M64: #define __AMX_TILE__ 1

diff  --git a/clang/test/Preprocessor/x86_target_features.c 
b/clang/test/Preprocessor/x86_target_features.c
index 5bf38cc3b256b..4481351b4e791 100644
--- a/clang/test/Preprocessor/x86_target_features.c
+++ b/clang/test/Preprocessor/x86_target_features.c
@@ -562,14 +562,14 @@
 // RUN: %clang -target x86_64-unknown-linux-gnu -march=x86-64 -mamx-complex -x 
c \
 // RUN: -E -dM -o - %s | FileCheck  -check-prefix=AMX-COMPLEX %s
 
-// AMX-COMPLEX: #define __AMXCOMPLEX__ 1
+// AMX-COMPLEX: #define __AMX_COMPLEX__ 1
 
 // RUN: %clang -target x86_64-unknown-linux-gnu -march=x86-64 -mno-amx-complex 
-x c \
 // RUN: -E -dM -o - %s | FileCheck  -check-prefix=NO-AMX-COMPLEX %s
 // RUN: %clang -target x86_64-unknown-linux-gnu -march=x86-64 -mamx-complex 
-mno-amx-tile \
 // RUN: -x c -E -dM -o - %s | FileCheck  -check-prefix=NO-AMX-COMPLEX %s
 
-// NO-AMX-COMPLEX-NOT: #define __AMXCOMPLEX__ 1
+// NO-AMX-COMPLEX-NOT: #define __AMX_COMPLEX__ 1
 
 // RUN: %clang -target i386-unknown-unknown -march=atom -mavxvnni -x c -E -dM 
-o - %s | FileCheck -match-full-lines --check-prefix=AVXVNNI %s
 

diff  --git a/llvm/lib/Target/X86/X86.td b/llvm/lib/Target/X86/X86.td
index 7f6399c937aea..1337bc9d9a6da 100644
--- a/llvm/lib/Target/X86/X86.td
+++ b/llvm/lib/Target/X86/X86.td
@@ -1054,7 +1054,8 @@ def ProcessorFeatures {
 
   // Graniterapids
   list GNRAdditionalFeatures = [FeatureAMXFP16,
-  FeaturePREFETCHI];
+  FeaturePREFETCHI,
+  FeatureAMXCOMPLEX];
   list GNRFeatures =
 !listconcat(SPRFeatures, GNRAdditionalFeatures);
 

diff  --git a/llvm/lib/TargetParser/X86TargetParser.cpp 
b/llvm/lib/TargetParser/X86TargetParser.cpp
index 8da45d96a8cc7..82fd181324a74 100644
--- a/llvm/lib/TargetParser/X86TargetParser.cpp
+++ b/llvm/lib/TargetParser/X86TargetParser.cpp
@@ -208,7 +208,8 @@ constexpr FeatureBitset FeaturesSapphireRapids =
 FeatureSERIALIZE | FeatureSHSTK | FeatureTSXLDTRK | FeatureUINTR |
 FeatureWAITPKG;
 constexpr FeatureBitset FeaturesGraniteRapids =
-FeaturesSapphireRapids | FeatureAMX_FP16 | FeaturePREFETCHI;
+FeaturesSapphireRapids 

[PATCH] D146463: [CodeGen][RISCV] Change Shadow Call Stack Register to X3

2023-04-05 Thread Jessica Clarke via Phabricator via cfe-commits
jrtc27 added a comment.

From an ABI/codegen perspective the small data limit doesn’t matter here, all 
it does is govern whether things go in .sdata or not. The linker is what 
chooses whether to use GP, which happens regardless of whether something is in 
.sdata, just things in .sdata are more likely to be picked, since GP is defined 
to be 0x800 from its start. What matters is that the linker is told not to do 
GP relaxation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146463

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


[PATCH] D147657: [Sema] Fix reporting of invalid shader attribute on HLSL entry function

2023-04-05 Thread Xiang Li via Phabricator via cfe-commits
python3kgae accepted this revision.
python3kgae added a comment.
This revision is now accepted and ready to land.

Thanks for fix the issue.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147657

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


[PATCH] D147572: [Clang][OpenMP] Fix failure with team-wide allocated variable

2023-04-05 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added inline comments.



Comment at: clang/test/OpenMP/target_team_variable_codegen.cpp:33
+//.
+// CHECK-NVIDIA: @local_a = internal addrspace(3) global [10 x i32] 
zeroinitializer, align 4
+//.

Shouldn't the Nvidia version also be undefined? Not sure why this should vary 
depending on the target.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147572

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


[PATCH] D143467: [PowerPC] Add target feature requirement to builtins

2023-04-05 Thread Qiu Chaofan via Phabricator via cfe-commits
qiucf added inline comments.



Comment at: clang/include/clang/Basic/BuiltinsPPC.def:444
+TARGET_BUILTIN(__builtin_altivec_vcmpnew_p, "iiV4iV4i", "", "power9-vector")
+TARGET_BUILTIN(__builtin_altivec_vcmpned_p, "iiV2LLiV2LLi", "", "altivec")
+

maryammo wrote:
> amyk wrote:
> > Does this need to be `vsx`?
> How do we find the appropriate FEATURE for the above 4 builtins?  (first 3 
> are p9 and the 4th one is altivec)
`vcmpneb` `vcmpneh` `vcmpnew` debute in ISA 3.0. `vcmpned` does not exist, so 
it's keeped as-is. (but `vector long long` requires vsx, so it's reasonable to 
require vsx)



Comment at: clang/include/clang/Basic/BuiltinsPPC.def:987
+
+UNALIASED_CUSTOM_BUILTIN(mma_assemble_acc, "vW512*", false, "mma")
+UNALIASED_CUSTOM_BUILTIN(mma_disassemble_acc, "vv*W512*", false, "mma")

kamaub wrote:
> stefanp wrote:
> > Based on the original implementation in `SemaBuiltinPPCMMACall` all of the 
> > `mma` builtins also require `paired-vector-memops`. 
> > Is this something that we still need?
> since we are able to supply a comma separated list as done with 
> `TARGET_BUILTIN(__builtin_ppc_compare_exp_uo, "idd", "", 
> "isa-v30-instructions,vsx")` @ 
> `clang/include/clang/Basic/BuiltinsPPC.def:105`we should definitely also 
> specify `paired-vector-memops,mma` for the `[UNALIASED_]CUSTOM_BUILTIN`s 
> previously covered under the default case of `SemaBuiltinPPCMMACall()` 
Since `mma` and `paired-vector-memops` are independent from each other, I think 
only assemble/disassemble builtins should require `paired-vector-memops`?



Comment at: clang/test/CodeGen/PowerPC/builtins-ppc-xlcompat-test.c:47
 
-int test_test_data_class_f() {
-// CHECK-LABEL:   @test_test_data_class_f
-// CHECK: [[TMP:%.*]] = call i32 
@llvm.ppc.test.data.class.f32(float %0, i32 127)
-// CHECK-NEXT:ret i32 [[TMP]]
-// CHECK-NONPWR9-ERR: error: this builtin is only valid on POWER9 or later CPUs
-// CHECK-NOVSX-ERR: error: this builtin requires VSX to be enabled
-  return __test_data_class(f, 127);
+// CHECK-NOVSX-ERR: error: '__builtin_ppc_compare_exp_uo' needs target feature 
isa-v30-instructions,vsx
+// CHECK-NOVSX-ERR: error: '__builtin_ppc_compare_exp_lt' needs target feature 
isa-v30-instructions,vsx

stefanp wrote:
> nit:
> Should this be 
> ```
> ... needs target feature vsx
> ```
> Instead of listing them both?
> 
> Fixing this might be more trouble than it's worth because you would have to 
> edit `CodeGenFunction::checkTargetFeatures`. I just thought I would mention 
> it.
Yes. That can be done in another patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143467

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


[clang] 5bbadec - Recommit [C++20] [Modules] Don't load declaration eagerly for named modules

2023-04-05 Thread Chuanqi Xu via cfe-commits

Author: Chuanqi Xu
Date: 2023-04-06T11:01:58+08:00
New Revision: 5bbadec2d1e0d5d0d25295759d49f6cd420d0968

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

LOG: Recommit [C++20] [Modules] Don't load declaration eagerly for named modules

Close https://github.com/llvm/llvm-project/issues/61064.

The root cause of the issue is that we will deserilize some declarations
eagerly when reading the BMI. However, many declarations in the BMI are
not necessary for the importer. So it wastes a lot of time.

The new commit handles the MSVC's extension #pragma comment and #pragma
detect_mismatch to follow MSVC's behavior. See pr61783 for details.

Added: 
clang/test/Modules/no-eager-load.cppm
clang/test/Modules/pr61783.cppm

Modified: 
clang/lib/Serialization/ASTWriterDecl.cpp

Removed: 




diff  --git a/clang/lib/Serialization/ASTWriterDecl.cpp 
b/clang/lib/Serialization/ASTWriterDecl.cpp
index abb6bb747bfa9..54b5e3877782d 100644
--- a/clang/lib/Serialization/ASTWriterDecl.cpp
+++ b/clang/lib/Serialization/ASTWriterDecl.cpp
@@ -2500,7 +2500,20 @@ void ASTWriter::WriteDeclAbbrevs() {
 /// relatively painless since they would presumably only do it for top-level
 /// decls.
 static bool isRequiredDecl(const Decl *D, ASTContext ,
-   bool WritingModule) {
+   Module *WritingModule) {
+  // Named modules have 
diff erent semantics than header modules. Every named
+  // module units owns a translation unit. So the importer of named modules
+  // doesn't need to deserilize everything ahead of time.
+  if (WritingModule && WritingModule->isModulePurview()) {
+// The PragmaCommentDecl and PragmaDetectMismatchDecl are MSVC's extension.
+// And the behavior of MSVC for such cases will leak this to the module
+// users. Given pragma is not a standard thing, the compiler has the space
+// to do their own decision. Let's follow MSVC here.
+if (isa(D))
+  return true;
+return false;
+  }
+
   // An ObjCMethodDecl is never considered as "required" because its
   // implementation container always is.
 

diff  --git a/clang/test/Modules/no-eager-load.cppm 
b/clang/test/Modules/no-eager-load.cppm
new file mode 100644
index 0..6632cc60c8eb8
--- /dev/null
+++ b/clang/test/Modules/no-eager-load.cppm
@@ -0,0 +1,110 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: cd %t
+//
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/a.cppm -o %t/a.pcm
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/b.cppm -o %t/b.pcm
+// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify %t/c.cpp \
+// RUN: -fprebuilt-module-path=%t
+// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify %t/d.cpp \
+// RUN: -fprebuilt-module-path=%t
+//
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/e.cppm -o %t/e.pcm
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/f.cppm -o %t/f.pcm
+// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify %t/g.cpp \
+// RUN: -fprebuilt-module-path=%t
+//
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/h.cppm \
+// RUN: -fprebuilt-module-path=%t -o %t/h.pcm
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/i.cppm \
+// RUN: -fprebuilt-module-path=%t -o %t/i.pcm
+// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify %t/j.cpp \
+// RUN: -fprebuilt-module-path=%t
+// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify %t/k.cpp \
+// RUN: -fprebuilt-module-path=%t
+
+//--- a.cppm
+export module a;
+export void foo() {
+
+}
+
+//--- b.cppm
+export module b;
+void bar();
+export void foo() {
+bar();
+}
+
+//--- c.cpp
+// expected-no-diagnostics
+// Since we will load all the declaration lazily, we won't be able to find
+// the ODR violation here.
+import a;
+import b;
+
+//--- d.cpp
+import a;
+import b;
+// Test that we can still check the odr violation if we call the function
+// actually.
+void use() {
+foo(); // expected-error@* {{'foo' has 
diff erent definitions in 
diff erent modules;}}
+   // expected-note@* {{but in 'a' found a 
diff erent body}}
+}
+
+//--- foo.h
+void foo() {
+
+}
+
+//--- bar.h
+void bar();
+void foo() {
+bar();
+}
+
+//--- e.cppm
+module;
+#include "foo.h"
+export module e;
+export using ::foo;
+
+//--- f.cppm
+module;
+#include "bar.h"
+export module f;
+export using ::foo;
+
+//--- g.cpp
+import e;
+import f;
+void use() {
+foo(); // expected-error@* {{'foo' has 
diff erent definitions in 
diff erent modules;}}
+   // expected-note@* {{but in 'e.' found a 
diff erent body}}
+}
+
+//--- h.cppm
+export module h;
+export import a;
+export import b;
+
+//--- i.cppm
+export module i;
+export import e;
+export import f;
+
+//--- j.cpp
+import h;
+void use() {
+foo(); // expected-error@* {{'foo' has 

[PATCH] D143479: [Clang] Emit error when caller cannot meet target feature requirement from always-inlining callee

2023-04-05 Thread Qiu Chaofan via Phabricator via cfe-commits
qiucf added a comment.

In D143479#4243143 , @erichkeane 
wrote:

> Based on GCC's behavior: https://godbolt.org/z/fxWzPTT9P  I suspect our 
> behavior is consistent/correct now, and the 'regressions' are to be expected, 
> since GCC diagnoses the same things we do (just nicer, albeit, less 
> informative).

This is expected. But we can do better like GCC to find 'real target 
requirements from called intrinsics' of a function, which may be a larger 
change though.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143479

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


[PATCH] D147417: [clang-tidy] Do not emit bugprone-exception-escape warnings from coroutines

2023-04-05 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added inline comments.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape-coro.cpp:75-79
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:11: warning: an exception may be thrown 
in function 'b_ShouldNotDiag' which should not throw exceptions
+  if (b == 0)
+throw b;
+
+  co_return a / b;

denizevrenci wrote:
> ChuanqiXu wrote:
> > denizevrenci wrote:
> > > ChuanqiXu wrote:
> > > > I don't understand why we shouldn't emit the warning here. Since the 
> > > > function is marked `noexcept` but it may throw actually in 
> > > > `unhandled_exception`. I think it is meaningful to warn for this.
> > > Right, I now see that this behavior is different between Clang's 
> > > `-Wexceptions` and Clang Tidy's `bugprone-exception-escape`. The former 
> > > does not warn on this code, the latter does.
> > > 
> > > ```
> > > int foo() {
> > >   throw 1;
> > > }
> > > 
> > > int bar() noexcept {
> > >   return foo();
> > > }
> > > ```
> > > 
> > > We need to treat coroutines differently and check whether `task::task`, 
> > > `promise::promise`,  `promise::initial_suspend`, 
> > > `promise::get_return_object`, and `promise::unhandled_exception` can 
> > > throw instead of the body of the coroutine.
> > I investigated the exception issue in coroutines before: 
> > https://reviews.llvm.org/D108277. And it is much more complex than I 
> > thought. The short conclusion here is that the coroutine is still may throw 
> > even if all the promise's method wouldn't throw. For example:
> > 
> > ```
> > struct Evil {
> > ~Evil() noexcept(false) { throw 32; }
> > };
> > 
> > task foo() noexcept { // all promise's method of task wouldn't throw
> > throw Evil;
> > }
> > ```
> > 
> > And in the above example, foo() may throw actually. Although the implicit 
> > `catch` block of `foo()` will catch `Evil`, the exception in the destructor 
> > of `Evil` will be thrown again.
> > 
> > So we can't be sure that a coroutine wouldn't throw even if all of its 
> > promise's method wouldn't throw.
> It looks like the function `foo` can throw until the first suspension point 
> in the coroutine. If `promise::initial_suspend` is `std::suspend_always`, 
> then it will not throw. Of course, determining this statically is quite 
> complicated.
> But I also think that this is a rather niche example,  it looks like 
> clang-tidy already warns with `bugprone-exception-escape` on the destructor 
> of `Evil` even when it is marked `noexcept(false)`. I assume this is due to 
> the other
> complications brought by throwing from destructors. Would that not be the 
> appropriate place to warn about this anyway?
> 
> For example, the code below terminates because the destructor of `Evil` gets 
> called while there is an active exception.
> ```
> task foo() { // all promise's method of task wouldn't throw
> Evil e;
> throw 1;
> co_return;
> }
> ```
If we've handled the case, the strategy makes sense to me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147417

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


[PATCH] D147615: [clang][Sema][NFC] Save token name instead of the full token

2023-04-05 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added inline comments.



Comment at: clang/lib/Parse/ParseDeclCXX.cpp:962
+  // Save the token name used for static assertion.
+  const char *TokName = Tok.getName();
 

It looks like this comes from a static array so it should be fine but let's see 
what Aaron says.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147615

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


[PATCH] D147590: [clang] Add test for CWG607

2023-04-05 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik accepted this revision.
shafik added a comment.
This revision is now accepted and ready to land.

Thank you for working on these DRs, LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147590

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


[PATCH] D146463: [CodeGen][RISCV] Change Shadow Call Stack Register to X3

2023-04-05 Thread Paul Kirth via Phabricator via cfe-commits
paulkirth added a comment.

whe




Comment at: clang/lib/Driver/SanitizerArgs.cpp:546
 
-  if ((Kinds & SanitizerKind::ShadowCallStack) &&
-  ((TC.getTriple().isAArch64() &&
-!llvm::AArch64::isX18ReservedByDefault(TC.getTriple())) ||
-   (TC.getTriple().isRISCV() &&
-!llvm::RISCV::isX18ReservedByDefault(TC.getTriple( &&
+  if ((Kinds & SanitizerKind::ShadowCallStack) && TC.getTriple().isAArch64() &&
+  !llvm::AArch64::isX18ReservedByDefault(TC.getTriple()) &&

mcgrathr wrote:
> For RISC-V this needs a similar check that the equivalent of 
> `-msmall-data-limit=0` is in force (that's the default under `-fPIC` but not 
> other modes).
> 
I'll look into adding support for that.



Comment at: llvm/lib/Target/RISCV/RISCVSubtarget.cpp:86
   InstrInfo(*this), RegInfo(getHwMode()), TLInfo(TM, *this) {
-  if (RISCV::isX18ReservedByDefault(TT))
-UserReservedRegister.set(RISCV::X18);

craig.topper wrote:
> Drop the blank line here.
@mcgrathr This stops Fuchsia and Android from reserving X18. I'll look at doing 
something similar for `-msmall-data-limit=0`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146463

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


[PATCH] D147666: [OPENMP] Adds /lib to rpath to avoid need to set LD_LIBRARY_PATH to find plugins.

2023-04-05 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added a comment.

Using `-rpath` by default with OpenMP was removed after a long conversation in 
https://reviews.llvm.org/D143306. The way forward is most likely to have AOMP 
provide this in a resource file configuration. I think @ronlieb has a working 
version of that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147666

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


[PATCH] D147611: [RISCV][MC] Add support for experimental Zvfbfmin extension

2023-04-05 Thread Craig Topper via Phabricator via cfe-commits
craig.topper accepted this revision.
craig.topper added a comment.
This revision is now accepted and ready to land.

LGTM


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

https://reviews.llvm.org/D147611

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


[PATCH] D147673: [Clang] Improve designated inits diagnostic location

2023-04-05 Thread Bill Wendling via Phabricator via cfe-commits
void created this revision.
void added a reviewer: rsmith.
Herald added a project: All.
void requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

A "null" designator won't have a valid location. Try to approximate this
location as best we can in that situation.

Closes 61118
Closes 46132


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D147673

Files:
  clang/lib/Sema/SemaInit.cpp
  clang/test/SemaCXX/cxx2b-designated-initializers.cpp


Index: clang/test/SemaCXX/cxx2b-designated-initializers.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/cxx2b-designated-initializers.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -std=c++2b -fsyntax-only -verify %s
+
+namespace PR61118 {
+
+union S {
+  struct {
+int a;
+  };
+}; 
+
+void f(int x, auto) {
+  const S result { // expected-error {{field designator (null) does not refer 
to any field in type 'const S'}}
+.a = x
+  };
+}
+
+void g(void) {
+  f(0, 0); // expected-note {{in instantiation of function template 
specialization 'PR61118::f' requested here}}
+}
+
+} // end namespace PR61118
Index: clang/lib/Sema/SemaInit.cpp
===
--- clang/lib/Sema/SemaInit.cpp
+++ clang/lib/Sema/SemaInit.cpp
@@ -2641,8 +2641,13 @@
   hadError = true;
 } else {
   // Typo correction didn't find anything.
-  SemaRef.Diag(D->getFieldLoc(), diag::err_field_designator_unknown)
-<< FieldName << CurrentObjectType;
+  SourceLocation Loc = D->getFieldLoc();
+  if (Loc.isInvalid())
+// This could happen with a "null" designator (i.e. an anonymous
+// union/struct). Do our best to approximate the location.
+Loc = IList->getBeginLoc();
+  SemaRef.Diag(Loc, diag::err_field_designator_unknown)
+<< FieldName << CurrentObjectType << DIE->getSourceRange();
   ++Index;
   return true;
 }


Index: clang/test/SemaCXX/cxx2b-designated-initializers.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/cxx2b-designated-initializers.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -std=c++2b -fsyntax-only -verify %s
+
+namespace PR61118 {
+
+union S {
+  struct {
+int a;
+  };
+}; 
+
+void f(int x, auto) {
+  const S result { // expected-error {{field designator (null) does not refer to any field in type 'const S'}}
+.a = x
+  };
+}
+
+void g(void) {
+  f(0, 0); // expected-note {{in instantiation of function template specialization 'PR61118::f' requested here}}
+}
+
+} // end namespace PR61118
Index: clang/lib/Sema/SemaInit.cpp
===
--- clang/lib/Sema/SemaInit.cpp
+++ clang/lib/Sema/SemaInit.cpp
@@ -2641,8 +2641,13 @@
   hadError = true;
 } else {
   // Typo correction didn't find anything.
-  SemaRef.Diag(D->getFieldLoc(), diag::err_field_designator_unknown)
-<< FieldName << CurrentObjectType;
+  SourceLocation Loc = D->getFieldLoc();
+  if (Loc.isInvalid())
+// This could happen with a "null" designator (i.e. an anonymous
+// union/struct). Do our best to approximate the location.
+Loc = IList->getBeginLoc();
+  SemaRef.Diag(Loc, diag::err_field_designator_unknown)
+<< FieldName << CurrentObjectType << DIE->getSourceRange();
   ++Index;
   return true;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D146686: [Driver] Fix rpath for compiler-rt

2023-04-05 Thread Yaxun Liu via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
yaxunl marked an inline comment as done.
Closed by commit rG5f91c747763c: [Driver] Fix rpath for compiler-rt (authored 
by yaxunl).
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D146686?vs=508823=511238#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146686

Files:
  clang/include/clang/Driver/ToolChain.h
  clang/lib/Driver/ToolChain.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Driver/ToolChains/OHOS.cpp
  clang/lib/Driver/ToolChains/OHOS.h
  clang/lib/Driver/ToolChains/VEToolchain.cpp
  clang/test/Driver/arch-specific-libdir-rpath.c

Index: clang/test/Driver/arch-specific-libdir-rpath.c
===
--- clang/test/Driver/arch-specific-libdir-rpath.c
+++ clang/test/Driver/arch-specific-libdir-rpath.c
@@ -75,6 +75,15 @@
 // RUN: -frtlib-add-rpath 2>&1 \
 // RUN:   | FileCheck --check-prefixes=RESDIR,NO-LIBPATH,NO-RPATH %s
 
+// Test that the driver adds an per-target arch-specific subdirectory in
+// {RESOURCE_DIR}/lib/{triple} to the linker search path and to '-rpath'
+//
+// RUN: %clang %s -### 2>&1 --target=x86_64-linux-gnu \
+// RUN: -fsanitize=address -shared-libasan \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
+// RUN: -frtlib-add-rpath \
+// RUN:   | FileCheck --check-prefixes=PERTARGET %s
+
 // RESDIR: "-resource-dir" "[[RESDIR:[^"]*]]"
 //
 // LIBPATH-X86_64: -L[[RESDIR]]{{(/|)lib(/|)linux(/|)x86_64}}
@@ -88,3 +97,7 @@
 //
 // NO-LIBPATH-NOT: "-L{{[^"]*Inputs(/|)resource_dir}}"
 // NO-RPATH-NOT:   "-rpath" {{.*(/|)Inputs(/|)resource_dir}}
+
+// PERTARGET: "-resource-dir" "[[PTRESDIR:[^"]*]]"
+// PERTARGET: -L[[PTRESDIR]]{{(/|)lib(/|)x86_64-unknown-linux-gnu}}
+// PERTARGET:   "-rpath" "[[PTRESDIR]]{{(/|)lib(/|)x86_64-unknown-linux-gnu}}"
Index: clang/lib/Driver/ToolChains/VEToolchain.cpp
===
--- clang/lib/Driver/ToolChains/VEToolchain.cpp
+++ clang/lib/Driver/ToolChains/VEToolchain.cpp
@@ -33,7 +33,7 @@
   // These are OK.
 
   // Default file paths are following:
-  //   ${RESOURCEDIR}/lib/linux/ve, (== getArchSpecificLibPath)
+  //   ${RESOURCEDIR}/lib/linux/ve, (== getArchSpecificLibPaths)
   //   /lib/../lib64,
   //   /usr/lib/../lib64,
   //   ${BINPATH}/../lib,
@@ -45,12 +45,13 @@
   getFilePaths().clear();
 
   // Add library directories:
-  //   ${BINPATH}/../lib/ve-unknown-linux-gnu, (== getStdlibPath)
-  //   ${RESOURCEDIR}/lib/linux/ve, (== getArchSpecificLibPath)
+  //   ${BINPATH}/../lib/ve-unknown-linux-gnu, (== getStdlibPaths)
+  //   ${RESOURCEDIR}/lib/linux/ve, (== getArchSpecificLibPaths)
   //   ${SYSROOT}/opt/nec/ve/lib,
   for (auto  : getStdlibPaths())
 getFilePaths().push_back(std::move(Path));
-  getFilePaths().push_back(getArchSpecificLibPath());
+  for (const auto  : getArchSpecificLibPaths())
+getFilePaths().push_back(Path);
   getFilePaths().push_back(computeSysRoot() + "/opt/nec/ve/lib");
 }
 
Index: clang/lib/Driver/ToolChains/OHOS.h
===
--- clang/lib/Driver/ToolChains/OHOS.h
+++ clang/lib/Driver/ToolChains/OHOS.h
@@ -83,7 +83,8 @@
   SanitizerMask getSupportedSanitizers() const override;
   void addProfileRTLibs(const llvm::opt::ArgList ,
  llvm::opt::ArgStringList ) const override;
-  std::string getArchSpecificLibPath() const override;
+  path_list getArchSpecificLibPaths() const override;
+
 private:
   Multilib SelectedMultilib;
 };
Index: clang/lib/Driver/ToolChains/OHOS.cpp
===
--- clang/lib/Driver/ToolChains/OHOS.cpp
+++ clang/lib/Driver/ToolChains/OHOS.cpp
@@ -139,9 +139,9 @@
   SelectedMultilib = Result.SelectedMultilib;
 
   getFilePaths().clear();
-  std::string CandidateLibPath = getArchSpecificLibPath();
-  if (getVFS().exists(CandidateLibPath))
-getFilePaths().push_back(CandidateLibPath);
+  for (const auto  : getArchSpecificLibPaths())
+if (getVFS().exists(CandidateLibPath))
+  getFilePaths().push_back(CandidateLibPath);
 
   getLibraryPaths().clear();
   for (auto  : getRuntimePaths())
@@ -401,9 +401,12 @@
   ToolChain::addProfileRTLibs(Args, CmdArgs);
 }
 
-std::string OHOS::getArchSpecificLibPath() const {
+ToolChain::path_list OHOS::getArchSpecificLibPaths() const {
+  ToolChain::path_list Paths;
   llvm::Triple Triple = getTriple();
-  return makePath({getDriver().ResourceDir, "lib", getMultiarchTriple(Triple)});
+  Paths.push_back(
+  makePath({getDriver().ResourceDir, "lib", getMultiarchTriple(Triple)}));
+  return Paths;
 }
 
 ToolChain::UnwindLibType OHOS::GetUnwindLibType(const llvm::opt::ArgList ) 

[clang] 5f91c74 - [Driver] Fix rpath for compiler-rt

2023-04-05 Thread Yaxun Liu via cfe-commits

Author: Yaxun (Sam) Liu
Date: 2023-04-05T20:14:53-04:00
New Revision: 5f91c747763c20a63f3d6156fced03b474f842a1

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

LOG: [Driver] Fix rpath for compiler-rt

The compiler-rt library path can be either {resource_dir}/lib/{triple}
or {resource_dir}/lib/{OS}/{arch} depending on whether
LLVM_ENABLE_PER_TARGET_RUNTIME_DIR_default is ON or OFF.
Currently, the rpath added by -rtlib-add-rpath only adds
the latter. This patch checks both and adds the one that exists.

Reviewed by: Fangrui Song

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

Added: 


Modified: 
clang/include/clang/Driver/ToolChain.h
clang/lib/Driver/ToolChain.cpp
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/lib/Driver/ToolChains/OHOS.cpp
clang/lib/Driver/ToolChains/OHOS.h
clang/lib/Driver/ToolChains/VEToolchain.cpp
clang/test/Driver/arch-specific-libdir-rpath.c

Removed: 




diff  --git a/clang/include/clang/Driver/ToolChain.h 
b/clang/include/clang/Driver/ToolChain.h
index e969edfc4e866..a4346a1bab8d2 100644
--- a/clang/include/clang/Driver/ToolChain.h
+++ b/clang/include/clang/Driver/ToolChain.h
@@ -492,9 +492,9 @@ class ToolChain {
   // Returns target specific standard library paths.
   path_list getStdlibPaths() const;
 
-  // Returns /lib//.  This is used by runtimes (such
-  // as OpenMP) to find arch-specific libraries.
-  virtual std::string getArchSpecificLibPath() const;
+  // Returns /lib// or /lib/.
+  // This is used by runtimes (such as OpenMP) to find arch-specific libraries.
+  virtual path_list getArchSpecificLibPaths() const;
 
   // Returns  part of above.
   virtual StringRef getOSLibName() const;

diff  --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
index 2dba975a5a8fa..27b66aa81ce2d 100644
--- a/clang/lib/Driver/ToolChain.cpp
+++ b/clang/lib/Driver/ToolChain.cpp
@@ -86,7 +86,8 @@ ToolChain::ToolChain(const Driver , const llvm::Triple ,
 addIfExists(getLibraryPaths(), Path);
   for (const auto  : getStdlibPaths())
 addIfExists(getFilePaths(), Path);
-  addIfExists(getFilePaths(), getArchSpecificLibPath());
+  for (const auto  : getArchSpecificLibPaths())
+addIfExists(getFilePaths(), Path);
 }
 
 llvm::Expected>
@@ -621,11 +622,20 @@ ToolChain::path_list ToolChain::getStdlibPaths() const {
   return Paths;
 }
 
-std::string ToolChain::getArchSpecificLibPath() const {
-  SmallString<128> Path(getDriver().ResourceDir);
-  llvm::sys::path::append(Path, "lib", getOSLibName(),
-  llvm::Triple::getArchTypeName(getArch()));
-  return std::string(Path.str());
+ToolChain::path_list ToolChain::getArchSpecificLibPaths() const {
+  path_list Paths;
+
+  auto AddPath = [&](const ArrayRef ) {
+SmallString<128> Path(getDriver().ResourceDir);
+llvm::sys::path::append(Path, "lib");
+for (auto  : SS)
+  llvm::sys::path::append(Path, S);
+Paths.push_back(std::string(Path.str()));
+  };
+
+  AddPath({getTriple().str()});
+  AddPath({getOSLibName(), llvm::Triple::getArchTypeName(getArch())});
+  return Paths;
 }
 
 bool ToolChain::needsProfileRT(const ArgList ) {

diff  --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 020ae8a98c7c7..6190c9d65ddbd 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -818,10 +818,11 @@ void tools::addArchSpecificRPath(const ToolChain , 
const ArgList ,
 options::OPT_fno_rtlib_add_rpath, DefaultValue))
 return;
 
-  std::string CandidateRPath = TC.getArchSpecificLibPath();
-  if (TC.getVFS().exists(CandidateRPath)) {
-CmdArgs.push_back("-rpath");
-CmdArgs.push_back(Args.MakeArgString(CandidateRPath));
+  for (const auto  : TC.getArchSpecificLibPaths()) {
+if (TC.getVFS().exists(CandidateRPath)) {
+  CmdArgs.push_back("-rpath");
+  CmdArgs.push_back(Args.MakeArgString(CandidateRPath));
+}
   }
 }
 

diff  --git a/clang/lib/Driver/ToolChains/OHOS.cpp 
b/clang/lib/Driver/ToolChains/OHOS.cpp
index d25c293716430..ea0c1c12541ca 100644
--- a/clang/lib/Driver/ToolChains/OHOS.cpp
+++ b/clang/lib/Driver/ToolChains/OHOS.cpp
@@ -139,9 +139,9 @@ OHOS::OHOS(const Driver , const llvm::Triple , 
const ArgList )
   SelectedMultilib = Result.SelectedMultilib;
 
   getFilePaths().clear();
-  std::string CandidateLibPath = getArchSpecificLibPath();
-  if (getVFS().exists(CandidateLibPath))
-getFilePaths().push_back(CandidateLibPath);
+  for (const auto  : getArchSpecificLibPaths())
+if (getVFS().exists(CandidateLibPath))
+  getFilePaths().push_back(CandidateLibPath);
 
   getLibraryPaths().clear();
   for (auto  : getRuntimePaths())
@@ -401,9 +401,12 @@ void 

[PATCH] D147612: [RISCV][MC] Add support for experimental Zvfbfwma extension

2023-04-05 Thread Craig Topper via Phabricator via cfe-commits
craig.topper accepted this revision.
craig.topper added a comment.
This revision is now accepted and ready to land.

LGTM


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

https://reviews.llvm.org/D147612

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


[PATCH] D146463: [CodeGen][RISCV] Change Shadow Call Stack Register to X3

2023-04-05 Thread Roland McGrath via Phabricator via cfe-commits
mcgrathr added a comment.

I don't see changes here to make the Fuchsia & Android targets stop doing 
implicit `-ffixed-x18` and to make them start doing implicit 
`-msmall-data-limit=0` for non-PIC modes.




Comment at: clang/lib/Driver/SanitizerArgs.cpp:546
 
-  if ((Kinds & SanitizerKind::ShadowCallStack) &&
-  ((TC.getTriple().isAArch64() &&
-!llvm::AArch64::isX18ReservedByDefault(TC.getTriple())) ||
-   (TC.getTriple().isRISCV() &&
-!llvm::RISCV::isX18ReservedByDefault(TC.getTriple( &&
+  if ((Kinds & SanitizerKind::ShadowCallStack) && TC.getTriple().isAArch64() &&
+  !llvm::AArch64::isX18ReservedByDefault(TC.getTriple()) &&

For RISC-V this needs a similar check that the equivalent of 
`-msmall-data-limit=0` is in force (that's the default under `-fPIC` but not 
other modes).




Comment at: llvm/test/CodeGen/RISCV/reserved-regs.ll:60
 
-; RUN: llc -mtriple=riscv64-fuchsia -verify-machineinstrs < %s | FileCheck %s 
-check-prefix=X18
-; RUN: llc -mtriple=riscv64-linux-android -verify-machineinstrs < %s | 
FileCheck %s -check-prefix=X18
+;; Check that targets that reserve a register by default reserve the correct 
registers
+;; Android and Fuchsia reserve the ShadowCallStack register (gp/x3) by default.

gp is a fixed register for all RISC-V targets. What's important to check is 
that Fuchsia and Android disable the small-data-section behavior.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146463

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


[PATCH] D147610: [RISCV][MC] Add support for experimental Zfbfmin extension

2023-04-05 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

LGTM


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

https://reviews.llvm.org/D147610

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


[PATCH] D128440: [WebAssembly] Initial support for reference type funcref in clang

2023-04-05 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added inline comments.
Herald added a project: clang-format.
Herald added reviewers: rymiel, HazardyKnusperkeks, owenpan, MyDeveloperDay.



Comment at: clang/lib/Format/FormatToken.h:615
tok::kw__Null_unspecified, tok::kw___ptr32, tok::kw___ptr64,
-   TT_AttributeMacro);
+   tok::kw___funcref, TT_AttributeMacro);
   }

Is there a unit test in clang format for this change?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128440

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


[PATCH] D147580: [Clang][NFC] Refactor "Designators" to be more similar

2023-04-05 Thread Bill Wendling 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 rGbfee6f114236: [Clang][NFC] Refactor Designators 
to be more similar (authored by void).

Changed prior to commit:
  https://reviews.llvm.org/D147580?vs=511215=511225#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147580

Files:
  clang/include/clang/AST/Expr.h
  clang/include/clang/Sema/Designator.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/Expr.cpp
  clang/lib/AST/StmtPrinter.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/Parse/ParseInit.cpp
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp

Index: clang/lib/Serialization/ASTWriterStmt.cpp
===
--- clang/lib/Serialization/ASTWriterStmt.cpp
+++ clang/lib/Serialization/ASTWriterStmt.cpp
@@ -1098,13 +1098,13 @@
   Record.AddSourceLocation(D.getFieldLoc());
 } else if (D.isArrayDesignator()) {
   Record.push_back(serialization::DESIG_ARRAY);
-  Record.push_back(D.getFirstExprIndex());
+  Record.push_back(D.getArrayIndex());
   Record.AddSourceLocation(D.getLBracketLoc());
   Record.AddSourceLocation(D.getRBracketLoc());
 } else {
   assert(D.isArrayRangeDesignator() && "Unknown designator");
   Record.push_back(serialization::DESIG_ARRAY_RANGE);
-  Record.push_back(D.getFirstExprIndex());
+  Record.push_back(D.getArrayIndex());
   Record.AddSourceLocation(D.getLBracketLoc());
   Record.AddSourceLocation(D.getEllipsisLoc());
   Record.AddSourceLocation(D.getRBracketLoc());
Index: clang/lib/Serialization/ASTReaderStmt.cpp
===
--- clang/lib/Serialization/ASTReaderStmt.cpp
+++ clang/lib/Serialization/ASTReaderStmt.cpp
@@ -1216,8 +1216,8 @@
   auto *Field = readDeclAs();
   SourceLocation DotLoc = readSourceLocation();
   SourceLocation FieldLoc = readSourceLocation();
-  Designators.push_back(Designator(Field->getIdentifier(), DotLoc,
-   FieldLoc));
+  Designators.push_back(Designator::CreateFieldDesignator(
+  Field->getIdentifier(), DotLoc, FieldLoc));
   Designators.back().setField(Field);
   break;
 }
@@ -1226,7 +1226,8 @@
   const IdentifierInfo *Name = Record.readIdentifier();
   SourceLocation DotLoc = readSourceLocation();
   SourceLocation FieldLoc = readSourceLocation();
-  Designators.push_back(Designator(Name, DotLoc, FieldLoc));
+  Designators.push_back(Designator::CreateFieldDesignator(Name, DotLoc,
+  FieldLoc));
   break;
 }
 
@@ -1234,7 +1235,9 @@
   unsigned Index = Record.readInt();
   SourceLocation LBracketLoc = readSourceLocation();
   SourceLocation RBracketLoc = readSourceLocation();
-  Designators.push_back(Designator(Index, LBracketLoc, RBracketLoc));
+  Designators.push_back(Designator::CreateArrayDesignator(Index,
+  LBracketLoc,
+  RBracketLoc));
   break;
 }
 
@@ -1243,8 +1246,8 @@
   SourceLocation LBracketLoc = readSourceLocation();
   SourceLocation EllipsisLoc = readSourceLocation();
   SourceLocation RBracketLoc = readSourceLocation();
-  Designators.push_back(Designator(Index, LBracketLoc, EllipsisLoc,
-   RBracketLoc));
+  Designators.push_back(Designator::CreateArrayRangeDesignator(
+  Index, LBracketLoc, EllipsisLoc, RBracketLoc));
   break;
 }
 }
Index: clang/lib/Sema/TreeTransform.h
===
--- clang/lib/Sema/TreeTransform.h
+++ clang/lib/Sema/TreeTransform.h
@@ -11661,9 +11661,8 @@
   bool ExprChanged = false;
   for (const DesignatedInitExpr::Designator  : E->designators()) {
 if (D.isFieldDesignator()) {
-  Desig.AddDesignator(Designator::getField(D.getFieldName(),
-   D.getDotLoc(),
-   D.getFieldLoc()));
+  Desig.AddDesignator(Designator::CreateFieldDesignator(
+  D.getFieldName(), D.getDotLoc(), D.getFieldLoc()));
   if (D.getField()) {
 FieldDecl *Field = cast_or_null(
 getDerived().TransformDecl(D.getFieldLoc(), D.getField()));
@@ -11686,7 +11685,7 @@
 return ExprError();
 
   Desig.AddDesignator(
-  Designator::getArray(Index.get(), D.getLBracketLoc()));
+  Designator::CreateArrayDesignator(Index.get(), D.getLBracketLoc()));
 
   ExprChanged = 

[clang] bfee6f1 - [Clang][NFC] Refactor "Designators" to be more similar

2023-04-05 Thread Bill Wendling via cfe-commits

Author: Bill Wendling
Date: 2023-04-05T15:46:40-07:00
New Revision: bfee6f1142368e522d09551930ef90f4e6be1f42

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

LOG: [Clang][NFC] Refactor "Designators" to be more similar

This makes the two interfaces for designators more similar so that it's
easier to merge them together in a future refactoring.

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

Added: 


Modified: 
clang/include/clang/AST/Expr.h
clang/include/clang/Sema/Designator.h
clang/lib/AST/ASTImporter.cpp
clang/lib/AST/Expr.cpp
clang/lib/AST/StmtPrinter.cpp
clang/lib/AST/StmtProfile.cpp
clang/lib/Parse/ParseInit.cpp
clang/lib/Sema/SemaCodeComplete.cpp
clang/lib/Sema/SemaInit.cpp
clang/lib/Sema/TreeTransform.h
clang/lib/Serialization/ASTReaderStmt.cpp
clang/lib/Serialization/ASTWriterStmt.cpp

Removed: 




diff  --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h
index d2a8f0349b257..65476322c77df 100644
--- a/clang/include/clang/AST/Expr.h
+++ b/clang/include/clang/AST/Expr.h
@@ -5071,37 +5071,6 @@ class DesignatedInitExpr final
   NumDesignators(0), NumSubExprs(NumSubExprs), Designators(nullptr) { }
 
 public:
-  /// A field designator, e.g., ".x".
-  struct FieldDesignator {
-/// Refers to the field that is being initialized. The low bit
-/// of this field determines whether this is actually a pointer
-/// to an IdentifierInfo (if 1) or a FieldDecl (if 0). When
-/// initially constructed, a field designator will store an
-/// IdentifierInfo*. After semantic analysis has resolved that
-/// name, the field designator will instead store a FieldDecl*.
-uintptr_t NameOrField;
-
-/// The location of the '.' in the designated initializer.
-SourceLocation DotLoc;
-
-/// The location of the field name in the designated initializer.
-SourceLocation FieldLoc;
-  };
-
-  /// An array or GNU array-range designator, e.g., "[9]" or "[10..15]".
-  struct ArrayOrRangeDesignator {
-/// Location of the first index expression within the designated
-/// initializer expression's list of subexpressions.
-unsigned Index;
-/// The location of the '[' starting the array range designator.
-SourceLocation LBracketLoc;
-/// The location of the ellipsis separating the start and end
-/// indices. Only valid for GNU array-range designators.
-SourceLocation EllipsisLoc;
-/// The location of the ']' terminating the array range designator.
-SourceLocation RBracketLoc;
-  };
-
   /// Represents a single C99 designator.
   ///
   /// @todo This class is infuriatingly similar to clang::Designator,
@@ -5109,118 +5078,184 @@ class DesignatedInitExpr final
   /// keep us from reusing it. Try harder, later, to rectify these
   /// 
diff erences.
   class Designator {
+/// A field designator, e.g., ".x".
+struct FieldDesignatorInfo {
+  /// Refers to the field that is being initialized. The low bit
+  /// of this field determines whether this is actually a pointer
+  /// to an IdentifierInfo (if 1) or a FieldDecl (if 0). When
+  /// initially constructed, a field designator will store an
+  /// IdentifierInfo*. After semantic analysis has resolved that
+  /// name, the field designator will instead store a FieldDecl*.
+  uintptr_t NameOrField;
+
+  /// The location of the '.' in the designated initializer.
+  SourceLocation DotLoc;
+
+  /// The location of the field name in the designated initializer.
+  SourceLocation FieldLoc;
+
+  FieldDesignatorInfo(const IdentifierInfo *II, SourceLocation DotLoc,
+  SourceLocation FieldLoc)
+  : NameOrField(reinterpret_cast(II) | 0x1), DotLoc(DotLoc),
+FieldLoc(FieldLoc) {}
+};
+
+/// An array or GNU array-range designator, e.g., "[9]" or "[10...15]".
+struct ArrayOrRangeDesignatorInfo {
+  /// Location of the first index expression within the designated
+  /// initializer expression's list of subexpressions.
+  unsigned Index;
+
+  /// The location of the '[' starting the array range designator.
+  SourceLocation LBracketLoc;
+
+  /// The location of the ellipsis separating the start and end
+  /// indices. Only valid for GNU array-range designators.
+  SourceLocation EllipsisLoc;
+
+  /// The location of the ']' terminating the array range designator.
+  SourceLocation RBracketLoc;
+
+  ArrayOrRangeDesignatorInfo(unsigned Index, SourceLocation LBracketLoc,
+ SourceLocation RBracketLoc)
+  : Index(Index), LBracketLoc(LBracketLoc), RBracketLoc(RBracketLoc) {}
+
+  ArrayOrRangeDesignatorInfo(unsigned Index,
+

[clang] 3242934 - Lazily deserialize default member initializers.

2023-04-05 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2023-04-05T15:46:13-07:00
New Revision: 32429341910d0a48336215be13c7c9140dd26da4

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

LOG: Lazily deserialize default member initializers.

This is important to break deserialization cycles, where a lambda in a
default member initializer can refer to the field as its context
declaration, and the initializer of the field can refer back to the
lambda.

This is a follow-up to bc73ef0031b5, which applied the same fix to
variable declarations for the same reason.

Added: 


Modified: 
clang/include/clang/AST/Decl.h
clang/lib/AST/Decl.cpp
clang/lib/Serialization/ASTCommon.cpp
clang/lib/Serialization/ASTReaderDecl.cpp
clang/lib/Serialization/ASTWriterDecl.cpp
clang/test/Modules/merge-lambdas.cpp

Removed: 




diff  --git a/clang/include/clang/AST/Decl.h b/clang/include/clang/AST/Decl.h
index fde957320ab4b..650baf56414c7 100644
--- a/clang/include/clang/AST/Decl.h
+++ b/clang/include/clang/AST/Decl.h
@@ -2943,11 +2943,7 @@ class FunctionDecl : public DeclaratorDecl,
 
 /// Represents a member of a struct/union/class.
 class FieldDecl : public DeclaratorDecl, public Mergeable {
-  unsigned BitField : 1;
-  unsigned Mutable : 1;
-  mutable unsigned CachedFieldIndex : 30;
-
-  /// The kinds of value we can store in InitializerOrBitWidth.
+  /// The kinds of value we can store in StorageKind.
   ///
   /// Note that this is compatible with InClassInitStyle except for
   /// ISK_CapturedVLAType.
@@ -2970,10 +2966,15 @@ class FieldDecl : public DeclaratorDecl, public 
Mergeable {
 ISK_CapturedVLAType,
   };
 
+  unsigned BitField : 1;
+  unsigned Mutable : 1;
+  unsigned StorageKind : 2;
+  mutable unsigned CachedFieldIndex : 28;
+
   /// If this is a bitfield with a default member initializer, this
   /// structure is used to represent the two expressions.
-  struct InitAndBitWidth {
-Expr *Init;
+  struct InitAndBitWidthStorage {
+LazyDeclStmtPtr Init;
 Expr *BitWidth;
   };
 
@@ -2986,16 +2987,25 @@ class FieldDecl : public DeclaratorDecl, public 
Mergeable {
   /// and attached.
   // FIXME: Tail-allocate this to reduce the size of FieldDecl in the
   // overwhelmingly common case that we have none of these things.
-  llvm::PointerIntPair InitStorage;
+  union {
+// Active member if ISK is not ISK_CapturedVLAType and BitField is false.
+LazyDeclStmtPtr Init;
+// Active member if ISK is ISK_NoInit and BitField is true.
+Expr *BitWidth;
+// Active member if ISK is ISK_InClass*Init and BitField is true.
+InitAndBitWidthStorage *InitAndBitWidth;
+// Active member if ISK is ISK_CapturedVLAType.
+const VariableArrayType *CapturedVLAType;
+  };
 
 protected:
   FieldDecl(Kind DK, DeclContext *DC, SourceLocation StartLoc,
-SourceLocation IdLoc, IdentifierInfo *Id,
-QualType T, TypeSourceInfo *TInfo, Expr *BW, bool Mutable,
+SourceLocation IdLoc, IdentifierInfo *Id, QualType T,
+TypeSourceInfo *TInfo, Expr *BW, bool Mutable,
 InClassInitStyle InitStyle)
-: DeclaratorDecl(DK, DC, IdLoc, Id, T, TInfo, StartLoc),
-  BitField(false), Mutable(Mutable), CachedFieldIndex(0),
-  InitStorage(nullptr, (InitStorageKind) InitStyle) {
+  : DeclaratorDecl(DK, DC, IdLoc, Id, T, TInfo, StartLoc), BitField(false),
+Mutable(Mutable), StorageKind((InitStorageKind)InitStyle),
+CachedFieldIndex(0), Init() {
 if (BW)
   setBitWidth(BW);
   }
@@ -3034,10 +3044,7 @@ class FieldDecl : public DeclaratorDecl, public 
Mergeable {
   Expr *getBitWidth() const {
 if (!BitField)
   return nullptr;
-void *Ptr = InitStorage.getPointer();
-if (getInClassInitStyle())
-  return static_cast(Ptr)->BitWidth;
-return static_cast(Ptr);
+return hasInClassInitializer() ? InitAndBitWidth->BitWidth : BitWidth;
   }
 
   unsigned getBitWidthValue(const ASTContext ) const;
@@ -3048,11 +3055,11 @@ class FieldDecl : public DeclaratorDecl, public 
Mergeable {
 assert(!hasCapturedVLAType() && !BitField &&
"bit width or captured type already set");
 assert(Width && "no bit width specified");
-InitStorage.setPointer(
-InitStorage.getInt()
-? new (getASTContext())
-  InitAndBitWidth{getInClassInitializer(), Width}
-: static_cast(Width));
+if (hasInClassInitializer())
+  InitAndBitWidth =
+  new (getASTContext()) InitAndBitWidthStorage{Init, Width};
+else
+  BitWidth = Width;
 BitField = true;
   }
 
@@ -3060,7 +3067,11 @@ class FieldDecl : public DeclaratorDecl, public 
Mergeable {
   // Note: used by some clients (i.e., do not remove it).
   void removeBitWidth() {
 

[PATCH] D143128: [-Wunsafe-buffer-usage] Fix-Its transforming `[any]` to `()[any]`

2023-04-05 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 added a comment.

In D143128#4245112 , @DavidSpickett 
wrote:

> I've reverted this, please try to fix the test then reland.
>
> The full test output can be downloaded from the buildbot page, if you need 
> any more information let me know.

Thank you @DavidSpickett for catching this issue and reverting the patch for 
me.  I have added a specific target triple for the test and re-laned it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143128

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


[PATCH] D146463: [CodeGen][RISCV] Change Shadow Call Stack Register to X3

2023-04-05 Thread Craig Topper via Phabricator via cfe-commits
craig.topper accepted this revision.
craig.topper added a comment.

LGTM other than that one comment.




Comment at: llvm/lib/Target/RISCV/RISCVSubtarget.cpp:86
   InstrInfo(*this), RegInfo(getHwMode()), TLInfo(TM, *this) {
-  if (RISCV::isX18ReservedByDefault(TT))
-UserReservedRegister.set(RISCV::X18);
 
   CallLoweringInfo.reset(new RISCVCallLowering(*getTargetLowering()));

Drop the blank line here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146463

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


[PATCH] D147546: [PS4][clang] Fix the format of the LTO debug options passed to orbis-ld

2023-04-05 Thread Matthew Voss via Phabricator via cfe-commits
ormris added a comment.

Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147546

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


[PATCH] D142907: LangRef: Add "dynamic" option to "denormal-fp-math"

2023-04-05 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.

ping


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

https://reviews.llvm.org/D142907

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


[PATCH] D147666: [OPENMP] Adds /lib to rpath to avoid need to set LD_LIBRARY_PATH to find plugins.

2023-04-05 Thread Greg Rodgers via Phabricator via cfe-commits
gregrodgers created this revision.
Herald added subscribers: sunshaoce, guansong, yaxunl.
Herald added a project: All.
gregrodgers requested review of this revision.
Herald added subscribers: cfe-commits, jplehr, sstefan1, MaskRay.
Herald added a reviewer: jdoerfert.
Herald added a project: clang.

Currently, The user of an OpenMP application needs to set LD_LIBRARY_PATH to 
the directory
that contains the offload plugins. This change adds the rpath for OpenMP 
applications.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D147666

Files:
  clang/lib/Driver/ToolChains/CommonArgs.cpp


Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -813,7 +813,9 @@
  ArgStringList ) {
   // Enable -frtlib-add-rpath by default for the case of VE.
   const bool IsVE = TC.getTriple().isVE();
-  bool DefaultValue = IsVE;
+  const bool IsOpenMP = (TC.getDriver().getOpenMPRuntime(Args)
+ != Driver::OMPRT_Unknown);
+  bool DefaultValue = IsVE || IsOpenMP ;
   if (!Args.hasFlag(options::OPT_frtlib_add_rpath,
 options::OPT_fno_rtlib_add_rpath, DefaultValue))
 return;
@@ -822,6 +824,16 @@
   if (TC.getVFS().exists(CandidateRPath)) {
 CmdArgs.push_back("-rpath");
 CmdArgs.push_back(Args.MakeArgString(CandidateRPath));
+  } else {
+if (IsOpenMP) {
+  SmallString<256> TopLibPath =
+llvm::sys::path::parent_path(TC.getDriver().Dir);
+  llvm::sys::path::append(TopLibPath, "lib");
+  if (TC.getVFS().exists(TopLibPath)) {
+CmdArgs.push_back("-rpath");
+CmdArgs.push_back(Args.MakeArgString(TopLibPath));
+  }
+}
   }
 }
 


Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -813,7 +813,9 @@
  ArgStringList ) {
   // Enable -frtlib-add-rpath by default for the case of VE.
   const bool IsVE = TC.getTriple().isVE();
-  bool DefaultValue = IsVE;
+  const bool IsOpenMP = (TC.getDriver().getOpenMPRuntime(Args)
+		  != Driver::OMPRT_Unknown);
+  bool DefaultValue = IsVE || IsOpenMP ;
   if (!Args.hasFlag(options::OPT_frtlib_add_rpath,
 options::OPT_fno_rtlib_add_rpath, DefaultValue))
 return;
@@ -822,6 +824,16 @@
   if (TC.getVFS().exists(CandidateRPath)) {
 CmdArgs.push_back("-rpath");
 CmdArgs.push_back(Args.MakeArgString(CandidateRPath));
+  } else {
+if (IsOpenMP) {
+  SmallString<256> TopLibPath =
+llvm::sys::path::parent_path(TC.getDriver().Dir);
+  llvm::sys::path::append(TopLibPath, "lib");
+  if (TC.getVFS().exists(TopLibPath)) {
+CmdArgs.push_back("-rpath");
+CmdArgs.push_back(Args.MakeArgString(TopLibPath));
+  }
+}
   }
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D147655: Implement mangling rules for C++20 concepts and requires-expressions.

2023-04-05 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: clang/include/clang/AST/ExprConcepts.h:502
ArrayRef LocalParameters,
+   SourceLocation RParenLoc,
ArrayRef Requirements,

erichkeane wrote:
> Is this an unrelated change?  Are paren locations required for mangling?
`requires (params) { blah; }` has a different mangling from `requires { blah; 
}` -- in particular, the former introduces a new level of function parameters, 
so references to enclosing function parameters are numbered differently in the 
two. This applies even if `params` is empty or `void` (`requires () { ... }` 
and `requires (void) { ... }` are both valid).

We previously generated the same AST for `requires { ... }` and `requires () { 
... }`, which meant we couldn't mangle this correctly. Tracking the parens (or 
at least their existence) fixes that (and also improves the AST fidelity for 
tooling).



Comment at: clang/lib/AST/ItaniumMangle.cpp:5180
+NotPrimaryExpr();
+if (RE->getLParenLoc().isValid()) {
+  Out << "rQ";

erichkeane wrote:
> What is happening here? What are we deriving from the validity of the paren?  
> Or is this differentiating:
> 
> `requires (something)` vs `requires C` sorta thing?
Yes, the `rq` form is for requires expressions without a parameter list, and 
the `rQ` form is for requires expressions with a parameter list.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147655

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


[clang] ca6ceeb - Reland "[-Wunsafe-buffer-usage] Fix-Its transforming `[any]` to `()[any]`"

2023-04-05 Thread Ziqing Luo via cfe-commits

Author: Ziqing Luo
Date: 2023-04-05T14:54:03-07:00
New Revision: ca6ceeb0d6cd5b8545410d878c8d7bcce9538a3a

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

LOG: Reland "[-Wunsafe-buffer-usage] Fix-Its transforming `[any]` to 
`()[any]`"

This commit relands 87b5807d3802b932c06d83c4287014872aa2caab, where a
test fails on a few specific targets.  Now hard-code a target
for the test.

Added: 

clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-addressof-arraysubscript.cpp

Modified: 
clang/include/clang/Analysis/Analyses/UnsafeBufferUsage.h
clang/include/clang/Analysis/Analyses/UnsafeBufferUsageGadgets.def
clang/lib/Analysis/UnsafeBufferUsage.cpp

Removed: 




diff  --git a/clang/include/clang/Analysis/Analyses/UnsafeBufferUsage.h 
b/clang/include/clang/Analysis/Analyses/UnsafeBufferUsage.h
index 8957ab664ed93..f78cf2c57689c 100644
--- a/clang/include/clang/Analysis/Analyses/UnsafeBufferUsage.h
+++ b/clang/include/clang/Analysis/Analyses/UnsafeBufferUsage.h
@@ -43,7 +43,7 @@ class UnsafeBufferUsageHandler {
 
   /// Returns the text indicating that the user needs to provide input there:
   virtual std::string
-  getUserFillPlaceHolder(StringRef HintTextToUser = "placeholder") {
+  getUserFillPlaceHolder(StringRef HintTextToUser = "placeholder") const {
 std::string s = std::string("<# ");
 s += HintTextToUser;
 s += " #>";

diff  --git 
a/clang/include/clang/Analysis/Analyses/UnsafeBufferUsageGadgets.def 
b/clang/include/clang/Analysis/Analyses/UnsafeBufferUsageGadgets.def
index a8485682c1d1f..f0c99a767071f 100644
--- a/clang/include/clang/Analysis/Analyses/UnsafeBufferUsageGadgets.def
+++ b/clang/include/clang/Analysis/Analyses/UnsafeBufferUsageGadgets.def
@@ -30,9 +30,10 @@ WARNING_GADGET(Decrement)
 WARNING_GADGET(ArraySubscript)
 WARNING_GADGET(PointerArithmetic)
 WARNING_GADGET(UnsafeBufferUsageAttr)
-FIXABLE_GADGET(ULCArraySubscript)
+FIXABLE_GADGET(ULCArraySubscript)  // `DRE[any]` in an Unspecified 
Lvalue Context
 FIXABLE_GADGET(DerefSimplePtrArithFixable)
 FIXABLE_GADGET(PointerDereference)
+FIXABLE_GADGET(UPCAddressofArraySubscript) // '[any]' in an Unspecified 
Pointer Context
 
 #undef FIXABLE_GADGET
 #undef WARNING_GADGET

diff  --git a/clang/lib/Analysis/UnsafeBufferUsage.cpp 
b/clang/lib/Analysis/UnsafeBufferUsage.cpp
index 4a8358af68ec5..1ef276ab90444 100644
--- a/clang/lib/Analysis/UnsafeBufferUsage.cpp
+++ b/clang/lib/Analysis/UnsafeBufferUsage.cpp
@@ -15,6 +15,7 @@
 #include "llvm/ADT/SmallVector.h"
 #include 
 #include 
+#include 
 
 using namespace llvm;
 using namespace clang;
@@ -112,6 +113,15 @@ class MatchDescendantVisitor
   bool Matches;
 };
 
+// Because we're dealing with raw pointers, let's define what we mean by that.
+static auto hasPointerType() {
+return hasType(hasCanonicalType(pointerType()));
+}
+
+static auto hasArrayType() {
+return hasType(hasCanonicalType(arrayType()));
+}
+  
 AST_MATCHER_P(Stmt, forEveryDescendant, internal::Matcher, innerMatcher) 
{
   const DynTypedMatcher  = static_cast(innerMatcher);
 
@@ -145,6 +155,30 @@ static auto 
isInUnspecifiedLvalueContext(internal::Matcher innerMatcher) {
 ));
 // clang-format off
 }
+
+
+// Returns a matcher that matches any expression `e` such that `InnerMatcher`
+// matches `e` and `e` is in an Unspecified Pointer Context (UPC).
+static internal::Matcher
+isInUnspecifiedPointerContext(internal::Matcher InnerMatcher) {
+  // A UPC can be
+  // 1. an argument of a function call (except the callee has [[unsafe_...]]
+  // attribute), or
+  // 2. the operand of a cast operation; or
+  // ...
+  auto CallArgMatcher =
+  callExpr(hasAnyArgument(allOf(
+   hasPointerType() /* array also decays to pointer type*/,
+   InnerMatcher)),
+   unless(callee(functionDecl(hasAttr(attr::UnsafeBufferUsage);
+  auto CastOperandMatcher =
+  explicitCastExpr(hasCastKind(CastKind::CK_PointerToIntegral),
+   castSubExpr(allOf(hasPointerType(), InnerMatcher)));
+
+ return stmt(anyOf(CallArgMatcher, CastOperandMatcher));
+  // FIXME: any more cases? (UPC excludes the RHS of an assignment.  For now we
+  // don't have to check that.)
+}
 } // namespace clang::ast_matchers
 
 namespace {
@@ -159,15 +193,6 @@ using FixItList = SmallVector;
 class Strategy;
 } // namespace
 
-// Because we're dealing with raw pointers, let's define what we mean by that.
-static auto hasPointerType() {
-return hasType(hasCanonicalType(pointerType()));
-}
-
-static auto hasArrayType() {
-return hasType(hasCanonicalType(arrayType()));
-}
-
 namespace {
 /// Gadget is an individual operation in the code that may be of interest to
 /// this analysis. Each (non-abstract) subclass corresponds to a specific
@@ -502,6 

[PATCH] D147580: [Clang] Refactor "Designators" to be more similar [NFC]

2023-04-05 Thread Bill Wendling via Phabricator via cfe-commits
void updated this revision to Diff 511215.
void added a comment.

Rebase.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147580

Files:
  clang/include/clang/AST/Expr.h
  clang/include/clang/Sema/Designator.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/Expr.cpp
  clang/lib/AST/StmtPrinter.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/Parse/ParseInit.cpp
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp

Index: clang/lib/Serialization/ASTWriterStmt.cpp
===
--- clang/lib/Serialization/ASTWriterStmt.cpp
+++ clang/lib/Serialization/ASTWriterStmt.cpp
@@ -1098,13 +1098,13 @@
   Record.AddSourceLocation(D.getFieldLoc());
 } else if (D.isArrayDesignator()) {
   Record.push_back(serialization::DESIG_ARRAY);
-  Record.push_back(D.getFirstExprIndex());
+  Record.push_back(D.getArrayIndex());
   Record.AddSourceLocation(D.getLBracketLoc());
   Record.AddSourceLocation(D.getRBracketLoc());
 } else {
   assert(D.isArrayRangeDesignator() && "Unknown designator");
   Record.push_back(serialization::DESIG_ARRAY_RANGE);
-  Record.push_back(D.getFirstExprIndex());
+  Record.push_back(D.getArrayIndex());
   Record.AddSourceLocation(D.getLBracketLoc());
   Record.AddSourceLocation(D.getEllipsisLoc());
   Record.AddSourceLocation(D.getRBracketLoc());
Index: clang/lib/Serialization/ASTReaderStmt.cpp
===
--- clang/lib/Serialization/ASTReaderStmt.cpp
+++ clang/lib/Serialization/ASTReaderStmt.cpp
@@ -1216,8 +1216,8 @@
   auto *Field = readDeclAs();
   SourceLocation DotLoc = readSourceLocation();
   SourceLocation FieldLoc = readSourceLocation();
-  Designators.push_back(Designator(Field->getIdentifier(), DotLoc,
-   FieldLoc));
+  Designators.push_back(Designator::CreateFieldDesignator(
+  Field->getIdentifier(), DotLoc, FieldLoc));
   Designators.back().setField(Field);
   break;
 }
@@ -1226,7 +1226,8 @@
   const IdentifierInfo *Name = Record.readIdentifier();
   SourceLocation DotLoc = readSourceLocation();
   SourceLocation FieldLoc = readSourceLocation();
-  Designators.push_back(Designator(Name, DotLoc, FieldLoc));
+  Designators.push_back(Designator::CreateFieldDesignator(Name, DotLoc,
+  FieldLoc));
   break;
 }
 
@@ -1234,7 +1235,9 @@
   unsigned Index = Record.readInt();
   SourceLocation LBracketLoc = readSourceLocation();
   SourceLocation RBracketLoc = readSourceLocation();
-  Designators.push_back(Designator(Index, LBracketLoc, RBracketLoc));
+  Designators.push_back(Designator::CreateArrayDesignator(Index,
+  LBracketLoc,
+  RBracketLoc));
   break;
 }
 
@@ -1243,8 +1246,8 @@
   SourceLocation LBracketLoc = readSourceLocation();
   SourceLocation EllipsisLoc = readSourceLocation();
   SourceLocation RBracketLoc = readSourceLocation();
-  Designators.push_back(Designator(Index, LBracketLoc, EllipsisLoc,
-   RBracketLoc));
+  Designators.push_back(Designator::CreateArrayRangeDesignator(
+  Index, LBracketLoc, EllipsisLoc, RBracketLoc));
   break;
 }
 }
Index: clang/lib/Sema/TreeTransform.h
===
--- clang/lib/Sema/TreeTransform.h
+++ clang/lib/Sema/TreeTransform.h
@@ -11661,9 +11661,8 @@
   bool ExprChanged = false;
   for (const DesignatedInitExpr::Designator  : E->designators()) {
 if (D.isFieldDesignator()) {
-  Desig.AddDesignator(Designator::getField(D.getFieldName(),
-   D.getDotLoc(),
-   D.getFieldLoc()));
+  Desig.AddDesignator(Designator::CreateFieldDesignator(
+  D.getFieldName(), D.getDotLoc(), D.getFieldLoc()));
   if (D.getField()) {
 FieldDecl *Field = cast_or_null(
 getDerived().TransformDecl(D.getFieldLoc(), D.getField()));
@@ -11686,7 +11685,7 @@
 return ExprError();
 
   Desig.AddDesignator(
-  Designator::getArray(Index.get(), D.getLBracketLoc()));
+  Designator::CreateArrayDesignator(Index.get(), D.getLBracketLoc()));
 
   ExprChanged = ExprChanged || Init.get() != E->getArrayIndex(D);
   ArrayExprs.push_back(Index.get());
@@ -11703,10 +11702,8 @@
 if (End.isInvalid())
   return ExprError();
 
-Desig.AddDesignator(Designator::getArrayRange(Start.get(),
-   

[PATCH] D146042: [clang-format] Fix numerous issues with "LambdaBodyIndentation: OuterScope" option

2023-04-05 Thread Owen Pan 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 rG5c614bd88f12: [clang-format] Fix bugs with 
LambdaBodyIndentation: OuterScope (authored by jp4a50, committed by 
owenpan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146042

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

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -22009,9 +22009,9 @@
   verifyFormat("void test() {\n"
"  (\n"
"  []() -> auto {\n"
-   "int b = 32;\n"
-   "return 3;\n"
-   "  },\n"
+   "int b = 32;\n"
+   "return 3;\n"
+   "  },\n"
"  foo, bar)\n"
"  .foo();\n"
"}",
@@ -22025,17 +22025,82 @@
"  .bar();\n"
"}",
Style);
-  Style = getGoogleStyle();
-  Style.LambdaBodyIndentation = FormatStyle::LBI_OuterScope;
-  verifyFormat("#define A   \\\n"
-   "  [] {  \\\n"
-   "xxx(\\\n"
-   "x); \\\n"
-   "  }",
-   Style);
-  // TODO: The current formatting has a minor issue that's not worth fixing
-  // right now whereby the closing brace is indented relative to the signature
-  // instead of being aligned. This only happens with macros.
+  verifyFormat("#define A  \\\n"
+   "  [] { \\\n"
+   "xxx(   \\\n"
+   "x);\\\n"
+   "  }",
+   Style);
+  verifyFormat("void foo() {\n"
+   "  aFunction(1, b(c(foo, bar, baz, [](d) {\n"
+   "auto f = e(d);\n"
+   "return f;\n"
+   "  })));\n"
+   "}",
+   Style);
+  Style.AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak;
+  verifyFormat("void foo() {\n"
+   "  aFunction(\n"
+   "  1, b(c(\n"
+   " [](d) -> Foo {\n"
+   "auto f = e(d);\n"
+   "return f;\n"
+   "  },\n"
+   " foo, Bar{},\n"
+   " [] {\n"
+   "auto g = h();\n"
+   "return g;\n"
+   "  },\n"
+   " baz)));\n"
+   "}",
+   Style);
+  verifyFormat("void foo() {\n"
+   "  aFunction(1, b(c(foo, Bar{}, baz, [](d) -> Foo {\n"
+   "auto f = e(\n"
+   "foo,\n"
+   "[&] {\n"
+   "  auto g = h();\n"
+   "  return g;\n"
+   "},\n"
+   "qux,\n"
+   "[&] -> Bar {\n"
+   "  auto i = j();\n"
+   "  return i;\n"
+   "});\n"
+   "return f;\n"
+   "  })));\n"
+   "}",
+   Style);
+  verifyFormat("Namespace::Foo::Foo(\n"
+   "LongClassName bar, AnotherLongClassName baz)\n"
+   ": baz{baz}, func{[&] {\n"
+   "  auto qux = bar;\n"
+   "  return aFunkyFunctionCall(qux);\n"
+   "}} {}",
+   Style);
+  Style.BreakBeforeBraces = FormatStyle::BS_Custom;
+  Style.BraceWrapping.BeforeLambdaBody = true;
+  verifyFormat("void foo() {\n"
+   "  aFunction(\n"
+   "  1, b(c(foo, Bar{}, baz,\n"
+   " [](d) -> Foo\n"
+   "  {\n"
+   "auto f = e(\n"
+   "[&]\n"
+   "{\n"
+   "  auto g = h();\n"
+   "  return g;\n"
+   "},\n"
+   "qux,\n"
+   "[&] -> Bar\n"
+   "{\n"
+   "  auto i = j();\n"
+   "  return i;\n"
+   "});\n"
+   "return f;\n"
+   "  })));\n"
+   "}",
+   Style);
 }
 
 TEST_F(FormatTest, LambdaWithLineComments) {
Index: 

[clang] 5c614bd - [clang-format] Fix bugs with "LambdaBodyIndentation: OuterScope"

2023-04-05 Thread Owen Pan via cfe-commits

Author: Jon Phillips
Date: 2023-04-05T14:38:38-07:00
New Revision: 5c614bd88f1252927ca1f9d9f8e802ef5e1eebe2

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

LOG: [clang-format] Fix bugs with "LambdaBodyIndentation: OuterScope"

The previous implementation of the option corrupted the parenthesis
state stack. (See https://reviews.llvm.org/D102706.)

Fixes #55708.
Fixes #53212.
Fixes #52846.
Fixes #59954.

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

Added: 


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

Removed: 




diff  --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index 527bdff5f5b56..f8ab42f46ba81 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -3540,11 +3540,7 @@ the configuration (without a prefix: ``Auto``).
   causes the lambda body to be indented one additional level relative to
   the indentation level of the signature. ``OuterScope`` forces the lambda
   body to be indented one additional level relative to the parent scope
-  containing the lambda signature. For callback-heavy code, it may improve
-  readability to have the signature indented two levels and to use
-  ``OuterScope``. The KJ style guide requires ``OuterScope``.
-  `KJ style guide
-  `_
+  containing the lambda signature.
 
   Possible values:
 
@@ -3569,6 +3565,11 @@ the configuration (without a prefix: ``Auto``).
  return;
});
 
+   someMethod(someOtherMethod(
+   [](SomeReallyLongLambdaSignatureArgument foo) {
+ return;
+   }));
+
 
 
 .. _Language:

diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 03d14fc89be4c..c07f23af4a629 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -427,6 +427,7 @@ clang-format
   put the initializers on the next line only.
 - Add additional Qualifier Ordering support for special cases such
   as templates, requires clauses, long qualified names.
+- Fix all known issues associated with ``LambdaBodyIndentation: OuterScope``.
 
 libclang
 

diff  --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index 755621ec53d63..0dfa052822458 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -2670,6 +2670,11 @@ struct FormatStyle {
 ///[](SomeReallyLongLambdaSignatureArgument foo) {
 ///  return;
 ///});
+///
+///someMethod(someOtherMethod(
+///[](SomeReallyLongLambdaSignatureArgument foo) {
+///  return;
+///}));
 /// \endcode
 LBI_OuterScope,
   };
@@ -2678,11 +2683,7 @@ struct FormatStyle {
   /// causes the lambda body to be indented one additional level relative to
   /// the indentation level of the signature. ``OuterScope`` forces the lambda
   /// body to be indented one additional level relative to the parent scope
-  /// containing the lambda signature. For callback-heavy code, it may improve
-  /// readability to have the signature indented two levels and to use
-  /// ``OuterScope``. The KJ style guide requires ``OuterScope``.
-  /// `KJ style guide
-  /// `_
+  /// containing the lambda signature.
   /// \version 13
   LambdaBodyIndentationKind LambdaBodyIndentation;
 

diff  --git a/clang/lib/Format/ContinuationIndenter.cpp 
b/clang/lib/Format/ContinuationIndenter.cpp
index 6b33ab0a76650..f5748cfc50890 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -1125,8 +1125,14 @@ unsigned ContinuationIndenter::getNewLineColumn(const 
LineState ) {
Style.IndentWidth;
   }
 
-  if (NextNonComment->is(tok::l_brace) && NextNonComment->is(BK_Block))
-return Current.NestingLevel == 0 ? State.FirstIndent : CurrentState.Indent;
+  if (NextNonComment->is(tok::l_brace) && NextNonComment->is(BK_Block)) {
+if (Current.NestingLevel == 0 ||
+(Style.LambdaBodyIndentation == FormatStyle::LBI_OuterScope &&
+ State.NextToken->is(TT_LambdaLBrace))) {
+  return State.FirstIndent;
+}
+return CurrentState.Indent;
+  }
   if ((Current.isOneOf(tok::r_brace, tok::r_square) ||
(Current.is(tok::greater) &&
 (Style.Language == FormatStyle::LK_Proto ||
@@ -1830,6 +1836,10 @@ void 
ContinuationIndenter::moveStatePastScopeCloser(LineState ) {
 }
 
 void 

[PATCH] D146463: [CodeGen][RISCV] Change Shadow Call Stack Register to X3

2023-04-05 Thread Paul Kirth via Phabricator via cfe-commits
paulkirth added a comment.

@asb, @craig.topper, @jrtc27  Are there any remaining considerations for us 
here? From the discussions in psABI and sig-toolchain, I think we have a 
consensus that this is the approach we'll be taking for RISC-V. We'd prefer to 
correct this ASAP, so as to prevent future incompatibility/continuing to use a 
non-standard register.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146463

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


[PATCH] D147661: [Sema] Tweak merging of availability attributes

2023-04-05 Thread Richard Sandiford via Phabricator via cfe-commits
rsandifo-arm created this revision.
rsandifo-arm added reviewers: arphaman, erichkeane.
Herald added a reviewer: aaron.ballman.
Herald added a project: All.
rsandifo-arm requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Two calls to mergeAvailabilityAttr dropped the original
AttributeCommonInfo and created a new one from just the range.
This new attribute would have a 0 kind (rather than AT_Availability)
and a 0 syntax (GNU).  I don't have any proof that this makes a
difference in practice.

Noticed while doing some changes to the attribute handling.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D147661

Files:
  clang/lib/Sema/SemaDeclAttr.cpp


Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -2775,7 +2775,7 @@
 return V;
   };
   AvailabilityAttr *NewAttr = S.mergeAvailabilityAttr(
-  ND, AL.getRange(), NewII, true /*Implicit*/,
+  ND, AL, NewII, true /*Implicit*/,
   MinMacCatalystVersion(Introduced.Version),
   MinMacCatalystVersion(Deprecated.Version),
   MinMacCatalystVersion(Obsoleted.Version), IsUnavailable, Str,
@@ -2817,7 +2817,7 @@
 return V ? *V : VersionTuple();
   };
   AvailabilityAttr *NewAttr = S.mergeAvailabilityAttr(
-  ND, AL.getRange(), NewII, true /*Implicit*/,
+  ND, AL, NewII, true /*Implicit*/,
   VersionOrEmptyVersion(NewIntroduced),
   VersionOrEmptyVersion(NewDeprecated),
   VersionOrEmptyVersion(NewObsoleted), /*IsUnavailable=*/false, 
Str,


Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -2775,7 +2775,7 @@
 return V;
   };
   AvailabilityAttr *NewAttr = S.mergeAvailabilityAttr(
-  ND, AL.getRange(), NewII, true /*Implicit*/,
+  ND, AL, NewII, true /*Implicit*/,
   MinMacCatalystVersion(Introduced.Version),
   MinMacCatalystVersion(Deprecated.Version),
   MinMacCatalystVersion(Obsoleted.Version), IsUnavailable, Str,
@@ -2817,7 +2817,7 @@
 return V ? *V : VersionTuple();
   };
   AvailabilityAttr *NewAttr = S.mergeAvailabilityAttr(
-  ND, AL.getRange(), NewII, true /*Implicit*/,
+  ND, AL, NewII, true /*Implicit*/,
   VersionOrEmptyVersion(NewIntroduced),
   VersionOrEmptyVersion(NewDeprecated),
   VersionOrEmptyVersion(NewObsoleted), /*IsUnavailable=*/false, Str,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D146399: [AIX][Clang][K] Create `-K` Option for AIX.

2023-04-05 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 511208.
francii added a comment.

Add -c test case


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146399

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/aix-ld.c


Index: clang/test/Driver/aix-ld.c
===
--- clang/test/Driver/aix-ld.c
+++ clang/test/Driver/aix-ld.c
@@ -1077,3 +1077,27 @@
 // RUN:-fopenmp=libfoo \
 // RUN:   | FileCheck --check-prefixes=CHECK-FOPENMP-FOO %s
 // CHECK-FOPENMP-FOO: error: unsupported argument 'libfoo' to option 
'-fopenmp='
+
+// Check powerpc-ibm-aix7.1.0.0. -K is a passthrough linker option.
+// RUN: %clang %s 2>&1 -### \
+// RUN:--target=powerpc-ibm-aix7.1.0.0 \
+// RUN:--sysroot %S/Inputs/aix_ppc_tree \
+// RUN:--unwindlib=libunwind \
+// RUN:-K \
+// RUN:   | FileCheck --check-prefixes=CHECK-K %s
+// CHECK-K: "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0"
+// CHECK-K: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-K: "{{.*}}ld{{(.exe)?}}"
+// CHECK-K: "[[SYSROOT]]/usr/lib{{/|}}crt0.o"
+// CHECK-K: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
+// CHECK-K: "-K"
+
+// Check powerpc-ibm-aix7.1.0.0. -K unused when not linking.
+// RUN: %clang %s 2>&1 -### \
+// RUN:--target=powerpc-ibm-aix7.1.0.0 \
+// RUN:--sysroot %S/Inputs/aix_ppc_tree \
+// RUN:--unwindlib=libunwind \
+// RUN:-K \
+// RUN:-c \
+// RUN:   | FileCheck --check-prefixes=CHECK-K-UNUSED %s
+// CHECK-K-UNUSED: clang: warning: -K: 'linker' input unused 
[-Wunused-command-line-argument]
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6328,6 +6328,10 @@
 }
   }
 
+  if (Arg *A = Args.getLastArg(options::OPT_K); A && !TC.getTriple().isOSAIX())
+D.Diag(diag::err_drv_unsupported_opt_for_target)
+<< A->getAsString(Args) << TripleStr;
+
   if (Args.getLastArg(options::OPT_fapple_kext) ||
   (Args.hasArg(options::OPT_mkernel) && types::isCXX(InputType)))
 CmdArgs.push_back("-fapple-kext");
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -3405,6 +3405,7 @@
   HelpText<"Overlay the virtual filesystem described by file over the real 
file system. "
"Additionally, pass this overlay file to the linker if it supports 
it">;
 def imultilib : Separate<["-"], "imultilib">, Group;
+def K : Flag<["-"], "K">, Flags<[LinkerInput]>;
 def keep__private__externs : Flag<["-"], "keep_private_externs">;
 def l : JoinedOrSeparate<["-"], "l">, Flags<[LinkerInput, RenderJoined]>,
 Group;


Index: clang/test/Driver/aix-ld.c
===
--- clang/test/Driver/aix-ld.c
+++ clang/test/Driver/aix-ld.c
@@ -1077,3 +1077,27 @@
 // RUN:-fopenmp=libfoo \
 // RUN:   | FileCheck --check-prefixes=CHECK-FOPENMP-FOO %s
 // CHECK-FOPENMP-FOO: error: unsupported argument 'libfoo' to option '-fopenmp='
+
+// Check powerpc-ibm-aix7.1.0.0. -K is a passthrough linker option.
+// RUN: %clang %s 2>&1 -### \
+// RUN:--target=powerpc-ibm-aix7.1.0.0 \
+// RUN:--sysroot %S/Inputs/aix_ppc_tree \
+// RUN:--unwindlib=libunwind \
+// RUN:-K \
+// RUN:   | FileCheck --check-prefixes=CHECK-K %s
+// CHECK-K: "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0"
+// CHECK-K: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-K: "{{.*}}ld{{(.exe)?}}"
+// CHECK-K: "[[SYSROOT]]/usr/lib{{/|}}crt0.o"
+// CHECK-K: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
+// CHECK-K: "-K"
+
+// Check powerpc-ibm-aix7.1.0.0. -K unused when not linking.
+// RUN: %clang %s 2>&1 -### \
+// RUN:--target=powerpc-ibm-aix7.1.0.0 \
+// RUN:--sysroot %S/Inputs/aix_ppc_tree \
+// RUN:--unwindlib=libunwind \
+// RUN:-K \
+// RUN:-c \
+// RUN:   | FileCheck --check-prefixes=CHECK-K-UNUSED %s
+// CHECK-K-UNUSED: clang: warning: -K: 'linker' input unused [-Wunused-command-line-argument]
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6328,6 +6328,10 @@
 }
   }
 
+  if (Arg *A = Args.getLastArg(options::OPT_K); A && !TC.getTriple().isOSAIX())
+D.Diag(diag::err_drv_unsupported_opt_for_target)
+<< A->getAsString(Args) << TripleStr;
+
   if (Args.getLastArg(options::OPT_fapple_kext) ||
   (Args.hasArg(options::OPT_mkernel) && types::isCXX(InputType)))
 CmdArgs.push_back("-fapple-kext");
Index: clang/include/clang/Driver/Options.td

[PATCH] D147626: [clang] Do not crash when initializing union with flexible array member

2023-04-05 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added a subscriber: rsmith.
shafik added a comment.

Thank you for this fix.




Comment at: clang/lib/Sema/SemaInit.cpp:808
   unsigned NumElems = numStructUnionElements(ILE->getType());
-  if (RDecl->hasFlexibleArrayMember())
+  if (!RDecl->isUnion() && RDecl->hasFlexibleArrayMember())
 ++NumElems;

Fznamznon wrote:
> Just for some context, numStructUnionElements checks that there is a flexible 
> array member and returns number_of_initializable_fields-1 for structs. For 
> unions it just returns 1 or 0, so flexible array member caused adding one 
> more element to initlistexpr that was never properly handled.
> 
> Instead of doing this change, we could probably never enter initialization 
> since the record (union) declaration is not valid, but that is not the case 
> even for other types of errors in code, for example, I've tried declaring 
> field of struct with a typo:
> 
> ```
> struct { cha x[]; } r = {1}; 
> ```
> Initialization is still performed by clang.
> Also, it seems MSVC considers flexible array member inside union as valid, so 
> the test code is probably not always invalid.
I am not sure what to think here, looking at gcc documentation for this 
extension: https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html 

and using the following code:

```
struct f1 {
  int x; int y[];
} f1 = { 1, { 2, 3, 4 } }; // #1

struct f2 {
  struct f1 f1; int data[3];
} f2 = { { 1 }, { 2, 3, 4 } }; // #2

struct { char x[]; } r = {1};  // #3
```

gcc rejects 2 and 3 even though 2 comes from their documentation. Clang warns 
on 2 and MSVC rejects 2

CC @aaron.ballman @rsmith 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147626

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


[PATCH] D147574: [NFC][clang] Fix Coverity static analyzer tool concerns about auto_causes_copy

2023-04-05 Thread Soumi Manna via Phabricator via cfe-commits
Manna added a comment.

I have committed the patch here: https://reviews.llvm.org/rG59cb47015a18


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147574

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


[clang] c61f45f - Update clang :: Driver/debug-options.c to fix the buildbots

2023-04-05 Thread Matthew Voss via cfe-commits

Author: Matthew Voss
Date: 2023-04-05T13:27:17-07:00
New Revision: c61f45fc3e041606c5b94c468a5c092e8a6e5601

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

LOG: Update clang :: Driver/debug-options.c to fix the buildbots

The format of the LTO debug options generated for orbis-ld changed,
breaking this test.

https://lab.llvm.org/buildbot/#/builders/230/builds/11367

Added: 


Modified: 
clang/test/Driver/debug-options.c

Removed: 




diff  --git a/clang/test/Driver/debug-options.c 
b/clang/test/Driver/debug-options.c
index dedd96c82da96..8617949cea1c8 100644
--- a/clang/test/Driver/debug-options.c
+++ b/clang/test/Driver/debug-options.c
@@ -390,8 +390,8 @@
 // LDGARANGE: {{".*ld.*"}} {{.*}}
 // LDGARANGE-NOT: "-plugin-opt=-generate-arange-section"
 // LLDGARANGE: {{".*lld.*"}} {{.*}} "-plugin-opt=-generate-arange-section"
-// SNLDTLTOGARANGE: {{".*orbis-ld.*"}} {{.*}} 
"-lto-thin-debug-options=-generate-arange-section"
-// SNLDFLTOGARANGE: {{".*orbis-ld.*"}} {{.*}} 
"-lto-debug-options=-generate-arange-section"
+// SNLDTLTOGARANGE: {{".*orbis-ld.*"}} {{.*}} "-lto-thin-debug-options= 
-generate-arange-section"
+// SNLDFLTOGARANGE: {{".*orbis-ld.*"}} {{.*}} "-lto-debug-options= 
-generate-arange-section"
 
 // PUB: -gpubnames
 //



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


[PATCH] D144651: [Serialization] Place command line defines in the correct file

2023-04-05 Thread Felipe de Azevedo Piovezan via Phabricator via cfe-commits
fdeazeve added a comment.

I can check out a copy of this patch and help test it


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144651

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


[PATCH] D146101: [clang-format] Add BracedInitializerIndentWidth option.

2023-04-05 Thread Jon Phillips via Phabricator via cfe-commits
jp4a50 added a comment.

Following on from our discussion about new options needing motivation from 
public style guides, I've updated the KJ style guide to clarify its stance on 
braced init lists: 
https://github.com/capnproto/capnproto/blob/master/style-guide.md#spacing-and-bracing


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146101

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


[PATCH] D147657: [Sema] Fix reporting of invalid shader attribute on HLSL entry function

2023-04-05 Thread Richard Sandiford via Phabricator via cfe-commits
rsandifo-arm created this revision.
rsandifo-arm added reviewers: python3kgae, erichkeane.
Herald added a subscriber: Anastasia.
Herald added a project: All.
rsandifo-arm requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

If the HLSL entry function had a shader attribute that conflicted
with the pipeline stage specified in the target triple, Clang
would emit:

  error: (null) attribute parameters do not match the previous declaration
  conflicting attribute is here

(where the second line doesn't reference an attribute).

This was because the code constructed a dummy attribute that had
only a source location, but no kind or syntax.

Noticed while doing some changes to the attribute handling.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D147657

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaDecl.cpp
  clang/test/SemaHLSL/entry_shader.hlsl


Index: clang/test/SemaHLSL/entry_shader.hlsl
===
--- /dev/null
+++ clang/test/SemaHLSL/entry_shader.hlsl
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-compute -x hlsl -hlsl-entry 
foo  -o - %s -DSHADER='"anyHit"' -verify
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-compute -x hlsl -hlsl-entry 
foo  -o - %s -DSHADER='"compute"'
+
+// expected-error@+1 {{'shader' attribute on entry function does not match the 
pipeline stage}}
+[numthreads(1,1,1), shader(SHADER)]
+void foo() {
+
+}
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -10205,14 +10205,19 @@
   CheckHLSLEntryPoint(NewFD);
   if (!NewFD->isInvalidDecl()) {
 auto Env = TargetInfo.getTriple().getEnvironment();
-AttributeCommonInfo AL(NewFD->getBeginLoc());
 HLSLShaderAttr::ShaderType ShaderType =
 static_cast(
 hlsl::getStageFromEnvironment(Env));
 // To share code with HLSLShaderAttr, add HLSLShaderAttr to entry
 // function.
-if (HLSLShaderAttr *Attr = mergeHLSLShaderAttr(NewFD, AL, ShaderType))
-  NewFD->addAttr(Attr);
+if (HLSLShaderAttr *NT = NewFD->getAttr()) {
+  if (NT->getType() != ShaderType)
+Diag(NT->getLocation(), diag::err_hlsl_entry_shader_attr_mismatch)
+<< NT;
+} else {
+  NewFD->addAttr(HLSLShaderAttr::Create(Context, ShaderType,
+NewFD->getBeginLoc()));
+}
   }
 }
 // HLSL does not support specifying an address space on a function return
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -11752,6 +11752,8 @@
"attribute %0 only applies to a field or parameter of type '%1'">;
 def err_hlsl_attr_invalid_ast_node : Error<
"attribute %0 only applies to %1">;
+def err_hlsl_entry_shader_attr_mismatch : Error<
+   "%0 attribute on entry function does not match the pipeline stage">;
 def err_hlsl_numthreads_argument_oor : Error<"argument '%select{X|Y|Z}0' to 
numthreads attribute cannot exceed %1">;
 def err_hlsl_numthreads_invalid : Error<"total number of threads cannot exceed 
%0">;
 def err_hlsl_missing_numthreads : Error<"missing numthreads attribute for %0 
shader entry">;


Index: clang/test/SemaHLSL/entry_shader.hlsl
===
--- /dev/null
+++ clang/test/SemaHLSL/entry_shader.hlsl
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-compute -x hlsl -hlsl-entry foo  -o - %s -DSHADER='"anyHit"' -verify
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-compute -x hlsl -hlsl-entry foo  -o - %s -DSHADER='"compute"'
+
+// expected-error@+1 {{'shader' attribute on entry function does not match the pipeline stage}}
+[numthreads(1,1,1), shader(SHADER)]
+void foo() {
+
+}
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -10205,14 +10205,19 @@
   CheckHLSLEntryPoint(NewFD);
   if (!NewFD->isInvalidDecl()) {
 auto Env = TargetInfo.getTriple().getEnvironment();
-AttributeCommonInfo AL(NewFD->getBeginLoc());
 HLSLShaderAttr::ShaderType ShaderType =
 static_cast(
 hlsl::getStageFromEnvironment(Env));
 // To share code with HLSLShaderAttr, add HLSLShaderAttr to entry
 // function.
-if (HLSLShaderAttr *Attr = mergeHLSLShaderAttr(NewFD, AL, ShaderType))
-  NewFD->addAttr(Attr);
+if (HLSLShaderAttr *NT = NewFD->getAttr()) {
+  if (NT->getType() != ShaderType)
+Diag(NT->getLocation(), 

[clang] 59cb470 - [NFC][clang] Fix Coverity static analyzer tool concerns about auto_causes_copy

2023-04-05 Thread via cfe-commits

Author: Manna, Soumi
Date: 2023-04-05T16:00:45-04:00
New Revision: 59cb47015a184862f3709a7ab084ccd086816176

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

LOG: [NFC][clang] Fix Coverity static analyzer tool concerns about 
auto_causes_copy

Reported by Coverity:

AUTO_CAUSES_COPY
Unnecessary object copies can affect performance

Inside FrontendActions.cpp file,
In clang::DumpModuleInfoAction::ExecuteAction(): Using the auto keyword 
without an & causes the copy of an object of type pair.

Inside ComputeDependence.cpp file,
In clang::computeDependence(clang::OverloadExpr *, bool, bool, bool): Using 
the auto keyword without an & causes the copy of an object of type 
TemplateArgumentLoc.

Reviewed By: erichkeane, aaron.ballman

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

Added: 


Modified: 
clang/lib/AST/ComputeDependence.cpp
clang/lib/Frontend/FrontendActions.cpp

Removed: 




diff  --git a/clang/lib/AST/ComputeDependence.cpp 
b/clang/lib/AST/ComputeDependence.cpp
index eb9afbdb1c879..cd204ed62b5dd 100644
--- a/clang/lib/AST/ComputeDependence.cpp
+++ b/clang/lib/AST/ComputeDependence.cpp
@@ -750,7 +750,7 @@ clang::computeDependence(OverloadExpr *E, bool 
KnownDependent,
   // If we have explicit template arguments, check for dependent
   // template arguments and whether they contain any unexpanded pack
   // expansions.
-  for (auto A : E->template_arguments())
+  for (const auto  : E->template_arguments())
 Deps |= toExprDependence(A.getArgument().getDependence());
   return Deps;
 }

diff  --git a/clang/lib/Frontend/FrontendActions.cpp 
b/clang/lib/Frontend/FrontendActions.cpp
index 0349e769595dd..c947772ec3e70 100644
--- a/clang/lib/Frontend/FrontendActions.cpp
+++ b/clang/lib/Frontend/FrontendActions.cpp
@@ -882,7 +882,7 @@ void DumpModuleInfoAction::ExecuteAction() {
 }
 
 // Now let's print out any modules we did not see as part of the Primary.
-for (auto SM : SubModMap) {
+for (const auto  : SubModMap) {
   if (!SM.second.Seen && SM.second.Mod) {
 Out << "  " << ModuleKindName(SM.second.Kind) << " '" << SM.first
 << "' at index #" << SM.second.Idx



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


[PATCH] D147546: [PS4][clang] Fix the format of the LTO debug options passed to orbis-ld

2023-04-05 Thread Matthew Voss 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 rGc37b95b515a5: [PS4][clang] Fix the format of the LTO debug 
options passed to orbis-ld (authored by ormris).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147546

Files:
  clang/lib/Driver/ToolChains/PS4CPU.cpp
  clang/test/Driver/ps4-ps5-linker.c


Index: clang/test/Driver/ps4-ps5-linker.c
===
--- clang/test/Driver/ps4-ps5-linker.c
+++ clang/test/Driver/ps4-ps5-linker.c
@@ -7,8 +7,8 @@
 // RUN: %clang --target=x86_64-scei-ps5 -flto -fjmc %s -### 2>&1 | FileCheck 
--check-prefixes=CHECK-PS5-LTO,CHECK-PS5-LIB %s
 
 // CHECK-PS4-NOT: -enable-jmc-instrument
-// CHECK-PS4-THIN-LTO: -lto-thin-debug-options=-enable-jmc-instrument
-// CHECK-PS4-FULL-LTO: -lto-debug-options=-enable-jmc-instrument
+// CHECK-PS4-THIN-LTO: "-lto-thin-debug-options= -generate-arange-section 
-enable-jmc-instrument"
+// CHECK-PS4-FULL-LTO: "-lto-debug-options= -generate-arange-section 
-enable-jmc-instrument"
 // CHECK-PS5-NOT: -plugin-opt=-enable-jmc-instrument
 // CHECK-PS5-LTO: -plugin-opt=-enable-jmc-instrument
 
@@ -23,7 +23,7 @@
 // RUN: %clang --target=x86_64-scei-ps5 -fcrash-diagnostics-dir=mydumps %s 
-### 2>&1 | FileCheck --check-prefixes=CHECK-DIAG-PS5 %s
 // RUN: %clang --target=x86_64-scei-ps5 -flto -fcrash-diagnostics-dir=mydumps 
%s -### 2>&1 | FileCheck --check-prefixes=CHECK-DIAG-PS5-LTO %s
 
-// CHECK-DIAG-PS4-THIN-LTO: 
-lto-thin-debug-options=-crash-diagnostics-dir=mydumps
-// CHECK-DIAG-PS4-FULL-LTO: -lto-debug-options=-crash-diagnostics-dir=mydumps
+// CHECK-DIAG-PS4-THIN-LTO: "-lto-thin-debug-options= -generate-arange-section 
-crash-diagnostics-dir=mydumps"
+// CHECK-DIAG-PS4-FULL-LTO: "-lto-debug-options= -generate-arange-section 
-crash-diagnostics-dir=mydumps"
 // CHECK-DIAG-PS5-NOT: -plugin-opt=-crash-diagnostics-dir=mydumps
 // CHECK-DIAG-PS5-LTO: -plugin-opt=-crash-diagnostics-dir=mydumps
Index: clang/lib/Driver/ToolChains/PS4CPU.cpp
===
--- clang/lib/Driver/ToolChains/PS4CPU.cpp
+++ clang/lib/Driver/ToolChains/PS4CPU.cpp
@@ -160,18 +160,12 @@
   const bool IsPS5 = TC.getTriple().isPS5();
   assert(IsPS4 || IsPS5);
 
+  const char *PS4LTOArgs = "";
   auto AddCodeGenFlag = [&](Twine Flag) {
-const char *Prefix = nullptr;
-if (IsPS4 && D.getLTOMode() == LTOK_Thin)
-  Prefix = "-lto-thin-debug-options=";
-else if (IsPS4 && D.getLTOMode() == LTOK_Full)
-  Prefix = "-lto-debug-options=";
+if (IsPS4)
+  PS4LTOArgs = Args.MakeArgString(Twine(PS4LTOArgs) + " " + Flag);
 else if (IsPS5)
-  Prefix = "-plugin-opt=";
-else
-  llvm_unreachable("new LTO mode?");
-
-CmdArgs.push_back(Args.MakeArgString(Twine(Prefix) + Flag));
+  CmdArgs.push_back(Args.MakeArgString(Twine("-plugin-opt=") + Flag));
   };
 
   if (UseLTO) {
@@ -185,6 +179,18 @@
 
 if (Arg *A = Args.getLastArg(options::OPT_fcrash_diagnostics_dir))
   AddCodeGenFlag(Twine("-crash-diagnostics-dir=") + A->getValue());
+
+if (IsPS4) {
+  const char *Prefix = nullptr;
+  if (D.getLTOMode() == LTOK_Thin)
+Prefix = "-lto-thin-debug-options=";
+  else if (D.getLTOMode() == LTOK_Full)
+Prefix = "-lto-debug-options=";
+  else
+llvm_unreachable("new LTO mode?");
+
+  CmdArgs.push_back(Args.MakeArgString(Twine(Prefix) + PS4LTOArgs));
+}
   }
 
   if (IsPS5 && UseLTO) {


Index: clang/test/Driver/ps4-ps5-linker.c
===
--- clang/test/Driver/ps4-ps5-linker.c
+++ clang/test/Driver/ps4-ps5-linker.c
@@ -7,8 +7,8 @@
 // RUN: %clang --target=x86_64-scei-ps5 -flto -fjmc %s -### 2>&1 | FileCheck --check-prefixes=CHECK-PS5-LTO,CHECK-PS5-LIB %s
 
 // CHECK-PS4-NOT: -enable-jmc-instrument
-// CHECK-PS4-THIN-LTO: -lto-thin-debug-options=-enable-jmc-instrument
-// CHECK-PS4-FULL-LTO: -lto-debug-options=-enable-jmc-instrument
+// CHECK-PS4-THIN-LTO: "-lto-thin-debug-options= -generate-arange-section -enable-jmc-instrument"
+// CHECK-PS4-FULL-LTO: "-lto-debug-options= -generate-arange-section -enable-jmc-instrument"
 // CHECK-PS5-NOT: -plugin-opt=-enable-jmc-instrument
 // CHECK-PS5-LTO: -plugin-opt=-enable-jmc-instrument
 
@@ -23,7 +23,7 @@
 // RUN: %clang --target=x86_64-scei-ps5 -fcrash-diagnostics-dir=mydumps %s -### 2>&1 | FileCheck --check-prefixes=CHECK-DIAG-PS5 %s
 // RUN: %clang --target=x86_64-scei-ps5 -flto -fcrash-diagnostics-dir=mydumps %s -### 2>&1 | FileCheck --check-prefixes=CHECK-DIAG-PS5-LTO %s
 
-// CHECK-DIAG-PS4-THIN-LTO: -lto-thin-debug-options=-crash-diagnostics-dir=mydumps
-// CHECK-DIAG-PS4-FULL-LTO: -lto-debug-options=-crash-diagnostics-dir=mydumps
+// 

[clang] c37b95b - [PS4][clang] Fix the format of the LTO debug options passed to orbis-ld

2023-04-05 Thread Matthew Voss via cfe-commits

Author: Matthew Voss
Date: 2023-04-05T12:57:21-07:00
New Revision: c37b95b515a5c69b2050c8fd50f076368742c6cb

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

LOG: [PS4][clang] Fix the format of the LTO debug options passed to orbis-ld

Currently, we pass multiple LTO debug options to orbis-ld like this:

orbis-ld --lto=thin --lto-thin-debug-options= 
--lto-thin-debug-options= ...

When it should be like this:

orbis-ld --lto=thin "--lto-thin-debug-options=  " ...

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/PS4CPU.cpp
clang/test/Driver/ps4-ps5-linker.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/PS4CPU.cpp 
b/clang/lib/Driver/ToolChains/PS4CPU.cpp
index 8c8b7c73c1bf5..71c6b650e1f52 100644
--- a/clang/lib/Driver/ToolChains/PS4CPU.cpp
+++ b/clang/lib/Driver/ToolChains/PS4CPU.cpp
@@ -160,18 +160,12 @@ void tools::PScpu::Linker::ConstructJob(Compilation , 
const JobAction ,
   const bool IsPS5 = TC.getTriple().isPS5();
   assert(IsPS4 || IsPS5);
 
+  const char *PS4LTOArgs = "";
   auto AddCodeGenFlag = [&](Twine Flag) {
-const char *Prefix = nullptr;
-if (IsPS4 && D.getLTOMode() == LTOK_Thin)
-  Prefix = "-lto-thin-debug-options=";
-else if (IsPS4 && D.getLTOMode() == LTOK_Full)
-  Prefix = "-lto-debug-options=";
+if (IsPS4)
+  PS4LTOArgs = Args.MakeArgString(Twine(PS4LTOArgs) + " " + Flag);
 else if (IsPS5)
-  Prefix = "-plugin-opt=";
-else
-  llvm_unreachable("new LTO mode?");
-
-CmdArgs.push_back(Args.MakeArgString(Twine(Prefix) + Flag));
+  CmdArgs.push_back(Args.MakeArgString(Twine("-plugin-opt=") + Flag));
   };
 
   if (UseLTO) {
@@ -185,6 +179,18 @@ void tools::PScpu::Linker::ConstructJob(Compilation , 
const JobAction ,
 
 if (Arg *A = Args.getLastArg(options::OPT_fcrash_diagnostics_dir))
   AddCodeGenFlag(Twine("-crash-diagnostics-dir=") + A->getValue());
+
+if (IsPS4) {
+  const char *Prefix = nullptr;
+  if (D.getLTOMode() == LTOK_Thin)
+Prefix = "-lto-thin-debug-options=";
+  else if (D.getLTOMode() == LTOK_Full)
+Prefix = "-lto-debug-options=";
+  else
+llvm_unreachable("new LTO mode?");
+
+  CmdArgs.push_back(Args.MakeArgString(Twine(Prefix) + PS4LTOArgs));
+}
   }
 
   if (IsPS5 && UseLTO) {

diff  --git a/clang/test/Driver/ps4-ps5-linker.c 
b/clang/test/Driver/ps4-ps5-linker.c
index ee8e96bbfbd02..8aae94c838834 100644
--- a/clang/test/Driver/ps4-ps5-linker.c
+++ b/clang/test/Driver/ps4-ps5-linker.c
@@ -7,8 +7,8 @@
 // RUN: %clang --target=x86_64-scei-ps5 -flto -fjmc %s -### 2>&1 | FileCheck 
--check-prefixes=CHECK-PS5-LTO,CHECK-PS5-LIB %s
 
 // CHECK-PS4-NOT: -enable-jmc-instrument
-// CHECK-PS4-THIN-LTO: -lto-thin-debug-options=-enable-jmc-instrument
-// CHECK-PS4-FULL-LTO: -lto-debug-options=-enable-jmc-instrument
+// CHECK-PS4-THIN-LTO: "-lto-thin-debug-options= -generate-arange-section 
-enable-jmc-instrument"
+// CHECK-PS4-FULL-LTO: "-lto-debug-options= -generate-arange-section 
-enable-jmc-instrument"
 // CHECK-PS5-NOT: -plugin-opt=-enable-jmc-instrument
 // CHECK-PS5-LTO: -plugin-opt=-enable-jmc-instrument
 
@@ -23,7 +23,7 @@
 // RUN: %clang --target=x86_64-scei-ps5 -fcrash-diagnostics-dir=mydumps %s 
-### 2>&1 | FileCheck --check-prefixes=CHECK-DIAG-PS5 %s
 // RUN: %clang --target=x86_64-scei-ps5 -flto -fcrash-diagnostics-dir=mydumps 
%s -### 2>&1 | FileCheck --check-prefixes=CHECK-DIAG-PS5-LTO %s
 
-// CHECK-DIAG-PS4-THIN-LTO: 
-lto-thin-debug-options=-crash-diagnostics-dir=mydumps
-// CHECK-DIAG-PS4-FULL-LTO: -lto-debug-options=-crash-diagnostics-dir=mydumps
+// CHECK-DIAG-PS4-THIN-LTO: "-lto-thin-debug-options= -generate-arange-section 
-crash-diagnostics-dir=mydumps"
+// CHECK-DIAG-PS4-FULL-LTO: "-lto-debug-options= -generate-arange-section 
-crash-diagnostics-dir=mydumps"
 // CHECK-DIAG-PS5-NOT: -plugin-opt=-crash-diagnostics-dir=mydumps
 // CHECK-DIAG-PS5-LTO: -plugin-opt=-crash-diagnostics-dir=mydumps



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


[PATCH] D146090: [Clang] Updating handling of defaulted comparison operators to reflect changes from P2448R2

2023-04-05 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

I'm happy whenever Aaron is.




Comment at: clang/lib/Sema/SemaDeclCXX.cpp:8809
+  //
+  // We will support P2448R2 in language modes earlier than C++23 as an 
extenion
+  // The concept of constexpr-compatible was removed.





Comment at: clang/lib/Sema/SemaDeclCXX.cpp:8826-8827
+  getLangOpts().CPlusPlus2b
+  ? 
diag::warn_cxx2b_compat_incorrect_defaulted_comparison_constexpr
+  : diag::ext_incorrect_defaulted_comparison_constexpr)
   << FD->isImplicit() << (int)DCK << FD->isConsteval();

I wonder if `incorrect_` is the best way to spell the diagnostic ID given the 
new rule. Suggested an alternative.


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

https://reviews.llvm.org/D146090

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


[PATCH] D147655: Implement mangling rules for C++20 concepts and requires-expressions.

2023-04-05 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

I can't really review the libcxxabi parts, or the llvm-demangler parts, but 
everything looks right to me.  I've got a pair of quick questions, otherwise I 
think this is going to be fine for me.

Note the extra paren changes are something I think are valuable, but I'm trying 
to figure out their meaning in thsi patch.




Comment at: clang/include/clang/AST/ExprConcepts.h:502
ArrayRef LocalParameters,
+   SourceLocation RParenLoc,
ArrayRef Requirements,

Is this an unrelated change?  Are paren locations required for mangling?



Comment at: clang/lib/AST/ItaniumMangle.cpp:5180
+NotPrimaryExpr();
+if (RE->getLParenLoc().isValid()) {
+  Out << "rQ";

What is happening here? What are we deriving from the validity of the paren?  
Or is this differentiating:

`requires (something)` vs `requires C` sorta thing?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147655

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


[PATCH] D147655: Implement mangling rules for C++20 concepts and requires-expressions.

2023-04-05 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

Here's the diff to `test_demangle.pass.cpp`:

  --- a/libcxxabi/test/test_demangle.pass.cpp
  +++ b/libcxxabi/test/test_demangle.pass.cpp
  @@ -29995,10 +29995,10 @@ const char* cases[][2] =
   {"_Z15test_uuidofTypeI10TestStructEvDTu8__uuidofT_EE", "void 
test_uuidofType(decltype(__uuidof(TestStruct)))"},
   {"_Z15test_uuidofExprI9HasMemberEvDTu8__uuidofXsrT_6memberEEE", "void 
test_uuidofExpr(decltype(__uuidof(HasMember::member)))"},
   
  -// C++2a char8_t:
  +// C++20 char8_t:
   {"_ZTSPDu", "typeinfo name for char8_t*"},
   
  -// C++2a lambda-expressions:
  +// C++20 lambda-expressions:
   {"_ZNK1xMUlTyT_E_clIiEEDaS_", "auto x::'lambda'($T)::operator()(x) const"},
   {"_ZNK1xMUlTnPA3_ivE_clILS0_0EEEDav", "auto x::'lambda'()::operator()<(int [3])0>() const"},
   {"_ZNK1xMUlTyTtTyTnT_TpTnPA3_TL0__ETpTyvE_clIi1XJfEEEDav", "auto 
x::'lambda' 
typename $TT, typename ...$T1>()::operator()() const"},
  @@ -30015,8 +30015,10 @@ const char* cases[][2] =
   // See https://github.com/itanium-cxx-abi/cxx-abi/issues/106.
   {"_ZN1XIZ1fIiEvOT_EUlS2_DpT0_E_EclIJEEEvDpT_", "void X(int&&)::'lambda'(int&&, auto...)>::operator()<>()"},
   
{"_N6abcdef9abcdefghi29abcdefabcdefabcdefabcefabcdef27xxxEN4absl8DurationERKNSt3__u12basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcPNS1_19yyyEENK3$_5clEvENKUlvE_clEvE6zz",
 
"abcdef::abcdefghi::abcdefabcdefabcdefabcefabcdef::xxx(absl::Duration,
 std::__u::basic_string, 
std::__u::allocator> const&, 
abcdef::abcdefghi::abcdefabcdefabcdefabcefabcdef::yyy*)::$_5::operator()()
 const::'lambda'()::operator()() const::zz"},
  +// See https://github.com/itanium-cxx-abi/cxx-abi/issues/165.
  +{"_ZN1C1fIiEEvDTtlNS_UlT_TL0__E_EEE", "void 
C::f(decltype(C::'lambda'(int, auto){}))"},
   
  -// C++2a class type non-type template parameters:
  +// C++20 class type non-type template parameters:
   {"_Z1fIXtl1BLPi0ELi1vv", "void f()"},
   {"_Z1fIXtl1BLPi32vv", "void f()"},
   {"_Z1fIXtl1BrcPiLi0vv", "void f(0)}>()"},
  @@ -30089,6 +30091,51 @@ const char* cases[][2] =
   {"_ZW1ML4Oink", "Oink@M"},
   {"_ZW1ML1fi", "f@M(int)"},
   
  +// C++20 concepts, see 
https://github.com/itanium-cxx-abi/cxx-abi/issues/24.
  +{"_Z2f0IiE1SIX1CIT_EEEv", "S> f0()"},
  +{"_ZN5test21AIiEF1fEzQ4TrueIT_E", "test2::A::friend f(...) requires 
True"},
  +{"_ZN5test2F1gIvEEvzQaa4TrueIT_E4TrueITL0__E", "void test2::friend 
g(...) requires True && True"},
  +{"_ZN5test21hIvEEvzQ4TrueITL0__E", "void test2::h(...) requires 
True"},
  +{"_ZN5test2F1iIvQaa4TrueIT_E4TrueITL0__EEEvz", "void test2::friend 
i(...)"},
  +{"_ZN5test21jIvQ4TrueITL0__EEEvz", "void test2::j(...)"},
  +{"_ZN5test2F1kITk4TruevQ4TrueIT_EEEvz", "void test2::friend 
k(...)"},
  +{"_ZN5test21lITk4TruevEEvz", "void test2::l(...)"},
  +{"_ZN5test31dITnDaLi0EEEvv", "void test3::d<0>()"},
  +{"_ZN5test31eITnDcLi0EEEvv", "void test3::e<0>()"},
  +{"_ZN5test31fITnDk1CLi0EEEvv", "void test3::f<0>()"},
  +{"_ZN5test31gITnDk1DIiELi0EEEvv", "void test3::g<0>()"},
  +{"_ZN5test31hIiTnDk1DIT_ELi0EEEvv", "void test3::h()"},
  +{"_ZN5test31iIiEEvDTnw_Dk1CpicvT__EEE", "void test3::i(decltype(new 
C auto((int)("},
  +{"_ZN5test31jIiEEvDTnw_DK1CpicvT__EEE", "void test3::j(decltype(new 
C decltype(auto)((int)("},
  +{"_ZN5test41fITk1CiEEvv", "void test4::f()"},
  +{"_ZN5test41gITk1DIiEiEEvv", "void test4::g()"},
  +{"_ZN5test51fINS_1XEEEvv", "void test5::f()"},
  +{"_ZN5test51fITtTyTnTL0__ENS_1YEEEvv", "void test5::f()"},
  +{"_ZN5test51fITtTyTnTL0__ENS_1ZEEEvv", "void test5::f()"},
  +{"_ZN5test51gITtTyTnTL0__Q1CIS1_EENS_1XEEEvv", "void 
test5::g()"},
  +{"_ZN5test51gINS_1YEEEvv", "void test5::g()"},
  +{"_ZN5test51gITtTyTnTL0__Q1CIS1_EENS_1ZEEEvv", "void 
test5::g()"},
  +{"_ZN5test51hITtTk1CTnTL0__ENS_1XEEEvv", "void test5::h()"},
  +{"_ZN5test51hITtTk1CTnTL0__ENS_1YEEEvv", "void test5::h()"},
  +{"_ZN5test51hINS_1ZEEEvv", "void test5::h()"},
  +{"_ZN5test51iITpTtTk1CTnTL0__EJNS_1XENS_1YENS_1Zvv", "void 
test5::i()"},
  +{"_ZN5test51iITpTtTk1CTnTL0__EJNS_1YENS_1ZENS_1Xvv", "void 
test5::i()"},
  +{"_ZN5test51iIJNS_1ZENS_1XENS_1Yvv", "void test5::i()"},
  +{"_ZN5test51pINS_1AEEEvv", "void test5::p()"},
  +{"_ZN5test51pITtTpTyENS_1BEEEvv", "void test5::p()"},
  +{"_ZN5test51qITtTyTyENS_1AEEEvv", "void test5::q()"},
  +{"_ZN5test51qINS_1BEEEvv", "void test5::q()"},
  +{"_ZN5test61fITk1CiEEvT_", "void test6::f(int)"},
  +{"_ZN5test61gIiTk1DIT_EiEEvT0_", "void test6::g(int)"},
  +
{"_ZZN5test71fIiEEvvENKUlTyQaa1CIT_E1CITL0__ET0_E_clIiiEEDaS3_Q1CIDtfp_EE", 
"auto void test7::f()::'lambda' requires C && C 
(auto)::operator()(auto) const requires C"},
  +

[PATCH] D146042: [clang-format] Fix numerous issues with "LambdaBodyIndentation: OuterScope" option

2023-04-05 Thread Jon Phillips via Phabricator via cfe-commits
jp4a50 added a comment.

Thanks for accepting!

Commit details as follows as per previous diff:

Name: Jon Phillips
Email: jonap2...@gmail.com

If someone could commit for me that would be much appreciated.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146042

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


[clang] 65c0134 - [clang][deps] NFC: Make PCH test more debuggable

2023-04-05 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2023-04-05T12:29:05-07:00
New Revision: 65c0134872c1e298ade176b5c84d86b4a058a85c

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

LOG: [clang][deps] NFC: Make PCH test more debuggable

Overwriting CDB files made it difficult to debug earlier clang-scan-deps 
invocations. This commit creates separate files for each.

Added: 


Modified: 
clang/test/ClangScanDeps/modules-pch.c

Removed: 




diff  --git a/clang/test/ClangScanDeps/modules-pch.c 
b/clang/test/ClangScanDeps/modules-pch.c
index 0e1e72225cb4a..aa568e5aaab4d 100644
--- a/clang/test/ClangScanDeps/modules-pch.c
+++ b/clang/test/ClangScanDeps/modules-pch.c
@@ -7,8 +7,8 @@
 
 // Scan dependencies of the PCH:
 //
-// RUN: sed "s|DIR|%/t|g" %S/Inputs/modules-pch/cdb_pch.json > %t/cdb.json
-// RUN: clang-scan-deps -compilation-database %t/cdb.json -format 
experimental-full \
+// RUN: sed "s|DIR|%/t|g" %S/Inputs/modules-pch/cdb_pch.json > %t/cdb_pch.json
+// RUN: clang-scan-deps -compilation-database %t/cdb_pch.json -format 
experimental-full \
 // RUN:   -module-files-dir %t/build > %t/result_pch.json
 // RUN: cat %t/result_pch.json | sed 's:\?:/:g' | FileCheck %s 
-DPREFIX=%/t -check-prefix=CHECK-PCH
 //
@@ -94,8 +94,8 @@
 
 // Scan dependencies of the TU:
 //
-// RUN: sed "s|DIR|%/t|g" %S/Inputs/modules-pch/cdb_tu.json > %t/cdb.json
-// RUN: clang-scan-deps -compilation-database %t/cdb.json -format 
experimental-full \
+// RUN: sed "s|DIR|%/t|g" %S/Inputs/modules-pch/cdb_tu.json > %t/cdb_tu.json
+// RUN: clang-scan-deps -compilation-database %t/cdb_tu.json -format 
experimental-full \
 // RUN:   -module-files-dir %t/build > %t/result_tu.json
 // RUN: cat %t/result_tu.json | sed 's:\?:/:g' | FileCheck %s -DPREFIX=%/t 
-check-prefix=CHECK-TU
 //
@@ -142,8 +142,8 @@
 
 // Scan dependencies of the TU that has common modules with the PCH:
 //
-// RUN: sed "s|DIR|%/t|g" %S/Inputs/modules-pch/cdb_tu_with_common.json > 
%t/cdb.json
-// RUN: clang-scan-deps -compilation-database %t/cdb.json -format 
experimental-full \
+// RUN: sed "s|DIR|%/t|g" %S/Inputs/modules-pch/cdb_tu_with_common.json > 
%t/cdb_tu_with_common.json
+// RUN: clang-scan-deps -compilation-database %t/cdb_tu_with_common.json 
-format experimental-full \
 // RUN:   -module-files-dir %t/build > %t/result_tu_with_common.json
 // RUN: cat %t/result_tu_with_common.json | sed 's:\?:/:g' | FileCheck %s 
-DPREFIX=%/t -check-prefix=CHECK-TU-WITH-COMMON
 //



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


[clang] 34f1439 - [clang][deps] NFC: Don't collect PCH input files

2023-04-05 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2023-04-05T12:29:03-07:00
New Revision: 34f143988f3f18dcca6d26a7a9817d8523300440

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

LOG: [clang][deps] NFC: Don't collect PCH input files

Since b4c83a13, PCH input files are no longer necessary.

Added: 


Modified: 
clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp

Removed: 




diff  --git a/clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp 
b/clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
index 5869418b98dfe..937f39ba3bffa 100644
--- a/clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
+++ b/clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
@@ -66,30 +66,19 @@ using PrebuiltModuleFilesT = 
decltype(HeaderSearchOptions::PrebuiltModuleFiles);
 class PrebuiltModuleListener : public ASTReaderListener {
 public:
   PrebuiltModuleListener(PrebuiltModuleFilesT ,
- llvm::StringSet<> , bool VisitInputFiles,
  llvm::SmallVector )
-  : PrebuiltModuleFiles(PrebuiltModuleFiles), InputFiles(InputFiles),
-VisitInputFiles(VisitInputFiles), NewModuleFiles(NewModuleFiles) {}
+  : PrebuiltModuleFiles(PrebuiltModuleFiles),
+NewModuleFiles(NewModuleFiles) {}
 
   bool needsImportVisitation() const override { return true; }
-  bool needsInputFileVisitation() override { return VisitInputFiles; }
-  bool needsSystemInputFileVisitation() override { return VisitInputFiles; }
 
   void visitImport(StringRef ModuleName, StringRef Filename) override {
 if (PrebuiltModuleFiles.insert({ModuleName.str(), Filename.str()}).second)
   NewModuleFiles.push_back(Filename.str());
   }
 
-  bool visitInputFile(StringRef Filename, bool isSystem, bool isOverridden,
-  bool isExplicitModule) override {
-InputFiles.insert(Filename);
-return true;
-  }
-
 private:
   PrebuiltModuleFilesT 
-  llvm::StringSet<> 
-  bool VisitInputFiles;
   llvm::SmallVector 
 };
 
@@ -97,13 +86,10 @@ class PrebuiltModuleListener : public ASTReaderListener {
 /// transitively imports and contributing input files.
 static void visitPrebuiltModule(StringRef PrebuiltModuleFilename,
 CompilerInstance ,
-PrebuiltModuleFilesT ,
-llvm::StringSet<> ,
-bool VisitInputFiles) {
+PrebuiltModuleFilesT ) {
   // List of module files to be processed.
   llvm::SmallVector Worklist{PrebuiltModuleFilename.str()};
-  PrebuiltModuleListener Listener(ModuleFiles, InputFiles, VisitInputFiles,
-  Worklist);
+  PrebuiltModuleListener Listener(ModuleFiles, Worklist);
 
   while (!Worklist.empty())
 ASTReader::readASTFileControlBlock(
@@ -204,15 +190,13 @@ class DependencyScanningAction : public 
tooling::ToolAction {
 
 ScanInstance.createSourceManager(*FileMgr);
 
-llvm::StringSet<> PrebuiltModulesInputFiles;
 // Store the list of prebuilt module files into header search options. This
 // will prevent the implicit build to create duplicate modules and will
 // force reuse of the existing prebuilt module files instead.
 if (!ScanInstance.getPreprocessorOpts().ImplicitPCHInclude.empty())
   visitPrebuiltModule(
   ScanInstance.getPreprocessorOpts().ImplicitPCHInclude, ScanInstance,
-  ScanInstance.getHeaderSearchOpts().PrebuiltModuleFiles,
-  PrebuiltModulesInputFiles, /*VisitInputFiles=*/DepFS != nullptr);
+  ScanInstance.getHeaderSearchOpts().PrebuiltModuleFiles);
 
 // Use the dependency scanning optimized file system if requested to do so.
 if (DepFS) {



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


[PATCH] D146376: Update static_assert message for redundant cases

2023-04-05 Thread Krishna Narayanan via Phabricator via cfe-commits
Krishna-13-cyber updated this revision to Diff 511181.
Krishna-13-cyber added a comment.

- Updated with the diagnostic messages (comments for test cases)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146376

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/SemaCXX/static-assert.cpp


Index: clang/test/SemaCXX/static-assert.cpp
===
--- clang/test/SemaCXX/static-assert.cpp
+++ clang/test/SemaCXX/static-assert.cpp
@@ -258,8 +258,14 @@
   constexpr bool invert(bool b) {
 return !b;
   }
-  static_assert(invert(true) == invert(false), ""); // expected-error 
{{failed}} \
+
+  static_assert(invert(true) || invert(true), ""); // expected-error {{static 
assertion failed due to requirement 'invert(true) || invert(true)'}}
+  static_assert(invert(true) == invert(false), ""); // expected-error {{static 
assertion failed due to requirement 'invert(true) == invert(false)'}} \
 // expected-note 
{{evaluates to 'false == true'}}
+  static_assert(true && false, ""); // expected-error {{static assertion 
failed due to requirement 'true && false'}}
+  static_assert(invert(true) || invert(true) || false, ""); // expected-error 
{{static assertion failed due to requirement 'invert(true) || invert(true) || 
false'}}
+  static_assert((true && invert(true)) || false, ""); // expected-error 
{{static assertion failed due to requirement '(true && invert(true)) || false'}}
+  static_assert(true && invert(false) && invert(true), ""); // expected-error 
{{static assertion failed due to requirement 'invert(true)'}}
 
   /// No notes here since we compare a bool expression with a bool literal.
   static_assert(invert(true) == true, ""); // expected-error {{failed}}
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -16715,7 +16715,8 @@
 /// Try to print more useful information about a failed static_assert
 /// with expression \E
 void Sema::DiagnoseStaticAssertDetails(const Expr *E) {
-  if (const auto *Op = dyn_cast(E)) {
+  if (const auto *Op = dyn_cast(E);
+  Op && Op->getOpcode() != BO_LOr) {
 const Expr *LHS = Op->getLHS()->IgnoreParenImpCasts();
 const Expr *RHS = Op->getRHS()->IgnoreParenImpCasts();
 
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -179,6 +179,9 @@
 - Clang now avoids duplicate warnings on unreachable ``[[fallthrough]];`` 
statements
   previously issued from ``-Wunreachable-code`` and 
``-Wunreachable-code-fallthrough``
   by prioritizing ``-Wunreachable-code-fallthrough``.
+- Clang now avoids unnecessary diagnostic warnings for obvious expressions in
+  the case of binary operators with logical OR operations.
+  (`#57906 `_)
 
 Bug Fixes in This Version
 -


Index: clang/test/SemaCXX/static-assert.cpp
===
--- clang/test/SemaCXX/static-assert.cpp
+++ clang/test/SemaCXX/static-assert.cpp
@@ -258,8 +258,14 @@
   constexpr bool invert(bool b) {
 return !b;
   }
-  static_assert(invert(true) == invert(false), ""); // expected-error {{failed}} \
+
+  static_assert(invert(true) || invert(true), ""); // expected-error {{static assertion failed due to requirement 'invert(true) || invert(true)'}}
+  static_assert(invert(true) == invert(false), ""); // expected-error {{static assertion failed due to requirement 'invert(true) == invert(false)'}} \
 // expected-note {{evaluates to 'false == true'}}
+  static_assert(true && false, ""); // expected-error {{static assertion failed due to requirement 'true && false'}}
+  static_assert(invert(true) || invert(true) || false, ""); // expected-error {{static assertion failed due to requirement 'invert(true) || invert(true) || false'}}
+  static_assert((true && invert(true)) || false, ""); // expected-error {{static assertion failed due to requirement '(true && invert(true)) || false'}}
+  static_assert(true && invert(false) && invert(true), ""); // expected-error {{static assertion failed due to requirement 'invert(true)'}}
 
   /// No notes here since we compare a bool expression with a bool literal.
   static_assert(invert(true) == true, ""); // expected-error {{failed}}
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -16715,7 +16715,8 @@
 /// Try to print more useful information about a failed static_assert
 /// with expression \E
 void 

[clang] 385bcc6 - Revert "[clang][lit] Make LIT aware of env CLANG_CRASH_DIAGNOSTICS_DIR."

2023-04-05 Thread Francesco Petrogalli via cfe-commits

Author: Francesco Petrogalli
Date: 2023-04-05T20:55:08+02:00
New Revision: 385bcc65ff44d9860572ee85adb5df1333860a05

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

LOG: Revert "[clang][lit] Make LIT aware of env CLANG_CRASH_DIAGNOSTICS_DIR."

This reverts commit 029212617ca8bdedd949d17bf2d33750605ea607.

Reverting because of failures when setting
`CLANG_CRASH_DIAGNOSTICS_DIR` before invoking `ninja check-clang`.

Added: 


Modified: 
clang/test/lit.cfg.py

Removed: 




diff  --git a/clang/test/lit.cfg.py b/clang/test/lit.cfg.py
index 7c5a55c8e313..e9bfaf2e9677 100644
--- a/clang/test/lit.cfg.py
+++ b/clang/test/lit.cfg.py
@@ -284,10 +284,6 @@ def exclude_unsupported_files_for_aix(dirname):
 config.substitutions.append(('llvm-nm', 'env OBJECT_MODE=any llvm-nm'))
 config.substitutions.append(('llvm-ar', 'env OBJECT_MODE=any llvm-ar'))
 
-# Pass the crash diagnostic dir set in the os environment to LIT.
-if 'CLANG_CRASH_DIAGNOSTICS_DIR' in os.environ:
-config.environment['CLANG_CRASH_DIAGNOSTICS_DIR'] = 
os.environ['CLANG_CRASH_DIAGNOSTICS_DIR']
-
 # It is not realistically possible to account for all options that could
 # possibly be present in system and user configuration files, so disable
 # default configs for the test runs.



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


[PATCH] D146654: [clang] replaces numeric SARIF ids with heirarchical names

2023-04-05 Thread Vaibhav Yenamandra via Phabricator via cfe-commits
vaibhav.y added inline comments.



Comment at: clang/lib/Frontend/SARIFDiagnostic.cpp:51-52
+  Diag->getDiags()->getDiagnosticIDs()->getStableName(Diag->getID()).str();
+  std::replace(StableName.begin(), StableName.end(), '_', '.');
+  SarifRule Rule = SarifRule::create().setRuleId(StableName);
 

cjdb wrote:
> denik wrote:
> > §3.5.4 says that the hierarchical strings are separated by "/".
> > 
> > But more generally, are diagnostic names really fall under "hierarchical" 
> > definition?
> > Words between underscores should be treated as components. And $3.27.5 says 
> > that the leading components have to be the identifier of the rule.
> > In some cases they look like valid components, e.g. `err_access`, 
> > `err_access_dtor`, `err_access_dtor_exception`.
> > But in cases like `err_cannot_open_file` neither of the leading components 
> > exists.
> > 
> > Theoretically we could use groups as the leading component for warnings for 
> > example. For errors the leading components are probably not even necessary, 
> > since if I understood correctly they are needed to suppress subsets of 
> > violations on the SARIF consumer side.
> > Or we just could keep the names with underscores as is. WDYT?
> I think in light of what you've said, changing back to underscores is 
> probably best.
> But more generally, are diagnostic names really fall under "hierarchical" 
> definition?

I have the same concern, but this is okay for a first pass as a "flat 
hierarchy" :)

If we want a deeper structure, we'll need some extra metadata in 
`DiagnosticSemaKinds.td`'s `Error<...>`  to add cluster names as a follow up to 
this.

WDYT about something like `clang/visibility/err_access` or 
`clang/syntax/err_stmtexpr_file_scope`.

Alternatively: we could draw from the c++ standard structure: 
https://eel.is/c++draft/basic.def.odr#term.odr.use and say the error code for 
an ODR violation could be `clang/basic/def/odr`, again I'm unsure how well this 
meshes with clang's diagnostic model.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146654

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


[PATCH] D147209: [clang][lit] Make LIT aware of env CLANG_CRASH_DIAGNOSTICS_DIR.

2023-04-05 Thread Francesco Petrogalli via Phabricator via cfe-commits
fpetrogalli added a comment.

In D147209#4246622 , @leonardchan 
wrote:

> In D147209#4245229 , @fpetrogalli 
> wrote:
>
>> In D147209#4244615 , @leonardchan 
>> wrote:
>>
>>> Hi. I think this led to some test failures on our builder at 
>>> https://luci-milo.appspot.com/ui/p/fuchsia/builders/toolchain.ci/clang-linux-x64/b8784708268307261009/overview:
>>
>> Hi @leonardchan - thank you for the heads up!
>>
>> I do not have access to this bot (the link you sent just shows me a blank 
>> page), and I have not seen this (clang?) test failing in my local build. I 
>> can revert the patch, but I'll need some more info to be able to fix those 
>> failures.
>>
>> Francesco
>
> Hmm, that's interesting since the link should be public and normally doesn't 
> just appear as blank. Does it still show up as blank if you click it again? 
> Otherwise I can share the full repro. I think you should be able to reproduce 
> this if you define `CLANG_CRASH_DIAGNOSTICS_DIR` as an environment variable 
> before running `ninja check-clang`.

yep - still a white page for me...

Anyway, thank you for the suggestion - I managed to reproduce the issue (for 
example, `FAIL: Clang :: Driver/crash-report.cpp (93 of 17575)`), I'll revert 
and submit a new patch with the fix.

Francesco


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147209

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


[PATCH] D147569: [Coverage] Fix crash when visiting PseudoObjectExpr.

2023-04-05 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu added a comment.

Added the missing release note at rG5bab9097ce5b093289e8d40809d02f002febe910 
.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147569

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


[clang] 5bab909 - Add release note for D147569.

2023-04-05 Thread Zequan Wu via cfe-commits

Author: Zequan Wu
Date: 2023-04-05T14:43:52-04:00
New Revision: 5bab9097ce5b093289e8d40809d02f002febe910

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

LOG: Add release note for D147569.

Added: 


Modified: 
clang/docs/ReleaseNotes.rst

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index bbfef9ff3cf7..03d14fc89be4 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -276,7 +276,9 @@ Bug Fixes in This Version
 - Fix crash when handling nested immediate invocations in initializers of 
global
   variables.
   (`#58207 `_)
-
+- Fix crash when generating code coverage information for `PseudoObjectExpr` 
in 
+  Clang AST.
+  (`#45481 `_)
 
 Bug Fixes to Compiler Builtins
 ^^



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


[PATCH] D147569: [Coverage] Fix crash when visiting PseudoObjectExpr.

2023-04-05 Thread Zequan Wu 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 rG4e93bd417445: [Coverage] Fix crash when visiting 
PseudoObjectExpr. (authored by zequanwu).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147569

Files:
  clang/lib/CodeGen/CoverageMappingGen.cpp
  clang/test/CoverageMapping/if.cpp
  clang/test/CoverageMapping/strong_order.cpp

Index: clang/test/CoverageMapping/strong_order.cpp
===
--- /dev/null
+++ clang/test/CoverageMapping/strong_order.cpp
@@ -0,0 +1,53 @@
+// RUN: %clang_cc1 -mllvm -emptyline-comment-coverage=false -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -std=c++2b -triple %itanium_abi_triple -main-file-name if.cpp %s
+
+// No crash for following example.
+// See https://github.com/llvm/llvm-project/issues/45481
+namespace std {
+class strong_ordering;
+
+// Mock how STD defined unspecified parameters for the operators below.
+struct _CmpUnspecifiedParam {
+  consteval
+  _CmpUnspecifiedParam(int _CmpUnspecifiedParam::*) noexcept {}
+};
+
+struct strong_ordering {
+  signed char value;
+
+  friend constexpr bool operator==(strong_ordering v,
+   _CmpUnspecifiedParam) noexcept {
+return v.value == 0;
+  }
+  friend constexpr bool operator<(strong_ordering v,
+  _CmpUnspecifiedParam) noexcept {
+return v.value < 0;
+  }
+  friend constexpr bool operator>(strong_ordering v,
+  _CmpUnspecifiedParam) noexcept {
+return v.value > 0;
+  }
+  friend constexpr bool operator>=(strong_ordering v,
+   _CmpUnspecifiedParam) noexcept {
+return v.value >= 0;
+  }
+  static const strong_ordering equal, greater, less;
+};
+constexpr strong_ordering strong_ordering::equal = {0};
+constexpr strong_ordering strong_ordering::greater = {1};
+constexpr strong_ordering strong_ordering::less = {-1};
+} // namespace std
+
+struct S {
+friend bool operator<(const S&, const S&);
+friend bool operator==(const S&, const S&);
+};
+
+struct MyStruct {
+friend bool operator==(MyStruct const& lhs, MyStruct const& rhs) = delete;
+friend std::strong_ordering operator<=>(MyStruct const& lhs, MyStruct const& rhs) = default;
+S value;
+};
+
+void foo(MyStruct bar){
+(void)(bar <=> bar);
+}
Index: clang/test/CoverageMapping/if.cpp
===
--- clang/test/CoverageMapping/if.cpp
+++ clang/test/CoverageMapping/if.cpp
@@ -1,6 +1,14 @@
-// RUN: %clang_cc1 -mllvm -emptyline-comment-coverage=false -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -std=c++2b -triple %itanium_abi_triple -main-file-name if.cpp %s | FileCheck %s
+// RUN: %clang_cc1 -fms-extensions -mllvm -emptyline-comment-coverage=false -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -std=c++2b -triple %itanium_abi_triple -main-file-name if.cpp %s | FileCheck %s
 
 int nop() { return 0; }
+struct S {
+   int i;
+   int putprop(int j) {
+  i = j;
+  return i;
+   }
+   __declspec(property(put = putprop)) int the_prop;
+};
 
 // CHECK-LABEL: _Z3foov:
 // CHECK-NEXT: [[@LINE+3]]:12 -> [[@LINE+8]]:2 = #0
@@ -70,7 +78,17 @@
   constexpr int c_i = check_consteval(0);
   check_consteval(i);
 
-  return 0;
+  // GH-45481
+  S s;
+  s.the_prop = 0? 1 : 2;// CHECK-NEXT: File 0, [[@LINE]]:16 -> [[@LINE]]:17 = #0
+// CHECK-NEXT: Branch,File 0, [[@LINE-1]]:16 -> [[@LINE-1]]:17 = 0, 0
+// CHECK-NEXT: Gap,File 0, [[@LINE-2]]:18 -> [[@LINE-2]]:19 = #7
+// CHECK-NEXT: File 0, [[@LINE-3]]:19 -> [[@LINE-3]]:20 = #7
+// CHECK-NEXT: File 0, [[@LINE-4]]:23 -> [[@LINE-4]]:24 = (#0 - #7)
+  if (s.the_prop = 1) { // CHECK-NEXT: File 0, [[@LINE]]:7 -> [[@LINE]]:21 = #0
+ return 1;  // CHECK-NEXT: Branch,File 0, [[@LINE-1]]:7 -> [[@LINE-1]]:21 = #8, (#0 - #8)
+  } // CHECK-NEXT: Gap,File 0, [[@LINE-2]]:22 -> [[@LINE-2]]:23 = #8
+// CHECK-NEXT: File 0, [[@LINE-3]]:23 -> [[@LINE-1]]:4 = #8
 }
 
 #define FOO true
Index: clang/lib/CodeGen/CoverageMappingGen.cpp
===
--- clang/lib/CodeGen/CoverageMappingGen.cpp
+++ clang/lib/CodeGen/CoverageMappingGen.cpp
@@ -1566,6 +1566,15 @@
 // Lambdas are treated as their own functions for now, so we shouldn't
 // propagate counts into them.
   }
+
+  void VisitPseudoObjectExpr(const PseudoObjectExpr *POE) {
+// Just visit syntatic expression 

[clang] 4e93bd4 - [Coverage] Fix crash when visiting PseudoObjectExpr.

2023-04-05 Thread Zequan Wu via cfe-commits

Author: Zequan Wu
Date: 2023-04-05T14:37:41-04:00
New Revision: 4e93bd4174454c7c70b8f2fa7512e2f97681f295

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

LOG: [Coverage] Fix crash when visiting PseudoObjectExpr.

This is a split of D147073.

Fixes #45481

Reviewed By: aaron.ballman

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

Added: 
clang/test/CoverageMapping/strong_order.cpp

Modified: 
clang/lib/CodeGen/CoverageMappingGen.cpp
clang/test/CoverageMapping/if.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CoverageMappingGen.cpp 
b/clang/lib/CodeGen/CoverageMappingGen.cpp
index 68e6457419ab1..426ac39b8767e 100644
--- a/clang/lib/CodeGen/CoverageMappingGen.cpp
+++ b/clang/lib/CodeGen/CoverageMappingGen.cpp
@@ -1566,6 +1566,15 @@ struct CounterCoverageMappingBuilder
 // Lambdas are treated as their own functions for now, so we shouldn't
 // propagate counts into them.
   }
+
+  void VisitPseudoObjectExpr(const PseudoObjectExpr *POE) {
+// Just visit syntatic expression as this is what users actually write.
+VisitStmt(POE->getSyntacticForm());
+  }
+
+  void VisitOpaqueValueExpr(const OpaqueValueExpr* OVE) {
+Visit(OVE->getSourceExpr());
+  }
 };
 
 } // end anonymous namespace

diff  --git a/clang/test/CoverageMapping/if.cpp 
b/clang/test/CoverageMapping/if.cpp
index de3554c100b96..f477db980e7f4 100644
--- a/clang/test/CoverageMapping/if.cpp
+++ b/clang/test/CoverageMapping/if.cpp
@@ -1,6 +1,14 @@
-// RUN: %clang_cc1 -mllvm -emptyline-comment-coverage=false 
-fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping 
-emit-llvm-only -std=c++2b -triple %itanium_abi_triple -main-file-name if.cpp 
%s | FileCheck %s
+// RUN: %clang_cc1 -fms-extensions -mllvm -emptyline-comment-coverage=false 
-fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping 
-emit-llvm-only -std=c++2b -triple %itanium_abi_triple -main-file-name if.cpp 
%s | FileCheck %s
 
 int nop() { return 0; }
+struct S {
+   int i;
+   int putprop(int j) {
+  i = j;
+  return i;
+   }
+   __declspec(property(put = putprop)) int the_prop;
+};
 
 // CHECK-LABEL: _Z3foov:
 // CHECK-NEXT: [[@LINE+3]]:12 -> [[@LINE+8]]:2 
= #0
@@ -70,7 +78,17 @@ int main() {// CHECK: File 0, 
[[@LINE]]:12 -> {{[0-9]+}}:2 =
   constexpr int c_i = check_consteval(0);
   check_consteval(i);
 
-  return 0;
+  // GH-45481
+  S s;
+  s.the_prop = 0? 1 : 2;// CHECK-NEXT: File 0, [[@LINE]]:16 -> 
[[@LINE]]:17 = #0
+// CHECK-NEXT: Branch,File 0, [[@LINE-1]]:16 
-> [[@LINE-1]]:17 = 0, 0
+// CHECK-NEXT: Gap,File 0, [[@LINE-2]]:18 -> 
[[@LINE-2]]:19 = #7
+// CHECK-NEXT: File 0, [[@LINE-3]]:19 -> 
[[@LINE-3]]:20 = #7
+// CHECK-NEXT: File 0, [[@LINE-4]]:23 -> 
[[@LINE-4]]:24 = (#0 - #7)
+  if (s.the_prop = 1) { // CHECK-NEXT: File 0, [[@LINE]]:7 -> 
[[@LINE]]:21 = #0
+ return 1;  // CHECK-NEXT: Branch,File 0, [[@LINE-1]]:7 -> 
[[@LINE-1]]:21 = #8, (#0 - #8)
+  } // CHECK-NEXT: Gap,File 0, [[@LINE-2]]:22 -> 
[[@LINE-2]]:23 = #8
+// CHECK-NEXT: File 0, [[@LINE-3]]:23 -> 
[[@LINE-1]]:4 = #8
 }
 
 #define FOO true

diff  --git a/clang/test/CoverageMapping/strong_order.cpp 
b/clang/test/CoverageMapping/strong_order.cpp
new file mode 100644
index 0..ebda311d2489b
--- /dev/null
+++ b/clang/test/CoverageMapping/strong_order.cpp
@@ -0,0 +1,53 @@
+// RUN: %clang_cc1 -mllvm -emptyline-comment-coverage=false 
-fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping 
-emit-llvm-only -std=c++2b -triple %itanium_abi_triple -main-file-name if.cpp %s
+
+// No crash for following example.
+// See https://github.com/llvm/llvm-project/issues/45481
+namespace std {
+class strong_ordering;
+
+// Mock how STD defined unspecified parameters for the operators below.
+struct _CmpUnspecifiedParam {
+  consteval
+  _CmpUnspecifiedParam(int _CmpUnspecifiedParam::*) noexcept {}
+};
+
+struct strong_ordering {
+  signed char value;
+
+  friend constexpr bool operator==(strong_ordering v,
+   _CmpUnspecifiedParam) noexcept {
+return v.value == 0;
+  }
+  friend constexpr bool operator<(strong_ordering v,
+  _CmpUnspecifiedParam) noexcept {
+return v.value < 0;
+  }
+  friend constexpr bool operator>(strong_ordering v,
+  _CmpUnspecifiedParam) noexcept {
+return v.value > 0;
+  }
+  friend constexpr bool operator>=(strong_ordering v,
+   _CmpUnspecifiedParam) noexcept 

[PATCH] D147209: [clang][lit] Make LIT aware of env CLANG_CRASH_DIAGNOSTICS_DIR.

2023-04-05 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added a comment.

In D147209#4245229 , @fpetrogalli 
wrote:

> In D147209#4244615 , @leonardchan 
> wrote:
>
>> Hi. I think this led to some test failures on our builder at 
>> https://luci-milo.appspot.com/ui/p/fuchsia/builders/toolchain.ci/clang-linux-x64/b8784708268307261009/overview:
>
> Hi @leonardchan - thank you for the heads up!
>
> I do not have access to this bot (the link you sent just shows me a blank 
> page), and I have not seen this (clang?) test failing in my local build. I 
> can revert the patch, but I'll need some more info to be able to fix those 
> failures.
>
> Francesco

Hmm, that's interesting since the link should be public and normally doesn't 
just appear as blank. Does it still show up as blank if you click it again? 
Otherwise I can share the full repro. I think you should be able to reproduce 
this if you define `CLANG_CRASH_DIAGNOSTICS_DIR` as an environment variable 
before running `ninja check-clang`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147209

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


[PATCH] D147569: [Coverage] Fix crash when visiting PseudoObjectExpr.

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

Thank you, this looks much better to me! LGTM, but please add a release note 
about the fix when landing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147569

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


[PATCH] D144651: [Serialization] Place command line defines in the correct file

2023-04-05 Thread John Brawn via Phabricator via cfe-commits
john.brawn updated this revision to Diff 511153.
john.brawn edited the summary of this revision.
john.brawn added a comment.

New version that checks for special filenames in ResolveImportedPath. I spent a 
while trying to come up with a test using just clang where not doing this 
fails, but couldn't as it looks like the failure is specific to objective-c 
module handing in lldb.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144651

Files:
  clang-tools-extra/clangd/index/SymbolCollector.cpp
  clang/docs/ReleaseNotes.rst
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/PCH/macro-cmdline.c
  clang/test/PCH/ms-pch-macro.c

Index: clang/test/PCH/ms-pch-macro.c
===
--- clang/test/PCH/ms-pch-macro.c
+++ clang/test/PCH/ms-pch-macro.c
@@ -36,4 +36,4 @@
 // CHECK-FOO: definition of macro 'FOO' differs between the precompiled header ('1') and the command line ('blah')
 // CHECK-NOFOO: macro 'FOO' was defined in the precompiled header but undef'd on the command line
 
-// expected-warning@1 {{definition of macro 'BAR' does not match definition in precompiled header}}
+// expected-warning@2 {{definition of macro 'BAR' does not match definition in precompiled header}}
Index: clang/test/PCH/macro-cmdline.c
===
--- /dev/null
+++ clang/test/PCH/macro-cmdline.c
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 %s -emit-pch -o %t1.pch -DMACRO1=1
+// RUN: %clang_cc1 -fsyntax-only %s -include-pch %t1.pch -DMACRO2=1 2>&1 | FileCheck %s
+
+#ifndef HEADER
+#define HEADER
+#else
+#define MACRO1 2
+// CHECK: macro-cmdline.c{{.*}}'MACRO1' macro redefined
+// CHECK: {{.*}}previous definition is here
+#define MACRO2 2
+// CHECK: macro-cmdline.c{{.*}}'MACRO2' macro redefined
+// CHECK: {{.*}}previous definition is here
+#endif
Index: clang/lib/Serialization/ASTWriter.cpp
===
--- clang/lib/Serialization/ASTWriter.cpp
+++ clang/lib/Serialization/ASTWriter.cpp
@@ -,6 +,11 @@
 bool ASTWriter::PreparePathForOutput(SmallVectorImpl ) {
   assert(Context && "should have context when outputting path");
 
+  // Leave special file names as they are.
+  StringRef PathStr(Path.data(), Path.size());
+  if (PathStr == "" || PathStr == "")
+return false;
+
   bool Changed =
   cleanPathForOutput(Context->getSourceManager().getFileManager(), Path);
 
Index: clang/lib/Serialization/ASTReader.cpp
===
--- clang/lib/Serialization/ASTReader.cpp
+++ clang/lib/Serialization/ASTReader.cpp
@@ -654,6 +654,10 @@
   SmallVector ExistingMacroNames;
   collectMacroDefinitions(ExistingPPOpts, ExistingMacros, );
 
+  // Use a line marker to enter the  file, as the defines and
+  // undefines here will have come from the command line.
+  SuggestedPredefines += "# 1 \"\" 1\n";
+
   for (unsigned I = 0, N = ExistingMacroNames.size(); I != N; ++I) {
 // Dig out the macro definition in the existing preprocessor options.
 StringRef MacroName = ExistingMacroNames[I];
@@ -713,6 +717,10 @@
 }
 return true;
   }
+
+  // Leave the  file and return to .
+  SuggestedPredefines += "# 1 \"\" 2\n";
+
   if (Validation == OptionValidateStrictMatches) {
 // If strict matches are requested, don't tolerate any extra defines in
 // the AST file that are missing on the command line.
@@ -1579,8 +1587,13 @@
 auto Buffer = ReadBuffer(SLocEntryCursor, Name);
 if (!Buffer)
   return true;
-SourceMgr.createFileID(std::move(Buffer), FileCharacter, ID,
-   BaseOffset + Offset, IncludeLoc);
+FileID FID = SourceMgr.createFileID(std::move(Buffer), FileCharacter, ID,
+BaseOffset + Offset, IncludeLoc);
+if (Record[3]) {
+  auto  =
+  const_cast(SourceMgr.getSLocEntry(FID).getFile());
+  FileInfo.setHasLineDirectives();
+}
 break;
   }
 
@@ -2510,7 +2523,8 @@
 }
 
 void ASTReader::ResolveImportedPath(std::string , StringRef Prefix) {
-  if (Filename.empty() || llvm::sys::path::is_absolute(Filename))
+  if (Filename.empty() || llvm::sys::path::is_absolute(Filename) ||
+  Filename == "" || Filename == "")
 return;
 
   SmallString<128> Buffer;
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -198,8 +198,8 @@
 - Diagnostic notes and fix-its are now generated for ``ifunc``/``alias`` attributes
   which point to functions whose names are mangled.
 - Diagnostics relating to macros on the command line of a preprocessed assembly
-  file are now reported as coming from the file  instead of
-  .
+  file or precompiled header are now reported as coming from 

[PATCH] D147324: [OpenMP][MLIR][Flang][bbc][Driver] Add OpenMP RTL Flags to Flang and generate omp.FlagsAttr from them

2023-04-05 Thread Andrew Gozillon via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG53152f12a47b: [OpenMP][MLIR][Flang][bbc][Driver] Add OpenMP 
RTL Flags to Flang and generate… (authored by agozillon).

Changed prior to commit:
  https://reviews.llvm.org/D147324?vs=510080=511154#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147324

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Flang.cpp
  flang/include/flang/Frontend/LangOptions.def
  flang/include/flang/Tools/CrossToolHelpers.h
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/lib/Frontend/FrontendActions.cpp
  flang/test/Driver/driver-help.f90
  flang/test/Driver/omp-frontend-forwarding.f90
  flang/test/Lower/OpenMP/rtl-flags.f90
  flang/tools/bbc/bbc.cpp

Index: flang/tools/bbc/bbc.cpp
===
--- flang/tools/bbc/bbc.cpp
+++ flang/tools/bbc/bbc.cpp
@@ -129,6 +129,38 @@
llvm::cl::desc("enable openmp device compilation"),
llvm::cl::init(false));
 
+// A simplified subset of the OpenMP RTL Flags from Flang, only the primary
+// positive options are available, no negative options e.g. fopen_assume* vs
+// fno_open_assume*
+static llvm::cl::opt setOpenMPTargetDebug(
+"fopenmp-target-debug",
+llvm::cl::desc("Enable debugging in the OpenMP offloading device RTL"),
+llvm::cl::init(0));
+
+static llvm::cl::opt setOpenMPThreadSubscription(
+"fopenmp-assume-threads-oversubscription",
+llvm::cl::desc("Assume work-shared loops do not have more "
+   "iterations than participating threads."),
+llvm::cl::init(false));
+
+static llvm::cl::opt setOpenMPTeamSubscription(
+"fopenmp-assume-teams-oversubscription",
+llvm::cl::desc("Assume distributed loops do not have more iterations than "
+   "participating teams."),
+llvm::cl::init(false));
+
+static llvm::cl::opt setOpenMPNoThreadState(
+"fopenmp-assume-no-thread-state",
+llvm::cl::desc(
+"Assume that no thread in a parallel region will modify an ICV."),
+llvm::cl::init(false));
+
+static llvm::cl::opt setOpenMPNoNestedParallelism(
+"fopenmp-assume-no-nested-parallelism",
+llvm::cl::desc("Assume that no thread in a parallel region will encounter "
+   "a parallel region."),
+llvm::cl::init(false));
+
 static llvm::cl::opt enableOpenACC("fopenacc",
  llvm::cl::desc("enable openacc"),
  llvm::cl::init(false));
@@ -244,8 +276,13 @@
   kindMap, loweringOptions, {});
   burnside.lower(parseTree, semanticsContext);
   mlir::ModuleOp mlirModule = burnside.getModule();
-  if (enableOpenMP)
-setOffloadModuleInterfaceAttributes(mlirModule, enableOpenMPDevice);
+  if (enableOpenMP) {
+auto offloadModuleOpts =
+OffloadModuleOpts(setOpenMPTargetDebug, setOpenMPTeamSubscription,
+  setOpenMPThreadSubscription, setOpenMPNoThreadState,
+  setOpenMPNoNestedParallelism, enableOpenMPDevice);
+setOffloadModuleInterfaceAttributes(mlirModule, offloadModuleOpts);
+  }
   std::error_code ec;
   std::string outputName = outputFilename;
   if (!outputName.size())
Index: flang/test/Lower/OpenMP/rtl-flags.f90
===
--- /dev/null
+++ flang/test/Lower/OpenMP/rtl-flags.f90
@@ -0,0 +1,29 @@
+!RUN: %flang_fc1 -emit-fir -fopenmp -fopenmp-is-device %s -o - | FileCheck %s --check-prefix=DEFAULT-DEVICE-FIR
+!RUN: %flang_fc1 -emit-fir -fopenmp %s -o - | FileCheck %s --check-prefix=DEFAULT-HOST-FIR
+!RUN: %flang_fc1 -emit-fir -fopenmp -fopenmp-target-debug -fopenmp-is-device %s -o - | FileCheck %s --check-prefix=DBG-DEVICE-FIR
+!RUN: %flang_fc1 -emit-fir -fopenmp -fopenmp-target-debug=111 -fopenmp-is-device %s -o - | FileCheck %s --check-prefix=DBG-EQ-DEVICE-FIR
+!RUN: %flang_fc1 -emit-fir -fopenmp -fopenmp-assume-teams-oversubscription -fopenmp-is-device %s -o - | FileCheck %s --check-prefix=TEAMS-OSUB-DEVICE-FIR
+!RUN: %flang_fc1 -emit-fir -fopenmp -fopenmp-assume-threads-oversubscription -fopenmp-is-device %s -o - | FileCheck %s --check-prefix=THREAD-OSUB-DEVICE-FIR
+!RUN: %flang_fc1 -emit-fir -fopenmp -fopenmp-assume-no-thread-state -fopenmp-is-device %s -o - | FileCheck %s --check-prefix=THREAD-STATE-DEVICE-FIR
+!RUN: %flang_fc1 -emit-fir -fopenmp -fopenmp-assume-no-nested-parallelism -fopenmp-is-device %s -o - | FileCheck %s --check-prefix=NEST-PAR-DEVICE-FIR
+!RUN: %flang_fc1 -emit-fir -fopenmp -fopenmp-target-debug -fopenmp-assume-teams-oversubscription -fopenmp-assume-no-nested-parallelism -fopenmp-assume-threads-oversubscription -fopenmp-assume-no-thread-state -fopenmp-is-device %s -o - | FileCheck %s --check-prefix=ALL-DEVICE-FIR
+!RUN: bbc -emit-fir -fopenmp -fopenmp-is-device -o - %s 

[clang] 53152f1 - [OpenMP][MLIR][Flang][bbc][Driver] Add OpenMP RTL Flags to Flang and generate omp.FlagsAttr from them

2023-04-05 Thread Andrew Gozillon via cfe-commits

Author: Andrew Gozillon
Date: 2023-04-05T12:50:32-05:00
New Revision: 53152f12a47bf6e97f1f2f2d6b71e7b4d4e3740a

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

LOG: [OpenMP][MLIR][Flang][bbc][Driver] Add OpenMP RTL Flags to Flang and 
generate omp.FlagsAttr from them

This patch ports OpenMP RTL flags from the shared Clang compiler
options to Flang. As well as adding a limited subset to bbc.

This patch enables the flags below (and any equals or inverse variants)
for Flang that exist in Clang:

-fopenmp-target-debug
-fopenmp-assume-threads-oversubscription
-fopenmp-assume-teams-oversubscription
-fopenmp-assume-no-nested-parallelism
-fopenmp-assume-no-thread-state

For the bbc tool it only utilises the primary variants to minimize
additional complexity in the tool.

The patch also provides FlagAttr generation from these flags. Which
will be lowered to LLVM-IR in a subsequent patch.

Reviewers: kiranchandramohan, awarzynski

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

Added: 
flang/test/Lower/OpenMP/rtl-flags.f90

Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Flang.cpp
flang/include/flang/Frontend/LangOptions.def
flang/include/flang/Tools/CrossToolHelpers.h
flang/lib/Frontend/CompilerInvocation.cpp
flang/lib/Frontend/FrontendActions.cpp
flang/test/Driver/driver-help.f90
flang/test/Driver/omp-frontend-forwarding.f90
flang/tools/bbc/bbc.cpp

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 831f8dd65a3e6..5e008fc9b26ee 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -2680,26 +2680,39 @@ def fopenmp_cuda_blocks_per_sm_EQ : Joined<["-"], 
"fopenmp-cuda-blocks-per-sm=">
   Flags<[CC1Option, NoArgumentUnused, HelpHidden]>;
 def fopenmp_cuda_teams_reduction_recs_num_EQ : Joined<["-"], 
"fopenmp-cuda-teams-reduction-recs-num=">, Group,
   Flags<[CC1Option, NoArgumentUnused, HelpHidden]>;
-def fopenmp_target_debug : Flag<["-"], "fopenmp-target-debug">, 
Group, Flags<[CC1Option, NoArgumentUnused]>,
+
+//===--===//
+// Shared cc1 + fc1 OpenMP Target Options
+//===--===//
+
+let Flags = [CC1Option, FC1Option, NoArgumentUnused] in {
+let Group = f_Group in {
+
+def fopenmp_target_debug : Flag<["-"], "fopenmp-target-debug">,
   HelpText<"Enable debugging in the OpenMP offloading device RTL">;
-def fno_openmp_target_debug : Flag<["-"], "fno-openmp-target-debug">, 
Group, Flags<[NoArgumentUnused]>;
-def fopenmp_target_debug_EQ : Joined<["-"], "fopenmp-target-debug=">, 
Group, Flags<[CC1Option, NoArgumentUnused, HelpHidden]>;
-def fopenmp_assume_teams_oversubscription : Flag<["-"], 
"fopenmp-assume-teams-oversubscription">,
-  Group, Flags<[CC1Option, NoArgumentUnused, HelpHidden]>;
-def fopenmp_assume_threads_oversubscription : Flag<["-"], 
"fopenmp-assume-threads-oversubscription">,
-  Group, Flags<[CC1Option, NoArgumentUnused, HelpHidden]>;
-def fno_openmp_assume_teams_oversubscription : Flag<["-"], 
"fno-openmp-assume-teams-oversubscription">,
-  Group, Flags<[CC1Option, NoArgumentUnused, HelpHidden]>;
-def fno_openmp_assume_threads_oversubscription : Flag<["-"], 
"fno-openmp-assume-threads-oversubscription">,
-  Group, Flags<[CC1Option, NoArgumentUnused, HelpHidden]>;
-def fopenmp_assume_no_thread_state : Flag<["-"], 
"fopenmp-assume-no-thread-state">, Group,
-  Flags<[CC1Option, NoArgumentUnused, HelpHidden]>,
+def fno_openmp_target_debug : Flag<["-"], "fno-openmp-target-debug">;
+
+} // let Group = f_Group
+} // let Flags = [CC1Option, FC1Option, NoArgumentUnused]
+
+let Flags = [CC1Option, FC1Option, NoArgumentUnused, HelpHidden] in {
+let Group = f_Group in {
+
+def fopenmp_target_debug_EQ : Joined<["-"], "fopenmp-target-debug=">;
+def fopenmp_assume_teams_oversubscription : Flag<["-"], 
"fopenmp-assume-teams-oversubscription">;
+def fopenmp_assume_threads_oversubscription : Flag<["-"], 
"fopenmp-assume-threads-oversubscription">;
+def fno_openmp_assume_teams_oversubscription : Flag<["-"], 
"fno-openmp-assume-teams-oversubscription">;
+def fno_openmp_assume_threads_oversubscription : Flag<["-"], 
"fno-openmp-assume-threads-oversubscription">;
+def fopenmp_assume_no_thread_state : Flag<["-"], 
"fopenmp-assume-no-thread-state">,
   HelpText<"Assert no thread in a parallel region modifies an ICV">,
   MarshallingInfoFlag>;
-def fopenmp_assume_no_nested_parallelism : Flag<["-"], 
"fopenmp-assume-no-nested-parallelism">, Group,
-  Flags<[CC1Option, NoArgumentUnused, HelpHidden]>,
+def fopenmp_assume_no_nested_parallelism : Flag<["-"], 

[PATCH] D147175: [clang] Add __is_trivially_equality_comparable

2023-04-05 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Ah, I like this approach -- it keeps things roughly in sync with checking for 
unique object representations, which is great. I spotted a few questions, but 
in general this is heading in the right direction. You should also add a 
release note to clang/docs/ReleaseNotes.rst so that users know there's a new 
builtin coming.

I suppose one thing to double-check: do you know of any other STL 
implementations that might be using this identifier as part of their 
implementation details? (We've had issues in the past where we accidentally 
stole a reserved identifier that was being used by libstdc++ and it caused 
issues.)




Comment at: clang/include/clang/AST/DeclCXX.h:1449
   /// Notify the class that this destructor is now selected.
-  /// 
+  ///
   /// Important properties of the class depend on destructor properties. Since

Spurious whitespace change.



Comment at: clang/lib/AST/Type.cpp:2598-2599
+static bool HasDefaultedEqualityComparison(const CXXRecordDecl *Decl) {
+  if (Decl->isUnion())
+return false;
+

Hmmm, is this correct? I thought there was a defaulted equality comparison 
operator in this case, but it's defined as deleted.

http://eel.is/c++draft/class.compare.default#2

Perhaps this function is looking for a usable defaulted equality comparison 
operator and not just "does it have one at all"?



Comment at: clang/lib/AST/Type.cpp:2616-2617
+  }) &&
+ llvm::all_of(Decl->fields(), [](const FieldDecl *FD) {
+   if (!FD->getType()->isRecordType())
+ return true;

Do we have to look for fields with references per 
http://eel.is/c++draft/class.compare.default#2 ?



Comment at: clang/lib/AST/Type.cpp:4643-4645
+QualType Deduced, AutoTypeKeyword Keyword,
+bool IsDependent, ConceptDecl *CD,
+ArrayRef Arguments) {

Spurious whitespace changes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147175

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


[PATCH] D147623: [MSVC] Allow declaration of multi-dim 'property' array fields

2023-04-05 Thread Mike Rice via Phabricator via cfe-commits
mikerice closed this revision.
mikerice added a comment.

57caadc57a30f2279099e5b86bb555b4aab621ce 



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

https://reviews.llvm.org/D147623

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


[clang] 57caadc - [MSVC] Allow declaration of multi-dim 'property' array fields

2023-04-05 Thread Mike Rice via cfe-commits

Author: Mike Rice
Date: 2023-04-05T10:29:37-07:00
New Revision: 57caadc57a30f2279099e5b86bb555b4aab621ce

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

LOG: [MSVC] Allow declaration of multi-dim 'property' array fields

MSVC allows declaration of multi-dim arrays like this:

__declspec(property(get=GetX, put=PutX)) int x[][][];

This syntax can appear in generated typelib headers.

Currently clang errors on declarators like this since it forms an array
type of incomplete array. Rather than try to handle such a type, ignore
adjacent empty chunks so this is treated as if there was only one empty
array chunk (i.e. int x[]).

The functionality to handle multi-dim subscripts of property fields
already works, but only if declared as a single-dim array.

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/Sema/ParsedAttr.h
clang/lib/Sema/SemaDeclCXX.cpp
clang/lib/Sema/SemaType.cpp
clang/test/CodeGenCXX/ms-property.cpp
clang/test/SemaCXX/ms-property-error.cpp
clang/test/SemaCXX/ms-property.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 1e280cb633e23..bbfef9ff3cf7c 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -146,6 +146,8 @@ Non-comprehensive list of changes in this release
 - Clang now supports ``__builtin_assume_separate_storage`` that indicates that
   its arguments point to objects in separate storage allocations.
 - Clang now supports expressions in ``#pragma clang __debug dump``.
+- Clang now supports declaration of multi-dimensional arrays with
+  ``__declspec(property)``.
 
 New Compiler Flags
 --

diff  --git a/clang/include/clang/Sema/ParsedAttr.h 
b/clang/include/clang/Sema/ParsedAttr.h
index e2b4be48c0bd1..5f45668851c73 100644
--- a/clang/include/clang/Sema/ParsedAttr.h
+++ b/clang/include/clang/Sema/ParsedAttr.h
@@ -896,6 +896,16 @@ class ParsedAttributesView {
 });
   }
 
+  const ParsedAttr *getMSPropertyAttr() const {
+auto It = llvm::find_if(AttrList, [](const ParsedAttr *AL) {
+  return AL->isDeclspecPropertyAttribute();
+});
+if (It != AttrList.end())
+  return *It;
+return nullptr;
+  }
+  bool hasMSPropertyAttr() const { return getMSPropertyAttr(); }
+
 private:
   VecTy AttrList;
 };

diff  --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index e28c44f97f1fe..312b6f801c1f0 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -3235,16 +3235,6 @@ static bool InitializationHasSideEffects(const FieldDecl 
) {
   return false;
 }
 
-static const ParsedAttr *getMSPropertyAttr(const ParsedAttributesView ) {
-  ParsedAttributesView::const_iterator Itr =
-  llvm::find_if(list, [](const ParsedAttr ) {
-return AL.isDeclspecPropertyAttribute();
-  });
-  if (Itr != list.end())
-return &*Itr;
-  return nullptr;
-}
-
 // Check if there is a field shadowing.
 void Sema::CheckShadowInheritedFields(const SourceLocation ,
   DeclarationName FieldName,
@@ -3322,7 +3312,7 @@ Sema::ActOnCXXMemberDeclarator(Scope *S, AccessSpecifier 
AS, Declarator ,
 
   bool isFunc = D.isDeclarationOfFunction();
   const ParsedAttr *MSPropertyAttr =
-  getMSPropertyAttr(D.getDeclSpec().getAttributes());
+  D.getDeclSpec().getAttributes().getMSPropertyAttr();
 
   if (cast(CurContext)->isInterface()) {
 // The Microsoft extension __interface only permits public member functions

diff  --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index 53852dd930a71..e195e85ab75b7 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -5070,6 +5070,19 @@ static TypeSourceInfo 
*GetFullTypeForDeclarator(TypeProcessingState ,
   DeclaratorChunk::ArrayTypeInfo  = DeclType.Arr;
   Expr *ArraySize = static_cast(ATI.NumElts);
   ArrayType::ArraySizeModifier ASM;
+
+  // Microsoft property fields can have multiple sizeless array chunks
+  // (i.e. int x[][][]). Skip all of these except one to avoid creating
+  // bad incomplete array types.
+  if (chunkIndex != 0 && !ArraySize &&
+  D.getDeclSpec().getAttributes().hasMSPropertyAttr()) {
+// This is a sizeless chunk. If the next is also, skip this one.
+DeclaratorChunk  = D.getTypeObject(chunkIndex - 1);
+if (NextDeclType.Kind == DeclaratorChunk::Array &&
+!NextDeclType.Arr.NumElts)
+  break;
+  }
+
   if (ATI.isStar)
 ASM = ArrayType::Star;
   else if (ATI.hasStatic)
@@ -6523,6 +6536,12 @@ GetTypeSourceInfoForDeclarator(TypeProcessingState 
,
   }
 
   for (unsigned i = 0, e = D.getNumTypeObjects(); i != e; ++i) {
+// Microsoft property 

[PATCH] D147324: [OpenMP][MLIR][Flang][bbc][Driver] Add OpenMP RTL Flags to Flang and generate omp.FlagsAttr from them

2023-04-05 Thread Andrew Gozillon via Phabricator via cfe-commits
agozillon added a comment.

In D147324#4245932 , 
@kiranchandramohan wrote:

> LG. This portion of the patch was accepted in 
> https://reviews.llvm.org/D145264.
>
> See inline comment about location of LLVM Dialect tests. You may either 
> remove the LLVM dialect tests from this patch and land it. Or you can submit 
> this and move the tests in a separate NFC patch and submit without review.

Hi Kiran,

Thanks for the quick reply. I'll do the former and remove the tests and land 
the patch today (back tracking on the previous statement of leaving landing it 
till later), I don't believe they add anything to the test suite as there is no 
modifications between FIR -> LLVM Dialect as far as this attribute and the 
ModuleOp go.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147324

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


[clang] 78d0d59 - Add some additional comments to this test; NFC

2023-04-05 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2023-04-05T13:15:34-04:00
New Revision: 78d0d59209bf858435bcd19046e94fce0386ace8

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

LOG: Add some additional comments to this test; NFC

It isn't immediately obvious why that code should be accepted given the
wording of C2x 6.7.10p4, so this adds a comment explaining that there
is an existing extension to support zero-sized arrays in C, and that
empty initialization of an unbounded array in C++ deduces the array
extent as zero, so C is exposing the same extension as in C++.

Added: 


Modified: 
clang/test/C/C2x/n2900_n3011.c

Removed: 




diff  --git a/clang/test/C/C2x/n2900_n3011.c b/clang/test/C/C2x/n2900_n3011.c
index b0de79e9a516f..6aaff3374c168 100644
--- a/clang/test/C/C2x/n2900_n3011.c
+++ b/clang/test/C/C2x/n2900_n3011.c
@@ -15,6 +15,13 @@ void test(void) {
   pedantic-warning {{use of an empty 
initializer is a C2x extension}}
   int j = (int){}; // compat-warning {{use of an empty initializer is 
incompatible with C standards before C2x}} \
   pedantic-warning {{use of an empty initializer is a C2x 
extension}}
+
+  // C2x 6.7.10p4 says, in part: An array of unknown size shall not be
+  // initialized by an empty initializer.
+  // However, Clang allows zero-sized arrays as an extension in both C and C++,
+  // and this initialization form will deduce the array extent as zero. Given
+  // that we support empty initialization of an unbounded array in C++, we also
+  // support it in C.
   int unknown_size[] = {}; // pedantic-warning {{zero size arrays are an 
extension}} \
   pedantic-warning {{use of an empty initializer 
is a C2x extension}} \
   compat-warning {{use of an empty initializer is 
incompatible with C standards before C2x}}



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


[PATCH] D147256: [DebugInfo] Fix file path separator when targeting windows.

2023-04-05 Thread Paul Robinson via Phabricator via cfe-commits
probinson added a comment.

An LLVM code change should be testable on its own; this has it tested by Clang.
I think you need a new command-line option to set 
TargetOptions::UseTargetPathSeparator e.g. via llvm-mc. Other TargetOptions are 
handled this way.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147256

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


[PATCH] D147623: [MSVC] Allow declaration of multi-dim 'property' array fields

2023-04-05 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.

Changes LGTM but please add a release note about the new functionality when 
landing.


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

https://reviews.llvm.org/D147623

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


[PATCH] D147623: [MSVC] Allow declaration of multi-dim 'property' array fields

2023-04-05 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

Ah, needs a release note however!


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

https://reviews.llvm.org/D147623

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


[PATCH] D147626: [clang] Do not crash when initializing union with flexible array member

2023-04-05 Thread Mariya Podchishchaeva via Phabricator via cfe-commits
Fznamznon added inline comments.



Comment at: clang/lib/Sema/SemaInit.cpp:808
   unsigned NumElems = numStructUnionElements(ILE->getType());
-  if (RDecl->hasFlexibleArrayMember())
+  if (!RDecl->isUnion() && RDecl->hasFlexibleArrayMember())
 ++NumElems;

Just for some context, numStructUnionElements checks that there is a flexible 
array member and returns number_of_initializable_fields-1 for structs. For 
unions it just returns 1 or 0, so flexible array member caused adding one more 
element to initlistexpr that was never properly handled.

Instead of doing this change, we could probably never enter initialization 
since the record (union) declaration is not valid, but that is not the case 
even for other types of errors in code, for example, I've tried declaring field 
of struct with a typo:

```
struct { cha x[]; } r = {1}; 
```
Initialization is still performed by clang.
Also, it seems MSVC considers flexible array member inside union as valid, so 
the test code is probably not always invalid.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147626

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


[PATCH] D146376: Update static_assert message for redundant cases

2023-04-05 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D146376#4244355 , 
@Krishna-13-cyber wrote:

> - Updated with release note
> - I had tried adding more text to the `expected-error` but it already gives a 
> diagnostic of `static assertion failed due to requirement` currently. If I 
> try additions to `{{failed}}` then we get **error diagnostics expected but 
> not seen**.

Ah, sorry for being unclear! We didn't mean add an additional `expected-error` 
comment, but to modify the ones you have. e.g.,

Currently:

  static_assert(true && false, ""); // expected-error {{failed}}

Changes to:

  static_assert(true && false, ""); // expected-error {{static assertion failed 
due to requirement 'true && false'}}

(or whatever the actual expected full text of the diagnostic is.)

This helps the reviewers to make sure that the diagnostic behavior isn't 
regressing in surprising ways but pass all our tests because we're only looking 
for the word `failed` and considering that passing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146376

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


[PATCH] D147574: [NFC][clang] Fix Coverity static analyzer tool concerns about auto_causes_copy

2023-04-05 Thread Soumi Manna via Phabricator via cfe-commits
Manna added a comment.

In D147574#4246004 , @aaron.ballman 
wrote:

> LGTM

Thank you @aaron.ballman


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147574

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


[PATCH] D146090: [Clang] Updating handling of defaulted comparison operators to reflect changes from P2448R2

2023-04-05 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/docs/ReleaseNotes.rst:91-92
   expressions and how their types are deduced therein, in all C++ language 
versions.
+- Implemented partial support for `P2448R2: Relaxing some constexpr 
restrictions `_
+  Explicitly defaulted functions no longer have to be constexpr-compatible but 
merely constexpr suitable.
 

Should we also say what's still missing that causes this to be partial?



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:9415-9421
+  "invokes a non-constexpr comparison function is a C++2b extension">, 
InGroup;
+def warn_cxx2b_compat_incorrect_defaulted_comparison_constexpr : Warning<
+  "defaulted definition of %select{%sub{select_defaulted_comparison_kind}1|"
+  "three-way comparison operator}0 that is "
+  "declared %select{constexpr|consteval}2 but"
+  "%select{|for which the corresponding implicit 'operator==' }0 "
+  "invokes a non-constexpr comparison function is a C++2b extension">, 
InGroup, DefaultIgnore;

Formatting fix-up and a wording correction.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:9410-9421
+def ext_incorrect_defaulted_comparison_constexpr : Extension<
   "defaulted definition of %select{%sub{select_defaulted_comparison_kind}1|"
   "three-way comparison operator}0 "
-  "cannot be declared %select{constexpr|consteval}2 because "
+  "declared %select{constexpr|consteval}2 but "
   "%select{it|the corresponding implicit 'operator=='}0 "
-  "invokes a non-constexpr comparison function">;
+  "invokes a non-constexpr comparison function are a C++2b extension">, 
InGroup;
+def warn_cxx2b_incorrect_defaulted_comparison_constexpr : Warning<

shafik wrote:
> rsmith wrote:
> > The grammar of these diagnostics looks a bit peculiar. Suggested an 
> > alternative, but it's still a bit awkward ("...but for which..."), maybe 
> > you can find something better.
> @aaron.ballman any suggestions for less awkward wording here? I don't think 
> what there is here now is too bad but asking for a another opinion.
Yeah, that wording is a bit... wordy, but I'm struggling to think of something 
more approachable that's still accurate.



Comment at: clang/lib/Sema/SemaDeclCXX.cpp:8811
+  // The concept of constexpr-compatible was removed.
+  // C++23 [dcl.fct.def.default]/p3 [P2448R2]
+  //  A function explicitly defaulted on its first declaration is implicitly





Comment at: clang/test/CXX/class/class.compare/class.compare.default/p4.cpp:153
+
+constexpr friend bool operator==(const my_struct &, const my_struct &) 
noexcept = default; // no diagnostic extension-warning {{declared constexpr but 
invokes a non-constexpr comparison function is a C++2b extension}}
+};

`no diagnostic extension-warning`?



Comment at: clang/test/CXX/class/class.compare/class.compare.default/p4.cpp:162
+
+my_struct obj; // extension-note {{in instantiation of 
template class 'GH61238::my_struct' requested 
here}}
+}

Can you add an instantiation that does use a constexpr suitable type to show 
that we don't issue the diagnostic on that instantiation, or do you think that 
is sufficiently covered by other test coverage?



Comment at: clang/www/cxx_status.html:1485
   https://wg21.link/P2448R2;>P2448R2
-  No
+  Partial
 

Please add   markup to explain why the support is partial, and it's 
probably not a bad idea to say `Clang 17 (Partial)` so users know when the 
partial support started.


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

https://reviews.llvm.org/D146090

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


[libunwind] d080b5f - [libunwind] Fix a case of inconsistent indentation. NFC.

2023-04-05 Thread Martin Storsjö via cfe-commits

Author: Martin Storsjö
Date: 2023-04-05T19:23:18+03:00
New Revision: d080b5f1737b4040aa74a5614ae01338f28cd714

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

LOG: [libunwind] Fix a case of inconsistent indentation. NFC.

Added: 


Modified: 
libunwind/include/__libunwind_config.h

Removed: 




diff  --git a/libunwind/include/__libunwind_config.h 
b/libunwind/include/__libunwind_config.h
index f69fe89e9a265..a4e1a3613bbf9 100644
--- a/libunwind/include/__libunwind_config.h
+++ b/libunwind/include/__libunwind_config.h
@@ -196,7 +196,7 @@
 # define _LIBUNWIND_TARGET_RISCV 1
 # define _LIBUNWIND_TARGET_VE 1
 # define _LIBUNWIND_TARGET_S390X 1
-#define _LIBUNWIND_TARGET_LOONGARCH 1
+ #define _LIBUNWIND_TARGET_LOONGARCH 1
 # define _LIBUNWIND_CONTEXT_SIZE 167
 # define _LIBUNWIND_CURSOR_SIZE 179
 # define _LIBUNWIND_HIGHEST_DWARF_REGISTER 287



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


[PATCH] D146591: [dataflow] add HTML logger: browse code/cfg/analysis timeline/state

2023-04-05 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 511126.
sammccall marked 8 inline comments as done.
sammccall added a comment.

address comments (sorry about long turnaround!)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146591

Files:
  clang/include/clang/Analysis/FlowSensitive/Logger.h
  clang/lib/Analysis/FlowSensitive/CMakeLists.txt
  clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
  clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp
  clang/lib/Analysis/FlowSensitive/HTMLLogger.css
  clang/lib/Analysis/FlowSensitive/HTMLLogger.html
  clang/lib/Analysis/FlowSensitive/HTMLLogger.js
  clang/unittests/Analysis/FlowSensitive/LoggerTest.cpp
  clang/utils/bundle_resources.py

Index: clang/utils/bundle_resources.py
===
--- /dev/null
+++ clang/utils/bundle_resources.py
@@ -0,0 +1,29 @@
+#!/usr/bin/env python3
+
+#===- bundle_resources.py - Generate string constants with file contents. ===
+#
+# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+# See https://llvm.org/LICENSE.txt for license information.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+#
+#===--===
+
+# Usage: bundle-resources.py foo.inc a.js path/b.css ...
+# Produces foo.inc containing:
+#   const char a_js[] = "...";
+#   const char b_css[] = "...";
+import os
+import sys
+
+outfile = sys.argv[1]
+infiles = sys.argv[2:]
+
+with open(outfile, 'w') as out:
+  for filename in infiles:
+varname = os.path.basename(filename).replace('.', '_')
+out.write("const char " + varname + "[] = \n");
+# MSVC limits each chunk of string to 2k, so split by lines.
+# The overall limit is 64k, which ought to be enough for anyone.
+for line in open(filename).read().split('\n'):
+  out.write('  R"x(' + line + ')x" "\\n"\n' )
+out.write('  ;\n');
Index: clang/unittests/Analysis/FlowSensitive/LoggerTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/LoggerTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/LoggerTest.cpp
@@ -9,6 +9,7 @@
 
 namespace clang::dataflow::test {
 namespace {
+using testing::HasSubstr;
 
 struct TestLattice {
   int Elements = 0;
@@ -83,19 +84,24 @@
   void logText(llvm::StringRef Text) override { OS << Text << "\n"; }
 };
 
-TEST(LoggerTest, Sequence) {
+AnalysisInputs makeInputs() {
   const char *Code = R"cpp(
 int target(bool b, int p, int q) {
   return b ? p : q;
 }
 )cpp";
+  static const std::vector Args = {
+  "-fsyntax-only", "-fno-delayed-template-parsing", "-std=c++17"};
 
   auto Inputs = AnalysisInputs(
   Code, ast_matchers::hasName("target"),
   [](ASTContext , Environment &) { return TestAnalysis(C); });
-  std::vector Args = {
-  "-fsyntax-only", "-fno-delayed-template-parsing", "-std=c++17"};
   Inputs.ASTBuildArgs = Args;
+  return Inputs;
+}
+
+TEST(LoggerTest, Sequence) {
+  auto Inputs = makeInputs();
   std::string Log;
   TestLogger Logger(Log);
   Inputs.BuiltinOptions.Log = 
@@ -148,5 +154,29 @@
 )");
 }
 
+TEST(LoggerTest, HTML) {
+  auto Inputs = makeInputs();
+  std::vector Logs;
+  auto Logger = Logger::html([&]() {
+Logs.emplace_back();
+return std::make_unique(Logs.back());
+  });
+  Inputs.BuiltinOptions.Log = Logger.get();
+
+  ASSERT_THAT_ERROR(checkDataflow(std::move(Inputs),
+[](const AnalysisOutputs &) {}),
+llvm::Succeeded());
+
+  // Simple smoke tests: we can't meaningfully test the behavior.
+  ASSERT_THAT(Logs, testing::SizeIs(1));
+  EXPECT_THAT(Logs[0], HasSubstr("function updateSelection")) << "embeds JS";
+  EXPECT_THAT(Logs[0], HasSubstr("html {")) << "embeds CSS";
+  EXPECT_THAT(Logs[0], HasSubstr("b (ImplicitCastExpr")) << "has CFG elements";
+  EXPECT_THAT(Logs[0], HasSubstr("\"B3:1_B3.1\":"))
+  << "has analysis point state";
+  EXPECT_THAT(Logs[0], HasSubstr("transferBranch(0)")) << "has analysis logs";
+  EXPECT_THAT(Logs[0], HasSubstr("LocToVal")) << "has built-in lattice dump";
+}
+
 } // namespace
 } // namespace clang::dataflow::test
Index: clang/lib/Analysis/FlowSensitive/HTMLLogger.js
===
--- /dev/null
+++ clang/lib/Analysis/FlowSensitive/HTMLLogger.js
@@ -0,0 +1,213 @@
+//===-- HTMLLogger.js -===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+// Based on selected objects, hide/show sections & populate data from templates.
+//
+// For example, if the selection is 

[PATCH] D147626: [clang] Do not crash when initializing union with flexible array member

2023-04-05 Thread Mariya Podchishchaeva via Phabricator via cfe-commits
Fznamznon created this revision.
Herald added a project: All.
Fznamznon requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Due to missing check on union, there was a null expression added to init
list that caused crash later.

Fixes https://github.com/llvm/llvm-project/issues/61746


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D147626

Files:
  clang/lib/Sema/SemaInit.cpp
  clang/test/Sema/init.c


Index: clang/test/Sema/init.c
===
--- clang/test/Sema/init.c
+++ clang/test/Sema/init.c
@@ -164,3 +164,6 @@
 
 typedef struct { uintptr_t x : 2; } StructWithBitfield;
 StructWithBitfield bitfieldvar = { (uintptr_t) }; // 
expected-error {{initializer element is not a compile-time constant}}
+
+// GH61746
+union { char x[]; } r = {0}; // expected-error {{flexible array member 'x' in 
a union is not allowed}}
Index: clang/lib/Sema/SemaInit.cpp
===
--- clang/lib/Sema/SemaInit.cpp
+++ clang/lib/Sema/SemaInit.cpp
@@ -805,7 +805,7 @@
   // order to leave them uninitialized, the ILE is expanded and the extra
   // fields are then filled with NoInitExpr.
   unsigned NumElems = numStructUnionElements(ILE->getType());
-  if (RDecl->hasFlexibleArrayMember())
+  if (!RDecl->isUnion() && RDecl->hasFlexibleArrayMember())
 ++NumElems;
   if (!VerifyOnly && ILE->getNumInits() < NumElems)
 ILE->resizeInits(SemaRef.Context, NumElems);


Index: clang/test/Sema/init.c
===
--- clang/test/Sema/init.c
+++ clang/test/Sema/init.c
@@ -164,3 +164,6 @@
 
 typedef struct { uintptr_t x : 2; } StructWithBitfield;
 StructWithBitfield bitfieldvar = { (uintptr_t) }; // expected-error {{initializer element is not a compile-time constant}}
+
+// GH61746
+union { char x[]; } r = {0}; // expected-error {{flexible array member 'x' in a union is not allowed}}
Index: clang/lib/Sema/SemaInit.cpp
===
--- clang/lib/Sema/SemaInit.cpp
+++ clang/lib/Sema/SemaInit.cpp
@@ -805,7 +805,7 @@
   // order to leave them uninitialized, the ILE is expanded and the extra
   // fields are then filled with NoInitExpr.
   unsigned NumElems = numStructUnionElements(ILE->getType());
-  if (RDecl->hasFlexibleArrayMember())
+  if (!RDecl->isUnion() && RDecl->hasFlexibleArrayMember())
 ++NumElems;
   if (!VerifyOnly && ILE->getNumInits() < NumElems)
 ILE->resizeInits(SemaRef.Context, NumElems);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D144269: [Analyzer] Show "taint originated here" note of alpha.security.taint.TaintPropagation checker at the correct place

2023-04-05 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

I think as we converge, now it could be time to update the summary of the patch 
to reflect the current implementation. (e.g. flowids etc.)


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

https://reviews.llvm.org/D144269

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


[PATCH] D144269: [Analyzer] Show "taint originated here" note of alpha.security.taint.TaintPropagation checker at the correct place

2023-04-05 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

Looks even better. Only minor concerns remained, mostly about style and 
suggestions of llvm utilities.




Comment at: clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp:129-130
 /// Given a pointer/reference argument, return the value it refers to.
-std::optional getPointeeOf(const CheckerContext , SVal Arg) {
+std::optional getPointeeOf(ASTContext ,
+ const ProgramStateRef State, SVal Arg) {
   if (auto LValue = Arg.getAs())

BTW I don't know but `State->getStateManager().getContext()` can give you an 
`ASTContext`. And we tend to not put `const` to variable declarations. See [[ 
https://releases.llvm.org/4.0.0/tools/clang/tools/extra/docs/clang-tidy/checks/readability-avoid-const-params-in-decls.html
 | readability-avoid-const-params-in-decls ]]

In other places we tend to refer to `ASTContext` by the `ACtx` I think.
We also prefer const refs over mutable refs. Is the mutable ref justified for 
this case?



Comment at: clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp:159
+/// when the return value, or the outgoing parameters are tainted.
+const NoteTag *taintOriginTrackerTag(CheckerContext ,
+ std::vector TaintedSymbols,

My bad. In LLVM style we use `UpperCamelCase` for variable names.



Comment at: clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp:173-175
+if (TaintedSymbols.empty()) {
+  return "Taint originated here";
+}

Generally, in LLVM style we don't put braces to single block statements unless 
it would hurt readability, which I don't think applies here.



Comment at: clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp:176-180
+for (auto Sym : llvm::enumerate(TaintedSymbols)) {
+  LLVM_DEBUG(llvm::dbgs() << "Taint Propagated from argument "
+  << TaintedArgs.at(Sym.index()) + 1 << "\n");
+  BR.markInteresting(Sym.value());
+}

I was also bad with this recommendation.
I think we can now use structured bindings to get the index and value right 
there, like:
`for (auto [Idx, Sym] : llvm::enumerate(TaintedSymbols))`
[[ 
https://github.com/llvm/llvm-project/blob/main/llvm/docs/ProgrammersManual.rst#enumerate
 | See ]]



Comment at: clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp:203
+int nofTaintedArgs = 0;
+for (auto Sym : llvm::enumerate(TaintedSymbols)) {
+  if (BR.isInteresting(Sym.value())) {

Same here about structured bindings.



Comment at: clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp:209-214
+  if (nofTaintedArgs == 0)
+Out << "Taint propagated to argument "
+<< TaintedArgs.at(Sym.index()) + 1;
+  else
+Out << ", " << TaintedArgs.at(Sym.index()) + 1;
+  nofTaintedArgs++;

I'd recommend using `llvm::interleaveComma()` in such cases.
You can probably get rid of `nofTaintedArgs` as well - by using this function.



Comment at: clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp:211
+Out << "Taint propagated to argument "
+<< TaintedArgs.at(Sym.index()) + 1;
+  else

For clang diagnostics we usually use ordinary suffixes like `{st,nd,rd,th}`. It 
would be nice to align with the rest of the clang diagnostics on this.
It would require a bit of work on the wording though, I admit.



Comment at: clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp:213
+  else
+Out << ", " << TaintedArgs.at(Sym.index()) + 1;
+  nofTaintedArgs++;

I believe this branch is uncovered by tests.



Comment at: clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp:221
+}
+return std::string(Out.str());
+  });

I think since you explicitly specify the return type of the lambda, you could 
omit the spelling of `std::string` here.



Comment at: clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp:863-864
   State = addTaint(State, Call.getReturnValue());
+  SymbolRef TaintedSym = isTainted(State, Call.getReturnValue());
+  if (TaintedSym) {
+TaintedSymbols.push_back(TaintedSym);

We tend to fuse such declarations:
I've seen other cases like this elsewhere. Please check.



Comment at: clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp:875-878
+  // FIXME: The call argument may be a complex expression
+  // referring to multiple tainted variables.
+  // Now we generate notes and track back only one of them.
+  SymbolRef TaintedSym = isTainted(State, *V);

You could iterate over the symbol dependencies of the SymExpr (of the `*V` 
SVal).

```lang=c++
SymbolRef 

[PATCH] D147256: [DebugInfo] Fix file path separator when targeting windows.

2023-04-05 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu updated this revision to Diff 58.
zequanwu added a comment.
Herald added a subscriber: ormris.

- Pass `LangOptions.UseTargetPathSeparator` down to TargetOptions to use host

path separator when it's set.

- Add a test case. The problem is when if we are targeting to linux, clang

won't generate codeview debuginfo with `-gcodeview`. So, I only add the test to
target on windows.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147256

Files:
  clang/include/clang/Basic/LangOptions.h
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGen/debug-info-slash.c
  clang/test/CodeGen/use-target-path-separator.c
  llvm/include/llvm/Target/TargetOptions.h
  llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp

Index: llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
===
--- llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
+++ llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
@@ -791,7 +791,15 @@
 // Don't emit the filename if we're writing to stdout or to /dev/null.
 PathRef = {};
   } else {
-llvm::sys::path::remove_dots(PathStore, /*remove_dot_dot=*/true);
+llvm::sys::path::Style Style =
+(!llvm::sys::path::is_absolute(PathRef,
+   llvm::sys::path::Style::posix) &&
+ Asm->TM.Options.UseTargetPathSeparator)
+? (Asm->TM.getTargetTriple().isOSWindows()
+   ? llvm::sys::path::Style::windows_backslash
+   : llvm::sys::path::Style::posix)
+: llvm::sys::path::Style::native;
+llvm::sys::path::remove_dots(PathStore, /*remove_dot_dot=*/true, Style);
 PathRef = PathStore;
   }
 
Index: llvm/include/llvm/Target/TargetOptions.h
===
--- llvm/include/llvm/Target/TargetOptions.h
+++ llvm/include/llvm/Target/TargetOptions.h
@@ -127,7 +127,8 @@
 : UnsafeFPMath(false), NoInfsFPMath(false), NoNaNsFPMath(false),
   NoTrappingFPMath(true), NoSignedZerosFPMath(false),
   ApproxFuncFPMath(false), EnableAIXExtendedAltivecABI(false),
-  HonorSignDependentRoundingFPMathOption(false), NoZerosInBSS(false),
+  HonorSignDependentRoundingFPMathOption(false),
+  UseTargetPathSeparator(false), NoZerosInBSS(false),
   GuaranteedTailCallOpt(false), StackSymbolOrdering(true),
   EnableFastISel(false), EnableGlobalISel(false), UseInitArray(false),
   DisableIntegratedAS(false), RelaxELFRelocations(true),
@@ -206,6 +207,11 @@
 unsigned HonorSignDependentRoundingFPMathOption : 1;
 bool HonorSignDependentRoundingFPMath() const;
 
+/// UseTargetPathSeparator - This Indicates whether to use target's
+/// platform-specific file separator when concatenating filename with
+/// directory.
+unsigned UseTargetPathSeparator : 1;
+
 /// NoZerosInBSS - By default some codegens place zero-initialized data to
 /// .bss section. This flag disables such behaviour (necessary, e.g. for
 /// crt*.o compiling).
Index: clang/test/CodeGen/use-target-path-separator.c
===
--- /dev/null
+++ clang/test/CodeGen/use-target-path-separator.c
@@ -0,0 +1,11 @@
+// RUN: rm -rf %t-dir
+// RUN: mkdir -p %t-dir/subdir
+// RUN: cd %t-dir
+// RUN: %clang_cl --target=x86_64-windows-msvc -ffile-reproducible /c /Z7 -fdebug-compilation-dir=. /Fosubdir/win.obj -- %s
+// RUN: llvm-readobj --codeview subdir/win.obj | FileCheck --check-prefix=WIN %s
+
+int main (void) {
+  return 0;
+}
+
+// WIN: ObjectName: subdir\win.obj
Index: clang/test/CodeGen/debug-info-slash.c
===
--- /dev/null
+++ clang/test/CodeGen/debug-info-slash.c
@@ -0,0 +1,6 @@
+// RUN: %clang -target x86_64-pc-win32  -ffile-reproducible -emit-llvm -S -g %s -o - | FileCheck --check-prefix=WIN %s
+// RUN: %clang -target x86_64-linux-gnu  -ffile-reproducible -emit-llvm -S -g %s -o - | FileCheck --check-prefix=LINUX %s
+int main() { return 0; }
+
+// WIN:   !DIFile(filename: "{{.*}}\\debug-info-slash.c"
+// LINUX: !DIFile(filename: "{{.*}}/debug-info-slash.c"
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -528,6 +528,7 @@
   // Get absolute path name.
   SourceManager  = CGM.getContext().getSourceManager();
   auto  = CGM.getCodeGenOpts();
+  const LangOptions  = CGM.getLangOpts();
   std::string MainFileName = CGO.MainFileName;
   if (MainFileName.empty())
 MainFileName = "";
@@ -542,9 +543,15 @@
 MainFileDir = std::string(MainFile->getDir().getName());
 if (!llvm::sys::path::is_absolute(MainFileName)) {
   llvm::SmallString<1024> MainFileDirSS(MainFileDir);
-  

[PATCH] D147621: [clang][Interp] Start handling mutable record members

2023-04-05 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder created this revision.
tbaeder added reviewers: aaron.ballman, erichkeane, tahonermann, shafik.
Herald added a project: All.
tbaeder 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/D147621

Files:
  clang/lib/AST/Interp/Interp.cpp
  clang/test/AST/Interp/records.cpp


Index: clang/test/AST/Interp/records.cpp
===
--- clang/test/AST/Interp/records.cpp
+++ clang/test/AST/Interp/records.cpp
@@ -664,6 +664,28 @@
 };
 #endif
 
+namespace MutableFields {
+  class Foo {
+  public:
+constexpr Foo() : I(1) {}
+mutable int I; // ref-note {{declared here}}
+  };
+
+
+  constexpr int foo() {
+const Foo F;
+F.I = 12;
+return F.I;
+  }
+  static_assert(foo() == 12, "");
+
+  /// FIXME: This should also be rejected in the new interpreter.
+  constexpr Foo GlobalF;
+  constexpr int foo2() { // ref-error {{never produces a constant expression}}
+return GlobalF.I; // ref-note {{read of mutable member 'I' is not allowed 
in a constant expression}}
+  }
+}
+
 /// FIXME: The following tests are broken.
 ///   They are using CXXDefaultInitExprs which contain a CXXThisExpr. The This 
pointer
 ///   in those refers to the declaration we are currently initializing, *not* 
the
Index: clang/lib/AST/Interp/Interp.cpp
===
--- clang/lib/AST/Interp/Interp.cpp
+++ clang/lib/AST/Interp/Interp.cpp
@@ -224,6 +224,14 @@
 return true;
   }
 
+  // Writing to mutable fields is fine even if the parent is
+  // declared const.
+  if (S.getLangOpts().CPlusPlus14) {
+if (const auto *FD = dyn_cast(Ptr.getFieldDesc()->asDecl());
+FD && FD->isMutable())
+  return true;
+  }
+
   const QualType Ty = Ptr.getType();
   const SourceInfo  = S.Current->getSource(OpPC);
   S.FFDiag(Loc, diag::note_constexpr_modify_const_type) << Ty;
@@ -236,6 +244,11 @@
 return true;
   }
 
+  // In C++14 onwards, it is permitted to read a mutable member whose
+  // lifetime began within the evaluation.
+  if (S.getLangOpts().CPlusPlus14)
+return true;
+
   const SourceInfo  = S.Current->getSource(OpPC);
   const FieldDecl *Field = Ptr.getField();
   S.FFDiag(Loc, diag::note_constexpr_access_mutable, 1) << AK_Read << Field;


Index: clang/test/AST/Interp/records.cpp
===
--- clang/test/AST/Interp/records.cpp
+++ clang/test/AST/Interp/records.cpp
@@ -664,6 +664,28 @@
 };
 #endif
 
+namespace MutableFields {
+  class Foo {
+  public:
+constexpr Foo() : I(1) {}
+mutable int I; // ref-note {{declared here}}
+  };
+
+
+  constexpr int foo() {
+const Foo F;
+F.I = 12;
+return F.I;
+  }
+  static_assert(foo() == 12, "");
+
+  /// FIXME: This should also be rejected in the new interpreter.
+  constexpr Foo GlobalF;
+  constexpr int foo2() { // ref-error {{never produces a constant expression}}
+return GlobalF.I; // ref-note {{read of mutable member 'I' is not allowed in a constant expression}}
+  }
+}
+
 /// FIXME: The following tests are broken.
 ///   They are using CXXDefaultInitExprs which contain a CXXThisExpr. The This pointer
 ///   in those refers to the declaration we are currently initializing, *not* the
Index: clang/lib/AST/Interp/Interp.cpp
===
--- clang/lib/AST/Interp/Interp.cpp
+++ clang/lib/AST/Interp/Interp.cpp
@@ -224,6 +224,14 @@
 return true;
   }
 
+  // Writing to mutable fields is fine even if the parent is
+  // declared const.
+  if (S.getLangOpts().CPlusPlus14) {
+if (const auto *FD = dyn_cast(Ptr.getFieldDesc()->asDecl());
+FD && FD->isMutable())
+  return true;
+  }
+
   const QualType Ty = Ptr.getType();
   const SourceInfo  = S.Current->getSource(OpPC);
   S.FFDiag(Loc, diag::note_constexpr_modify_const_type) << Ty;
@@ -236,6 +244,11 @@
 return true;
   }
 
+  // In C++14 onwards, it is permitted to read a mutable member whose
+  // lifetime began within the evaluation.
+  if (S.getLangOpts().CPlusPlus14)
+return true;
+
   const SourceInfo  = S.Current->getSource(OpPC);
   const FieldDecl *Field = Ptr.getField();
   S.FFDiag(Loc, diag::note_constexpr_access_mutable, 1) << AK_Read << Field;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D147574: [NFC][clang] Fix Coverity static analyzer tool concerns about auto_causes_copy

2023-04-05 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147574

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


[PATCH] D144036: [clang-tidy] Add bugprone-enum-to-bool-conversion check

2023-04-05 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL planned changes to this revision.
PiotrZSL added a comment.

TODO: Fix review comments, rename check.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144036

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


[PATCH] D144036: [clang-tidy] Add bugprone-enum-to-bool-conversion check

2023-04-05 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL added a comment.

Thank you for review, I will correct comments in this week.




Comment at: clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp:107
+CheckFactories.registerCheck(
+"bugprone-enum-to-bool-conversion");
 CheckFactories.registerCheck(

carlosgalvezp wrote:
> I think the name is a bit generic, do we foresee risk of conflict with other 
> similar checks in the future? I wonder if we should narrow it down to 
> something like `bugprone-non-zero-enum-to-bool-conversion`. WDYT?
I'm fine with name change



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/bugprone/enum-to-bool-conversion.rst:41
+{
+// this true-branch in theory wont be executed
+return;

carlosgalvezp wrote:
> carlosgalvezp wrote:
> > won't
> Remove?
enums are ints, you can assign them any value by using static casts or when 
reading data from external message, so thats why in theory, but in this example 
you right, there is no "in theory"


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144036

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


[PATCH] D144036: [clang-tidy] Add bugprone-enum-to-bool-conversion check

2023-04-05 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp added a comment.

Such a great check, thanks! I have very minor comments, the most debatable one 
about the name of the check (but no strong opinion).




Comment at: clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp:107
+CheckFactories.registerCheck(
+"bugprone-enum-to-bool-conversion");
 CheckFactories.registerCheck(

I think the name is a bit generic, do we foresee risk of conflict with other 
similar checks in the future? I wonder if we should narrow it down to something 
like `bugprone-non-zero-enum-to-bool-conversion`. WDYT?



Comment at: 
clang-tools-extra/clang-tidy/bugprone/EnumToBoolConversionCheck.cpp:23
+AST_MATCHER(EnumDecl, isCompleteAndHasNoZeroValue) {
+  const auto *Definition = Node.getDefinition();
+  return Definition and Node.isComplete() and

 Use explicit type



Comment at: 
clang-tools-extra/clang-tidy/bugprone/EnumToBoolConversionCheck.cpp:24
+  const auto *Definition = Node.getDefinition();
+  return Definition and Node.isComplete() and
+ std::none_of(

The convention in the LLVM repo is to use traditional operators, please keep 
consistency.



Comment at: 
clang-tools-extra/clang-tidy/bugprone/EnumToBoolConversionCheck.cpp:27
+ Definition->enumerator_begin(), Definition->enumerator_end(),
+ [](const auto *Value) { return Value->getInitVal().isZero(); });
+}

Use explicit type



Comment at: 
clang-tools-extra/clang-tidy/bugprone/EnumToBoolConversionCheck.cpp:72
+  << Enum;
+
+  diag(Enum->getLocation(), "enum is defined here", DiagnosticIDs::Note);

Unnecessary empty line



Comment at: clang-tools-extra/docs/ReleaseNotes.rst:112
 
+- New :doc:`bugprone-enum-to-bool-conversion
+  ` check.

Keep alphabetical order.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/bugprone/enum-to-bool-conversion.rst:12-13
+
+The check produces false positives if the ``enum`` is used to store other 
values
+(used as a bit-mask or zero-initialized on purpose). To deal with 
false-positives,
+``//NOLINT`` or casting first to the underlying type before casting to ``bool``

I can't think of a case where this could happen, might be worth adding an 
example below.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/bugprone/enum-to-bool-conversion.rst:14
+(used as a bit-mask or zero-initialized on purpose). To deal with 
false-positives,
+``//NOLINT`` or casting first to the underlying type before casting to ``bool``
+can be used.

Nit: Add space between `//` and `NOLINT`



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/bugprone/enum-to-bool-conversion.rst:38
+void process(EStatus status)
+{
+if (not status)

Nit: use 2 chars indentation



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/bugprone/enum-to-bool-conversion.rst:39
+{
+if (not status)
+{

Use traditional operators for consistency.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/bugprone/enum-to-bool-conversion.rst:41
+{
+// this true-branch in theory wont be executed
+return;

won't



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/bugprone/enum-to-bool-conversion.rst:41
+{
+// this true-branch in theory wont be executed
+return;

carlosgalvezp wrote:
> won't
Remove?



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/bugprone/enum-to-bool-conversion-cpp11.cpp:9
+SUCCESS   = 1,
+FAILURE   = 2,
+INVALID_PARAM = 3,

Indent with 2 chars instead of 4.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/bugprone/enum-to-bool-conversion-cpp11.cpp:16
+{
+// CHECK-MESSAGES: :[[@LINE+1]]:12: warning: conversion of 'EStatus' into 
'bool' will always return 'true', enum doesn't have a zero-value enumerator 
[bugprone-enum-to-bool-conversion]
+return static_cast(value);

Nit: Add 2 chars indentation to align with the code.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/bugprone/enum-to-bool-conversion-cpp11.cpp:20
+
+enum EResult : short
+{

Maybe test also "int", since it's the most common default? Also test one `enum 
class` without explicit underlying type.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144036

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


[PATCH] D147324: [OpenMP][MLIR][Flang][bbc][Driver] Add OpenMP RTL Flags to Flang and generate omp.FlagsAttr from them

2023-04-05 Thread Kiran Chandramohan via Phabricator via cfe-commits
kiranchandramohan accepted this revision.
kiranchandramohan added a comment.
This revision is now accepted and ready to land.

LG. This portion of the patch was accepted in https://reviews.llvm.org/D145264.

See inline comment about location of LLVM Dialect tests. You may either remove 
the LLVM dialect tests from this patch and land it. Or you can submit this and 
move the tests in a separate NFC patch and submit without review.




Comment at: flang/test/Lower/OpenMP/rtl-flags.f90:10-27
+!RUN: %flang_fc1 -emit-fir -fopenmp %s -o - | fir-opt --fir-to-llvm-ir | 
FileCheck %s  --check-prefix=DEFAULT-HOST-LLVMDIALECT
+!RUN: %flang_fc1 -emit-fir -fopenmp -fopenmp-is-device %s -o - | fir-opt 
--fir-to-llvm-ir | FileCheck %s --check-prefix=DEFAULT-DEVICE-LLVMDIALECT
+!RUN: %flang_fc1 -emit-fir -fopenmp -fopenmp-target-debug -fopenmp-is-device 
%s -o - | fir-opt --fir-to-llvm-ir | FileCheck %s 
--check-prefix=DBG-DEVICE-LLVMDIALECT
+!RUN: %flang_fc1 -emit-fir -fopenmp -fopenmp-target-debug=111 
-fopenmp-is-device %s -o - | fir-opt --fir-to-llvm-ir | FileCheck %s 
--check-prefix=DBG-EQ-DEVICE-LLVMDIALECT
+!RUN: %flang_fc1 -emit-fir -fopenmp -fopenmp-assume-teams-oversubscription 
-fopenmp-is-device %s -o - | fir-opt --fir-to-llvm-ir | FileCheck %s 
--check-prefix=TEAMS-OSUB-DEVICE-LLVMDIALECT
+!RUN: %flang_fc1 -emit-fir -fopenmp -fopenmp-assume-threads-oversubscription 
-fopenmp-is-device %s -o - | fir-opt --fir-to-llvm-ir | FileCheck %s 
--check-prefix=THREAD-OSUB-DEVICE-LLVMDIALECT
+!RUN: %flang_fc1 -emit-fir -fopenmp -fopenmp-assume-no-thread-state 
-fopenmp-is-device %s -o - | fir-opt --fir-to-llvm-ir | FileCheck %s 
--check-prefix=THREAD-STATE-DEVICE-LLVMDIALECT

The tests for LLVM dialect should be in 
https://github.com/llvm/llvm-project/blob/main/flang/test/Fir/convert-to-llvm-openmp-and-fir.fir.

Same for other LLVM dialect RUN lines below.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147324

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


[PATCH] D147574: [NFC][clang] Fix Coverity static analyzer tool concerns about auto_causes_copy

2023-04-05 Thread Soumi Manna via Phabricator via cfe-commits
Manna added a comment.

In D147574#4245881 , @erichkeane 
wrote:

> In D147574#4245877 , @Manna wrote:
>
>> Thanks @erichkeane.
>>
>> Is this known failure?
>>
>> Failed Tests (1):
>>
>>   Clang :: 
>> SemaCXX/warn-unsafe-buffer-usage-fixits-addressof-arraysubscript.cpp
>>
>> https://buildkite.com/llvm-project/premerge-checks/builds/145026#01874e21-00e2-47a9-9bc4-975357d197ef
>
> Looks like the commit that added that test got reverted here 
> d5c428356f6ee107a97977eb9ef1aa4d5fa0c378 
>  because 
> it caused the test to fail, so it looks like the answer is 'yes'.

Thanks @erichkeane for confirming!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147574

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


[PATCH] D146042: [clang-format] Fix numerous issues with "LambdaBodyIndentation: OuterScope" option

2023-04-05 Thread Jon Phillips via Phabricator via cfe-commits
jp4a50 updated this revision to Diff 511098.
jp4a50 added a comment.

Add release note.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146042

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

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -22009,9 +22009,9 @@
   verifyFormat("void test() {\n"
"  (\n"
"  []() -> auto {\n"
-   "int b = 32;\n"
-   "return 3;\n"
-   "  },\n"
+   "int b = 32;\n"
+   "return 3;\n"
+   "  },\n"
"  foo, bar)\n"
"  .foo();\n"
"}",
@@ -22025,17 +22025,82 @@
"  .bar();\n"
"}",
Style);
-  Style = getGoogleStyle();
-  Style.LambdaBodyIndentation = FormatStyle::LBI_OuterScope;
-  verifyFormat("#define A   \\\n"
-   "  [] {  \\\n"
-   "xxx(\\\n"
-   "x); \\\n"
-   "  }",
-   Style);
-  // TODO: The current formatting has a minor issue that's not worth fixing
-  // right now whereby the closing brace is indented relative to the signature
-  // instead of being aligned. This only happens with macros.
+  verifyFormat("#define A  \\\n"
+   "  [] { \\\n"
+   "xxx(   \\\n"
+   "x);\\\n"
+   "  }",
+   Style);
+  verifyFormat("void foo() {\n"
+   "  aFunction(1, b(c(foo, bar, baz, [](d) {\n"
+   "auto f = e(d);\n"
+   "return f;\n"
+   "  })));\n"
+   "}",
+   Style);
+  Style.AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak;
+  verifyFormat("void foo() {\n"
+   "  aFunction(\n"
+   "  1, b(c(\n"
+   " [](d) -> Foo {\n"
+   "auto f = e(d);\n"
+   "return f;\n"
+   "  },\n"
+   " foo, Bar{},\n"
+   " [] {\n"
+   "auto g = h();\n"
+   "return g;\n"
+   "  },\n"
+   " baz)));\n"
+   "}",
+   Style);
+  verifyFormat("void foo() {\n"
+   "  aFunction(1, b(c(foo, Bar{}, baz, [](d) -> Foo {\n"
+   "auto f = e(\n"
+   "foo,\n"
+   "[&] {\n"
+   "  auto g = h();\n"
+   "  return g;\n"
+   "},\n"
+   "qux,\n"
+   "[&] -> Bar {\n"
+   "  auto i = j();\n"
+   "  return i;\n"
+   "});\n"
+   "return f;\n"
+   "  })));\n"
+   "}",
+   Style);
+  verifyFormat("Namespace::Foo::Foo(\n"
+   "LongClassName bar, AnotherLongClassName baz)\n"
+   ": baz{baz}, func{[&] {\n"
+   "  auto qux = bar;\n"
+   "  return aFunkyFunctionCall(qux);\n"
+   "}} {}",
+   Style);
+  Style.BreakBeforeBraces = FormatStyle::BS_Custom;
+  Style.BraceWrapping.BeforeLambdaBody = true;
+  verifyFormat("void foo() {\n"
+   "  aFunction(\n"
+   "  1, b(c(foo, Bar{}, baz,\n"
+   " [](d) -> Foo\n"
+   "  {\n"
+   "auto f = e(\n"
+   "[&]\n"
+   "{\n"
+   "  auto g = h();\n"
+   "  return g;\n"
+   "},\n"
+   "qux,\n"
+   "[&] -> Bar\n"
+   "{\n"
+   "  auto i = j();\n"
+   "  return i;\n"
+   "});\n"
+   "return f;\n"
+   "  })));\n"
+   "}",
+   Style);
 }
 
 TEST_F(FormatTest, LambdaWithLineComments) {
Index: clang/lib/Format/UnwrappedLineFormatter.cpp
===
--- clang/lib/Format/UnwrappedLineFormatter.cpp
+++ clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -1003,17 

[PATCH] D147574: [NFC][clang] Fix Coverity static analyzer tool concerns about auto_causes_copy

2023-04-05 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

In D147574#4245877 , @Manna wrote:

> Thanks @erichkeane.
>
> Is this known failure?
>
> Failed Tests (1):
>
>   Clang :: 
> SemaCXX/warn-unsafe-buffer-usage-fixits-addressof-arraysubscript.cpp
>
> https://buildkite.com/llvm-project/premerge-checks/builds/145026#01874e21-00e2-47a9-9bc4-975357d197ef

Looks like the commit that added that test got reverted here 
d5c428356f6ee107a97977eb9ef1aa4d5fa0c378 
 because 
it caused the test to fail, so it looks like the answer is 'yes'.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147574

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


[PATCH] D147324: [OpenMP][MLIR][Flang][bbc][Driver] Add OpenMP RTL Flags to Flang and generate omp.FlagsAttr from them

2023-04-05 Thread Andrew Gozillon via Phabricator via cfe-commits
agozillon added a comment.

Hi @awarzynski would it please be possible to get this reviewed when you have a 
spare moment or few, it's essentially the segment of the modifications from 
this patch which you accepted: https://reviews.llvm.org/D145264 the lowering 
has been separated into a different phab review as was requested. This pass 
just adds flags and creates the attribute on the Module! So it is hopefully 
good to go or close to it depending on your feedback :-) although I'll commit 
it at the same time as the lowering segment of the pass is accepted.

Thank you very much as always for your time reviewing my patches, I appreciate 
it greatly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147324

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


[PATCH] D147574: [NFC][clang] Fix Coverity static analyzer tool concerns about auto_causes_copy

2023-04-05 Thread Soumi Manna via Phabricator via cfe-commits
Manna added a comment.

Thanks @erichkeane.

Is this known failure?

Failed Tests (1):

  Clang :: SemaCXX/warn-unsafe-buffer-usage-fixits-addressof-arraysubscript.cpp

https://buildkite.com/llvm-project/premerge-checks/builds/145026#01874e21-00e2-47a9-9bc4-975357d197ef


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147574

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


[PATCH] D147615: [clang][Sema][NFC] Save token name instead of the full token

2023-04-05 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder created this revision.
tbaeder added a reviewer: aaron.ballman.
Herald added a project: All.
tbaeder requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This makes it a bit clearer why we're saving the token (so no need for the 
later comment).

I'm just not 100% sure about the lifetime of the token name.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D147615

Files:
  clang/lib/Parse/ParseDeclCXX.cpp


Index: clang/lib/Parse/ParseDeclCXX.cpp
===
--- clang/lib/Parse/ParseDeclCXX.cpp
+++ clang/lib/Parse/ParseDeclCXX.cpp
@@ -958,8 +958,8 @@
   assert(Tok.isOneOf(tok::kw_static_assert, tok::kw__Static_assert) &&
  "Not a static_assert declaration");
 
-  // Save the token used for static assertion.
-  Token SavedTok = Tok;
+  // Save the token name used for static assertion.
+  const char *TokName = Tok.getName();
 
   if (Tok.is(tok::kw__Static_assert) && !getLangOpts().C11)
 Diag(Tok, diag::ext_c11_feature) << Tok.getName();
@@ -1027,9 +1027,7 @@
   T.consumeClose();
 
   DeclEnd = Tok.getLocation();
-  // Passing the token used to the error message.
-  ExpectAndConsumeSemi(diag::err_expected_semi_after_static_assert,
-   SavedTok.getName());
+  ExpectAndConsumeSemi(diag::err_expected_semi_after_static_assert, TokName);
 
   return Actions.ActOnStaticAssertDeclaration(StaticAssertLoc, 
AssertExpr.get(),
   AssertMessage.get(),


Index: clang/lib/Parse/ParseDeclCXX.cpp
===
--- clang/lib/Parse/ParseDeclCXX.cpp
+++ clang/lib/Parse/ParseDeclCXX.cpp
@@ -958,8 +958,8 @@
   assert(Tok.isOneOf(tok::kw_static_assert, tok::kw__Static_assert) &&
  "Not a static_assert declaration");
 
-  // Save the token used for static assertion.
-  Token SavedTok = Tok;
+  // Save the token name used for static assertion.
+  const char *TokName = Tok.getName();
 
   if (Tok.is(tok::kw__Static_assert) && !getLangOpts().C11)
 Diag(Tok, diag::ext_c11_feature) << Tok.getName();
@@ -1027,9 +1027,7 @@
   T.consumeClose();
 
   DeclEnd = Tok.getLocation();
-  // Passing the token used to the error message.
-  ExpectAndConsumeSemi(diag::err_expected_semi_after_static_assert,
-   SavedTok.getName());
+  ExpectAndConsumeSemi(diag::err_expected_semi_after_static_assert, TokName);
 
   return Actions.ActOnStaticAssertDeclaration(StaticAssertLoc, AssertExpr.get(),
   AssertMessage.get(),
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D147561: [clang] don't serialize MODULE_DIRECTORY with ModuleFileHomeIsCwd

2023-04-05 Thread Richard Howell via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8ee5029b225b: [clang] dont serialize MODULE_DIRECTORY 
with ModuleFileHomeIsCwd (authored by rmaz).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147561

Files:
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/Modules/module-file-home-is-cwd.m


Index: clang/test/Modules/module-file-home-is-cwd.m
===
--- clang/test/Modules/module-file-home-is-cwd.m
+++ clang/test/Modules/module-file-home-is-cwd.m
@@ -5,11 +5,12 @@
 // RUN: -fmodules-embed-all-files %S/Inputs/normal-module-map/module.map \
 // RUN: -o %t/mod.pcm
 // RUN: llvm-bcanalyzer --dump --disable-histogram %t/mod.pcm | FileCheck %s
+// RUN: llvm-bcanalyzer --dump --disable-histogram %t/mod.pcm | FileCheck %s 
--check-prefix=INPUT
 
-// CHECK:  blob data = 
'Inputs{{/|\\}}normal-module-map{{/|\\}}module.map'
-// CHECK:  blob data = 
'Inputs{{/|\\}}normal-module-map{{/|\\}}a2.h'
-// CHECK:  blob data = 
'Inputs{{/|\\}}normal-module-map{{/|\\}}a1.h'
 // CHECK-NOT: MODULE_DIRECTORY
+// INPUT:  blob data = 
'Inputs{{/|\\}}normal-module-map{{/|\\}}module.map'
+// INPUT:  blob data = 
'Inputs{{/|\\}}normal-module-map{{/|\\}}a2.h'
+// INPUT:  blob data = 
'Inputs{{/|\\}}normal-module-map{{/|\\}}a1.h'
 
 @import libA;
 
Index: clang/lib/Serialization/ASTWriter.cpp
===
--- clang/lib/Serialization/ASTWriter.cpp
+++ clang/lib/Serialization/ASTWriter.cpp
@@ -1288,11 +1288,11 @@
 // If the home of the module is the current working directory, then we
 // want to pick up the cwd of the build process loading the module, not
 // our cwd, when we load this module.
-if (!(PP.getHeaderSearchInfo()
+if (!PP.getHeaderSearchInfo().getHeaderSearchOpts().ModuleFileHomeIsCwd &&
+(!PP.getHeaderSearchInfo()
   .getHeaderSearchOpts()
   .ModuleMapFileHomeIsCwd ||
-  PP.getHeaderSearchInfo().getHeaderSearchOpts().ModuleFileHomeIsCwd) 
||
-WritingModule->Directory->getName() != StringRef(".")) {
+ WritingModule->Directory->getName() != StringRef("."))) {
   // Module directory.
   auto Abbrev = std::make_shared();
   Abbrev->Add(BitCodeAbbrevOp(MODULE_DIRECTORY));


Index: clang/test/Modules/module-file-home-is-cwd.m
===
--- clang/test/Modules/module-file-home-is-cwd.m
+++ clang/test/Modules/module-file-home-is-cwd.m
@@ -5,11 +5,12 @@
 // RUN: -fmodules-embed-all-files %S/Inputs/normal-module-map/module.map \
 // RUN: -o %t/mod.pcm
 // RUN: llvm-bcanalyzer --dump --disable-histogram %t/mod.pcm | FileCheck %s
+// RUN: llvm-bcanalyzer --dump --disable-histogram %t/mod.pcm | FileCheck %s --check-prefix=INPUT
 
-// CHECK:  blob data = 'Inputs{{/|\\}}normal-module-map{{/|\\}}module.map'
-// CHECK:  blob data = 'Inputs{{/|\\}}normal-module-map{{/|\\}}a2.h'
-// CHECK:  blob data = 'Inputs{{/|\\}}normal-module-map{{/|\\}}a1.h'
 // CHECK-NOT: MODULE_DIRECTORY
+// INPUT:  blob data = 'Inputs{{/|\\}}normal-module-map{{/|\\}}module.map'
+// INPUT:  blob data = 'Inputs{{/|\\}}normal-module-map{{/|\\}}a2.h'
+// INPUT:  blob data = 'Inputs{{/|\\}}normal-module-map{{/|\\}}a1.h'
 
 @import libA;
 
Index: clang/lib/Serialization/ASTWriter.cpp
===
--- clang/lib/Serialization/ASTWriter.cpp
+++ clang/lib/Serialization/ASTWriter.cpp
@@ -1288,11 +1288,11 @@
 // If the home of the module is the current working directory, then we
 // want to pick up the cwd of the build process loading the module, not
 // our cwd, when we load this module.
-if (!(PP.getHeaderSearchInfo()
+if (!PP.getHeaderSearchInfo().getHeaderSearchOpts().ModuleFileHomeIsCwd &&
+(!PP.getHeaderSearchInfo()
   .getHeaderSearchOpts()
   .ModuleMapFileHomeIsCwd ||
-  PP.getHeaderSearchInfo().getHeaderSearchOpts().ModuleFileHomeIsCwd) ||
-WritingModule->Directory->getName() != StringRef(".")) {
+ WritingModule->Directory->getName() != StringRef("."))) {
   // Module directory.
   auto Abbrev = std::make_shared();
   Abbrev->Add(BitCodeAbbrevOp(MODULE_DIRECTORY));
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 8ee5029 - [clang] don't serialize MODULE_DIRECTORY with ModuleFileHomeIsCwd

2023-04-05 Thread Richard Howell via cfe-commits

Author: Richard Howell
Date: 2023-04-05T07:19:48-07:00
New Revision: 8ee5029b225ba1ff415e0a0a6a68dc4e3efee4d1

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

LOG: [clang] don't serialize MODULE_DIRECTORY with ModuleFileHomeIsCwd

Fix a bug in the MODULE_DIRECTORY serialization logic
that would cause MODULE_DIRECTORY to be serialized when
`-fmodule-file-home-is-cwd` is specified.

This matches the original logic added in:
https://github.com/apple/llvm-project/commit/f7b41371d9ede1aecf0930e5bd4a463519264633

Reviewed By: keith

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

Added: 


Modified: 
clang/lib/Serialization/ASTWriter.cpp
clang/test/Modules/module-file-home-is-cwd.m

Removed: 




diff  --git a/clang/lib/Serialization/ASTWriter.cpp 
b/clang/lib/Serialization/ASTWriter.cpp
index 177a3c3a34d73..245304254811a 100644
--- a/clang/lib/Serialization/ASTWriter.cpp
+++ b/clang/lib/Serialization/ASTWriter.cpp
@@ -1288,11 +1288,11 @@ void ASTWriter::WriteControlBlock(Preprocessor , 
ASTContext ,
 // If the home of the module is the current working directory, then we
 // want to pick up the cwd of the build process loading the module, not
 // our cwd, when we load this module.
-if (!(PP.getHeaderSearchInfo()
+if (!PP.getHeaderSearchInfo().getHeaderSearchOpts().ModuleFileHomeIsCwd &&
+(!PP.getHeaderSearchInfo()
   .getHeaderSearchOpts()
   .ModuleMapFileHomeIsCwd ||
-  PP.getHeaderSearchInfo().getHeaderSearchOpts().ModuleFileHomeIsCwd) 
||
-WritingModule->Directory->getName() != StringRef(".")) {
+ WritingModule->Directory->getName() != StringRef("."))) {
   // Module directory.
   auto Abbrev = std::make_shared();
   Abbrev->Add(BitCodeAbbrevOp(MODULE_DIRECTORY));

diff  --git a/clang/test/Modules/module-file-home-is-cwd.m 
b/clang/test/Modules/module-file-home-is-cwd.m
index 706b815e6d0c2..a3875d578bb60 100644
--- a/clang/test/Modules/module-file-home-is-cwd.m
+++ b/clang/test/Modules/module-file-home-is-cwd.m
@@ -5,11 +5,12 @@
 // RUN: -fmodules-embed-all-files %S/Inputs/normal-module-map/module.map \
 // RUN: -o %t/mod.pcm
 // RUN: llvm-bcanalyzer --dump --disable-histogram %t/mod.pcm | FileCheck %s
+// RUN: llvm-bcanalyzer --dump --disable-histogram %t/mod.pcm | FileCheck %s 
--check-prefix=INPUT
 
-// CHECK:  blob data = 
'Inputs{{/|\\}}normal-module-map{{/|\\}}module.map'
-// CHECK:  blob data = 
'Inputs{{/|\\}}normal-module-map{{/|\\}}a2.h'
-// CHECK:  blob data = 
'Inputs{{/|\\}}normal-module-map{{/|\\}}a1.h'
 // CHECK-NOT: MODULE_DIRECTORY
+// INPUT:  blob data = 
'Inputs{{/|\\}}normal-module-map{{/|\\}}module.map'
+// INPUT:  blob data = 
'Inputs{{/|\\}}normal-module-map{{/|\\}}a2.h'
+// INPUT:  blob data = 
'Inputs{{/|\\}}normal-module-map{{/|\\}}a1.h'
 
 @import libA;
 



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


[PATCH] D146873: [2/N][POC][Clang][RISCV] Define RVV tuple types

2023-04-05 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 511093.
eopXD added a comment.

Rebase upon change of parent patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146873

Files:
  clang/include/clang/Basic/RISCVVTypes.def
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CodeGenTypes.cpp
  clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/rvv-tuple-type-0.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/rvv-tuple-type-1.c
  clang/test/Sema/riscv-types.c

Index: clang/test/Sema/riscv-types.c
===
--- clang/test/Sema/riscv-types.c
+++ clang/test/Sema/riscv-types.c
@@ -133,6 +133,9 @@
 
   // CHECK: __rvv_int8mf2_t x43;
   __rvv_int8mf2_t x43;
+
+  // CHECK: __rvv_int32m1x2_t x44;
+  __rvv_int32m1x2_t x44;
 }
 
 typedef __rvv_bool4_t vbool4_t;
Index: clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/rvv-tuple-type-1.c
===
--- /dev/null
+++ clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/rvv-tuple-type-1.c
@@ -0,0 +1,49 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 2
+// RUN: %clang_cc1 -triple riscv64 -target-feature +zve32x -disable-O0-optnone \
+// RUN:   -emit-llvm %s -o - | opt -S -passes=mem2reg | FileCheck %s
+
+#include 
+
+// Declare local variable
+// CHECK-LABEL: define dso_local void @foo
+// CHECK-SAME: () #[[ATTR0:[0-9]+]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:ret void
+//
+void foo() {
+  __rvv_int32m1x2_t v_tuple;
+}
+
+// Declare local variable and return
+// CHECK-LABEL: define dso_local { ,  } @bar
+// CHECK-SAME: () #[[ATTR0]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:ret { ,  } undef
+//
+__rvv_int32m1x2_t bar() {
+  __rvv_int32m1x2_t v_tuple;
+  return v_tuple;
+}
+
+// Pass as function parameter
+// CHECK-LABEL: define dso_local void @baz
+// CHECK-SAME: ( [[V_TUPLE_COERCE0:%.*]],  [[V_TUPLE_COERCE1:%.*]]) #[[ATTR0]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = insertvalue { ,  } undef,  [[V_TUPLE_COERCE0]], 0
+// CHECK-NEXT:[[TMP1:%.*]] = insertvalue { ,  } [[TMP0]],  [[V_TUPLE_COERCE1]], 1
+// CHECK-NEXT:ret void
+//
+void baz(__rvv_int32m1x2_t v_tuple) {
+}
+
+// Pass as function parameter and return
+// CHECK-LABEL: define dso_local { ,  } @qux
+// CHECK-SAME: ( [[V_TUPLE_COERCE0:%.*]],  [[V_TUPLE_COERCE1:%.*]]) #[[ATTR0]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = insertvalue { ,  } undef,  [[V_TUPLE_COERCE0]], 0
+// CHECK-NEXT:[[TMP1:%.*]] = insertvalue { ,  } [[TMP0]],  [[V_TUPLE_COERCE1]], 1
+// CHECK-NEXT:ret { ,  } [[TMP1]]
+//
+__rvv_int32m1x2_t qux(__rvv_int32m1x2_t v_tuple) {
+  return v_tuple;
+}
Index: clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/rvv-tuple-type-0.c
===
--- /dev/null
+++ clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/rvv-tuple-type-0.c
@@ -0,0 +1,65 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 2
+// RUN: %clang_cc1 -triple riscv64 -target-feature +zve32x -O0 \
+// RUN:   -emit-llvm %s -o - | FileCheck %s
+
+#include 
+
+// Declare local variable
+// CHECK-LABEL: define dso_local void @foo
+// CHECK-SAME: () #[[ATTR0:[0-9]+]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[V_TUPLE:%.*]] = alloca { ,  }, align 4
+// CHECK-NEXT:ret void
+//
+void foo() {
+  __rvv_int32m1x2_t v_tuple;
+}
+
+// Declare local variable and return
+// CHECK-LABEL: define dso_local { ,  } @bar
+// CHECK-SAME: () #[[ATTR0]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[V_TUPLE:%.*]] = alloca { ,  }, align 4
+// CHECK-NEXT:[[TMP0:%.*]] = load { ,  }, ptr [[V_TUPLE]], align 4
+// CHECK-NEXT:ret { ,  } [[TMP0]]
+//
+__rvv_int32m1x2_t bar() {
+  __rvv_int32m1x2_t v_tuple;
+  return v_tuple;
+}
+
+// Pass as function parameter
+// CHECK-LABEL: define dso_local void @baz
+// CHECK-SAME: ( [[V_TUPLE_COERCE0:%.*]],  [[V_TUPLE_COERCE1:%.*]]) #[[ATTR0]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[V_TUPLE:%.*]] = alloca { ,  }, align 4
+// CHECK-NEXT:[[V_TUPLE_ADDR:%.*]] = alloca { ,  }, align 4
+// CHECK-NEXT:[[TMP0:%.*]] = load { ,  }, ptr [[V_TUPLE]], align 4
+// CHECK-NEXT:[[TMP1:%.*]] = insertvalue { ,  } [[TMP0]],  [[V_TUPLE_COERCE0]], 0
+// CHECK-NEXT:[[TMP2:%.*]] = insertvalue { ,  } [[TMP1]],  [[V_TUPLE_COERCE1]], 1
+// CHECK-NEXT:store { ,  } [[TMP2]], ptr [[V_TUPLE]], align 4
+// CHECK-NEXT:[[V_TUPLE1:%.*]] = load { ,  }, ptr [[V_TUPLE]], align 4
+// CHECK-NEXT:store { ,  } [[V_TUPLE1]], ptr [[V_TUPLE_ADDR]], align 4
+// CHECK-NEXT:ret void
+//
+void baz(__rvv_int32m1x2_t v_tuple) {
+}
+
+// Pass as function parameter and return
+// CHECK-LABEL: define dso_local { ,  } @qux
+// CHECK-SAME: ( [[V_TUPLE_COERCE0:%.*]],  [[V_TUPLE_COERCE1:%.*]]) #[[ATTR0]] {
+// CHECK-NEXT:  entry:

[PATCH] D141215: [clang-repl] Introduce Value to capture expression results

2023-04-05 Thread Jun Zhang via Phabricator via cfe-commits
junaire updated this revision to Diff 511090.
junaire added a comment.

Remove old code


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141215

Files:
  clang/include/clang/AST/Decl.h
  clang/include/clang/Basic/TokenKinds.def
  clang/include/clang/Interpreter/Interpreter.h
  clang/include/clang/Interpreter/Value.h
  clang/include/clang/Parse/Parser.h
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Frontend/PrintPreprocessedOutput.cpp
  clang/lib/Interpreter/CMakeLists.txt
  clang/lib/Interpreter/IncrementalASTConsumer.cpp
  clang/lib/Interpreter/IncrementalASTConsumer.h
  clang/lib/Interpreter/IncrementalExecutor.cpp
  clang/lib/Interpreter/IncrementalExecutor.h
  clang/lib/Interpreter/IncrementalParser.cpp
  clang/lib/Interpreter/IncrementalParser.h
  clang/lib/Interpreter/Interpreter.cpp
  clang/lib/Interpreter/InterpreterUtils.cpp
  clang/lib/Interpreter/InterpreterUtils.h
  clang/lib/Interpreter/Value.cpp
  clang/lib/Lex/PPLexerChange.cpp
  clang/lib/Parse/ParseCXXInlineMethods.cpp
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseStmt.cpp
  clang/lib/Parse/Parser.cpp
  clang/tools/clang-repl/CMakeLists.txt
  clang/unittests/Interpreter/CMakeLists.txt
  clang/unittests/Interpreter/InterpreterTest.cpp

Index: clang/unittests/Interpreter/InterpreterTest.cpp
===
--- clang/unittests/Interpreter/InterpreterTest.cpp
+++ clang/unittests/Interpreter/InterpreterTest.cpp
@@ -17,6 +17,7 @@
 #include "clang/AST/Mangle.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/TextDiagnosticPrinter.h"
+#include "clang/Interpreter/Value.h"
 #include "clang/Sema/Lookup.h"
 #include "clang/Sema/Sema.h"
 
@@ -33,6 +34,10 @@
 #define CLANG_INTERPRETER_NO_SUPPORT_EXEC
 #endif
 
+int Global = 42;
+int getGlobal() { return Global; }
+void setGlobal(int val) { Global = val; }
+
 namespace {
 using Args = std::vector;
 static std::unique_ptr
@@ -276,8 +281,7 @@
   std::vector Args = {"-fno-delayed-template-parsing"};
   std::unique_ptr Interp = createInterpreter(Args);
 
-  llvm::cantFail(Interp->Parse("void* operator new(__SIZE_TYPE__, void* __p);"
-   "extern \"C\" int printf(const char*,...);"
+  llvm::cantFail(Interp->Parse("extern \"C\" int printf(const char*,...);"
"class A {};"
"struct B {"
"  template"
@@ -314,4 +318,38 @@
   free(NewA);
 }
 
+TEST(InterpreterTest, Value) {
+  std::unique_ptr Interp = createInterpreter();
+
+  Value V1;
+  llvm::cantFail(Interp->ParseAndExecute("int x = 42;"));
+  llvm::cantFail(Interp->ParseAndExecute("x", ));
+  EXPECT_EQ(V1.getInt(), 42);
+  EXPECT_TRUE(V1.getType()->isIntegerType());
+
+  Value V2;
+  llvm::cantFail(Interp->ParseAndExecute("double y = 3.14;"));
+  llvm::cantFail(Interp->ParseAndExecute("y", ));
+  EXPECT_EQ(V2.getAs(), 3.14);
+  EXPECT_TRUE(V2.getType()->isFloatingType());
+  EXPECT_EQ(V2.castAs(), 3);
+
+  llvm::cantFail(Interp->ParseAndExecute("int getGlobal();"));
+  llvm::cantFail(Interp->ParseAndExecute("void setGlobal(int);"));
+  Value V3;
+  llvm::cantFail(Interp->ParseAndExecute("getGlobal()", ));
+  EXPECT_EQ(V3.getInt(), 42);
+  EXPECT_TRUE(V3.getType()->isIntegerType());
+
+  // Change the global from the compiled code.
+  setGlobal(43);
+  Value V4;
+  llvm::cantFail(Interp->ParseAndExecute("getGlobal()", ));
+  EXPECT_EQ(V4.getInt(), 43);
+  EXPECT_TRUE(V4.getType()->isIntegerType());
+
+  // Change the global from the interpreted code.
+  llvm::cantFail(Interp->ParseAndExecute("setGlobal(44);"));
+  EXPECT_EQ(getGlobal(), 44);
+}
 } // end anonymous namespace
Index: clang/unittests/Interpreter/CMakeLists.txt
===
--- clang/unittests/Interpreter/CMakeLists.txt
+++ clang/unittests/Interpreter/CMakeLists.txt
@@ -22,3 +22,5 @@
 if(NOT WIN32)
   add_subdirectory(ExceptionTests)
 endif()
+
+export_executable_symbols(ClangReplInterpreterTests)
Index: clang/tools/clang-repl/CMakeLists.txt
===
--- clang/tools/clang-repl/CMakeLists.txt
+++ clang/tools/clang-repl/CMakeLists.txt
@@ -12,6 +12,7 @@
   )
 
 clang_target_link_libraries(clang-repl PRIVATE
+  clangAST
   clangBasic
   clangFrontend
   clangInterpreter
Index: clang/lib/Parse/Parser.cpp
===
--- clang/lib/Parse/Parser.cpp
+++ clang/lib/Parse/Parser.cpp
@@ -320,6 +320,7 @@
 case tok::annot_module_begin:
 case tok::annot_module_end:
 case tok::annot_module_include:
+case tok::annot_input_end:
   // Stop before we change submodules. They generally indicate a "good"
   // place to pick up parsing again (except in the special case where
   // we're trying to skip to EOF).
@@ -616,8 +617,8 @@
 
   // 

  1   2   >