[PATCH] D145892: [SemaCXX]use CorrectDelayedTyposInExpr in ActOnCXXFoldExpr only when Diag

2023-03-14 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

In D145892#4191220 , @HerrCai0907 
wrote:

> I cannot find an example that throw `error: expression contains unexpanded 
> parameter pack 'T'` in fold expression because code like ` (foo(10 + 
> (static_cast(1))) + ...);` can be unpack both `T` and `U` in same `...` 
> operator
>
> But this code can be diagnosed correctly
>
>   template  struct A {
> template  void foo(T &&...Params) {
>   (foo(1 + (static_cast(1))) + ...); // ok
>   
>   // error: expression contains unexpanded parameter pack 'T'
>   foo((... + static_cast(1)));
>   
>   (foo((... + static_cast(1))) + ...); // ok
> }
>   };
>
> Should I add this case into test?

I spent some time on this and I can't come up with any counter examples either. 
 Please add this to the test, add a release note, then this LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145892

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


[PATCH] D145906: [clang-tidy] Correctly handle evaluation order of designated initializers.

2023-03-14 Thread Martin Böhme via Phabricator via cfe-commits
mboehme added inline comments.



Comment at: clang-tools-extra/clang-tidy/utils/ExprSequence.cpp:67
+llvm::SmallVector
+allInitListExprForms(const InitListExpr *InitList) {
+  llvm::SmallVector result = {InitList};

PiotrZSL wrote:
> maybe some other name instead of allInitListExprForms, like getAllInitForms
How about this?



Comment at: clang-tools-extra/clang-tidy/utils/ExprSequence.cpp:69-72
+  if (InitList->isSemanticForm() && InitList->getSyntacticForm())
+result.push_back(InitList->getSyntacticForm());
+  if (InitList->isSyntacticForm() && InitList->getSemanticForm())
+result.push_back(InitList->getSemanticForm());

PiotrZSL wrote:
> this looks like typo... but it isn't, it's just unnecessary.
> 
> ``InitList->isSemanticForm() && InitList->getSyntacticForm()`` is equal to:
> ``AltForm.getInt() && AltForm.getPointer()``
> 
> ``InitList->isSyntacticForm() && InitList->getSemanticForm()`` is equal to:
> ``(!AltForm.getInt() || !AltForm.getPointer()) && (!AltForm.getInt()) && 
> AltForm.getPointer()``
> 
> Why we coudn't have "getAnyForm".
> 
> any code could just look like this:
> ``if (const InitListExpr * Form = InitList->getSyntacticForm())``
> ``  result.push_back(Form);``
> ``if (const InitListExpr * Form = InitList->getSemanticForm())``
> ``  result.push_back(Form);``
> 
> this looks like typo... but it isn't, it's just unnecessary.

Ah, of course, thanks for pointing this out to me.

> Why we coudn't have "getAnyForm".

Not sure exactly what you mean?

I've updated the code to do what you suggested above (i.e. don't call 
`isSemanticForm()`, just call `getSyntacticForm()` and see if returns non-null).

We still need to initialize `result` with `InitList` because 
`InitList->getSyntacticForm()` returns null if `InitList` is already in 
syntactic form.

I hope that makes sense? Please let me know if there's anything I missed from 
your original response.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145906

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


[PATCH] D145868: [clang][ASTImporter] Fix import of anonymous structures

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

The problem is somewhat bigger and not fast to fix. This test shows what is 
problematic:

  TEST_P(ASTImporterOptionSpecificTestBase,
 ImportExistingTypedefToUnnamedRecordPtr) {
const char *Code =
R"(
typedef const struct { int fff; } * const T;
extern T x;
)";
Decl *ToTU = getToTuDecl(Code, Lang_C99);
Decl *FromTU = getTuDecl(Code, Lang_C99);
  
auto *FromX =
FirstDeclMatcher().match(FromTU, varDecl(hasName("x")));
auto *ToX = Import(FromX, Lang_C99);
EXPECT_TRUE(ToX);
  
auto *Typedef1 =
FirstDeclMatcher().match(ToTU, typedefDecl(hasName("T")));
auto *Typedef2 =
LastDeclMatcher().match(ToTU, typedefDecl(hasName("T")));
EXPECT_EQ(Typedef1, Typedef2);

auto *FromR =
FirstDeclMatcher().match(FromTU, 
recordDecl(hasDescendant(fieldDecl(hasName("fff");
auto *ToRExisting =
FirstDeclMatcher().match(ToTU, 
recordDecl(hasDescendant(fieldDecl(hasName("fff");
ASSERT_TRUE(FromR);
auto *ToRImported = Import(FromR, Lang_C99);
EXPECT_EQ(ToRExisting, ToRImported);
  }

The test fails because the last `EXPECT_EQ` fails (without the fix in this 
patch it crashes with the hasSameType assertion): The record is imported 
separately but the typedef was already imported before with a different record 
(in fact not imported, the import returned the existing typedef, this is caused 
by the existence of `PointerType` or any other type that has reference to 
unnamed struct but is not a `RecordType` at the typedef). The ToTU AST contains 
then two instances of the unnamed record (the last one is created when the 
second import in the test happens). The problem can be solved probably only if 
the import of existing equivalent AST nodes from another TU (in the root 
context, not in namespace with no name) is changed: The import should return 
the existing one and not create a new. I do not know how difficult is to change 
this.
But until a better fix is found the current solution is acceptable (with FIXME 
included).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145868

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


[PATCH] D145545: [clang][Interp] Fix local variable (destructor) management in loop bodies

2023-03-14 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder updated this revision to Diff 505084.

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

https://reviews.llvm.org/D145545

Files:
  clang/lib/AST/Interp/ByteCodeExprGen.h
  clang/lib/AST/Interp/ByteCodeStmtGen.cpp
  clang/lib/AST/Interp/ByteCodeStmtGen.h

Index: clang/lib/AST/Interp/ByteCodeStmtGen.h
===
--- clang/lib/AST/Interp/ByteCodeStmtGen.h
+++ clang/lib/AST/Interp/ByteCodeStmtGen.h
@@ -54,6 +54,7 @@
   // Statement visitors.
   bool visitStmt(const Stmt *S);
   bool visitCompoundStmt(const CompoundStmt *S);
+  bool visitUnscopedCompoundStmt(const Stmt *S);
   bool visitDeclStmt(const DeclStmt *DS);
   bool visitReturnStmt(const ReturnStmt *RS);
   bool visitIfStmt(const IfStmt *IS);
Index: clang/lib/AST/Interp/ByteCodeStmtGen.cpp
===
--- clang/lib/AST/Interp/ByteCodeStmtGen.cpp
+++ clang/lib/AST/Interp/ByteCodeStmtGen.cpp
@@ -194,6 +194,21 @@
   }
 }
 
+template 
+bool ByteCodeStmtGen::visitUnscopedCompoundStmt(const Stmt *S) {
+  if (isa(S))
+return true;
+
+  if (const auto *CS = dyn_cast(S)) {
+for (auto *InnerStmt : CS->body())
+  if (!visitStmt(InnerStmt))
+return false;
+return true;
+  }
+
+  return this->visitStmt(S);
+}
+
 template 
 bool ByteCodeStmtGen::visitCompoundStmt(
 const CompoundStmt *CompoundStmt) {
@@ -306,11 +321,13 @@
   if (!this->jumpFalse(EndLabel))
 return false;
 
-  if (!this->visitStmt(Body))
+  LocalScope Scope(this);
+  if (!this->visitUnscopedCompoundStmt(Body))
 return false;
+
+  Scope.emitDestructors();
   if (!this->jump(CondLabel))
 return false;
-
   this->emitLabel(EndLabel);
 
   return true;
@@ -325,13 +342,16 @@
   LabelTy EndLabel = this->getLabel();
   LabelTy CondLabel = this->getLabel();
   LoopScope LS(this, EndLabel, CondLabel);
+  LocalScope Scope(this);
 
   this->emitLabel(StartLabel);
-  if (!this->visitStmt(Body))
+  if (!this->visitUnscopedCompoundStmt(Body))
 return false;
   this->emitLabel(CondLabel);
   if (!this->visitBool(Cond))
 return false;
+
+  Scope.emitDestructors();
   if (!this->jumpTrue(StartLabel))
 return false;
   this->emitLabel(EndLabel);
@@ -350,6 +370,7 @@
   LabelTy CondLabel = this->getLabel();
   LabelTy IncLabel = this->getLabel();
   LoopScope LS(this, EndLabel, IncLabel);
+  LocalScope Scope(this);
 
   if (Init && !this->visitStmt(Init))
 return false;
@@ -360,11 +381,13 @@
 if (!this->jumpFalse(EndLabel))
   return false;
   }
-  if (Body && !this->visitStmt(Body))
+  if (Body && !this->visitUnscopedCompoundStmt(Body))
 return false;
   this->emitLabel(IncLabel);
   if (Inc && !this->discard(Inc))
 return false;
+
+  Scope.emitDestructors();
   if (!this->jump(CondLabel))
 return false;
   this->emitLabel(EndLabel);
@@ -386,38 +409,38 @@
   LabelTy CondLabel = this->getLabel();
   LabelTy IncLabel = this->getLabel();
   LoopScope LS(this, EndLabel, IncLabel);
-  {
-ExprScope ES(this);
 
-// Emit declarations needed in the loop.
-if (Init && !this->visitStmt(Init))
-  return false;
-if (!this->visitStmt(RangeStmt))
-  return false;
-if (!this->visitStmt(BeginStmt))
-  return false;
-if (!this->visitStmt(EndStmt))
-  return false;
+  // Emit declarations needed in the loop.
+  if (Init && !this->visitStmt(Init))
+return false;
+  if (!this->visitStmt(RangeStmt))
+return false;
+  if (!this->visitStmt(BeginStmt))
+return false;
+  if (!this->visitStmt(EndStmt))
+return false;
 
-// Now the condition as well as the loop variable assignment.
-this->emitLabel(CondLabel);
-if (!this->visitBool(Cond))
-  return false;
-if (!this->jumpFalse(EndLabel))
-  return false;
+  // Now the condition as well as the loop variable assignment.
+  this->emitLabel(CondLabel);
+  if (!this->visitBool(Cond))
+return false;
+  if (!this->jumpFalse(EndLabel))
+return false;
 
-if (!this->visitVarDecl(LoopVar))
-  return false;
+  if (!this->visitVarDecl(LoopVar))
+return false;
 
-// Body.
-if (!this->visitStmt(Body))
-  return false;
-this->emitLabel(IncLabel);
-if (!this->discard(Inc))
-  return false;
-if (!this->jump(CondLabel))
-  return false;
-  }
+  // Body.
+  LocalScope Scope(this);
+  if (!this->visitUnscopedCompoundStmt(Body))
+return false;
+  this->emitLabel(IncLabel);
+  if (!this->discard(Inc))
+return false;
+
+  Scope.emitDestructors();
+  if (!this->jump(CondLabel))
+return false;
 
   this->emitLabel(EndLabel);
   return true;
@@ -428,7 +451,7 @@
   if (!BreakLabel)
 return false;
 
-  this->emitCleanup();
+  this->VarScope->emitDestructors();
   return this->jump(*BreakLabel);
 }
 
@@ -437,7 +460,7 @@
   if (!ContinueLabel)
 return false;
 
-  this->emitCleanup();
+  this->VarScope->emitDestructors();
   return this->jump(*ContinueLabel);
 }
 
Inde

[PATCH] D145391: [HIP] Supports env var HIP_PATH

2023-03-14 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked 2 inline comments as done.
yaxunl added inline comments.



Comment at: clang/lib/Driver/ToolChains/AMDGPU.cpp:442
+   llvm::sys::Process::GetEnv("HIP_PATH")) {
+if (!HIPPathEnv->empty()) {
+  HIPSearchDirs.emplace_back(std::move(*HIPPathEnv));

tra wrote:
> Style nit. Single-statement if body should be w/o `{}`.
will fix



Comment at: clang/test/Driver/rocm-detect.hip:42
+
+// RUN: rm -rf %T/myhip
+// RUN: rm -rf %T/myhip_nouse

MaskRay wrote:
> `%T` is not recommended.
> 
> https://llvm.org/docs/CommandGuide/lit.html
> "parent directory of %t (not unique, deprecated, do not use)"
> 
> Just use `RUN: rm -rf %t && mkdir %t`
> 
I will use %t/myhip, as I need a deterministic unique name to check that it is 
used 


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

https://reviews.llvm.org/D145391

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


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

2023-03-14 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 aside from some small nits that you can fix when landing. Thank you for 
your patience on this review!




Comment at: clang/lib/AST/DeclBase.cpp:1056
+  else if (const auto *D = dyn_cast(this))
+Ty = D->getUnderlyingType();
+  else

erichkeane wrote:
> probably want to canonicalize here (and above).  Else 
> typedefs-to-typedefs/etc might getcha.
Yeah, I'd do that below on the return, as in: `return 
Ty.getCanonicalType()->isFunctionPointerType();`



Comment at: clang/test/SemaCXX/wasm-funcref.cpp:14
+}
\ No newline at end of file


Please add a newline to the end of the file.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128440

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


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

2023-03-14 Thread Erich Keane via Phabricator via cfe-commits
erichkeane accepted this revision.
erichkeane added a comment.
This revision is now accepted and ready to land.

Thanks for your patience, I was buried trying to get the 16.0 release done.  
This LGTM!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143479

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


[PATCH] D145408: Fix false positive with unreachable C++ catch handlers

2023-03-14 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman marked 2 inline comments as done.
aaron.ballman added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145408

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


[PATCH] D146026: [clangd] Patch PragmaMarks in preamble section of the file

2023-03-14 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 505091.
kadircet marked an inline comment as done.
kadircet added a comment.

- Use collectPragmaMarksCallback


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146026

Files:
  clang-tools-extra/clangd/Preamble.cpp
  clang-tools-extra/clangd/Preamble.h
  clang-tools-extra/clangd/unittests/PreambleTests.cpp

Index: clang-tools-extra/clangd/unittests/PreambleTests.cpp
===
--- clang-tools-extra/clangd/unittests/PreambleTests.cpp
+++ clang-tools-extra/clangd/unittests/PreambleTests.cpp
@@ -829,6 +829,10 @@
   }
 }
 
+MATCHER_P2(Mark, Range, Text, "") {
+  return std::tie(arg.Rng, arg.Trivia) == std::tie(Range, Text);
+}
+
 TEST(PreamblePatch, MacroAndMarkHandling) {
   Config Cfg;
   Cfg.Diagnostics.AllowStalePreamble = true;
@@ -847,13 +851,18 @@
 #ifndef FOO
 #define FOO
 #define BAR
-#pragma mark XX
+#pragma $x[[mark XX
+]]
+#pragma $y[[mark YY
+]]
 
 #endif)cpp");
 auto AST = createPatchedAST(Code.code(), NewCode.code());
 // FIXME: Macros and marks have locations that need to be patched.
 EXPECT_THAT(AST->getMacros().Names, IsEmpty());
-EXPECT_THAT(AST->getMarks(), IsEmpty());
+EXPECT_THAT(AST->getMarks(),
+UnorderedElementsAre(Mark(NewCode.range("x"), " XX"),
+ Mark(NewCode.range("y"), " YY")));
   }
 }
 
Index: clang-tools-extra/clangd/Preamble.h
===
--- clang-tools-extra/clangd/Preamble.h
+++ clang-tools-extra/clangd/Preamble.h
@@ -182,6 +182,7 @@
   std::vector PatchedDiags;
   PreambleBounds ModifiedBounds = {0, false};
   const PreambleData *Baseline = nullptr;
+  std::vector PatchedMarks;
 };
 
 } // namespace clangd
Index: clang-tools-extra/clangd/Preamble.cpp
===
--- clang-tools-extra/clangd/Preamble.cpp
+++ clang-tools-extra/clangd/Preamble.cpp
@@ -15,7 +15,9 @@
 #include "Protocol.h"
 #include "SourceCode.h"
 #include "clang-include-cleaner/Record.h"
+#include "index/CanonicalIncludes.h"
 #include "support/Logger.h"
+#include "support/Path.h"
 #include "support/ThreadsafeFS.h"
 #include "support/Trace.h"
 #include "clang/AST/DeclTemplate.h"
@@ -27,6 +29,7 @@
 #include "clang/Basic/TokenKinds.h"
 #include "clang/Frontend/CompilerInvocation.h"
 #include "clang/Frontend/FrontendActions.h"
+#include "clang/Frontend/PrecompiledPreamble.h"
 #include "clang/Lex/HeaderSearch.h"
 #include "clang/Lex/Lexer.h"
 #include "clang/Lex/PPCallbacks.h"
@@ -42,6 +45,7 @@
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Casting.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/FormatVariadic.h"
@@ -50,10 +54,12 @@
 #include "llvm/Support/VirtualFileSystem.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
+#include 
 #include 
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -318,6 +324,7 @@
   // Literal lines of the preamble contents.
   std::vector Lines;
   PreambleBounds Bounds = {0, false};
+  std::vector Marks;
 };
 
 /// Scans the preprocessor directives in the preamble section of the file by
@@ -372,6 +379,8 @@
   SP.Bounds = Bounds;
   PP.addPPCallbacks(
   std::make_unique(PP, SP.TextualDirectives));
+  PP.addPPCallbacks(
+  collectPragmaMarksCallback(PP.getSourceManager(), SP.Marks));
   if (llvm::Error Err = Action.Execute())
 return std::move(Err);
   Action.EndSourceFile();
@@ -849,6 +858,7 @@
   }
 
   PP.PatchedDiags = patchDiags(Baseline.Diags, *BaselineScan, *ModifiedScan);
+  PP.PatchedMarks = std::move(ModifiedScan->Marks);
   dlog("Created preamble patch: {0}", Patch.str());
   Patch.flush();
   return PP;
@@ -902,8 +912,7 @@
 llvm::ArrayRef PreamblePatch::marks() const {
   if (PatchContents.empty())
 return Baseline->Marks;
-  // FIXME: Patch pragma marks.
-  return {};
+  return PatchedMarks;
 }
 
 MainFileMacros PreamblePatch::mainFileMacros() const {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D145906: [clang-tidy] Correctly handle evaluation order of designated initializers.

2023-03-14 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL accepted this revision.
PiotrZSL added a comment.
This revision is now accepted and ready to land.

Looks good to me, consider adding info to Release notes, that this check has 
been improved/fixed support for designated initializers.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145906

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


[PATCH] D146026: [clangd] Patch PragmaMarks in preamble section of the file

2023-03-14 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/Preamble.cpp:576
+
+std::vector getPragmaMarks(const ScannedPreamble &Modified) {
+  std::vector Marks;

hokein wrote:
> any reason not calling `collectPragmaMarksCallback` just like the 
> https://reviews.llvm.org/D146028 for macros? is it for simplicity?
> 
> The pragma mark might be simple enough to parse ourselves, but it doesn't 
> handle well for some trivial/corner cases like (well we probably don't care 
> about these cases)
> 
> ```
> #pragma mark \
>abc
> ```
yeah it was for not running it unnecessarily, but you're right I guess it's not 
worth the discrepancy. using `collectPragmaMarksCallback` instead.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146026

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


[PATCH] D145861: [clang][Interp] Ignore more non-VarDecl declarations

2023-03-14 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder updated this revision to Diff 505092.

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

https://reviews.llvm.org/D145861

Files:
  clang/lib/AST/Interp/ByteCodeStmtGen.cpp
  clang/test/AST/Interp/literals.cpp


Index: clang/test/AST/Interp/literals.cpp
===
--- clang/test/AST/Interp/literals.cpp
+++ clang/test/AST/Interp/literals.cpp
@@ -768,3 +768,16 @@
   static_assert(S3{}.foo(), "");
   static_assert(!S3{}.foo(), "");
 }
+
+#if __cplusplus >= 201402L
+constexpr int ignoredDecls() {
+  static_assert(true);
+  struct F { int a; };
+  enum E { b };
+  using A = int;
+  typedef int Z;
+
+  return F{12}.a;
+}
+static_assert(ignoredDecls() == 12, "");
+#endif
Index: clang/lib/AST/Interp/ByteCodeStmtGen.cpp
===
--- clang/lib/AST/Interp/ByteCodeStmtGen.cpp
+++ clang/lib/AST/Interp/ByteCodeStmtGen.cpp
@@ -221,7 +221,7 @@
 template 
 bool ByteCodeStmtGen::visitDeclStmt(const DeclStmt *DS) {
   for (auto *D : DS->decls()) {
-if (isa(D))
+if (isa(D))
   continue;
 
 const auto *VD = dyn_cast(D);


Index: clang/test/AST/Interp/literals.cpp
===
--- clang/test/AST/Interp/literals.cpp
+++ clang/test/AST/Interp/literals.cpp
@@ -768,3 +768,16 @@
   static_assert(S3{}.foo(), "");
   static_assert(!S3{}.foo(), "");
 }
+
+#if __cplusplus >= 201402L
+constexpr int ignoredDecls() {
+  static_assert(true);
+  struct F { int a; };
+  enum E { b };
+  using A = int;
+  typedef int Z;
+
+  return F{12}.a;
+}
+static_assert(ignoredDecls() == 12, "");
+#endif
Index: clang/lib/AST/Interp/ByteCodeStmtGen.cpp
===
--- clang/lib/AST/Interp/ByteCodeStmtGen.cpp
+++ clang/lib/AST/Interp/ByteCodeStmtGen.cpp
@@ -221,7 +221,7 @@
 template 
 bool ByteCodeStmtGen::visitDeclStmt(const DeclStmt *DS) {
   for (auto *D : DS->decls()) {
-if (isa(D))
+if (isa(D))
   continue;
 
 const auto *VD = dyn_cast(D);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D146028: [clangd] Patch main file macros in preamble

2023-03-14 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 505093.
kadircet marked an inline comment as done.
kadircet added a comment.

- Rebase
- Prevent unnecessary copies


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146028

Files:
  clang-tools-extra/clangd/Preamble.cpp
  clang-tools-extra/clangd/Preamble.h
  clang-tools-extra/clangd/unittests/PreambleTests.cpp


Index: clang-tools-extra/clangd/unittests/PreambleTests.cpp
===
--- clang-tools-extra/clangd/unittests/PreambleTests.cpp
+++ clang-tools-extra/clangd/unittests/PreambleTests.cpp
@@ -30,7 +30,6 @@
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/ScopedPrinter.h"
 #include "llvm/Support/VirtualFileSystem.h"
-#include "llvm/Testing/Support/SupportHelpers.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest-matchers.h"
 #include "gtest/gtest.h"
@@ -855,11 +854,12 @@
 ]]
 #pragma $y[[mark YY
 ]]
+#define BAZ
 
 #endif)cpp");
 auto AST = createPatchedAST(Code.code(), NewCode.code());
-// FIXME: Macros and marks have locations that need to be patched.
-EXPECT_THAT(AST->getMacros().Names, IsEmpty());
+EXPECT_THAT(AST->getMacros().Names.keys(),
+UnorderedElementsAreArray({"FOO", "BAR", "BAZ"}));
 EXPECT_THAT(AST->getMarks(),
 UnorderedElementsAre(Mark(NewCode.range("x"), " XX"),
  Mark(NewCode.range("y"), " YY")));
Index: clang-tools-extra/clangd/Preamble.h
===
--- clang-tools-extra/clangd/Preamble.h
+++ clang-tools-extra/clangd/Preamble.h
@@ -164,7 +164,7 @@
   static constexpr llvm::StringLiteral HeaderName = "__preamble_patch__.h";
 
   llvm::ArrayRef marks() const;
-  MainFileMacros mainFileMacros() const;
+  const MainFileMacros &mainFileMacros() const;
 
 private:
   static PreamblePatch create(llvm::StringRef FileName,
@@ -183,6 +183,7 @@
   PreambleBounds ModifiedBounds = {0, false};
   const PreambleData *Baseline = nullptr;
   std::vector PatchedMarks;
+  MainFileMacros PatchedMacros;
 };
 
 } // namespace clangd
Index: clang-tools-extra/clangd/Preamble.cpp
===
--- clang-tools-extra/clangd/Preamble.cpp
+++ clang-tools-extra/clangd/Preamble.cpp
@@ -325,6 +325,7 @@
   std::vector Lines;
   PreambleBounds Bounds = {0, false};
   std::vector Marks;
+  MainFileMacros Macros;
 };
 
 /// Scans the preprocessor directives in the preamble section of the file by
@@ -373,14 +374,15 @@
   if (!Action.BeginSourceFile(*Clang, Clang->getFrontendOpts().Inputs[0]))
 return error("failed BeginSourceFile");
   Preprocessor &PP = Clang->getPreprocessor();
+  const auto &SM = PP.getSourceManager();
   IncludeStructure Includes;
   Includes.collect(*Clang);
   ScannedPreamble SP;
   SP.Bounds = Bounds;
   PP.addPPCallbacks(
   std::make_unique(PP, SP.TextualDirectives));
-  PP.addPPCallbacks(
-  collectPragmaMarksCallback(PP.getSourceManager(), SP.Marks));
+  PP.addPPCallbacks(collectPragmaMarksCallback(SM, SP.Marks));
+  PP.addPPCallbacks(std::make_unique(SM, SP.Macros));
   if (llvm::Error Err = Action.Execute())
 return std::move(Err);
   Action.EndSourceFile();
@@ -859,6 +861,7 @@
 
   PP.PatchedDiags = patchDiags(Baseline.Diags, *BaselineScan, *ModifiedScan);
   PP.PatchedMarks = std::move(ModifiedScan->Marks);
+  PP.PatchedMacros = std::move(ModifiedScan->Macros);
   dlog("Created preamble patch: {0}", Patch.str());
   Patch.flush();
   return PP;
@@ -915,11 +918,10 @@
   return PatchedMarks;
 }
 
-MainFileMacros PreamblePatch::mainFileMacros() const {
+const MainFileMacros &PreamblePatch::mainFileMacros() const {
   if (PatchContents.empty())
 return Baseline->Macros;
-  // FIXME: Patch main file macros.
-  return MainFileMacros();
+  return PatchedMacros;
 }
 } // namespace clangd
 } // namespace clang


Index: clang-tools-extra/clangd/unittests/PreambleTests.cpp
===
--- clang-tools-extra/clangd/unittests/PreambleTests.cpp
+++ clang-tools-extra/clangd/unittests/PreambleTests.cpp
@@ -30,7 +30,6 @@
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/ScopedPrinter.h"
 #include "llvm/Support/VirtualFileSystem.h"
-#include "llvm/Testing/Support/SupportHelpers.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest-matchers.h"
 #include "gtest/gtest.h"
@@ -855,11 +854,12 @@
 ]]
 #pragma $y[[mark YY
 ]]
+#define BAZ
 
 #endif)cpp");
 auto AST = createPatchedAST(Code.code(), NewCode.code());
-// FIXME: Macros and marks have locations that need to be patched.
-EXPECT_THAT(AST->getMacros().Names, IsEmpty());
+EXPECT_THAT(AST->getMacros().Names.keys(),
+UnorderedElementsAreArray({"FOO", "BAR", "BAZ"}));
 EXPECT_THAT(AST->getMarks(),
 UnorderedElementsAre(Mark(NewCode.ra

[PATCH] D146041: Fix weirdly apologetic diagnostic messages

2023-03-14 Thread David Spickett via Phabricator via cfe-commits
DavidSpickett added a comment.

Is there some standard for writing warning messages? For llvm that is, it would 
be worth looking through the getting started guides to see. I think the 
majority of warnings are "formal" in that sense so this seems fine.

Personally I agree with making the warnings more succinct but aside from that I 
don't see the need to change comments or testing scripts.

You may consider splitting this change into 2. One that only changes warnings 
and errors (a less controversial change) and the rest (that is up to the 
reviewers of each bit).




Comment at: clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp:51
 template<_Complex int> struct ComplexInt {};
-using CI = ComplexInt<1 + 3i>; // FIXME: expected-error {{sorry}}
-using CI = ComplexInt<1 + 3i>; // FIXME: expected-error {{sorry}}

Please find out what the {{sorry}} here was for. Did someone literally write it 
as an apology, or is it indicating some warning that should be emitted here, if 
the FIXME is fixed?

You could git blame this file and find the commit that introduced it, as a 
starting point.



Comment at: polly/lib/External/isl/imath/tests/test.sh:12
 if [ ! -f ../imtest ] ; then
-  echo "I can't find the imath test driver 'imtest', did you build it?"
-  echo "I can't proceed with the unit tests until you do so, sorry."
+  echo "The imath test driver 'imtest' was not found."
+  echo "It needs to be build before proceeding with the unit tests."

Given that this is a developer facing script, I think the "did you build it" is 
in fact quite useful here. Perhaps it could say:
"The imath test driver 'imtest' was not found. Did you build it? It is required 
for running the tests."


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146041

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


[PATCH] D146041: Fix weirdly apologetic diagnostic messages

2023-03-14 Thread David Spickett via Phabricator via cfe-commits
DavidSpickett added a comment.

Ah, here it is: 
https://llvm.org/docs/CodingStandards.html#error-and-warning-messages

Seems to back you up.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146041

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


[PATCH] D145892: [SemaCXX]use CorrectDelayedTyposInExpr in ActOnCXXFoldExpr only when Diag

2023-03-14 Thread Congcong Cai via Phabricator via cfe-commits
HerrCai0907 updated this revision to Diff 505096.
HerrCai0907 added a comment.

add more testcase


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

https://reviews.llvm.org/D145892

Files:
  clang/lib/Sema/SemaTemplateVariadic.cpp
  clang/test/SemaCXX/fold_expr_typo.cpp


Index: clang/test/SemaCXX/fold_expr_typo.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/fold_expr_typo.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++17 %s
+
+template 
+void foo(T &&...Params) {
+  foo(Unknown); // expected-error {{expression contains unexpanded 
parameter pack 'T'}}\
+  expected-error {{use of undeclared identifier 'Unknown'}}
+  ((foo(Unknown)), ...); // expected-error {{use of undeclared identifier 
'Unknown'}}
+}
+
+template  struct A {
+  template  void foo(T &&...Params) {
+foo((... + static_cast(1))); // expected-error {{expression contains 
unexpanded parameter pack 'T'}}
+  }
+};
Index: clang/lib/Sema/SemaTemplateVariadic.cpp
===
--- clang/lib/Sema/SemaTemplateVariadic.cpp
+++ clang/lib/Sema/SemaTemplateVariadic.cpp
@@ -1220,10 +1220,11 @@
   if (!LHS || !RHS) {
 Expr *Pack = LHS ? LHS : RHS;
 assert(Pack && "fold expression with neither LHS nor RHS");
-DiscardOperands();
-if (!Pack->containsUnexpandedParameterPack())
+if (!Pack->containsUnexpandedParameterPack()) {
+  DiscardOperands();
   return Diag(EllipsisLoc, 
diag::err_pack_expansion_without_parameter_packs)
  << Pack->getSourceRange();
+}
   }
 
   BinaryOperatorKind Opc = ConvertTokenKindToBinaryOpcode(Operator);


Index: clang/test/SemaCXX/fold_expr_typo.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/fold_expr_typo.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++17 %s
+
+template 
+void foo(T &&...Params) {
+  foo(Unknown); // expected-error {{expression contains unexpanded parameter pack 'T'}}\
+  expected-error {{use of undeclared identifier 'Unknown'}}
+  ((foo(Unknown)), ...); // expected-error {{use of undeclared identifier 'Unknown'}}
+}
+
+template  struct A {
+  template  void foo(T &&...Params) {
+foo((... + static_cast(1))); // expected-error {{expression contains unexpanded parameter pack 'T'}}
+  }
+};
Index: clang/lib/Sema/SemaTemplateVariadic.cpp
===
--- clang/lib/Sema/SemaTemplateVariadic.cpp
+++ clang/lib/Sema/SemaTemplateVariadic.cpp
@@ -1220,10 +1220,11 @@
   if (!LHS || !RHS) {
 Expr *Pack = LHS ? LHS : RHS;
 assert(Pack && "fold expression with neither LHS nor RHS");
-DiscardOperands();
-if (!Pack->containsUnexpandedParameterPack())
+if (!Pack->containsUnexpandedParameterPack()) {
+  DiscardOperands();
   return Diag(EllipsisLoc, diag::err_pack_expansion_without_parameter_packs)
  << Pack->getSourceRange();
+}
   }
 
   BinaryOperatorKind Opc = ConvertTokenKindToBinaryOpcode(Operator);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D145892: [SemaCXX]use CorrectDelayedTyposInExpr in ActOnCXXFoldExpr only when Diag

2023-03-14 Thread Congcong Cai via Phabricator via cfe-commits
HerrCai0907 added a comment.

Should I add release note in `clang/docs/ReleaseNotes.rst` or any other way?


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

https://reviews.llvm.org/D145892

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


[PATCH] D145974: [libclang] Add index option to store preambles in memory

2023-03-14 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/D145974/new/

https://reviews.llvm.org/D145974

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


[PATCH] D145892: [SemaCXX]use CorrectDelayedTyposInExpr in ActOnCXXFoldExpr only when Diag

2023-03-14 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

In D145892#4193085 , @HerrCai0907 
wrote:

> Should I add release note in `clang/docs/ReleaseNotes.rst` or any other way?

Yes, that is the correct place.


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

https://reviews.llvm.org/D145892

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


[clang] 0950332 - Fix false positive with unreachable C++ catch handlers

2023-03-14 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2023-03-14T11:08:39-04:00
New Revision: 0950332e91df0281c386874c45d7ce33b7da495b

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

LOG: Fix false positive with unreachable C++ catch handlers

This addresses an issue found by WG21 and tracked by CWG2699 (which is
not yet publicly published). The basic problem is that Clang issues a
diagnostic about not being able to reach a handler, but that handler
*is* reached at runtime. Clang's diagnostic behavior was matching the
standard wording, and our runtime behavior was matching the standard's
intent.

This fixes the diagnostic so that it matches the runtime behavior more
closely, and reduces the number of false positives. This is the
direction of choice taken by Core for CWG2699 and it seems unlikely
that WG21 will change direction here.

Fixes https://github.com/llvm/llvm-project/issues/61177
Differential Revision: https://reviews.llvm.org/D145408

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/Sema/SemaStmt.cpp
clang/test/CXX/drs/dr3xx.cpp
clang/test/SemaCXX/unreachable-catch-clauses.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 66a9210c35b66..a52af53bbd28b 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -193,6 +193,10 @@ Bug Fixes in This Version
   (`#60405 `_)
 - Fix aggregate initialization inside lambda constexpr.
   (`#60936 `_)
+- No longer issue a false positive diagnostic about a catch handler that cannot
+  be reached despite being reachable. This fixes
+  `#61177 `_ in anticipation
+  of `CWG2699 _` being accepted by WG21.
 
 Bug Fixes to Compiler Builtins
 ^^

diff  --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp
index f15603fd0bd4a..eda4e01f8f0f0 100644
--- a/clang/lib/Sema/SemaStmt.cpp
+++ b/clang/lib/Sema/SemaStmt.cpp
@@ -4351,9 +4351,9 @@ class CatchHandlerType {
 if (QT->isPointerType())
   IsPointer = true;
 
+QT = QT.getUnqualifiedType();
 if (IsPointer || QT->isReferenceType())
   QT = QT->getPointeeType();
-QT = QT.getUnqualifiedType();
   }
 
   /// Used when creating a CatchHandlerType from a base class type; pretends 
the
@@ -4402,31 +4402,43 @@ template <> struct DenseMapInfo {
 namespace {
 class CatchTypePublicBases {
   ASTContext &Ctx;
-  const llvm::DenseMap &TypesToCheck;
-  const bool CheckAgainstPointer;
+  const llvm::DenseMap &TypesToCheck;
 
   CXXCatchStmt *FoundHandler;
-  CanQualType FoundHandlerType;
+  QualType FoundHandlerType;
+  QualType TestAgainstType;
 
 public:
-  CatchTypePublicBases(
-  ASTContext &Ctx,
-  const llvm::DenseMap &T, bool C)
-  : Ctx(Ctx), TypesToCheck(T), CheckAgainstPointer(C),
-FoundHandler(nullptr) {}
+  CatchTypePublicBases(ASTContext &Ctx,
+   const llvm::DenseMap &T,
+   QualType QT)
+  : Ctx(Ctx), TypesToCheck(T), FoundHandler(nullptr), TestAgainstType(QT) 
{}
 
   CXXCatchStmt *getFoundHandler() const { return FoundHandler; }
-  CanQualType getFoundHandlerType() const { return FoundHandlerType; }
+  QualType getFoundHandlerType() const { return FoundHandlerType; }
 
   bool operator()(const CXXBaseSpecifier *S, CXXBasePath &) {
 if (S->getAccessSpecifier() == AccessSpecifier::AS_public) {
-  CatchHandlerType Check(S->getType(), CheckAgainstPointer);
+  QualType Check = S->getType().getCanonicalType();
   const auto &M = TypesToCheck;
   auto I = M.find(Check);
   if (I != M.end()) {
-FoundHandler = I->second;
-FoundHandlerType = Ctx.getCanonicalType(S->getType());
-return true;
+// We're pretty sure we found what we need to find. However, we still
+// need to make sure that we properly compare for pointers and
+// references, to handle cases like:
+//
+// } catch (Base *b) {
+// } catch (Derived &d) {
+// }
+//
+// where there is a qualification mismatch that disqualifies this
+// handler as a potential problem.
+if (I->second->getCaughtType()->isPointerType() ==
+TestAgainstType->isPointerType()) {
+  FoundHandler = I->second;
+  FoundHandlerType = Check;
+  return true;
+}
   }
 }
 return false;
@@ -4465,6 +4477,7 @@ StmtResult Sema::ActOnCXXTryBlock(SourceLocation TryLoc, 
Stmt *TryBlock,
   assert(!Handlers.empty() &&
  "The parser shouldn't call this if there are no handlers.");
 
+  llvm::DenseMap HandledBaseTypes;

[PATCH] D145408: Fix false positive with unreachable C++ catch handlers

2023-03-14 Thread Aaron Ballman via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0950332e91df: Fix false positive with unreachable C++ catch 
handlers (authored by aaron.ballman).

Changed prior to commit:
  https://reviews.llvm.org/D145408?vs=502739&id=505106#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145408

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaStmt.cpp
  clang/test/CXX/drs/dr3xx.cpp
  clang/test/SemaCXX/unreachable-catch-clauses.cpp

Index: clang/test/SemaCXX/unreachable-catch-clauses.cpp
===
--- clang/test/SemaCXX/unreachable-catch-clauses.cpp
+++ clang/test/SemaCXX/unreachable-catch-clauses.cpp
@@ -9,5 +9,25 @@
 void test()
 try {}
 catch (BaseEx &e) { f(); } // expected-note 2{{for type 'BaseEx &'}}
-catch (Ex1 &e) { f(); } // expected-warning {{exception of type 'Ex1 &' will be caught by earlier handler}}
-catch (Ex2 &e) { f(); } // expected-warning {{exception of type 'Ex2 &' (aka 'Ex1 &') will be caught by earlier handler}}
+catch (Ex1 &e) { f(); } // expected-warning {{exception of type 'Ex1 &' will be caught by earlier handler}} \
+   expected-note {{for type 'Ex1 &'}}
+// FIXME: It would be nicer to only issue one warning on the below line instead
+// of two. We get two diagnostics because the first one is noticing that there
+// is a class hierarchy inversion where the earlier base class handler will
+// catch throwing the derived class and the second one is because Ex2 and Ex1
+// are the same type after canonicalization.
+catch (Ex2 &e) { f(); } // expected-warning 2{{exception of type 'Ex2 &' (aka 'Ex1 &') will be caught by earlier handler}}
+
+namespace GH61177 {
+void func() {
+  const char arr[4] = "abc";
+
+  // We should not issue an "exception will be caught by earlier handler"
+  // diagnostic, as that is a lie.
+  try {
+throw arr;
+  } catch (char *p) {
+  } catch (const char *p) {
+  }
+}
+} // GH61177
Index: clang/test/CXX/drs/dr3xx.cpp
===
--- clang/test/CXX/drs/dr3xx.cpp
+++ clang/test/CXX/drs/dr3xx.cpp
@@ -161,6 +161,15 @@
   struct C : A {};
   struct D : B, C {};
   void f() {
+// NB: the warning here is correct despite being the opposite of the
+// comments in the catch handlers. The "unreachable" comment is correct
+// because there is an ambiguous base path to A from the D that is thrown.
+// The warnings generated are also correct because the handlers handle
+// const B& and const A& and we don't check to see if other derived classes
+// exist that would cause an ambiguous base path. We issue the diagnostic
+// despite the potential for a false positive because users are not
+// expected to have ambiguous base paths all that often, so the false
+// positive rate should be acceptably low.
 try {
   throw D();
 } catch (const A&) { // expected-note {{for type 'const A &'}}
Index: clang/lib/Sema/SemaStmt.cpp
===
--- clang/lib/Sema/SemaStmt.cpp
+++ clang/lib/Sema/SemaStmt.cpp
@@ -4351,9 +4351,9 @@
 if (QT->isPointerType())
   IsPointer = true;
 
+QT = QT.getUnqualifiedType();
 if (IsPointer || QT->isReferenceType())
   QT = QT->getPointeeType();
-QT = QT.getUnqualifiedType();
   }
 
   /// Used when creating a CatchHandlerType from a base class type; pretends the
@@ -4402,31 +4402,43 @@
 namespace {
 class CatchTypePublicBases {
   ASTContext &Ctx;
-  const llvm::DenseMap &TypesToCheck;
-  const bool CheckAgainstPointer;
+  const llvm::DenseMap &TypesToCheck;
 
   CXXCatchStmt *FoundHandler;
-  CanQualType FoundHandlerType;
+  QualType FoundHandlerType;
+  QualType TestAgainstType;
 
 public:
-  CatchTypePublicBases(
-  ASTContext &Ctx,
-  const llvm::DenseMap &T, bool C)
-  : Ctx(Ctx), TypesToCheck(T), CheckAgainstPointer(C),
-FoundHandler(nullptr) {}
+  CatchTypePublicBases(ASTContext &Ctx,
+   const llvm::DenseMap &T,
+   QualType QT)
+  : Ctx(Ctx), TypesToCheck(T), FoundHandler(nullptr), TestAgainstType(QT) {}
 
   CXXCatchStmt *getFoundHandler() const { return FoundHandler; }
-  CanQualType getFoundHandlerType() const { return FoundHandlerType; }
+  QualType getFoundHandlerType() const { return FoundHandlerType; }
 
   bool operator()(const CXXBaseSpecifier *S, CXXBasePath &) {
 if (S->getAccessSpecifier() == AccessSpecifier::AS_public) {
-  CatchHandlerType Check(S->getType(), CheckAgainstPointer);
+  QualType Check = S->getType().getCanonicalType();
   const auto &M = TypesToCheck;
   auto I = M.find(Check);
   if (I != M.end()) {
-FoundHandler = I->second;
-FoundHandlerType = Ctx.getCanonicalType(S-

[PATCH] D145892: [SemaCXX]use CorrectDelayedTyposInExpr in ActOnCXXFoldExpr only when Diag

2023-03-14 Thread Congcong Cai via Phabricator via cfe-commits
HerrCai0907 updated this revision to Diff 505105.
HerrCai0907 added a comment.

add release note


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

https://reviews.llvm.org/D145892

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaTemplateVariadic.cpp
  clang/test/SemaCXX/fold_expr_typo.cpp


Index: clang/test/SemaCXX/fold_expr_typo.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/fold_expr_typo.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++17 %s
+
+template 
+void foo(T &&...Params) {
+  foo(Unknown); // expected-error {{expression contains unexpanded 
parameter pack 'T'}}\
+  expected-error {{use of undeclared identifier 'Unknown'}}
+  ((foo(Unknown)), ...); // expected-error {{use of undeclared identifier 
'Unknown'}}
+}
+
+template  struct A {
+  template  void foo(T &&...Params) {
+foo((... + static_cast(1))); // expected-error {{expression contains 
unexpanded parameter pack 'T'}}
+  }
+};
Index: clang/lib/Sema/SemaTemplateVariadic.cpp
===
--- clang/lib/Sema/SemaTemplateVariadic.cpp
+++ clang/lib/Sema/SemaTemplateVariadic.cpp
@@ -1220,10 +1220,11 @@
   if (!LHS || !RHS) {
 Expr *Pack = LHS ? LHS : RHS;
 assert(Pack && "fold expression with neither LHS nor RHS");
-DiscardOperands();
-if (!Pack->containsUnexpandedParameterPack())
+if (!Pack->containsUnexpandedParameterPack()) {
+  DiscardOperands();
   return Diag(EllipsisLoc, 
diag::err_pack_expansion_without_parameter_packs)
  << Pack->getSourceRange();
+}
   }
 
   BinaryOperatorKind Opc = ConvertTokenKindToBinaryOpcode(Operator);
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -170,6 +170,7 @@
 - Clang now avoids duplicate warnings on unreachable ``[[fallthrough]];`` 
statements
   previously issued from ``-Wunreachable-code`` and 
``-Wunreachable-code-fallthrough``
   by prioritizing ``-Wunreachable-code-fallthrough``.
+- Clang won't crash when fold expression contains a delayed typos correction.
 
 Bug Fixes in This Version
 -


Index: clang/test/SemaCXX/fold_expr_typo.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/fold_expr_typo.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++17 %s
+
+template 
+void foo(T &&...Params) {
+  foo(Unknown); // expected-error {{expression contains unexpanded parameter pack 'T'}}\
+  expected-error {{use of undeclared identifier 'Unknown'}}
+  ((foo(Unknown)), ...); // expected-error {{use of undeclared identifier 'Unknown'}}
+}
+
+template  struct A {
+  template  void foo(T &&...Params) {
+foo((... + static_cast(1))); // expected-error {{expression contains unexpanded parameter pack 'T'}}
+  }
+};
Index: clang/lib/Sema/SemaTemplateVariadic.cpp
===
--- clang/lib/Sema/SemaTemplateVariadic.cpp
+++ clang/lib/Sema/SemaTemplateVariadic.cpp
@@ -1220,10 +1220,11 @@
   if (!LHS || !RHS) {
 Expr *Pack = LHS ? LHS : RHS;
 assert(Pack && "fold expression with neither LHS nor RHS");
-DiscardOperands();
-if (!Pack->containsUnexpandedParameterPack())
+if (!Pack->containsUnexpandedParameterPack()) {
+  DiscardOperands();
   return Diag(EllipsisLoc, diag::err_pack_expansion_without_parameter_packs)
  << Pack->getSourceRange();
+}
   }
 
   BinaryOperatorKind Opc = ConvertTokenKindToBinaryOpcode(Operator);
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -170,6 +170,7 @@
 - Clang now avoids duplicate warnings on unreachable ``[[fallthrough]];`` statements
   previously issued from ``-Wunreachable-code`` and ``-Wunreachable-code-fallthrough``
   by prioritizing ``-Wunreachable-code-fallthrough``.
+- Clang won't crash when fold expression contains a delayed typos correction.
 
 Bug Fixes in This Version
 -
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D146041: Fix weirdly apologetic diagnostic messages

2023-03-14 Thread Jun Zhang via Phabricator via cfe-commits
junaire added a comment.

I'm not certain if it's bad to say 'sorry', IMHO it's fine?

Anyway, you can't just simply delete those words (in diagnostic messages and 
regression tests), that doesn't work. To verify the patch is good, you can run 
`ninja check-all` to make sure the testsuite passes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146041

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


[PATCH] D145892: [SemaCXX]use CorrectDelayedTyposInExpr in ActOnCXXFoldExpr only when Diag

2023-03-14 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: clang/docs/ReleaseNotes.rst:173
   by prioritizing ``-Wunreachable-code-fallthrough``.
+- Clang won't crash when fold expression contains a delayed typos correction.
 

This should go in the `Bug Fixes In This Version` section, right below this.  
Also, try to elaborate and make it more like the format of the others around 
there.


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

https://reviews.llvm.org/D145892

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


[PATCH] D145408: Fix false positive with unreachable C++ catch handlers

2023-03-14 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added a comment.

Apologies for late review.




Comment at: clang/lib/Sema/SemaStmt.cpp:4405
   ASTContext &Ctx;
-  const llvm::DenseMap &TypesToCheck;
-  const bool CheckAgainstPointer;
+  const llvm::DenseMap &TypesToCheck;
 

Can we just make `llvm::DenseMap` a typedef so we 
don't have the verbose type in the function parameter right below and further 
down.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145408

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


[PATCH] D146054: [RISCV] Add -print-supported-marchs and -march=help support

2023-03-14 Thread Brandon Wu via Phabricator via cfe-commits
4vtomat created this revision.
Herald added subscribers: jobnoorman, luke, VincentWu, vkmr, frasercrmck, 
evandro, luismarques, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, 
jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, 
zzheng, jrtc27, shiva0217, kito-cheng, niosHD, sabuasal, simoncook, johnrusso, 
rbar, asb, hiraditya, arichardson.
Herald added a project: All.
4vtomat requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, pcwang-thead, eopXD, 
MaskRay.
Herald added projects: clang, LLVM.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D146054

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/print-supported-marchs.c
  llvm/lib/Support/RISCVISAInfo.cpp

Index: llvm/lib/Support/RISCVISAInfo.cpp
===
--- llvm/lib/Support/RISCVISAInfo.cpp
+++ llvm/lib/Support/RISCVISAInfo.cpp
@@ -17,6 +17,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -139,6 +140,34 @@
 {"ztso", RISCVExtensionVersion{0, 1}},
 };
 
+void RISCVMarchHelp() {
+  auto Cmp = [](const RISCVSupportedExtension &a,
+const RISCVSupportedExtension &b) {
+   StringRef aRef{a.Name}, bRef{b.Name};
+   return std::tie(aRef, a.Version.Major, a.Version.Minor) <
+  std::tie(bRef, b.Version.Major, b.Version.Minor); };
+
+  errs() << "All available -march extensions for RISC-V\n\n";
+  errs() << '\t' << left_justify("Name", 20) << "Version\n";
+  std::set TempSet(Cmp);
+  for (auto E : SupportedExtensions)
+TempSet.insert(E);
+  for (auto E : TempSet)
+errs() << format("\t%-20s%d.%d\n", E.Name, E.Version.Major, E.Version.Minor);
+
+  errs() << "\nExperimental extensions\n";
+  TempSet.clear();
+  for (auto E : SupportedExperimentalExtensions)
+TempSet.insert(E);
+  for (auto E : TempSet)
+errs() << format("\t%-20s%d.%d\n",
+ E.Name, E.Version.Major, E.Version.Minor);
+  errs() << '\n';
+
+  errs() << "Use -march to specify the target's extension.\n"
+"For example, clang -march=rv32i_v1p0\n";
+}
+
 static bool stripExperimentalPrefix(StringRef &Ext) {
   return Ext.consume_front("experimental-");
 }
Index: clang/test/Driver/print-supported-marchs.c
===
--- /dev/null
+++ clang/test/Driver/print-supported-marchs.c
@@ -0,0 +1,98 @@
+// Test that --print-supported-marchs lists supported Marchs.
+
+// REQUIRES: riscv-registered-target
+
+// RUN: %clang --target=riscv64 --print-supported-marchs 2>&1 | \
+// RUN:   FileCheck %s --check-prefix=CHECK-RISCV
+
+// Test -march=help alias.
+// RUN: %clang --target=riscv64 -march=help 2>&1 | \
+// RUN:   FileCheck %s --check-prefix=CHECK-RISCV
+
+// CHECK-NOT: warning: argument unused during compilation
+// CHECK-RISCV: Target: riscv64
+// CHECK-RISCV: All available -march extensions for RISC-V
+// CHECK-RISCV: 	NameVersion
+// CHECK-RISCV: 	a   2.0
+// CHECK-RISCV: 	c   2.0
+// CHECK-RISCV: 	d   2.0
+// CHECK-RISCV: 	e   1.9
+// CHECK-RISCV: 	f   2.0
+// CHECK-RISCV: 	h   1.0
+// CHECK-RISCV: 	i   2.0
+// CHECK-RISCV: 	m   2.0
+// CHECK-RISCV: 	svinval 1.0
+// CHECK-RISCV: 	svnapot 1.0
+// CHECK-RISCV: 	svpbmt  1.0
+// CHECK-RISCV: 	v   1.0
+// CHECK-RISCV: 	xtheadba1.0
+// CHECK-RISCV: 	xtheadbb1.0
+// CHECK-RISCV: 	xtheadbs1.0
+// CHECK-RISCV: 	xtheadcmo   1.0
+// CHECK-RISCV: 	xtheadcondmov   1.0
+// CHECK-RISCV: 	xtheadfmemidx   1.0
+// CHECK-RISCV: 	xtheadmac   1.0
+// CHECK-RISCV: 	xtheadmemidx1.0
+// CHECK-RISCV: 	xtheadmempair   1.0
+// CHECK-RISCV: 	xtheadsync  1.0
+// CHECK-RISCV: 	xtheadvdot  1.0
+// CHECK-RISCV: 	xventanacondops 1.0
+// CHECK-RISCV: 	zawrs   1.0
+// CHECK-RISCV: 	zba 1.0
+// CHECK-RISCV: 	zbb 1.0
+// CHECK-RISCV: 	zbc 1.0
+// CHECK-RISCV: 	zbkb1.0
+// CHECK-RISCV: 	zbkc1.0
+// CHECK-RISCV: 	zbkx1.0
+// CHECK-RISCV: 	zbs 1.0
+// CHECK-RISCV: 	zdinx   1.0
+// CHECK-RISCV: 	zfh 1.0
+// CHECK-RISCV: 	zfhmin  1.0
+// CHECK-RISCV: 	zfinx   1.0
+// CHECK-RISCV: 	zhinx   1.0
+// CHECK-RISCV: 	zhinxmin1.0
+// CHECK-RISCV: 	zicbom  1.0
+// CHECK-RISCV: 	zicbop  1.0
+// CHECK-RISCV: 	zicboz  1.0
+// CHECK-RISCV: 	zicsr   2.0
+// CHECK-RISCV: 	zifencei2.0
+// CHECK-RISCV: 	zihintpause 2.0
+// CHECK-RISCV: 	zk  1.0
+// CHECK-RISCV: 	zkn 1.0
+// CH

[PATCH] D145861: [clang][Interp] Ignore more non-VarDecl declarations

2023-03-14 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!


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

https://reviews.llvm.org/D145861

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


[PATCH] D145892: [SemaCXX]use CorrectDelayedTyposInExpr in ActOnCXXFoldExpr only when Diag

2023-03-14 Thread Congcong Cai via Phabricator via cfe-commits
HerrCai0907 updated this revision to Diff 505111.

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

https://reviews.llvm.org/D145892

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaTemplateVariadic.cpp
  clang/test/SemaCXX/fold_expr_typo.cpp


Index: clang/test/SemaCXX/fold_expr_typo.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/fold_expr_typo.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++17 %s
+
+template 
+void foo(T &&...Params) {
+  foo(Unknown); // expected-error {{expression contains unexpanded 
parameter pack 'T'}}\
+  expected-error {{use of undeclared identifier 'Unknown'}}
+  ((foo(Unknown)), ...); // expected-error {{use of undeclared identifier 
'Unknown'}}
+}
+
+template  struct A {
+  template  void foo(T &&...Params) {
+foo((... + static_cast(1))); // expected-error {{expression contains 
unexpanded parameter pack 'T'}}
+  }
+};
Index: clang/lib/Sema/SemaTemplateVariadic.cpp
===
--- clang/lib/Sema/SemaTemplateVariadic.cpp
+++ clang/lib/Sema/SemaTemplateVariadic.cpp
@@ -1220,10 +1220,11 @@
   if (!LHS || !RHS) {
 Expr *Pack = LHS ? LHS : RHS;
 assert(Pack && "fold expression with neither LHS nor RHS");
-DiscardOperands();
-if (!Pack->containsUnexpandedParameterPack())
+if (!Pack->containsUnexpandedParameterPack()) {
+  DiscardOperands();
   return Diag(EllipsisLoc, 
diag::err_pack_expansion_without_parameter_packs)
  << Pack->getSourceRange();
+}
   }
 
   BinaryOperatorKind Opc = ConvertTokenKindToBinaryOpcode(Operator);
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -193,6 +193,8 @@
   (`#60405 `_)
 - Fix aggregate initialization inside lambda constexpr.
   (`#60936 `_)
+- Fix crash when parsing fold expression contains a delayed typos correction.
+  (`#61326 `_)
 
 Bug Fixes to Compiler Builtins
 ^^


Index: clang/test/SemaCXX/fold_expr_typo.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/fold_expr_typo.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++17 %s
+
+template 
+void foo(T &&...Params) {
+  foo(Unknown); // expected-error {{expression contains unexpanded parameter pack 'T'}}\
+  expected-error {{use of undeclared identifier 'Unknown'}}
+  ((foo(Unknown)), ...); // expected-error {{use of undeclared identifier 'Unknown'}}
+}
+
+template  struct A {
+  template  void foo(T &&...Params) {
+foo((... + static_cast(1))); // expected-error {{expression contains unexpanded parameter pack 'T'}}
+  }
+};
Index: clang/lib/Sema/SemaTemplateVariadic.cpp
===
--- clang/lib/Sema/SemaTemplateVariadic.cpp
+++ clang/lib/Sema/SemaTemplateVariadic.cpp
@@ -1220,10 +1220,11 @@
   if (!LHS || !RHS) {
 Expr *Pack = LHS ? LHS : RHS;
 assert(Pack && "fold expression with neither LHS nor RHS");
-DiscardOperands();
-if (!Pack->containsUnexpandedParameterPack())
+if (!Pack->containsUnexpandedParameterPack()) {
+  DiscardOperands();
   return Diag(EllipsisLoc, diag::err_pack_expansion_without_parameter_packs)
  << Pack->getSourceRange();
+}
   }
 
   BinaryOperatorKind Opc = ConvertTokenKindToBinaryOpcode(Operator);
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -193,6 +193,8 @@
   (`#60405 `_)
 - Fix aggregate initialization inside lambda constexpr.
   (`#60936 `_)
+- Fix crash when parsing fold expression contains a delayed typos correction.
+  (`#61326 `_)
 
 Bug Fixes to Compiler Builtins
 ^^
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D141672: [RISCV] Support vector crypto extension ISA string and assembly

2023-03-14 Thread Brandon Wu via Phabricator via cfe-commits
4vtomat updated this revision to Diff 505112.
4vtomat added a comment.

Resolved Craig's comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141672

Files:
  clang/test/Preprocessor/riscv-target-features.c
  llvm/docs/RISCVUsage.rst
  llvm/lib/Support/RISCVISAInfo.cpp
  llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h
  llvm/lib/Target/RISCV/RISCVFeatures.td
  llvm/lib/Target/RISCV/RISCVInstrFormats.td
  llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
  llvm/lib/Target/RISCV/RISCVInstrInfo.td
  llvm/lib/Target/RISCV/RISCVInstrInfoV.td
  llvm/lib/Target/RISCV/RISCVInstrInfoZvk.td
  llvm/test/CodeGen/RISCV/attributes.ll
  llvm/test/MC/RISCV/attribute-arch.s
  llvm/test/MC/RISCV/rvv/zvkb.s
  llvm/test/MC/RISCV/rvv/zvkg.s
  llvm/test/MC/RISCV/rvv/zvkned-invalid.s
  llvm/test/MC/RISCV/rvv/zvkned.s
  llvm/test/MC/RISCV/rvv/zvknh.s
  llvm/test/MC/RISCV/rvv/zvksed-invalid.s
  llvm/test/MC/RISCV/rvv/zvksed.s
  llvm/test/MC/RISCV/rvv/zvksh.s

Index: llvm/test/MC/RISCV/rvv/zvksh.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rvv/zvksh.s
@@ -0,0 +1,21 @@
+# RUN: llvm-mc -triple=riscv32 -show-encoding --mattr=+zve32x --mattr=+experimental-zvksh %s \
+# RUN:| FileCheck %s --check-prefixes=CHECK-ENCODING,CHECK-INST
+# RUN: not llvm-mc -triple=riscv32 -show-encoding %s 2>&1 \
+# RUN:| FileCheck %s --check-prefix=CHECK-ERROR
+# RUN: llvm-mc -triple=riscv32 -filetype=obj --mattr=+zve32x --mattr=+experimental-zvksh %s \
+# RUN:| llvm-objdump -d --mattr=+zve32x --mattr=+experimental-zvksh  - \
+# RUN:| FileCheck %s --check-prefix=CHECK-INST
+# RUN: llvm-mc -triple=riscv32 -filetype=obj --mattr=+zve32x --mattr=+experimental-zvksh %s \
+# RUN:| llvm-objdump -d - | FileCheck %s --check-prefix=CHECK-UNKNOWN
+
+vsm3c.vi v10, v9, 7
+# CHECK-INST: vsm3c.vi v10, v9, 7
+# CHECK-ENCODING: [0x77,0xa5,0x93,0xae]
+# CHECK-ERROR: instruction requires the following: 'Zvksh' (SM3 Hash Function Instructions.){{$}}
+# CHECK-UNKNOWN: 77 a5 93 ae   
+
+vsm3me.vv v10, v9, v8
+# CHECK-INST: vsm3me.vv v10, v9, v8
+# CHECK-ENCODING: [0x77,0x25,0x94,0x82]
+# CHECK-ERROR: instruction requires the following: 'Zvksh' (SM3 Hash Function Instructions.){{$}}
+# CHECK-UNKNOWN: 77 25 94 82   
Index: llvm/test/MC/RISCV/rvv/zvksed.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rvv/zvksed.s
@@ -0,0 +1,27 @@
+# RUN: llvm-mc -triple=riscv32 -show-encoding --mattr=+zve32x --mattr=+experimental-zvksed %s \
+# RUN:| FileCheck %s --check-prefixes=CHECK-ENCODING,CHECK-INST
+# RUN: not llvm-mc -triple=riscv32 -show-encoding %s 2>&1 \
+# RUN:| FileCheck %s --check-prefix=CHECK-ERROR
+# RUN: llvm-mc -triple=riscv32 -filetype=obj --mattr=+zve32x --mattr=+experimental-zvksed %s \
+# RUN:| llvm-objdump -d --mattr=+zve32x --mattr=+experimental-zvksed  - \
+# RUN:| FileCheck %s --check-prefix=CHECK-INST
+# RUN: llvm-mc -triple=riscv32 -filetype=obj --mattr=+zve32x --mattr=+experimental-zvksed %s \
+# RUN:| llvm-objdump -d - | FileCheck %s --check-prefix=CHECK-UNKNOWN
+
+vsm4k.vi v10, v9, 7
+# CHECK-INST: vsm4k.vi v10, v9, 7
+# CHECK-ENCODING: [0x77,0xa5,0x93,0x86]
+# CHECK-ERROR: instruction requires the following: 'Zvksed' (SM4 Block Cipher Instructions.){{$}}
+# CHECK-UNKNOWN: 77 a5 93 86   
+
+vsm4r.vv v10, v9
+# CHECK-INST: vsm4r.vv v10, v9
+# CHECK-ENCODING: [0x77,0x25,0x98,0xa2]
+# CHECK-ERROR: instruction requires the following: 'Zvksed' (SM4 Block Cipher Instructions.){{$}}
+# CHECK-UNKNOWN: 77 25 98 a2   
+
+vsm4r.vs v10, v9
+# CHECK-INST: vsm4r.vs v10, v9
+# CHECK-ENCODING: [0x77,0x25,0x98,0xa6]
+# CHECK-ERROR: instruction requires the following: 'Zvksed' (SM4 Block Cipher Instructions.){{$}}
+# CHECK-UNKNOWN: 77 25 98 a6   
Index: llvm/test/MC/RISCV/rvv/zvksed-invalid.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rvv/zvksed-invalid.s
@@ -0,0 +1,5 @@
+# RUN: not llvm-mc -triple=riscv32 --mattr=+zve32x --mattr=+experimental-zvksed -show-encoding %s 2>&1 \
+# RUN:| FileCheck %s --check-prefix=CHECK-ERROR
+
+vsm4k.vi v10, v9, 8
+# CHECK-ERROR: immediate must be an integer in the range [0, 7]
Index: llvm/test/MC/RISCV/rvv/zvknh.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rvv/zvknh.s
@@ -0,0 +1,34 @@
+# RUN: llvm-mc -triple=riscv32 -show-encoding --mattr=+zve32x --mattr=+experimental-zvknha %s \
+# RUN:| FileCheck %s --check-prefixes=CHECK-ENCODING,CHECK-INST
+# RUN: llvm-mc -triple=riscv64 -show-encoding --mattr=+zve64x --mattr=+experimental-zvknhb %s \
+# RUN:| FileCheck %s --check-prefixes=CHECK-ENCODING,CHECK-INST
+# RUN: llvm-mc -triple=riscv32 -filetype=obj --mattr=+zve32x --mattr=+expe

[PATCH] D145892: [SemaCXX]use CorrectDelayedTyposInExpr in ActOnCXXFoldExpr only when Diag

2023-03-14 Thread Erich Keane via Phabricator via cfe-commits
erichkeane accepted this revision.
erichkeane added a comment.
This revision is now accepted and ready to land.

LGTM with 2 nits.




Comment at: clang/docs/ReleaseNotes.rst:196
   (`#60936 `_)
+- Fix crash when parsing fold expression contains a delayed typos correction.
+  (`#61326 `_)




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

https://reviews.llvm.org/D145892

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


[PATCH] D142914: [MLIR][OpenMP] Added OMPIRBuilder support for Target Data directives.

2023-03-14 Thread Akash Banerjee via Phabricator via cfe-commits
TIFitis updated this revision to Diff 505116.
TIFitis added a comment.
Herald added a project: Flang.

Added TODO for unsupported map operand types in Flang frontend


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142914

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  flang/lib/Lower/OpenMP.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPConstants.h
  llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
  llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
  mlir/include/mlir/Target/LLVMIR/Dialect/OpenMPCommon.h
  mlir/lib/Target/LLVMIR/CMakeLists.txt
  mlir/lib/Target/LLVMIR/Dialect/OpenACC/OpenACCToLLVMIRTranslation.cpp
  mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
  mlir/lib/Target/LLVMIR/Dialect/OpenMPCommon.cpp
  mlir/test/Target/LLVMIR/omptarget-llvm.mlir

Index: mlir/test/Target/LLVMIR/omptarget-llvm.mlir
===
--- /dev/null
+++ mlir/test/Target/LLVMIR/omptarget-llvm.mlir
@@ -0,0 +1,176 @@
+// RUN: mlir-translate -mlir-to-llvmir -split-input-file %s | FileCheck %s
+
+llvm.func @_QPopenmp_target_data() {
+  %0 = llvm.mlir.constant(1 : i64) : i64
+  %1 = llvm.alloca %0 x i32 {bindc_name = "i", in_type = i32, operand_segment_sizes = array, uniq_name = "_QFopenmp_target_dataEi"} : (i64) -> !llvm.ptr
+  omp.target_data   map((tofrom -> %1 : !llvm.ptr)) {
+%2 = llvm.mlir.constant(99 : i32) : i32
+llvm.store %2, %1 : !llvm.ptr
+omp.terminator
+  }
+  llvm.return
+}
+
+// CHECK: @.offload_maptypes = private unnamed_addr constant [1 x i64] [i64 3]
+// CHECK-LABEL: define void @_QPopenmp_target_data() {
+// CHECK: %[[VAL_0:.*]] = alloca [1 x ptr], align 8
+// CHECK: %[[VAL_1:.*]] = alloca [1 x ptr], align 8
+// CHECK: %[[VAL_2:.*]] = alloca [1 x i64], align 8
+// CHECK: %[[VAL_3:.*]] = alloca i32, i64 1, align 4
+// CHECK: br label %[[VAL_4:.*]]
+// CHECK:   entry:; preds = %[[VAL_5:.*]]
+// CHECK: %[[VAL_6:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_0]], i32 0, i32 0
+// CHECK: store ptr %[[VAL_3]], ptr %[[VAL_6]], align 8
+// CHECK: %[[VAL_7:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_1]], i32 0, i32 0
+// CHECK: store ptr %[[VAL_3]], ptr %[[VAL_7]], align 8
+// CHECK: %[[VAL_8:.*]] = getelementptr inbounds [1 x i64], ptr %[[VAL_2]], i32 0, i32 0
+// CHECK: store i64 ptrtoint (ptr getelementptr (ptr, ptr null, i32 1) to i64), ptr %[[VAL_8]], align 4
+// CHECK: %[[VAL_9:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_0]], i32 0, i32 0
+// CHECK: %[[VAL_10:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_1]], i32 0, i32 0
+// CHECK: %[[VAL_11:.*]] = getelementptr inbounds [1 x i64], ptr %[[VAL_2]], i32 0, i32 0
+// CHECK: call void @__tgt_target_data_begin_mapper(ptr @2, i64 -1, i32 1, ptr %[[VAL_9]], ptr %[[VAL_10]], ptr %[[VAL_11]], ptr @.offload_maptypes, ptr @.offload_mapnames, ptr null)
+// CHECK: br label %[[VAL_12:.*]]
+// CHECK:   omp.data.region:  ; preds = %[[VAL_4]]
+// CHECK: store i32 99, ptr %[[VAL_3]], align 4
+// CHECK: br label %[[VAL_13:.*]]
+// CHECK:   omp.region.cont:  ; preds = %[[VAL_12]]
+// CHECK: %[[VAL_14:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_0]], i32 0, i32 0
+// CHECK: %[[VAL_15:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_1]], i32 0, i32 0
+// CHECK: %[[VAL_16:.*]] = getelementptr inbounds [1 x i64], ptr %[[VAL_2]], i32 0, i32 0
+// CHECK: call void @__tgt_target_data_end_mapper(ptr @2, i64 -1, i32 1, ptr %[[VAL_14]], ptr %[[VAL_15]], ptr %[[VAL_16]], ptr @.offload_maptypes, ptr @.offload_mapnames, ptr null)
+// CHECK: ret void
+
+// -
+
+llvm.func @_QPopenmp_target_data_region(%1 : !llvm.ptr>) {
+  omp.target_data   map((from -> %1 : !llvm.ptr>)) {
+%2 = llvm.mlir.constant(99 : i32) : i32
+%3 = llvm.mlir.constant(1 : i64) : i64
+%4 = llvm.mlir.constant(1 : i64) : i64
+%5 = llvm.mlir.constant(0 : i64) : i64
+%6 = llvm.getelementptr %1[0, %5] : (!llvm.ptr>, i64) -> !llvm.ptr
+llvm.store %2, %6 : !llvm.ptr
+omp.terminator
+  }
+  llvm.return
+}
+
+// CHECK: @.offload_maptypes = private unnamed_addr constant [1 x i64] [i64 2]
+// CHECK-LABEL: define void @_QPopenmp_target_data_region
+// CHECK: (ptr %[[ARG_0:.*]]) {
+// CHECK: %[[VAL_0:.*]] = alloca [1 x ptr], align 8
+// CHECK: %[[VAL_1:.*]] = alloca [1 x ptr], align 8
+// CHECK: %[[VAL_2:.*]] = alloca [1 x i64], align 8
+// CHECK: br label %[[VAL_3:.*]]
+// CHECK:   entry:; preds = %[[VAL_4:.*]]
+// CHECK: %[[VAL_5:.*]] = getelementptr

[PATCH] D142914: [MLIR][OpenMP] Added OMPIRBuilder support for Target Data directives.

2023-03-14 Thread Akash Banerjee via Phabricator via cfe-commits
TIFitis marked an inline comment as done.
TIFitis added inline comments.



Comment at: 
mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp:1357
+/// Process MapOperands for Target Data directives.
+static LogicalResult processMapOperand(
+llvm::IRBuilderBase &builder, LLVM::ModuleTranslation &moduleTranslation,

kiranchandramohan wrote:
> TIFitis wrote:
> > TIFitis wrote:
> > > TIFitis wrote:
> > > > kiranchandramohan wrote:
> > > > > kiranchandramohan wrote:
> > > > > > TIFitis wrote:
> > > > > > > TIFitis wrote:
> > > > > > > > kiranchandramohan wrote:
> > > > > > > > > TIFitis wrote:
> > > > > > > > > > kiranchandramohan wrote:
> > > > > > > > > > > TIFitis wrote:
> > > > > > > > > > > > kiranchandramohan wrote:
> > > > > > > > > > > > > Isn't it possible to sink this whole function into 
> > > > > > > > > > > > > the OpenMPIRBuilder by passing it a list of 
> > > > > > > > > > > > > `mapOpValue` and `mapTypeFlags`?
> > > > > > > > > > > > > `lvm::Value *mapOpValue = 
> > > > > > > > > > > > > moduleTranslation.lookupValue(mapOp);`
> > > > > > > > > > > > > 
> > > > > > > > > > > > > Did i miss something? Or is this in anticipation of 
> > > > > > > > > > > > > more processing required for other types?
> > > > > > > > > > > > I'm not fully sure but we might need more MLIR related 
> > > > > > > > > > > > things when supporting types other than 
> > > > > > > > > > > > LLVMPointerType. Also there is a call to 
> > > > > > > > > > > > mlir::LLVM::createMappingInformation.
> > > > > > > > > > > > 
> > > > > > > > > > > > I guess it might still be possible to move most of it 
> > > > > > > > > > > > to the IRBuilder, would you like me to do that?
> > > > > > > > > > > Callbacks are useful when there is frontend-specific 
> > > > > > > > > > > handling that is required. If more types require to be 
> > > > > > > > > > > handled then it is better to have the callback. We can 
> > > > > > > > > > > revisit this after all types are handled. I assume, the 
> > > > > > > > > > > current handling is for scalars and arrays of known-size.
> > > > > > > > > > I am a novice at FORTRAN so I'm not aware of all  the types 
> > > > > > > > > > and scenarios.
> > > > > > > > > > 
> > > > > > > > > > I've tested the following cases and they work end-to-end:
> > > > > > > > > > 
> > > > > > > > > > **Fortran:**
> > > > > > > > > > ```
> > > > > > > > > > subroutine openmp_target_data_region(a)
> > > > > > > > > > real :: a(*)
> > > > > > > > > > integer :: b(1024)
> > > > > > > > > > character :: c
> > > > > > > > > > integer, pointer :: p
> > > > > > > > > > !$omp target enter data map(to: a, b, c, p)
> > > > > > > > > > end subroutine openmp_target_data_region
> > > > > > > > > > ```
> > > > > > > > > > 
> > > > > > > > > > **LLVM IR(** `flang-new -fc1 -emit-llvm -fopenmp test.f90 
> > > > > > > > > > -o test.ll`** ):**
> > > > > > > > > > 
> > > > > > > > > > ```
> > > > > > > > > > ; ModuleID = 'FIRModule'
> > > > > > > > > > source_filename = "FIRModule"
> > > > > > > > > > target datalayout = 
> > > > > > > > > > "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
> > > > > > > > > > target triple = "x86_64-unknown-linux-gnu"
> > > > > > > > > > 
> > > > > > > > > > %struct.ident_t = type { i32, i32, i32, i32, ptr }
> > > > > > > > > > 
> > > > > > > > > > @0 = private unnamed_addr constant [13 x i8] 
> > > > > > > > > > c"loc(unknown)\00", align 1
> > > > > > > > > > @1 = private unnamed_addr constant [56 x i8] 
> > > > > > > > > > c";/home/akash/Documents/scratch/test2.f90;unknown;3;16;;\00",
> > > > > > > > > >  align 1
> > > > > > > > > > @2 = private unnamed_addr constant [56 x i8] 
> > > > > > > > > > c";/home/akash/Documents/scratch/test2.f90;unknown;4;18;;\00",
> > > > > > > > > >  align 1
> > > > > > > > > > @3 = private unnamed_addr constant [56 x i8] 
> > > > > > > > > > c";/home/akash/Documents/scratch/test2.f90;unknown;5;25;;\00",
> > > > > > > > > >  align 1
> > > > > > > > > > @4 = private unnamed_addr constant [23 x i8] 
> > > > > > > > > > c";unknown;unknown;0;0;;\00", align 1
> > > > > > > > > > @5 = private unnamed_addr constant %struct.ident_t { i32 0, 
> > > > > > > > > > i32 2, i32 0, i32 22, ptr @4 }, align 8
> > > > > > > > > > @.offload_maptypes = private unnamed_addr constant [4 x 
> > > > > > > > > > i64] [i64 1, i64 1, i64 1, i64 1]
> > > > > > > > > > @.offload_mapnames = private constant [4 x ptr] [ptr @0, 
> > > > > > > > > > ptr @1, ptr @2, ptr @3]
> > > > > > > > > > 
> > > > > > > > > > declare ptr @malloc(i64)
> > > > > > > > > > 
> > > > > > > > > > declare void @free(ptr)
> > > > > > > > > > 
> > > > > > > > > > define void @openmp_target_data_region_(ptr %0) {
> > > > > > > > > >   %2 = alloca [4 x ptr], align 8
> > > > > > > > > >   %3 = alloca [4 x ptr], align 8
> > > > > > > > > >   %4 = alloca [4 x i64], align 8
> > > > > > > > > >   %5 = alloca [1024 x i32], i64 1, align 4
> > > > > 

[PATCH] D145970: [MSVC][PS][dllexport/dllimport] Propagate a dllexport/dllimport attribute to template baseclasses

2023-03-14 Thread Wolfgang Pieb via Phabricator via cfe-commits
wolfgangp added a comment.

In D145970#4192679 , @hans wrote:

> LGTM
>
> I've always found this to be an interesting behavior, and I'm guessing you 
> found some code where it does matter :)

Well, one of our customers did, anyway. The code in the description is the 
distilled version of it.

Thank you for the review!




Comment at: clang/lib/Sema/SemaDeclCXX.cpp:2612
+  if (Context.getTargetInfo().getCXXABI().isMicrosoft() ||
+  Context.getTargetInfo().getTriple().isPS()) {
 if (Attr *ClassAttr = getDLLAttr(Class)) {

hans wrote:
> Would using `getTargetInfo().shouldDLLImportComdatSymbols()` be appropriate 
> here now?
Perhaps. It would affect the Windows/Itanium platform in addition to what's 
here, and I wasn't sure if that was desirable.


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

https://reviews.llvm.org/D145970

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


[clang] f2a6fe6 - Remove an unused private data member; NFC

2023-03-14 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2023-03-14T11:32:11-04:00
New Revision: f2a6fe601a862b4520266cd660ae4a130886ef33

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

LOG: Remove an unused private data member; NFC

Added: 


Modified: 
clang/lib/Sema/SemaStmt.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp
index eda4e01f8f0f..3e0b3c2b953f 100644
--- a/clang/lib/Sema/SemaStmt.cpp
+++ b/clang/lib/Sema/SemaStmt.cpp
@@ -4401,7 +4401,6 @@ template <> struct DenseMapInfo {
 
 namespace {
 class CatchTypePublicBases {
-  ASTContext &Ctx;
   const llvm::DenseMap &TypesToCheck;
 
   CXXCatchStmt *FoundHandler;
@@ -4409,10 +4408,9 @@ class CatchTypePublicBases {
   QualType TestAgainstType;
 
 public:
-  CatchTypePublicBases(ASTContext &Ctx,
-   const llvm::DenseMap &T,
+  CatchTypePublicBases(const llvm::DenseMap &T,
QualType QT)
-  : Ctx(Ctx), TypesToCheck(T), FoundHandler(nullptr), TestAgainstType(QT) 
{}
+  : TypesToCheck(T), FoundHandler(nullptr), TestAgainstType(QT) {}
 
   CXXCatchStmt *getFoundHandler() const { return FoundHandler; }
   QualType getFoundHandlerType() const { return FoundHandlerType; }
@@ -4511,7 +4509,7 @@ StmtResult Sema::ActOnCXXTryBlock(SourceLocation TryLoc, 
Stmt *TryBlock,
   // as the original type.
   CXXBasePaths Paths;
   Paths.setOrigin(RD);
-  CatchTypePublicBases CTPB(Context, HandledBaseTypes,
+  CatchTypePublicBases CTPB(HandledBaseTypes,
 H->getCaughtType().getCanonicalType());
   if (RD->lookupInBases(CTPB, Paths)) {
 const CXXCatchStmt *Problem = CTPB.getFoundHandler();



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


[clang] 9afcebb - [AIX] change "llvm-ar" to "env OBJECT_MODE=any llvm-ar" in clang/test for AIX OS

2023-03-14 Thread via cfe-commits

Author: zhijian
Date: 2023-03-14T11:50:20-04:00
New Revision: 9afcebb2202eb705da1ddbf6b36c1f5629042f6e

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

LOG: [AIX] change "llvm-ar" to "env OBJECT_MODE=any llvm-ar" in clang/test for 
AIX OS

Summary:

In patch https://reviews.llvm.org/D127864. we add a new option -X for AIX OS, 
and default value is -X32. In order not effect the test cases in clang/test. we 
need to change "llvm-ar" to "env OBJECT_MODE=any llvm-ar" in clang/test for AIX 
OS

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

Added: 


Modified: 
clang/test/Driver/linker-wrapper-libs.c
clang/test/lit.cfg.py

Removed: 




diff  --git a/clang/test/Driver/linker-wrapper-libs.c 
b/clang/test/Driver/linker-wrapper-libs.c
index 65d4c2546ba9c..ee05304b7f1a2 100644
--- a/clang/test/Driver/linker-wrapper-libs.c
+++ b/clang/test/Driver/linker-wrapper-libs.c
@@ -2,8 +2,6 @@
 // REQUIRES: nvptx-registered-target
 // REQUIRES: amdgpu-registered-target
 
-// REQUIRES: system-linux
-
 // RUN: %clang -cc1 %s -triple x86_64-unknown-linux-gnu -emit-obj -o %t.elf.o
 
 #if defined(RESOLVES)

diff  --git a/clang/test/lit.cfg.py b/clang/test/lit.cfg.py
index 839960e9633df..e9bfaf2e96774 100644
--- a/clang/test/lit.cfg.py
+++ b/clang/test/lit.cfg.py
@@ -282,6 +282,7 @@ def exclude_unsupported_files_for_aix(dirname):
 
 if 'system-aix' in config.available_features:
 config.substitutions.append(('llvm-nm', 'env OBJECT_MODE=any llvm-nm'))
+config.substitutions.append(('llvm-ar', 'env OBJECT_MODE=any llvm-ar'))
 
 # It is not realistically possible to account for all options that could
 # possibly be present in system and user configuration files, so disable



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


[PATCH] D145600: [AIX] change "llvm-ar" to "env OBJECT_MODE=any llvm-ar" in clang/test for AIX OS

2023-03-14 Thread 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 rG9afcebb2202e: [AIX] change "llvm-ar" to "env 
OBJECT_MODE=any llvm-ar" in clang/test for AIX OS (authored by zhijian 
).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145600

Files:
  clang/test/Driver/linker-wrapper-libs.c
  clang/test/lit.cfg.py


Index: clang/test/lit.cfg.py
===
--- clang/test/lit.cfg.py
+++ clang/test/lit.cfg.py
@@ -282,6 +282,7 @@
 
 if 'system-aix' in config.available_features:
 config.substitutions.append(('llvm-nm', 'env OBJECT_MODE=any llvm-nm'))
+config.substitutions.append(('llvm-ar', 'env OBJECT_MODE=any llvm-ar'))
 
 # It is not realistically possible to account for all options that could
 # possibly be present in system and user configuration files, so disable
Index: clang/test/Driver/linker-wrapper-libs.c
===
--- clang/test/Driver/linker-wrapper-libs.c
+++ clang/test/Driver/linker-wrapper-libs.c
@@ -2,8 +2,6 @@
 // REQUIRES: nvptx-registered-target
 // REQUIRES: amdgpu-registered-target
 
-// REQUIRES: system-linux
-
 // RUN: %clang -cc1 %s -triple x86_64-unknown-linux-gnu -emit-obj -o %t.elf.o
 
 #if defined(RESOLVES)


Index: clang/test/lit.cfg.py
===
--- clang/test/lit.cfg.py
+++ clang/test/lit.cfg.py
@@ -282,6 +282,7 @@
 
 if 'system-aix' in config.available_features:
 config.substitutions.append(('llvm-nm', 'env OBJECT_MODE=any llvm-nm'))
+config.substitutions.append(('llvm-ar', 'env OBJECT_MODE=any llvm-ar'))
 
 # It is not realistically possible to account for all options that could
 # possibly be present in system and user configuration files, so disable
Index: clang/test/Driver/linker-wrapper-libs.c
===
--- clang/test/Driver/linker-wrapper-libs.c
+++ clang/test/Driver/linker-wrapper-libs.c
@@ -2,8 +2,6 @@
 // REQUIRES: nvptx-registered-target
 // REQUIRES: amdgpu-registered-target
 
-// REQUIRES: system-linux
-
 // RUN: %clang -cc1 %s -triple x86_64-unknown-linux-gnu -emit-obj -o %t.elf.o
 
 #if defined(RESOLVES)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D145892: [SemaCXX]use CorrectDelayedTyposInExpr in ActOnCXXFoldExpr only when Diag

2023-03-14 Thread Congcong Cai via Phabricator via cfe-commits
HerrCai0907 updated this revision to Diff 505122.

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

https://reviews.llvm.org/D145892

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaTemplateVariadic.cpp
  clang/test/SemaCXX/fold_expr_typo.cpp


Index: clang/test/SemaCXX/fold_expr_typo.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/fold_expr_typo.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++17 %s
+
+template 
+void foo(T &&...Params) {
+  foo(Unknown); // expected-error {{expression contains unexpanded 
parameter pack 'T'}}\
+  expected-error {{use of undeclared identifier 'Unknown'}}
+  ((foo(Unknown)), ...); // expected-error {{use of undeclared identifier 
'Unknown'}}
+}
+
+template  struct A {
+  template  void foo(T &&...Params) {
+foo((... + static_cast(1))); // expected-error {{expression contains 
unexpanded parameter pack 'T'}}
+  }
+};
Index: clang/lib/Sema/SemaTemplateVariadic.cpp
===
--- clang/lib/Sema/SemaTemplateVariadic.cpp
+++ clang/lib/Sema/SemaTemplateVariadic.cpp
@@ -1220,10 +1220,11 @@
   if (!LHS || !RHS) {
 Expr *Pack = LHS ? LHS : RHS;
 assert(Pack && "fold expression with neither LHS nor RHS");
-DiscardOperands();
-if (!Pack->containsUnexpandedParameterPack())
+if (!Pack->containsUnexpandedParameterPack()) {
+  DiscardOperands();
   return Diag(EllipsisLoc, 
diag::err_pack_expansion_without_parameter_packs)
  << Pack->getSourceRange();
+}
   }
 
   BinaryOperatorKind Opc = ConvertTokenKindToBinaryOpcode(Operator);
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -193,6 +193,8 @@
   (`#60405 `_)
 - Fix aggregate initialization inside lambda constexpr.
   (`#60936 `_)
+- Fix crash when parsing fold expression containing a delayed typo correction.
+  (`#61326 `_)
 
 Bug Fixes to Compiler Builtins
 ^^


Index: clang/test/SemaCXX/fold_expr_typo.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/fold_expr_typo.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++17 %s
+
+template 
+void foo(T &&...Params) {
+  foo(Unknown); // expected-error {{expression contains unexpanded parameter pack 'T'}}\
+  expected-error {{use of undeclared identifier 'Unknown'}}
+  ((foo(Unknown)), ...); // expected-error {{use of undeclared identifier 'Unknown'}}
+}
+
+template  struct A {
+  template  void foo(T &&...Params) {
+foo((... + static_cast(1))); // expected-error {{expression contains unexpanded parameter pack 'T'}}
+  }
+};
Index: clang/lib/Sema/SemaTemplateVariadic.cpp
===
--- clang/lib/Sema/SemaTemplateVariadic.cpp
+++ clang/lib/Sema/SemaTemplateVariadic.cpp
@@ -1220,10 +1220,11 @@
   if (!LHS || !RHS) {
 Expr *Pack = LHS ? LHS : RHS;
 assert(Pack && "fold expression with neither LHS nor RHS");
-DiscardOperands();
-if (!Pack->containsUnexpandedParameterPack())
+if (!Pack->containsUnexpandedParameterPack()) {
+  DiscardOperands();
   return Diag(EllipsisLoc, diag::err_pack_expansion_without_parameter_packs)
  << Pack->getSourceRange();
+}
   }
 
   BinaryOperatorKind Opc = ConvertTokenKindToBinaryOpcode(Operator);
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -193,6 +193,8 @@
   (`#60405 `_)
 - Fix aggregate initialization inside lambda constexpr.
   (`#60936 `_)
+- Fix crash when parsing fold expression containing a delayed typo correction.
+  (`#61326 `_)
 
 Bug Fixes to Compiler Builtins
 ^^
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D145892: [SemaCXX]use CorrectDelayedTyposInExpr in ActOnCXXFoldExpr only when Diag

2023-03-14 Thread Congcong Cai via Phabricator via cfe-commits
HerrCai0907 updated this revision to Diff 505126.
HerrCai0907 marked an inline comment as done.

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

https://reviews.llvm.org/D145892

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaTemplateVariadic.cpp
  clang/test/SemaCXX/fold_expr_typo.cpp


Index: clang/test/SemaCXX/fold_expr_typo.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/fold_expr_typo.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++17 %s
+
+template 
+void foo(T &&...Params) {
+  foo(Unknown); // expected-error {{expression contains unexpanded 
parameter pack 'T'}}\
+  expected-error {{use of undeclared identifier 'Unknown'}}
+  ((foo(Unknown)), ...); // expected-error {{use of undeclared identifier 
'Unknown'}}
+}
+
+template  struct A {
+  template  void foo(T &&...Params) {
+foo((... + static_cast(1))); // expected-error {{expression contains 
unexpanded parameter pack 'T'}}
+  }
+};
Index: clang/lib/Sema/SemaTemplateVariadic.cpp
===
--- clang/lib/Sema/SemaTemplateVariadic.cpp
+++ clang/lib/Sema/SemaTemplateVariadic.cpp
@@ -1220,10 +1220,11 @@
   if (!LHS || !RHS) {
 Expr *Pack = LHS ? LHS : RHS;
 assert(Pack && "fold expression with neither LHS nor RHS");
-DiscardOperands();
-if (!Pack->containsUnexpandedParameterPack())
+if (!Pack->containsUnexpandedParameterPack()) {
+  DiscardOperands();
   return Diag(EllipsisLoc, 
diag::err_pack_expansion_without_parameter_packs)
  << Pack->getSourceRange();
+}
   }
 
   BinaryOperatorKind Opc = ConvertTokenKindToBinaryOpcode(Operator);
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -193,6 +193,8 @@
   (`#60405 `_)
 - Fix aggregate initialization inside lambda constexpr.
   (`#60936 `_)
+- Fix crash when parsing fold expression containing a delayed typo correction.
+  (`#61326 `_)
 
 Bug Fixes to Compiler Builtins
 ^^


Index: clang/test/SemaCXX/fold_expr_typo.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/fold_expr_typo.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++17 %s
+
+template 
+void foo(T &&...Params) {
+  foo(Unknown); // expected-error {{expression contains unexpanded parameter pack 'T'}}\
+  expected-error {{use of undeclared identifier 'Unknown'}}
+  ((foo(Unknown)), ...); // expected-error {{use of undeclared identifier 'Unknown'}}
+}
+
+template  struct A {
+  template  void foo(T &&...Params) {
+foo((... + static_cast(1))); // expected-error {{expression contains unexpanded parameter pack 'T'}}
+  }
+};
Index: clang/lib/Sema/SemaTemplateVariadic.cpp
===
--- clang/lib/Sema/SemaTemplateVariadic.cpp
+++ clang/lib/Sema/SemaTemplateVariadic.cpp
@@ -1220,10 +1220,11 @@
   if (!LHS || !RHS) {
 Expr *Pack = LHS ? LHS : RHS;
 assert(Pack && "fold expression with neither LHS nor RHS");
-DiscardOperands();
-if (!Pack->containsUnexpandedParameterPack())
+if (!Pack->containsUnexpandedParameterPack()) {
+  DiscardOperands();
   return Diag(EllipsisLoc, diag::err_pack_expansion_without_parameter_packs)
  << Pack->getSourceRange();
+}
   }
 
   BinaryOperatorKind Opc = ConvertTokenKindToBinaryOpcode(Operator);
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -193,6 +193,8 @@
   (`#60405 `_)
 - Fix aggregate initialization inside lambda constexpr.
   (`#60936 `_)
+- Fix crash when parsing fold expression containing a delayed typo correction.
+  (`#61326 `_)
 
 Bug Fixes to Compiler Builtins
 ^^
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D146054: [RISCV] Add -print-supported-marchs and -march=help support

2023-03-14 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: clang/lib/Driver/Driver.cpp:110
 
+extern void RISCVMarchHelp();
+

Can we declare this in RISCVISAInfo.h and include that here?



Comment at: llvm/lib/Support/RISCVISAInfo.cpp:143
 
+void RISCVMarchHelp() {
+  auto Cmp = [](const RISCVSupportedExtension &a,

This function is not in the llvm namespace or a namespace nested under it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146054

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


[PATCH] D145369: Emit const globals with constexpr destructor as constant LLVM values

2023-03-14 Thread Hans Wennborg via Phabricator via cfe-commits
hans updated this revision to Diff 505127.
hans added a comment.

Thanks for the review!

Added tests to cover other calls that change behavior due to this.

Please take another look.


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

https://reviews.llvm.org/D145369

Files:
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGenCXX/const-init-cxx11.cpp
  clang/test/CodeGenCXX/const-init-cxx2a.cpp
  clang/test/CodeGenCXX/init-invariant.cpp
  clang/test/CodeGenCXX/static-init.cpp

Index: clang/test/CodeGenCXX/static-init.cpp
===
--- clang/test/CodeGenCXX/static-init.cpp
+++ clang/test/CodeGenCXX/static-init.cpp
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 %s -triple=x86_64-pc-linuxs -emit-llvm -std=c++98 -o - | FileCheck -check-prefix=CHECK -check-prefix=CHECK98 %s
 // RUN: %clang_cc1 %s -triple=x86_64-pc-linuxs -emit-llvm -std=c++11 -o - | FileCheck -check-prefix=CHECK -check-prefix=CHECK11 %s
+// RUN: %clang_cc1 %s -triple=x86_64-pc-linuxs -emit-llvm -std=c++20 -o - | FileCheck -check-prefix=CHECK -check-prefix=CHECK20 %s
 
 // CHECK: @_ZZ1hvE1i = internal global i32 0, align 4
 // CHECK: @base_req ={{.*}} global [4 x i8] c"foo\00", align 1
@@ -7,6 +8,8 @@
 
 // CHECK: @_ZZN5test31BC1EvE1u = internal global { i8, [3 x i8] } { i8 97, [3 x i8] undef }, align 4
 
+// CHECK20: @_ZZN5test51fEvE1a = internal constant %"struct.test5::A" { i32 42 }
+
 // CHECK: @_ZZ2h2vE1i = linkonce_odr global i32 0, comdat, align 4
 // CHECK: @_ZGVZ2h2vE1i = linkonce_odr global i64 0, comdat, align 8{{$}}
 // CHECK: @_ZZN5test1L6getvarEiE3var = internal constant [4 x i32] [i32 1, i32 0, i32 2, i32 4], align 16
@@ -173,3 +176,18 @@
 // CHECK: define linkonce_odr noundef nonnull align 8 dereferenceable(8) ptr @_ZN5test414useStaticLocalEv()
 // CHECK: ret ptr{{.*}} @_ZZN5test414useStaticLocalEvE3obj
 }
+
+#if __cplusplus >= 202002L
+// A const object with constexpr destructor can be emitted as a constant.
+namespace test5 {
+  struct A {
+constexpr A(int x) : x_(x) {}
+constexpr ~A() {}
+int x_;
+  };
+  const int *f() {
+static const A a{42};
+return &a.x_;
+  }
+}
+#endif
Index: clang/test/CodeGenCXX/init-invariant.cpp
===
--- clang/test/CodeGenCXX/init-invariant.cpp
+++ clang/test/CodeGenCXX/init-invariant.cpp
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -triple i686-linux-gnu -emit-llvm %s -disable-llvm-passes -o - | FileCheck %s --check-prefix=CHECK-O0
-// RUN: %clang_cc1 -triple i686-linux-gnu -emit-llvm %s -O1 -disable-llvm-passes -o - | FileCheck %s
+// RUN: %clang_cc1 -triple i686-linux-gnu -std=c++20 -emit-llvm %s -disable-llvm-passes -o - | FileCheck %s --check-prefix=CHECK-O0
+// RUN: %clang_cc1 -triple i686-linux-gnu -std=c++20 -emit-llvm %s -O1 -disable-llvm-passes -o - | FileCheck %s
 
 // Check that we add an llvm.invariant.start.p0i8 to mark when a global becomes
 // read-only. If globalopt can fold the initializer, it will then mark the
@@ -16,6 +16,16 @@
 // CHECK: @a ={{.*}} global {{.*}} zeroinitializer
 extern const A a = A();
 
+struct A2 {
+  A2();
+  constexpr ~A2() {}
+  int n;
+};
+
+// CHECK: @a2 ={{.*}} global {{.*}} zeroinitializer
+extern const A2 a2 = A2();
+
+
 struct B {
   B();
   mutable int n;
@@ -44,6 +54,9 @@
 // CHECK: call void @_ZN1AC1Ev(ptr noundef {{[^,]*}} @a)
 // CHECK: call {{.*}}@llvm.invariant.start.p0(i64 4, ptr @a)
 
+// CHECK: call void @_ZN2A2C1Ev(ptr noundef {{[^,]*}} @a2)
+// CHECK: call {{.*}}@llvm.invariant.start.p0(i64 4, ptr @a2)
+
 // CHECK: call void @_ZN1BC1Ev(ptr noundef {{[^,]*}} @b)
 // CHECK-NOT: call {{.*}}@llvm.invariant.start.p0(i64 noundef 4, ptr @b)
 
Index: clang/test/CodeGenCXX/const-init-cxx2a.cpp
===
--- clang/test/CodeGenCXX/const-init-cxx2a.cpp
+++ clang/test/CodeGenCXX/const-init-cxx2a.cpp
@@ -11,10 +11,10 @@
   constexpr ~B() { n *= 5; }
   int n = 123;
 };
-// CHECK: @b ={{.*}} global {{.*}} i32 123
+// CHECK: @b ={{.*}} constant {{.*}} i32 123
 extern constexpr B b = B();
 
-// CHECK: @_ZL1c = internal global {{.*}} i32 123
+// CHECK: @_ZL1c = internal constant {{.*}} i32 123
 const B c;
 int use_c() { return c.n; }
 
Index: clang/test/CodeGenCXX/const-init-cxx11.cpp
===
--- clang/test/CodeGenCXX/const-init-cxx11.cpp
+++ clang/test/CodeGenCXX/const-init-cxx11.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -no-opaque-pointers -w -fmerge-all-constants -triple x86_64-elf-gnu -emit-llvm -o - %s -std=c++11 | FileCheck %s
+// RUN: %clang_cc1 -no-opaque-pointers -w -fmerge-all-constants -triple x86_64-elf-gnu -emit-llvm -o - %s -std=c++20 | FileCheck -check-prefix=CHECK20 %s
 
 // FIXME: The padding in all these objects should be zero-initialized.
 namespace StructUnion {
@@ -424,6 +425,7 @@
 // CHECK: @_ZGRN39ClassTemplateWithHiddenStaticDataMember1SIvE1aE_ = linkonce_odr hidden constant i3

[PATCH] D145892: [SemaCXX]use CorrectDelayedTyposInExpr in ActOnCXXFoldExpr only when Diag

2023-03-14 Thread Congcong Cai via Phabricator via cfe-commits
HerrCai0907 updated this revision to Diff 505129.

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

https://reviews.llvm.org/D145892

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaTemplateVariadic.cpp
  clang/test/SemaCXX/fold_expr_typo.cpp


Index: clang/test/SemaCXX/fold_expr_typo.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/fold_expr_typo.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++17 %s
+
+template 
+void foo(T &&...Params) {
+  foo(Unknown); // expected-error {{expression contains unexpanded 
parameter pack 'T'}}\
+  expected-error {{use of undeclared identifier 'Unknown'}}
+  ((foo(Unknown)), ...); // expected-error {{use of undeclared identifier 
'Unknown'}}
+}
+
+template  struct A {
+  template  void foo(T &&...Params) {
+foo((... + static_cast(1))); // expected-error {{expression contains 
unexpanded parameter pack 'T'}}
+  }
+};
Index: clang/lib/Sema/SemaTemplateVariadic.cpp
===
--- clang/lib/Sema/SemaTemplateVariadic.cpp
+++ clang/lib/Sema/SemaTemplateVariadic.cpp
@@ -1220,10 +1220,11 @@
   if (!LHS || !RHS) {
 Expr *Pack = LHS ? LHS : RHS;
 assert(Pack && "fold expression with neither LHS nor RHS");
-DiscardOperands();
-if (!Pack->containsUnexpandedParameterPack())
+if (!Pack->containsUnexpandedParameterPack()) {
+  DiscardOperands();
   return Diag(EllipsisLoc, 
diag::err_pack_expansion_without_parameter_packs)
  << Pack->getSourceRange();
+}
   }
 
   BinaryOperatorKind Opc = ConvertTokenKindToBinaryOpcode(Operator);
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -193,6 +193,8 @@
   (`#60405 `_)
 - Fix aggregate initialization inside lambda constexpr.
   (`#60936 `_)
+- Fix crash when parsing fold expression containing a delayed typo correction.
+  (`#61326 `_)
 
 Bug Fixes to Compiler Builtins
 ^^


Index: clang/test/SemaCXX/fold_expr_typo.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/fold_expr_typo.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++17 %s
+
+template 
+void foo(T &&...Params) {
+  foo(Unknown); // expected-error {{expression contains unexpanded parameter pack 'T'}}\
+  expected-error {{use of undeclared identifier 'Unknown'}}
+  ((foo(Unknown)), ...); // expected-error {{use of undeclared identifier 'Unknown'}}
+}
+
+template  struct A {
+  template  void foo(T &&...Params) {
+foo((... + static_cast(1))); // expected-error {{expression contains unexpanded parameter pack 'T'}}
+  }
+};
Index: clang/lib/Sema/SemaTemplateVariadic.cpp
===
--- clang/lib/Sema/SemaTemplateVariadic.cpp
+++ clang/lib/Sema/SemaTemplateVariadic.cpp
@@ -1220,10 +1220,11 @@
   if (!LHS || !RHS) {
 Expr *Pack = LHS ? LHS : RHS;
 assert(Pack && "fold expression with neither LHS nor RHS");
-DiscardOperands();
-if (!Pack->containsUnexpandedParameterPack())
+if (!Pack->containsUnexpandedParameterPack()) {
+  DiscardOperands();
   return Diag(EllipsisLoc, diag::err_pack_expansion_without_parameter_packs)
  << Pack->getSourceRange();
+}
   }
 
   BinaryOperatorKind Opc = ConvertTokenKindToBinaryOpcode(Operator);
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -193,6 +193,8 @@
   (`#60405 `_)
 - Fix aggregate initialization inside lambda constexpr.
   (`#60936 `_)
+- Fix crash when parsing fold expression containing a delayed typo correction.
+  (`#61326 `_)
 
 Bug Fixes to Compiler Builtins
 ^^
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D145892: [SemaCXX]use CorrectDelayedTyposInExpr in ActOnCXXFoldExpr only when Diag

2023-03-14 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

Looks good!  Thanks!  Commit when you're ready.


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

https://reviews.llvm.org/D145892

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


[PATCH] D145391: [HIP] Supports env var HIP_PATH

2023-03-14 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 505133.
yaxunl marked 2 inline comments as done.
yaxunl added a comment.

fix tests


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

https://reviews.llvm.org/D145391

Files:
  clang/lib/Driver/ToolChains/AMDGPU.cpp
  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
@@ -25,6 +25,31 @@
 // RUN:   --print-rocm-search-dirs %s 2>&1 \
 // RUN:   | FileCheck -check-prefixes=ROCM-ENV %s
 
+// Test interaction between environment variables HIP_PATH and ROCM_PATH.
+// Device libs are found under ROCM_PATH. HIP include files and HIP runtime 
library
+// are found under HIP_PATH.
+
+// RUN: rm -rf %t/myhip
+// RUN: mkdir -p %t/myhip
+// RUN: cp -r %S/Inputs/rocm/bin %t/myhip
+// RUN: env ROCM_PATH=%S/Inputs/rocm HIP_PATH=%t/myhip \
+// RUN:   %clang -### -target x86_64-linux-gnu --offload-arch=gfx1010 
--hip-link \
+// RUN:   --print-rocm-search-dirs %s 2>&1 \
+// RUN:   | FileCheck -check-prefixes=ROCM-ENV,HIP-PATH %s
+
+// Test --hip-path option overrides environment variable HIP_PATH.
+
+// RUN: rm -rf %t/myhip
+// RUN: rm -rf %t/myhip_nouse
+// RUN: mkdir -p %t/myhip
+// RUN: mkdir -p %t/myhip_nouse
+// RUN: cp -r %S/Inputs/rocm/bin %t/myhip
+// RUN: cp -r %S/Inputs/rocm/bin %t/myhip_nouse
+// RUN: env ROCM_PATH=%S/Inputs/rocm HIP_PATH=%t/myhip_nouse \
+// RUN:   %clang -### -target x86_64-linux-gnu --offload-arch=gfx1010 
--hip-link \
+// RUN:   --hip-path=%t/myhip --print-rocm-search-dirs %s 2>&1 \
+// RUN:   | FileCheck -check-prefixes=ROCM-ENV,HIP-PATH %s
+
 // Test detecting latest /opt/rocm-{release} directory.
 // RUN: rm -rf %T/opt
 // RUN: mkdir -p %T/opt
@@ -75,7 +100,11 @@
 
 // COMMON: "-triple" "amdgcn-amd-amdhsa"
 
-// ROCM-ENV: ROCm installation search path: {{.*}}/Inputs/rocm
+// ROCM-ENV: ROCm installation search path: [[ROCM_PATH:.*/Inputs/rocm]]
+
+// HIP-PATH: "-mlink-builtin-bitcode" 
"[[ROCM_PATH]]/amdgcn/bitcode/oclc_isa_version_1010.bc"
+// HIP-PATH: "-idirafter" "[[HIP_PATH:.*/myhip]]/include"
+// HIP-PATH: "-L[[HIP_PATH]]/lib" "-lamdhip64"
 
 // ROCM-REL: ROCm installation search path: {{.*}}/opt/rocm
 // ROCM-REL: ROCm installation search path: {{.*}}/opt/rocm-3.10.0
Index: clang/lib/Driver/ToolChains/AMDGPU.cpp
===
--- clang/lib/Driver/ToolChains/AMDGPU.cpp
+++ clang/lib/Driver/ToolChains/AMDGPU.cpp
@@ -437,7 +437,11 @@
   SmallVector HIPSearchDirs;
   if (!HIPPathArg.empty())
 HIPSearchDirs.emplace_back(HIPPathArg.str(), /*StrictChecking=*/true);
-  else
+  else if (std::optional HIPPathEnv =
+   llvm::sys::Process::GetEnv("HIP_PATH")) {
+if (!HIPPathEnv->empty()
+  HIPSearchDirs.emplace_back(std::move(*HIPPathEnv));
+  } else
 HIPSearchDirs.append(getInstallationPathCandidates());
   auto &FS = D.getVFS();
 


Index: clang/test/Driver/rocm-detect.hip
===
--- clang/test/Driver/rocm-detect.hip
+++ clang/test/Driver/rocm-detect.hip
@@ -25,6 +25,31 @@
 // RUN:   --print-rocm-search-dirs %s 2>&1 \
 // RUN:   | FileCheck -check-prefixes=ROCM-ENV %s
 
+// Test interaction between environment variables HIP_PATH and ROCM_PATH.
+// Device libs are found under ROCM_PATH. HIP include files and HIP runtime library
+// are found under HIP_PATH.
+
+// RUN: rm -rf %t/myhip
+// RUN: mkdir -p %t/myhip
+// RUN: cp -r %S/Inputs/rocm/bin %t/myhip
+// RUN: env ROCM_PATH=%S/Inputs/rocm HIP_PATH=%t/myhip \
+// RUN:   %clang -### -target x86_64-linux-gnu --offload-arch=gfx1010 --hip-link \
+// RUN:   --print-rocm-search-dirs %s 2>&1 \
+// RUN:   | FileCheck -check-prefixes=ROCM-ENV,HIP-PATH %s
+
+// Test --hip-path option overrides environment variable HIP_PATH.
+
+// RUN: rm -rf %t/myhip
+// RUN: rm -rf %t/myhip_nouse
+// RUN: mkdir -p %t/myhip
+// RUN: mkdir -p %t/myhip_nouse
+// RUN: cp -r %S/Inputs/rocm/bin %t/myhip
+// RUN: cp -r %S/Inputs/rocm/bin %t/myhip_nouse
+// RUN: env ROCM_PATH=%S/Inputs/rocm HIP_PATH=%t/myhip_nouse \
+// RUN:   %clang -### -target x86_64-linux-gnu --offload-arch=gfx1010 --hip-link \
+// RUN:   --hip-path=%t/myhip --print-rocm-search-dirs %s 2>&1 \
+// RUN:   | FileCheck -check-prefixes=ROCM-ENV,HIP-PATH %s
+
 // Test detecting latest /opt/rocm-{release} directory.
 // RUN: rm -rf %T/opt
 // RUN: mkdir -p %T/opt
@@ -75,7 +100,11 @@
 
 // COMMON: "-triple" "amdgcn-amd-amdhsa"
 
-// ROCM-ENV: ROCm installation search path: {{.*}}/Inputs/rocm
+// ROCM-ENV: ROCm installation search path: [[ROCM_PATH:.*/Inputs/rocm]]
+
+// HIP-PATH: "-mlink-builtin-bitcode" "[[ROCM_PATH]]/amdgcn/bitcode/oclc_isa_version_1010.bc"
+// HIP-PATH: "-idirafter" "[[HIP_PATH:.*/myhip]]/include"
+// HIP-PATH: "-L[[HIP_PATH]]/lib" "-lamdhip64"
 
 // ROCM-REL: ROCm installation search path: {{.*}}/opt/rocm
 // ROCM-REL: ROCm installat

[PATCH] D145892: [SemaCXX]use CorrectDelayedTyposInExpr in ActOnCXXFoldExpr only when Diag

2023-03-14 Thread Congcong Cai via Phabricator via cfe-commits
HerrCai0907 updated this revision to Diff 505134.
HerrCai0907 added a comment.

rebase to main


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

https://reviews.llvm.org/D145892

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaTemplateVariadic.cpp
  clang/test/SemaCXX/fold_expr_typo.cpp


Index: clang/test/SemaCXX/fold_expr_typo.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/fold_expr_typo.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++17 %s
+
+template 
+void foo(T &&...Params) {
+  foo(Unknown); // expected-error {{expression contains unexpanded 
parameter pack 'T'}}\
+  expected-error {{use of undeclared identifier 'Unknown'}}
+  ((foo(Unknown)), ...); // expected-error {{use of undeclared identifier 
'Unknown'}}
+}
+
+template  struct A {
+  template  void foo(T &&...Params) {
+foo((... + static_cast(1))); // expected-error {{expression contains 
unexpanded parameter pack 'T'}}
+  }
+};
Index: clang/lib/Sema/SemaTemplateVariadic.cpp
===
--- clang/lib/Sema/SemaTemplateVariadic.cpp
+++ clang/lib/Sema/SemaTemplateVariadic.cpp
@@ -1220,10 +1220,11 @@
   if (!LHS || !RHS) {
 Expr *Pack = LHS ? LHS : RHS;
 assert(Pack && "fold expression with neither LHS nor RHS");
-DiscardOperands();
-if (!Pack->containsUnexpandedParameterPack())
+if (!Pack->containsUnexpandedParameterPack()) {
+  DiscardOperands();
   return Diag(EllipsisLoc, 
diag::err_pack_expansion_without_parameter_packs)
  << Pack->getSourceRange();
+}
   }
 
   BinaryOperatorKind Opc = ConvertTokenKindToBinaryOpcode(Operator);
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -197,6 +197,8 @@
   be reached despite being reachable. This fixes
   `#61177 `_ in anticipation
   of `CWG2699 _` being accepted by WG21.
+- Fix crash when parsing fold expression containing a delayed typo correction.
+  (`#61326 `_)
 
 Bug Fixes to Compiler Builtins
 ^^


Index: clang/test/SemaCXX/fold_expr_typo.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/fold_expr_typo.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++17 %s
+
+template 
+void foo(T &&...Params) {
+  foo(Unknown); // expected-error {{expression contains unexpanded parameter pack 'T'}}\
+  expected-error {{use of undeclared identifier 'Unknown'}}
+  ((foo(Unknown)), ...); // expected-error {{use of undeclared identifier 'Unknown'}}
+}
+
+template  struct A {
+  template  void foo(T &&...Params) {
+foo((... + static_cast(1))); // expected-error {{expression contains unexpanded parameter pack 'T'}}
+  }
+};
Index: clang/lib/Sema/SemaTemplateVariadic.cpp
===
--- clang/lib/Sema/SemaTemplateVariadic.cpp
+++ clang/lib/Sema/SemaTemplateVariadic.cpp
@@ -1220,10 +1220,11 @@
   if (!LHS || !RHS) {
 Expr *Pack = LHS ? LHS : RHS;
 assert(Pack && "fold expression with neither LHS nor RHS");
-DiscardOperands();
-if (!Pack->containsUnexpandedParameterPack())
+if (!Pack->containsUnexpandedParameterPack()) {
+  DiscardOperands();
   return Diag(EllipsisLoc, diag::err_pack_expansion_without_parameter_packs)
  << Pack->getSourceRange();
+}
   }
 
   BinaryOperatorKind Opc = ConvertTokenKindToBinaryOpcode(Operator);
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -197,6 +197,8 @@
   be reached despite being reachable. This fixes
   `#61177 `_ in anticipation
   of `CWG2699 _` being accepted by WG21.
+- Fix crash when parsing fold expression containing a delayed typo correction.
+  (`#61326 `_)
 
 Bug Fixes to Compiler Builtins
 ^^
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D145892: [SemaCXX]use CorrectDelayedTyposInExpr in ActOnCXXFoldExpr only when Diag

2023-03-14 Thread Congcong Cai via Phabricator via cfe-commits
HerrCai0907 added a comment.

I don't have write access now. Could you kindly help me to commit it?


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

https://reviews.llvm.org/D145892

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


[PATCH] D144190: [AIX][clang] Storage Locations for Constant Pointers

2023-03-14 Thread Stephen Peckham via Phabricator via cfe-commits
stephenpeckham added inline comments.



Comment at: clang/docs/ReleaseNotes.rst:230
+- Introduced the ``-mroptr`` option to place constant objects with relocatable
+  address values in the read-only data section. This option is intended to
+  be used with the ``-fdata-sections`` option. When ``-mroptr`` is in effect

"intended" is a bit misleading.  It's an error to use -mroptr and 
-fno-data-sections together.



Comment at: clang/include/clang/Driver/Options.td:3896
+def mroptr : Flag<["-"], "mroptr">, Group, Flags<[CC1Option]>,
+  HelpText<"Place constant objects with relocatable address values in the RO 
data section and imply -bforceimprw when specified at link time">;
+def mno_roptr : Flag<["-"], "mno-roptr">, Group;

Should you add "(AIX only)"? Also, I don't think "imply" is a good choice here. 
I would say:  ... and add -bforceimprw to the linker flags."  



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:1960
+
+// Since the stroage mapping class is specified per csect,
+// without using data sections, it is ambiguous what exactly should

typo



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:1961
+// Since the stroage mapping class is specified per csect,
+// without using data sections, it is ambiguous what exactly should
+// be done for the read-only pointers. Using read-only pointers may cause

It's not ambiguous to use -fno-data-sections and -mroptr together, but it would 
be  less effective.  


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144190

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


[PATCH] D145892: [SemaCXX]use CorrectDelayedTyposInExpr in ActOnCXXFoldExpr only when Diag

2023-03-14 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

In D145892#4193428 , @HerrCai0907 
wrote:

> I don't have write access now. Could you kindly help me to commit it?

Sure, just give me the name and email address you'd like it committed as.


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

https://reviews.llvm.org/D145892

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


[clang] 3d9880e - [OpenMP]Skip generating this[:1] map info for non-member variable.

2023-03-14 Thread Jennifer Yu via cfe-commits

Author: Jennifer Yu
Date: 2023-03-14T09:09:20-07:00
New Revision: 3d9880ebbcb7d458753ac73a65b401af94c7b762

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

LOG: [OpenMP]Skip generating this[:1] map info for non-member variable.

My change of D14093 is only fixed problem for "pragma target data".

The problem still here for "pragma target"
what I am missing is:
When processing "pragma target data", the VD is passed when call to
emitCombinedEntry, so check VD is null as map for this pointer.

But when processing "pragma target" the VD is passed as nullptr, so
check VD is null is not working.

To fix this I add a new parameter IsMapThis. During the call to
emitCombinedEntry passes true if it is capturing this pointer and use
that instead check of "!VD".

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

Added: 


Modified: 
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/test/OpenMP/target_map_member_expr_codegen.cpp
openmp/libomptarget/test/mapping/target_map_for_member_data.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index 60e03320a391c..8ebdad4c63ee3 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -8378,7 +8378,8 @@ class MappableExprsHandler {
   // individual members mapped. Emit an extra combined entry.
   if (PartialStruct.Base.isValid()) {
 CurInfo.NonContigInfo.Dims.push_back(0);
-emitCombinedEntry(CombinedInfo, CurInfo.Types, PartialStruct, VD);
+emitCombinedEntry(CombinedInfo, CurInfo.Types, PartialStruct,
+  /*IsMapThis*/ !VD, VD);
   }
 
   // We need to append the results of this capture to what we already
@@ -8444,7 +8445,7 @@ class MappableExprsHandler {
   /// individual struct members.
   void emitCombinedEntry(MapCombinedInfoTy &CombinedInfo,
  MapFlagsArrayTy &CurTypes,
- const StructRangeInfoTy &PartialStruct,
+ const StructRangeInfoTy &PartialStruct, bool 
IsMapThis,
  const ValueDecl *VD = nullptr,
  bool NotTargetParams = true) const {
 if (CurTypes.size() == 1 &&
@@ -8466,8 +8467,7 @@ class MappableExprsHandler {
 const CXXMethodDecl *MD =
 CGF.CurFuncDecl ? dyn_cast(CGF.CurFuncDecl) : nullptr;
 const CXXRecordDecl *RD = MD ? MD->getParent() : nullptr;
-// When VD is not null, it is not field of class, skip generating this[:1].
-bool HasBaseClass = RD && !VD ? RD->getNumBases() > 0 : false;
+bool HasBaseClass = RD && IsMapThis ? RD->getNumBases() > 0 : false;
 // There should not be a mapper for a combined entry.
 if (HasBaseClass) {
   // OpenMP 5.2 148:21:
@@ -10052,8 +10052,8 @@ void CGOpenMPRuntime::emitTargetCall(
   if (PartialStruct.Base.isValid()) {
 CombinedInfo.append(PartialStruct.PreliminaryMapData);
 MEHandler.emitCombinedEntry(
-CombinedInfo, CurInfo.Types, PartialStruct, nullptr,
-!PartialStruct.PreliminaryMapData.BasePointers.empty());
+CombinedInfo, CurInfo.Types, PartialStruct, CI->capturesThis(),
+nullptr, !PartialStruct.PreliminaryMapData.BasePointers.empty());
   }
 
   // We need to append the results of this capture to what we already have.

diff  --git a/clang/test/OpenMP/target_map_member_expr_codegen.cpp 
b/clang/test/OpenMP/target_map_member_expr_codegen.cpp
index fa47fcee41a4c..26676ad7c3832 100644
--- a/clang/test/OpenMP/target_map_member_expr_codegen.cpp
+++ b/clang/test/OpenMP/target_map_member_expr_codegen.cpp
@@ -56,6 +56,9 @@ class C : public BASE
for (int i = 0; i < Csize; ++i)
   d.C[i] = 1;
  }
+ #pragma omp target map(from:d.C[0:Csize])
+   for (int i = 0; i < Csize; ++i)
+  d.C[i] = 1;
}
 };
 
@@ -66,9 +69,11 @@ void foo() {
   descriptor d;
   c.bar(d);
 }
+
 // CHECK: @.offload_sizes = private unnamed_addr constant [4 x i64] [i64 12, 
i64 4, i64 4, i64 4]
 // CHECK-NOT: @.offload_sizes = private unnamed_addr constant [4 x i64] [i64 
0, i64 4, i64 4, i64 4]
-
+// CHECK: @.offload_sizes.4 = private unnamed_addr constant [3 x i64] [i64 4, 
i64 0, i64 0]
+// CHECK-NOT: @.offload_sizes.4 = private unnamed_addr constant [3 x i64] [i64 
4, i64 1, i64 0]
 // CHECK-LABEL: define {{[^@]+}}@_Z3foov
 // CHECK-SAME: () #[[ATTR0:[0-9]+]] {
 // CHECK-NEXT:  entry:
@@ -189,6 +194,12 @@ void foo() {
 // CHECK-NEXT:[[DOTOFFLOAD_BASEPTRS9:%.*]] = alloca [2 x ptr], align 8
 // CHECK-NEXT:[[DOTOFFLOAD_PTRS10:%.*]] = alloca [2 x ptr], align 8
 // CHECK-NEXT:[[DOTOFFLOAD_MAPPERS11:%.*]] = alloca [2 x ptr], align 8
+// CHECK-NEXT:[[_TMP12:%.*]] = alloca ptr, 

[PATCH] D146000: [OpenMP]Skip generating this[:1] map info for non-member variable.

2023-03-14 Thread Jennifer Yu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3d9880ebbcb7: [OpenMP]Skip generating this[:1] map info for 
non-member variable. (authored by jyu2).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146000

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/test/OpenMP/target_map_member_expr_codegen.cpp
  openmp/libomptarget/test/mapping/target_map_for_member_data.cpp

Index: openmp/libomptarget/test/mapping/target_map_for_member_data.cpp
===
--- openmp/libomptarget/test/mapping/target_map_for_member_data.cpp
+++ openmp/libomptarget/test/mapping/target_map_for_member_data.cpp
@@ -68,11 +68,13 @@
 auto Asize = 4;
 auto Csize = 4;
 
-#pragma omp target data map(to : d.A) map(from : d.C)
+#pragma omp target data map(from : d.C)
 {
 #pragma omp target teams firstprivate(Csize)
   d.C = 1;
 }
+#pragma omp target map(from : d.A)
+d.A = 3;
   }
 };
 
@@ -91,4 +93,6 @@
   z.bar(d);
   // CHECK 1
   printf("%d\n", d.C);
+  // CHECK 3
+  printf("%d\n", d.A);
 }
Index: clang/test/OpenMP/target_map_member_expr_codegen.cpp
===
--- clang/test/OpenMP/target_map_member_expr_codegen.cpp
+++ clang/test/OpenMP/target_map_member_expr_codegen.cpp
@@ -56,6 +56,9 @@
for (int i = 0; i < Csize; ++i)
   d.C[i] = 1;
  }
+ #pragma omp target map(from:d.C[0:Csize])
+   for (int i = 0; i < Csize; ++i)
+  d.C[i] = 1;
}
 };
 
@@ -66,9 +69,11 @@
   descriptor d;
   c.bar(d);
 }
+
 // CHECK: @.offload_sizes = private unnamed_addr constant [4 x i64] [i64 12, i64 4, i64 4, i64 4]
 // CHECK-NOT: @.offload_sizes = private unnamed_addr constant [4 x i64] [i64 0, i64 4, i64 4, i64 4]
-
+// CHECK: @.offload_sizes.4 = private unnamed_addr constant [3 x i64] [i64 4, i64 0, i64 0]
+// CHECK-NOT: @.offload_sizes.4 = private unnamed_addr constant [3 x i64] [i64 4, i64 1, i64 0]
 // CHECK-LABEL: define {{[^@]+}}@_Z3foov
 // CHECK-SAME: () #[[ATTR0:[0-9]+]] {
 // CHECK-NEXT:  entry:
@@ -189,6 +194,12 @@
 // CHECK-NEXT:[[DOTOFFLOAD_BASEPTRS9:%.*]] = alloca [2 x ptr], align 8
 // CHECK-NEXT:[[DOTOFFLOAD_PTRS10:%.*]] = alloca [2 x ptr], align 8
 // CHECK-NEXT:[[DOTOFFLOAD_MAPPERS11:%.*]] = alloca [2 x ptr], align 8
+// CHECK-NEXT:[[_TMP12:%.*]] = alloca ptr, align 8
+// CHECK-NEXT:[[CSIZE_CASTED13:%.*]] = alloca i64, align 8
+// CHECK-NEXT:[[DOTOFFLOAD_BASEPTRS18:%.*]] = alloca [3 x ptr], align 8
+// CHECK-NEXT:[[DOTOFFLOAD_PTRS19:%.*]] = alloca [3 x ptr], align 8
+// CHECK-NEXT:[[DOTOFFLOAD_MAPPERS20:%.*]] = alloca [3 x ptr], align 8
+// CHECK-NEXT:[[DOTOFFLOAD_SIZES21:%.*]] = alloca [3 x i64], align 8
 // CHECK-NEXT:store ptr [[THIS]], ptr [[THIS_ADDR]], align 8
 // CHECK-NEXT:store ptr [[D]], ptr [[D_ADDR]], align 8
 // CHECK-NEXT:[[THIS1:%.*]] = load ptr, ptr [[THIS_ADDR]], align 8
@@ -323,6 +334,87 @@
 // CHECK-NEXT:[[TMP71:%.*]] = getelementptr inbounds [3 x ptr], ptr [[DOTOFFLOAD_PTRS]], i32 0, i32 0
 // CHECK-NEXT:[[TMP72:%.*]] = getelementptr inbounds [3 x i64], ptr [[DOTOFFLOAD_SIZES]], i32 0, i32 0
 // CHECK-NEXT:call void @__tgt_target_data_end_mapper(ptr @[[GLOB1]], i64 -1, i32 3, ptr [[TMP70]], ptr [[TMP71]], ptr [[TMP72]], ptr @.offload_maptypes.1, ptr null, ptr null)
+// CHECK-NEXT:[[TMP73:%.*]] = load ptr, ptr [[D_ADDR]], align 8
+// CHECK-NEXT:store ptr [[TMP73]], ptr [[_TMP12]], align 8
+// CHECK-NEXT:[[TMP74:%.*]] = load i32, ptr [[CSIZE]], align 4
+// CHECK-NEXT:store i32 [[TMP74]], ptr [[CSIZE_CASTED13]], align 4
+// CHECK-NEXT:[[TMP75:%.*]] = load i64, ptr [[CSIZE_CASTED13]], align 8
+// CHECK-NEXT:[[TMP76:%.*]] = load ptr, ptr [[_TMP12]], align 8
+// CHECK-NEXT:[[TMP77:%.*]] = load ptr, ptr [[_TMP12]], align 8
+// CHECK-NEXT:[[TMP78:%.*]] = load ptr, ptr [[_TMP12]], align 8
+// CHECK-NEXT:[[C14:%.*]] = getelementptr inbounds [[STRUCT_DESCRIPTOR]], ptr [[TMP78]], i32 0, i32 1
+// CHECK-NEXT:[[TMP79:%.*]] = load ptr, ptr [[_TMP12]], align 8
+// CHECK-NEXT:[[C15:%.*]] = getelementptr inbounds [[STRUCT_DESCRIPTOR]], ptr [[TMP79]], i32 0, i32 1
+// CHECK-NEXT:[[TMP80:%.*]] = load ptr, ptr [[C15]], align 8
+// CHECK-NEXT:[[ARRAYIDX16:%.*]] = getelementptr inbounds float, ptr [[TMP80]], i64 0
+// CHECK-NEXT:[[TMP81:%.*]] = load i32, ptr [[CSIZE]], align 4
+// CHECK-NEXT:[[CONV17:%.*]] = zext i32 [[TMP81]] to i64
+// CHECK-NEXT:[[TMP82:%.*]] = mul nuw i64 [[CONV17]], 4
+// CHECK-NEXT:[[TMP83:%.*]] = getelementptr ptr, ptr [[C14]], i32 1
+// CHECK-NEXT:[[TMP84:%.*]] = ptrtoint ptr [[TMP83]] to i64
+// CHECK-NEXT:[[TMP85:%.*]] = ptrtoint ptr [[C14]] to i64
+// CHECK-NEXT:[[TMP86:%.*]] = sub i64 [[TMP84]], [[TMP85]]
+// CHECK-NEXT:[[TMP87:%.*]] = sdiv exact i64 [[TMP86]], ptrtoint (p

[PATCH] D145892: [SemaCXX]use CorrectDelayedTyposInExpr in ActOnCXXFoldExpr only when Diag

2023-03-14 Thread Congcong Cai via Phabricator via cfe-commits
HerrCai0907 added a comment.

HerrCai0907 and congcongcai0...@163.com

Thanks a lot!


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

https://reviews.llvm.org/D145892

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


[PATCH] D145883: [Flang][RISCV] Emit target features for RISC-V

2023-03-14 Thread Shao-Ce SUN via Phabricator via cfe-commits
sunshaoce added a comment.

Any other opinions? If not, I will land it later.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145883

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


[PATCH] D145892: [SemaCXX]use CorrectDelayedTyposInExpr in ActOnCXXFoldExpr only when Diag

2023-03-14 Thread Congcong Cai via Phabricator via cfe-commits
HerrCai0907 added a comment.

Hello Erichkeane, I have the access now, maybe I can push it by myself. Thanks 
again!


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

https://reviews.llvm.org/D145892

___
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-03-14 Thread Luís Marques via Phabricator via cfe-commits
luismarques added inline comments.



Comment at: clang/test/CodeGen/RISCV/abi-empty-structs.c:21-22
 
 // Fields containing empty structs or unions are ignored when flattening
 // structs for the hard FP ABIs, even in C++.
-// FIXME: This isn't currently respected.

Shouldn't you mention the array exception here? (which you now cover in 
`test_s7` and `test_s8`).


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] D145892: [SemaCXX]use CorrectDelayedTyposInExpr in ActOnCXXFoldExpr only when Diag

2023-03-14 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

In D145892#4193522 , @HerrCai0907 
wrote:

> Hello Erichkeane, I have the access now, maybe I can push it by myself. 
> Thanks again!

Alright, let me know if you need any help!
-Erich


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

https://reviews.llvm.org/D145892

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


[PATCH] D144976: [clangd] Add provider info on symbol hover.

2023-03-14 Thread Viktoriia Bakalova via Phabricator via cfe-commits
VitaNuo updated this revision to Diff 505147.
VitaNuo added a comment.
Herald added a subscriber: ChuanqiXu.

Re-work the patch to use include_cleaner::headersForSymbol.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144976

Files:
  clang-tools-extra/clangd/Hover.cpp
  clang-tools-extra/clangd/Hover.h
  clang-tools-extra/clangd/IncludeCleaner.cpp
  clang-tools-extra/clangd/IncludeCleaner.h
  clang-tools-extra/clangd/Preamble.cpp
  clang-tools-extra/clangd/unittests/HoverTests.cpp
  clang-tools-extra/include-cleaner/include/clang-include-cleaner/Analysis.h

Index: clang-tools-extra/include-cleaner/include/clang-include-cleaner/Analysis.h
===
--- clang-tools-extra/include-cleaner/include/clang-include-cleaner/Analysis.h
+++ clang-tools-extra/include-cleaner/include/clang-include-cleaner/Analysis.h
@@ -13,9 +13,11 @@
 
 #include "clang-include-cleaner/Record.h"
 #include "clang-include-cleaner/Types.h"
+#include "clang/Basic/SourceLocation.h"
 #include "clang/Format/Format.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/STLFunctionalExtras.h"
+#include "llvm/ADT/SmallVector.h"
 #include "llvm/Support/MemoryBufferRef.h"
 #include 
 
@@ -75,6 +77,14 @@
 
 std::string spellHeader(const Header &H, HeaderSearch &HS,
 const FileEntry *Main);
+
+/// Gets all the providers for a symbol by traversing each location.
+/// Returned headers are sorted by relevance, first element is the most
+/// likely provider for the symbol.
+llvm::SmallVector headersForSymbol(const Symbol &S,
+   const SourceManager &SM,
+   const PragmaIncludes *PI);
+
 } // namespace include_cleaner
 } // namespace clang
 
Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -14,11 +14,12 @@
 #include "TestTU.h"
 #include "index/MemIndex.h"
 #include "clang/AST/Attr.h"
+#include "clang/Format/Format.h"
 #include "clang/Index/IndexSymbol.h"
 #include "llvm/ADT/StringRef.h"
 
-#include "gmock/gmock.h"
 #include "gtest/gtest.h"
+#include 
 #include 
 #include 
 
@@ -28,6 +29,10 @@
 
 using PassMode = HoverInfo::PassType::PassMode;
 
+std::string guard(llvm::StringRef Code) {
+  return "#pragma once\n" + Code.str();
+}
+
 TEST(Hover, Structured) {
   struct {
 const char *const Code;
@@ -2882,6 +2887,280 @@
   }
 }
 
+TEST(Hover, Providers) {
+  struct {
+Annotations Code;
+llvm::StringLiteral FooHeader;
+llvm::StringLiteral BarHeader;
+llvm::StringLiteral FooBarHeader;
+const std::function ExpectedBuilder;
+  } Cases[] = {
+  {Annotations(
+   R"cpp(
+  struct Foo {}; 
+  Foo F = [[Fo^o]]{};
+)cpp"),
+   "int foo();", "", "", [](HoverInfo &HI) { HI.Provider = ""; }},
+  {Annotations(
+   R"cpp(
+  #include "foo.h"
+  int F = [[fo^o]]();
+)cpp"),
+   "int foo();", "", "", [](HoverInfo &HI) { HI.Provider = "\"foo.h\""; }},
+  {Annotations(
+   R"cpp(
+  #include "bar.h"
+  #include "foo.h"
+  int F = [[f^oo]]();
+)cpp"),
+   "int foo();", "int foo();", "",
+   [](HoverInfo &HI) { HI.Provider = "\"foo.h\""; }},
+  {Annotations(
+   R"cpp(
+  #include "bar.h"
+  #include "foo.h"
+  int F = [[^foo]]();
+)cpp"),
+   "int foo();", "#include \"foobar.h\"", "int foo();",
+   [](HoverInfo &HI) { HI.Provider = "\"foo.h\""; }},
+  {Annotations(
+   R"cpp(
+  #include "bar.h"
+  #include "foo.h"
+  #include "foobar.h"
+  int F = [[^foo]]();
+)cpp"),
+   "int foo();", "int foo();", "#include \"bar.h\"",
+   [](HoverInfo &HI) { HI.Provider = "\"foo.h\""; }},
+  {Annotations(
+   R"cpp(
+  #include "bar.h"
+  #include "foo.h"
+  #include "foobar.h"
+  int F = [[foo^]]();
+)cpp"),
+   "int foo();", "#include \"foo.h\"", "#include \"foo.h\"",
+   [](HoverInfo &HI) { HI.Provider = "\"foo.h\""; }},
+   {Annotations(
+   R"cpp(
+ #include "foo.h"
+
+ Foo [[f^oo]] = 42;
+)cpp"),
+   R"cpp(
+class Foo {
+  public:
+  Foo(int val): val(val) {}
+  private:
+int val;
+};
+   )cpp", "", "", [](HoverInfo &HI) { HI.Provider = ""; }},
+   {Annotations(
+ 

[PATCH] D144844: [C++20] [Modules] Offer -fno-import-inter-module-function-defs to avoid duplicated compilation in modules

2023-03-14 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

Seem to recall @iains and others were concerned about the number of modules 
flags - this one I'd be inclined to suggest we shouldn't add if possible. If 
one way or the other is generally better - we should, at least initially, 
dictate that behavior entirely until someone can demonstrate divergent use 
cases that seem reasonable to support but must have different behavior here.

The performance of cross-module inlining could be achieved with something like 
ThinLTO if we were to lean in favor of not allowing cross-module inlining by 
default, for instance.

But if there are particular idioms where cross-module inlining is 
disadvantageous, perhaps we can implement better ways for clang to detect them 
(or if they're undetectable, offer users a way to annotate their code, maybe).

Could we key off -Os or -Oz or some other existing optimization/compile time 
tradeoff flags instead of introducing a new flag?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144844

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


[PATCH] D145238: [NVPTX] Expose LDU builtins

2023-03-14 Thread Artem Belevich via Phabricator via cfe-commits
tra accepted this revision.
tra added a comment.
This revision is now accepted and ready to land.

LGTM with a test nit.




Comment at: llvm/test/CodeGen/NVPTX/ldu-ldg.ll:30
 
+; CHECK: test_ldu_i16
+define i16 @test_ldu_i16(ptr addrspace(1) %ptr) {

Nit. Function names usually checked with `CHECK-LABEL`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145238

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


[PATCH] D144976: [clangd] Add provider info on symbol hover.

2023-03-14 Thread Viktoriia Bakalova via Phabricator via cfe-commits
VitaNuo marked an inline comment as done.
VitaNuo added a comment.

Thanks for the comments!




Comment at: clang-tools-extra/clangd/Hover.cpp:1099
+  trace::Span Tracer("Hover::maybeAddSymbolProviders");
+  include_cleaner::walkUsed(
+  AST.getLocalTopLevelDecls(), MacroReferences, AST.getPragmaIncludes(),

hokein wrote:
> It seems that the `walkUsed` API might be not the best fit. `walkUsed` API 
> has some special logic on handling different AST nodes, e.g. refs of 
> operators are ignored, so if we hover on an operator ref, we will not show 
> the providing header (which we should).
> 
> Our goal is to provide the information (header) where the symbol under the 
> hover comes from (ref satisfaction is out of the scope). I think 
> `include_cleaner::headersForSymbol` is a better fit for our purpose, and the 
> implementation is simpler:
> 
> - on hover, we have the selected symbol (either a regular declaration or a 
> macro)
> - it is easy to construct a `include_cleaner::Symbol` from the selected symbol
> - choose the first result from `headersForSymbol`
> 
> To do that we need to expose `headersForSymbol` from the internal 
> `AnalysisInternal.h`.
Thank you! I am using `headersForSymbols` now.

Ref satisfaction is not entirely out of scope.
If the provider is included, we would like to show this provider in the hover 
card, irrespective of the ranking.

If the provider is not included, we show the best provider from the whole list 
of possible providers.

The behavior is different, based on ref satisfaction.
Because of that, the implementation is actually not that much shorter than the 
version with `walkUsed`.

However, you're right that it solves the issue with operators (wasn't aware of 
that, thanks!). I've added a test case for the hover on operators.

As an additional bonus, it also solves the issue with `using` decls as 
discussed in a different comment thread below. We can now say `Provided by 
` in the hover card that pops up for the `absl::string_view` 
references because we are doing the analysis on the `std::string_view` decl.



Comment at: clang-tools-extra/clangd/Hover.cpp:1140
+// Check that the user is hovering over the current symbol reference.
+if (CurLoc < Ref.RefLocation || CurLoc > RefEndLocation) {
+  return;

VitaNuo wrote:
> hokein wrote:
> > We're using the location as a heuristic to join the symbol (Decl) from two 
> > difference sources (clangd's hover impl, and include-cleaner lib impl)
> > 
> > This heuristics works most of time, but it will fail in the case where the 
> > symbol under the hover is a `UsingDecl`
> > 
> > ```
> > // absl_string_view.h
> > namespace absl {
> > using std::string_view;
> > }
> > 
> > // main.cpp
> > #includle "absl_string_view.h"
> > absl::str^ing_view abc; // hover on string_view
> > ```
> > 
> > - clangd's hover uses the underlying decl (std::string_view), see the 
> > `pickDeclToUse` function for details;
> > - include-cleaner lib reports the using decl (asbl::string_view);
> > 
> > As a result, we will show the #include of the using decl for the underlying 
> > decl in the hover card.
> > 
> > To solve the issue, I think we need to check the equality of Decl from 
> > hover and Decl from `SymbolReference` (comparing both `getCanonicalDecl` 
> > should be enough).
> > 
> Interesting case. I've tried it out, you're right indeed. And it seems like 
> there's no way to pick the standard library header as provider, since 
> include-cleaner doesn't report it (the absl header is the only candidate).
> 
> I guess we'll skip providing the header info in this case then.
> 
> 
> We're using the location as a heuristic to join the symbol (Decl) from two 
> difference sources (clangd's hover impl, and include-cleaner lib impl)
> 
> This heuristics works most of time, but it will fail in the case where the 
> symbol under the hover is a `UsingDecl`
> 
> ```
> // absl_string_view.h
> namespace absl {
> using std::string_view;
> }
> 
> // main.cpp
> #includle "absl_string_view.h"
> absl::str^ing_view abc; // hover on string_view
> ```
> 
> - clangd's hover uses the underlying decl (std::string_view), see the 
> `pickDeclToUse` function for details;
> - include-cleaner lib reports the using decl (asbl::string_view);
> 
> As a result, we will show the #include of the using decl for the underlying 
> decl in the hover card.
> 
> To solve the issue, I think we need to check the equality of Decl from hover 
> and Decl from `SymbolReference` (comparing both `getCanonicalDecl` should be 
> enough).
> 




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144976

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


[PATCH] D144870: [Clang][DebugInfo] Emit zero size bitfields in the debug info to delimit bitfields in different allocation units.

2023-03-14 Thread Juan Manuel Martinez Caamaño via Phabricator via cfe-commits
jmmartinez updated this revision to Diff 505148.
jmmartinez added a comment.

Update:

- Took into account remarks and got my ideas straight.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144870

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDebugInfo.h
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/CodeGen/TargetInfo.h
  clang/test/CodeGen/debug-info-bitfield-0-struct.c

Index: clang/test/CodeGen/debug-info-bitfield-0-struct.c
===
--- /dev/null
+++ clang/test/CodeGen/debug-info-bitfield-0-struct.c
@@ -0,0 +1,106 @@
+// RUN: %clang_cc1 -triple x86_64-unk-unk -o - -emit-llvm -debug-info-kind=limited %s | FileCheck --check-prefixes NOSEPARATOR,BOTH %s
+// RUN: %clang_cc1 -triple amdgcn-unk-unk -o - -emit-llvm -debug-info-kind=limited %s | FileCheck --check-prefixes SEPARATOR,BOTH %s
+
+struct First {
+  // BOTH-DAG: ![[FIRST:[0-9]+]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "First", file: !{{[0-9]+}}, line: {{[0-9]+}}, size: 32, elements: ![[FIRST_ELEMENTS:[0-9]+]])
+  // BOTH-DAG: ![[FIRST_ELEMENTS]] = !{![[FIRST_X:[0-9]+]], ![[FIRST_Y:[0-9]+]]}
+  // BOTH-DAG: ![[FIRST_X]] = !DIDerivedType(tag: DW_TAG_member, name: "x", scope: ![[FIRST]], file: !{{[0-9]+}}, line: {{[0-9]+}}, baseType: !{{[0-9]+}}, size: 4, flags: DIFlagBitField, extraData: i64 0)
+  // BOTH-DAG: ![[FIRST_Y]] = !DIDerivedType(tag: DW_TAG_member, name: "y", scope: ![[FIRST]], file: !{{[0-9]+}}, line: {{[0-9]+}}, baseType: !{{[0-9]+}}, size: 4, offset: 4, flags: DIFlagBitField, extraData: i64 0)
+  int : 0;
+  int x : 4;
+  int y : 4;
+};
+
+struct FirstDuplicate {
+  // BOTH-DAG: ![[FIRSTD:[0-9]+]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "FirstDuplicate", file: !{{[0-9]+}}, line: {{[0-9]+}}, size: 32, elements: ![[FIRSTD_ELEMENTS:[0-9]+]])
+  // BOTH-DAG: ![[FIRSTD_ELEMENTS]] = !{![[FIRSTD_X:[0-9]+]], ![[FIRSTD_Y:[0-9]+]]}
+  // BOTH-DAG: ![[FIRSTD_X]] = !DIDerivedType(tag: DW_TAG_member, name: "x", scope: ![[FIRSTD]], file: !{{[0-9]+}}, line: {{[0-9]+}}, baseType: !{{[0-9]+}}, size: 4, flags: DIFlagBitField, extraData: i64 0)
+  // BOTH-DAG: ![[FIRSTD_Y]] = !DIDerivedType(tag: DW_TAG_member, name: "y", scope: ![[FIRSTD]], file: !{{[0-9]+}}, line: {{[0-9]+}}, baseType: !{{[0-9]+}}, size: 4, offset: 4, flags: DIFlagBitField, extraData: i64 0)
+  int : 0;
+  int : 0;
+  int x : 4;
+  int y : 4;
+};
+
+struct Second {
+  // BOTH-DAG: ![[SECOND:[0-9]+]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Second", file: !{{[0-9]+}}, line: {{[0-9]+}}, size: 64, elements: ![[SECOND_ELEMENTS:[0-9]+]])
+
+  // NOSEPARATOR-DAG: ![[SECOND_ELEMENTS]] = !{![[SECOND_X:[0-9]+]], ![[SECOND_Y:[0-9]+]]}
+  // SEPARATOR-DAG: ![[SECOND_ELEMENTS]] = !{![[SECOND_X:[0-9]+]], ![[SECOND_ZERO:[0-9]+]], ![[SECOND_Y:[0-9]+]]}
+
+  // BOTH-DAG: ![[SECOND_X]] = !DIDerivedType(tag: DW_TAG_member, name: "x", scope: ![[SECOND]], file: !{{[0-9]+}}, line: {{[0-9]+}}, baseType: !{{[0-9]+}}, size: 4, flags: DIFlagBitField, extraData: i64 0)
+  // SEPARATOR-DAG: ![[SECOND_ZERO]] = !DIDerivedType(tag: DW_TAG_member, scope: ![[SECOND]], file: !{{[0-9]+}}, line: {{[0-9]+}}, baseType: !{{[0-9]+}}, offset: 32, flags: DIFlagBitField, extraData: i64 32)
+  // BOTH-DAG: ![[SECOND_Y]] = !DIDerivedType(tag: DW_TAG_member, name: "y", scope: ![[SECOND]], file: !{{[0-9]+}}, line: {{[0-9]+}}, baseType: !{{[0-9]+}}, size: 4, offset: 32, flags: DIFlagBitField, extraData: i64 32)
+  int x : 4;
+  int : 0;
+  int y : 4;
+};
+
+struct SecondDuplicate {
+  // BOTH-DAG: ![[SECONDD:[0-9]+]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "SecondDuplicate", file: !{{[0-9]+}}, line: {{[0-9]+}}, size: 64, elements: ![[SECONDD_ELEMENTS:[0-9]+]])
+
+  // NOSEPARATOR-DAG: ![[SECONDD_ELEMENTS]] = !{![[SECONDD_X:[0-9]+]], ![[SECONDD_Y:[0-9]+]]}
+  // SEPARATOR-DAG: ![[SECONDD_ELEMENTS]] = !{![[SECONDD_X:[0-9]+]], ![[SECONDD_ZERO:[0-9]+]], ![[SECONDD_Y:[0-9]+]]}
+
+  // BOTH-DAG: ![[SECONDD_X]] = !DIDerivedType(tag: DW_TAG_member, name: "x", scope: ![[SECONDD]], file: !{{[0-9]+}}, line: {{[0-9]+}}, baseType: !{{[0-9]+}}, size: 4, flags: DIFlagBitField, extraData: i64 0)
+  // SEPARATOR-DAG: ![[SECONDD_ZERO]] = !DIDerivedType(tag: DW_TAG_member, scope: ![[SECONDD]], file: !{{[0-9]+}}, line: {{[0-9]+}}, baseType: !{{[0-9]+}}, offset: 32, flags: DIFlagBitField, extraData: i64 32)
+  // BOTH-DAG: ![[SECONDD_Y]] = !DIDerivedType(tag: DW_TAG_member, name: "y", scope: ![[SECONDD]], file: !{{[0-9]+}}, line: {{[0-9]+}}, baseType: !{{[0-9]+}}, size: 4, offset: 32, flags: DIFlagBitField, extraData: i64 32)
+  int x : 4;
+  int : 0;
+  int : 0;
+  int y : 4;
+};
+
+struct Last {
+  // BOTH-DAG: ![[LAST:[0-9]+]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Last", file: !{{[0-9]+}}, line: {{[0-9]+}}, size: 32, elements: ![[LAST_ELEMENTS:[0-9]+]])
+  // BOTH-DAG: ![[LAST_

[PATCH] D144709: [clang-format] Improve QualifierAlignment

2023-03-14 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

In D144709#4188921 , 
@AlexanderHederstaf wrote:

> What is the next step in the process? Anything I should do?

If you have commit access you can go ahead and commit, if not and you want one 
of us to do it, we need your name and email address


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144709

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


[clang] e417f02 - [SemaCXX]use CorrectDelayedTyposInExpr in ActOnCXXFoldExpr only when Diag

2023-03-14 Thread Congcong Cai via cfe-commits

Author: Congcong Cai
Date: 2023-03-15T01:08:41+08:00
New Revision: e417f02b5159c13f011335636faaf8c6847b627f

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

LOG: [SemaCXX]use CorrectDelayedTyposInExpr in ActOnCXXFoldExpr only when Diag

PR #61326

- fix clang crash when fold expression contains a delayed typos correction.

code snippet in `ActOnCXXFoldExpr`
```  if (!LHS || !RHS) {
Expr *Pack = LHS ? LHS : RHS;
assert(Pack && "fold expression with neither LHS nor RHS");
DiscardOperands();
if (!Pack->containsUnexpandedParameterPack())
  return Diag(EllipsisLoc, diag::err_pack_expansion_without_parameter_packs)
 << Pack->getSourceRange();
  }
```
`DiscardOperands` will be triggered when LHS/RHS is delayed typo correction 
expression.
It will output and clean all diagnose but still return a valid expression. (in 
else branch)
valid expression will be handled in caller function. When caller wants to 
output the diagnose, the diagnose in delayed typo correction expression has 
been consumed in `ActOnCXXFoldExpr`. It causes clang crash.

Reviewed By: erichkeane

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

Added: 
clang/test/SemaCXX/fold_expr_typo.cpp

Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/Sema/SemaTemplateVariadic.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index a52af53bbd28..5fae7ce3077a 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -197,6 +197,8 @@ Bug Fixes in This Version
   be reached despite being reachable. This fixes
   `#61177 `_ in anticipation
   of `CWG2699 _` being accepted by WG21.
+- Fix crash when parsing fold expression containing a delayed typo correction.
+  (`#61326 `_)
 
 Bug Fixes to Compiler Builtins
 ^^

diff  --git a/clang/lib/Sema/SemaTemplateVariadic.cpp 
b/clang/lib/Sema/SemaTemplateVariadic.cpp
index 86268b504cbb..dfcc78dafdc4 100644
--- a/clang/lib/Sema/SemaTemplateVariadic.cpp
+++ b/clang/lib/Sema/SemaTemplateVariadic.cpp
@@ -1220,10 +1220,11 @@ ExprResult Sema::ActOnCXXFoldExpr(Scope *S, 
SourceLocation LParenLoc, Expr *LHS,
   if (!LHS || !RHS) {
 Expr *Pack = LHS ? LHS : RHS;
 assert(Pack && "fold expression with neither LHS nor RHS");
-DiscardOperands();
-if (!Pack->containsUnexpandedParameterPack())
+if (!Pack->containsUnexpandedParameterPack()) {
+  DiscardOperands();
   return Diag(EllipsisLoc, 
diag::err_pack_expansion_without_parameter_packs)
  << Pack->getSourceRange();
+}
   }
 
   BinaryOperatorKind Opc = ConvertTokenKindToBinaryOpcode(Operator);

diff  --git a/clang/test/SemaCXX/fold_expr_typo.cpp 
b/clang/test/SemaCXX/fold_expr_typo.cpp
new file mode 100644
index ..0ef9c15b5947
--- /dev/null
+++ b/clang/test/SemaCXX/fold_expr_typo.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++17 %s
+
+template 
+void foo(T &&...Params) {
+  foo(Unknown); // expected-error {{expression contains unexpanded 
parameter pack 'T'}}\
+  expected-error {{use of undeclared identifier 'Unknown'}}
+  ((foo(Unknown)), ...); // expected-error {{use of undeclared identifier 
'Unknown'}}
+}
+
+template  struct A {
+  template  void foo(T &&...Params) {
+foo((... + static_cast(1))); // expected-error {{expression contains 
unexpanded parameter pack 'T'}}
+  }
+};



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


[PATCH] D145888: [clang-format] Fix non-case colons in Verilog case lines

2023-03-14 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added inline comments.



Comment at: clang/lib/Format/TokenAnnotator.cpp:4424
-if (Line.First->isOneOf(tok::kw_default, tok::kw_case))
-  return Style.SpaceBeforeCaseColon;
 const FormatToken *Next = Right.getNextNonComment();

Hmm.. this is going to impact others, did you make a change here before and 
break something for c++? or was this a bug in the C++ code, is there not a unit 
test for setting SpaceBeforeCaseColon? 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145888

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


[PATCH] D145892: [SemaCXX]use CorrectDelayedTyposInExpr in ActOnCXXFoldExpr only when Diag

2023-03-14 Thread Congcong Cai 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 rGe417f02b5159: [SemaCXX]use CorrectDelayedTyposInExpr in 
ActOnCXXFoldExpr only when Diag (authored by HerrCai0907).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145892

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaTemplateVariadic.cpp
  clang/test/SemaCXX/fold_expr_typo.cpp


Index: clang/test/SemaCXX/fold_expr_typo.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/fold_expr_typo.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++17 %s
+
+template 
+void foo(T &&...Params) {
+  foo(Unknown); // expected-error {{expression contains unexpanded 
parameter pack 'T'}}\
+  expected-error {{use of undeclared identifier 'Unknown'}}
+  ((foo(Unknown)), ...); // expected-error {{use of undeclared identifier 
'Unknown'}}
+}
+
+template  struct A {
+  template  void foo(T &&...Params) {
+foo((... + static_cast(1))); // expected-error {{expression contains 
unexpanded parameter pack 'T'}}
+  }
+};
Index: clang/lib/Sema/SemaTemplateVariadic.cpp
===
--- clang/lib/Sema/SemaTemplateVariadic.cpp
+++ clang/lib/Sema/SemaTemplateVariadic.cpp
@@ -1220,10 +1220,11 @@
   if (!LHS || !RHS) {
 Expr *Pack = LHS ? LHS : RHS;
 assert(Pack && "fold expression with neither LHS nor RHS");
-DiscardOperands();
-if (!Pack->containsUnexpandedParameterPack())
+if (!Pack->containsUnexpandedParameterPack()) {
+  DiscardOperands();
   return Diag(EllipsisLoc, 
diag::err_pack_expansion_without_parameter_packs)
  << Pack->getSourceRange();
+}
   }
 
   BinaryOperatorKind Opc = ConvertTokenKindToBinaryOpcode(Operator);
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -197,6 +197,8 @@
   be reached despite being reachable. This fixes
   `#61177 `_ in anticipation
   of `CWG2699 _` being accepted by WG21.
+- Fix crash when parsing fold expression containing a delayed typo correction.
+  (`#61326 `_)
 
 Bug Fixes to Compiler Builtins
 ^^


Index: clang/test/SemaCXX/fold_expr_typo.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/fold_expr_typo.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++17 %s
+
+template 
+void foo(T &&...Params) {
+  foo(Unknown); // expected-error {{expression contains unexpanded parameter pack 'T'}}\
+  expected-error {{use of undeclared identifier 'Unknown'}}
+  ((foo(Unknown)), ...); // expected-error {{use of undeclared identifier 'Unknown'}}
+}
+
+template  struct A {
+  template  void foo(T &&...Params) {
+foo((... + static_cast(1))); // expected-error {{expression contains unexpanded parameter pack 'T'}}
+  }
+};
Index: clang/lib/Sema/SemaTemplateVariadic.cpp
===
--- clang/lib/Sema/SemaTemplateVariadic.cpp
+++ clang/lib/Sema/SemaTemplateVariadic.cpp
@@ -1220,10 +1220,11 @@
   if (!LHS || !RHS) {
 Expr *Pack = LHS ? LHS : RHS;
 assert(Pack && "fold expression with neither LHS nor RHS");
-DiscardOperands();
-if (!Pack->containsUnexpandedParameterPack())
+if (!Pack->containsUnexpandedParameterPack()) {
+  DiscardOperands();
   return Diag(EllipsisLoc, diag::err_pack_expansion_without_parameter_packs)
  << Pack->getSourceRange();
+}
   }
 
   BinaryOperatorKind Opc = ConvertTokenKindToBinaryOpcode(Operator);
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -197,6 +197,8 @@
   be reached despite being reachable. This fixes
   `#61177 `_ in anticipation
   of `CWG2699 _` being accepted by WG21.
+- Fix crash when parsing fold expression containing a delayed typo correction.
+  (`#61326 `_)
 
 Bug Fixes to Compiler Builtins
 ^^
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D144878: __builtin_FILE_NAME()

2023-03-14 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/docs/ReleaseNotes.rst:113-114
   nondeterministic value of the same type as the provided argument.
+- Clang now supports ``__builtin_FILE_NAME`` that returns a
+  ``__FILE_NAME__`` value at the "invocation point".
 





Comment at: clang/include/clang/AST/Expr.h:4689
 /// Represents a function call to one of __builtin_LINE(), __builtin_COLUMN(),
-/// __builtin_FUNCTION(), __builtin_FILE(), or __builtin_source_location().
+/// __builtin_FUNCTION(), __builtin_FILE(), builtin_FILE_NAME(),
+/// or __builtin_source_location().





Comment at: clang/lib/AST/Expr.cpp:2283-2284
+  case SourceLocExpr::FileName: {
+// builtin_FILE_NAME() is a Clang-specific extension that expands to the
+// the last part of builtin_FILE().
+SmallString<256> FileName;





Comment at: clang/lib/Lex/PPMacroExpansion.cpp:2000-2002
+  if (PLFileName.empty()) {
+PLFileName = PLoc.getFilename();
+  }

Minor coding style nit.



Comment at: clang/lib/Parse/ParseExpr.cpp:805-816
+/// [C++11] simple-type-specifier braced-init-list [C++11 5.2.3] [C++]
+/// typename-specifier '(' expression-list[opt] ')' [C++ 5.2.3] [C++11]
+/// typename-specifier braced-init-list [C++11 5.2.3] [C++]
+/// 'const_cast' '<' type-name '>' '(' expression ')'   [C++ 5.2p1] [C++]
+/// 'dynamic_cast' '<' type-name '>' '(' expression ')' [C++ 5.2p1] [C++]
+/// 'reinterpret_cast' '<' type-name '>' '(' expression ')' [C++ 5.2p1] [C++]
+/// 'static_cast' '<' type-name '>' '(' expression ')'  [C++ 5.2p1] [C++]

It looks like the formatting here got wrecked, you should back these changes 
out.


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

https://reviews.llvm.org/D144878

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


[PATCH] D144569: [Clang][OpenMP] Fix accessing of aligned arrays in offloaded target regions

2023-03-14 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
doru1004 updated this revision to Diff 505157.
Herald added a subscriber: sunshaoce.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144569

Files:
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/amdgpu_target_with_aligned_attribute.c
  clang/test/OpenMP/parallel_firstprivate_codegen.cpp
  clang/test/OpenMP/parallel_master_taskloop_firstprivate_codegen.cpp
  clang/test/OpenMP/parallel_master_taskloop_simd_firstprivate_codegen.cpp
  clang/test/OpenMP/target_firstprivate_codegen.cpp
  clang/test/OpenMP/target_is_device_ptr_codegen.cpp
  clang/test/OpenMP/teams_firstprivate_codegen.cpp

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


[PATCH] D146069: [StandardInstrumentations] Rename -verify-cfg-preserved -> -verify-preserved-analyses

2023-03-14 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks created this revision.
aeubanks added a reviewer: yrouban.
Herald added subscribers: ormris, wenlei, steven_wu, hiraditya.
Herald added a project: All.
aeubanks requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

In preparation for adding more checks under this flag.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D146069

Files:
  clang/test/CodeGen/lto-newpm-pipeline.c
  llvm/lib/Passes/StandardInstrumentations.cpp
  llvm/test/Other/loop-pm-invalidation.ll
  llvm/test/Other/new-pass-manager.ll
  llvm/test/Other/new-pm-O0-defaults.ll
  llvm/test/Other/new-pm-defaults.ll
  llvm/test/Other/new-pm-lto-defaults.ll
  llvm/test/Other/new-pm-thinlto-defaults.ll
  llvm/test/Other/new-pm-thinlto-postlink-pgo-defaults.ll
  llvm/test/Other/new-pm-thinlto-postlink-samplepgo-defaults.ll
  llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll
  llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll
  llvm/test/Transforms/ConstraintElimination/analysis-invalidation.ll
  llvm/test/Transforms/LoopRotate/pr35210.ll
  
llvm/test/Transforms/SimpleLoopUnswitch/nontrivial-unswitch-markloopasdeleted.ll

Index: llvm/test/Transforms/SimpleLoopUnswitch/nontrivial-unswitch-markloopasdeleted.ll
===
--- llvm/test/Transforms/SimpleLoopUnswitch/nontrivial-unswitch-markloopasdeleted.ll
+++ llvm/test/Transforms/SimpleLoopUnswitch/nontrivial-unswitch-markloopasdeleted.ll
@@ -1,4 +1,4 @@
-; RUN: opt < %s -enable-loop-distribute -passes='loop-distribute,loop-mssa(simple-loop-unswitch),loop-distribute' -o /dev/null -S -verify-cfg-preserved -debug-pass-manager=verbose 2>&1 | FileCheck %s
+; RUN: opt < %s -enable-loop-distribute -passes='loop-distribute,loop-mssa(simple-loop-unswitch),loop-distribute' -o /dev/null -S -verify-preserved-analyses -debug-pass-manager=verbose 2>&1 | FileCheck %s
 
 
 ; Running loop-distribute will result in LoopAccessAnalysis being required and
Index: llvm/test/Transforms/LoopRotate/pr35210.ll
===
--- llvm/test/Transforms/LoopRotate/pr35210.ll
+++ llvm/test/Transforms/LoopRotate/pr35210.ll
@@ -1,5 +1,5 @@
-;RUN: opt %s -aa-pipeline= -passes='adce,loop(loop-rotate),adce' -S -verify-cfg-preserved=0 -debug-pass-manager -debug-only=loop-rotate 2>&1 | FileCheck %s
-;RUN: opt %s -aa-pipeline= -passes='adce,loop-mssa(loop-rotate),adce' -S -verify-cfg-preserved=0 -debug-pass-manager -debug-only=loop-rotate -verify-memoryssa 2>&1 | FileCheck %s --check-prefix=MSSA
+;RUN: opt %s -aa-pipeline= -passes='adce,loop(loop-rotate),adce' -S -verify-preserved-analyses=0 -debug-pass-manager -debug-only=loop-rotate 2>&1 | FileCheck %s
+;RUN: opt %s -aa-pipeline= -passes='adce,loop-mssa(loop-rotate),adce' -S -verify-preserved-analyses=0 -debug-pass-manager -debug-only=loop-rotate -verify-memoryssa 2>&1 | FileCheck %s --check-prefix=MSSA
 ;REQUIRES: asserts
 
 ; This test is to make sure we invalidate the post dominator pass after loop rotate simplifies the loop latch.
Index: llvm/test/Transforms/ConstraintElimination/analysis-invalidation.ll
===
--- llvm/test/Transforms/ConstraintElimination/analysis-invalidation.ll
+++ llvm/test/Transforms/ConstraintElimination/analysis-invalidation.ll
@@ -1,4 +1,4 @@
-; RUN: opt -passes='require,constraint-elimination,require' -disable-verify -verify-cfg-preserved=false -debug-pass-manager -disable-output %s 2>&1 | FileCheck %s
+; RUN: opt -passes='require,constraint-elimination,require' -disable-verify -verify-preserved-analyses=false -debug-pass-manager -disable-output %s 2>&1 | FileCheck %s
 
 ; Check that constraint-elimination properly invalidates anlyses.
 
Index: llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll
===
--- llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll
+++ llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll
@@ -1,26 +1,26 @@
 ; Validate ThinLTO prelink pipeline when we have Sample PGO
 ;
-; RUN: opt -disable-verify -verify-cfg-preserved=0 -eagerly-invalidate-analyses=0 -debug-pass-manager \
+; RUN: opt -disable-verify -verify-preserved-analyses=0 -eagerly-invalidate-analyses=0 -debug-pass-manager \
 ; RUN: -pgo-kind=pgo-sample-use-pipeline -profile-file='%S/Inputs/new-pm-thinlto-samplepgo-defaults.prof' \
 ; RUN: -passes='thinlto-pre-link' -S %s 2>&1 \
 ; RUN: | FileCheck %s --check-prefixes=CHECK-O,CHECK-O123,CHECK-O1
-; RUN: opt -disable-verify -verify-cfg-preserved=0 -eagerly-invalidate-analyses=0 -debug-pass-manager \
+; RUN: opt -disable-verify -verify-preserved-analyses=0 -eagerly-invalidate-analyses=0 -debug-pass-manager \
 ; RUN: -pgo-kind=pgo-sample-use-pipeline -profile-file='%S/Inputs/new-pm-thinlto-samplepgo-defaults.prof' \
 ; RUN: -passes='thinlto-pre-link' 

[PATCH] D145227: [LLVM][OHOS] Clang toolchain and targets

2023-03-14 Thread Daniel Thornburgh via Phabricator via cfe-commits
mysterymath added a comment.

This is also causing a breakage on the Linux and Mac Fuchsia toolchain builds:
https://luci-milo.appspot.com/ui/p/fuchsia/builders/toolchain.ci/clang-linux-x64/b8786633328903858561/overview


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145227

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


[PATCH] D144844: [C++20] [Modules] Offer -fno-import-inter-module-function-defs to avoid duplicated compilation in modules

2023-03-14 Thread Iain Sandoe via Phabricator via cfe-commits
iains added a comment.

In D144844#4193568 , @dblaikie wrote:

> Seem to recall @iains and others were concerned about the number of modules 
> flags - this one I'd be inclined to suggest we shouldn't add if possible. If 
> one way or the other is generally better - we should, at least initially, 
> dictate that behavior entirely until someone can demonstrate divergent use 
> cases that seem reasonable to support but must have different behavior here.

Agreed, [IMO, at least] we have a very large set of modules options, and 
expanding that should only be done if no sensible alternative can be found (we 
are already seeing users getting confused about which ones apply in each case).

A second point here - that (once we have the ability to generate object and PCM 
in the same compilation) that we will move to elide the function bodies for 
non-inline and non-dependent cases from the PCM, so that this problem will 
magically "go away" (to restore the current behaviour, we'd then be using some 
optimisation control to avoid the elision, I suppose).

> The performance of cross-module inlining could be achieved with something 
> like ThinLTO if we were to lean in favor of not allowing cross-module 
> inlining by default, for instance.

+1 this seems exactly what LTO is intended for (also there are folks who seem 
to have an expectation that the BMI somehow magically contains an optimised 
representation of the source - which again is the province of LTO).

> But if there are particular idioms where cross-module inlining is 
> disadvantageous, perhaps we can implement better ways for clang to detect 
> them (or if they're undetectable, offer users a way to annotate their code, 
> maybe).

I'd be interested to see an example where cross-module function body imports 
somehow beats the equivalent LTO.

> Could we key off -Os or -Oz or some other existing optimization/compile time 
> tradeoff flags instead of introducing a new flag?

That's an interesting idea .. I'd suggest we should default the behaviour to 
"off" (so that compilation speed is prioritised for default options, as usual) 
and then maybe enable import of function bodie at O3 
 or so? [maybe even an optimisation 
representative of LTO .. so that when we slim the BMIs down we do not get 
complaints about regression in code performance].


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144844

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


[PATCH] D144870: [Clang][DebugInfo] Emit zero size bitfields in the debug info to delimit bitfields in different allocation units.

2023-03-14 Thread Paul Robinson via Phabricator via cfe-commits
probinson added inline comments.



Comment at: clang/lib/CodeGen/CGDebugInfo.cpp:1558
+  EmitSeparator = FieldIt->isBitField();
+  }
+

I might not be following this correctly, but it feels like EmitSeparator will 
end up true if the last field is a bitfield, even if there are no zero-length 
bitfields in front of it. The test does not cover this case (to show that the 
no-zero-bitfields case is handled properly).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144870

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


[PATCH] D145941: [Clang] Always use -zdefs when linking AMDGPU images

2023-03-14 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 updated this revision to Diff 505166.
jhuber6 added a comment.

Adding release notes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145941

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Driver/ToolChains/AMDGPU.cpp
  clang/test/Driver/amdgpu-toolchain-opencl.cl
  clang/test/Driver/amdgpu-toolchain.c


Index: clang/test/Driver/amdgpu-toolchain.c
===
--- clang/test/Driver/amdgpu-toolchain.c
+++ clang/test/Driver/amdgpu-toolchain.c
@@ -6,7 +6,7 @@
 // RUN: %clang -### -g --target=amdgcn-mesa-mesa3d -mcpu=kaveri %s 2>&1 | 
FileCheck -check-prefix=DWARF_VER %s
 
 // AS_LINK: "-cc1as"
-// AS_LINK: ld.lld{{.*}} "-shared"
+// AS_LINK: ld.lld{{.*}} "--no-undefined" "-shared"
 
 // DWARF_VER: "-dwarf-version=5"
 
Index: clang/test/Driver/amdgpu-toolchain-opencl.cl
===
--- clang/test/Driver/amdgpu-toolchain-opencl.cl
+++ clang/test/Driver/amdgpu-toolchain-opencl.cl
@@ -25,3 +25,6 @@
 
 // CHK-INC: "-cc1" {{.*}}"-finclude-default-header" 
"-fdeclare-opencl-builtins" {{.*}}"-x" "cl"
 // CHK-INC-NOT: "-cc1" {{.*}}"-finclude-default-header" 
"-fdeclare-opencl-builtins" {{.*}}"-x" "cpp-output"
+
+// RUN: %clang -### --target=amdgcn-amd-amdhsa-opencl -x cl -emit-llvm 
-mcpu=fiji %s 2>&1 | FileCheck -check-prefix=CHK-LINK %s
+// CHK-LINK: ld.lld{{.*}} "--no-undefined" "-shared"
Index: clang/lib/Driver/ToolChains/AMDGPU.cpp
===
--- clang/lib/Driver/ToolChains/AMDGPU.cpp
+++ clang/lib/Driver/ToolChains/AMDGPU.cpp
@@ -543,6 +543,7 @@
   if (C.getDriver().isUsingLTO())
 addLTOOptions(getToolChain(), Args, CmdArgs, Output, Inputs[0],
   C.getDriver().getLTOMode() == LTOK_Thin);
+  CmdArgs.push_back("--no-undefined");
   CmdArgs.push_back("-shared");
   CmdArgs.push_back("-o");
   CmdArgs.push_back(Output.getFilename());
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -222,6 +222,14 @@
 Target Specific Changes
 ---
 
+AMDGPU Support
+^^
+
+- Linking for AMDGPU now uses ``--no-undefined`` by default. This causes 
+  undefined symbols in the created module to be a linker error. To prevent 
this, 
+  pass ``-Wl,--undefined`` if compiling directly, or ``-Xoffload-linker 
+  --undefined`` if using an offloading language.
+
 X86 Support
 ^^^
 


Index: clang/test/Driver/amdgpu-toolchain.c
===
--- clang/test/Driver/amdgpu-toolchain.c
+++ clang/test/Driver/amdgpu-toolchain.c
@@ -6,7 +6,7 @@
 // RUN: %clang -### -g --target=amdgcn-mesa-mesa3d -mcpu=kaveri %s 2>&1 | FileCheck -check-prefix=DWARF_VER %s
 
 // AS_LINK: "-cc1as"
-// AS_LINK: ld.lld{{.*}} "-shared"
+// AS_LINK: ld.lld{{.*}} "--no-undefined" "-shared"
 
 // DWARF_VER: "-dwarf-version=5"
 
Index: clang/test/Driver/amdgpu-toolchain-opencl.cl
===
--- clang/test/Driver/amdgpu-toolchain-opencl.cl
+++ clang/test/Driver/amdgpu-toolchain-opencl.cl
@@ -25,3 +25,6 @@
 
 // CHK-INC: "-cc1" {{.*}}"-finclude-default-header" "-fdeclare-opencl-builtins" {{.*}}"-x" "cl"
 // CHK-INC-NOT: "-cc1" {{.*}}"-finclude-default-header" "-fdeclare-opencl-builtins" {{.*}}"-x" "cpp-output"
+
+// RUN: %clang -### --target=amdgcn-amd-amdhsa-opencl -x cl -emit-llvm -mcpu=fiji %s 2>&1 | FileCheck -check-prefix=CHK-LINK %s
+// CHK-LINK: ld.lld{{.*}} "--no-undefined" "-shared"
Index: clang/lib/Driver/ToolChains/AMDGPU.cpp
===
--- clang/lib/Driver/ToolChains/AMDGPU.cpp
+++ clang/lib/Driver/ToolChains/AMDGPU.cpp
@@ -543,6 +543,7 @@
   if (C.getDriver().isUsingLTO())
 addLTOOptions(getToolChain(), Args, CmdArgs, Output, Inputs[0],
   C.getDriver().getLTOMode() == LTOK_Thin);
+  CmdArgs.push_back("--no-undefined");
   CmdArgs.push_back("-shared");
   CmdArgs.push_back("-o");
   CmdArgs.push_back(Output.getFilename());
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -222,6 +222,14 @@
 Target Specific Changes
 ---
 
+AMDGPU Support
+^^
+
+- Linking for AMDGPU now uses ``--no-undefined`` by default. This causes 
+  undefined symbols in the created module to be a linker error. To prevent this, 
+  pass ``-Wl,--undefined`` if compiling directly, or ``-Xoffload-linker 
+  --undefined`` if using an offloading language.
+
 X86 Support
 ^^^
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-com

[PATCH] D146003: [StandardInstrumentations] Verify function doesn't change if analyses are preserved

2023-03-14 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks updated this revision to Diff 505169.
aeubanks retitled this revision from "[StandardInstrumentations] Check that the 
number of instructions doesn't change if analyses are preserved" to 
"[StandardInstrumentations] Verify function doesn't change if analyses are 
preserved".
aeubanks edited the summary of this revision.
aeubanks added a comment.

split out other changes, use StructuralHash instead


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146003

Files:
  llvm/include/llvm/IR/StructuralHash.h
  llvm/lib/IR/StructuralHash.cpp
  llvm/lib/Passes/StandardInstrumentations.cpp
  llvm/unittests/IR/PassManagerTest.cpp

Index: llvm/unittests/IR/PassManagerTest.cpp
===
--- llvm/unittests/IR/PassManagerTest.cpp
+++ llvm/unittests/IR/PassManagerTest.cpp
@@ -950,4 +950,37 @@
   FPM.addPass(TestSimplifyCFGWrapperPass(InnerFPM));
   FPM.run(*F, FAM);
 }
+
+#ifdef EXPENSIVE_CHECKS
+
+struct WrongFunctionPass : PassInfoMixin {
+  PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM) {
+F.getEntryBlock().begin()->eraseFromParent();
+return PreservedAnalyses::all();
+  }
+  static StringRef name() { return "WrongFunctionPass"; }
+};
+
+TEST_F(PassManagerTest, FunctionAnalysisMissedInvalidation) {
+  LLVMContext Context;
+  auto M = parseIR(Context, "define void @foo() {\n"
+"  %a = add i32 0, 0\n"
+"  ret void\n"
+"}\n");
+
+  FunctionAnalysisManager FAM;
+  PassInstrumentationCallbacks PIC;
+  StandardInstrumentations SI(M->getContext(), /*DebugLogging*/ false);
+  SI.registerCallbacks(PIC, &FAM);
+  FAM.registerPass([&] { return PassInstrumentationAnalysis(&PIC); });
+
+  FunctionPassManager FPM;
+  FPM.addPass(WrongFunctionPass());
+
+  auto *F = M->getFunction("foo");
+  EXPECT_DEATH(FPM.run(*F, FAM), "Function @foo changed by WrongFunctionPass without invalidating analyses");
+}
+
+#endif
+
 }
Index: llvm/lib/Passes/StandardInstrumentations.cpp
===
--- llvm/lib/Passes/StandardInstrumentations.cpp
+++ llvm/lib/Passes/StandardInstrumentations.cpp
@@ -24,6 +24,7 @@
 #include "llvm/IR/PassInstrumentation.h"
 #include "llvm/IR/PassManager.h"
 #include "llvm/IR/PrintPasses.h"
+#include "llvm/IR/StructuralHash.h"
 #include "llvm/IR/Verifier.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/CrashRecoveryContext.h"
@@ -1048,6 +1049,23 @@
 
 AnalysisKey PreservedCFGCheckerAnalysis::Key;
 
+struct PreservedFunctionHashAnalysis
+: public AnalysisInfoMixin {
+  static AnalysisKey Key;
+
+  struct FunctionHash {
+uint64_t Hash;
+  };
+
+  using Result = FunctionHash;
+
+  Result run(Function &F, FunctionAnalysisManager &FAM) {
+return Result{StructuralHash(F)};
+  }
+};
+
+AnalysisKey PreservedFunctionHashAnalysis::Key;
+
 bool PreservedCFGCheckerInstrumentation::CFG::invalidate(
 Function &F, const PreservedAnalyses &PA,
 FunctionAnalysisManager::Invalidator &) {
@@ -1062,6 +1080,7 @@
 return;
 
   FAM.registerPass([&] { return PreservedCFGCheckerAnalysis(); });
+  FAM.registerPass([&] { return PreservedFunctionHashAnalysis(); });
 
   PIC.registerBeforeNonSkippedPassCallback(
   [this, &FAM](StringRef P, Any IR) {
@@ -1075,6 +1094,8 @@
 
 // Make sure a fresh CFG snapshot is available before the pass.
 FAM.getResult(*const_cast(*F));
+FAM.getResult(
+*const_cast(*F));
   });
 
   PIC.registerAfterPassInvalidatedCallback(
@@ -1094,12 +1115,27 @@
 #endif
 (void)this;
 
-const auto **F = any_cast(&IR);
-if (!F)
+const auto **MaybeF = any_cast(&IR);
+if (!MaybeF)
+  return;
+Function &F = *const_cast(*MaybeF);
+
+// FIXME: we shouldn't have to check PassPA, we should just be able to check
+// if the cached analysis exists, but currently PassInstrumentation runs
+// before analyses are invalidated.
+if (!PassPA.allAnalysesInSetPreserved>())
   return;
 
-if (!PassPA.allAnalysesInSetPreserved() &&
-!PassPA.allAnalysesInSetPreserved>())
+if (auto *HashBefore =
+FAM.getCachedResult(F)) {
+  if (HashBefore->Hash != StructuralHash(F)) {
+report_fatal_error(formatv(
+"Function @{0} changed by {1} without invalidating analyses",
+F.getName(), P));
+  }
+}
+
+if (!PassPA.allAnalysesInSetPreserved())
   return;
 
 auto CheckCFG = [](StringRef Pass, StringRef FuncName,
@@ -1115,10 +1151,9 @@
   report_fatal_error(Twine("CFG unexpectedly changed by ", Pass));
 };
 
-if (auto *GraphBefore = FAM.getCachedResult(
-*const_cast(*F)))
-  CheckCFG(P, (*F)->getName(), *GraphBefore,
-   CFG(*F, /* TrackBBLifetime */ false));
+if (auto *GraphBefore = FAM.getCachedResult(F))
+ 

[PATCH] D145726: Fix assembler error when -g and -gdwarf-* is passed with -fno-integrated-as.

2023-03-14 Thread garvit gupta via Phabricator via cfe-commits
garvitgupta08 updated this revision to Diff 505171.
garvitgupta08 added a comment.

Addressed the comments. Using gcc_forward.c for checking c extension.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145726

Files:
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/test/Driver/as-options.cpp
  clang/test/Driver/gcc_forward.c


Index: clang/test/Driver/gcc_forward.c
===
--- clang/test/Driver/gcc_forward.c
+++ clang/test/Driver/gcc_forward.c
@@ -34,3 +34,15 @@
 // CHECK-NOT: "-Wall"
 // CHECK-NOT: "-Wdocumentation"
 // CHECK: "-o" "a.out"
+//
+// Test that -g and -gdwarf-* are not passed through to GAS.
+// RUN: %clang --target=arm-linux-gnueabi -fno-integrated-as -g -c %s -### 
2>&1 | \
+// RUN:   FileCheck --check-prefix=DEBUG %s
+// RUN: %clang --target=arm-linux-gnueabi -fno-integrated-as -gdwarf-4 -c %s 
-### 2>&1 | \
+// RUN:   FileCheck --check-prefix=DEBUG %s
+// RUN: %clang --target=arm-linux-gnueabi -fno-integrated-as -gdwarf-4 -g -c 
%s -### 2>&1 | \
+// RUN:   FileCheck --check-prefix=DEBUG %s
+// RUN: %clang --target=arm-linux-gnueabi -fno-integrated-as -g \
+// RUN:   -fdebug-default-version=4 -c %s -### 2>&1 | FileCheck 
--check-prefix=DEBUG %s
+// DEBUG-NOT: "-g"
+// DEBUG-NOT: "-gdwarf-4"
Index: clang/test/Driver/as-options.cpp
===
--- /dev/null
+++ clang/test/Driver/as-options.cpp
@@ -0,0 +1,11 @@
+// Test that -g and -gdwarf-* are not passed through to GAS.
+// RUN: %clang --target=arm-linux-gnueabi -fno-integrated-as -g -c %s -### 
2>&1 | \
+// RUN:   FileCheck --check-prefix=DEBUG %s
+// RUN: %clang --target=arm-linux-gnueabi -fno-integrated-as -gdwarf-4 -c %s 
-### 2>&1 | \
+// RUN:   FileCheck --check-prefix=DEBUG %s
+// RUN: %clang --target=arm-linux-gnueabi -fno-integrated-as -gdwarf-4 -g -c 
%s -### 2>&1 | \
+// RUN:   FileCheck --check-prefix=DEBUG %s
+// RUN: %clang --target=arm-linux-gnueabi -fno-integrated-as -g \
+// RUN:   -fdebug-default-version=4 -c %s -### 2>&1 | FileCheck 
--check-prefix=DEBUG %s
+// DEBUG-NOT: "-g"
+// DEBUG-NOT: "-gdwarf-4"
Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -972,19 +972,24 @@
   CmdArgs.push_back("-o");
   CmdArgs.push_back(Output.getFilename());
 
-  for (const auto &II : Inputs)
+  for (const auto &II : Inputs) {
 CmdArgs.push_back(II.getFilename());
-
-  if (Arg *A = Args.getLastArg(options::OPT_g_Flag, options::OPT_gN_Group,
-   options::OPT_gdwarf_2, options::OPT_gdwarf_3,
-   options::OPT_gdwarf_4, options::OPT_gdwarf_5,
-   options::OPT_gdwarf))
-if (!A->getOption().matches(options::OPT_g0)) {
-  Args.AddLastArg(CmdArgs, options::OPT_g_Flag);
-
-  unsigned DwarfVersion = getDwarfVersion(getToolChain(), Args);
-  CmdArgs.push_back(Args.MakeArgString("-gdwarf-" + Twine(DwarfVersion)));
-}
+StringRef BaseInput = StringRef(II.getBaseInput());
+types::ID InputType = types::lookupTypeForExtension(
+llvm::sys::path::extension(BaseInput).drop_front());
+if (InputType == types::TY_Asm || InputType == types::TY_PP_Asm)
+  if (Arg *A = Args.getLastArg(options::OPT_g_Flag, options::OPT_gN_Group,
+   options::OPT_gdwarf_2, 
options::OPT_gdwarf_3,
+   options::OPT_gdwarf_4, 
options::OPT_gdwarf_5,
+   options::OPT_gdwarf))
+if (!A->getOption().matches(options::OPT_g0)) {
+  Args.AddLastArg(CmdArgs, options::OPT_g_Flag);
+  unsigned DwarfVersion = getDwarfVersion(getToolChain(), Args);
+  CmdArgs.push_back(
+  Args.MakeArgString("-gdwarf-" + Twine(DwarfVersion)));
+  break;
+}
+  }
 
   const char *Exec =
   Args.MakeArgString(getToolChain().GetProgramPath(DefaultAssembler));


Index: clang/test/Driver/gcc_forward.c
===
--- clang/test/Driver/gcc_forward.c
+++ clang/test/Driver/gcc_forward.c
@@ -34,3 +34,15 @@
 // CHECK-NOT: "-Wall"
 // CHECK-NOT: "-Wdocumentation"
 // CHECK: "-o" "a.out"
+//
+// Test that -g and -gdwarf-* are not passed through to GAS.
+// RUN: %clang --target=arm-linux-gnueabi -fno-integrated-as -g -c %s -### 2>&1 | \
+// RUN:   FileCheck --check-prefix=DEBUG %s
+// RUN: %clang --target=arm-linux-gnueabi -fno-integrated-as -gdwarf-4 -c %s -### 2>&1 | \
+// RUN:   FileCheck --check-prefix=DEBUG %s
+// RUN: %clang --target=arm-linux-gnueabi -fno-integrated-as -gdwarf-4 -g -c %s -### 2>&1 | \
+// RUN:   FileCheck --check-prefix=DEBUG %s
+// RUN: %clang --target=arm-linux-gnueabi -fno-integrated-as -g \
+// RUN:   -fdebug-default-versi

[PATCH] D145859: [Clang][CodeGen] Fix linkage and visibility of template parameter objects

2023-03-14 Thread Alexander Shaposhnikov via Phabricator via cfe-commits
alexander-shaposhnikov updated this revision to Diff 505175.
alexander-shaposhnikov retitled this revision from "[Clang][CodeGen] Fix 
linkage of template parameter objects" to "[Clang][CodeGen] Fix linkage and 
visibility of template parameter objects".
alexander-shaposhnikov edited the summary of this revision.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145859

Files:
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGenCXX/template-param-objects-linkage.cpp
  clang/test/CodeGenCXX/template-param-objects-visibility.cpp
  clang/test/CodeGenCXX/template-param-objects.cpp


Index: clang/test/CodeGenCXX/template-param-objects.cpp
===
--- clang/test/CodeGenCXX/template-param-objects.cpp
+++ clang/test/CodeGenCXX/template-param-objects.cpp
@@ -7,7 +7,9 @@
 
 // ITANIUM: 
[[HELLO:@_ZTAXtl1StlA32_cLc104ELc101ELc108ELc108ELc111ELc32ELc119ELc111ELc114ELc108ELc100]]
 // MSABI: 
[[HELLO:@"[?][?]__N2US@@3D0GI@@0GF@@0GM@@0GM@@0GP@@0CA@@0HH@@0GP@@0HC@@0GM@@0GE@@0A@@0A@@0A@@0A@@0A@@0A@@0A@@0A@@0A@@0A@@0A@@0A@@0A@@0A@@0A@@0A@@0A@@0A@@0A@@0A@@0A@"]]
-// CHECK-SAME: = linkonce_odr constant { <{ [11 x i8], [21 x i8] }> } { <{ [11 
x i8], [21 x i8] }> <{ [11 x i8] c"hello world", [21 x i8] zeroinitializer }> 
}, comdat
+// ITANIUM-SAME: = linkonce_odr constant { <{ [11 x i8], [21 x i8] }> } { <{ 
[11 x i8], [21 x i8] }> <{ [11 x i8] c"hello world", [21 x i8] zeroinitializer 
}> }, comdat
+// MSABI-SAME: = linkonce_odr dso_local constant { <{ [11 x i8], [21 x i8] }> 
} { <{ [11 x i8], [21 x i8] }> <{ [11 x i8] c"hello world", [21 x i8] 
zeroinitializer }> }, comdat
+
 
 // ITANIUM: @p
 // MSABI: @"?p@@3PEBDEB"
Index: clang/test/CodeGenCXX/template-param-objects-visibility.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/template-param-objects-visibility.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -std=c++20 %s -emit-llvm -o - | 
FileCheck %s
+
+struct S { char buf[32]; };
+template constexpr const char* f() { return s.buf; }
+const char* fbuf = f();
+// CHECK: @_ZTAXtl1StlA32_cLc97 = linkonce_odr constant { <{ i8, [31 x i8] 
}> }
+
+struct __attribute__ ((visibility ("hidden"))) HN { char buf[64]; };
+template  constexpr const char* g() { return hn.buf; }
+const char* gbuf = g();
+// CHECK: @_ZTAXtl2HNtlA64_cLc98 = linkonce_odr hidden constant { <{ i8, 
[63 x i8] }> }
Index: clang/test/CodeGenCXX/template-param-objects-linkage.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/template-param-objects-linkage.cpp
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -std=c++20 %s -emit-llvm -o - | 
FileCheck %s
+
+struct S { char buf[32]; };
+template constexpr const char* f() { return s.buf; }
+const char* fbuf = f();
+// CHECK: @_ZTAXtl1StlA32_cLc97 = linkonce_odr constant { <{ i8, [31 x i8] 
}> }
+
+namespace {
+  struct UN { char buf[64]; };
+}
+template  constexpr const char* g() { return un.buf; }
+const char* gbuf = g();
+// CHECK: @_ZTAXtlN12_GLOBAL__N_12UNEtlA64_cLc98 = internal constant { <{ 
i8, [63 x i8] }> }
+
+struct Foo { int *i; };
+int m = 0;
+namespace { int n; }
+
+template 
+const int* h() { return foo.i; }
+
+const int* hm = h();
+// CHECK: @_ZTAXtl3FooadL_Z1mEEE = linkonce_odr constant %struct.Foo { ptr @m }
+
+const int* hn = h();
+// CHECK: @_ZTAXtl3FooadL_ZN12_GLOBAL__N_11n = internal constant 
%struct.Foo { ptr @_ZN12_GLOBAL__N_11nE }
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -3238,9 +3238,13 @@
 return ConstantAddress::invalid();
   }
 
-  auto *GV = new llvm::GlobalVariable(
-  getModule(), Init->getType(),
-  /*isConstant=*/true, llvm::GlobalValue::LinkOnceODRLinkage, Init, Name);
+  llvm::GlobalValue::LinkageTypes Linkage =
+  isExternallyVisible(TPO->getLinkageAndVisibility().getLinkage())
+  ? llvm::GlobalValue::LinkOnceODRLinkage
+  : llvm::GlobalValue::InternalLinkage;
+  auto *GV = new llvm::GlobalVariable(getModule(), Init->getType(),
+  /*isConstant=*/true, Linkage, Init, 
Name);
+  setGVProperties(GV, TPO);
   if (supportsCOMDAT())
 GV->setComdat(TheModule.getOrInsertComdat(GV->getName()));
   Emitter.finalize(GV);


Index: clang/test/CodeGenCXX/template-param-objects.cpp
===
--- clang/test/CodeGenCXX/template-param-objects.cpp
+++ clang/test/CodeGenCXX/template-param-objects.cpp
@@ -7,7 +7,9 @@
 
 // ITANIUM: [[HELLO:@_ZTAXtl1StlA32_cLc104ELc101ELc108ELc108ELc111ELc32ELc119ELc111ELc114ELc108ELc100]]
 // MSABI: [[HELLO:@"[?][?]__N2US@@3D0GI@@0GF@@0GM@@0GM@@0GP@@0CA@@0HH

[PATCH] D146073: Revert "Revert "[Clang][AIX][p] Manually Claim -p in front end""

2023-03-14 Thread Michael Francis via Phabricator via cfe-commits
francii created this revision.
Herald added a project: All.
francii requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay.
Herald added a project: clang.

This reverts commit 7488dd25e1613894d79d69f153469545b9bf660a 
. The
original revert was due to the original commit causing segfaults.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D146073

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/ibm-profiling.c
  clang/test/Driver/zos-profiling-error.c

Index: clang/test/Driver/zos-profiling-error.c
===
--- clang/test/Driver/zos-profiling-error.c
+++ /dev/null
@@ -1,2 +0,0 @@
-// RUN: %clang 2>&1 -### --target=s390x-none-zos -pg -S %s | FileCheck -check-prefix=FAIL-PG-NAME %s
-// FAIL-PG-NAME: error: unsupported option '-pg' for target 's390x-none-zos'
Index: clang/test/Driver/ibm-profiling.c
===
--- /dev/null
+++ clang/test/Driver/ibm-profiling.c
@@ -0,0 +1,27 @@
+// Check that -pg throws an error on z/OS.
+// RUN: %clang -### 2>&1 --target=s390x-none-zos -S -pg %s | FileCheck -check-prefix=FAIL-PG-NAME %s
+// FAIL-PG-NAME: error: unsupported option '-pg' for target 's390x-none-zos'
+
+// Check that -p is still used when not linking on AIX.
+// RUN: %clang -### 2>&1 --target=powerpc-ibm-aix7.1.0.0 -S -p -S %s \
+// RUN:   | FileCheck --check-prefix=CHECK %s
+// CHECK-NOT: warning: argument unused during compilation: '-p'
+
+// Check precedence: -pg is unused when passed first on AIX.
+// RUN: %clang -### 2>&1 --target=powerpc-ibm-aix7.1.0.0 --sysroot %S/Inputs/aix_ppc_tree -pg -p %s \
+// RUN:| FileCheck --check-prefix=CHECK2 %s
+// CHECK2-NOT: warning: argument unused during compilation: '-p' [-Wunused-command-line-argument]
+// CHECK2: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK2: "[[SYSROOT]]/usr/lib{{/|}}mcrt0.o"
+// CHECK2: "-L[[SYSROOT]]/lib/profiled"
+// CHECK2: "-L[[SYSROOT]]/usr/lib/profiled"
+
+// Check precedence: -p is unused when passed first on AIX.
+// RUN: %clang -### 2>&1 --target=powerpc-ibm-aix7.1.0.0 --sysroot %S/Inputs/aix_ppc_tree -p -pg %s \
+// RUN:| FileCheck --check-prefix=CHECK3 %s
+// CHECK3: warning: argument unused during compilation: '-p' [-Wunused-command-line-argument]
+// CHECK3: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK3: "[[SYSROOT]]/usr/lib{{/|}}gcrt0.o"
+// CHECK3: "-L[[SYSROOT]]/lib/profiled"
+// CHECK3: "-L[[SYSROOT]]/usr/lib/profiled"
+
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6322,20 +6322,26 @@
 << A->getAsString(Args) << TripleStr;
 }
   }
-  if (Arg *A = Args.getLastArgNoClaim(options::OPT_p)) {
-if (TC.getTriple().isOSAIX()) {
-  CmdArgs.push_back("-pg");
-} else if (!TC.getTriple().isOSOpenBSD()) {
+
+  if (Arg *A = Args.getLastArgNoClaim(options::OPT_pg)) {
+if (TC.getTriple().isOSzOS()) {
   D.Diag(diag::err_drv_unsupported_opt_for_target)
   << A->getAsString(Args) << TripleStr;
 }
   }
-  if (Arg *A = Args.getLastArgNoClaim(options::OPT_pg)) {
-if (TC.getTriple().isOSzOS()) {
+  if (Arg *A = Args.getLastArgNoClaim(options::OPT_p)) {
+if (!(TC.getTriple().isOSAIX() || TC.getTriple().isOSOpenBSD())) {
   D.Diag(diag::err_drv_unsupported_opt_for_target)
   << A->getAsString(Args) << TripleStr;
 }
   }
+  if (Arg *A = Args.getLastArgNoClaim(options::OPT_p, options::OPT_pg)) {
+if (A->getOption().matches(options::OPT_p)) {
+  A->claim();
+  if (TC.getTriple().isOSAIX() && !Args.hasArgNoClaim(options::OPT_pg))
+CmdArgs.push_back("-pg");
+}
+  }
 
   if (Args.getLastArg(options::OPT_fapple_kext) ||
   (Args.hasArg(options::OPT_mkernel) && types::isCXX(InputType)))
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -164,11 +164,12 @@
   }
 
   auto getCrt0Basename = [&Args, IsArch32Bit] {
+Arg *A = Args.getLastArgNoClaim(options::OPT_p, options::OPT_pg);
 // Enable gprofiling when "-pg" is specified.
-if (Args.hasArg(options::OPT_pg))
+if (A->getOption().matches(options::OPT_pg))
   return IsArch32Bit ? "gcrt0.o" : "gcrt0_64.o";
 // Enable profiling when "-p" is specified.
-else if (Args.hasArg(options::OPT_p))
+else if (A->getOption().matches(options::OPT_p))
   return IsArch32Bit ? "mcrt0.o" : "mcrt0_64.o";
 else
   return IsArch32Bit ? "crt0.o" : "crt0_64.o";
@@ -271,7 +272,7 @@
 
 CmdArgs.push_back("-lc");
 
-if (Args.hasArg(option

[PATCH] D146073: Revert "Revert "[Clang][AIX][p] Manually Claim -p in front end""

2023-03-14 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 505179.
francii added a comment.

Update message


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146073

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/ibm-profiling.c
  clang/test/Driver/zos-profiling-error.c

Index: clang/test/Driver/zos-profiling-error.c
===
--- clang/test/Driver/zos-profiling-error.c
+++ /dev/null
@@ -1,2 +0,0 @@
-// RUN: %clang 2>&1 -### --target=s390x-none-zos -pg -S %s | FileCheck -check-prefix=FAIL-PG-NAME %s
-// FAIL-PG-NAME: error: unsupported option '-pg' for target 's390x-none-zos'
Index: clang/test/Driver/ibm-profiling.c
===
--- /dev/null
+++ clang/test/Driver/ibm-profiling.c
@@ -0,0 +1,27 @@
+// Check that -pg throws an error on z/OS.
+// RUN: %clang -### 2>&1 --target=s390x-none-zos -S -pg %s | FileCheck -check-prefix=FAIL-PG-NAME %s
+// FAIL-PG-NAME: error: unsupported option '-pg' for target 's390x-none-zos'
+
+// Check that -p is still used when not linking on AIX.
+// RUN: %clang -### 2>&1 --target=powerpc-ibm-aix7.1.0.0 -S -p -S %s \
+// RUN:   | FileCheck --check-prefix=CHECK %s
+// CHECK-NOT: warning: argument unused during compilation: '-p'
+
+// Check precedence: -pg is unused when passed first on AIX.
+// RUN: %clang -### 2>&1 --target=powerpc-ibm-aix7.1.0.0 --sysroot %S/Inputs/aix_ppc_tree -pg -p %s \
+// RUN:| FileCheck --check-prefix=CHECK2 %s
+// CHECK2-NOT: warning: argument unused during compilation: '-p' [-Wunused-command-line-argument]
+// CHECK2: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK2: "[[SYSROOT]]/usr/lib{{/|}}mcrt0.o"
+// CHECK2: "-L[[SYSROOT]]/lib/profiled"
+// CHECK2: "-L[[SYSROOT]]/usr/lib/profiled"
+
+// Check precedence: -p is unused when passed first on AIX.
+// RUN: %clang -### 2>&1 --target=powerpc-ibm-aix7.1.0.0 --sysroot %S/Inputs/aix_ppc_tree -p -pg %s \
+// RUN:| FileCheck --check-prefix=CHECK3 %s
+// CHECK3: warning: argument unused during compilation: '-p' [-Wunused-command-line-argument]
+// CHECK3: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK3: "[[SYSROOT]]/usr/lib{{/|}}gcrt0.o"
+// CHECK3: "-L[[SYSROOT]]/lib/profiled"
+// CHECK3: "-L[[SYSROOT]]/usr/lib/profiled"
+
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6322,20 +6322,26 @@
 << A->getAsString(Args) << TripleStr;
 }
   }
-  if (Arg *A = Args.getLastArgNoClaim(options::OPT_p)) {
-if (TC.getTriple().isOSAIX()) {
-  CmdArgs.push_back("-pg");
-} else if (!TC.getTriple().isOSOpenBSD()) {
+
+  if (Arg *A = Args.getLastArgNoClaim(options::OPT_pg)) {
+if (TC.getTriple().isOSzOS()) {
   D.Diag(diag::err_drv_unsupported_opt_for_target)
   << A->getAsString(Args) << TripleStr;
 }
   }
-  if (Arg *A = Args.getLastArgNoClaim(options::OPT_pg)) {
-if (TC.getTriple().isOSzOS()) {
+  if (Arg *A = Args.getLastArgNoClaim(options::OPT_p)) {
+if (!(TC.getTriple().isOSAIX() || TC.getTriple().isOSOpenBSD())) {
   D.Diag(diag::err_drv_unsupported_opt_for_target)
   << A->getAsString(Args) << TripleStr;
 }
   }
+  if (Arg *A = Args.getLastArgNoClaim(options::OPT_p, options::OPT_pg)) {
+if (A->getOption().matches(options::OPT_p)) {
+  A->claim();
+  if (TC.getTriple().isOSAIX() && !Args.hasArgNoClaim(options::OPT_pg))
+CmdArgs.push_back("-pg");
+}
+  }
 
   if (Args.getLastArg(options::OPT_fapple_kext) ||
   (Args.hasArg(options::OPT_mkernel) && types::isCXX(InputType)))
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -164,11 +164,12 @@
   }
 
   auto getCrt0Basename = [&Args, IsArch32Bit] {
+Arg *A = Args.getLastArgNoClaim(options::OPT_p, options::OPT_pg);
 // Enable gprofiling when "-pg" is specified.
-if (Args.hasArg(options::OPT_pg))
+if (A->getOption().matches(options::OPT_pg))
   return IsArch32Bit ? "gcrt0.o" : "gcrt0_64.o";
 // Enable profiling when "-p" is specified.
-else if (Args.hasArg(options::OPT_p))
+else if (A->getOption().matches(options::OPT_p))
   return IsArch32Bit ? "mcrt0.o" : "mcrt0_64.o";
 else
   return IsArch32Bit ? "crt0.o" : "crt0_64.o";
@@ -271,7 +272,7 @@
 
 CmdArgs.push_back("-lc");
 
-if (Args.hasArg(options::OPT_p, options::OPT_pg)) {
+if (Args.hasArgNoClaim(options::OPT_p, options::OPT_pg)) {
   CmdArgs.push_back(Args.MakeArgString((llvm::Twine("-L") + D.SysRoot) +
"/lib/profiled")

[PATCH] D144190: [AIX][clang] Storage Locations for Constant Pointers

2023-03-14 Thread Qiongsi Wu via Phabricator via cfe-commits
qiongsiwu1 updated this revision to Diff 505181.
qiongsiwu1 added a comment.

Thanks for the comments @stephenpeckham ! This update addresses all of them.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144190

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/PowerPC/aix-roptr.c
  clang/test/Driver/ppc-roptr.c

Index: clang/test/Driver/ppc-roptr.c
===
--- /dev/null
+++ clang/test/Driver/ppc-roptr.c
@@ -0,0 +1,57 @@
+// RUN: %clang -### -target powerpc-ibm-aix-xcoff -mroptr %s 2>&1 | \
+// RUN: FileCheck %s --check-prefixes=ROPTR,LINK
+// RUN: %clang -### -target powerpc-ibm-aix-xcoff -c -mroptr %s 2>&1 | \
+// RUN: FileCheck %s --check-prefix=ROPTR
+// RUN: %clang -### -target powerpc-ibm-aix-xcoff -S -mroptr %s 2>&1 | \
+// RUN: FileCheck %s --check-prefix=ROPTR
+// RUN: %clang -### -target powerpc-ibm-aix-xcoff -mroptr -mno-roptr %s 2>&1 | \
+// RUN: FileCheck %s --check-prefix=NO_ROPTR
+// RUN: %clang -### -target powerpc-ibm-aix-xcoff %s 2>&1 | \
+// RUN: FileCheck %s --check-prefix=NO_ROPTR
+// RUN: %clang -### -target powerpc-ibm-aix-xcoff -mroptr -flto %s 2>&1 | \
+// RUN: FileCheck %s --check-prefix=LTO_ROPTR
+// RUN: touch %t.o
+// RUN: %clang -### -target powerpc-ibm-aix-xcoff -mroptr %t.o 2>&1 | \
+// RUN: FileCheck %s --check-prefix=LINK
+
+// RUN: %clang -### -target powerpc64-ibm-aix-xcoff -mroptr %s 2>&1 | \
+// RUN: FileCheck %s --check-prefixes=ROPTR,LINK
+// RUN: %clang -### -target powerpc64-ibm-aix-xcoff -c -mroptr %s 2>&1 | \
+// RUN: FileCheck %s --check-prefix=ROPTR
+// RUN: %clang -### -target powerpc64-ibm-aix-xcoff -S -mroptr %s 2>&1 | \
+// RUN: FileCheck %s --check-prefix=ROPTR
+// RUN: %clang -### -target powerpc64-ibm-aix-xcoff -mroptr -mno-roptr %s 2>&1 | \
+// RUN: FileCheck %s --check-prefix=NO_ROPTR
+// RUN: %clang -### -target powerpc-ibm-aix-xcoff %s 2>&1 | \
+// RUN: FileCheck %s --check-prefix=NO_ROPTR
+// RUN: %clang -### -target powerpc64-ibm-aix-xcoff -mroptr -flto %s 2>&1 | \
+// RUN: FileCheck %s --check-prefix=LTO_ROPTR
+// RUN: touch %t.o
+// RUN: %clang -### -target powerpc64-ibm-aix-xcoff -mroptr %t.o 2>&1 | \
+// RUN: FileCheck %s --check-prefix=LINK
+
+// RUN: %clang -### -target powerpc64le-unknown-linux-gnu -mroptr \
+// RUN: %s 2>&1 | FileCheck %s --check-prefix=TARGET_ROPTR_ERR
+// RUN: %clang -### -target powerpc64le-unknown-linux-gnu -mno-roptr \
+// RUN: %s 2>&1 | FileCheck %s --check-prefix=TARGET_NOROPTR_ERR
+// RUN: %clang -### -target powerpc-ibm-aix-xcoff -mroptr -shared \
+// RUN: %s 2>&1 | FileCheck %s --check-prefix=SHARED_ERR
+// RUN: %clang -### -target powerpc64-ibm-aix-xcoff -mroptr -shared \
+// RUN: %s 2>&1 | FileCheck %s --check-prefix=SHARED_ERR
+// RUN: %clang -### -target powerpc64le-unknown-linux-gnu -mroptr -flto \
+// RUN: %s 2>&1 | FileCheck %s --check-prefix=TARGET_ROPTR_ERR
+// RUN: %clang -### -target powerpc64-ibm-aix-xcoff -mroptr -flto -fno-data-sections \
+// RUN: %s 2>&1 | FileCheck %s --check-prefix=DATA_SECTION_ERR
+// RUN: %clang -### -target powerpc64le-unknown-linux-gnu -mno-roptr -flto \
+// RUN: %s 2>&1 | FileCheck %s --check-prefix=TARGET_NOROPTR_ERR
+
+// ROPTR: "-mroptr"
+// LINK: "-bforceimprw"
+// LTO_ROPTR: "-bplugin_opt:-mroptr"
+// NO_ROPTR-NOT: "-mroptr"
+// NO_ROPTR-NOT: "-bforceimprw"
+
+// DATA_SECTION_ERR: error: -mroptr is supported only with -fdata-sections
+// TARGET_ROPTR_ERR: error: unsupported option '-mroptr' for target 'powerpc64le-unknown-linux-gnu'
+// TARGET_NOROPTR_ERR: error: unsupported option '-mno-roptr' for target 'powerpc64le-unknown-linux-gnu'
+// SHARED_ERR: error: -mroptr is not suppored with -shared
Index: clang/test/CodeGen/PowerPC/aix-roptr.c
===
--- /dev/null
+++ clang/test/CodeGen/PowerPC/aix-roptr.c
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -triple=powerpc-ibm-aix-xcoff -mroptr -fdata-sections \
+// RUN: -S <%s | FileCheck %s --check-prefix=CHECK32
+// RUN: %clang_cc1 -triple=powerpc64-ibm-aix-xcoff -mroptr -fdata-sections \
+// RUN: -S <%s | FileCheck %s --check-prefix=CHECK64
+// RUN: not %clang_cc1 -triple=powerpc-ibm-aix-xcoff -mroptr \
+// RUN: -S <%s 2>&1 | FileCheck %s --check-prefix=DATA_SECTION_ERR
+// RUN: not %clang_cc1 -triple=powerpc64-ibm-aix-xcoff -mroptr \
+// RUN: -S <%s 2>&1 | FileCheck %s --check-prefix=DATA_SECTION_ERR
+// RUN: not %clang_cc1 -triple=powerpc64le-unknown-linux-gnu -mroptr \
+// RUN: %s 2>

[PATCH] D145726: Fix assembler error when -g and -gdwarf-* is passed with -fno-integrated-as.

2023-03-14 Thread garvit gupta via Phabricator via cfe-commits
garvitgupta08 added a comment.






Comment at: clang/lib/Driver/ToolChains/Gnu.cpp:978-986
+  if (Arg *A = Args.getLastArg(options::OPT_g_Flag, options::OPT_gN_Group,
+   options::OPT_gdwarf_2, 
options::OPT_gdwarf_3,
+   options::OPT_gdwarf_4, 
options::OPT_gdwarf_5,
+   options::OPT_gdwarf))
+if (!A->getOption().matches(options::OPT_g0)) {
+  Args.AddLastArg(CmdArgs, options::OPT_g_Flag);
+  unsigned DwarfVersion = getDwarfVersion(getToolChain(), Args);

nickdesaulniers wrote:
> Isn't this potentially going to add `-gdwarf-` repeatedly if there's many 
> inputs?
> 
> Wouldn't it be better to scan the inputs to see if there's any .S or .s 
> files, then add the flags once?
Let me know if this is fine.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145726

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


[clang] 55f3849 - [Clang] Always use --no-undefined when linking AMDGPU images

2023-03-14 Thread Joseph Huber via cfe-commits

Author: Joseph Huber
Date: 2023-03-14T13:11:33-05:00
New Revision: 55f38495e38e2a3aeb4f2dac852644eb4937bd74

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

LOG: [Clang] Always use --no-undefined when linking AMDGPU images

AMDGPU uses ELF shared libraries to implement their executable device
images. One downside to this method is that it disables regular warnings
on undefined symbols. This is because shared libraries expect these to
be resolves by later loads. However, the GPU images do not support
dynamic linking so any undefined symbol is going to cause a runtime
error. This patch adds `--no-undefined` to the `ld.lld` invocation to guarantee
that undefined symbols are always caught as linking errors rather than
runtime errors.

Reviewed By: arsenm, MaskRay, #amdgpu

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

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/Driver/ToolChains/AMDGPU.cpp
clang/test/Driver/amdgpu-toolchain-opencl.cl
clang/test/Driver/amdgpu-toolchain.c

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 5fae7ce3077a7..4a5d3f8199682 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -231,6 +231,14 @@ Miscellaneous Clang Crashes Fixed
 Target Specific Changes
 ---
 
+AMDGPU Support
+^^
+
+- Linking for AMDGPU now uses ``--no-undefined`` by default. This causes
+  undefined symbols in the created module to be a linker error. To prevent 
this,
+  pass ``-Wl,--undefined`` if compiling directly, or ``-Xoffload-linker
+  --undefined`` if using an offloading language.
+
 X86 Support
 ^^^
 

diff  --git a/clang/lib/Driver/ToolChains/AMDGPU.cpp 
b/clang/lib/Driver/ToolChains/AMDGPU.cpp
index 08496c1abbc41..99e2fb839221b 100644
--- a/clang/lib/Driver/ToolChains/AMDGPU.cpp
+++ b/clang/lib/Driver/ToolChains/AMDGPU.cpp
@@ -543,6 +543,7 @@ void amdgpu::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
   if (C.getDriver().isUsingLTO())
 addLTOOptions(getToolChain(), Args, CmdArgs, Output, Inputs[0],
   C.getDriver().getLTOMode() == LTOK_Thin);
+  CmdArgs.push_back("--no-undefined");
   CmdArgs.push_back("-shared");
   CmdArgs.push_back("-o");
   CmdArgs.push_back(Output.getFilename());

diff  --git a/clang/test/Driver/amdgpu-toolchain-opencl.cl 
b/clang/test/Driver/amdgpu-toolchain-opencl.cl
index 78c477b5bce9d..c4038e00a0e5d 100644
--- a/clang/test/Driver/amdgpu-toolchain-opencl.cl
+++ b/clang/test/Driver/amdgpu-toolchain-opencl.cl
@@ -25,3 +25,6 @@
 
 // CHK-INC: "-cc1" {{.*}}"-finclude-default-header" 
"-fdeclare-opencl-builtins" {{.*}}"-x" "cl"
 // CHK-INC-NOT: "-cc1" {{.*}}"-finclude-default-header" 
"-fdeclare-opencl-builtins" {{.*}}"-x" "cpp-output"
+
+// RUN: %clang -### --target=amdgcn-amd-amdhsa-opencl -x cl -emit-llvm 
-mcpu=fiji %s 2>&1 | FileCheck -check-prefix=CHK-LINK %s
+// CHK-LINK: ld.lld{{.*}} "--no-undefined" "-shared"

diff  --git a/clang/test/Driver/amdgpu-toolchain.c 
b/clang/test/Driver/amdgpu-toolchain.c
index a00c75b83f3e0..3477d50527c66 100644
--- a/clang/test/Driver/amdgpu-toolchain.c
+++ b/clang/test/Driver/amdgpu-toolchain.c
@@ -6,7 +6,7 @@
 // RUN: %clang -### -g --target=amdgcn-mesa-mesa3d -mcpu=kaveri %s 2>&1 | 
FileCheck -check-prefix=DWARF_VER %s
 
 // AS_LINK: "-cc1as"
-// AS_LINK: ld.lld{{.*}} "-shared"
+// AS_LINK: ld.lld{{.*}} "--no-undefined" "-shared"
 
 // DWARF_VER: "-dwarf-version=5"
 



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


[PATCH] D145941: [Clang] Always use --no-undefined when linking AMDGPU images

2023-03-14 Thread Joseph Huber via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG55f38495e38e: [Clang] Always use --no-undefined when linking 
AMDGPU images (authored by jhuber6).

Changed prior to commit:
  https://reviews.llvm.org/D145941?vs=505166&id=505185#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145941

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Driver/ToolChains/AMDGPU.cpp
  clang/test/Driver/amdgpu-toolchain-opencl.cl
  clang/test/Driver/amdgpu-toolchain.c


Index: clang/test/Driver/amdgpu-toolchain.c
===
--- clang/test/Driver/amdgpu-toolchain.c
+++ clang/test/Driver/amdgpu-toolchain.c
@@ -6,7 +6,7 @@
 // RUN: %clang -### -g --target=amdgcn-mesa-mesa3d -mcpu=kaveri %s 2>&1 | 
FileCheck -check-prefix=DWARF_VER %s
 
 // AS_LINK: "-cc1as"
-// AS_LINK: ld.lld{{.*}} "-shared"
+// AS_LINK: ld.lld{{.*}} "--no-undefined" "-shared"
 
 // DWARF_VER: "-dwarf-version=5"
 
Index: clang/test/Driver/amdgpu-toolchain-opencl.cl
===
--- clang/test/Driver/amdgpu-toolchain-opencl.cl
+++ clang/test/Driver/amdgpu-toolchain-opencl.cl
@@ -25,3 +25,6 @@
 
 // CHK-INC: "-cc1" {{.*}}"-finclude-default-header" 
"-fdeclare-opencl-builtins" {{.*}}"-x" "cl"
 // CHK-INC-NOT: "-cc1" {{.*}}"-finclude-default-header" 
"-fdeclare-opencl-builtins" {{.*}}"-x" "cpp-output"
+
+// RUN: %clang -### --target=amdgcn-amd-amdhsa-opencl -x cl -emit-llvm 
-mcpu=fiji %s 2>&1 | FileCheck -check-prefix=CHK-LINK %s
+// CHK-LINK: ld.lld{{.*}} "--no-undefined" "-shared"
Index: clang/lib/Driver/ToolChains/AMDGPU.cpp
===
--- clang/lib/Driver/ToolChains/AMDGPU.cpp
+++ clang/lib/Driver/ToolChains/AMDGPU.cpp
@@ -543,6 +543,7 @@
   if (C.getDriver().isUsingLTO())
 addLTOOptions(getToolChain(), Args, CmdArgs, Output, Inputs[0],
   C.getDriver().getLTOMode() == LTOK_Thin);
+  CmdArgs.push_back("--no-undefined");
   CmdArgs.push_back("-shared");
   CmdArgs.push_back("-o");
   CmdArgs.push_back(Output.getFilename());
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -231,6 +231,14 @@
 Target Specific Changes
 ---
 
+AMDGPU Support
+^^
+
+- Linking for AMDGPU now uses ``--no-undefined`` by default. This causes
+  undefined symbols in the created module to be a linker error. To prevent 
this,
+  pass ``-Wl,--undefined`` if compiling directly, or ``-Xoffload-linker
+  --undefined`` if using an offloading language.
+
 X86 Support
 ^^^
 


Index: clang/test/Driver/amdgpu-toolchain.c
===
--- clang/test/Driver/amdgpu-toolchain.c
+++ clang/test/Driver/amdgpu-toolchain.c
@@ -6,7 +6,7 @@
 // RUN: %clang -### -g --target=amdgcn-mesa-mesa3d -mcpu=kaveri %s 2>&1 | FileCheck -check-prefix=DWARF_VER %s
 
 // AS_LINK: "-cc1as"
-// AS_LINK: ld.lld{{.*}} "-shared"
+// AS_LINK: ld.lld{{.*}} "--no-undefined" "-shared"
 
 // DWARF_VER: "-dwarf-version=5"
 
Index: clang/test/Driver/amdgpu-toolchain-opencl.cl
===
--- clang/test/Driver/amdgpu-toolchain-opencl.cl
+++ clang/test/Driver/amdgpu-toolchain-opencl.cl
@@ -25,3 +25,6 @@
 
 // CHK-INC: "-cc1" {{.*}}"-finclude-default-header" "-fdeclare-opencl-builtins" {{.*}}"-x" "cl"
 // CHK-INC-NOT: "-cc1" {{.*}}"-finclude-default-header" "-fdeclare-opencl-builtins" {{.*}}"-x" "cpp-output"
+
+// RUN: %clang -### --target=amdgcn-amd-amdhsa-opencl -x cl -emit-llvm -mcpu=fiji %s 2>&1 | FileCheck -check-prefix=CHK-LINK %s
+// CHK-LINK: ld.lld{{.*}} "--no-undefined" "-shared"
Index: clang/lib/Driver/ToolChains/AMDGPU.cpp
===
--- clang/lib/Driver/ToolChains/AMDGPU.cpp
+++ clang/lib/Driver/ToolChains/AMDGPU.cpp
@@ -543,6 +543,7 @@
   if (C.getDriver().isUsingLTO())
 addLTOOptions(getToolChain(), Args, CmdArgs, Output, Inputs[0],
   C.getDriver().getLTOMode() == LTOK_Thin);
+  CmdArgs.push_back("--no-undefined");
   CmdArgs.push_back("-shared");
   CmdArgs.push_back("-o");
   CmdArgs.push_back(Output.getFilename());
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -231,6 +231,14 @@
 Target Specific Changes
 ---
 
+AMDGPU Support
+^^
+
+- Linking for AMDGPU now uses ``--no-undefined`` by default. This causes
+  undefined symbols in the created module to be a linker error. To prevent this,
+  pass ``-Wl,--undefined`` if compiling directly, or ``-Xoffload-linker
+ 

[PATCH] D145999: [RISCV] Reserve X18 by default for Android

2023-03-14 Thread Alex Bradbury via Phabricator via cfe-commits
asb added inline comments.



Comment at: clang/test/Driver/riscv-fixed-x-register.c:343
+
+// Check that x18 is reserved on Android by default
+// RUN: %clang --target=riscv64-linux-android -### %s 2> %t

samitolvanen wrote:
> This seems redundant. Isn't the LLVM codegen test sufficient here?
I think testing that the `+reserve-x18` target feature is added by the frontend 
probably has some value.

I think it would better match the rest of this file to just do 
`--check-prefix=CHECK-FIXED-X18` (I _think_ that works, but it is the end of 
the day so I may be missing something obvious...).

Please do try to remember to generate patches with full context (`-U99` or 
similar).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145999

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


[PATCH] D145021: [Clang][AIX][p] Manually claim -p in front end

2023-03-14 Thread David Tenty via Phabricator via cfe-commits
daltenty added a comment.

Reopen since this was reverted


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145021

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


[PATCH] D145021: [Clang][AIX][p] Manually claim -p in front end

2023-03-14 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 505186.
francii added a comment.

Make `-p` a CC1 option.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145021

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/ibm-profiling.c
  clang/test/Driver/zos-profiling-error.c

Index: clang/test/Driver/zos-profiling-error.c
===
--- clang/test/Driver/zos-profiling-error.c
+++ /dev/null
@@ -1,2 +0,0 @@
-// RUN: %clang 2>&1 -### --target=s390x-none-zos -pg -S %s | FileCheck -check-prefix=FAIL-PG-NAME %s
-// FAIL-PG-NAME: error: unsupported option '-pg' for target 's390x-none-zos'
Index: clang/test/Driver/ibm-profiling.c
===
--- /dev/null
+++ clang/test/Driver/ibm-profiling.c
@@ -0,0 +1,27 @@
+// Check that -pg throws an error on z/OS.
+// RUN: %clang -### 2>&1 --target=s390x-none-zos -S -pg %s | FileCheck -check-prefix=FAIL-PG-NAME %s
+// FAIL-PG-NAME: error: unsupported option '-pg' for target 's390x-none-zos'
+
+// Check that -p is still used when not linking on AIX.
+// RUN: %clang -### 2>&1 --target=powerpc-ibm-aix7.1.0.0 -S -p -S %s \
+// RUN:   | FileCheck --check-prefix=CHECK %s
+// CHECK-NOT: warning: argument unused during compilation: '-p'
+
+// Check precedence: -pg is unused when passed first on AIX.
+// RUN: %clang -### 2>&1 --target=powerpc-ibm-aix7.1.0.0 --sysroot %S/Inputs/aix_ppc_tree -pg -p %s \
+// RUN:| FileCheck --check-prefix=CHECK2 %s
+// CHECK2-NOT: warning: argument unused during compilation: '-p' [-Wunused-command-line-argument]
+// CHECK2: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK2: "[[SYSROOT]]/usr/lib{{/|}}mcrt0.o"
+// CHECK2: "-L[[SYSROOT]]/lib/profiled"
+// CHECK2: "-L[[SYSROOT]]/usr/lib/profiled"
+
+// Check precedence: -p is unused when passed first on AIX.
+// RUN: %clang -### 2>&1 --target=powerpc-ibm-aix7.1.0.0 --sysroot %S/Inputs/aix_ppc_tree -p -pg %s \
+// RUN:| FileCheck --check-prefix=CHECK3 %s
+// CHECK3: warning: argument unused during compilation: '-p' [-Wunused-command-line-argument]
+// CHECK3: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK3: "[[SYSROOT]]/usr/lib{{/|}}gcrt0.o"
+// CHECK3: "-L[[SYSROOT]]/lib/profiled"
+// CHECK3: "-L[[SYSROOT]]/usr/lib/profiled"
+
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6322,20 +6322,26 @@
 << A->getAsString(Args) << TripleStr;
 }
   }
-  if (Arg *A = Args.getLastArgNoClaim(options::OPT_p)) {
-if (TC.getTriple().isOSAIX()) {
-  CmdArgs.push_back("-pg");
-} else if (!TC.getTriple().isOSOpenBSD()) {
+
+  if (Arg *A = Args.getLastArgNoClaim(options::OPT_pg)) {
+if (TC.getTriple().isOSzOS()) {
   D.Diag(diag::err_drv_unsupported_opt_for_target)
   << A->getAsString(Args) << TripleStr;
 }
   }
-  if (Arg *A = Args.getLastArgNoClaim(options::OPT_pg)) {
-if (TC.getTriple().isOSzOS()) {
+  if (Arg *A = Args.getLastArgNoClaim(options::OPT_p)) {
+if (!(TC.getTriple().isOSAIX() || TC.getTriple().isOSOpenBSD())) {
   D.Diag(diag::err_drv_unsupported_opt_for_target)
   << A->getAsString(Args) << TripleStr;
 }
   }
+  if (Arg *A = Args.getLastArgNoClaim(options::OPT_p, options::OPT_pg)) {
+if (A->getOption().matches(options::OPT_p)) {
+  A->claim();
+  if (TC.getTriple().isOSAIX() && !Args.hasArgNoClaim(options::OPT_pg))
+CmdArgs.push_back("-pg");
+}
+  }
 
   if (Args.getLastArg(options::OPT_fapple_kext) ||
   (Args.hasArg(options::OPT_mkernel) && types::isCXX(InputType)))
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -164,11 +164,12 @@
   }
 
   auto getCrt0Basename = [&Args, IsArch32Bit] {
+Arg *A = Args.getLastArgNoClaim(options::OPT_p, options::OPT_pg);
 // Enable gprofiling when "-pg" is specified.
-if (Args.hasArg(options::OPT_pg))
+if (A->getOption().matches(options::OPT_pg))
   return IsArch32Bit ? "gcrt0.o" : "gcrt0_64.o";
 // Enable profiling when "-p" is specified.
-else if (Args.hasArg(options::OPT_p))
+else if (A->getOption().matches(options::OPT_p))
   return IsArch32Bit ? "mcrt0.o" : "mcrt0_64.o";
 else
   return IsArch32Bit ? "crt0.o" : "crt0_64.o";
@@ -271,7 +272,7 @@
 
 CmdArgs.push_back("-lc");
 
-if (Args.hasArg(options::OPT_p, options::OPT_pg)) {
+if (Args.hasArgNoClaim(options::OPT_p, options::OPT_pg)) {
   CmdArgs.push_back(Args.MakeArgString((llvm::Twine("-L") + D.SysRoot) +
"/lib/p

[PATCH] D145190: [memprof] Record BuildIDs in the raw profile.

2023-03-14 Thread Snehasish Kumar via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa1bbf5ac3cbd: [memprof] Record BuildIDs in the raw profile. 
(authored by snehasish).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145190

Files:
  clang/test/CodeGen/Inputs/memprof.exe
  clang/test/CodeGen/Inputs/memprof.memprofraw
  compiler-rt/include/profile/MemProfData.inc
  compiler-rt/lib/memprof/memprof_allocator.cpp
  compiler-rt/lib/memprof/memprof_rawprofile.cpp
  compiler-rt/lib/memprof/memprof_rawprofile.h
  compiler-rt/lib/memprof/tests/rawprofile.cpp
  llvm/include/llvm/ProfileData/MemProfData.inc
  llvm/lib/ProfileData/RawMemProfReader.cpp
  llvm/test/Transforms/PGOProfile/Inputs/memprof.exe
  llvm/test/Transforms/PGOProfile/Inputs/memprof.memprofraw
  llvm/test/Transforms/PGOProfile/Inputs/memprof_pgo.profraw
  llvm/test/tools/llvm-profdata/Inputs/basic.memprofexe
  llvm/test/tools/llvm-profdata/Inputs/basic.memprofraw
  llvm/test/tools/llvm-profdata/Inputs/buildid.memprofexe
  llvm/test/tools/llvm-profdata/Inputs/buildid.memprofraw
  llvm/test/tools/llvm-profdata/Inputs/inline.memprofexe
  llvm/test/tools/llvm-profdata/Inputs/inline.memprofraw
  llvm/test/tools/llvm-profdata/Inputs/multi.memprofexe
  llvm/test/tools/llvm-profdata/Inputs/multi.memprofraw
  llvm/test/tools/llvm-profdata/Inputs/pic.memprofexe
  llvm/test/tools/llvm-profdata/Inputs/pic.memprofraw
  llvm/test/tools/llvm-profdata/Inputs/update_memprof_inputs.sh
  llvm/test/tools/llvm-profdata/memprof-basic.test
  llvm/test/tools/llvm-profdata/memprof-buildid.test
  llvm/test/tools/llvm-profdata/memprof-inline.test
  llvm/test/tools/llvm-profdata/memprof-multi.test

Index: llvm/test/tools/llvm-profdata/memprof-multi.test
===
--- llvm/test/tools/llvm-profdata/memprof-multi.test
+++ llvm/test/tools/llvm-profdata/memprof-multi.test
@@ -7,7 +7,7 @@
 
 CHECK:  MemprofProfile:
 CHECK-NEXT:  Summary:
-CHECK-NEXT:Version: 2
+CHECK-NEXT:Version: 3
 CHECK-NEXT:NumSegments: {{[0-9]+}}
 CHECK-NEXT:NumMibInfo: 2
 CHECK-NEXT:NumAllocFunctions: 1
Index: llvm/test/tools/llvm-profdata/memprof-inline.test
===
--- llvm/test/tools/llvm-profdata/memprof-inline.test
+++ llvm/test/tools/llvm-profdata/memprof-inline.test
@@ -5,17 +5,17 @@
 
 CHECK:  MemprofProfile:
 CHECK-NEXT:  Summary:
-CHECK-NEXT:Version: 2
+CHECK-NEXT:Version: 3
 CHECK-NEXT:NumSegments: {{[0-9]+}}
 CHECK-NEXT:NumMibInfo: 2
 CHECK-NEXT:NumAllocFunctions: 2
 CHECK-NEXT:NumStackOffsets: 1
 CHECK-NEXT:  Segments:
 CHECK-NEXT:  -
-CHECK-NEXT:BuildId: 
-CHECK-NEXT:Start: 0x{{[0-9]+}}
-CHECK-NEXT:End: 0x{{[0-9]+}}
-CHECK-NEXT:Offset: 0x{{[0-9]+}}
+CHECK-NEXT:BuildId: {{[[:xdigit:]]+}}
+CHECK-NEXT:Start: 0x{{[[:xdigit:]]+}}
+CHECK-NEXT:End: 0x{{[[:xdigit:]]+}}
+CHECK-NEXT:Offset: 0x{{[[:xdigit:]]+}}
 CHECK-NEXT:  -
 
 CHECK:  Records:
Index: llvm/test/tools/llvm-profdata/memprof-buildid.test
===
--- /dev/null
+++ llvm/test/tools/llvm-profdata/memprof-buildid.test
@@ -0,0 +1,12 @@
+REQUIRES: x86_64-linux
+
+To update the inputs used below run Inputs/update_memprof_inputs.sh /path/to/updated/clang
+RUN: llvm-readelf --notes %p/Inputs/buildid.memprofexe > %t1.txt
+RUN: llvm-profdata show --memory %p/Inputs/buildid.memprofraw --profiled-binary %p/Inputs/buildid.memprofexe -o -  > %t2.txt
+RUN: cat %t1.txt %t2.txt | FileCheck %s
+
+COM: First extract the id from the llvm-readelf output.
+CHECK: Build ID: [[ID:[[:xdigit:]]+]]
+
+COM: Then match it with the profdata output.
+CHECK: BuildId: {{.*}}[[ID]]
Index: llvm/test/tools/llvm-profdata/memprof-basic.test
===
--- llvm/test/tools/llvm-profdata/memprof-basic.test
+++ llvm/test/tools/llvm-profdata/memprof-basic.test
@@ -8,17 +8,17 @@
 
 CHECK:  MemprofProfile:
 CHECK-NEXT:   Summary:
-CHECK-NEXT: Version: 2
+CHECK-NEXT: Version: 3
 CHECK-NEXT: NumSegments: {{[0-9]+}}
 CHECK-NEXT: NumMibInfo: 2
 CHECK-NEXT: NumAllocFunctions: 1
 CHECK-NEXT: NumStackOffsets: 2
 CHECK-NEXT:   Segments:
 CHECK-NEXT:   -
-CHECK-NEXT: BuildId: 
-CHECK-NEXT: Start: 0x{{[0-9]+}}
-CHECK-NEXT: End: 0x{{[0-9]+}}
-CHECK-NEXT: Offset: 0x{{[0-9]+}}
+CHECK-NEXT: BuildId: {{[[:xdigit:]]+}}
+CHECK-NEXT: Start: 0x{{[[:xdigit:]]+}}
+CHECK-NEXT: End: 0x{{[[:xdigit:]]+}}
+CHECK-NEXT: Offset: 0x{{[[:xdigit:]]+}}
 CHECK-NEXT:   -
 
 CHECK:   Records:
Index: llvm/test/tools/llvm-profdata/Inputs/update_memprof_inputs.sh
===
--- llvm/test/tools/llvm-profdata/Inputs/update_memprof_inputs.sh
+++ llvm/test/tools/llvm-profdata/Inputs/update_memprof_inputs.sh
@@ -72,6 +72,

[PATCH] D143436: [clangd] Move standard options adaptor to CommandMangler

2023-03-14 Thread Dmitry Polukhin via Phabricator via cfe-commits
DmitryPolukhin added a comment.

@kadircet could you please take another look?
I had to update diff to make it work when LLVM is configured without X86 
targets so they are not valid and thus not injected into the command line.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143436

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


[clang] 8403ccd - [Clang][CodeGen] Fix linkage and visibility of template parameter objects

2023-03-14 Thread Alexander Shaposhnikov via cfe-commits

Author: Alexander Shaposhnikov
Date: 2023-03-14T18:23:06Z
New Revision: 8403ccdcd28c2ff30c1e980ce4a8c851fae01a9d

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

LOG: [Clang][CodeGen] Fix linkage and visibility of template parameter objects

This diff fixes linkage and visibility of template parameter objects.
The associated GitHub issue: https://github.com/llvm/llvm-project/issues/51571#

Test plan:
1/ ninja check-all
2/ bootstrapped Clang passes tests

Differential revision: https://reviews.llvm.org/D145859

Added: 
clang/test/CodeGenCXX/template-param-objects-linkage.cpp
clang/test/CodeGenCXX/template-param-objects-visibility.cpp

Modified: 
clang/lib/CodeGen/CodeGenModule.cpp
clang/test/CodeGenCXX/template-param-objects.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index b512fb576a2c0..7055205862ded 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -3238,9 +3238,13 @@ ConstantAddress 
CodeGenModule::GetAddrOfTemplateParamObject(
 return ConstantAddress::invalid();
   }
 
-  auto *GV = new llvm::GlobalVariable(
-  getModule(), Init->getType(),
-  /*isConstant=*/true, llvm::GlobalValue::LinkOnceODRLinkage, Init, Name);
+  llvm::GlobalValue::LinkageTypes Linkage =
+  isExternallyVisible(TPO->getLinkageAndVisibility().getLinkage())
+  ? llvm::GlobalValue::LinkOnceODRLinkage
+  : llvm::GlobalValue::InternalLinkage;
+  auto *GV = new llvm::GlobalVariable(getModule(), Init->getType(),
+  /*isConstant=*/true, Linkage, Init, 
Name);
+  setGVProperties(GV, TPO);
   if (supportsCOMDAT())
 GV->setComdat(TheModule.getOrInsertComdat(GV->getName()));
   Emitter.finalize(GV);

diff  --git a/clang/test/CodeGenCXX/template-param-objects-linkage.cpp 
b/clang/test/CodeGenCXX/template-param-objects-linkage.cpp
new file mode 100644
index 0..63e7d8c646869
--- /dev/null
+++ b/clang/test/CodeGenCXX/template-param-objects-linkage.cpp
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -std=c++20 %s -emit-llvm -o - | 
FileCheck %s
+
+struct S { char buf[32]; };
+template constexpr const char* f() { return s.buf; }
+const char* fbuf = f();
+// CHECK: @_ZTAXtl1StlA32_cLc97 = linkonce_odr constant { <{ i8, [31 x i8] 
}> }
+
+namespace {
+  struct UN { char buf[64]; };
+}
+template  constexpr const char* g() { return un.buf; }
+const char* gbuf = g();
+// CHECK: @_ZTAXtlN12_GLOBAL__N_12UNEtlA64_cLc98 = internal constant { <{ 
i8, [63 x i8] }> }
+
+struct Foo { int *i; };
+int m = 0;
+namespace { int n; }
+
+template 
+const int* h() { return foo.i; }
+
+const int* hm = h();
+// CHECK: @_ZTAXtl3FooadL_Z1mEEE = linkonce_odr constant %struct.Foo { ptr @m }
+
+const int* hn = h();
+// CHECK: @_ZTAXtl3FooadL_ZN12_GLOBAL__N_11n = internal constant 
%struct.Foo { ptr @_ZN12_GLOBAL__N_11nE }

diff  --git a/clang/test/CodeGenCXX/template-param-objects-visibility.cpp 
b/clang/test/CodeGenCXX/template-param-objects-visibility.cpp
new file mode 100644
index 0..bf85016b0aff6
--- /dev/null
+++ b/clang/test/CodeGenCXX/template-param-objects-visibility.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -std=c++20 %s -emit-llvm -o - | 
FileCheck %s
+
+struct S { char buf[32]; };
+template constexpr const char* f() { return s.buf; }
+const char* fbuf = f();
+// CHECK: @_ZTAXtl1StlA32_cLc97 = linkonce_odr constant { <{ i8, [31 x i8] 
}> }
+
+struct __attribute__ ((visibility ("hidden"))) HN { char buf[64]; };
+template  constexpr const char* g() { return hn.buf; }
+const char* gbuf = g();
+// CHECK: @_ZTAXtl2HNtlA64_cLc98 = linkonce_odr hidden constant { <{ i8, 
[63 x i8] }> }

diff  --git a/clang/test/CodeGenCXX/template-param-objects.cpp 
b/clang/test/CodeGenCXX/template-param-objects.cpp
index e36b27185b526..11ebd21521e83 100644
--- a/clang/test/CodeGenCXX/template-param-objects.cpp
+++ b/clang/test/CodeGenCXX/template-param-objects.cpp
@@ -7,7 +7,9 @@ template constexpr const char *end() { return s.buf + 
__builtin_strlen(s.bu
 
 // ITANIUM: 
[[HELLO:@_ZTAXtl1StlA32_cLc104ELc101ELc108ELc108ELc111ELc32ELc119ELc111ELc114ELc108ELc100]]
 // MSABI: 
[[HELLO:@"[?][?]__N2US@@3D0GI@@0GF@@0GM@@0GM@@0GP@@0CA@@0HH@@0GP@@0HC@@0GM@@0GE@@0A@@0A@@0A@@0A@@0A@@0A@@0A@@0A@@0A@@0A@@0A@@0A@@0A@@0A@@0A@@0A@@0A@@0A@@0A@@0A@@0A@"]]
-// CHECK-SAME: = linkonce_odr constant { <{ [11 x i8], [21 x i8] }> } { <{ [11 
x i8], [21 x i8] }> <{ [11 x i8] c"hello world", [21 x i8] zeroinitializer }> 
}, comdat
+// ITANIUM-SAME: = linkonce_odr constant { <{ [11 x i8], [21 x i8] }> } { <{ 
[11 x i8], [21 x i8] }> <{ [11 x i8] c"hello world", [21 x i8] zeroinitializer 
}> }, comdat
+// MSABI-SAME:

[PATCH] D145859: [Clang][CodeGen] Fix linkage and visibility of template parameter objects

2023-03-14 Thread Alexander Shaposhnikov 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 rG8403ccdcd28c: [Clang][CodeGen] Fix linkage and visibility of 
template parameter objects (authored by alexander-shaposhnikov).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145859

Files:
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGenCXX/template-param-objects-linkage.cpp
  clang/test/CodeGenCXX/template-param-objects-visibility.cpp
  clang/test/CodeGenCXX/template-param-objects.cpp


Index: clang/test/CodeGenCXX/template-param-objects.cpp
===
--- clang/test/CodeGenCXX/template-param-objects.cpp
+++ clang/test/CodeGenCXX/template-param-objects.cpp
@@ -7,7 +7,9 @@
 
 // ITANIUM: 
[[HELLO:@_ZTAXtl1StlA32_cLc104ELc101ELc108ELc108ELc111ELc32ELc119ELc111ELc114ELc108ELc100]]
 // MSABI: 
[[HELLO:@"[?][?]__N2US@@3D0GI@@0GF@@0GM@@0GM@@0GP@@0CA@@0HH@@0GP@@0HC@@0GM@@0GE@@0A@@0A@@0A@@0A@@0A@@0A@@0A@@0A@@0A@@0A@@0A@@0A@@0A@@0A@@0A@@0A@@0A@@0A@@0A@@0A@@0A@"]]
-// CHECK-SAME: = linkonce_odr constant { <{ [11 x i8], [21 x i8] }> } { <{ [11 
x i8], [21 x i8] }> <{ [11 x i8] c"hello world", [21 x i8] zeroinitializer }> 
}, comdat
+// ITANIUM-SAME: = linkonce_odr constant { <{ [11 x i8], [21 x i8] }> } { <{ 
[11 x i8], [21 x i8] }> <{ [11 x i8] c"hello world", [21 x i8] zeroinitializer 
}> }, comdat
+// MSABI-SAME: = linkonce_odr dso_local constant { <{ [11 x i8], [21 x i8] }> 
} { <{ [11 x i8], [21 x i8] }> <{ [11 x i8] c"hello world", [21 x i8] 
zeroinitializer }> }, comdat
+
 
 // ITANIUM: @p
 // MSABI: @"?p@@3PEBDEB"
Index: clang/test/CodeGenCXX/template-param-objects-visibility.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/template-param-objects-visibility.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -std=c++20 %s -emit-llvm -o - | 
FileCheck %s
+
+struct S { char buf[32]; };
+template constexpr const char* f() { return s.buf; }
+const char* fbuf = f();
+// CHECK: @_ZTAXtl1StlA32_cLc97 = linkonce_odr constant { <{ i8, [31 x i8] 
}> }
+
+struct __attribute__ ((visibility ("hidden"))) HN { char buf[64]; };
+template  constexpr const char* g() { return hn.buf; }
+const char* gbuf = g();
+// CHECK: @_ZTAXtl2HNtlA64_cLc98 = linkonce_odr hidden constant { <{ i8, 
[63 x i8] }> }
Index: clang/test/CodeGenCXX/template-param-objects-linkage.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/template-param-objects-linkage.cpp
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -std=c++20 %s -emit-llvm -o - | 
FileCheck %s
+
+struct S { char buf[32]; };
+template constexpr const char* f() { return s.buf; }
+const char* fbuf = f();
+// CHECK: @_ZTAXtl1StlA32_cLc97 = linkonce_odr constant { <{ i8, [31 x i8] 
}> }
+
+namespace {
+  struct UN { char buf[64]; };
+}
+template  constexpr const char* g() { return un.buf; }
+const char* gbuf = g();
+// CHECK: @_ZTAXtlN12_GLOBAL__N_12UNEtlA64_cLc98 = internal constant { <{ 
i8, [63 x i8] }> }
+
+struct Foo { int *i; };
+int m = 0;
+namespace { int n; }
+
+template 
+const int* h() { return foo.i; }
+
+const int* hm = h();
+// CHECK: @_ZTAXtl3FooadL_Z1mEEE = linkonce_odr constant %struct.Foo { ptr @m }
+
+const int* hn = h();
+// CHECK: @_ZTAXtl3FooadL_ZN12_GLOBAL__N_11n = internal constant 
%struct.Foo { ptr @_ZN12_GLOBAL__N_11nE }
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -3238,9 +3238,13 @@
 return ConstantAddress::invalid();
   }
 
-  auto *GV = new llvm::GlobalVariable(
-  getModule(), Init->getType(),
-  /*isConstant=*/true, llvm::GlobalValue::LinkOnceODRLinkage, Init, Name);
+  llvm::GlobalValue::LinkageTypes Linkage =
+  isExternallyVisible(TPO->getLinkageAndVisibility().getLinkage())
+  ? llvm::GlobalValue::LinkOnceODRLinkage
+  : llvm::GlobalValue::InternalLinkage;
+  auto *GV = new llvm::GlobalVariable(getModule(), Init->getType(),
+  /*isConstant=*/true, Linkage, Init, 
Name);
+  setGVProperties(GV, TPO);
   if (supportsCOMDAT())
 GV->setComdat(TheModule.getOrInsertComdat(GV->getName()));
   Emitter.finalize(GV);


Index: clang/test/CodeGenCXX/template-param-objects.cpp
===
--- clang/test/CodeGenCXX/template-param-objects.cpp
+++ clang/test/CodeGenCXX/template-param-objects.cpp
@@ -7,7 +7,9 @@
 
 // ITANIUM: [[HELLO:@_ZTAXtl1StlA32_cLc104ELc101ELc108ELc108ELc111ELc32ELc119ELc111ELc114ELc108ELc100]]
 // MSABI: [[HELLO:@"[?][?]__N2US@@3D0GI@@0GF@@0GM@@0GM@@0GP@@0CA@@0HH@@0GP@@0HC@@0GM@@0GE@@0A@@0A@@0A@@0A@@0

[PATCH] D146075: [flang][driver][openmp] Write MLIR for -save-temps

2023-03-14 Thread Sergio Afonso via Phabricator via cfe-commits
skatrak created this revision.
skatrak added reviewers: gregrodgers, dpalermo, domada, jsjodin, agozillon, 
kiranchandramohan, awarzynski.
Herald added subscribers: sunshaoce, bzcheeseman, rriddle, guansong, yaxunl.
Herald added a reviewer: sscalpone.
Herald added projects: Flang, All.
skatrak requested review of this revision.
Herald added subscribers: cfe-commits, sstefan1, stephenneuendorffer, 
jdoerfert, MaskRay.
Herald added a reviewer: jdoerfert.
Herald added a project: clang.

This patch adds support for producing MLIR files when using -save-temps on
flang. One MLIR file will be produced before lowering and optimization passes,
containing the operations produced by the PFT-to-MLIR lowering bridge, and
another at the end of the process, just before LLVM IR generation.

This is accomplished by forwarding the -save-temps flag from the driver to the
frontend, and modifying it to output MLIR files accordingly.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D146075

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Flang.cpp
  flang/include/flang/Frontend/CodeGenOptions.h
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/lib/Frontend/FrontendActions.cpp
  flang/test/Driver/driver-help.f90

Index: flang/test/Driver/driver-help.f90
===
--- flang/test/Driver/driver-help.f90
+++ flang/test/Driver/driver-help.f90
@@ -170,6 +170,8 @@
 ! HELP-FC1-NEXT: -pic-level   Value for __PIC__
 ! HELP-FC1-NEXT: -plugin  Use the named plugin action instead of the default action (use "help" to list available options)
 ! HELP-FC1-NEXT: -P Disable linemarker output in -E mode
+! HELP-FC1-NEXT: -save-temps=Save intermediate compilation results.
+! HELP-FC1-NEXT: -save-tempsSave intermediate compilation results
 ! HELP-FC1-NEXT: -std=   Language standard to compile for
 ! HELP-FC1-NEXT: -S Only run preprocess and compilation steps
 ! HELP-FC1-NEXT: -target-cpu Target a specific cpu type
Index: flang/lib/Frontend/FrontendActions.cpp
===
--- flang/lib/Frontend/FrontendActions.cpp
+++ flang/lib/Frontend/FrontendActions.cpp
@@ -13,6 +13,7 @@
 #include "flang/Frontend/FrontendActions.h"
 #include "flang/Common/default-kinds.h"
 #include "flang/Frontend/CompilerInstance.h"
+#include "flang/Frontend/CompilerInvocation.h"
 #include "flang/Frontend/FrontendOptions.h"
 #include "flang/Frontend/PreprocessorOptions.h"
 #include "flang/Lower/Bridge.h"
@@ -52,10 +53,14 @@
 #include "llvm/Passes/PassPlugin.h"
 #include "llvm/Passes/StandardInstrumentations.h"
 #include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/FileSystem.h"
 #include "llvm/Support/SourceMgr.h"
+#include "llvm/Support/ToolOutputFile.h"
 #include "llvm/Target/TargetMachine.h"
 #include "llvm/Transforms/Utils/ModuleUtils.h"
+#include 
 #include 
+#include 
 
 using namespace Fortran::frontend;
 
@@ -64,6 +69,52 @@
   llvm::PassPluginLibraryInfo get##Ext##PluginInfo();
 #include "llvm/Support/Extension.def"
 
+namespace {
+
+/// Save the given \c mlirModule to a temporary .mlir file, in a location
+/// decided by the -save-temps flag. No files are produced if the flag is not
+/// specified.
+bool saveMLIRTempFile(const CompilerInvocation &ci, mlir::ModuleOp mlirModule,
+  llvm::StringRef inputFile, llvm::StringRef outputTag) {
+  if (!ci.getCodeGenOpts().SaveTempsDir.has_value()) {
+return true;
+  }
+
+  const std::string &compilerOutFile = ci.getFrontendOpts().outputFile;
+  const std::string &dir = ci.getCodeGenOpts().SaveTempsDir.value();
+  std::string outDir =
+  llvm::StringSwitch(dir)
+  .Case("cwd", "")
+  .Case("obj", llvm::sys::path::parent_path(compilerOutFile).str())
+  .Default(dir);
+
+  if (llvm::sys::fs::is_directory(outDir)) {
+outDir.append("/");
+  }
+
+  // Build file name from the compiler output file name, triple, cpu and OpenMP
+  // information
+  llvm::StringRef input = llvm::sys::path::filename(inputFile);
+  std::string outFile = input.substr(0, input.find_last_of('.'))
+.str()
+.append("-")
+.append(outputTag.str())
+.append(".mlir");
+
+  std::error_code ec;
+  llvm::ToolOutputFile out(outDir + outFile, ec, llvm::sys::fs::OF_Text);
+  if (ec) {
+return false;
+  }
+  mlirModule->print(out.os());
+  out.os().close();
+  out.keep();
+
+  return true;
+}
+
+} // namespace
+
 //===--===//
 // Custom BeginSourceFileAction
 //===--===//
@@ -206,6 +257,15 @@
 return false;
   }
 
+  // FIR.mlir: This is 1st -save-temps file created for mlir
+  if (!saveMLIRTempFile(ci.getInvocation(), *ml

[PATCH] D125171: Add a new clang-format option AlwaysBreakBeforeFunctionParameters

2023-03-14 Thread jonathan molinatto via Phabricator via cfe-commits
jrmolin added a comment.

In D125171#4167866 , @owenpan wrote:

> Please see 
> https://clang.llvm.org/docs/ClangFormatStyleOptions.html#adding-additional-style-options.

I am doing this for my team, which writes the security endpoint for Elastic 
Defend. The code is currently private, though the binaries are free to download 
and run. The number of contributors is around 30, and the lines of code is in 
the 100Ks (around 500K). I have not found a way to accomplish what this does 
with the available options. I am adding tests and am happy to maintain this. It 
is a rather small addition, so it is quite simple to keep updated.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125171

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


[PATCH] D145369: Emit const globals with constexpr destructor as constant LLVM values

2023-03-14 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: clang/test/CodeGenCXX/static-init.cpp:181
+#if __cplusplus >= 202002L
+// A const object with constexpr destructor can be emitted as a constant.
+namespace test5 {

I don't see how this works.  For a static local variable, in general, we 
register the destructor with __cxa_atexit, and the destructor can have 
arbitrary side-effects.  For example:

```
extern void foo();
struct A {
  constexpr A() : x(1) {}
  constexpr ~A() {if (x) foo();}
  int x;
};
const int *f() {
  static const A a{};
  return &a.x;
}
```


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

https://reviews.llvm.org/D145369

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


[PATCH] D125171: Add a new clang-format option AlwaysBreakBeforeFunctionParameters

2023-03-14 Thread jonathan molinatto via Phabricator via cfe-commits
jrmolin marked 4 inline comments as done.
jrmolin added inline comments.



Comment at: clang/include/clang/Format/Format.h:827
+  /// \code
+  ///   someFunction(
+  ///   int argument1,

HazardyKnusperkeks wrote:
> That's not a valid declaration (missing return type), so not a good example.
fixed. creating a new patch with all the requested context.



Comment at: clang/include/clang/Format/Format.h:831
+  /// \endcode
+  bool AlwaysBreakBeforeFunctionParameters;
+

HazardyKnusperkeks wrote:
> HazardyKnusperkeks wrote:
> > Please sort alphabetically. (So above `AlwaysBreakBeforeMultilineStrings`.)
> You are missing the \since 17.
`\version 17`? I added this locally and am generating a new patch, with all the 
requested context.



Comment at: clang/include/clang/Format/Format.h:831
+  /// \endcode
+  bool AlwaysBreakBeforeFunctionParameters;
+

jrmolin wrote:
> HazardyKnusperkeks wrote:
> > HazardyKnusperkeks wrote:
> > > Please sort alphabetically. (So above 
> > > `AlwaysBreakBeforeMultilineStrings`.)
> > You are missing the \since 17.
> `\version 17`? I added this locally and am generating a new patch, with all 
> the requested context.
sorted. creating a patch with requested context



Comment at: clang/lib/Format/TokenAnnotator.cpp:4740-4742
+  if (Left.is(tok::l_paren) && Style.AlwaysBreakBeforeFunctionParameters &&
+  !Right.is(tok::r_paren)) {
+if (Left.Previous) {

HazardyKnusperkeks wrote:
> Merge the `if`s.
I'm not sure I collapsed what you wanted. I am generating a new patch with all 
the context.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125171

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


[PATCH] D145369: Emit const globals with constexpr destructor as constant LLVM values

2023-03-14 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:4344
+ (Record->hasTrivialDestructor() ||
+  Record->hasConstexprDestructor());
   }

For the purposes of CodeGen, checking `Record->hasConstexprDestructor()` isn't 
really helpful.  Even if `Record->hasConstexprDestructor()` is true, a 
destructor can still have side-effects.  Since the callers need to handle that 
possibility anyway, you might as well just skip the 
`Record->hasTrivialDestructor() || Record->hasConstexprDestructor()` check.


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

https://reviews.llvm.org/D145369

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


[PATCH] D129689: [limits.h] USHRT_MAX fix for 16 bit architectures

2023-03-14 Thread Sebastian Perta via Phabricator via cfe-commits
SebastianPerta added a comment.

@cor3ntin can I close it?


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

https://reviews.llvm.org/D129689

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


[PATCH] D145999: [RISCV] Reserve X18 by default for Android

2023-03-14 Thread Alex Bradbury via Phabricator via cfe-commits
asb accepted this revision.
asb added a comment.

LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145999

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


[PATCH] D145726: Fix assembler error when -g and -gdwarf-* is passed with -fno-integrated-as.

2023-03-14 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers requested changes to this revision.
nickdesaulniers added a comment.
This revision now requires changes to proceed.

The description needs to be rewritten to elucidate that this is purely to 
support old versions of the GNU assembler still in use by various Linux LTS 
distros.  This problem does not exist for folks using up to date tooling.  I 
would like to see specific GNU assembler version details in the commit 
description as well.




Comment at: clang/lib/Driver/ToolChains/Gnu.cpp:978-986
+  if (Arg *A = Args.getLastArg(options::OPT_g_Flag, options::OPT_gN_Group,
+   options::OPT_gdwarf_2, 
options::OPT_gdwarf_3,
+   options::OPT_gdwarf_4, 
options::OPT_gdwarf_5,
+   options::OPT_gdwarf))
+if (!A->getOption().matches(options::OPT_g0)) {
+  Args.AddLastArg(CmdArgs, options::OPT_g_Flag);
+  unsigned DwarfVersion = getDwarfVersion(getToolChain(), Args);

garvitgupta08 wrote:
> nickdesaulniers wrote:
> > Isn't this potentially going to add `-gdwarf-` repeatedly if there's many 
> > inputs?
> > 
> > Wouldn't it be better to scan the inputs to see if there's any .S or .s 
> > files, then add the flags once?
> Let me know if this is fine.
I don't think the current implementation addresses my point.  Having 
`CmdArgs.push_back` be called in a loop on the number of inputs will 
potentially add the arg repeatedly.

I think you should simply check if the `InputType` is asm or asm-with-cpp in 
the loop, potentially setting a boolean scoped outside the loop. Then, after 
the loop, decide whether to add the cmd arg.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145726

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


[PATCH] D125171: Add a new clang-format option AlwaysBreakBeforeFunctionParameters

2023-03-14 Thread jonathan molinatto via Phabricator via cfe-commits
jrmolin updated this revision to Diff 505215.
jrmolin marked 3 inline comments as done.
jrmolin added a comment.

respond to code review requests/comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125171

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

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -25346,6 +25346,27 @@
   verifyFormat("auto x = 5s .count() == 5;");
 }
 
+TEST_F(FormatTest, BreakBeforeParameterList) {
+  FormatStyle Style = getLLVMStyle();
+  EXPECT_EQ(Style.AlwaysBreakBeforeFunctionParameters, false);
+
+  const StringRef Code("int function1(int param1, int param2, int param3);\n"
+   "int function2();\n");
+
+  // verify that there is no break by default
+  verifyFormat("int function1(int param1, int param2, int param3);\n"
+   "int function2();\n",
+   Code, Style);
+
+  // verify that there is a break when told to break
+  Style.AlwaysBreakBeforeFunctionParameters = true;
+  verifyFormat("int function1(\n"
+   "int param1,\n"
+   "int param2,\n"
+   "int param3);\n"
+   "int function2();\n",
+   Code, Style);
+}
 } // namespace
 } // namespace test
 } // namespace format
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -4737,6 +4737,16 @@
 return true;
   }
 
+  // If AlwaysBreakBeforeFunctionParameters is true, we want to break before
+  // the next parameter, if there is one.
+  if (Left.is(tok::l_paren) && Style.AlwaysBreakBeforeFunctionParameters &&
+  !Right.is(tok::r_paren) && Left.Previous) {
+  const FormatToken &TwoPrevious = *Left.Previous;
+  if (TwoPrevious.is(TT_FunctionDeclarationName)) {
+  return true;
+  }
+  }
+
   // If the last token before a '}', ']', or ')' is a comma or a trailing
   // comment, the intention is to insert a line break after it in order to make
   // shuffling around entries easier. Import statements, especially in
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -870,6 +870,8 @@
Style.AlwaysBreakAfterReturnType);
 IO.mapOptional("AlwaysBreakBeforeMultilineStrings",
Style.AlwaysBreakBeforeMultilineStrings);
+IO.mapOptional("AlwaysBreakBeforeFunctionParameters",
+   Style.AlwaysBreakBeforeFunctionParameters);
 IO.mapOptional("AlwaysBreakTemplateDeclarations",
Style.AlwaysBreakTemplateDeclarations);
 IO.mapOptional("AttributeMacros", Style.AttributeMacros);
@@ -1325,6 +1327,7 @@
   LLVMStyle.AllowShortLoopsOnASingleLine = false;
   LLVMStyle.AlwaysBreakAfterReturnType = FormatStyle::RTBS_None;
   LLVMStyle.AlwaysBreakAfterDefinitionReturnType = FormatStyle::DRTBS_None;
+  LLVMStyle.AlwaysBreakBeforeFunctionParameters = false;
   LLVMStyle.AlwaysBreakBeforeMultilineStrings = false;
   LLVMStyle.AlwaysBreakTemplateDeclarations = FormatStyle::BTDS_MultiLine;
   LLVMStyle.AttributeMacros.push_back("__capability");
Index: clang/lib/Format/ContinuationIndenter.cpp
===
--- clang/lib/Format/ContinuationIndenter.cpp
+++ clang/lib/Format/ContinuationIndenter.cpp
@@ -354,6 +354,11 @@
 auto LambdaBodyLength = getLengthToMatchingParen(Current, State.Stack);
 return LambdaBodyLength > getColumnLimit(State);
   }
+  // Check if we want to break before function parameters in declarations
+  if (startsNextParameter(Current, Style) &&
+  Style.AlwaysBreakBeforeFunctionParameters &&
+  State.Line->MustBeDeclaration)
+return true;
   if (Current.MustBreakBefore ||
   (Current.is(TT_InlineASMColon) &&
(Style.BreakBeforeInlineASMColon == FormatStyle::BBIAS_Always ||
@@ -1055,7 +1060,9 @@
 // If we are breaking after '(', '{', '<', or this is the break after a ':'
 // to start a member initializater list in a constructor, this should not
 // be considered bin packing unless the relevant AllowAll option is false or
-// this is a dict/object literal.
+// this is a dict/object literal. Break if
+// AlwaysBreakBeforeFunctionParameters is true and it's a function
+// declaration.
 bool PreviousIsBreakingCtorInitializerColon =
 PreviousNonComment && PreviousNonComment->is(TT_CtorInitializerColon) &&
 Style.BreakConst

[PATCH] D145564: [clang][docs] Clarify the semantics of -fexceptions

2023-03-14 Thread Eli Friedman via Phabricator via cfe-commits
efriedma accepted this revision.
efriedma added a comment.
This revision is now accepted and ready to land.

LGTM


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

https://reviews.llvm.org/D145564

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


[PATCH] D145726: Fix assembler error when -g and -gdwarf-* is passed with -fno-integrated-as.

2023-03-14 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added inline comments.



Comment at: clang/lib/Driver/ToolChains/Gnu.cpp:978-986
+  if (Arg *A = Args.getLastArg(options::OPT_g_Flag, options::OPT_gN_Group,
+   options::OPT_gdwarf_2, 
options::OPT_gdwarf_3,
+   options::OPT_gdwarf_4, 
options::OPT_gdwarf_5,
+   options::OPT_gdwarf))
+if (!A->getOption().matches(options::OPT_g0)) {
+  Args.AddLastArg(CmdArgs, options::OPT_g_Flag);
+  unsigned DwarfVersion = getDwarfVersion(getToolChain(), Args);

nickdesaulniers wrote:
> garvitgupta08 wrote:
> > nickdesaulniers wrote:
> > > Isn't this potentially going to add `-gdwarf-` repeatedly if there's many 
> > > inputs?
> > > 
> > > Wouldn't it be better to scan the inputs to see if there's any .S or .s 
> > > files, then add the flags once?
> > Let me know if this is fine.
> I don't think the current implementation addresses my point.  Having 
> `CmdArgs.push_back` be called in a loop on the number of inputs will 
> potentially add the arg repeatedly.
> 
> I think you should simply check if the `InputType` is asm or asm-with-cpp in 
> the loop, potentially setting a boolean scoped outside the loop. Then, after 
> the loop, decide whether to add the cmd arg.
Specifically, if `llvm::any_of` the inputs are asm or asm-with-cpp, then we 
might want to modify the command line flags passed to the external assembler.

We don't want to pass additional flags per input.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145726

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


[PATCH] D145851: [Clang][Sema] Fix incorrect deletion of default constructors for some unions

2023-03-14 Thread Roy Jacobson via Phabricator via cfe-commits
royjacobson updated this revision to Diff 505216.
royjacobson added a comment.

Fix the codegen test, add a standard ref to the comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145851

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/CodeGen/union-non-trivial-member.cpp
  clang/test/SemaCXX/cxx0x-nontrivial-union.cpp

Index: clang/test/SemaCXX/cxx0x-nontrivial-union.cpp
===
--- clang/test/SemaCXX/cxx0x-nontrivial-union.cpp
+++ clang/test/SemaCXX/cxx0x-nontrivial-union.cpp
@@ -144,3 +144,47 @@
 
   Test2 t2x;  // expected-error {{call to implicitly-deleted default constructor of 'Test2'}}
 }
+
+namespace GH48416 {
+
+struct non_trivial_constructor {
+constexpr non_trivial_constructor() : x(100) {}
+int x;
+};
+
+
+union U1 {
+int a;
+non_trivial_constructor b; // expected-note {{has a non-trivial default constructor}}
+};
+
+union U2 {
+int a{1000};
+non_trivial_constructor b;
+};
+
+union U3 {
+int a;
+non_trivial_constructor b{};
+};
+
+union U4 {
+int a{}; // expected-note {{previous initialization is here}}
+non_trivial_constructor b{}; // expected-error {{initializing multiple members of union}}
+};
+
+U1 u1; // expected-error {{call to implicitly-deleted default constructor}}
+U2 u2;
+U3 u3;
+U4 u4;
+
+static_assert(U2().a == 1000, "");
+static_assert(U3().a == 1000, "");
+// expected-error@-1 {{static assertion expression is not an integral constant expression}}
+// expected-note@-2 {{read of member 'a' of union with active member 'b'}}
+static_assert(U2().b.x == 100, "");
+// expected-error@-1 {{static assertion expression is not an integral constant expression}}
+// expected-note@-2 {{read of member 'b' of union with active member 'a'}}
+static_assert(U3().b.x == 100, "");
+
+} // namespace GH48416
Index: clang/test/CodeGen/union-non-trivial-member.cpp
===
--- /dev/null
+++ clang/test/CodeGen/union-non-trivial-member.cpp
@@ -0,0 +1,52 @@
+// RUN: %clang_cc1 --std=c++17 -emit-llvm %s -o - -triple x86_64-unknown-linux-gnu | FileCheck %s
+
+struct non_trivial_constructor {
+constexpr non_trivial_constructor() : x(100) { }
+int x;
+};
+
+union UnionInt {
+int a{1000};
+non_trivial_constructor b;
+};
+
+union UnionNonTrivial {
+int a;
+non_trivial_constructor b{};
+};
+
+void f() {
+UnionInt u1;
+UnionNonTrivial u2;
+}
+
+// CHECK:  define dso_local void @_Z1fv() {{.*}} {
+// CHECK-NEXT: entry:
+// CHECK:call void @_ZN8UnionIntC1Ev{{.*}}
+// CHECK-NEXT:   call void @_ZN15UnionNonTrivialC1Ev{{.*}}
+// CHECK-NEXT:   ret void
+// CHECK-NEXT: }
+
+// CHECK:  define {{.*}} void @_ZN8UnionIntC1Ev{{.*}}
+// CHECK-NEXT: entry:
+// CHECK:call void @_ZN8UnionIntC2Ev{{.*}}
+// CHECK-NEXT:   ret void
+// CHECK-NEXT: }
+
+// CHECK:  define {{.*}} void @_ZN15UnionNonTrivialC1Ev{{.*}}
+// CHECK-NEXT: entry:
+// CHECK:call void @_ZN15UnionNonTrivialC2Ev{{.*}}
+// CHECK-NEXT:   ret void
+// CHECK-NEXT: }
+
+// CHECK:  define {{.*}} void @_ZN8UnionIntC2Ev{{.*}}
+// CHECK-NEXT: entry:
+// CHECK:store i32 1000{{.*}}
+// CHECK-NEXT:   ret void
+// CHECK-NEXT: }
+
+// CHECK:  define {{.*}} void @_ZN15UnionNonTrivialC2Ev{{.*}}
+// CHECK-NEXT: entry:
+// CHECK:call void @_ZN23non_trivial_constructorC1Ev{{.*}}
+// CHECK-NEXT:   ret void
+// CHECK-NEXT: }
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -9157,7 +9157,18 @@
 // must be accessible and non-deleted, but need not be trivial. Such a
 // destructor is never actually called, but is semantically checked as
 // if it were.
-DiagKind = 4;
+if (CSM == Sema::CXXDefaultConstructor) {
+  // [class.default.ctor]p2:
+  //   A defaulted default constructor for class X is defined as deleted if
+  //   - X is a union that has a variant member with a non-trivial default
+  // constructor and no variant member of X has a default member
+  // initializer
+  const auto *RD = cast(Field->getParent());
+  if (!RD->hasInClassInitializer())
+DiagKind = 4;
+} else {
+  DiagKind = 4;
+}
   }
 
   if (DiagKind == -1)
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -202,6 +202,8 @@
 - Fix crash when evaluating consteval constructor of derived class whose base
   has more than one field.
   (`#60166 `_)
+- Fix incorrect deletion of the default constructor of unions in some
+  cases. (`#48416 

[PATCH] D145851: [Clang][Sema] Fix incorrect deletion of default constructors for some unions

2023-03-14 Thread Roy Jacobson via Phabricator via cfe-commits
royjacobson added a comment.

Oops, sorry for the bad codegen test and thanks for the comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145851

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


[PATCH] D146041: Fix weirdly apologetic diagnostic messages

2023-03-14 Thread Aryan Godara via Phabricator via cfe-commits
AryanGodara added a comment.

In D146041#4192816 , @mehdi_amini 
wrote:

> You should look into the title and description of the commit: 
> https://cbea.ms/git-commit/

Is the title and description appropriate now?
I can add more details to the description, as required


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146041

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


  1   2   3   >