[PATCH] D145840: [Docs] Added -fomit-frame-pointer and -fno-omit-frame-pointer flag documentation

2023-03-11 Thread Tiwari Abhinav Ashok Kumar via Phabricator via cfe-commits
aabhinavg created this revision.
aabhinavg added reviewers: MaskRay, vitalybuka, aheejin.
Herald added a project: All.
aabhinavg requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Fix #61322


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D145840

Files:
  clang/include/clang/Driver/Options.td


Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2535,7 +2535,8 @@
   Flags<[CoreOption]>;
 def fno_objc_legacy_dispatch : Flag<["-"], "fno-objc-legacy-dispatch">, 
Group;
 def fno_objc_weak : Flag<["-"], "fno-objc-weak">, Group, 
Flags<[CC1Option]>;
-def fno_omit_frame_pointer : Flag<["-"], "fno-omit-frame-pointer">, 
Group;
+def fno_omit_frame_pointer : Flag<["-"], "fno-omit-frame-pointer">, 
Group,
+  HelpText<"Help to produce better stack traces during debugging">;
 defm operator_names : BoolFOption<"operator-names",
   LangOpts<"CXXOperatorNames">, Default,
   NegFlag,
@@ -2638,7 +2639,8 @@
   NegFlag,
   BothFlags<[CC1Option, NoDriverOption], " to avoid heapifying local blocks">>;
 
-def fomit_frame_pointer : Flag<["-"], "fomit-frame-pointer">, Group;
+def fomit_frame_pointer : Flag<["-"], "fomit-frame-pointer">, Group,
+  HelpText<"Used to instruct the compiler to omit the frame pointer which 
leads to smaller code size and faster execution.">;
 def fopenmp : Flag<["-"], "fopenmp">, Group, Flags<[CC1Option, 
NoArgumentUnused, FlangOption, FC1Option]>,
   HelpText<"Parse OpenMP pragmas and generate parallel code.">;
 def fno_openmp : Flag<["-"], "fno-openmp">, Group, 
Flags<[NoArgumentUnused]>;


Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2535,7 +2535,8 @@
   Flags<[CoreOption]>;
 def fno_objc_legacy_dispatch : Flag<["-"], "fno-objc-legacy-dispatch">, Group;
 def fno_objc_weak : Flag<["-"], "fno-objc-weak">, Group, Flags<[CC1Option]>;
-def fno_omit_frame_pointer : Flag<["-"], "fno-omit-frame-pointer">, Group;
+def fno_omit_frame_pointer : Flag<["-"], "fno-omit-frame-pointer">, Group,
+  HelpText<"Help to produce better stack traces during debugging">;
 defm operator_names : BoolFOption<"operator-names",
   LangOpts<"CXXOperatorNames">, Default,
   NegFlag,
@@ -2638,7 +2639,8 @@
   NegFlag,
   BothFlags<[CC1Option, NoDriverOption], " to avoid heapifying local blocks">>;
 
-def fomit_frame_pointer : Flag<["-"], "fomit-frame-pointer">, Group;
+def fomit_frame_pointer : Flag<["-"], "fomit-frame-pointer">, Group,
+  HelpText<"Used to instruct the compiler to omit the frame pointer which leads to smaller code size and faster execution.">;
 def fopenmp : Flag<["-"], "fopenmp">, Group, Flags<[CC1Option, NoArgumentUnused, FlangOption, FC1Option]>,
   HelpText<"Parse OpenMP pragmas and generate parallel code.">;
 def fno_openmp : Flag<["-"], "fno-openmp">, Group, Flags<[NoArgumentUnused]>;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D139834: [clang-format] AllowShortCompoundRequirementOnASingleLine

2023-03-11 Thread Emilia Dreamer via Phabricator via cfe-commits
rymiel added inline comments.



Comment at: clang/lib/Format/Format.cpp:809
Style.AllowShortCaseLabelsOnASingleLine);
+IO.mapOptional("AllowShortCompoundRequirementOnASingleLine",
+   Style.AllowShortCompoundRequirementOnASingleLine);

Backl1ght wrote:
> MyDeveloperDay wrote:
> > haven't we use "Requires" in other options? What is the definition of 
> > Compound?
> > 
> > I might be tempted for this to be AllShortRequiresOnASingleLine but then it 
> > be an enum with the following options
> > 
> > ```
> > Leave
> > Never
> > Always
> > Compound
> > ```
> There are some options related to requires like IndentRequiresClause, 
> RequiresClausePosition, etc. But as for single line and brace wrapping, 
> requires is not yet considered.
> 
> "Compound" is from Compound Requirements section in this page 
> https://en.cppreference.com/w/cpp/language/requires
> 
> I think this is a better way, I would try implementing it.
A //compound-requirement// is what the standard calls it, so I think the name 
is fine.

I'm not sure if collating it with other options as suggested is a good idea, 
since a //requires-expression// can contain multiple //compound-requirement//s, 
such as:

```
requires {
  { E1 } -> C;
  { E2 } -> D;
};
```

This //requires-expression// has two //compound-requirement//s, and two 
formatting of those two individually is what's being controlled by the option.

Although I will agree it should probably still be an enum, but in that case, it 
probably shouldn't start with "Allow"


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139834

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


[PATCH] D145841: [clang][Interp] Fix diagnostics for calling non-constexpr constructors

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

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D145841

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


Index: clang/test/AST/Interp/records.cpp
===
--- clang/test/AST/Interp/records.cpp
+++ clang/test/AST/Interp/records.cpp
@@ -308,7 +308,7 @@
 };
 
 namespace DeriveFailures {
-  struct Base { // ref-note 2{{declared here}}
+  struct Base { // ref-note 2{{declared here}} expected-note {{declared here}}
 int Val;
   };
 
@@ -316,13 +316,15 @@
 int OtherVal;
 
 constexpr Derived(int i) : OtherVal(i) {} // ref-error {{never produces a 
constant expression}} \
-  // ref-note 2{{non-constexpr 
constructor 'Base' cannot be used in a constant expression}}
+  // ref-note 2{{non-constexpr 
constructor 'Base' cannot be used in a constant expression}} \
+  // expected-note {{non-constexpr 
constructor 'Base' cannot be used in a constant expression}}
   };
 
   constexpr Derived D(12); // ref-error {{must be initialized by a constant 
expression}} \
// ref-note {{in call to 'Derived(12)'}} \
// ref-note {{declared here}} \
-   // expected-error {{must be initialized by a 
constant expression}}
+   // expected-error {{must be initialized by a 
constant expression}} \
+   // expected-note {{in call to 'Derived(12)'}}
   static_assert(D.Val == 0, ""); // ref-error {{not an integral constant 
expression}} \
  // ref-note {{initializer of 'D' is not a 
constant expression}} \
  // expected-error {{not an integral constant 
expression}} \
@@ -348,7 +350,7 @@
   };
 
   struct YetAnotherDerived : YetAnotherBase {
-using YetAnotherBase::YetAnotherBase; //ref-note {{declared here}}
+using YetAnotherBase::YetAnotherBase; //ref-note {{declared here}} 
expected-note {{declared here}}
 int OtherVal;
 
 constexpr bool doit() const { return Val == OtherVal; }
@@ -356,8 +358,8 @@
 
   constexpr YetAnotherDerived Oops(0); // ref-error {{must be initialized by a 
constant expression}} \
// ref-note {{constructor inherited 
from base class 'YetAnotherBase' cannot be used in a constant expression}} \
-   // expected-error {{must be initialized 
by a constant expression}}
-   // FIXME: Missing reason for rejection.
+   // expected-error {{must be initialized 
by a constant expression}} \
+   // expected-note {{constructor 
inherited from base class 'YetAnotherBase' cannot be used in a constant 
expression}}
 };
 
 namespace EmptyCtor {
Index: clang/test/AST/Interp/cxx20.cpp
===
--- clang/test/AST/Interp/cxx20.cpp
+++ clang/test/AST/Interp/cxx20.cpp
@@ -207,13 +207,15 @@
   // ref-note {{declared const here}}
 int a;
   public:
-constexpr Foo() {
+constexpr Foo() { // expected-note {{declared here}}
   this->a = 10;
   T = 13; // expected-error {{cannot assign to non-static data member 'T' 
with const-qualified type}} \
   // ref-error {{cannot assign to non-static data member 'T' with 
const-qualified type}}
 }
   };
   constexpr Foo F; // expected-error {{must be initialized by a constant 
expression}} \
+   // FIXME: The following note is wrong.
+   // expected-note {{undefined constructor 'Foo' cannot be 
used in a constant expression}} \
// ref-error {{must be initialized by a constant 
expression}}
 
 
Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp
===
--- clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -1376,7 +1376,7 @@
   if (const auto CtorExpr = dyn_cast(Initializer)) {
 const Function *Func = getFunction(CtorExpr->getConstructor());
 
-if (!Func || !Func->isConstexpr())
+if (!Func)
   return false;
 
 // The This pointer is already on the stack because this is an initializer,


Index: clang/test/AST/Interp/records.cpp
===
--- clang/test/AST/Interp/records.cpp
+++ clang/test/AST/Interp/records.cpp
@@ -308,7 +308,7 @@
 };
 
 namespace DeriveFailures {
-

[PATCH] D145642: [clang-format] Annotate lambdas with requires clauses.

2023-03-11 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment.

In D145642#4186462 , @rymiel wrote:

> Could you please clarify what you mean by "regressions" here? Isn't the 
> behaviour of this syntax broken to begin with? It doesn't change anything 
> about lambdas without //requires-clause//s

Let's use you example :

  $ cat test.cpp
  #include 
  
  template 
  struct foo {
  static const bool value = true;
  };
  
  template 
  inline constexpr bool foo_v = foo::value;
  
  template 
  concept foo_c = foo_v;
  
  int main() {
[&]
  requires foo::value
(Callable&& callable)
{
  static_cast(callable);
};
  
[&]
  requires foo_c
(Callable&& callable)
{
  static_cast(callable);
};
  
[&]
  requires foo_v
(Callable&& callable)
{
  static_cast(callable);
};
  }
  $ clang-format -version
  clang-format version 17.0.0 (https://github.com/llvm/llvm-project 
f6e7a5c29221f445e4cbddc32667a1e12a1446db)
  $ clang-format test.cpp
  #include 
  
  template  struct foo {
static const bool value = true;
  };
  
  template  inline constexpr bool foo_v = foo::value;
  
  template 
  concept foo_c = foo_v;
  
  int main() {
[&]
  requires foo::value(Callable && callable)
{
  static_cast(callable);
};
  
[&]
  requires foo_c(Callable && callable)
{
  static_cast(callable);
};
  
[&]
  requires foo_v(Callable && callable)
{
  static_cast(callable);
};
  }

If this patch would merge the lambda bodies into single lines, would that be 
considered a possible regression? My guess is that it would be unless the 
lambda bodies should be merged in the first place, in which case the patch 
would also fix a formatting bug in addition to the annotation bug.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145642

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


[PATCH] D145842: [clang][Sema] Avoid duplicate diagnostics for unreachable fallthrough attribute

2023-03-11 Thread Takuya Shimizu via Phabricator via cfe-commits
hazohelet created this revision.
hazohelet added reviewers: tbaeder, aaron.ballman, cjdb.
Herald added a reviewer: NoQ.
Herald added a project: All.
hazohelet requested review of this revision.
Herald added a project: clang.

This patch checks whether `-Wunreachable-code-fallthrough` is enabled when 
clang encounters unreachable fallthrough attributes and, if so, suppresses 
`code will never be executed` warning to avoid duplicate warnings.
This fixes https://github.com/llvm/llvm-project/issues/60416


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D145842

Files:
  clang/include/clang/Analysis/Analyses/ReachableCode.h
  clang/lib/Analysis/ReachableCode.cpp
  clang/lib/Sema/AnalysisBasedWarnings.cpp
  clang/test/Sema/warn-unreachable-fallthrough.c

Index: clang/test/Sema/warn-unreachable-fallthrough.c
===
--- /dev/null
+++ clang/test/Sema/warn-unreachable-fallthrough.c
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c2x -Wunreachable-code-fallthrough %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c2x -Wunreachable-code %s
+// RUN: %clang_cc1 -fsyntax-only -verify=code -std=c2x -Wunreachable-code -Wno-unreachable-code-fallthrough %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c2x -Wno-unreachable-code -Wunreachable-code-fallthrough %s
+
+int n;
+void f(void){
+ switch (n){
+ [[fallthrough]]; // expected-warning{{fallthrough annotation in unreachable code}}
+  // code-warning@-1{{never be executed}}
+ case 1:;
+ }
+}
Index: clang/lib/Sema/AnalysisBasedWarnings.cpp
===
--- clang/lib/Sema/AnalysisBasedWarnings.cpp
+++ clang/lib/Sema/AnalysisBasedWarnings.cpp
@@ -123,7 +123,8 @@
 return;
 
   UnreachableCodeHandler UC(S);
-  reachable_code::FindUnreachableCode(AC, S.getPreprocessor(), UC);
+  reachable_code::FindUnreachableCode(AC, S.getPreprocessor(),
+  S.getDiagnostics(), UC);
 }
 
 namespace {
Index: clang/lib/Analysis/ReachableCode.cpp
===
--- clang/lib/Analysis/ReachableCode.cpp
+++ clang/lib/Analysis/ReachableCode.cpp
@@ -12,6 +12,7 @@
 //===--===//
 
 #include "clang/Analysis/Analyses/ReachableCode.h"
+#include "clang/AST/Attr.h"
 #include "clang/AST/Expr.h"
 #include "clang/AST/ExprCXX.h"
 #include "clang/AST/ExprObjC.h"
@@ -22,6 +23,7 @@
 #include "clang/Basic/Builtins.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Lex/Preprocessor.h"
+#include "clang/Sema/SemaDiagnostic.h"
 #include "llvm/ADT/BitVector.h"
 #include "llvm/ADT/SmallVector.h"
 #include 
@@ -408,15 +410,15 @@
   PP(PP), C(C) {}
 
 void enqueue(const CFGBlock *block);
-unsigned scanBackwards(const CFGBlock *Start,
-clang::reachable_code::Callback &CB);
+unsigned scanBackwards(const CFGBlock *Start, const DiagnosticsEngine &Diag,
+   clang::reachable_code::Callback &CB);
 
 bool isDeadCodeRoot(const CFGBlock *Block);
 
 const Stmt *findDeadCode(const CFGBlock *Block);
 
-void reportDeadCode(const CFGBlock *B,
-const Stmt *S,
+void reportDeadCode(const CFGBlock *B, const Stmt *S,
+const DiagnosticsEngine &Diag,
 clang::reachable_code::Callback &CB);
   };
 }
@@ -488,6 +490,7 @@
 }
 
 unsigned DeadCodeScan::scanBackwards(const clang::CFGBlock *Start,
+ const DiagnosticsEngine &Diag,
  clang::reachable_code::Callback &CB) {
 
   unsigned count = 0;
@@ -521,7 +524,7 @@
 }
 
 if (isDeadCodeRoot(Block)) {
-  reportDeadCode(Block, S, CB);
+  reportDeadCode(Block, S, Diag, CB);
   count += scanMaybeReachableFromBlock(Block, PP, Reachable);
 }
 else {
@@ -540,7 +543,7 @@
   const CFGBlock *Block = I.first;
   if (Reachable[Block->getBlockID()])
 continue;
-  reportDeadCode(Block, I.second, CB);
+  reportDeadCode(Block, I.second, Diag, CB);
   count += scanMaybeReachableFromBlock(Block, PP, Reachable);
 }
   }
@@ -613,8 +616,8 @@
   return S->getBeginLoc();
 }
 
-void DeadCodeScan::reportDeadCode(const CFGBlock *B,
-  const Stmt *S,
+void DeadCodeScan::reportDeadCode(const CFGBlock *B, const Stmt *S,
+  const DiagnosticsEngine &Diag,
   clang::reachable_code::Callback &CB) {
   // Classify the unreachable code found, or suppress it in some cases.
   reachable_code::UnreachableKind UK = reachable_code::UK_Other;
@@ -663,6 +666,16 @@
 }
   }
 
+  // If S is `[[fallthrough]];` and `-Wunreachable-code-fallthrough` is enabled,
+  // suppress `code will never be executed` warning to avoid generating
+  // 

[PATCH] D145833: Switch ABI references to env/environment

2023-03-11 Thread Renato Golin via Phabricator via cfe-commits
rengolin accepted this revision.
rengolin added a comment.
This revision is now accepted and ready to land.

IIRC, "abi" used to be what Arm called, but "env" is equally good. And it it's 
consistent with `Triple.h`, even better. LGTM, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145833

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


[PATCH] D145843: [clangd] Add option to always insert headers with <> instead of ""

2023-03-11 Thread Andrew Kaster via Phabricator via cfe-commits
ADKaster created this revision.
Herald added subscribers: kadircet, arphaman.
Herald added a project: All.
ADKaster requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

Projects can now add the following config fragment to their .clangd:

  yaml
  Style:
AlwaysBracketedInclude: Yes

to force headers inserted via the --header-insertion=iwyu mode to have
<> around them in all cases, rather than relying on whether the header
was included via -isystem or not.

Ref https://github.com/clangd/clangd/issues/1247

This solution does not allow forcing "" in all cases, nor does it affect
other clang tools like clang-format.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D145843

Files:
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/Config.h
  clang-tools-extra/clangd/ConfigCompile.cpp
  clang-tools-extra/clangd/ConfigFragment.h
  clang-tools-extra/clangd/ConfigYAML.cpp
  clang-tools-extra/clangd/Headers.cpp
  clang-tools-extra/clangd/Headers.h
  clang-tools-extra/clangd/ParsedAST.cpp
  clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
  clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
  clang-tools-extra/clangd/unittests/HeadersTests.cpp

Index: clang-tools-extra/clangd/unittests/HeadersTests.cpp
===
--- clang-tools-extra/clangd/unittests/HeadersTests.cpp
+++ clang-tools-extra/clangd/unittests/HeadersTests.cpp
@@ -108,7 +108,8 @@
 
 IncludeInserter Inserter(MainFile, /*Code=*/"", format::getLLVMStyle(),
  CDB.getCompileCommand(MainFile)->Directory,
- &Clang->getPreprocessor().getHeaderSearchInfo());
+ &Clang->getPreprocessor().getHeaderSearchInfo(),
+ AlwaysBracketedInclude);
 for (const auto &Inc : Inclusions)
   Inserter.addExisting(Inc);
 auto Inserted = ToHeaderFile(Preferred);
@@ -128,7 +129,8 @@
 
 IncludeInserter Inserter(MainFile, /*Code=*/"", format::getLLVMStyle(),
  CDB.getCompileCommand(MainFile)->Directory,
- &Clang->getPreprocessor().getHeaderSearchInfo());
+ &Clang->getPreprocessor().getHeaderSearchInfo(),
+ AlwaysBracketedInclude);
 auto Edit = Inserter.insert(VerbatimHeader, Directive);
 Action.EndSourceFile();
 return Edit;
@@ -139,6 +141,7 @@
   std::string MainFile = testPath("main.cpp");
   std::string Subdir = testPath("sub");
   std::string SearchDirArg = (llvm::Twine("-I") + Subdir).str();
+  bool AlwaysBracketedInclude = false;
   IgnoringDiagConsumer IgnoreDiags;
   std::unique_ptr Clang;
 };
@@ -309,6 +312,9 @@
   std::string Path = testPath("sub/bar.h");
   FS.Files[Path] = "";
   EXPECT_EQ(calculate(Path), "\"bar.h\"");
+
+  AlwaysBracketedInclude = true;
+  EXPECT_EQ(calculate(Path), "");
 }
 
 TEST_F(HeadersTest, DoNotInsertIfInSameFile) {
@@ -331,6 +337,17 @@
   EXPECT_EQ(calculate(BarHeader), "\"sub/bar.h\"");
 }
 
+TEST_F(HeadersTest, ShortenIncludesInSearchPathBracketed) {
+  AlwaysBracketedInclude = true;
+  std::string BarHeader = testPath("sub/bar.h");
+  EXPECT_EQ(calculate(BarHeader), "");
+
+  SearchDirArg = (llvm::Twine("-I") + Subdir + "/..").str();
+  CDB.ExtraClangFlags = {SearchDirArg.c_str()};
+  BarHeader = testPath("sub/bar.h");
+  EXPECT_EQ(calculate(BarHeader), "");
+}
+
 TEST_F(HeadersTest, ShortenedIncludeNotInSearchPath) {
   std::string BarHeader =
   llvm::sys::path::convert_to_slash(testPath("sub-2/bar.h"));
@@ -343,6 +360,10 @@
 
   std::string BazHeader = testPath("sub/baz.h");
   EXPECT_EQ(calculate(BarHeader, BazHeader), "\"baz.h\"");
+
+  AlwaysBracketedInclude = true;
+  std::string BiffHeader = testPath("sub/biff.h");
+  EXPECT_EQ(calculate(BarHeader, BiffHeader), "");
 }
 
 TEST_F(HeadersTest, DontInsertDuplicatePreferred) {
@@ -375,7 +396,8 @@
 TEST(Headers, NoHeaderSearchInfo) {
   std::string MainFile = testPath("main.cpp");
   IncludeInserter Inserter(MainFile, /*Code=*/"", format::getLLVMStyle(),
-   /*BuildDir=*/"", /*HeaderSearchInfo=*/nullptr);
+   /*BuildDir=*/"", /*HeaderSearchInfo=*/nullptr,
+   /*AlwaysBracketedInclude*/ false);
 
   auto HeaderPath = testPath("sub/bar.h");
   auto Inserting = HeaderFile{HeaderPath, /*Verbatim=*/false};
Index: clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
===
--- clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
+++ clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
@@ -265,13 +265,16 @@
   CapturedDiags Diags;
   Annotations YAML(R"yaml(
 Style:
-  FullyQualifiedNamespaces: [foo, bar])yaml");
+  FullyQualifiedNamespaces: [foo, bar]
+  AlwaysBracketedInclude: Yes)yaml");
   auto Results =
   

[PATCH] D145843: [clangd] Add option to always insert headers with <> instead of ""

2023-03-11 Thread Andrew Kaster via Phabricator via cfe-commits
ADKaster added a comment.

If this patch is accepted, I don't have commit access. If someone could commit 
as "Andrew Kaster " that would be much appreciated.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145843

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


[PATCH] D144206: [clang-tidy] Fix false-positive in cppcoreguidelines-slicing

2023-03-11 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp added a comment.

Looks good, just a small comment!




Comment at: 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/slicing.cpp:102
+
+struct BaseA {
+virtual ~BaseA() {}

Please briefly document this test case, i.e. why in this case this is not 
considered slicing and the check should not warn. It would be good to also 
mention the Github issue for traceability.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144206

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


[clang-tools-extra] efda335 - [clang-tidy] Make readability-container-data-pointer use header

2023-03-11 Thread Carlos Galvez via cfe-commits

Author: Mike Crowe
Date: 2023-03-11T13:59:42Z
New Revision: efda335bf5be11b5ad4f94f3319d859563542553

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

LOG: [clang-tidy] Make readability-container-data-pointer use  header

This requires operator[] to be added to the std::basic_string
implementation.

Depends on D144216

Reviewed By: carlosgalvezp

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

Added: 


Modified: 
clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/string

clang-tools-extra/test/clang-tidy/checkers/readability/container-data-pointer.cpp

Removed: 




diff  --git a/clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/string 
b/clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/string
index 614480968f2aa..5cc9cd367e4d9 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/string
+++ b/clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/string
@@ -42,6 +42,9 @@ struct basic_string {
   _Type& insert(size_type pos, const C* s);
   _Type& insert(size_type pos, const C* s, size_type n);
 
+  _Type& operator[](size_type);
+  const _Type& operator[](size_type) const;
+
   _Type& operator+=(const _Type& str);
   _Type& operator+=(const C* s);
   _Type& operator=(const _Type& str);

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/readability/container-data-pointer.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/readability/container-data-pointer.cpp
index 7f75564ad9dc9..ee2ba6a48752c 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/readability/container-data-pointer.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/readability/container-data-pointer.cpp
@@ -1,4 +1,5 @@
-// RUN: %check_clang_tidy %s readability-container-data-pointer %t -- -- 
-fno-delayed-template-parsing
+// RUN: %check_clang_tidy %s readability-container-data-pointer %t -- -- 
-isystem %clang_tidy_headers -fno-delayed-template-parsing
+#include 
 
 typedef __SIZE_TYPE__ size_t;
 
@@ -17,22 +18,6 @@ struct vector {
   const T &operator[](size_type) const;
 };
 
-template 
-struct basic_string {
-  using size_type = size_t;
-
-  basic_string();
-
-  T *data();
-  const T *data() const;
-
-  T &operator[](size_t);
-  const T &operator[](size_type) const;
-};
-
-typedef basic_string string;
-typedef basic_string wstring;
-
 template 
 struct is_integral;
 



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


[PATCH] D145310: [clang-tidy] Make readability-container-data-pointer use header

2023-03-11 Thread Carlos Galvez via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGefda335bf5be: [clang-tidy] Make 
readability-container-data-pointer use  header (authored by 
mikecrowe, committed by carlosgalvezp).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145310

Files:
  clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/string
  
clang-tools-extra/test/clang-tidy/checkers/readability/container-data-pointer.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/readability/container-data-pointer.cpp
===
--- 
clang-tools-extra/test/clang-tidy/checkers/readability/container-data-pointer.cpp
+++ 
clang-tools-extra/test/clang-tidy/checkers/readability/container-data-pointer.cpp
@@ -1,4 +1,5 @@
-// RUN: %check_clang_tidy %s readability-container-data-pointer %t -- -- 
-fno-delayed-template-parsing
+// RUN: %check_clang_tidy %s readability-container-data-pointer %t -- -- 
-isystem %clang_tidy_headers -fno-delayed-template-parsing
+#include 
 
 typedef __SIZE_TYPE__ size_t;
 
@@ -17,22 +18,6 @@
   const T &operator[](size_type) const;
 };
 
-template 
-struct basic_string {
-  using size_type = size_t;
-
-  basic_string();
-
-  T *data();
-  const T *data() const;
-
-  T &operator[](size_t);
-  const T &operator[](size_type) const;
-};
-
-typedef basic_string string;
-typedef basic_string wstring;
-
 template 
 struct is_integral;
 
Index: clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/string
===
--- clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/string
+++ clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/string
@@ -42,6 +42,9 @@
   _Type& insert(size_type pos, const C* s);
   _Type& insert(size_type pos, const C* s, size_type n);
 
+  _Type& operator[](size_type);
+  const _Type& operator[](size_type) const;
+
   _Type& operator+=(const _Type& str);
   _Type& operator+=(const C* s);
   _Type& operator=(const _Type& str);


Index: clang-tools-extra/test/clang-tidy/checkers/readability/container-data-pointer.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability/container-data-pointer.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability/container-data-pointer.cpp
@@ -1,4 +1,5 @@
-// RUN: %check_clang_tidy %s readability-container-data-pointer %t -- -- -fno-delayed-template-parsing
+// RUN: %check_clang_tidy %s readability-container-data-pointer %t -- -- -isystem %clang_tidy_headers -fno-delayed-template-parsing
+#include 
 
 typedef __SIZE_TYPE__ size_t;
 
@@ -17,22 +18,6 @@
   const T &operator[](size_type) const;
 };
 
-template 
-struct basic_string {
-  using size_type = size_t;
-
-  basic_string();
-
-  T *data();
-  const T *data() const;
-
-  T &operator[](size_t);
-  const T &operator[](size_type) const;
-};
-
-typedef basic_string string;
-typedef basic_string wstring;
-
 template 
 struct is_integral;
 
Index: clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/string
===
--- clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/string
+++ clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/string
@@ -42,6 +42,9 @@
   _Type& insert(size_type pos, const C* s);
   _Type& insert(size_type pos, const C* s, size_type n);
 
+  _Type& operator[](size_type);
+  const _Type& operator[](size_type) const;
+
   _Type& operator+=(const _Type& str);
   _Type& operator+=(const C* s);
   _Type& operator=(const _Type& str);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D145845: [Flang] Allow compile *.f03, *.f08 file

2023-03-11 Thread Shao-Ce SUN via Phabricator via cfe-commits
sunshaoce created this revision.
sunshaoce added reviewers: awarzynski, klausler, clementval, sscalpone.
Herald added a project: All.
sunshaoce requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay.
Herald added a project: clang.

Fix issue #61260


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D145845

Files:
  clang/lib/Driver/Types.cpp


Index: clang/lib/Driver/Types.cpp
===
--- clang/lib/Driver/Types.cpp
+++ clang/lib/Driver/Types.cpp
@@ -331,6 +331,10 @@
   .Case("cui", TY_PP_CUDA)
   .Case("cxx", TY_CXX)
   .Case("CXX", TY_CXX)
+  .Case("F03", TY_Fortran)
+  .Case("f03", TY_PP_Fortran)
+  .Case("F08", TY_Fortran)
+  .Case("f08", TY_PP_Fortran)
   .Case("F90", TY_Fortran)
   .Case("f90", TY_PP_Fortran)
   .Case("F95", TY_Fortran)


Index: clang/lib/Driver/Types.cpp
===
--- clang/lib/Driver/Types.cpp
+++ clang/lib/Driver/Types.cpp
@@ -331,6 +331,10 @@
   .Case("cui", TY_PP_CUDA)
   .Case("cxx", TY_CXX)
   .Case("CXX", TY_CXX)
+  .Case("F03", TY_Fortran)
+  .Case("f03", TY_PP_Fortran)
+  .Case("F08", TY_Fortran)
+  .Case("f08", TY_PP_Fortran)
   .Case("F90", TY_Fortran)
   .Case("f90", TY_PP_Fortran)
   .Case("F95", TY_Fortran)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D145845: [Flang] Allow compile *.f03, *.f08 file

2023-03-11 Thread Valentin Clement via Phabricator via cfe-commits
clementval added a comment.

Thanks. Can you add tests in `flang/test/Driver`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145845

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


[PATCH] D145845: [Flang] Allow compile *.f03, *.f08 file

2023-03-11 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski added a comment.

Thanks!

In D145845#4186590 , @clementval 
wrote:

> Thanks. Can you add tests in `flang/test/Driver`?

Hm, this is a `clangDriver` change rather than anything Flang specific 🤔 . Btw, 
how does https://github.com/llvm/llvm-project/issues/61260 manifest to you? I'm 
trying to figure out how to best test it (I couldn't find any other tests for 
this specifically).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145845

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


[PATCH] D145845: [Flang] Allow compile *.f03, *.f08 file

2023-03-11 Thread Valentin Clement via Phabricator via cfe-commits
clementval added a comment.

In D145845#4186607 , @awarzynski 
wrote:

> Thanks!
>
> In D145845#4186590 , @clementval 
> wrote:
>
>> Thanks. Can you add tests in `flang/test/Driver`?
>
> Hm, this is a `clangDriver` change rather than anything Flang specific 🤔 . 
> Btw, how does https://github.com/llvm/llvm-project/issues/61260 manifest to 
> you? I'm trying to figure out how to best test it (I couldn't find any other 
> tests for this specifically).

Cannot we just have a a .f03 file and compile it and see if we have an 
executable?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145845

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


[PATCH] D145845: [Flang] Allow compile *.f03, *.f08 file

2023-03-11 Thread Shao-Ce SUN via Phabricator via cfe-commits
sunshaoce updated this revision to Diff 504359.
sunshaoce added a comment.

Add tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145845

Files:
  clang/lib/Driver/Types.cpp
  flang/test/Driver/f03-suffix.f03
  flang/test/Driver/f08-suffix.f08


Index: flang/test/Driver/f08-suffix.f08
===
--- /dev/null
+++ flang/test/Driver/f08-suffix.f08
@@ -0,0 +1,6 @@
+! RUN: %flang -### -flang-experimental-exec %s 2>&1 | FileCheck %s
+
+! CHECK: "{{.*}}flang-new" "-fc1" {{.*}} "/tmp/{{.*}}.o"
+! CHECK: "{{.*}}ld" {{.*}} "/tmp/{{.*}}.o"
+program f08
+end program f08
Index: flang/test/Driver/f03-suffix.f03
===
--- /dev/null
+++ flang/test/Driver/f03-suffix.f03
@@ -0,0 +1,6 @@
+! RUN: %flang -### -flang-experimental-exec %s 2>&1 | FileCheck %s
+
+! CHECK: "{{.*}}flang-new" "-fc1" {{.*}} "/tmp/{{.*}}.o"
+! CHECK: "{{.*}}ld" {{.*}} "/tmp/{{.*}}.o"
+program f03
+end program f03
Index: clang/lib/Driver/Types.cpp
===
--- clang/lib/Driver/Types.cpp
+++ clang/lib/Driver/Types.cpp
@@ -331,6 +331,10 @@
   .Case("cui", TY_PP_CUDA)
   .Case("cxx", TY_CXX)
   .Case("CXX", TY_CXX)
+  .Case("F03", TY_Fortran)
+  .Case("f03", TY_PP_Fortran)
+  .Case("F08", TY_Fortran)
+  .Case("f08", TY_PP_Fortran)
   .Case("F90", TY_Fortran)
   .Case("f90", TY_PP_Fortran)
   .Case("F95", TY_Fortran)


Index: flang/test/Driver/f08-suffix.f08
===
--- /dev/null
+++ flang/test/Driver/f08-suffix.f08
@@ -0,0 +1,6 @@
+! RUN: %flang -### -flang-experimental-exec %s 2>&1 | FileCheck %s
+
+! CHECK: "{{.*}}flang-new" "-fc1" {{.*}} "/tmp/{{.*}}.o"
+! CHECK: "{{.*}}ld" {{.*}} "/tmp/{{.*}}.o"
+program f08
+end program f08
Index: flang/test/Driver/f03-suffix.f03
===
--- /dev/null
+++ flang/test/Driver/f03-suffix.f03
@@ -0,0 +1,6 @@
+! RUN: %flang -### -flang-experimental-exec %s 2>&1 | FileCheck %s
+
+! CHECK: "{{.*}}flang-new" "-fc1" {{.*}} "/tmp/{{.*}}.o"
+! CHECK: "{{.*}}ld" {{.*}} "/tmp/{{.*}}.o"
+program f03
+end program f03
Index: clang/lib/Driver/Types.cpp
===
--- clang/lib/Driver/Types.cpp
+++ clang/lib/Driver/Types.cpp
@@ -331,6 +331,10 @@
   .Case("cui", TY_PP_CUDA)
   .Case("cxx", TY_CXX)
   .Case("CXX", TY_CXX)
+  .Case("F03", TY_Fortran)
+  .Case("f03", TY_PP_Fortran)
+  .Case("F08", TY_Fortran)
+  .Case("f08", TY_PP_Fortran)
   .Case("F90", TY_Fortran)
   .Case("f90", TY_PP_Fortran)
   .Case("F95", TY_Fortran)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D145845: [Flang] Allow compile *.f03, *.f08 file

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

Before

  $ /home/sunshaoce/dev/llvm-project/build/bin/flang-new 
/home/sunshaoce/dev/llvm-project/build/temp.f03 -flang-experimental-exec -o 
temp.out -###
  flang-new version 17.0.0 (https://github.com/llvm/llvm-project.git 
890e6c871d31dca9e461c01118cf25fb303b9cad)
  Target: x86_64-unknown-linux-gnu
  Thread model: posix
  InstalledDir: /home/sunshaoce/dev/llvm-project/build/bin
   "/usr/bin/ld" "-pie" "-z" "relro" "--hash-style=gnu" "--eh-frame-hdr" "-m" 
"elf_x86_64" "-dynamic-linker" "/lib64/ld-linux-x86-64.so.2" "-o" "temp.out" 
"/lib/x86_64-linux-gnu/Scrt1.o" "/lib/x86_64-linux-gnu/crti.o" 
"/usr/lib/gcc/x86_64-linux-gnu/9/crtbeginS.o" 
"-L/usr/lib/gcc/x86_64-linux-gnu/9" 
"-L/usr/lib/gcc/x86_64-linux-gnu/9/../../../../lib64" "-L/lib/x86_64-linux-gnu" 
"-L/lib/../lib64" "-L/usr/lib/x86_64-linux-gnu" "-L/usr/lib/../lib64" "-L/lib" 
"-L/usr/lib" "/home/sunshaoce/dev/llvm-project/build/temp.f03" 
"-L/home/sunshaoce/dev/llvm-project/build/lib" "-lFortran_main" 
"-lFortranRuntime" "-lFortranDecimal" "-lm" "-lgcc" "--as-needed" "-lgcc_s" 
"--no-as-needed" "-lc" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" 
"/usr/lib/gcc/x86_64-linux-gnu/9/crtendS.o" "/lib/x86_64-linux-gnu/crtn.o"

after

  $ /home/sunshaoce/dev/llvm-project/build/bin/flang-new 
/home/sunshaoce/dev/llvm-project/build/temp.f03 -flang-experimental-exec -o 
temp.out -###
  flang-new version 17.0.0 (https://github.com/llvm/llvm-project.git 
890e6c871d31dca9e461c01118cf25fb303b9cad)
  Target: x86_64-unknown-linux-gnu
  Thread model: posix
  InstalledDir: /home/sunshaoce/dev/llvm-project/build/bin
   "/home/sunshaoce/dev/llvm-project/build/bin/flang-new" "-fc1" "-triple" 
"x86_64-unknown-linux-gnu" "-emit-obj" "-fcolor-diagnostics" 
"-mrelocation-model" "pic" "-pic-level" "2" "-pic-is-pie" "-target-cpu" 
"x86-64" "-o" "/tmp/temp-72c5c0.o" "-x" "f95-cpp-input" 
"/home/sunshaoce/dev/llvm-project/build/temp.f03"
   "/usr/bin/ld" "-pie" "-z" "relro" "--hash-style=gnu" "--eh-frame-hdr" "-m" 
"elf_x86_64" "-dynamic-linker" "/lib64/ld-linux-x86-64.so.2" "-o" "temp.out" 
"/lib/x86_64-linux-gnu/Scrt1.o" "/lib/x86_64-linux-gnu/crti.o" 
"/usr/lib/gcc/x86_64-linux-gnu/9/crtbeginS.o" 
"-L/usr/lib/gcc/x86_64-linux-gnu/9" 
"-L/usr/lib/gcc/x86_64-linux-gnu/9/../../../../lib64" "-L/lib/x86_64-linux-gnu" 
"-L/lib/../lib64" "-L/usr/lib/x86_64-linux-gnu" "-L/usr/lib/../lib64" "-L/lib" 
"-L/usr/lib" "/tmp/temp-72c5c0.o" 
"-L/home/sunshaoce/dev/llvm-project/build/lib" "-lFortran_main" 
"-lFortranRuntime" "-lFortranDecimal" "-lm" "-lgcc" "--as-needed" "-lgcc_s" 
"--no-as-needed" "-lc" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" 
"/usr/lib/gcc/x86_64-linux-gnu/9/crtendS.o" "/lib/x86_64-linux-gnu/crtn.o"

So, I tested it by checking whether `flang` was called.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145845

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


[PATCH] D145845: [Flang] Allow compile *.f03, *.f08 file

2023-03-11 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski added a comment.

In D145845#4186608 , @clementval 
wrote:

> In D145845#4186607 , @awarzynski 
> wrote:
>
>> Thanks!
>>
>> In D145845#4186590 , @clementval 
>> wrote:
>>
>>> Thanks. Can you add tests in `flang/test/Driver`?
>>
>> Hm, this is a `clangDriver` change rather than anything Flang specific 🤔 . 
>> Btw, how does https://github.com/llvm/llvm-project/issues/61260 manifest to 
>> you? I'm trying to figure out how to best test it (I couldn't find any other 
>> tests for this specifically).
>
> Cannot we just have a a .f03 file and compile it and see if we have an 
> executable?

We don't really build executable for testing the Driver. Also, building an 
executable involves many steps:

1. The driver (`flang-new`) identifies the file as a valid Fortran file. 
Delegates to "Flang" for the next step.
2. "Flang" parses the input, runs semantic checks and lowers to LLVM IR. This 
is driven by the frontend driver, `flang-new -fc1`.
3. LLVM IR is compiled into machine code (via LLVM) (also driven by `flang-new 
-fc1`).
4. Machine code generated in 3 is then linked by the driver to generate an 
executable (this step is driven by `flang-new`).

  It would be good to understand what exactly this change unblocks and then 
test that specifically. To me it sounds like this change is only really needed 
for 1. and hence we should only be testing 1 and avoid doing extra work that's 
not needed.

I suspect that without this change, `.*.f03` files are recognized as object 
rather than Fortran files and hence step 1. is followed by step 4. rather than 
step 2. So, try `flang-new -### file.f03` **with** and **without** your change. 
You should see that **with** this change you do see the frontend driver 
invocation  (`flang-new -fc1 `) that would run steps 2 and 3.. IMO 
that's the only thing that requires verifying here.

Does this make sense?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145845

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


[PATCH] D145845: [Flang] Allow compile *.f03, *.f08 file

2023-03-11 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski added a comment.

I'd move these tests to flang/test/Driver/supported-suffices. That would help 
documenting what these tests actual check for. Also, one could be tempted to 
test for other suffices and then it would be nice to keep them in one place. Ta!




Comment at: flang/test/Driver/f03-suffix.f03:1
+! RUN: %flang -### -flang-experimental-exec %s 2>&1 | FileCheck %s
+

You can safely drop `-flang-experimental-exec` here.



Comment at: flang/test/Driver/f03-suffix.f03:4
+! CHECK: "{{.*}}flang-new" "-fc1" {{.*}} "/tmp/{{.*}}.o"
+! CHECK: "{{.*}}ld" {{.*}} "/tmp/{{.*}}.o"
+program f03

The linker invocation is unrelated to this change. Also, it will very likely 
look differently on other operating systems. Best to skip it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145845

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


[PATCH] D145845: [Flang] Allow compile *.f03, *.f08 file

2023-03-11 Thread Shao-Ce SUN via Phabricator via cfe-commits
sunshaoce updated this revision to Diff 504360.
sunshaoce added a comment.

Remove -flang-experimental-exec


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145845

Files:
  clang/lib/Driver/Types.cpp
  flang/test/Driver/f03-suffix.f03
  flang/test/Driver/f08-suffix.f08


Index: flang/test/Driver/f08-suffix.f08
===
--- /dev/null
+++ flang/test/Driver/f08-suffix.f08
@@ -0,0 +1,6 @@
+! RUN: %flang -### %s 2>&1 | FileCheck %s
+
+! CHECK: "{{.*}}flang-new" "-fc1" {{.*}} "/tmp/{{.*}}.o"
+! CHECK: "{{.*}}ld" {{.*}} "/tmp/{{.*}}.o"
+program f08
+end program f08
Index: flang/test/Driver/f03-suffix.f03
===
--- /dev/null
+++ flang/test/Driver/f03-suffix.f03
@@ -0,0 +1,6 @@
+! RUN: %flang -### %s 2>&1 | FileCheck %s
+
+! CHECK: "{{.*}}flang-new" "-fc1" {{.*}} "/tmp/{{.*}}.o"
+! CHECK: "{{.*}}ld" {{.*}} "/tmp/{{.*}}.o"
+program f03
+end program f03
Index: clang/lib/Driver/Types.cpp
===
--- clang/lib/Driver/Types.cpp
+++ clang/lib/Driver/Types.cpp
@@ -331,6 +331,10 @@
   .Case("cui", TY_PP_CUDA)
   .Case("cxx", TY_CXX)
   .Case("CXX", TY_CXX)
+  .Case("F03", TY_Fortran)
+  .Case("f03", TY_PP_Fortran)
+  .Case("F08", TY_Fortran)
+  .Case("f08", TY_PP_Fortran)
   .Case("F90", TY_Fortran)
   .Case("f90", TY_PP_Fortran)
   .Case("F95", TY_Fortran)


Index: flang/test/Driver/f08-suffix.f08
===
--- /dev/null
+++ flang/test/Driver/f08-suffix.f08
@@ -0,0 +1,6 @@
+! RUN: %flang -### %s 2>&1 | FileCheck %s
+
+! CHECK: "{{.*}}flang-new" "-fc1" {{.*}} "/tmp/{{.*}}.o"
+! CHECK: "{{.*}}ld" {{.*}} "/tmp/{{.*}}.o"
+program f08
+end program f08
Index: flang/test/Driver/f03-suffix.f03
===
--- /dev/null
+++ flang/test/Driver/f03-suffix.f03
@@ -0,0 +1,6 @@
+! RUN: %flang -### %s 2>&1 | FileCheck %s
+
+! CHECK: "{{.*}}flang-new" "-fc1" {{.*}} "/tmp/{{.*}}.o"
+! CHECK: "{{.*}}ld" {{.*}} "/tmp/{{.*}}.o"
+program f03
+end program f03
Index: clang/lib/Driver/Types.cpp
===
--- clang/lib/Driver/Types.cpp
+++ clang/lib/Driver/Types.cpp
@@ -331,6 +331,10 @@
   .Case("cui", TY_PP_CUDA)
   .Case("cxx", TY_CXX)
   .Case("CXX", TY_CXX)
+  .Case("F03", TY_Fortran)
+  .Case("f03", TY_PP_Fortran)
+  .Case("F08", TY_Fortran)
+  .Case("f08", TY_PP_Fortran)
   .Case("F90", TY_Fortran)
   .Case("f90", TY_PP_Fortran)
   .Case("F95", TY_Fortran)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D145845: [Flang] Allow compile *.f03, *.f08 file

2023-03-11 Thread Shao-Ce SUN via Phabricator via cfe-commits
sunshaoce updated this revision to Diff 504362.
sunshaoce added a comment.

Address @awarzynski's comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145845

Files:
  clang/lib/Driver/Types.cpp
  flang/test/Driver/supported-suffices/f03-suffix.f03
  flang/test/Driver/supported-suffices/f08-suffix.f08


Index: flang/test/Driver/supported-suffices/f08-suffix.f08
===
--- /dev/null
+++ flang/test/Driver/supported-suffices/f08-suffix.f08
@@ -0,0 +1,6 @@
+! RUN: %flang -### %s 2>&1 | FileCheck %s
+
+! CHECK: "{{.*}}flang-new" "-fc1" {{.*}} "/tmp/{{.*}}.o"
+! CHECK: "{{.*}}ld" {{.*}} "/tmp/{{.*}}.o"
+program f08
+end program f08
Index: flang/test/Driver/supported-suffices/f03-suffix.f03
===
--- /dev/null
+++ flang/test/Driver/supported-suffices/f03-suffix.f03
@@ -0,0 +1,6 @@
+! RUN: %flang -### %s 2>&1 | FileCheck %s
+
+! CHECK: "{{.*}}flang-new" "-fc1" {{.*}} "/tmp/{{.*}}.o"
+! CHECK: "{{.*}}ld" {{.*}} "/tmp/{{.*}}.o"
+program f03
+end program f03
Index: clang/lib/Driver/Types.cpp
===
--- clang/lib/Driver/Types.cpp
+++ clang/lib/Driver/Types.cpp
@@ -331,6 +331,10 @@
   .Case("cui", TY_PP_CUDA)
   .Case("cxx", TY_CXX)
   .Case("CXX", TY_CXX)
+  .Case("F03", TY_Fortran)
+  .Case("f03", TY_PP_Fortran)
+  .Case("F08", TY_Fortran)
+  .Case("f08", TY_PP_Fortran)
   .Case("F90", TY_Fortran)
   .Case("f90", TY_PP_Fortran)
   .Case("F95", TY_Fortran)


Index: flang/test/Driver/supported-suffices/f08-suffix.f08
===
--- /dev/null
+++ flang/test/Driver/supported-suffices/f08-suffix.f08
@@ -0,0 +1,6 @@
+! RUN: %flang -### %s 2>&1 | FileCheck %s
+
+! CHECK: "{{.*}}flang-new" "-fc1" {{.*}} "/tmp/{{.*}}.o"
+! CHECK: "{{.*}}ld" {{.*}} "/tmp/{{.*}}.o"
+program f08
+end program f08
Index: flang/test/Driver/supported-suffices/f03-suffix.f03
===
--- /dev/null
+++ flang/test/Driver/supported-suffices/f03-suffix.f03
@@ -0,0 +1,6 @@
+! RUN: %flang -### %s 2>&1 | FileCheck %s
+
+! CHECK: "{{.*}}flang-new" "-fc1" {{.*}} "/tmp/{{.*}}.o"
+! CHECK: "{{.*}}ld" {{.*}} "/tmp/{{.*}}.o"
+program f03
+end program f03
Index: clang/lib/Driver/Types.cpp
===
--- clang/lib/Driver/Types.cpp
+++ clang/lib/Driver/Types.cpp
@@ -331,6 +331,10 @@
   .Case("cui", TY_PP_CUDA)
   .Case("cxx", TY_CXX)
   .Case("CXX", TY_CXX)
+  .Case("F03", TY_Fortran)
+  .Case("f03", TY_PP_Fortran)
+  .Case("F08", TY_Fortran)
+  .Case("f08", TY_PP_Fortran)
   .Case("F90", TY_Fortran)
   .Case("f90", TY_PP_Fortran)
   .Case("F95", TY_Fortran)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D145845: [Flang] Allow compile *.f03, *.f08 file

2023-03-11 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski added inline comments.



Comment at: flang/test/Driver/supported-suffices/f08-suffix.f08:4
+! CHECK: "{{.*}}flang-new" "-fc1" {{.*}} "/tmp/{{.*}}.o"
+! CHECK: "{{.*}}ld" {{.*}} "/tmp/{{.*}}.o"
+program f08

This line will not appear without `-flang-experimental-exec` - you need to 
delete it. Same for the other test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145845

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


[PATCH] D145845: [Flang] Allow compile *.f03, *.f08 file

2023-03-11 Thread Shao-Ce SUN via Phabricator via cfe-commits
sunshaoce updated this revision to Diff 504363.
sunshaoce marked 2 inline comments as done.
sunshaoce added a comment.

Sorry, I just missed a comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145845

Files:
  clang/lib/Driver/Types.cpp
  flang/test/Driver/supported-suffices/f03-suffix.f03
  flang/test/Driver/supported-suffices/f08-suffix.f08


Index: flang/test/Driver/supported-suffices/f08-suffix.f08
===
--- /dev/null
+++ flang/test/Driver/supported-suffices/f08-suffix.f08
@@ -0,0 +1,5 @@
+! RUN: %flang -### %s 2>&1 | FileCheck %s
+
+! CHECK: "{{.*}}flang-new" "-fc1" {{.*}} "/tmp/{{.*}}.o"
+program f08
+end program f08
Index: flang/test/Driver/supported-suffices/f03-suffix.f03
===
--- /dev/null
+++ flang/test/Driver/supported-suffices/f03-suffix.f03
@@ -0,0 +1,5 @@
+! RUN: %flang -### %s 2>&1 | FileCheck %s
+
+! CHECK: "{{.*}}flang-new" "-fc1" {{.*}} "/tmp/{{.*}}.o"
+program f03
+end program f03
Index: clang/lib/Driver/Types.cpp
===
--- clang/lib/Driver/Types.cpp
+++ clang/lib/Driver/Types.cpp
@@ -331,6 +331,10 @@
   .Case("cui", TY_PP_CUDA)
   .Case("cxx", TY_CXX)
   .Case("CXX", TY_CXX)
+  .Case("F03", TY_Fortran)
+  .Case("f03", TY_PP_Fortran)
+  .Case("F08", TY_Fortran)
+  .Case("f08", TY_PP_Fortran)
   .Case("F90", TY_Fortran)
   .Case("f90", TY_PP_Fortran)
   .Case("F95", TY_Fortran)


Index: flang/test/Driver/supported-suffices/f08-suffix.f08
===
--- /dev/null
+++ flang/test/Driver/supported-suffices/f08-suffix.f08
@@ -0,0 +1,5 @@
+! RUN: %flang -### %s 2>&1 | FileCheck %s
+
+! CHECK: "{{.*}}flang-new" "-fc1" {{.*}} "/tmp/{{.*}}.o"
+program f08
+end program f08
Index: flang/test/Driver/supported-suffices/f03-suffix.f03
===
--- /dev/null
+++ flang/test/Driver/supported-suffices/f03-suffix.f03
@@ -0,0 +1,5 @@
+! RUN: %flang -### %s 2>&1 | FileCheck %s
+
+! CHECK: "{{.*}}flang-new" "-fc1" {{.*}} "/tmp/{{.*}}.o"
+program f03
+end program f03
Index: clang/lib/Driver/Types.cpp
===
--- clang/lib/Driver/Types.cpp
+++ clang/lib/Driver/Types.cpp
@@ -331,6 +331,10 @@
   .Case("cui", TY_PP_CUDA)
   .Case("cxx", TY_CXX)
   .Case("CXX", TY_CXX)
+  .Case("F03", TY_Fortran)
+  .Case("f03", TY_PP_Fortran)
+  .Case("F08", TY_Fortran)
+  .Case("f08", TY_PP_Fortran)
   .Case("F90", TY_Fortran)
   .Case("f90", TY_PP_Fortran)
   .Case("F95", TY_Fortran)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D145845: [Flang] Allow compile *.f03, *.f08 file

2023-03-11 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski accepted this revision.
awarzynski added a comment.
This revision is now accepted and ready to land.

LGTM, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145845

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


[clang] 171794d - [Flang] Allow compile *.f03, *.f08 file

2023-03-11 Thread Shao-Ce SUN via cfe-commits

Author: Shao-Ce SUN
Date: 2023-03-11T23:23:21+08:00
New Revision: 171794de533b400edb47f0e6df4375a7ae052fc8

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

LOG: [Flang] Allow compile *.f03, *.f08 file

Fix issue [#61260](https://github.com/llvm/llvm-project/issues/61260)

Reviewed By: awarzynski

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

Added: 
flang/test/Driver/supported-suffices/f03-suffix.f03
flang/test/Driver/supported-suffices/f08-suffix.f08

Modified: 
clang/lib/Driver/Types.cpp

Removed: 




diff  --git a/clang/lib/Driver/Types.cpp b/clang/lib/Driver/Types.cpp
index a890cc58ee421..7d6308d757bc7 100644
--- a/clang/lib/Driver/Types.cpp
+++ b/clang/lib/Driver/Types.cpp
@@ -331,6 +331,10 @@ types::ID types::lookupTypeForExtension(llvm::StringRef 
Ext) {
   .Case("cui", TY_PP_CUDA)
   .Case("cxx", TY_CXX)
   .Case("CXX", TY_CXX)
+  .Case("F03", TY_Fortran)
+  .Case("f03", TY_PP_Fortran)
+  .Case("F08", TY_Fortran)
+  .Case("f08", TY_PP_Fortran)
   .Case("F90", TY_Fortran)
   .Case("f90", TY_PP_Fortran)
   .Case("F95", TY_Fortran)

diff  --git a/flang/test/Driver/supported-suffices/f03-suffix.f03 
b/flang/test/Driver/supported-suffices/f03-suffix.f03
new file mode 100644
index 0..e1c74e065ca14
--- /dev/null
+++ b/flang/test/Driver/supported-suffices/f03-suffix.f03
@@ -0,0 +1,5 @@
+! RUN: %flang -### %s 2>&1 | FileCheck %s
+
+! CHECK: "{{.*}}flang-new" "-fc1" {{.*}} "/tmp/{{.*}}.o"
+program f03
+end program f03

diff  --git a/flang/test/Driver/supported-suffices/f08-suffix.f08 
b/flang/test/Driver/supported-suffices/f08-suffix.f08
new file mode 100644
index 0..e9039d14529b1
--- /dev/null
+++ b/flang/test/Driver/supported-suffices/f08-suffix.f08
@@ -0,0 +1,5 @@
+! RUN: %flang -### %s 2>&1 | FileCheck %s
+
+! CHECK: "{{.*}}flang-new" "-fc1" {{.*}} "/tmp/{{.*}}.o"
+program f08
+end program f08



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


[PATCH] D145845: [Flang] Allow compile *.f03, *.f08 file

2023-03-11 Thread Shao-Ce SUN via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
sunshaoce marked an inline comment as done.
Closed by commit rG171794de533b: [Flang] Allow compile *.f03, *.f08 file 
(authored by sunshaoce).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145845

Files:
  clang/lib/Driver/Types.cpp
  flang/test/Driver/supported-suffices/f03-suffix.f03
  flang/test/Driver/supported-suffices/f08-suffix.f08


Index: flang/test/Driver/supported-suffices/f08-suffix.f08
===
--- /dev/null
+++ flang/test/Driver/supported-suffices/f08-suffix.f08
@@ -0,0 +1,5 @@
+! RUN: %flang -### %s 2>&1 | FileCheck %s
+
+! CHECK: "{{.*}}flang-new" "-fc1" {{.*}} "/tmp/{{.*}}.o"
+program f08
+end program f08
Index: flang/test/Driver/supported-suffices/f03-suffix.f03
===
--- /dev/null
+++ flang/test/Driver/supported-suffices/f03-suffix.f03
@@ -0,0 +1,5 @@
+! RUN: %flang -### %s 2>&1 | FileCheck %s
+
+! CHECK: "{{.*}}flang-new" "-fc1" {{.*}} "/tmp/{{.*}}.o"
+program f03
+end program f03
Index: clang/lib/Driver/Types.cpp
===
--- clang/lib/Driver/Types.cpp
+++ clang/lib/Driver/Types.cpp
@@ -331,6 +331,10 @@
   .Case("cui", TY_PP_CUDA)
   .Case("cxx", TY_CXX)
   .Case("CXX", TY_CXX)
+  .Case("F03", TY_Fortran)
+  .Case("f03", TY_PP_Fortran)
+  .Case("F08", TY_Fortran)
+  .Case("f08", TY_PP_Fortran)
   .Case("F90", TY_Fortran)
   .Case("f90", TY_PP_Fortran)
   .Case("F95", TY_Fortran)


Index: flang/test/Driver/supported-suffices/f08-suffix.f08
===
--- /dev/null
+++ flang/test/Driver/supported-suffices/f08-suffix.f08
@@ -0,0 +1,5 @@
+! RUN: %flang -### %s 2>&1 | FileCheck %s
+
+! CHECK: "{{.*}}flang-new" "-fc1" {{.*}} "/tmp/{{.*}}.o"
+program f08
+end program f08
Index: flang/test/Driver/supported-suffices/f03-suffix.f03
===
--- /dev/null
+++ flang/test/Driver/supported-suffices/f03-suffix.f03
@@ -0,0 +1,5 @@
+! RUN: %flang -### %s 2>&1 | FileCheck %s
+
+! CHECK: "{{.*}}flang-new" "-fc1" {{.*}} "/tmp/{{.*}}.o"
+program f03
+end program f03
Index: clang/lib/Driver/Types.cpp
===
--- clang/lib/Driver/Types.cpp
+++ clang/lib/Driver/Types.cpp
@@ -331,6 +331,10 @@
   .Case("cui", TY_PP_CUDA)
   .Case("cxx", TY_CXX)
   .Case("CXX", TY_CXX)
+  .Case("F03", TY_Fortran)
+  .Case("f03", TY_PP_Fortran)
+  .Case("F08", TY_Fortran)
+  .Case("f08", TY_PP_Fortran)
   .Case("F90", TY_Fortran)
   .Case("f90", TY_PP_Fortran)
   .Case("F95", TY_Fortran)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2023-03-11 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson accepted this revision.
tejohnson added a comment.

lgtm


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145190

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


[PATCH] D109727: [Driver] Remove unneeded *-suse-* triples

2023-03-11 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert added a comment.
Herald added a subscriber: pcwang-thead.
Herald added a project: All.

Basically this should be Ok. We set the `LLVM_HOST_TRIPLE` to match the GCC 
triple on almost all platforms now.

But we'll need to patch `isGNUEnvironment` like D110900 
 does and the previously mentioned 
`config.guess` changes.




Comment at: clang/lib/Driver/ToolChains/Gnu.cpp:2091-2092
- "armv7hl-redhat-linux-gnueabi",
- "armv6hl-suse-linux-gnueabi",
- "armv7hl-suse-linux-gnueabi"};
   static const char *const ARMebLibDirs[] = {"/lib"};

Not sure if we can remove them. We now use `gnueabihf` in the default triple, 
but I think the GCC installation is still at `-gnueabi`. Also we're using 
`armv6kz` instead of `armv6hl` for some reason that's beyond my understanding.



Comment at: llvm/lib/Support/Triple.cpp:989-991
-  // SUSE uses "gnueabi" to mean "gnueabihf"
-  if (Vendor == Triple::SUSE && Environment == llvm::Triple::GNUEABI)
-Components[3] = "gnueabihf";

We have that included in out `LLVM_HOST_TRIPLE` now, so this should be fine. 
But this means we'll need to keep the translation to GCC triple alive.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109727

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


[PATCH] D145848: [Driver] Correct -f(no-)xray-function-index behavior

2023-03-11 Thread Oleksii Lozovskyi via Phabricator via cfe-commits
ilammy created this revision.
ilammy added reviewers: MaskRay, ianlevesque, dberris.
ilammy added a project: clang.
Herald added a subscriber: arphaman.
Herald added a project: All.
ilammy requested review of this revision.
Herald added a subscriber: cfe-commits.

This option has undergone several refactorings and got inverted along
the way. The `XRayOmitFunctionIndex` flag governs codegen behavior,
*omitting* "xray_fn_idx" section if it is set. But the command-line
flag behavior was not adjusted at the time. Right now it's like this:

 (default): no function index
 -fxray-function-index: no function index
  -fno-xray-function-index: "xray_fn_idx" is present

While the default behavior should be keep "xray_fn_idx", unless
-fno-xray-function-index is given:

 (default): "xray_fn_idx" is present
 -fxray-function-index: same, present, but explicitly
  -fno-xray-function-index: no function index

Flip the flags to make it so.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D145848

Files:
  clang/include/clang/Driver/Options.td
  clang/test/CodeGen/xray-function-index.cpp


Index: clang/test/CodeGen/xray-function-index.cpp
===
--- /dev/null
+++ clang/test/CodeGen/xray-function-index.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -fxray-instrument  -x c++ 
-std=c++11 -triple x86_64-unknown-linux-gnu -S -o - %s | FileCheck %s 
--check-prefixes=CHECK,CHECK-ENABLED
+// RUN: %clang_cc1 -fxray-instrument -fno-xray-function-index -x c++ 
-std=c++11 -triple x86_64-unknown-linux-gnu -S -o - %s | FileCheck %s 
--check-prefixes=CHECK,CHECK-DISABLED
+
+[[clang::xray_always_instrument]] void foo() {}
+
+// CHECK-LABEL: .section xray_instr_map,"ao",@progbits,_Z3foov
+// CHECK-ENABLED: .section xray_fn_idx,"awo",@progbits,_Z3foov
+// CHECK-DISABLED-NOT: xray_fn_idx
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2173,10 +2173,10 @@
   NegFlag>;
 
 defm xray_function_index : BoolFOption<"xray-function-index",
-  CodeGenOpts<"XRayOmitFunctionIndex">, DefaultTrue,
-  NegFlag, DefaultFalse,
+  NegFlag,
-  PosFlag>;
+  PosFlag>;
 
 def fxray_link_deps : Flag<["-"], "fxray-link-deps">, Group,
   Flags<[CC1Option]>,


Index: clang/test/CodeGen/xray-function-index.cpp
===
--- /dev/null
+++ clang/test/CodeGen/xray-function-index.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -fxray-instrument  -x c++ -std=c++11 -triple x86_64-unknown-linux-gnu -S -o - %s | FileCheck %s --check-prefixes=CHECK,CHECK-ENABLED
+// RUN: %clang_cc1 -fxray-instrument -fno-xray-function-index -x c++ -std=c++11 -triple x86_64-unknown-linux-gnu -S -o - %s | FileCheck %s --check-prefixes=CHECK,CHECK-DISABLED
+
+[[clang::xray_always_instrument]] void foo() {}
+
+// CHECK-LABEL: .section xray_instr_map,"ao",@progbits,_Z3foov
+// CHECK-ENABLED: .section xray_fn_idx,"awo",@progbits,_Z3foov
+// CHECK-DISABLED-NOT: xray_fn_idx
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2173,10 +2173,10 @@
   NegFlag>;
 
 defm xray_function_index : BoolFOption<"xray-function-index",
-  CodeGenOpts<"XRayOmitFunctionIndex">, DefaultTrue,
-  NegFlag, DefaultFalse,
+  NegFlag,
-  PosFlag>;
+  PosFlag>;
 
 def fxray_link_deps : Flag<["-"], "fxray-link-deps">, Group,
   Flags<[CC1Option]>,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D145849: [Driver][xray] Allow XRay on Apple Silicon

2023-03-11 Thread Oleksii Lozovskyi via Phabricator via cfe-commits
ilammy created this revision.
ilammy added reviewers: MaskRay, ianlevesque, dberris.
ilammy added a project: clang.
Herald added a subscriber: kristof.beyls.
Herald added a project: All.
ilammy requested review of this revision.
Herald added a subscriber: cfe-commits.

Codegen can handle XRay for AArch64, tell the driver to allow it.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D145849

Files:
  clang/lib/Driver/XRayArgs.cpp
  clang/test/Driver/XRay/xray-instrument-macos.c
  clang/test/Driver/XRay/xray-instrument-os.c


Index: clang/test/Driver/XRay/xray-instrument-os.c
===
--- clang/test/Driver/XRay/xray-instrument-os.c
+++ clang/test/Driver/XRay/xray-instrument-os.c
@@ -1,4 +1,4 @@
 // RUN: not %clang -o /dev/null -v -fxray-instrument -c %s
-// XFAIL: target={{.*-(linux|freebsd).*}}, 
target=x86_64-apple-{{(darwin|macos).*}}
+// XFAIL: target={{.*-(linux|freebsd).*}}, 
target={{(aarch64|x86_64)-apple-(darwin|macos).*}}
 // REQUIRES: target={{(amd64|x86_64|x86_64h|arm|aarch64|arm64)-.*}}
 typedef int a;
Index: clang/test/Driver/XRay/xray-instrument-macos.c
===
--- clang/test/Driver/XRay/xray-instrument-macos.c
+++ clang/test/Driver/XRay/xray-instrument-macos.c
@@ -1,4 +1,5 @@
+// RUN: %clang -o /dev/null -v -fxray-instrument -target 
aarch64-apple-darwin20 -c %s
 // RUN: %clang -o /dev/null -v -fxray-instrument -target 
x86_64-apple-macos10.11 -c %s
 // RUN: %clang -o /dev/null -v -fxray-instrument -target x86_64-apple-darwin15 
-c %s
-// REQUIRES: x86_64 || x86_64h
+// REQUIRES: aarch64 || x86_64 || x86_64h
 typedef int a;
Index: clang/lib/Driver/XRayArgs.cpp
===
--- clang/lib/Driver/XRayArgs.cpp
+++ clang/lib/Driver/XRayArgs.cpp
@@ -52,11 +52,20 @@
   << (std::string(XRayInstrumentOption) + " on " + Triple.str());
 }
   } else if (Triple.isOSFreeBSD() || Triple.isOSOpenBSD() ||
- Triple.isOSNetBSD() || Triple.isMacOSX()) {
+ Triple.isOSNetBSD()) {
 if (Triple.getArch() != llvm::Triple::x86_64) {
   D.Diag(diag::err_drv_clang_unsupported)
   << (std::string(XRayInstrumentOption) + " on " + Triple.str());
 }
+  } else if (Triple.isMacOSX()) {
+switch (Triple.getArch()) {
+case llvm::Triple::x86_64:
+case llvm::Triple::aarch64:
+  break;
+default:
+  D.Diag(diag::err_drv_clang_unsupported)
+  << (std::string(XRayInstrumentOption) + " on " + Triple.str());
+}
   } else if (Triple.getOS() == llvm::Triple::Fuchsia) {
 switch (Triple.getArch()) {
 case llvm::Triple::x86_64:


Index: clang/test/Driver/XRay/xray-instrument-os.c
===
--- clang/test/Driver/XRay/xray-instrument-os.c
+++ clang/test/Driver/XRay/xray-instrument-os.c
@@ -1,4 +1,4 @@
 // RUN: not %clang -o /dev/null -v -fxray-instrument -c %s
-// XFAIL: target={{.*-(linux|freebsd).*}}, target=x86_64-apple-{{(darwin|macos).*}}
+// XFAIL: target={{.*-(linux|freebsd).*}}, target={{(aarch64|x86_64)-apple-(darwin|macos).*}}
 // REQUIRES: target={{(amd64|x86_64|x86_64h|arm|aarch64|arm64)-.*}}
 typedef int a;
Index: clang/test/Driver/XRay/xray-instrument-macos.c
===
--- clang/test/Driver/XRay/xray-instrument-macos.c
+++ clang/test/Driver/XRay/xray-instrument-macos.c
@@ -1,4 +1,5 @@
+// RUN: %clang -o /dev/null -v -fxray-instrument -target aarch64-apple-darwin20 -c %s
 // RUN: %clang -o /dev/null -v -fxray-instrument -target x86_64-apple-macos10.11 -c %s
 // RUN: %clang -o /dev/null -v -fxray-instrument -target x86_64-apple-darwin15 -c %s
-// REQUIRES: x86_64 || x86_64h
+// REQUIRES: aarch64 || x86_64 || x86_64h
 typedef int a;
Index: clang/lib/Driver/XRayArgs.cpp
===
--- clang/lib/Driver/XRayArgs.cpp
+++ clang/lib/Driver/XRayArgs.cpp
@@ -52,11 +52,20 @@
   << (std::string(XRayInstrumentOption) + " on " + Triple.str());
 }
   } else if (Triple.isOSFreeBSD() || Triple.isOSOpenBSD() ||
- Triple.isOSNetBSD() || Triple.isMacOSX()) {
+ Triple.isOSNetBSD()) {
 if (Triple.getArch() != llvm::Triple::x86_64) {
   D.Diag(diag::err_drv_clang_unsupported)
   << (std::string(XRayInstrumentOption) + " on " + Triple.str());
 }
+  } else if (Triple.isMacOSX()) {
+switch (Triple.getArch()) {
+case llvm::Triple::x86_64:
+case llvm::Triple::aarch64:
+  break;
+default:
+  D.Diag(diag::err_drv_clang_unsupported)
+  << (std::string(XRayInstrumentOption) + " on " + Triple.str());
+}
   } else if (Triple.getOS() == llvm::Triple::Fuchsia) {
 switch (Triple.getArch()) {
 case llvm::Triple::x86_64:
___
cfe-commits mailing list
cfe-commits@lists.llvm.o

[clang] 56cc0bb - Revert "[Flang] Allow compile *.f03, *.f08 file"

2023-03-11 Thread Shao-Ce SUN via cfe-commits

Author: Shao-Ce SUN
Date: 2023-03-12T00:06:09+08:00
New Revision: 56cc0bbe41fd41fb0766062ca0975eba64e92447

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

LOG: Revert "[Flang] Allow compile *.f03, *.f08 file"

The test will fail in the MSVC environment.

This reverts commit 171794de533b400edb47f0e6df4375a7ae052fc8.

Added: 


Modified: 
clang/lib/Driver/Types.cpp

Removed: 
flang/test/Driver/supported-suffices/f03-suffix.f03
flang/test/Driver/supported-suffices/f08-suffix.f08



diff  --git a/clang/lib/Driver/Types.cpp b/clang/lib/Driver/Types.cpp
index 7d6308d757bc7..a890cc58ee421 100644
--- a/clang/lib/Driver/Types.cpp
+++ b/clang/lib/Driver/Types.cpp
@@ -331,10 +331,6 @@ types::ID types::lookupTypeForExtension(llvm::StringRef 
Ext) {
   .Case("cui", TY_PP_CUDA)
   .Case("cxx", TY_CXX)
   .Case("CXX", TY_CXX)
-  .Case("F03", TY_Fortran)
-  .Case("f03", TY_PP_Fortran)
-  .Case("F08", TY_Fortran)
-  .Case("f08", TY_PP_Fortran)
   .Case("F90", TY_Fortran)
   .Case("f90", TY_PP_Fortran)
   .Case("F95", TY_Fortran)

diff  --git a/flang/test/Driver/supported-suffices/f03-suffix.f03 
b/flang/test/Driver/supported-suffices/f03-suffix.f03
deleted file mode 100644
index e1c74e065ca14..0
--- a/flang/test/Driver/supported-suffices/f03-suffix.f03
+++ /dev/null
@@ -1,5 +0,0 @@
-! RUN: %flang -### %s 2>&1 | FileCheck %s
-
-! CHECK: "{{.*}}flang-new" "-fc1" {{.*}} "/tmp/{{.*}}.o"
-program f03
-end program f03

diff  --git a/flang/test/Driver/supported-suffices/f08-suffix.f08 
b/flang/test/Driver/supported-suffices/f08-suffix.f08
deleted file mode 100644
index e9039d14529b1..0
--- a/flang/test/Driver/supported-suffices/f08-suffix.f08
+++ /dev/null
@@ -1,5 +0,0 @@
-! RUN: %flang -### %s 2>&1 | FileCheck %s
-
-! CHECK: "{{.*}}flang-new" "-fc1" {{.*}} "/tmp/{{.*}}.o"
-program f08
-end program f08



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


[PATCH] D145845: [Flang] Allow compile *.f03, *.f08 file

2023-03-11 Thread Shao-Ce SUN via Phabricator via cfe-commits
sunshaoce reopened this revision.
sunshaoce added a comment.
This revision is now accepted and ready to land.

Sorry! My previous tests were not comprehensive enough, which resulted in 
failures in the MSVC environment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145845

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


[PATCH] D124351: [Clang] Implement Change scope of lambda trailing-return-type

2023-03-11 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added inline comments.



Comment at: clang/lib/Sema/SemaCXXScopeSpec.cpp:295-298
+  if (getCurLambda()) {
+Diag(SuperLoc, diag::err_super_in_lambda_unsupported);
+return true;
+  }

rsmith wrote:
> Will this also reject `__super` in a local class inside a lambda? That seems 
> like something we should still permit.
https://godbolt.org/z/dEj3vG8nc 
Seems to work fine -

In both cases we create a non capturing function scope so `getCurLambda` 
returns nullptr


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124351

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


[PATCH] D145845: [Flang] Allow compile *.f03, *.f08 file

2023-03-11 Thread Shao-Ce SUN via Phabricator via cfe-commits
sunshaoce updated this revision to Diff 504372.
sunshaoce added a comment.

Fix the issue of failing in the MSVC environment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145845

Files:
  clang/lib/Driver/Types.cpp
  flang/test/Driver/supported-suffices/f03-suffix.f03
  flang/test/Driver/supported-suffices/f08-suffix.f08


Index: flang/test/Driver/supported-suffices/f08-suffix.f08
===
--- /dev/null
+++ flang/test/Driver/supported-suffices/f08-suffix.f08
@@ -0,0 +1,5 @@
+! RUN: %flang -### %s 2>&1 | FileCheck %s
+
+! CHECK: "{{.*}}flang-new" "-fc1" {{.*}} "-o" "{{.*}}.o"
+program f08
+end program f08
Index: flang/test/Driver/supported-suffices/f03-suffix.f03
===
--- /dev/null
+++ flang/test/Driver/supported-suffices/f03-suffix.f03
@@ -0,0 +1,5 @@
+! RUN: %flang -### %s 2>&1 | FileCheck %s
+
+! CHECK: "{{.*}}flang-new" "-fc1" {{.*}} "-o" "{{.*}}.o"
+program f03
+end program f03
Index: clang/lib/Driver/Types.cpp
===
--- clang/lib/Driver/Types.cpp
+++ clang/lib/Driver/Types.cpp
@@ -331,6 +331,10 @@
   .Case("cui", TY_PP_CUDA)
   .Case("cxx", TY_CXX)
   .Case("CXX", TY_CXX)
+  .Case("F03", TY_Fortran)
+  .Case("f03", TY_PP_Fortran)
+  .Case("F08", TY_Fortran)
+  .Case("f08", TY_PP_Fortran)
   .Case("F90", TY_Fortran)
   .Case("f90", TY_PP_Fortran)
   .Case("F95", TY_Fortran)


Index: flang/test/Driver/supported-suffices/f08-suffix.f08
===
--- /dev/null
+++ flang/test/Driver/supported-suffices/f08-suffix.f08
@@ -0,0 +1,5 @@
+! RUN: %flang -### %s 2>&1 | FileCheck %s
+
+! CHECK: "{{.*}}flang-new" "-fc1" {{.*}} "-o" "{{.*}}.o"
+program f08
+end program f08
Index: flang/test/Driver/supported-suffices/f03-suffix.f03
===
--- /dev/null
+++ flang/test/Driver/supported-suffices/f03-suffix.f03
@@ -0,0 +1,5 @@
+! RUN: %flang -### %s 2>&1 | FileCheck %s
+
+! CHECK: "{{.*}}flang-new" "-fc1" {{.*}} "-o" "{{.*}}.o"
+program f03
+end program f03
Index: clang/lib/Driver/Types.cpp
===
--- clang/lib/Driver/Types.cpp
+++ clang/lib/Driver/Types.cpp
@@ -331,6 +331,10 @@
   .Case("cui", TY_PP_CUDA)
   .Case("cxx", TY_CXX)
   .Case("CXX", TY_CXX)
+  .Case("F03", TY_Fortran)
+  .Case("f03", TY_PP_Fortran)
+  .Case("F08", TY_Fortran)
+  .Case("f08", TY_PP_Fortran)
   .Case("F90", TY_Fortran)
   .Case("f90", TY_PP_Fortran)
   .Case("F95", TY_Fortran)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] c0dc8f7 - [Clang][Doc] Fix inconsistent links in release notes

2023-03-11 Thread Roy Jacobson via cfe-commits

Author: Roy Jacobson
Date: 2023-03-11T18:39:33+02:00
New Revision: c0dc8f7a29e70fb69456517aa32db43d45f9a124

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

LOG: [Clang][Doc] Fix inconsistent links in release notes

Added: 


Modified: 
clang/docs/ReleaseNotes.rst

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 8d880a4fba266..76e0a71931c1c 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -79,7 +79,7 @@ C++ Language Changes
 C++20 Feature Support
 ^
 - Support for out-of-line definitions of constrained templates has been 
improved.
-  This partially fixes `https://github.com/llvm/llvm-project/issues/49620`.
+  This partially fixes `#49620 
`_.
 
 C++2b Feature Support
 ^
@@ -95,8 +95,7 @@ Resolutions to C++ Defect Reports
 C Language Changes
 --
 - Support for outputs from asm goto statements along indirect edges has been
-  added. This fixes
-  `Issue 53562 `_.
+  added. (`#53562 `_)
 
 C2x Feature Support
 ^^^
@@ -153,7 +152,7 @@ Improvements to Clang's diagnostics
 ---
 - We now generate a diagnostic for signed integer overflow due to unary minus
   in a non-constant expression context.
-  (`#31643 `)
+  (`#31643 `_)
 - Clang now warns by default for C++20 and later about deprecated capture of
   ``this`` with a capture default of ``=``. This warning can be disabled with
   ``-Wno-deprecated-this-capture``.
@@ -310,7 +309,7 @@ Static Analyzer
 ---
 - Fix incorrect alignment attribute on the this parameter of certain
   non-complete destructors when using the Microsoft ABI.
-  `Issue 60465 `_.
+  (`#60465 `_)
 
 .. _release-notes-sanitizers:
 



___
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-11 Thread Roy Jacobson via Phabricator via cfe-commits
royjacobson created this revision.
Herald added a project: All.
royjacobson requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

If a union has explicit initializers for some members, we shouldn't delete
its default constructor.
Fixes https://github.com/llvm/llvm-project/issues/48416.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D145851

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaDeclCXX.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,37 @@
 
   Test2 t2x;  // expected-error {{call to implicitly-deleted default 
constructor of 'Test2'}}
 }
+
+namespace GH48416 {
+
+struct non_trivial_constructor {
+non_trivial_constructor() {}
+};
+
+
+union U1 {
+int a;
+non_trivial_constructor b; // expected-note {{has a non-trivial default 
constructor}}
+};
+
+union U2 {
+int a{};
+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;
+
+} // namespace GH48416
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -9157,7 +9157,15 @@
 // 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) {
+  // Default constructor of a union can also be valid if one of the
+  // members has an explicit initializer.
+  auto* Constructor = dyn_cast(Decl);
+  auto* RD = dyn_cast(Field->getParent());
+  if (!Constructor || !RD || !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 `_)
 
 Bug Fixes to AST Handling
 ^


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,37 @@
 
   Test2 t2x;  // expected-error {{call to implicitly-deleted default constructor of 'Test2'}}
 }
+
+namespace GH48416 {
+
+struct non_trivial_constructor {
+non_trivial_constructor() {}
+};
+
+
+union U1 {
+int a;
+non_trivial_constructor b; // expected-note {{has a non-trivial default constructor}}
+};
+
+union U2 {
+int a{};
+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;
+
+} // namespace GH48416
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -9157,7 +9157,15 @@
 // 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) {
+  // Default constructor of a union can also be valid if one of the
+  // members has an explicit initializer.
+  auto* Constructor = dyn_cast(Decl);
+  auto* RD = dyn_cast(Field->getParent());
+  if (!Constructor || !RD || !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.
   (`#601

[PATCH] D145852: [Clang][AST] Fix __has_unique_object_representations computation for unnamed bitfields.

2023-03-11 Thread Roy Jacobson via Phabricator via cfe-commits
royjacobson created this revision.
Herald added a project: All.
royjacobson requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

As pointed out in https://github.com/llvm/llvm-project/issues/61336, objects 
with
unnamed bitfields aren't be uniquely representable.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D145852

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/AST/ASTContext.cpp
  clang/test/SemaCXX/type-traits.cpp


Index: clang/test/SemaCXX/type-traits.cpp
===
--- clang/test/SemaCXX/type-traits.cpp
+++ clang/test/SemaCXX/type-traits.cpp
@@ -2878,9 +2878,15 @@
   char d : 2;
 };
 
+struct UnnamedBitfield {
+  int named : 8;
+  int : 24;
+};
+
 static_assert(!has_unique_object_representations::value, 
"Bitfield padding");
 static_assert(has_unique_object_representations::value, 
"Bitfield padding");
 
static_assert(!has_unique_object_representations::value, 
"Bitfield padding");
+static_assert(!has_unique_object_representations::value, 
"Bitfield padding");
 
 struct BoolBitfield {
   bool b : 8;
Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -2831,13 +2831,17 @@
   return structHasUniqueObjectRepresentations(Context, RD);
 }
 
-template 
+template 
 static std::optional structSubobjectsHaveUniqueObjectRepresentations(
 const RangeT &Subobjects, int64_t CurOffsetInBits,
 const ASTContext &Context, const clang::ASTRecordLayout &Layout) {
   for (const auto *Subobject : Subobjects) {
 std::optional SizeInBits =
 getSubobjectSizeInBits(Subobject, Context);
+if constexpr (CheckUnnamedBitFields) {
+  if (Subobject->isUnnamedBitfield())
+return std::nullopt;
+}
 if (!SizeInBits)
   return std::nullopt;
 if (*SizeInBits != 0) {
@@ -2873,15 +2877,15 @@
 });
 
 std::optional OffsetAfterBases =
-structSubobjectsHaveUniqueObjectRepresentations(Bases, CurOffsetInBits,
-Context, Layout);
+structSubobjectsHaveUniqueObjectRepresentations(
+Bases, CurOffsetInBits, Context, Layout);
 if (!OffsetAfterBases)
   return std::nullopt;
 CurOffsetInBits = *OffsetAfterBases;
   }
 
   std::optional OffsetAfterFields =
-  structSubobjectsHaveUniqueObjectRepresentations(
+  structSubobjectsHaveUniqueObjectRepresentations(
   RD->fields(), CurOffsetInBits, Context, Layout);
   if (!OffsetAfterFields)
 return std::nullopt;
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -202,6 +202,9 @@
 - Fix crash when evaluating consteval constructor of derived class whose base
   has more than one field.
   (`#60166 `_)
+- Fix bug in the computation of the ``__has_unique_object_representations``
+  builtin for types with unnamed bitfields.
+  (`#61336 `_)
 
 Bug Fixes to AST Handling
 ^


Index: clang/test/SemaCXX/type-traits.cpp
===
--- clang/test/SemaCXX/type-traits.cpp
+++ clang/test/SemaCXX/type-traits.cpp
@@ -2878,9 +2878,15 @@
   char d : 2;
 };
 
+struct UnnamedBitfield {
+  int named : 8;
+  int : 24;
+};
+
 static_assert(!has_unique_object_representations::value, "Bitfield padding");
 static_assert(has_unique_object_representations::value, "Bitfield padding");
 static_assert(!has_unique_object_representations::value, "Bitfield padding");
+static_assert(!has_unique_object_representations::value, "Bitfield padding");
 
 struct BoolBitfield {
   bool b : 8;
Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -2831,13 +2831,17 @@
   return structHasUniqueObjectRepresentations(Context, RD);
 }
 
-template 
+template 
 static std::optional structSubobjectsHaveUniqueObjectRepresentations(
 const RangeT &Subobjects, int64_t CurOffsetInBits,
 const ASTContext &Context, const clang::ASTRecordLayout &Layout) {
   for (const auto *Subobject : Subobjects) {
 std::optional SizeInBits =
 getSubobjectSizeInBits(Subobject, Context);
+if constexpr (CheckUnnamedBitFields) {
+  if (Subobject->isUnnamedBitfield())
+return std::nullopt;
+}
 if (!SizeInBits)
   return std::nullopt;
 if (*SizeInBits != 0) {
@@ -2873,15 +2877,15 @@
 });
 
 std::optional OffsetAfterBases =
-structSubobjectsHaveUniqueObjectRepresentations(Bases, CurOffsetInBits,
-Context, Layout);
+structSub

[PATCH] D145852: [Clang][AST] Fix __has_unique_object_representations computation for unnamed bitfields.

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

Change to a simpler fix.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145852

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/AST/ASTContext.cpp
  clang/test/SemaCXX/type-traits.cpp


Index: clang/test/SemaCXX/type-traits.cpp
===
--- clang/test/SemaCXX/type-traits.cpp
+++ clang/test/SemaCXX/type-traits.cpp
@@ -2878,9 +2878,15 @@
   char d : 2;
 };
 
+struct UnnamedBitfield {
+  int named : 8;
+  int : 24;
+};
+
 static_assert(!has_unique_object_representations::value, 
"Bitfield padding");
 static_assert(has_unique_object_representations::value, 
"Bitfield padding");
 
static_assert(!has_unique_object_representations::value, 
"Bitfield padding");
+static_assert(!has_unique_object_representations::value, 
"Bitfield padding");
 
 struct BoolBitfield {
   bool b : 8;
Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -2810,6 +2810,9 @@
   int64_t FieldSizeInBits =
   Context.toBits(Context.getTypeSizeInChars(Field->getType()));
   if (Field->isBitField()) {
+if (Field->isUnnamedBitfield())
+  return std::nullopt;
+
 int64_t BitfieldSize = Field->getBitWidthValue(Context);
 if (IsBitIntType) {
   if ((unsigned)BitfieldSize >
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -202,6 +202,9 @@
 - Fix crash when evaluating consteval constructor of derived class whose base
   has more than one field.
   (`#60166 `_)
+- Fix bug in the computation of the ``__has_unique_object_representations``
+  builtin for types with unnamed bitfields.
+  (`#61336 `_)
 
 Bug Fixes to AST Handling
 ^


Index: clang/test/SemaCXX/type-traits.cpp
===
--- clang/test/SemaCXX/type-traits.cpp
+++ clang/test/SemaCXX/type-traits.cpp
@@ -2878,9 +2878,15 @@
   char d : 2;
 };
 
+struct UnnamedBitfield {
+  int named : 8;
+  int : 24;
+};
+
 static_assert(!has_unique_object_representations::value, "Bitfield padding");
 static_assert(has_unique_object_representations::value, "Bitfield padding");
 static_assert(!has_unique_object_representations::value, "Bitfield padding");
+static_assert(!has_unique_object_representations::value, "Bitfield padding");
 
 struct BoolBitfield {
   bool b : 8;
Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -2810,6 +2810,9 @@
   int64_t FieldSizeInBits =
   Context.toBits(Context.getTypeSizeInChars(Field->getType()));
   if (Field->isBitField()) {
+if (Field->isUnnamedBitfield())
+  return std::nullopt;
+
 int64_t BitfieldSize = Field->getBitWidthValue(Context);
 if (IsBitIntType) {
   if ((unsigned)BitfieldSize >
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -202,6 +202,9 @@
 - Fix crash when evaluating consteval constructor of derived class whose base
   has more than one field.
   (`#60166 `_)
+- Fix bug in the computation of the ``__has_unique_object_representations``
+  builtin for types with unnamed bitfields.
+  (`#61336 `_)
 
 Bug Fixes to AST Handling
 ^
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D144206: [clang-tidy] Fix false-positive in cppcoreguidelines-slicing

2023-03-11 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL updated this revision to Diff 504377.
PiotrZSL marked an inline comment as done.
PiotrZSL added a comment.

Review comments fix


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144206

Files:
  clang-tools-extra/clang-tidy/cppcoreguidelines/SlicingCheck.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/slicing.cpp


Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/slicing.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/slicing.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/slicing.cpp
@@ -98,3 +98,25 @@
   a = h;
   // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: slicing object from type 
'DerivedThatOverridesH' to 'Base' discards override 'h'
 }
+
+namespace PR31187 {
+// Don't warn when calling constructor of base virtual class, from
+// initialization list of derived class constructor.
+
+struct BaseA {
+virtual ~BaseA() {}
+virtual void foo() {}
+
+int i;
+};
+
+struct BaseB : virtual BaseA {
+virtual void foo() {}
+};
+
+struct ClassWithVirtualBases : BaseB {
+  ClassWithVirtualBases(const BaseB& other) : BaseA(other), BaseB(other) {}
+  ClassWithVirtualBases(const ClassWithVirtualBases& other) : BaseA(other), 
BaseB(other) {}
+};
+
+}
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -199,11 +199,15 @@
   ` check. Basic support
   for bit-field and integer members as a loop variable or upper limit were 
added.
 
-- Improved :doc:`readability-magic-numbers 
+- Improved :doc:`readability-magic-numbers
   ` check, now allows for
   magic numbers in type aliases such as ``using`` and ``typedef`` declarations 
if
   the new ``IgnoreTypeAliases`` option is set to true.
 
+- Fixed a false positive in :doc:`cppcoreguidelines-slicing
+  ` check when warning would be
+  emitted in constructor for virtual base class initialization.
+
 Removed checks
 ^^
 
Index: clang-tools-extra/clang-tidy/cppcoreguidelines/SlicingCheck.cpp
===
--- clang-tools-extra/clang-tidy/cppcoreguidelines/SlicingCheck.cpp
+++ clang-tools-extra/clang-tidy/cppcoreguidelines/SlicingCheck.cpp
@@ -40,12 +40,15 @@
   const auto HasTypeDerivedFromBaseDecl =
   anyOf(hasType(IsDerivedFromBaseDecl),
 hasType(references(IsDerivedFromBaseDecl)));
-  const auto IsWithinDerivedCtor =
-  hasParent(cxxConstructorDecl(ofClass(equalsBoundNode("DerivedDecl";
+  const auto IsCallToBaseClass = hasParent(cxxConstructorDecl(
+  ofClass(isSameOrDerivedFrom(equalsBoundNode("DerivedDecl"))),
+  hasAnyConstructorInitializer(allOf(
+  isBaseInitializer(), withInitializer(equalsBoundNode("Call"));
 
   // Assignment slicing: "a = b;" and "a = std::move(b);" variants.
   const auto SlicesObjectInAssignment =
-  callExpr(callee(cxxMethodDecl(anyOf(isCopyAssignmentOperator(),
+  callExpr(expr().bind("Call"),
+   callee(cxxMethodDecl(anyOf(isCopyAssignmentOperator(),
   isMoveAssignmentOperator()),
 OfBaseClass)),
hasArgument(1, HasTypeDerivedFromBaseDecl));
@@ -53,17 +56,17 @@
   // Construction slicing: "A a{b};" and "f(b);" variants. Note that in case of
   // slicing the letter will create a temporary and therefore call a ctor.
   const auto SlicesObjectInCtor = cxxConstructExpr(
+  expr().bind("Call"),
   hasDeclaration(cxxConstructorDecl(
   anyOf(isCopyConstructor(), isMoveConstructor()), OfBaseClass)),
   hasArgument(0, HasTypeDerivedFromBaseDecl),
   // We need to disable matching on the call to the base copy/move
   // constructor in DerivedDecl's constructors.
-  unless(IsWithinDerivedCtor));
+  unless(IsCallToBaseClass));
 
-  Finder->addMatcher(traverse(TK_AsIs, expr(anyOf(SlicesObjectInAssignment,
-  SlicesObjectInCtor))
-   .bind("Call")),
- this);
+  Finder->addMatcher(
+  traverse(TK_AsIs, expr(SlicesObjectInAssignment).bind("Call")), this);
+  Finder->addMatcher(traverse(TK_AsIs, SlicesObjectInCtor), this);
 }
 
 /// Warns on methods overridden in DerivedDecl with respect to BaseDecl.


Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/slicing.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/slicing.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/slicing.cpp
@@ -98,3 +98,25 @@
   a = h;
   // CHECK-MESSAGES: :[[@LINE-1]]:5: war

[PATCH] D144206: [clang-tidy] Fix false-positive in cppcoreguidelines-slicing

2023-03-11 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL added a comment.

Ack.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144206

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


[clang] b1fdcd5 - [Flang] Allow compile *.f03, *.f08 file

2023-03-11 Thread Shao-Ce SUN via cfe-commits

Author: Shao-Ce SUN
Date: 2023-03-12T01:11:42+08:00
New Revision: b1fdcd5fbc09f9f3e1c8a8b954aa8f9067401b31

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

LOG: [Flang] Allow compile *.f03, *.f08 file

Fix issue [#61260](https://github.com/llvm/llvm-project/issues/61260)

Reviewed By: awarzynski

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

Added: 
flang/test/Driver/supported-suffices/f03-suffix.f03
flang/test/Driver/supported-suffices/f08-suffix.f08

Modified: 
clang/lib/Driver/Types.cpp

Removed: 




diff  --git a/clang/lib/Driver/Types.cpp b/clang/lib/Driver/Types.cpp
index a890cc58ee421..7d6308d757bc7 100644
--- a/clang/lib/Driver/Types.cpp
+++ b/clang/lib/Driver/Types.cpp
@@ -331,6 +331,10 @@ types::ID types::lookupTypeForExtension(llvm::StringRef 
Ext) {
   .Case("cui", TY_PP_CUDA)
   .Case("cxx", TY_CXX)
   .Case("CXX", TY_CXX)
+  .Case("F03", TY_Fortran)
+  .Case("f03", TY_PP_Fortran)
+  .Case("F08", TY_Fortran)
+  .Case("f08", TY_PP_Fortran)
   .Case("F90", TY_Fortran)
   .Case("f90", TY_PP_Fortran)
   .Case("F95", TY_Fortran)

diff  --git a/flang/test/Driver/supported-suffices/f03-suffix.f03 
b/flang/test/Driver/supported-suffices/f03-suffix.f03
new file mode 100644
index 0..6e03f9f43fc60
--- /dev/null
+++ b/flang/test/Driver/supported-suffices/f03-suffix.f03
@@ -0,0 +1,5 @@
+! RUN: %flang -### %s 2>&1 | FileCheck %s
+
+! CHECK: "{{.*}}flang-new" "-fc1" {{.*}} "-o" "{{.*}}.o"
+program f03
+end program f03

diff  --git a/flang/test/Driver/supported-suffices/f08-suffix.f08 
b/flang/test/Driver/supported-suffices/f08-suffix.f08
new file mode 100644
index 0..d5bcf4ce1de1c
--- /dev/null
+++ b/flang/test/Driver/supported-suffices/f08-suffix.f08
@@ -0,0 +1,5 @@
+! RUN: %flang -### %s 2>&1 | FileCheck %s
+
+! CHECK: "{{.*}}flang-new" "-fc1" {{.*}} "-o" "{{.*}}.o"
+program f08
+end program f08



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


[PATCH] D145845: [Flang] Allow compile *.f03, *.f08 file

2023-03-11 Thread Shao-Ce SUN via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb1fdcd5fbc09: [Flang] Allow compile *.f03, *.f08 file 
(authored by sunshaoce).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145845

Files:
  clang/lib/Driver/Types.cpp
  flang/test/Driver/supported-suffices/f03-suffix.f03
  flang/test/Driver/supported-suffices/f08-suffix.f08


Index: flang/test/Driver/supported-suffices/f08-suffix.f08
===
--- /dev/null
+++ flang/test/Driver/supported-suffices/f08-suffix.f08
@@ -0,0 +1,5 @@
+! RUN: %flang -### %s 2>&1 | FileCheck %s
+
+! CHECK: "{{.*}}flang-new" "-fc1" {{.*}} "-o" "{{.*}}.o"
+program f08
+end program f08
Index: flang/test/Driver/supported-suffices/f03-suffix.f03
===
--- /dev/null
+++ flang/test/Driver/supported-suffices/f03-suffix.f03
@@ -0,0 +1,5 @@
+! RUN: %flang -### %s 2>&1 | FileCheck %s
+
+! CHECK: "{{.*}}flang-new" "-fc1" {{.*}} "-o" "{{.*}}.o"
+program f03
+end program f03
Index: clang/lib/Driver/Types.cpp
===
--- clang/lib/Driver/Types.cpp
+++ clang/lib/Driver/Types.cpp
@@ -331,6 +331,10 @@
   .Case("cui", TY_PP_CUDA)
   .Case("cxx", TY_CXX)
   .Case("CXX", TY_CXX)
+  .Case("F03", TY_Fortran)
+  .Case("f03", TY_PP_Fortran)
+  .Case("F08", TY_Fortran)
+  .Case("f08", TY_PP_Fortran)
   .Case("F90", TY_Fortran)
   .Case("f90", TY_PP_Fortran)
   .Case("F95", TY_Fortran)


Index: flang/test/Driver/supported-suffices/f08-suffix.f08
===
--- /dev/null
+++ flang/test/Driver/supported-suffices/f08-suffix.f08
@@ -0,0 +1,5 @@
+! RUN: %flang -### %s 2>&1 | FileCheck %s
+
+! CHECK: "{{.*}}flang-new" "-fc1" {{.*}} "-o" "{{.*}}.o"
+program f08
+end program f08
Index: flang/test/Driver/supported-suffices/f03-suffix.f03
===
--- /dev/null
+++ flang/test/Driver/supported-suffices/f03-suffix.f03
@@ -0,0 +1,5 @@
+! RUN: %flang -### %s 2>&1 | FileCheck %s
+
+! CHECK: "{{.*}}flang-new" "-fc1" {{.*}} "-o" "{{.*}}.o"
+program f03
+end program f03
Index: clang/lib/Driver/Types.cpp
===
--- clang/lib/Driver/Types.cpp
+++ clang/lib/Driver/Types.cpp
@@ -331,6 +331,10 @@
   .Case("cui", TY_PP_CUDA)
   .Case("cxx", TY_CXX)
   .Case("CXX", TY_CXX)
+  .Case("F03", TY_Fortran)
+  .Case("f03", TY_PP_Fortran)
+  .Case("F08", TY_Fortran)
+  .Case("f08", TY_PP_Fortran)
   .Case("F90", TY_Fortran)
   .Case("f90", TY_PP_Fortran)
   .Case("F95", TY_Fortran)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D144206: [clang-tidy] Fix false-positive in cppcoreguidelines-slicing

2023-03-11 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp accepted this revision.
carlosgalvezp added a comment.
This revision is now accepted and ready to land.

LGTM, thanks for the fix!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144206

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


[PATCH] D145311: [clang-tidy] Make abseil-redundant-strcat-calls checker use header

2023-03-11 Thread Mike Crowe via Phabricator via cfe-commits
mikecrowe added a comment.

In D145311#4184159 , @PiotrZSL wrote:

> It's fine, absl::StrCat returns std::string.
> So those changes are correct.

Thanks. Would you like me to remove the unnecessary noise from the commit 
message then, or will you do that as part of landing it?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145311

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


[PATCH] D133289: [C2X] N3007 Type inference for object definitions

2023-03-11 Thread Guillot Tony via Phabricator via cfe-commits
to268 updated this revision to Diff 504381.
to268 added a comment.

Patch update: Reverting `auto` as a type specifier.
I am currently figuring out what behavior the `auto` keyword need to match.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133289

Files:
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Sema/DeclSpec.cpp
  clang/test/C/C2x/n3007.c
  clang/test/CodeGen/auto.c
  clang/test/Parser/c2x-auto.c
  clang/test/Sema/c2x-auto.c
  clang/www/c_status.html

Index: clang/www/c_status.html
===
--- clang/www/c_status.html
+++ clang/www/c_status.html
@@ -1195,7 +1195,7 @@
 
   Type inference for object declarations
   https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3007.htm";>N3007
-  No
+  Clang 17
 
 
   constexpr for object definitions
Index: clang/test/Sema/c2x-auto.c
===
--- /dev/null
+++ clang/test/Sema/c2x-auto.c
@@ -0,0 +1,75 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c2x %s
+
+void test_basic_types(void) {
+  auto undefined; // expected-error {{declaration of variable 'undefined' with deduced type 'auto' requires an initializer}}
+  auto auto_int = 4;
+  auto auto_long = 4UL;
+}
+
+void test_sizeof_typeof(void) {
+  auto auto_size = sizeof(auto);  // expected-error {{expected expression}}
+  typeof(auto) tpof = 4;  // expected-error {{expected expression}}
+}
+
+void test_casts(void) {
+  auto int_cast = (int)(4 + 3);
+  auto double_cast = (double)(1 / 3);
+  auto long_cast = (long)(4UL + 3UL);
+  auto auto_cast = (auto)(4 + 3); // expected-error {{expected expression}}
+}
+
+void test_compound_literral(void) {
+  auto int_cl = (int){13};
+  auto double_cl = (double){2.5};
+  auto array[] = { 1, 2, 3 }; // expected-error {{'array' declared as array of 'auto'}}
+
+  // FIXME: This should be accepted per C2x 6.5.2.5p4
+  auto auto_cl = (auto){13};  // expected-error {{expected expression}}
+}
+
+void test_array_pointers(void) {
+  double array[3] = { 0 };
+  auto a = array;
+  auto b = &array;
+}
+
+void test_qualifiers(const int y) {
+  const auto a = 12;
+  auto b = y;
+  static auto c = 1UL;
+  int* pa = &a; // expected-warning {{initializing 'int *' with an expression of type 'const int *' discards qualifiers}}
+  const int* pb = &b;
+  int* pc = &c; // expected-warning {{incompatible pointer types initializing 'int *' with an expression of type 'unsigned long *'}}
+
+}
+
+void test_strings(void) {
+  auto str = "this is a string";
+  // FIXME: This should work for char*
+  auto str2[] = "this is a string"; // expected-error {{str2' declared as array of 'auto'}}
+  auto (str3) = "this is a string";
+  auto (((str4))) = "this is a string";
+}
+
+void test_pointers(void) {
+  // FIXME: as mentioned in N3076, it seems that auto* is allowed
+  auto a = 12;
+  auto *ptr = &a;
+  auto *str = "this is a string";
+  const auto *str2 = "this is a string";
+  auto *b = &a;
+  *b = &a; // expected-error {{incompatible pointer to integer conversion assigning to 'int' from 'int *'; remove &}}
+}
+
+void test_scopes(void) {
+  double a = 7;
+  double b = 9;
+  {
+auto a = a * a; // expected-error {{variable 'a' declared with deduced type 'auto' cannot appear in its own initializer}} \
+   expected-error {{variable 'a' declared with deduced type 'auto' cannot appear in its own initializer}}
+  }
+  {
+auto b = a * a;
+auto a = b;
+  }
+}
Index: clang/test/Parser/c2x-auto.c
===
--- /dev/null
+++ clang/test/Parser/c2x-auto.c
@@ -0,0 +1,123 @@
+// RUN: %clang_cc1 -fsyntax-only -verify=expected,c2x -std=c2x %s
+// RUN: %clang_cc1 -fsyntax-only -verify=expected,c17 -std=c17 %s
+
+#define AUTO_MACRO(_NAME, ARG, ARG2, ARG3) \
+auto _NAME = ARG + (ARG2 / ARG3);
+
+struct S {
+  int a;
+  auto b;   // c2x-error {{'auto' not allowed in struct member}} \
+   c17-error {{type name does not allow storage class to be specified}} \
+   c17-error {{type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int}}
+  union {
+char c;
+auto smth;  // c2x-error {{'auto' not allowed in union member}} \
+   c17-error {{type name does not allow storage class to be specified}} \
+   c17-error {{type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int}}
+  } u;
+};
+
+enum E : auto { // c2x-error {{'auto' not allowed here}} \
+   c17-error {{expected a type}} \
+   c17-error {{type name does not allow storage class to be specified}}
+  One,
+  Two,
+  Tree,
+};
+
+auto basic_usage(auto auto) {   // c2x-error {{'auto' not allowed in function prototype}} \
+   c2x-error {{'auto

[clang-tools-extra] f1e2469 - [clang-tidy] Fix false-positive in cppcoreguidelines-slicing

2023-03-11 Thread Piotr Zegar via cfe-commits

Author: Piotr Zegar
Date: 2023-03-11T17:36:21Z
New Revision: f1e2469edcfc160867e4ef73b2dcc259974c9d6a

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

LOG: [clang-tidy] Fix false-positive in cppcoreguidelines-slicing

When warning would be emitted in constructor for virtual base class
initialization.

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

Reviewed By: carlosgalvezp

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/cppcoreguidelines/SlicingCheck.cpp
clang-tools-extra/docs/ReleaseNotes.rst
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/slicing.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/cppcoreguidelines/SlicingCheck.cpp 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/SlicingCheck.cpp
index bc094a2f028d..76754394de76 100644
--- a/clang-tools-extra/clang-tidy/cppcoreguidelines/SlicingCheck.cpp
+++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/SlicingCheck.cpp
@@ -40,12 +40,15 @@ void SlicingCheck::registerMatchers(MatchFinder *Finder) {
   const auto HasTypeDerivedFromBaseDecl =
   anyOf(hasType(IsDerivedFromBaseDecl),
 hasType(references(IsDerivedFromBaseDecl)));
-  const auto IsWithinDerivedCtor =
-  hasParent(cxxConstructorDecl(ofClass(equalsBoundNode("DerivedDecl";
+  const auto IsCallToBaseClass = hasParent(cxxConstructorDecl(
+  ofClass(isSameOrDerivedFrom(equalsBoundNode("DerivedDecl"))),
+  hasAnyConstructorInitializer(allOf(
+  isBaseInitializer(), withInitializer(equalsBoundNode("Call"));
 
   // Assignment slicing: "a = b;" and "a = std::move(b);" variants.
   const auto SlicesObjectInAssignment =
-  callExpr(callee(cxxMethodDecl(anyOf(isCopyAssignmentOperator(),
+  callExpr(expr().bind("Call"),
+   callee(cxxMethodDecl(anyOf(isCopyAssignmentOperator(),
   isMoveAssignmentOperator()),
 OfBaseClass)),
hasArgument(1, HasTypeDerivedFromBaseDecl));
@@ -53,17 +56,17 @@ void SlicingCheck::registerMatchers(MatchFinder *Finder) {
   // Construction slicing: "A a{b};" and "f(b);" variants. Note that in case of
   // slicing the letter will create a temporary and therefore call a ctor.
   const auto SlicesObjectInCtor = cxxConstructExpr(
+  expr().bind("Call"),
   hasDeclaration(cxxConstructorDecl(
   anyOf(isCopyConstructor(), isMoveConstructor()), OfBaseClass)),
   hasArgument(0, HasTypeDerivedFromBaseDecl),
   // We need to disable matching on the call to the base copy/move
   // constructor in DerivedDecl's constructors.
-  unless(IsWithinDerivedCtor));
+  unless(IsCallToBaseClass));
 
-  Finder->addMatcher(traverse(TK_AsIs, expr(anyOf(SlicesObjectInAssignment,
-  SlicesObjectInCtor))
-   .bind("Call")),
- this);
+  Finder->addMatcher(
+  traverse(TK_AsIs, expr(SlicesObjectInAssignment).bind("Call")), this);
+  Finder->addMatcher(traverse(TK_AsIs, SlicesObjectInCtor), this);
 }
 
 /// Warns on methods overridden in DerivedDecl with respect to BaseDecl.

diff  --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index bda6168f3aac..4e861dcd38cf 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -199,11 +199,15 @@ Changes in existing checks
   ` check. Basic support
   for bit-field and integer members as a loop variable or upper limit were 
added.
 
-- Improved :doc:`readability-magic-numbers 
+- Improved :doc:`readability-magic-numbers
   ` check, now allows for
   magic numbers in type aliases such as ``using`` and ``typedef`` declarations 
if
   the new ``IgnoreTypeAliases`` option is set to true.
 
+- Fixed a false positive in :doc:`cppcoreguidelines-slicing
+  ` check when warning would be
+  emitted in constructor for virtual base class initialization.
+
 Removed checks
 ^^
 

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/slicing.cpp 
b/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/slicing.cpp
index 6856f52f7061..58ca644f18d4 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/slicing.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/slicing.cpp
@@ -98,3 +98,25 @@ void negatives() {
   a = h;
   // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: slicing object from type 
'DerivedThatOverridesH' to 'Base' discards override 'h'
 }
+
+namespace PR31187 {
+// Don't warn when calling constructor of base virtual class, from
+// initialization list of derived class constructor.
+

[PATCH] D144206: [clang-tidy] Fix false-positive in cppcoreguidelines-slicing

2023-03-11 Thread Piotr Zegar via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf1e2469edcfc: [clang-tidy] Fix false-positive in 
cppcoreguidelines-slicing (authored by PiotrZSL).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144206

Files:
  clang-tools-extra/clang-tidy/cppcoreguidelines/SlicingCheck.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/slicing.cpp


Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/slicing.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/slicing.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/slicing.cpp
@@ -98,3 +98,25 @@
   a = h;
   // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: slicing object from type 
'DerivedThatOverridesH' to 'Base' discards override 'h'
 }
+
+namespace PR31187 {
+// Don't warn when calling constructor of base virtual class, from
+// initialization list of derived class constructor.
+
+struct BaseA {
+virtual ~BaseA() {}
+virtual void foo() {}
+
+int i;
+};
+
+struct BaseB : virtual BaseA {
+virtual void foo() {}
+};
+
+struct ClassWithVirtualBases : BaseB {
+  ClassWithVirtualBases(const BaseB& other) : BaseA(other), BaseB(other) {}
+  ClassWithVirtualBases(const ClassWithVirtualBases& other) : BaseA(other), 
BaseB(other) {}
+};
+
+}
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -199,11 +199,15 @@
   ` check. Basic support
   for bit-field and integer members as a loop variable or upper limit were 
added.
 
-- Improved :doc:`readability-magic-numbers 
+- Improved :doc:`readability-magic-numbers
   ` check, now allows for
   magic numbers in type aliases such as ``using`` and ``typedef`` declarations 
if
   the new ``IgnoreTypeAliases`` option is set to true.
 
+- Fixed a false positive in :doc:`cppcoreguidelines-slicing
+  ` check when warning would be
+  emitted in constructor for virtual base class initialization.
+
 Removed checks
 ^^
 
Index: clang-tools-extra/clang-tidy/cppcoreguidelines/SlicingCheck.cpp
===
--- clang-tools-extra/clang-tidy/cppcoreguidelines/SlicingCheck.cpp
+++ clang-tools-extra/clang-tidy/cppcoreguidelines/SlicingCheck.cpp
@@ -40,12 +40,15 @@
   const auto HasTypeDerivedFromBaseDecl =
   anyOf(hasType(IsDerivedFromBaseDecl),
 hasType(references(IsDerivedFromBaseDecl)));
-  const auto IsWithinDerivedCtor =
-  hasParent(cxxConstructorDecl(ofClass(equalsBoundNode("DerivedDecl";
+  const auto IsCallToBaseClass = hasParent(cxxConstructorDecl(
+  ofClass(isSameOrDerivedFrom(equalsBoundNode("DerivedDecl"))),
+  hasAnyConstructorInitializer(allOf(
+  isBaseInitializer(), withInitializer(equalsBoundNode("Call"));
 
   // Assignment slicing: "a = b;" and "a = std::move(b);" variants.
   const auto SlicesObjectInAssignment =
-  callExpr(callee(cxxMethodDecl(anyOf(isCopyAssignmentOperator(),
+  callExpr(expr().bind("Call"),
+   callee(cxxMethodDecl(anyOf(isCopyAssignmentOperator(),
   isMoveAssignmentOperator()),
 OfBaseClass)),
hasArgument(1, HasTypeDerivedFromBaseDecl));
@@ -53,17 +56,17 @@
   // Construction slicing: "A a{b};" and "f(b);" variants. Note that in case of
   // slicing the letter will create a temporary and therefore call a ctor.
   const auto SlicesObjectInCtor = cxxConstructExpr(
+  expr().bind("Call"),
   hasDeclaration(cxxConstructorDecl(
   anyOf(isCopyConstructor(), isMoveConstructor()), OfBaseClass)),
   hasArgument(0, HasTypeDerivedFromBaseDecl),
   // We need to disable matching on the call to the base copy/move
   // constructor in DerivedDecl's constructors.
-  unless(IsWithinDerivedCtor));
+  unless(IsCallToBaseClass));
 
-  Finder->addMatcher(traverse(TK_AsIs, expr(anyOf(SlicesObjectInAssignment,
-  SlicesObjectInCtor))
-   .bind("Call")),
- this);
+  Finder->addMatcher(
+  traverse(TK_AsIs, expr(SlicesObjectInAssignment).bind("Call")), this);
+  Finder->addMatcher(traverse(TK_AsIs, SlicesObjectInCtor), this);
 }
 
 /// Warns on methods overridden in DerivedDecl with respect to BaseDecl.


Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/slicing.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/slicing.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/slicing.cpp
@@ -98,3 +98,25

[PATCH] D143342: [clang-tidy] Support std::format and std::print in readability-redundant-string-cstr

2023-03-11 Thread Mike Crowe via Phabricator via cfe-commits
mikecrowe added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp:189
+  getLangOpts().CPlusPlus2b
+  ? hasAnyName("::std::print", "::std::format")
+  : hasName("::std::format"))),

PiotrZSL wrote:
> Please introduce configuration option to specify custom functions.
> For example if some project (like mine) is wrapping fmt::format with some 
> variadic template function, then such function could be specified.
> Same goes to things like some loggers.
> 
> Check utils/OptionsUtils.h for configuration, and  utils/Matchers.h 
> (matchesAnyListedName)
> Please introduce configuration option to specify custom functions.
> For example if some project (like mine) is wrapping fmt::format with some 
> variadic template function, then such function could be specified.

That's exactly where this change originated (as part of [[ 
https://github.com/mikecrowe/clang-tidy-fmt | my clang-tidy fmt fork ]], which 
I hope to submit for review soon once I've made it configurable too and 
improved the test cases.)

> Same goes to things like some loggers.
> 
> Check utils/OptionsUtils.h for configuration, and  utils/Matchers.h 
> (matchesAnyListedName)

Thanks for the pointer. I shall study those files for how to support this.

Do you think that the change can land like in its current state first? Or would 
you prefer that the configuration option is added at the same time?


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

https://reviews.llvm.org/D143342

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


[clang-tools-extra] 9883558 - [clang-tidy][NFC] Make abseil-redundant-strcat-calls checker use header

2023-03-11 Thread Piotr Zegar via cfe-commits

Author: Mike Crowe
Date: 2023-03-11T17:46:56Z
New Revision: 988355808efcf88719b0fa542779c47742756764

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

LOG: [clang-tidy][NFC] Make abseil-redundant-strcat-calls checker use  
header

Remove duplication in abseil-redundant-strcat-calls check tests,
by using dummy  header file string.

Depends on D145310

Reviewed By: PiotrZSL

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

Added: 


Modified: 
clang-tools-extra/test/clang-tidy/checkers/abseil/redundant-strcat-calls.cpp

Removed: 




diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/abseil/redundant-strcat-calls.cpp 
b/clang-tools-extra/test/clang-tidy/checkers/abseil/redundant-strcat-calls.cpp
index dad8ef857e2a1..ecd17bba293c5 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/abseil/redundant-strcat-calls.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/abseil/redundant-strcat-calls.cpp
@@ -1,92 +1,8 @@
-// RUN: %check_clang_tidy %s abseil-redundant-strcat-calls %t
+// RUN: %check_clang_tidy %s abseil-redundant-strcat-calls %t -- -- -isystem 
%clang_tidy_headers
+#include 
 
 int strlen(const char *);
 
-// Here we mimic the hierarchy of ::string.
-// We need to do so because we are matching on the fully qualified name of the
-// methods.
-struct __sso_string_base {};
-namespace __gnu_cxx {
-template 
-class __versa_string {
- public:
-  const char *c_str() const;
-  const char *data() const;
-  int size() const;
-  int capacity() const;
-  int length() const;
-  bool empty() const;
-  char &operator[](int);
-  void clear();
-  void resize(int);
-  int compare(const __versa_string &) const;
-};
-}  // namespace __gnu_cxx
-
-namespace std {
-template 
-class char_traits {};
-template 
-class allocator {};
-}  // namespace std
-
-template ,
-  typename C = std::allocator>
-class basic_string : public __gnu_cxx::__versa_string {
- public:
-  basic_string();
-  basic_string(const basic_string &);
-  basic_string(const char *, C = C());
-  basic_string(const char *, int, C = C());
-  basic_string(const basic_string &, int, int, C = C());
-  ~basic_string();
-
-  basic_string &operator+=(const basic_string &);
-};
-
-template 
-basic_string operator+(const basic_string &,
-const basic_string &);
-template 
-basic_string operator+(const basic_string &, const char *);
-
-typedef basic_string string;
-
-bool operator==(const string &, const string &);
-bool operator==(const string &, const char *);
-bool operator==(const char *, const string &);
-
-bool operator!=(const string &, const string &);
-bool operator<(const string &, const string &);
-bool operator>(const string &, const string &);
-bool operator<=(const string &, const string &);
-bool operator>=(const string &, const string &);
-
-namespace std {
-template ,
-  typename _Alloc = allocator<_CharT>>
-class basic_string;
-
-template 
-class basic_string {
- public:
-  basic_string();
-  basic_string(const basic_string &);
-  basic_string(const char *, const _Alloc & = _Alloc());
-  basic_string(const char *, int, const _Alloc & = _Alloc());
-  basic_string(const basic_string &, int, int, const _Alloc & = _Alloc());
-  ~basic_string();
-
-  basic_string &operator+=(const basic_string &);
-
-  unsigned size() const;
-  unsigned length() const;
-  bool empty() const;
-};
-
-typedef basic_string string;
-}  // namespace std
-
 namespace absl {
 
 class string_view {
@@ -95,12 +11,12 @@ class string_view {
 
   string_view();
   string_view(const char *);
-  string_view(const string &);
+  string_view(const std::string &);
   string_view(const char *, int);
   string_view(string_view, int);
 
   template 
-  explicit operator ::basic_string() const;
+  explicit operator std::basic_string() const;
 
   const char *data() const;
   int size() const;
@@ -113,7 +29,7 @@ struct AlphaNum {
   AlphaNum(int i);
   AlphaNum(double f);
   AlphaNum(const char *c_str);
-  AlphaNum(const string &str);
+  AlphaNum(const std::string &str);
   AlphaNum(const string_view &pc);
 
  private:
@@ -121,28 +37,28 @@ struct AlphaNum {
   AlphaNum &operator=(const AlphaNum &);
 };
 
-string StrCat();
-string StrCat(const AlphaNum &A);
-string StrCat(const AlphaNum &A, const AlphaNum &B);
-string StrCat(const AlphaNum &A, const AlphaNum &B, const AlphaNum &C);
-string StrCat(const AlphaNum &A, const AlphaNum &B, const AlphaNum &C,
-  const AlphaNum &D);
+std::string StrCat();
+std::string StrCat(const AlphaNum &A);
+std::string StrCat(const AlphaNum &A, const AlphaNum &B);
+std::string StrCat(const AlphaNum &A, const AlphaNum &B, const AlphaNum &C);
+std::string StrCat(const AlphaNum &A, const AlphaNum &B, const AlphaNum &C,
+   const AlphaNum &D);
 
 // 

[PATCH] D145311: [clang-tidy][NFC] Make abseil-redundant-strcat-calls checker use header

2023-03-11 Thread Piotr Zegar via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG988355808efc: [clang-tidy][NFC] Make 
abseil-redundant-strcat-calls checker use  header (authored by 
mikecrowe, committed by PiotrZSL).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145311

Files:
  clang-tools-extra/test/clang-tidy/checkers/abseil/redundant-strcat-calls.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/abseil/redundant-strcat-calls.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/abseil/redundant-strcat-calls.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/abseil/redundant-strcat-calls.cpp
@@ -1,92 +1,8 @@
-// RUN: %check_clang_tidy %s abseil-redundant-strcat-calls %t
+// RUN: %check_clang_tidy %s abseil-redundant-strcat-calls %t -- -- -isystem %clang_tidy_headers
+#include 
 
 int strlen(const char *);
 
-// Here we mimic the hierarchy of ::string.
-// We need to do so because we are matching on the fully qualified name of the
-// methods.
-struct __sso_string_base {};
-namespace __gnu_cxx {
-template 
-class __versa_string {
- public:
-  const char *c_str() const;
-  const char *data() const;
-  int size() const;
-  int capacity() const;
-  int length() const;
-  bool empty() const;
-  char &operator[](int);
-  void clear();
-  void resize(int);
-  int compare(const __versa_string &) const;
-};
-}  // namespace __gnu_cxx
-
-namespace std {
-template 
-class char_traits {};
-template 
-class allocator {};
-}  // namespace std
-
-template ,
-  typename C = std::allocator>
-class basic_string : public __gnu_cxx::__versa_string {
- public:
-  basic_string();
-  basic_string(const basic_string &);
-  basic_string(const char *, C = C());
-  basic_string(const char *, int, C = C());
-  basic_string(const basic_string &, int, int, C = C());
-  ~basic_string();
-
-  basic_string &operator+=(const basic_string &);
-};
-
-template 
-basic_string operator+(const basic_string &,
-const basic_string &);
-template 
-basic_string operator+(const basic_string &, const char *);
-
-typedef basic_string string;
-
-bool operator==(const string &, const string &);
-bool operator==(const string &, const char *);
-bool operator==(const char *, const string &);
-
-bool operator!=(const string &, const string &);
-bool operator<(const string &, const string &);
-bool operator>(const string &, const string &);
-bool operator<=(const string &, const string &);
-bool operator>=(const string &, const string &);
-
-namespace std {
-template ,
-  typename _Alloc = allocator<_CharT>>
-class basic_string;
-
-template 
-class basic_string {
- public:
-  basic_string();
-  basic_string(const basic_string &);
-  basic_string(const char *, const _Alloc & = _Alloc());
-  basic_string(const char *, int, const _Alloc & = _Alloc());
-  basic_string(const basic_string &, int, int, const _Alloc & = _Alloc());
-  ~basic_string();
-
-  basic_string &operator+=(const basic_string &);
-
-  unsigned size() const;
-  unsigned length() const;
-  bool empty() const;
-};
-
-typedef basic_string string;
-}  // namespace std
-
 namespace absl {
 
 class string_view {
@@ -95,12 +11,12 @@
 
   string_view();
   string_view(const char *);
-  string_view(const string &);
+  string_view(const std::string &);
   string_view(const char *, int);
   string_view(string_view, int);
 
   template 
-  explicit operator ::basic_string() const;
+  explicit operator std::basic_string() const;
 
   const char *data() const;
   int size() const;
@@ -113,7 +29,7 @@
   AlphaNum(int i);
   AlphaNum(double f);
   AlphaNum(const char *c_str);
-  AlphaNum(const string &str);
+  AlphaNum(const std::string &str);
   AlphaNum(const string_view &pc);
 
  private:
@@ -121,28 +37,28 @@
   AlphaNum &operator=(const AlphaNum &);
 };
 
-string StrCat();
-string StrCat(const AlphaNum &A);
-string StrCat(const AlphaNum &A, const AlphaNum &B);
-string StrCat(const AlphaNum &A, const AlphaNum &B, const AlphaNum &C);
-string StrCat(const AlphaNum &A, const AlphaNum &B, const AlphaNum &C,
-  const AlphaNum &D);
+std::string StrCat();
+std::string StrCat(const AlphaNum &A);
+std::string StrCat(const AlphaNum &A, const AlphaNum &B);
+std::string StrCat(const AlphaNum &A, const AlphaNum &B, const AlphaNum &C);
+std::string StrCat(const AlphaNum &A, const AlphaNum &B, const AlphaNum &C,
+   const AlphaNum &D);
 
 // Support 5 or more arguments
 template 
-string StrCat(const AlphaNum &A, const AlphaNum &B, const AlphaNum &C,
+std::string StrCat(const AlphaNum &A, const AlphaNum &B, const AlphaNum &C,
   const AlphaNum &D, const AlphaNum &E, const AV &... args);
 
-void StrAppend(string *Dest, const AlphaNum &A);
-void StrAppend(string *Dest, const AlphaNum &A, const AlphaNum &B);
-void StrAppend(string *Dest, const AlphaNum &A, const 

[PATCH] D145852: [Clang][AST] Fix __has_unique_object_representations computation for unnamed bitfields.

2023-03-11 Thread Vlad Serebrennikov via Phabricator via cfe-commits
Endill accepted this revision.
Endill added a comment.
This revision is now accepted and ready to land.

LGTM
I got confused at first why this fix is done in a function named 
`getSubobjectSizeInBits`, and why do we calculate size to produce a boolean 
value in the end. Then I realized that this function returns number of bits of 
value representation, or `std::nullopt` if there are any padding bits, and we 
take advantage of the latter to implement `hasUniqueObjectRepresentations`. I 
guess I'm either missing some context or that function could be named better 
(not in this patch, of course).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145852

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


[PATCH] D145803: [clang][DebugInfo] Emit DW_AT_type of preferred name if available

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

Yeah, can't say this had occurred to me - but totally makes sense/reckon it's 
OK. Any reason to limit this to lldb? I'd expect it'd probably "Just Work(tm)" 
on any DWARF consumer?

it doesn't hit any recursion issues? (I guess maybe skirts it due to the 
existing recursion handling in the decl/def structure type stuff - so it 
creates a declaration for the type, then creates the typedef, which can find 
that existing declaration, then return the typedef from the create type query?)

I guess it means that references to the type even for like, the type of the 
"this" parameter - would refer to the typedef? That's /probably/ OK if a bit 
surprising to some people/consumers sometimes?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145803

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


[PATCH] D143342: [clang-tidy] Support std::format and std::print in readability-redundant-string-cstr

2023-03-11 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL added a comment.

"Do you think that the change can land like in its current state first? Or 
would you prefer that the configuration option is added at the same time?"

Code is fine, probably If would would write this, then I would bother to split 
into C++20 and C++2B simply because `std::print` wouldn't compile if it 
wouldn't be available. So I would just use hasAnyName.
But code looks fine, configuration could be added later...


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

https://reviews.llvm.org/D143342

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


[PATCH] D143342: [clang-tidy] Support std::format and std::print in readability-redundant-string-cstr

2023-03-11 Thread Mike Crowe via Phabricator via cfe-commits
mikecrowe added a comment.

In D143342#4186809 , @PiotrZSL wrote:

> Code is fine, probably If would would write this, then I would bother to 
> split into C++20 and C++2B simply because `std::print` wouldn't compile if it 
> wouldn't be available. So I would just use hasAnyName.
> But code looks fine, configuration could be added later...

Thanks. I originally wrote it like that, but @njames93 requested that I checked 
the version, so I did. :) It doesn't do any harm and might avoid confusion.


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

https://reviews.llvm.org/D143342

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


[clang] 43c90f9 - [HIP] Make `--offload-add-rpath` alias of `-frtlib-add-rpath`

2023-03-11 Thread Yaxun Liu via cfe-commits

Author: Yaxun (Sam) Liu
Date: 2023-03-11T13:33:17-05:00
New Revision: 43c90f905a2293dde1d6975e6747ce50063cd155

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

LOG: [HIP] Make `--offload-add-rpath` alias of `-frtlib-add-rpath`

HIP runtime is the language runtime of HIP. When users need
to specify rpath, they usually need to specify rpath for
both compiler-rt and HIP runtime. It seems redundant
to have separate options. Therefore make --offload-add-rpath
an alias to -frtlib-add-rpath.

Reviewed by: Fangrui Song, Artem Belevich

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

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Linux.cpp
clang/test/Driver/hip-runtime-libs-linux.hip

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index cf7194a855835..52f58f045e8c0 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -4253,13 +4253,15 @@ def rpath : Separate<["-"], "rpath">, 
Flags<[LinkerInput]>, Group;
 def rtlib_EQ : Joined<["-", "--"], "rtlib=">,
   HelpText<"Compiler runtime library to use">;
 def frtlib_add_rpath: Flag<["-"], "frtlib-add-rpath">, 
Flags<[NoArgumentUnused]>,
-  HelpText<"Add -rpath with architecture-specific resource directory to the 
linker flags">;
+  HelpText<"Add -rpath with architecture-specific resource directory to the 
linker flags. "
+  "When --hip-link is specified, also add -rpath with HIP runtime library 
directory to the linker flags">;
 def fno_rtlib_add_rpath: Flag<["-"], "fno-rtlib-add-rpath">, 
Flags<[NoArgumentUnused]>,
-  HelpText<"Do not add -rpath with architecture-specific resource directory to 
the linker flags">;
+  HelpText<"Do not add -rpath with architecture-specific resource directory to 
the linker flags. "
+  "When --hip-link is specified, do not add -rpath with HIP runtime library 
directory to the linker flags">;
 def offload_add_rpath: Flag<["--"], "offload-add-rpath">, 
Flags<[NoArgumentUnused]>,
-  HelpText<"Add -rpath with HIP runtime library directory to the linker 
flags">;
+  Alias;
 def no_offload_add_rpath: Flag<["--"], "no-offload-add-rpath">, 
Flags<[NoArgumentUnused]>,
-  HelpText<"Do not add -rpath with HIP runtime library directory to the linker 
flags">;
+  Alias;
 def r : Flag<["-"], "r">, Flags<[LinkerInput,NoArgumentUnused]>,
 Group;
 def save_temps_EQ : Joined<["-", "--"], "save-temps=">, Flags<[CC1Option, 
FlangOption, NoXarchOption]>,

diff  --git a/clang/lib/Driver/ToolChains/Linux.cpp 
b/clang/lib/Driver/ToolChains/Linux.cpp
index e8890af0ab9ac..4bbb2f8ef6818 100644
--- a/clang/lib/Driver/ToolChains/Linux.cpp
+++ b/clang/lib/Driver/ToolChains/Linux.cpp
@@ -694,8 +694,8 @@ void Linux::AddHIPRuntimeLibArgs(const ArgList &Args,
   CmdArgs.push_back(
   Args.MakeArgString(StringRef("-L") + RocmInstallation->getLibPath()));
 
-  if (Args.hasFlag(options::OPT_offload_add_rpath,
-   options::OPT_no_offload_add_rpath, false))
+  if (Args.hasFlag(options::OPT_frtlib_add_rpath,
+   options::OPT_fno_rtlib_add_rpath, false))
 CmdArgs.append(
 {"-rpath", Args.MakeArgString(RocmInstallation->getLibPath())});
 

diff  --git a/clang/test/Driver/hip-runtime-libs-linux.hip 
b/clang/test/Driver/hip-runtime-libs-linux.hip
index aa71798a80bb4..b0e9f3a460eb0 100644
--- a/clang/test/Driver/hip-runtime-libs-linux.hip
+++ b/clang/test/Driver/hip-runtime-libs-linux.hip
@@ -16,6 +16,10 @@
 // RUN:   --rocm-path=%S/Inputs/rocm %t.o --offload-add-rpath 2>&1 \
 // RUN:   | FileCheck -check-prefixes=ROCM-RPATH %s
 
+// RUN: %clang -### --hip-link --target=x86_64-linux-gnu \
+// RUN:   --rocm-path=%S/Inputs/rocm %t.o -frtlib-add-rpath 2>&1 \
+// RUN:   | FileCheck -check-prefixes=ROCM-RPATH %s
+
 // Test detecting latest /opt/rocm-{release} directory.
 // RUN: rm -rf %t && mkdir -p %t/opt
 // RUN: cp -r %S/Inputs/rocm %t/opt/rocm-3.9.0-1234



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


[PATCH] D145393: [HIP] Make `--offload-add-rpath` alias of `-frtlib-add-rpath`

2023-03-11 Thread Yaxun Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG43c90f905a22: [HIP] Make `--offload-add-rpath` alias of 
`-frtlib-add-rpath` (authored by yaxunl).
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D145393?vs=502672&id=504386#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145393

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Linux.cpp
  clang/test/Driver/hip-runtime-libs-linux.hip


Index: clang/test/Driver/hip-runtime-libs-linux.hip
===
--- clang/test/Driver/hip-runtime-libs-linux.hip
+++ clang/test/Driver/hip-runtime-libs-linux.hip
@@ -16,6 +16,10 @@
 // RUN:   --rocm-path=%S/Inputs/rocm %t.o --offload-add-rpath 2>&1 \
 // RUN:   | FileCheck -check-prefixes=ROCM-RPATH %s
 
+// RUN: %clang -### --hip-link --target=x86_64-linux-gnu \
+// RUN:   --rocm-path=%S/Inputs/rocm %t.o -frtlib-add-rpath 2>&1 \
+// RUN:   | FileCheck -check-prefixes=ROCM-RPATH %s
+
 // Test detecting latest /opt/rocm-{release} directory.
 // RUN: rm -rf %t && mkdir -p %t/opt
 // RUN: cp -r %S/Inputs/rocm %t/opt/rocm-3.9.0-1234
Index: clang/lib/Driver/ToolChains/Linux.cpp
===
--- clang/lib/Driver/ToolChains/Linux.cpp
+++ clang/lib/Driver/ToolChains/Linux.cpp
@@ -694,8 +694,8 @@
   CmdArgs.push_back(
   Args.MakeArgString(StringRef("-L") + RocmInstallation->getLibPath()));
 
-  if (Args.hasFlag(options::OPT_offload_add_rpath,
-   options::OPT_no_offload_add_rpath, false))
+  if (Args.hasFlag(options::OPT_frtlib_add_rpath,
+   options::OPT_fno_rtlib_add_rpath, false))
 CmdArgs.append(
 {"-rpath", Args.MakeArgString(RocmInstallation->getLibPath())});
 
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -4253,13 +4253,15 @@
 def rtlib_EQ : Joined<["-", "--"], "rtlib=">,
   HelpText<"Compiler runtime library to use">;
 def frtlib_add_rpath: Flag<["-"], "frtlib-add-rpath">, 
Flags<[NoArgumentUnused]>,
-  HelpText<"Add -rpath with architecture-specific resource directory to the 
linker flags">;
+  HelpText<"Add -rpath with architecture-specific resource directory to the 
linker flags. "
+  "When --hip-link is specified, also add -rpath with HIP runtime library 
directory to the linker flags">;
 def fno_rtlib_add_rpath: Flag<["-"], "fno-rtlib-add-rpath">, 
Flags<[NoArgumentUnused]>,
-  HelpText<"Do not add -rpath with architecture-specific resource directory to 
the linker flags">;
+  HelpText<"Do not add -rpath with architecture-specific resource directory to 
the linker flags. "
+  "When --hip-link is specified, do not add -rpath with HIP runtime library 
directory to the linker flags">;
 def offload_add_rpath: Flag<["--"], "offload-add-rpath">, 
Flags<[NoArgumentUnused]>,
-  HelpText<"Add -rpath with HIP runtime library directory to the linker 
flags">;
+  Alias;
 def no_offload_add_rpath: Flag<["--"], "no-offload-add-rpath">, 
Flags<[NoArgumentUnused]>,
-  HelpText<"Do not add -rpath with HIP runtime library directory to the linker 
flags">;
+  Alias;
 def r : Flag<["-"], "r">, Flags<[LinkerInput,NoArgumentUnused]>,
 Group;
 def save_temps_EQ : Joined<["-", "--"], "save-temps=">, Flags<[CC1Option, 
FlangOption, NoXarchOption]>,


Index: clang/test/Driver/hip-runtime-libs-linux.hip
===
--- clang/test/Driver/hip-runtime-libs-linux.hip
+++ clang/test/Driver/hip-runtime-libs-linux.hip
@@ -16,6 +16,10 @@
 // RUN:   --rocm-path=%S/Inputs/rocm %t.o --offload-add-rpath 2>&1 \
 // RUN:   | FileCheck -check-prefixes=ROCM-RPATH %s
 
+// RUN: %clang -### --hip-link --target=x86_64-linux-gnu \
+// RUN:   --rocm-path=%S/Inputs/rocm %t.o -frtlib-add-rpath 2>&1 \
+// RUN:   | FileCheck -check-prefixes=ROCM-RPATH %s
+
 // Test detecting latest /opt/rocm-{release} directory.
 // RUN: rm -rf %t && mkdir -p %t/opt
 // RUN: cp -r %S/Inputs/rocm %t/opt/rocm-3.9.0-1234
Index: clang/lib/Driver/ToolChains/Linux.cpp
===
--- clang/lib/Driver/ToolChains/Linux.cpp
+++ clang/lib/Driver/ToolChains/Linux.cpp
@@ -694,8 +694,8 @@
   CmdArgs.push_back(
   Args.MakeArgString(StringRef("-L") + RocmInstallation->getLibPath()));
 
-  if (Args.hasFlag(options::OPT_offload_add_rpath,
-   options::OPT_no_offload_add_rpath, false))
+  if (Args.hasFlag(options::OPT_frtlib_add_rpath,
+   options::OPT_fno_rtlib_add_rpath, false))
 CmdArgs.append(
 {"-rpath", Args.MakeArgString(RocmInstallation->getLibPath())});
 
Index: clang/include/clang/Driver/Options.td

[PATCH] D145803: [clang][DebugInfo] Emit DW_AT_type of preferred name if available

2023-03-11 Thread Michael Buch via Phabricator via cfe-commits
Michael137 added a comment.

In D145803#4186805 , @dblaikie wrote:

> Yeah, can't say this had occurred to me - but totally makes sense/reckon it's 
> OK. Any reason to limit this to lldb? I'd expect it'd probably "Just 
> Work(tm)" on any DWARF consumer?

No particular reason other than being on the safe side and get field experience 
before enabling it for all consumers. But I agree, I don't see why this 
couldn't be enabled always.

> it doesn't hit any recursion issues? (I guess maybe skirts it due to the 
> existing recursion handling in the decl/def structure type stuff - so it 
> creates a declaration for the type, then creates the typedef, which can find 
> that existing declaration, then return the typedef from the create type 
> query?)

Yup that's the intention

> I guess it means that references to the type even for like, the type of the 
> "this" parameter - would refer to the typedef? That's /probably/ OK if a bit 
> surprising to some people/consumers sometimes?

Good point, it does also repoint the `this` pointer to the typedef. LLDB seems 
to handle this fine. Can add some test cases for this (in Clang and LLDB)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145803

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


[PATCH] D143342: [clang-tidy] Support std::format and std::print in readability-redundant-string-cstr

2023-03-11 Thread Mike Crowe via Phabricator via cfe-commits
mikecrowe added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp:189
+  getLangOpts().CPlusPlus2b
+  ? hasAnyName("::std::print", "::std::format")
+  : hasName("::std::format"))),

mikecrowe wrote:
> PiotrZSL wrote:
> > Please introduce configuration option to specify custom functions.
> > For example if some project (like mine) is wrapping fmt::format with some 
> > variadic template function, then such function could be specified.
> > Same goes to things like some loggers.
> > 
> > Check utils/OptionsUtils.h for configuration, and  utils/Matchers.h 
> > (matchesAnyListedName)
> > Please introduce configuration option to specify custom functions.
> > For example if some project (like mine) is wrapping fmt::format with some 
> > variadic template function, then such function could be specified.
> 
> That's exactly where this change originated (as part of [[ 
> https://github.com/mikecrowe/clang-tidy-fmt | my clang-tidy fmt fork ]], 
> which I hope to submit for review soon once I've made it configurable too and 
> improved the test cases.)
> 
> > Same goes to things like some loggers.
> > 
> > Check utils/OptionsUtils.h for configuration, and  utils/Matchers.h 
> > (matchesAnyListedName)
> 
> Thanks for the pointer. I shall study those files for how to support this.
> 
> Do you think that the change can land like in its current state first? Or 
> would you prefer that the configuration option is added at the same time?
> Please introduce configuration option to specify custom functions.
> For example if some project (like mine) is wrapping fmt::format with some 
> variadic template function, then such function could be specified.

I could add some sort of `readability-redundant-string-cstr.PrintFunction` 
option or `readability-redundant-string-cstr.FormatFunction` option, but 
reducing this to its fundamental behaviour would be "a function that takes 
`const char *` arguments that is also willing to take `std::string` arguments". 
I'm struggling to find a sensible name for such an option. Maybe 
`readability-redundant-string-cstr.StdStringAcceptingFunction=::fmt::format`? 
Or just `readability-redundant-string-cstr.FunctionCall=::fmt::format`?

> Same goes to things like some loggers.

Loggers may be classes, so there would need to be an option that specifies a 
class name (or even a base class name) and a method name (which may be an 
operator.) See [[ 
https://github.com/mikecrowe/clang-tidy-fmt/blob/7ace8a3ff41e9679104fe558835b0ef3cb33d969/clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp#L196
 | this hard-coded example ]] (If it's not obvious, there's a description in 
the [[ 
https://github.com/mikecrowe/clang-tidy-fmt/blob/7ace8a3ff41e9679104fe558835b0ef3cb33d969/README.md?plain=1#L103
 | README ]]. In such cases the options could be 
`readability-redundant-string-cstr.Class=::BaseTrace` and 
`readability-redundant-string-cstr.Method=Log` or 
`readability-redundant-string-cstr.Operator=()`, but then it would be hard to 
tie together the right classes and methods. That could be avoided with 
something like 
`readability-redundant-string-cstr.MemberFunctionCall=::BaseTrace::operator(),::NullTrace::operator()`
 and some parsing I suppose.

Regardless, I'll try and get the simple case working and await suggestions for 
appropriate option names.

Thanks again for the suggestions.



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

https://reviews.llvm.org/D143342

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


[PATCH] D145848: [Driver] Correct -f(no-)xray-function-index behavior

2023-03-11 Thread Ian Levesque via Phabricator via cfe-commits
ianlevesque accepted this revision.
ianlevesque added a comment.
This revision is now accepted and ready to land.

Good catch, thanks for the fix.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145848

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


[PATCH] D145852: [Clang][AST] Fix __has_unique_object_representations computation for unnamed bitfields.

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

Handle 0-length unnamed bit fields as well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145852

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/AST/ASTContext.cpp
  clang/test/SemaCXX/type-traits.cpp


Index: clang/test/SemaCXX/type-traits.cpp
===
--- clang/test/SemaCXX/type-traits.cpp
+++ clang/test/SemaCXX/type-traits.cpp
@@ -2878,9 +2878,21 @@
   char d : 2;
 };
 
+struct UnnamedBitfield {
+  int named : 8;
+  int : 24;
+};
+
+struct UnnamedEmptyBitfield {
+  int named;
+  int : 0;
+};
+
 static_assert(!has_unique_object_representations::value, 
"Bitfield padding");
 static_assert(has_unique_object_representations::value, 
"Bitfield padding");
 
static_assert(!has_unique_object_representations::value, 
"Bitfield padding");
+static_assert(!has_unique_object_representations::value, 
"Bitfield padding");
+static_assert(has_unique_object_representations::value, 
"Bitfield padding");
 
 struct BoolBitfield {
   bool b : 8;
Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -2811,6 +2811,12 @@
   Context.toBits(Context.getTypeSizeInChars(Field->getType()));
   if (Field->isBitField()) {
 int64_t BitfieldSize = Field->getBitWidthValue(Context);
+
+// If we have explicit padding bits, return nullopt to indicate no
+// unique representation.
+if (Field->isUnnamedBitfield() && BitfieldSize > 0)
+  return std::nullopt;
+
 if (IsBitIntType) {
   if ((unsigned)BitfieldSize >
   cast(Field->getType())->getNumBits())
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -202,6 +202,9 @@
 - Fix crash when evaluating consteval constructor of derived class whose base
   has more than one field.
   (`#60166 `_)
+- Fix bug in the computation of the ``__has_unique_object_representations``
+  builtin for types with unnamed bitfields.
+  (`#61336 `_)
 
 Bug Fixes to AST Handling
 ^


Index: clang/test/SemaCXX/type-traits.cpp
===
--- clang/test/SemaCXX/type-traits.cpp
+++ clang/test/SemaCXX/type-traits.cpp
@@ -2878,9 +2878,21 @@
   char d : 2;
 };
 
+struct UnnamedBitfield {
+  int named : 8;
+  int : 24;
+};
+
+struct UnnamedEmptyBitfield {
+  int named;
+  int : 0;
+};
+
 static_assert(!has_unique_object_representations::value, "Bitfield padding");
 static_assert(has_unique_object_representations::value, "Bitfield padding");
 static_assert(!has_unique_object_representations::value, "Bitfield padding");
+static_assert(!has_unique_object_representations::value, "Bitfield padding");
+static_assert(has_unique_object_representations::value, "Bitfield padding");
 
 struct BoolBitfield {
   bool b : 8;
Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -2811,6 +2811,12 @@
   Context.toBits(Context.getTypeSizeInChars(Field->getType()));
   if (Field->isBitField()) {
 int64_t BitfieldSize = Field->getBitWidthValue(Context);
+
+// If we have explicit padding bits, return nullopt to indicate no
+// unique representation.
+if (Field->isUnnamedBitfield() && BitfieldSize > 0)
+  return std::nullopt;
+
 if (IsBitIntType) {
   if ((unsigned)BitfieldSize >
   cast(Field->getType())->getNumBits())
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -202,6 +202,9 @@
 - Fix crash when evaluating consteval constructor of derived class whose base
   has more than one field.
   (`#60166 `_)
+- Fix bug in the computation of the ``__has_unique_object_representations``
+  builtin for types with unnamed bitfields.
+  (`#61336 `_)
 
 Bug Fixes to AST Handling
 ^
___
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-11 Thread Roy Jacobson via Phabricator via cfe-commits
royjacobson updated this revision to Diff 504391.
royjacobson added a comment.

Small cleanup


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/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,37 @@
 
   Test2 t2x;  // expected-error {{call to implicitly-deleted default 
constructor of 'Test2'}}
 }
+
+namespace GH48416 {
+
+struct non_trivial_constructor {
+non_trivial_constructor() {}
+};
+
+
+union U1 {
+int a;
+non_trivial_constructor b; // expected-note {{has a non-trivial default 
constructor}}
+};
+
+union U2 {
+int a{};
+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;
+
+} // namespace GH48416
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -9157,7 +9157,15 @@
 // 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) {
+  // Default constructor of a union can also be valid if one of the
+  // members has an explicit initializer.
+  auto* RD = dyn_cast(Field->getParent());
+  assert(RD);
+  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 `_)
 
 Bug Fixes to AST Handling
 ^


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,37 @@
 
   Test2 t2x;  // expected-error {{call to implicitly-deleted default constructor of 'Test2'}}
 }
+
+namespace GH48416 {
+
+struct non_trivial_constructor {
+non_trivial_constructor() {}
+};
+
+
+union U1 {
+int a;
+non_trivial_constructor b; // expected-note {{has a non-trivial default constructor}}
+};
+
+union U2 {
+int a{};
+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;
+
+} // namespace GH48416
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -9157,7 +9157,15 @@
 // 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) {
+  // Default constructor of a union can also be valid if one of the
+  // members has an explicit initializer.
+  auto* RD = dyn_cast(Field->getParent());
+  assert(RD);
+  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 `_)
 
 Bug Fixes to AST Handling
 ^
__

[PATCH] D143617: [Clang][CMake] Support perf, LBR, and Instrument CLANG_BOLT options

2023-03-11 Thread Amir Ayupov via Phabricator via cfe-commits
Amir updated this revision to Diff 504392.
Amir added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143617

Files:
  clang/CMakeLists.txt
  clang/cmake/caches/BOLT.cmake
  clang/utils/perf-training/CMakeLists.txt
  clang/utils/perf-training/bolt.lit.cfg
  clang/utils/perf-training/bolt.lit.site.cfg.in
  clang/utils/perf-training/perf-helper.py

Index: clang/utils/perf-training/perf-helper.py
===
--- clang/utils/perf-training/perf-helper.py
+++ clang/utils/perf-training/perf-helper.py
@@ -56,6 +56,57 @@
   subprocess.check_call(cmd)
   return 0
 
+def perf(args):
+  parser = argparse.ArgumentParser(prog='perf-helper perf',
+description='perf wrapper for BOLT profile collection')
+  parser.add_argument('--lbr', required=False, action='store_true',
+help='Use perf with branch stacks')
+  parser.add_argument('cmd', nargs='*', help='')
+
+  # Use python's arg parser to handle all leading option arguments, but pass
+  # everything else through to perf
+  first_cmd = next(arg for arg in args if not arg.startswith("--"))
+  last_arg_idx = args.index(first_cmd)
+
+  opts = parser.parse_args(args[:last_arg_idx])
+  #cmd = shlex.split(args[last_arg_idx:])
+  cmd = args[last_arg_idx:]
+
+  perf_args = []
+  perf_args.extend((
+'perf', 'record', '--event=cycles:u', '--freq=max',
+'--output=%d.perf.data' % os.getpid()))
+  if opts.lbr:
+perf_args += ['--branch-filter=any,u']
+  perf_args.extend(cmd)
+
+  start_time = time.time()
+  subprocess.check_call(perf_args)
+
+  elapsed = time.time() - start_time
+  print("... data collection took %.4fs" % elapsed)
+  return 0
+
+def perf2bolt(args):
+  parser = argparse.ArgumentParser(prog='perf-helper perf2bolt',
+description='perf2bolt conversion wrapper for perf.data files')
+  parser.add_argument('p2b_path', help='Path to llvm-bolt')
+  parser.add_argument('path', help='Path containing perf.data files')
+  parser.add_argument('binary', help='Input binary')
+  parser.add_argument('--nolbr', required=False, action='store_true',
+help='Use -nl perf2bolt mode')
+  opts = parser.parse_args(args)
+
+  p2b_args = []
+  p2b_args.extend((opts.p2b_path, opts.binary, '--aggregate-only',
+'--profile-format=yaml'))
+  if opts.nolbr:
+p2b_args += ['-nl']
+  p2b_args += ['-p']
+  for filename in findFilesWithExtension(opts.path, 'perf.data'):
+subprocess.check_call(p2b_args + [filename, '-o', filename+'.fdata'])
+  return 0
+
 def dtrace(args):
   parser = argparse.ArgumentParser(prog='perf-helper dtrace',
 description='dtrace wrapper for order file generation')
@@ -410,6 +461,8 @@
   'cc1' : cc1,
   'gen-order-file' : genOrderFile,
   'merge-fdata' : merge_fdata,
+  'perf' : perf,
+  'perf2bolt' : perf2bolt,
   }
 
 def main():
Index: clang/utils/perf-training/bolt.lit.site.cfg.in
===
--- clang/utils/perf-training/bolt.lit.site.cfg.in
+++ clang/utils/perf-training/bolt.lit.site.cfg.in
@@ -9,6 +9,7 @@
 config.target_triple = "@LLVM_TARGET_TRIPLE@"
 config.python_exe = "@Python3_EXECUTABLE@"
 config.clang_obj_root = path(r"@CLANG_BINARY_DIR@")
+config.clang_bolt_mode = "@CLANG_BOLT@"
 
 # Let the main config do the real work.
 lit_config.load_config(config, "@CLANG_SOURCE_DIR@/utils/perf-training/bolt.lit.cfg")
Index: clang/utils/perf-training/bolt.lit.cfg
===
--- clang/utils/perf-training/bolt.lit.cfg
+++ clang/utils/perf-training/bolt.lit.cfg
@@ -6,15 +6,25 @@
 import os
 import subprocess
 
-config.clang = os.path.realpath(lit.util.which('clang-bolt.inst', config.clang_tools_dir)).replace('\\', '/')
+clang_binary = 'clang'
+perf_wrapper = ''
+if config.clang_bolt_mode.lower() == "instrument":
+  clang_binary = 'clang-bolt.inst'
+else: # perf or LBR
+  perf_wrapper = '%s %s/perf-helper.py perf' % (config.python_exe, config.perf_helper_dir)
+  if config.clang_bolt_mode.lower() == "lbr":
+perf_wrapper += " --lbr"
+  perf_wrapper += " -- "
+
+config.clang = os.path.realpath(lit.util.which(clang_binary, config.clang_tools_dir)).replace('\\', '/')
 
 config.name = 'Clang Perf Training'
 config.suffixes = ['.c', '.cc', '.cpp', '.m', '.mm', '.cu', '.ll', '.cl', '.s', '.S', '.modulemap', '.test']
 
 use_lit_shell = os.environ.get("LIT_USE_INTERNAL_SHELL")
 config.test_format = lit.formats.ShTest(use_lit_shell == "0")
-config.substitutions.append( ('%clang_cpp_skip_driver', ' %s --driver-mode=g++ ' % (config.clang)))
-config.substitutions.append( ('%clang_cpp', ' %s --driver-mode=g++ ' % (config.clang)))
-config.substitutions.append( ('%clang_skip_driver', ' %s ' % (config.clang)))
-config.substitutions.append( ('%clang', ' %s ' % (config.clang) ) )
+config.substitutions.append( ('%clang_cpp_skip_driver', ' %s %s --driver-mode=g++ ' % (perf_wrapper, config.

[PATCH] D145803: [clang][DebugInfo] Emit DW_AT_type of preferred name if available

2023-03-11 Thread Michael Buch via Phabricator via cfe-commits
Michael137 added a comment.

Apparently some Objective-C/gmodules LLDB tests aren't happy with this change
Investigating...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145803

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


[PATCH] D83906: [CodeGen] Emit a call instruction instead of an invoke if the called llvm function is marked nounwind

2023-03-11 Thread Hongtao Yu via Phabricator via cfe-commits
hoy added a comment.

In D83906#4184916 , @dexonsmith wrote:

> In D83906#4183453 , @hoy wrote:
>
>> Wondering if we can come up with a way to tell the optimizer about that, 
>> e.g., through a new module flag. When it comes to LTO, the selection of 
>> linkonce_odr symbols should already been done and the optimizer may be able 
>> to recompute the attributes based on pre-LTO attributes, or at least we can 
>> allow IPO to one module only, which should still do a better job than FE 
>> does?
>
> I don't think there's much point in passing anything to LTO. There are very 
> few `linkonce_odr` symbols in LTO, since LTO has the advantage of an export 
> list from the link. Symbols not on the export list are internalized (they're 
> given local linkage).

That sounds to me an opportunity to get a broader IPO done precisely in the 
prelink optimizer, as long as we find a way to tell it the incoming IR has 
source fidelity. What do you think about idea of introducing a module flag? 
Maybe it's worth discussing in the forum as a followup of introducing a cc1 
flag for a stable IR gen.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83906

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


[PATCH] D143342: [clang-tidy] Support std::format and std::print in readability-redundant-string-cstr

2023-03-11 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp:189
+  getLangOpts().CPlusPlus2b
+  ? hasAnyName("::std::print", "::std::format")
+  : hasName("::std::format"))),

mikecrowe wrote:
> mikecrowe wrote:
> > PiotrZSL wrote:
> > > Please introduce configuration option to specify custom functions.
> > > For example if some project (like mine) is wrapping fmt::format with some 
> > > variadic template function, then such function could be specified.
> > > Same goes to things like some loggers.
> > > 
> > > Check utils/OptionsUtils.h for configuration, and  utils/Matchers.h 
> > > (matchesAnyListedName)
> > > Please introduce configuration option to specify custom functions.
> > > For example if some project (like mine) is wrapping fmt::format with some 
> > > variadic template function, then such function could be specified.
> > 
> > That's exactly where this change originated (as part of [[ 
> > https://github.com/mikecrowe/clang-tidy-fmt | my clang-tidy fmt fork ]], 
> > which I hope to submit for review soon once I've made it configurable too 
> > and improved the test cases.)
> > 
> > > Same goes to things like some loggers.
> > > 
> > > Check utils/OptionsUtils.h for configuration, and  utils/Matchers.h 
> > > (matchesAnyListedName)
> > 
> > Thanks for the pointer. I shall study those files for how to support this.
> > 
> > Do you think that the change can land like in its current state first? Or 
> > would you prefer that the configuration option is added at the same time?
> > Please introduce configuration option to specify custom functions.
> > For example if some project (like mine) is wrapping fmt::format with some 
> > variadic template function, then such function could be specified.
> 
> I could add some sort of `readability-redundant-string-cstr.PrintFunction` 
> option or `readability-redundant-string-cstr.FormatFunction` option, but 
> reducing this to its fundamental behaviour would be "a function that takes 
> `const char *` arguments that is also willing to take `std::string` 
> arguments". I'm struggling to find a sensible name for such an option. Maybe 
> `readability-redundant-string-cstr.StdStringAcceptingFunction=::fmt::format`? 
> Or just `readability-redundant-string-cstr.FunctionCall=::fmt::format`?
> 
> > Same goes to things like some loggers.
> 
> Loggers may be classes, so there would need to be an option that specifies a 
> class name (or even a base class name) and a method name (which may be an 
> operator.) See [[ 
> https://github.com/mikecrowe/clang-tidy-fmt/blob/7ace8a3ff41e9679104fe558835b0ef3cb33d969/clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp#L196
>  | this hard-coded example ]] (If it's not obvious, there's a description in 
> the [[ 
> https://github.com/mikecrowe/clang-tidy-fmt/blob/7ace8a3ff41e9679104fe558835b0ef3cb33d969/README.md?plain=1#L103
>  | README ]]. In such cases the options could be 
> `readability-redundant-string-cstr.Class=::BaseTrace` and 
> `readability-redundant-string-cstr.Method=Log` or 
> `readability-redundant-string-cstr.Operator=()`, but then it would be hard to 
> tie together the right classes and methods. That could be avoided with 
> something like 
> `readability-redundant-string-cstr.MemberFunctionCall=::BaseTrace::operator(),::NullTrace::operator()`
>  and some parsing I suppose.
> 
> Regardless, I'll try and get the simple case working and await suggestions 
> for appropriate option names.
> 
> Thanks again for the suggestions.
> 
I asked AI, and it suggested 
readability-redundant-string-cstr.FormattingFunctionsList.
Also, I thing that matchesAnyListedName should support things like 
'::NullTrace::operator()', so one option should be sufficient.

FormattingFunctionsList:
A semicolon-separated list of (fully qualified) function/method/operator names, 
with the requirement that 
any parameter capable of accepting a 'const char*' input should also be able to 
accept 'std::string' or 
'std::string_view' inputs, or proper overload candidates that can do so should 
exist.


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

https://reviews.llvm.org/D143342

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


[PATCH] D53891: [LTO] Add option to enable LTOUnit splitting, and disable unless needed

2023-03-11 Thread Nikita Popov via Phabricator via cfe-commits
nikic added a comment.
Herald added a project: All.

In D53891#2116541 , @hans wrote:

> Would be possible to add some documentation for this flag? From a quick 
> search it's not clear to me what it does and when one is supposed to use it.

Ping on adding documentation.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D53891

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


[PATCH] D53891: [LTO] Add option to enable LTOUnit splitting, and disable unless needed

2023-03-11 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson added a comment.

In D53891#4186892 , @nikic wrote:

> In D53891#2116541 , @hans wrote:
>
>> Would be possible to add some documentation for this flag? From a quick 
>> search it's not clear to me what it does and when one is supposed to use it.
>
> Ping on adding documentation.

Thanks for the reminder, will do


Repository:
  rL LLVM

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

https://reviews.llvm.org/D53891

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


[PATCH] D145856: [clang-tidy] Let misc-const-correctness detect auto local variables that can be made const

2023-03-11 Thread Chris Thrasher via Phabricator via cfe-commits
ChrisThrasher created this revision.
ChrisThrasher added a reviewer: JonasToth.
Herald added subscribers: PiotrZSL, carlosgalvezp, xazax.hun.
Herald added a reviewer: njames93.
Herald added a project: All.
ChrisThrasher requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D145856

Files:
  clang-tools-extra/clang-tidy/misc/ConstCorrectnessCheck.cpp


Index: clang-tools-extra/clang-tidy/misc/ConstCorrectnessCheck.cpp
===
--- clang-tools-extra/clang-tidy/misc/ConstCorrectnessCheck.cpp
+++ clang-tools-extra/clang-tidy/misc/ConstCorrectnessCheck.cpp
@@ -73,9 +73,9 @@
   
hasType(referenceType(pointee(hasCanonicalType(templateTypeParmType(),
   hasType(referenceType(pointee(substTemplateTypeParmType();
 
-  const auto AutoTemplateType = varDecl(
-  anyOf(hasType(autoType()), hasType(referenceType(pointee(autoType(,
-hasType(pointerType(pointee(autoType());
+  const auto AutoTemplateType =
+  varDecl(anyOf(hasType(referenceType(pointee(autoType(,
+hasType(pointerType(pointee(autoType());
 
   const auto FunctionPointerRef =
   hasType(hasCanonicalType(referenceType(pointee(functionType();


Index: clang-tools-extra/clang-tidy/misc/ConstCorrectnessCheck.cpp
===
--- clang-tools-extra/clang-tidy/misc/ConstCorrectnessCheck.cpp
+++ clang-tools-extra/clang-tidy/misc/ConstCorrectnessCheck.cpp
@@ -73,9 +73,9 @@
   hasType(referenceType(pointee(hasCanonicalType(templateTypeParmType(),
   hasType(referenceType(pointee(substTemplateTypeParmType();
 
-  const auto AutoTemplateType = varDecl(
-  anyOf(hasType(autoType()), hasType(referenceType(pointee(autoType(,
-hasType(pointerType(pointee(autoType());
+  const auto AutoTemplateType =
+  varDecl(anyOf(hasType(referenceType(pointee(autoType(,
+hasType(pointerType(pointee(autoType());
 
   const auto FunctionPointerRef =
   hasType(hasCanonicalType(referenceType(pointee(functionType();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D145857: [X86] Make triple ArchName override OS for i686 and i786

2023-03-11 Thread Phoebe Wang via Phabricator via cfe-commits
pengfei created this revision.
Herald added a project: All.
pengfei requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay.
Herald added a project: clang.

Fixes #61347


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D145857

Files:
  clang/lib/Driver/ToolChains/Arch/X86.cpp


Index: clang/lib/Driver/ToolChains/Arch/X86.cpp
===
--- clang/lib/Driver/ToolChains/Arch/X86.cpp
+++ clang/lib/Driver/ToolChains/Arch/X86.cpp
@@ -102,6 +102,12 @@
   if (Is64Bit)
 return "x86-64";
 
+  if (Triple.getArchName() == "i686")
+return "i686";
+
+  if (Triple.getArchName() == "i786")
+return "pentiumpro"
+
   switch (Triple.getOS()) {
   case llvm::Triple::NetBSD:
 return "i486";


Index: clang/lib/Driver/ToolChains/Arch/X86.cpp
===
--- clang/lib/Driver/ToolChains/Arch/X86.cpp
+++ clang/lib/Driver/ToolChains/Arch/X86.cpp
@@ -102,6 +102,12 @@
   if (Is64Bit)
 return "x86-64";
 
+  if (Triple.getArchName() == "i686")
+return "i686";
+
+  if (Triple.getArchName() == "i786")
+return "pentiumpro"
+
   switch (Triple.getOS()) {
   case llvm::Triple::NetBSD:
 return "i486";
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D145857: [X86] Make triple ArchName override OS for i686 and i786

2023-03-11 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

Did you test this? I kind of expected the triple would be normalized before 
this. I’m not at a computer to check.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145857

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


[PATCH] D145857: [X86] Make triple ArchName override OS for i686 and i786

2023-03-11 Thread Phoebe Wang via Phabricator via cfe-commits
pengfei planned changes to this revision.
pengfei added a comment.

In D145857#4186957 , @craig.topper 
wrote:

> Did you test this? I kind of expected the triple would be normalized before 
> this. I’m not at a computer to check.

No, I just tried with gdb which proves the idea here. Will add test cases.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145857

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


[PATCH] D145857: [X86] Make triple ArchName override OS for i686 and i786

2023-03-11 Thread Phoebe Wang via Phabricator via cfe-commits
pengfei updated this revision to Diff 504400.
pengfei added a comment.

Fix typo & add tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145857

Files:
  clang/lib/Driver/ToolChains/Arch/X86.cpp
  clang/test/Driver/cl-x86-flags.c


Index: clang/test/Driver/cl-x86-flags.c
===
--- clang/test/Driver/cl-x86-flags.c
+++ clang/test/Driver/cl-x86-flags.c
@@ -133,5 +133,11 @@
 // tune: "-target-cpu" "sandybridge"
 // tune-SAME: "-tune-cpu" "haswell"
 
+// RUN: %clang_cl --target=i686-unknown-unknown -### -- 2>&1 %s | FileCheck 
-check-prefix=i686 %s
+// i686: "-target-cpu" "i686"
+
+// RUN: %clang_cl --target=i786-unknown-unknown -### -- 2>&1 %s | FileCheck 
-check-prefix=i786 %s
+// i786: "-target-cpu" "pentiumpro"
+
 void f(void) {
 }
Index: clang/lib/Driver/ToolChains/Arch/X86.cpp
===
--- clang/lib/Driver/ToolChains/Arch/X86.cpp
+++ clang/lib/Driver/ToolChains/Arch/X86.cpp
@@ -102,6 +102,12 @@
   if (Is64Bit)
 return "x86-64";
 
+  if (Triple.getArchName() == "i686")
+return "i686";
+
+  if (Triple.getArchName() == "i786")
+return "pentiumpro";
+
   switch (Triple.getOS()) {
   case llvm::Triple::NetBSD:
 return "i486";


Index: clang/test/Driver/cl-x86-flags.c
===
--- clang/test/Driver/cl-x86-flags.c
+++ clang/test/Driver/cl-x86-flags.c
@@ -133,5 +133,11 @@
 // tune: "-target-cpu" "sandybridge"
 // tune-SAME: "-tune-cpu" "haswell"
 
+// RUN: %clang_cl --target=i686-unknown-unknown -### -- 2>&1 %s | FileCheck -check-prefix=i686 %s
+// i686: "-target-cpu" "i686"
+
+// RUN: %clang_cl --target=i786-unknown-unknown -### -- 2>&1 %s | FileCheck -check-prefix=i786 %s
+// i786: "-target-cpu" "pentiumpro"
+
 void f(void) {
 }
Index: clang/lib/Driver/ToolChains/Arch/X86.cpp
===
--- clang/lib/Driver/ToolChains/Arch/X86.cpp
+++ clang/lib/Driver/ToolChains/Arch/X86.cpp
@@ -102,6 +102,12 @@
   if (Is64Bit)
 return "x86-64";
 
+  if (Triple.getArchName() == "i686")
+return "i686";
+
+  if (Triple.getArchName() == "i786")
+return "pentiumpro";
+
   switch (Triple.getOS()) {
   case llvm::Triple::NetBSD:
 return "i486";
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D145857: [X86] Make triple ArchName override OS for i686 and i786

2023-03-11 Thread Phoebe Wang via Phabricator via cfe-commits
pengfei updated this revision to Diff 504401.
pengfei added a comment.

Fix lit failure.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145857

Files:
  clang/lib/Driver/ToolChains/Arch/X86.cpp
  clang/test/Driver/cl-x86-flags.c
  clang/test/Driver/nacl-direct.c


Index: clang/test/Driver/nacl-direct.c
===
--- clang/test/Driver/nacl-direct.c
+++ clang/test/Driver/nacl-direct.c
@@ -6,7 +6,7 @@
 // RUN:   | FileCheck --check-prefix=CHECK-I686 %s
 // CHECK-I686: "-cc1"
 // CHECK-I686-NOT: "-fno-use-init-array"
-// CHECK-I686: "-target-cpu" "pentium4"
+// CHECK-I686: "-target-cpu" "i686"
 // CHECK-I686: "-resource-dir" "foo"
 // CHECK-I686: "-internal-isystem" "foo{{/|}}include"
 // CHECK-I686: "-internal-isystem" 
"{{.*}}{{/|}}..{{/|}}i686-nacl{{/|}}usr{{/|}}include"
Index: clang/test/Driver/cl-x86-flags.c
===
--- clang/test/Driver/cl-x86-flags.c
+++ clang/test/Driver/cl-x86-flags.c
@@ -133,5 +133,11 @@
 // tune: "-target-cpu" "sandybridge"
 // tune-SAME: "-tune-cpu" "haswell"
 
+// RUN: %clang_cl --target=i686-unknown-unknown -### -- 2>&1 %s | FileCheck 
-check-prefix=i686 %s
+// i686: "-target-cpu" "i686"
+
+// RUN: %clang_cl --target=i786-unknown-unknown -### -- 2>&1 %s | FileCheck 
-check-prefix=i786 %s
+// i786: "-target-cpu" "pentiumpro"
+
 void f(void) {
 }
Index: clang/lib/Driver/ToolChains/Arch/X86.cpp
===
--- clang/lib/Driver/ToolChains/Arch/X86.cpp
+++ clang/lib/Driver/ToolChains/Arch/X86.cpp
@@ -102,6 +102,12 @@
   if (Is64Bit)
 return "x86-64";
 
+  if (Triple.getArchName() == "i686")
+return "i686";
+
+  if (Triple.getArchName() == "i786")
+return "pentiumpro";
+
   switch (Triple.getOS()) {
   case llvm::Triple::NetBSD:
 return "i486";


Index: clang/test/Driver/nacl-direct.c
===
--- clang/test/Driver/nacl-direct.c
+++ clang/test/Driver/nacl-direct.c
@@ -6,7 +6,7 @@
 // RUN:   | FileCheck --check-prefix=CHECK-I686 %s
 // CHECK-I686: "-cc1"
 // CHECK-I686-NOT: "-fno-use-init-array"
-// CHECK-I686: "-target-cpu" "pentium4"
+// CHECK-I686: "-target-cpu" "i686"
 // CHECK-I686: "-resource-dir" "foo"
 // CHECK-I686: "-internal-isystem" "foo{{/|}}include"
 // CHECK-I686: "-internal-isystem" "{{.*}}{{/|}}..{{/|}}i686-nacl{{/|}}usr{{/|}}include"
Index: clang/test/Driver/cl-x86-flags.c
===
--- clang/test/Driver/cl-x86-flags.c
+++ clang/test/Driver/cl-x86-flags.c
@@ -133,5 +133,11 @@
 // tune: "-target-cpu" "sandybridge"
 // tune-SAME: "-tune-cpu" "haswell"
 
+// RUN: %clang_cl --target=i686-unknown-unknown -### -- 2>&1 %s | FileCheck -check-prefix=i686 %s
+// i686: "-target-cpu" "i686"
+
+// RUN: %clang_cl --target=i786-unknown-unknown -### -- 2>&1 %s | FileCheck -check-prefix=i786 %s
+// i786: "-target-cpu" "pentiumpro"
+
 void f(void) {
 }
Index: clang/lib/Driver/ToolChains/Arch/X86.cpp
===
--- clang/lib/Driver/ToolChains/Arch/X86.cpp
+++ clang/lib/Driver/ToolChains/Arch/X86.cpp
@@ -102,6 +102,12 @@
   if (Is64Bit)
 return "x86-64";
 
+  if (Triple.getArchName() == "i686")
+return "i686";
+
+  if (Triple.getArchName() == "i786")
+return "pentiumpro";
+
   switch (Triple.getOS()) {
   case llvm::Triple::NetBSD:
 return "i486";
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D140996: [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.

2023-03-11 Thread Andrey Ali Khan Bolshakov via Phabricator via cfe-commits
bolshakov-a updated this revision to Diff 504402.
bolshakov-a added a comment.

Rebase and replace "Clang 16" with "Clang 17" in `cxx_status.html` (Clang 16 RC 
has already been branched off, AFAIK).


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

https://reviews.llvm.org/D140996

Files:
  clang-tools-extra/clangd/DumpAST.cpp
  clang-tools-extra/clangd/FindTarget.cpp
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/ODRHash.h
  clang/include/clang/AST/PropertiesBase.td
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/AST/TemplateArgumentVisitor.h
  clang/include/clang/AST/TemplateBase.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/ASTStructuralEquivalence.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/AST/ODRHash.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/AST/TemplateBase.cpp
  clang/lib/AST/TypeLoc.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/Index/USRGeneration.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Sema/SemaTemplateVariadic.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp
  clang/test/CodeGenCXX/mangle-ms-templates.cpp
  clang/test/CodeGenCXX/mangle-template.cpp
  clang/test/CodeGenCXX/template-arguments.cpp
  clang/test/Modules/odr_hash.cpp
  clang/test/SemaCXX/warn-bool-conversion.cpp
  clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
  clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
  clang/tools/libclang/CIndex.cpp
  clang/tools/libclang/CXCursor.cpp
  clang/www/cxx_status.html
  lldb/include/lldb/lldb-enumerations.h
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp

Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -7311,6 +7311,9 @@
 
   case clang::TemplateArgument::Pack:
 return eTemplateArgumentKindPack;
+
+  case clang::TemplateArgument::UncommonValue:
+return eTemplateArgumentKindUncommonValue;
   }
   llvm_unreachable("Unhandled clang::TemplateArgument::ArgKind");
 }
Index: lldb/include/lldb/lldb-enumerations.h
===
--- lldb/include/lldb/lldb-enumerations.h
+++ lldb/include/lldb/lldb-enumerations.h
@@ -834,6 +834,7 @@
   eTemplateArgumentKindExpression,
   eTemplateArgumentKindPack,
   eTemplateArgumentKindNullPtr,
+  eTemplateArgumentKindUncommonValue,
 };
 
 /// Type of match to be performed when looking for a formatter for a data type.
Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1053,13 +1053,21 @@
 
 
 
-  Class types as non-type template parameters
+  Class types as non-type template parameters
   https://wg21.link/p0732r2";>P0732R2
-  Partial
+  Clang 12
+
+ 
+  Generalized non-type template parameters of scalar type
+  https://wg21.link/p1907r1";>P1907R1
+  
+
+  Clang 17 (Partial)
+  Reference type template arguments referring to instantiation-dependent objects and subobjects
+  (i.e. delcared inside a template but neither type- nor value-dependent) aren't fully supported.
+
+  
 
-   
-https://wg21.link/p1907r1";>P1907R1
-  
 
   Destroying operator delete
   https://wg21.link/p0722r3";>P0722R3
Index: clang/tools/libclang/CXCursor.cpp
===
--- clang/tools/libclang/CXCursor.cpp
+++ clang/tools/libclang/CXCursor.cpp
@@ -1463,6 +1463,9 @@
 return CXTemplateArgumentKind_NullPtr;
   case TemplateArgument::Integral:
 return CXTemplateArgumentKind_Integral;
+  case TemplateArgument::UncommonValue:
+// FIXME: Expose these values.
+return CXTemplateArgumentKind_Invalid;
   case TemplateArgument::Template:
 return CXTemplateArgumentKind_Template;
   case TemplateArgument::TemplateExpansion:
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -1570,6 +1570,11 @@
   return Visit(MakeCXCursor(E, StmtParent, TU, RegionOfInterest));
 return false;
 
+  case TemplateArgument::UncommonValue:
+if (Expr *E = TAL.getSourceUncommonValueExpression())
+  return Visit(MakeCXCursor(E, StmtParent, TU, RegionOfInterest));
+return

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

2023-03-11 Thread Alexander Shaposhnikov via Phabricator via cfe-commits
alexander-shaposhnikov created this revision.
alexander-shaposhnikov added reviewers: rsmith, aaron.ballman.
alexander-shaposhnikov created this object with visibility "All Users".
Herald added a project: All.
alexander-shaposhnikov requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This diff fixes linkage 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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D145859

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


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,12 @@
 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);
   if (supportsCOMDAT())
 GV->setComdat(TheModule.getOrInsertComdat(GV->getName()));
   Emitter.finalize(GV);


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,12 @@
 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);
   if (supportsCOMDAT())
 GV->setComdat(TheModule.getOrInsertComdat(GV->getName()));
   Emitter.finalize(GV);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D144943: [clang][Interp] Implement bitcasts (WIP)

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

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144943

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


[PATCH] D145841: [clang][Interp] Fix diagnostics for calling non-constexpr constructors

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

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

https://reviews.llvm.org/D145841

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


Index: clang/test/AST/Interp/records.cpp
===
--- clang/test/AST/Interp/records.cpp
+++ clang/test/AST/Interp/records.cpp
@@ -308,7 +308,7 @@
 };
 
 namespace DeriveFailures {
-  struct Base { // ref-note 2{{declared here}}
+  struct Base { // ref-note 2{{declared here}} expected-note {{declared here}}
 int Val;
   };
 
@@ -316,13 +316,15 @@
 int OtherVal;
 
 constexpr Derived(int i) : OtherVal(i) {} // ref-error {{never produces a 
constant expression}} \
-  // ref-note 2{{non-constexpr 
constructor 'Base' cannot be used in a constant expression}}
+  // ref-note 2{{non-constexpr 
constructor 'Base' cannot be used in a constant expression}} \
+  // expected-note {{non-constexpr 
constructor 'Base' cannot be used in a constant expression}}
   };
 
   constexpr Derived D(12); // ref-error {{must be initialized by a constant 
expression}} \
// ref-note {{in call to 'Derived(12)'}} \
// ref-note {{declared here}} \
-   // expected-error {{must be initialized by a 
constant expression}}
+   // expected-error {{must be initialized by a 
constant expression}} \
+   // expected-note {{in call to 'Derived(12)'}}
   static_assert(D.Val == 0, ""); // ref-error {{not an integral constant 
expression}} \
  // ref-note {{initializer of 'D' is not a 
constant expression}} \
  // expected-error {{not an integral constant 
expression}} \
@@ -348,7 +350,7 @@
   };
 
   struct YetAnotherDerived : YetAnotherBase {
-using YetAnotherBase::YetAnotherBase; //ref-note {{declared here}}
+using YetAnotherBase::YetAnotherBase; //ref-note {{declared here}} 
expected-note {{declared here}}
 int OtherVal;
 
 constexpr bool doit() const { return Val == OtherVal; }
@@ -356,8 +358,8 @@
 
   constexpr YetAnotherDerived Oops(0); // ref-error {{must be initialized by a 
constant expression}} \
// ref-note {{constructor inherited 
from base class 'YetAnotherBase' cannot be used in a constant expression}} \
-   // expected-error {{must be initialized 
by a constant expression}}
-   // FIXME: Missing reason for rejection.
+   // expected-error {{must be initialized 
by a constant expression}} \
+   // expected-note {{constructor 
inherited from base class 'YetAnotherBase' cannot be used in a constant 
expression}}
 };
 
 namespace EmptyCtor {
Index: clang/test/AST/Interp/cxx20.cpp
===
--- clang/test/AST/Interp/cxx20.cpp
+++ clang/test/AST/Interp/cxx20.cpp
@@ -207,13 +207,15 @@
   // ref-note {{declared const here}}
 int a;
   public:
-constexpr Foo() {
+constexpr Foo() { // expected-note {{declared here}}
   this->a = 10;
   T = 13; // expected-error {{cannot assign to non-static data member 'T' 
with const-qualified type}} \
   // ref-error {{cannot assign to non-static data member 'T' with 
const-qualified type}}
 }
   };
   constexpr Foo F; // expected-error {{must be initialized by a constant 
expression}} \
+   // FIXME: The following note is wrong. \
+   // expected-note {{undefined constructor 'Foo' cannot be 
used in a constant expression}} \
// ref-error {{must be initialized by a constant 
expression}}
 
 
Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp
===
--- clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -1376,7 +1376,7 @@
   if (const auto CtorExpr = dyn_cast(Initializer)) {
 const Function *Func = getFunction(CtorExpr->getConstructor());
 
-if (!Func || !Func->isConstexpr())
+if (!Func)
   return false;
 
 // The This pointer is already on the stack because this is an initializer,


Index: clang/test/AST/Interp/records.cpp
===
--- clang/test/AST/Interp/records.cpp
+++ clang/test/AST/Interp/records.cpp
@@ -308,7 +308,7 @@
 };
 
 namespace DeriveFailures {
-  struct Base { // ref-note 2{{declared here}}
+  struct Base { // ref-note 2{{declared here}} expected-note {{declared here}}
 int Val;
   };
 
@@ -316,13 +316,15 @@

[PATCH] D140996: [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.

2023-03-11 Thread Andrey Ali Khan Bolshakov via Phabricator via cfe-commits
bolshakov-a updated this revision to Diff 504407.
bolshakov-a added a comment.

Fix formatting.


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

https://reviews.llvm.org/D140996

Files:
  clang-tools-extra/clangd/DumpAST.cpp
  clang-tools-extra/clangd/FindTarget.cpp
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/ODRHash.h
  clang/include/clang/AST/PropertiesBase.td
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/AST/TemplateArgumentVisitor.h
  clang/include/clang/AST/TemplateBase.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/ASTStructuralEquivalence.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/AST/ODRHash.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/AST/TemplateBase.cpp
  clang/lib/AST/TypeLoc.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/Index/USRGeneration.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Sema/SemaTemplateVariadic.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp
  clang/test/CodeGenCXX/mangle-ms-templates.cpp
  clang/test/CodeGenCXX/mangle-template.cpp
  clang/test/CodeGenCXX/template-arguments.cpp
  clang/test/Modules/odr_hash.cpp
  clang/test/SemaCXX/warn-bool-conversion.cpp
  clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
  clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
  clang/tools/libclang/CIndex.cpp
  clang/tools/libclang/CXCursor.cpp
  clang/www/cxx_status.html
  lldb/include/lldb/lldb-enumerations.h
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp

Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -7311,6 +7311,9 @@
 
   case clang::TemplateArgument::Pack:
 return eTemplateArgumentKindPack;
+
+  case clang::TemplateArgument::UncommonValue:
+return eTemplateArgumentKindUncommonValue;
   }
   llvm_unreachable("Unhandled clang::TemplateArgument::ArgKind");
 }
Index: lldb/include/lldb/lldb-enumerations.h
===
--- lldb/include/lldb/lldb-enumerations.h
+++ lldb/include/lldb/lldb-enumerations.h
@@ -834,6 +834,7 @@
   eTemplateArgumentKindExpression,
   eTemplateArgumentKindPack,
   eTemplateArgumentKindNullPtr,
+  eTemplateArgumentKindUncommonValue,
 };
 
 /// Type of match to be performed when looking for a formatter for a data type.
Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1053,13 +1053,21 @@
 
 
 
-  Class types as non-type template parameters
+  Class types as non-type template parameters
   https://wg21.link/p0732r2";>P0732R2
-  Partial
+  Clang 12
+
+ 
+  Generalized non-type template parameters of scalar type
+  https://wg21.link/p1907r1";>P1907R1
+  
+
+  Clang 17 (Partial)
+  Reference type template arguments referring to instantiation-dependent objects and subobjects
+  (i.e. delcared inside a template but neither type- nor value-dependent) aren't fully supported.
+
+  
 
-   
-https://wg21.link/p1907r1";>P1907R1
-  
 
   Destroying operator delete
   https://wg21.link/p0722r3";>P0722R3
Index: clang/tools/libclang/CXCursor.cpp
===
--- clang/tools/libclang/CXCursor.cpp
+++ clang/tools/libclang/CXCursor.cpp
@@ -1463,6 +1463,9 @@
 return CXTemplateArgumentKind_NullPtr;
   case TemplateArgument::Integral:
 return CXTemplateArgumentKind_Integral;
+  case TemplateArgument::UncommonValue:
+// FIXME: Expose these values.
+return CXTemplateArgumentKind_Invalid;
   case TemplateArgument::Template:
 return CXTemplateArgumentKind_Template;
   case TemplateArgument::TemplateExpansion:
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -1570,6 +1570,11 @@
   return Visit(MakeCXCursor(E, StmtParent, TU, RegionOfInterest));
 return false;
 
+  case TemplateArgument::UncommonValue:
+if (Expr *E = TAL.getSourceUncommonValueExpression())
+  return Visit(MakeCXCursor(E, StmtParent, TU, RegionOfInterest));
+return false;
+
   case TemplateArgument::NullPtr:
 if (Expr *E = TAL.getSourceNullPtrExpression())
  

[PATCH] D145860: [clang][Interp] Fix initializing fields after base class members

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

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D145860

Files:
  clang/lib/AST/Interp/ByteCodeExprGen.cpp
  clang/test/AST/Interp/cxx20.cpp


Index: clang/test/AST/Interp/cxx20.cpp
===
--- clang/test/AST/Interp/cxx20.cpp
+++ clang/test/AST/Interp/cxx20.cpp
@@ -583,3 +583,19 @@
   constexpr Outer O;
   static_assert(O.bar() == 12);
 }
+
+namespace BaseAndFieldInit {
+  struct A {
+int a;
+  };
+
+  struct B : A {
+int b;
+  };
+
+  struct C : B {
+int c;
+  };
+
+  constexpr C c = {1,2,3};
+}
Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp
===
--- clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -1410,6 +1410,7 @@
 
 if (!this->emitPopPtr(Initializer))
   return false;
+++InitIndex;
   } else {
 // Initializer for a direct base class.
 if (const Record::Base *B = R->getBase(Init->getType())) {
@@ -1421,6 +1422,8 @@
 
   if (!this->emitPopPtr(Initializer))
 return false;
+  // Base initializers don't increase InitIndex, since they don't count
+  // into the Record's fields.
 } else {
   const Record::Field *FieldToInit = R->getField(InitIndex);
   // Non-primitive case. Get a pointer to the field-to-initialize
@@ -1433,9 +1436,9 @@
 
   if (!this->emitPopPtr(Initializer))
 return false;
+  ++InitIndex;
 }
   }
-  ++InitIndex;
 }
 
 return true;


Index: clang/test/AST/Interp/cxx20.cpp
===
--- clang/test/AST/Interp/cxx20.cpp
+++ clang/test/AST/Interp/cxx20.cpp
@@ -583,3 +583,19 @@
   constexpr Outer O;
   static_assert(O.bar() == 12);
 }
+
+namespace BaseAndFieldInit {
+  struct A {
+int a;
+  };
+
+  struct B : A {
+int b;
+  };
+
+  struct C : B {
+int c;
+  };
+
+  constexpr C c = {1,2,3};
+}
Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp
===
--- clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -1410,6 +1410,7 @@
 
 if (!this->emitPopPtr(Initializer))
   return false;
+++InitIndex;
   } else {
 // Initializer for a direct base class.
 if (const Record::Base *B = R->getBase(Init->getType())) {
@@ -1421,6 +1422,8 @@
 
   if (!this->emitPopPtr(Initializer))
 return false;
+  // Base initializers don't increase InitIndex, since they don't count
+  // into the Record's fields.
 } else {
   const Record::Field *FieldToInit = R->getField(InitIndex);
   // Non-primitive case. Get a pointer to the field-to-initialize
@@ -1433,9 +1436,9 @@
 
   if (!this->emitPopPtr(Initializer))
 return false;
+  ++InitIndex;
 }
   }
-  ++InitIndex;
 }
 
 return true;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D145848: [Driver] Correct -f(no-)xray-function-index behavior

2023-03-11 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay requested changes to this revision.
MaskRay added inline comments.
This revision now requires changes to proceed.



Comment at: clang/test/CodeGen/xray-function-index.cpp:1
+// RUN: %clang_cc1 -fxray-instrument  -x c++ 
-std=c++11 -triple x86_64-unknown-linux-gnu -S -o - %s | FileCheck %s 
--check-prefixes=CHECK,CHECK-ENABLED
+// RUN: %clang_cc1 -fxray-instrument -fno-xray-function-index -x c++ 
-std=c++11 -triple x86_64-unknown-linux-gnu -S -o - %s | FileCheck %s 
--check-prefixes=CHECK,CHECK-DISABLED

Add `// REQUIRES: x86-registered-target`



Comment at: clang/test/CodeGen/xray-function-index.cpp:8
+// CHECK-ENABLED: .section xray_fn_idx,"awo",@progbits,_Z3foov
+// CHECK-DISABLED-NOT: xray_fn_idx

`.section xray_fn_idx`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145848

___
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-11 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder created this revision.
tbaeder added reviewers: aaron.ballman, erichkeane, tahonermann, shafik.
Herald added a subscriber: kristof.beyls.
Herald added a project: All.
tbaeder requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

  They are harmless and handled by other means, but we used to return
  false from visitDeclStmt.


Repository:
  rG LLVM Github Monorepo

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,14 @@
   static_assert(S3{}.foo(), "");
   static_assert(!S3{}.foo(), "");
 }
+
+#if __cplusplus >= 201402L
+constexpr int ignoredDecls() {
+  static_assert(true);
+  struct F { int a; };
+  enum E { b };
+
+  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,14 @@
   static_assert(S3{}.foo(), "");
   static_assert(!S3{}.foo(), "");
 }
+
+#if __cplusplus >= 201402L
+constexpr int ignoredDecls() {
+  static_assert(true);
+  struct F { int a; };
+  enum E { b };
+
+  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


[clang] 59848b9 - [Clang][AIX][p] Manually Claim -p in front end

2023-03-11 Thread Michael Francis via cfe-commits

Author: Michael Francis
Date: 2023-03-12T07:33:21Z
New Revision: 59848b9ebae6a92a4342b1e8aa32feaf5c9c4b51

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

LOG: [Clang][AIX][p] Manually Claim -p in front end

The current implementation of `-p` does not claim the argument once it
is passed. Since it pushes `-pg` directly, it is only ever referred to
again when linking. As a result, when compiling with `-S`, the compiler
warns that `-p` goes unused even though that is not the case.

With this patch, if both `-p` and `-pg` are passed, the argument that is
passed second will take precedence. `-p` will still throw an error on
unsupported platforms, regardless of precedence.

This revision includes a test case, which has been placed in
`clang/test/Driver/zos-profiling-error.c`. As a result,
`zos-profiling-error.c` has been renamed to `ibm-profiling.c`. This
revision also passes `clang/test/Driver/aix-ld.c`.

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

Added: 
clang/test/Driver/ibm-profiling.c

Modified: 
clang/lib/Driver/ToolChains/AIX.cpp
clang/lib/Driver/ToolChains/Clang.cpp

Removed: 
clang/test/Driver/zos-profiling-error.c



diff  --git a/clang/lib/Driver/ToolChains/AIX.cpp 
b/clang/lib/Driver/ToolChains/AIX.cpp
index 15560e1c81bca..57234f235156e 100644
--- a/clang/lib/Driver/ToolChains/AIX.cpp
+++ b/clang/lib/Driver/ToolChains/AIX.cpp
@@ -164,11 +164,12 @@ void aix::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
   }
 
   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 @@ void aix::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
 
 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"));
   CmdArgs.push_back(Args.MakeArgString((llvm::Twine("-L") + D.SysRoot) +

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 79fcf4526df3e..87862e028636f 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -6322,20 +6322,26 @@ void Clang::ConstructJob(Compilation &C, const 
JobAction &JA,
 << 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)))

diff  --git a/clang/test/Driver/ibm-profiling.c 
b/clang/test/Driver/ibm-profiling.c
new file mode 100644
index 0..26bc0d7784373
--- /dev/null
+++ b/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.
+// RU

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

2023-03-11 Thread Michael Francis 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 rG59848b9ebae6: [Clang][AIX][p] Manually Claim -p in front end 
(authored by francii).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145021

Files:
  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.Ma