[PATCH] D156239: [X86] Support -march=arrowlake, arrowlake-s, lunarlake

2023-07-27 Thread Freddy, Ye via Phabricator via cfe-commits
FreddyYe updated this revision to Diff 544625.
FreddyYe marked an inline comment as done.
FreddyYe added a comment.

address comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156239

Files:
  clang/lib/Basic/Targets/X86.cpp
  clang/test/CodeGen/attr-cpuspecific-cpus.c
  clang/test/CodeGen/attr-target-mv.c
  clang/test/CodeGen/target-builtin-noerror.c
  clang/test/Driver/x86-march.c
  clang/test/Misc/target-invalid-cpu-note.c
  clang/test/Preprocessor/predefined-arch-macros.c
  compiler-rt/lib/builtins/cpu_model.c
  llvm/include/llvm/TargetParser/X86TargetParser.def
  llvm/include/llvm/TargetParser/X86TargetParser.h
  llvm/lib/Target/X86/X86.td
  llvm/lib/TargetParser/Host.cpp
  llvm/lib/TargetParser/X86TargetParser.cpp
  llvm/test/CodeGen/X86/cpus-intel.ll

Index: llvm/test/CodeGen/X86/cpus-intel.ll
===
--- llvm/test/CodeGen/X86/cpus-intel.ll
+++ llvm/test/CodeGen/X86/cpus-intel.ll
@@ -32,6 +32,10 @@
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=graniterapids 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=graniterapids-d 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=emeraldrapids 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=arrowlake 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=arrowlake-s 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=arrowlake_s 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=lunarlake 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 
 ; RUN: llc < %s -o /dev/null -mtriple=x86_64-unknown-unknown -mcpu=nocona 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=x86_64-unknown-unknown -mcpu=core2 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
@@ -90,6 +94,10 @@
 ; RUN: llc < %s -o /dev/null -mtriple=x86_64-unknown-unknown -mcpu=grandridge 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=x86_64-unknown-unknown -mcpu=graniterapids 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=x86_64-unknown-unknown -mcpu=graniterapids-d 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=x86_64-unknown-unknown -mcpu=arrowlake 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=x86_64-unknown-unknown -mcpu=arrowlake-s 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=x86_64-unknown-unknown -mcpu=arrowlake_s 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=x86_64-unknown-unknown -mcpu=lunarlake 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 
 define void @foo() {
   ret void
Index: llvm/lib/TargetParser/X86TargetParser.cpp
===
--- llvm/lib/TargetParser/X86TargetParser.cpp
+++ llvm/lib/TargetParser/X86TargetParser.cpp
@@ -237,6 +237,8 @@
 FeatureENQCMD | FeatureAVXNECONVERT | FeatureAVXVNNIINT8;
 constexpr FeatureBitset FeaturesGrandridge =
 FeaturesSierraforest | FeatureRAOINT;
+constexpr FeatureBitset FeaturesArrowlakeS = FeaturesSierraforest |
+FeatureAVXVNNIINT16 | FeatureSHA512 | FeatureSM3 | FeatureSM4;
 
 // Geode Processor.
 constexpr FeatureBitset FeaturesGeode =
@@ -422,6 +424,12 @@
   { {"raptorlake"}, CK_Raptorlake, FEATURE_AVX2, FeaturesAlderlake, 'p', false },
   // Meteorlake microarchitecture based processors.
   { {"meteorlake"}, CK_Meteorlake, FEATURE_AVX2, FeaturesAlderlake, 'p', false },
+  // Arrowlake microarchitecture based processors.
+  { {"arrowlake"}, CK_Arrowlake, FEATURE_AVX2, FeaturesSierraforest, 'p', false },
+  { {"arrowlake-s"}, CK_ArrowlakeS, FEATURE_AVX2, FeaturesArrowlakeS, '\0', false },
+  { {"arrowlake_s"}, CK_ArrowlakeS, FEATURE_AVX2, FeaturesArrowlakeS, 'p', true },
+  // Lunarlake microarchitecture based processors.
+  { {"lunarlake"}, CK_Lunarlake, FEATURE_AVX2, FeaturesArrowlakeS, 'p', false },
   // Sierraforest microarchitecture based processors.
   { {"sierraforest"}, CK_Sierraforest, FEATURE_AVX2, FeaturesSierraforest, 'p', false },
   // Grandridge microarchitecture based processors.
Index: llvm/lib/TargetParser/Host.cpp
===
--- llvm/lib/TargetPa

[PATCH] D142660: [AIX] supporting -X options for llvm-ranlib in AIX OS

2023-07-27 Thread James Henderson via Phabricator via cfe-commits
jhenderson added a comment.

In D142660#4535693 , @stephenpeckham 
wrote:

> I don't see any reason to check the OBJECT_MODE environment variable if the 
> -X flag is used.  What would the error be:  "You specified a valid -X flag, 
> but by the way, OBJECT_MODE is set to an invalid value"?

The error would be "invalid value for OBJECT_MODE environment variable" (or 
something to that effect), which would mean the user fixes their environment, 
just the same as if they hadn't used -X. I just want to emphasise though that 
my main concern is that llvm-ar and llvm-ranlib are being inconsistent - one of 
them checks the environment variable first, the other checks the command-line 
option first, and this seems wrong - they should do the same thing. By reading 
and checking the environment variable first, it simplifies the code logic (no 
need for `HasAIXXOption` for example).

As an alternative (but I think adds unnecessary complexity, due to needing an 
extra variable), you could have both tools read the environment variable into a 
string variable, then, if the -X option is present, overwrite that variable, 
and finally feed that string into the parsing code that converts into a 
`BitMode` value. If the string is invalid, the parsing code could report an 
error along the lines of "invalid OBJECT_MODE or -X option value".

> I think all the commands that examine XCOFF files (llvm-ar, lllvm-ranlib, 
> llvm-readobj, llvm-objdump, llvm-nm, etc.) should recognize "32", "64", 
> "32_64", and "any".  I don't think it's necessary to recognize "d64", even if 
> AIX commands do.  In addition, I wouldn't bother recognizing an XCOFF file 
> with the magic number for a discontinued 64-bit object.  That means that 
> "32_64" and "any" have the same behavior.   If -X is specified and does not 
> have one of the 4 specified values, a usage message should be printed.  If -X 
> is not specified but OBJECT_MODE is in the environment, a message should be 
> printed if the value is not one of the 4 specified values.

Yes, to be clear, I'm not advocating that "d64" support should be added (I'm 
not opposed to it, should there be a use-case for it either).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142660

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


[PATCH] D156247: [Clang] Add a warning on uses of coroutine keywords

2023-07-27 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added a comment.

FYI, for https://github.com/llvm/llvm-project/issues/56301, I've posted 
https://discourse.llvm.org/t/rfc-a-new-aapass-for-coroutines-or-a-simple-workaround/72336
 to make some initial progress.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156247

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


[PATCH] D155165: [clang][Interp] Fully serialize Floatings to bytes

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

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155165

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


[clang] f443838 - [clang][ASTImporter] Fix import of recursive field initializer.

2023-07-27 Thread Balázs Kéri via cfe-commits

Author: Balázs Kéri
Date: 2023-07-27T09:34:34+02:00
New Revision: f4438385d4d9b7e652b41f908250e55f75695ab6

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

LOG: [clang][ASTImporter] Fix import of recursive field initializer.

Import of field initializers with circular reference was not working,
this is fixed now.

Fixes issue #63120

Reviewed By: steakhal

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

Added: 


Modified: 
clang/lib/AST/ASTImporter.cpp
clang/unittests/AST/ASTImporterTest.cpp

Removed: 




diff  --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp
index 39c7a8fa397048..eb8e28ccd3e622 100644
--- a/clang/lib/AST/ASTImporter.cpp
+++ b/clang/lib/AST/ASTImporter.cpp
@@ -3925,7 +3925,6 @@ ExpectedDecl ASTNodeImporter::VisitFieldDecl(FieldDecl 
*D) {
   auto ToTInfo = importChecked(Err, D->getTypeSourceInfo());
   auto ToBitWidth = importChecked(Err, D->getBitWidth());
   auto ToInnerLocStart = importChecked(Err, D->getInnerLocStart());
-  auto ToInitializer = importChecked(Err, D->getInClassInitializer());
   if (Err)
 return std::move(Err);
   const Type *ToCapturedVLAType = nullptr;
@@ -3948,12 +3947,24 @@ ExpectedDecl ASTNodeImporter::VisitFieldDecl(FieldDecl 
*D) {
 return std::move(Err);
   ToField->setAccess(D->getAccess());
   ToField->setLexicalDeclContext(LexicalDC);
-  if (ToInitializer)
-ToField->setInClassInitializer(ToInitializer);
   ToField->setImplicit(D->isImplicit());
   if (ToCapturedVLAType)
 ToField->setCapturedVLAType(cast(ToCapturedVLAType));
   LexicalDC->addDeclInternal(ToField);
+  // Import initializer only after the field was created, it may have recursive
+  // reference to the field.
+  auto ToInitializer = importChecked(Err, D->getInClassInitializer());
+  if (Err)
+return std::move(Err);
+  if (ToInitializer) {
+auto *AlreadyImported = ToField->getInClassInitializer();
+if (AlreadyImported)
+  assert(ToInitializer == AlreadyImported &&
+ "Duplicate import of in-class initializer.");
+else
+  ToField->setInClassInitializer(ToInitializer);
+  }
+
   return ToField;
 }
 

diff  --git a/clang/unittests/AST/ASTImporterTest.cpp 
b/clang/unittests/AST/ASTImporterTest.cpp
index 3a1058f5e3fe90..c6ae2693930409 100644
--- a/clang/unittests/AST/ASTImporterTest.cpp
+++ b/clang/unittests/AST/ASTImporterTest.cpp
@@ -8165,6 +8165,83 @@ TEST_P(ASTImporterOptionSpecificTestBase,
   EXPECT_TRUE(ToX->getInClassInitializer());
 }
 
+TEST_P(ASTImporterOptionSpecificTestBase, ImportRecursiveFieldInitializer) {
+  const char *Code =
+  R"(
+  struct AP_TECS;
+
+  struct AP_Landing {
+AP_TECS *TECS_controller;
+  };
+
+  struct AP_TECS {
+AP_Landing landing;
+  };
+
+  class Plane {
+AP_TECS TECS_controller{landing};
+AP_Landing landing{&TECS_controller};
+  };
+  )";
+  Decl *FromTU = getTuDecl(Code, Lang_CXX11);
+
+  auto *FromR = FirstDeclMatcher().match(
+  FromTU, cxxRecordDecl(hasName("Plane")));
+  for (FieldDecl *F : FromR->fields())
+EXPECT_TRUE(F->getInClassInitializer());
+  auto *ToR = Import(FromR, Lang_CXX11);
+  for (FieldDecl *F : ToR->fields())
+EXPECT_TRUE(F->getInClassInitializer());
+}
+
+TEST_P(ASTImporterOptionSpecificTestBase, ImportFieldInitializerWithItself) {
+  const char *Code =
+  R"(
+  class A {
+int a{a};
+  };
+  )";
+  Decl *FromTU = getTuDecl(Code, Lang_CXX11);
+  auto *FromA = FirstDeclMatcher().match(
+  FromTU, cxxRecordDecl(hasName("A")));
+  EXPECT_TRUE(FromA->field_begin()->getInClassInitializer());
+  auto *ToA = Import(FromA, Lang_CXX11);
+  EXPECT_TRUE(ToA->field_begin()->getInClassInitializer());
+}
+
+TEST_P(ASTImporterOptionSpecificTestBase, ImportRecursiveFieldInitializer1) {
+  // FIXME: This is a example of recursive field initialization that is not
+  // supported.
+  // The following import chain occurs (not complete):
+  // import of A => A.a => in-class initializer of A.a => ref_B() => B => B.b
+  // => in-class initializer of B.b => ref_A() => CXXConstructExpr for A =>
+  // CXXDefaultInitExpr for A.a => in-class initializer of A.a
+  // in-class initializer of A.a is created in two 
diff erent instances in this
+  // case (import of FieldDecl and CXXDefaultInitExpr). Probably not a big
+  // problem because it is an Expr (the second construction can be ignored
+  // instead of assert). But such recursive init code should not occur in
+  // practice.
+  const char *Code =
+  R"(
+  static int ref_A();
+  static int ref_B();
+  struct A {
+int a = ref_B();
+  };
+  struct B {
+int b = ref_A();
+  };
+  int ref_B() { B b; return b.b; }
+  int ref_A() { A a; return a.a;

[PATCH] D155574: [clang][ASTImporter] Fix import of recursive field initializer.

2023-07-27 Thread Balázs Kéri via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf4438385d4d9: [clang][ASTImporter] Fix import of recursive 
field initializer. (authored by balazske).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155574

Files:
  clang/lib/AST/ASTImporter.cpp
  clang/unittests/AST/ASTImporterTest.cpp

Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -8165,6 +8165,83 @@
   EXPECT_TRUE(ToX->getInClassInitializer());
 }
 
+TEST_P(ASTImporterOptionSpecificTestBase, ImportRecursiveFieldInitializer) {
+  const char *Code =
+  R"(
+  struct AP_TECS;
+
+  struct AP_Landing {
+AP_TECS *TECS_controller;
+  };
+
+  struct AP_TECS {
+AP_Landing landing;
+  };
+
+  class Plane {
+AP_TECS TECS_controller{landing};
+AP_Landing landing{&TECS_controller};
+  };
+  )";
+  Decl *FromTU = getTuDecl(Code, Lang_CXX11);
+
+  auto *FromR = FirstDeclMatcher().match(
+  FromTU, cxxRecordDecl(hasName("Plane")));
+  for (FieldDecl *F : FromR->fields())
+EXPECT_TRUE(F->getInClassInitializer());
+  auto *ToR = Import(FromR, Lang_CXX11);
+  for (FieldDecl *F : ToR->fields())
+EXPECT_TRUE(F->getInClassInitializer());
+}
+
+TEST_P(ASTImporterOptionSpecificTestBase, ImportFieldInitializerWithItself) {
+  const char *Code =
+  R"(
+  class A {
+int a{a};
+  };
+  )";
+  Decl *FromTU = getTuDecl(Code, Lang_CXX11);
+  auto *FromA = FirstDeclMatcher().match(
+  FromTU, cxxRecordDecl(hasName("A")));
+  EXPECT_TRUE(FromA->field_begin()->getInClassInitializer());
+  auto *ToA = Import(FromA, Lang_CXX11);
+  EXPECT_TRUE(ToA->field_begin()->getInClassInitializer());
+}
+
+TEST_P(ASTImporterOptionSpecificTestBase, ImportRecursiveFieldInitializer1) {
+  // FIXME: This is a example of recursive field initialization that is not
+  // supported.
+  // The following import chain occurs (not complete):
+  // import of A => A.a => in-class initializer of A.a => ref_B() => B => B.b
+  // => in-class initializer of B.b => ref_A() => CXXConstructExpr for A =>
+  // CXXDefaultInitExpr for A.a => in-class initializer of A.a
+  // in-class initializer of A.a is created in two different instances in this
+  // case (import of FieldDecl and CXXDefaultInitExpr). Probably not a big
+  // problem because it is an Expr (the second construction can be ignored
+  // instead of assert). But such recursive init code should not occur in
+  // practice.
+  const char *Code =
+  R"(
+  static int ref_A();
+  static int ref_B();
+  struct A {
+int a = ref_B();
+  };
+  struct B {
+int b = ref_A();
+  };
+  int ref_B() { B b; return b.b; }
+  int ref_A() { A a; return a.a; }
+  )";
+  Decl *FromTU = getTuDecl(Code, Lang_CXX11);
+  auto *FromA = FirstDeclMatcher().match(
+  FromTU, cxxRecordDecl(hasName("A")));
+  EXPECT_TRUE(FromA->field_begin()->getInClassInitializer());
+  // auto *ToA = Import(FromA, Lang_CXX11);
+  // EXPECT_TRUE(ToA->field_begin()->getInClassInitializer());
+}
+
 TEST_P(ASTImporterOptionSpecificTestBase, isNewDecl) {
   Decl *FromTU = getTuDecl(
   R"(
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -3925,7 +3925,6 @@
   auto ToTInfo = importChecked(Err, D->getTypeSourceInfo());
   auto ToBitWidth = importChecked(Err, D->getBitWidth());
   auto ToInnerLocStart = importChecked(Err, D->getInnerLocStart());
-  auto ToInitializer = importChecked(Err, D->getInClassInitializer());
   if (Err)
 return std::move(Err);
   const Type *ToCapturedVLAType = nullptr;
@@ -3948,12 +3947,24 @@
 return std::move(Err);
   ToField->setAccess(D->getAccess());
   ToField->setLexicalDeclContext(LexicalDC);
-  if (ToInitializer)
-ToField->setInClassInitializer(ToInitializer);
   ToField->setImplicit(D->isImplicit());
   if (ToCapturedVLAType)
 ToField->setCapturedVLAType(cast(ToCapturedVLAType));
   LexicalDC->addDeclInternal(ToField);
+  // Import initializer only after the field was created, it may have recursive
+  // reference to the field.
+  auto ToInitializer = importChecked(Err, D->getInClassInitializer());
+  if (Err)
+return std::move(Err);
+  if (ToInitializer) {
+auto *AlreadyImported = ToField->getInClassInitializer();
+if (AlreadyImported)
+  assert(ToInitializer == AlreadyImported &&
+ "Duplicate import of in-class initializer.");
+else
+  ToField->setInClassInitializer(ToInitializer);
+  }
+
   return ToField;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailma

[PATCH] D156064: [SemaCXX] Recognise initializer_list injected-class-name types as initializer_lists

2023-07-27 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin accepted this revision.
cor3ntin 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/D156064/new/

https://reviews.llvm.org/D156064

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


[PATCH] D156064: [SemaCXX] Recognise initializer_list injected-class-name types as initializer_lists

2023-07-27 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added inline comments.



Comment at: clang/docs/ReleaseNotes.rst:111
+- Fix CTAD for ``std::initializer_list``. This allows
+  ``std::initializer_list{1, 2, 3}`` to be a ``std::initializer_list``
+  as intended.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156064

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


[PATCH] D156212: [clang][Interp] Implement remaining strcmp builtins

2023-07-27 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added inline comments.



Comment at: clang/lib/AST/Interp/InterpBuiltin.cpp:88-92
+  if (!AT->getElementType()->isCharType() &&
+  !AT->getElementType()->isChar8Type())
+return false;
+
+  return true;

aaron.ballman wrote:
> Allowing `char8_t` seems wrong to me -- https://godbolt.org/z/zK74hMP7q
Just agreeing with Aaron there.
I don't have a problem  with making `__builtin_strcmp` work with any charN_t 
but in this case we need to make sure both parameters are of the same element 
type.
Your implementation seems to allow `__builtin_strcmp(u8"", "")` which is 
comparing very different things. ie `__builtin_strcmp(u8"a", "z")` could be 
true, which is really not something we want to support :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156212

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


[PATCH] D156047: [clang][Interp] Handle CXXParenListInitExprs

2023-07-27 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added inline comments.



Comment at: clang/lib/AST/Interp/ByteCodeExprGen.cpp:661
 assert(E->getNumInits() == 1);
 return DiscardResult ? this->discard(E->inits()[0])
  : this->visit(E->inits()[0]);

how could DiscardResult ever be true here (we return L655?)


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

https://reviews.llvm.org/D156047

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


[PATCH] D156400: [clang][Interp] Implement __builtin_offsetof

2023-07-27 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder created this revision.
tbaeder added reviewers: aaron.ballman, erichkeane, shafik, cor3ntin.
Herald added a project: All.
tbaeder requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Put all the index expressions on the stack and cast them to `SInt64`. Then add 
a new `OffsetOf` opcode so we can evaluate the index expressions.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D156400

Files:
  clang/lib/AST/Interp/ByteCodeExprGen.cpp
  clang/lib/AST/Interp/ByteCodeExprGen.h
  clang/lib/AST/Interp/Interp.h
  clang/lib/AST/Interp/InterpBuiltin.cpp
  clang/lib/AST/Interp/Opcodes.td
  clang/test/AST/Interp/class-layout.cpp
  clang/test/AST/Interp/literals.cpp
  clang/test/Sema/offsetof-64.c
  clang/test/SemaCXX/class-layout.cpp
  clang/test/SemaCXX/offsetof-0x.cpp
  clang/test/SemaCXX/offsetof.cpp

Index: clang/test/SemaCXX/offsetof.cpp
===
--- clang/test/SemaCXX/offsetof.cpp
+++ clang/test/SemaCXX/offsetof.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -triple x86_64-apple-darwin10.0.0 -fsyntax-only -verify %s -Winvalid-offsetof -std=c++98
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10.0.0 -fsyntax-only -verify %s -Winvalid-offsetof -std=c++98 -fexperimental-new-constant-interpreter
 
 struct NonPOD {
   virtual void f();
Index: clang/test/SemaCXX/offsetof-0x.cpp
===
--- clang/test/SemaCXX/offsetof-0x.cpp
+++ clang/test/SemaCXX/offsetof-0x.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -triple x86_64-apple-darwin10.0.0 -fsyntax-only -std=c++11 -verify %s -Winvalid-offsetof
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10.0.0 -fsyntax-only -std=c++11 -verify %s -Winvalid-offsetof -fexperimental-new-constant-interpreter
 
 struct NonPOD {
   virtual void f();
Index: clang/test/SemaCXX/class-layout.cpp
===
--- clang/test/SemaCXX/class-layout.cpp
+++ clang/test/SemaCXX/class-layout.cpp
@@ -14,6 +14,25 @@
 // RUN: %clang_cc1 -triple s390x-none-zos %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base
 // RUN: %clang_cc1 -triple s390x-none-zos %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
 
+// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -triple x86_64-unknown-unknown %s -fsyntax-only -verify -std=c++98 -Wno-inaccessible-base -Wno-c++11-extensions
+// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -triple x86_64-unknown-unknown %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base
+// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -triple x86_64-apple-darwin%s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=15
+// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -triple x86_64-scei-ps4%s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=6
+// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -triple x86_64-sie-ps5 %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=6
+// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -triple x86_64-unknown-unknown %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -fclang-abi-compat=6 -DCLANG_ABI_COMPAT=6
+// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -triple x86_64-unknown-unknown %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -fclang-abi-compat=14 -DCLANG_ABI_COMPAT=14
+// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -triple x86_64-unknown-unknown %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
+// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -triple x86_64-unknown-unknown %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -fclang-abi-compat=16 -DCLANG_ABI_COMPAT=16
+// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -triple powerpc-ibm-aix7.3.0.0 %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=15
+// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -triple powerpc-ibm-aix7.3.0.0 %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
+// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -triple powerpc64-ibm-aix7.3.0.0 %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=15
+// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -triple powerpc64-ibm-aix7.3.0.0 %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
+// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -triple s390x-none-zos %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base
+// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -triple s390x-none-zos %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_

[PATCH] D142327: [clang][RISCV] Fix ABI handling of empty structs with hard FP calling conventions in C++

2023-07-27 Thread Roger Ferrer Ibanez via Phabricator via cfe-commits
rogfer01 added a comment.

I didn't have libcxx handy but @SixWeining testcase also failed with libstdcxx 
so I made a slightly smaller standalone testcase based on what libstdcxx does 
and I manually replaced all the template stuff.

  typedef decltype((int *)2 - (int *)1) my_ptrdiff_t;
  
  struct my_lambda {
bool operator()(int i) { return i == 2; }
  };
  
  struct my_iter_pred {
my_lambda _M_pred;
  
bool operator()(int *__it) { return bool(_M_pred(*__it)); }
  };
  
  my_ptrdiff_t __my_count_if(int *__first, int *__last, my_iter_pred __pred) {
my_ptrdiff_t __n = 0;
for (; __first != __last; ++__first)
  if (__pred(__first))
++__n;
return __n;
  }
  
  inline my_iter_pred my_pred_iter(my_lambda __my_lambda) {
return my_iter_pred(/* move */ static_cast(_my_lambda));
  }
  
  inline my_ptrdiff_t my_count_if(int *__first, int *__last,
  my_lambda __my_lambda) {
return __my_count_if(__first, __last, my_pred_iter(__my_lambda));
  }
  
  int main() {
int v[] = {1, 2, 3, 2, 2};
return my_count_if(v, v + sizeof(v) / sizeof(*v), my_lambda());
  }

I tried to simplify it further by removing the `my_pred_iter` / `my_iter_pred` 
adapter but then it would not crash anymore. Hope this helps.


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

https://reviews.llvm.org/D142327

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


[PATCH] D142327: [clang][RISCV] Fix ABI handling of empty structs with hard FP calling conventions in C++

2023-07-27 Thread Roger Ferrer Ibanez via Phabricator via cfe-commits
rogfer01 added a comment.

I didn't have libcxx handy but @SixWeining testcase also fails with libstdcxx 
so I expanded what C++ does and removed the templates.

With the new patch this does not fail anymore.

  typedef decltype((int *)2 - (int *)1) my_ptrdiff_t;
  
  struct my_lambda {
bool operator()(int i) { return i == 2; }
  };
  
  struct my_iter_pred {
my_lambda _M_pred;
  
explicit my_iter_pred(my_lambda __pred)
: _M_pred(/* move */ static_cast(__pred)) {}
  
bool operator()(int *__it) { return bool(_M_pred(*__it)); }
  };
  
  my_ptrdiff_t __my_count_if(int *__first, int *__last, my_iter_pred __pred) {
my_ptrdiff_t __n = 0;
for (; __first != __last; ++__first)
  if (__pred(__first))
++__n;
return __n;
  }
  
  inline my_iter_pred my_pred_iter(my_lambda __my_lambda) {
return my_iter_pred(/* move */ static_cast(__my_lambda));
  }
  
  inline my_ptrdiff_t my_count_if(int *__first, int *__last,
  my_lambda __my_lambda) {
return __my_count_if(__first, __last, my_pred_iter(__my_lambda));
  }
  
  int main() {
int v[] = {1, 2, 3, 2, 2};
return my_count_if(v, v + sizeof(v) / sizeof(*v), my_lambda());
  }

I tried to remove the `my_pred_iter` / `my_iter_pred` wrapper but then the 
original patch would not fail anymore.

Hope this helps.


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

https://reviews.llvm.org/D142327

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


[PATCH] D112921: [clang] Enable sized deallocation by default in C++14 onwards

2023-07-27 Thread Wang Pengcheng via Phabricator via cfe-commits
wangpc updated this revision to Diff 544640.
wangpc added a comment.

- Remove usages of `-fsized-deallocation` in some tests.
- Rebase.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112921

Files:
  clang-tools-extra/clangd/unittests/FindTargetTests.cpp
  clang-tools-extra/test/clang-tidy/checkers/misc/new-delete-overloads.cpp
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/SizedDeallocation.h
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/Darwin.cpp
  clang/lib/Driver/ToolChains/Darwin.h
  clang/lib/Driver/ToolChains/ZOS.cpp
  clang/test/AST/ast-dump-expr-json.cpp
  clang/test/AST/ast-dump-expr.cpp
  clang/test/AST/ast-dump-stmt-json.cpp
  clang/test/Analysis/cxxnewexpr-callback.cpp
  
clang/test/CXX/basic/basic.stc/basic.stc.dynamic/basic.stc.dynamic.deallocation/p2.cpp
  clang/test/CXX/expr/expr.unary/expr.new/p14.cpp
  clang/test/CodeGenCXX/cxx1y-sized-deallocation.cpp
  clang/test/CodeGenCXX/cxx1z-aligned-allocation.cpp
  clang/test/CodeGenCXX/cxx2a-destroying-delete.cpp
  clang/test/CodeGenCXX/delete-two-arg.cpp
  clang/test/CodeGenCXX/delete.cpp
  clang/test/CodeGenCXX/dllimport.cpp
  clang/test/CodeGenCXX/new.cpp
  clang/test/CodeGenCoroutines/coro-aligned-alloc-2.cpp
  clang/test/CodeGenCoroutines/coro-aligned-alloc.cpp
  clang/test/CodeGenCoroutines/coro-alloc.cpp
  clang/test/CodeGenCoroutines/coro-cleanup.cpp
  clang/test/CodeGenCoroutines/coro-dealloc.cpp
  clang/test/CodeGenCoroutines/coro-gro.cpp
  clang/test/CodeGenCoroutines/pr56919.cpp
  clang/test/Lexer/cxx-features.cpp
  clang/test/PCH/cxx1z-aligned-alloc.cpp
  clang/test/SemaCXX/MicrosoftExtensions.cpp
  clang/test/SemaCXX/builtin-operator-new-delete.cpp
  clang/test/SemaCXX/cxx1y-sized-deallocation.cpp
  clang/test/SemaCXX/unavailable_aligned_allocation.cpp
  clang/unittests/StaticAnalyzer/CallEventTest.cpp
  clang/www/cxx_status.html
  libcxx/test/libcxx/language.support/support.dynamic/libcpp_deallocate.sh.cpp
  
libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array14.pass.cpp
  
libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete14.pass.cpp

Index: libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete14.pass.cpp
===
--- libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete14.pass.cpp
+++ libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete14.pass.cpp
@@ -8,11 +8,14 @@
 
 // test sized operator delete replacement.
 
+// TODO(mordante) fix this test after updating clang in Docker
+// UNSUPPORTED: clang-17
 // UNSUPPORTED: sanitizer-new-delete, c++03, c++11
+// XFAIL: clang-15, clang-16
+// XFAIL: apple-clang
 
-// NOTE: Clang does not enable sized-deallocation in C++14 and beyond by
-// default. It is only enabled when -fsized-deallocation is given.
-// XFAIL: clang, apple-clang
+// Sized deallocation was added in macOS 10.12 and aligned OSes.
+// XFAIL: use_system_cxx_lib && target={{.+}}-apple-macosx10.{{9|10|11}}
 
 #include 
 #include 
Index: libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array14.pass.cpp
===
--- libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array14.pass.cpp
+++ libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array14.pass.cpp
@@ -8,11 +8,14 @@
 
 // test sized operator delete[] replacement.
 
+// TODO(mordante) fix this test after updating clang in Docker
+// UNSUPPORTED: clang-17
 // UNSUPPORTED: sanitizer-new-delete, c++03, c++11
+// XFAIL: clang-15, clang-16
+// XFAIL: apple-clang
 
-// NOTE: Clang does not enable sized-deallocation in C++14 and beyond by
-// default. It is only enabled when -fsized-deallocation is given.
-// XFAIL: clang, apple-clang
+// Sized deallocation was added in macOS 10.12 and aligned OSes.
+// XFAIL: use_system_cxx_lib && target={{.+}}-apple-macosx10.{{9|10|11}}
 
 #include 
 #include 
Index: libcxx/test/libcxx/language.support/support.dynamic/libcpp_deallocate.sh.cpp
===
--- libcxx/test/libcxx/language.support/support.dynamic/libcpp_deallocate.sh.cpp
+++ libcxx/test/libcxx/language.support/support.dynamic/libcpp_deallocate.sh.cpp
@@ -25,6 +25,9 @@
 // GCC doesn't support the aligned-allocation flags.
 // XFAIL: gcc
 
+// TODO(mordante) fix this test after updating clang in Docker
+// UNSUPPORTED: clang-17
+
 // RUN: %{build} -faligned-allocation -fsized-deallocation
 // RUN: %{run}
 // RUN: %{build} -faligned-allocation -fno-sized-deallocation -DNO_SIZE
Index: clang/www/cxx_status.html
==

[PATCH] D112921: [clang] Enable sized deallocation by default in C++14 onwards

2023-07-27 Thread Wang Pengcheng via Phabricator via cfe-commits
wangpc added a comment.

In D112921#4536088 , @Mordante wrote:

> In D112921#4535716 , @wangpc wrote:
>
>> In D112921#4532378 , @Mordante 
>> wrote:
>>
>>> In D112921#4530916 , @wangpc 
>>> wrote:
>>>
 In D112921#4529182 , @Mordante 
 wrote:

> I noticed some of the CI jobs are still failing with the patch, I didn't 
> look into them.

 I don't think they are related to this patch, so I rebased again. If still 
 failed, I will try to fix them later.
>>>
>>> I see changes in the libc++ ABI list output
>>>
>>>   Symbol added: _ZdlPvmSt11align_val_t
>>>   {'name': '_ZdlPvmSt11align_val_t', 'type': 'FUNC', 'is_defined': 
>>> False}
>>>   
>>>   Symbol added: _ZdlPvm
>>>   {'name': '_ZdlPvm', 'type': 'FUNC', 'is_defined': False}
>>>   
>>>   SYMBOL REMOVED: _ZdlPvSt11align_val_t
>>>   {'is_defined': False, 'name': '_ZdlPvSt11align_val_t', 'type': 'FUNC'}
>>>   
>>>   Summary
>>>   Added:   2
>>>   Removed: 1
>>>   Changed: 0
>>>
>>> There seems to be small change in the symbol name. What does the `m` in the 
>>> added symbol mean?
>>>
>>>   _ZdlPvmSt11align_val_t - added
>>>   _ZdlPvSt11align_val_t  - remove
>>>
>>> There is also a new symbol `_ZdlPvm` added.
>>
>> `m` means `unsigned long` in mangled name (5.1.5.2 Builtin types 
>> ), 
>> which is the `size` of sized deallocation.
>>
>>   $ c++filt _ZdlPvmSt11align_val_t _ZdlPvm
>>   operator delete(void*, unsigned long, std::align_val_t)
>>   operator delete(void*, unsigned long)
>>
>> I am not familiar  with libcxx, can you please help me to fix these tests? I 
>> hope we can catch up with the release of LLVM 17.
>
> Looking at the ABI list we currently have
>
>   _ZdlPv -> operator delete(void*)   // this 
> one is kept
>   _ZdlPvSt11align_val_t -> operator delete(void*, std::align_val_t)  // this 
> one is removed
>
> You add the overloads
>
>   operator delete(void*, unsigned long, std::align_val_t)
>   operator delete(void*, unsigned long)
>
> Looking in the current WP 
> http://eel.is/c++draft/replacement.functions#lib:new,operator the removed 
> overload is still listed there.
>
> Do you know why `operator delete(void*)` and `operator delete(void*, unsigned 
> long)` are both available?

I don't know the details about C++ spec, but I think they should be available 
for runtimes with/without sized deallocations.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112921

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


[PATCH] D155955: [Clang] Improve the handling of large arrays evaluation.

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

In D155955#4537145 , @efriedma wrote:

> The general approach seems fine.  The multiplier for constexpr vs. constant 
> folding can be left for a followup, and we can continue to consider other 
> possible improvements elsewhere.
>
> I guess I have one remaining question here: how does this interact with 
> SFINAE?  In other words, if we hit the limit analyzing the signature of a 
> function, do we print an error, or silently remove the function from the 
> overload list?

SFINAE https://godbolt.org/z/8can1q7GW (there is no difference between constant 
expression invalid because they exceed limits, or because they are not constant 
for other reasons)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155955

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


[PATCH] D156221: [RISCV] Support overloaded version ntlh intrinsic function

2023-07-27 Thread Piyou Chen via Phabricator via cfe-commits
BeMg updated this revision to Diff 544645.
BeMg added a comment.

Add prefix __riscv_ for all marco


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156221

Files:
  clang/lib/Headers/riscv_ntlh.h
  clang/test/CodeGen/RISCV/ntlh-intrinsics/riscv32-zihintntl.c


Index: clang/test/CodeGen/RISCV/ntlh-intrinsics/riscv32-zihintntl.c
===
--- clang/test/CodeGen/RISCV/ntlh-intrinsics/riscv32-zihintntl.c
+++ clang/test/CodeGen/RISCV/ntlh-intrinsics/riscv32-zihintntl.c
@@ -100,6 +100,24 @@
   *scvs1 = __riscv_ntl_load(scvs2, __RISCV_NTLH_ALL);   // CHECK: load {{.*}}align 8, !nontemporal !4, !riscv-nontemporal-domain !8
   *scvc1 = __riscv_ntl_load(scvc2, __RISCV_NTLH_ALL);   // CHECK: load {{.*}}align 8, !nontemporal !4, !riscv-nontemporal-domain !8
 
+  uc = __riscv_ntl_load(&sc);   // CHECK: load i8{{.*}}align 1, !nontemporal 
!4, !riscv-nontemporal-domain !8
+  sc = __riscv_ntl_load(&uc);   // CHECK: load i8{{.*}}align 1, !nontemporal 
!4, !riscv-nontemporal-domain !8
+  us = __riscv_ntl_load(&ss);   // CHECK: load i16{{.*}}align 2, !nontemporal 
!4, !riscv-nontemporal-domain !8
+  ss = __riscv_ntl_load(&us);   // CHECK: load i16{{.*}}align 2, !nontemporal 
!4, !riscv-nontemporal-domain !8
+  ui = __riscv_ntl_load(&si);   // CHECK: load i32{{.*}}align 4, !nontemporal 
!4, !riscv-nontemporal-domain !8
+  si = __riscv_ntl_load(&ui);   // CHECK: load i32{{.*}}align 4, !nontemporal 
!4, !riscv-nontemporal-domain !8
+  ull = __riscv_ntl_load(&sll); // CHECK: load i64{{.*}}align 8, !nontemporal 
!4, !riscv-nontemporal-domain !8
+  sll = __riscv_ntl_load(&ull); // CHECK: load i64{{.*}}align 8, !nontemporal 
!4, !riscv-nontemporal-domain !8
+  h1 = __riscv_ntl_load(&h2);   // CHECK: load half{{.*}}align 2, !nontemporal 
!4, !riscv-nontemporal-domain !8
+  f1 = __riscv_ntl_load(&f2);   // CHECK: load float{{.*}}align 4, 
!nontemporal !4, !riscv-nontemporal-domain !8
+  d1 = __riscv_ntl_load(&d2);   // CHECK: load double{{.*}}align 8, 
!nontemporal !4, !riscv-nontemporal-domain !8
+  v4si1 = __riscv_ntl_load(&v4si2);   // CHECK: load <4 x i32>{{.*}}align 16, 
!nontemporal !4, !riscv-nontemporal-domain !8
+  v8ss1 = __riscv_ntl_load(&v8ss2);   // CHECK: load <8 x i16>{{.*}}align 16, 
!nontemporal !4, !riscv-nontemporal-domain !8
+  v16sc1 = __riscv_ntl_load(&v16sc2);   // CHECK: load <16 x i8>{{.*}}align 
16, !nontemporal !4, !riscv-nontemporal-domain !8
+  *scvi1 = __riscv_ntl_load(scvi2);   // CHECK: load {{.*}}align 8, !nontemporal !4, !riscv-nontemporal-domain !8
+  *scvs1 = __riscv_ntl_load(scvs2);   // CHECK: load {{.*}}align 8, !nontemporal !4, !riscv-nontemporal-domain !8
+  *scvc1 = __riscv_ntl_load(scvc2);   // CHECK: load {{.*}}align 8, !nontemporal !4, !riscv-nontemporal-domain !8
+
   __riscv_ntl_store(&uc, 1, __RISCV_NTLH_INNERMOST_PRIVATE);// CHECK: 
store i8{{.*}}align 1, !nontemporal !4, !riscv-nontemporal-domain !5
   __riscv_ntl_store(&sc, 1, __RISCV_NTLH_INNERMOST_PRIVATE);// CHECK: 
store i8{{.*}}align 1, !nontemporal !4, !riscv-nontemporal-domain !5
   __riscv_ntl_store(&us, 1, __RISCV_NTLH_INNERMOST_PRIVATE);// CHECK: 
store i16{{.*}}align 2, !nontemporal !4, !riscv-nontemporal-domain !5
@@ -172,6 +190,23 @@
   __riscv_ntl_store(scvs2, *scvs1, __RISCV_NTLH_ALL);  // CHECK: store {{.*}}align 8, !nontemporal !4, !riscv-nontemporal-domain !8
   __riscv_ntl_store(scvc2, *scvc1, __RISCV_NTLH_ALL);  // CHECK: store {{.*}}align 8, !nontemporal !4, !riscv-nontemporal-domain !8
 
+  __riscv_ntl_store(&uc, 1);// CHECK: store i8{{.*}}align 1, !nontemporal 
!4, !riscv-nontemporal-domain !8
+  __riscv_ntl_store(&sc, 1);// CHECK: store i8{{.*}}align 1, !nontemporal 
!4, !riscv-nontemporal-domain !8
+  __riscv_ntl_store(&us, 1);// CHECK: store i16{{.*}}align 2, !nontemporal 
!4, !riscv-nontemporal-domain !8
+  __riscv_ntl_store(&ss, 1);// CHECK: store i16{{.*}}align 2, !nontemporal 
!4, !riscv-nontemporal-domain !8
+  __riscv_ntl_store(&ui, 1);// CHECK: store i32{{.*}}align 4, !nontemporal 
!4, !riscv-nontemporal-domain !8
+  __riscv_ntl_store(&si, 1);// CHECK: store i32{{.*}}align 4, !nontemporal 
!4, !riscv-nontemporal-domain !8
+  __riscv_ntl_store(&ull, 1);   // CHECK: store i64{{.*}}align 8, !nontemporal 
!4, !riscv-nontemporal-domain !8
+  __riscv_ntl_store(&sll, 1);   // CHECK: store i64{{.*}}align 8, !nontemporal 
!4, !riscv-nontemporal-domain !8
+  __riscv_ntl_store(&h1, 1.0);  // CHECK: store half{{.*}}align 2, 
!nontemporal !4, !riscv-nontemporal-domain !8
+  __riscv_ntl_store(&f1, 1.0);  // CHECK: store float{{.*}}align 4, 
!nontemporal !4, !riscv-nontemporal-domain !8
+  __riscv_ntl_store(&d1, 1.0);  // CHECK: store double{{.*}}align 8, 
!nontemporal !4, !riscv-nontemporal-domain !8
+  __riscv_ntl_store(&v4si1, v4si2);  // CHECK: store <4 x i32>{{.*}}align 16, 
!nontemporal !4, !riscv-nontemporal-domain !8
+  __riscv_ntl

[PATCH] D155457: [clang] Skip tautological comparison if the comparison involves the 'size_t' type

2023-07-27 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added inline comments.



Comment at: clang/lib/Sema/SemaChecking.cpp:13807-13815
+  // Don't warn if the comparison involves integral or floating-point types 
with
+  // the same canonical types.
+  QualType LHSCanonical = Constant->getType().getCanonicalType();
+  QualType RHSCanonical = Other->getType().getCanonicalType();
+  if ((LHSCanonical->isIntegralOrEnumerationType() ||
+   LHSCanonical->isFloatingType()) &&
+  S.Context.hasSameType(LHSCanonical, RHSCanonical)) {

This is what I had in mind. I haven't tested it though


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155457

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


[PATCH] D156402: [clang][dataflow] Don't crash when constructing an array of records.

2023-07-27 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.

When I wrote https://reviews.llvm.org/D155446, I assumed that a
`CXXConstructExpr` would always have record type, but this isn't true: It can
have array type when constructing an array of records. The code would crash in
this situation because `createValue()` would return null.

This patch includes a test that reproduces the crash without the other changes
in the patch.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D156402

Files:
  clang/lib/Analysis/FlowSensitive/Transfer.cpp
  clang/unittests/Analysis/FlowSensitive/TransferTest.cpp


Index: clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
@@ -310,6 +310,28 @@
   });
 }
 
+TEST(TransferTest, StructArrayVarDecl) {
+  std::string Code = R"(
+struct A {};
+
+void target() {
+  A Array[2];
+  // [[p]]
+}
+  )";
+  runDataflow(
+  Code,
+  [](const llvm::StringMap> &Results,
+ ASTContext &ASTCtx) {
+const Environment &Env = getEnvironmentAtAnnotation(Results, "p");
+
+const ValueDecl *ArrayDecl = findValueDecl(ASTCtx, "Array");
+
+// We currently don't create values for arrays.
+ASSERT_THAT(Env.getValue(*ArrayDecl), IsNull());
+  });
+}
+
 TEST(TransferTest, ClassVarDecl) {
   std::string Code = R"(
 class A {
Index: clang/lib/Analysis/FlowSensitive/Transfer.cpp
===
--- clang/lib/Analysis/FlowSensitive/Transfer.cpp
+++ clang/lib/Analysis/FlowSensitive/Transfer.cpp
@@ -500,9 +500,14 @@
   return;
 }
 
-auto &InitialVal = *cast(Env.createValue(S->getType()));
-copyRecord(InitialVal.getAggregateLoc(), Env.getResultObjectLocation(*S),
-   Env);
+// `CXXConstructExpr` can have array type if default-initializing an array
+// of records, and we currently can't create values for arrays. So check if
+// we've got a record type.
+if (S->getType()->isRecordType()) {
+  auto &InitialVal = *cast(Env.createValue(S->getType()));
+  copyRecord(InitialVal.getAggregateLoc(), Env.getResultObjectLocation(*S),
+ Env);
+}
 
 transferInlineCall(S, ConstructorDecl);
   }


Index: clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
@@ -310,6 +310,28 @@
   });
 }
 
+TEST(TransferTest, StructArrayVarDecl) {
+  std::string Code = R"(
+struct A {};
+
+void target() {
+  A Array[2];
+  // [[p]]
+}
+  )";
+  runDataflow(
+  Code,
+  [](const llvm::StringMap> &Results,
+ ASTContext &ASTCtx) {
+const Environment &Env = getEnvironmentAtAnnotation(Results, "p");
+
+const ValueDecl *ArrayDecl = findValueDecl(ASTCtx, "Array");
+
+// We currently don't create values for arrays.
+ASSERT_THAT(Env.getValue(*ArrayDecl), IsNull());
+  });
+}
+
 TEST(TransferTest, ClassVarDecl) {
   std::string Code = R"(
 class A {
Index: clang/lib/Analysis/FlowSensitive/Transfer.cpp
===
--- clang/lib/Analysis/FlowSensitive/Transfer.cpp
+++ clang/lib/Analysis/FlowSensitive/Transfer.cpp
@@ -500,9 +500,14 @@
   return;
 }
 
-auto &InitialVal = *cast(Env.createValue(S->getType()));
-copyRecord(InitialVal.getAggregateLoc(), Env.getResultObjectLocation(*S),
-   Env);
+// `CXXConstructExpr` can have array type if default-initializing an array
+// of records, and we currently can't create values for arrays. So check if
+// we've got a record type.
+if (S->getType()->isRecordType()) {
+  auto &InitialVal = *cast(Env.createValue(S->getType()));
+  copyRecord(InitialVal.getAggregateLoc(), Env.getResultObjectLocation(*S),
+ Env);
+}
 
 transferInlineCall(S, ConstructorDecl);
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D156403: [clangd] Revert the symbol collector behavior to old pre-include-cleaner-library behavior due to a regression.

2023-07-27 Thread Viktoriia Bakalova via Phabricator via cfe-commits
VitaNuo created this revision.
Herald added subscribers: kadircet, arphaman.
Herald added a project: All.
VitaNuo requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D156403

Files:
  clang-tools-extra/clangd/index/SymbolCollector.cpp
  clang-tools-extra/clangd/unittests/FileIndexTests.cpp
  clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp


Index: clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
===
--- clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
+++ clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
@@ -1592,7 +1592,7 @@
  includeHeader("\"the/good/header.h\"";
 }
 
-TEST_F(SymbolCollectorTest, IWYUPragmaExport) {
+TEST_F(SymbolCollectorTest, DISABLED_IWYUPragmaExport) {
   CollectorOpts.CollectIncludePath = true;
   const std::string Header = R"cpp(#pragma once
 #include "exporter.h"
Index: clang-tools-extra/clangd/unittests/FileIndexTests.cpp
===
--- clang-tools-extra/clangd/unittests/FileIndexTests.cpp
+++ clang-tools-extra/clangd/unittests/FileIndexTests.cpp
@@ -239,7 +239,7 @@
   "");
 }
 
-TEST(FileIndexTest, IWYUPragmaExport) {
+TEST(FileIndexTest, DISABLED_IWYUPragmaExport) {
   FileIndex M;
 
   TestTU File;
Index: clang-tools-extra/clangd/index/SymbolCollector.cpp
===
--- clang-tools-extra/clangd/index/SymbolCollector.cpp
+++ clang-tools-extra/clangd/index/SymbolCollector.cpp
@@ -36,6 +36,7 @@
 #include "clang/Lex/Preprocessor.h"
 #include "clang/Lex/Token.h"
 #include "clang/Tooling/Inclusions/HeaderAnalysis.h"
+#include "clang/Tooling/Inclusions/StandardLibrary.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/SmallVector.h"
@@ -898,19 +899,39 @@
 if (Directives == Symbol::Invalid)
   continue;
 
-// Use the include location-based logic for Objective-C symbols.
-if (Directives & Symbol::Import) {
-  if (auto IncludeHeader = HeaderFileURIs->getIncludeHeader(FID);
-  !IncludeHeader.empty()) {
-auto NewSym = *S;
-NewSym.IncludeHeaders.push_back({IncludeHeader, 1, Directives});
-Symbols.insert(NewSym);
-  }
-  // FIXME: use providers from include-cleaner library once it's polished
-  // for Objective-C.
+// FIXME: Remove the block below once we can rely on standard library
+// mapping inside the include-cleaner library again.
+llvm::StringRef IncludeHeader;
+if (auto StdSym = tooling::stdlib::Symbol::named(S->Scope, S->Name))
+  if (auto Header = StdSym->header())
+IncludeHeader = Header->name();
+if (S->Scope == "std::" && S->Name == "move") {
+  IncludeHeader = "";
+  if (S->Signature.contains(','))
+IncludeHeader = "";
+}
+if (!IncludeHeader.empty()) {
+  auto NewSym = *S;
+  NewSym.IncludeHeaders.push_back({IncludeHeader, 1, Directives});
+  Symbols.insert(NewSym);
   continue;
 }
 
+// Use the old include location-based logic both for Objective-C and C++
+// symbols.
+if (auto IncludeHeader = HeaderFileURIs->getIncludeHeader(FID);
+!IncludeHeader.empty()) {
+  auto NewSym = *S;
+  NewSym.IncludeHeaders.push_back({IncludeHeader, 1, Directives});
+  Symbols.insert(NewSym);
+}
+
+// FIXME: use providers from include-cleaner library once it's polished
+// for Objective-C.
+continue;
+
+// FIXME: Re-enable for C++ code. The code below uses include-cleaner
+// library but is currently unreachable due to regression.
 assert(Directives == Symbol::Include);
 // For #include's, use the providers computed by the include-cleaner
 // library.


Index: clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
===
--- clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
+++ clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
@@ -1592,7 +1592,7 @@
  includeHeader("\"the/good/header.h\"";
 }
 
-TEST_F(SymbolCollectorTest, IWYUPragmaExport) {
+TEST_F(SymbolCollectorTest, DISABLED_IWYUPragmaExport) {
   CollectorOpts.CollectIncludePath = true;
   const std::string Header = R"cpp(#pragma once
 #include "exporter.h"
Index: clang-tools-extra/clangd/unittests/FileIndexTests.cpp
===
--- clang-tools-extra/clangd/unittests/FileIndexTests.cpp
+++ clang-tools-extra/clangd/unittests/FileIndexTests.cpp
@@ -239,7 +239,7 @@
   "");
 }
 
-TEST(FileIndexTest, IWYUPragmaExport) {
+TEST(FileIndexTest, DISABLED_IWYUPragmaExport) {
   FileIndex M;
 
   TestTU

[PATCH] D156337: [clang] Allow setting the uninitialized attribute on record

2023-07-27 Thread Mariya Podchishchaeva via Phabricator via cfe-commits
Fznamznon added inline comments.



Comment at: clang/lib/CodeGen/CGDecl.cpp:1906-1908
+  if (D.isConstexpr())
+// Note: constexpr already initializes everything correctly.
+trivialAutoVarInit = LangOptions::TrivialAutoVarInitKind::Uninitialized;

Should we have curly braces here?



Comment at: clang/lib/CodeGen/CGDecl.cpp:1909
+trivialAutoVarInit = LangOptions::TrivialAutoVarInitKind::Uninitialized;
+  else if (D.getAttr())
+trivialAutoVarInit = LangOptions::TrivialAutoVarInitKind::Uninitialized;





Comment at: clang/lib/Sema/SemaDeclAttr.cpp:8442
+  assert(((isa(D) &&
+   cast(D)->getStorageDuration() == SD_Automatic) ||
+  isa(D)) &&

AFAIK `cast` does `isa`, since it is already done here we can probably switch 
to `dyn_cast`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156337

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


[PATCH] D156047: [clang][Interp] Handle CXXParenListInitExprs

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



Comment at: clang/lib/AST/Interp/ByteCodeExprGen.cpp:661
 assert(E->getNumInits() == 1);
 return DiscardResult ? this->discard(E->inits()[0])
  : this->visit(E->inits()[0]);

cor3ntin wrote:
> how could DiscardResult ever be true here (we return L655?)
Ah yes,  you're right.


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

https://reviews.llvm.org/D156047

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


[PATCH] D156403: [clangd] Revert the symbol collector behavior to old pre-include-cleaner-library behavior due to a regression.

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



Comment at: clang-tools-extra/clangd/index/SymbolCollector.cpp:841-847
   auto [It, Inserted] = SymbolProviders.try_emplace(S.ID);
   if (Inserted) {
 auto Headers =
 include_cleaner::headersForSymbol(Sym, SM, Opts.PragmaIncludes);
 if (!Headers.empty())
   It->second = Headers.front();
   }

can you also get rid of this piece, and `SymbolProviders` map ?



Comment at: clang-tools-extra/clangd/index/SymbolCollector.cpp:873
   llvm::DenseMap FileToContainsImportsOrObjC;
   llvm::DenseMap HeaderSpelling;
   // Fill in IncludeHeaders.

we can drop this too



Comment at: clang-tools-extra/clangd/index/SymbolCollector.cpp:903-927
+// mapping inside the include-cleaner library again.
+llvm::StringRef IncludeHeader;
+if (auto StdSym = tooling::stdlib::Symbol::named(S->Scope, S->Name))
+  if (auto Header = StdSym->header())
+IncludeHeader = Header->name();
+if (S->Scope == "std::" && S->Name == "move") {
+  IncludeHeader = "";

rather than duplicating some of the checks, can we rewrite this block as:
```
llvm::StringRef IncludeHeader = getStdlibHeader(*S, ASTCtx->getLangOpts());
if (IncludeHeader.empty())
  IncludeHeader = HeaderFileURIs->getIncludeHeader(FID);
if (!IncludeHeader.empty()) {
  auto NewSym = *S;
  NewSym.IncludeHeaders.push_back({IncludeHeader, 1, Directives});
  Symbols.insert(NewSym);
}
```



Comment at: clang-tools-extra/clangd/index/SymbolCollector.cpp:905
+llvm::StringRef IncludeHeader;
+if (auto StdSym = tooling::stdlib::Symbol::named(S->Scope, S->Name))
+  if (auto Header = StdSym->header())

let's pass in the language options from ASTCtx into here



Comment at: clang-tools-extra/clangd/index/SymbolCollector.cpp:908-912
+if (S->Scope == "std::" && S->Name == "move") {
+  IncludeHeader = "";
+  if (S->Signature.contains(','))
+IncludeHeader = "";
+}

i think the old order of, first dealing with `std::move` and then using 
`tooling::stdlib` is less error-prone and the order in which we apply the 
mapping in include-cleaner, so that would be a more compatible change going 
forward.



Comment at: clang-tools-extra/clangd/index/SymbolCollector.cpp:929-964
+// FIXME: use providers from include-cleaner library once it's polished
+// for Objective-C.
+continue;
+
+// FIXME: Re-enable for C++ code. The code below uses include-cleaner
+// library but is currently unreachable due to regression.
 assert(Directives == Symbol::Include);

let's drop this block to not create confusion


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156403

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


[clang] 4cd7d8e - [clang] UnsafeBufferUsage.cpp - fix MSVC "not all control paths return a value" warning. NFC.

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

Author: Simon Pilgrim
Date: 2023-07-27T10:17:57+01:00
New Revision: 4cd7d8e30aca25c86ff40cd547f78b27d573a503

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

LOG: [clang] UnsafeBufferUsage.cpp - fix MSVC "not all control paths return a 
value" warning. NFC.

Added: 


Modified: 
clang/lib/Analysis/UnsafeBufferUsage.cpp

Removed: 




diff  --git a/clang/lib/Analysis/UnsafeBufferUsage.cpp 
b/clang/lib/Analysis/UnsafeBufferUsage.cpp
index 781dc13c898d22..d0451401dc305a 100644
--- a/clang/lib/Analysis/UnsafeBufferUsage.cpp
+++ b/clang/lib/Analysis/UnsafeBufferUsage.cpp
@@ -322,6 +322,7 @@ class Gadget {
 #define GADGET(x) case Kind::x: return #x;
 #include "clang/Analysis/Analyses/UnsafeBufferUsageGadgets.def"
 }
+llvm_unreachable("Unhandled Gadget::Kind enum");
   }
 #endif
 



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


[PATCH] D156325: [Driver] Link shared asan runtime lib with -z now on Solaris/x86

2023-07-27 Thread Rainer Orth via Phabricator via cfe-commits
ro added a comment.

In D156325#4537237 , @MaskRay wrote:

> This needs a clang/test/Driver test.

Indeed, I forgot.  Added now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156325

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


[PATCH] D156325: [Driver] Link shared asan runtime lib with -z now on Solaris/x86

2023-07-27 Thread Rainer Orth via Phabricator via cfe-commits
ro updated this revision to Diff 544660.
ro added a comment.

Add testcases.

Re-tested on `amd64-pc-solaris2.11` and `x86_64-pc-linux-gnu`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156325

Files:
  clang/lib/Driver/ToolChains/Solaris.cpp
  clang/test/Driver/solaris-ld-sanitizer.c


Index: clang/test/Driver/solaris-ld-sanitizer.c
===
--- clang/test/Driver/solaris-ld-sanitizer.c
+++ clang/test/Driver/solaris-ld-sanitizer.c
@@ -49,3 +49,19 @@
 // RUN: --gcc-toolchain="" --sysroot=%S/Inputs/solaris_x86_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-LD-X64-UBSAN %s
 // CHECK-LD-X64-UBSAN: -zrelax=transtls
+
+/// General tests that the ld -z now workaround is only applied on
+/// Solaris/i386 with shared libclang_rt.asan.. Note that we use sysroot to
+/// make these tests independent of the host system.
+
+/// Check i386-pc-solaris2.11, 32bit, shared libclang_rt.asan
+// RUN: %clang -fsanitize=address -shared-libasan --target=i386-pc-solaris2.11 
%s -### 2>&1 \
+// RUN: --gcc-toolchain="" --sysroot=%S/Inputs/solaris_x86_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-LD-X32-ASAN-SHARED %s
+// CHECK-LD-X32-ASAN-SHARED: -znow
+
+/// Check i386-pc-solaris2.11, 32bit, static libclang_rt.asan
+// RUN: %clang -fsanitize=address --target=i386-pc-solaris2.11 %s -### 2>&1 \
+// RUN: --gcc-toolchain="" --sysroot=%S/Inputs/solaris_x86_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-LD-X32-ASAN %s
+// CHECK-LD-X32-ASAN-NOT: -znow
Index: clang/lib/Driver/ToolChains/Solaris.cpp
===
--- clang/lib/Driver/ToolChains/Solaris.cpp
+++ clang/lib/Driver/ToolChains/Solaris.cpp
@@ -151,18 +151,22 @@
   CmdArgs.push_back("-lgcc");
   CmdArgs.push_back("-lm");
 }
+const SanitizerArgs &SA = getToolChain().getSanitizerArgs(Args);
 if (NeedsSanitizerDeps) {
   linkSanitizerRuntimeDeps(getToolChain(), CmdArgs);
 
   // Work around Solaris/amd64 ld bug when calling __tls_get_addr directly.
   // However, ld -z relax=transtls is available since Solaris 11.2, but not
   // in Illumos.
-  const SanitizerArgs &SA = getToolChain().getSanitizerArgs(Args);
   if (getToolChain().getTriple().getArch() == llvm::Triple::x86_64 &&
   (SA.needsAsanRt() || SA.needsStatsRt() ||
(SA.needsUbsanRt() && !SA.requiresMinimalRuntime(
 CmdArgs.push_back("-zrelax=transtls");
 }
+// Avoid AsanInitInternal cycle, Issue #64126.
+if (getToolChain().getTriple().isX86() && SA.needsSharedRt() &&
+SA.needsAsanRt())
+  CmdArgs.push_back("-znow");
   }
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles,


Index: clang/test/Driver/solaris-ld-sanitizer.c
===
--- clang/test/Driver/solaris-ld-sanitizer.c
+++ clang/test/Driver/solaris-ld-sanitizer.c
@@ -49,3 +49,19 @@
 // RUN: --gcc-toolchain="" --sysroot=%S/Inputs/solaris_x86_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-LD-X64-UBSAN %s
 // CHECK-LD-X64-UBSAN: -zrelax=transtls
+
+/// General tests that the ld -z now workaround is only applied on
+/// Solaris/i386 with shared libclang_rt.asan.. Note that we use sysroot to
+/// make these tests independent of the host system.
+
+/// Check i386-pc-solaris2.11, 32bit, shared libclang_rt.asan
+// RUN: %clang -fsanitize=address -shared-libasan --target=i386-pc-solaris2.11 %s -### 2>&1 \
+// RUN: --gcc-toolchain="" --sysroot=%S/Inputs/solaris_x86_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-LD-X32-ASAN-SHARED %s
+// CHECK-LD-X32-ASAN-SHARED: -znow
+
+/// Check i386-pc-solaris2.11, 32bit, static libclang_rt.asan
+// RUN: %clang -fsanitize=address --target=i386-pc-solaris2.11 %s -### 2>&1 \
+// RUN: --gcc-toolchain="" --sysroot=%S/Inputs/solaris_x86_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-LD-X32-ASAN %s
+// CHECK-LD-X32-ASAN-NOT: -znow
Index: clang/lib/Driver/ToolChains/Solaris.cpp
===
--- clang/lib/Driver/ToolChains/Solaris.cpp
+++ clang/lib/Driver/ToolChains/Solaris.cpp
@@ -151,18 +151,22 @@
   CmdArgs.push_back("-lgcc");
   CmdArgs.push_back("-lm");
 }
+const SanitizerArgs &SA = getToolChain().getSanitizerArgs(Args);
 if (NeedsSanitizerDeps) {
   linkSanitizerRuntimeDeps(getToolChain(), CmdArgs);
 
   // Work around Solaris/amd64 ld bug when calling __tls_get_addr directly.
   // However, ld -z relax=transtls is available since Solaris 11.2, but not
   // in Illumos.
-  const SanitizerArgs &SA = getToolChain().getSanitizerArgs(Args);
   if (getToolChain().getTriple().getArch() == llvm::Triple::x86_64 &&
   (SA.needsAsanRt() || SA.needsStatsRt() ||
(SA.needsUbsanRt() && !SA.requiresMinimalRuntime(
  

[clang] 6b5149a - [Driver] Link shared asan runtime lib with -z now on Solaris/x86

2023-07-27 Thread Rainer Orth via cfe-commits

Author: Rainer Orth
Date: 2023-07-27T11:32:48+02:00
New Revision: 6b5149aa442efc10afa00e8864e58a24a9cf5c9f

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

LOG: [Driver] Link shared asan runtime lib with -z now on Solaris/x86

As detailed in Issue #64126, several asan tests `FAIL` due to a cycle in
`AsanInitInternal`.  This can by avoided by disabling lazy binding with `ld
-z now`.

Tested on `amd64-pc-solaris2.11` and `x86_64-pc-linux-gnu`.

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/Solaris.cpp
clang/test/Driver/solaris-ld-sanitizer.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Solaris.cpp 
b/clang/lib/Driver/ToolChains/Solaris.cpp
index 335a5a88cdfac6..86c789f5fcef5c 100644
--- a/clang/lib/Driver/ToolChains/Solaris.cpp
+++ b/clang/lib/Driver/ToolChains/Solaris.cpp
@@ -151,18 +151,22 @@ void solaris::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
   CmdArgs.push_back("-lgcc");
   CmdArgs.push_back("-lm");
 }
+const SanitizerArgs &SA = getToolChain().getSanitizerArgs(Args);
 if (NeedsSanitizerDeps) {
   linkSanitizerRuntimeDeps(getToolChain(), CmdArgs);
 
   // Work around Solaris/amd64 ld bug when calling __tls_get_addr directly.
   // However, ld -z relax=transtls is available since Solaris 11.2, but not
   // in Illumos.
-  const SanitizerArgs &SA = getToolChain().getSanitizerArgs(Args);
   if (getToolChain().getTriple().getArch() == llvm::Triple::x86_64 &&
   (SA.needsAsanRt() || SA.needsStatsRt() ||
(SA.needsUbsanRt() && !SA.requiresMinimalRuntime(
 CmdArgs.push_back("-zrelax=transtls");
 }
+// Avoid AsanInitInternal cycle, Issue #64126.
+if (getToolChain().getTriple().isX86() && SA.needsSharedRt() &&
+SA.needsAsanRt())
+  CmdArgs.push_back("-znow");
   }
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles,

diff  --git a/clang/test/Driver/solaris-ld-sanitizer.c 
b/clang/test/Driver/solaris-ld-sanitizer.c
index caf01919d4671e..d4fe62b5e14943 100644
--- a/clang/test/Driver/solaris-ld-sanitizer.c
+++ b/clang/test/Driver/solaris-ld-sanitizer.c
@@ -49,3 +49,19 @@
 // RUN: --gcc-toolchain="" --sysroot=%S/Inputs/solaris_x86_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-LD-X64-UBSAN %s
 // CHECK-LD-X64-UBSAN: -zrelax=transtls
+
+/// General tests that the ld -z now workaround is only applied on
+/// Solaris/i386 with shared libclang_rt.asan.. Note that we use sysroot to
+/// make these tests independent of the host system.
+
+/// Check i386-pc-solaris2.11, 32bit, shared libclang_rt.asan
+// RUN: %clang -fsanitize=address -shared-libasan --target=i386-pc-solaris2.11 
%s -### 2>&1 \
+// RUN: --gcc-toolchain="" --sysroot=%S/Inputs/solaris_x86_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-LD-X32-ASAN-SHARED %s
+// CHECK-LD-X32-ASAN-SHARED: -znow
+
+/// Check i386-pc-solaris2.11, 32bit, static libclang_rt.asan
+// RUN: %clang -fsanitize=address --target=i386-pc-solaris2.11 %s -### 2>&1 \
+// RUN: --gcc-toolchain="" --sysroot=%S/Inputs/solaris_x86_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-LD-X32-ASAN %s
+// CHECK-LD-X32-ASAN-NOT: -znow



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


[PATCH] D156325: [Driver] Link shared asan runtime lib with -z now on Solaris/x86

2023-07-27 Thread Rainer Orth 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 rG6b5149aa442e: [Driver] Link shared asan runtime lib with -z 
now on Solaris/x86 (authored by ro).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156325

Files:
  clang/lib/Driver/ToolChains/Solaris.cpp
  clang/test/Driver/solaris-ld-sanitizer.c


Index: clang/test/Driver/solaris-ld-sanitizer.c
===
--- clang/test/Driver/solaris-ld-sanitizer.c
+++ clang/test/Driver/solaris-ld-sanitizer.c
@@ -49,3 +49,19 @@
 // RUN: --gcc-toolchain="" --sysroot=%S/Inputs/solaris_x86_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-LD-X64-UBSAN %s
 // CHECK-LD-X64-UBSAN: -zrelax=transtls
+
+/// General tests that the ld -z now workaround is only applied on
+/// Solaris/i386 with shared libclang_rt.asan.. Note that we use sysroot to
+/// make these tests independent of the host system.
+
+/// Check i386-pc-solaris2.11, 32bit, shared libclang_rt.asan
+// RUN: %clang -fsanitize=address -shared-libasan --target=i386-pc-solaris2.11 
%s -### 2>&1 \
+// RUN: --gcc-toolchain="" --sysroot=%S/Inputs/solaris_x86_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-LD-X32-ASAN-SHARED %s
+// CHECK-LD-X32-ASAN-SHARED: -znow
+
+/// Check i386-pc-solaris2.11, 32bit, static libclang_rt.asan
+// RUN: %clang -fsanitize=address --target=i386-pc-solaris2.11 %s -### 2>&1 \
+// RUN: --gcc-toolchain="" --sysroot=%S/Inputs/solaris_x86_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-LD-X32-ASAN %s
+// CHECK-LD-X32-ASAN-NOT: -znow
Index: clang/lib/Driver/ToolChains/Solaris.cpp
===
--- clang/lib/Driver/ToolChains/Solaris.cpp
+++ clang/lib/Driver/ToolChains/Solaris.cpp
@@ -151,18 +151,22 @@
   CmdArgs.push_back("-lgcc");
   CmdArgs.push_back("-lm");
 }
+const SanitizerArgs &SA = getToolChain().getSanitizerArgs(Args);
 if (NeedsSanitizerDeps) {
   linkSanitizerRuntimeDeps(getToolChain(), CmdArgs);
 
   // Work around Solaris/amd64 ld bug when calling __tls_get_addr directly.
   // However, ld -z relax=transtls is available since Solaris 11.2, but not
   // in Illumos.
-  const SanitizerArgs &SA = getToolChain().getSanitizerArgs(Args);
   if (getToolChain().getTriple().getArch() == llvm::Triple::x86_64 &&
   (SA.needsAsanRt() || SA.needsStatsRt() ||
(SA.needsUbsanRt() && !SA.requiresMinimalRuntime(
 CmdArgs.push_back("-zrelax=transtls");
 }
+// Avoid AsanInitInternal cycle, Issue #64126.
+if (getToolChain().getTriple().isX86() && SA.needsSharedRt() &&
+SA.needsAsanRt())
+  CmdArgs.push_back("-znow");
   }
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles,


Index: clang/test/Driver/solaris-ld-sanitizer.c
===
--- clang/test/Driver/solaris-ld-sanitizer.c
+++ clang/test/Driver/solaris-ld-sanitizer.c
@@ -49,3 +49,19 @@
 // RUN: --gcc-toolchain="" --sysroot=%S/Inputs/solaris_x86_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-LD-X64-UBSAN %s
 // CHECK-LD-X64-UBSAN: -zrelax=transtls
+
+/// General tests that the ld -z now workaround is only applied on
+/// Solaris/i386 with shared libclang_rt.asan.. Note that we use sysroot to
+/// make these tests independent of the host system.
+
+/// Check i386-pc-solaris2.11, 32bit, shared libclang_rt.asan
+// RUN: %clang -fsanitize=address -shared-libasan --target=i386-pc-solaris2.11 %s -### 2>&1 \
+// RUN: --gcc-toolchain="" --sysroot=%S/Inputs/solaris_x86_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-LD-X32-ASAN-SHARED %s
+// CHECK-LD-X32-ASAN-SHARED: -znow
+
+/// Check i386-pc-solaris2.11, 32bit, static libclang_rt.asan
+// RUN: %clang -fsanitize=address --target=i386-pc-solaris2.11 %s -### 2>&1 \
+// RUN: --gcc-toolchain="" --sysroot=%S/Inputs/solaris_x86_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-LD-X32-ASAN %s
+// CHECK-LD-X32-ASAN-NOT: -znow
Index: clang/lib/Driver/ToolChains/Solaris.cpp
===
--- clang/lib/Driver/ToolChains/Solaris.cpp
+++ clang/lib/Driver/ToolChains/Solaris.cpp
@@ -151,18 +151,22 @@
   CmdArgs.push_back("-lgcc");
   CmdArgs.push_back("-lm");
 }
+const SanitizerArgs &SA = getToolChain().getSanitizerArgs(Args);
 if (NeedsSanitizerDeps) {
   linkSanitizerRuntimeDeps(getToolChain(), CmdArgs);
 
   // Work around Solaris/amd64 ld bug when calling __tls_get_addr directly.
   // However, ld -z relax=transtls is available since Solaris 11.2, but not
   // in Illumos.
-  const SanitizerArgs &SA = getToolChain().getSanitizerArgs(Args);
   if (getToolChain().getTriple().getArch() == llvm::Triple::x86_64 &&
   (SA.needs

[PATCH] D156405: [NFC][clang] Fix static analyzer concerns

2023-07-27 Thread Mariya Podchishchaeva via Phabricator via cfe-commits
Fznamznon created this revision.
Herald added subscribers: manas, ASDenysPetrov, dkrupp, donat.nagy, Szelethus, 
a.sidorin, baloghadamsoftware.
Herald added a project: All.
Fznamznon requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

DelegatingDeserializationListener frees resources in the destructor but doesn't
have user-written copy c'tor or assignment operator, so copying it using
default ones can cause double free.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D156405

Files:
  clang/lib/Frontend/FrontendAction.cpp


Index: clang/lib/Frontend/FrontendAction.cpp
===
--- clang/lib/Frontend/FrontendAction.cpp
+++ clang/lib/Frontend/FrontendAction.cpp
@@ -61,6 +61,11 @@
   delete Previous;
   }
 
+  DelegatingDeserializationListener(const DelegatingDeserializationListener &) 
=
+  delete;
+  DelegatingDeserializationListener &
+  operator=(const DelegatingDeserializationListener &) = delete;
+
   void ReaderInitialized(ASTReader *Reader) override {
 if (Previous)
   Previous->ReaderInitialized(Reader);


Index: clang/lib/Frontend/FrontendAction.cpp
===
--- clang/lib/Frontend/FrontendAction.cpp
+++ clang/lib/Frontend/FrontendAction.cpp
@@ -61,6 +61,11 @@
   delete Previous;
   }
 
+  DelegatingDeserializationListener(const DelegatingDeserializationListener &) =
+  delete;
+  DelegatingDeserializationListener &
+  operator=(const DelegatingDeserializationListener &) = delete;
+
   void ReaderInitialized(ASTReader *Reader) override {
 if (Previous)
   Previous->ReaderInitialized(Reader);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D156406: [NFC][clang] Fix static analyzer concerns

2023-07-27 Thread Mariya Podchishchaeva via Phabricator via cfe-commits
Fznamznon created this revision.
Herald added subscribers: manas, ASDenysPetrov, dkrupp, donat.nagy, Szelethus, 
a.sidorin, baloghadamsoftware.
Herald added a project: All.
Fznamznon requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

IdentifierResolver frees resources in the destructor but doesn't
have user-written copy c'tor or assignment operator, so copying it using
default ones can cause double free.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D156406

Files:
  clang/include/clang/Sema/IdentifierResolver.h


Index: clang/include/clang/Sema/IdentifierResolver.h
===
--- clang/include/clang/Sema/IdentifierResolver.h
+++ clang/include/clang/Sema/IdentifierResolver.h
@@ -134,6 +134,9 @@
   explicit IdentifierResolver(Preprocessor &PP);
   ~IdentifierResolver();
 
+  IdentifierResolver(const IdentifierResolver &) = delete;
+  IdentifierResolver &operator=(const IdentifierResolver &) = delete;
+
   /// Returns a range of decls with the name 'Name'.
   llvm::iterator_range decls(DeclarationName Name);
 


Index: clang/include/clang/Sema/IdentifierResolver.h
===
--- clang/include/clang/Sema/IdentifierResolver.h
+++ clang/include/clang/Sema/IdentifierResolver.h
@@ -134,6 +134,9 @@
   explicit IdentifierResolver(Preprocessor &PP);
   ~IdentifierResolver();
 
+  IdentifierResolver(const IdentifierResolver &) = delete;
+  IdentifierResolver &operator=(const IdentifierResolver &) = delete;
+
   /// Returns a range of decls with the name 'Name'.
   llvm::iterator_range decls(DeclarationName Name);
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D155819: [include-cleaner] Loose matching for verbatim headers

2023-07-27 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet accepted this revision.
kadircet added inline comments.
This revision is now accepted and ready to land.



Comment at: clang-tools-extra/include-cleaner/lib/Types.cpp:171-173
+for (unsigned I : BySpellingAlternate.lookup(Spelling))
+  if (!llvm::is_contained(Result, &All[I]))
+Result.push_back(&All[I]);

sammccall wrote:
> kadircet wrote:
> > i think we shouldn't look into alternate spellings if we've already found 
> > an exact spelling. we would be matching wrong headers for sure in those 
> > cases.
> I had it this way initially and changed my mind. Having the presence of some 
> includes affect whether others match at all breaks an "obvious" part of the 
> contract. (So obvious that I assumed it in the test ten minutes after 
> deliberately breaking it). I wouldn't add a special case here unless there's 
> some observed bad-results motivation for it.
> 
> > we would be matching wrong headers for sure in those cases.
> 
> You could be including the same header under two paths (and in fact that's 
> what this testcase is doing). I don't know why you would, but we also don't 
> have real examples of this happening with *different* headers.
> You could be including the same header under two paths (and in fact that's 
> what this testcase is doing). I don't know why you would

I do think it's better to diagnose one of those as unused in such a scenario. 
As tools like clang-format won't be able to de-duplicate those automatically.

but you're right about not having examples for alternate spellings resolving to 
different files, so I guess this is at least "safe" and we can change the 
behaviour if we encounter examples.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155819

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


[PATCH] D156064: [SemaCXX] Recognise initializer_list injected-class-name types as initializer_lists

2023-07-27 Thread Mital Ashok via Phabricator via cfe-commits
MitalAshok updated this revision to Diff 544673.
MitalAshok added a comment.

wording of changelog


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156064

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp


Index: clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
===
--- clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
+++ clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
@@ -12,14 +12,19 @@
 size_t n;
 initializer_list();
   };
-  // FIXME: This should probably not be necessary.
-  template initializer_list(initializer_list) -> 
initializer_list;
 }
 
 template constexpr bool has_type(...) { return false; }
 template constexpr bool has_type(T&) { return true; }
 
-std::initializer_list il = {1, 2, 3, 4, 5};
+std::initializer_list il1 = {1, 2, 3, 4, 5};
+auto il2 = std::initializer_list{1, 2, 3, 4};
+auto il3 = std::initializer_list{il1};
+auto il4 = std::initializer_list{il1, il1, il1};
+static_assert(has_type>(il1));
+static_assert(has_type>(il2));
+static_assert(has_type>(il3));
+static_assert(has_type>>(il4));
 
 template struct vector {
   template vector(Iter, Iter);
Index: clang/lib/Sema/SemaInit.cpp
===
--- clang/lib/Sema/SemaInit.cpp
+++ clang/lib/Sema/SemaInit.cpp
@@ -10589,8 +10589,6 @@
   // FIXME: Perform "exact type" matching first, per CWG discussion?
   //Or implement this via an implied 'T(T) -> T' deduction guide?
 
-  // FIXME: Do we need/want a std::initializer_list special case?
-
   // Look up deduction guides, including those synthesized from constructors.
   //
   // C++1z [over.match.class.deduct]p1:
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -11749,11 +11749,17 @@
 
 Template = Specialization->getSpecializedTemplate();
 Arguments = Specialization->getTemplateArgs().data();
-  } else if (const TemplateSpecializationType *TST =
- Ty->getAs()) {
-Template = dyn_cast_or_null(
-TST->getTemplateName().getAsTemplateDecl());
-Arguments = TST->template_arguments().begin();
+  } else {
+const TemplateSpecializationType *TST = nullptr;
+if (auto *ICN = Ty->getAs())
+  TST = ICN->getInjectedTST();
+else
+  TST = Ty->getAs();
+if (TST) {
+  Template = dyn_cast_or_null(
+  TST->getTemplateName().getAsTemplateDecl());
+  Arguments = TST->template_arguments().begin();
+}
   }
   if (!Template)
 return false;
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -108,6 +108,10 @@
 Bug Fixes to C++ Support
 
 
+- Fix CTAD for ``std::initializer_list``. This allows
+  ``std::initializer_list{1, 2, 3}`` to be deduced as
+  ``std::initializer_list`` as intended.
+
 Bug Fixes to AST Handling
 ^
 


Index: clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
===
--- clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
+++ clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
@@ -12,14 +12,19 @@
 size_t n;
 initializer_list();
   };
-  // FIXME: This should probably not be necessary.
-  template initializer_list(initializer_list) -> initializer_list;
 }
 
 template constexpr bool has_type(...) { return false; }
 template constexpr bool has_type(T&) { return true; }
 
-std::initializer_list il = {1, 2, 3, 4, 5};
+std::initializer_list il1 = {1, 2, 3, 4, 5};
+auto il2 = std::initializer_list{1, 2, 3, 4};
+auto il3 = std::initializer_list{il1};
+auto il4 = std::initializer_list{il1, il1, il1};
+static_assert(has_type>(il1));
+static_assert(has_type>(il2));
+static_assert(has_type>(il3));
+static_assert(has_type>>(il4));
 
 template struct vector {
   template vector(Iter, Iter);
Index: clang/lib/Sema/SemaInit.cpp
===
--- clang/lib/Sema/SemaInit.cpp
+++ clang/lib/Sema/SemaInit.cpp
@@ -10589,8 +10589,6 @@
   // FIXME: Perform "exact type" matching first, per CWG discussion?
   //Or implement this via an implied 'T(T) -> T' deduction guide?
 
-  // FIXME: Do we need/want a std::initializer_list special case?
-
   // Look up deduction guides, including those synthesized from constructors.
   //
   // C++1z [over.match.class.deduct]p1:
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/

[PATCH] D156351: clang driver throws error for -mabi=elfv2 or elfv2

2023-07-27 Thread Kishan Parmar via Phabricator via cfe-commits
long5hot updated this revision to Diff 544674.
long5hot added a comment.
Herald added a subscriber: kbarton.

failure is only when we do not give full target triple.
for e.x. --target=ppc64 -mabi=elfv2 
or even when OS option is unknown e.g. --target=powerpc64-unknown-gnu


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156351

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/ppc-abi.c


Index: clang/test/Driver/ppc-abi.c
===
--- clang/test/Driver/ppc-abi.c
+++ clang/test/Driver/ppc-abi.c
@@ -15,6 +15,10 @@
 // RUN:   -mabi=elfv2 | FileCheck -check-prefix=CHECK-ELFv2 %s
 // RUN: %clang -target powerpc64le-unknown-linux-gnu %s -### -o %t.o 2>&1 \
 // RUN:   -mabi=altivec | FileCheck -check-prefix=CHECK-ELFv2 %s
+// RUN: %clang -target powerpc64le-unknown-unknown-gnu %s -### -o %t.o 2>&1 \
+// RUN:   -mabi=elfv1 | FileCheck -check-prefix=CHECK-UNKNOWN-ELFv1 %s
+// RUN: %clang -target powerpc64le-unknown-unknown-gnu %s -### -o %t.o 2>&1 \
+// RUN:   -mabi=elfv2 | FileCheck -check-prefix=CHECK-UNKNOWN-ELFv2 %s
 
 // RUN: %clang -target powerpc64-unknown-freebsd11 %s -### 2>&1 | FileCheck 
--check-prefix=CHECK-ELFv1 %s
 // RUN: %clang -target powerpc64-unknown-freebsd12 %s -### 2>&1 | FileCheck 
--check-prefix=CHECK-ELFv1 %s
@@ -31,6 +35,8 @@
 // CHECK-ELFv2-BE: "-target-abi" "elfv2"
 // CHECK-ELFv2-BE-PIE: "-mrelocation-model" "pic" "-pic-level" "2" 
"-pic-is-pie"
 // CHECK-ELFv2-BE-PIE: "-target-abi" "elfv2"
+// CHECK-UNKNOWN-ELFv1: "-target-abi" "elfv1"
+// CHECK-UNKNOWN-ELFv2: "-target-abi" "elfv2"
 
 // RUN: %clang -fPIC -target powerpc64-unknown-linux-gnu %s -### -o %t.o 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-ELFv1-PIC %s
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -2068,6 +2068,12 @@
 } else if (V == "vec-extabi") {
   VecExtabi = true;
   A->claim();
+} else if (V == "elfv1") {
+  ABIName = "elfv1";
+  A->claim();
+} else if (V == "elfv2") {
+  ABIName = "elfv2";
+  A->claim();
 } else if (V != "altivec")
   // The ppc64 linux abis are all "altivec" abis by default. Accept and 
ignore
   // the option if given as we don't have backend support for any targets


Index: clang/test/Driver/ppc-abi.c
===
--- clang/test/Driver/ppc-abi.c
+++ clang/test/Driver/ppc-abi.c
@@ -15,6 +15,10 @@
 // RUN:   -mabi=elfv2 | FileCheck -check-prefix=CHECK-ELFv2 %s
 // RUN: %clang -target powerpc64le-unknown-linux-gnu %s -### -o %t.o 2>&1 \
 // RUN:   -mabi=altivec | FileCheck -check-prefix=CHECK-ELFv2 %s
+// RUN: %clang -target powerpc64le-unknown-unknown-gnu %s -### -o %t.o 2>&1 \
+// RUN:   -mabi=elfv1 | FileCheck -check-prefix=CHECK-UNKNOWN-ELFv1 %s
+// RUN: %clang -target powerpc64le-unknown-unknown-gnu %s -### -o %t.o 2>&1 \
+// RUN:   -mabi=elfv2 | FileCheck -check-prefix=CHECK-UNKNOWN-ELFv2 %s
 
 // RUN: %clang -target powerpc64-unknown-freebsd11 %s -### 2>&1 | FileCheck --check-prefix=CHECK-ELFv1 %s
 // RUN: %clang -target powerpc64-unknown-freebsd12 %s -### 2>&1 | FileCheck --check-prefix=CHECK-ELFv1 %s
@@ -31,6 +35,8 @@
 // CHECK-ELFv2-BE: "-target-abi" "elfv2"
 // CHECK-ELFv2-BE-PIE: "-mrelocation-model" "pic" "-pic-level" "2" "-pic-is-pie"
 // CHECK-ELFv2-BE-PIE: "-target-abi" "elfv2"
+// CHECK-UNKNOWN-ELFv1: "-target-abi" "elfv1"
+// CHECK-UNKNOWN-ELFv2: "-target-abi" "elfv2"
 
 // RUN: %clang -fPIC -target powerpc64-unknown-linux-gnu %s -### -o %t.o 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-ELFv1-PIC %s
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -2068,6 +2068,12 @@
 } else if (V == "vec-extabi") {
   VecExtabi = true;
   A->claim();
+} else if (V == "elfv1") {
+  ABIName = "elfv1";
+  A->claim();
+} else if (V == "elfv2") {
+  ABIName = "elfv2";
+  A->claim();
 } else if (V != "altivec")
   // The ppc64 linux abis are all "altivec" abis by default. Accept and ignore
   // the option if given as we don't have backend support for any targets
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D156411: [clang][dataflow] HTMLLogger: Don't crash if CFG contains unreachable blocks.

2023-07-27 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/D156411

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


Index: clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp
===
--- clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp
+++ clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp
@@ -458,8 +458,9 @@
   GraphS << "  " << blockID(I) << " [id=" << blockID(I) << "]\n";
 for (const auto *Block : CFG) {
   for (const auto &Succ : Block->succs()) {
-GraphS << "  " << blockID(Block->getBlockID()) << " -> "
-   << blockID(Succ.getReachableBlock()->getBlockID()) << "\n";
+if (Succ.getReachableBlock())
+  GraphS << "  " << blockID(Block->getBlockID()) << " -> "
+ << blockID(Succ.getReachableBlock()->getBlockID()) << "\n";
   }
 }
 GraphS << "}\n";


Index: clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp
===
--- clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp
+++ clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp
@@ -458,8 +458,9 @@
   GraphS << "  " << blockID(I) << " [id=" << blockID(I) << "]\n";
 for (const auto *Block : CFG) {
   for (const auto &Succ : Block->succs()) {
-GraphS << "  " << blockID(Block->getBlockID()) << " -> "
-   << blockID(Succ.getReachableBlock()->getBlockID()) << "\n";
+if (Succ.getReachableBlock())
+  GraphS << "  " << blockID(Block->getBlockID()) << " -> "
+ << blockID(Succ.getReachableBlock()->getBlockID()) << "\n";
   }
 }
 GraphS << "}\n";
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 99ce17b - [clang][docs][OpenMP] Update status of OMPT support.

2023-07-27 Thread Michael Halkenhaeuser via cfe-commits

Author: Michael Halkenhaeuser
Date: 2023-07-27T06:16:13-04:00
New Revision: 99ce17b71c41190cd82f4c5382910d71cb673abe

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

LOG: [clang][docs][OpenMP] Update status of OMPT support.

Update documentation on implementation status of OMPT.

Reviewed By: jdoerfert

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

Added: 


Modified: 
clang/docs/OpenMPSupport.rst

Removed: 




diff  --git a/clang/docs/OpenMPSupport.rst b/clang/docs/OpenMPSupport.rst
index 20b9007ec8b107..bfae0a7e43f775 100644
--- a/clang/docs/OpenMPSupport.rst
+++ b/clang/docs/OpenMPSupport.rst
@@ -140,7 +140,7 @@ implementation.
 
+--+--+--+---+
 | OMPD | OMPD interfaces   
   | :part:`not upstream` | 
https://github.com/OpenMPToolsInterface/LLVM-openmp/tree/ompd-tests   |
 
+--+--+--+---+
-| OMPT | OMPT interfaces   
   | :part:`mostly done`  | 
  |
+| OMPT | OMPT interfaces (callback support)
   | :good:`done` | 
  |
 
+--+--+--+---+
 | thread affinity  | thread affinity   
   | :good:`done` | 
  |
 
+--+--+--+---+
@@ -355,7 +355,9 @@ implementation.
 
+--+--+--+---+
 | OMPT | new barrier state values added to 
ompt_state_t enum  | :none:`unclaimed`| 
  |
 
+--+--+--+---+
-| OMPT | new 'emi' callbacks for external monitoring 
interfaces   | :none:`unclaimed`|   
|
+| OMPT | new 'emi' callbacks for external monitoring 
interfaces   | :good:`done` |   
|
++--+--+--+---+
+| OMPT | device tracing interface  
   | :none:`unclaimed`| 
  |
 
+--+--+--+---+
 | task | 'strict' modifier for taskloop construct  
   | :none:`unclaimed`| 
  |
 
+--+--+--+---+



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


[PATCH] D156403: [clangd] Revert the symbol collector behavior to old pre-include-cleaner-library behavior due to a regression.

2023-07-27 Thread Viktoriia Bakalova via Phabricator via cfe-commits
VitaNuo updated this revision to Diff 544684.
VitaNuo marked 6 inline comments as done.
VitaNuo added a comment.

Address comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156403

Files:
  clang-tools-extra/clangd/index/SymbolCollector.cpp
  clang-tools-extra/clangd/index/SymbolCollector.h
  clang-tools-extra/clangd/unittests/FileIndexTests.cpp
  clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp

Index: clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
===
--- clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
+++ clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
@@ -1592,7 +1592,7 @@
  includeHeader("\"the/good/header.h\"";
 }
 
-TEST_F(SymbolCollectorTest, IWYUPragmaExport) {
+TEST_F(SymbolCollectorTest, DISABLED_IWYUPragmaExport) {
   CollectorOpts.CollectIncludePath = true;
   const std::string Header = R"cpp(#pragma once
 #include "exporter.h"
Index: clang-tools-extra/clangd/unittests/FileIndexTests.cpp
===
--- clang-tools-extra/clangd/unittests/FileIndexTests.cpp
+++ clang-tools-extra/clangd/unittests/FileIndexTests.cpp
@@ -239,7 +239,7 @@
   "");
 }
 
-TEST(FileIndexTest, IWYUPragmaExport) {
+TEST(FileIndexTest, DISABLED_IWYUPragmaExport) {
   FileIndex M;
 
   TestTU File;
Index: clang-tools-extra/clangd/index/SymbolCollector.h
===
--- clang-tools-extra/clangd/index/SymbolCollector.h
+++ clang-tools-extra/clangd/index/SymbolCollector.h
@@ -175,11 +175,6 @@
   void setIncludeLocation(const Symbol &S, SourceLocation,
   const include_cleaner::Symbol &Sym);
 
-  // Providers for Symbol.IncludeHeaders.
-  // The final spelling is calculated in finish().
-  llvm::DenseMap>
-  SymbolProviders;
-
   // Files which contain ObjC symbols.
   // This is finalized and used in finish().
   llvm::DenseSet FilesWithObjCConstructs;
Index: clang-tools-extra/clangd/index/SymbolCollector.cpp
===
--- clang-tools-extra/clangd/index/SymbolCollector.cpp
+++ clang-tools-extra/clangd/index/SymbolCollector.cpp
@@ -36,6 +36,7 @@
 #include "clang/Lex/Preprocessor.h"
 #include "clang/Lex/Token.h"
 #include "clang/Tooling/Inclusions/HeaderAnalysis.h"
+#include "clang/Tooling/Inclusions/StandardLibrary.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/SmallVector.h"
@@ -836,14 +837,6 @@
   // Use the expansion location to get the #include header since this is
   // where the symbol is exposed.
   IncludeFiles[S.ID] = SM.getDecomposedExpansionLoc(DefLoc).first;
-
-  auto [It, Inserted] = SymbolProviders.try_emplace(S.ID);
-  if (Inserted) {
-auto Headers =
-include_cleaner::headersForSymbol(Sym, SM, Opts.PragmaIncludes);
-if (!Headers.empty())
-  It->second = Headers.front();
-  }
 }
 
 void SymbolCollector::finish() {
@@ -869,16 +862,13 @@
 }
   }
   llvm::DenseMap FileToContainsImportsOrObjC;
-  llvm::DenseMap HeaderSpelling;
   // Fill in IncludeHeaders.
   // We delay this until end of TU so header guards are all resolved.
-  for (const auto &[SID, OptionalProvider] : SymbolProviders) {
+  for (const auto &[SID, FID] : IncludeFiles) {
 const Symbol *S = Symbols.find(SID);
 if (!S)
   continue;
-assert(IncludeFiles.find(SID) != IncludeFiles.end());
 
-const auto FID = IncludeFiles.at(SID);
 // Determine if the FID is #include'd or #import'ed.
 Symbol::IncludeDirective Directives = Symbol::Invalid;
 auto CollectDirectives = shouldCollectIncludePath(S->SymInfo.Kind);
@@ -898,54 +888,32 @@
 if (Directives == Symbol::Invalid)
   continue;
 
-// Use the include location-based logic for Objective-C symbols.
-if (Directives & Symbol::Import) {
-  if (auto IncludeHeader = HeaderFileURIs->getIncludeHeader(FID);
-  !IncludeHeader.empty()) {
-auto NewSym = *S;
-NewSym.IncludeHeaders.push_back({IncludeHeader, 1, Directives});
-Symbols.insert(NewSym);
-  }
-  // FIXME: use providers from include-cleaner library once it's polished
-  // for Objective-C.
-  continue;
+// FIXME: Use the include-cleaner library instead.
+tooling::stdlib::Lang Lang = tooling::stdlib::Lang::CXX;
+if (ASTCtx->getLangOpts().C11)
+  Lang = tooling::stdlib::Lang::C;
+llvm::StringRef IncludeHeader;
+if (S->Scope == "std::" && S->Name == "move") {
+  IncludeHeader = "";
+  if (S->Signature.contains(','))
+IncludeHeader = "";
 }
+if (auto StdSym = tooling::stdlib::Symbol::named(S->Scope, S->Name, Lang))
+  if (auto Header = StdSym->header())
+IncludeHeader = Header->name();
 
-assert(Dire

[PATCH] D156336: [clang][docs][OpenMP] Update status of OMPT support.

2023-07-27 Thread Michael Halkenhäuser 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 rG99ce17b71c41: [clang][docs][OpenMP] Update status of OMPT 
support. (authored by mhalk).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156336

Files:
  clang/docs/OpenMPSupport.rst


Index: clang/docs/OpenMPSupport.rst
===
--- clang/docs/OpenMPSupport.rst
+++ clang/docs/OpenMPSupport.rst
@@ -140,7 +140,7 @@
 
+--+--+--+---+
 | OMPD | OMPD interfaces   
   | :part:`not upstream` | 
https://github.com/OpenMPToolsInterface/LLVM-openmp/tree/ompd-tests   |
 
+--+--+--+---+
-| OMPT | OMPT interfaces   
   | :part:`mostly done`  | 
  |
+| OMPT | OMPT interfaces (callback support)
   | :good:`done` | 
  |
 
+--+--+--+---+
 | thread affinity  | thread affinity   
   | :good:`done` | 
  |
 
+--+--+--+---+
@@ -355,7 +355,9 @@
 
+--+--+--+---+
 | OMPT | new barrier state values added to 
ompt_state_t enum  | :none:`unclaimed`| 
  |
 
+--+--+--+---+
-| OMPT | new 'emi' callbacks for external monitoring 
interfaces   | :none:`unclaimed`|   
|
+| OMPT | new 'emi' callbacks for external monitoring 
interfaces   | :good:`done` |   
|
++--+--+--+---+
+| OMPT | device tracing interface  
   | :none:`unclaimed`| 
  |
 
+--+--+--+---+
 | task | 'strict' modifier for taskloop construct  
   | :none:`unclaimed`| 
  |
 
+--+--+--+---+


Index: clang/docs/OpenMPSupport.rst
===
--- clang/docs/OpenMPSupport.rst
+++ clang/docs/OpenMPSupport.rst
@@ -140,7 +140,7 @@
 +--+--+--+---+
 | OMPD | OMPD interfaces  | :part:`not upstream` | https://github.com/OpenMPToolsInterface/LLVM-openmp/tree/ompd-tests   |
 +--+--+--+---+
-| OMPT | OM

[PATCH] D156415: [NFC][clang] Fix static analyzer concerns

2023-07-27 Thread Mariya Podchishchaeva via Phabricator via cfe-commits
Fznamznon created this revision.
Herald added subscribers: manas, ASDenysPetrov, dkrupp, donat.nagy, Szelethus, 
a.sidorin, baloghadamsoftware.
Herald added a reviewer: NoQ.
Herald added a project: All.
Fznamznon requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

CFGStmtMap frees resources in the destructor but doesn't
have user-written copy c'tor or assignment operator, so copying it using
default ones can cause double free.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D156415

Files:
  clang/include/clang/Analysis/CFGStmtMap.h


Index: clang/include/clang/Analysis/CFGStmtMap.h
===
--- clang/include/clang/Analysis/CFGStmtMap.h
+++ clang/include/clang/Analysis/CFGStmtMap.h
@@ -26,6 +26,8 @@
   void *M;
 
   CFGStmtMap(ParentMap *pm, void *m) : PM(pm), M(m) {}
+  CFGStmtMap(const CFGStmtMap &) = delete;
+  CFGStmtMap &operator=(const CFGStmtMap &) = delete;
 
 public:
   ~CFGStmtMap();


Index: clang/include/clang/Analysis/CFGStmtMap.h
===
--- clang/include/clang/Analysis/CFGStmtMap.h
+++ clang/include/clang/Analysis/CFGStmtMap.h
@@ -26,6 +26,8 @@
   void *M;
 
   CFGStmtMap(ParentMap *pm, void *m) : PM(pm), M(m) {}
+  CFGStmtMap(const CFGStmtMap &) = delete;
+  CFGStmtMap &operator=(const CFGStmtMap &) = delete;
 
 public:
   ~CFGStmtMap();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D156403: [clangd] Revert the symbol collector behavior to old pre-include-cleaner-library behavior due to a regression.

2023-07-27 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet accepted this revision.
kadircet added inline comments.
This revision is now accepted and ready to land.



Comment at: clang-tools-extra/clangd/index/SymbolCollector.cpp:901
 }
+if (auto StdSym = tooling::stdlib::Symbol::named(S->Scope, S->Name, Lang))
+  if (auto Header = StdSym->header())

we shouldn't be overriding the include header if it's already set above. also i 
think it would be easier to have this out of the way so that reverting to old 
behaviour is easier:
```
llvm::StringRef getStdHeader(const Symbol *S, const LanguageOptions &LO) {
  tooling::stdlib::Lang Lang = tooling::stdlib::Lang::CXX;
if (ASTCtx->getLangOpts().C11)
  Lang = tooling::stdlib::Lang::C;
else if(!ASTCtx->getLangOpts().CPlusPlus)
  return "";

if (S->Scope == "std::" && S->Name == "move") {
  if (!S->Signature.contains(','))
return "";
  return "";
}
   
if (auto StdSym = tooling::stdlib::Symbol::named(S->Scope, S->Name, Lang))
 if (auto Header = StdSym->header())
   return Header->name();
return "";
}
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156403

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


[PATCH] D144634: [Clang][OpenMP] Support for Code Generation of loop bind clause

2023-07-27 Thread Sunil K via Phabricator via cfe-commits
koops updated this revision to Diff 544688.
koops added a comment.

Correction for clang-format errors.


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

https://reviews.llvm.org/D144634

Files:
  clang/include/clang/AST/StmtOpenMP.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/TreeTransform.h
  clang/test/OpenMP/generic_loop_ast_print.cpp
  clang/test/OpenMP/generic_loop_codegen.cpp
  clang/test/OpenMP/loop_bind_codegen.cpp
  clang/test/OpenMP/loop_bind_enclosed.cpp
  clang/test/OpenMP/loop_bind_messages.cpp
  clang/test/OpenMP/nested_loop_codegen.cpp

Index: clang/test/OpenMP/nested_loop_codegen.cpp
===
--- clang/test/OpenMP/nested_loop_codegen.cpp
+++ clang/test/OpenMP/nested_loop_codegen.cpp
@@ -58,6 +58,12 @@
 // CHECK1-NEXT:[[DOTGLOBAL_TID__ADDR:%.*]] = alloca ptr, align 8
 // CHECK1-NEXT:[[DOTBOUND_TID__ADDR:%.*]] = alloca ptr, align 8
 // CHECK1-NEXT:[[I_ADDR:%.*]] = alloca ptr, align 8
+// CHECK1-NEXT:[[TMP:%.*]] = alloca i32, align 4
+// CHECK1-NEXT:[[DOTOMP_IV:%.*]] = alloca i32, align 4
+// CHECK1-NEXT:[[DOTOMP_LB:%.*]] = alloca i32, align 4
+// CHECK1-NEXT:[[DOTOMP_UB:%.*]] = alloca i32, align 4
+// CHECK1-NEXT:[[DOTOMP_STRIDE:%.*]] = alloca i32, align 4
+// CHECK1-NEXT:[[DOTOMP_IS_LAST:%.*]] = alloca i32, align 4
 // CHECK1-NEXT:[[K:%.*]] = alloca i32, align 4
 // CHECK1-NEXT:store ptr [[DOTGLOBAL_TID_]], ptr [[DOTGLOBAL_TID__ADDR]], align 8
 // CHECK1-NEXT:store ptr [[DOTBOUND_TID_]], ptr [[DOTBOUND_TID__ADDR]], align 8
@@ -66,35 +72,27 @@
 // CHECK1-NEXT:store i32 0, ptr [[TMP0]], align 4
 // CHECK1-NEXT:br label [[FOR_COND:%.*]]
 // CHECK1:   for.cond:
-// CHECK1-NEXT:[[TMP1:%.*]] = load i32, ptr [[TMP0]], align 4
-// CHECK1-NEXT:[[CMP:%.*]] = icmp slt i32 [[TMP1]], 10
-// CHECK1-NEXT:br i1 [[CMP]], label [[FOR_BODY:%.*]], label [[FOR_END7:%.*]]
 // CHECK1:   for.body:
-// CHECK1-NEXT:store i32 0, ptr [[K]], align 4
-// CHECK1-NEXT:br label [[FOR_COND1:%.*]]
-// CHECK1:   for.cond1:
-// CHECK1-NEXT:[[TMP2:%.*]] = load i32, ptr [[K]], align 4
-// CHECK1-NEXT:[[CMP2:%.*]] = icmp slt i32 [[TMP2]], 5
-// CHECK1-NEXT:br i1 [[CMP2]], label [[FOR_BODY3:%.*]], label [[FOR_END:%.*]]
-// CHECK1:   for.body3:
-// CHECK1-NEXT:[[TMP3:%.*]] = load i32, ptr [[K]], align 4
-// CHECK1-NEXT:[[INC:%.*]] = add nsw i32 [[TMP3]], 1
-// CHECK1-NEXT:store i32 [[INC]], ptr [[K]], align 4
-// CHECK1-NEXT:br label [[FOR_INC:%.*]]
-// CHECK1:   for.inc:
-// CHECK1-NEXT:[[TMP4:%.*]] = load i32, ptr [[K]], align 4
-// CHECK1-NEXT:[[INC4:%.*]] = add nsw i32 [[TMP4]], 1
-// CHECK1-NEXT:store i32 [[INC4]], ptr [[K]], align 4
-// CHECK1-NEXT:br label [[FOR_COND1]], !llvm.loop [[LOOP3:![0-9]+]]
-// CHECK1:   for.end:
-// CHECK1-NEXT:br label [[FOR_INC5:%.*]]
-// CHECK1:   for.inc5:
-// CHECK1-NEXT:[[TMP5:%.*]] = load i32, ptr [[TMP0]], align 4
-// CHECK1-NEXT:[[INC6:%.*]] = add nsw i32 [[TMP5]], 1
-// CHECK1-NEXT:store i32 [[INC6]], ptr [[TMP0]], align 4
-// CHECK1-NEXT:br label [[FOR_COND]], !llvm.loop [[LOOP5:![0-9]+]]
-// CHECK1:   for.end7:
-// CHECK1-NEXT:ret void
+// CHECK1-NEXT [[TMP2:%.*]] = load ptr, ptr [[DOTGLOBAL_TID__ADDR]], align 8
+// CHECK1-NEXT [[TMP3:%.*]] = load i32, ptr [[TMP2]], align 4
+// CHECK1-NEXT call void @__kmpc_for_static_init_4(ptr @1, i32 [[TMP3]], i32 34, ptr [[DOTOMP_IS_LAST]], ptr [[DOTOMP_LB]], ptr [[DOTOMP_UB]], ptr [[DOTOMP_STRIDE]], i32 1, i32 1)
+//CHECK1 cond.end:
+//CHECK1 omp.inner.for.cond:
+//CHECK1 omp.inner.for.body:
+//CHECK1 omp.body.continue:
+//CHECK1 omp.inner.for.inc:
+//CHECK1 omp.inner.for.end:
+//CHECK1 omp.loop.exit:
+// CHECK1-NEXT [[TMP13:%.*]] = load ptr, ptr [[DOTGLOBAL_TID__ADDR]], align 8
+// CHECK1-NEXT [[TMP14:%.*]] = load i32, ptr [[TMP12]], align 4
+// CHECK1-NEXT call void @__kmpc_for_static_fini(ptr @1, i32 [[TMP14]])
+// CHECK1-NEXT [[TMP15:%.*]] = load ptr, ptr [[DOTGLOBAL_TID__ADDR]], align 8
+// CHECK1-NEXT [[TMP16:%.*]] = load i32, ptr [[TMP15]], align 4
+// CHECK1-NEXT call void @__kmpc_barrier(ptr @2, i32 [[TMP16]])
+//CHECK1 for.inc:
+//CHECK1 for.end:
+// CHECK1-NEXT ret void
+//
 //
 //
 // CHECK1-LABEL: define {{[^@]+}}@_Z11inline_declv
@@ -114,45 +112,36 @@
 // CHECK1-NEXT:[[DOTBOUND_TID__ADDR:%.*]] = alloca ptr, align 8
 // CHECK1-NEXT:[[I_ADDR:%.*]] = alloca ptr, align 8
 // CHECK1-NEXT:[[RES_ADDR:%.*]] = alloca ptr, align 8
-// CHECK1-NEXT:[[K:%.*]] = alloca i32, align 4
-// CHECK1-NEXT:store ptr [[DOTGLOBAL_TID_]], ptr [[DOTGLOBAL_TID__ADDR]], align 8
-// CHECK1-NEXT:store ptr [[DOTBOUND_TID_]], ptr [[DOTBOUND_TID__ADDR]], align 8
-// CHECK1-NEXT:store ptr [[I]], ptr [[I_ADDR]], align 8
-// CHECK1

[PATCH] D156403: [clangd] Revert the symbol collector behavior to old pre-include-cleaner-library behavior due to a regression.

2023-07-27 Thread Viktoriia Bakalova via Phabricator via cfe-commits
VitaNuo updated this revision to Diff 544689.
VitaNuo marked an inline comment as done.
VitaNuo added a comment.

Address comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156403

Files:
  clang-tools-extra/clangd/index/SymbolCollector.cpp
  clang-tools-extra/clangd/index/SymbolCollector.h
  clang-tools-extra/clangd/unittests/FileIndexTests.cpp
  clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp

Index: clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
===
--- clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
+++ clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
@@ -1592,7 +1592,7 @@
  includeHeader("\"the/good/header.h\"";
 }
 
-TEST_F(SymbolCollectorTest, IWYUPragmaExport) {
+TEST_F(SymbolCollectorTest, DISABLED_IWYUPragmaExport) {
   CollectorOpts.CollectIncludePath = true;
   const std::string Header = R"cpp(#pragma once
 #include "exporter.h"
Index: clang-tools-extra/clangd/unittests/FileIndexTests.cpp
===
--- clang-tools-extra/clangd/unittests/FileIndexTests.cpp
+++ clang-tools-extra/clangd/unittests/FileIndexTests.cpp
@@ -239,7 +239,7 @@
   "");
 }
 
-TEST(FileIndexTest, IWYUPragmaExport) {
+TEST(FileIndexTest, DISABLED_IWYUPragmaExport) {
   FileIndex M;
 
   TestTU File;
Index: clang-tools-extra/clangd/index/SymbolCollector.h
===
--- clang-tools-extra/clangd/index/SymbolCollector.h
+++ clang-tools-extra/clangd/index/SymbolCollector.h
@@ -175,11 +175,6 @@
   void setIncludeLocation(const Symbol &S, SourceLocation,
   const include_cleaner::Symbol &Sym);
 
-  // Providers for Symbol.IncludeHeaders.
-  // The final spelling is calculated in finish().
-  llvm::DenseMap>
-  SymbolProviders;
-
   // Files which contain ObjC symbols.
   // This is finalized and used in finish().
   llvm::DenseSet FilesWithObjCConstructs;
Index: clang-tools-extra/clangd/index/SymbolCollector.cpp
===
--- clang-tools-extra/clangd/index/SymbolCollector.cpp
+++ clang-tools-extra/clangd/index/SymbolCollector.cpp
@@ -36,6 +36,7 @@
 #include "clang/Lex/Preprocessor.h"
 #include "clang/Lex/Token.h"
 #include "clang/Tooling/Inclusions/HeaderAnalysis.h"
+#include "clang/Tooling/Inclusions/StandardLibrary.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/SmallVector.h"
@@ -836,14 +837,25 @@
   // Use the expansion location to get the #include header since this is
   // where the symbol is exposed.
   IncludeFiles[S.ID] = SM.getDecomposedExpansionLoc(DefLoc).first;
+}
 
-  auto [It, Inserted] = SymbolProviders.try_emplace(S.ID);
-  if (Inserted) {
-auto Headers =
-include_cleaner::headersForSymbol(Sym, SM, Opts.PragmaIncludes);
-if (!Headers.empty())
-  It->second = Headers.front();
-  }
+llvm::StringRef getStdHeader(const Symbol *S, const LangOptions &LangOpts) {
+  tooling::stdlib::Lang Lang = tooling::stdlib::Lang::CXX;
+if (LangOpts.C11)
+  Lang = tooling::stdlib::Lang::C;
+else if(!LangOpts.CPlusPlus)
+  return "";
+
+if (S->Scope == "std::" && S->Name == "move") {
+  if (!S->Signature.contains(','))
+return "";
+  return "";
+}
+   
+if (auto StdSym = tooling::stdlib::Symbol::named(S->Scope, S->Name, Lang))
+ if (auto Header = StdSym->header())
+   return Header->name();
+return "";
 }
 
 void SymbolCollector::finish() {
@@ -869,16 +881,13 @@
 }
   }
   llvm::DenseMap FileToContainsImportsOrObjC;
-  llvm::DenseMap HeaderSpelling;
   // Fill in IncludeHeaders.
   // We delay this until end of TU so header guards are all resolved.
-  for (const auto &[SID, OptionalProvider] : SymbolProviders) {
+  for (const auto &[SID, FID] : IncludeFiles) {
 const Symbol *S = Symbols.find(SID);
 if (!S)
   continue;
-assert(IncludeFiles.find(SID) != IncludeFiles.end());
 
-const auto FID = IncludeFiles.at(SID);
 // Determine if the FID is #include'd or #import'ed.
 Symbol::IncludeDirective Directives = Symbol::Invalid;
 auto CollectDirectives = shouldCollectIncludePath(S->SymInfo.Kind);
@@ -898,54 +907,20 @@
 if (Directives == Symbol::Invalid)
   continue;
 
-// Use the include location-based logic for Objective-C symbols.
-if (Directives & Symbol::Import) {
-  if (auto IncludeHeader = HeaderFileURIs->getIncludeHeader(FID);
-  !IncludeHeader.empty()) {
-auto NewSym = *S;
-NewSym.IncludeHeaders.push_back({IncludeHeader, 1, Directives});
-Symbols.insert(NewSym);
-  }
-  // FIXME: use providers from include-cleaner library once it's polished
-  // for Objective-C.
-  continu

[PATCH] D156403: [clangd] Revert the symbol collector behavior to old pre-include-cleaner-library behavior due to a regression.

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



Comment at: clang-tools-extra/clangd/index/SymbolCollector.cpp:842
 
-  auto [It, Inserted] = SymbolProviders.try_emplace(S.ID);
-  if (Inserted) {
-auto Headers =
-include_cleaner::headersForSymbol(Sym, SM, Opts.PragmaIncludes);
-if (!Headers.empty())
-  It->second = Headers.front();
-  }
+llvm::StringRef getStdHeader(const Symbol *S, const LangOptions &LangOpts) {
+  tooling::stdlib::Lang Lang = tooling::stdlib::Lang::CXX;

can you also move this into an anonymous namespace?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156403

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


[clang-tools-extra] 3c6a7b0 - [clangd] Revert the symbol collector behavior to old pre-include-cleaner-library behavior due to a regression.

2023-07-27 Thread Viktoriia Bakalova via cfe-commits

Author: Viktoriia Bakalova
Date: 2023-07-27T10:34:35Z
New Revision: 3c6a7b0045afe9a230346e476bf07f88c145fdb5

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

LOG: [clangd] Revert the symbol collector behavior to old 
pre-include-cleaner-library behavior due to a regression.

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

Added: 


Modified: 
clang-tools-extra/clangd/index/SymbolCollector.cpp
clang-tools-extra/clangd/index/SymbolCollector.h
clang-tools-extra/clangd/unittests/FileIndexTests.cpp
clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/index/SymbolCollector.cpp 
b/clang-tools-extra/clangd/index/SymbolCollector.cpp
index e9522171d70b75..c9a211b9c4fc2c 100644
--- a/clang-tools-extra/clangd/index/SymbolCollector.cpp
+++ b/clang-tools-extra/clangd/index/SymbolCollector.cpp
@@ -36,6 +36,7 @@
 #include "clang/Lex/Preprocessor.h"
 #include "clang/Lex/Token.h"
 #include "clang/Tooling/Inclusions/HeaderAnalysis.h"
+#include "clang/Tooling/Inclusions/StandardLibrary.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/SmallVector.h"
@@ -836,14 +837,25 @@ void SymbolCollector::setIncludeLocation(const Symbol &S, 
SourceLocation DefLoc,
   // Use the expansion location to get the #include header since this is
   // where the symbol is exposed.
   IncludeFiles[S.ID] = SM.getDecomposedExpansionLoc(DefLoc).first;
+}
 
-  auto [It, Inserted] = SymbolProviders.try_emplace(S.ID);
-  if (Inserted) {
-auto Headers =
-include_cleaner::headersForSymbol(Sym, SM, Opts.PragmaIncludes);
-if (!Headers.empty())
-  It->second = Headers.front();
-  }
+llvm::StringRef getStdHeader(const Symbol *S, const LangOptions &LangOpts) {
+  tooling::stdlib::Lang Lang = tooling::stdlib::Lang::CXX;
+if (LangOpts.C11)
+  Lang = tooling::stdlib::Lang::C;
+else if(!LangOpts.CPlusPlus)
+  return "";
+
+if (S->Scope == "std::" && S->Name == "move") {
+  if (!S->Signature.contains(','))
+return "";
+  return "";
+}
+   
+if (auto StdSym = tooling::stdlib::Symbol::named(S->Scope, S->Name, Lang))
+ if (auto Header = StdSym->header())
+   return Header->name();
+return "";
 }
 
 void SymbolCollector::finish() {
@@ -869,16 +881,13 @@ void SymbolCollector::finish() {
 }
   }
   llvm::DenseMap FileToContainsImportsOrObjC;
-  llvm::DenseMap HeaderSpelling;
   // Fill in IncludeHeaders.
   // We delay this until end of TU so header guards are all resolved.
-  for (const auto &[SID, OptionalProvider] : SymbolProviders) {
+  for (const auto &[SID, FID] : IncludeFiles) {
 const Symbol *S = Symbols.find(SID);
 if (!S)
   continue;
-assert(IncludeFiles.find(SID) != IncludeFiles.end());
 
-const auto FID = IncludeFiles.at(SID);
 // Determine if the FID is #include'd or #import'ed.
 Symbol::IncludeDirective Directives = Symbol::Invalid;
 auto CollectDirectives = shouldCollectIncludePath(S->SymInfo.Kind);
@@ -898,54 +907,20 @@ void SymbolCollector::finish() {
 if (Directives == Symbol::Invalid)
   continue;
 
-// Use the include location-based logic for Objective-C symbols.
-if (Directives & Symbol::Import) {
-  if (auto IncludeHeader = HeaderFileURIs->getIncludeHeader(FID);
-  !IncludeHeader.empty()) {
-auto NewSym = *S;
-NewSym.IncludeHeaders.push_back({IncludeHeader, 1, Directives});
-Symbols.insert(NewSym);
-  }
-  // FIXME: use providers from include-cleaner library once it's polished
-  // for Objective-C.
-  continue;
-}
-
-assert(Directives == Symbol::Include);
-// For #include's, use the providers computed by the include-cleaner
-// library.
-if (!OptionalProvider)
-  continue;
-const auto &H = *OptionalProvider;
-const auto [SpellingIt, Inserted] = HeaderSpelling.try_emplace(H);
-if (Inserted) {
-  auto &SM = ASTCtx->getSourceManager();
-  if (H.kind() == include_cleaner::Header::Kind::Physical) {
-if (auto Canonical =
-HeaderFileURIs->mapCanonical(H.physical()->getName());
-!Canonical.empty())
-  SpellingIt->second = Canonical;
-else if (tooling::isSelfContainedHeader(H.physical(), SM,
-PP->getHeaderSearchInfo()))
-  SpellingIt->second =
-  HeaderFileURIs->toURI(H.physical()->getLastRef());
-  } else {
-SpellingIt->second = include_cleaner::spellHeader(
-{H, PP->getHeaderSearchInfo(),
- SM.getFileEntryForID(SM.getMainFileID())});
-  }
-}
+// FIXME: Use the include-cleaner library instead.
+llvm::StringRef IncludeHeade

[PATCH] D156403: [clangd] Revert the symbol collector behavior to old pre-include-cleaner-library behavior due to a regression.

2023-07-27 Thread Viktoriia Bakalova 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 rG3c6a7b0045af: [clangd] Revert the symbol collector behavior 
to old pre-include-cleaner… (authored by VitaNuo).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156403

Files:
  clang-tools-extra/clangd/index/SymbolCollector.cpp
  clang-tools-extra/clangd/index/SymbolCollector.h
  clang-tools-extra/clangd/unittests/FileIndexTests.cpp
  clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp

Index: clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
===
--- clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
+++ clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
@@ -1592,7 +1592,7 @@
  includeHeader("\"the/good/header.h\"";
 }
 
-TEST_F(SymbolCollectorTest, IWYUPragmaExport) {
+TEST_F(SymbolCollectorTest, DISABLED_IWYUPragmaExport) {
   CollectorOpts.CollectIncludePath = true;
   const std::string Header = R"cpp(#pragma once
 #include "exporter.h"
Index: clang-tools-extra/clangd/unittests/FileIndexTests.cpp
===
--- clang-tools-extra/clangd/unittests/FileIndexTests.cpp
+++ clang-tools-extra/clangd/unittests/FileIndexTests.cpp
@@ -239,7 +239,7 @@
   "");
 }
 
-TEST(FileIndexTest, IWYUPragmaExport) {
+TEST(FileIndexTest, DISABLED_IWYUPragmaExport) {
   FileIndex M;
 
   TestTU File;
Index: clang-tools-extra/clangd/index/SymbolCollector.h
===
--- clang-tools-extra/clangd/index/SymbolCollector.h
+++ clang-tools-extra/clangd/index/SymbolCollector.h
@@ -175,11 +175,6 @@
   void setIncludeLocation(const Symbol &S, SourceLocation,
   const include_cleaner::Symbol &Sym);
 
-  // Providers for Symbol.IncludeHeaders.
-  // The final spelling is calculated in finish().
-  llvm::DenseMap>
-  SymbolProviders;
-
   // Files which contain ObjC symbols.
   // This is finalized and used in finish().
   llvm::DenseSet FilesWithObjCConstructs;
Index: clang-tools-extra/clangd/index/SymbolCollector.cpp
===
--- clang-tools-extra/clangd/index/SymbolCollector.cpp
+++ clang-tools-extra/clangd/index/SymbolCollector.cpp
@@ -36,6 +36,7 @@
 #include "clang/Lex/Preprocessor.h"
 #include "clang/Lex/Token.h"
 #include "clang/Tooling/Inclusions/HeaderAnalysis.h"
+#include "clang/Tooling/Inclusions/StandardLibrary.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/SmallVector.h"
@@ -836,14 +837,25 @@
   // Use the expansion location to get the #include header since this is
   // where the symbol is exposed.
   IncludeFiles[S.ID] = SM.getDecomposedExpansionLoc(DefLoc).first;
+}
 
-  auto [It, Inserted] = SymbolProviders.try_emplace(S.ID);
-  if (Inserted) {
-auto Headers =
-include_cleaner::headersForSymbol(Sym, SM, Opts.PragmaIncludes);
-if (!Headers.empty())
-  It->second = Headers.front();
-  }
+llvm::StringRef getStdHeader(const Symbol *S, const LangOptions &LangOpts) {
+  tooling::stdlib::Lang Lang = tooling::stdlib::Lang::CXX;
+if (LangOpts.C11)
+  Lang = tooling::stdlib::Lang::C;
+else if(!LangOpts.CPlusPlus)
+  return "";
+
+if (S->Scope == "std::" && S->Name == "move") {
+  if (!S->Signature.contains(','))
+return "";
+  return "";
+}
+   
+if (auto StdSym = tooling::stdlib::Symbol::named(S->Scope, S->Name, Lang))
+ if (auto Header = StdSym->header())
+   return Header->name();
+return "";
 }
 
 void SymbolCollector::finish() {
@@ -869,16 +881,13 @@
 }
   }
   llvm::DenseMap FileToContainsImportsOrObjC;
-  llvm::DenseMap HeaderSpelling;
   // Fill in IncludeHeaders.
   // We delay this until end of TU so header guards are all resolved.
-  for (const auto &[SID, OptionalProvider] : SymbolProviders) {
+  for (const auto &[SID, FID] : IncludeFiles) {
 const Symbol *S = Symbols.find(SID);
 if (!S)
   continue;
-assert(IncludeFiles.find(SID) != IncludeFiles.end());
 
-const auto FID = IncludeFiles.at(SID);
 // Determine if the FID is #include'd or #import'ed.
 Symbol::IncludeDirective Directives = Symbol::Invalid;
 auto CollectDirectives = shouldCollectIncludePath(S->SymInfo.Kind);
@@ -898,54 +907,20 @@
 if (Directives == Symbol::Invalid)
   continue;
 
-// Use the include location-based logic for Objective-C symbols.
-if (Directives & Symbol::Import) {
-  if (auto IncludeHeader = HeaderFileURIs->getIncludeHeader(FID);
-  !IncludeHeader.empty()) {
-auto NewSym = *S;
-NewSym.IncludeHeaders.push_back({IncludeHeader, 1, Directives});
-Symbols.insert(NewSym);

[PATCH] D155546: [clang][Interp] Implement __builtin_fmin

2023-07-27 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder updated this revision to Diff 544691.

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

https://reviews.llvm.org/D155546

Files:
  clang/lib/AST/Interp/InterpBuiltin.cpp
  clang/test/AST/Interp/builtin-functions.cpp


Index: clang/test/AST/Interp/builtin-functions.cpp
===
--- clang/test/AST/Interp/builtin-functions.cpp
+++ clang/test/AST/Interp/builtin-functions.cpp
@@ -60,3 +60,15 @@
  // expected-note {{read of 
dereferenced one-past-the-end pointer}} \
  // expected-note {{in call to}}
 }
+
+namespace fmin {
+  constexpr float f1 = __builtin_fmin(1.0, 2.0f);
+  static_assert(f1 == 1.0f, "");
+
+  constexpr float min = __builtin_fmin(__builtin_nan(""), 1);
+  static_assert(min == 1, "");
+  constexpr float min2 = __builtin_fmin(1, __builtin_nan(""));
+  static_assert(min2 == 1, "");
+  constexpr float min3 = __builtin_fmin(__builtin_inf(), __builtin_nan(""));
+  static_assert(min3 == __builtin_inf(), "");
+}
Index: clang/lib/AST/Interp/InterpBuiltin.cpp
===
--- clang/lib/AST/Interp/InterpBuiltin.cpp
+++ clang/lib/AST/Interp/InterpBuiltin.cpp
@@ -143,6 +143,25 @@
   return true;
 }
 
+static bool interp__builtin_fmin(InterpState &S, CodePtr OpPC,
+ const InterpFrame *Frame, const Function *F) {
+  const Floating &LHS = getParam(Frame, 0);
+  const Floating &RHS = getParam(Frame, 1);
+
+  Floating Result;
+
+  // When comparing zeroes, return -0.0 if one of the zeroes is negative.
+  if (LHS.isZero() && RHS.isZero() && RHS.isNegative())
+Result = RHS;
+  else if (LHS.isNan() || RHS < LHS)
+Result = RHS;
+  else
+Result = LHS;
+
+  S.Stk.push(Result);
+  return true;
+}
+
 bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const Function *F) {
   InterpFrame *Frame = S.Current;
   APValue Dummy;
@@ -195,6 +214,14 @@
   return Ret(S, OpPC, Dummy);
 break;
 
+  case Builtin::BI__builtin_fmin:
+  case Builtin::BI__builtin_fminf:
+  case Builtin::BI__builtin_fminl:
+  case Builtin::BI__builtin_fminf16:
+  case Builtin::BI__builtin_fminf128:
+if (interp__builtin_fmin(S, OpPC, Frame, F))
+  return Ret(S, OpPC, Dummy);
+break;
 
   default:
 return false;


Index: clang/test/AST/Interp/builtin-functions.cpp
===
--- clang/test/AST/Interp/builtin-functions.cpp
+++ clang/test/AST/Interp/builtin-functions.cpp
@@ -60,3 +60,15 @@
  // expected-note {{read of dereferenced one-past-the-end pointer}} \
  // expected-note {{in call to}}
 }
+
+namespace fmin {
+  constexpr float f1 = __builtin_fmin(1.0, 2.0f);
+  static_assert(f1 == 1.0f, "");
+
+  constexpr float min = __builtin_fmin(__builtin_nan(""), 1);
+  static_assert(min == 1, "");
+  constexpr float min2 = __builtin_fmin(1, __builtin_nan(""));
+  static_assert(min2 == 1, "");
+  constexpr float min3 = __builtin_fmin(__builtin_inf(), __builtin_nan(""));
+  static_assert(min3 == __builtin_inf(), "");
+}
Index: clang/lib/AST/Interp/InterpBuiltin.cpp
===
--- clang/lib/AST/Interp/InterpBuiltin.cpp
+++ clang/lib/AST/Interp/InterpBuiltin.cpp
@@ -143,6 +143,25 @@
   return true;
 }
 
+static bool interp__builtin_fmin(InterpState &S, CodePtr OpPC,
+ const InterpFrame *Frame, const Function *F) {
+  const Floating &LHS = getParam(Frame, 0);
+  const Floating &RHS = getParam(Frame, 1);
+
+  Floating Result;
+
+  // When comparing zeroes, return -0.0 if one of the zeroes is negative.
+  if (LHS.isZero() && RHS.isZero() && RHS.isNegative())
+Result = RHS;
+  else if (LHS.isNan() || RHS < LHS)
+Result = RHS;
+  else
+Result = LHS;
+
+  S.Stk.push(Result);
+  return true;
+}
+
 bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const Function *F) {
   InterpFrame *Frame = S.Current;
   APValue Dummy;
@@ -195,6 +214,14 @@
   return Ret(S, OpPC, Dummy);
 break;
 
+  case Builtin::BI__builtin_fmin:
+  case Builtin::BI__builtin_fminf:
+  case Builtin::BI__builtin_fminl:
+  case Builtin::BI__builtin_fminf16:
+  case Builtin::BI__builtin_fminf128:
+if (interp__builtin_fmin(S, OpPC, Frame, F))
+  return Ret(S, OpPC, Dummy);
+break;
 
   default:
 return false;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D156047: [clang][Interp] Handle CXXParenListInitExprs

2023-07-27 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder updated this revision to Diff 544692.
tbaeder marked an inline comment as done.

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

https://reviews.llvm.org/D156047

Files:
  clang/lib/AST/Interp/ByteCodeExprGen.cpp
  clang/lib/AST/Interp/ByteCodeExprGen.h
  clang/test/AST/Interp/records.cpp
  clang/test/SemaCXX/source_location.cpp

Index: clang/test/SemaCXX/source_location.cpp
===
--- clang/test/SemaCXX/source_location.cpp
+++ clang/test/SemaCXX/source_location.cpp
@@ -4,9 +4,9 @@
 // RUN: %clang_cc1 -std=c++1z -fcxx-exceptions -fms-extensions -DMS -fexceptions -verify %s
 // RUN: %clang_cc1 -std=c++2a -fcxx-exceptions -fms-extensions -DMS -DUSE_CONSTEVAL -fexceptions -verify %s
 //
-/// FIXME: The -DPAREN_INIT one is missing for the new interpreter.
 // RUN: %clang_cc1 -std=c++1z -fcxx-exceptions -fexceptions -fexperimental-new-constant-interpreter -DNEW_INTERP -verify %s
 // RUN: %clang_cc1 -std=c++2a -fcxx-exceptions -DUSE_CONSTEVAL -fexceptions -fexperimental-new-constant-interpreter -DNEW_INTERP -verify %s
+// RUN: %clang_cc1 -std=c++2b -fcxx-exceptions -DUSE_CONSTEVAL -DPAREN_INIT -fexceptions -fexperimental-new-constant-interpreter -DNEW_INTERP -verify %s
 // RUN: %clang_cc1 -std=c++1z -fcxx-exceptions -fms-extensions -DMS -fexceptions -fexperimental-new-constant-interpreter -DNEW_INTERP -verify %s
 // RUN: %clang_cc1 -std=c++2a -fcxx-exceptions -fms-extensions -DMS -DUSE_CONSTEVAL -fexceptions -fexperimental-new-constant-interpreter -DNEW_INTERP -verify %s
 // expected-no-diagnostics
Index: clang/test/AST/Interp/records.cpp
===
--- clang/test/AST/Interp/records.cpp
+++ clang/test/AST/Interp/records.cpp
@@ -909,3 +909,17 @@
 }
 static_assert(BPand(BoolPair{true, false}) == false, "");
 #endif
+
+#if __cplusplus >= 202002L
+namespace ParenInit {
+  struct A {
+int a;
+  };
+
+  struct B : A {
+int b;
+  };
+
+  constexpr B b(A(1),2);
+}
+#endif
Index: clang/lib/AST/Interp/ByteCodeExprGen.h
===
--- clang/lib/AST/Interp/ByteCodeExprGen.h
+++ clang/lib/AST/Interp/ByteCodeExprGen.h
@@ -80,6 +80,7 @@
   bool VisitSubstNonTypeTemplateParmExpr(const SubstNonTypeTemplateParmExpr *E);
   bool VisitArraySubscriptExpr(const ArraySubscriptExpr *E);
   bool VisitInitListExpr(const InitListExpr *E);
+  bool VisitCXXParenListInitExpr(const CXXParenListInitExpr *E);
   bool VisitConstantExpr(const ConstantExpr *E);
   bool VisitUnaryExprOrTypeTraitExpr(const UnaryExprOrTypeTraitExpr *E);
   bool VisitMemberExpr(const MemberExpr *E);
@@ -199,6 +200,8 @@
   bool visitConditional(const AbstractConditionalOperator *E,
 llvm::function_ref V);
 
+  bool visitInitList(ArrayRef Inits, const Expr *E);
+
   /// Creates a local primitive value.
   unsigned allocateLocalPrimitive(DeclTy &&Decl, PrimType Ty, bool IsConst,
   bool IsExtended = false);
Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp
===
--- clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -586,80 +586,85 @@
 }
 
 template 
-bool ByteCodeExprGen::VisitInitListExpr(const InitListExpr *E) {
-  // Handle discarding first.
-  if (DiscardResult) {
-for (const Expr *Init : E->inits()) {
-  if (!this->discard(Init))
-return false;
-}
-return true;
-  }
-
-  // Primitive values.
-  if (std::optional T = classify(E->getType())) {
-assert(E->getNumInits() == 1);
-return DiscardResult ? this->discard(E->inits()[0])
- : this->visit(E->inits()[0]);
-  }
+bool ByteCodeExprGen::visitInitList(ArrayRef Inits,
+ const Expr *E) {
+  assert(E->getType()->isRecordType());
+  const Record *R = getRecord(E->getType());
 
-  QualType T = E->getType();
-  if (T->isRecordType()) {
-const Record *R = getRecord(T);
+  unsigned InitIndex = 0;
+  for (const Expr *Init : Inits) {
+if (!this->emitDupPtr(E))
+  return false;
 
-unsigned InitIndex = 0;
-for (const Expr *Init : E->inits()) {
-  if (!this->emitDupPtr(E))
+if (std::optional T = classify(Init)) {
+  const Record::Field *FieldToInit = R->getField(InitIndex);
+  if (!this->visit(Init))
 return false;
 
-  if (std::optional T = classify(Init)) {
-const Record::Field *FieldToInit = R->getField(InitIndex);
-if (!this->visit(Init))
+  if (FieldToInit->isBitField()) {
+if (!this->emitInitBitField(*T, FieldToInit, E))
+  return false;
+  } else {
+if (!this->emitInitField(*T, FieldToInit->Offset, E))
   return false;
+  }
 
-if (FieldToInit->isBitField()) {
-  if (!this->emitInitBitField(*T, FieldToInit, E))
-return false;
-} 

[PATCH] D156400: [clang][Interp] Implement __builtin_offsetof

2023-07-27 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder updated this revision to Diff 544693.

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

https://reviews.llvm.org/D156400

Files:
  clang/lib/AST/Interp/ByteCodeExprGen.cpp
  clang/lib/AST/Interp/ByteCodeExprGen.h
  clang/lib/AST/Interp/Interp.h
  clang/lib/AST/Interp/InterpBuiltin.cpp
  clang/lib/AST/Interp/Opcodes.td
  clang/test/AST/Interp/class-layout.cpp
  clang/test/AST/Interp/literals.cpp
  clang/test/Sema/offsetof-64.c
  clang/test/SemaCXX/class-layout.cpp
  clang/test/SemaCXX/offsetof-0x.cpp
  clang/test/SemaCXX/offsetof.cpp

Index: clang/test/SemaCXX/offsetof.cpp
===
--- clang/test/SemaCXX/offsetof.cpp
+++ clang/test/SemaCXX/offsetof.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -triple x86_64-apple-darwin10.0.0 -fsyntax-only -verify %s -Winvalid-offsetof -std=c++98
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10.0.0 -fsyntax-only -verify %s -Winvalid-offsetof -std=c++98 -fexperimental-new-constant-interpreter
 
 struct NonPOD {
   virtual void f();
Index: clang/test/SemaCXX/offsetof-0x.cpp
===
--- clang/test/SemaCXX/offsetof-0x.cpp
+++ clang/test/SemaCXX/offsetof-0x.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -triple x86_64-apple-darwin10.0.0 -fsyntax-only -std=c++11 -verify %s -Winvalid-offsetof
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10.0.0 -fsyntax-only -std=c++11 -verify %s -Winvalid-offsetof -fexperimental-new-constant-interpreter
 
 struct NonPOD {
   virtual void f();
Index: clang/test/SemaCXX/class-layout.cpp
===
--- clang/test/SemaCXX/class-layout.cpp
+++ clang/test/SemaCXX/class-layout.cpp
@@ -14,6 +14,25 @@
 // RUN: %clang_cc1 -triple s390x-none-zos %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base
 // RUN: %clang_cc1 -triple s390x-none-zos %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
 
+// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -triple x86_64-unknown-unknown %s -fsyntax-only -verify -std=c++98 -Wno-inaccessible-base -Wno-c++11-extensions
+// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -triple x86_64-unknown-unknown %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base
+// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -triple x86_64-apple-darwin%s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=15
+// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -triple x86_64-scei-ps4%s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=6
+// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -triple x86_64-sie-ps5 %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=6
+// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -triple x86_64-unknown-unknown %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -fclang-abi-compat=6 -DCLANG_ABI_COMPAT=6
+// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -triple x86_64-unknown-unknown %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -fclang-abi-compat=14 -DCLANG_ABI_COMPAT=14
+// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -triple x86_64-unknown-unknown %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
+// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -triple x86_64-unknown-unknown %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -fclang-abi-compat=16 -DCLANG_ABI_COMPAT=16
+// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -triple powerpc-ibm-aix7.3.0.0 %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=15
+// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -triple powerpc-ibm-aix7.3.0.0 %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
+// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -triple powerpc64-ibm-aix7.3.0.0 %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=15
+// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -triple powerpc64-ibm-aix7.3.0.0 %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
+// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -triple s390x-none-zos %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base
+// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -triple s390x-none-zos %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
+
+
+
+
 // expected-no-diagnostics
 
 #if !defined(__MVS__) && !defined(_AIX)
Index: clang/test/Sema/offsetof-64.c
===
--- clang/test/Sema/offsetof-64.c
+++ clang/test/Sema/offsetof-64.c
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -fsyntax-only -v

[PATCH] D142660: [AIX] supporting -X options for llvm-ranlib in AIX OS

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



Comment at: clang/test/lit.cfg.py:391
+if 'system-aix' in config.available_features:
+   config.environment['OBJECT_MODE'] = '32_64'
 

Recent Python style prefers double quotes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142660

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


[PATCH] D152093: [clang][Analysis] Handle && and || against variable and its negation as tautology

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

Ping


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

https://reviews.llvm.org/D152093

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


[PATCH] D144634: [Clang][OpenMP] Support for Code Generation of loop bind clause

2023-07-27 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/lib/Sema/TreeTransform.h:1652
+  Stmt *AStmt, SourceLocation StartLoc, SourceLocation EndLoc,
+  OpenMPDirectiveKind prevMappedDirective = OMPD_unknown) {
+

PrevMappedDirective


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

https://reviews.llvm.org/D144634

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


[PATCH] D156406: [NFC][clang] Fix static analyzer concerns

2023-07-27 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!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156406

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


[PATCH] D156405: [NFC][clang] Fix static analyzer concerns

2023-07-27 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!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156405

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


[PATCH] D156047: [clang][Interp] Handle CXXParenListInitExprs

2023-07-27 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin accepted this revision.
cor3ntin added a comment.
This revision is now accepted and ready to land.

LGTM, thanks!
But please look at the bot failures, i suppose you need to rebase before 
merging.
Also, can you try to add the new interpreter to 
`test/SemaCXX/paren-list-agg-init.cpp` ?


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

https://reviews.llvm.org/D156047

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


[PATCH] D152093: [clang][Analysis] Handle && and || against variable and its negation as tautology

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

Generally LGTM, just a minor suggestion on slightly rewording the diagnostics 
and combining them.




Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:9743-9748
+def warn_tautological_negation_and_compare: Warning<
+  "'&&' against a variable and its negation always evaluates to false">,
+  InGroup, DefaultIgnore;
+def warn_tautological_negation_or_compare: Warning<
+  "'||' against a variable and its negation always evaluates to true">,
+  InGroup, DefaultIgnore;

Let's combine these if we can. I'm not 100% certain that `%select` is going to 
like `&&|||` though, so if there's an issue, separate is also fine.


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

https://reviews.llvm.org/D152093

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


[PATCH] D155546: [clang][Interp] Implement __builtin_fmin

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

In D155546#4532839 , @jcranmer-intel 
wrote:

> Treating sNaN as always signaling FE_INVALID is probably the safer option.

That sounds reasonable to me.




Comment at: clang/test/AST/Interp/builtin-functions.cpp:65-73
+  constexpr float f1 = __builtin_fmin(1.0, 2.0f);
+  static_assert(f1 == 1.0f, "");
+
+  constexpr float min = __builtin_fmin(__builtin_nan(""), 1);
+  static_assert(min == 1, "");
+  constexpr float min2 = __builtin_fmin(1, __builtin_nan(""));
+  static_assert(min2 == 1, "");

Can you add a test using `__builtin_nans` to show that it results in an invalid 
constant expression because of the `FE_INVALID` signal?


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

https://reviews.llvm.org/D155546

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


[PATCH] D144006: [DebugMetadata][DwarfDebug] Support function-local types in lexical block scopes (4/7)

2023-07-27 Thread Vladislav Dzhidzhoev via Phabricator via cfe-commits
dzhidzhoev updated this revision to Diff 544711.
dzhidzhoev added a comment.

Rebased on top of https://reviews.llvm.org/D155818.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144006

Files:
  clang/test/CodeGen/debug-info-codeview-unnamed.c
  clang/test/CodeGen/debug-info-unused-types.c
  clang/test/CodeGen/debug-info-unused-types.cpp
  clang/test/CodeGenCXX/debug-info-access.cpp
  clang/test/CodeGenCXX/debug-info-anon-union-vars.cpp
  clang/test/CodeGenCXX/debug-info-codeview-unnamed.cpp
  clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp
  clang/test/CodeGenCXX/debug-lambda-this.cpp
  llvm/include/llvm/IR/DIBuilder.h
  llvm/lib/Bitcode/Reader/MetadataLoader.cpp
  llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
  llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h
  llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
  llvm/lib/IR/DIBuilder.cpp
  llvm/lib/IR/Verifier.cpp
  llvm/test/Bitcode/upgrade-cu-locals.ll
  llvm/test/Bitcode/upgrade-cu-locals.ll.bc
  llvm/test/DebugInfo/Generic/inlined-local-type.ll
  llvm/test/DebugInfo/Generic/lexical-block-retained-types.ll
  llvm/test/DebugInfo/Generic/lexical-block-types.ll
  llvm/test/DebugInfo/Generic/split-dwarf-local-import.ll
  llvm/test/DebugInfo/Generic/split-dwarf-local-import2.ll
  llvm/test/DebugInfo/Generic/split-dwarf-local-import3.ll
  llvm/test/DebugInfo/Generic/verifier-invalid-disubprogram.ll
  llvm/test/DebugInfo/X86/local-type-as-template-parameter.ll
  llvm/test/DebugInfo/X86/set.ll
  llvm/test/DebugInfo/X86/split-dwarf-local-import.ll
  llvm/test/DebugInfo/X86/split-dwarf-local-import2.ll
  llvm/test/DebugInfo/X86/split-dwarf-local-import3.ll

Index: llvm/test/DebugInfo/Generic/split-dwarf-local-import3.ll
===
--- /dev/null
+++ llvm/test/DebugInfo/Generic/split-dwarf-local-import3.ll
@@ -1,70 +0,0 @@
-; REQUIRES: x86_64-linux
-; RUN: %llc_dwarf -O1 -filetype=obj -split-dwarf-file=%t.dwo < %s \
-; RUN:   | llvm-dwarfdump -debug-info -   \
-; RUN:   | FileCheck %s --implicit-check-not "{{DW_TAG|NULL}}"
-
-target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
-target triple = "x86_64-unknown-linux-gnu"
-
-; Ensure that the imported entity 'nn::A' gets emitted in 'foo()'s abstract tree
-; in the destination (where 'foo()' was inlined) compile unit.
-
-; CHECK-LABEL: .debug_info contents
-; CHECK: DW_TAG_skeleton_unit
-; CHECK:   DW_AT_dwo_name
-
-; CHECK-LABEL: .debug_info.dwo contents:
-; CHECK: DW_TAG_compile_unit
-; CHECK:   DW_AT_name ("test.cpp")
-; CHECK:   DW_AT_dwo_name
-
-; CHECK:   [[ABSTRACT_FOO:0x[0-9a-f]+]]: DW_TAG_subprogram
-; CHECK: DW_AT_name	("foo")
-; CHECK: DW_TAG_imported_declaration
-; CHECK:   DW_AT_import  ([[A:0x[0-9a-f]+]])
-; CHECK: NULL
-
-; CHECK:   DW_TAG_base_type
-; CHECK: DW_AT_name	("int")
-
-; CHECK:   DW_TAG_subprogram
-; CHECK: DW_AT_name	("main")
-; CHECK: DW_TAG_inlined_subroutine
-; CHECK:   DW_AT_abstract_origin ([[ABSTRACT_FOO]] "_Z3foov")
-; CHECK: NULL
-
-; CHECK:   DW_TAG_namespace
-; CHECK: DW_AT_name	("nn")
-; CHECK: [[A]]: DW_TAG_variable
-; CHECK:   DW_AT_name	("A")
-; CHECK: NULL
-; CHECK:   NULL
-
-define dso_local noundef i32 @main() local_unnamed_addr !dbg !20 {
-entry:
-  ret i32 42, !dbg !21
-}
-
-!llvm.dbg.cu = !{!0, !2}
-!llvm.module.flags = !{!13, !14}
-!llvm.ident = !{!19, !19}
-
-!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 15.0.0", isOptimized: true, runtimeVersion: 0, splitDebugFilename: "test.dwo", emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: GNU)
-!1 = !DIFile(filename: "test.cpp", directory: "/", checksumkind: CSK_MD5, checksum: "e7c2808ee27614e496499d55e4b37962")
-!2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !3, producer: "clang version 15.0.0", isOptimized: true, runtimeVersion: 0, splitDebugFilename: "cu1.dwo", emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: GNU)
-!3 = !DIFile(filename: "cu1.cpp", directory: "/", checksumkind: CSK_MD5, checksum: "c0b84240ef5682b87083b33cf9038171")
-!4 = !{!5}
-!5 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !6, entity: !11, file: !3, line: 5)
-!6 = distinct !DISubprogram(name: "foo", linkageName: "_Z3foov", scope: !3, file: !3, line: 5, type: !7, scopeLine: 5, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !4)
-!7 = !DISubroutineType(types: !8)
-!8 = !{!9}
-!9 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
-!10 = !{}
-!11 = distinct !DIGlobalVariable(name: "A", linkageName: "_ZN2nn1AE", scope: !12, file: !3, line: 2, type: !9, isLocal: false, isDefinition: true)
-!12 = !DINamespace(name: "nn", scope: null)
-!13 = !{i32 7, !"Dwarf Version", i32 5}
-!14 = !{i32 2, !"Debug Info Version", i32 3

[PATCH] D156047: [clang][Interp] Handle CXXParenListInitExprs

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

> Also, can you try to add the new interpreter to 
> test/SemaCXX/paren-list-agg-init.cpp ?

Hmm no, looks like there's a problem with rvalue references.


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

https://reviews.llvm.org/D156047

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


[PATCH] D143967: [DebugInfo][BPF] Add 'btf:type_tag' annotation in DWARF

2023-07-27 Thread Eduard Zingerman via Phabricator via cfe-commits
eddyz87 added a comment.

Hi @dblaikie,

Could you please take a look at my reply 
?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143967

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


[PATCH] D150946: [clang][Interp] PointerToIntegral casts

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

In D150946#4536971 , @phosek wrote:

> This test is failing on our Windows builders with the following error:
>
>   Script:
>   --
>   : 'RUN: at line 1';   c:\b\s\w\ir\x\w\llvm_build\bin\clang.exe -cc1 
> -internal-isystem c:\b\s\w\ir\x\w\llvm_build\lib\clang\18\include 
> -nostdsysteminc -fexperimental-new-constant-interpreter -fms-extensions 
> -std=c++11 -verify 
> C:\b\s\w\ir\x\w\llvm-llvm-project\clang\test\AST\Interp\literals.cpp
>   : 'RUN: at line 2';   c:\b\s\w\ir\x\w\llvm_build\bin\clang.exe -cc1 
> -internal-isystem c:\b\s\w\ir\x\w\llvm_build\lib\clang\18\include 
> -nostdsysteminc -fexperimental-new-constant-interpreter -fms-extensions 
> -std=c++20 -verify 
> C:\b\s\w\ir\x\w\llvm-llvm-project\clang\test\AST\Interp\literals.cpp
>   : 'RUN: at line 3';   c:\b\s\w\ir\x\w\llvm_build\bin\clang.exe -cc1 
> -internal-isystem c:\b\s\w\ir\x\w\llvm_build\lib\clang\18\include 
> -nostdsysteminc -std=c++11 -fms-extensions -verify=ref 
> C:\b\s\w\ir\x\w\llvm-llvm-project\clang\test\AST\Interp\literals.cpp
>   : 'RUN: at line 4';   c:\b\s\w\ir\x\w\llvm_build\bin\clang.exe -cc1 
> -internal-isystem c:\b\s\w\ir\x\w\llvm_build\lib\clang\18\include 
> -nostdsysteminc -std=c++20 -fms-extensions -verify=ref 
> C:\b\s\w\ir\x\w\llvm-llvm-project\clang\test\AST\Interp\literals.cpp
>   --
>   Exit Code: 1
>   
>   Command Output (stdout):
>   --
>   $ ":" "RUN: at line 1"
>   $ "c:\b\s\w\ir\x\w\llvm_build\bin\clang.exe" "-cc1" "-internal-isystem" 
> "c:\b\s\w\ir\x\w\llvm_build\lib\clang\18\include" "-nostdsysteminc" 
> "-fexperimental-new-constant-interpreter" "-fms-extensions" "-std=c++11" 
> "-verify" 
> "C:\b\s\w\ir\x\w\llvm-llvm-project\clang\test\AST\Interp\literals.cpp"
>   # command stderr:
>   error: 'warning' diagnostics seen but not expected: 
> File C:\b\s\w\ir\x\w\llvm-llvm-project\clang\test\AST\Interp\literals.cpp 
> Line 946: cast to smaller integer type 'long' from 'char *'
>   1 error generated.
>   
>   error: command failed with exit status: 1
>
> Would it be possible to either quickly address the issue or revert the change?

Did the changes in 2a6cfc4baa784ff299a81f8c5e7163207c93eafe 
 address 
the issue for you?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150946

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


[PATCH] D156307: [clang][DeclPrinter] Fix AST print of curly constructor initializers

2023-07-27 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!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156307

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


[PATCH] D156402: [clang][dataflow] Don't crash when constructing an array of records.

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

CI failures look unrelated


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156402

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


[PATCH] D156423: [OMPIRBuilder] Fix module finalization

2023-07-27 Thread Dominik Adamski via Phabricator via cfe-commits
domada created this revision.
domada added reviewers: jsjodin, skatrak, agozillon, kiranchandramohan, 
kiranktp, NimishMishra, TIFitis, raghavendhra, dpalermo, jdoerfert.
domada added a project: OpenMP.
Herald added subscribers: gysit, Dinistro, bviyer, Moerafaat, zero9178, 
bzcheeseman, awarzynski, sdasgup3, wenzhicui, wrengr, ormris, cota, teijeong, 
rdzhabarov, tatianashp, msifontes, jurahul, Kayjukh, grosul1, Joonsoo, 
liufengdb, aartbik, mgester, arpith-jacob, antiagainst, shauheen, rriddle, 
mehdi_amini, hiraditya.
Herald added a reviewer: ftynse.
Herald added a reviewer: dcaballe.
Herald added a project: All.
domada requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, jplehr, sstefan1, 
stephenneuendorffer, nicolasvasilache.
Herald added projects: clang, MLIR, LLVM.

OMP offload module metadata should be created only when module generation is 
finalized. If we finalize LLVM IR function we should not create omp offload 
metadata.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D156423

Files:
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/test/OpenMP/irbuilder_omp_offload_metadata.c
  llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
  llvm/lib/Transforms/IPO/OpenMPOpt.cpp
  llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
  mlir/lib/Target/LLVMIR/ModuleTranslation.cpp

Index: mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
===
--- mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
+++ mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
@@ -471,7 +471,7 @@
 
 ModuleTranslation::~ModuleTranslation() {
   if (ompBuilder)
-ompBuilder->finalize();
+ompBuilder->finalizeModule();
 }
 
 void ModuleTranslation::forgetMapping(Region ®ion) {
Index: llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
===
--- llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
+++ llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
@@ -664,7 +664,7 @@
   Builder.restoreIP(AfterIP);
   Builder.CreateRetVoid();
 
-  OMPBuilder.finalize();
+  OMPBuilder.finalizeModule();
 
   EXPECT_NE(PrivAI, nullptr);
   Function *OutlinedFn = PrivAI->getFunction();
@@ -760,7 +760,7 @@
   Builder.restoreIP(AfterIP);
   Builder.CreateRetVoid();
 
-  OMPBuilder.finalize();
+  OMPBuilder.finalizeModule();
 
   EXPECT_EQ(M->size(), 5U);
   for (Function &OutlinedFn : *M) {
@@ -864,7 +864,7 @@
   Builder.restoreIP(AfterIP);
   Builder.CreateRetVoid();
 
-  OMPBuilder.finalize();
+  OMPBuilder.finalizeModule();
 
   EXPECT_EQ(M->size(), 6U);
   for (Function &OutlinedFn : *M) {
@@ -976,7 +976,7 @@
 
   Builder.restoreIP(AfterIP);
   Builder.CreateRetVoid();
-  OMPBuilder.finalize();
+  OMPBuilder.finalizeModule();
 
   EXPECT_NE(PrivAI, nullptr);
   Function *OutlinedFn = PrivAI->getFunction();
@@ -1093,7 +1093,7 @@
 
   Builder.restoreIP(AfterIP);
   Builder.CreateRetVoid();
-  OMPBuilder.finalize();
+  OMPBuilder.finalizeModule();
 
   EXPECT_FALSE(verifyModule(*M, &errs()));
 
@@ -1172,7 +1172,7 @@
   Builder.restoreIP(AfterIP);
   Builder.CreateRetVoid();
 
-  OMPBuilder.finalize();
+  OMPBuilder.finalizeModule();
 
   EXPECT_FALSE(verifyModule(*M, &errs()));
   Function *OutlinedFn = Internal->getFunction();
@@ -1206,7 +1206,7 @@
 
   Builder.restoreIP(Loop->getAfterIP());
   ReturnInst *RetInst = Builder.CreateRetVoid();
-  OMPBuilder.finalize();
+  OMPBuilder.finalizeModule();
 
   Loop->assertOK();
   EXPECT_FALSE(verifyModule(*M, &errs()));
@@ -1307,7 +1307,7 @@
 
   // Finalize the function and verify it.
   Builder.CreateRetVoid();
-  OMPBuilder.finalize();
+  OMPBuilder.finalizeModule();
   EXPECT_FALSE(verifyModule(*M, &errs()));
 }
 
@@ -1368,7 +1368,7 @@
   CanonicalLoopInfo *Collapsed =
   OMPBuilder.collapseLoops(DL, {OuterLoop, InnerLoop}, ComputeIP);
 
-  OMPBuilder.finalize();
+  OMPBuilder.finalizeModule();
   EXPECT_FALSE(verifyModule(*M, &errs()));
 
   // Verify control flow and BB order.
@@ -1419,7 +1419,7 @@
   std::vector GenLoops =
   OMPBuilder.tileLoops(DL, {Loop}, {TileSize});
 
-  OMPBuilder.finalize();
+  OMPBuilder.finalizeModule();
   EXPECT_FALSE(verifyModule(*M, &errs()));
 
   EXPECT_EQ(GenLoops.size(), 2u);
@@ -1486,7 +1486,7 @@
   std::vector GenLoops = OMPBuilder.tileLoops(
   DL, {OuterLoop, InnerLoop}, {OuterTileSize, InnerTileSize});
 
-  OMPBuilder.finalize();
+  OMPBuilder.finalizeModule();
   EXPECT_FALSE(verifyModule(*M, &errs()));
 
   EXPECT_EQ(GenLoops.size(), 4u);
@@ -1588,7 +1588,7 @@
   std::vector GenLoops =
   OMPBuilder.tileLoops(DL, {OuterLoop, InnerLoop}, {TileSize0, TileSize1});
 
-  OMPBuilder.finalize();
+  OMPBuilder.finalizeModule();
   EXPECT_FALSE(verifyModule(*M, &errs()));
 
   EXPECT_EQ(GenLoops.size(), 4u);
@@ -1741,7 +1741,7 @@
 
   // Finalize the function.
   Builder.CreateRetVoid();
-  OMPBuilder.finalize();
+  OMPBuilder.finalizeModule();
 
   EXPECT_FALSE(verify

[PATCH] D152093: [clang][Analysis] Handle && and || against variable and its negation as tautology

2023-07-27 Thread Nico Weber via Phabricator via cfe-commits
thakis accepted this revision.
thakis added a comment.
This revision is now accepted and ready to land.

lg with aaron's suggestion. thanks for the patch, and for your patience!


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

https://reviews.llvm.org/D152093

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


[PATCH] D151834: Include math-errno with fast-math

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



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:2321-2328
+  if ((FD->hasAttr() && !ErrnoOverriden && !OptNone) ||
   ((ConstWithoutErrnoAndExceptions || ConstWithoutExceptions) &&
-   (!ConstWithoutErrnoAndExceptions || (!getLangOpts().MathErrno {
+   (!ConstWithoutErrnoAndExceptions ||
+(!getLangOpts().MathErrno && !ErrnoOverriden && !OptNone) ||
+// If math-errno was enabled on command line but overriden to false
+// via '#pragma float_control(precise, off))', and optimizations are
+// enabled, generate intrinsics.

zahiraam wrote:
> aaron.ballman wrote:
> > I think this has gotten sufficiently complex that it might be worth 
> > splitting the logic out a bit more:
> > ```
> > bool Optimize = FD->hasAttr() && !ErrnoOverriden && !OptNone;
> > if (!Optimize) Optimize = FD->hasAttr() && !ErrnoOverriden && 
> > !OptNone;
> > ... and so on ...
> > ```
> > WDYT?
> I understand I need to split the logic, but I don't get your proposal here. 
> Do you mean?
> 
> 
> ```
> bool Optimize = FD->hasAttr() && !ErrnoOverriden && !OptNone;
> if (!Optimize) Optimize = !getLangOpts().MathErrno && !ErrnoOverriden && 
> !OptNone;
> ... and so on ...
> ```
> 
Oops, yeah, that a was copy pasta mistake on my part. You've got the right idea 
-- mostly just split up the logic and add comments explaining why the 
predicates exist.


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

https://reviews.llvm.org/D151834

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


[clang] e6e83cb - [clang][dataflow] Don't crash when constructing an array of records.

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

Author: Martin Braenne
Date: 2023-07-27T12:46:13Z
New Revision: e6e83cbcc748a55a7eddce67b228298820cb9315

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

LOG: [clang][dataflow] Don't crash when constructing an array of records.

When I wrote https://reviews.llvm.org/D155446, I assumed that a 
`CXXConstructExpr` would always have record type, but this isn't true: It can 
have array type when constructing an array of records. The code would crash in 
this situation because `createValue()` would return null.

This patch includes a test that reproduces the crash without the other changes 
in the patch.

Reviewed By: sammccall

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

Added: 


Modified: 
clang/lib/Analysis/FlowSensitive/Transfer.cpp
clang/unittests/Analysis/FlowSensitive/TransferTest.cpp

Removed: 




diff  --git a/clang/lib/Analysis/FlowSensitive/Transfer.cpp 
b/clang/lib/Analysis/FlowSensitive/Transfer.cpp
index 0b7c22fe24e301..8f8f807a3a4b22 100644
--- a/clang/lib/Analysis/FlowSensitive/Transfer.cpp
+++ b/clang/lib/Analysis/FlowSensitive/Transfer.cpp
@@ -500,9 +500,14 @@ class TransferVisitor : public 
ConstStmtVisitor {
   return;
 }
 
-auto &InitialVal = *cast(Env.createValue(S->getType()));
-copyRecord(InitialVal.getAggregateLoc(), Env.getResultObjectLocation(*S),
-   Env);
+// `CXXConstructExpr` can have array type if default-initializing an array
+// of records, and we currently can't create values for arrays. So check if
+// we've got a record type.
+if (S->getType()->isRecordType()) {
+  auto &InitialVal = *cast(Env.createValue(S->getType()));
+  copyRecord(InitialVal.getAggregateLoc(), Env.getResultObjectLocation(*S),
+ Env);
+}
 
 transferInlineCall(S, ConstructorDecl);
   }

diff  --git a/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp 
b/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
index 5acb28bd87abff..57c8a5f3589bc4 100644
--- a/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
+++ b/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
@@ -310,6 +310,28 @@ TEST(TransferTest, StructVarDeclWithInit) {
   });
 }
 
+TEST(TransferTest, StructArrayVarDecl) {
+  std::string Code = R"(
+struct A {};
+
+void target() {
+  A Array[2];
+  // [[p]]
+}
+  )";
+  runDataflow(
+  Code,
+  [](const llvm::StringMap> &Results,
+ ASTContext &ASTCtx) {
+const Environment &Env = getEnvironmentAtAnnotation(Results, "p");
+
+const ValueDecl *ArrayDecl = findValueDecl(ASTCtx, "Array");
+
+// We currently don't create values for arrays.
+ASSERT_THAT(Env.getValue(*ArrayDecl), IsNull());
+  });
+}
+
 TEST(TransferTest, ClassVarDecl) {
   std::string Code = R"(
 class A {



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


[PATCH] D156402: [clang][dataflow] Don't crash when constructing an array of records.

2023-07-27 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 rGe6e83cbcc748: [clang][dataflow] Don't crash when 
constructing an array of records. (authored by mboehme).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156402

Files:
  clang/lib/Analysis/FlowSensitive/Transfer.cpp
  clang/unittests/Analysis/FlowSensitive/TransferTest.cpp


Index: clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
@@ -310,6 +310,28 @@
   });
 }
 
+TEST(TransferTest, StructArrayVarDecl) {
+  std::string Code = R"(
+struct A {};
+
+void target() {
+  A Array[2];
+  // [[p]]
+}
+  )";
+  runDataflow(
+  Code,
+  [](const llvm::StringMap> &Results,
+ ASTContext &ASTCtx) {
+const Environment &Env = getEnvironmentAtAnnotation(Results, "p");
+
+const ValueDecl *ArrayDecl = findValueDecl(ASTCtx, "Array");
+
+// We currently don't create values for arrays.
+ASSERT_THAT(Env.getValue(*ArrayDecl), IsNull());
+  });
+}
+
 TEST(TransferTest, ClassVarDecl) {
   std::string Code = R"(
 class A {
Index: clang/lib/Analysis/FlowSensitive/Transfer.cpp
===
--- clang/lib/Analysis/FlowSensitive/Transfer.cpp
+++ clang/lib/Analysis/FlowSensitive/Transfer.cpp
@@ -500,9 +500,14 @@
   return;
 }
 
-auto &InitialVal = *cast(Env.createValue(S->getType()));
-copyRecord(InitialVal.getAggregateLoc(), Env.getResultObjectLocation(*S),
-   Env);
+// `CXXConstructExpr` can have array type if default-initializing an array
+// of records, and we currently can't create values for arrays. So check if
+// we've got a record type.
+if (S->getType()->isRecordType()) {
+  auto &InitialVal = *cast(Env.createValue(S->getType()));
+  copyRecord(InitialVal.getAggregateLoc(), Env.getResultObjectLocation(*S),
+ Env);
+}
 
 transferInlineCall(S, ConstructorDecl);
   }


Index: clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
@@ -310,6 +310,28 @@
   });
 }
 
+TEST(TransferTest, StructArrayVarDecl) {
+  std::string Code = R"(
+struct A {};
+
+void target() {
+  A Array[2];
+  // [[p]]
+}
+  )";
+  runDataflow(
+  Code,
+  [](const llvm::StringMap> &Results,
+ ASTContext &ASTCtx) {
+const Environment &Env = getEnvironmentAtAnnotation(Results, "p");
+
+const ValueDecl *ArrayDecl = findValueDecl(ASTCtx, "Array");
+
+// We currently don't create values for arrays.
+ASSERT_THAT(Env.getValue(*ArrayDecl), IsNull());
+  });
+}
+
 TEST(TransferTest, ClassVarDecl) {
   std::string Code = R"(
 class A {
Index: clang/lib/Analysis/FlowSensitive/Transfer.cpp
===
--- clang/lib/Analysis/FlowSensitive/Transfer.cpp
+++ clang/lib/Analysis/FlowSensitive/Transfer.cpp
@@ -500,9 +500,14 @@
   return;
 }
 
-auto &InitialVal = *cast(Env.createValue(S->getType()));
-copyRecord(InitialVal.getAggregateLoc(), Env.getResultObjectLocation(*S),
-   Env);
+// `CXXConstructExpr` can have array type if default-initializing an array
+// of records, and we currently can't create values for arrays. So check if
+// we've got a record type.
+if (S->getType()->isRecordType()) {
+  auto &InitialVal = *cast(Env.createValue(S->getType()));
+  copyRecord(InitialVal.getAggregateLoc(), Env.getResultObjectLocation(*S),
+ Env);
+}
 
 transferInlineCall(S, ConstructorDecl);
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D155457: [clang] Skip tautological comparison if the comparison involves the 'size_t' type

2023-07-27 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta updated this revision to Diff 544728.
xgupta added a comment.

updated code as per the comment of @cor3ntin


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155457

Files:
  clang/lib/Sema/SemaChecking.cpp
  clang/test/Sema/type-limit-compare.cpp
  clang/test/SemaCXX/bool-compare.cpp


Index: clang/test/SemaCXX/bool-compare.cpp
===
--- clang/test/SemaCXX/bool-compare.cpp
+++ clang/test/SemaCXX/bool-compare.cpp
@@ -8,13 +8,13 @@
   if(b > true){} // expected-warning {{comparison of true with expression 
of type 'bool' is always false}}
   if(b < true){} // no warning
   if(b >= true)   {} // no warning
-  if(b <= true)   {} // expected-warning {{comparison of true with expression 
of type 'bool' is always true}}
+  if(b <= true)   {} // expected-warning {{result of comparison of true with 
expression of type 'bool' is always true}}
   if(b == true)   {} // no warning
   if(b != true)   {} // no warning
 
   if(b > false)   {} // no warning
-  if(b < false)   {} // expected-warning {{comparison of false with expression 
of type 'bool' is always false}}
-  if(b >= false)  {} // expected-warning {{comparison of false with expression 
of type 'bool' is always true}}
+  if(b < false)   {} // expected-warning {{result of comparison of false with 
expression of type 'bool' is always false}}
+  if(b >= false)  {} // expected-warning {{result of comparison of false with 
expression of type 'bool' is always true}}
   if(b <= false)  {} // no warning
   if(b == false)  {} // no warning
   if(b != false)  {} // no warning
Index: clang/test/Sema/type-limit-compare.cpp
===
--- /dev/null
+++ clang/test/Sema/type-limit-compare.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 %s -fsyntax-only -Wtautological-type-limit-compare -verify
+
+// expected-no-diagnostics
+#if defined(_WIN32)
+typedef unsigned long long uint64_t;
+#else
+typedef unsigned long uint64_t;
+#endif
+
+namespace std {
+using size_t = decltype(sizeof(0));
+} // namespace std
+
+bool func(uint64_t Size) {
+  if (sizeof(std::size_t) < sizeof(uint64_t) &&
+ Size > (uint64_t)(__SIZE_MAX__))
+return false;
+  return true;
+}
+
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -13804,6 +13804,25 @@
   if (InRange && IsEnumConstOrFromMacro(S, Constant))
 return false;
 
+  // Don't warn if the comparison involves integral or floating-point types 
with
+  // the same canonical types.
+  QualType LHSCanonical = Constant->getType().getCanonicalType();
+  QualType RHSCanonical = Other->getType().getCanonicalType();
+  if (TautologicalTypeCompare &&
+  (LHSCanonical->isIntegralOrEnumerationType() ||
+   LHSCanonical->isFloatingType()) &&
+  S.Context.hasSameType(LHSCanonical, RHSCanonical) &&
+  !S.Context.hasSameType(Constant->getType(), Other->getType())) {
+return false;
+  }
+
+  // Don't warn if the comparison involves the 'size_t' type.
+  QualType SizeT = S.Context.getSizeType();
+  if (S.Context.hasSameType(Constant->getType().getCanonicalType(), SizeT) &&
+  S.Context.hasSameType(Other->getType().getCanonicalType(), SizeT)) {
+return false;
+  }
+
   // A comparison of an unsigned bit-field against 0 is really a type problem,
   // even though at the type level the bit-field might promote to 'signed int'.
   if (Other->refersToBitField() && InRange && Value == 0 &&


Index: clang/test/SemaCXX/bool-compare.cpp
===
--- clang/test/SemaCXX/bool-compare.cpp
+++ clang/test/SemaCXX/bool-compare.cpp
@@ -8,13 +8,13 @@
   if(b > true){} // expected-warning {{comparison of true with expression of type 'bool' is always false}}
   if(b < true){} // no warning
   if(b >= true)   {} // no warning
-  if(b <= true)   {} // expected-warning {{comparison of true with expression of type 'bool' is always true}}
+  if(b <= true)   {} // expected-warning {{result of comparison of true with expression of type 'bool' is always true}}
   if(b == true)   {} // no warning
   if(b != true)   {} // no warning
 
   if(b > false)   {} // no warning
-  if(b < false)   {} // expected-warning {{comparison of false with expression of type 'bool' is always false}}
-  if(b >= false)  {} // expected-warning {{comparison of false with expression of type 'bool' is always true}}
+  if(b < false)   {} // expected-warning {{result of comparison of false with expression of type 'bool' is always false}}
+  if(b >= false)  {} // expected-warning {{result of comparison of false with expression of type 'bool' is always true}}
   if(b <= false)  {} // no warning
   if(b == false)  {} // no warning
   if(b != false)  {} // no warning
Index: clang/test/Se

[PATCH] D156411: [clang][dataflow] HTMLLogger: Don't crash if CFG contains unreachable blocks.

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

Pre-merge failure looks unrelated


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156411

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


[PATCH] D155457: [clang] Skip tautological comparison if the comparison involves the 'size_t' type

2023-07-27 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta updated this revision to Diff 544732.
xgupta added a comment.

minor update


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155457

Files:
  clang/lib/Sema/SemaChecking.cpp
  clang/test/Sema/type-limit-compare.cpp


Index: clang/test/Sema/type-limit-compare.cpp
===
--- /dev/null
+++ clang/test/Sema/type-limit-compare.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 %s -fsyntax-only -Wtautological-type-limit-compare -verify
+
+// expected-no-diagnostics
+#if defined(_WIN32)
+typedef unsigned long long uint64_t;
+#else
+typedef unsigned long uint64_t;
+#endif
+
+namespace std {
+using size_t = decltype(sizeof(0));
+} // namespace std
+
+bool func(uint64_t Size) {
+  if (sizeof(std::size_t) < sizeof(uint64_t) &&
+ Size > (uint64_t)(__SIZE_MAX__))
+return false;
+  return true;
+}
+
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -13804,6 +13804,25 @@
   if (InRange && IsEnumConstOrFromMacro(S, Constant))
 return false;
 
+  // Don't warn if the comparison involves integral or floating-point types 
with
+  // the same canonical types.
+  QualType LHSCanonical = Constant->getType().getCanonicalType();
+  QualType RHSCanonical = Other->getType().getCanonicalType();
+  if (TautologicalTypeCompare &&
+  (LHSCanonical->isIntegralOrEnumerationType() ||
+   LHSCanonical->isFloatingType()) &&
+  S.Context.hasSameType(LHSCanonical, RHSCanonical) &&
+  !S.Context.hasSameType(Constant->getType(), Other->getType())) {
+return false;
+  }
+
+  // Don't warn if the comparison involves the 'size_t' type.
+  QualType SizeT = S.Context.getSizeType();
+  if (S.Context.hasSameType(Constant->getType().getCanonicalType(), SizeT) &&
+  S.Context.hasSameType(Other->getType().getCanonicalType(), SizeT)) {
+return false;
+  }
+
   // A comparison of an unsigned bit-field against 0 is really a type problem,
   // even though at the type level the bit-field might promote to 'signed int'.
   if (Other->refersToBitField() && InRange && Value == 0 &&


Index: clang/test/Sema/type-limit-compare.cpp
===
--- /dev/null
+++ clang/test/Sema/type-limit-compare.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 %s -fsyntax-only -Wtautological-type-limit-compare -verify
+
+// expected-no-diagnostics
+#if defined(_WIN32)
+typedef unsigned long long uint64_t;
+#else
+typedef unsigned long uint64_t;
+#endif
+
+namespace std {
+using size_t = decltype(sizeof(0));
+} // namespace std
+
+bool func(uint64_t Size) {
+  if (sizeof(std::size_t) < sizeof(uint64_t) &&
+ Size > (uint64_t)(__SIZE_MAX__))
+return false;
+  return true;
+}
+
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -13804,6 +13804,25 @@
   if (InRange && IsEnumConstOrFromMacro(S, Constant))
 return false;
 
+  // Don't warn if the comparison involves integral or floating-point types with
+  // the same canonical types.
+  QualType LHSCanonical = Constant->getType().getCanonicalType();
+  QualType RHSCanonical = Other->getType().getCanonicalType();
+  if (TautologicalTypeCompare &&
+  (LHSCanonical->isIntegralOrEnumerationType() ||
+   LHSCanonical->isFloatingType()) &&
+  S.Context.hasSameType(LHSCanonical, RHSCanonical) &&
+  !S.Context.hasSameType(Constant->getType(), Other->getType())) {
+return false;
+  }
+
+  // Don't warn if the comparison involves the 'size_t' type.
+  QualType SizeT = S.Context.getSizeType();
+  if (S.Context.hasSameType(Constant->getType().getCanonicalType(), SizeT) &&
+  S.Context.hasSameType(Other->getType().getCanonicalType(), SizeT)) {
+return false;
+  }
+
   // A comparison of an unsigned bit-field against 0 is really a type problem,
   // even though at the type level the bit-field might promote to 'signed int'.
   if (Other->refersToBitField() && InRange && Value == 0 &&
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D156247: [Clang] Add a warning on uses of coroutine keywords

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

In D156247#4537351 , @ChuanqiXu wrote:

> While I am not against the approach, do you think we need similar semantics 
> for `-fno-concepts`, `-fno-modules`, etc... ?

I think we need to take it on a case by case basis. In general, we only let 
users disable language features when the feature has hidden costs that cannot 
be avoided (e.g., exceptions and RTTI in C++), which isn't the case with 
coroutines. However, because GCC allows you to disable coroutines and we try to 
keep our flags reasonably compatible, and because we have users with a concrete 
need, it is perhaps reasonable in this case. I think the answer is different 
for something like concepts because those are used by the STL, so disabling 
them has greater impact on what code is accepted by the compiler. If GCC didn't 
support `-fno-coroutines`, I'd likely be opposed to adding it to Clang because 
coroutines impose no hidden costs unless you actually use the feature and the 
use case is unmotivated (clang-tidy is the tool for enforcing coding style 
guides).

We definitely do not want a complicated testing matrix of "what if this set of 
features is enabled and that set of features is disabled but the rest follows 
the given language standard". One thing that worries me in this case is the 
`` header in C++23; without coroutines, that can't compile.

Personally, I think we should err on the side of being conservative with 
language dialect flags unless there's a clear need: don't reflexively enable 
features as extensions in older language modes and don't allow users to disable 
features in newer language modes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156247

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


[clang] 771d7d7 - [clang][dataflow] HTMLLogger: Don't crash if CFG contains unreachable blocks.

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

Author: Martin Braenne
Date: 2023-07-27T13:02:42Z
New Revision: 771d7d71df418f12c80632ec6c3488af98f9b196

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

LOG: [clang][dataflow] HTMLLogger: Don't crash if CFG contains unreachable 
blocks.

Reviewed By: sammccall

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

Added: 


Modified: 
clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp

Removed: 




diff  --git a/clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp 
b/clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp
index ee89e074f84676..ea9052b0e7171e 100644
--- a/clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp
+++ b/clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp
@@ -462,8 +462,9 @@ class HTMLLogger : public Logger {
   GraphS << "  " << blockID(I) << " [id=" << blockID(I) << "]\n";
 for (const auto *Block : CFG) {
   for (const auto &Succ : Block->succs()) {
-GraphS << "  " << blockID(Block->getBlockID()) << " -> "
-   << blockID(Succ.getReachableBlock()->getBlockID()) << "\n";
+if (Succ.getReachableBlock())
+  GraphS << "  " << blockID(Block->getBlockID()) << " -> "
+ << blockID(Succ.getReachableBlock()->getBlockID()) << "\n";
   }
 }
 GraphS << "}\n";



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


[PATCH] D156411: [clang][dataflow] HTMLLogger: Don't crash if CFG contains unreachable blocks.

2023-07-27 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 rG771d7d71df41: [clang][dataflow] HTMLLogger: Don't crash 
if CFG contains unreachable blocks. (authored by mboehme).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156411

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


Index: clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp
===
--- clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp
+++ clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp
@@ -462,8 +462,9 @@
   GraphS << "  " << blockID(I) << " [id=" << blockID(I) << "]\n";
 for (const auto *Block : CFG) {
   for (const auto &Succ : Block->succs()) {
-GraphS << "  " << blockID(Block->getBlockID()) << " -> "
-   << blockID(Succ.getReachableBlock()->getBlockID()) << "\n";
+if (Succ.getReachableBlock())
+  GraphS << "  " << blockID(Block->getBlockID()) << " -> "
+ << blockID(Succ.getReachableBlock()->getBlockID()) << "\n";
   }
 }
 GraphS << "}\n";


Index: clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp
===
--- clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp
+++ clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp
@@ -462,8 +462,9 @@
   GraphS << "  " << blockID(I) << " [id=" << blockID(I) << "]\n";
 for (const auto *Block : CFG) {
   for (const auto &Succ : Block->succs()) {
-GraphS << "  " << blockID(Block->getBlockID()) << " -> "
-   << blockID(Succ.getReachableBlock()->getBlockID()) << "\n";
+if (Succ.getReachableBlock())
+  GraphS << "  " << blockID(Block->getBlockID()) << " -> "
+ << blockID(Succ.getReachableBlock()->getBlockID()) << "\n";
   }
 }
 GraphS << "}\n";
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D155922: [clang][dataflow] Eliminate `ReferenceValue`.

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

Pre-merge failure looks unrelated. It's in AST/Interp/literals.cpp, and this 
patch shouldn't affect that in any way.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155922

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


[PATCH] D155921: [clang][dataflow] Reverse course on `getValue()` deprecation.

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

Pre-merge failure looks unrelated. It's in AST/Interp/literals.cpp, and this 
patch shouldn't affect that in any way.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155921

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


[PATCH] D151373: [libclang] Expose arguments of clang::annotate{_type}

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

In D151373#4533550 , @fridtjof wrote:

> I fixed the failing IBOutletCollection.m test - there was code to do special 
> handling for the respective attribute type, which my patch accidentally 
> skipped previously. I reordered the generic attribute handling to come after 
> the special cases in VisitChildren.

Nice!

> I cleaned up my unit test. After trying a bit to fix it for testing 
> annotate_type as well, I found out that for some unknown reason it is not 
> exposed like usual attributes (maybe because it's a type attribute?).
> Therefore, I decided to drop it from the test altogether.

I think we should drop the `annotate_type` functionality from the patch 
entirely rather than add it without any test coverage knowing it doesn't seem 
to work as expected.


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

https://reviews.llvm.org/D151373

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


[PATCH] D156425: [clang-repl] Remove redundant tests

2023-07-27 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld created this revision.
Hahnfeld added a reviewer: v.g.vassilev.
Herald added a project: All.
Hahnfeld requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

They only need to be tested once in `execute.cpp` and `fail.cpp`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D156425

Files:
  clang/test/Interpreter/code-undo.cpp
  clang/test/Interpreter/execute-weak.cpp
  clang/test/Interpreter/execute.cpp
  clang/test/Interpreter/fail.cpp
  clang/test/Interpreter/lambda.cpp


Index: clang/test/Interpreter/lambda.cpp
===
--- clang/test/Interpreter/lambda.cpp
+++ clang/test/Interpreter/lambda.cpp
@@ -1,9 +1,5 @@
-// RUN: clang-repl "int x = 10;" "int y=7; err;" "int y = 10;"
-// RUN: clang-repl "int i = 10;" 'extern "C" int printf(const char*,...);' \
-// RUN:'auto r1 = printf("i = %d\n", i);' | FileCheck 
--check-prefix=CHECK-DRIVER %s
 // REQUIRES: host-supports-jit
 // UNSUPPORTED: system-aix
-// CHECK-DRIVER: i = 10
 // RUN: cat %s | clang-repl | FileCheck %s
 // RUN: cat %s | clang-repl -Xcc -O2 | FileCheck %s
 extern "C" int printf(const char *, ...);
Index: clang/test/Interpreter/fail.cpp
===
--- clang/test/Interpreter/fail.cpp
+++ clang/test/Interpreter/fail.cpp
@@ -3,11 +3,8 @@
 // error, and then successfully recovers if we decide it's a success then for
 // the non-interactive mode the exit code should be a failure.
 // RUN: clang-repl "int x = 10;" "int y=7; err;" "int y = 10;"
-// RUN: clang-repl "int i = 10;" 'extern "C" int printf(const char*,...);' \
-// RUN:'auto r1 = printf("i = %d\n", i);' | FileCheck 
--check-prefix=CHECK-DRIVER %s
 // REQUIRES: host-supports-jit
 // UNSUPPORTED: system-aix
-// CHECK-DRIVER: i = 10
 // RUN: cat %s | not clang-repl | FileCheck %s
 BOOM!
 extern "C" int printf(const char *, ...);
Index: clang/test/Interpreter/execute.cpp
===
--- clang/test/Interpreter/execute.cpp
+++ clang/test/Interpreter/execute.cpp
@@ -1,9 +1,10 @@
+// UNSUPPORTED: system-aix
+
 // clang-format off
-// RUN: clang-repl "int x = 10;" "int y=7; err;" "int y = 10;"
 // RUN: clang-repl "int i = 10;" 'extern "C" int printf(const char*,...);' \
 // RUN:'auto r1 = printf("i = %d\n", i);' | FileCheck 
--check-prefix=CHECK-DRIVER %s
-// UNSUPPORTED: system-aix
 // CHECK-DRIVER: i = 10
+
 // RUN: cat %s | clang-repl | FileCheck %s
 // RUN: cat %s | clang-repl -Xcc -O2 | FileCheck %s
 extern "C" int printf(const char *, ...);
Index: clang/test/Interpreter/execute-weak.cpp
===
--- clang/test/Interpreter/execute-weak.cpp
+++ clang/test/Interpreter/execute-weak.cpp
@@ -1,8 +1,3 @@
-// RUN: clang-repl "int x = 10;" "int y=7; err;" "int y = 10;"
-// RUN: clang-repl "int i = 10;" 'extern "C" int printf(const char*,...);' \
-// RUN:'auto r1 = printf("i = %d\n", i);' | FileCheck 
--check-prefix=CHECK-DRIVER %s
-// CHECK-DRIVER: i = 10
-//
 // UNSUPPORTED: system-aix, system-windows
 // RUN: cat %s | clang-repl | FileCheck %s
 
Index: clang/test/Interpreter/code-undo.cpp
===
--- clang/test/Interpreter/code-undo.cpp
+++ clang/test/Interpreter/code-undo.cpp
@@ -1,7 +1,4 @@
-// RUN: clang-repl "int i = 10;" 'extern "C" int printf(const char*,...);' \
-// RUN:'auto r1 = printf("i = %d\n", i);' | FileCheck 
--check-prefix=CHECK-DRIVER %s
 // UNSUPPORTED: system-aix
-// CHECK-DRIVER: i = 10
 // RUN: cat %s | clang-repl | FileCheck %s
 extern "C" int printf(const char *, ...);
 int x1 = 0;


Index: clang/test/Interpreter/lambda.cpp
===
--- clang/test/Interpreter/lambda.cpp
+++ clang/test/Interpreter/lambda.cpp
@@ -1,9 +1,5 @@
-// RUN: clang-repl "int x = 10;" "int y=7; err;" "int y = 10;"
-// RUN: clang-repl "int i = 10;" 'extern "C" int printf(const char*,...);' \
-// RUN:'auto r1 = printf("i = %d\n", i);' | FileCheck --check-prefix=CHECK-DRIVER %s
 // REQUIRES: host-supports-jit
 // UNSUPPORTED: system-aix
-// CHECK-DRIVER: i = 10
 // RUN: cat %s | clang-repl | FileCheck %s
 // RUN: cat %s | clang-repl -Xcc -O2 | FileCheck %s
 extern "C" int printf(const char *, ...);
Index: clang/test/Interpreter/fail.cpp
===
--- clang/test/Interpreter/fail.cpp
+++ clang/test/Interpreter/fail.cpp
@@ -3,11 +3,8 @@
 // error, and then successfully recovers if we decide it's a success then for
 // the non-interactive mode the exit code should be a failure.
 // RUN: clang-repl "int x = 10;" "int y=7; err;" "int y = 10;"
-// RUN: clang-repl "int i = 10;" 'extern "C" int printf(const char*,...);' \
-// RUN:'auto r1 = printf("i = %d\n", i);

[clang] 1b334a2 - [clang][dataflow] Eliminate `ReferenceValue`.

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

Author: Martin Braenne
Date: 2023-07-27T13:14:47Z
New Revision: 1b334a2ae7af8ad8b2e3367db6433f1bc7b2b1a4

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

LOG: [clang][dataflow] Eliminate `ReferenceValue`.

There are no remaining uses of this class in the framework.

This patch is part of the ongoing migration to strict handling of value 
categories (see https://discourse.llvm.org/t/70086 for details).

Reviewed By: ymandel, xazax.hun, gribozavr2

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

Added: 


Modified: 
clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
clang/include/clang/Analysis/FlowSensitive/Value.h
clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
clang/lib/Analysis/FlowSensitive/DebugSupport.cpp
clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp
clang/lib/Analysis/FlowSensitive/Value.cpp
clang/unittests/Analysis/FlowSensitive/ValueTest.cpp

Removed: 




diff  --git a/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h 
b/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
index 5cf52ad3d72235..6a6c6856cce95b 100644
--- a/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
+++ b/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
@@ -47,6 +47,7 @@ enum class SkipPast {
   /// No indirections should be skipped past.
   None,
   /// An optional reference should be skipped past.
+  /// This is deprecated; it is equivalent to `None` and will be removed.
   Reference,
 };
 
@@ -304,9 +305,10 @@ class Environment {
   ///  `E` must be a glvalue or a `BuiltinType::BuiltinFn`
   void setStorageLocationStrict(const Expr &E, StorageLocation &Loc);
 
-  /// Returns the storage location assigned to `E` in the environment, applying
-  /// the `SP` policy for skipping past indirections, or null if `E` isn't
-  /// assigned a storage location in the environment.
+  /// Returns the storage location assigned to `E` in the environment, or null
+  /// if `E` isn't assigned a storage location in the environment.
+  ///
+  /// The `SP` parameter has no effect.
   ///
   /// This function is deprecated; prefer `getStorageLocationStrict()`.
   /// For details, see https://discourse.llvm.org/t/70086.
@@ -490,12 +492,14 @@ class Environment {
   /// isn't assigned a value in the environment.
   Value *getValue(const StorageLocation &Loc) const;
 
-  /// Equivalent to `getValue(getStorageLocation(D, SP), SkipPast::None)` if 
`D`
-  /// is assigned a storage location in the environment, otherwise returns 
null.
+  /// Equivalent to `getValue(getStorageLocation(D))` if `D` is assigned a
+  /// storage location in the environment, otherwise returns null.
   Value *getValue(const ValueDecl &D) const;
 
-  /// Equivalent to `getValue(getStorageLocation(E, SP), SkipPast::None)` if 
`E`
-  /// is assigned a storage location in the environment, otherwise returns 
null.
+  /// Equivalent to `getValue(getStorageLocation(E, SP))` if `E` is assigned a
+  /// storage location in the environment, otherwise returns null.
+  ///
+  /// The `SP` parameter has no effect.
   ///
   /// This function is deprecated; prefer `getValueStrict()`. For details, see
   /// https://discourse.llvm.org/t/70086.
@@ -672,9 +676,6 @@ class Environment {
   StorageLocation &createObjectInternal(const VarDecl *D, QualType Ty,
 const Expr *InitExpr);
 
-  StorageLocation &skip(StorageLocation &Loc, SkipPast SP) const;
-  const StorageLocation &skip(const StorageLocation &Loc, SkipPast SP) const;
-
   /// Shared implementation of `pushCall` overloads. Note that unlike
   /// `pushCall`, this member is invoked on the environment of the callee, not
   /// of the caller.

diff  --git a/clang/include/clang/Analysis/FlowSensitive/Value.h 
b/clang/include/clang/Analysis/FlowSensitive/Value.h
index 7d9a7b7d28254b..d1432fe8217a13 100644
--- a/clang/include/clang/Analysis/FlowSensitive/Value.h
+++ b/clang/include/clang/Analysis/FlowSensitive/Value.h
@@ -34,7 +34,6 @@ class Value {
 public:
   enum class Kind {
 Integer,
-Reference,
 Pointer,
 Struct,
 
@@ -165,23 +164,6 @@ class IntegerValue : public Value {
   }
 };
 
-/// Models a dereferenced pointer. For example, a reference in C++ or an lvalue
-/// in C.
-class ReferenceValue final : public Value {
-public:
-  explicit ReferenceValue(StorageLocation &ReferentLoc)
-  : Value(Kind::Reference), ReferentLoc(ReferentLoc) {}
-
-  static bool classof(const Value *Val) {
-return Val->getKind() == Kind::Reference;
-  }
-
-  StorageLocation &getReferentLoc() const { return ReferentLoc; }
-
-private:
-  StorageLocation &ReferentLoc;
-};
-
 /// Models a symbolic pointer. Specifically, any value of type `T*`.
 class PointerVa

[clang] e95134b - [clang][dataflow] Reverse course on `getValue()` deprecation.

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

Author: Martin Braenne
Date: 2023-07-27T13:14:49Z
New Revision: e95134b9cb1885b0da929737858163486a5c399c

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

LOG: [clang][dataflow] Reverse course on `getValue()` deprecation.

In the [value categories RFC](https://discourse.llvm.org/t/70086), I proposed 
that the end state of the migration should be that `getValue()` should only be 
legal to call on prvalues.

As a stepping stone, to allow migrating off existing calls to `getValue()`, I 
proposed introducing `getValueStrict()`, which would already have the new 
semantics.

However, I've now reconsidered this. Any expression, whether prvalue or 
glvalue, has a value, so really there isn't any reason to forbid calling 
`getValue()` on glvalues. I'm therefore removing the deprecation from 
`getValue()` and transitioning existing `getValueStrict()` calls back to 
`getValue()`.

The other "strict" accessors are a different case. `setValueStrict()` should 
only be called on prvalues because glvalues need to have a storage location 
associated with them; it doesn't make sense to only set a value for them. And, 
of course, `getStorageLocationStrict()` and `setStorageLocationStrict()` should 
obviously only be called on glvalues because prvalues don't have storage 
locations.

Reviewed By: ymandel, xazax.hun

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

Added: 


Modified: 
clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp
clang/lib/Analysis/FlowSensitive/Transfer.cpp
clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
clang/unittests/Analysis/FlowSensitive/SignAnalysisTest.cpp
clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp

Removed: 




diff  --git a/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h 
b/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
index 6a6c6856cce95b..460727973ed4c8 100644
--- a/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
+++ b/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
@@ -499,20 +499,14 @@ class Environment {
   /// Equivalent to `getValue(getStorageLocation(E, SP))` if `E` is assigned a
   /// storage location in the environment, otherwise returns null.
   ///
-  /// The `SP` parameter has no effect.
-  ///
-  /// This function is deprecated; prefer `getValueStrict()`. For details, see
-  /// https://discourse.llvm.org/t/70086.
-  Value *getValue(const Expr &E, SkipPast SP) const;
+  /// The `SP` parameter is deprecated and has no effect. New callers should
+  /// avoid passing this parameter.
+  Value *getValue(const Expr &E, SkipPast SP = SkipPast::None) const;
 
   /// Returns the `Value` assigned to the prvalue `E` in the environment, or
   /// null if `E` isn't assigned a value in the environment.
   ///
-  /// This function is the preferred alternative to
-  /// `getValue(const Expr &, SkipPast)`. Once the migration to strict handling
-  /// of value categories is complete (see https://discourse.llvm.org/t/70086),
-  /// `getValue()` will be removed and this function will be renamed to
-  /// `getValue()`.
+  /// This function is deprecated. Call `getValue(E)` instead.
   ///
   /// Requirements:
   ///

diff  --git a/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp 
b/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
index d3d5f3338ddf49..903d9ec300e2f6 100644
--- a/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
+++ b/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
@@ -686,7 +686,7 @@ void Environment::setValueStrict(const Expr &E, Value &Val) 
{
   assert(E.isPRValue());
 
   if (auto *StructVal = dyn_cast(&Val)) {
-if (auto *ExistingVal = cast_or_null(getValueStrict(E)))
+if (auto *ExistingVal = cast_or_null(getValue(E)))
   assert(&ExistingVal->getAggregateLoc() == &StructVal->getAggregateLoc());
 if (StorageLocation *ExistingLoc = getStorageLocation(E, SkipPast::None))
   assert(ExistingLoc == &StructVal->getAggregateLoc());
@@ -724,9 +724,7 @@ Value *Environment::getValue(const Expr &E, SkipPast SP) 
const {
 
 Value *Environment::getValueStrict(const Expr &E) const {
   assert(E.isPRValue());
-  Value *Val = getValue(E, SkipPast::None);
-
-  return Val;
+  return getValue(E);
 }
 
 Value *Environment::createValue(QualType Type) {
@@ -859,7 +857,7 @@ StorageLocation &Environment::createObjectInternal(const 
VarDecl *D,
 // assert that `InitExpr` is interpreted, rather than supplying a
 // default value (assuming we don't update the environment A

[PATCH] D155922: [clang][dataflow] Eliminate `ReferenceValue`.

2023-07-27 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 rG1b334a2ae7af: [clang][dataflow] Eliminate `ReferenceValue`. 
(authored by mboehme).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155922

Files:
  clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
  clang/include/clang/Analysis/FlowSensitive/Value.h
  clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
  clang/lib/Analysis/FlowSensitive/DebugSupport.cpp
  clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp
  clang/lib/Analysis/FlowSensitive/Value.cpp
  clang/unittests/Analysis/FlowSensitive/ValueTest.cpp

Index: clang/unittests/Analysis/FlowSensitive/ValueTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/ValueTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/ValueTest.cpp
@@ -29,14 +29,6 @@
   EXPECT_FALSE(areEquivalentValues(V1, V2));
 }
 
-TEST(ValueTest, AliasedReferencesEquivalent) {
-  auto L = ScalarStorageLocation(QualType());
-  ReferenceValue V1(L);
-  ReferenceValue V2(L);
-  EXPECT_TRUE(areEquivalentValues(V1, V2));
-  EXPECT_TRUE(areEquivalentValues(V2, V1));
-}
-
 TEST(ValueTest, AliasedPointersEquivalent) {
   auto L = ScalarStorageLocation(QualType());
   PointerValue V1(L);
@@ -68,21 +60,12 @@
 TEST(ValueTest, DifferentKindsNotEquivalent) {
   Arena A;
   auto L = ScalarStorageLocation(QualType());
-  ReferenceValue V1(L);
+  PointerValue V1(L);
   TopBoolValue V2(A.makeAtomRef(Atom(0)));
   EXPECT_FALSE(areEquivalentValues(V1, V2));
   EXPECT_FALSE(areEquivalentValues(V2, V1));
 }
 
-TEST(ValueTest, NotAliasedReferencesNotEquivalent) {
-  auto L1 = ScalarStorageLocation(QualType());
-  ReferenceValue V1(L1);
-  auto L2 = ScalarStorageLocation(QualType());
-  ReferenceValue V2(L2);
-  EXPECT_FALSE(areEquivalentValues(V1, V2));
-  EXPECT_FALSE(areEquivalentValues(V2, V1));
-}
-
 TEST(ValueTest, NotAliasedPointersNotEquivalent) {
   auto L1 = ScalarStorageLocation(QualType());
   PointerValue V1(L1);
Index: clang/lib/Analysis/FlowSensitive/Value.cpp
===
--- clang/lib/Analysis/FlowSensitive/Value.cpp
+++ clang/lib/Analysis/FlowSensitive/Value.cpp
@@ -19,10 +19,6 @@
 
 static bool areEquivalentIndirectionValues(const Value &Val1,
const Value &Val2) {
-  if (auto *IndVal1 = dyn_cast(&Val1)) {
-auto *IndVal2 = cast(&Val2);
-return &IndVal1->getReferentLoc() == &IndVal2->getReferentLoc();
-  }
   if (auto *IndVal1 = dyn_cast(&Val1)) {
 auto *IndVal2 = cast(&Val2);
 return &IndVal1->getPointeeLoc() == &IndVal2->getPointeeLoc();
@@ -38,10 +34,6 @@
 
 raw_ostream &operator<<(raw_ostream &OS, const Value &Val) {
   switch (Val.getKind()) {
-  case Value::Kind::Reference: {
-const auto *RV = cast(&Val);
-return OS << "Reference(" << &RV->getReferentLoc() << ")";
-  }
   case Value::Kind::Pointer: {
 const auto *PV = dyn_cast(&Val);
 return OS << "Pointer(" << &PV->getPointeeLoc() << ")";
Index: clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp
===
--- clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp
+++ clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp
@@ -99,10 +99,6 @@
 case Value::Kind::AtomicBool:
 case Value::Kind::FormulaBool:
   break;
-case Value::Kind::Reference:
-  JOS.attributeObject(
-  "referent", [&] { dump(cast(V).getReferentLoc()); });
-  break;
 case Value::Kind::Pointer:
   JOS.attributeObject(
   "pointee", [&] { dump(cast(V).getPointeeLoc()); });
Index: clang/lib/Analysis/FlowSensitive/DebugSupport.cpp
===
--- clang/lib/Analysis/FlowSensitive/DebugSupport.cpp
+++ clang/lib/Analysis/FlowSensitive/DebugSupport.cpp
@@ -26,8 +26,6 @@
   switch (Kind) {
   case Value::Kind::Integer:
 return "Integer";
-  case Value::Kind::Reference:
-return "Reference";
   case Value::Kind::Pointer:
 return "Pointer";
   case Value::Kind::Struct:
Index: clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
===
--- clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
+++ clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
@@ -68,7 +68,6 @@
   case ComparisonResult::Unknown:
 switch (Val1.getKind()) {
 case Value::Kind::Integer:
-case Value::Kind::Reference:
 case Value::Kind::Pointer:
 case Value::Kind::Struct:
   // FIXME: this choice intentionally introduces unsoundness to allow
@@ -140,11 +139,6 @@
 
   // FIXME: Consider destroying `MergedValue` immediately if `ValueModel::merge`
   // returns false to avoid storing unneeded values in `DACtx`.
-  // FIXME: Creating the

[PATCH] D156247: [Clang] Add a warning on uses of coroutine keywords

2023-07-27 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a reviewer: libc++.
aaron.ballman added a comment.

I would like explicit buy-in from the libc++ folks on the idea of adding 
`-fno-coroutines` as they're going to be impacted by Clang supporting such an 
option (and they may have additional testing requirements to ensure that libc++ 
works reasonably well when coroutines are disabled).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156247

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


[PATCH] D155921: [clang][dataflow] Reverse course on `getValue()` deprecation.

2023-07-27 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 rGe95134b9cb18: [clang][dataflow] Reverse course on 
`getValue()` deprecation. (authored by mboehme).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155921

Files:
  clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
  clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
  clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp
  clang/lib/Analysis/FlowSensitive/Transfer.cpp
  clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
  clang/unittests/Analysis/FlowSensitive/SignAnalysisTest.cpp
  clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
  clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp

Index: clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
@@ -415,7 +415,7 @@
 if (const auto *E = selectFirst(
 "call", match(cxxConstructExpr(HasSpecialBoolType).bind("call"), *S,
   getASTContext( {
-  cast(Env.getValueStrict(*E))
+  cast(Env.getValue(*E))
   ->setProperty("is_set", Env.getBoolLiteralValue(false));
 } else if (const auto *E = selectFirst(
"call", match(cxxMemberCallExpr(callee(cxxMethodDecl(ofClass(
@@ -572,7 +572,7 @@
 *S, getASTContext());
 if (const auto *E = selectFirst(
 "construct", Matches)) {
-  cast(Env.getValueStrict(*E))
+  cast(Env.getValue(*E))
   ->setProperty("has_value", Env.getBoolLiteralValue(false));
 } else if (const auto *E =
selectFirst("operator", Matches)) {
Index: clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
@@ -5546,7 +5546,7 @@
   ASTCtx));
 
 ASSERT_THAT(ImplicitCast, NotNull());
-EXPECT_THAT(Env.getValueStrict(*ImplicitCast), IsNull());
+EXPECT_THAT(Env.getValue(*ImplicitCast), IsNull());
   });
 }
 
Index: clang/unittests/Analysis/FlowSensitive/SignAnalysisTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/SignAnalysisTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/SignAnalysisTest.cpp
@@ -114,7 +114,7 @@
 return {nullptr, {}, {}};
 
   // Value of the unary op.
-  auto *UnaryOpValue = State.Env.getValueStrict(*UO);
+  auto *UnaryOpValue = State.Env.getValue(*UO);
   if (!UnaryOpValue) {
 UnaryOpValue = &State.Env.makeAtomicBoolValue();
 State.Env.setValueStrict(*UO, *UnaryOpValue);
@@ -133,7 +133,7 @@
 LatticeTransferState &State) {
   auto &A = State.Env.arena();
   const Formula *Comp;
-  if (BoolValue *V = cast_or_null(State.Env.getValueStrict(*BO))) {
+  if (BoolValue *V = cast_or_null(State.Env.getValue(*BO))) {
 Comp = &V->formula();
   } else {
 Comp = &A.makeAtomRef(A.makeAtom());
@@ -143,8 +143,8 @@
   // FIXME Use this as well:
   // auto *NegatedComp = &State.Env.makeNot(*Comp);
 
-  auto *LHS = State.Env.getValueStrict(*BO->getLHS());
-  auto *RHS = State.Env.getValueStrict(*BO->getRHS());
+  auto *LHS = State.Env.getValue(*BO->getLHS());
+  auto *RHS = State.Env.getValue(*BO->getRHS());
 
   if (!LHS || !RHS)
 return;
@@ -271,7 +271,7 @@
   Env.setValue(*Loc, *Val);
 }
   } else {
-Val = Env.getValueStrict(*E);
+Val = Env.getValue(*E);
 if (!Val) {
   Val = Env.createValue(E->getType());
   Env.setValueStrict(*E, *Val);
Index: clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
===
--- clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
+++ clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
@@ -125,10 +125,10 @@
 private:
   TerminatorVisitorRetTy extendFlowCondition(const Expr &Cond) {
 // The terminator sub-expression might not be evaluated.
-if (Env.getValueStrict(Cond) == nullptr)
+if (Env.getValue(Cond) == nullptr)
   transfer(StmtToEnv, Cond, Env);
 
-auto *Val = cast_or_null(Env.getValueStrict(Cond));
+auto *Val = cast_or_null(Env.getValue(Cond));
 // Value merging depends on flow conditions from different environments
 // being mutually exclusive -- that is, they cannot both be true in their
 // entirety (even if they may share some clauses). So, we need *some* value
@@ -407,7 +407,7 @@
   return;
 
 ParentLoc->setChild(*Member, InitE

[PATCH] D156247: [Clang] Add a warning on uses of coroutine keywords

2023-07-27 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added a comment.

Thanks for the explanation. I am strongly in favor with you : )


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156247

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


[PATCH] D156426: [HIP] link HIP runtime library without --hip-link

2023-07-27 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.
yaxunl added reviewers: tra, scchan, MaskRay, jhuber6.
Herald added a project: All.
yaxunl requested review of this revision.

When doing combined compilation/link for HIP source files, clang should link 
the HIP runtime library automatically without `--hip-link`.


https://reviews.llvm.org/D156426

Files:
  clang/docs/HIPSupport.rst
  clang/include/clang/Driver/Driver.h
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/hip-runtime-libs-linux.hip
  clang/test/Driver/hip-runtime-libs-msvc.hip
  clang/test/Driver/rocm-detect.hip

Index: clang/test/Driver/rocm-detect.hip
===
--- clang/test/Driver/rocm-detect.hip
+++ clang/test/Driver/rocm-detect.hip
@@ -35,32 +35,32 @@
 
 // Test HIP_PATH overrides ROCM_PATH.
 // RUN: env ROCM_PATH=%S/Inputs/rocm HIP_PATH=%t/myhip \
-// RUN:   %clang -### -target x86_64-linux-gnu --offload-arch=gfx1010 --hip-link \
+// RUN:   %clang -### -target x86_64-linux-gnu --offload-arch=gfx1010 \
 // RUN:   --print-rocm-search-dirs %s 2>&1 \
 // RUN:   | FileCheck -check-prefixes=ROCM-ENV,HIP-PATH %s
 
 // Test --hip-path overrides ROCM_PATH.
 // RUN: env ROCM_PATH=%S/Inputs/rocm \
-// RUN:   %clang -### -target x86_64-linux-gnu --offload-arch=gfx1010 --hip-link \
+// RUN:   %clang -### -target x86_64-linux-gnu --offload-arch=gfx1010 \
 // RUN:   --hip-path=%t/myhip \
 // RUN:   --print-rocm-search-dirs %s 2>&1 \
 // RUN:   | FileCheck -check-prefixes=ROCM-ENV,HIP-PATH %s
 
 // Test --hip-path overrides --rocm-path.
-// RUN: %clang -### -target x86_64-linux-gnu --offload-arch=gfx1010 --hip-link \
+// RUN: %clang -### -target x86_64-linux-gnu --offload-arch=gfx1010 \
 // RUN:   --hip-path=%t/myhip --rocm-path=%S/Inputs/rocm \
 // RUN:   --print-rocm-search-dirs %s 2>&1 \
 // RUN:   | FileCheck -check-prefixes=ROCM-ENV,HIP-PATH %s
 
 // Test HIP_PATH overrides --rocm-path.
-// RUN: env HIP_PATH=%t/myhip %clang -### -target x86_64-linux-gnu --offload-arch=gfx1010 --hip-link \
+// RUN: env HIP_PATH=%t/myhip %clang -### -target x86_64-linux-gnu --offload-arch=gfx1010 \
 // RUN:   --rocm-path=%S/Inputs/rocm \
 // RUN:   --print-rocm-search-dirs %s 2>&1 \
 // RUN:   | FileCheck -check-prefixes=ROCM-ENV,HIP-PATH %s
 
 // Test empty HIP_PATH does not override --rocm-path.
 // RUN: env HIP_PATH= \
-// RUN:   %clang -### -target x86_64-linux-gnu --offload-arch=gfx1010 --hip-link \
+// RUN:   %clang -### -target x86_64-linux-gnu --offload-arch=gfx1010 \
 // RUN:   --rocm-path=%S/Inputs/rocm --print-rocm-search-dirs %s 2>&1 \
 // RUN:   | FileCheck -check-prefixes=ROCM-PATH %s
 
Index: clang/test/Driver/hip-runtime-libs-msvc.hip
===
--- clang/test/Driver/hip-runtime-libs-msvc.hip
+++ clang/test/Driver/hip-runtime-libs-msvc.hip
@@ -7,4 +7,9 @@
 // RUN:   --rocm-path=%S/Inputs/rocm %t.o 2>&1 \
 // RUN:   | FileCheck %s
 
+// Test HIP runtime lib is linked without --hip-link when there is HIP input file.
+// RUN: %clang -### --target=x86_64-pc-windows-msvc \
+// RUN:   --rocm-path=%S/Inputs/rocm %s 2>&1 \
+// RUN:   | FileCheck %s
+
 // CHECK: "-libpath:{{.*Inputs.*rocm.*lib}}" "amdhip64.lib"
Index: clang/test/Driver/hip-runtime-libs-linux.hip
===
--- clang/test/Driver/hip-runtime-libs-linux.hip
+++ clang/test/Driver/hip-runtime-libs-linux.hip
@@ -43,6 +43,11 @@
 // RUN:   --rocm-path=%S/Inputs/rocm %t.o 2>&1 \
 // RUN:   | FileCheck -check-prefixes=NOHIPRT %s
 
+// Test HIP runtime lib is linked without hip-link if there is HIP input file.
+// RUN: %clang -### --target=x86_64-linux-gnu \
+// RUN:   --rocm-path=%S/Inputs/rocm %s 2>&1 \
+// RUN:   | FileCheck -check-prefixes=ROCM-PATH %s
+
 // ROCM-PATH: "-L[[HIPRT:.*/Inputs/rocm/lib]]" "-lamdhip64"
 // ROCM-RPATH: "-L[[HIPRT:.*/Inputs/rocm/lib]]" "-rpath" "[[HIPRT]]" "-lamdhip64"
 // ROCM-REL: "-L[[HIPRT:.*/opt/rocm-3.10.0/lib]]" "-lamdhip64"
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -2431,7 +2431,7 @@
 void tools::addHIPRuntimeLibArgs(const ToolChain &TC,
  const llvm::opt::ArgList &Args,
  llvm::opt::ArgStringList &CmdArgs) {
-  if (Args.hasArg(options::OPT_hip_link) &&
+  if ((Args.hasArg(options::OPT_hip_link) || TC.getDriver().hasHIPInputs()) &&
   !Args.hasArg(options::OPT_nostdlib) &&
   !Args.hasArg(options::OPT_no_hip_rt)) {
 TC.AddHIPRuntimeLibArgs(Args, CmdArgs);
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -786,12 +786,7 @@
   llvm::any_of(Inputs, [](std::pair &I) {
 return types::isCuda(I.first);
 

[PATCH] D156426: [HIP] link HIP runtime library without --hip-link

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

So this is equivalent to `nvcc` implicitly calling `-lcudart`? I've had 
thoughts about the `clang-linker-wrapper` adding known runtime flags to the 
link job if it's not found. E.g. if we find a CUDA image we pass `-lcudart`.


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

https://reviews.llvm.org/D156426

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


[PATCH] D156247: [Clang] Add a warning on uses of coroutine keywords

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

In D156247#4534645 , @ilya-biryukov 
wrote:

> At Google, we would like to postpone adoption of coroutines until the 
> aforementioned bugs are fixed, but we feel that Clang 17 would be a good 
> candidate to enable other C++20 features (sans Modules).
> We could have landed a local patch with a similar warning in our main 
> toolchain that we control tightly. However, we want to have it for other 
> toolchains (e.g. Apple Clang) that are based on upstream and we do not 
> control.

Given that adoption by Apple Clang is one of the motivation to make this change 
upstream, do we have a reasonable expectation they would pick this change soon? 
Historically Apple follows a release schedule that is not synchronized 
with the LLVM release process.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156247

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


[PATCH] D156426: [HIP] link HIP runtime library without --hip-link

2023-07-27 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In D156426#4538646 , @jhuber6 wrote:

> So this is equivalent to `nvcc` implicitly calling `-lcudart`? I've had 
> thoughts about the `clang-linker-wrapper` adding known runtime flags to the 
> link job if it's not found. E.g. if we find a CUDA image we pass `-lcudart`.

yes


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

https://reviews.llvm.org/D156426

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


[PATCH] D156426: [HIP] link HIP runtime library without --hip-link

2023-07-27 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added inline comments.



Comment at: clang/include/clang/Driver/Driver.h:712
+  /// Whether there are HIP input files.
+  bool hasHIPInputs() const { return HasHIPInputs; }
+

Shouldn't we have access to the compilation? I figured we could check 
`C.getActiveOffloadKinds()` or w/e it's called.


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

https://reviews.llvm.org/D156426

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


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

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

Can you update the patch description with more details about why these changes 
are being made in this way (to help people doing code archaeology in the 
future)?




Comment at: clang/include/clang/Basic/DiagnosticCommonKinds.td:60
+  "'external_source_symbol' attribute|"
+  "as argument of '%1' attribute}0">;
+

This duplicates part of `err_attribute_argument_type`; probably worth it to 
update that diagnostic so we get consistent diagnostic wording between 
attributes expecting string literal arguments.



Comment at: clang/lib/Parse/ParseDeclCXX.cpp:1029
 }
-
 if (AssertMessage.isInvalid()) {

Spurious whitespace change is the only change in this file.



Comment at: clang/lib/Parse/ParseExpr.cpp:3497-3499
+} else {
   Expr = ParseAssignmentExpression();
+}

Spurious brace changes are the only changes in this file.



Comment at: clang/test/Parser/cxx-attributes.cpp:44
 
-[[deprecated([""])]] int WrongArgs; // expected-error {{expected variable name 
or 'this' in lambda capture list}}
+[[deprecated([""])]] int WrongArgs; // expected-error {{expected string 
literal as argument of 'deprecated' attribute}}
 [[,]] int Commas1; // ok

LOL this is a much better diagnostic than the previous one. :-D


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156237

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


[PATCH] D156247: [Clang] Add a warning on uses of coroutine keywords

2023-07-27 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

Thanks, disabling the language feature definitely makes more sense.
`-fno-coroutines` is trickier to implement, but this cannot be too hard.

While we are waiting for libc++ folks to come back with feedback, what would be 
the desired behavior. GCC seems to

1. errors out on `#include `,
2. treats coroutine keywords as identifiers.

While (1) makes total sense, I'm not sure about (2). Should we instead show 
errors, but still treat `co_await` and friends as keywords?
I think it would be a better choice because it would prevent writing 
non-standard-compliant code.
On the other hand, given the `co_` prefix, the clashes should be **really** 
rare anyway and we might want to match GCC behavior.

Thoughts?

In D156247#4538647 , @cor3ntin wrote:

> In D156247#4534645 , @ilya-biryukov 
> wrote:
>
>> At Google, we would like to postpone adoption of coroutines until the 
>> aforementioned bugs are fixed, but we feel that Clang 17 would be a good 
>> candidate to enable other C++20 features (sans Modules).
>> We could have landed a local patch with a similar warning in our main 
>> toolchain that we control tightly. However, we want to have it for other 
>> toolchains (e.g. Apple Clang) that are based on upstream and we do not 
>> control.
>> Given that adoption by Apple Clang is one of the motivation to make this 
>> change upstream, do we have a reasonable expectation they would pick this 
>> change soon? Historically Apple follows a release schedule that is not 
>> synchronized
>
> with the LLVM release process.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156247

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


[PATCH] D154130: [lit][clang] Avoid realpath on Windows due to MAX_PATH limitations

2023-07-27 Thread Tristan Labelle via Phabricator via cfe-commits
MrTrillian updated this revision to Diff 544743.
MrTrillian added a comment.

Reduced path small strings length to 256 (incidentally close to MAX_PATH on 
Windows), per @benlangmuir 's comment


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

https://reviews.llvm.org/D154130

Files:
  clang/include/clang/Basic/FileManager.h
  clang/lib/Basic/FileManager.cpp
  clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
  clang/test/Lexer/case-insensitive-include-win.c
  llvm/cmake/modules/AddLLVM.cmake
  llvm/docs/CommandGuide/lit.rst
  llvm/docs/TestingGuide.rst
  llvm/utils/lit/lit/LitConfig.py
  llvm/utils/lit/lit/TestRunner.py
  llvm/utils/lit/lit/builtin_commands/diff.py
  llvm/utils/lit/lit/cl_arguments.py
  llvm/utils/lit/lit/discovery.py
  llvm/utils/lit/lit/util.py
  llvm/utils/lit/setup.py
  llvm/utils/lit/tests/Inputs/config-map-discovery/driver.py
  llvm/utils/lit/tests/Inputs/config-map-discovery/lit.alt.cfg
  llvm/utils/lit/tests/Inputs/use-llvm-tool-required/lit.cfg
  llvm/utils/lit/tests/Inputs/use-llvm-tool/lit.cfg
  llvm/utils/lit/tests/lit.cfg
  llvm/utils/llvm-lit/llvm-lit.in

Index: llvm/utils/llvm-lit/llvm-lit.in
===
--- llvm/utils/llvm-lit/llvm-lit.in
+++ llvm/utils/llvm-lit/llvm-lit.in
@@ -8,7 +8,7 @@
 
 def map_config(source_dir, site_config):
 global config_map
-source_dir = os.path.realpath(source_dir)
+source_dir = os.path.abspath(source_dir)
 source_dir = os.path.normcase(source_dir)
 site_config = os.path.normpath(site_config)
 config_map[source_dir] = site_config
Index: llvm/utils/lit/tests/lit.cfg
===
--- llvm/utils/lit/tests/lit.cfg
+++ llvm/utils/lit/tests/lit.cfg
@@ -6,6 +6,7 @@
 import subprocess
 
 import lit.formats
+import lit.util
 from lit.llvm import llvm_config
 
 # Configuration file for the 'lit' test runner.
@@ -35,7 +36,7 @@
 lit_path = os.path.join(llvm_src_root, "utils", "lit")
 else:
 lit_path = os.path.join(config.test_source_root, "..")
-lit_path = os.path.abspath(lit_path)
+lit_path = lit.util.abs_path_preserve_drive(lit_path)
 
 # Required because some tests import the lit module
 if llvm_config:
Index: llvm/utils/lit/tests/Inputs/use-llvm-tool/lit.cfg
===
--- llvm/utils/lit/tests/Inputs/use-llvm-tool/lit.cfg
+++ llvm/utils/lit/tests/Inputs/use-llvm-tool/lit.cfg
@@ -1,4 +1,5 @@
 import lit.formats
+import lit.util
 
 config.name = "use-llvm-tool"
 config.suffixes = [".txt"]
@@ -7,7 +8,7 @@
 config.test_exec_root = None
 import os.path
 
-this_dir = os.path.realpath(os.path.dirname(__file__))
+this_dir = os.path.dirname(lit.util.abs_path_preserve_drive(__file__))
 config.llvm_tools_dir = os.path.join(this_dir, "build")
 import lit.llvm
 
Index: llvm/utils/lit/tests/Inputs/use-llvm-tool-required/lit.cfg
===
--- llvm/utils/lit/tests/Inputs/use-llvm-tool-required/lit.cfg
+++ llvm/utils/lit/tests/Inputs/use-llvm-tool-required/lit.cfg
@@ -1,4 +1,5 @@
 import lit.formats
+import lit.util
 
 config.name = "use-llvm-tool-required"
 config.suffixes = [".txt"]
@@ -7,7 +8,7 @@
 config.test_exec_root = None
 import os.path
 
-config.llvm_tools_dir = os.path.realpath(os.path.dirname(__file__))
+config.llvm_tools_dir = os.path.dirname(lit.util.abs_path_preserve_drive(__file__))
 import lit.llvm
 
 lit.llvm.initialize(lit_config, config)
Index: llvm/utils/lit/tests/Inputs/config-map-discovery/lit.alt.cfg
===
--- llvm/utils/lit/tests/Inputs/config-map-discovery/lit.alt.cfg
+++ llvm/utils/lit/tests/Inputs/config-map-discovery/lit.alt.cfg
@@ -5,5 +5,5 @@
 config.test_format = lit.formats.ShTest()
 
 import os
-config.test_exec_root = os.path.realpath(os.path.dirname(__file__))
+config.test_exec_root = os.path.dirname(lit.util.abs_path_preserve_drive(__file__))
 config.test_source_root = os.path.join(config.test_exec_root, "tests")
Index: llvm/utils/lit/tests/Inputs/config-map-discovery/driver.py
===
--- llvm/utils/lit/tests/Inputs/config-map-discovery/driver.py
+++ llvm/utils/lit/tests/Inputs/config-map-discovery/driver.py
@@ -2,9 +2,7 @@
 import os
 import sys
 
-main_config = sys.argv[1]
-main_config = os.path.realpath(main_config)
-main_config = os.path.normcase(main_config)
+main_config = lit.util.abs_path_preserve_drive(sys.argv[1])
 
 config_map = {main_config: sys.argv[2]}
 builtin_parameters = {"config_map": config_map}
Index: llvm/utils/lit/setup.py
===
--- llvm/utils/lit/setup.py
+++ llvm/utils/lit/setup.py
@@ -7,7 +7,7 @@
 # is nice to allow:
 #   python path/to/setup.py install
 # to work (for scripts, etc.)
-os.chdir(os.path.dirname(os.path.abspath(__file__)))
+os.chdir(os.path.dirname(

[PATCH] D142660: [AIX] supporting -X options for llvm-ranlib in AIX OS

2023-07-27 Thread Digger Lin via Phabricator via cfe-commits
DiggerLin marked 3 inline comments as done.
DiggerLin added inline comments.



Comment at: llvm/test/tools/llvm-ranlib/aix-X-option.test:17-18
+## Test the OBJECT_MODE environment variable when adding symbol table.
+# RUN: unset OBJECT_MODE
+# RUN: llvm-ranlib t_X32.a
+# RUN: llvm-nm --print-armap t_X32.a 2>&1 | FileCheck --check-prefixes=GLOB32 
--implicit-check-not="in t64" %s

jhenderson wrote:
> DiggerLin wrote:
> > jhenderson wrote:
> > > Assuming the unsetting is intended to be just for the llvm-ranlib line, I 
> > > believe the preferred approach is `env -u OBJECT_MODE llvm-ranlib ...`. 
> > > That way, you don't impact the behaviour in subsequent lines.
> > the command `env` of AIX OS do not support -u.  and there is no mapping  
> > option of `env -u`
> > 
> > https://www.ibm.com/docs/en/aix/7.2?topic=e-env-command
> I'm 90% certain that `env` here is the built-in lit `env`, not a system `env` 
> executable. `env -u` seems to be only rarely used in the test suite, but see 
> llvm/utils/lit/tests/Inputs/shtest-env/env-u.txt for an example. I assume you 
> can run this test locally?
it run fail in AIX OS locally.



Comment at: llvm/tools/llvm-ar/llvm-ar.cpp:1463
 
+  if (object::Archive::getDefaultKindForHost() == object::Archive::K_AIXBIG) {
+// If not specify -X option, get BitMode from enviorment variable

jhenderson wrote:
> DiggerLin wrote:
> > jhenderson wrote:
> > > DiggerLin wrote:
> > > > jhenderson wrote:
> > > > > Is there a particular reason that this is after the command-line 
> > > > > option parsing for llvm-ranlib, but before it in llvm-ar? If this 
> > > > > were before the option parsing, you wouldn't need the `HasAixXOption` 
> > > > > variable.
> > > > in AIX OS  `ranlib` has behavior as
> > > > 
> > > > 
> > > > ```
> > > > -bash-5.0$ env OBJECT_MODE=31 ranlib tmpk.a
> > > > 0654-603 The OBJECT_MODE environment variable has an invalid setting.
> > > > OBJECT_MODE must be 32, 64, or 32_64.
> > > > -bash-5.0$ env OBJECT_MODE=31 ranlib -X32  tmpk.a
> > > > -bash-5.0$
> > > > ```  
> > > > 
> > > > Given invalid env OBJECT_MODE , if there is no -X option in the ranlib 
> > > > command, it will output as 
> > > > 
> > > > ```
> > > > 0654-603 The OBJECT_MODE environment variable has an invalid setting.
> > > > OBJECT_MODE must be 32, 64, or 32_64.
> > > > ```
> > > > 
> > > > Given invalid env OBJECT_MODE , and there is -X option in the ranlib 
> > > > command,  it do not care about the invalid env OBJECT_MODE,  So I has 
> > > > to parse the -X option before the getBitMode(getenv("OBJECT_MODE"))
> > > > 
> > > So with AIX ar, does an invalid OBJECT_MODE environment variable get 
> > > reported if the -X option is specified?
> > > 
> > > In my opinion, I think it is very unlikely there will be any real users 
> > > out there with an invalid OBJECT_MODE environment variable, because other 
> > > tools will reject it, even if ranlib doesn't. Even if there are, they 
> > > should be able to easily fix their variable, if they start getting an 
> > > error message after switching to llvm-ranlib. I'm therefore thinking that 
> > > there isn't a need to mirror this logic in llvm-ranlib, if it would make 
> > > the code simpler (which it would).
> > > So with AIX ar, does an invalid OBJECT_MODE environment variable get 
> > > reported if the -X option is specified?
> > 
> > it do no report invalid OBJECT_MODE environment if the -X option is 
> > specified.
> > 
> > 
> > ```
> > bash-5.0$ export OBJECT_MODE=31
> > bash-5.0$ ar  q tmpp.acheck.o
> > ar: 0707-133 The OBJECT_MODE environment variable has an invalid setting.
> > OBJECT_MODE must be 32, 64, 32_64, d64, or any.
> > bash-5.0$ ar -X32 q tmpp.acheck.o
> > bash-5.0$
> > ```
> > 
> > 
> > 
> > > In my opinion, I think it is very unlikely there will be any real users 
> > > out there with an invalid OBJECT_MODE environment variable, because other 
> > > tools will reject it, even if ranlib doesn't. Even if there are, they 
> > > should be able to easily fix their variable, if they start getting an 
> > > error message after switching to llvm-ranlib. I'm therefore thinking that 
> > > there isn't a need to mirror this logic in llvm-ranlib, if it would make 
> > > the code simpler (which it would).
> > 
> > since -X option will overwrite the env variable OBJECT_MODE, 
> > in the source code , we should check the -X option of the command line 
> > first, if there is no  -X option ,  we will check the env variable 
> > OBJECT_MODE. the logic of code is correct in the patch.  we should not 
> > always  getenv("OBJECT_MODE")  before checking the -X option.
> > 
> > since -X option will overwrite the env variable OBJECT_MODE, in the source 
> > code , we should check the -X option of the command line first, if there is 
> > no -X option , we will check the env variable OBJECT_MODE. the logic of 
> > code is correct in the patch. we should not always get

[PATCH] D154130: [lit][clang] Avoid realpath on Windows due to MAX_PATH limitations

2023-07-27 Thread Tristan Labelle via Phabricator via cfe-commits
MrTrillian marked an inline comment as done.
MrTrillian added inline comments.



Comment at: clang/lib/Basic/FileManager.cpp:663
+} else {
+  llvm::sys::path::remove_dots(AbsPathBuf, /*remove_dot_dot=*/true);
+  CanonicalName = AbsPathBuf.str().copy(CanonicalNameStorage);

benlangmuir wrote:
> Removing .. can change where the path points in the presence of symlinks; is 
> this needed?
> Removing .. can change where the path points in the presence of symlinks; is 
> this needed?

@benlangmuir That's true and not ideal, but `makeAbsolute` will not resolve 
`/./` or `/../` in paths, so it's not a canonicalization and some tests were 
failing because of that. One alternative would be to use `makeAbsolute` + 
`remove_dots` on Windows (where removing dot dots is semantically correct) and 
`getRealPath` on Unix, like I do in lit. Suggestions?



Comment at: clang/lib/ExtractAPI/ExtractAPIConsumer.cpp:190
 
-StringRef FileName = File->tryGetRealPathName().empty()
- ? File->getName()
- : File->tryGetRealPathName();
+StringRef FileName = SM.getFileManager().getCanonicalName(File);
 

benlangmuir wrote:
> Why is this change needed?
> Why is this change needed?

@benlangmuir We don't want raw `getRealPath`s on Windows because of substitute 
drives and MAX_PATH issues. That is the idea behind this diff. If I leave the 
`tryGetRealPathName` here, I need to change the `relative_include.m` test as in 
this previous diff: https://reviews.llvm.org/D154130?id=539683 , which is 
undesirable.


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

https://reviews.llvm.org/D154130

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


[PATCH] D151834: Include math-errno with fast-math

2023-07-27 Thread Zahira Ammarguellat via Phabricator via cfe-commits
zahiraam updated this revision to Diff 544745.
zahiraam marked 3 inline comments as done.

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

https://reviews.llvm.org/D151834

Files:
  clang/include/clang/Basic/FPOptions.def
  clang/include/clang/Basic/LangOptions.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/test/CodeGen/math-errno.c

Index: clang/test/CodeGen/math-errno.c
===
--- /dev/null
+++ clang/test/CodeGen/math-errno.c
@@ -0,0 +1,64 @@
+// -O2
+// RUN: %clang_cc1 -Wno-implicit-function-declaration  \
+// RUN: -fmath-errno -ffp-contract=on -fno-rounding-math -O2 -emit-llvm -o - %s \
+// RUN: | FileCheck %s
+
+// -ffast-math
+// RUN: %clang_cc1 -Wno-implicit-function-declaration  \
+// RUN: -menable-no-infs -menable-no-nans -fapprox-func \
+// RUN: -funsafe-math-optimizations -fno-signed-zeros -mreassociate \
+// RUN: -freciprocal-math -ffp-contract=fast -fno-rounding-math -ffast-math \
+// RUN: -ffinite-math-only -ffast-math -emit-llvm -o - %s \
+// RUN: | FileCheck %s -check-prefix=FAST
+
+// -O0
+// RUN: %clang_cc1 -Wno-implicit-function-declaration  \
+// RUN: -fmath-errno -ffp-contract=on -fno-rounding-math -O0 \
+// RUN: -emit-llvm -o - %s | FileCheck %s -check-prefix=NOOPT
+
+#pragma float_control(precise,on)
+float f1(float x) {
+  return sqrtf(x);
+}
+
+// CHECK-LABEL: define dso_local float @f1
+// CHECK: tail call float @sqrtf(float noundef {{.*}}) #[[ATTR4_O2:[0-9]+]]
+
+// FAST-LABEL: define dso_local nofpclass(nan inf) float @f1
+// FAST: call fast nofpclass(nan inf) float @sqrtf(float noundef nofpclass(nan inf) {{.*}}) #[[ATTR3_FAST:[0-9]+]]
+
+// NOOPT-LABEL: define dso_local float @f1
+// NOOPT: call float @sqrtf(float noundef {{.*}}) #[[ATTR4_NOOPT:[0-9]+]]
+
+#pragma float_control(precise,off)
+float f2(float x) {
+  return sqrtf(x);
+}
+
+// CHECK-LABEL: define dso_local float @f2
+// CHECK: tail call float @llvm.sqrt.f32(float {{.*}})
+
+// FAST-LABEL: define dso_local nofpclass(nan inf) float @f2
+// FAST: call fast float @llvm.sqrt.f32(float {{.*}})
+
+// NOOPT-LABEL: define dso_local float @f2
+// NOOPT: call float @sqrtf(float {{.*}}) #[[ATTR4_NOOPT:[0-9]+]]
+
+__attribute__((optnone))
+float f3(float x) {
+  x = sqrtf(x);
+  return x;
+}
+
+// CHECK-LABEL: define dso_local float @f3
+// CHECK: call float @sqrtf(float noundef {{.*}})
+
+// FAST-LABEL: define dso_local nofpclass(nan inf) float @f3
+// FAST: call fast nofpclass(nan inf) float @sqrtf(float noundef nofpclass(nan inf) {{.*}}) #[[ATTR4_FAST:[0-9]+]]
+
+// NOOPT-LABEL: define dso_local float @f3
+// NOOPT:  call float @sqrtf(float noundef %0) #[[ATTR4_NOOPT:[0-9]+]]
+
+// CHECK: [[ATTR4_O2]] = { nounwind }
+// FAST: [[ATTR3_FAST]] =  { nounwind willreturn memory(none) }
+// NOOPT: [[ATTR4_NOOPT]] = { nounwind }
Index: clang/lib/CodeGen/CodeGenModule.h
===
--- clang/lib/CodeGen/CodeGenModule.h
+++ clang/lib/CodeGen/CodeGenModule.h
@@ -1252,6 +1252,12 @@
   llvm::AttributeList &Attrs, unsigned &CallingConv,
   bool AttrOnCallSite, bool IsThunk);
 
+  /// Adjust Memory attribute to ensure that the BE gets the right attribute
+  // in order to generate the library call or the intrinsic for the function
+  // name 'Name'.
+  void AdjustMemoryAttribute(StringRef Name, CGCalleeInfo CalleeInfo,
+ llvm::AttributeList &Attrs);
+
   /// Adds attributes to F according to our CodeGenOptions and LangOptions, as
   /// though we had emitted it ourselves.  We remove any attributes on F that
   /// conflict with the attributes we add here.
Index: clang/lib/CodeGen/CGCall.cpp
===
--- clang/lib/CodeGen/CGCall.cpp
+++ clang/lib/CodeGen/CGCall.cpp
@@ -2247,6 +2247,17 @@
   return Mask;
 }
 
+void CodeGenModule::AdjustMemoryAttribute(StringRef Name,
+  CGCalleeInfo CalleeInfo,
+  llvm::AttributeList &Attrs) {
+  if (Attrs.getMemoryEffects().getModRef() == llvm::ModRefInfo::NoModRef) {
+Attrs = Attrs.removeFnAttribute(getLLVMContext(), llvm::Attribute::Memory);
+llvm::Attribute MemoryAttr = llvm::Attribute::getWithMemoryEffects(
+getLLVMContext(), llvm::MemoryEffects::writeOnly());
+Attrs = Attrs.addFnAttribute(getLLVMContext(), MemoryAttr);
+  }
+}
+
 /// Construct the IR attribute list of a function or call.
 ///
 /// When adding an attribute, please consider where it should be handled:
@@ -5442,11 +5453,18 @@
  /*AttrOnCallSite=*/true,
  /*IsThunk=*/false);
 
-  if (const FunctionDecl *FD = dyn_cast_or_null(CurFuncDecl))
+  if (const FunctionDecl *FD = dyn_cast_or_null(CurFuncDecl)) {
 if (FD->hasAttr())
   // All calls with

[PATCH] D156427: [clang] Improve hermeticity of clang header tests.

2023-07-27 Thread Simi Pallipurath via Phabricator via cfe-commits
simpal01 created this revision.
Herald added a project: All.
simpal01 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Specifying --sysroot prevents these header tests

  from  being located in standard library directories.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D156427

Files:
  clang/test/Headers/arm-fp16-header.c
  clang/test/Headers/arm-neon-header.c


Index: clang/test/Headers/arm-neon-header.c
===
--- clang/test/Headers/arm-neon-header.c
+++ clang/test/Headers/arm-neon-header.c
@@ -2,27 +2,27 @@
 // RUN: %clang_cc1 -triple thumbv7-apple-darwin10 -target-cpu cortex-a8 
-fsyntax-only -flax-vector-conversions=none -ffreestanding %s
 // RUN: %clang_cc1 -x c++ -triple thumbv7-apple-darwin10 -target-cpu cortex-a8 
-fsyntax-only -Wvector-conversions -ffreestanding %s
 
-// RUN: %clang -fsyntax-only   -ffreestanding 
--target=aarch64-none-elf -march=armv8.2-a+fp16 -std=c89 -xc %s
-// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64-none-elf -march=armv8.2-a+fp16 -std=c99 -xc %s
-// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64-none-elf -march=armv8.2-a+fp16 -std=c11 -xc %s
+// RUN: %clang -fsyntax-only   -ffreestanding 
--target=aarch64-none-elf -march=armv8.2-a+fp16 -std=c89 --sysroot=%S/Inputs 
-xc %s
+// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64-none-elf -march=armv8.2-a+fp16 -std=c99 --sysroot=%S/Inputs 
-xc %s
+// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64-none-elf -march=armv8.2-a+fp16 -std=c11 --sysroot=%S/Inputs 
-xc %s
 
-// RUN: %clang -fsyntax-only   -ffreestanding 
--target=aarch64_be-none-elf -march=armv8.2-a+fp16 -std=c89 -xc %s
-// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64_be-none-elf -march=armv8.2-a+fp16 -std=c99 -xc %s
-// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64_be-none-elf -march=armv8.2-a+fp16 -std=c11 -xc %s
+// RUN: %clang -fsyntax-only   -ffreestanding 
--target=aarch64_be-none-elf -march=armv8.2-a+fp16 -std=c89 -xc 
--sysroot=%S/Inputs %s
+// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64_be-none-elf -march=armv8.2-a+fp16 -std=c99 -xc 
--sysroot=%S/Inputs %s
+// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64_be-none-elf -march=armv8.2-a+fp16 -std=c11 -xc 
--sysroot=%S/Inputs %s
 
-// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding -nostdinc++ 
--target=aarch64-none-elf -march=armv8.2-a+fp16 -std=c++98 -xc++ %s
-// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding -nostdinc++ 
--target=aarch64-none-elf -march=armv8.2-a+fp16 -std=c++11 -xc++ %s
-// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding -nostdinc++ 
--target=aarch64-none-elf -march=armv8.2-a+fp16 -std=c++14 -xc++ %s
-// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding -nostdinc++ 
--target=aarch64-none-elf -march=armv8.2-a+fp16 -std=c++17 -xc++ %s
+// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding -nostdinc++ 
--target=aarch64-none-elf -march=armv8.2-a+fp16 -std=c++98 -xc++ 
--sysroot=%S/Inputs %s
+// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding -nostdinc++ 
--target=aarch64-none-elf -march=armv8.2-a+fp16 -std=c++11 -xc++ 
--sysroot=%S/Inputs %s
+// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding -nostdinc++ 
--target=aarch64-none-elf -march=armv8.2-a+fp16 -std=c++14 -xc++ 
--sysroot=%S/Inputs %s
+// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding -nostdinc++ 
--target=aarch64-none-elf -march=armv8.2-a+fp16 -std=c++17 -xc++ 
--sysroot=%S/Inputs %s
 
-// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding -nostdinc++ 
--target=aarch64_be-none-elf -march=armv8.2-a+fp16 -std=c++98 -xc++ %s
-// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding -nostdinc++ 
--target=aarch64_be-none-elf -march=armv8.2-a+fp16 -std=c++11 -xc++ %s
-// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding -nostdinc++ 
--target=aarch64_be-none-elf -march=armv8.2-a+fp16 -std=c++14 -xc++ %s
-// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding -nostdinc++ 
--target=aarch64_be-none-elf -march=armv8.2-a+fp16 -std=c++17 -xc++ %s
+// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding -nostdinc++ 
--target=aarch64_be-none-elf -march=armv8.2-a+fp16 -std=c++98 -xc++ 
--sysroot=%S/Inputs %s
+// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding -nostdinc++ 
--target=aarch64_be-none-elf -march=armv8.2-a+fp16 -std=c++11 -xc++ 
--sysroot=%S/Inputs %s
+// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding -nostdinc++ 
--target=aarch64_be-none-elf -march=armv8.2-a+fp16 -std=c++14 -xc++ 
--sysroot=%S/Inputs %s
+// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding -nostdinc++ 
--target=aarch64_be-none-elf -march=armv8.2-a+fp16 -std=c++17 -xc++ 
--sysroot=%S/Inputs %s
 

[PATCH] D151834: Include math-errno with fast-math

2023-07-27 Thread Zahira Ammarguellat via Phabricator via cfe-commits
zahiraam added inline comments.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:2321-2328
+  if ((FD->hasAttr() && !ErrnoOverriden && !OptNone) ||
   ((ConstWithoutErrnoAndExceptions || ConstWithoutExceptions) &&
-   (!ConstWithoutErrnoAndExceptions || (!getLangOpts().MathErrno {
+   (!ConstWithoutErrnoAndExceptions ||
+(!getLangOpts().MathErrno && !ErrnoOverriden && !OptNone) ||
+// If math-errno was enabled on command line but overriden to false
+// via '#pragma float_control(precise, off))', and optimizations are
+// enabled, generate intrinsics.

aaron.ballman wrote:
> zahiraam wrote:
> > aaron.ballman wrote:
> > > I think this has gotten sufficiently complex that it might be worth 
> > > splitting the logic out a bit more:
> > > ```
> > > bool Optimize = FD->hasAttr() && !ErrnoOverriden && !OptNone;
> > > if (!Optimize) Optimize = FD->hasAttr() && !ErrnoOverriden && 
> > > !OptNone;
> > > ... and so on ...
> > > ```
> > > WDYT?
> > I understand I need to split the logic, but I don't get your proposal here. 
> > Do you mean?
> > 
> > 
> > ```
> > bool Optimize = FD->hasAttr() && !ErrnoOverriden && !OptNone;
> > if (!Optimize) Optimize = !getLangOpts().MathErrno && !ErrnoOverriden && 
> > !OptNone;
> > ... and so on ...
> > ```
> > 
> Oops, yeah, that a was copy pasta mistake on my part. You've got the right 
> idea -- mostly just split up the logic and add comments explaining why the 
> predicates exist.
Changed the name of the variable you proposed. Is that OK?


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

https://reviews.llvm.org/D151834

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


[PATCH] D156426: [HIP] link HIP runtime library without --hip-link

2023-07-27 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked an inline comment as done.
yaxunl added inline comments.



Comment at: clang/include/clang/Driver/Driver.h:712
+  /// Whether there are HIP input files.
+  bool hasHIPInputs() const { return HasHIPInputs; }
+

jhuber6 wrote:
> Shouldn't we have access to the compilation? I figured we could check 
> `C.getActiveOffloadKinds()` or w/e it's called.
yes that is a better solution. will do


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

https://reviews.llvm.org/D156426

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


[PATCH] D156426: [HIP] link HIP runtime library without --hip-link

2023-07-27 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 544750.
yaxunl marked an inline comment as done.
yaxunl added a comment.

revised by comments


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

https://reviews.llvm.org/D156426

Files:
  clang/docs/HIPSupport.rst
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Driver/ToolChains/CommonArgs.h
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/lib/Driver/ToolChains/MSVC.cpp
  clang/test/Driver/hip-runtime-libs-linux.hip
  clang/test/Driver/hip-runtime-libs-msvc.hip
  clang/test/Driver/rocm-detect.hip

Index: clang/test/Driver/rocm-detect.hip
===
--- clang/test/Driver/rocm-detect.hip
+++ clang/test/Driver/rocm-detect.hip
@@ -35,32 +35,32 @@
 
 // Test HIP_PATH overrides ROCM_PATH.
 // RUN: env ROCM_PATH=%S/Inputs/rocm HIP_PATH=%t/myhip \
-// RUN:   %clang -### -target x86_64-linux-gnu --offload-arch=gfx1010 --hip-link \
+// RUN:   %clang -### -target x86_64-linux-gnu --offload-arch=gfx1010 \
 // RUN:   --print-rocm-search-dirs %s 2>&1 \
 // RUN:   | FileCheck -check-prefixes=ROCM-ENV,HIP-PATH %s
 
 // Test --hip-path overrides ROCM_PATH.
 // RUN: env ROCM_PATH=%S/Inputs/rocm \
-// RUN:   %clang -### -target x86_64-linux-gnu --offload-arch=gfx1010 --hip-link \
+// RUN:   %clang -### -target x86_64-linux-gnu --offload-arch=gfx1010 \
 // RUN:   --hip-path=%t/myhip \
 // RUN:   --print-rocm-search-dirs %s 2>&1 \
 // RUN:   | FileCheck -check-prefixes=ROCM-ENV,HIP-PATH %s
 
 // Test --hip-path overrides --rocm-path.
-// RUN: %clang -### -target x86_64-linux-gnu --offload-arch=gfx1010 --hip-link \
+// RUN: %clang -### -target x86_64-linux-gnu --offload-arch=gfx1010 \
 // RUN:   --hip-path=%t/myhip --rocm-path=%S/Inputs/rocm \
 // RUN:   --print-rocm-search-dirs %s 2>&1 \
 // RUN:   | FileCheck -check-prefixes=ROCM-ENV,HIP-PATH %s
 
 // Test HIP_PATH overrides --rocm-path.
-// RUN: env HIP_PATH=%t/myhip %clang -### -target x86_64-linux-gnu --offload-arch=gfx1010 --hip-link \
+// RUN: env HIP_PATH=%t/myhip %clang -### -target x86_64-linux-gnu --offload-arch=gfx1010 \
 // RUN:   --rocm-path=%S/Inputs/rocm \
 // RUN:   --print-rocm-search-dirs %s 2>&1 \
 // RUN:   | FileCheck -check-prefixes=ROCM-ENV,HIP-PATH %s
 
 // Test empty HIP_PATH does not override --rocm-path.
 // RUN: env HIP_PATH= \
-// RUN:   %clang -### -target x86_64-linux-gnu --offload-arch=gfx1010 --hip-link \
+// RUN:   %clang -### -target x86_64-linux-gnu --offload-arch=gfx1010 \
 // RUN:   --rocm-path=%S/Inputs/rocm --print-rocm-search-dirs %s 2>&1 \
 // RUN:   | FileCheck -check-prefixes=ROCM-PATH %s
 
Index: clang/test/Driver/hip-runtime-libs-msvc.hip
===
--- clang/test/Driver/hip-runtime-libs-msvc.hip
+++ clang/test/Driver/hip-runtime-libs-msvc.hip
@@ -7,4 +7,9 @@
 // RUN:   --rocm-path=%S/Inputs/rocm %t.o 2>&1 \
 // RUN:   | FileCheck %s
 
+// Test HIP runtime lib is linked without --hip-link when there is HIP input file.
+// RUN: %clang -### --target=x86_64-pc-windows-msvc \
+// RUN:   --rocm-path=%S/Inputs/rocm %s 2>&1 \
+// RUN:   | FileCheck %s
+
 // CHECK: "-libpath:{{.*Inputs.*rocm.*lib}}" "amdhip64.lib"
Index: clang/test/Driver/hip-runtime-libs-linux.hip
===
--- clang/test/Driver/hip-runtime-libs-linux.hip
+++ clang/test/Driver/hip-runtime-libs-linux.hip
@@ -43,6 +43,11 @@
 // RUN:   --rocm-path=%S/Inputs/rocm %t.o 2>&1 \
 // RUN:   | FileCheck -check-prefixes=NOHIPRT %s
 
+// Test HIP runtime lib is linked without hip-link if there is HIP input file.
+// RUN: %clang -### --target=x86_64-linux-gnu \
+// RUN:   --rocm-path=%S/Inputs/rocm %s 2>&1 \
+// RUN:   | FileCheck -check-prefixes=ROCM-PATH %s
+
 // ROCM-PATH: "-L[[HIPRT:.*/Inputs/rocm/lib]]" "-lamdhip64"
 // ROCM-RPATH: "-L[[HIPRT:.*/Inputs/rocm/lib]]" "-rpath" "[[HIPRT]]" "-lamdhip64"
 // ROCM-REL: "-L[[HIPRT:.*/opt/rocm-3.10.0/lib]]" "-lamdhip64"
Index: clang/lib/Driver/ToolChains/MSVC.cpp
===
--- clang/lib/Driver/ToolChains/MSVC.cpp
+++ clang/lib/Driver/ToolChains/MSVC.cpp
@@ -315,7 +315,7 @@
 A.renderAsInput(Args, CmdArgs);
   }
 
-  addHIPRuntimeLibArgs(TC, Args, CmdArgs);
+  addHIPRuntimeLibArgs(TC, C, Args, CmdArgs);
 
   TC.addProfileRTLibs(Args, CmdArgs);
 
Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -549,7 +549,7 @@
   addLinkerCompressDebugSectionsOption(ToolChain, Args, CmdArgs);
   AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA);
 
-  addHIPRuntimeLibArgs(ToolChain, Args, CmdArgs);
+  addHIPRuntimeLibArgs(ToolChain, C, Args, CmdArgs);
 
   // The profile runtime also needs access to system libraries.
   getToolChain().addProfileRTLibs(Args, CmdArgs);
Index: clang/lib/Driver/ToolChains/CommonArgs.h
=

[PATCH] D153769: [clangd] Implement the 'Organize Imports' source action. Fix include-cleaner findings in batch.

2023-07-27 Thread Viktoriia Bakalova via Phabricator via cfe-commits
VitaNuo updated this revision to Diff 544751.
VitaNuo marked 8 inline comments as done.
VitaNuo added a comment.

Address review comments. Update the action to trigger when source action is 
requested explicitly or from the preamble range. Add unit test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153769

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/Protocol.cpp
  clang-tools-extra/clangd/Protocol.h
  clang-tools-extra/clangd/refactor/Tweak.cpp
  clang-tools-extra/clangd/refactor/Tweak.h
  clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt
  clang-tools-extra/clangd/refactor/tweaks/OrganizeImports.cpp
  clang-tools-extra/clangd/test/code-action-request.test
  clang-tools-extra/clangd/test/include-cleaner-batch-fix.test
  clang-tools-extra/clangd/test/request-reply.test
  clang-tools-extra/clangd/test/tweaks-format.test
  clang-tools-extra/clangd/tool/Check.cpp
  clang-tools-extra/clangd/unittests/CMakeLists.txt
  clang-tools-extra/clangd/unittests/ClangdTests.cpp
  clang-tools-extra/clangd/unittests/FeatureModulesTests.cpp
  clang-tools-extra/clangd/unittests/tweaks/OrganizeImportsTests.cpp
  clang-tools-extra/clangd/unittests/tweaks/TweakTesting.cpp

Index: clang-tools-extra/clangd/unittests/tweaks/TweakTesting.cpp
===
--- clang-tools-extra/clangd/unittests/tweaks/TweakTesting.cpp
+++ clang-tools-extra/clangd/unittests/tweaks/TweakTesting.cpp
@@ -8,6 +8,7 @@
 
 #include "TweakTesting.h"
 
+#include "Protocol.h"
 #include "SourceCode.h"
 #include "TestTU.h"
 #include "refactor/Tweak.h"
@@ -65,18 +66,19 @@
 applyTweak(ParsedAST &AST, llvm::Annotations::Range Range, StringRef TweakID,
const SymbolIndex *Index, llvm::vfs::FileSystem *FS) {
   std::optional> Result;
-  SelectionTree::createEach(AST.getASTContext(), AST.getTokens(), Range.Begin,
-Range.End, [&](SelectionTree ST) {
-  Tweak::Selection S(Index, AST, Range.Begin,
- Range.End, std::move(ST), FS);
-  if (auto T = prepareTweak(TweakID, S, nullptr)) {
-Result = (*T)->apply(S);
-return true;
-  } else {
-llvm::consumeError(T.takeError());
-return false;
-  }
-});
+  SelectionTree::createEach(
+  AST.getASTContext(), AST.getTokens(), Range.Begin, Range.End,
+  [&](SelectionTree ST) {
+Tweak::Selection S(Index, AST, Range.Begin, Range.End, std::move(ST),
+   FS, {std::string{CodeAction::SOURCE_KIND}});
+if (auto T = prepareTweak(TweakID, S, nullptr)) {
+  Result = (*T)->apply(S);
+  return true;
+} else {
+  llvm::consumeError(T.takeError());
+  return false;
+}
+  });
   return Result;
 }
 
Index: clang-tools-extra/clangd/unittests/tweaks/OrganizeImportsTests.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/unittests/tweaks/OrganizeImportsTests.cpp
@@ -0,0 +1,84 @@
+//===--OrganizeImportsTest.cpp --*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "TweakTesting.h"
+#include "llvm/ADT/StringRef.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace clangd {
+namespace {
+
+TWEAK_TEST(OrganizeImports);
+
+TEST_F(OrganizeImportsTest, All) {
+  Header = "void foo();";
+  struct {
+llvm::StringRef Code;
+llvm::StringRef Header;
+llvm::StringRef Expected;
+  } Cases[] = {{// Remove unused include.
+R"cpp(
+#include "TestTU.h"
+void foo() {}
+void b^ar() {
+foo();
+}
+)cpp",
+R"cpp(
+#pragma once
+)cpp",
+R"cpp(
+void foo() {}
+void bar() {
+foo();
+}
+)cpp"},
+   {// Add missing include.
+R"cpp(
+void b^ar() {
+foo();
+}
+)cpp",
+R"cpp(
+#pragma once
+void foo();
+)cpp",
+R"cpp(
+#include "TestTU.h"
+void bar() {
+foo();
+}
+)cpp"},
+   {// Replace unused include with missing.
+R"cpp(
+#include "foo.h"
+void b^ar() {
+foo();
+}
+)cpp",
+R"cpp(
+#pragma once
+void foo();
+)cpp",
+R"cpp(
+#include "TestTU.h"
+void bar() {
+foo();
+}
+)cpp"}};
+  for (auto C : Cases) {
+

[PATCH] D156426: [HIP] link HIP runtime library without --hip-link

2023-07-27 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 accepted this revision.
jhuber6 added a comment.
This revision is now accepted and ready to land.

LG, thanks.


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

https://reviews.llvm.org/D156426

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


[PATCH] D156425: [clang-repl] Remove redundant tests

2023-07-27 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev accepted this revision.
v.g.vassilev added a comment.
This revision is now accepted and ready to land.

Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156425

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


  1   2   3   >