[clang] 5f038e0 - [Clang][NFC] Fix "initalizer" typo

2023-07-10 Thread Corentin Jabot via cfe-commits

Author: Corentin Jabot
Date: 2023-07-10T09:06:19+02:00
New Revision: 5f038e0e20641515fe412e1df298a62eb657f554

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

LOG: [Clang][NFC] Fix "initalizer" typo

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticASTKinds.td
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/CodeGen/CGDeclCXX.cpp
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaInit.cpp
clang/test/Modules/odr_hash.cpp
clang/test/SemaCXX/cxx2a-consteval-default-params.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticASTKinds.td 
b/clang/include/clang/Basic/DiagnosticASTKinds.td
index 856293dd45d089..566cdc3406058f 100644
--- a/clang/include/clang/Basic/DiagnosticASTKinds.td
+++ b/clang/include/clang/Basic/DiagnosticASTKinds.td
@@ -781,7 +781,7 @@ def err_module_odr_violation_field : Error<
   "%select{non-|}5bitfield %4|"
   "bitfield %4 with one width expression|"
   "%select{non-|}5mutable field %4|"
-  "field %4 with %select{no|an}5 initalizer|"
+  "field %4 with %select{no|an}5 initializer|"
   "field %4 with an initializer"
   "}3">;
 def note_module_odr_violation_field : Note<

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 7ca91020181845..eea4d4961c077a 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -2671,7 +2671,7 @@ def note_immediate_function_reason : Note<
   "expression}3">;
 
 def note_invalid_consteval_initializer : Note<
-  "in the default initalizer of %0">;
+  "in the default initializer of %0">;
 def note_invalid_consteval_initializer_here : Note<
   "initialized here %0">;
 def err_invalid_consteval_decl_kind : Error<
@@ -9660,7 +9660,7 @@ def note_lambda_capture_initializer : Note<
   "%select{implicitly |}2captured%select{| by reference}3"
   "%select{%select{ due to use|}2 here|"
   " via initialization of lambda capture %0}1">;
-def note_init_with_default_member_initalizer : Note<
+def note_init_with_default_member_initializer : Note<
   "initializing field %0 with default member initializer">;
 
 // Check for initializing a member variable with the address or a reference to

diff  --git a/clang/lib/CodeGen/CGDeclCXX.cpp b/clang/lib/CodeGen/CGDeclCXX.cpp
index 8a77ffeed52f7c..be8fb6c274db10 100644
--- a/clang/lib/CodeGen/CGDeclCXX.cpp
+++ b/clang/lib/CodeGen/CGDeclCXX.cpp
@@ -643,7 +643,7 @@ void CodeGenModule::EmitCXXThreadLocalInitFunc() {
This is arranged to be run only once regardless of how many times the module
might be included transitively.  This arranged by using a guard variable.
 
-   If there are no initalizers at all (and also no imported modules) we reduce
+   If there are no initializers at all (and also no imported modules) we reduce
this to an empty function (since the Itanium ABI requires that this function
be available to a caller, which might be produced by a 
diff erent
implementation).

diff  --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index e3cbcd6795ea66..7a4e154cb26110 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -19601,7 +19601,7 @@ static void CheckForDuplicateEnumValues(Sema &S, 
ArrayRef Elements,
   return;
 }
 
-// Constants with initalizers are handled in the next loop.
+// Constants with initializers are handled in the next loop.
 if (ECD->getInitExpr())
   continue;
 

diff  --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp
index 71d59a64fb5767..89fd56fb660b8b 100644
--- a/clang/lib/Sema/SemaInit.cpp
+++ b/clang/lib/Sema/SemaInit.cpp
@@ -8282,7 +8282,7 @@ void Sema::checkInitializerLifetime(const 
InitializedEntity &Entity,
 
   case IndirectLocalPathEntry::DefaultInit: {
 auto *FD = cast(Elem.D);
-Diag(FD->getLocation(), diag::note_init_with_default_member_initalizer)
+Diag(FD->getLocation(), 
diag::note_init_with_default_member_initializer)
 << FD << nextPathEntryRange(Path, I + 1, L);
 break;
   }

diff  --git a/clang/test/Modules/odr_hash.cpp b/clang/test/Modules/odr_hash.cpp
index fffac5e318f5d5..c5bf6e873e52ec 100644
--- a/clang/test/Modules/odr_hash.cpp
+++ b/clang/test/Modules/odr_hash.cpp
@@ -334,7 +334,7 @@ struct S10 {
 };
 #else
 S10 s10;
-// expected-error@second.h:* {{'Field::S10' has 
diff erent definitions in 
diff erent modules; first 
diff erence is definition in module 'SecondModule' found field 'x' with no 
initalizer}}
+// expected-error@second.h:* {{'Field::S10' has 
diff erent definitions in 
diff erent modules; first 
diff erence is definition in module 'SecondModule' found field 'x' with no 
initializer}}
 // expected-note@first.h

[clang] 29f630a - [RISCV][MC] MC layer support for the experimental zacas extension

2023-07-10 Thread Alex Bradbury via cfe-commits

Author: Alex Bradbury
Date: 2023-07-10T08:26:31+01:00
New Revision: 29f630a1ddcbb03caa31b5002f0cbc105ff3a869

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

LOG: [RISCV][MC] MC layer support for the experimental zacas extension

This implements the v1.0-rc1 draft extension.

amocas.d on RV32 and amocas.q have the restriction that rd and rs2 must
be even registers. I've opted to implement this restriction in
RISCVAsmParser::validateInstruction even though for codegen we'll need a
new register class and can then remove this validation. This also
sidesteps, for now, the issue of amocas.d being different on rv32 vs
rv64.

See  for the
issue of needing an agreed asm register constraint for register pairs.

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

Added: 
llvm/test/MC/RISCV/rv32zacas-invalid.s
llvm/test/MC/RISCV/rv32zacas-valid.s
llvm/test/MC/RISCV/rv64zacas-invalid.s
llvm/test/MC/RISCV/rv64zacas-valid.s

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

Removed: 




diff  --git a/clang/test/Preprocessor/riscv-target-features.c 
b/clang/test/Preprocessor/riscv-target-features.c
index 9de44408b74f5c..27c089494de177 100644
--- a/clang/test/Preprocessor/riscv-target-features.c
+++ b/clang/test/Preprocessor/riscv-target-features.c
@@ -72,6 +72,7 @@
 // CHECK-NOT: __riscv_zfbfmin {{.*$}}
 // CHECK-NOT: __riscv_zvfbfmin {{.*$}}
 // CHECK-NOT: __riscv_zvfbfwma {{.*$}}
+// CHECK-NOT: __riscv_zacas {{.*$}}
 
 // RUN: %clang -target riscv32-unknown-linux-gnu -march=rv32i -x c -E -dM %s \
 // RUN: -o - | FileCheck %s
@@ -771,3 +772,11 @@
 // RUN: | FileCheck --check-prefix=CHECK-COMBINE-INTO-ZVKSG %s
 // CHECK-COMBINE-INTO-ZVKSG: __riscv_zvks 100{{$}}
 // CHECK-COMBINE-INTO-ZVKSG: __riscv_zvksg 100{{$}}
+
+// RUN: %clang -target riscv32 -menable-experimental-extensions \
+// RUN: -march=rv32i_zacas1p0 -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-ZACAS-EXT %s
+// RUN: %clang -target riscv64 -menable-experimental-extensions \
+// RUN: -march=rv64i_zacas1p0 -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-ZACAS-EXT %s
+// CHECK-ZACAS-EXT: __riscv_zacas 100{{$}}

diff  --git a/llvm/docs/RISCVUsage.rst b/llvm/docs/RISCVUsage.rst
index 2f1942d75058ac..be71a9e028acd7 100644
--- a/llvm/docs/RISCVUsage.rst
+++ b/llvm/docs/RISCVUsage.rst
@@ -191,6 +191,9 @@ The primary goal of experimental support is to assist in 
the process of ratifica
 ``experimental-ssaia``
   LLVM implements the `Ratification candidate 3 
`_.
 
+``experimental-zacas``
+  LLVM implements the `1.0-rc1 draft specification 
`_.
+
 ``experimental-zfa``
   LLVM implements the `0.2 draft specification 
`__.
 

diff  --git a/llvm/docs/ReleaseNotes.rst b/llvm/docs/ReleaseNotes.rst
index 4016e1badcbcc6..606adc92f910d6 100644
--- a/llvm/docs/ReleaseNotes.rst
+++ b/llvm/docs/ReleaseNotes.rst
@@ -253,6 +253,8 @@ Changes to the RISC-V Backend
 * Assembly support was added for the experimental Zfbfmin (scalar BF16
   conversions), Zvfbfmin (vector BF16 conversions), and Zvfbfwma (vector BF16
   widening mul-add) extensions.
+* Added assembler/disassembler support for the experimental Zacas (atomic
+  compare-and-swap) extension.
 
 Changes to the WebAssembly Backend
 --

diff  --git a/llvm/lib/Support/RISCVISAInfo.cpp 
b/llvm/lib/Support/RISCVISAInfo.cpp
index 720ed06ecf7f65..3cd1ff4c02e3f4 100644
--- a/llvm/lib/Support/RISCVISAInfo.cpp
+++ b/llvm/lib/Support/RISCVISAInfo.cpp
@@ -153,6 +153,8 @@ static const RISCVSupportedExtension 
SupportedExperimentalExtensions[] = {
 {"smaia", RISCVExtensionVersion{1, 0}},
 {"ssaia", RISCVExtensionVersion{1, 0}},
 
+{"zacas", RISCVExtensionVersion{1, 0}},
+
 {"zfa", RISCVExtensionVersion{0, 2}},
 {"zfbfmin", RISCVExtensionVersion{0, 6}},
 
@@ -944,6 +946,7 @@ static const char *ImpliedExtsF[] = {"zicsr"};
 static const char *ImpliedExtsV[] = {"zvl128b", "zve64d"};
 static const char *ImpliedExtsXTHeadVdot[] = {"v"};
 static const char *ImpliedExtsXsfvcp[] = {"zve32x"};
+static const char *ImpliedExtsZacas[] = {"a"};
 static const char *ImpliedExtsZcb[] = {"zca"};
 static const char *I

[PATCH] D149248: [RISCV][MC] MC layer support for the experimental zacas extension

2023-07-10 Thread Alex Bradbury 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 rG29f630a1ddcb: [RISCV][MC] MC layer support for the 
experimental zacas extension (authored by asb).

Changed prior to commit:
  https://reviews.llvm.org/D149248?vs=535372&id=538526#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149248

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

Index: llvm/test/MC/RISCV/rv64zacas-valid.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rv64zacas-valid.s
@@ -0,0 +1,51 @@
+# RUN: llvm-mc %s -triple=riscv64 -mattr=+experimental-zacas -riscv-no-aliases -show-encoding \
+# RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s
+# RUN: llvm-mc -filetype=obj -triple=riscv64 -mattr=+experimental-zacas < %s \
+# RUN: | llvm-objdump --mattr=+experimental-zacas -M no-aliases -d -r - \
+# RUN: | FileCheck --check-prefix=CHECK-ASM-AND-OBJ %s
+# RUN: not llvm-mc -triple=riscv64 -mattr=+a -show-encoding %s 2>&1 \
+# RUN:| FileCheck %s --check-prefix=CHECK-ERROR
+
+# Odd register numbers for rd and rs2 are allowed for amocas.d on RV64.
+
+# CHECK-ASM-AND-OBJ: amocas.d a1, a3, (a5)
+# CHECK-ASM: encoding: [0xaf,0xb5,0xd7,0x28]
+# CHECK-ERROR: instruction requires the following: 'Zacas' (Atomic Compare-And-Swap Instructions){{$}}
+amocas.d a1, a3, (a5)
+# CHECK-ASM-AND-OBJ: amocas.d.aq a1, a3, (a5)
+# CHECK-ASM: encoding: [0xaf,0xb5,0xd7,0x2c]
+# CHECK-ERROR: instruction requires the following: 'Zacas' (Atomic Compare-And-Swap Instructions){{$}}
+amocas.d.aq a1, a3, (a5)
+# CHECK-ASM-AND-OBJ: amocas.d.rl a1, a3, (a5)
+# CHECK-ASM: encoding: [0xaf,0xb5,0xd7,0x2a]
+# CHECK-ERROR: instruction requires the following: 'Zacas' (Atomic Compare-And-Swap Instructions){{$}}
+amocas.d.rl a1, a3, (a5)
+# CHECK-ASM-AND-OBJ: amocas.d.aqrl a1, a3, (a5)
+# CHECK-ASM: encoding: [0xaf,0xb5,0xd7,0x2e]
+# CHECK-ERROR: instruction requires the following: 'Zacas' (Atomic Compare-And-Swap Instructions){{$}}
+amocas.d.aqrl a1, a3, (a5)
+
+# CHECK-ASM-AND-OBJ: amocas.q a0, a2, (a1)
+# CHECK-ASM: encoding: [0x2f,0xc5,0xc5,0x28]
+# CHECK-ERROR: instruction requires the following: 'Zacas' (Atomic Compare-And-Swap Instructions){{$}}
+amocas.q a0, a2, (a1)
+# CHECK-ASM-AND-OBJ: amocas.q a0, a2, (a1)
+# CHECK-ASM: encoding: [0x2f,0xc5,0xc5,0x28]
+# CHECK-ERROR: instruction requires the following: 'Zacas' (Atomic Compare-And-Swap Instructions){{$}}
+amocas.q a0, a2, 0(a1)
+# CHECK-ASM-AND-OBJ: amocas.q zero, zero, (a1)
+# CHECK-ASM: encoding: [0x2f,0xc0,0x05,0x28]
+# CHECK-ERROR: instruction requires the following: 'Zacas' (Atomic Compare-And-Swap Instructions){{$}}
+amocas.q zero, zero, (a1)
+# CHECK-ASM-AND-OBJ: amocas.q.aq zero, zero, (a1)
+# CHECK-ASM: encoding: [0x2f,0xc0,0x05,0x2c]
+# CHECK-ERROR: instruction requires the following: 'Zacas' (Atomic Compare-And-Swap Instructions){{$}}
+amocas.q.aq zero, zero, (a1)
+# CHECK-ASM-AND-OBJ: amocas.q.rl zero, zero, (a1)
+# CHECK-ASM: encoding: [0x2f,0xc0,0x05,0x2a]
+# CHECK-ERROR: instruction requires the following: 'Zacas' (Atomic Compare-And-Swap Instructions){{$}}
+amocas.q.rl zero, zero, (a1)
+# CHECK-ASM-AND-OBJ: amocas.q.aqrl zero, zero, (a1)
+# CHECK-ASM: encoding: [0x2f,0xc0,0x05,0x2e]
+# CHECK-ERROR: instruction requires the following: 'Zacas' (Atomic Compare-And-Swap Instructions){{$}}
+amocas.q.aqrl zero, zero, (a1)
Index: llvm/test/MC/RISCV/rv64zacas-invalid.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rv64zacas-invalid.s
@@ -0,0 +1,16 @@
+# RUN: not llvm-mc -triple riscv64 -mattr=+experimental-zacas < %s 2>&1 | FileCheck %s
+
+# Non-zero offsets not supported for the third operand (rs1).
+amocas.w a1, a3, 1(a5) # CHECK: :[[@LINE]]:18: error: optional integer offset must be 0
+amocas.d a1, a3, 2(a5) # CHECK: :[[@LINE]]:18: error: optional integer offset must be 0
+amocas.q a1, a3, 3(a5) # CHECK: :[[@LINE]]:18: error: optional integer offset must be 0
+
+# First and second operands (rd and rs2) of amocas.q must be even.
+amocas.q a1, a2, (a1) # CHECK: :[[@LINE]]:10: error: The destination register must be even.
+amocas.q a0, a1, (a1) # CHECK: :[[@LINE]]:14: error: The source register must be even.
+amocas.q.aq a1, a2, (a1) # CHECK: :[[@LINE]]:13: error: The destination register must be even.
+amocas.q.aq a0, a1

[PATCH] D154689: [clang] Correct calculation of MemberExpr's dependence

2023-07-10 Thread Mariya Podchishchaeva via Phabricator via cfe-commits
Fznamznon updated this revision to Diff 538531.
Fznamznon added a comment.

Rebase, add tests for dependent NameInfo


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154689

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/AST/ComputeDependence.cpp
  clang/lib/AST/Expr.cpp
  clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp

Index: clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
===
--- clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
+++ clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
@@ -306,3 +306,22 @@
 f(A()); // OK
   }
 }
+
+namespace GH48731 {
+template  using N = int;
+struct X { template void f(); };
+template decltype((X().f>(), ...)) x;
+template decltype(((new X())->f>(), ...)) y;
+
+struct A {};
+template using Tfoo = A;
+template void foo(A a) {
+  (a.~Tfoo(), ...);
+}
+
+struct B { operator int(); };
+template using Tbar = int;
+template void bar(B b) {
+  (b.operator Tbar(), ...);
+}
+}
Index: clang/lib/AST/Expr.cpp
===
--- clang/lib/AST/Expr.cpp
+++ clang/lib/AST/Expr.cpp
@@ -1759,16 +1759,7 @@
   MemberExpr *E = new (Mem) MemberExpr(Base, IsArrow, OperatorLoc, MemberDecl,
NameInfo, T, VK, OK, NOUR);
 
-  // FIXME: remove remaining dependence computation to computeDependence().
-  auto Deps = E->getDependence();
   if (HasQualOrFound) {
-// FIXME: Wrong. We should be looking at the member declaration we found.
-if (QualifierLoc && QualifierLoc.getNestedNameSpecifier()->isDependent())
-  Deps |= ExprDependence::TypeValueInstantiation;
-else if (QualifierLoc &&
- QualifierLoc.getNestedNameSpecifier()->isInstantiationDependent())
-  Deps |= ExprDependence::Instantiation;
-
 E->MemberExprBits.HasQualifierOrFoundDecl = true;
 
 MemberExprNameQualifier *NQ =
@@ -1780,13 +1771,16 @@
   E->MemberExprBits.HasTemplateKWAndArgsInfo =
   TemplateArgs || TemplateKWLoc.isValid();
 
+  // FIXME: remove remaining dependence computation to computeDependence().
+  auto Deps = E->getDependence();
   if (TemplateArgs) {
 auto TemplateArgDeps = TemplateArgumentDependence::None;
 E->getTrailingObjects()->initializeFrom(
 TemplateKWLoc, *TemplateArgs,
 E->getTrailingObjects(), TemplateArgDeps);
-if (TemplateArgDeps & TemplateArgumentDependence::Instantiation)
-  Deps |= ExprDependence::Instantiation;
+for (const TemplateArgumentLoc &ArgLoc : TemplateArgs->arguments()) {
+  Deps |= toExprDependence(ArgLoc.getArgument().getDependence());
+}
   } else if (TemplateKWLoc.isValid()) {
 E->getTrailingObjects()->initializeFrom(
 TemplateKWLoc);
Index: clang/lib/AST/ComputeDependence.cpp
===
--- clang/lib/AST/ComputeDependence.cpp
+++ clang/lib/AST/ComputeDependence.cpp
@@ -611,9 +611,24 @@
   return D;
 }
 
+static inline ExprDependence getDependenceInExpr(DeclarationNameInfo Name) {
+  auto D = ExprDependence::None;
+  if (Name.isInstantiationDependent())
+D |= ExprDependence::Instantiation;
+  if (Name.containsUnexpandedParameterPack())
+D |= ExprDependence::UnexpandedPack;
+  return D;
+}
+
 ExprDependence clang::computeDependence(MemberExpr *E) {
-  auto *MemberDecl = E->getMemberDecl();
   auto D = E->getBase()->getDependence();
+  D |= getDependenceInExpr(E->getMemberNameInfo());
+
+  if (auto *NNS = E->getQualifier())
+D |= toExprDependence(NNS->getDependence() &
+  ~NestedNameSpecifierDependence::Dependent);
+
+  auto *MemberDecl = E->getMemberDecl();
   if (FieldDecl *FD = dyn_cast(MemberDecl)) {
 DeclContext *DC = MemberDecl->getDeclContext();
 // dyn_cast_or_null is used to handle objC variables which do not
@@ -723,15 +738,6 @@
   return D;
 }
 
-static inline ExprDependence getDependenceInExpr(DeclarationNameInfo Name) {
-  auto D = ExprDependence::None;
-  if (Name.isInstantiationDependent())
-D |= ExprDependence::Instantiation;
-  if (Name.containsUnexpandedParameterPack())
-D |= ExprDependence::UnexpandedPack;
-  return D;
-}
-
 ExprDependence
 clang::computeDependence(OverloadExpr *E, bool KnownDependent,
  bool KnownInstantiationDependent,
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -573,6 +573,9 @@
 - Stop evaluating a constant expression if the condition expression which in
   switch statement contains errors.
   (`#63453 _`)
+- Fixed false positive error diagnostic when pack expansion appears in template
+  parameters of a member expression.
+  (`#48731 `_)
 
 Bug Fixes to Compi

[PATCH] D154736: [Driver][ARM] Warn about -mabi= for assembler input with -fno-integrated-as

2023-07-10 Thread Michael Platings via Phabricator via cfe-commits
michaelplatings accepted this revision.
michaelplatings added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154736

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


[PATCH] D154290: [Clang] Implement P2741R3 - user-generated static_assert messages

2023-07-10 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added a comment.

> but right now I'm confused by the distinction… Why don't always evaluate the 
> message?

2 reasons

- it would be a rather important breaking change for compiler who don't always 
use utf-8 at their literal encoding
- we do not want to limit static_assert to the capabilities of the literal 
encoding.

That oddity (there is no denying it's odd), was discussed by the C++ committee 
and we decided this was fine.
However we did also consider supporting `char8_t*` in data, which would allow 
users to use evaluated utf-8
strings. 
We did decide against doing it right now but i suspect it will happen at some 
point.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154290

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


[PATCH] D154581: [clang][Interp] Track existing InitMaps in InterpState

2023-07-10 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added a comment.

One problem this does not fix (but rather introduce) is that the `InterpState` 
will also free initmaps of global variables which haven't been fully 
initialized. When the initialization fails midway throught, the `InterpState` 
will free the `InitMap`, leaving the global variable with a dangling pointer to 
an `InitMap`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154581

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


[PATCH] D152246: [clang][ThreadSafety] Analyze known function pointer values

2023-07-10 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added a comment.

> Maybe you can show an example how this might look like in practice?

AFAIU, the real-world case is more a C "class" struct with a couple of function 
pointers (a vtable), which might be different depending on circumstances.

So, the problem with this (type of) analysis is that we don't have a perfect 
view of the (global) program state, right? The CFG is per-function, and any 
other function (etc.) might change a function pointer. And we don't even know 
its initial value. Correct? The CFG-based anaylsis is just not enough to 
reliably diagnose this sort of problem.


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

https://reviews.llvm.org/D152246

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


[PATCH] D153536: [Clang] Implement P2169 A nice placeholder with no name

2023-07-10 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 538545.
cor3ntin added a comment.

Add more lookup tests, including designated initializers


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153536

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/Decl.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/IdentifierTable.h
  clang/include/clang/Sema/Lookup.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/Decl.cpp
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Parse/ParseTemplate.cpp
  clang/lib/Parse/Parser.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/lib/Sema/SemaLambda.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/test/Lexer/cxx-features.cpp
  clang/test/Lexer/unicode.c
  clang/test/SemaCXX/anonymous-union-export.cpp
  clang/test/SemaCXX/cxx2c-placeholder-vars.cpp
  clang/www/cxx_status.html

Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -145,7 +145,7 @@
  
   Placeholder variables with no name
   https://wg21.link/P2169R4";>P2169R4
-  No
+  Clang 17
  
 
 
Index: clang/test/SemaCXX/cxx2c-placeholder-vars.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/cxx2c-placeholder-vars.cpp
@@ -0,0 +1,258 @@
+///
+// RUN: %clang -cc1 -fsyntax-only -verify -std=c++2c -Wunused-parameter -Wunused -Wpre-c++26-compat %s
+
+void static_var() {
+static int _; // expected-note {{previous definition is here}} \
+  // expected-note {{candidate}}
+static int _; // expected-error {{redefinition of '_'}}
+int _;// expected-warning {{placeholder variables are incompatible with C++ standards before C++2c}} \
+  // expected-note {{candidate}}
+_++; // expected-error{{reference to '_' is ambiguous}}
+}
+
+void static_var_2() {
+int _; // expected-note {{previous definition is here}}
+static int _; // expected-error {{redefinition of '_'}}
+}
+
+void bindings() {
+int arr[4] = {0, 1, 2, 3};
+auto [_, _, _, _] = arr; // expected-warning 3{{placeholder variables are incompatible with C++ standards before C++2c}} \
+ // expected-note 4{{placeholder declared here}}
+_ == 42; // expected-error {{ambiguous reference to placeholder '_', which is defined multiple times}}
+{
+// no extension warning as we only introduce a single placeholder.
+auto [_, a, b, c] = arr; // expected-warning {{unused variable '[_, a, b, c]'}}
+}
+{
+auto [_, _, b, c] = arr; // expected-warning {{unused variable '[_, _, b, c]'}} \
+ // expected-warning {{placeholder variables are incompatible with C++ standards before C++2c}}
+}
+{
+// There are only 3 extension warnings because the first
+// introduction of `_` is valid in all C++ standards
+auto [_, _, _, _] = arr; // expected-warning 3{{placeholder variables are incompatible with C++ standards before C++2c}}
+}
+}
+
+namespace StaticBindings {
+
+int arr[2] = {0, 1};
+static auto [_, _] = arr; // expected-error {{redefinition of '_'}} \
+  // expected-note  {{previous definition is here}}
+
+void f() {
+int arr[2] = {0, 1};
+static auto [_, _] = arr; // expected-error {{redefinition of '_'}} \
+// expected-note  {{previous definition is here}}
+}
+
+}
+
+void lambda() {
+(void)[_ = 0, _ = 1] { // expected-warning {{placeholder variables are incompatible with C++ standards before C++2c}} \
+   // expected-note 4{{placeholder declared here}}
+(void)_++; // expected-error {{ambiguous reference to placeholder '_', which is defined multiple times}}
+};
+
+{
+int _ = 12;
+(void)[_ = 0]{}; // no warning (different scope)
+}
+}
+
+namespace global_var {
+int _; // expected-note {{previous definition is here}}
+int _; // expected-error {{redefinition of '_'}}
+}
+
+namespace {
+int _; // expected-note {{previous definition is here}}
+int _; // expected-error {{redefinition of '_'}}
+}
+
+
+namespace global_fun {
+void _();
+void _();
+
+void _() {} // expected-note {{previous definition is here}}
+void _() {} // expected-error {{redefinition of '_'}}
+void _(int){}
+}
+
+typedef int _;
+typedef int _; // Type redeclaration, nothing to do with placeholders
+
+void extern_test() {
+extern int _;
+extern int _; // expected-note {{candidate}}
+int _; //expected-note {{candidate}}
+_++; // expected-error {{reference to '_' is ambiguous}}
+}
+
+
+struct Members {
+int _; // expected-note 2{{placeholder d

[PATCH] D154822: Support '-fgpu-default-stream=per-thread' for NVIDIA CUDA

2023-07-10 Thread boxu.zhang via Phabricator via cfe-commits
boxu-zhang created this revision.
Herald added subscribers: mattd, yaxunl.
Herald added a project: All.
boxu-zhang 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/D154822

Files:
  clang/lib/CodeGen/CGCUDANV.cpp
  clang/test/CodeGenCUDA/Inputs/cuda.h
  clang/test/CodeGenCUDA/kernel-call.cu


Index: clang/test/CodeGenCUDA/kernel-call.cu
===
--- clang/test/CodeGenCUDA/kernel-call.cu
+++ clang/test/CodeGenCUDA/kernel-call.cu
@@ -2,6 +2,9 @@
 // RUN: | FileCheck %s --check-prefixes=CUDA-OLD,CHECK
 // RUN: %clang_cc1 -target-sdk-version=9.2  -emit-llvm %s -o - \
 // RUN: | FileCheck %s --check-prefixes=CUDA-NEW,CHECK
+// RUN: %clang_cc1 -target-sdk-version=9.2  -emit-llvm %s -o - \
+// RUN:   -fgpu-default-stream=per-thread\
+// RUN: | FileCheck %s --check-prefixes=CUDA-PTH,CHECK
 // RUN: %clang_cc1 -x hip -emit-llvm %s -o - \
 // RUN: | FileCheck %s --check-prefixes=HIP-OLD,CHECK
 // RUN: %clang_cc1 -fhip-new-launch-api -x hip -emit-llvm %s -o - \
@@ -25,6 +28,7 @@
 // CUDA-OLD: call{{.*}}cudaLaunch
 // CUDA-NEW: call{{.*}}__cudaPopCallConfiguration
 // CUDA-NEW: call{{.*}}cudaLaunchKernel
+// CUDA-PTH: call{{.*}}cudaLaunchKernel_ptsz
 __global__ void g1(int x) {}
 
 // CHECK-LABEL: define{{.*}}main
Index: clang/test/CodeGenCUDA/Inputs/cuda.h
===
--- clang/test/CodeGenCUDA/Inputs/cuda.h
+++ clang/test/CodeGenCUDA/Inputs/cuda.h
@@ -58,6 +58,10 @@
 extern "C" cudaError_t cudaLaunchKernel(const void *func, dim3 gridDim,
 dim3 blockDim, void **args,
 size_t sharedMem, cudaStream_t stream);
+extern "C" cudaError_t cudaLaunchKernel_ptsz(const void *func, dim3 gridDim,
+dim3 blockDim, void **args,
+size_t sharedMem, cudaStream_t stream);
+
 #endif
 
 extern "C" __device__ int printf(const char*, ...);
Index: clang/lib/CodeGen/CGCUDANV.cpp
===
--- clang/lib/CodeGen/CGCUDANV.cpp
+++ clang/lib/CodeGen/CGCUDANV.cpp
@@ -358,9 +358,13 @@
   TranslationUnitDecl *TUDecl = CGM.getContext().getTranslationUnitDecl();
   DeclContext *DC = TranslationUnitDecl::castToDeclContext(TUDecl);
   std::string KernelLaunchAPI = "LaunchKernel";
-  if (CGF.getLangOpts().HIP && CGF.getLangOpts().GPUDefaultStream ==
-   
LangOptions::GPUDefaultStreamKind::PerThread)
-KernelLaunchAPI = KernelLaunchAPI + "_spt";
+  if (CGF.getLangOpts().GPUDefaultStream ==
+  LangOptions::GPUDefaultStreamKind::PerThread) {
+if (CGF.getLangOpts().HIP)
+  KernelLaunchAPI = KernelLaunchAPI + "_spt";
+else if (CGF.getLangOpts().CUDA)
+  KernelLaunchAPI = KernelLaunchAPI + "_ptsz";
+  }
   auto LaunchKernelName = addPrefixToName(KernelLaunchAPI);
   IdentifierInfo &cudaLaunchKernelII =
   CGM.getContext().Idents.get(LaunchKernelName);


Index: clang/test/CodeGenCUDA/kernel-call.cu
===
--- clang/test/CodeGenCUDA/kernel-call.cu
+++ clang/test/CodeGenCUDA/kernel-call.cu
@@ -2,6 +2,9 @@
 // RUN: | FileCheck %s --check-prefixes=CUDA-OLD,CHECK
 // RUN: %clang_cc1 -target-sdk-version=9.2  -emit-llvm %s -o - \
 // RUN: | FileCheck %s --check-prefixes=CUDA-NEW,CHECK
+// RUN: %clang_cc1 -target-sdk-version=9.2  -emit-llvm %s -o - \
+// RUN:   -fgpu-default-stream=per-thread\
+// RUN: | FileCheck %s --check-prefixes=CUDA-PTH,CHECK
 // RUN: %clang_cc1 -x hip -emit-llvm %s -o - \
 // RUN: | FileCheck %s --check-prefixes=HIP-OLD,CHECK
 // RUN: %clang_cc1 -fhip-new-launch-api -x hip -emit-llvm %s -o - \
@@ -25,6 +28,7 @@
 // CUDA-OLD: call{{.*}}cudaLaunch
 // CUDA-NEW: call{{.*}}__cudaPopCallConfiguration
 // CUDA-NEW: call{{.*}}cudaLaunchKernel
+// CUDA-PTH: call{{.*}}cudaLaunchKernel_ptsz
 __global__ void g1(int x) {}
 
 // CHECK-LABEL: define{{.*}}main
Index: clang/test/CodeGenCUDA/Inputs/cuda.h
===
--- clang/test/CodeGenCUDA/Inputs/cuda.h
+++ clang/test/CodeGenCUDA/Inputs/cuda.h
@@ -58,6 +58,10 @@
 extern "C" cudaError_t cudaLaunchKernel(const void *func, dim3 gridDim,
 dim3 blockDim, void **args,
 size_t sharedMem, cudaStream_t stream);
+extern "C" cudaError_t cudaLaunchKernel_ptsz(const void *func, dim3 gridDim,
+dim3 blockDim, void **args,
+size_t sharedMem, cudaStream_t stream);
+
 #endif
 
 extern "C" __device__ int printf(const char*, ...);
Index: clang/lib/CodeGen/CGCUDANV.cpp
===
--- clang/lib/CodeG

[PATCH] D154423: [clang][analyzer] Add all success/failure messages to StdLibraryFunctionsChecker.

2023-07-10 Thread Donát Nagy via Phabricator via cfe-commits
donat.nagy accepted this revision.
donat.nagy added a comment.
This revision is now accepted and ready to land.

Ok, then I think you can finally merge this commit and its two predecessors. 
I'm happy to see that this improvement is complete.

I hope that you can later add a special case for the standard streams, but I 
agree that it should be a separate commit.

Thanks for clarifying the `ftell` situation, that's clearly an engine issue 
that should not block this checker improvement. However, I'd be really glad to 
see a cleanup of the interestingness system (as a separate project), because 
its inconsistency leads to lots of very confusing bug reports.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154423

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


[clang] 36a1e99 - [ARM][Driver] Partial revert of D154578

2023-07-10 Thread Michael Platings via cfe-commits

Author: Michael Platings
Date: 2023-07-10T10:10:38+01:00
New Revision: 36a1e998030d47097c4651e0b88595363a057952

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

LOG: [ARM][Driver] Partial revert of D154578

Checking that "warning:" isn't emitted is too broad.
Downstream code may emit unrelated warnings which causes the test to
fail.

Added: 


Modified: 
clang/test/Driver/arm-no-float-regs.c

Removed: 




diff  --git a/clang/test/Driver/arm-no-float-regs.c 
b/clang/test/Driver/arm-no-float-regs.c
index b46d8fc292c916..3087b7598f248f 100644
--- a/clang/test/Driver/arm-no-float-regs.c
+++ b/clang/test/Driver/arm-no-float-regs.c
@@ -19,4 +19,4 @@
 
 // CHECK: warning: '-mfloat-abi=hard': selected processor lacks floating point 
registers
 // HARDFLOAT: warning: '-mhard-float': selected processor lacks floating point 
registers
-// NOWARN-NOT: warning:
+// NOWARN-NOT: selected processor lacks floating point registers



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


[PATCH] D153776: [clang][analyzer] Display notes in StdLibraryFunctionsChecker only if interesting

2023-07-10 Thread Donát Nagy via Phabricator via cfe-commits
donat.nagy accepted this revision.
donat.nagy added a comment.
This revision is now accepted and ready to land.

LGTM, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153776

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


[PATCH] D153536: [Clang] Implement P2169 A nice placeholder with no name

2023-07-10 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 538549.
cor3ntin added a comment.

Add missing designated initializer test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153536

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/Decl.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/IdentifierTable.h
  clang/include/clang/Sema/Lookup.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/Decl.cpp
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Parse/ParseTemplate.cpp
  clang/lib/Parse/Parser.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/lib/Sema/SemaLambda.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/test/Lexer/cxx-features.cpp
  clang/test/Lexer/unicode.c
  clang/test/SemaCXX/anonymous-union-export.cpp
  clang/test/SemaCXX/cxx2c-placeholder-vars.cpp
  clang/www/cxx_status.html

Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -145,7 +145,7 @@
  
   Placeholder variables with no name
   https://wg21.link/P2169R4";>P2169R4
-  No
+  Clang 17
  
 
 
Index: clang/test/SemaCXX/cxx2c-placeholder-vars.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/cxx2c-placeholder-vars.cpp
@@ -0,0 +1,255 @@
+///
+// RUN: %clang -cc1 -fsyntax-only -verify -std=c++2c -Wunused-parameter -Wunused -Wpre-c++26-compat %s
+
+void static_var() {
+static int _; // expected-note {{previous definition is here}} \
+  // expected-note {{candidate}}
+static int _; // expected-error {{redefinition of '_'}}
+int _;// expected-warning {{placeholder variables are incompatible with C++ standards before C++2c}} \
+  // expected-note {{candidate}}
+_++; // expected-error{{reference to '_' is ambiguous}}
+}
+
+void static_var_2() {
+int _; // expected-note {{previous definition is here}}
+static int _; // expected-error {{redefinition of '_'}}
+}
+
+void bindings() {
+int arr[4] = {0, 1, 2, 3};
+auto [_, _, _, _] = arr; // expected-warning 3{{placeholder variables are incompatible with C++ standards before C++2c}} \
+ // expected-note 4{{placeholder declared here}}
+_ == 42; // expected-error {{ambiguous reference to placeholder '_', which is defined multiple times}}
+{
+// no extension warning as we only introduce a single placeholder.
+auto [_, a, b, c] = arr; // expected-warning {{unused variable '[_, a, b, c]'}}
+}
+{
+auto [_, _, b, c] = arr; // expected-warning {{unused variable '[_, _, b, c]'}} \
+ // expected-warning {{placeholder variables are incompatible with C++ standards before C++2c}}
+}
+{
+// There are only 3 extension warnings because the first
+// introduction of `_` is valid in all C++ standards
+auto [_, _, _, _] = arr; // expected-warning 3{{placeholder variables are incompatible with C++ standards before C++2c}}
+}
+}
+
+namespace StaticBindings {
+
+int arr[2] = {0, 1};
+static auto [_, _] = arr; // expected-error {{redefinition of '_'}} \
+  // expected-note  {{previous definition is here}}
+
+void f() {
+int arr[2] = {0, 1};
+static auto [_, _] = arr; // expected-error {{redefinition of '_'}} \
+// expected-note  {{previous definition is here}}
+}
+
+}
+
+void lambda() {
+(void)[_ = 0, _ = 1] { // expected-warning {{placeholder variables are incompatible with C++ standards before C++2c}} \
+   // expected-note 4{{placeholder declared here}}
+(void)_++; // expected-error {{ambiguous reference to placeholder '_', which is defined multiple times}}
+};
+
+{
+int _ = 12;
+(void)[_ = 0]{}; // no warning (different scope)
+}
+}
+
+namespace global_var {
+int _; // expected-note {{previous definition is here}}
+int _; // expected-error {{redefinition of '_'}}
+}
+
+namespace {
+int _; // expected-note {{previous definition is here}}
+int _; // expected-error {{redefinition of '_'}}
+}
+
+
+namespace global_fun {
+void _();
+void _();
+
+void _() {} // expected-note {{previous definition is here}}
+void _() {} // expected-error {{redefinition of '_'}}
+void _(int){}
+}
+
+typedef int _;
+typedef int _; // Type redeclaration, nothing to do with placeholders
+
+void extern_test() {
+extern int _;
+extern int _; // expected-note {{candidate}}
+int _; //expected-note {{candidate}}
+_++; // expected-error {{reference to '_' is ambiguous}}
+}
+
+
+struct Members {
+int _; // expected-note 2{{placeholder declared here}}
+ 

[clang-tools-extra] 7ec9e20 - [clangd][c++20]Check for correct auto location in DeducedTypeVisitor

2023-07-10 Thread Jens Massberg via cfe-commits

Author: Jens Massberg
Date: 2023-07-10T11:33:42+02:00
New Revision: 7ec9e2048024daa2fbd02a1b64f62194326abbbd

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

LOG: [clangd][c++20]Check for correct auto location in DeducedTypeVisitor

In case of a constrained auto the correct location has to chosen.

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

Added: 


Modified: 
clang-tools-extra/clangd/AST.cpp
clang-tools-extra/clangd/unittests/HoverTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/AST.cpp 
b/clang-tools-extra/clangd/AST.cpp
index 17c4dbf6dbe70d..5b81ec213ff984 100644
--- a/clang-tools-extra/clangd/AST.cpp
+++ b/clang-tools-extra/clangd/AST.cpp
@@ -482,7 +482,11 @@ class DeducedTypeVisitor : public 
RecursiveASTVisitor {
   //- auto* i = &a;
   bool VisitDeclaratorDecl(DeclaratorDecl *D) {
 if (!D->getTypeSourceInfo() ||
-D->getTypeSourceInfo()->getTypeLoc().getBeginLoc() != SearchedLocation)
+!D->getTypeSourceInfo()->getTypeLoc().getContainedAutoTypeLoc() ||
+D->getTypeSourceInfo()
+->getTypeLoc()
+.getContainedAutoTypeLoc()
+.getNameLoc() != SearchedLocation)
   return true;
 
 if (auto *AT = D->getType()->getContainedAutoType()) {

diff  --git a/clang-tools-extra/clangd/unittests/HoverTests.cpp 
b/clang-tools-extra/clangd/unittests/HoverTests.cpp
index 0f45e7851bc87e..91060a517de530 100644
--- a/clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ b/clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -477,6 +477,16 @@ class Foo final {})cpp";
  HI.Kind = index::SymbolKind::TypeAlias;
  HI.Definition = "/* not deduced */";
}},
+  // constrained auto
+  {R"cpp(
+template  concept F = true;
+F [[au^to]] x = 1;
+)cpp",
+   [](HoverInfo &HI) {
+ HI.Name = "auto";
+ HI.Kind = index::SymbolKind::TypeAlias;
+ HI.Definition = "int";
+   }},
   // auto on lambda
   {R"cpp(
 void foo() {
@@ -1314,7 +1324,7 @@ class Foo final {})cpp";
 
 Annotations T(Case.Code);
 TestTU TU = TestTU::withCode(T.code());
-TU.ExtraArgs.push_back("-std=c++17");
+TU.ExtraArgs.push_back("-std=c++20");
 // Types might be 
diff erent depending on the target triplet, we chose a
 // fixed one to make sure tests passes on 
diff erent platform.
 TU.ExtraArgs.push_back("--target=x86_64-pc-linux-gnu");



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


[PATCH] D154623: [clangd][c++20]Check for correct auto location in DeducedTypeVisitor

2023-07-10 Thread Jens Massberg via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7ec9e2048024: [clangd][c++20]Check for correct auto location 
in DeducedTypeVisitor (authored by massberg).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154623

Files:
  clang-tools-extra/clangd/AST.cpp
  clang-tools-extra/clangd/unittests/HoverTests.cpp


Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -477,6 +477,16 @@
  HI.Kind = index::SymbolKind::TypeAlias;
  HI.Definition = "/* not deduced */";
}},
+  // constrained auto
+  {R"cpp(
+template  concept F = true;
+F [[au^to]] x = 1;
+)cpp",
+   [](HoverInfo &HI) {
+ HI.Name = "auto";
+ HI.Kind = index::SymbolKind::TypeAlias;
+ HI.Definition = "int";
+   }},
   // auto on lambda
   {R"cpp(
 void foo() {
@@ -1314,7 +1324,7 @@
 
 Annotations T(Case.Code);
 TestTU TU = TestTU::withCode(T.code());
-TU.ExtraArgs.push_back("-std=c++17");
+TU.ExtraArgs.push_back("-std=c++20");
 // Types might be different depending on the target triplet, we chose a
 // fixed one to make sure tests passes on different platform.
 TU.ExtraArgs.push_back("--target=x86_64-pc-linux-gnu");
Index: clang-tools-extra/clangd/AST.cpp
===
--- clang-tools-extra/clangd/AST.cpp
+++ clang-tools-extra/clangd/AST.cpp
@@ -482,7 +482,11 @@
   //- auto* i = &a;
   bool VisitDeclaratorDecl(DeclaratorDecl *D) {
 if (!D->getTypeSourceInfo() ||
-D->getTypeSourceInfo()->getTypeLoc().getBeginLoc() != SearchedLocation)
+!D->getTypeSourceInfo()->getTypeLoc().getContainedAutoTypeLoc() ||
+D->getTypeSourceInfo()
+->getTypeLoc()
+.getContainedAutoTypeLoc()
+.getNameLoc() != SearchedLocation)
   return true;
 
 if (auto *AT = D->getType()->getContainedAutoType()) {


Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -477,6 +477,16 @@
  HI.Kind = index::SymbolKind::TypeAlias;
  HI.Definition = "/* not deduced */";
}},
+  // constrained auto
+  {R"cpp(
+template  concept F = true;
+F [[au^to]] x = 1;
+)cpp",
+   [](HoverInfo &HI) {
+ HI.Name = "auto";
+ HI.Kind = index::SymbolKind::TypeAlias;
+ HI.Definition = "int";
+   }},
   // auto on lambda
   {R"cpp(
 void foo() {
@@ -1314,7 +1324,7 @@
 
 Annotations T(Case.Code);
 TestTU TU = TestTU::withCode(T.code());
-TU.ExtraArgs.push_back("-std=c++17");
+TU.ExtraArgs.push_back("-std=c++20");
 // Types might be different depending on the target triplet, we chose a
 // fixed one to make sure tests passes on different platform.
 TU.ExtraArgs.push_back("--target=x86_64-pc-linux-gnu");
Index: clang-tools-extra/clangd/AST.cpp
===
--- clang-tools-extra/clangd/AST.cpp
+++ clang-tools-extra/clangd/AST.cpp
@@ -482,7 +482,11 @@
   //- auto* i = &a;
   bool VisitDeclaratorDecl(DeclaratorDecl *D) {
 if (!D->getTypeSourceInfo() ||
-D->getTypeSourceInfo()->getTypeLoc().getBeginLoc() != SearchedLocation)
+!D->getTypeSourceInfo()->getTypeLoc().getContainedAutoTypeLoc() ||
+D->getTypeSourceInfo()
+->getTypeLoc()
+.getContainedAutoTypeLoc()
+.getNameLoc() != SearchedLocation)
   return true;
 
 if (auto *AT = D->getType()->getContainedAutoType()) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D146242: [ARM] Fixing ABI mismatch for packed structs passed as function arguments

2023-07-10 Thread Momchil Velikov via Phabricator via cfe-commits
chill added a comment.

Following D148094  , the patch does not apply.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146242

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


[clang] a0130fc - [clang] Correct calculation of MemberExpr's dependence

2023-07-10 Thread Mariya Podchishchaeva via cfe-commits

Author: Mariya Podchishchaeva
Date: 2023-07-10T06:00:11-04:00
New Revision: a0130fc51cbc0b0bbeca378a27430eba5136f142

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

LOG: [clang] Correct calculation of MemberExpr's dependence

Due to incorrect calculation false positive diagnostics were emitted.

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

Reviewed By: shafik, cor3ntin

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

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/AST/ComputeDependence.cpp
clang/lib/AST/Expr.cpp
clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 1ae7b8377e3e4e..ae88de6a4aa7e6 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -573,6 +573,9 @@ Bug Fixes in This Version
 - Stop evaluating a constant expression if the condition expression which in
   switch statement contains errors.
   (`#63453 _`)
+- Fixed false positive error diagnostic when pack expansion appears in template
+  parameters of a member expression.
+  (`#48731 `_)
 
 Bug Fixes to Compiler Builtins
 ^^

diff  --git a/clang/lib/AST/ComputeDependence.cpp 
b/clang/lib/AST/ComputeDependence.cpp
index 829a2e750f254e..632f38f711fb1b 100644
--- a/clang/lib/AST/ComputeDependence.cpp
+++ b/clang/lib/AST/ComputeDependence.cpp
@@ -611,9 +611,24 @@ ExprDependence clang::computeDependence(OffsetOfExpr *E) {
   return D;
 }
 
+static inline ExprDependence getDependenceInExpr(DeclarationNameInfo Name) {
+  auto D = ExprDependence::None;
+  if (Name.isInstantiationDependent())
+D |= ExprDependence::Instantiation;
+  if (Name.containsUnexpandedParameterPack())
+D |= ExprDependence::UnexpandedPack;
+  return D;
+}
+
 ExprDependence clang::computeDependence(MemberExpr *E) {
-  auto *MemberDecl = E->getMemberDecl();
   auto D = E->getBase()->getDependence();
+  D |= getDependenceInExpr(E->getMemberNameInfo());
+
+  if (auto *NNS = E->getQualifier())
+D |= toExprDependence(NNS->getDependence() &
+  ~NestedNameSpecifierDependence::Dependent);
+
+  auto *MemberDecl = E->getMemberDecl();
   if (FieldDecl *FD = dyn_cast(MemberDecl)) {
 DeclContext *DC = MemberDecl->getDeclContext();
 // dyn_cast_or_null is used to handle objC variables which do not
@@ -723,15 +738,6 @@ ExprDependence 
clang::computeDependence(CXXPseudoDestructorExpr *E) {
   return D;
 }
 
-static inline ExprDependence getDependenceInExpr(DeclarationNameInfo Name) {
-  auto D = ExprDependence::None;
-  if (Name.isInstantiationDependent())
-D |= ExprDependence::Instantiation;
-  if (Name.containsUnexpandedParameterPack())
-D |= ExprDependence::UnexpandedPack;
-  return D;
-}
-
 ExprDependence
 clang::computeDependence(OverloadExpr *E, bool KnownDependent,
  bool KnownInstantiationDependent,

diff  --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index dc5f193d37f0a5..25d3535e5dac43 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -1759,16 +1759,7 @@ MemberExpr *MemberExpr::Create(
   MemberExpr *E = new (Mem) MemberExpr(Base, IsArrow, OperatorLoc, MemberDecl,
NameInfo, T, VK, OK, NOUR);
 
-  // FIXME: remove remaining dependence computation to computeDependence().
-  auto Deps = E->getDependence();
   if (HasQualOrFound) {
-// FIXME: Wrong. We should be looking at the member declaration we found.
-if (QualifierLoc && QualifierLoc.getNestedNameSpecifier()->isDependent())
-  Deps |= ExprDependence::TypeValueInstantiation;
-else if (QualifierLoc &&
- QualifierLoc.getNestedNameSpecifier()->isInstantiationDependent())
-  Deps |= ExprDependence::Instantiation;
-
 E->MemberExprBits.HasQualifierOrFoundDecl = true;
 
 MemberExprNameQualifier *NQ =
@@ -1780,13 +1771,16 @@ MemberExpr *MemberExpr::Create(
   E->MemberExprBits.HasTemplateKWAndArgsInfo =
   TemplateArgs || TemplateKWLoc.isValid();
 
+  // FIXME: remove remaining dependence computation to computeDependence().
+  auto Deps = E->getDependence();
   if (TemplateArgs) {
 auto TemplateArgDeps = TemplateArgumentDependence::None;
 E->getTrailingObjects()->initializeFrom(
 TemplateKWLoc, *TemplateArgs,
 E->getTrailingObjects(), TemplateArgDeps);
-if (TemplateArgDeps & TemplateArgumentDependence::Instantiation)
-  Deps |= ExprDependence::Instantiation;
+for (const TemplateArgumentLoc &ArgLoc : TemplateArgs->arguments()) {
+  Deps |= toExprDependence(ArgLoc.getArgument().getDependence());
+}
   } e

[PATCH] D154689: [clang] Correct calculation of MemberExpr's dependence

2023-07-10 Thread Mariya Podchishchaeva 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 rGa0130fc51cbc: [clang] Correct calculation of 
MemberExpr's dependence (authored by Fznamznon).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154689

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/AST/ComputeDependence.cpp
  clang/lib/AST/Expr.cpp
  clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp

Index: clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
===
--- clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
+++ clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
@@ -306,3 +306,22 @@
 f(A()); // OK
   }
 }
+
+namespace GH48731 {
+template  using N = int;
+struct X { template void f(); };
+template decltype((X().f>(), ...)) x;
+template decltype(((new X())->f>(), ...)) y;
+
+struct A {};
+template using Tfoo = A;
+template void foo(A a) {
+  (a.~Tfoo(), ...);
+}
+
+struct B { operator int(); };
+template using Tbar = int;
+template void bar(B b) {
+  (b.operator Tbar(), ...);
+}
+}
Index: clang/lib/AST/Expr.cpp
===
--- clang/lib/AST/Expr.cpp
+++ clang/lib/AST/Expr.cpp
@@ -1759,16 +1759,7 @@
   MemberExpr *E = new (Mem) MemberExpr(Base, IsArrow, OperatorLoc, MemberDecl,
NameInfo, T, VK, OK, NOUR);
 
-  // FIXME: remove remaining dependence computation to computeDependence().
-  auto Deps = E->getDependence();
   if (HasQualOrFound) {
-// FIXME: Wrong. We should be looking at the member declaration we found.
-if (QualifierLoc && QualifierLoc.getNestedNameSpecifier()->isDependent())
-  Deps |= ExprDependence::TypeValueInstantiation;
-else if (QualifierLoc &&
- QualifierLoc.getNestedNameSpecifier()->isInstantiationDependent())
-  Deps |= ExprDependence::Instantiation;
-
 E->MemberExprBits.HasQualifierOrFoundDecl = true;
 
 MemberExprNameQualifier *NQ =
@@ -1780,13 +1771,16 @@
   E->MemberExprBits.HasTemplateKWAndArgsInfo =
   TemplateArgs || TemplateKWLoc.isValid();
 
+  // FIXME: remove remaining dependence computation to computeDependence().
+  auto Deps = E->getDependence();
   if (TemplateArgs) {
 auto TemplateArgDeps = TemplateArgumentDependence::None;
 E->getTrailingObjects()->initializeFrom(
 TemplateKWLoc, *TemplateArgs,
 E->getTrailingObjects(), TemplateArgDeps);
-if (TemplateArgDeps & TemplateArgumentDependence::Instantiation)
-  Deps |= ExprDependence::Instantiation;
+for (const TemplateArgumentLoc &ArgLoc : TemplateArgs->arguments()) {
+  Deps |= toExprDependence(ArgLoc.getArgument().getDependence());
+}
   } else if (TemplateKWLoc.isValid()) {
 E->getTrailingObjects()->initializeFrom(
 TemplateKWLoc);
Index: clang/lib/AST/ComputeDependence.cpp
===
--- clang/lib/AST/ComputeDependence.cpp
+++ clang/lib/AST/ComputeDependence.cpp
@@ -611,9 +611,24 @@
   return D;
 }
 
+static inline ExprDependence getDependenceInExpr(DeclarationNameInfo Name) {
+  auto D = ExprDependence::None;
+  if (Name.isInstantiationDependent())
+D |= ExprDependence::Instantiation;
+  if (Name.containsUnexpandedParameterPack())
+D |= ExprDependence::UnexpandedPack;
+  return D;
+}
+
 ExprDependence clang::computeDependence(MemberExpr *E) {
-  auto *MemberDecl = E->getMemberDecl();
   auto D = E->getBase()->getDependence();
+  D |= getDependenceInExpr(E->getMemberNameInfo());
+
+  if (auto *NNS = E->getQualifier())
+D |= toExprDependence(NNS->getDependence() &
+  ~NestedNameSpecifierDependence::Dependent);
+
+  auto *MemberDecl = E->getMemberDecl();
   if (FieldDecl *FD = dyn_cast(MemberDecl)) {
 DeclContext *DC = MemberDecl->getDeclContext();
 // dyn_cast_or_null is used to handle objC variables which do not
@@ -723,15 +738,6 @@
   return D;
 }
 
-static inline ExprDependence getDependenceInExpr(DeclarationNameInfo Name) {
-  auto D = ExprDependence::None;
-  if (Name.isInstantiationDependent())
-D |= ExprDependence::Instantiation;
-  if (Name.containsUnexpandedParameterPack())
-D |= ExprDependence::UnexpandedPack;
-  return D;
-}
-
 ExprDependence
 clang::computeDependence(OverloadExpr *E, bool KnownDependent,
  bool KnownInstantiationDependent,
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -573,6 +573,9 @@
 - Stop evaluating a constant expression if the condition expression which in
   switch statement contains errors.
   (`#63453 _`)
+- Fixed false positive error diagnostic when pack expansion appears in template

[PATCH] D154591: [OpenMP][OMPIRBuilder] Rename IsEmbedded and IsTargetCodegen flags

2023-07-10 Thread Sergio Afonso via Phabricator via cfe-commits
skatrak updated this revision to Diff 538564.
skatrak added a comment.

Rebase.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154591

Files:
  clang/docs/OffloadingDesign.rst
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/OpenMPClause.cpp
  clang/lib/Basic/Targets/NVPTX.cpp
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.h
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.h
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/CodeGen/CGVTables.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/Targets/NVPTX.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/Flang.cpp
  clang/lib/Frontend/CompilerInstance.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/lib/Lex/LiteralSupport.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/CodeGen/PowerPC/ppc64le-varargs-f128.c
  clang/test/CodeGen/ibm128-unsupported.c
  clang/test/Driver/openmp-offload-gpu.c
  clang/test/Driver/openmp-offload.c
  clang/test/Headers/__clang_hip_libdevice_declares.cpp
  clang/test/Headers/amdgcn-openmp-device-math-complex.c
  clang/test/Headers/amdgcn-openmp-device-math-complex.cpp
  clang/test/Headers/amdgcn_openmp_device_math.c
  clang/test/Headers/amdgcn_openmp_device_math_c.c
  clang/test/Headers/amdgcn_openmp_device_math_constexpr.cpp
  clang/test/Headers/nvptx_device_cmath_functions.c
  clang/test/Headers/nvptx_device_cmath_functions.cpp
  clang/test/Headers/nvptx_device_cmath_functions_cxx17.cpp
  clang/test/Headers/nvptx_device_math_complex.c
  clang/test/Headers/nvptx_device_math_complex.cpp
  clang/test/Headers/nvptx_device_math_functions.c
  clang/test/Headers/nvptx_device_math_functions.cpp
  clang/test/Headers/nvptx_device_math_functions_cxx17.cpp
  clang/test/Headers/nvptx_device_math_macro.cpp
  clang/test/Headers/nvptx_device_math_modf.cpp
  clang/test/Headers/nvptx_device_math_sin.c
  clang/test/Headers/nvptx_device_math_sin.cpp
  clang/test/Headers/nvptx_device_math_sin_cos.cpp
  clang/test/Headers/nvptx_device_math_sincos.cpp
  clang/test/Headers/openmp-device-functions-bool.c
  clang/test/Headers/openmp_device_math_isnan.cpp
  clang/test/Headers/openmp_new_nothrow.cpp
  clang/test/Headers/target_include_new.cpp
  clang/test/OpenMP/amdgcn-attributes.cpp
  clang/test/OpenMP/amdgcn_device_function_call.cpp
  clang/test/OpenMP/amdgcn_ldbl_check.cpp
  clang/test/OpenMP/amdgcn_target_codegen.cpp
  clang/test/OpenMP/amdgcn_target_device_vla.cpp
  clang/test/OpenMP/amdgcn_target_global_constructor.cpp
  clang/test/OpenMP/amdgcn_target_init_temp_alloca.cpp
  clang/test/OpenMP/amdgpu_target_with_aligned_attribute.c
  clang/test/OpenMP/assumes_include_nvptx.cpp
  clang/test/OpenMP/aux-triple-macros.cpp
  clang/test/OpenMP/declare_target_codegen.cpp
  clang/test/OpenMP/declare_target_codegen_globalization.cpp
  clang/test/OpenMP/declare_target_constexpr_codegen.cpp
  clang/test/OpenMP/declare_target_link_codegen.cpp
  clang/test/OpenMP/declare_target_messages.cpp
  clang/test/OpenMP/declare_target_only_one_side_compilation.cpp
  clang/test/OpenMP/declare_variant_device_kind_codegen.cpp
  clang/test/OpenMP/declare_variant_mixed_codegen.c
  clang/test/OpenMP/distribute_codegen.cpp
  clang/test/OpenMP/distribute_simd_codegen.cpp
  clang/test/OpenMP/metadirective_device_arch_codegen.cpp
  clang/test/OpenMP/metadirective_device_isa_codegen_amdgcn.cpp
  clang/test/OpenMP/multiple_regions_per_line.cpp
  clang/test/OpenMP/nvptx_NRVO_variable.cpp
  clang/test/OpenMP/nvptx_SPMD_codegen.cpp
  clang/test/OpenMP/nvptx_allocate_codegen.cpp
  clang/test/OpenMP/nvptx_allocate_messages.cpp
  clang/test/OpenMP/nvptx_asm_delayed_diags.c
  clang/test/OpenMP/nvptx_data_sharing.cpp
  clang/test/OpenMP/nvptx_declare_target_var_ctor_dtor_codegen.cpp
  clang/test/OpenMP/nvptx_declare_variant_device_kind_codegen.cpp
  clang/test/OpenMP/nvptx_declare_variant_implementation_vendor_codegen.cpp
  clang/test/OpenMP/nvptx_declare_variant_name_mangling.cpp
  clang/test/OpenMP/nvptx_distribute_parallel_generic_mode_codegen.cpp
  clang/test/OpenMP/nvptx_lambda_capturing.cpp
  clang/test/OpenMP/nvptx_multi_target_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_nested_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_parallel_for_codegen.cpp
  clang/test/OpenMP/nvptx_param_translate.c
  clang/test/OpenMP/nvptx_prohibit_thread_local.cpp
  clang/test/OpenMP/nvptx_target_codegen.cpp
  clang/test/OpenMP/nvptx_target_cuda_mode_m

[PATCH] D154827: [analyzer] NonParamVarRegion should prefer definition over canonical decl

2023-07-10 Thread Balázs Benics via Phabricator via cfe-commits
steakhal created this revision.
steakhal added reviewers: xazax.hun, donat.nagy, NoQ.
Herald added subscribers: manas, ASDenysPetrov, martong, dkrupp, Szelethus, 
mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware.
Herald added a reviewer: Szelethus.
Herald added a project: All.
steakhal requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

When we construct a `NonParamVarRegion`, we canonicalize the decl to
always use the same entity for consistency.
At the moment that is the canonical decl - which is the first decl in
the redecl chain.

However, this can cause problems with tentative declarations and extern
declarations if we declare an array with unknown bounds.

Consider this C example :

  typedef typeof(sizeof(int)) size_t;
  size_t clang_analyzer_getExtent(const void *p);
  void clang_analyzer_dump(size_t n);
  
  extern const unsigned char extern_redecl[];
  const unsigned char extern_redecl[] = { 1,2,3,4 };
  const unsigned char tentative_redecl[];
  const unsigned char tentative_redecl[] = { 1,2,3,4 };
  
  const unsigned char direct_decl[] = { 1,2,3,4 };
  
  void test_redeclaration_extent(void) {
clang_analyzer_dump(clang_analyzer_getExtent(direct_decl));  // 4
clang_analyzer_dump(clang_analyzer_getExtent(extern_redecl));// should 
be 4 instead of Unknown
clang_analyzer_dump(clang_analyzer_getExtent(tentative_redecl)); // should 
be 4 instead of Unknown
  }

The `getType()` of the canonical decls for the forward declared globals,
will return `IncompleteArrayType`, unlike the
`getDefinition()->getType()`, which would have returned
`ConstantArrayType` of 4 elements.

This makes the `MemRegionManager::getStaticSize()` return `Unknown` as
the extent for the array variables, leading to FNs.

To resolve this, I think we should prefer the definition decl (if
present) over the canonical decl when constructing `NonParamVarRegion`s.

FYI The canonicalization of the decl was introduced by D57619 
 in 2019.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D154827

Files:
  clang/lib/StaticAnalyzer/Core/MemRegion.cpp
  clang/test/Analysis/globals.c


Index: clang/test/Analysis/globals.c
===
--- /dev/null
+++ clang/test/Analysis/globals.c
@@ -0,0 +1,18 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -verify 
%s
+
+typedef typeof(sizeof(int)) size_t;
+size_t clang_analyzer_getExtent(const void *p);
+void clang_analyzer_dump(size_t n);
+
+extern const unsigned char extern_redecl[];
+const unsigned char extern_redecl[] = { 1,2,3,4 };
+const unsigned char tentative_redecl[];
+const unsigned char tentative_redecl[] = { 1,2,3,4 };
+
+const unsigned char direct_decl[] = { 1,2,3,4 };
+
+void test_redeclaration_extent(void) {
+  clang_analyzer_dump(clang_analyzer_getExtent(direct_decl));  // 
expected-warning {{4 S64b}}
+  clang_analyzer_dump(clang_analyzer_getExtent(extern_redecl));// 
expected-warning {{4 S64b}}
+  clang_analyzer_dump(clang_analyzer_getExtent(tentative_redecl)); // 
expected-warning {{4 S64b}}
+}
Index: clang/lib/StaticAnalyzer/Core/MemRegion.cpp
===
--- clang/lib/StaticAnalyzer/Core/MemRegion.cpp
+++ clang/lib/StaticAnalyzer/Core/MemRegion.cpp
@@ -1077,13 +1077,16 @@
 }
   }
 
-  return getSubRegion(D, sReg);
+  return getNonParamVarRegion(D, sReg);
 }
 
 const NonParamVarRegion *
 MemRegionManager::getNonParamVarRegion(const VarDecl *D,
const MemRegion *superR) {
+  // Prefer the definition over the canonical decl as the canonical form.
   D = D->getCanonicalDecl();
+  if (const VarDecl *Def = D->getDefinition())
+D = Def;
   return getSubRegion(D, superR);
 }
 


Index: clang/test/Analysis/globals.c
===
--- /dev/null
+++ clang/test/Analysis/globals.c
@@ -0,0 +1,18 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -verify %s
+
+typedef typeof(sizeof(int)) size_t;
+size_t clang_analyzer_getExtent(const void *p);
+void clang_analyzer_dump(size_t n);
+
+extern const unsigned char extern_redecl[];
+const unsigned char extern_redecl[] = { 1,2,3,4 };
+const unsigned char tentative_redecl[];
+const unsigned char tentative_redecl[] = { 1,2,3,4 };
+
+const unsigned char direct_decl[] = { 1,2,3,4 };
+
+void test_redeclaration_extent(void) {
+  clang_analyzer_dump(clang_analyzer_getExtent(direct_decl));  // expected-warning {{4 S64b}}
+  clang_analyzer_dump(clang_analyzer_getExtent(extern_redecl));// expected-warning {{4 S64b}}
+  clang_analyzer_dump(clang_analyzer_getExtent(tentative_redecl)); // expected-warning {{4 S64b}}
+}
Index: clang/lib/StaticAnalyzer/Core/MemRegion.cpp
===
---

[PATCH] D154827: [analyzer] NonParamVarRegion should prefer definition over canonical decl

2023-07-10 Thread Tomasz Kamiński via Phabricator via cfe-commits
tomasz-kaminski-sonarsource accepted this revision.
tomasz-kaminski-sonarsource added a comment.
This revision is now accepted and ready to land.

Looks good. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154827

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


[PATCH] D153725: [clang] Make amdgpu-arch tool work on Windows

2023-07-10 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a comment.

The right thing to do on Linux for this is to query the driver directly. That 
is, the kernel should populate some string under /sys that we read. That isn't 
yet implemented. Does windows happen to have that functionality available?

(landed here while trying to work out why tests aren't running because we now 
print errors about failing to load libamdhip64.so when hsa fails)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153725

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


[PATCH] D153725: [clang] Make amdgpu-arch tool work on Windows

2023-07-10 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added inline comments.



Comment at: clang/tools/amdgpu-arch/AMDGPUArch.cpp:50
+#else
+  return printGPUsByHSA();
+#endif

yaxunl wrote:
> jhuber6 wrote:
> > arsenm wrote:
> > > The HIP path should work on linux too. I generally think we should build 
> > > as much code as possible on all hosts, so how about
> > > ```
> > > #ifndef _WIN32
> > >   if (tryHSA())
> > > return 0;
> > > #endif
> > > 
> > > tryHIP()
> > > ```
> > > 
> > > 
> > > 
> > That'd be fine, I'm in favor of sticking to HSA since it's a smaller 
> > runtime that's more reasonable to build standalone without the whole ROCm 
> > stack.
> done
I can't think of a case on linux where HIP would work and HSA would not, given 
that HIP calls into HSA to do the same query. So I think this fallback path 
only contributes to line noise when HSA doesn't load, 

```
./bin/amdgpu-arch 
Failed to 'dlopen' libhsa-runtime64.so
Failed to load libamdhip64.so: libamdhip64.so: cannot open shared object file: 
No such file or directory
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153725

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


[PATCH] D153725: [clang] Make amdgpu-arch tool work on Windows

2023-07-10 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.

In D153725#4484711 , @JonChesterfield 
wrote:

> The right thing to do on Linux for this is to query the driver directly. That 
> is, the kernel should populate some string under /sys that we read. That 
> isn't yet implemented.

It should definitely not do that. That's what this redundant thing does 

 . The kernel doesn't know the names of these devices. The kernel knows 
different names that map to PCI ids that are not the same as the gfx numbers. 
The compiler should not be responsible for maintaining yet another name mapping 
table and should go through a real API

> Does windows happen to have that functionality available?

This sounds very un-windows like. I assume the equivalent is digging around in 
the registry


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153725

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


[PATCH] D153725: [clang] Make amdgpu-arch tool work on Windows

2023-07-10 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added inline comments.



Comment at: clang/tools/amdgpu-arch/AMDGPUArchByHIP.cpp:80
+if (err != hipSuccess) {
+  llvm::errs() << "Failed to get device id for ordinal " << i << "\n";
+  return 1;

yaxunl wrote:
> arsenm wrote:
> > single quotes around '\n'
> will do
Should print some kind of stringified error codes for all of these


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153725

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


[PATCH] D153725: [clang] Make amdgpu-arch tool work on Windows

2023-07-10 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a comment.

In D153725#4484747 , @arsenm wrote:

> In D153725#4484711 , 
> @JonChesterfield wrote:
>
>> The right thing to do on Linux for this is to query the driver directly. 
>> That is, the kernel should populate some string under /sys that we read. 
>> That isn't yet implemented.
>
> It should definitely not do that. That's what this redundant thing does 
> 
>  . The kernel doesn't know the names of these devices. The kernel knows 
> different names that map to PCI ids that are not the same as the gfx numbers. 
> The compiler should not be responsible for maintaining yet another name 
> mapping table and should go through a real API

There's a lot of pcie to gfx906 style tables lying around already. There used 
to be one in roct, last time I looked people wanted to move that to somewhere 
else. I don't really want to copy/paste it.

The problem with using the proper API via HSA or similar is twofold:

- we use this tool to enable tests, which means HSA has to exist before 
building clang or the tests don't run and HSA now requires clang to build
- if you open the driver too many times at once it fails to open, so running a 
parallel build that uses this tool doesn't work on fast machines


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153725

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


[PATCH] D154290: [Clang] Implement P2741R3 - user-generated static_assert messages

2023-07-10 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 538579.
cor3ntin marked 3 inline comments as done.
cor3ntin added a comment.

Address Sergei's feedback

- Add more tests
- Support non const member functions
- Make sure diagnostics messages are never produced twice
- Support returning intermediate objects from data()/size()


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154290

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/AST/Expr.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/DeclCXX.cpp
  clang/lib/AST/DeclPrinter.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/AST/ODRDiagsEmitter.cpp
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/test/Lexer/cxx-features.cpp
  clang/test/SemaCXX/static-assert-cxx26.cpp
  clang/tools/libclang/CIndex.cpp
  clang/www/cxx_status.html

Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -145,7 +145,7 @@
  
   User-generated static_assert messages
   https://wg21.link/P2741R3";>P2741R3
-  No
+  Clang 17
  
  
   Placeholder variables with no name
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -1294,7 +1294,7 @@
 bool CursorVisitor::VisitStaticAssertDecl(StaticAssertDecl *D) {
   if (Visit(MakeCXCursor(D->getAssertExpr(), StmtParent, TU, RegionOfInterest)))
 return true;
-  if (StringLiteral *Message = D->getMessage())
+  if (auto *Message = dyn_cast(D->getMessage()))
 if (Visit(MakeCXCursor(Message, StmtParent, TU, RegionOfInterest)))
   return true;
   return false;
Index: clang/test/SemaCXX/static-assert-cxx26.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/static-assert-cxx26.cpp
@@ -0,0 +1,194 @@
+// RUN: %clang_cc1 -std=c++2c -fsyntax-only %s -verify
+
+static_assert(true, "");
+static_assert(true, 0); // expected-error {{the message in a static_assert declaration must be a string literal or an object with data() and size() member functions}}
+struct Empty{};
+static_assert(true, Empty{}); // expected-error {{the message in a static_assert declaration must be a string literal or an object with data() and size() member functions}}
+struct NoData {
+unsigned long size() const;
+};
+struct NoSize {
+const char* data() const;
+};
+static_assert(true, NoData{}); // expected-error {{the message in a static_assert declaration must be a string literal or an object with data() and size() member functions}}
+static_assert(true, NoSize{}); // expected-error {{the message in a static_assert declaration must be a string literal or an object with data() and size() member functions}}
+
+struct InvalidSize {
+const char* size() const;
+const char* data() const;
+};
+static_assert(true, InvalidSize{}); // expected-error {{the message in a static_assert declaration must have a size() member function returning an object convertible to std::size_t}} \
+// expected-error {{value of type 'const char *' is not implicitly convertible to 'unsigned long'}}
+struct InvalidData {
+unsigned long size() const;
+unsigned long data() const;
+};
+static_assert(true, InvalidData{}); // expected-error {{the message in a static_assert declaration must have a data() member function returning an object convertible to const char*}} \
+// expected-error {{value of type 'unsigned long' is not implicitly convertible to 'const char *'}}
+
+struct NonConstexprSize {
+unsigned long size() const; // expected-note {{declared here}}
+constexpr const char* data() const;
+};
+
+static_assert(true, NonConstexprSize{});
+static_assert(false, NonConstexprSize{}); // expected-error {{the message in a static_assert declaration must be produced by constant expression}} \
+  // expected-error {{static assertion failed}} \
+  // expected-note  {{non-constexpr function 'size' cannot be used in a constant expression}}
+
+struct NonConstexprData {
+constexpr unsigned long size() const {
+return 32;
+}
+const char* data() const;  // expected-note {{declared here}}
+};
+
+static_assert(true, NonConstexprData{});
+static_assert(false, NonConstexprData{}); // expected-error {{the message in a static_assert declaration must be produced by constant expression}} \
+  // expected-error {{static assertion failed}} \
+   

[PATCH] D154833: [clang][dataflow] Add `AnalysisInputs::withSolverFactory()`.

2023-07-10 Thread Martin Böhme via Phabricator via cfe-commits
mboehme created this revision.
Herald added subscribers: martong, xazax.hun.
Herald added a project: All.
mboehme 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/D154833

Files:
  clang/unittests/Analysis/FlowSensitive/TestingSupport.h


Index: clang/unittests/Analysis/FlowSensitive/TestingSupport.h
===
--- clang/unittests/Analysis/FlowSensitive/TestingSupport.h
+++ clang/unittests/Analysis/FlowSensitive/TestingSupport.h
@@ -143,6 +143,12 @@
 BuiltinOptions = std::move(Options);
 return std::move(*this);
   }
+  AnalysisInputs &&
+  withSolverFactory(std::function()> Factory) && {
+assert(Factory);
+SolverFactory = std::move(Factory);
+return std::move(*this);
+  }
 
   /// Required. Input code that is analyzed.
   llvm::StringRef Code;
@@ -170,6 +176,10 @@
   tooling::FileContentMappings ASTBuildVirtualMappedFiles = {};
   /// Configuration options for the built-in model.
   DataflowAnalysisContext::Options BuiltinOptions;
+  /// SAT solver factory.
+  std::function()> SolverFactory = [] {
+return std::make_unique();
+  };
 };
 
 /// Returns assertions based on annotations that are present after statements 
in
@@ -248,7 +258,7 @@
 auto &CFCtx = *MaybeCFCtx;
 
 // Initialize states for running dataflow analysis.
-DataflowAnalysisContext DACtx(std::make_unique(),
+DataflowAnalysisContext DACtx(AI.SolverFactory(),
   {/*Opts=*/AI.BuiltinOptions});
 Environment InitEnv(DACtx, *Target);
 auto Analysis = AI.MakeAnalysis(Context, InitEnv);


Index: clang/unittests/Analysis/FlowSensitive/TestingSupport.h
===
--- clang/unittests/Analysis/FlowSensitive/TestingSupport.h
+++ clang/unittests/Analysis/FlowSensitive/TestingSupport.h
@@ -143,6 +143,12 @@
 BuiltinOptions = std::move(Options);
 return std::move(*this);
   }
+  AnalysisInputs &&
+  withSolverFactory(std::function()> Factory) && {
+assert(Factory);
+SolverFactory = std::move(Factory);
+return std::move(*this);
+  }
 
   /// Required. Input code that is analyzed.
   llvm::StringRef Code;
@@ -170,6 +176,10 @@
   tooling::FileContentMappings ASTBuildVirtualMappedFiles = {};
   /// Configuration options for the built-in model.
   DataflowAnalysisContext::Options BuiltinOptions;
+  /// SAT solver factory.
+  std::function()> SolverFactory = [] {
+return std::make_unique();
+  };
 };
 
 /// Returns assertions based on annotations that are present after statements in
@@ -248,7 +258,7 @@
 auto &CFCtx = *MaybeCFCtx;
 
 // Initialize states for running dataflow analysis.
-DataflowAnalysisContext DACtx(std::make_unique(),
+DataflowAnalysisContext DACtx(AI.SolverFactory(),
   {/*Opts=*/AI.BuiltinOptions});
 Environment InitEnv(DACtx, *Target);
 auto Analysis = AI.MakeAnalysis(Context, InitEnv);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D154834: [clang][dataflow][NFC] Expand a comment.

2023-07-10 Thread Martin Böhme via Phabricator via cfe-commits
mboehme created this revision.
Herald added subscribers: martong, xazax.hun.
Herald added a reviewer: NoQ.
Herald added a project: All.
mboehme 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/D154834

Files:
  clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp


Index: clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
===
--- clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
+++ clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
@@ -123,6 +123,9 @@
   // returns false to avoid storing unneeded values in `DACtx`.
   // FIXME: Creating the value based on the type alone creates misshapen values
   // for lvalues, since the type does not reflect the need for 
`ReferenceValue`.
+  // This issue will be resolved when `ReferenceValue` is eliminated as part
+  // of the ongoing migration to strict handling of value categories (see
+  // https://discourse.llvm.org/t/70086 for details).
   if (Value *MergedVal = MergedEnv.createValue(Type))
 if (Model.merge(Type, Val1, Env1, Val2, Env2, *MergedVal, MergedEnv))
   return MergedVal;


Index: clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
===
--- clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
+++ clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
@@ -123,6 +123,9 @@
   // returns false to avoid storing unneeded values in `DACtx`.
   // FIXME: Creating the value based on the type alone creates misshapen values
   // for lvalues, since the type does not reflect the need for `ReferenceValue`.
+  // This issue will be resolved when `ReferenceValue` is eliminated as part
+  // of the ongoing migration to strict handling of value categories (see
+  // https://discourse.llvm.org/t/70086 for details).
   if (Value *MergedVal = MergedEnv.createValue(Type))
 if (Model.merge(Type, Val1, Env1, Val2, Env2, *MergedVal, MergedEnv))
   return MergedVal;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D152495: [Clang][SemaCXX] Add unused warning for variables declared in condition expressions

2023-07-10 Thread Takuya Shimizu via Phabricator via cfe-commits
hazohelet added a comment.

In D152495#4481588 , @aaron.ballman 
wrote:

> This is a bit of an odd situation -- the condition variable *is* used (e.g., 
> its value is loaded to determine whether to go into the if branch or the else 
> branch), so we should not be marking it as unused in 
> `Sema::CheckConditionVariable()`. Instead, I think we need to decide what 
> constitutes "unused" in this case. Consider:
>
>   struct RAII {
> int &x;
>   
> RAII(int &ref) : x(ref) {}
> ~RAII() { x = 0; }
>   
> operator bool() const { return true; }
>   };
>   
>   void func() {
> int i = 12;
> if (RAII name{i}) {
> }
>   }
>
> I don't think `name` is unused in the same way that `i` is unused in `if (int 
> i = 1) {}`. So I think we only want this to apply to scalars and not class 
> types. I think the changes should be happening in 
> `Sema::ShouldDiagnoseUnusedDecl()`  (and you might need to thread the `Scope` 
> object through to that call -- my naive thinking is that a variable 
> declaration in a condition scope should be diagnosed as unused if it is used 
> but not referenced, but I could be off-base).

Thank you for the insightful feedback!
I agree that we should not be emitting Wunused warnings in condition 
expressions when the declaration is of class type.

About the `Scope` object, if you mean `ConditionVarScope` flag by "condition 
scope", it seems to be used only for the condition of for-statements. 
(https://github.com/llvm/llvm-project/blob/f36b0169b8821e431644cb240f081538eb2b55ef/clang/lib/Parse/ParseExprCXX.cpp#L2045-L2057)
 Also it does not push new scope but modifies the flag of the current scope.
So it does not seem to be usable for our purpose here.

Instead, I think used-but-not-referenced variable declarations can be diagnosed 
as unused regardless of whether they are declared in condition expressions. 
This saves us from deleting the assertion from CodeGen and modifying AST tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152495

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


[PATCH] D152495: [Clang][SemaCXX] Add unused warning for variables declared in condition expressions

2023-07-10 Thread Takuya Shimizu via Phabricator via cfe-commits
hazohelet updated this revision to Diff 538591.
hazohelet marked 5 inline comments as done.
hazohelet added a comment.

- Stop marking condition variable declarations as unused and diagnose all 
`VarDecl` that is marked used but not referenced
- Added test not to warn when the declaration is not aggregate type
- NFC changes (comments, typo)


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

https://reviews.llvm.org/D152495

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/test/SemaCXX/warn-unused-variables.cpp

Index: clang/test/SemaCXX/warn-unused-variables.cpp
===
--- clang/test/SemaCXX/warn-unused-variables.cpp
+++ clang/test/SemaCXX/warn-unused-variables.cpp
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -fsyntax-only -Wunused-variable -Wunused-label -Wno-c++1y-extensions -verify %s
-// RUN: %clang_cc1 -fsyntax-only -Wunused-variable -Wunused-label -Wno-c++1y-extensions -verify -std=c++11 %s
+// RUN: %clang_cc1 -fsyntax-only -Wunused-variable -Wunused-label -Wno-c++1y-extensions -Wno-c++1z-extensions -verify -std=c++11 %s
 template void f() {
   T t;
   t = 17;
@@ -294,3 +294,49 @@
 }
 
 } // namespace gh54489
+
+namespace inside_condition {
+  void ifs() {
+if (int hoge = 0) // expected-warning {{unused variable 'hoge'}}
+  return;
+if (const int const_hoge = 0) // expected-warning {{unused variable 'const_hoge'}}
+  return;
+else if (int fuga = 0)
+  (void)fuga;
+else if (int used = 1; int catched = used) // expected-warning {{unused variable 'catched'}}
+  return;
+else if (int refed = 1; int used = refed)
+  (void)used;
+else if (int unused1 = 2; int unused2 = 3) // expected-warning {{unused variable 'unused1'}} \
+   // expected-warning {{unused variable 'unused2'}}
+  return;
+else if (int unused = 4; int used = 5) // expected-warning {{unused variable 'unused'}}
+  (void)used;
+else if (int used = 6; int unused = 7) // expected-warning {{unused variable 'unused'}}
+  (void)used;
+else if (int used1 = 8; int used2 = 9)
+  (void)(used1 + used2);
+  }
+
+  void fors() {
+for (int i = 0;int unused = 0;); // expected-warning {{unused variable 'i'}} \
+ // expected-warning {{unused variable 'unused'}}
+for (int i = 0;int used = 0;) // expected-warning {{unused variable 'i'}}
+  (void)used;
+  while(int var = 1) // expected-warning {{unused variable 'var'}}
+return;
+  }
+
+  struct RAII {
+int &x;
+RAII(int &ref) : x(ref) {}
+~RAII() { x = 0;}
+operator bool() const { return true; }
+  };
+  void aggregate() {
+int x = 10;
+if (RAII var = x) {}
+  }
+
+
+} // namespace inside_condition
Index: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -5345,7 +5345,7 @@
   // will have been deferred.
   if (!NewVar->isInvalidDecl() &&
   NewVar->getDeclContext()->isFunctionOrMethod() &&
-  OldVar->getType()->isDependentType())
+  OldVar->getType()->isDependentType() && !OldVar->isImplicit())
 DiagnoseUnusedDecl(NewVar);
 }
 
Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -4013,6 +4013,11 @@
   ConditionVar, ConditionVar->getType().getNonReferenceType(), VK_LValue,
   ConditionVar->getLocation());
 
+  // Ensure that `-Wunused-variable` will be emitted for condition variables
+  // that are not referenced later. e.g.: if (int var = init());
+  if (!T->isAggregateType())
+ConditionVar->setReferenced(/*R=*/false);
+
   switch (CK) {
   case ConditionKind::Boolean:
 return CheckBooleanCondition(StmtLoc, Condition.get());
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -1989,7 +1989,7 @@
 return false;
   } else if (!D->getDeclName()) {
 return false;
-  } else if (D->isReferenced() || D->isUsed()) {
+  } else if (D->isReferenced() || (!isa(D) && D->isUsed())) {
 return false;
   }
 
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -381,6 +381,9 @@
   (`#57081: `_)
 - Clang no longer emits inappropriate notes about the loss of ``__unaligned`` qualifier
   on overload resolution, when the actual reason for the failure is loss of other qualifiers.
+- Clang now warns on unused variables of non-aggregate types declar

[PATCH] D153738: Add LibClang guide

2023-07-10 Thread Manuel via Phabricator via cfe-commits
manuel5975p added a comment.

I guess manuel5975p (manuel.wink...@gmx.ch) would be nice


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153738

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


[PATCH] D154833: [clang][dataflow] Add `AnalysisInputs::withSolverFactory()`.

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



Comment at: clang/unittests/Analysis/FlowSensitive/TestingSupport.h:180
+  /// SAT solver factory.
+  std::function()> SolverFactory = [] {
+return std::make_unique();

(lambdas in headers make me slightly leery, this looks fine though)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154833

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


[PATCH] D154833: [clang][dataflow] Add `AnalysisInputs::withSolverFactory()`.

2023-07-10 Thread Martin Böhme via Phabricator via cfe-commits
mboehme added a comment.

libcxx failure looks unrelated


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154833

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


[PATCH] D154591: [OpenMP][OMPIRBuilder] Rename IsEmbedded and IsTargetCodegen flags

2023-07-10 Thread Sergio Afonso via Phabricator via cfe-commits
skatrak added a comment.

This patch has been triggering a seemingly unrelated build error in libcxx, 
even after multiple rebases. Can I land it as-is or is this error something I 
should address first? Thank you.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154591

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


[PATCH] D154591: [OpenMP][OMPIRBuilder] Rename IsEmbedded and IsTargetCodegen flags

2023-07-10 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added a comment.

Yeah that happens sometimes, if it's working on your system it's safe to assume 
it's fine. Worst case scenario you can always revert, it's not a big deal.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154591

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


[PATCH] D152554: [OpenMP] Migrate device code privatisation from Clang CodeGen to OMPIRBuilder

2023-07-10 Thread Akash Banerjee via Phabricator via cfe-commits
TIFitis added a comment.

Ping for review :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152554

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


[PATCH] D154838: [analyzer] Add check for null pointer passed to %p of printf family

2023-07-10 Thread Georgiy Lebedev via Phabricator via cfe-commits
CuriousGeorgiy added a comment.

Hi! This is my first time contributing to the LLVM project and particularly the 
clang static analyzer. This patch is based off 
https://reviews.llvm.org/D139604?id=481154. I have several questions regarding 
the reviewers comments (most of which I tried to address) and the patch itself:

> 4. One should be able to disable your rule in case something goes wild. So, 
> your checker should be registered at the end of the file by applying the 
> REGISTER_CHECKER() macro.

This check is part of the UnixAPIPortability checker, which is already 
registered. Do you suggest creating a separate checker for this check?

> 5. One should update the documentation and also mention the new check in the 
> release docs to give visibility.

The current documentation for the UnixAPIPortability checker is quite generic 
(docs/analyazer/checkers.rst) and doesn’t mention specific checks. Should I 
mention this new check there?

> 1. Add tests demonstrating all possible aspects of your change.

I added a number of tests for various aspects of the new check, but I’m not 
sure they are sufficient and I’m not sure what needs to be covered. For 
instance, should I add test that the warning is not issued for functions not 
located in the global namespace? Should I add a test case for `nullptr`?

A couple of questions regarding the patch itself:

1. Should I cover non-standard (i.e., non ISO C standard) functions from the 
`printf_s` family? Should I cover non-standard functions like `dprintf`?
2. What is the right way to emit a bug report? I have studied the code base and 
found several patterns: in some cases, an error node is simply generated, in 
others a new transition is also added based on the analyzed state. In some 
cases an expression value is also tracked.
3. Should I try to report all possible bugs, or only report the first one found?
4. What is the correct way to update expected plists for test inputs? I tried 
to simply replace the existing one (unix-fns.c.plist) with the output I get 
from executing the first command of unix-fns.c test, but I still get the 
following error:


  console
  georgiy.lebedev@georgiy-lebedev llvm-project % build-debug/bin/llvm-lit -sv 
clang/test/Analysis/unix-fns.c
  llvm-lit: 
/Users/georgiy.lebedev/Work/llvm-project/llvm/utils/lit/lit/llvm/config.py:484: 
note: using clang: 
/Users/georgiy.lebedev/Work/llvm-project/build-debug/bin/clang
  llvm-lit: 
/Users/georgiy.lebedev/Work/llvm-project/llvm/utils/lit/lit/util.py:439: note: 
using SDKROOT: 
'/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk'
  FAIL: Clang :: Analysis/unix-fns.c (1 of 1)
   TEST 'Clang :: Analysis/unix-fns.c' FAILED 

  Script:
  --
  : 'RUN: at line 1';   
/Users/georgiy.lebedev/Work/llvm-project/build-debug/bin/clang -cc1 
-internal-isystem 
/Users/georgiy.lebedev/Work/llvm-project/build-debug/lib/clang/17/include 
-nostdsysteminc -analyze -analyzer-constraints=range -setup-static-analyzer 
-triple x86_64-apple-darwin10 
-analyzer-checker=core,unix.API,osx.API,optin.portability 
/Users/georgiy.lebedev/Work/llvm-project/clang/test/Analysis/unix-fns.c 
-analyzer-output=plist -analyzer-config faux-bodies=true  -fblocks -verify -o 
/Users/georgiy.lebedev/Work/llvm-project/build-debug/tools/clang/test/Analysis/Output/unix-fns.c.tmp.plist
  : 'RUN: at line 2';   grep -Ev '^[[:space:]]*.* version 
.*[[:space:]]*$|^[[:space:]]*/.*[[:space:]]*$|^[[:space:]]*.:.*[[:space:]]*$'
 

   
clang_version
  -clang version 17.0.0 (g...@github.com:llvm/llvm-project.git 
1882a4ee69b3cc2202d8d7d7b6465475f6d19886)
diagnostics

 
  @@ -4065,7 +4064,6 @@

files

  -  
/Users/georgiy.lebedev/Work/llvm-project/clang/test/Analysis/unix-fns.c

   
   
  
  --
  
  
  
  Failed Tests (1):
Clang :: Analysis/unix-fns.c
  
  
  Testing Time: 0.79s
Failed: 1




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154838

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


[PATCH] D153725: [clang] Make amdgpu-arch tool work on Windows

2023-07-10 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.

In D153725#4484754 , @JonChesterfield 
wrote:

> - if you open the driver too many times at once it fails to open, so running 
> a parallel build that uses this tool doesn't work on fast machines

Why would this happen? Seems like a bug to fix?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153725

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


[PATCH] D153725: [clang] Make amdgpu-arch tool work on Windows

2023-07-10 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.

In D153725#4484754 , @JonChesterfield 
wrote:

> The problem with using the proper API via HSA or similar is twofold:
>
> - we use this tool to enable tests, which means HSA has to exist before 
> building clang or the tests don't run and HSA now requires clang to build

I don't follow this. You don't need this to work to perform the build and test 
build. You may need it to execute the tests, but if HSA doesn't exist they 
won't be able to run anyway. If a build is invoking these tools at cmake time 
it's just broken


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153725

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


[PATCH] D153725: [clang] Make amdgpu-arch tool work on Windows

2023-07-10 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added a comment.

In D153725#4484966 , @arsenm wrote:

> In D153725#4484754 , 
> @JonChesterfield wrote:
>
>> - if you open the driver too many times at once it fails to open, so running 
>> a parallel build that uses this tool doesn't work on fast machines
>
> Why would this happen? Seems like a bug to fix?

Jon is probably referring to a recurring problem we've noticed with the `libc` 
tests on HSA that they will sometimes fail when running with multiple threads, 
see 
https://lab.llvm.org/staging/#/builders/247/builds/2599/steps/10/logs/stdio. 
Haven't been able to track down whether or not that's a bug in the 
implementation or interface somewhere.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153725

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


[PATCH] D154591: [OpenMP][OMPIRBuilder] Rename IsEmbedded and IsTargetCodegen flags

2023-07-10 Thread Sergio Afonso 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 rG63ca93c7d1d1: [OpenMP][OMPIRBuilder] Rename IsEmbedded and 
IsTargetCodegen flags (authored by skatrak).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154591

Files:
  clang/docs/OffloadingDesign.rst
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/OpenMPClause.cpp
  clang/lib/Basic/Targets/NVPTX.cpp
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.h
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.h
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/CodeGen/CGVTables.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/Targets/NVPTX.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/Flang.cpp
  clang/lib/Frontend/CompilerInstance.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/lib/Lex/LiteralSupport.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/CodeGen/PowerPC/ppc64le-varargs-f128.c
  clang/test/CodeGen/ibm128-unsupported.c
  clang/test/Driver/openmp-offload-gpu.c
  clang/test/Driver/openmp-offload.c
  clang/test/Headers/__clang_hip_libdevice_declares.cpp
  clang/test/Headers/amdgcn-openmp-device-math-complex.c
  clang/test/Headers/amdgcn-openmp-device-math-complex.cpp
  clang/test/Headers/amdgcn_openmp_device_math.c
  clang/test/Headers/amdgcn_openmp_device_math_c.c
  clang/test/Headers/amdgcn_openmp_device_math_constexpr.cpp
  clang/test/Headers/nvptx_device_cmath_functions.c
  clang/test/Headers/nvptx_device_cmath_functions.cpp
  clang/test/Headers/nvptx_device_cmath_functions_cxx17.cpp
  clang/test/Headers/nvptx_device_math_complex.c
  clang/test/Headers/nvptx_device_math_complex.cpp
  clang/test/Headers/nvptx_device_math_functions.c
  clang/test/Headers/nvptx_device_math_functions.cpp
  clang/test/Headers/nvptx_device_math_functions_cxx17.cpp
  clang/test/Headers/nvptx_device_math_macro.cpp
  clang/test/Headers/nvptx_device_math_modf.cpp
  clang/test/Headers/nvptx_device_math_sin.c
  clang/test/Headers/nvptx_device_math_sin.cpp
  clang/test/Headers/nvptx_device_math_sin_cos.cpp
  clang/test/Headers/nvptx_device_math_sincos.cpp
  clang/test/Headers/openmp-device-functions-bool.c
  clang/test/Headers/openmp_device_math_isnan.cpp
  clang/test/Headers/openmp_new_nothrow.cpp
  clang/test/Headers/target_include_new.cpp
  clang/test/OpenMP/amdgcn-attributes.cpp
  clang/test/OpenMP/amdgcn_device_function_call.cpp
  clang/test/OpenMP/amdgcn_ldbl_check.cpp
  clang/test/OpenMP/amdgcn_target_codegen.cpp
  clang/test/OpenMP/amdgcn_target_device_vla.cpp
  clang/test/OpenMP/amdgcn_target_global_constructor.cpp
  clang/test/OpenMP/amdgcn_target_init_temp_alloca.cpp
  clang/test/OpenMP/amdgpu_target_with_aligned_attribute.c
  clang/test/OpenMP/assumes_include_nvptx.cpp
  clang/test/OpenMP/aux-triple-macros.cpp
  clang/test/OpenMP/declare_target_codegen.cpp
  clang/test/OpenMP/declare_target_codegen_globalization.cpp
  clang/test/OpenMP/declare_target_constexpr_codegen.cpp
  clang/test/OpenMP/declare_target_link_codegen.cpp
  clang/test/OpenMP/declare_target_messages.cpp
  clang/test/OpenMP/declare_target_only_one_side_compilation.cpp
  clang/test/OpenMP/declare_variant_device_kind_codegen.cpp
  clang/test/OpenMP/declare_variant_mixed_codegen.c
  clang/test/OpenMP/distribute_codegen.cpp
  clang/test/OpenMP/distribute_simd_codegen.cpp
  clang/test/OpenMP/metadirective_device_arch_codegen.cpp
  clang/test/OpenMP/metadirective_device_isa_codegen_amdgcn.cpp
  clang/test/OpenMP/multiple_regions_per_line.cpp
  clang/test/OpenMP/nvptx_NRVO_variable.cpp
  clang/test/OpenMP/nvptx_SPMD_codegen.cpp
  clang/test/OpenMP/nvptx_allocate_codegen.cpp
  clang/test/OpenMP/nvptx_allocate_messages.cpp
  clang/test/OpenMP/nvptx_asm_delayed_diags.c
  clang/test/OpenMP/nvptx_data_sharing.cpp
  clang/test/OpenMP/nvptx_declare_target_var_ctor_dtor_codegen.cpp
  clang/test/OpenMP/nvptx_declare_variant_device_kind_codegen.cpp
  clang/test/OpenMP/nvptx_declare_variant_implementation_vendor_codegen.cpp
  clang/test/OpenMP/nvptx_declare_variant_name_mangling.cpp
  clang/test/OpenMP/nvptx_distribute_parallel_generic_mode_codegen.cpp
  clang/test/OpenMP/nvptx_lambda_capturing.cpp
  clang/test/OpenMP/nvptx_multi_target_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_nested_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_parallel_for_codegen.cpp
  clang/test

[PATCH] D154423: [clang][analyzer] Add all success/failure messages to StdLibraryFunctionsChecker.

2023-07-10 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added a comment.

It would be more simple to handle the standard streams in `StreamChecker` only. 
There it is possible to detect standard streams (should be variables with the 
known names) as arguments to functions. If `StreamChecker` eliminates the 
failure branch of `fileno` it will disappear from the analysis (order of 
checker callbacks does not matter, at the end only the correct branch remains). 
If stream checker is not enabled we will still get the failure for 
`fileno(stdin)`. `StdLibraryFunctionsChecker` does not have a mechanism to 
detect special variables to arguments, probably it is possible to implement 
with a special type of argument constraint.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154423

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


[PATCH] D146242: [ARM] Fixing ABI mismatch for packed structs passed as function arguments

2023-07-10 Thread Momchil Velikov via Phabricator via cfe-commits
chill added inline comments.



Comment at: clang/test/CodeGen/aarch64-ABI-align-packed-assembly.c:100
   struct packed_struct on_callee_stack;
   on_callee_stack = va_arg(vl, struct packed_struct);
 }

Can we add some `CHECK:` lines here and to other variadic functions as well (I 
recognize it might not be straightforward)?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146242

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


[PATCH] D153725: [clang] Make amdgpu-arch tool work on Windows

2023-07-10 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.

In D153725#4484973 , @arsenm wrote:

> In D153725#4484754 , 
> @JonChesterfield wrote:
>
>> The problem with using the proper API via HSA or similar is twofold:
>>
>> - we use this tool to enable tests, which means HSA has to exist before 
>> building clang or the tests don't run and HSA now requires clang to build
>
> I don't follow this. You don't need this to work to perform the build and 
> test build. You may need it to execute the tests, but if HSA doesn't exist 
> they won't be able to run anyway. If a build is invoking these tools at cmake 
> time it's just broken

And the libomptarget build is in fact doing that, but it shouldn't have to. 
What it's doing actually seems really unreasonable. It's only building the 
locally found targets when it should be building all targetable devices. The 
inconvenience there is that's too many devices, so as a build time hack you 
should be able to opt-in to a restricted subset. Even better would be if we 
would only build a copy for a reasonable subset of targets (i.e. one per 
generation where there's actually some semblance of compatibility). Or could 
just capitulate and rely on the hacks device libs does


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153725

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


[PATCH] D153725: [clang] Make amdgpu-arch tool work on Windows

2023-07-10 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a comment.

In D153725#4484966 , @arsenm wrote:

> In D153725#4484754 , 
> @JonChesterfield wrote:
>
>> - if you open the driver too many times at once it fails to open, so running 
>> a parallel build that uses this tool doesn't work on fast machines
>
> Why would this happen? Seems like a bug to fix?

It definitely annoys me. The argument is you can't usefully run some large N 
number of programs at the same time anyway and the driver failing to open is a 
rate limit. The problem is there are things we could usefully do, like this 
query, without needing to run a kernel as well. The net effect is we don't run 
tests widely in parallel because they fail if we do, for this and possibly 
other reasons.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153725

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


[PATCH] D153725: [clang] Make amdgpu-arch tool work on Windows

2023-07-10 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a comment.

The test detection is an awkward compromise between people who want to run the 
GPU tests and people who don't, and reflects diverse hardware in use and 
variation on whether cuda / hsa are installed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153725

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


[PATCH] D153725: [clang] Make amdgpu-arch tool work on Windows

2023-07-10 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added a comment.

In D153725#4485039 , @arsenm wrote:

> And the libomptarget build is in fact doing that, but it shouldn't have to. 
> What it's doing actually seems really unreasonable. It's only building the 
> locally found targets when it should be building all targetable devices. The 
> inconvenience there is that's too many devices, so as a build time hack you 
> should be able to opt-in to a restricted subset. Even better would be if we 
> would only build a copy for a reasonable subset of targets (i.e. one per 
> generation where there's actually some semblance of compatibility). Or could 
> just capitulate and rely on the hacks device libs does

The `libomptarget` build uses it to determine if it should build the tests 
mostly, we don't want to configure tests for a system that cannot support them. 
The `libc` tests however requires it to set the architecture for its test 
configuration since we can't support multiple test architectures at the same 
time, it required too much work so I shelved that. We more or less just say "If 
you've got HSA / CUDA we expect to run tests".


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153725

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


[PATCH] D154833: [clang][dataflow] Add `AnalysisInputs::withSolverFactory()`.

2023-07-10 Thread Martin Böhme 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 rG8bc13c884727: [clang][dataflow] Add 
`AnalysisInputs::withSolverFactory()`. (authored by mboehme).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154833

Files:
  clang/unittests/Analysis/FlowSensitive/TestingSupport.h


Index: clang/unittests/Analysis/FlowSensitive/TestingSupport.h
===
--- clang/unittests/Analysis/FlowSensitive/TestingSupport.h
+++ clang/unittests/Analysis/FlowSensitive/TestingSupport.h
@@ -143,6 +143,12 @@
 BuiltinOptions = std::move(Options);
 return std::move(*this);
   }
+  AnalysisInputs &&
+  withSolverFactory(std::function()> Factory) && {
+assert(Factory);
+SolverFactory = std::move(Factory);
+return std::move(*this);
+  }
 
   /// Required. Input code that is analyzed.
   llvm::StringRef Code;
@@ -170,6 +176,10 @@
   tooling::FileContentMappings ASTBuildVirtualMappedFiles = {};
   /// Configuration options for the built-in model.
   DataflowAnalysisContext::Options BuiltinOptions;
+  /// SAT solver factory.
+  std::function()> SolverFactory = [] {
+return std::make_unique();
+  };
 };
 
 /// Returns assertions based on annotations that are present after statements 
in
@@ -248,7 +258,7 @@
 auto &CFCtx = *MaybeCFCtx;
 
 // Initialize states for running dataflow analysis.
-DataflowAnalysisContext DACtx(std::make_unique(),
+DataflowAnalysisContext DACtx(AI.SolverFactory(),
   {/*Opts=*/AI.BuiltinOptions});
 Environment InitEnv(DACtx, *Target);
 auto Analysis = AI.MakeAnalysis(Context, InitEnv);


Index: clang/unittests/Analysis/FlowSensitive/TestingSupport.h
===
--- clang/unittests/Analysis/FlowSensitive/TestingSupport.h
+++ clang/unittests/Analysis/FlowSensitive/TestingSupport.h
@@ -143,6 +143,12 @@
 BuiltinOptions = std::move(Options);
 return std::move(*this);
   }
+  AnalysisInputs &&
+  withSolverFactory(std::function()> Factory) && {
+assert(Factory);
+SolverFactory = std::move(Factory);
+return std::move(*this);
+  }
 
   /// Required. Input code that is analyzed.
   llvm::StringRef Code;
@@ -170,6 +176,10 @@
   tooling::FileContentMappings ASTBuildVirtualMappedFiles = {};
   /// Configuration options for the built-in model.
   DataflowAnalysisContext::Options BuiltinOptions;
+  /// SAT solver factory.
+  std::function()> SolverFactory = [] {
+return std::make_unique();
+  };
 };
 
 /// Returns assertions based on annotations that are present after statements in
@@ -248,7 +258,7 @@
 auto &CFCtx = *MaybeCFCtx;
 
 // Initialize states for running dataflow analysis.
-DataflowAnalysisContext DACtx(std::make_unique(),
+DataflowAnalysisContext DACtx(AI.SolverFactory(),
   {/*Opts=*/AI.BuiltinOptions});
 Environment InitEnv(DACtx, *Target);
 auto Analysis = AI.MakeAnalysis(Context, InitEnv);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 8bc13c8 - [clang][dataflow] Add `AnalysisInputs::withSolverFactory()`.

2023-07-10 Thread Martin Braenne via cfe-commits

Author: Martin Braenne
Date: 2023-07-10T13:43:13Z
New Revision: 8bc13c884727f0b9be876303d654dd1eda300dc3

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

LOG: [clang][dataflow] Add `AnalysisInputs::withSolverFactory()`.

Reviewed By: sammccall

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

Added: 


Modified: 
clang/unittests/Analysis/FlowSensitive/TestingSupport.h

Removed: 




diff  --git a/clang/unittests/Analysis/FlowSensitive/TestingSupport.h 
b/clang/unittests/Analysis/FlowSensitive/TestingSupport.h
index 93991d87d77f20..1568fc9a200e47 100644
--- a/clang/unittests/Analysis/FlowSensitive/TestingSupport.h
+++ b/clang/unittests/Analysis/FlowSensitive/TestingSupport.h
@@ -143,6 +143,12 @@ template  struct AnalysisInputs {
 BuiltinOptions = std::move(Options);
 return std::move(*this);
   }
+  AnalysisInputs &&
+  withSolverFactory(std::function()> Factory) && {
+assert(Factory);
+SolverFactory = std::move(Factory);
+return std::move(*this);
+  }
 
   /// Required. Input code that is analyzed.
   llvm::StringRef Code;
@@ -170,6 +176,10 @@ template  struct AnalysisInputs {
   tooling::FileContentMappings ASTBuildVirtualMappedFiles = {};
   /// Configuration options for the built-in model.
   DataflowAnalysisContext::Options BuiltinOptions;
+  /// SAT solver factory.
+  std::function()> SolverFactory = [] {
+return std::make_unique();
+  };
 };
 
 /// Returns assertions based on annotations that are present after statements 
in
@@ -248,7 +258,7 @@ checkDataflow(AnalysisInputs AI,
 auto &CFCtx = *MaybeCFCtx;
 
 // Initialize states for running dataflow analysis.
-DataflowAnalysisContext DACtx(std::make_unique(),
+DataflowAnalysisContext DACtx(AI.SolverFactory(),
   {/*Opts=*/AI.BuiltinOptions});
 Environment InitEnv(DACtx, *Target);
 auto Analysis = AI.MakeAnalysis(Context, InitEnv);



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


[PATCH] D41416: [modules] [pch] Do not deserialize all lazy template specializations when looking for one.

2023-07-10 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev updated this revision to Diff 538633.
v.g.vassilev added a comment.

Rebase.


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

https://reviews.llvm.org/D41416

Files:
  clang/include/clang/AST/DeclTemplate.h
  clang/lib/AST/DeclTemplate.cpp
  clang/lib/AST/ODRHash.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/lib/Serialization/ASTWriterDecl.cpp

Index: clang/lib/Serialization/ASTWriterDecl.cpp
===
--- clang/lib/Serialization/ASTWriterDecl.cpp
+++ clang/lib/Serialization/ASTWriterDecl.cpp
@@ -177,11 +177,11 @@
   Record.AddSourceLocation(typeParams->getRAngleLoc());
 }
 
-/// Add to the record the first declaration from each module file that
-/// provides a declaration of D. The intent is to provide a sufficient
-/// set such that reloading this set will load all current redeclarations.
-void AddFirstDeclFromEachModule(const Decl *D, bool IncludeLocal) {
-  llvm::MapVector Firsts;
+/// Collect the first declaration from each module file that provides a
+/// declaration of D.
+void CollectFirstDeclFromEachModule(const Decl *D, bool IncludeLocal,
+llvm::MapVector &Firsts) {
+
   // FIXME: We can skip entries that we know are implied by others.
   for (const Decl *R = D->getMostRecentDecl(); R; R = R->getPreviousDecl()) {
 if (R->isFromASTFile())
@@ -189,10 +189,49 @@
 else if (IncludeLocal)
   Firsts[nullptr] = R;
   }
+}
+
+/// Add to the record the first declaration from each module file that
+/// provides a declaration of D. The intent is to provide a sufficient
+/// set such that reloading this set will load all current redeclarations.
+void AddFirstDeclFromEachModule(const Decl *D, bool IncludeLocal) {
+  llvm::MapVector Firsts;
+  CollectFirstDeclFromEachModule(D, IncludeLocal, Firsts);
+
   for (const auto &F : Firsts)
 Record.AddDeclRef(F.second);
 }
 
+/// Add to the record the first template specialization from each module
+/// file that provides a declaration of D. We store the DeclId and an
+/// ODRHash of the template arguments of D which should provide enough
+/// information to load D only if the template instantiator needs it.
+void AddFirstSpecializationDeclFromEachModule(const Decl *D,
+  bool IncludeLocal) {
+  assert(isa(D) ||
+ isa(D) || isa(D) &&
+ "Must not be called with other decls");
+  llvm::MapVector Firsts;
+  CollectFirstDeclFromEachModule(D, IncludeLocal, Firsts);
+
+  for (const auto &F : Firsts) {
+Record.AddDeclRef(F.second);
+ArrayRef Args;
+if (auto *CTSD = dyn_cast(D))
+  Args = CTSD->getTemplateArgs().asArray();
+else if (auto *VTSD = dyn_cast(D))
+  Args = VTSD->getTemplateArgs().asArray();
+else if (auto *FD = dyn_cast(D))
+  Args = FD->getTemplateSpecializationArgs()->asArray();
+assert(Args.size());
+Record.push_back(TemplateArgumentList::ComputeODRHash(Args));
+bool IsPartialSpecialization
+  = isa(D) ||
+  isa(D);
+Record.push_back(IsPartialSpecialization);
+  }
+}
+
 /// Get the specialization decl from an entry in the specialization list.
 template 
 typename RedeclarableTemplateDecl::SpecEntryTraits::DeclType *
@@ -205,7 +244,8 @@
 decltype(T::PartialSpecializations) &getPartialSpecializations(T *Common) {
   return Common->PartialSpecializations;
 }
-ArrayRef getPartialSpecializations(FunctionTemplateDecl::Common *) {
+MutableArrayRef
+getPartialSpecializations(FunctionTemplateDecl::Common *) {
   return std::nullopt;
 }
 
@@ -222,9 +262,11 @@
 assert(!Common->LazySpecializations);
   }
 
-  ArrayRef LazySpecializations;
+  using LazySpecializationInfo
+= RedeclarableTemplateDecl::LazySpecializationInfo;
+  ArrayRef LazySpecializations;
   if (auto *LS = Common->LazySpecializations)
-LazySpecializations = llvm::ArrayRef(LS + 1, LS[0]);
+LazySpecializations = llvm::ArrayRef(LS + 1, LS[0].DeclID);
 
   // Add a slot to the record for the number of specializations.
   unsigned I = Record.size();
@@ -240,12 +282,20 @@
 
   for (auto *D : Specs) {
 assert(D->isCanonicalDecl() && "non-canonical decl in set");
-AddFirstDeclFromEachModule(D, /*IncludeLocal*/true);
+AddFirstSpecializationDeclFromEachModule(D, /*IncludeLocal*/true);
+  }
+  for (auto &SpecInfo : LazySpecializations) {
+Record.push_back(SpecInfo.DeclID);
+Record.push_back(SpecInfo.ODRHash);
+Record.push_back(SpecInfo.IsPartial);
   }
-  Record.append(LazySpecializations.begin(), LazySpec

[PATCH] D152900: [clangd] Update symbol collector to use include-cleaner.

2023-07-10 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/ClangdServer.cpp:85
 auto Task = [FIndex(FIndex), Path(Path.str()), Version(Version.str()),
- ASTCtx(std::move(ASTCtx)),
- CanonIncludes(CanonIncludes)]() mutable {
+ ASTCtx(std::move(ASTCtx)), PI]() mutable {
   trace::Span Tracer("PreambleIndexing");

nit: `PI(std::move(PI))`



Comment at: clang-tools-extra/clangd/TUScheduler.cpp:1086
 Callbacks.onPreambleAST(FileName, Inputs.Version, std::move(ASTCtx),
-CanonIncludes);
+PI);
   },

nit: s/PI/std::move(PI)



Comment at: clang-tools-extra/clangd/index/CanonicalIncludes.cpp:672
 
 llvm::StringRef CanonicalIncludes::mapHeader(FileEntryRef Header) const {
   if (!StdSuffixHeaderMapping)

we're no longer using any `FileEntry` pieces of this parameter you can take in 
just a `llvm::StringRef HeaderPath` instead.



Comment at: clang-tools-extra/clangd/index/CanonicalIncludes.h:40
   /// Adds a file-to-string mapping from \p ID to \p CanonicalPath.
   void addMapping(FileEntryRef Header, llvm::StringRef CanonicalPath);
 

VitaNuo wrote:
> kadircet wrote:
> > AFAICT, only users of this endpoint were in `IWYUCommentHandler` (and some 
> > tests). we can also get rid of this one now.
> > 
> > More importantly now this turns into a mapper used only by symbolcollector, 
> > that can be cheaply created at use time (we just copy around a pointer 
> > every time we want to create it). so you can drop `CanonicalIncludes` from 
> > all of the interfaces, including `SymbolCollector::Options` and create one 
> > on demand in `HeaderFileURICache`. all we need is langopts, and it's 
> > available through preprocessor (not necessarily on construction, but at the 
> > time when we want to do the mappings).
> > 
> > As you're already touching all of the interfaces that propagate 
> > `CanonicalIncludes` around, hopefully this change should only make things 
> > simpler (and you already need to touch them when you rebase), but if that 
> > feels like too much churn in this patch feel free to do that in a follow up 
> > as well.
> > ... and create one on demand in HeaderFileURICache. all we need is 
> > langopts, and it's available through preprocessor (not necessarily on 
> > construction, but at the time when we want to do the mappings
> 
> This time sounds a little late, since we don't want to rebuild the system 
> header mapping every time we request a mapping for a particular header. 
> Cache construction time doesn't work, since it happens before the 
> preprocessor is set in the symbol collector (and we need the preprocessor to 
> retrieve language options).
> So far the safe place I've found is right after the preprocessor is set in 
> the symbol collector. Another option is to collect the system header options 
> in the finish() method, but I can't see why we would need to delay until 
> then. 
> This time sounds a little late, since we don't want to rebuild the system 
> header mapping every time we request a mapping for a particular header.

System header mapping is a singleton, we build it statically once on first 
request throughout the whole process and just use that for the rest of the 
execution.



Comment at: clang-tools-extra/clangd/index/FileIndex.cpp:49
+const MainFileMacros *MacroRefsToIndex,
+std::shared_ptr PI,
+bool IsIndexMainAST, llvm::StringRef Version, bool CollectMainFileRefs) {

again you can have a `const include_cleaner::PragmaIncludes &` without 
`shared_ptr` here.



Comment at: clang-tools-extra/clangd/index/FileIndex.h:118
+ Preprocessor &PP,
+ std::shared_ptr PI);
   void updatePreamble(IndexFileIn);

you can have a `const include_cleaner::PragmaIncludes& PI` directly both in 
here and in `indexHeaderSymbols`.

after building a preamble we always have a non-null PragmaIncludes and these 
functions are always executed synchronously, so no need to extend ownership and 
make the code indirect.



Comment at: clang-tools-extra/clangd/index/IndexAction.cpp:230
   }
-  auto Includes = std::make_unique();
-  Opts.Includes = Includes.get();
-  return std::make_unique(
-  std::make_shared(std::move(Opts)), std::move(Includes),
-  IndexOpts, SymbolsCallback, RefsCallback, RelationsCallback,
-  IncludeGraphCallback);
+  auto PragmaIncludes = std::make_shared();
+  Opts.PragmaIncludes = PragmaIncludes;

you can have a unique_ptr here instead (once we store a non-owning pointer in 
`Opts.PragmaIncludes`)



Comment at: clang-tools-extra/clangd/index/SymbolCollector.cpp:407
+
+if (auto Verbatim = PI->getPublic(SM.getFileEntryForID(FID));
+!Verbatim.emp

[PATCH] D154850: [libc] Remove GPU string functions incompatible with C++

2023-07-10 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 created this revision.
jhuber6 added reviewers: jdoerfert, JonChesterfield, sivachandra, lntue, 
michaelrj, ronlieb.
Herald added projects: libc-project, All.
Herald added a subscriber: libc-commits.
jhuber6 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

These functions have definitions differing between C and C++. GNU
respects the C++ definitions while the LLVM libc does not. This causes
many bugs and the current hack creates other issues. Rather than hack
around this I'd rather temporarily disable these than regress with the
integration into other offloading languages. We lose test support for
them but we should be able to re-enable these once the `libc` headers
provide these correctly.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D154850

Files:
  clang/lib/Headers/llvm_libc_wrappers/string.h
  libc/config/gpu/entrypoints.txt
  libc/docs/gpu/support.rst


Index: libc/docs/gpu/support.rst
===
--- libc/docs/gpu/support.rst
+++ libc/docs/gpu/support.rst
@@ -47,7 +47,7 @@
 bcmp   |check|
 bzero  |check|
 memccpy|check|
-memchr |check|
+memchr 
 memcmp |check|
 memcpy |check|
 memmove|check|
@@ -57,7 +57,7 @@
 stpcpy |check|
 stpncpy|check|
 strcat |check|
-strchr |check|
+strchr 
 strcmp |check|
 strcpy |check|
 strcspn|check|
@@ -68,10 +68,10 @@
 strncmp|check|
 strncpy|check|
 strnlen|check|
-strpbrk|check|
-strrchr|check|
+strpbrk
+strrchr
 strspn |check|
-strstr |check|
+strstr 
 strtok |check|
 strtok_r   |check|
 strdup
Index: libc/config/gpu/entrypoints.txt
===
--- libc/config/gpu/entrypoints.txt
+++ libc/config/gpu/entrypoints.txt
@@ -21,7 +21,6 @@
 libc.src.string.bcmp
 libc.src.string.bzero
 libc.src.string.memccpy
-libc.src.string.memchr
 libc.src.string.memcmp
 libc.src.string.memcpy
 libc.src.string.memmem
@@ -32,10 +31,7 @@
 libc.src.string.stpcpy
 libc.src.string.stpncpy
 libc.src.string.strcasecmp
-libc.src.string.strcasestr
 libc.src.string.strcat
-libc.src.string.strchr
-libc.src.string.strchrnul
 libc.src.string.strcmp
 libc.src.string.strcpy
 libc.src.string.strcspn
@@ -47,10 +43,7 @@
 libc.src.string.strncmp
 libc.src.string.strncpy
 libc.src.string.strnlen
-libc.src.string.strpbrk
-libc.src.string.strrchr
 libc.src.string.strspn
-libc.src.string.strstr
 libc.src.string.strtok
 libc.src.string.strtok_r
 
Index: clang/lib/Headers/llvm_libc_wrappers/string.h
===
--- clang/lib/Headers/llvm_libc_wrappers/string.h
+++ clang/lib/Headers/llvm_libc_wrappers/string.h
@@ -13,22 +13,11 @@
 #error "This file is for GPU offloading compilation only"
 #endif
 
-// The GNU headers provide non C-standard headers when in C++ mode. Manually
-// undefine it here so that the definitions agree with the C standard for our
-// purposes.
-#ifdef __cplusplus
-extern "C" {
-#pragma push_macro("__cplusplus")
-#undef __cplusplus
-#endif
-
+// FIXME: The GNU headers provide C++ standard compliant headers when in C++
+// mode and the LLVM libc does not. We cannot enable memchr, strchr, strchrnul,
+// strpbrk, strrchr, strstr, or strcasestr until this is addressed.
 #include_next 
 
-#pragma pop_macro("__cplusplus")
-#ifdef __cplusplus
-}
-#endif
-
 #if __has_include()
 
 #if defined(__HIP__) || defined(__CUDA__)


Index: libc/docs/gpu/support.rst
===
--- libc/docs/gpu/support.rst
+++ libc/docs/gpu/support.rst
@@ -47,7 +47,7 @@
 bcmp   |check|
 bzero  |check|
 memccpy|check|
-memchr |check|
+memchr 
 memcmp |check|
 memcpy |check|
 memmove|check|
@@ -57,7 +57,7 @@
 stpcpy |check|
 stpncpy|check|
 strcat |check|
-strchr |check|
+strchr 
 strcmp |check|
 strcpy |check|
 strcspn|check|
@@ -68,10 +68,10 @@
 strncmp|check|
 strncpy|check|
 strnlen|check|
-strpbrk|check|
-strrchr|check|
+strpbrk
+strrchr
 strspn |check|
-strstr |check|
+strstr 
 strtok |check|
 strtok_r   |check|
 strdup
Index: libc/config/gpu/entrypoints.txt
===
--- libc/config/gpu/entrypoints.txt
+++ libc/config/gpu/entrypoints.txt
@@ -21,7 +21,6 @@
 libc.src.string.bcmp
 libc.src.string.bzero
 libc.src.string.memccpy
-libc.src.string.memchr
 libc.src.string.memcmp
 libc.src.string.memcpy
 lib

[PATCH] D154850: [libc] Remove GPU string functions incompatible with C++

2023-07-10 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield accepted this revision.
JonChesterfield added a comment.
This revision is now accepted and ready to land.

Is this a const thing? If so I'd naively hope we can declare both in C++ mode 
and alias them, but I can believe that is detectably broken.

How does glibc manage their hack?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154850

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


[clang] 12d72e4 - Add libClang guide

2023-07-10 Thread Aaron Ballman via cfe-commits

Author: manuel5975p
Date: 2023-07-10T11:15:48-04:00
New Revision: 12d72e4fdee91b3f1e314759d6aa33d25fb38f86

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

LOG: Add libClang guide

Add a libclang .rst file with some code examples, going over the most
important types and functions of libclang.

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

Added: 
clang/docs/LibClang.rst

Modified: 
clang/docs/index.rst

Removed: 




diff  --git a/clang/docs/LibClang.rst b/clang/docs/LibClang.rst
new file mode 100644
index 00..08cf452a0df6c4
--- /dev/null
+++ b/clang/docs/LibClang.rst
@@ -0,0 +1,360 @@
+.. role:: raw-html(raw)
+:format: html
+
+Libclang tutorial
+=
+The C Interface to Clang provides a relatively small API that exposes 
facilities for parsing source code into an abstract syntax tree (AST), loading 
already-parsed ASTs, traversing the AST, associating physical source locations 
with elements within the AST, and other facilities that support Clang-based 
development tools.
+This C interface to Clang will never provide all of the information 
representation stored in Clang's C++ AST, nor should it: the intent is to 
maintain an API that is relatively stable from one release to the next, 
providing only the basic functionality needed to support development tools.
+The entire C interface of libclang is available in the file `Index.h`_
+
+Essential types overview
+-
+
+All types of libclang are prefixed with ``CX``
+
+CXIndex
+~~~
+An Index that consists of a set of translation units that would typically be 
linked together into an executable or library.
+
+CXTranslationUnit
+~
+A single translation unit, which resides in an index.
+
+CXCursor
+
+A cursor representing a pointer to some element in the abstract syntax tree of 
a translation unit.
+
+
+Code example
+
+
+.. code-block:: cpp
+
+  // file.cpp
+  struct foo{
+int bar;
+int* bar_pointer;
+  };
+
+.. code-block:: cpp
+
+  #include 
+  #include 
+
+  int main(){
+CXIndex index = clang_createIndex(0, 0); //Create index
+CXTranslationUnit unit = clang_parseTranslationUnit(
+  index,
+  "file.cpp", nullptr, 0,
+  nullptr, 0,
+  CXTranslationUnit_None); //Parse "file.cpp"
+
+
+if (unit == nullptr){
+  std::cerr << "Unable to parse translation unit. Quitting.\n";
+  return 0;
+}
+CXCursor cursor = clang_getTranslationUnitCursor(unit); //Obtain a cursor 
at the root of the translation unit
+  }
+
+Visiting elements of an AST
+~~~
+The elements of an AST can be recursively visited with pre-order traversal 
with ``clang_visitChildren``.
+
+.. code-block:: cpp
+
+  clang_visitChildren(
+cursor, //Root cursor
+[](CXCursor current_cursor, CXCursor parent, CXClientData client_data){
+
+  CXString current_display_name = 
clang_getCursorDisplayName(current_cursor);
+  //Allocate a CXString representing the name of the current cursor
+
+  std::cout << "Visiting element " << 
clang_getCString(current_display_name) << "\n";
+  //Print the char* value of current_display_name
+
+  clang_disposeString(current_display_name);
+  //Since clang_getCursorDisplayName allocates a new CXString, it must be 
freed. This applies
+  //to all functions returning a CXString
+
+  return CXChildVisit_Recurse;
+
+
+}, //CXCursorVisitor: a function pointer
+nullptr //client_data
+);
+
+The return value of ``CXCursorVisitor``, the callable argument of 
``clang_visitChildren``, can return one of the three:
+
+#. ``CXChildVisit_Break``: Terminates the cursor traversal
+
+#. ``CXChildVisit_Continue``: Continues the cursor traversal with the next 
sibling of the cursor just visited, without visiting its children.
+
+#. ``CXChildVisit_Recurse``: Recursively traverse the children of this cursor, 
using the same visitor and client data
+
+The expected output of that program is
+
+.. code-block::
+
+  Visiting element foo
+  Visiting element bar
+  Visiting element bar_pointer
+
+
+Extracting information from a Cursor
+
+.. The following functions take a ``CXCursor`` as an argument and return 
associated information.
+
+
+
+Extracting the Cursor kind
+""
+
+``CXCursorKind clang_getCursorKind(CXCursor)`` Describes the kind of entity 
that a cursor refers to. Example values:
+
+- ``CXCursor_StructDecl``: A C or C++ struct.
+- ``CXCursor_FieldDecl``: A field in a struct, union, or C++ class.
+- ``CXCursor_CallExpr``: An expression that calls a function.
+
+
+Extracting the Cursor type
+""
+``CXType clang_getCursorType(CXCursor)``: Retrieve the type of a CXCursor 

[PATCH] D153738: Add LibClang guide

2023-07-10 Thread Aaron Ballman 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 rG12d72e4fdee9: Add libClang guide (authored by manuel5975p, 
committed by aaron.ballman).
Herald added a subscriber: arphaman.

Changed prior to commit:
  https://reviews.llvm.org/D153738?vs=538333&id=538655#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153738

Files:
  clang/docs/LibClang.rst
  clang/docs/index.rst

Index: clang/docs/index.rst
===
--- clang/docs/index.rst
+++ clang/docs/index.rst
@@ -65,6 +65,7 @@
ExternalClangExamples
IntroductionToTheClangAST
LibTooling
+   LibClang
LibFormat
ClangPlugins
RAVFrontendAction
Index: clang/docs/LibClang.rst
===
--- /dev/null
+++ clang/docs/LibClang.rst
@@ -0,0 +1,360 @@
+.. role:: raw-html(raw)
+:format: html
+
+Libclang tutorial
+=
+The C Interface to Clang provides a relatively small API that exposes facilities for parsing source code into an abstract syntax tree (AST), loading already-parsed ASTs, traversing the AST, associating physical source locations with elements within the AST, and other facilities that support Clang-based development tools.
+This C interface to Clang will never provide all of the information representation stored in Clang's C++ AST, nor should it: the intent is to maintain an API that is relatively stable from one release to the next, providing only the basic functionality needed to support development tools.
+The entire C interface of libclang is available in the file `Index.h`_
+
+Essential types overview
+-
+
+All types of libclang are prefixed with ``CX``
+
+CXIndex
+~~~
+An Index that consists of a set of translation units that would typically be linked together into an executable or library.
+
+CXTranslationUnit
+~
+A single translation unit, which resides in an index.
+
+CXCursor
+
+A cursor representing a pointer to some element in the abstract syntax tree of a translation unit.
+
+
+Code example
+
+
+.. code-block:: cpp
+
+  // file.cpp
+  struct foo{
+int bar;
+int* bar_pointer;
+  };
+
+.. code-block:: cpp
+
+  #include 
+  #include 
+
+  int main(){
+CXIndex index = clang_createIndex(0, 0); //Create index
+CXTranslationUnit unit = clang_parseTranslationUnit(
+  index,
+  "file.cpp", nullptr, 0,
+  nullptr, 0,
+  CXTranslationUnit_None); //Parse "file.cpp"
+
+
+if (unit == nullptr){
+  std::cerr << "Unable to parse translation unit. Quitting.\n";
+  return 0;
+}
+CXCursor cursor = clang_getTranslationUnitCursor(unit); //Obtain a cursor at the root of the translation unit
+  }
+
+Visiting elements of an AST
+~~~
+The elements of an AST can be recursively visited with pre-order traversal with ``clang_visitChildren``.
+
+.. code-block:: cpp
+
+  clang_visitChildren(
+cursor, //Root cursor
+[](CXCursor current_cursor, CXCursor parent, CXClientData client_data){
+
+  CXString current_display_name = clang_getCursorDisplayName(current_cursor);
+  //Allocate a CXString representing the name of the current cursor
+
+  std::cout << "Visiting element " << clang_getCString(current_display_name) << "\n";
+  //Print the char* value of current_display_name
+
+  clang_disposeString(current_display_name);
+  //Since clang_getCursorDisplayName allocates a new CXString, it must be freed. This applies
+  //to all functions returning a CXString
+
+  return CXChildVisit_Recurse;
+
+
+}, //CXCursorVisitor: a function pointer
+nullptr //client_data
+);
+
+The return value of ``CXCursorVisitor``, the callable argument of ``clang_visitChildren``, can return one of the three:
+
+#. ``CXChildVisit_Break``: Terminates the cursor traversal
+
+#. ``CXChildVisit_Continue``: Continues the cursor traversal with the next sibling of the cursor just visited, without visiting its children.
+
+#. ``CXChildVisit_Recurse``: Recursively traverse the children of this cursor, using the same visitor and client data
+
+The expected output of that program is
+
+.. code-block::
+
+  Visiting element foo
+  Visiting element bar
+  Visiting element bar_pointer
+
+
+Extracting information from a Cursor
+
+.. The following functions take a ``CXCursor`` as an argument and return associated information.
+
+
+
+Extracting the Cursor kind
+""
+
+``CXCursorKind clang_getCursorKind(CXCursor)`` Describes the kind of entity that a cursor refers to. Example values:
+
+- ``CXCursor_StructDecl``: A C or C++ struct.
+- ``CXCursor_FieldDecl``: A field in a struct, union, or C++ class.
+- ``CXCursor_CallExpr``: An expression that call

[PATCH] D153738: Add LibClang guide

2023-07-10 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D153738#4484865 , @manuel5975p 
wrote:

> I guess manuel5975p (manuel.wink...@gmx.ch) would be nice

Thank you for the new documentation, it's really appreciated! I've landed this 
on your behalf in 12d72e4fdee91b3f1e314759d6aa33d25fb38f86 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153738

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


[PATCH] D152504: [clang][ThreadSafety] Analyze cleanup functions

2023-07-10 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added inline comments.



Comment at: clang/lib/Analysis/ThreadSafety.cpp:2436
+CF.getVarDecl()->getLocation());
+  break;
+}

tbaeder wrote:
> aaronpuchert wrote:
> > aaronpuchert wrote:
> > > tbaeder wrote:
> > > > This handles the function call, but without the instance parameter. I 
> > > > was wondering how to best do that.
> > > Should you not simply pass `SxBuilder.createVariable(CF.getVarDecl())` as 
> > > third parameter in analogy with the `AutomaticObjectDtor` case? It might 
> > > also make sense to copy the attribute check.
> > Can you write a test case that relies on passing the variable? Here is an 
> > idea:
> > ```
> > void unlock_scope(Mutex **mu) __attribute__((release_capability(*mu))) {
> >   mutex_exclusive_unlock(*mu);
> > }
> > 
> > Mutex* const CLEANUP(unlock_scope) scope = &mu1;
> > mutex_exclusive_lock(*scope);
> > // Unlock should happen automatically.
> > ```
> > I think this is mildly more interesting than the cleanup function with an 
> > unused parameter.
> > 
> > Unfortunately this is not quite as powerful as a scoped lock in C++, as we 
> > don't track the identity `scope == &mu1`. So `guarded_by` won't work with 
> > this. But we can at least see warnings on balanced locking/unlocking.
> > 
> > As for proper scoped locking, we could treat some variable initializations 
> > like construction of a C++ scoped lock. But let's discuss this separately.
> Yeah, it doesn't find the lock; I assume that's because the first parameter 
> here is not an _actual_ this parameter; I'd have to handle the var decl as a 
> regular parameter.
@aaronpuchert Can you explain how that would work? One goal from before was to 
avoid creating new fake AST nodes, would I'd have to insert the instance 
parameter as a new `DeclRefExpr` in the CFG, wouldn't I?


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

https://reviews.llvm.org/D152504

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


[PATCH] D154675: [Clang] Fix crash when emitting diagnostic for out of order designated initializers in C++

2023-07-10 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D154675#4484194 , @cor3ntin wrote:

> Thanks, this looks good! (the libc++ test seems completely unrelated, it 
> happens before compilation starts).
> Can you add re release note though? Thanks!

+1 to both of these sentences. :-)




Comment at: clang/lib/Sema/SemaInit.cpp:2847
 
-unsigned OldIndex = NumBases + PrevField->getFieldIndex();
+unsigned OldIndex = StructuredIndex - 1;
 if (StructuredList && OldIndex <= StructuredList->getNumInits()) {

Should we be asserting that `StructuredIndex` is not 0? The logic in this 
function makes it tough to see, but the fact that we're in a block checking 
`IsFirstDesignator` makes me think this is dangerous.



Comment at: clang/test/SemaCXX/cxx2a-initializer-aggregates.cpp:66
   .y = 1, // override-note {{previous}}
-  .y = 1, // override-error {{overrides prior initialization}}
+  .y = 1, // override-error {{overrides prior initialization}} // reorder-note 
{{previous initialization for field 'y' is here}}
   .x = 1, // reorder-error {{declaration order}} override-error {{overrides 
prior initialization}} override-note {{previous}}

A few questions: 1) what is this new note attached to? The only `reorder-*` 
diagnostic I see in the test is for the initialization of `x`. 2) is the note 
actually on the correct previous use? I would have expected this to be on the 
assignment to `y` one line above.


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

https://reviews.llvm.org/D154675

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


[PATCH] D154853: [clangd][c++20]Consider the constraint of a constrained auto in FindTarget.

2023-07-10 Thread Jens Massberg via Phabricator via cfe-commits
massberg created this revision.
massberg added a reviewer: sammccall.
Herald added subscribers: kadircet, arphaman.
Herald added a project: All.
massberg requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

This enables support of hover on concepts with auto types.

I'm not 100% sure if this is the correct fix, but it works for
the exmaples and in vscode.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D154853

Files:
  clang-tools-extra/clangd/FindTarget.cpp
  clang-tools-extra/clangd/unittests/FindTargetTests.cpp
  clang-tools-extra/clangd/unittests/HoverTests.cpp


Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -487,6 +487,46 @@
  HI.Kind = index::SymbolKind::TypeAlias;
  HI.Definition = "int";
}},
+  // constraint of constrained auto
+  {R"cpp(
+template  concept Fooable = true;
+[[Foo^able]] auto x = 1;
+)cpp",
+   [](HoverInfo &HI) {
+ HI.NamespaceScope = "";
+ HI.Name = "Fooable";
+ HI.Kind = index::SymbolKind::Concept;
+ HI.Definition = "template \n"
+ "concept Fooable = true";
+   }},
+  {R"cpp(
+template  concept Fooable = true;
+template<[[Fooa^ble]] auto x> void Foo() {}
+)cpp",
+   [](HoverInfo &HI) {
+ HI.NamespaceScope = "";
+ HI.Name = "Fooable";
+ HI.Kind = index::SymbolKind::Concept;
+ HI.Definition = "template \n"
+ "concept Fooable = true";
+   }},
+  // concept
+  {R"cpp(
+template 
+concept Fooable = requires (T t) { t.foo(); };
+
+template  requires [[Fo^oable]]
+void bar(T t) {
+  t.foo();
+}
+)cpp",
+   [](HoverInfo &HI) {
+ HI.NamespaceScope = "";
+ HI.Name = "Fooable";
+ HI.Kind = index::SymbolKind::Concept;
+ HI.Definition = "template \n"
+ "concept Fooable = requires(T t) { t.foo(); }";
+   }},
   // auto on lambda
   {R"cpp(
 void foo() {
Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -572,6 +572,27 @@
   )cpp";
   EXPECT_DECLS("ConceptSpecializationExpr",
{"template  concept Fooable = true"});
+
+  // Constrained auto
+  Code = R"cpp(
+template 
+concept Fooable = true;
+
+[[Fooable]] auto i = 42;
+  )cpp";
+  EXPECT_DECLS(
+  "AutoTypeLoc",
+  {"template  concept Fooable = true"});
+
+  Code = R"cpp(
+template 
+concept Fooable = true;
+
+template<[[Fooable]] auto x> void Foo() {}
+  )cpp";
+  EXPECT_DECLS(
+  "AutoTypeLoc",
+  {"template  concept Fooable = true"});
 }
 
 TEST_F(TargetDeclTest, Coroutine) {
Index: clang-tools-extra/clangd/FindTarget.cpp
===
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -471,6 +471,12 @@
   void VisitObjCInterfaceType(const ObjCInterfaceType *OIT) {
 Outer.add(OIT->getDecl(), Flags);
   }
+  void VisitAutoType(const AutoType *T) {
+if (T->isConstrained()) {
+  Outer.add(T->getTypeConstraintConcept(), Flags);
+}
+TypeVisitor::VisitAutoType(T);
+  }
 };
 Visitor(*this, Flags).Visit(T.getTypePtr());
   }


Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -487,6 +487,46 @@
  HI.Kind = index::SymbolKind::TypeAlias;
  HI.Definition = "int";
}},
+  // constraint of constrained auto
+  {R"cpp(
+template  concept Fooable = true;
+[[Foo^able]] auto x = 1;
+)cpp",
+   [](HoverInfo &HI) {
+ HI.NamespaceScope = "";
+ HI.Name = "Fooable";
+ HI.Kind = index::SymbolKind::Concept;
+ HI.Definition = "template \n"
+ "concept Fooable = true";
+   }},
+  {R"cpp(
+template  concept Fooable = true;
+template<[[Fooa^ble]] auto x> void Foo() {}
+)cpp",
+   [](HoverInfo &HI) {
+ HI.NamespaceScope = "";
+ HI.Name = "Fooable";
+ HI.Kind = index::SymbolKind::Concept;
+ HI.Definition = "template \n"
+ "concept Fooable = true";
+   }},
+  // concept
+  {R"cpp(
+template 
+concept Fooable = requ

[PATCH] D154773: [AST] Use correct APSInt width when evaluating string literals

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

I think this is a good NFC change as it brings us one TINY step closer towards 
supporting platforms where `CHAR_BIT != 8`. But I agree with Corentin that a 
lot more work needs to happen to support that kind of target; restarting the 
discussion on the linked RFC would be a good idea if you plan to aim for full 
support.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154773

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


[clang] b454e7a - [libc] Remove GPU string functions incompatible with C++

2023-07-10 Thread Joseph Huber via cfe-commits

Author: Joseph Huber
Date: 2023-07-10T10:40:10-05:00
New Revision: b454e7aa7ceb35a0070406ebd7ffdf1ed85f5ef8

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

LOG: [libc] Remove GPU string functions incompatible with C++

These functions have definitions differing between C and C++. GNU
respects the C++ definitions while the LLVM libc does not. This causes
many bugs and the current hack creates other issues. Rather than hack
around this I'd rather temporarily disable these than regress with the
integration into other offloading languages. We lose test support for
them but we should be able to re-enable these once the `libc` headers
provide these correctly.

Reviewed By: JonChesterfield

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

Added: 


Modified: 
clang/lib/Headers/llvm_libc_wrappers/string.h
libc/config/gpu/entrypoints.txt
libc/docs/gpu/support.rst

Removed: 




diff  --git a/clang/lib/Headers/llvm_libc_wrappers/string.h 
b/clang/lib/Headers/llvm_libc_wrappers/string.h
index 0cab5615ad1300..027c415c1d0f8f 100644
--- a/clang/lib/Headers/llvm_libc_wrappers/string.h
+++ b/clang/lib/Headers/llvm_libc_wrappers/string.h
@@ -13,22 +13,11 @@
 #error "This file is for GPU offloading compilation only"
 #endif
 
-// The GNU headers provide non C-standard headers when in C++ mode. Manually
-// undefine it here so that the definitions agree with the C standard for our
-// purposes.
-#ifdef __cplusplus
-extern "C" {
-#pragma push_macro("__cplusplus")
-#undef __cplusplus
-#endif
-
+// FIXME: The GNU headers provide C++ standard compliant headers when in C++
+// mode and the LLVM libc does not. We cannot enable memchr, strchr, strchrnul,
+// strpbrk, strrchr, strstr, or strcasestr until this is addressed.
 #include_next 
 
-#pragma pop_macro("__cplusplus")
-#ifdef __cplusplus
-}
-#endif
-
 #if __has_include()
 
 #if defined(__HIP__) || defined(__CUDA__)

diff  --git a/libc/config/gpu/entrypoints.txt b/libc/config/gpu/entrypoints.txt
index 4316f8a57a8731..e475c80d26b205 100644
--- a/libc/config/gpu/entrypoints.txt
+++ b/libc/config/gpu/entrypoints.txt
@@ -21,7 +21,6 @@ set(TARGET_LIBC_ENTRYPOINTS
 libc.src.string.bcmp
 libc.src.string.bzero
 libc.src.string.memccpy
-libc.src.string.memchr
 libc.src.string.memcmp
 libc.src.string.memcpy
 libc.src.string.memmem
@@ -32,10 +31,7 @@ set(TARGET_LIBC_ENTRYPOINTS
 libc.src.string.stpcpy
 libc.src.string.stpncpy
 libc.src.string.strcasecmp
-libc.src.string.strcasestr
 libc.src.string.strcat
-libc.src.string.strchr
-libc.src.string.strchrnul
 libc.src.string.strcmp
 libc.src.string.strcpy
 libc.src.string.strcspn
@@ -47,10 +43,7 @@ set(TARGET_LIBC_ENTRYPOINTS
 libc.src.string.strncmp
 libc.src.string.strncpy
 libc.src.string.strnlen
-libc.src.string.strpbrk
-libc.src.string.strrchr
 libc.src.string.strspn
-libc.src.string.strstr
 libc.src.string.strtok
 libc.src.string.strtok_r
 

diff  --git a/libc/docs/gpu/support.rst b/libc/docs/gpu/support.rst
index bc94c833efeb70..1c7b2538fffd53 100644
--- a/libc/docs/gpu/support.rst
+++ b/libc/docs/gpu/support.rst
@@ -47,7 +47,7 @@ Function Name  Available  RPC Required
 bcmp   |check|
 bzero  |check|
 memccpy|check|
-memchr |check|
+memchr 
 memcmp |check|
 memcpy |check|
 memmove|check|
@@ -57,7 +57,7 @@ memset |check|
 stpcpy |check|
 stpncpy|check|
 strcat |check|
-strchr |check|
+strchr 
 strcmp |check|
 strcpy |check|
 strcspn|check|
@@ -68,10 +68,10 @@ strncat|check|
 strncmp|check|
 strncpy|check|
 strnlen|check|
-strpbrk|check|
-strrchr|check|
+strpbrk
+strrchr
 strspn |check|
-strstr |check|
+strstr 
 strtok |check|
 strtok_r   |check|
 strdup



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


[PATCH] D154850: [libc] Remove GPU string functions incompatible with C++

2023-07-10 Thread Joseph Huber 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 rGb454e7aa7ceb: [libc] Remove GPU string functions 
incompatible with C++ (authored by jhuber6).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154850

Files:
  clang/lib/Headers/llvm_libc_wrappers/string.h
  libc/config/gpu/entrypoints.txt
  libc/docs/gpu/support.rst


Index: libc/docs/gpu/support.rst
===
--- libc/docs/gpu/support.rst
+++ libc/docs/gpu/support.rst
@@ -47,7 +47,7 @@
 bcmp   |check|
 bzero  |check|
 memccpy|check|
-memchr |check|
+memchr 
 memcmp |check|
 memcpy |check|
 memmove|check|
@@ -57,7 +57,7 @@
 stpcpy |check|
 stpncpy|check|
 strcat |check|
-strchr |check|
+strchr 
 strcmp |check|
 strcpy |check|
 strcspn|check|
@@ -68,10 +68,10 @@
 strncmp|check|
 strncpy|check|
 strnlen|check|
-strpbrk|check|
-strrchr|check|
+strpbrk
+strrchr
 strspn |check|
-strstr |check|
+strstr 
 strtok |check|
 strtok_r   |check|
 strdup
Index: libc/config/gpu/entrypoints.txt
===
--- libc/config/gpu/entrypoints.txt
+++ libc/config/gpu/entrypoints.txt
@@ -21,7 +21,6 @@
 libc.src.string.bcmp
 libc.src.string.bzero
 libc.src.string.memccpy
-libc.src.string.memchr
 libc.src.string.memcmp
 libc.src.string.memcpy
 libc.src.string.memmem
@@ -32,10 +31,7 @@
 libc.src.string.stpcpy
 libc.src.string.stpncpy
 libc.src.string.strcasecmp
-libc.src.string.strcasestr
 libc.src.string.strcat
-libc.src.string.strchr
-libc.src.string.strchrnul
 libc.src.string.strcmp
 libc.src.string.strcpy
 libc.src.string.strcspn
@@ -47,10 +43,7 @@
 libc.src.string.strncmp
 libc.src.string.strncpy
 libc.src.string.strnlen
-libc.src.string.strpbrk
-libc.src.string.strrchr
 libc.src.string.strspn
-libc.src.string.strstr
 libc.src.string.strtok
 libc.src.string.strtok_r
 
Index: clang/lib/Headers/llvm_libc_wrappers/string.h
===
--- clang/lib/Headers/llvm_libc_wrappers/string.h
+++ clang/lib/Headers/llvm_libc_wrappers/string.h
@@ -13,22 +13,11 @@
 #error "This file is for GPU offloading compilation only"
 #endif
 
-// The GNU headers provide non C-standard headers when in C++ mode. Manually
-// undefine it here so that the definitions agree with the C standard for our
-// purposes.
-#ifdef __cplusplus
-extern "C" {
-#pragma push_macro("__cplusplus")
-#undef __cplusplus
-#endif
-
+// FIXME: The GNU headers provide C++ standard compliant headers when in C++
+// mode and the LLVM libc does not. We cannot enable memchr, strchr, strchrnul,
+// strpbrk, strrchr, strstr, or strcasestr until this is addressed.
 #include_next 
 
-#pragma pop_macro("__cplusplus")
-#ifdef __cplusplus
-}
-#endif
-
 #if __has_include()
 
 #if defined(__HIP__) || defined(__CUDA__)


Index: libc/docs/gpu/support.rst
===
--- libc/docs/gpu/support.rst
+++ libc/docs/gpu/support.rst
@@ -47,7 +47,7 @@
 bcmp   |check|
 bzero  |check|
 memccpy|check|
-memchr |check|
+memchr 
 memcmp |check|
 memcpy |check|
 memmove|check|
@@ -57,7 +57,7 @@
 stpcpy |check|
 stpncpy|check|
 strcat |check|
-strchr |check|
+strchr 
 strcmp |check|
 strcpy |check|
 strcspn|check|
@@ -68,10 +68,10 @@
 strncmp|check|
 strncpy|check|
 strnlen|check|
-strpbrk|check|
-strrchr|check|
+strpbrk
+strrchr
 strspn |check|
-strstr |check|
+strstr 
 strtok |check|
 strtok_r   |check|
 strdup
Index: libc/config/gpu/entrypoints.txt
===
--- libc/config/gpu/entrypoints.txt
+++ libc/config/gpu/entrypoints.txt
@@ -21,7 +21,6 @@
 libc.src.string.bcmp
 libc.src.string.bzero
 libc.src.string.memccpy
-libc.src.string.memchr
 libc.src.string.memcmp
 libc.src.string.memcpy
 libc.src.string.memmem
@@ -32,10 +31,7 @@
 libc.src.string.stpcpy
 libc.src.string.stpncpy
 libc.src.string.strcasecmp
-libc.src.string.strcasestr
 libc.src.string.strcat
-libc.src.string.strchr
-libc.src.string.strchrnul
 libc.src.string.strcmp
 libc.src.string.strcpy
 libc.src.string.strcspn
@@ -47,10 +43,7 @@
 libc.src.string.strncmp
 libc.src.string.strncpy
 libc.src.string.strnlen
-libc.src.stri

[clang] 86943d8 - Formula.h - fix MSVC "'clang::dataflow::Formula::numOperands': not all control paths return a value". NFC.

2023-07-10 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2023-07-10T16:55:52+01:00
New Revision: 86943d863ef66d68bf79d3e2f0ec2c205814b235

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

LOG: Formula.h - fix MSVC "'clang::dataflow::Formula::numOperands': not all 
control paths return a value". NFC.

Added: 


Modified: 
clang/include/clang/Analysis/FlowSensitive/Formula.h

Removed: 




diff  --git a/clang/include/clang/Analysis/FlowSensitive/Formula.h 
b/clang/include/clang/Analysis/FlowSensitive/Formula.h
index 0c7b1ecd02b17c..64fe8f5b630a0f 100644
--- a/clang/include/clang/Analysis/FlowSensitive/Formula.h
+++ b/clang/include/clang/Analysis/FlowSensitive/Formula.h
@@ -104,6 +104,7 @@ class alignas(const Formula *) Formula {
 case Equal:
   return 2;
 }
+llvm_unreachable("Unhandled Formula::Kind enum");
   }
 
   Kind FormulaKind;



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


[PATCH] D154856: [MemProf] Use new option/pass for profile feedback and matching

2023-07-10 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson created this revision.
tejohnson added reviewers: snehasish, davidxl.
Herald added subscribers: wlei, Enna1, ormris, wenlei, steven_wu, hiraditya.
Herald added a project: All.
tejohnson requested review of this revision.
Herald added a subscriber: MaskRay.
Herald added projects: clang, LLVM.

Previously the MemProf profile was expected to be in the same profile
file as a normal PGO profile, passed via the usual -fprofile-use=
option, and was matched in the same pass. To simplify profile
preparation, since the raw MemProf profile requires the binary for
symbolization and may be simpler to index separately from the raw PGO
profile, and also to enable providing a MemProf profile for a SamplePGO
build, separate out the MemProf feedback option and matching pass.

This patch adds the -fmemory-profile-use=${file} option, and the
provided file is passed down to LLVM and ultimately used in a new
MemProfUsePass which performs the matching of just the memory profile
contents of that file.

Note that a single profile file containing both normal PGO and MemProf
profile data is still supported, and the relevant profile data is
matched by the appropriate matching pass(es) based on which option(s)
the profile is provided with (the same profile file can be supplied to
both feedback options).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D154856

Files:
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/CodeGen/memprof.cpp
  clang/test/Driver/fmemprof.cpp
  llvm/include/llvm/Support/PGOOptions.h
  llvm/include/llvm/Transforms/Instrumentation/MemProfiler.h
  llvm/lib/LTO/LTOBackend.cpp
  llvm/lib/Passes/PassBuilder.cpp
  llvm/lib/Passes/PassBuilderPipelines.cpp
  llvm/lib/Passes/PassRegistry.def
  llvm/lib/Support/PGOOptions.cpp
  llvm/lib/Transforms/Instrumentation/MemProfiler.cpp
  llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
  llvm/test/Transforms/PGOProfile/memprof.ll
  llvm/test/Transforms/PGOProfile/memprofmissingfunc.ll
  llvm/tools/opt/NewPMDriver.cpp

Index: llvm/tools/opt/NewPMDriver.cpp
===
--- llvm/tools/opt/NewPMDriver.cpp
+++ llvm/tools/opt/NewPMDriver.cpp
@@ -176,6 +176,9 @@
   "Use sampled profile to guide PGO.")));
 static cl::opt ProfileFile("profile-file",
  cl::desc("Path to the profile."), cl::Hidden);
+static cl::opt
+MemoryProfileFile("memory-profile-file",
+  cl::desc("Path to the memory profile."), cl::Hidden);
 
 static cl::opt CSPGOKindFlag(
 "cspgo-kind", cl::init(NoCSPGO), cl::Hidden,
@@ -336,19 +339,21 @@
   std::optional P;
   switch (PGOKindFlag) {
   case InstrGen:
-P = PGOOptions(ProfileFile, "", "", FS, PGOOptions::IRInstr);
+P = PGOOptions(ProfileFile, "", "", MemoryProfileFile, FS,
+   PGOOptions::IRInstr);
 break;
   case InstrUse:
-P = PGOOptions(ProfileFile, "", ProfileRemappingFile, FS,
+P = PGOOptions(ProfileFile, "", ProfileRemappingFile, MemoryProfileFile, FS,
PGOOptions::IRUse);
 break;
   case SampleUse:
-P = PGOOptions(ProfileFile, "", ProfileRemappingFile, FS,
+P = PGOOptions(ProfileFile, "", ProfileRemappingFile, MemoryProfileFile, FS,
PGOOptions::SampleUse);
 break;
   case NoPGO:
-if (DebugInfoForProfiling || PseudoProbeForProfiling)
-  P = PGOOptions("", "", "", nullptr, PGOOptions::NoAction,
+if (DebugInfoForProfiling || PseudoProbeForProfiling ||
+!MemoryProfileFile.empty())
+  P = PGOOptions("", "", "", MemoryProfileFile, FS, PGOOptions::NoAction,
  PGOOptions::NoCSAction, DebugInfoForProfiling,
  PseudoProbeForProfiling);
 else
@@ -369,8 +374,9 @@
 P->CSAction = PGOOptions::CSIRInstr;
 P->CSProfileGenFile = CSProfileGenFile;
   } else
-P = PGOOptions("", CSProfileGenFile, ProfileRemappingFile, FS,
-   PGOOptions::NoAction, PGOOptions::CSIRInstr);
+P = PGOOptions("", CSProfileGenFile, ProfileRemappingFile,
+   /*MemoryProfile=*/"", FS, PGOOptions::NoAction,
+   PGOOptions::CSIRInstr);
 } else /* CSPGOKindFlag == CSInstrUse */ {
   if (!P) {
 errs() << "CSInstrUse needs to be together with InstrUse";
Index: llvm/test/Transforms/PGOProfile/memprofmissingfunc.ll
===
--- llvm/test/Transforms/PGOProfile/memprofmissingfunc.ll
+++ llvm/test/Transforms/PGOProfile/memprofmissingfunc.ll
@@ -11,7 +11,7 @@
 
 ; RUN: llvm-profdata merge %S/Inputs/memprof.memprofraw --profiled-binary %S/Inputs/memprof.exe -o %t.memprofdata
 
-; RUN: opt < %s -passes=pgo-instr-use -pgo-test-profile-file=%t.memprofdata -pgo-warn-missing-function -S 2>&1

[PATCH] D152632: [Clang] Add warnings for CWG2521

2023-07-10 Thread PoYao Chang via Phabricator via cfe-commits
rZhBoYao updated this revision to Diff 538678.
rZhBoYao edited the summary of this revision.
rZhBoYao added a comment.

Defaults to on for C++23 only. Enable for all the language modes in another 
patch.


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

https://reviews.llvm.org/D152632

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/IdentifierTable.h
  clang/lib/Basic/IdentifierTable.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/CXX/drs/dr25xx.cpp
  clang/www/cxx_dr_status.html

Index: clang/www/cxx_dr_status.html
===
--- clang/www/cxx_dr_status.html
+++ clang/www/cxx_dr_status.html
@@ -14933,7 +14933,7 @@
 https://cplusplus.github.io/CWG/issues/2521.html";>2521
 DR
 User-defined literals and reserved identifiers
-Unknown
+Clang 17
   
   
 https://cplusplus.github.io/CWG/issues/2522.html";>2522
Index: clang/test/CXX/drs/dr25xx.cpp
===
--- clang/test/CXX/drs/dr25xx.cpp
+++ clang/test/CXX/drs/dr25xx.cpp
@@ -1,4 +1,14 @@
-// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-unknown %s -verify
+// RUN: %clang_cc1 -std=c++98 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++23 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++2c -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
+
+#if __cplusplus < 201103L
+// expected-no-diagnostics
+#endif
 
 namespace dr2516 { // dr2516: yes
// NB: reusing 1482 test
@@ -13,9 +23,13 @@
 
 namespace dr2518 { // dr2518: 17
 
+#if __cplusplus >= 201103L
 template 
 void f(T t) {
   if constexpr (sizeof(T) != sizeof(int)) {
+#if __cplusplus < 201703L
+// expected-error@-2 {{constexpr if is a C++17 extension}}
+#endif
 static_assert(false, "must be int-sized"); // expected-error {{must be int-size}}
   }
 }
@@ -28,6 +42,9 @@
 template 
 struct S {
   static_assert(false); // expected-error {{static assertion failed}}
+#if __cplusplus < 201703L
+// expected-error@-2 {{'static_assert' with no message is a C++17 extension}}
+#endif
 };
 
 template <>
@@ -41,11 +58,28 @@
   S s2;
   S s3; // expected-note {{in instantiation of template class 'dr2518::S' requested here}}
 }
+#endif
 
 }
 
+namespace dr2521 { // dr2521: 17
+#if __cplusplus >= 202302L
+long double operator""  _\u03C0___(long double);
+// expected-warning@-1 {{identifier '_π___' preceded by space(s) in the literal operator declaration is deprecated}}
+// expected-warning@-2 {{user-defined literal suffixes containing '__' are reserved}}
+
+template  decltype(sizeof 0)
+operator""  _div();
+// expected-warning@-1 {{identifier '_div' preceded by space(s) in the literal operator declaration is deprecated}}
+
+using ::dr2521::operator"" _\u03C0___;
+using ::dr2521::operator""_div;
+// expected-warning@-2 {{identifier '_π___' preceded by space(s) in the literal operator declaration is deprecated}}
+#endif
+} // namespace dr2521
 
 namespace dr2565 { // dr2565: 16 open
+#if __cplusplus >= 202002L
   template
 concept C = requires (typename T::type x) {
   x + 1;
@@ -107,4 +141,5 @@
   // expected-error@-1{{static assertion failed}}
   // expected-note@-2{{because substituted constraint expression is ill-formed: constraint depends on a previously diagnosed expression}}
 
+#endif
 }
Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -502,13 +502,17 @@
 IdentifierInfo *II = Name.Identifier;
 ReservedIdentifierStatus Status = II->isReserved(PP.getLangOpts());
 SourceLocation Loc = Name.getEndLoc();
-if (isReservedInAllContexts(Status) &&
-!PP.getSourceManager().isInSystemHeader(Loc)) {
-  Diag(Loc, diag::warn_reserved_extern_symbol)
-  << II << static_cast(Status)
-  << FixItHint::CreateReplacement(
- Name.getSourceRange(),
- (StringRef("operator\"\"") + II->getName()).str());
+if (!PP.getSourceManager().isInSystemHeader(Loc)) {
+  if (auto Hint = FixItHint::CreateReplacement(
+  Name.getSourceRange(),
+

[PATCH] D154287: [clang-tidy] Add modernize-use-std-format check

2023-07-10 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL added inline comments.



Comment at: clang-tools-extra/clang-tidy/modernize/UseStdFormatCheck.cpp:46
+void UseStdFormatCheck::registerMatchers(MatchFinder *Finder) {
+  Finder->addMatcher(
+  callExpr(argumentCountAtLeast(1), hasArgument(0, stringLiteral()),

mikecrowe wrote:
> This matcher also matches the `operator+` call in:
> ```
> std::string A(const std::string &in)  
>   
> 
> { 
>   
> 
> return "_" + in;  
>   
> 
> } 
>   
> 
> ```
> which causes an assertion failure:
> ```
> clang-tidy: /home/mac/git/llvm-project/clang/include/clang/AST/Decl.h:275: 
> llvm::StringRef clang::NamedDecl::getName() const: Assertion 
> `Name.isIdentifier() && "Name is not a simple identifier"' failed.
> ```
> when the `StrFormatLikeFunctions` option is set to an unqualified name:
> ```
> -config="{CheckOptions: [{key: modernize-use-std-format.StrictMode, value: 
> false}, {key: modernize-use-std-format.StrFormatLikeFunctions, value: 
> 'strprintf'}]}"
> ```
> 
> `MatchesAnyListedNameMatcher::NameMatcher::match` calls `NamedDecl.getName()` 
> which presumably raises the assertion due to the `operator+` not having a 
> name (that's mentioned in the source anyway.)
> 
> I'm unsure whether I should be narrowing the matcher here so that it 
> guaranteed to not try calling `matchesAnyListedName` on something that lacks 
> a name, or whether `MatchesAnyListedNameMatcher` ought to be more tolerant of 
> being called in such situations.
> 
> I note that `HasNameMatcher` has rather more elaborate code for generating 
> the name than `MatchesAnyListedNameMatcher` does.
> 
> This problem also affects `modernize-use-std-print`, but due to the need for 
> there to be no return value in that check it requires somewhat-unlikely code 
> like:
> ```
> void A(const std::string &in)
> {
>   "_" + in;
> }
> ```
> 
> Do you have any advice? Given that this problem affects a check that has 
> already landed should I open a bug?
`unless(hasName(""))` could do a trick, or create own matcher to verify first 
if function got name.
Probably similar issues can be with cxxConversionDecl.

Other best option would be to change 
MatchesAnyListedNameMatcher::NameMatcher::match to verify if NamedDecl got name 
before calling it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154287

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


[PATCH] D153156: [Clang] CWG1473: do not err on the lack of space after operator""

2023-07-10 Thread PoYao Chang via Phabricator via cfe-commits
rZhBoYao updated this revision to Diff 538688.
rZhBoYao edited the summary of this revision.
rZhBoYao added a comment.

Reverse the dependency chain.


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

https://reviews.llvm.org/D153156

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticLexKinds.td
  clang/lib/Lex/Lexer.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/CXX/drs/dr14xx.cpp
  clang/test/CXX/drs/dr17xx.cpp
  clang/test/CXX/drs/dr25xx.cpp
  clang/test/CXX/lex/lex.literal/lex.ext/p1.cpp
  clang/test/CXX/lex/lex.literal/lex.ext/p10.cpp
  clang/test/CXX/lex/lex.literal/lex.ext/p11.cpp
  clang/test/CXX/lex/lex.literal/lex.ext/p3.cpp
  clang/test/CXX/lex/lex.literal/lex.ext/p4.cpp
  clang/test/CXX/lex/lex.literal/lex.ext/p5.cpp
  clang/test/CXX/lex/lex.literal/lex.ext/p6.cpp
  clang/test/CXX/lex/lex.literal/lex.ext/p7.cpp
  clang/test/CXX/lex/lex.literal/lex.ext/p8.cpp
  clang/test/CXX/lex/lex.literal/lex.ext/p9.cpp
  clang/test/CXX/over/over.oper/over.literal/p2.cpp
  clang/test/CXX/over/over.oper/over.literal/p3.cpp
  clang/test/CXX/over/over.oper/over.literal/p5.cpp
  clang/test/CXX/over/over.oper/over.literal/p6.cpp
  clang/test/CXX/over/over.oper/over.literal/p7.cpp
  clang/test/CXX/over/over.oper/over.literal/p8.cpp
  clang/test/CodeGenCXX/cxx11-user-defined-literal.cpp
  clang/test/CodeGenCXX/mangle-ms-cxx11.cpp
  clang/test/FixIt/fixit-c++11.cpp
  clang/test/OpenMP/amdgcn_ldbl_check.cpp
  clang/test/PCH/cxx11-user-defined-literals.cpp
  clang/test/Parser/cxx0x-literal-operators.cpp
  clang/test/Parser/cxx11-user-defined-literals.cpp
  clang/test/SemaCXX/cxx11-ast-print.cpp
  clang/test/SemaCXX/cxx11-user-defined-literals-unused.cpp
  clang/test/SemaCXX/cxx11-user-defined-literals.cpp
  clang/test/SemaCXX/cxx1y-user-defined-literals.cpp
  clang/test/SemaCXX/cxx1z-user-defined-literals.cpp
  clang/test/SemaCXX/cxx2a-consteval.cpp
  clang/test/SemaCXX/cxx98-compat.cpp
  clang/test/SemaCXX/literal-operators.cpp
  clang/test/SemaCXX/no-warn-user-defined-literals-in-system-headers.cpp
  clang/test/SemaCXX/reserved-identifier.cpp
  clang/test/SemaCXX/warn-xor-as-pow.cpp
  clang/www/cxx_dr_status.html

Index: clang/www/cxx_dr_status.html
===
--- clang/www/cxx_dr_status.html
+++ clang/www/cxx_dr_status.html
@@ -8645,7 +8645,7 @@
 https://cplusplus.github.io/CWG/issues/1473.html";>1473
 CD3
 Syntax of literal-operator-id
-Unknown
+Clang 17
   
   
 https://cplusplus.github.io/CWG/issues/1474.html";>1474
Index: clang/test/SemaCXX/warn-xor-as-pow.cpp
===
--- clang/test/SemaCXX/warn-xor-as-pow.cpp
+++ clang/test/SemaCXX/warn-xor-as-pow.cpp
@@ -19,10 +19,10 @@
 #define flexor 7
 
 #ifdef __cplusplus
-constexpr long long operator"" _xor(unsigned long long v) { return v; }
+constexpr long long operator""_xor(unsigned long long v) { return v; }
 
-constexpr long long operator"" _0b(unsigned long long v) { return v; }
-constexpr long long operator"" _0X(unsigned long long v) { return v; }
+constexpr long long operator""_0b(unsigned long long v) { return v; }
+constexpr long long operator""_0X(unsigned long long v) { return v; }
 #else
 #define xor ^ // iso646.h
 #endif
Index: clang/test/SemaCXX/reserved-identifier.cpp
===
--- clang/test/SemaCXX/reserved-identifier.cpp
+++ clang/test/SemaCXX/reserved-identifier.cpp
@@ -89,7 +89,7 @@
 long double sacrebleu = operator"" _SacreBleu(1.2); // expected-warning {{identifier '_SacreBleu' is reserved because it starts with '_' followed by a capital letter}}
 long double sangbleu = operator""_SacreBleu(1.2);   // no-warning
 
-void operator"" _lowercase(unsigned long long); // no-warning
+void operator""_lowercase(unsigned long long); // no-warning
 void operator""_lowercase(unsigned long long); // no-warning
 
 struct _BarbeRouge { // expected-warning {{identifier '_BarbeRouge' is reserved because it starts with '_' followed by a capital letter}}
Index: clang/test/SemaCXX/no-warn-user-defined-literals-in-system-headers.cpp
===
--- clang/test/SemaCXX/no-warn-user-defined-literals-in-system-headers.cpp
+++ clang/test/SemaCXX/no-warn-user-defined-literals-in-system-headers.cpp
@@ -2,4 +2,4 @@
 
 #include 
 
-void operator "" bar(long double); // expected-warning{{user-defined literal suffixes not starting with '_' are reserved}}
+void operator ""bar(long double); // expected-warning{{user-defined literal suffixes not starting with '_' are reserved}}
Index: clang/test/SemaCXX/literal-operators.cpp
===
--- clang/test/SemaCXX/literal-operators.cpp
+++ clang/test/SemaCXX/literal-operators.cpp
@@ -3,46 +3,46 @@
 #include 
 
 struct tag {
-  void operator "" _tag_bad (const char *); // expected-error 

[PATCH] D154822: Support '-fgpu-default-stream=per-thread' for NVIDIA CUDA

2023-07-10 Thread Artem Belevich via Phabricator via cfe-commits
tra added a reviewer: tra.
tra added a comment.

Looking at CUDA headers, it appears that changing only compiler-generated-glue 
may be insufficient. A lot of other CUDA API calls need to be changed to 
`_ptsz` variant and for that we need to have 
`CUDA_API_PER_THREAD_DEFAULT_STREAM` defined.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154822

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


[PATCH] D153612: [clang][analyzer] Add and change NoteTags in StdLibraryFunctionsChecker.

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

Please, let me have a look at this stack tomorrow or the day after prior 
landing it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153612

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


[PATCH] D154861: [clang][AST] Propagate the contains-errors bit to DeclRefExpr from VarDecl's initializer.

2023-07-10 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added reviewers: aaron.ballman, shafik, sammccall.
Herald added a project: All.
hokein requested review of this revision.
Herald added a project: clang.

Similar to the https://reviews.llvm.org/D86048 (it only sets the bit for C++
code), we propagate the contains-errors bit for C-code path.

Fixes https://github.com/llvm/llvm-project/issues/50236
Fixes https://github.com/llvm/llvm-project/issues/50243
Fixes https://github.com/llvm/llvm-project/issues/48636
Fixes https://github.com/llvm/llvm-project/issues/50320


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D154861

Files:
  clang/lib/AST/ComputeDependence.cpp
  clang/test/AST/ast-dump-recovery.c
  clang/test/SemaCXX/cxx11-crashes.cpp


Index: clang/test/SemaCXX/cxx11-crashes.cpp
===
--- clang/test/SemaCXX/cxx11-crashes.cpp
+++ clang/test/SemaCXX/cxx11-crashes.cpp
@@ -65,7 +65,7 @@
   struct S {}; // expected-note 3{{candidate}}
   void f() {
 S s(1, 2, 3); // expected-error {{no matching}}
-for (auto x : s) { // expected-error {{invalid range expression of}}
+for (auto x : s) {
   // We used to attempt to evaluate the initializer of this variable,
   // and crash because it has an undeduced type.
   const int &n(x);
Index: clang/test/AST/ast-dump-recovery.c
===
--- clang/test/AST/ast-dump-recovery.c
+++ clang/test/AST/ast-dump-recovery.c
@@ -126,3 +126,25 @@
   // CHECK-NEXT:   `-RecoveryExpr {{.*}} ''
   sizeof array / sizeof foo(undef);
 }
+
+// No crash on DeclRefExpr that refers to ValueDecl with invalid initializers.
+void test7() {
+  int b[] = {""()};
+
+  // CHECK:  CStyleCastExpr {{.*}} 'unsigned int' contains-errors
+  // CHECK-NEXT: | `-DeclRefExpr {{.*}} 'int[]' contains-errors
+  (unsigned) b; // GH50236
+
+  // CHECK:  BinaryOperator {{.*}} '' contains-errors '+'
+  // CHECK-NEXT: |-DeclRefExpr {{.*}} 'int[]' contains-errors
+  // CHECK-NEXT: `-IntegerLiteral {{.*}}
+  b + 1; // GH50243
+
+  // CHECK:  CallExpr {{.*}} '' contains-errors
+  // CHECK-NEXT: |-DeclRefExpr {{.*}} 'int ()' Function
+  // CHECK-NEXT: `-DeclRefExpr {{.*}} 'int[]' contains-errors
+  return c(b); // GH48636
+}
+int test8_GH50320_b[] = {""()};
+// CHECK: ArraySubscriptExpr {{.*}} 'int' contains-errors lvalue
+int test8 = test_8GH50320_b[0];
\ No newline at end of file
Index: clang/lib/AST/ComputeDependence.cpp
===
--- clang/lib/AST/ComputeDependence.cpp
+++ clang/lib/AST/ComputeDependence.cpp
@@ -489,7 +489,7 @@
   // more bullets here that we handle by treating the declaration as having a
   // dependent type if they involve a placeholder type that can't be deduced.]
   if (Type->isDependentType())
-return Deps | ExprDependence::TypeValueInstantiation;
+Deps |= ExprDependence::TypeValueInstantiation;
   else if (Type->isInstantiationDependentType())
 Deps |= ExprDependence::Instantiation;
 
@@ -525,12 +525,14 @@
   //   - it names a potentially-constant variable that is initialized with an
   // expression that is value-dependent
   if (const auto *Var = dyn_cast(Decl)) {
+if (const Expr *Init = Var->getAnyInitializer();
+Init && Init->containsErrors())
+  Deps |= ExprDependence::Error;
+
 if (Var->mightBeUsableInConstantExpressions(Ctx)) {
   if (const Expr *Init = Var->getAnyInitializer()) {
 if (Init->isValueDependent())
   Deps |= ExprDependence::ValueInstantiation;
-if (Init->containsErrors())
-  Deps |= ExprDependence::Error;
   }
 }
 


Index: clang/test/SemaCXX/cxx11-crashes.cpp
===
--- clang/test/SemaCXX/cxx11-crashes.cpp
+++ clang/test/SemaCXX/cxx11-crashes.cpp
@@ -65,7 +65,7 @@
   struct S {}; // expected-note 3{{candidate}}
   void f() {
 S s(1, 2, 3); // expected-error {{no matching}}
-for (auto x : s) { // expected-error {{invalid range expression of}}
+for (auto x : s) {
   // We used to attempt to evaluate the initializer of this variable,
   // and crash because it has an undeduced type.
   const int &n(x);
Index: clang/test/AST/ast-dump-recovery.c
===
--- clang/test/AST/ast-dump-recovery.c
+++ clang/test/AST/ast-dump-recovery.c
@@ -126,3 +126,25 @@
   // CHECK-NEXT:   `-RecoveryExpr {{.*}} ''
   sizeof array / sizeof foo(undef);
 }
+
+// No crash on DeclRefExpr that refers to ValueDecl with invalid initializers.
+void test7() {
+  int b[] = {""()};
+
+  // CHECK:  CStyleCastExpr {{.*}} 'unsigned int' contains-errors
+  // CHECK-NEXT: | `-DeclRefExpr {{.*}} 'int[]' contains-errors
+  (unsigned) b; // GH50236
+
+  // CHECK:  BinaryOperator {{.*}} '' contains-errors '+'
+  // CHECK-NEXT: |-DeclRefExpr {{.*}} 'int[]' contains-errors
+  // C

[PATCH] D153969: [clang][ExprConstant] Fix crash on uninitialized base class subobject

2023-07-10 Thread Takuya Shimizu via Phabricator via cfe-commits
hazohelet added a comment.

Ping


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

https://reviews.llvm.org/D153969

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


[PATCH] D154784: [clang] Fix crash caused by PseudoObjectExprBitfields::NumSubExprs overflow

2023-07-10 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In general, I think this is a good approach. However, it sort of kicks the can 
down the road a bit; we will still overflow the member if there are enough 
fields. Would it make sense to also add a diagnostic to Sema so that overflow 
with the widened fields is diagnosed rather than causing a crash?




Comment at: clang/include/clang/AST/Stmt.h:603
 
-// These don't need to be particularly wide, because they're
-// strictly limited by the forms of expressions we permit.
-unsigned NumSubExprs : 8;
-unsigned ResultIndex : 32 - 8 - NumExprBits;
+// Whether the PseudoObjectExpr has result.
+unsigned HasResult : 1;





Comment at: clang/test/SemaCXX/builtin-dump-struct.cpp:163
+
+// Check that PseudoObjectExprBitfields:NumSubExprs doesn't overflow.
+struct t1 {




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154784

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


[PATCH] D152632: [Clang] Add warnings for CWG2521

2023-07-10 Thread PoYao Chang via Phabricator via cfe-commits
rZhBoYao marked 6 inline comments as done.
rZhBoYao added a comment.

In D152632#4443284 , @shafik wrote:

> I am wondering why we don't fold this into `-Wreserved-identifier`

The "ud-suffix" of the user-defined-string-literal or the identifier in a 
literal-operator-id is called a literal suffix identifier.
However "//ud-suffix//" and "identifiers appearing as a //token// or 
//preprocessing-token//" are treated differently in the standard.
Thus, I don't think folding -Wuser-defined-literals into -Wreserved-identifier 
is a good idea.




Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:411
+  "identifier '%0' preceded by space(s) in the literal operator declaration "
+  "is deprecated">, InGroup, DefaultIgnore;
 def warn_reserved_module_name : Warning<

rZhBoYao wrote:
> aaron.ballman wrote:
> > Oye, I'm of two minds about `DefaultIgnore`.
> > 
> > On the one hand, this is going to fire *a lot*: 
> > https://sourcegraph.com/search?q=context:global+operator%5B%5B:space:%5D%5D*%5C%22%5C%22%5B%5B:space:%5D%5D%5BA-Za-z0-9_%5D%2B&patternType=regexp&case=yes&sm=1&groupBy=repo
> > 
> > On the other hand, if we don't warn about it being deprecated, users won't 
> > know about it, which makes it harder to do anything about it the longer we 
> > silently allow it. (We have plenty of experience with this particular 
> > flavor of pain.)
> > 
> > I think we should warn about this by default. It's under its own warning 
> > group, so users who want to ignore the warning and live dangerously can do 
> > so. And it will be silenced in system headers automatically, so issuing the 
> > diagnostic should generally be actionable for users.
> I'm thinking the same after seeing [[ 
> https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/p2863r0.html#D.9 | 
> P2863R0 § 6.9 ]]
> 
> However, a lot of tests are written in the deprecated way. I think a patch 
> removing all the whitespaces only preceding this one is needed, to not 
> clutter up this one.
Default on and diagnose for C++23 only. Enable for all the lang modes in 
https://reviews.llvm.org/D153156



Comment at: clang/include/clang/Basic/IdentifierTable.h:56
+  NotStartsWithUnderscore,
+  ContainsDoubleUnderscore,
+};

shafik wrote:
> I would think starting with a double underscore would also not be allowed, at 
> least that is my reading.
That is indeed the case.


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

https://reviews.llvm.org/D152632

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


[PATCH] D154797: [CUDA][HIP] Rename and fix `-fcuda-approx-transcendentals`

2023-07-10 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

Looks good in general.




Comment at: clang/lib/Driver/ToolChains/Clang.cpp:7221-7223
+bool UseApproxTranscendentals = false;
+if (Args.hasFlag(options::OPT_ffast_math, options::OPT_fno_fast_math,
+ false))

```
bool UseApproxTranscendentals = Args.hasFlag(options::OPT_ffast_math, 
options::OPT_fno_fast_math,  false));
```



Comment at: clang/lib/Frontend/InitPreprocessor.cpp:1292-1293
+  if (LangOpts.GPUDeviceApproxTranscendentals) {
+Builder.defineMacro(Twine("__CLANG_") + (LangOpts.HIP ? "HIP" : "CUDA") +
+"_APPROX_TRANSCENDENTALS__");
   }

We may want to rename the macro to `__CLANG_GPU_APPROX_TRANSCENDENTALS__`, too. 



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

https://reviews.llvm.org/D154797

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


[clang] bbd0d12 - Implement -frecord-command-line for XCOFF

2023-07-10 Thread Jake Egan via cfe-commits

Author: Jake Egan
Date: 2023-07-10T12:47:07-04:00
New Revision: bbd0d123d3aaa67d8bed9d16d9001b33540fc04d

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

LOG: Implement -frecord-command-line for XCOFF

This patch extends support of the option `-frecord-command-line` to XCOFF. 
XCOFF doesn’t have custom sections like ELF, so the command line data is 
emitted to a .info section instead. A C_INFO symbol is generated with the .info 
section to preserve the command line data past the link step. Multiple command 
lines are separated by newlines and null bytes. The command line data can be 
retrieved on AIX with command `what file_name`.

Reviewed By: scott.linder

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

Added: 
llvm/test/CodeGen/PowerPC/aix-command-line-metadata.ll

Modified: 
clang/lib/Driver/ToolChains/Clang.cpp
llvm/include/llvm/CodeGen/AsmPrinter.h
llvm/include/llvm/MC/MCStreamer.h
llvm/include/llvm/MC/MCXCOFFStreamer.h
llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
llvm/lib/MC/MCAsmStreamer.cpp
llvm/lib/MC/MCStreamer.cpp
llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index efdb7889bc838b..a9efab7ae07816 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -7153,7 +7153,8 @@ void Clang::ConstructJob(Compilation &C, const JobAction 
&JA,
   auto FRecordSwitches =
   Args.hasFlag(options::OPT_frecord_command_line,
options::OPT_fno_record_command_line, false);
-  if (FRecordSwitches && !Triple.isOSBinFormatELF())
+  if (FRecordSwitches && !Triple.isOSBinFormatELF() &&
+  !Triple.isOSBinFormatXCOFF())
 D.Diag(diag::err_drv_unsupported_opt_for_target)
 << 
Args.getLastArg(options::OPT_frecord_command_line)->getAsString(Args)
 << TripleStr;

diff  --git a/llvm/include/llvm/CodeGen/AsmPrinter.h 
b/llvm/include/llvm/CodeGen/AsmPrinter.h
index 8d2684698233a4..0ac497c5f8efbd 100644
--- a/llvm/include/llvm/CodeGen/AsmPrinter.h
+++ b/llvm/include/llvm/CodeGen/AsmPrinter.h
@@ -866,7 +866,7 @@ class AsmPrinter : public MachineFunctionPass {
   /// Emit llvm.ident metadata in an '.ident' directive.
   void emitModuleIdents(Module &M);
   /// Emit bytes for llvm.commandline metadata.
-  void emitModuleCommandLines(Module &M);
+  virtual void emitModuleCommandLines(Module &M);
 
   GCMetadataPrinter *getOrCreateGCPrinter(GCStrategy &S);
   void emitGlobalAlias(Module &M, const GlobalAlias &GA);

diff  --git a/llvm/include/llvm/MC/MCStreamer.h 
b/llvm/include/llvm/MC/MCStreamer.h
index 5f12fcc1c840b7..dcd84a6efda0e8 100644
--- a/llvm/include/llvm/MC/MCStreamer.h
+++ b/llvm/include/llvm/MC/MCStreamer.h
@@ -647,6 +647,12 @@ class MCStreamer {
   /// \param Sym - The symbol on the .ref directive.
   virtual void emitXCOFFRefDirective(const MCSymbol *Symbol);
 
+  /// Emit a C_INFO symbol with XCOFF embedded metadata to the .info section.
+  ///
+  /// \param Name - The embedded metadata name
+  /// \param Metadata - The embedded metadata
+  virtual void emitXCOFFCInfoSym(StringRef Name, StringRef Metadata);
+
   /// Emit an ELF .size directive.
   ///
   /// This corresponds to an assembler statement such as:

diff  --git a/llvm/include/llvm/MC/MCXCOFFStreamer.h 
b/llvm/include/llvm/MC/MCXCOFFStreamer.h
index aea2a3265d572c..a3db636e5b3a93 100644
--- a/llvm/include/llvm/MC/MCXCOFFStreamer.h
+++ b/llvm/include/llvm/MC/MCXCOFFStreamer.h
@@ -40,6 +40,10 @@ class MCXCOFFStreamer : public MCObjectStreamer {
   void emitXCOFFExceptDirective(const MCSymbol *Symbol, const MCSymbol *Trap,
 unsigned Lang, unsigned Reason,
 unsigned FunctionSize, bool hasDebug) override;
+  void emitXCOFFCInfoSym(StringRef Name, StringRef Metadata) override {
+report_fatal_error("emitXCOFFCInfoSym is not implemented yet on "
+   "object generation path");
+  }
 };
 
 } // end namespace llvm

diff  --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp 
b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
index b1e41c573a87f9..79a4e168e7e795 100644
--- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -486,6 +486,11 @@ bool AsmPrinter::doInitialization(Module &M) {
 }
   }
 
+  // On AIX, emit bytes for llvm.commandline metadata after .file so that the
+  // C_INFO symbol is preserved if any csect is kept by the linker.
+  if (TM.getTargetTriple().isOSBinFormatXCOFF())
+emitModuleCommandLines(M);
+
   GCModuleInfo *MI = getAnalysisIfAvailable();
   assert(MI && "AsmPrinter didn't require GCModuleInfo?");
   for (const auto &I : *MI)
@@ -2330,7 +2335,9 @@ bool AsmPrin

[PATCH] D153600: Implement -frecord-command-line for XCOFF

2023-07-10 Thread Jake Egan 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 rGbbd0d123d3aa: Implement -frecord-command-line for XCOFF 
(authored by Jake-Egan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153600

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  llvm/include/llvm/CodeGen/AsmPrinter.h
  llvm/include/llvm/MC/MCStreamer.h
  llvm/include/llvm/MC/MCXCOFFStreamer.h
  llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
  llvm/lib/MC/MCAsmStreamer.cpp
  llvm/lib/MC/MCStreamer.cpp
  llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
  llvm/test/CodeGen/PowerPC/aix-command-line-metadata.ll

Index: llvm/test/CodeGen/PowerPC/aix-command-line-metadata.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/aix-command-line-metadata.ll
@@ -0,0 +1,23 @@
+; RUN: llc -mtriple powerpc-ibm-aix-xcoff < %s | \
+; RUN: FileCheck --check-prefix=ASM %s
+; RUN: llc -mtriple powerpc64-ibm-aix-xcoff < %s | \
+; RUN: FileCheck --check-prefix=ASM %s
+
+; RUN: not --crash llc -mtriple powerpc-ibm-aix-xcoff -filetype=obj  < %s 2>&1 | \
+; RUN: FileCheck --check-prefix=OBJ %s
+; RUN: not --crash llc -mtriple powerpc64-ibm-aix-xcoff -filetype=obj  < %s 2>&1 | \
+; RUN: FileCheck --check-prefix=OBJ %s
+
+; Verify that llvm.commandline metadata is emitted to .info sections and that the
+; metadata is padded if necessary.
+
+; OBJ: LLVM ERROR: emitXCOFFCInfoSym is not implemented yet on object generation path
+
+; ASM: .info ".GCC.command.line", 0x003a,
+; ASM: .info , 0x40282329, 0x6f707420, 0x636c616e, 0x67202d63, 0x6f6d6d61, 0x6e64202d
+; ASM: .info , 0x6c696e65, 0x0a004028, 0x23296f70, 0x7420736f, 0x6d657468, 0x696e6720
+; ASM: .info , 0x656c7365, 0x20313233, 0x0a00
+
+!llvm.commandline = !{!0, !1}
+!0 = !{!"clang -command -line"}
+!1 = !{!"something else 123"}
Index: llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
===
--- llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
+++ llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
@@ -290,6 +290,8 @@
   bool doFinalization(Module &M) override;
 
   void emitTTypeReference(const GlobalValue *GV, unsigned Encoding) override;
+
+  void emitModuleCommandLines(Module &M) override;
 };
 
 } // end anonymous namespace
@@ -2954,6 +2956,26 @@
   return new PPCLinuxAsmPrinter(tm, std::move(Streamer));
 }
 
+void PPCAIXAsmPrinter::emitModuleCommandLines(Module &M) {
+  const NamedMDNode *NMD = M.getNamedMetadata("llvm.commandline");
+  if (!NMD || !NMD->getNumOperands())
+return;
+
+  std::string S;
+  raw_string_ostream RSOS(S);
+  for (unsigned i = 0, e = NMD->getNumOperands(); i != e; ++i) {
+const MDNode *N = NMD->getOperand(i);
+assert(N->getNumOperands() == 1 &&
+   "llvm.commandline metadata entry can have only one operand");
+const MDString *MDS = cast(N->getOperand(0));
+// Add "@(#)" to support retrieving the command line information with the
+// AIX "what" command
+RSOS << "@(#)opt " << MDS->getString() << "\n";
+RSOS.write('\0');
+  }
+  OutStreamer->emitXCOFFCInfoSym(".GCC.command.line", RSOS.str());
+}
+
 // Force static initialization.
 extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializePowerPCAsmPrinter() {
   TargetRegistry::RegisterAsmPrinter(getThePPC32Target(),
Index: llvm/lib/MC/MCStreamer.cpp
===
--- llvm/lib/MC/MCStreamer.cpp
+++ llvm/lib/MC/MCStreamer.cpp
@@ -1208,6 +1208,11 @@
  "XCOFF targets");
 }
 
+void MCStreamer::emitXCOFFCInfoSym(StringRef Name, StringRef Metadata) {
+  llvm_unreachable("emitXCOFFCInfoSym is only supported on"
+   "XCOFF targets");
+}
+
 void MCStreamer::emitELFSize(MCSymbol *Symbol, const MCExpr *Value) {}
 void MCStreamer::emitELFSymverDirective(const MCSymbol *OriginalSym,
 StringRef Name, bool KeepOriginalSym) {}
Index: llvm/lib/MC/MCAsmStreamer.cpp
===
--- llvm/lib/MC/MCAsmStreamer.cpp
+++ llvm/lib/MC/MCAsmStreamer.cpp
@@ -36,6 +36,7 @@
 #include "llvm/Support/LEB128.h"
 #include "llvm/Support/MathExtras.h"
 #include "llvm/Support/Path.h"
+#include 
 #include 
 
 using namespace llvm;
@@ -200,6 +201,7 @@
 const MCSymbol *Trap,
 unsigned Lang, unsigned Reason,
 unsigned FunctionSize, bool hasDebug) override;
+  void emitXCOFFCInfoSym(StringRef Name, StringRef Metadata) override;
 
   void emitELFSize(MCSymbol *Symbol, const MCExpr *Value) override;
   void emitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
@@ -966,6 +968,70 @@
   EmitEOL();
 }
 
+void MCAsmStreamer::emitXCOFFCInfoSym(StringRef Name, StringRef Metadata) {
+  const char InfoDirective[] = "\

[PATCH] D154861: [clang][AST] Propagate the contains-errors bit to DeclRefExpr from VarDecl's initializer.

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

LGTM, but please be sure to add a release note (and the newline at the end of 
the test file). Thank you for the fix!




Comment at: clang/test/AST/ast-dump-recovery.c:151
+int test8 = test_8GH50320_b[0];
\ No newline at end of file


Please add a newline to the end of the file. :-)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154861

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


[PATCH] D154357: [Driver] Recognize powerpc-unknown-eabi as a bare-metal toolchain

2023-07-10 Thread Jon Roelofs via Phabricator via cfe-commits
jroelofs added a comment.

I don't think those failures look related.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154357

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


[PATCH] D153156: [Clang] CWG1473: do not err on the lack of space after operator""

2023-07-10 Thread PoYao Chang via Phabricator via cfe-commits
rZhBoYao updated this revision to Diff 538707.

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

https://reviews.llvm.org/D153156

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticLexKinds.td
  clang/lib/Lex/Lexer.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/CXX/drs/dr14xx.cpp
  clang/test/CXX/drs/dr17xx.cpp
  clang/test/CXX/drs/dr25xx.cpp
  clang/test/CXX/lex/lex.literal/lex.ext/p1.cpp
  clang/test/CXX/lex/lex.literal/lex.ext/p10.cpp
  clang/test/CXX/lex/lex.literal/lex.ext/p11.cpp
  clang/test/CXX/lex/lex.literal/lex.ext/p3.cpp
  clang/test/CXX/lex/lex.literal/lex.ext/p4.cpp
  clang/test/CXX/lex/lex.literal/lex.ext/p5.cpp
  clang/test/CXX/lex/lex.literal/lex.ext/p6.cpp
  clang/test/CXX/lex/lex.literal/lex.ext/p7.cpp
  clang/test/CXX/lex/lex.literal/lex.ext/p8.cpp
  clang/test/CXX/lex/lex.literal/lex.ext/p9.cpp
  clang/test/CXX/over/over.oper/over.literal/p2.cpp
  clang/test/CXX/over/over.oper/over.literal/p3.cpp
  clang/test/CXX/over/over.oper/over.literal/p5.cpp
  clang/test/CXX/over/over.oper/over.literal/p6.cpp
  clang/test/CXX/over/over.oper/over.literal/p7.cpp
  clang/test/CXX/over/over.oper/over.literal/p8.cpp
  clang/test/CodeGenCXX/cxx11-user-defined-literal.cpp
  clang/test/CodeGenCXX/mangle-ms-cxx11.cpp
  clang/test/FixIt/fixit-c++11.cpp
  clang/test/OpenMP/amdgcn_ldbl_check.cpp
  clang/test/PCH/cxx11-user-defined-literals.cpp
  clang/test/Parser/cxx0x-literal-operators.cpp
  clang/test/Parser/cxx11-user-defined-literals.cpp
  clang/test/SemaCXX/cxx11-ast-print.cpp
  clang/test/SemaCXX/cxx11-user-defined-literals-unused.cpp
  clang/test/SemaCXX/cxx11-user-defined-literals.cpp
  clang/test/SemaCXX/cxx1y-user-defined-literals.cpp
  clang/test/SemaCXX/cxx1z-user-defined-literals.cpp
  clang/test/SemaCXX/cxx2a-consteval.cpp
  clang/test/SemaCXX/cxx98-compat.cpp
  clang/test/SemaCXX/literal-operators.cpp
  clang/test/SemaCXX/no-warn-user-defined-literals-in-system-headers.cpp
  clang/test/SemaCXX/reserved-identifier.cpp
  clang/test/SemaCXX/warn-xor-as-pow.cpp
  clang/www/cxx_dr_status.html

Index: clang/www/cxx_dr_status.html
===
--- clang/www/cxx_dr_status.html
+++ clang/www/cxx_dr_status.html
@@ -8645,7 +8645,7 @@
 https://cplusplus.github.io/CWG/issues/1473.html";>1473
 CD3
 Syntax of literal-operator-id
-Unknown
+Clang 17
   
   
 https://cplusplus.github.io/CWG/issues/1474.html";>1474
Index: clang/test/SemaCXX/warn-xor-as-pow.cpp
===
--- clang/test/SemaCXX/warn-xor-as-pow.cpp
+++ clang/test/SemaCXX/warn-xor-as-pow.cpp
@@ -19,10 +19,10 @@
 #define flexor 7
 
 #ifdef __cplusplus
-constexpr long long operator"" _xor(unsigned long long v) { return v; }
+constexpr long long operator""_xor(unsigned long long v) { return v; }
 
-constexpr long long operator"" _0b(unsigned long long v) { return v; }
-constexpr long long operator"" _0X(unsigned long long v) { return v; }
+constexpr long long operator""_0b(unsigned long long v) { return v; }
+constexpr long long operator""_0X(unsigned long long v) { return v; }
 #else
 #define xor ^ // iso646.h
 #endif
Index: clang/test/SemaCXX/reserved-identifier.cpp
===
--- clang/test/SemaCXX/reserved-identifier.cpp
+++ clang/test/SemaCXX/reserved-identifier.cpp
@@ -89,7 +89,7 @@
 long double sacrebleu = operator"" _SacreBleu(1.2); // expected-warning {{identifier '_SacreBleu' is reserved because it starts with '_' followed by a capital letter}}
 long double sangbleu = operator""_SacreBleu(1.2);   // no-warning
 
-void operator"" _lowercase(unsigned long long); // no-warning
+void operator""_lowercase(unsigned long long); // no-warning
 void operator""_lowercase(unsigned long long); // no-warning
 
 struct _BarbeRouge { // expected-warning {{identifier '_BarbeRouge' is reserved because it starts with '_' followed by a capital letter}}
Index: clang/test/SemaCXX/no-warn-user-defined-literals-in-system-headers.cpp
===
--- clang/test/SemaCXX/no-warn-user-defined-literals-in-system-headers.cpp
+++ clang/test/SemaCXX/no-warn-user-defined-literals-in-system-headers.cpp
@@ -2,4 +2,4 @@
 
 #include 
 
-void operator "" bar(long double); // expected-warning{{user-defined literal suffixes not starting with '_' are reserved}}
+void operator ""bar(long double); // expected-warning{{user-defined literal suffixes not starting with '_' are reserved}}
Index: clang/test/SemaCXX/literal-operators.cpp
===
--- clang/test/SemaCXX/literal-operators.cpp
+++ clang/test/SemaCXX/literal-operators.cpp
@@ -3,46 +3,46 @@
 #include 
 
 struct tag {
-  void operator "" _tag_bad (const char *); // expected-error {{literal operator 'operator""_tag_bad' must be in a namespace or global scope}}
-  friend void operator

[PATCH] D154784: [clang] Fix crash caused by PseudoObjectExprBitfields::NumSubExprs overflow

2023-07-10 Thread Yurong via Phabricator via cfe-commits
yronglin updated this revision to Diff 538709.
yronglin added a comment.

Address Aaron's comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154784

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/Expr.h
  clang/include/clang/AST/Stmt.h
  clang/lib/AST/Expr.cpp
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/test/SemaCXX/builtin-dump-struct.cpp

Index: clang/test/SemaCXX/builtin-dump-struct.cpp
===
--- clang/test/SemaCXX/builtin-dump-struct.cpp
+++ clang/test/SemaCXX/builtin-dump-struct.cpp
@@ -159,3 +159,28 @@
 // expected-note@#Format {{no known conversion from 'int' to 'ConstexprString &' for 1st argument}}
 }
 #endif
+
+// Check that PseudoObjectExprBitfields:NumSubExprs doesn't overflow. This
+// would previously cause a crash.
+struct t1 {
+  int v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16,
+  v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31,
+  v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46,
+  v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61,
+  v62, v63, v64, v65, v66, v67, v68, v69, v70, v71, v72, v73, v74, v75, v76,
+  v77, v78, v79, v80, v81, v82, v83, v84, v85, v86, v87, v88, v89, v90, v91,
+  v92, v93, v94, v95, v96, v97, v98, v99;
+};
+
+struct t2 {
+  t1 v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16,
+  v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31,
+  v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46,
+  v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61,
+  v62, v63, v64, v65, v66, v67, v68, v69, v70, v71, v72, v73, v74, v75, v76,
+  v77, v78, v79, v80, v81, v82, v83, v84, v85, v86, v87, v88, v89, v90, v91,
+  v92, v93, v94, v95, v96, v97, v98, v99;
+};
+
+int printf(const char *, ...);
+void f1(t2 w) { __builtin_dump_struct(&w, printf); }
Index: clang/lib/Serialization/ASTReaderStmt.cpp
===
--- clang/lib/Serialization/ASTReaderStmt.cpp
+++ clang/lib/Serialization/ASTReaderStmt.cpp
@@ -1378,8 +1378,15 @@
 void ASTStmtReader::VisitPseudoObjectExpr(PseudoObjectExpr *E) {
   VisitExpr(E);
   unsigned numSemanticExprs = Record.readInt();
-  assert(numSemanticExprs + 1 == E->PseudoObjectExprBits.NumSubExprs);
-  E->PseudoObjectExprBits.ResultIndex = Record.readInt();
+  assert(numSemanticExprs + 1 == E->getNumSubExprs());
+
+  unsigned ResultIndex = Record.readInt();
+  if (ResultIndex) {
+E->PseudoObjectExprBits.HasResult = true;
+E->PseudoObjectExprBits.ResultBits.ResultIndex = ResultIndex;
+  } else {
+E->PseudoObjectExprBits.HasResult = false;
+  }
 
   // Read the syntactic expression.
   E->getSubExprsBuffer()[0] = Record.readSubExpr();
Index: clang/lib/AST/Expr.cpp
===
--- clang/lib/AST/Expr.cpp
+++ clang/lib/AST/Expr.cpp
@@ -4842,7 +4842,8 @@
 
 PseudoObjectExpr::PseudoObjectExpr(EmptyShell shell, unsigned numSemanticExprs)
   : Expr(PseudoObjectExprClass, shell) {
-  PseudoObjectExprBits.NumSubExprs = numSemanticExprs + 1;
+  PseudoObjectExprBits.HasResult = false;
+  PseudoObjectExprBits.NumSubExprsIfNoResult = numSemanticExprs + 1;
 }
 
 PseudoObjectExpr *PseudoObjectExpr::Create(const ASTContext &C, Expr *syntax,
@@ -4873,8 +4874,15 @@
Expr *syntax, ArrayRef semantics,
unsigned resultIndex)
 : Expr(PseudoObjectExprClass, type, VK, OK_Ordinary) {
-  PseudoObjectExprBits.NumSubExprs = semantics.size() + 1;
-  PseudoObjectExprBits.ResultIndex = resultIndex + 1;
+
+  if (resultIndex == NoResult) {
+PseudoObjectExprBits.HasResult = false;
+PseudoObjectExprBits.NumSubExprsIfNoResult = semantics.size() + 1;
+  } else {
+PseudoObjectExprBits.HasResult = true;
+PseudoObjectExprBits.ResultBits.NumSubExprs = semantics.size() + 1;
+PseudoObjectExprBits.ResultBits.ResultIndex = resultIndex + 1;
+  }
 
   for (unsigned i = 0, e = semantics.size() + 1; i != e; ++i) {
 Expr *E = (i == 0 ? syntax : semantics[i-1]);
Index: clang/include/clang/AST/Stmt.h
===
--- clang/include/clang/AST/Stmt.h
+++ clang/include/clang/AST/Stmt.h
@@ -591,12 +591,26 @@
 friend class ASTStmtReader; // deserialization
 friend class PseudoObjectExpr;
 
+struct ResultBitfields {
+  // These don't need to be particularly wide, because they're
+  // strictly limited by the forms of expressions we permit.
+  unsigned NumSubExprs : 16;
+  unsigned ResultIndex : 16;
+};
+
 unsigned : NumExprBits;
 
-// These don't need to be pa

[PATCH] D86310: [X86] Align i128 to 16 bytes in x86-64 datalayout

2023-07-10 Thread Trevor Gross via Phabricator via cfe-commits
tmgross added a comment.
Herald added a subscriber: wangpc.

What is the current status of this patch? Are the reviewers here OK with this 
fix in general but just need to see changes to autoupgrade?

@craig.topper or @hvdijk since you worked on it, are you interested in doing 
these changes, or is this patch in need of new authors?


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

https://reviews.llvm.org/D86310

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


[clang] 26718d9 - [Driver][ARM] Warn about -mabi= for assembler input with -fno-integrated-as

2023-07-10 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2023-07-10T10:02:27-07:00
New Revision: 26718d931feea5b72fafa2e91a15ee5080db4c22

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

LOG: [Driver][ARM] Warn about -mabi= for assembler input with -fno-integrated-as

Similar to D153691, but for `-x assembler -fno-integrated-as`.

Close https://github.com/ClangBuiltLinux/linux/issues/1878

Reviewed By: michaelplatings

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/Gnu.cpp
clang/test/Driver/arm-abi.c
clang/test/Driver/linux-as.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Gnu.cpp 
b/clang/lib/Driver/ToolChains/Gnu.cpp
index 7d4d8e054b0a20..4c08c61eb07213 100644
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
@@ -849,6 +849,11 @@ void tools::gnutools::Assembler::ConstructJob(Compilation 
&C,
 normalizeCPUNamesForAssembler(Args, CmdArgs);
 
 Args.AddLastArg(CmdArgs, options::OPT_mfpu_EQ);
+// The integrated assembler doesn't implement e_flags setting behavior for
+// -meabi=gnu (gcc -mabi={apcs-gnu,atpcs} passes -meabi=gnu to gas). For
+// compatibility we accept but warn.
+if (Arg *A = Args.getLastArgNoClaim(options::OPT_mabi_EQ))
+  A->ignoreTargetSpecific();
 break;
   }
   case llvm::Triple::aarch64:

diff  --git a/clang/test/Driver/arm-abi.c b/clang/test/Driver/arm-abi.c
index 38076f092c8e6f..7bf5977992f65a 100644
--- a/clang/test/Driver/arm-abi.c
+++ b/clang/test/Driver/arm-abi.c
@@ -64,6 +64,8 @@
 
 // RUN: %clang --target=arm---gnueabi -mabi=aapcs -x assembler %s -### -o 
/dev/null 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-ASM %s
+// RUN: %clang --target=arm---gnueabi -mabi=aapcs -x assembler %s -### -o 
/dev/null -fno-integrated-as 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-ASM %s
 
 /// The combination -x assember & -mabi is not implemented, but for GCC 
compatibility we accept with a warning.
 // CHECK-ASM: warning: argument unused during compilation: '-mabi={{.*}}'

diff  --git a/clang/test/Driver/linux-as.c b/clang/test/Driver/linux-as.c
index 7a4d3657dc5de2..fb6de85ba105b0 100644
--- a/clang/test/Driver/linux-as.c
+++ b/clang/test/Driver/linux-as.c
@@ -15,10 +15,11 @@
 // RUN:   | FileCheck -check-prefix=CHECK-ARM-MFPU %s
 // CHECK-ARM-MFPU: as{{(.exe)?}}" "-EL" "-mfloat-abi=soft" "-mfpu=neon"
 //
-// RUN: %clang -target arm-linux -march=armv7-a -### \
+// RUN: %clang --target=arm-linux -march=armv7-a -mabi=aapcs-linux -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-ARM-MARCH %s
 // CHECK-ARM-MARCH: as{{(.exe)?}}" "-EL" "-mfloat-abi=soft" "-march=armv7-a"
+// CHECK-ARM-MARCH-NOT: "-mabi=
 //
 // RUN: %clang -target armeb-linux -mlittle-endian -mcpu=cortex-a8 -mfpu=neon 
-march=armv7-a -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \



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


[PATCH] D154736: [Driver][ARM] Warn about -mabi= for assembler input with -fno-integrated-as

2023-07-10 Thread Fangrui Song 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 rG26718d931fee: [Driver][ARM] Warn about -mabi= for assembler 
input with -fno-integrated-as (authored by MaskRay).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154736

Files:
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/test/Driver/arm-abi.c
  clang/test/Driver/linux-as.c


Index: clang/test/Driver/linux-as.c
===
--- clang/test/Driver/linux-as.c
+++ clang/test/Driver/linux-as.c
@@ -15,10 +15,11 @@
 // RUN:   | FileCheck -check-prefix=CHECK-ARM-MFPU %s
 // CHECK-ARM-MFPU: as{{(.exe)?}}" "-EL" "-mfloat-abi=soft" "-mfpu=neon"
 //
-// RUN: %clang -target arm-linux -march=armv7-a -### \
+// RUN: %clang --target=arm-linux -march=armv7-a -mabi=aapcs-linux -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-ARM-MARCH %s
 // CHECK-ARM-MARCH: as{{(.exe)?}}" "-EL" "-mfloat-abi=soft" "-march=armv7-a"
+// CHECK-ARM-MARCH-NOT: "-mabi=
 //
 // RUN: %clang -target armeb-linux -mlittle-endian -mcpu=cortex-a8 -mfpu=neon 
-march=armv7-a -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
Index: clang/test/Driver/arm-abi.c
===
--- clang/test/Driver/arm-abi.c
+++ clang/test/Driver/arm-abi.c
@@ -64,6 +64,8 @@
 
 // RUN: %clang --target=arm---gnueabi -mabi=aapcs -x assembler %s -### -o 
/dev/null 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-ASM %s
+// RUN: %clang --target=arm---gnueabi -mabi=aapcs -x assembler %s -### -o 
/dev/null -fno-integrated-as 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-ASM %s
 
 /// The combination -x assember & -mabi is not implemented, but for GCC 
compatibility we accept with a warning.
 // CHECK-ASM: warning: argument unused during compilation: '-mabi={{.*}}'
Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -849,6 +849,11 @@
 normalizeCPUNamesForAssembler(Args, CmdArgs);
 
 Args.AddLastArg(CmdArgs, options::OPT_mfpu_EQ);
+// The integrated assembler doesn't implement e_flags setting behavior for
+// -meabi=gnu (gcc -mabi={apcs-gnu,atpcs} passes -meabi=gnu to gas). For
+// compatibility we accept but warn.
+if (Arg *A = Args.getLastArgNoClaim(options::OPT_mabi_EQ))
+  A->ignoreTargetSpecific();
 break;
   }
   case llvm::Triple::aarch64:


Index: clang/test/Driver/linux-as.c
===
--- clang/test/Driver/linux-as.c
+++ clang/test/Driver/linux-as.c
@@ -15,10 +15,11 @@
 // RUN:   | FileCheck -check-prefix=CHECK-ARM-MFPU %s
 // CHECK-ARM-MFPU: as{{(.exe)?}}" "-EL" "-mfloat-abi=soft" "-mfpu=neon"
 //
-// RUN: %clang -target arm-linux -march=armv7-a -### \
+// RUN: %clang --target=arm-linux -march=armv7-a -mabi=aapcs-linux -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-ARM-MARCH %s
 // CHECK-ARM-MARCH: as{{(.exe)?}}" "-EL" "-mfloat-abi=soft" "-march=armv7-a"
+// CHECK-ARM-MARCH-NOT: "-mabi=
 //
 // RUN: %clang -target armeb-linux -mlittle-endian -mcpu=cortex-a8 -mfpu=neon -march=armv7-a -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
Index: clang/test/Driver/arm-abi.c
===
--- clang/test/Driver/arm-abi.c
+++ clang/test/Driver/arm-abi.c
@@ -64,6 +64,8 @@
 
 // RUN: %clang --target=arm---gnueabi -mabi=aapcs -x assembler %s -### -o /dev/null 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-ASM %s
+// RUN: %clang --target=arm---gnueabi -mabi=aapcs -x assembler %s -### -o /dev/null -fno-integrated-as 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-ASM %s
 
 /// The combination -x assember & -mabi is not implemented, but for GCC compatibility we accept with a warning.
 // CHECK-ASM: warning: argument unused during compilation: '-mabi={{.*}}'
Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -849,6 +849,11 @@
 normalizeCPUNamesForAssembler(Args, CmdArgs);
 
 Args.AddLastArg(CmdArgs, options::OPT_mfpu_EQ);
+// The integrated assembler doesn't implement e_flags setting behavior for
+// -meabi=gnu (gcc -mabi={apcs-gnu,atpcs} passes -meabi=gnu to gas). For
+// compatibility we accept but warn.
+if (Arg *A = Args.getLastArgNoClaim(options::OPT_mabi_EQ))
+  A->ignoreTargetSpecific();
 break;
   }
   case llvm::Triple::aarch64:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D154784: [clang] Fix crash caused by PseudoObjectExprBitfields::NumSubExprs overflow

2023-07-10 Thread Yurong via Phabricator via cfe-commits
yronglin updated this revision to Diff 538712.
yronglin marked 2 inline comments as done.
yronglin added a comment.

Update comments in PseudoObjectExpr.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154784

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/Expr.h
  clang/include/clang/AST/Stmt.h
  clang/lib/AST/Expr.cpp
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/test/SemaCXX/builtin-dump-struct.cpp

Index: clang/test/SemaCXX/builtin-dump-struct.cpp
===
--- clang/test/SemaCXX/builtin-dump-struct.cpp
+++ clang/test/SemaCXX/builtin-dump-struct.cpp
@@ -159,3 +159,28 @@
 // expected-note@#Format {{no known conversion from 'int' to 'ConstexprString &' for 1st argument}}
 }
 #endif
+
+// Check that PseudoObjectExprBitfields:NumSubExprs doesn't overflow. This
+// would previously cause a crash.
+struct t1 {
+  int v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16,
+  v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31,
+  v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46,
+  v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61,
+  v62, v63, v64, v65, v66, v67, v68, v69, v70, v71, v72, v73, v74, v75, v76,
+  v77, v78, v79, v80, v81, v82, v83, v84, v85, v86, v87, v88, v89, v90, v91,
+  v92, v93, v94, v95, v96, v97, v98, v99;
+};
+
+struct t2 {
+  t1 v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16,
+  v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31,
+  v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46,
+  v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61,
+  v62, v63, v64, v65, v66, v67, v68, v69, v70, v71, v72, v73, v74, v75, v76,
+  v77, v78, v79, v80, v81, v82, v83, v84, v85, v86, v87, v88, v89, v90, v91,
+  v92, v93, v94, v95, v96, v97, v98, v99;
+};
+
+int printf(const char *, ...);
+void f1(t2 w) { __builtin_dump_struct(&w, printf); }
Index: clang/lib/Serialization/ASTReaderStmt.cpp
===
--- clang/lib/Serialization/ASTReaderStmt.cpp
+++ clang/lib/Serialization/ASTReaderStmt.cpp
@@ -1378,8 +1378,15 @@
 void ASTStmtReader::VisitPseudoObjectExpr(PseudoObjectExpr *E) {
   VisitExpr(E);
   unsigned numSemanticExprs = Record.readInt();
-  assert(numSemanticExprs + 1 == E->PseudoObjectExprBits.NumSubExprs);
-  E->PseudoObjectExprBits.ResultIndex = Record.readInt();
+  assert(numSemanticExprs + 1 == E->getNumSubExprs());
+
+  unsigned ResultIndex = Record.readInt();
+  if (ResultIndex) {
+E->PseudoObjectExprBits.HasResult = true;
+E->PseudoObjectExprBits.ResultBits.ResultIndex = ResultIndex;
+  } else {
+E->PseudoObjectExprBits.HasResult = false;
+  }
 
   // Read the syntactic expression.
   E->getSubExprsBuffer()[0] = Record.readSubExpr();
Index: clang/lib/AST/Expr.cpp
===
--- clang/lib/AST/Expr.cpp
+++ clang/lib/AST/Expr.cpp
@@ -4842,7 +4842,8 @@
 
 PseudoObjectExpr::PseudoObjectExpr(EmptyShell shell, unsigned numSemanticExprs)
   : Expr(PseudoObjectExprClass, shell) {
-  PseudoObjectExprBits.NumSubExprs = numSemanticExprs + 1;
+  PseudoObjectExprBits.HasResult = false;
+  PseudoObjectExprBits.NumSubExprsIfNoResult = numSemanticExprs + 1;
 }
 
 PseudoObjectExpr *PseudoObjectExpr::Create(const ASTContext &C, Expr *syntax,
@@ -4873,8 +4874,15 @@
Expr *syntax, ArrayRef semantics,
unsigned resultIndex)
 : Expr(PseudoObjectExprClass, type, VK, OK_Ordinary) {
-  PseudoObjectExprBits.NumSubExprs = semantics.size() + 1;
-  PseudoObjectExprBits.ResultIndex = resultIndex + 1;
+
+  if (resultIndex == NoResult) {
+PseudoObjectExprBits.HasResult = false;
+PseudoObjectExprBits.NumSubExprsIfNoResult = semantics.size() + 1;
+  } else {
+PseudoObjectExprBits.HasResult = true;
+PseudoObjectExprBits.ResultBits.NumSubExprs = semantics.size() + 1;
+PseudoObjectExprBits.ResultBits.ResultIndex = resultIndex + 1;
+  }
 
   for (unsigned i = 0, e = semantics.size() + 1; i != e; ++i) {
 Expr *E = (i == 0 ? syntax : semantics[i-1]);
Index: clang/include/clang/AST/Stmt.h
===
--- clang/include/clang/AST/Stmt.h
+++ clang/include/clang/AST/Stmt.h
@@ -591,12 +591,26 @@
 friend class ASTStmtReader; // deserialization
 friend class PseudoObjectExpr;
 
+struct ResultBitfields {
+  // These don't need to be particularly wide, because they're
+  // strictly limited by the forms of expressions we permit.
+  unsigned NumSubExprs : 16;
+  unsigned ResultIndex : 16;
+};
+
 unsig

[PATCH] D154357: [Driver] Recognize powerpc-unknown-eabi as a bare-metal toolchain

2023-07-10 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

> At Indel, we have been building bare-metal embedded applications that run on 
> custom PowerPC and ARM systems with Clang and LLD for a couple of years now, 
> using target triples powerpc-indel-eabi, powerpc-indel-eabi750, 
> arm-indel-eabi, aarch64-indel-eabi (which I just learned from D153430 
>  is wrong and should be aarch64-indel-elf 
> instead, but that’s a different matter).

If `eabi` is not valid for `powerpc`, Clang Driver should not endorse this use 
case and we should not add positive tests for `powerpc-unknown-eabi` or 
`powerpc64le-unknown-eabi`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154357

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


[PATCH] D154784: [clang] Fix crash caused by PseudoObjectExprBitfields::NumSubExprs overflow

2023-07-10 Thread Yurong via Phabricator via cfe-commits
yronglin added a comment.

In D154784#4485752 , @aaron.ballman 
wrote:

> In general, I think this is a good approach. However, it sort of kicks the 
> can down the road a bit; we will still overflow the member if there are 
> enough fields. Would it make sense to also add a diagnostic to Sema so that 
> overflow with the widened fields is diagnosed rather than causing a crash?

Thanks you for take a look!

> Would it make sense to also add a diagnostic to Sema so that overflow with 
> the widened fields is diagnosed rather than causing a crash?

Ah, I think your are right. It doesn't make sense, As the comments for 
`PseudoObjectExprBitfields` says `These don't need to be particularly wide, 
because they're strictly limited by the forms of expressions we permit.` I 
think developers who use `PseudoObjectExprBitfields` need to be more careful.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154784

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


[PATCH] D86310: [X86] Align i128 to 16 bytes in x86-64 datalayout

2023-07-10 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

In D86310#4485837 , @tmgross wrote:

> What is the current status of this patch? Are the reviewers here OK with this 
> fix in general but just need to see changes to autoupgrade?
>
> @craig.topper or @hvdijk since you worked on it, are you interested in doing 
> these changes, or is this patch in need of new authors?

I'm no longer working on X86 so I won't be able to work on it.


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

https://reviews.llvm.org/D86310

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


[PATCH] D154357: [Driver] Recognize powerpc-unknown-eabi as a bare-metal toolchain

2023-07-10 Thread Jon Roelofs via Phabricator via cfe-commits
jroelofs added a comment.

gcc docs seem to indicate that these are valid triples:

https://gcc.gnu.org/install/specific.html#powerpc-x-eabi


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154357

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


[PATCH] D86310: [X86] Align i128 to 16 bytes in x86-64 datalayout

2023-07-10 Thread Harald van Dijk via Phabricator via cfe-commits
hvdijk added a comment.

In D86310#4485837 , @tmgross wrote:

> What is the current status of this patch? Are the reviewers here OK with this 
> fix in general but just need to see changes to autoupgrade?



> @craig.topper or @hvdijk since you worked on it, are you interested in doing 
> these changes, or is this patch in need of new authors?

The `TT.isArch64Bit()` thing I commented on is something I could change, if 
desired, but from my perspective, the suggested changes to the upgrade 
mechanism are an unreasonable amount of work considering the benefit is that it 
keeps already broken code equally broken, so I am not planning on working on 
that, sorry.


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

https://reviews.llvm.org/D86310

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


[PATCH] D153536: [Clang] Implement P2169 A nice placeholder with no name

2023-07-10 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added a comment.

In D153536#4483191 , 
@hubert.reinterpretcast wrote:

> Similarly, only one local variable out of two in the same line reported:

I can confirm that adding a lexical block scope causes both variables to be 
recorded into the debug info (thus this is a debug info generation issue unique 
to the new feature).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153536

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


[PATCH] D154856: [MemProf] Use new option/pass for profile feedback and matching

2023-07-10 Thread Snehasish Kumar via Phabricator via cfe-commits
snehasish added inline comments.



Comment at: llvm/lib/Transforms/Instrumentation/MemProfiler.cpp:912
+const TargetLibraryInfo &TLI = FAM.getResult(F);
+readMemprof(M, F, MemProfReader.get(), TLI);
+  }

I think we can we split this patch into two to make the changes clearer. 
Consider the following -- 

First move the readMemprof and its callees to MemProfiler.cpp and call it from 
the original code. Also in this step consider using Error as the return type of 
readMemprof, right now the bool returned is ignored. Using Error doesn't need 
to be fatal, we can handle it and emit a warning but it would enforce the check 
I think.

Second, add the pass to MemProfiler and all the related options/plumbing.

What do you think? 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154856

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


[clang] d77588d - [llvm][vfs] For virtual directories, use the virtual path as the real path

2023-07-10 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2023-07-10T10:41:15-07:00
New Revision: d77588df4553f0e93a74e6eab33e1ce87b576320

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

LOG: [llvm][vfs] For virtual directories, use the virtual path as the real path

A follow-up to D135841. This patch returns the virtual path for directories 
from `RedirectingFileSystem`. This ensures the contents of `Path` are the same 
as the contents of `FS->getRealPath(Path)`. This also means we can drop the 
workaround in Clang's module map canonicalization, where we couldn't use the 
real path for a directory if it resolved to a different `DirectoryEntry`. In 
addition to that, we can also avoid introducing new workaround for a bug 
triggered by the newly introduced test case.

Reviewed By: benlangmuir

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

Added: 
clang/test/ClangScanDeps/modules-canononical-module-map-case.c

Modified: 
clang/lib/Lex/ModuleMap.cpp
llvm/include/llvm/Support/VirtualFileSystem.h
llvm/lib/Support/VirtualFileSystem.cpp
llvm/unittests/Support/VirtualFileSystemTest.cpp

Removed: 




diff  --git a/clang/lib/Lex/ModuleMap.cpp b/clang/lib/Lex/ModuleMap.cpp
index cf546c4b3f9fe3..7a22fead3a0896 100644
--- a/clang/lib/Lex/ModuleMap.cpp
+++ b/clang/lib/Lex/ModuleMap.cpp
@@ -1325,18 +1325,8 @@ 
ModuleMap::canonicalizeModuleMapPath(SmallVectorImpl &Path) {
 
   // Canonicalize the directory.
   StringRef CanonicalDir = FM.getCanonicalName(*DirEntry);
-  if (CanonicalDir != Dir) {
-auto CanonicalDirEntry = FM.getDirectory(CanonicalDir);
-// Only use the canonicalized path if it resolves to the same entry as the
-// original. This is not true if there's a VFS overlay on top of a FS where
-// the directory is a symlink. The overlay would not remap the target path
-// of the symlink to the same directory entry in that case.
-if (CanonicalDirEntry && *CanonicalDirEntry == *DirEntry) {
-  bool Done = llvm::sys::path::replace_path_prefix(Path, Dir, 
CanonicalDir);
-  (void)Done;
-  assert(Done && "Path should always start with Dir");
-}
-  }
+  if (CanonicalDir != Dir)
+llvm::sys::path::replace_path_prefix(Path, Dir, CanonicalDir);
 
   // In theory, the filename component should also be canonicalized if it
   // on a case-insensitive filesystem. However, the extra canonicalization is

diff  --git a/clang/test/ClangScanDeps/modules-canononical-module-map-case.c 
b/clang/test/ClangScanDeps/modules-canononical-module-map-case.c
new file mode 100644
index 00..a7c9624e2de71c
--- /dev/null
+++ b/clang/test/ClangScanDeps/modules-canononical-module-map-case.c
@@ -0,0 +1,71 @@
+// This test checks that VFS-mapped module map path has the correct spelling
+// after canonicalization, even if it was first accessed using 
diff erent case.
+
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+
+//--- actual/One.h
+#import 
+//--- actual/Two.h
+// empty
+//--- frameworks/FW.framework/Modules/module.modulemap
+framework module FW {
+  header "One.h"
+  header "Two.h"
+}
+//--- tu.m
+#import 
+
+//--- overlay.json.in
+{
+  "version": 0,
+  "case-sensitive": "false",
+  "roots": [
+{
+  "contents": [
+{
+  "external-contents": "DIR/actual/One.h",
+  "name": "One.h",
+  "type": "file"
+},
+{
+  "external-contents": "DIR/actual/Two.h",
+  "name": "Two.h",
+  "type": "file"
+}
+  ],
+  "name": "DIR/frameworks/FW.framework/Headers",
+  "type": "directory"
+}
+  ]
+}
+
+//--- cdb.json.in
+[{
+  "directory": "DIR",
+  "file": "DIR/tu.m",
+  "command": "clang -fmodules -fmodules-cache-path=DIR/cache -ivfsoverlay 
DIR/overlay.json -F DIR/frameworks -c DIR/tu.m -o DIR/tu.o"
+}]
+
+// RUN: sed -e "s|DIR|%/t|g" %t/cdb.json.in > %t/cdb.json
+// RUN: sed -e "s|DIR|%/t|g" %t/overlay.json.in > %t/overlay.json
+// RUN: clang-scan-deps -compilation-database %t/cdb.json -format 
experimental-full > %t/result.json
+// RUN: cat %t/result.json | sed 's:\?:/:g' | FileCheck %s -DPREFIX=%/t
+
+// CHECK:  {
+// CHECK-NEXT:   "modules": [
+// CHECK-NEXT: {
+// CHECK-NEXT:   "clang-module-deps": [],
+// CHECK-NEXT:   "clang-modulemap-file": 
"[[PREFIX]]/frameworks/FW.framework/Modules/module.modulemap",
+// CHECK-NEXT:   "command-line": [
+// CHECK:  "-x"
+// CHECK-NEXT: "objective-c"
+// CHECK-NEXT: 
"[[PREFIX]]/frameworks/FW.framework/Modules/module.modulemap"
+// CHECK:],
+// CHECK-NEXT:   "context-hash": "{{.*}}",
+// CHECK-NEXT:   "file-deps": [
+// CHECK:],
+// CHECK-NEXT:   "name": "FW"
+// CHECK-NEXT: }
+// CHECK-NEXT:   ]
+// CHECK:  }

diff  --git a/llvm/include/llvm/Support/Virt

[PATCH] D135849: [llvm][vfs] For virtual directories, use the virtual path as the real path

2023-07-10 Thread Jan Svoboda 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 rGd77588df4553: [llvm][vfs] For virtual directories, use the 
virtual path as the real path (authored by jansvoboda11).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135849

Files:
  clang/lib/Lex/ModuleMap.cpp
  clang/test/ClangScanDeps/modules-canononical-module-map-case.c
  llvm/include/llvm/Support/VirtualFileSystem.h
  llvm/lib/Support/VirtualFileSystem.cpp
  llvm/unittests/Support/VirtualFileSystemTest.cpp

Index: llvm/unittests/Support/VirtualFileSystemTest.cpp
===
--- llvm/unittests/Support/VirtualFileSystemTest.cpp
+++ llvm/unittests/Support/VirtualFileSystemTest.cpp
@@ -2580,6 +2580,7 @@
   Lower->addSymlink("/link");
   IntrusiveRefCntPtr FS = getFromYAMLString(
   "{ 'use-external-names': false,\n"
+  "  'case-sensitive': false,\n"
   "  'roots': [\n"
   "{\n"
   "  'type': 'directory',\n"
@@ -2588,6 +2589,11 @@
   "  'type': 'file',\n"
   "  'name': 'bar',\n"
   "  'external-contents': '/link'\n"
+  "},\n"
+  "{\n"
+  "  'type': 'directory',\n"
+  "  'name': 'baz',\n"
+  "  'contents': []\n"
   "}\n"
   "  ]\n"
   "},\n"
@@ -2610,9 +2616,9 @@
   EXPECT_FALSE(FS->getRealPath("//root/bar", RealPath));
   EXPECT_EQ(RealPath.str(), "/symlink");
 
-  // Directories should fall back to the underlying file system is possible.
-  EXPECT_FALSE(FS->getRealPath("//dir/", RealPath));
-  EXPECT_EQ(RealPath.str(), "//dir/");
+  // Directories should return the virtual path as written in the definition.
+  EXPECT_FALSE(FS->getRealPath("//ROOT/baz", RealPath));
+  EXPECT_EQ(RealPath.str(), "//root/baz");
 
   // Try a non-existing file.
   EXPECT_EQ(FS->getRealPath("/non_existing", RealPath),
Index: llvm/lib/Support/VirtualFileSystem.cpp
===
--- llvm/lib/Support/VirtualFileSystem.cpp
+++ llvm/lib/Support/VirtualFileSystem.cpp
@@ -2239,6 +2239,14 @@
   }
 }
 
+void RedirectingFileSystem::LookupResult::getPath(
+llvm::SmallVectorImpl &Result) const {
+  Result.clear();
+  for (Entry *Parent : Parents)
+llvm::sys::path::append(Result, Parent->getName());
+  llvm::sys::path::append(Result, E->getName());
+}
+
 std::error_code
 RedirectingFileSystem::makeCanonical(SmallVectorImpl &Path) const {
   if (std::error_code EC = makeAbsolute(Path))
@@ -2257,11 +2265,14 @@
 RedirectingFileSystem::lookupPath(StringRef Path) const {
   sys::path::const_iterator Start = sys::path::begin(Path);
   sys::path::const_iterator End = sys::path::end(Path);
+  llvm::SmallVector Entries;
   for (const auto &Root : Roots) {
 ErrorOr Result =
-lookupPathImpl(Start, End, Root.get());
-if (Result || Result.getError() != llvm::errc::no_such_file_or_directory)
+lookupPathImpl(Start, End, Root.get(), Entries);
+if (Result || Result.getError() != llvm::errc::no_such_file_or_directory) {
+  Result->Parents = std::move(Entries);
   return Result;
+}
   }
   return make_error_code(llvm::errc::no_such_file_or_directory);
 }
@@ -2269,7 +2280,8 @@
 ErrorOr
 RedirectingFileSystem::lookupPathImpl(
 sys::path::const_iterator Start, sys::path::const_iterator End,
-RedirectingFileSystem::Entry *From) const {
+RedirectingFileSystem::Entry *From,
+llvm::SmallVectorImpl &Entries) const {
   assert(!isTraversalComponent(*Start) &&
  !isTraversalComponent(From->getName()) &&
  "Paths should not contain traversal components");
@@ -2298,10 +2310,12 @@
   auto *DE = cast(From);
   for (const std::unique_ptr &DirEntry :
llvm::make_range(DE->contents_begin(), DE->contents_end())) {
+Entries.push_back(From);
 ErrorOr Result =
-lookupPathImpl(Start, End, DirEntry.get());
+lookupPathImpl(Start, End, DirEntry.get(), Entries);
 if (Result || Result.getError() != llvm::errc::no_such_file_or_directory)
   return Result;
+Entries.pop_back();
   }
 
   return make_error_code(llvm::errc::no_such_file_or_directory);
@@ -2543,10 +2557,12 @@
 return P;
   }
 
-  // If we found a DirectoryEntry, still fallthrough to the original path if
-  // allowed, because directories don't have a single external contents path.
-  if (Redirection == RedirectKind::Fallthrough)
-return ExternalFS->getRealPath(CanonicalPath, Output);
+  // We found a DirectoryEntry, which does not have a single external contents
+  // path. Use the canonical virtual path.
+  if (Redirection == RedirectKind::Fallthrough) {
+Result->getPath(Output);
+return {};
+  }
   return llvm::errc::invalid_argumen

[PATCH] D154869: [Flang] [FlangRT] Implement FlangRT library as solution to Flang's runtime LLVM integration

2023-07-10 Thread Paul Scoropan via Phabricator via cfe-commits
pscoro created this revision.
Herald added subscribers: sunshaoce, mstorsjo.
Herald added a reviewer: sscalpone.
Herald added a reviewer: awarzynski.
Herald added projects: Flang, All.
pscoro requested review of this revision.
Herald added subscribers: llvm-commits, libcxx-commits, cfe-commits, jplehr, 
sstefan1, jdoerfert, MaskRay.
Herald added a reviewer: jdoerfert.
Herald added projects: clang, libc++, libc++abi, libunwind, LLVM.
Herald added a reviewer: libc++.
Herald added a reviewer: libc++abi.
Herald added a reviewer: libunwind.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D154869

Files:
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  flang-rt/CMakeLists.txt
  flang-rt/src/dummy.cpp
  flang/cmake/modules/AddFlang.cmake
  flang/include/flang/Runtime/float128.h
  flang/lib/Decimal/CMakeLists.txt
  flang/runtime/CMakeLists.txt
  flang/test/CMakeLists.txt
  flang/test/Driver/linker-flags.f90
  flang/test/lit.cfg.py
  lld/COFF/MinGW.cpp
  llvm/CMakeLists.txt
  runtimes/CMakeLists.txt

Index: runtimes/CMakeLists.txt
===
--- runtimes/CMakeLists.txt
+++ runtimes/CMakeLists.txt
@@ -19,7 +19,7 @@
 
 # We order libraries to mirror roughly how they are layered, except that compiler-rt can depend
 # on libc++, so we put it after.
-set(LLVM_DEFAULT_RUNTIMES "libc;libunwind;libcxxabi;pstl;libcxx;compiler-rt;openmp")
+set(LLVM_DEFAULT_RUNTIMES "libc;libunwind;libcxxabi;pstl;libcxx;compiler-rt;openmp;flang-rt")
 set(LLVM_SUPPORTED_RUNTIMES "${LLVM_DEFAULT_RUNTIMES};llvm-libgcc")
 set(LLVM_ENABLE_RUNTIMES "" CACHE STRING
   "Semicolon-separated list of runtimes to build, or \"all\" (${LLVM_DEFAULT_RUNTIMES}). Supported runtimes are ${LLVM_SUPPORTED_RUNTIMES}.")
Index: llvm/CMakeLists.txt
===
--- llvm/CMakeLists.txt
+++ llvm/CMakeLists.txt
@@ -149,7 +149,10 @@
 # As we migrate runtimes to using the bootstrapping build, the set of default runtimes
 # should grow as we remove those runtimes from LLVM_ENABLE_PROJECTS above.
 set(LLVM_DEFAULT_RUNTIMES "libcxx;libcxxabi;libunwind")
-set(LLVM_SUPPORTED_RUNTIMES "libc;libunwind;libcxxabi;pstl;libcxx;compiler-rt;openmp;llvm-libgcc")
+if ("flang" IN_LIST LLVM_ENABLE_PROJECTS)
+  set(LLVM_DEFAULT_RUNTIMES "libcxx;libcxxabi;libunwind;flang-rt")
+endif()
+set(LLVM_SUPPORTED_RUNTIMES "libc;libunwind;libcxxabi;pstl;libcxx;compiler-rt;openmp;llvm-libgcc;flang-rt")
 set(LLVM_ENABLE_RUNTIMES "" CACHE STRING
   "Semicolon-separated list of runtimes to build, or \"all\" (${LLVM_DEFAULT_RUNTIMES}). Supported runtimes are ${LLVM_SUPPORTED_RUNTIMES}.")
 if(LLVM_ENABLE_RUNTIMES STREQUAL "all")
Index: lld/COFF/MinGW.cpp
===
--- lld/COFF/MinGW.cpp
+++ lld/COFF/MinGW.cpp
@@ -50,8 +50,7 @@
   "libc++",
   "libc++abi",
   "libFortran_main",
-  "libFortranRuntime",
-  "libFortranDecimal",
+  "libFlangRT",
   "libunwind",
   "libmsvcrt",
   "libucrtbase",
Index: flang/test/lit.cfg.py
===
--- flang/test/lit.cfg.py
+++ flang/test/lit.cfg.py
@@ -153,19 +153,16 @@
 # the C++ runtime libraries. For this we need a C compiler. If for some reason
 # we don't have one, we can just disable the test.
 if config.cc:
-libruntime = os.path.join(config.flang_lib_dir, "libFortranRuntime.a")
-libdecimal = os.path.join(config.flang_lib_dir, "libFortranDecimal.a")
+libruntime = os.path.join(config.flang_lib_dir, "libFlangRT.a")
 include = os.path.join(config.flang_src_dir, "include")
 
 if (
 os.path.isfile(libruntime)
-and os.path.isfile(libdecimal)
 and os.path.isdir(include)
 ):
 config.available_features.add("c-compiler")
 tools.append(ToolSubst("%cc", command=config.cc, unresolved="fatal"))
 tools.append(ToolSubst("%libruntime", command=libruntime, unresolved="fatal"))
-tools.append(ToolSubst("%libdecimal", command=libdecimal, unresolved="fatal"))
 tools.append(ToolSubst("%include", command=include, unresolved="fatal"))
 
 # Add all the tools and their substitutions (if applicable). Use the search paths provided for
Index: flang/test/Driver/linker-flags.f90
===
--- flang/test/Driver/linker-flags.f90
+++ flang/test/Driver/linker-flags.f90
@@ -24,21 +24,18 @@
 ! GNU-LABEL:  "{{.*}}ld{{(\.exe)?}}"
 ! GNU-SAME: "[[object_file]]"
 ! GNU-SAME: -lFortran_main
-! GNU-SAME: -lFortranRuntime
-! GNU-SAME: -lFortranDecimal
+! GNU-SAME: -lFlangRT
 ! GNU-SAME: -lm
 
 ! DARWIN-LABEL:  "{{.*}}ld{{(\.exe)?}}"
 ! DARWIN-SAME: "[[object_file]]"
 ! DARWIN-SAME: -lFortran_main
-! DARWIN-SAME: -lFortranRuntime
-! DARWIN-SAME: -lFortranDecimal
+! DARWIN-SAME: -lFlangRT
 
 ! MINGW-LABEL:  "{{.*}}ld{{(\.exe)?}}"
 ! MINGW-SAME: "[[object_file]]"
 ! MINGW-SAME: -lFortran_main
-! MIN

[PATCH] D154856: [MemProf] Use new option/pass for profile feedback and matching

2023-07-10 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson added inline comments.



Comment at: llvm/lib/Transforms/Instrumentation/MemProfiler.cpp:912
+const TargetLibraryInfo &TLI = FAM.getResult(F);
+readMemprof(M, F, MemProfReader.get(), TLI);
+  }

snehasish wrote:
> I think we can we split this patch into two to make the changes clearer. 
> Consider the following -- 
> 
> First move the readMemprof and its callees to MemProfiler.cpp and call it 
> from the original code. Also in this step consider using Error as the return 
> type of readMemprof, right now the bool returned is ignored. Using Error 
> doesn't need to be fatal, we can handle it and emit a warning but it would 
> enforce the check I think.
> 
> Second, add the pass to MemProfiler and all the related options/plumbing.
> 
> What do you think? 
Ok let me try that. I think actually readMemprof should have a void return. The 
only time we are returning false the error has already been handled within 
readMemprof itself.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154856

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


[PATCH] D154797: [CUDA][HIP] Rename and fix `-fcuda-approx-transcendentals`

2023-07-10 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/test/Driver/hip-options.hip:179
+// RUN: %clang -### --target=x86_64-unknown-linux-gnu -nogpuinc -nogpulib 
-fgpu-approx-transcendentals \
+// RUN:   --cuda-gpu-arch=gfx906  %s 2>&1 | FileCheck -check-prefixes=APPROX %s
+

excess spaces before `%s`

ditto below

Prefer `--check-prefix=` when there is one single check.


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

https://reviews.llvm.org/D154797

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


[PATCH] D153969: [clang][ExprConstant] Fix crash on uninitialized base class subobject

2023-07-10 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/docs/ReleaseNotes.rst:382-383
   on overload resolution, when the actual reason for the failure is loss of 
other qualifiers.
+- Clang contexpr evaluator now displays notes as well as an error when a 
constructor
+  of base class is not called in the constructor of its derived class.
 





Comment at: clang/lib/AST/ExprConstant.cpp:2422
+  << BS.getType();
+  Info.Note(BS.getBeginLoc(), 
diag::note_constexpr_base_inherited_here);
+  return false;

hazohelet wrote:
> hazohelet wrote:
> > tbaeder wrote:
> > > Can you pass `<< BS.getSourceRange()` here? Does that improve things?
> > Currently, `DiagLoc` points to the variable declaration and the 
> > `BS.getSourceRange` covers the line where the base class is inherited. This 
> > causes distant source range and thus unnecessarily many lines of snippet 
> > printing.
> > e.g.
> > ```
> > struct Base {
> >   Base() = delete;
> > };
> > struct Derived : Base {
> >   constexpr Derived() {}
> > };
> > constexpr Derived dd;
> > ```
> > Output:
> > ```
> > source.cpp:7:19: error: constexpr variable 'dd' must be initialized by a 
> > constant expression
> > 7 | constexpr Derived dd;
> >   |   ^~
> > source.cpp:7:19: note: constructor of base class 'Base' is not called
> > 7 | struct Derived : Base {
> >   |  
> > 8 |   constexpr Derived() {}
> > 9 | };
> >10 | constexpr Derived dd;
> >   |   ^
> > source.cpp:4:18: note: base class inherited here
> > 4 | struct Derived : Base {
> >   |  ^
> > ```
> > (The line numbers seem incorrect but is already reported in 
> > https://github.com/llvm/llvm-project/issues/63524)
> > 
> > I think we don't need two notes here because the error is already pointing 
> > to the variable declaration. Having something like the following would be 
> > succint.
> > ```
> > source.cpp:7:19: error: constexpr variable 'dd' must be initialized by a 
> > constant expression
> > 7 | constexpr Derived dd;
> >   |   ^~
> > source.cpp:4:18: note: constructor of base class 'Base' is not called
> > 4 | struct Derived : Base {
> >   |  ^~~~
> > ```
> > Providing source range would be beneficial because the inherited class 
> > often spans in a few lines (the code in the crashing report, for example)
> Sorry, I was looking at the line above. The distant source range problem 
> doesn't occur.
> 
> I tested another input
> ```
> struct Base {
>   Base() = delete;
>   constexpr Base(int){}
> };
> 
> struct Derived : Base {
>   constexpr Derived() {}
>   constexpr Derived(int n): Base(n) {}
> };
> 
> constexpr Derived darr[3] = {1, Derived(), 3};
> ```
> expecting that the `DiagLoc` points to the second initializer `Derived()`, 
> but it pointed to the same location as the error, so I'm still in favor of 
> the idea of having a single note here.
Erich's suggestion in 
https://github.com/llvm/llvm-project/issues/63496#issuecomment-1607415201 was 
to continue to evaluate the constructor because there may be further follow-on 
diagnostics that are relevant and not related to the base class subobject. I 
tend to agree -- is there a reason why you're not doing that here?



Comment at: clang/test/SemaCXX/constexpr-subobj-initialization.cpp:30
+} // namespace baseclass_uninit
+

I'd also like to see a test case with more interesting base class specifiers:
```
struct Foo {
  constexpr Foo();
};

struct Bar : protected Foo {
  int i;
  constexpr Bar() : i(12) {}
}

template 
struct Baz {
  constexpr Baz();
};

struct Quux : Baz, private Bar {
  int i;
  constexpr Quux() : i(12) {}
}
```


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

https://reviews.llvm.org/D153969

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


[PATCH] D154869: [Flang] [FlangRT] Implement FlangRT library as solution to Flang's runtime LLVM integration

2023-07-10 Thread Paul Scoropan via Phabricator via cfe-commits
pscoro added inline comments.



Comment at: flang/cmake/modules/AddFlang.cmake:68
   llvm_add_library(${name} ${LIBTYPE} ${ARG_UNPARSED_ARGUMENTS} ${srcs})
+  set_target_properties(${name} PROPERTIES POSITION_INDEPENDENT_CODE ON)
 

This is something I am still investigating.

PIC is needed for the object libraries if FlangRT is being built as shared. I 
am thinking I will add a condition for this to only be enabled for 
FortranRuntime and FortranDecimalRT. Also, if my understanding is correct, if 
we build FlangRT as static this change may also not be needed (and keeping it 
may be slightly less optimal?), so I may ad a condition for this as well. 

My understanding of PIC is limited so if anybody sees any problems with my 
understanding please let me know.



Comment at: flang/include/flang/Runtime/float128.h:42
  */
-#if __x86_64__
-#if __GNUC__ >= 7 || __clang_major__ >= 7
-#define HAS_FLOAT128 1
-#endif
-#elif defined __PPC__ && __GNUC__ >= 8
-#define HAS_FLOAT128 1
-#endif
+//#if __x86_64__
+//#if __GNUC__ >= 7 || __clang_major__ >= 7

Entirely uncertain why this code was giving me issues during my testing. I 
commented it out for the time being but I will take a closer look later. I hope 
that it is related to my setup and not something about the patch itself, 
however I will have to investigate further before I can draw any conclusions.



Comment at: flang/lib/Decimal/CMakeLists.txt:62
+if ("flang-rt" IN_LIST LLVM_ENABLE_RUNTIMES OR FLANG_RT_STANDALONE_BUILD)
+  add_flang_library(FortranDecimalRT STATIC INSTALL_WITH_TOOLCHAIN
+binary-to-decimal.cpp

The code in AddFlang.cmake seems to build object libraries for calls to 
`add_flang_library` by default when STATIC argument is passed.



Comment at: flang/runtime/CMakeLists.txt:252
+if ("flang-rt" IN_LIST LLVM_ENABLE_RUNTIMES)
+  add_flang_library(FortranRuntime STATIC
+${sources}

The code in AddFlang.cmake seems to build object libraries for calls to 
`add_flang_library` by default when STATIC argument is passed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154869

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


  1   2   3   >