[PATCH] D127910: [Clang][AArch64][SME] Add vector load/store (ld1/st1) intrinsics

2023-05-15 Thread Bryan Chan via Phabricator via cfe-commits
bryanpkc updated this revision to Diff 522064.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127910

Files:
  clang/include/clang/Basic/BuiltinsAArch64.def
  clang/include/clang/Basic/BuiltinsARM.def
  clang/include/clang/Basic/BuiltinsNEON.def
  clang/include/clang/Basic/BuiltinsSME.def
  clang/include/clang/Basic/CMakeLists.txt
  clang/include/clang/Basic/TargetBuiltins.h
  clang/include/clang/Basic/arm_sme.td
  clang/include/clang/Basic/arm_sve.td
  clang/include/clang/Basic/arm_sve_sme_incl.td
  clang/lib/Basic/Targets/AArch64.cpp
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/Headers/CMakeLists.txt
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_ld1.c
  clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_ld1_vnum.c
  clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_st1.c
  clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_st1_vnum.c
  clang/test/Sema/aarch64-sme-intrinsics/acle_sme_imm.cpp
  clang/test/Sema/aarch64-sme-intrinsics/acle_sme_target.c
  clang/utils/TableGen/SveEmitter.cpp
  clang/utils/TableGen/TableGen.cpp
  clang/utils/TableGen/TableGenBackends.h

Index: clang/utils/TableGen/TableGenBackends.h
===
--- clang/utils/TableGen/TableGenBackends.h
+++ clang/utils/TableGen/TableGenBackends.h
@@ -101,6 +101,11 @@
 void EmitSveTypeFlags(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
 void EmitSveRangeChecks(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
 
+void EmitSmeHeader(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
+void EmitSmeBuiltins(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
+void EmitSmeBuiltinCG(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
+void EmitSmeRangeChecks(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
+
 void EmitMveHeader(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
 void EmitMveBuiltinDef(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
 void EmitMveBuiltinSema(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
Index: clang/utils/TableGen/TableGen.cpp
===
--- clang/utils/TableGen/TableGen.cpp
+++ clang/utils/TableGen/TableGen.cpp
@@ -82,6 +82,10 @@
   GenArmSveBuiltinCG,
   GenArmSveTypeFlags,
   GenArmSveRangeChecks,
+  GenArmSmeHeader,
+  GenArmSmeBuiltins,
+  GenArmSmeBuiltinCG,
+  GenArmSmeRangeChecks,
   GenArmCdeHeader,
   GenArmCdeBuiltinDef,
   GenArmCdeBuiltinSema,
@@ -226,6 +230,14 @@
"Generate arm_sve_typeflags.inc for clang"),
 clEnumValN(GenArmSveRangeChecks, "gen-arm-sve-sema-rangechecks",
"Generate arm_sve_sema_rangechecks.inc for clang"),
+clEnumValN(GenArmSmeHeader, "gen-arm-sme-header",
+   "Generate arm_sme.h for clang"),
+clEnumValN(GenArmSmeBuiltins, "gen-arm-sme-builtins",
+   "Generate arm_sme_builtins.inc for clang"),
+clEnumValN(GenArmSmeBuiltinCG, "gen-arm-sme-builtin-codegen",
+   "Generate arm_sme_builtin_cg_map.inc for clang"),
+clEnumValN(GenArmSmeRangeChecks, "gen-arm-sme-sema-rangechecks",
+   "Generate arm_sme_sema_rangechecks.inc for clang"),
 clEnumValN(GenArmMveHeader, "gen-arm-mve-header",
"Generate arm_mve.h for clang"),
 clEnumValN(GenArmMveBuiltinDef, "gen-arm-mve-builtin-def",
@@ -454,6 +466,18 @@
   case GenArmSveRangeChecks:
 EmitSveRangeChecks(Records, OS);
 break;
+  case GenArmSmeHeader:
+EmitSmeHeader(Records, OS);
+break;
+  case GenArmSmeBuiltins:
+EmitSmeBuiltins(Records, OS);
+break;
+  case GenArmSmeBuiltinCG:
+EmitSmeBuiltinCG(Records, OS);
+break;
+  case GenArmSmeRangeChecks:
+EmitSmeRangeChecks(Records, OS);
+break;
   case GenArmCdeHeader:
 EmitCdeHeader(Records, OS);
 break;
Index: clang/utils/TableGen/SveEmitter.cpp
===
--- clang/utils/TableGen/SveEmitter.cpp
+++ clang/utils/TableGen/SveEmitter.cpp
@@ -228,7 +228,7 @@
   }
 
   /// Emits the intrinsic declaration to the ostream.
-  void emitIntrinsic(raw_ostream &OS) const;
+  void emitIntrinsic(raw_ostream &OS, SVEEmitter &Emitter) const;
 
 private:
   std::string getMergeSuffix() const { return MergeSuffix; }
@@ -346,8 +346,21 @@
   /// Create the SVETypeFlags used in CGBuiltins
   void createTypeFlags(raw_ostream &o);
 
+  /// Emit arm_sme.h.
+  void createSMEHeader(raw_ostream &o);
+
+  /// Emit all the SME __builtin prototypes and code needed by Sema.
+  void createSMEBuiltins(raw_ostream &o);
+
+  /// Emit all the information needed to map builtin -> LLVM IR intrinsic.
+  void createSMECodeGenMap(raw_ostream &o);
+
+  /// Emit all the range checks for the immediates.
+  void createSMERangeChecks(r

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

2023-05-15 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast accepted this revision.
hubert.reinterpretcast added a comment.
This revision is now accepted and ready to land.

LGTM with minor comments!




Comment at: clang/lib/Driver/ToolChains/AIX.cpp:132
+// possible. Then `-bforceimprw` changes such sections to RW if they 
contain
+// imported symbols that needs to be resolved.
+CmdArgs.push_back("-bforceimprw");

Minor nit: needs => need



Comment at: clang/lib/Driver/ToolChains/CommonArgs.cpp:728-729
+if (HasRoptr) {
+  // On AIX, data_sections is on by default. We only need to check
+  // if data_sections is explicitly turned off.
+  if (!Args.hasFlag(options::OPT_fdata_sections,

Remove the comment. The `hasFlag` check requires no special reasoning.



Comment at: clang/test/CodeGen/PowerPC/aix-roptr.c:13
+char c1 = 10;
+char c2 = 20;
+char* const c1_ptr = &c1;

Remove `c2`. Not needed for the test.



Comment at: clang/test/CodeGen/PowerPC/aix-roptr.c:27-30
+
+int main() {
+*(char**)&c1_ptr = &c2;
+}

Remove `main`. Not needed for the test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144190

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


[PATCH] D128648: [Clang][AArch64][SME] Add vector read/write (mova) intrinsics

2023-05-15 Thread Bryan Chan via Phabricator via cfe-commits
bryanpkc added a comment.

Rebased on main, and removed dependence on the SME attributes patch as per 
https://reviews.llvm.org/D127910?vs=522039&id=522064#inline-1451681.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128648

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


[PATCH] D149437: [clangd] Emit ChangeAnnotation label and description for include-cleaner diagnostics.

2023-05-15 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 522067.
hokein marked 3 inline comments as done.
hokein added a comment.
Herald added a subscriber: mgrang.

address comments and polish implementations.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149437

Files:
  clang-tools-extra/clangd/Hover.cpp
  clang-tools-extra/clangd/IncludeCleaner.cpp
  clang-tools-extra/clangd/IncludeCleaner.h
  clang-tools-extra/clangd/test/include-cleaner-batch-fix.test
  clang-tools-extra/include-cleaner/include/clang-include-cleaner/Types.h
  clang-tools-extra/include-cleaner/lib/Types.cpp

Index: clang-tools-extra/include-cleaner/lib/Types.cpp
===
--- clang-tools-extra/include-cleaner/lib/Types.cpp
+++ clang-tools-extra/include-cleaner/lib/Types.cpp
@@ -15,6 +15,18 @@
 
 namespace clang::include_cleaner {
 
+std::string Symbol::name() const {
+  switch (kind()) {
+  case Symbol::Declaration:
+if (const auto *ND = llvm::dyn_cast(&declaration()))
+  return ND->getNameAsString();
+return "";
+  case Symbol::Macro:
+return macro().Name->getName().str();
+  }
+  llvm_unreachable("unhandled Symbol kind!");
+}
+
 llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const Symbol &S) {
   switch (S.kind()) {
   case Symbol::Declaration:
@@ -136,4 +148,5 @@
   }
   llvm_unreachable("unhandled Header kind");
 }
+
 } // namespace clang::include_cleaner
Index: clang-tools-extra/include-cleaner/include/clang-include-cleaner/Types.h
===
--- clang-tools-extra/include-cleaner/include/clang-include-cleaner/Types.h
+++ clang-tools-extra/include-cleaner/include/clang-include-cleaner/Types.h
@@ -68,6 +68,8 @@
   const Decl &declaration() const { return *std::get(Storage); }
   struct Macro macro() const { return std::get(Storage); }
 
+  std::string name() const;
+
 private:
   // Order must match Kind enum!
   std::variant Storage;
Index: clang-tools-extra/clangd/test/include-cleaner-batch-fix.test
===
--- clang-tools-extra/clangd/test/include-cleaner-batch-fix.test
+++ clang-tools-extra/clangd/test/include-cleaner-batch-fix.test
@@ -152,11 +152,13 @@
 # CHECK-NEXT:{
 # CHECK-NEXT:  "changeAnnotations": {
 # CHECK-NEXT:"AddAllMissingIncludes0": {
-# CHECK-NEXT:  "label": "",
+# CHECK-NEXT:  "description": "Provides Foo",
+# CHECK-NEXT:  "label": "{{.*}}foo.h{{.*}}",
 # CHECK-NEXT:  "needsConfirmation": true
 # CHECK-NEXT:},
 # CHECK-NEXT:"AddAllMissingIncludes1": {
-# CHECK-NEXT:  "label": "",
+# CHECK-NEXT:  "description": "Provides Bar",
+# CHECK-NEXT:  "label": "{{.*}}bar.h{{.*}}",
 # CHECK-NEXT:  "needsConfirmation": true
 # CHECK-NEXT:}
 # CHECK-NEXT:  },
@@ -165,7 +167,7 @@
 # CHECK-NEXT:  "edits": [
 # CHECK-NEXT:{
 # CHECK-NEXT:  "annotationId": "AddAllMissingIncludes0",
-# CHECK-NEXT:  "newText": "#include {{.*}}bar.h{{.*}}",
+# CHECK-NEXT:  "newText": "#include {{.*}}foo.h{{.*}}",
 # CHECK-NEXT:  "range": {
 # CHECK-NEXT:"end": {
 # CHECK-NEXT:  "character": 0,
@@ -179,7 +181,7 @@
 # CHECK-NEXT:},
 # CHECK-NEXT:{
 # CHECK-NEXT:  "annotationId": "AddAllMissingIncludes1",
-# CHECK-NEXT:  "newText": "#include {{.*}}foo.h{{.*}}",
+# CHECK-NEXT:  "newText": "#include {{.*}}bar.h{{.*}}",
 # CHECK-NEXT:  "range": {
 # CHECK-NEXT:"end": {
 # CHECK-NEXT:  "character": 0,
@@ -208,19 +210,21 @@
 # CHECK-NEXT:{
 # CHECK-NEXT:  "changeAnnotations": {
 # CHECK-NEXT:"AddAllMissingIncludes0": {
-# CHECK-NEXT:  "label": "",
+# CHECK-NEXT:  "description": "Provides Foo",
+# CHECK-NEXT:  "label": "{{.*}}foo.h{{.*}}",
 # CHECK-NEXT:  "needsConfirmation": true
 # CHECK-NEXT:},
 # CHECK-NEXT:"AddAllMissingIncludes1": {
-# CHECK-NEXT:  "label": "",
+# CHECK-NEXT:  "description": "Provides Bar",
+# CHECK-NEXT:  "label": "{{.*}}bar.h{{.*}}",
 # CHECK-NEXT:  "needsConfirmation": true
 # CHECK-NEXT:},
 # CHECK-NEXT:"RemoveAllUnusedIncludes0": {
-# CHECK-NEXT:  "label": "",
+# CHECK-NEXT:  "label": "Remove {{.*}}all1.h{{.*}}",
 # CHECK-NEXT:  "needsConfirmation": true
 # CHECK-NEXT:},
 # CHECK-NEXT:"RemoveAllUnusedIncludes1": {
-# CHECK-NEXT:  "label": "",
+# CHECK-NEXT:  "label": "Remove {{.*}}all2.h{{.

[PATCH] D149437: [clangd] Emit ChangeAnnotation label and description for include-cleaner diagnostics.

2023-05-15 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

I have polished the implementation about the fix-all for missing-include 
diagnostics, please take a look on the new code.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149437

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


[PATCH] D150258: [clang][parser] Fix namespace dropping after malformed declarations

2023-05-15 Thread Alejandro Álvarez Ayllón via Phabricator via cfe-commits
alejandro-alvarez-sonarsource added a comment.

In D150258#4337880 , @aaron.ballman 
wrote:

> LGTM! Do you need me to commit on your behalf? If so, what name and email 
> address would you like used for patch attribution?

Thanks a lot! And yes, I would need you to commit. You can use

Name: Alejandro Álvarez Ayllón
Email: alejandro.alva...@sonarsource.com


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

https://reviews.llvm.org/D150258

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


[PATCH] D150352: [clang][dataflow] Don't analyze templated declarations.

2023-05-15 Thread Martin Böhme via Phabricator via cfe-commits
mboehme updated this revision to Diff 522075.
mboehme added a comment.

Set `-fnodelayed-template-parsing` again.

This is needed to make tests pass on Windows.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150352

Files:
  clang/include/clang/Analysis/FlowSensitive/ControlFlowContext.h
  clang/lib/Analysis/FlowSensitive/ControlFlowContext.cpp
  clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
  clang/lib/Analysis/FlowSensitive/Transfer.cpp
  clang/unittests/Analysis/FlowSensitive/TestingSupport.h
  clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
  clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp

Index: clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
@@ -68,7 +68,7 @@
   assert(Body != nullptr);
 
   auto CFCtx = llvm::cantFail(
-  ControlFlowContext::build(nullptr, *Body, AST->getASTContext()));
+  ControlFlowContext::build(*Func, *Body, AST->getASTContext()));
 
   AnalysisT Analysis = MakeAnalysis(AST->getASTContext());
   DataflowAnalysisContext DACtx(std::make_unique());
Index: clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
@@ -39,13 +39,17 @@
 using BuiltinOptions = DataflowAnalysisContext::Options;
 
 template 
-void runDataflow(llvm::StringRef Code, Matcher Match,
- DataflowAnalysisOptions Options,
- LangStandard::Kind Std = LangStandard::lang_cxx17,
- llvm::StringRef TargetFun = "target") {
+llvm::Error
+runDataflowReturnError(llvm::StringRef Code, Matcher Match,
+   DataflowAnalysisOptions Options,
+   LangStandard::Kind Std = LangStandard::lang_cxx17,
+   llvm::StringRef TargetFun = "target") {
   using ast_matchers::hasName;
   llvm::SmallVector ASTBuildArgs = {
-  "-fsyntax-only", "-fno-delayed-template-parsing",
+  // -fnodelayed-template-parsing is the default everywhere but on Windows.
+  // Set it explicitly so that tests behave the same on Windows as on other
+  // platforms.
+  "-fsyntax-only", "-fnodelayed-template-parsing",
   "-std=" +
   std::string(LangStandard::getLangStandardForKind(Std).getName())};
   AnalysisInputs AI(
@@ -61,13 +65,21 @@
   AI.ASTBuildArgs = ASTBuildArgs;
   if (Options.BuiltinOpts)
 AI.BuiltinOptions = *Options.BuiltinOpts;
+  return checkDataflow(
+  std::move(AI),
+  /*VerifyResults=*/
+  [&Match](
+  const llvm::StringMap> &Results,
+  const AnalysisOutputs &AO) { Match(Results, AO.ASTCtx); });
+}
+
+template 
+void runDataflow(llvm::StringRef Code, Matcher Match,
+ DataflowAnalysisOptions Options,
+ LangStandard::Kind Std = LangStandard::lang_cxx17,
+ llvm::StringRef TargetFun = "target") {
   ASSERT_THAT_ERROR(
-  checkDataflow(
-  std::move(AI),
-  /*VerifyResults=*/
-  [&Match](const llvm::StringMap>
-   &Results,
-   const AnalysisOutputs &AO) { Match(Results, AO.ASTCtx); }),
+  runDataflowReturnError(Code, Match, Options, Std, TargetFun),
   llvm::Succeeded());
 }
 
@@ -2534,31 +2546,34 @@
   });
 }
 
-TEST(TransferTest, DerefDependentPtr) {
+TEST(TransferTest, CannotAnalyzeFunctionTemplate) {
   std::string Code = R"(
 template 
-void target(T *Foo) {
-  T &Bar = *Foo;
-  /*[[p]]*/
-}
+void target() {}
   )";
-  runDataflow(
-  Code,
-  [](const llvm::StringMap> &Results,
- ASTContext &ASTCtx) {
-ASSERT_THAT(Results.keys(), UnorderedElementsAre("p"));
-const Environment &Env = getEnvironmentAtAnnotation(Results, "p");
-
-const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo");
-ASSERT_THAT(FooDecl, NotNull());
-
-const ValueDecl *BarDecl = findValueDecl(ASTCtx, "Bar");
-ASSERT_THAT(BarDecl, NotNull());
+  ASSERT_THAT_ERROR(
+  runDataflowReturnError(
+  Code,
+  [](const llvm::StringMap> &Results,
+ ASTContext &ASTCtx) {},
+  {BuiltinOptions()}),
+  llvm::FailedWithMessage("Cannot analyze templated declarations"));
+}
 
-const auto *FooVal = cast(Env.getValue(*FooDecl));
-const auto *BarLoc = Env.getStorageLocation(*BarDecl);
-EXPECT_EQ(BarLoc, &FooVal->getPointeeLoc());
-  });
+TEST(TransferTest, CannotAnalyzeMethodOfClassTemplate) {
+  std::string Code = R"(
+template 
+struct A {
+  void target() {}
+};
+ 

[PATCH] D150352: [clang][dataflow] Don't analyze templated declarations.

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



Comment at: clang/unittests/Analysis/FlowSensitive/TransferTest.cpp:2537
 
-TEST(TransferTest, DerefDependentPtr) {
   std::string Code = R"(

mboehme wrote:
> gribozavr2 wrote:
> > This `DerefDependentPtr` test was originally added in 
> > https://reviews.llvm.org/D117567 and re-landed in 
> > https://github.com/llvm/llvm-project/commit/acd4b0359097dd8ad166d569a4566879e82a2793
> > 
> > Could you try to revert the effects of those commits? Specifically:
> > 
> > - remove reference skipping from the transfer function for `UO_Deref` (and 
> > the comment),
> > 
> > - remove the `-fno-delayed-template-parsing` flag from 
> > `clang/unittests/Analysis/FlowSensitive/TransferTest.cpp`.
> Thanks for pointing this out! Done.
> - remove the `-fno-delayed-template-parsing` flag from 
> `clang/unittests/Analysis/FlowSensitive/TransferTest.cpp`.

I've re-added this because removing it causes tests to fail on Windows.

`-fnodelayed-template-parsing` is the default everywhere except on Windows, so 
setting it explicitly makes tests on Windows behave the same as on other 
platforms. I've added a comment explaining this.

The reason that `-fnodelayed-template-parsing` was causing the tests to fail is 
that `checkDataflow()` only looks as function declarations that have a body, 
and late-parsed templated functions don't have bodies.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150352

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


[PATCH] D150191: [clang][Diagnostics] Provide a source range for 'use of undeclared identifier' diagnostics

2023-05-15 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder abandoned this revision.
tbaeder added a comment.

Abandoning this. The code in question was dead before as far as I can tell, 
since the `Ranges` list was always empty. I can't add this without regressing 
any of the existing tests.


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

https://reviews.llvm.org/D150191

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


[PATCH] D149718: [NFC][Clang] Fix Coverity issues of copy without assign

2023-05-15 Thread Mikael Holmén via Phabricator via cfe-commits
uabelho added a comment.

In D149718#4341052 , @uabelho wrote:

> Compiling with clang 15.0.5 I get the following warning/error with this patch:
>
>   ../../clang/include/clang/Sema/ParsedAttr.h:705:18: error: explicitly 
> defaulted move assignment operator is implicitly deleted 
> [-Werror,-Wdefaulted-function-deleted]
> AttributePool &operator=(AttributePool &&pool) = default;
>^
>   ../../clang/include/clang/Sema/ParsedAttr.h:674:21: note: move assignment 
> operator of 'AttributePool' is implicitly deleted because field 'Factory' is 
> of reference type 'clang::AttributeFactory &'
> AttributeFactory &Factory;
>   ^
>   1 error generated.

Also seen in this buildbot:
 https://lab.llvm.org/buildbot/#/builders/214/builds/7476


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149718

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


[PATCH] D148088: [RFC][clangd] Move preamble index out of document open critical path

2023-05-15 Thread Kugan Vivekanandarajah via Phabricator via cfe-commits
kuganv updated this revision to Diff 522083.
kuganv added a comment.

Fixed tests
clangd/unittests/TUSchedulerTests.cpp require re-warite due to delayed 
onPreambleAST callback.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148088

Files:
  clang-tools-extra/clangd/Preamble.cpp
  clang-tools-extra/clangd/Preamble.h
  clang-tools-extra/clangd/TUScheduler.cpp
  clang-tools-extra/clangd/tool/Check.cpp
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
  clang-tools-extra/clangd/unittests/FileIndexTests.cpp
  clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
  clang-tools-extra/clangd/unittests/PreambleTests.cpp
  clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
  clang-tools-extra/clangd/unittests/TestTU.cpp
  clang-tools-extra/clangd/unittests/TestTU.h
  clang/include/clang/Frontend/CompilerInstance.h

Index: clang/include/clang/Frontend/CompilerInstance.h
===
--- clang/include/clang/Frontend/CompilerInstance.h
+++ clang/include/clang/Frontend/CompilerInstance.h
@@ -12,6 +12,7 @@
 #include "clang/AST/ASTConsumer.h"
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/SourceManager.h"
+#include "clang/Basic/TargetInfo.h"
 #include "clang/Frontend/CompilerInvocation.h"
 #include "clang/Frontend/PCHContainerOperations.h"
 #include "clang/Frontend/Utils.h"
@@ -233,6 +234,8 @@
 return *Invocation;
   }
 
+  std::shared_ptr getInvocationPtr() { return Invocation; }
+
   /// setInvocation - Replace the current invocation.
   void setInvocation(std::shared_ptr Value);
 
@@ -338,6 +341,11 @@
 return *Diagnostics;
   }
 
+  IntrusiveRefCntPtr getDiagnosticsPtr() const {
+assert(Diagnostics && "Compiler instance has no diagnostics!");
+return Diagnostics;
+  }
+
   /// setDiagnostics - Replace the current diagnostics engine.
   void setDiagnostics(DiagnosticsEngine *Value);
 
@@ -373,6 +381,11 @@
 return *Target;
   }
 
+  IntrusiveRefCntPtr getTargetPtr() const {
+assert(Target && "Compiler instance has no target!");
+return Target;
+  }
+
   /// Replace the current Target.
   void setTarget(TargetInfo *Value);
 
@@ -406,6 +419,11 @@
 return *FileMgr;
   }
 
+  IntrusiveRefCntPtr getFileManagerPtr() const {
+assert(FileMgr && "Compiler instance has no file manager!");
+return FileMgr;
+  }
+
   void resetAndLeakFileManager() {
 llvm::BuryPointer(FileMgr.get());
 FileMgr.resetWithoutRelease();
@@ -426,6 +444,11 @@
 return *SourceMgr;
   }
 
+  IntrusiveRefCntPtr getSourceManagerPtr() const {
+assert(SourceMgr && "Compiler instance has no source manager!");
+return SourceMgr;
+  }
+
   void resetAndLeakSourceManager() {
 llvm::BuryPointer(SourceMgr.get());
 SourceMgr.resetWithoutRelease();
@@ -466,6 +489,11 @@
 return *Context;
   }
 
+  IntrusiveRefCntPtr getASTContextPtr() const {
+assert(Context && "Compiler instance has no AST context!");
+return Context;
+  }
+
   void resetAndLeakASTContext() {
 llvm::BuryPointer(Context.get());
 Context.resetWithoutRelease();
Index: clang-tools-extra/clangd/unittests/TestTU.h
===
--- clang-tools-extra/clangd/unittests/TestTU.h
+++ clang-tools-extra/clangd/unittests/TestTU.h
@@ -32,6 +32,8 @@
 namespace clang {
 namespace clangd {
 
+using PreambleParsedCallback = std::function;
 struct TestTU {
   static TestTU withCode(llvm::StringRef Code) {
 TestTU TU;
@@ -89,7 +91,7 @@
   // The result will always have getDiagnostics() populated.
   ParsedAST build() const;
   std::shared_ptr
-  preamble(PreambleParsedCallback PreambleCallback = nullptr) const;
+  preamble(PreambleParsedCallback = nullptr) const;
   ParseInputs inputs(MockFS &FS) const;
   SymbolSlab headerSymbols() const;
   RefSlab headerRefs() const;
Index: clang-tools-extra/clangd/unittests/TestTU.cpp
===
--- clang-tools-extra/clangd/unittests/TestTU.cpp
+++ clang-tools-extra/clangd/unittests/TestTU.cpp
@@ -107,8 +107,16 @@
 initializeModuleCache(*CI);
   auto ModuleCacheDeleter = llvm::make_scope_exit(
   std::bind(deleteModuleCache, CI->getHeaderSearchOpts().ModuleCachePath));
-  return clang::clangd::buildPreamble(testPath(Filename), *CI, Inputs,
-  /*StoreInMemory=*/true, PreambleCallback);
+  auto res = clang::clangd::buildPreamble(testPath(Filename), *CI, Inputs,
+  /*StoreInMemory=*/true);
+  if (PreambleCallback) {
+auto &ASTCtx = *res.second;
+ASTContext &Ctx = ASTCtx.getASTContext();
+Preprocessor &PP = ASTCtx.getPreprocessor();
+auto &CanonIncludes = res.first->CanonIncludes;
+PreambleCallback(Ctx, PP, CanonIncludes);
+  }
+  return res.first;
 }
 
 ParsedAST TestTU::build() const {
@@ -124,8 +132,8 @@
   std::

[PATCH] D149733: [clang][USR] Prevent crashes on incomplete FunctionDecls

2023-05-15 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

gentle ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149733

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


[PATCH] D150548: [clangd] Deduplicate diagnostic codeaction fixes when the codeaction fixes multiple diagnostics

2023-05-15 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: kadircet.
Herald added a subscriber: arphaman.
Herald added a project: All.
hokein requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

Fixes https://github.com/clangd/clangd/issues/1633


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D150548

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/IncludeCleaner.cpp
  clang-tools-extra/clangd/Protocol.cpp
  clang-tools-extra/clangd/Protocol.h
  clang-tools-extra/clangd/test/include-cleaner-batch-fix.test

Index: clang-tools-extra/clangd/test/include-cleaner-batch-fix.test
===
--- clang-tools-extra/clangd/test/include-cleaner-batch-fix.test
+++ clang-tools-extra/clangd/test/include-cleaner-batch-fix.test
@@ -308,6 +308,100 @@
 # CHECK-NEXT:{
 # CHECK-NEXT:  "arguments": [
 # CHECK-NEXT:{
+# CHECK-NEXT:  "changeAnnotations": {
+# CHECK-NEXT:"AddAllMissingIncludes0": {
+# CHECK-NEXT:  "description": "Provides {{.*}}",
+# CHECK-NEXT:  "label": "{{.*}}",
+# CHECK-NEXT:  "needsConfirmation": true
+# CHECK-NEXT:},
+# CHECK-NEXT:"AddAllMissingIncludes1": {
+# CHECK-NEXT:  "description": "Provides {{.*}}",
+# CHECK-NEXT:  "label": "{{.*}}",
+# CHECK-NEXT:  "needsConfirmation": true
+# CHECK-NEXT:},
+# CHECK-NEXT:"RemoveAllUnusedIncludes0": {
+# CHECK-NEXT:  "label": "Remove {{.*}}",
+# CHECK-NEXT:  "needsConfirmation": true
+# CHECK-NEXT:},
+# CHECK-NEXT:"RemoveAllUnusedIncludes1": {
+# CHECK-NEXT:  "label": "Remove {{.*}}",
+# CHECK-NEXT:  "needsConfirmation": true
+# CHECK-NEXT:}
+# CHECK-NEXT:  },
+# CHECK-NEXT:  "documentChanges": [
+# CHECK-NEXT:{
+# CHECK-NEXT:  "edits": [
+# CHECK-NEXT:{
+# CHECK-NEXT:  "annotationId": "RemoveAllUnusedIncludes0",
+# CHECK-NEXT:  "newText": "",
+# CHECK-NEXT:  "range": {
+# CHECK-NEXT:"end": {
+# CHECK-NEXT:  "character": 0,
+# CHECK-NEXT:  "line": 1
+# CHECK-NEXT:},
+# CHECK-NEXT:"start": {
+# CHECK-NEXT:  "character": 0,
+# CHECK-NEXT:  "line": 0
+# CHECK-NEXT:}
+# CHECK-NEXT:  }
+# CHECK-NEXT:},
+# CHECK-NEXT:{
+# CHECK-NEXT:  "annotationId": "RemoveAllUnusedIncludes1",
+# CHECK-NEXT:  "newText": "",
+# CHECK-NEXT:  "range": {
+# CHECK-NEXT:"end": {
+# CHECK-NEXT:  "character": 0,
+# CHECK-NEXT:  "line": 2
+# CHECK-NEXT:},
+# CHECK-NEXT:"start": {
+# CHECK-NEXT:  "character": 0,
+# CHECK-NEXT:  "line": 1
+# CHECK-NEXT:}
+# CHECK-NEXT:  }
+# CHECK-NEXT:},
+# CHECK-NEXT:{
+# CHECK-NEXT:  "annotationId": "AddAllMissingIncludes0",
+# CHECK-NEXT:  "newText": "#include {{.*}}foo.h{{.*}}",
+# CHECK-NEXT:  "range": {
+# CHECK-NEXT:"end": {
+# CHECK-NEXT:  "character": 0,
+# CHECK-NEXT:  "line": 2
+# CHECK-NEXT:},
+# CHECK-NEXT:"start": {
+# CHECK-NEXT:  "character": 0,
+# CHECK-NEXT:  "line": 2
+# CHECK-NEXT:}
+# CHECK-NEXT:  }
+# CHECK-NEXT:},
+# CHECK-NEXT:{
+# CHECK-NEXT:  "annotationId": "AddAllMissingIncludes1",
+# CHECK-NEXT:  "newText": "#include {{.*}}bar.h{{.*}}",
+# CHECK-NEXT:  "range": {
+# CHECK-NEXT:"end": {
+# CHECK-NEXT:  "character": 0,
+# CHECK-NEXT:  "line": 2
+# CHECK-NEXT:},
+# CHECK-NEXT:"start": {
+# CHECK-NEXT:  "character": 0,
+# CHECK-NEXT:  "line": 2
+# CHECK-NEXT:}
+# CHECK-NEXT:  }
+# CHECK-NEXT:}
+# CHECK-NEXT:  ],
+# CHECK-NEXT:  "textDocument": {
+# CHECK-NEXT:"uri": "file://{{.*}}/simple.cpp",
+# CHECK-NEXT:"version": 0
+# CHECK-NEXT:  }
+# CHECK-NEXT:}
+# CHECK-NEXT:  ]
+# CHECK-NEXT:}
+# CHECK-NEXT:  ],
+# CHECK-NEXT:  "command": "clangd.applyFix",
+# CHECK-NEXT:  "title": "App

[PATCH] D150549: Move SubtargetFeature.h from MC to TargetParser

2023-05-15 Thread Job Noorman via Phabricator via cfe-commits
jobnoorman created this revision.
jobnoorman added reviewers: chandlerc, grosbach, andreadb, MaskRay, 
craig.topper.
Herald added subscribers: bviyer, asb, luke, Moerafaat, zero9178, bzcheeseman, 
pmatos, sdasgup3, wenzhicui, wrengr, ormris, foad, cota, teijeong, frasercrmck, 
rdzhabarov, tatianashp, msifontes, jurahul, Kayjukh, grosul1, Joonsoo, kerbowa, 
liufengdb, aartbik, mgester, arpith-jacob, csigg, antiagainst, shauheen, 
rriddle, mehdi_amini, luismarques, apazos, sameer.abuasal, s.egerton, Jim, 
jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, steven_wu, 
atanasyan, edward-jones, zzheng, jrtc27, gbedwell, niosHD, sabuasal, simoncook, 
johnrusso, rbar, fedor.sergeev, hiraditya, arichardson, sbc100, jvesely, 
sdardis, dylanmckay, jyknight, arsenm.
Herald added a project: All.
jobnoorman requested review of this revision.
Herald added subscribers: llvm-commits, openmp-commits, cfe-commits, 
pcwang-thead, stephenneuendorffer, nicolasvasilache, aheejin.
Herald added projects: clang, OpenMP, MLIR, LLVM.

SubtargetFeature.h is currently part of MC while it doesn't depend on
anything in MC. Since some LLVM components might have the need to work
with target features without necessarily needing MC, it might be
worthwhile to move SubtargetFeature.h to a different location. This will
reduce the dependencies of said components.

Note that I choose TargetParser as the destination because that's where
Triple lives and SubtargetFeatures feels related to that. Suggestions
for alternative locations are welcome.

This issues came up during a JITLink review (D149522 
). JITLink would
like to avoid a dependency on MC while still needing to store target
features.

I'm not entirely sure who should review this patch so please add more
reviewers if necessary.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D150549

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/ToolChains/AVR.cpp
  llvm/include/llvm/ExecutionEngine/Orc/JITTargetMachineBuilder.h
  llvm/include/llvm/MC/MCParser/MCTargetAsmParser.h
  llvm/include/llvm/MC/MCSubtargetInfo.h
  llvm/include/llvm/MC/SubtargetFeature.h
  llvm/include/llvm/Object/COFF.h
  llvm/include/llvm/Object/ELFObjectFile.h
  llvm/include/llvm/Object/GOFFObjectFile.h
  llvm/include/llvm/Object/MachO.h
  llvm/include/llvm/TargetParser/SubtargetFeature.h
  llvm/lib/CodeGen/CommandFlags.cpp
  llvm/lib/ExecutionEngine/TargetSelect.cpp
  llvm/lib/LTO/LTOBackend.cpp
  llvm/lib/LTO/LTOCodeGenerator.cpp
  llvm/lib/LTO/LTOModule.cpp
  llvm/lib/LTO/ThinLTOCodeGenerator.cpp
  llvm/lib/MC/CMakeLists.txt
  llvm/lib/MC/MCSubtargetInfo.cpp
  llvm/lib/MC/SubtargetFeature.cpp
  llvm/lib/Object/ELFObjectFile.cpp
  llvm/lib/Object/WasmObjectFile.cpp
  llvm/lib/Object/XCOFFObjectFile.cpp
  llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
  llvm/lib/Target/AArch64/Utils/AArch64BaseInfo.h
  llvm/lib/Target/AMDGPU/MCTargetDesc/R600MCCodeEmitter.cpp
  llvm/lib/Target/AMDGPU/MCTargetDesc/R600MCTargetDesc.cpp
  llvm/lib/Target/AMDGPU/MCTargetDesc/SIMCCodeEmitter.cpp
  llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp
  llvm/lib/Target/ARM/ARMTargetTransformInfo.h
  llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
  llvm/lib/Target/ARM/Disassembler/ARMDisassembler.cpp
  llvm/lib/Target/ARM/MCTargetDesc/ARMInstPrinter.cpp
  llvm/lib/Target/ARM/Utils/ARMBaseInfo.h
  llvm/lib/Target/AVR/MCTargetDesc/AVRELFStreamer.cpp
  llvm/lib/Target/BPF/Disassembler/BPFDisassembler.cpp
  llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCCodeEmitter.h
  llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchBaseInfo.h
  llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVMatInt.h
  llvm/lib/Target/Sparc/MCTargetDesc/SparcMCCodeEmitter.cpp
  llvm/lib/Target/TargetMachineC.cpp
  llvm/lib/TargetParser/CMakeLists.txt
  llvm/lib/TargetParser/SubtargetFeature.cpp
  llvm/tools/llc/llc.cpp
  llvm/tools/llvm-jitlink/llvm-jitlink.h
  llvm/tools/llvm-mc-assemble-fuzzer/llvm-mc-assemble-fuzzer.cpp
  llvm/tools/llvm-mc-disassemble-fuzzer/llvm-mc-disassemble-fuzzer.cpp
  llvm/tools/opt/opt.cpp
  llvm/unittests/tools/llvm-mca/MCATestBase.h
  llvm/utils/TableGen/DecoderEmitter.cpp
  llvm/utils/TableGen/SubtargetEmitter.cpp
  mlir/lib/ExecutionEngine/ExecutionEngine.cpp
  openmp/libomptarget/plugins-nextgen/common/PluginInterface/JIT.cpp

Index: openmp/libomptarget/plugins-nextgen/common/PluginInterface/JIT.cpp
===
--- openmp/libomptarget/plugins-nextgen/common/PluginInterface/JIT.cpp
+++ openmp/libomptarget/plugins-nextgen/common/PluginInterface/JIT.cpp
@@ -23,7 +23,6 @@
 #include "llvm/IR/LegacyPassManager.h"
 #include "llvm/IRReader/IRReader.h"
 #include "llvm/InitializePasses.h"
-#include "llvm/MC/SubtargetFeature.h"
 #include "llvm/MC/TargetRegistry.h"
 #include "llvm/Object/IRObjectFile.h"
 #include "llvm/Passes/OptimizationLevel.

[PATCH] D150352: [clang][dataflow] Don't analyze templated declarations.

2023-05-15 Thread Martin Böhme via Phabricator via cfe-commits
mboehme updated this revision to Diff 522096.
mboehme added a comment.

Spell `-fno-delayed-template-parsing` correctly (it was missing a hyphen).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150352

Files:
  clang/include/clang/Analysis/FlowSensitive/ControlFlowContext.h
  clang/lib/Analysis/FlowSensitive/ControlFlowContext.cpp
  clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
  clang/lib/Analysis/FlowSensitive/Transfer.cpp
  clang/unittests/Analysis/FlowSensitive/TestingSupport.h
  clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
  clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp

Index: clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
@@ -68,7 +68,7 @@
   assert(Body != nullptr);
 
   auto CFCtx = llvm::cantFail(
-  ControlFlowContext::build(nullptr, *Body, AST->getASTContext()));
+  ControlFlowContext::build(*Func, *Body, AST->getASTContext()));
 
   AnalysisT Analysis = MakeAnalysis(AST->getASTContext());
   DataflowAnalysisContext DACtx(std::make_unique());
Index: clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
@@ -39,12 +39,16 @@
 using BuiltinOptions = DataflowAnalysisContext::Options;
 
 template 
-void runDataflow(llvm::StringRef Code, Matcher Match,
- DataflowAnalysisOptions Options,
- LangStandard::Kind Std = LangStandard::lang_cxx17,
- llvm::StringRef TargetFun = "target") {
+llvm::Error
+runDataflowReturnError(llvm::StringRef Code, Matcher Match,
+   DataflowAnalysisOptions Options,
+   LangStandard::Kind Std = LangStandard::lang_cxx17,
+   llvm::StringRef TargetFun = "target") {
   using ast_matchers::hasName;
   llvm::SmallVector ASTBuildArgs = {
+  // -fnodelayed-template-parsing is the default everywhere but on Windows.
+  // Set it explicitly so that tests behave the same on Windows as on other
+  // platforms.
   "-fsyntax-only", "-fno-delayed-template-parsing",
   "-std=" +
   std::string(LangStandard::getLangStandardForKind(Std).getName())};
@@ -61,13 +65,21 @@
   AI.ASTBuildArgs = ASTBuildArgs;
   if (Options.BuiltinOpts)
 AI.BuiltinOptions = *Options.BuiltinOpts;
+  return checkDataflow(
+  std::move(AI),
+  /*VerifyResults=*/
+  [&Match](
+  const llvm::StringMap> &Results,
+  const AnalysisOutputs &AO) { Match(Results, AO.ASTCtx); });
+}
+
+template 
+void runDataflow(llvm::StringRef Code, Matcher Match,
+ DataflowAnalysisOptions Options,
+ LangStandard::Kind Std = LangStandard::lang_cxx17,
+ llvm::StringRef TargetFun = "target") {
   ASSERT_THAT_ERROR(
-  checkDataflow(
-  std::move(AI),
-  /*VerifyResults=*/
-  [&Match](const llvm::StringMap>
-   &Results,
-   const AnalysisOutputs &AO) { Match(Results, AO.ASTCtx); }),
+  runDataflowReturnError(Code, Match, Options, Std, TargetFun),
   llvm::Succeeded());
 }
 
@@ -2534,31 +2546,34 @@
   });
 }
 
-TEST(TransferTest, DerefDependentPtr) {
+TEST(TransferTest, CannotAnalyzeFunctionTemplate) {
   std::string Code = R"(
 template 
-void target(T *Foo) {
-  T &Bar = *Foo;
-  /*[[p]]*/
-}
+void target() {}
   )";
-  runDataflow(
-  Code,
-  [](const llvm::StringMap> &Results,
- ASTContext &ASTCtx) {
-ASSERT_THAT(Results.keys(), UnorderedElementsAre("p"));
-const Environment &Env = getEnvironmentAtAnnotation(Results, "p");
-
-const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo");
-ASSERT_THAT(FooDecl, NotNull());
-
-const ValueDecl *BarDecl = findValueDecl(ASTCtx, "Bar");
-ASSERT_THAT(BarDecl, NotNull());
+  ASSERT_THAT_ERROR(
+  runDataflowReturnError(
+  Code,
+  [](const llvm::StringMap> &Results,
+ ASTContext &ASTCtx) {},
+  {BuiltinOptions()}),
+  llvm::FailedWithMessage("Cannot analyze templated declarations"));
+}
 
-const auto *FooVal = cast(Env.getValue(*FooDecl));
-const auto *BarLoc = Env.getStorageLocation(*BarDecl);
-EXPECT_EQ(BarLoc, &FooVal->getPointeeLoc());
-  });
+TEST(TransferTest, CannotAnalyzeMethodOfClassTemplate) {
+  std::string Code = R"(
+template 
+struct A {
+  void target() {}
+};
+  )";
+  ASSERT_THAT_ERROR(
+  runDataflowReturnError(
+  Code,
+  [](con

[PATCH] D150253: [RISCV] Add Zvfhmin extension.

2023-05-15 Thread Jianjian Guan via Phabricator via cfe-commits
jacquesguan added a comment.

To enable specific EEW for specific insturction in instruction selection, I 
will create some parent revisions. Here is the first one. 
https://reviews.llvm.org/D150550


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150253

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


[PATCH] D149276: [Clang] Fix parsing of `(auto(x))`.

2023-05-15 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added a comment.

@aaron.ballman this won;t get approve by core un

In D149276#4302700 , @aaron.ballman 
wrote:

> The changes generally LGTM, but:
>
>> in a way consistent with the proposed resolution to CWG1223.
>
> What are the chances that CWG changes their mind and picks a different 
> direction?

They were happy with the direction friday when we looked at it ( not the 
wording though). I think we should go ahead, waiting until after issaquah might 
be a bit too late (and if we are claiming auto(x) is implemented we should 
merge that in 17)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149276

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


[PATCH] D150552: [analyzer] Fix QTimer::singleShot NewDeleteLeaks false positive

2023-05-15 Thread Michael Klein via Phabricator via cfe-commits
mkmvzlb created this revision.
Herald added subscribers: steakhal, manas, ASDenysPetrov, martong, dkrupp, 
donat.nagy, Szelethus, mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, 
xazax.hun.
Herald added a reviewer: NoQ.
Herald added a project: All.
mkmvzlb requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Fixes #39713


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D150552

Files:
  clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
  clang/test/Analysis/Inputs/qt-simulator.h
  clang/test/Analysis/qt_malloc.cpp


Index: clang/test/Analysis/qt_malloc.cpp
===
--- clang/test/Analysis/qt_malloc.cpp
+++ clang/test/Analysis/qt_malloc.cpp
@@ -19,3 +19,8 @@
new QtPrivate::QSlotObjectBase(), (Qt::ConnectionType)0,
nullptr, nullptr);
 }
+
+void singleShot(QTimer *timer) {
+  timer->singleShotImpl(0, (Qt::TimerType)0, nullptr,
+new QtPrivate::QSlotObjectBase());
+}
Index: clang/test/Analysis/Inputs/qt-simulator.h
===
--- clang/test/Analysis/Inputs/qt-simulator.h
+++ clang/test/Analysis/Inputs/qt-simulator.h
@@ -6,6 +6,7 @@
 
 namespace Qt {
 enum ConnectionType {};
+enum TimerType {};
 }
 
 struct QMetaObject {
@@ -31,3 +32,8 @@
 };
 
 struct QApplication : public QCoreApplication {};
+
+struct QTimer {
+  static void singleShotImpl(int, Qt::TimerType, const QObject *,
+ QtPrivate::QSlotObjectBase *);
+};
Index: clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
@@ -3259,6 +3259,11 @@
 return true;
   }
 
+  if (FName == "singleShotImpl" &&
+  FD->getQualifiedNameAsString() == "QTimer::singleShotImpl") {
+return true;
+  }
+
   // Handle cases where we know a buffer's /address/ can escape.
   // Note that the above checks handle some special cases where we know that
   // even though the address escapes, it's still our responsibility to free the


Index: clang/test/Analysis/qt_malloc.cpp
===
--- clang/test/Analysis/qt_malloc.cpp
+++ clang/test/Analysis/qt_malloc.cpp
@@ -19,3 +19,8 @@
new QtPrivate::QSlotObjectBase(), (Qt::ConnectionType)0,
nullptr, nullptr);
 }
+
+void singleShot(QTimer *timer) {
+  timer->singleShotImpl(0, (Qt::TimerType)0, nullptr,
+new QtPrivate::QSlotObjectBase());
+}
Index: clang/test/Analysis/Inputs/qt-simulator.h
===
--- clang/test/Analysis/Inputs/qt-simulator.h
+++ clang/test/Analysis/Inputs/qt-simulator.h
@@ -6,6 +6,7 @@
 
 namespace Qt {
 enum ConnectionType {};
+enum TimerType {};
 }
 
 struct QMetaObject {
@@ -31,3 +32,8 @@
 };
 
 struct QApplication : public QCoreApplication {};
+
+struct QTimer {
+  static void singleShotImpl(int, Qt::TimerType, const QObject *,
+ QtPrivate::QSlotObjectBase *);
+};
Index: clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
@@ -3259,6 +3259,11 @@
 return true;
   }
 
+  if (FName == "singleShotImpl" &&
+  FD->getQualifiedNameAsString() == "QTimer::singleShotImpl") {
+return true;
+  }
+
   // Handle cases where we know a buffer's /address/ can escape.
   // Note that the above checks handle some special cases where we know that
   // even though the address escapes, it's still our responsibility to free the
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D149850: [Clang][Modules] Support `requires cplusplus20` in a modulemap

2023-05-15 Thread Egor Zhdan via Phabricator via cfe-commits
egorzhdan added a comment.

@Bigcheese, @ChuanqiXu, could you please take a look at this patch?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149850

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


[PATCH] D149850: [Clang][Modules] Support `requires cplusplus20` in a modulemap

2023-05-15 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu accepted this revision.
ChuanqiXu added a comment.

LGTM. Sorry for misleading.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149850

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


[PATCH] D148370: [Clang][Flang][OpenMP] Add loadOffloadInfoMetadata and createOffloadEntriesAndInfoMetadata into OMPIRBuilder's finalize and initialize

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

If it would be possible to get some poor reviewers precious time on this I 
would greatly appreciate it! Thank you very much ahead of time.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148370

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


[clang] 1a42f79 - [clang][dataflow] Don't analyze templated declarations.

2023-05-15 Thread Martin Braenne via cfe-commits

Author: Martin Braenne
Date: 2023-05-15T11:04:51Z
New Revision: 1a42f795587b9d57291d009989aace6efd0a7a7f

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

LOG: [clang][dataflow] Don't analyze templated declarations.

Attempting to analyze templated code doesn't have a good cost-benefit ratio. We
have so far done a best-effort attempt at this, but maintaining this support has
an ongoing high maintenance cost because the AST for templates can violate a lot
of the invariants that otherwise hold for the AST of concrete code. As just one
example, in concrete code the operand of a UnaryOperator '*' is always a prvalue
(https://godbolt.org/z/s3e5xxMd1), but in templates this isn't true
(https://godbolt.org/z/6W9xxGvoM).

Further rationale for not analyzing templates:

* The semantics of a template itself are weakly defined; semantics can depend
  strongly on the concrete template arguments. Analyzing the template itself (as
  opposed to an instantiation) therefore has limited value.

* Analyzing templates requires a lot of special-case code that isn't necessary
  for concrete code because dependent types are hard to deal with and the AST
  violates invariants that otherwise hold for concrete code (see above).

* There's precedent in that neither Clang Static Analyzer nor the flow-sensitive
  warnings in Clang (such as uninitialized variables) support analyzing
  templates.

Reviewed By: gribozavr2, xazax.hun

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

Added: 


Modified: 
clang/include/clang/Analysis/FlowSensitive/ControlFlowContext.h
clang/lib/Analysis/FlowSensitive/ControlFlowContext.cpp
clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
clang/lib/Analysis/FlowSensitive/Transfer.cpp
clang/unittests/Analysis/FlowSensitive/TestingSupport.h
clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp

Removed: 




diff  --git a/clang/include/clang/Analysis/FlowSensitive/ControlFlowContext.h 
b/clang/include/clang/Analysis/FlowSensitive/ControlFlowContext.h
index 3495bdfc538cb..b51e2cb23634d 100644
--- a/clang/include/clang/Analysis/FlowSensitive/ControlFlowContext.h
+++ b/clang/include/clang/Analysis/FlowSensitive/ControlFlowContext.h
@@ -32,7 +32,13 @@ namespace dataflow {
 class ControlFlowContext {
 public:
   /// Builds a ControlFlowContext from an AST node. `D` is the function in 
which
-  /// `S` resides and must not be null.
+  /// `S` resides. `D.isTemplated()` must be false.
+  static llvm::Expected build(const Decl &D, Stmt &S,
+  ASTContext &C);
+
+  /// Builds a ControlFlowContext from an AST node. `D` is the function in 
which
+  /// `S` resides. `D` must not be null and `D->isTemplated()` must be false.
+  LLVM_DEPRECATED("Use the version that takes a const Decl & instead", "")
   static llvm::Expected build(const Decl *D, Stmt &S,
   ASTContext &C);
 

diff  --git a/clang/lib/Analysis/FlowSensitive/ControlFlowContext.cpp 
b/clang/lib/Analysis/FlowSensitive/ControlFlowContext.cpp
index 5520633da68ae..4556787d10a8e 100644
--- a/clang/lib/Analysis/FlowSensitive/ControlFlowContext.cpp
+++ b/clang/lib/Analysis/FlowSensitive/ControlFlowContext.cpp
@@ -68,7 +68,12 @@ static llvm::BitVector findReachableBlocks(const CFG &Cfg) {
 }
 
 llvm::Expected
-ControlFlowContext::build(const Decl *D, Stmt &S, ASTContext &C) {
+ControlFlowContext::build(const Decl &D, Stmt &S, ASTContext &C) {
+  if (D.isTemplated())
+return llvm::createStringError(
+std::make_error_code(std::errc::invalid_argument),
+"Cannot analyze templated declarations");
+
   CFG::BuildOptions Options;
   Options.PruneTriviallyFalseEdges = true;
   Options.AddImplicitDtors = true;
@@ -79,7 +84,7 @@ ControlFlowContext::build(const Decl *D, Stmt &S, ASTContext 
&C) {
   // Ensure that all sub-expressions in basic blocks are evaluated.
   Options.setAllAlwaysAdd();
 
-  auto Cfg = CFG::buildCFG(D, &S, &C, Options);
+  auto Cfg = CFG::buildCFG(&D, &S, &C, Options);
   if (Cfg == nullptr)
 return llvm::createStringError(
 std::make_error_code(std::errc::invalid_argument),
@@ -90,9 +95,19 @@ ControlFlowContext::build(const Decl *D, Stmt &S, ASTContext 
&C) {
 
   llvm::BitVector BlockReachable = findReachableBlocks(*Cfg);
 
-  return ControlFlowContext(D, std::move(Cfg), std::move(StmtToBlock),
+  return ControlFlowContext(&D, std::move(Cfg), std::move(StmtToBlock),
 std::move(BlockReachable));
 }
 
+llvm::Expected
+ControlFlowContext::build(const Decl *D, Stmt &S, ASTContext &C) {
+  if (D == nullptr)
+return llvm::createStringError(
+std::mak

[PATCH] D150352: [clang][dataflow] Don't analyze templated declarations.

2023-05-15 Thread Martin Böhme via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1a42f795587b: [clang][dataflow] Don't analyze templated 
declarations. (authored by mboehme).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150352

Files:
  clang/include/clang/Analysis/FlowSensitive/ControlFlowContext.h
  clang/lib/Analysis/FlowSensitive/ControlFlowContext.cpp
  clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
  clang/lib/Analysis/FlowSensitive/Transfer.cpp
  clang/unittests/Analysis/FlowSensitive/TestingSupport.h
  clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
  clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp

Index: clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
@@ -68,7 +68,7 @@
   assert(Body != nullptr);
 
   auto CFCtx = llvm::cantFail(
-  ControlFlowContext::build(nullptr, *Body, AST->getASTContext()));
+  ControlFlowContext::build(*Func, *Body, AST->getASTContext()));
 
   AnalysisT Analysis = MakeAnalysis(AST->getASTContext());
   DataflowAnalysisContext DACtx(std::make_unique());
Index: clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
@@ -39,12 +39,16 @@
 using BuiltinOptions = DataflowAnalysisContext::Options;
 
 template 
-void runDataflow(llvm::StringRef Code, Matcher Match,
- DataflowAnalysisOptions Options,
- LangStandard::Kind Std = LangStandard::lang_cxx17,
- llvm::StringRef TargetFun = "target") {
+llvm::Error
+runDataflowReturnError(llvm::StringRef Code, Matcher Match,
+   DataflowAnalysisOptions Options,
+   LangStandard::Kind Std = LangStandard::lang_cxx17,
+   llvm::StringRef TargetFun = "target") {
   using ast_matchers::hasName;
   llvm::SmallVector ASTBuildArgs = {
+  // -fnodelayed-template-parsing is the default everywhere but on Windows.
+  // Set it explicitly so that tests behave the same on Windows as on other
+  // platforms.
   "-fsyntax-only", "-fno-delayed-template-parsing",
   "-std=" +
   std::string(LangStandard::getLangStandardForKind(Std).getName())};
@@ -61,13 +65,21 @@
   AI.ASTBuildArgs = ASTBuildArgs;
   if (Options.BuiltinOpts)
 AI.BuiltinOptions = *Options.BuiltinOpts;
+  return checkDataflow(
+  std::move(AI),
+  /*VerifyResults=*/
+  [&Match](
+  const llvm::StringMap> &Results,
+  const AnalysisOutputs &AO) { Match(Results, AO.ASTCtx); });
+}
+
+template 
+void runDataflow(llvm::StringRef Code, Matcher Match,
+ DataflowAnalysisOptions Options,
+ LangStandard::Kind Std = LangStandard::lang_cxx17,
+ llvm::StringRef TargetFun = "target") {
   ASSERT_THAT_ERROR(
-  checkDataflow(
-  std::move(AI),
-  /*VerifyResults=*/
-  [&Match](const llvm::StringMap>
-   &Results,
-   const AnalysisOutputs &AO) { Match(Results, AO.ASTCtx); }),
+  runDataflowReturnError(Code, Match, Options, Std, TargetFun),
   llvm::Succeeded());
 }
 
@@ -2534,31 +2546,34 @@
   });
 }
 
-TEST(TransferTest, DerefDependentPtr) {
+TEST(TransferTest, CannotAnalyzeFunctionTemplate) {
   std::string Code = R"(
 template 
-void target(T *Foo) {
-  T &Bar = *Foo;
-  /*[[p]]*/
-}
+void target() {}
   )";
-  runDataflow(
-  Code,
-  [](const llvm::StringMap> &Results,
- ASTContext &ASTCtx) {
-ASSERT_THAT(Results.keys(), UnorderedElementsAre("p"));
-const Environment &Env = getEnvironmentAtAnnotation(Results, "p");
-
-const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo");
-ASSERT_THAT(FooDecl, NotNull());
-
-const ValueDecl *BarDecl = findValueDecl(ASTCtx, "Bar");
-ASSERT_THAT(BarDecl, NotNull());
+  ASSERT_THAT_ERROR(
+  runDataflowReturnError(
+  Code,
+  [](const llvm::StringMap> &Results,
+ ASTContext &ASTCtx) {},
+  {BuiltinOptions()}),
+  llvm::FailedWithMessage("Cannot analyze templated declarations"));
+}
 
-const auto *FooVal = cast(Env.getValue(*FooDecl));
-const auto *BarLoc = Env.getStorageLocation(*BarDecl);
-EXPECT_EQ(BarLoc, &FooVal->getPointeeLoc());
-  });
+TEST(TransferTest, CannotAnalyzeMethodOfClassTemplate) {
+  std::string Code = R"(
+template 
+struct A {
+  void target() {}
+};
+  )";
+  ASSERT_THAT_ERROR(
+  runDataflowReturnEr

[clang] b321738 - [clang][parser] Fix namespace dropping after malformed declarations

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

Author: Alejandro Álvarez Ayllón
Date: 2023-05-15T07:39:58-04:00
New Revision: b321738f71259d138c9b2002944eb65f099ec2a6

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

LOG: [clang][parser] Fix namespace dropping after malformed declarations

* After a malformed top-level declaration
* After a malformed templated class method declaration

In both cases, when there is a malformed declaration, any following
namespace is dropped from the AST. This can trigger a cascade of
confusing diagnostics that may hide the original error. An example:
```
// Start #include "SomeFile.h"
template 
void Foo::Bar(void* aRawPtr) {
(void)(aRawPtr);
}
// End #include "SomeFile.h"

int main() {}
```
We get the original error, plus 19 others from the standard library.
With this patch, we only get the original error.

clangd can also benefit from this patch, as namespaces following the
malformed declaration is now preserved. i.e.
```

MACRO_FROM_MISSING_INCLUDE("X")

namespace my_namespace {
//...
}
```
Before this patch, my_namespace is not visible for auto-completion.

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

Added: 
clang/test/Parser/cxx-namespace-after-missing-semicolon.cpp
clang/test/Parser/cxx-template-recovery.cpp

Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/Parse/ParseDecl.cpp
clang/lib/Parse/ParseTemplate.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index bb2178bfa5f96..00edb842ae715 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -449,6 +449,8 @@ Bug Fixes to C++ Support
 Bug Fixes to AST Handling
 ^
 
+- Preserve ``namespace`` definitions that follow malformed declarations.
+
 Miscellaneous Bug Fixes
 ^^^
 

diff  --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index 2bbe2ba82139d..92fa7d8a8a759 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -2176,13 +2176,16 @@ Parser::DeclGroupPtrTy 
Parser::ParseDeclGroup(ParsingDeclSpec &DS,
   return Actions.ConvertDeclToDeclGroup(TheDecl);
 }
 
-if (isDeclarationSpecifier(ImplicitTypenameContext::No)) {
-  // If there is an invalid declaration specifier right after the
-  // function prototype, then we must be in a missing semicolon case
-  // where this isn't actually a body.  Just fall through into the code
-  // that handles it as a prototype, and let the top-level code handle
-  // the erroneous declspec where it would otherwise expect a comma or
-  // semicolon.
+if (isDeclarationSpecifier(ImplicitTypenameContext::No) ||
+Tok.is(tok::kw_namespace)) {
+  // If there is an invalid declaration specifier or a namespace
+  // definition right after the function prototype, then we must be in 
a
+  // missing semicolon case where this isn't actually a body.  Just 
fall
+  // through into the code that handles it as a prototype, and let the
+  // top-level code handle the erroneous declspec where it would
+  // otherwise expect a comma or semicolon. Note that
+  // isDeclarationSpecifier already covers 'inline namespace', since
+  // 'inline' can be a declaration specifier.
 } else {
   Diag(Tok, diag::err_expected_fn_body);
   SkipUntil(tok::semi);
@@ -2303,10 +2306,8 @@ Parser::DeclGroupPtrTy 
Parser::ParseDeclGroup(ParsingDeclSpec &DS,
 // Okay, there was no semicolon and one was expected.  If we see a
 // declaration specifier, just assume it was missing and continue parsing.
 // Otherwise things are very confused and we skip to recover.
-if (!isDeclarationSpecifier(ImplicitTypenameContext::No)) {
-  SkipUntil(tok::r_brace, StopAtSemi | StopBeforeMatch);
-  TryConsumeToken(tok::semi);
-}
+if (!isDeclarationSpecifier(ImplicitTypenameContext::No))
+  SkipMalformedDecl();
   }
 
   return Actions.FinalizeDeclaratorGroup(getCurScope(), DS, DeclsInGroup);

diff  --git a/clang/lib/Parse/ParseTemplate.cpp 
b/clang/lib/Parse/ParseTemplate.cpp
index 72df117c123e6..964d985b6b6e6 100644
--- a/clang/lib/Parse/ParseTemplate.cpp
+++ b/clang/lib/Parse/ParseTemplate.cpp
@@ -275,10 +275,7 @@ Decl *Parser::ParseSingleDeclarationAfterTemplate(
 
   // Error parsing the declarator?
   if (!DeclaratorInfo.hasName()) {
-// If so, skip until the semi-colon or a }.
-SkipUntil(tok::r_brace, StopAtSemi | StopBeforeMatch);
-if (Tok.is(tok::semi))
-  ConsumeToken();
+SkipMalformedDecl();
 return nullptr;
   }
 

diff  --git a/clang/test/Parser/cxx-namespace-after-missing-semicolon.cpp 
b/clang/test/Parser/cxx-namespace-after-miss

[PATCH] D150258: [clang][parser] Fix namespace dropping after malformed declarations

2023-05-15 Thread Aaron Ballman via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb321738f7125: [clang][parser] Fix namespace dropping after 
malformed declarations (authored by alejandro-alvarez-sonarsource, committed by 
aaron.ballman).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150258

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseTemplate.cpp
  clang/test/Parser/cxx-namespace-after-missing-semicolon.cpp
  clang/test/Parser/cxx-template-recovery.cpp

Index: clang/test/Parser/cxx-template-recovery.cpp
===
--- /dev/null
+++ clang/test/Parser/cxx-template-recovery.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+template 
+void Foo::Bar(void* aRawPtr) { // expected-error {{no template named 'Foo'}}
+(void)(aRawPtr);
+}
+
+namespace baz {
+  class klass {};
+}
+
+int *variable = 0; // ok
+const baz::klass object; // ok
Index: clang/test/Parser/cxx-namespace-after-missing-semicolon.cpp
===
--- /dev/null
+++ clang/test/Parser/cxx-namespace-after-missing-semicolon.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+UNKNOWN_MACRO_1("z", 1) // expected-error {{a type specifier is required for all declarations}}
+// expected-error@-1 {{expected ';' after top level declarator}}
+
+namespace foo {
+  class bar {};
+}
+
+int variable = 0; // ok
+foo::bar something; // ok
+
+UNKNOWN_MACRO_2(void) // expected-error {{a type specifier is required for all declarations}}
+// expected-error@-1 {{expected ';' after top level declarator}}
+
+namespace baz {
+  using Bool = bool;
+}
+
+int variable2 = 2; // ok
+const baz::Bool flag = false;  // ok
Index: clang/lib/Parse/ParseTemplate.cpp
===
--- clang/lib/Parse/ParseTemplate.cpp
+++ clang/lib/Parse/ParseTemplate.cpp
@@ -275,10 +275,7 @@
 
   // Error parsing the declarator?
   if (!DeclaratorInfo.hasName()) {
-// If so, skip until the semi-colon or a }.
-SkipUntil(tok::r_brace, StopAtSemi | StopBeforeMatch);
-if (Tok.is(tok::semi))
-  ConsumeToken();
+SkipMalformedDecl();
 return nullptr;
   }
 
Index: clang/lib/Parse/ParseDecl.cpp
===
--- clang/lib/Parse/ParseDecl.cpp
+++ clang/lib/Parse/ParseDecl.cpp
@@ -2176,13 +2176,16 @@
   return Actions.ConvertDeclToDeclGroup(TheDecl);
 }
 
-if (isDeclarationSpecifier(ImplicitTypenameContext::No)) {
-  // If there is an invalid declaration specifier right after the
-  // function prototype, then we must be in a missing semicolon case
-  // where this isn't actually a body.  Just fall through into the code
-  // that handles it as a prototype, and let the top-level code handle
-  // the erroneous declspec where it would otherwise expect a comma or
-  // semicolon.
+if (isDeclarationSpecifier(ImplicitTypenameContext::No) ||
+Tok.is(tok::kw_namespace)) {
+  // If there is an invalid declaration specifier or a namespace
+  // definition right after the function prototype, then we must be in a
+  // missing semicolon case where this isn't actually a body.  Just fall
+  // through into the code that handles it as a prototype, and let the
+  // top-level code handle the erroneous declspec where it would
+  // otherwise expect a comma or semicolon. Note that
+  // isDeclarationSpecifier already covers 'inline namespace', since
+  // 'inline' can be a declaration specifier.
 } else {
   Diag(Tok, diag::err_expected_fn_body);
   SkipUntil(tok::semi);
@@ -2303,10 +2306,8 @@
 // Okay, there was no semicolon and one was expected.  If we see a
 // declaration specifier, just assume it was missing and continue parsing.
 // Otherwise things are very confused and we skip to recover.
-if (!isDeclarationSpecifier(ImplicitTypenameContext::No)) {
-  SkipUntil(tok::r_brace, StopAtSemi | StopBeforeMatch);
-  TryConsumeToken(tok::semi);
-}
+if (!isDeclarationSpecifier(ImplicitTypenameContext::No))
+  SkipMalformedDecl();
   }
 
   return Actions.FinalizeDeclaratorGroup(getCurScope(), DS, DeclsInGroup);
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -449,6 +449,8 @@
 Bug Fixes to AST Handling
 ^
 
+- Preserve ``namespace`` definitions that follow malformed declarations.
+
 Miscellaneous Bug Fixes
 ^^^
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/

[PATCH] D149997: [clang] [test] Narrow down MSVC specific behaviours from "any windows" to only MSVC/clang-cl

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

In D149997#4338897 , @mstorsjo wrote:

> Updated to check for `defined(_WIN32) && !defined(__MINGW32__)`. It's a kinda 
> ugly way of checking for an MSVC-like environment specifically (when the MSVC 
> mode is the exception compared with the rest), but neither `_MSC_VER` or 
> `_MSC_EXTENSIONS` are defined by default in a `clang -cc1` invocation.

This seems like forward progress to me, so LG!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149997

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


[PATCH] D149276: [Clang] Fix parsing of `(auto(x))`.

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

In D149276#4341552 , @cor3ntin wrote:

> @aaron.ballman this won;t get approve by core un
>
> In D149276#4302700 , @aaron.ballman 
> wrote:
>
>> The changes generally LGTM, but:
>>
>>> in a way consistent with the proposed resolution to CWG1223.
>>
>> What are the chances that CWG changes their mind and picks a different 
>> direction?
>
> They were happy with the direction friday when we looked at it ( not the 
> wording though). I think we should go ahead, waiting until after issaquah 
> might be a bit too late (and if we are claiming auto(x) is implemented we 
> should merge that in 17)

We don't have to wait for the wording to be final so long as the direction is 
in line with what you've done here, so LGTM! Thank you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149276

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


[PATCH] D143984: [DebugMetadata] Simplify handling subprogram's retainedNodes field. NFCI (1/7)

2023-05-15 Thread Vladislav Dzhidzhoev via Phabricator via cfe-commits
dzhidzhoev commandeered this revision.
dzhidzhoev added a reviewer: krisb.
dzhidzhoev added a comment.

@krisb is out of office for some time, so she asked to retake and wrap up this 
patchset.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143984

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


[PATCH] D144004: [DebugMetadata][DwarfDebug] Fix DWARF emisson of function-local imported entities (3/7)

2023-05-15 Thread Vladislav Dzhidzhoev via Phabricator via cfe-commits
dzhidzhoev commandeered this revision.
dzhidzhoev added a reviewer: krisb.
dzhidzhoev added a comment.

See https://reviews.llvm.org/D143984#4341780


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144004

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


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

2023-05-15 Thread Vladislav Dzhidzhoev via Phabricator via cfe-commits
dzhidzhoev commandeered this revision.
dzhidzhoev added a reviewer: krisb.
dzhidzhoev added a comment.

See https://reviews.llvm.org/D143984#4341780


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144006

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


[clang-tools-extra] d0e8911 - [clangd] Fix fixAll not shown when there is only one unused-include and missing-include diagnostics.

2023-05-15 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2023-05-15T14:02:20+02:00
New Revision: d0e89116aff224ac2d8d3f88029ae44e12c9b6cc

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

LOG: [clangd] Fix fixAll not shown when there is only one unused-include and 
missing-include diagnostics.

Discovered during the review in https://reviews.llvm.org/D149437#inline-1444851.

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

Added: 


Modified: 
clang-tools-extra/clangd/IncludeCleaner.cpp
clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/IncludeCleaner.cpp 
b/clang-tools-extra/clangd/IncludeCleaner.cpp
index 3b913d851abe2..22d0808235f7f 100644
--- a/clang-tools-extra/clangd/IncludeCleaner.cpp
+++ b/clang-tools-extra/clangd/IncludeCleaner.cpp
@@ -440,8 +440,9 @@ IncludeCleanerFindings 
computeIncludeCleanerFindings(ParsedAST &AST) {
   return {std::move(UnusedIncludes), std::move(MissingIncludes)};
 }
 
-Fix removeAllUnusedIncludes(llvm::ArrayRef UnusedIncludes) {
-  assert(!UnusedIncludes.empty());
+std::optional removeAllUnusedIncludes(llvm::ArrayRef 
UnusedIncludes) {
+  if (UnusedIncludes.empty())
+return std::nullopt;
 
   Fix RemoveAll;
   RemoveAll.Message = "remove all unused includes";
@@ -465,8 +466,10 @@ Fix removeAllUnusedIncludes(llvm::ArrayRef 
UnusedIncludes) {
   }
   return RemoveAll;
 }
-Fix addAllMissingIncludes(llvm::ArrayRef MissingIncludeDiags) {
-  assert(!MissingIncludeDiags.empty());
+std::optional
+addAllMissingIncludes(llvm::ArrayRef MissingIncludeDiags) {
+  if (MissingIncludeDiags.empty())
+return std::nullopt;
 
   Fix AddAllMissing;
   AddAllMissing.Message = "add all missing includes";
@@ -516,15 +519,11 @@ std::vector generateIncludeCleanerDiagnostic(
 llvm::StringRef Code) {
   std::vector UnusedIncludes = generateUnusedIncludeDiagnostics(
   AST.tuPath(), Findings.UnusedIncludes, Code);
-  std::optional RemoveAllUnused;;
-  if (UnusedIncludes.size() > 1)
-RemoveAllUnused = removeAllUnusedIncludes(UnusedIncludes);
+  std::optional RemoveAllUnused = removeAllUnusedIncludes(UnusedIncludes);
 
   std::vector MissingIncludeDiags = generateMissingIncludeDiagnostics(
   AST, Findings.MissingIncludes, Code);
-  std::optional AddAllMissing;
-  if (MissingIncludeDiags.size() > 1)
-AddAllMissing = addAllMissingIncludes(MissingIncludeDiags);
+  std::optional AddAllMissing = 
addAllMissingIncludes(MissingIncludeDiags);
 
   std::optional FixAll;
   if (RemoveAllUnused && AddAllMissing)
@@ -535,11 +534,16 @@ std::vector generateIncludeCleanerDiagnostic(
 Out->Fixes.push_back(*F);
   };
   for (auto &Diag : MissingIncludeDiags) {
-AddBatchFix(AddAllMissing, &Diag);
+AddBatchFix(MissingIncludeDiags.size() > 1
+? AddAllMissing
+: std::nullopt,
+&Diag);
 AddBatchFix(FixAll, &Diag);
   }
   for (auto &Diag : UnusedIncludes) {
-AddBatchFix(RemoveAllUnused, &Diag);
+AddBatchFix(UnusedIncludes.size() > 1 ? RemoveAllUnused
+  : std::nullopt,
+&Diag);
 AddBatchFix(FixAll, &Diag);
   }
 

diff  --git a/clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp 
b/clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
index a38c01b43270f..c0831c2693c97 100644
--- a/clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
+++ b/clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
@@ -197,10 +197,10 @@ TEST(IncludeCleaner, GenerateMissingHeaderDiags) {
 
 ns::$bar[[Bar]] bar;
 bar.d();
-$f[[f]](); 
+$f[[f]]();
 
 // this should not be diagnosed, because it's ignored in the config
-buzz(); 
+buzz();
 
 $foobar[[foobar]]();
 
@@ -244,7 +244,7 @@ TEST(IncludeCleaner, GenerateMissingHeaderDiags) {
   TU.AdditionalFiles["foo.h"] = guard(R"cpp(
 #define BAR(x) Foo *x
 #define FOO 1
-struct Foo{}; 
+struct Foo{};
   )cpp");
 
   TU.Code = MainFile.code();
@@ -510,6 +510,71 @@ TEST(IncludeCleaner, FirstMatchedProvider) {
   }
 }
 
+TEST(IncludeCleaner, BatchFix) {
+  Config Cfg;
+  Cfg.Diagnostics.MissingIncludes = Config::IncludesPolicy::Strict;
+  Cfg.Diagnostics.UnusedIncludes = Config::IncludesPolicy::Strict;
+  WithContextValue Ctx(Config::Key, std::move(Cfg));
+
+  TestTU TU;
+  TU.Filename = "main.cpp";
+  TU.AdditionalFiles["foo.h"] = guard("class Foo;");
+  TU.AdditionalFiles["bar.h"] = guard("class Bar;");
+  TU.AdditionalFiles["all.h"] = guard(R"cpp(
+#include "foo.h"
+#include "bar.h"
+  )cpp");
+
+  TU.Code = R"cpp(
+  #include "all.h"
+
+  Foo* foo;
+  )cpp";
+  auto AST = TU.build();
+  EXPECT_THAT(
+  issueIncludeCleanerDiagnostics(AST, TU.Code),
+  UnorderedElementsAre(withFix({FixMe

[PATCH] D149822: [clangd] Fix fixAll not shown when there is only one unused-include and missing-include diagnostics.

2023-05-15 Thread Haojian Wu via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd0e89116aff2: [clangd] Fix fixAll not shown when there is 
only one unused-include and missing… (authored by hokein).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149822

Files:
  clang-tools-extra/clangd/IncludeCleaner.cpp
  clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp

Index: clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
===
--- clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
+++ clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
@@ -197,10 +197,10 @@
 
 ns::$bar[[Bar]] bar;
 bar.d();
-$f[[f]](); 
+$f[[f]]();
 
 // this should not be diagnosed, because it's ignored in the config
-buzz(); 
+buzz();
 
 $foobar[[foobar]]();
 
@@ -244,7 +244,7 @@
   TU.AdditionalFiles["foo.h"] = guard(R"cpp(
 #define BAR(x) Foo *x
 #define FOO 1
-struct Foo{}; 
+struct Foo{};
   )cpp");
 
   TU.Code = MainFile.code();
@@ -510,6 +510,71 @@
   }
 }
 
+TEST(IncludeCleaner, BatchFix) {
+  Config Cfg;
+  Cfg.Diagnostics.MissingIncludes = Config::IncludesPolicy::Strict;
+  Cfg.Diagnostics.UnusedIncludes = Config::IncludesPolicy::Strict;
+  WithContextValue Ctx(Config::Key, std::move(Cfg));
+
+  TestTU TU;
+  TU.Filename = "main.cpp";
+  TU.AdditionalFiles["foo.h"] = guard("class Foo;");
+  TU.AdditionalFiles["bar.h"] = guard("class Bar;");
+  TU.AdditionalFiles["all.h"] = guard(R"cpp(
+#include "foo.h"
+#include "bar.h"
+  )cpp");
+
+  TU.Code = R"cpp(
+  #include "all.h"
+
+  Foo* foo;
+  )cpp";
+  auto AST = TU.build();
+  EXPECT_THAT(
+  issueIncludeCleanerDiagnostics(AST, TU.Code),
+  UnorderedElementsAre(withFix({FixMessage("#include \"foo.h\""),
+FixMessage("fix all includes")}),
+   withFix({FixMessage("remove #include directive"),
+FixMessage("fix all includes")})));
+
+  TU.Code = R"cpp(
+  #include "all.h"
+  #include "bar.h"
+
+  Foo* foo;
+  )cpp";
+  AST = TU.build();
+  EXPECT_THAT(
+  issueIncludeCleanerDiagnostics(AST, TU.Code),
+  UnorderedElementsAre(withFix({FixMessage("#include \"foo.h\""),
+FixMessage("fix all includes")}),
+   withFix({FixMessage("remove #include directive"),
+FixMessage("remove all unused includes"),
+FixMessage("fix all includes")}),
+   withFix({FixMessage("remove #include directive"),
+   FixMessage("remove all unused includes"),
+FixMessage("fix all includes")})));
+
+  TU.Code = R"cpp(
+  #include "all.h"
+
+  Foo* foo;
+  Bar* bar;
+  )cpp";
+  AST = TU.build();
+  EXPECT_THAT(
+  issueIncludeCleanerDiagnostics(AST, TU.Code),
+  UnorderedElementsAre(withFix({FixMessage("#include \"foo.h\""),
+FixMessage("add all missing includes"),
+FixMessage("fix all includes")}),
+   withFix({FixMessage("#include \"bar.h\""),
+FixMessage("add all missing includes"),
+FixMessage("fix all includes")}),
+   withFix({FixMessage("remove #include directive"),
+FixMessage("fix all includes")})));
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/IncludeCleaner.cpp
===
--- clang-tools-extra/clangd/IncludeCleaner.cpp
+++ clang-tools-extra/clangd/IncludeCleaner.cpp
@@ -440,8 +440,9 @@
   return {std::move(UnusedIncludes), std::move(MissingIncludes)};
 }
 
-Fix removeAllUnusedIncludes(llvm::ArrayRef UnusedIncludes) {
-  assert(!UnusedIncludes.empty());
+std::optional removeAllUnusedIncludes(llvm::ArrayRef UnusedIncludes) {
+  if (UnusedIncludes.empty())
+return std::nullopt;
 
   Fix RemoveAll;
   RemoveAll.Message = "remove all unused includes";
@@ -465,8 +466,10 @@
   }
   return RemoveAll;
 }
-Fix addAllMissingIncludes(llvm::ArrayRef MissingIncludeDiags) {
-  assert(!MissingIncludeDiags.empty());
+std::optional
+addAllMissingIncludes(llvm::ArrayRef MissingIncludeDiags) {
+  if (MissingIncludeDiags.empty())
+return std::nullopt;
 
   Fix AddAllMissing;
   AddAllMissing.Message = "add all missing includes";
@@ -516,15 +519,11 @@
 llvm::StringRef Code) {
   std::vector UnusedIncludes = generateUnusedIncludeDiagnostics(
   AST.tuPath(), Findings.UnusedIncludes, Code);
-  std::optional RemoveAllUnused;;
-  if (UnusedIncludes.size(

[PATCH] D150450: Add C++26 compile flags.

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



Comment at: clang/docs/CommandGuide/clang.rst:206-210
+   Working draft for ISO C++ 2026
+
+  | ``gnu++2c``
+
+   Working draft for ISO C++ 2026 with GNU extensions

We shouldn't call it `ISO C++ 2026` until it's published by ISO. (I don't have 
strong opinions about 2c vs 26 in there, but since we need to update it anyway 
when 26 is released, I figured it'd be easier to find again with 2c.)



Comment at: clang/docs/ReleaseNotes.rst:114
+^
+- Compiler flags -std=c++2c and -std=gnu++2c have been added for experimental 
C++2c implementation work.
+





Comment at: clang/include/clang/Basic/DiagnosticGroups.td:1120
+// earlier C++ versions.
+def CXX26 : DiagGroup<"c++26-extensions">;
+

Same here as above.



Comment at: clang/include/clang/Basic/DiagnosticGroups.td:310
   DiagGroup<"pre-c++23-compat-pedantic", [CXXPre23Compat]>;
+def CXXPre26Compat : DiagGroup<"pre-c++26-compat">;
+def CXXPre26CompatPedantic :

erichkeane wrote:
> Aaron: note the names of the diag groups: would you prefer this to be `c++2c`?
Let's go ahead and add the alias so that either c++2c or c++26 works.



Comment at: clang/include/clang/Basic/LangOptions.def:101
 LANGOPT(CPlusPlus23   , 1, 0, "C++23")
+LANGOPT(CPlusPlus26   , 1, 0, "C++26")
 LANGOPT(ObjC  , 1, 0, "Objective-C")

erichkeane wrote:
> It isn't clear to me what the string here is used to output, so not sure if 
> this should be 2c.
The only place this matters is when dumping information about a module file for 
debugging purposes, so I don't think it's critical this be named 2c.



Comment at: clang/include/clang/Basic/LangStandard.h:128
+
+  // hasDigraphs - Language supports digraphs.
   bool hasDigraphs() const { return Flags & Digraphs; }

h-vetinari wrote:
> Spuriously removed slash




Comment at: clang/include/clang/Basic/LangStandards.def:167
+LANGSTANDARD(cxx26, "c++2c",
+ CXX, "Working draft for ISO C++ 2026 DIS",
+ LineComment | CPlusPlus | CPlusPlus11 | CPlusPlus14 | CPlusPlus17 
|

We should probably drop `ISO` from this as we did above?



Comment at: clang/lib/Frontend/InitPreprocessor.cpp:456
+  // FIXME: Use correct value for C++26.
+  Builder.defineMacro("__cplusplus", "202402L");
+else if (LangOpts.CPlusPlus23)

This value is fine by me, but we should probably coordinate with the GCC folks 
so we don't wind up with two different values between us.



Comment at: clang/lib/Frontend/InitPreprocessor.cpp:458
+else if (LangOpts.CPlusPlus23)
+  Builder.defineMacro("__cplusplus", "202302L");
 //  [C++20] The integer literal 202002L.

xbolva00 wrote:
> Separate patch / commit?
Agreed, the change for C++23 should be done in a separate patch.



Comment at: clang/www/OpenProjects.html:126
 
-Continue work on C++20, C++23, and C2x support:
+Continue work on C++20, C++23, C++26, and C2x support:
   There are still several C++20 features to complete, and work has begun on

cor3ntin wrote:
> erichkeane wrote:
> > Should this spot in the docs be `C++2c`?
> I think so
Agreed -- basically, if it's user-facing, it should be 2c, and if it's internal 
to the project, it should be 26.



Comment at: clang/www/cxx_status.html:1568
 
+C++2c implementation status
+

cor3ntin wrote:
> h-vetinari wrote:
> > The longer this page gets, the more I feel it should be sorted in reverse 
> > chronological order of the standard versions. It's bothersome IMO to keep 
> > scrolling past almost-fully implemented standards (currently the tables for 
> > C++17 & C++20) before getting to see the status of the latest & greatest. 
> > 
> > https://en.cppreference.com/w/cpp/compiler_support is sorted in reverse 
> > order as well.
> This sounds like an excellent improvement.
> Erich, would you rather do that in this pr, or i can submit a different patch 
> afterwards?
I love the idea, and I think it should be done in a separate patch.


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

https://reviews.llvm.org/D150450

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


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

2023-05-15 Thread Qiongsi Wu via Phabricator via cfe-commits
qiongsiwu1 updated this revision to Diff 522132.
qiongsiwu1 added a comment.

Thanks so much @hubert.reinterpretcast !! The comments are addressed. I will 
land the patch when the pre-commit CI finishes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144190

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

Index: clang/test/Driver/ppc-roptr.c
===
--- /dev/null
+++ clang/test/Driver/ppc-roptr.c
@@ -0,0 +1,46 @@
+// RUN: %clang -### --target=powerpc-ibm-aix-xcoff -mxcoff-roptr %s 2>&1 | \
+// RUN: FileCheck %s --check-prefixes=ROPTR,LINK
+// RUN: %clang -### --target=powerpc-ibm-aix-xcoff -c -mxcoff-roptr %s 2>&1 | \
+// RUN: FileCheck %s --check-prefix=ROPTR
+// RUN: %clang -### --target=powerpc-ibm-aix-xcoff -mxcoff-roptr -mno-xcoff-roptr %s 2>&1 | \
+// RUN: FileCheck %s --check-prefix=NO_ROPTR
+
+// RUN: %clang -### --target=powerpc64-ibm-aix-xcoff -mxcoff-roptr %s 2>&1 | \
+// RUN: FileCheck %s --check-prefixes=ROPTR,LINK
+// RUN: %clang -### --target=powerpc64-ibm-aix-xcoff -S -mxcoff-roptr %s 2>&1 | \
+// RUN: FileCheck %s --check-prefix=ROPTR
+// RUN: %clang -### --target=powerpc-ibm-aix-xcoff %s 2>&1 | \
+// RUN: FileCheck %s --check-prefix=NO_ROPTR
+// RUN: %clang -### --target=powerpc64-ibm-aix-xcoff -mxcoff-roptr -flto %s 2>&1 | \
+// RUN: FileCheck %s --check-prefixes=ROPTR,LINK,LTO_ROPTR
+// RUN: touch %t.o
+// RUN: %clang -### --target=powerpc64-ibm-aix-xcoff -mxcoff-roptr %t.o 2>&1 | \
+// RUN: FileCheck %s --check-prefix=LINK
+
+// RUN: %clang -### --target=powerpc64le-unknown-linux-gnu -mxcoff-roptr \
+// RUN: %s 2>&1 | FileCheck %s --check-prefix=TARGET_ROPTR_ERR
+// RUN: %clang -### --target=powerpc64le-unknown-linux-gnu -mno-xcoff-roptr \
+// RUN: %s 2>&1 | FileCheck %s --check-prefix=TARGET_NOROPTR_ERR
+// RUN: touch %t.o
+// RUN: %clang -### --target=powerpc64-ibm-aix-xcoff -mxcoff-roptr -shared \
+// RUN: %t.o 2>&1 | FileCheck %s --check-prefix=SHARED_ERR
+// RUN: %clang -### --target=powerpc64le-unknown-linux-gnu -mxcoff-roptr -flto \
+// RUN: %t.o 2>&1 | FileCheck %s --check-prefix=TARGET_ROPTR_ERR
+// RUN: %clang -### --target=powerpc64-ibm-aix-xcoff -mxcoff-roptr -flto -fno-data-sections \
+// RUN: %t.o 2>&1 | FileCheck %s --check-prefix=DATA_SECTION_ERR
+// RUN: %clang -### --target=powerpc64-ibm-aix-xcoff -mno-xcoff-roptr -flto -fno-data-sections \
+// RUN: %t.o 2>&1 | FileCheck %s --check-prefix=NO_DATA_SECTION_ERR
+// RUN: %clang -### --target=powerpc64le-unknown-linux-gnu -mno-xcoff-roptr -flto \
+// RUN: %t.o 2>&1 | FileCheck %s --check-prefix=TARGET_NOROPTR_ERR
+
+// ROPTR: "-mxcoff-roptr"
+// LINK: "-bforceimprw"
+// LTO_ROPTR: "-bplugin_opt:-mxcoff-roptr"
+// NO_ROPTR-NOT: "-mxcoff-roptr"
+// NO_ROPTR-NOT: "-bforceimprw"
+
+// DATA_SECTION_ERR: error: -mxcoff-roptr is supported only with -fdata-sections
+// NO_DATA_SECTION_ERR-NOT: error: -mxcoff-roptr is supported only with -fdata-sections
+// TARGET_ROPTR_ERR: error: unsupported option '-mxcoff-roptr' for target 'powerpc64le-unknown-linux-gnu'
+// TARGET_NOROPTR_ERR: error: unsupported option '-mno-xcoff-roptr' for target 'powerpc64le-unknown-linux-gnu'
+// SHARED_ERR: error: -mxcoff-roptr is not supported with -shared
Index: clang/test/CodeGen/PowerPC/aix-roptr.c
===
--- /dev/null
+++ clang/test/CodeGen/PowerPC/aix-roptr.c
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -triple=powerpc-ibm-aix-xcoff -mxcoff-roptr -fdata-sections \
+// RUN: -S <%s | FileCheck %s --check-prefix=CHECK32
+// RUN: %clang_cc1 -triple=powerpc64-ibm-aix-xcoff -mxcoff-roptr -fdata-sections \
+// RUN: -S <%s | FileCheck %s --check-prefix=CHECK64
+// RUN: not %clang_cc1 -triple=powerpc-ibm-aix-xcoff -mxcoff-roptr \
+// RUN: -S <%s 2>&1 | FileCheck %s --check-prefix=DATA_SECTION_ERR
+// RUN: not %clang_cc1 -triple=powerpc64-ibm-aix-xcoff -mxcoff-roptr \
+// RUN: -S <%s 2>&1 | FileCheck %s --check-prefix=DATA_SECTION_ERR
+// RUN: not %clang_cc1 -triple=powerpc64le-unknown-linux-gnu -mxcoff-roptr \
+// RUN: %s 2>&1 | FileCheck %s --check-prefix=TARGET_ROPTR_ERR
+
+char c1 = 10;
+char* const c1_ptr = &c1;
+// CHECK32: .csect c1_ptr[RO],2
+// CHECK32-NEXT:	.globl	c1_ptr[RO]
+// CHECK32-NEXT:	.align	2
+// CHECK32-NEXT:	.vbyte	4, c1[RW]
+
+// CHECK64: .csect c1_ptr[RO],3
+// CHECK64-NEXT:	.globl	c1_ptr[RO]
+// CHECK64-NEXT:	.align	3
+// CHECK64-NEXT:	.vbyte	8, c

[PATCH] D143984: [DebugMetadata] Simplify handling subprogram's retainedNodes field. NFCI (1/7)

2023-05-15 Thread Vladislav Dzhidzhoev via Phabricator via cfe-commits
dzhidzhoev updated this revision to Diff 522136.
dzhidzhoev added a comment.

Rebased.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143984

Files:
  clang/test/CodeGen/attr-btf_tag-disubprogram-callsite.c
  clang/test/CodeGenCXX/aix-static-init-debug-info.cpp
  clang/test/CodeGenCXX/debug-info-cxx1y.cpp
  clang/test/CodeGenCXX/debug-info-template.cpp
  clang/test/CodeGenObjC/debug-info-category.m
  llvm/include/llvm/IR/DIBuilder.h
  llvm/include/llvm/IR/DebugInfoMetadata.h
  llvm/lib/IR/DIBuilder.cpp

Index: llvm/lib/IR/DIBuilder.cpp
===
--- llvm/lib/IR/DIBuilder.cpp
+++ llvm/lib/IR/DIBuilder.cpp
@@ -52,23 +52,11 @@
 }
 
 void DIBuilder::finalizeSubprogram(DISubprogram *SP) {
-  MDTuple *Temp = SP->getRetainedNodes().get();
-  if (!Temp || !Temp->isTemporary())
-return;
-
-  SmallVector RetainedNodes;
-
-  auto PV = PreservedVariables.find(SP);
-  if (PV != PreservedVariables.end())
-RetainedNodes.append(PV->second.begin(), PV->second.end());
-
-  auto PL = PreservedLabels.find(SP);
-  if (PL != PreservedLabels.end())
-RetainedNodes.append(PL->second.begin(), PL->second.end());
-
-  DINodeArray Node = getOrCreateArray(RetainedNodes);
-
-  TempMDTuple(Temp)->replaceAllUsesWith(Node.get());
+  auto PN = SubprogramTrackedNodes.find(SP);
+  if (PN != SubprogramTrackedNodes.end())
+SP->replaceRetainedNodes(
+MDTuple::get(VMContext, SmallVector(PN->second.begin(),
+PN->second.end(;
 }
 
 void DIBuilder::finalize() {
@@ -766,26 +754,20 @@
 
 static DILocalVariable *createLocalVariable(
 LLVMContext &VMContext,
-DenseMap> &PreservedVariables,
-DIScope *Scope, StringRef Name, unsigned ArgNo, DIFile *File,
+SmallVectorImpl &PreservedNodes,
+DIScope *Context, StringRef Name, unsigned ArgNo, DIFile *File,
 unsigned LineNo, DIType *Ty, bool AlwaysPreserve, DINode::DIFlags Flags,
 uint32_t AlignInBits, DINodeArray Annotations = nullptr) {
-  // FIXME: Why getNonCompileUnitScope()?
-  // FIXME: Why is "!Context" okay here?
   // FIXME: Why doesn't this check for a subprogram or lexical block (AFAICT
   // the only valid scopes)?
-  DIScope *Context = getNonCompileUnitScope(Scope);
-
-  auto *Node = DILocalVariable::get(
-  VMContext, cast_or_null(Context), Name, File, LineNo, Ty,
-  ArgNo, Flags, AlignInBits, Annotations);
+  auto *Scope = cast(Context);
+  auto *Node = DILocalVariable::get(VMContext, Scope, Name, File, LineNo, Ty,
+ArgNo, Flags, AlignInBits, Annotations);
   if (AlwaysPreserve) {
 // The optimizer may remove local variables. If there is an interest
 // to preserve variable info in such situation then stash it in a
 // named mdnode.
-DISubprogram *Fn = getDISubprogram(Scope);
-assert(Fn && "Missing subprogram for local variable");
-PreservedVariables[Fn].emplace_back(Node);
+PreservedNodes.emplace_back(Node);
   }
   return Node;
 }
@@ -795,9 +777,11 @@
DIType *Ty, bool AlwaysPreserve,
DINode::DIFlags Flags,
uint32_t AlignInBits) {
-  return createLocalVariable(VMContext, PreservedVariables, Scope, Name,
- /* ArgNo */ 0, File, LineNo, Ty, AlwaysPreserve,
- Flags, AlignInBits);
+  assert(Scope && isa(Scope) &&
+ "Unexpected scope for a local variable.");
+  return createLocalVariable(
+  VMContext, getSubprogramNodesTrackingVector(Scope), Scope, Name,
+  /* ArgNo */ 0, File, LineNo, Ty, AlwaysPreserve, Flags, AlignInBits);
 }
 
 DILocalVariable *DIBuilder::createParameterVariable(
@@ -805,25 +789,23 @@
 unsigned LineNo, DIType *Ty, bool AlwaysPreserve, DINode::DIFlags Flags,
 DINodeArray Annotations) {
   assert(ArgNo && "Expected non-zero argument number for parameter");
-  return createLocalVariable(VMContext, PreservedVariables, Scope, Name, ArgNo,
- File, LineNo, Ty, AlwaysPreserve, Flags,
- /*AlignInBits=*/0, Annotations);
+  assert(Scope && isa(Scope) &&
+ "Unexpected scope for a local variable.");
+  return createLocalVariable(
+  VMContext, getSubprogramNodesTrackingVector(Scope), Scope, Name, ArgNo,
+  File, LineNo, Ty, AlwaysPreserve, Flags, /*AlignInBits=*/0, Annotations);
 }
 
-DILabel *DIBuilder::createLabel(DIScope *Scope, StringRef Name, DIFile *File,
-unsigned LineNo, bool AlwaysPreserve) {
-  DIScope *Context = getNonCompileUnitScope(Scope);
-
-  auto *Node = DILabel::get(VMContext, cast_or_null(Context),
-Name, File, LineNo);
+DILabel *DIBuilder::createLabel(DIScope *Context, StringRef Name, DIFile *File

[PATCH] D144004: [DebugMetadata][DwarfDebug] Fix DWARF emisson of function-local imported entities (3/7)

2023-05-15 Thread Vladislav Dzhidzhoev via Phabricator via cfe-commits
dzhidzhoev updated this revision to Diff 522138.
dzhidzhoev added a comment.

Rebased.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144004

Files:
  clang/test/CodeGenCXX/debug-info-namespace.cpp
  llvm/include/llvm/IR/DIBuilder.h
  llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
  llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h
  llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
  llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h
  llvm/lib/CodeGen/AsmPrinter/DwarfFile.h
  llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
  llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h
  llvm/lib/IR/DIBuilder.cpp
  llvm/lib/IR/Verifier.cpp
  llvm/lib/Linker/IRMover.cpp
  llvm/test/CodeGen/Generic/DbgValueAggregate.ll
  llvm/test/DebugInfo/Generic/import-inlined-declaration.ll
  llvm/test/DebugInfo/Generic/imported-name-inlined.ll
  llvm/test/DebugInfo/Generic/namespace.ll
  llvm/test/DebugInfo/Generic/split-dwarf-local-import.ll
  llvm/test/DebugInfo/Generic/split-dwarf-local-import2.ll
  llvm/test/DebugInfo/Generic/split-dwarf-local-import3.ll
  llvm/test/DebugInfo/Generic/verifier-invalid-disubprogram.ll
  llvm/test/DebugInfo/X86/dimodule-external-fortran.ll
  llvm/test/DebugInfo/X86/dwarfdump-DIImportedEntity_elements.ll
  llvm/test/DebugInfo/X86/fission-inline.ll
  llvm/test/DebugInfo/X86/fission-local-import.ll
  llvm/test/DebugInfo/X86/fission-no-inline-gsym.ll
  llvm/test/DebugInfo/X86/lexical-block-file-inline.ll
  llvm/test/DebugInfo/X86/namelist2.ll
  llvm/test/DebugInfo/omit-empty.ll
  llvm/test/ThinLTO/X86/debuginfo-cu-import.ll

Index: llvm/test/ThinLTO/X86/debuginfo-cu-import.ll
===
--- llvm/test/ThinLTO/X86/debuginfo-cu-import.ll
+++ llvm/test/ThinLTO/X86/debuginfo-cu-import.ll
@@ -5,15 +5,13 @@
 ; RUN: opt -module-summary %p/Inputs/debuginfo-cu-import.ll -o %t2.bc
 ; RUN: llvm-lto -thinlto-action=thinlink -o %t.index.bc %t1.bc %t2.bc
 
-; Don't import enums, macros, retainedTypes or globals lists.
-; Only import local scope imported entities.
+; Don't import enums, macros, retainedTypes, globals or imports lists.
 ; RUN: llvm-lto -thinlto-action=import %t2.bc -thinlto-index=%t.index.bc -o - | llvm-dis -o - | FileCheck %s
 ; CHECK-NOT: DICompileUnit{{.*}} enums:
 ; CHECK-NOT: DICompileUnit{{.*}} macros:
 ; CHECK-NOT: DICompileUnit{{.*}} retainedTypes:
 ; CHECK-NOT: DICompileUnit{{.*}} globals:
-; CHECK: DICompileUnit{{.*}} imports: ![[IMP:[0-9]+]]
-; CHECK: ![[IMP]] = !{!{{[0-9]+}}}
+; CHECK-NOT: DICompileUnit{{.*}} imports:
 
 ; ModuleID = 'debuginfo-cu-import.c'
 source_filename = "debuginfo-cu-import.c"
@@ -50,14 +48,14 @@
 !8 = !{!9}
 !9 = !DIGlobalVariableExpression(var: !10, expr: !DIExpression())
 !10 = !DIGlobalVariable(name: "version", scope: !4, file: !1, line: 2, type: !7, isLocal: false, isDefinition: true)
-!11 = !{!12, !16}
+!11 = !{!12}
 !12 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !4, entity: !13, file: !1, line: 8)
 !13 = distinct !DISubprogram(name: "a", linkageName: "_ZN1A1aEv", scope: !4, file: !1, line: 7, type: !14, isLocal: false, isDefinition: true, scopeLine: 7, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !5)
 !14 = !DISubroutineType(types: !15)
 !15 = !{null}
 !16 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !17, entity: !19, file: !1, line: 8)
 !17 = distinct !DILexicalBlock(scope: !18, file: !1, line: 9, column: 8)
-!18 = distinct !DISubprogram(name: "c", linkageName: "_ZN1A1cEv", scope: !4, file: !1, line: 9, type: !14, isLocal: false, isDefinition: true, scopeLine: 8, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !5)
+!18 = distinct !DISubprogram(name: "c", linkageName: "_ZN1A1cEv", scope: !4, file: !1, line: 9, type: !14, isLocal: false, isDefinition: true, scopeLine: 8, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !33)
 !19 = distinct !DILexicalBlock(scope: !20, file: !1, line: 10, column: 8)
 !20 = distinct !DISubprogram(name: "d", linkageName: "_ZN1A1dEv", scope: !4, file: !1, line: 10, type: !14, isLocal: false, isDefinition: true, scopeLine: 8, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !5)
 !21 = !{!22}
@@ -72,4 +70,4 @@
 !30 = !DILocation(line: 7, column: 12, scope: !13)
 !31 = distinct !DISubprogram(name: "b", linkageName: "_ZN1A1bEv", scope: !4, file: !1, line: 8, type: !14, isLocal: true, isDefinition: true, scopeLine: 8, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !5)
 !32 = !DILocation(line: 8, column: 24, scope: !31)
-
+!33 = !{!16}
Index: llvm/test/DebugInfo/omit-empty.ll
===
--- llvm/test/DebugInfo/omit-empty.ll
+++ llvm/test/DebugInfo/omit-empty.ll
@@ -6,15 +6,15 @@
 !llvm.dbg.cu = !{!0, !5}
 !llvm.module.flags = !{!3, !4}
 
-!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "LLVM", isOptimized:

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

2023-05-15 Thread Vladislav Dzhidzhoev via Phabricator via cfe-commits
dzhidzhoev updated this revision to Diff 522140.
dzhidzhoev added a comment.

Rebased.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144006

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

Index: llvm/test/DebugInfo/X86/set.ll
===
--- llvm/test/DebugInfo/X86/set.ll
+++ llvm/test/DebugInfo/X86/set.ll
@@ -68,11 +68,11 @@
 !llvm.module.flags = !{!18, !19, !20}
 
 !0 = !{!"versions- cm3: d5.10.0 llvm: 9.0"}
-!1 = distinct !DICompileUnit(language: DW_LANG_Modula3, file: !2, producer: "cm3", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !3)
+!1 = distinct !DICompileUnit(language: DW_LANG_Modula3, file: !2, producer: "cm3", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
 !2 = !DIFile(filename: "Main.m3", directory: "/home/cm3/settest/src")
 !3 = !{!4}
 !4 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "Enum", scope: !5, file: !2, line: 11, size: 8, align: 8, elements: !9)
-!5 = distinct !DISubprogram(name: "Test", linkageName: "Main__Test", scope: !2, file: !2, line: 11, type: !6, scopeLine: 11, spFlags: DISPFlagDefinition, unit: !1, retainedNodes: !8)
+!5 = distinct !DISubprogram(name: "Test", linkageName: "Main__Test", scope: !2, file: !2, line: 11, type: !6, scopeLine: 11, spFlags: DISPFlagDefinition, unit: !1, retainedNodes: !3)
 !6 = !DISubroutineType(types: !7)
 !7 = !{null}
 !8 = !{}
Index: llvm/test/DebugInfo/Generic/verifier-invalid-disubprogram.ll
===
--- llvm/test/DebugInfo/Generic/verifier-invalid-disubprogram.ll
+++ llvm/test/DebugInfo/Generic/verifier-invalid-disubprogram.ll
@@ -38,7 +38,7 @@
 define void @invalid_retained_nodes_list() !dbg !10 { ret void }
 !10 = distinct !DISubprogram(retainedNodes: !0)
 
-; CHECK: invalid retained nodes, expected DILocalVariable, DILabel or DIImportedEntity
+; CHECK: invalid retained nodes, expected DILocalVariable, DILabel, DIImportedEntity or DIType
 define void @invalid_retained_nodes_expected() !dbg !11 { ret void }
 !11 = distinct !DISubprogram(retainedNodes: !{!0})
 
Index: llvm/test/DebugInfo/Generic/local-type-as-template-parameter.ll
===
--- /dev/null
+++ llvm/test/DebugInfo/Generic/local-type-as-template-parameter.ll
@@ -0,0 +1,160 @@
+; RUN: %llc_dwarf -O0 -filetype=obj < %s  \
+; RUN:  | llvm-dwarfdump --show-children --name=foo - \
+; RUN:  | FileCheck --implicit-check-not "{{DW_TAG|NULL}}" %s
+
+; The test ensures that AsmPrinter doesn't crashed compiling this.
+; It also demostrates misplacement for a local type (see PR55680 for details).
+
+; The test compiled from:
+
+; template
+; struct A {
+;   A(T &in) : a(in) {}
+;   T a;
+; };
+;
+; __attribute__((always_inline))
+; void foo() {
+;   struct B { int i; };
+;   B objB;
+;   A objA(objB);
+; }
+;
+; int main() {
+;   foo();
+; }
+
+; Concrete out-of-line tree of foo().
+; CHECK: DW_TAG_subprogram
+; CHECK:   DW_AT_abstract_origin {{.*}} "_Z3foov"
+;
+; CHECK:   DW_TAG_variable
+; CHECK: DW_AT_abstract_origin {{.*}} "objB"
+; CHECK:   DW_TAG_variable
+; CHECK: DW_AT_abstract_origin {{.*}} "objA"
+
+; FIXME: 'struct B' should be in the abstract tree below, not here.
+; CHECK:   DW_TAG_structure_type
+; CHECK: DW_AT_name	("B")
+; CHECK: DW_TAG_member
+; CHECK: NULL
+
+; CHECK:   NULL
+
+; Abstract tree of foo().
+; CHECK: DW_TAG_subprogram
+; CHECK:   DW_AT_name	("foo")
+; CHECK:   DW_AT_inline	(DW_INL_inlined)
+
+; CHECK:   DW_TAG_variable
+; CHECK: DW_AT_name	("objB")
+; CHECK:   DW_TAG_variable
+; CHECK: DW_AT_name	("objA")
+
+; CHECK:   NULL
+
+; CHECK: DW_TAG_inlined_subroutine
+; CHECK:   DW_AT_abstract_origin {{.*}} "_Z3foov"
+; CHECK:   DW_TAG_variable
+; CHECK: DW_AT_abstract_origin {{.*}} "objB"
+; CHECK:   DW_TAG_variable
+; CHECK: DW_AT_abstract_origin {{.*}} "objA"
+; CHECK:   NULL
+
+%struc

[PATCH] D149872: [OpenMP][OMPIRBuilder] Migrate emitOffloadingArrays and EmitNonContiguousDescriptor from Clang

2023-05-15 Thread Akash Banerjee via Phabricator via cfe-commits
TIFitis marked 3 inline comments as done.
TIFitis added a comment.

Ping for review :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149872

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


[PATCH] D149733: [clang][USR] Prevent crashes on incomplete FunctionDecls

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

In D149733#4321610 , @kadircet wrote:

>> However, I'm not keen on us playing whack-a-mole with the kinds of checks 
>> from this review. For starters, that's going to have a long-tail that makes 
>> it hard to know if we've ever gotten to the bottom of the issue. But also, 
>> each one of these checks is basically useless for the primary way in which 
>> Clang is consumed (as a compiler), so this increases compile times for 
>> limited benefit to "most" users.
>
> I completely agree, that's the reason why I've stayed away from adding those 
> checks to various FunctionDecl helpers (isVariadic, params, etc.).
>
>> In this particular case, we may be fine as this is limited to libclang and 
>> so it shouldn't add overhead for the common path, but I suspect we're going 
>> to find cases that need fixing in more common areas of the compiler that 
>> could be more troublesome.
>
> Agreed, and I am also pretty sure this is not the only place that can be 
> affected from incomplete decls/types. But this is the only one showing up 
> quite frequently ever since changes to lambda parsing.
> I think there's some strategy decision to be made about clang's invariants:
>
> - whether to accept declarations/types can be inspected in the middle of 
> parsing as a new constraint, declare all the existing violations as bugs and 
> fix them as we go (without introducing new ones, which is quite hard) and 
> give people the means to construct ast nodes "safely".
> - claim that variants are WAI and it's on use cases that perform such 
> inspections to figure out how to deal with consequences (e.g. in 
> code-completion consumers).
>
> But in either case, I don't think this review is the right medium to make 
> that decision. Surely it contains a lot of useful pointers, and I am happy to 
> move them to a discourse thread (LMK if I should do it, or you'd like to kick 
> it off @aaron.ballman) to raise awareness, but in the end this review is just 
> trying to fix an issue by adding extra checks to only the applications that 
> can violate contracts of clang parsing. So unless we've specific concerns 
> about the issue being addressed in this patch, I'd like to move forward.

I think we probably should have a broader discussion before moving forward 
here. It's not that this isn't incremental progress fixing an issue, but it's 
more that this same justification works to add the workaround 200 more times 
without ever addressing the underlying architectural concerns.

That said, is this issue blocking further work so you need to land this in 
order to make forward progress elsewhere?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149733

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


[PATCH] D149447: [clang][analyzer] Improve documentation of StdCLibraryFunctionArgs checker (NFC)

2023-05-15 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus requested changes to this revision.
Szelethus added inline comments.
This revision now requires changes to proceed.



Comment at: clang/docs/analyzer/checkers.rst:2457
 If the user disables the checker then the argument violation warning is
 suppressed. However, the assumption about the argument is still modeled. This
 is because exploring an execution path that already contains undefined behavior

This makes sense to me, and likely all of us knowledgable about symbolic 
execution (and clang in particular), but make little sense to end users. Could 
you add an example to ease reading?

"For instance, if the argument to  must be in between 0 and 255. If the 
value of the argument is unknown, the analyzer will assume that it is in this 
interval, even if warnings for this checker are disabled. Similarly, if a 
function mustn't be called with a null pointer but it is, analysis will stop on 
that execution path (similarly to a division by zero), with or without a 
warning."



Comment at: clang/docs/analyzer/checkers.rst:2459
 is because exploring an execution path that already contains undefined behavior
-is not valuable.
+is not valuable. This applies to all the restrictions that are listed below.
 

Restriction is not a bad word, but lets ease into it a bit.

"You can think of this checker as defining restrictions (pre- and 
postconditions) on standard library functions. Preconditions are checked, and 
when they are violated, a warning is emitted. Post conditions are added to the 
analysis, e.g. that the return value must be no greater than 255."



Comment at: clang/docs/analyzer/checkers.rst:2490-2523
+**List of checked functions**
+
+``fgetc``, ``fread``, ``fwrite``, ``getc``, ``getchar``, ``getdelim``,
+``getenv``, ``getline``, ``isalnum``, ``isalpha``, ``isascii``, ``isblank``,
+``isdigit``, ``isgraph``, ``islower``, ``isprint``, ``ispunct``, ``isspace``,
+``isupper``, ``isxdigit``, ``read``, ``toascii``, ``tolower``, ``toupper``,
+``write``

We should create an option or something the //actual// list of functions we 
model. This is the prime example of unsustainable documenting.



Comment at: clang/docs/analyzer/checkers.rst:2542
+modeling (and emit diagnostics) of additional functions that are defined in the
+POSIX standard. This option is disabled by default. Note that this option
+belongs to a separate built-in checker ``apiModeling.StdCLibraryFunctions`` and

Isn't this something that we either do or do not enable by default? My memory 
betrays me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149447

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


[PATCH] D148088: [RFC][clangd] Move preamble index out of document open critical path

2023-05-15 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

i think something went wrong with the diff, you don't seem to update 
PreambleCallbacks to trigger indexing on a different thread at all (and also 
there are certain lifetime issues). is this the final version of the patch or 
did I bump into a WIP version unknowingly ?




Comment at: clang-tools-extra/clangd/Preamble.cpp:106-113
+CI.setSema(nullptr);
+CI.setASTConsumer(nullptr);
+if (CI.getASTReader()) {
+  CI.getASTReader()->setDeserializationListener(nullptr);
+  /* This just sets consumer to null when DeserializationListener is null 
*/
+  CI.getASTReader()->StartTranslationUnit(nullptr);
 }

why are we triggering destructors for all of these objects eagerly? if this is 
deliberate to "fix" some issue, could you mention that in comments?



Comment at: clang-tools-extra/clangd/Preamble.cpp:694
 Result->MainIsIncludeGuarded = CapturedInfo.isMainFileIncludeGuarded();
-return Result;
+CapturedCtx.emplace(CapturedInfo.takeLife());
+return std::make_pair(Result, CapturedCtx);

what about just keeping the callback (with a different signature) and calling 
it here? e.g.:
```
PreambleCallback(CapturedInfo.takeLife());
```

that way we don't need to change the return type and also control if we 
received a valid object on every call site (since callback will only be invoked 
on success)



Comment at: clang-tools-extra/clangd/TUScheduler.cpp:1063-1071
+  if (LatestBuild) {
+assert(CapturedCtx);
+CanonicalIncludes CanonIncludes = LatestBuild->CanonIncludes;
+CompilerInvocation &CI = CapturedCtx->getCompilerInvocation();
+ASTContext &Ctx = CapturedCtx->getASTContext();
+Preprocessor &PP = CapturedCtx->getPreprocessor();
+Callbacks.onPreambleAST(FileName, Inputs.Version, CI, Ctx, PP,

you can just execute this block around the call to `reportPreambleBuild` right? 
is there any particular reason to make this part of scope cleanup ? especially 
call it after the call to `updatePreamble` ?



Comment at: clang-tools-extra/clangd/TUScheduler.cpp:1066-1068
+CompilerInvocation &CI = CapturedCtx->getCompilerInvocation();
+ASTContext &Ctx = CapturedCtx->getASTContext();
+Preprocessor &PP = CapturedCtx->getPreprocessor();

these are all references to `CapturedCtx` which will be destroyed after the 
call. i guess we should be passing shared_ptrs/IntrusiveRefCntPtrs instead, 
right?

also I don't think it's enough to just pass these 3. we need to make sure rest 
of the fields in CapturedCtx is also kept alive (e.g. Preprocessor has raw 
pointers to Target/AuxTarget, which would be dangling after CapturedCtx goes 
out of scope).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148088

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


[PATCH] D150563: clang-format: [JS] terminate import sorting on `export type X = Y`

2023-05-15 Thread Jan Kühle via Phabricator via cfe-commits
jankuehle created this revision.
jankuehle added projects: clang, clang-format.
Herald added a project: All.
Herald added a subscriber: cfe-commits.
Herald added reviewers: rymiel, HazardyKnusperkeks, owenpan, MyDeveloperDay.
jankuehle requested review of this revision.

https://reviews.llvm.org/D150116 introduced a bug. `export type X = Y` was 
considered an export declaration and took part in import sorting. This is not 
correct. With this change `export type X = Y` properly terminates import 
sorting.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D150563

Files:
  clang/lib/Format/SortJavaScriptImports.cpp
  clang/unittests/Format/SortImportsTestJS.cpp


Index: clang/unittests/Format/SortImportsTestJS.cpp
===
--- clang/unittests/Format/SortImportsTestJS.cpp
+++ clang/unittests/Format/SortImportsTestJS.cpp
@@ -503,6 +503,15 @@
   verifySort("export {A, type B} from 'foo';\n",
  "export {A} from 'foo';\n"
  "export   {type B} from 'foo';");
+
+  // `export type X = Y;` should terminate import sorting. The following export
+  // statements should therefore not merge.
+  verifySort("export type A = B;\n"
+ "export {X};\n"
+ "export {Y};\n",
+ "export type A = B;\n"
+ "export {X};\n"
+ "export {Y};\n");
 }
 
 } // end namespace
Index: clang/lib/Format/SortJavaScriptImports.cpp
===
--- clang/lib/Format/SortJavaScriptImports.cpp
+++ clang/lib/Format/SortJavaScriptImports.cpp
@@ -517,7 +517,7 @@
 }
 
 // eat a potential "import X, " prefix.
-if (Current->is(tok::identifier)) {
+if (!Reference.IsExport && Current->is(tok::identifier)) {
   Reference.DefaultImport = Current->TokenText;
   nextToken();
   if (Current->is(Keywords.kw_from))


Index: clang/unittests/Format/SortImportsTestJS.cpp
===
--- clang/unittests/Format/SortImportsTestJS.cpp
+++ clang/unittests/Format/SortImportsTestJS.cpp
@@ -503,6 +503,15 @@
   verifySort("export {A, type B} from 'foo';\n",
  "export {A} from 'foo';\n"
  "export   {type B} from 'foo';");
+
+  // `export type X = Y;` should terminate import sorting. The following export
+  // statements should therefore not merge.
+  verifySort("export type A = B;\n"
+ "export {X};\n"
+ "export {Y};\n",
+ "export type A = B;\n"
+ "export {X};\n"
+ "export {Y};\n");
 }
 
 } // end namespace
Index: clang/lib/Format/SortJavaScriptImports.cpp
===
--- clang/lib/Format/SortJavaScriptImports.cpp
+++ clang/lib/Format/SortJavaScriptImports.cpp
@@ -517,7 +517,7 @@
 }
 
 // eat a potential "import X, " prefix.
-if (Current->is(tok::identifier)) {
+if (!Reference.IsExport && Current->is(tok::identifier)) {
   Reference.DefaultImport = Current->TokenText;
   nextToken();
   if (Current->is(Keywords.kw_from))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D148370: [Clang][Flang][OpenMP] Add loadOffloadInfoMetadata and createOffloadEntriesAndInfoMetadata into OMPIRBuilder's finalize and initialize

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

LG. Please wait a day before submitting.




Comment at: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp:455-468
+  auto Buf = MemoryBuffer::getFile(HostFilePath);
+  if (auto Err = Buf.getError())
+report_fatal_error(("error opening host file from host file path inside of 
"
+"OpenMPIRBuilder: " +
+Err.message())
+   .c_str());
+

Nit: Might be good to spell the types and use braces for multi-line code inside 
`if`.



Comment at: mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h:18
 #include "mlir/Dialect/LLVMIR/LLVMInterfaces.h"
+#include "mlir/Dialect/OpenMP/OpenMPDialect.h"
 #include "mlir/IR/Operation.h"

Nit: Is this required here? Can it be in the CPP File?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148370

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


[PATCH] D150563: clang-format: [JS] terminate import sorting on `export type X = Y`

2023-05-15 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir accepted this revision.
krasimir added a comment.
This revision is now accepted and ready to land.

Thank you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150563

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


[clang] 292a6c1 - Fix build error caused by https://reviews.llvm.org/D149718

2023-05-15 Thread via cfe-commits

Author: Manna, Soumi
Date: 2023-05-15T06:03:47-07:00
New Revision: 292a6c1c2395f990bbde8d968825243e4fe9b954

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

LOG: Fix build error caused by https://reviews.llvm.org/D149718

The patch(https://reviews.llvm.org/D149718) broke buildbot

../../clang/include/clang/Sema/ParsedAttr.h:705:18: error: explicitly defaulted 
move assignment operator is implicitly deleted 
[-Werror,-Wdefaulted-function-deleted]
  AttributePool &operator=(AttributePool &&pool) = default;
 ^
../../clang/include/clang/Sema/ParsedAttr.h:674:21: note: move assignment 
operator of 'AttributePool' is implicitly deleted because field 'Factory' is of 
reference type 'clang::AttributeFactory &'
  AttributeFactory &Factory;
^
1 error generated.

This patch fixes the build error.

Added: 


Modified: 
clang/include/clang/Sema/ParsedAttr.h

Removed: 




diff  --git a/clang/include/clang/Sema/ParsedAttr.h 
b/clang/include/clang/Sema/ParsedAttr.h
index 837725c07980..cb27dd727f0f 100644
--- a/clang/include/clang/Sema/ParsedAttr.h
+++ b/clang/include/clang/Sema/ParsedAttr.h
@@ -702,7 +702,6 @@ class AttributePool {
 
   /// Move the given pool's allocations to this pool.
   AttributePool(AttributePool &&pool) = default;
-  AttributePool &operator=(AttributePool &&pool) = default;
 
   AttributeFactory &getFactory() const { return Factory; }
 



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


[PATCH] D148370: [Clang][Flang][OpenMP] Add loadOffloadInfoMetadata and createOffloadEntriesAndInfoMetadata into OMPIRBuilder's finalize and initialize

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

Thank you very much @kiranchandramohan! More than happy to wait a day incase 
anyone else wishes to do a final review. I'll add the Nits where possible when 
I commit the patch upstream and it should hopefully update the review with the 
alterations!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148370

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


[PATCH] D150566: [clang] Provide source range to 'invalid subexpr in const expr' diags

2023-05-15 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder created this revision.
tbaeder added reviewers: cjdb, aaron.ballman.
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/D150566

Files:
  clang/lib/AST/ExprConstant.cpp
  clang/lib/AST/Interp/Interp.h
  clang/lib/AST/Interp/InterpFrame.cpp
  clang/lib/AST/Interp/InterpFrame.h
  clang/lib/AST/Interp/Source.cpp
  clang/lib/AST/Interp/Source.h
  clang/test/Misc/constexpr-source-ranges.cpp

Index: clang/test/Misc/constexpr-source-ranges.cpp
===
--- /dev/null
+++ clang/test/Misc/constexpr-source-ranges.cpp
@@ -0,0 +1,9 @@
+// RUN: not %clang_cc1 -fsyntax-only -fdiagnostics-print-source-range-info -fcxx-exceptions %s 2>&1 | FileCheck %s
+// RUN: not %clang_cc1 -fsyntax-only -fexperimental-new-constant-interpreter -fdiagnostics-print-source-range-info -fcxx-exceptions %s 2>&1 | FileCheck %s
+
+constexpr int f() {
+  throw 1;
+  return 0;
+}
+
+// CHECK: constexpr-source-ranges.cpp:5:3:{5:3-5:10}
Index: clang/lib/AST/Interp/Source.h
===
--- clang/lib/AST/Interp/Source.h
+++ clang/lib/AST/Interp/Source.h
@@ -74,6 +74,7 @@
   SourceInfo(const Decl *D) : Source(D) {}
 
   SourceLocation getLoc() const;
+  SourceRange getRange() const;
 
   const Stmt *asStmt() const { return Source.dyn_cast(); }
   const Decl *asDecl() const { return Source.dyn_cast(); }
@@ -99,6 +100,7 @@
   const Expr *getExpr(const Function *F, CodePtr PC) const;
   /// Returns the location from which an opcode originates.
   SourceLocation getLocation(const Function *F, CodePtr PC) const;
+  SourceRange getRange(const Function *F, CodePtr PC) const;
 };
 
 } // namespace interp
Index: clang/lib/AST/Interp/Source.cpp
===
--- clang/lib/AST/Interp/Source.cpp
+++ clang/lib/AST/Interp/Source.cpp
@@ -22,6 +22,16 @@
   return SourceLocation();
 }
 
+SourceRange SourceInfo::getRange() const {
+  if (const Expr *E = asExpr())
+return E->getSourceRange();
+  if (const Stmt *S = asStmt())
+return S->getSourceRange();
+  if (const Decl *D = asDecl())
+return D->getSourceRange();
+  return SourceRange();
+}
+
 const Expr *SourceInfo::asExpr() const {
   if (auto *S = Source.dyn_cast())
 return dyn_cast(S);
@@ -37,3 +47,7 @@
 SourceLocation SourceMapper::getLocation(const Function *F, CodePtr PC) const {
   return getSource(F, PC).getLoc();
 }
+
+SourceRange SourceMapper::getRange(const Function *F, CodePtr PC) const {
+  return getSource(F, PC).getRange();
+}
Index: clang/lib/AST/Interp/InterpFrame.h
===
--- clang/lib/AST/Interp/InterpFrame.h
+++ clang/lib/AST/Interp/InterpFrame.h
@@ -118,6 +118,7 @@
   virtual SourceInfo getSource(CodePtr PC) const;
   const Expr *getExpr(CodePtr PC) const;
   SourceLocation getLocation(CodePtr PC) const;
+  SourceRange getRange(CodePtr PC) const;
 
   unsigned getDepth() const { return Depth; }
 
Index: clang/lib/AST/Interp/InterpFrame.cpp
===
--- clang/lib/AST/Interp/InterpFrame.cpp
+++ clang/lib/AST/Interp/InterpFrame.cpp
@@ -225,3 +225,6 @@
   return S.getLocation(Func, PC);
 }
 
+SourceRange InterpFrame::getRange(CodePtr PC) const {
+  return S.getRange(Func, PC);
+}
Index: clang/lib/AST/Interp/Interp.h
===
--- clang/lib/AST/Interp/Interp.h
+++ clang/lib/AST/Interp/Interp.h
@@ -1827,7 +1827,8 @@
 /// op is not valid in a constant context.
 inline bool Invalid(InterpState &S, CodePtr OpPC) {
   const SourceLocation &Loc = S.Current->getLocation(OpPC);
-  S.FFDiag(Loc, diag::note_invalid_subexpr_in_const_expr);
+  S.FFDiag(Loc, diag::note_invalid_subexpr_in_const_expr)
+  << S.Current->getRange(OpPC);
   return false;
 }
 
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -5201,7 +5201,7 @@
   return ESR_Succeeded;
 }
 
-Info.FFDiag(S->getBeginLoc());
+Info.FFDiag(S->getBeginLoc()) << S->getSourceRange();
 return ESR_Failed;
 
   case Stmt::NullStmtClass:
@@ -7427,7 +7427,7 @@
   /// Report an evaluation error. This should only be called when an error is
   /// first discovered. When propagating an error, just return false.
   bool Error(const Expr *E, diag::kind D) {
-Info.FFDiag(E, D);
+Info.FFDiag(E, D) << E->getSourceRange();
 return false;
   }
   bool Error(const Expr *E) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D149733: [clang][USR] Prevent crashes on incomplete FunctionDecls

2023-05-15 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

> I think we probably should have a broader discussion before moving forward 
> here. It's not that this isn't incremental progress fixing an issue, but it's 
> more that this same justification works to add the workaround 200 more times 
> without ever addressing the underlying architectural concerns.

I can see the desire to fix such issues at a higher level, and not wanting to 
play whack-a-mole in various places. But that's the reason why this patch 
specifically increases robustness in a piece of code that already has some 
logic to deal with invalid code. Rather than core clang pieces, which has 
different assumptions about invariants of the AST (e.g. not adding the 
null-check to every getType call in FunctionDecl methods).
If we're not willing to land such fixes that only add relevant checks to pieces 
of clang that's suppose to be more robust against invalid code, I don't see how 
we can have any stable tooling in the short term. Most of the feature work that 
introduces handling for new language constructs introduces regressions on 
invalid code as it's not really a concern and never verified. Hence we fix 
those afterwards as we notice them, fixing the implementation whenever it's 
feasible or increasing robustness in rest of the pieces when fixing the 
implementation is infeasible (or implementation is just right and the 
application was relying on some assurances that were incidentally there 
before). As we happen to hit some increasing resistance towards these 
robustness improvement patches, it'd be nice to understand what should be the 
way to fix them going forward. e.g. treat them as usual crashes, find the 
offending patch and just revert it with the reproducer?

> That said, is this issue blocking further work so you need to land this in 
> order to make forward progress elsewhere?

This is resulting in crashes in clangd whenever the users trigger code 
completion in such code patterns (which is ~100s times a day in our production 
setup, so not rare in practice). 
So it isn't linked to any bigger task, but rather general robustness/QoL 
improvements for invalid code handling in clang(d) which are quite important 
especially on big projects. As a crash could cost minutes of warm-up times 
because we need to rebuild all of the caches.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149733

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


[PATCH] D150354: [OpenMP][MLIR][Flang][bbc][Driver] Add fopenmp-version and generate corresponding MLIR attribute

2023-05-15 Thread Dominik Adamski via Phabricator via cfe-commits
domada updated this revision to Diff 522157.
domada added a comment.

Patch rebased because I applied remarks for parent revision.


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

https://reviews.llvm.org/D150354

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

Index: flang/tools/bbc/bbc.cpp
===
--- flang/tools/bbc/bbc.cpp
+++ flang/tools/bbc/bbc.cpp
@@ -132,6 +132,11 @@
 // A simplified subset of the OpenMP RTL Flags from Flang, only the primary
 // positive options are available, no negative options e.g. fopen_assume* vs
 // fno_open_assume*
+static llvm::cl::opt
+setOpenMPVersion("fopenmp-version",
+ llvm::cl::desc("OpenMP standard version"),
+ llvm::cl::init(50));
+
 static llvm::cl::opt setOpenMPTargetDebug(
 "fopenmp-target-debug",
 llvm::cl::desc("Enable debugging in the OpenMP offloading device RTL"),
@@ -277,11 +282,12 @@
   burnside.lower(parseTree, semanticsContext);
   mlir::ModuleOp mlirModule = burnside.getModule();
   if (enableOpenMP) {
-auto offloadModuleOpts =
-OffloadModuleOpts(setOpenMPTargetDebug, setOpenMPTeamSubscription,
-  setOpenMPThreadSubscription, setOpenMPNoThreadState,
-  setOpenMPNoNestedParallelism, enableOpenMPDevice);
+auto offloadModuleOpts = OffloadModuleOpts(
+setOpenMPTargetDebug, setOpenMPTeamSubscription,
+setOpenMPThreadSubscription, setOpenMPNoThreadState,
+setOpenMPNoNestedParallelism, enableOpenMPDevice, setOpenMPVersion);
 setOffloadModuleInterfaceAttributes(mlirModule, offloadModuleOpts);
+setOpenMPVersionAttribute(mlirModule, setOpenMPVersion);
   }
   std::error_code ec;
   std::string outputName = outputFilename;
Index: flang/test/Lower/OpenMP/rtl-flags.f90
===
--- flang/test/Lower/OpenMP/rtl-flags.f90
+++ flang/test/Lower/OpenMP/rtl-flags.f90
@@ -1,5 +1,7 @@
 !RUN: %flang_fc1 -emit-fir -fopenmp -fopenmp-is-device %s -o - | FileCheck %s --check-prefix=DEFAULT-DEVICE-FIR
-!RUN: %flang_fc1 -emit-fir -fopenmp %s -o - | FileCheck %s --check-prefix=DEFAULT-HOST-FIR
+!RUN: %flang_fc1 -emit-fir -fopenmp -fopenmp-version=45 %s -o - | FileCheck %s --check-prefix=DEFAULT-HOST-FIR
+!RUN: %flang_fc1 -emit-fir -fopenmp -fopenmp-is-device -fopenmp-version=45  %s -o - | FileCheck %s --check-prefix=DEFAULT-DEVICE-FIR-VERSION
+!RUN: %flang_fc1 -emit-fir -fopenmp -fopenmp-version=45 %s -o - | FileCheck %s --check-prefix=DEFAULT-HOST-FIR-VERSION
 !RUN: %flang_fc1 -emit-fir -fopenmp -fopenmp-target-debug -fopenmp-is-device %s -o - | FileCheck %s --check-prefix=DBG-DEVICE-FIR
 !RUN: %flang_fc1 -emit-fir -fopenmp -fopenmp-target-debug=111 -fopenmp-is-device %s -o - | FileCheck %s --check-prefix=DBG-EQ-DEVICE-FIR
 !RUN: %flang_fc1 -emit-fir -fopenmp -fopenmp-assume-teams-oversubscription -fopenmp-is-device %s -o - | FileCheck %s --check-prefix=TEAMS-OSUB-DEVICE-FIR
@@ -8,7 +10,9 @@
 !RUN: %flang_fc1 -emit-fir -fopenmp -fopenmp-assume-no-nested-parallelism -fopenmp-is-device %s -o - | FileCheck %s --check-prefix=NEST-PAR-DEVICE-FIR
 !RUN: %flang_fc1 -emit-fir -fopenmp -fopenmp-target-debug -fopenmp-assume-teams-oversubscription -fopenmp-assume-no-nested-parallelism -fopenmp-assume-threads-oversubscription -fopenmp-assume-no-thread-state -fopenmp-is-device %s -o - | FileCheck %s --check-prefix=ALL-DEVICE-FIR
 !RUN: bbc -emit-fir -fopenmp -fopenmp-is-device -o - %s | FileCheck %s --check-prefix=DEFAULT-DEVICE-FIR
+!RUN: bbc -emit-fir -fopenmp -fopenmp-is-device -fopenmp-version=45 -o - %s | FileCheck %s --check-prefix=DEFAULT-DEVICE-FIR-VERSION
 !RUN: bbc -emit-fir -fopenmp -o - %s | FileCheck %s --check-prefix=DEFAULT-HOST-FIR
+!RUN: bbc -emit-fir -fopenmp -fopenmp-version=45 -o - %s | FileCheck %s --check-prefix=DEFAULT-HOST-FIR-VERSION
 !RUN: bbc -emit-fir -fopenmp -fopenmp-target-debug=111 -fopenmp-is-device -o - %s | FileCheck %s --check-prefix=DBG-EQ-DEVICE-FIR
 !RUN: bbc -emit-fir -fopenmp -fopenmp-assume-teams-oversubscription -fopenmp-is-device -o - %s | FileCheck %s --check-prefix=TEAMS-OSUB-DEVICE-FIR
 !RUN: bbc -emit-fir -fopenmp -fopenmp-assume-threads-oversubscription -fopenmp-is-device -o - %s | FileCheck %s --check-prefix=THREAD-OSUB-DEVICE-FIR
@@ -17,7 +21,9 @@
 !RUN: bbc -emit-fir -fopenmp -fopenmp-target-debug=1 -fopenmp-assume-teams-oversubscription -fopenmp-assume-no-nested-parallelism -fopenmp-assume-threads-oversubscription -fopenmp-assume-no-thread-state -fopenmp-is-dev

[PATCH] D148088: [RFC][clangd] Move preamble index out of document open critical path

2023-05-15 Thread Kugan Vivekanandarajah via Phabricator via cfe-commits
kuganv added inline comments.



Comment at: clang-tools-extra/clangd/Preamble.cpp:106-113
+CI.setSema(nullptr);
+CI.setASTConsumer(nullptr);
+if (CI.getASTReader()) {
+  CI.getASTReader()->setDeserializationListener(nullptr);
+  /* This just sets consumer to null when DeserializationListener is null 
*/
+  CI.getASTReader()->StartTranslationUnit(nullptr);
 }

kadircet wrote:
> why are we triggering destructors for all of these objects eagerly? if this 
> is deliberate to "fix" some issue, could you mention that in comments?
> why are we triggering destructors for all of these objects eagerly? if this 
> is deliberate to "fix" some issue, could you mention that in comments?

Thanks a lot for the review.
If we don't destruct and set it to null, CapturedASTCtx will also have to keep 
instances such as ASTConsumer including other related callbacks such 
PreambleCallbacks. This was making the CapturedASTCtx interface and 
implementation complex.



Comment at: clang-tools-extra/clangd/Preamble.cpp:694
 Result->MainIsIncludeGuarded = CapturedInfo.isMainFileIncludeGuarded();
-return Result;
+CapturedCtx.emplace(CapturedInfo.takeLife());
+return std::make_pair(Result, CapturedCtx);

kadircet wrote:
> what about just keeping the callback (with a different signature) and calling 
> it here? e.g.:
> ```
> PreambleCallback(CapturedInfo.takeLife());
> ```
> 
> that way we don't need to change the return type and also control if we 
> received a valid object on every call site (since callback will only be 
> invoked on success)
> what about just keeping the callback (with a different signature) and calling 
> it here? e.g.:
> ```
> PreambleCallback(CapturedInfo.takeLife());
> ```
> 
> that way we don't need to change the return type and also control if we 
> received a valid object on every call site (since callback will only be 
> invoked on success)

Apologies for the misunderstanding.  Just to be clear, you prefer indexing in 
UpdateIndexCallbacks using the thread Tasks that also indexes in indexStdlib? 
In this implementation, I am calling the index action in preamble thread. I 
will revise it.



Comment at: clang-tools-extra/clangd/TUScheduler.cpp:1063-1071
+  if (LatestBuild) {
+assert(CapturedCtx);
+CanonicalIncludes CanonIncludes = LatestBuild->CanonIncludes;
+CompilerInvocation &CI = CapturedCtx->getCompilerInvocation();
+ASTContext &Ctx = CapturedCtx->getASTContext();
+Preprocessor &PP = CapturedCtx->getPreprocessor();
+Callbacks.onPreambleAST(FileName, Inputs.Version, CI, Ctx, PP,

kadircet wrote:
> you can just execute this block around the call to `reportPreambleBuild` 
> right? is there any particular reason to make this part of scope cleanup ? 
> especially call it after the call to `updatePreamble` ?
> you can just execute this block around the call to `reportPreambleBuild` 
> right? is there any particular reason to make this part of scope cleanup ? 
> especially call it after the call to `updatePreamble` ?

Yes, we can do it around reportPreambleBuild. However, based on your previous 
comment, I got the impression that you prefer it be a callback to buildPreamble 
which indexes in the tasks. We could do it either way. 





Comment at: clang-tools-extra/clangd/TUScheduler.cpp:1066-1068
+CompilerInvocation &CI = CapturedCtx->getCompilerInvocation();
+ASTContext &Ctx = CapturedCtx->getASTContext();
+Preprocessor &PP = CapturedCtx->getPreprocessor();

kadircet wrote:
> these are all references to `CapturedCtx` which will be destroyed after the 
> call. i guess we should be passing shared_ptrs/IntrusiveRefCntPtrs instead, 
> right?
> 
> also I don't think it's enough to just pass these 3. we need to make sure 
> rest of the fields in CapturedCtx is also kept alive (e.g. Preprocessor has 
> raw pointers to Target/AuxTarget, which would be dangling after CapturedCtx 
> goes out of scope).
> these are all references to `CapturedCtx` which will be destroyed after the 
> call. i guess we should be passing shared_ptrs/IntrusiveRefCntPtrs instead, 
> right?
> 
> also I don't think it's enough to just pass these 3. we need to make sure 
> rest of the fields in CapturedCtx is also kept alive (e.g. Preprocessor has 
> raw pointers to Target/AuxTarget, which would be dangling after CapturedCtx 
> goes out of scope).

In this implementation, I am using these in the same scope. But I will revise 
it as per previous comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148088

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


[PATCH] D150354: [OpenMP][MLIR][Flang][bbc][Driver] Add fopenmp-version and generate corresponding MLIR attribute

2023-05-15 Thread Dominik Adamski via Phabricator via cfe-commits
domada added a comment.

In D150354#4337148 , @awarzynski 
wrote:

> All in all LGTM, but I'm not sure whether Flang should be defaulting to 
> OpenMP 5.0. AFAIK, that's not supported yet.

If you wish I can set to OpenMP 4.5. But then we need to have two separate 
flags in clang/include/clang/Driver/Options.td (one for clang and the second 
one for flang).




Comment at: clang/lib/Driver/ToolChains/Flang.cpp:34
+  Args.AddAllArgs(CmdArgs, {options::OPT_ffixed_form,
+options::OPT_ffree_form,
+options::OPT_ffixed_line_length_EQ,

awarzynski wrote:
> Is this clang-format? Looks like a big block of unrelated changes (not 
> against it).
Yes, this is output of clang format.


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

https://reviews.llvm.org/D150354

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


[PATCH] D150528: [Clang] Fix the diagnoses when the argument to alignas is an incomplete type

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

Thank you for working on this! Just a few minor things.




Comment at: clang/docs/ReleaseNotes.rst:279-281
+- Clang now correctly diagnoses when the argument to alignas is an incomplete 
type.
+  (`#55175: `_,
+  Incorrect mention of 'alignof' in a diagnostic about 'alignas').





Comment at: clang/lib/Parse/ParseDecl.cpp:3032
+  ExprResult ArgExpr =
+  ParseAlignArgument(KWName->getName(), T.getOpenLocation(), EllipsisLoc);
   if (ArgExpr.isInvalid()) {





Comment at: clang/lib/Sema/SemaExpr.cpp:4714
+/// [dcl.align] An alignment-specifier of the form alignas(type-id) has the 
same
+/// effect as alignas(​alignof(type-id)).
+ExprResult Sema::ActOnAlignasTypeArgument(StringRef KWName, ParsedType Ty,

It looks like a zero-width joiner was added here around the `!` that should be 
removed.



Comment at: clang/lib/Sema/SemaExpr.cpp:4720
+  &TInfo);
+  return CreateUnaryExprOrTypeTraitExpr(TInfo, OpLoc, UETT_AlignOf, KWName, R);
+}




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150528

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


[clang] e1f34b7 - clang-format: [JS] terminate import sorting on `export type X = Y`

2023-05-15 Thread Krasimir Georgiev via cfe-commits

Author: Jan Kuhle
Date: 2023-05-15T15:37:18+02:00
New Revision: e1f34b735b669c5978bfdead874ee59d33f99eb0

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

LOG: clang-format: [JS] terminate import sorting on `export type X = Y`

Contributed by @jankuehle!

https://reviews.llvm.org/D150116 introduced a bug. `export type X = Y` was 
considered an export declaration and took part in import sorting. This is not 
correct. With this change `export type X = Y` properly terminates import 
sorting.

Reviewed By: krasimir

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

Added: 


Modified: 
clang/lib/Format/SortJavaScriptImports.cpp
clang/unittests/Format/SortImportsTestJS.cpp

Removed: 




diff  --git a/clang/lib/Format/SortJavaScriptImports.cpp 
b/clang/lib/Format/SortJavaScriptImports.cpp
index af2d3400c970d..e24fe051a26ce 100644
--- a/clang/lib/Format/SortJavaScriptImports.cpp
+++ b/clang/lib/Format/SortJavaScriptImports.cpp
@@ -517,7 +517,7 @@ class JavaScriptImportSorter : public TokenAnalyzer {
 }
 
 // eat a potential "import X, " prefix.
-if (Current->is(tok::identifier)) {
+if (!Reference.IsExport && Current->is(tok::identifier)) {
   Reference.DefaultImport = Current->TokenText;
   nextToken();
   if (Current->is(Keywords.kw_from))

diff  --git a/clang/unittests/Format/SortImportsTestJS.cpp 
b/clang/unittests/Format/SortImportsTestJS.cpp
index 9d779cd988d0c..2778d6efcdf9a 100644
--- a/clang/unittests/Format/SortImportsTestJS.cpp
+++ b/clang/unittests/Format/SortImportsTestJS.cpp
@@ -503,6 +503,15 @@ TEST_F(SortImportsTestJS, ImportExportType) {
   verifySort("export {A, type B} from 'foo';\n",
  "export {A} from 'foo';\n"
  "export   {type B} from 'foo';");
+
+  // `export type X = Y;` should terminate import sorting. The following export
+  // statements should therefore not merge.
+  verifySort("export type A = B;\n"
+ "export {X};\n"
+ "export {Y};\n",
+ "export type A = B;\n"
+ "export {X};\n"
+ "export {Y};\n");
 }
 
 } // end namespace



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


[PATCH] D150563: clang-format: [JS] terminate import sorting on `export type X = Y`

2023-05-15 Thread Krasimir Georgiev 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 rGe1f34b735b66: clang-format: [JS] terminate import sorting on 
`export type X = Y` (authored by jankuehle, committed by krasimir).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150563

Files:
  clang/lib/Format/SortJavaScriptImports.cpp
  clang/unittests/Format/SortImportsTestJS.cpp


Index: clang/unittests/Format/SortImportsTestJS.cpp
===
--- clang/unittests/Format/SortImportsTestJS.cpp
+++ clang/unittests/Format/SortImportsTestJS.cpp
@@ -503,6 +503,15 @@
   verifySort("export {A, type B} from 'foo';\n",
  "export {A} from 'foo';\n"
  "export   {type B} from 'foo';");
+
+  // `export type X = Y;` should terminate import sorting. The following export
+  // statements should therefore not merge.
+  verifySort("export type A = B;\n"
+ "export {X};\n"
+ "export {Y};\n",
+ "export type A = B;\n"
+ "export {X};\n"
+ "export {Y};\n");
 }
 
 } // end namespace
Index: clang/lib/Format/SortJavaScriptImports.cpp
===
--- clang/lib/Format/SortJavaScriptImports.cpp
+++ clang/lib/Format/SortJavaScriptImports.cpp
@@ -517,7 +517,7 @@
 }
 
 // eat a potential "import X, " prefix.
-if (Current->is(tok::identifier)) {
+if (!Reference.IsExport && Current->is(tok::identifier)) {
   Reference.DefaultImport = Current->TokenText;
   nextToken();
   if (Current->is(Keywords.kw_from))


Index: clang/unittests/Format/SortImportsTestJS.cpp
===
--- clang/unittests/Format/SortImportsTestJS.cpp
+++ clang/unittests/Format/SortImportsTestJS.cpp
@@ -503,6 +503,15 @@
   verifySort("export {A, type B} from 'foo';\n",
  "export {A} from 'foo';\n"
  "export   {type B} from 'foo';");
+
+  // `export type X = Y;` should terminate import sorting. The following export
+  // statements should therefore not merge.
+  verifySort("export type A = B;\n"
+ "export {X};\n"
+ "export {Y};\n",
+ "export type A = B;\n"
+ "export {X};\n"
+ "export {Y};\n");
 }
 
 } // end namespace
Index: clang/lib/Format/SortJavaScriptImports.cpp
===
--- clang/lib/Format/SortJavaScriptImports.cpp
+++ clang/lib/Format/SortJavaScriptImports.cpp
@@ -517,7 +517,7 @@
 }
 
 // eat a potential "import X, " prefix.
-if (Current->is(tok::identifier)) {
+if (!Reference.IsExport && Current->is(tok::identifier)) {
   Reference.DefaultImport = Current->TokenText;
   nextToken();
   if (Current->is(Keywords.kw_from))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D136746: [mlir] Saturation arithmetic intrinsics

2023-05-15 Thread Tobias Gysi via Phabricator via cfe-commits
gysit added a comment.
Herald added subscribers: bviyer, Moerafaat.

@omri123 are you interested in rebasing and landing this?


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

https://reviews.llvm.org/D136746

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


[PATCH] D146178: [Clang][Sema] Fix comparison of constraint expressions

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

In D146178#4339561 , @awson wrote:

> Now, this
>
>   #include 
>   #include 
>   
>   auto drop1(const std::vector& s){
>   return s | std::views::drop(1);
>   }
>
> when compiled against gcc's-13.1 libstdc++ spits:
>
>   boro.cpp:5:11: error: invalid operands to binary expression ('const 
> std::vector' and '_Partial<_Drop, decay_t>' (aka 
> '_Partial'))
>   return s | std::views::drop(1);
>  ~ ^ ~~~
>   C:\Progs\msys64\ucrt64\include\c++\13.1.0\cstddef:135:3: note: candidate 
> function not viable: no known conversion from 'const std::vector' to 
> 'byte' for 1st argument
> operator|(byte __l, byte __r) noexcept
> ^
>   C:\Progs\msys64\ucrt64\include\c++\13.1.0\bits/ios_base.h:87:3: note: 
> candidate function not viable: no known conversion from 'const 
> std::vector' to '_Ios_Fmtflags' for 1st argument
> operator|(_Ios_Fmtflags __a, _Ios_Fmtflags __b)
> ^
>   C:\Progs\msys64\ucrt64\include\c++\13.1.0\bits/ios_base.h:130:3: note: 
> candidate function not viable: no known conversion from 'const 
> std::vector' to '_Ios_Openmode' for 1st argument
> operator|(_Ios_Openmode __a, _Ios_Openmode __b)
> ^
>   C:\Progs\msys64\ucrt64\include\c++\13.1.0\bits/ios_base.h:170:3: note: 
> candidate function not viable: no known conversion from 'const 
> std::vector' to '_Ios_Iostate' for 1st argument
> operator|(_Ios_Iostate __a, _Ios_Iostate __b)
> ^
>   C:\Progs\msys64\ucrt64\include\c++\13.1.0\ranges:887:7: note: candidate 
> template ignored: constraints not satisfied [with _Self = _Partial<_Drop, 
> decay_t>, _Range = const std::vector &]
> operator|(_Range&& __r, _Self&& __self)
> ^
>   C:\Progs\msys64\ucrt64\include\c++\13.1.0\ranges:885:5: note: because 
> '__adaptor_invocable  int>, const std::vector &>' evaluated to false
>   && __adaptor_invocable<_Self, _Range>
>  ^
>   C:\Progs\msys64\ucrt64\include\c++\13.1.0\ranges:860:20: note: because 
> 'std::declval<_Adaptor>()(declval<_Args>()...)' would be invalid: no matching 
> function for call to object of type 
> 'std::ranges::views::__adaptor::_Partial'
> = requires { std::declval<_Adaptor>()(declval<_Args>()...); };
>  ^
>   C:\Progs\msys64\ucrt64\include\c++\13.1.0\ranges:896:7: note: candidate 
> template ignored: constraints not satisfied [with _Lhs = std::vector, 
> _Rhs = _Partial<_Drop, decay_t>]
> operator|(_Lhs __lhs, _Rhs __rhs)
> ^
>   C:\Progs\msys64\ucrt64\include\c++\13.1.0\ranges:893:16: note: because 
> 'derived_from, _RangeAdaptorClosure>' evaluated to false
> requires derived_from<_Lhs, _RangeAdaptorClosure>
>  ^
>   C:\Progs\msys64\ucrt64\include\c++\13.1.0\concepts:67:28: note: because 
> '__is_base_of(std::ranges::views::__adaptor::_RangeAdaptorClosure, 
> std::vector)' evaluated to false
>   concept derived_from = __is_base_of(_Base, _Derived)
>  ^
>   1 error generated.
>
> `transform` doesn't work either.

It isn't clear to me what the issue is here from looking at that.  
@alexander-shaposhnikov : Any chance you have time soon to analyze this so we 
don't have to revert?  I'd very much like to not have to do that...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146178

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


[PATCH] D146358: [clang][AST] Print name instead of type when diagnosing uninitialized subobject in constexpr variables

2023-05-15 Thread Takuya Shimizu via Phabricator via cfe-commits
hazohelet updated this revision to Diff 522165.
hazohelet added a comment.

Rebase and Ping


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

https://reviews.llvm.org/D146358

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticASTKinds.td
  clang/lib/AST/ExprConstant.cpp
  clang/lib/AST/Interp/Interp.cpp
  clang/test/AST/Interp/cxx20.cpp
  clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p4.cpp
  clang/test/SemaCXX/constant-expression-cxx2a.cpp
  clang/test/SemaCXX/cxx2a-consteval.cpp

Index: clang/test/SemaCXX/cxx2a-consteval.cpp
===
--- clang/test/SemaCXX/cxx2a-consteval.cpp
+++ clang/test/SemaCXX/cxx2a-consteval.cpp
@@ -761,7 +761,7 @@
 };
 
 S s1; // expected-error {{call to consteval function 'NamespaceScopeConsteval::S::S' is not a constant expression}} \
- expected-note {{subobject of type 'int' is not initialized}}
+ expected-note {{subobject 'Val' is not initialized}}
 
 template 
 struct T {
@@ -770,7 +770,7 @@
 };
 
 T t; // expected-error {{call to consteval function 'NamespaceScopeConsteval::T::T' is not a constant expression}} \
- expected-note {{subobject of type 'int' is not initialized}}
+ expected-note {{subobject 'Val' is not initialized}}
 
 } // namespace NamespaceScopeConsteval
 
Index: clang/test/SemaCXX/constant-expression-cxx2a.cpp
===
--- clang/test/SemaCXX/constant-expression-cxx2a.cpp
+++ clang/test/SemaCXX/constant-expression-cxx2a.cpp
@@ -409,12 +409,12 @@
 b.a.x = 2;
 return b;
   }
-  constexpr B uninit = return_uninit(); // expected-error {{constant expression}} expected-note {{subobject of type 'int' is not initialized}}
+  constexpr B uninit = return_uninit(); // expected-error {{constant expression}} expected-note {{subobject 'y' is not initialized}}
   static_assert(return_uninit().a.x == 2);
   constexpr A return_uninit_struct() {
 B b = {.b = 1};
 b.a.x = 2;
-return b.a; // expected-note {{in call to 'A(b.a)'}} expected-note {{subobject of type 'int' is not initialized}}
+return b.a; // expected-note {{in call to 'A(b.a)'}} expected-note {{subobject 'y' is not initialized}}
   }
   // Note that this is rejected even though return_uninit() is accepted, and
   // return_uninit() copies the same stuff wrapped in a union.
@@ -558,7 +558,7 @@
 }
   };
   constinit X x1(true);
-  constinit X x2(false); // expected-error {{constant initializer}} expected-note {{constinit}} expected-note {{subobject of type 'int' is not initialized}}
+  constinit X x2(false); // expected-error {{constant initializer}} expected-note {{constinit}} expected-note {{subobject 'n' is not initialized}}
 
   struct Y {
 struct Z { int n; }; // expected-note {{here}}
@@ -577,7 +577,7 @@
   };
   // FIXME: This is working around clang not implementing DR2026. With that
   // fixed, we should be able to test this without the injected copy.
-  constexpr Y copy(Y y) { return y; } // expected-note {{in call to 'Y(y)'}} expected-note {{subobject of type 'int' is not initialized}}
+  constexpr Y copy(Y y) { return y; } // expected-note {{in call to 'Y(y)'}} expected-note {{subobject 'n' is not initialized}}
   constexpr Y y1 = copy(Y());
   static_assert(y1.z1.n == 1 && y1.z2.n == 2 && y1.z3.n == 3);
 
Index: clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p4.cpp
===
--- clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p4.cpp
+++ clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p4.cpp
@@ -360,7 +360,7 @@
   // The constructor is still 'constexpr' here, but the result is not intended
   // to be a constant expression. The standard is not clear on how this should
   // work.
-  constexpr V v; // expected-error {{constant expression}} expected-note {{subobject of type 'int' is not initialized}}
+  constexpr V v; // expected-error {{constant expression}} expected-note {{subobject 'y' is not initialized}}
 
   constexpr int k = V().x; // FIXME: ok?
 }
Index: clang/test/AST/Interp/cxx20.cpp
===
--- clang/test/AST/Interp/cxx20.cpp
+++ clang/test/AST/Interp/cxx20.cpp
@@ -143,9 +143,9 @@
 constexpr A() {}
   };
   constexpr A a; // expected-error {{must be initialized by a constant expression}} \
- // expected-note {{subobject of type 'int' is not initialized}} \
+ // expected-note {{subobject 'a' is not initialized}} \
  // ref-error {{must be initialized by a constant expression}} \
- // ref-note {{subobject of type 'int' is not initialized}}
+ // ref-note {{subobject 'a' is not initialized}}
 
 
   class Base {
@@ -161,18 +161,18 @@
 constexpr Derived() : Base() {}   };
 
   constexpr Derived D; // expected-error {{must be initialized by a constant expression}} \
-  

[PATCH] D139010: [clang][WebAssembly] Implement support for table types and builtins

2023-05-15 Thread Paulo Matos via Phabricator via cfe-commits
pmatos marked an inline comment as done.
pmatos added a comment.

@tlively @aaron.ballman pinging both to get final reviews on the LLVM and Clang 
parts respectively. It would be great to have this merged soon.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139010

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


[PATCH] D150553: [SVE ACLE] Change the lowering of SVE integer mla_u/mls_u builtins

2023-05-15 Thread mgabka via Phabricator via cfe-commits
mgabka added inline comments.



Comment at: llvm/include/llvm/IR/IntrinsicsAArch64.td:1665
 def int_aarch64_sve_mla_lane   : AdvSIMD_3VectorArgIndexed_Intrinsic;
+def int_aarch64_sve_mla_u  : AdvSIMD_Pred3VectorArg_Intrinsic;
 def int_aarch64_sve_mls: AdvSIMD_Pred3VectorArg_Intrinsic;

it is not a bug, but just a preference to keep better ordering here, could you 
move this new definition to be straight below the def int_aarch64_sve_mla ? so 
the regular and _u intrinsics are defined in the same order as in all other 
cases.

Same request to the mls_u definition.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150553

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


[PATCH] D147732: [AMDGPU] Add type mangling for {read, write, readfirst, perm}lane intrinsics

2023-05-15 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

Please make sure we can consume old IR using unmangled llvm.amdgcn.permlanex16 
by fixing auto upgrade. Otherwise, it may cause regressions for device libs or 
existing apps. Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147732

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


[PATCH] D150394: [OpenMP 5.2] Deprecate MINUS (-) operator on reduction clauses

2023-05-15 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:10487-10488
   "a reduction list item with incomplete type %0">;
+def err_omp_reduction_minus_type : Error<
+  "a reduction list item with minus(-) operator is not supported">;
+def warn_omp_minus_in_reduction_deprecated : Warning<

We already have message for unsupported reduction identifier. Better to modify 
switch in static bool actOnOMPReductionKindClause function and check if OpenMP 
> 52, set BOK to BO_Comma, if incoming OOK is OO_Minus. In this case it will be 
automatically diagnosed for OpenMP>52 as not allowed reduction identifier.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:10490
+def warn_omp_minus_in_reduction_deprecated : Warning<
+  "minus(-) operator for reductions is deprecated; use an user defined 
reduction instead">,
+  InGroup;

`use + or user defined reudction instead`? And better make it a fixme note.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150394

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


[PATCH] D146418: Support for OpenMP 5.0 sec 2.12.7 - Declare Target initializer expressions

2023-05-15 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/include/clang/Sema/Sema.h:11329
+  /// directive.
+  void ActOnOpenMPImplicitDeclareTarget(Decl *D);
+

Do I understand correctly, that the variable itself is marked explicitly, but 
the initializer shall be marked implicitly? If so, please fix the function name



Comment at: clang/lib/Sema/SemaOpenMP.cpp:23097-23098
+public:
+  void SetTargetDecl(Decl *TargetDecl) { this->TargetDecl = TargetDecl; }
+  bool CheckDeclVector() { return this->DeclVector.empty(); }
+  void PushDeclVector(VarDecl *TargetVarDecl) {

Remove `this->`, where not required.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:23099
+  bool CheckDeclVector() { return this->DeclVector.empty(); }
+  void PushDeclVector(VarDecl *TargetVarDecl) {
+this->DeclVector.push_back(TargetVarDecl);

1. Wrong function name format.
2. Do you really need to make it public? Hide as much as possible.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:23102
+  }
+  VarDecl *PopDeclVector() { return (this->DeclVector.pop_back_val()); }
+  void VisitDeclRefExpr(const DeclRefExpr *Node) {

Same, as for Push



Comment at: clang/lib/Sema/SemaOpenMP.cpp:23126-23140
+  while (!Checker.CheckDeclVector()) {
+VarDecl *TargetVarDecl = Checker.PopDeclVector();
+if (TargetVarDecl->hasAttr()) {
+  if (TargetVarDecl->hasInit() && TargetVarDecl->hasGlobalStorage()) {
+Expr *Ex = TargetVarDecl->getInit();
+if (Ex) {
+  if (auto *DeclRef = dyn_cast_or_null(Ex)) {

Better to hide this in GlobalDeclRefChecker


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

https://reviews.llvm.org/D146418

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


[PATCH] D149733: [clang][USR] Prevent crashes on incomplete FunctionDecls

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

In D149733#4342095 , @kadircet wrote:

>> I think we probably should have a broader discussion before moving forward 
>> here. It's not that this isn't incremental progress fixing an issue, but 
>> it's more that this same justification works to add the workaround 200 more 
>> times without ever addressing the underlying architectural concerns.
>
> I can see the desire to fix such issues at a higher level, and not wanting to 
> play whack-a-mole in various places. But that's the reason why this patch 
> specifically increases robustness in a piece of code that already has some 
> logic to deal with invalid code. Rather than core clang pieces, which has 
> different assumptions about invariants of the AST (e.g. not adding the 
> null-check to every getType call in FunctionDecl methods).
> If we're not willing to land such fixes that only add relevant checks to 
> pieces of clang that's suppose to be more robust against invalid code, I 
> don't see how we can have any stable tooling in the short term. Most of the 
> feature work that introduces handling for new language constructs introduces 
> regressions on invalid code as it's not really a concern and never verified. 
> Hence we fix those afterwards as we notice them, fixing the implementation 
> whenever it's feasible or increasing robustness in rest of the pieces when 
> fixing the implementation is infeasible (or implementation is just right and 
> the application was relying on some assurances that were incidentally there 
> before). As we happen to hit some increasing resistance towards these 
> robustness improvement patches, it'd be nice to understand what should be the 
> way to fix them going forward. e.g. treat them as usual crashes, find the 
> offending patch and just revert it with the reproducer?

On the one hand, I agree with you about the fact that this code is already 
trying to be robust against invalid code and thus it's reasonable to add more 
checks for that. No argument from me about that! But at the same time, it's 
become more obvious (at least to me) that clangd has features that don't work 
with all of the invariants in Clang and I don't know that we ever really 
stopped to figure out whether that's reasonable or not. That's why I think we 
need a broader discussion. The problem is not ideological, it's one of 
maintainability of the primary product. For example, the community could decide 
"it is not Clang's job to be resilient to this sort of thing". Or we could 
decide "we need to be resilient to this but only if it doesn't introduce more 
than X% overhead". And so on. Each time we land another one of these 
whack-a-mole changes, we potentially make it harder to get to a more principled 
approach.

(My personal feelings are that invariants about internal object state are going 
to be hard for us to change or introduce unwarranted overhead in at least some 
circumstances. In those circumstances, I think the onus is on clangd to 
determine how to work within those invariants and not on clang to change unless 
there isn't another reasonable option. Refactoring or adding smoke tests can 
introduce overhead that typical compilation scenarios should never have to pay 
the cost for, and we should avoid that as best we can. But I also realize this 
adds burden to the clangd folks to have compiler performance statistics for 
changes or refactoring that relate to invariants which may or may not be 
reasonable.)

>> That said, is this issue blocking further work so you need to land this in 
>> order to make forward progress elsewhere?
>
> This is resulting in crashes in clangd whenever the users trigger code 
> completion in such code patterns (which is ~100s times a day in our 
> production setup, so not rare in practice). 
> So it isn't linked to any bigger task, but rather general robustness/QoL 
> improvements for invalid code handling in clang(d) which are quite important 
> especially on big projects. As a crash could cost minutes of warm-up times 
> because we need to rebuild all of the caches.

The fact that this is happening 100s of times a day for you suggests we should 
land the changes in this patch so there's less pressure when having the broader 
discussion about where the division of labor is between clangd and clang. So 
LGTM!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149733

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


[PATCH] D149718: [NFC][Clang] Fix Coverity issues of copy without assign

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

In D149718#4341384 , @uabelho wrote:

> In D149718#4341052 , @uabelho wrote:
>
>> Compiling with clang 15.0.5 I get the following warning/error with this 
>> patch:
>>
>>   ../../clang/include/clang/Sema/ParsedAttr.h:705:18: error: explicitly 
>> defaulted move assignment operator is implicitly deleted 
>> [-Werror,-Wdefaulted-function-deleted]
>> AttributePool &operator=(AttributePool &&pool) = default;
>>^
>>   ../../clang/include/clang/Sema/ParsedAttr.h:674:21: note: move assignment 
>> operator of 'AttributePool' is implicitly deleted because field 'Factory' is 
>> of reference type 'clang::AttributeFactory &'
>> AttributeFactory &Factory;
>>   ^
>>   1 error generated.
>
> Also seen in this buildbot:
>  https://lab.llvm.org/buildbot/#/builders/214/builds/7476

Thank you @uabelho for reporting. Build error is fixed by 
https://github.com/llvm/llvm-project/commit/292a6c1c2395f990bbde8d968825243e4fe9b954


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149718

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


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

2023-05-15 Thread Qiongsi Wu via Phabricator via cfe-commits
qiongsiwu1 added a comment.

Pre-commit CI x64 Debian is failing 
https://buildkite.com/llvm-project/premerge-checks/builds/152189 because the 
build machine's cmake version is too old. I am landing this patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144190

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


[PATCH] D149718: [NFC][Clang] Fix Coverity issues of copy without assign

2023-05-15 Thread Mikael Holmén via Phabricator via cfe-commits
uabelho added a comment.

In D149718#4342320 , @Manna wrote:

> In D149718#4341384 , @uabelho wrote:
>
>> In D149718#4341052 , @uabelho 
>> wrote:
>>
>>> Compiling with clang 15.0.5 I get the following warning/error with this 
>>> patch:
>>>
>>>   ../../clang/include/clang/Sema/ParsedAttr.h:705:18: error: explicitly 
>>> defaulted move assignment operator is implicitly deleted 
>>> [-Werror,-Wdefaulted-function-deleted]
>>> AttributePool &operator=(AttributePool &&pool) = default;
>>>^
>>>   ../../clang/include/clang/Sema/ParsedAttr.h:674:21: note: move assignment 
>>> operator of 'AttributePool' is implicitly deleted because field 'Factory' 
>>> is of reference type 'clang::AttributeFactory &'
>>> AttributeFactory &Factory;
>>>   ^
>>>   1 error generated.
>>
>> Also seen in this buildbot:
>>  https://lab.llvm.org/buildbot/#/builders/214/builds/7476
>
> Thank you @uabelho for reporting. Build error is fixed by 
> https://github.com/llvm/llvm-project/commit/292a6c1c2395f990bbde8d968825243e4fe9b954

Great, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149718

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


[PATCH] D149276: [Clang] Fix parsing of `(auto(x))`.

2023-05-15 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 522180.
cor3ntin added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149276

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Parse/Parser.h
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseTentative.cpp
  clang/lib/Parse/Parser.cpp
  clang/test/Parser/cxx1z-decomposition.cpp
  clang/test/Parser/cxx2b-auto-x.cpp

Index: clang/test/Parser/cxx2b-auto-x.cpp
===
--- clang/test/Parser/cxx2b-auto-x.cpp
+++ clang/test/Parser/cxx2b-auto-x.cpp
@@ -18,7 +18,37 @@
 
 using T = looks_like_declaration *;
 void f() { T(&a)->n = 1; }
-// FIXME: They should be deemed expressions without breaking function pointer
-//parameter declarations with trailing return types.
-// void g() { auto(&a)->n = 0; }
-// void h() { auto{&a}->n = 0; }
+void g() { auto(&a)->n = 0; } // cxx23-warning {{before C++23}} \
+  // cxx20-error {{declaration of variable 'a' with deduced type 'auto (&)' requires an initializer}} \
+  // cxx20-error {{expected ';' at end of declaration}}
+void h() { auto{&a}->n = 0; } // cxx23-warning {{before C++23}} \
+  // cxx20-error {{expected unqualified-id}} \
+  // cxx20-error {{expected expression}}
+
+void e(auto (*p)(int y) -> decltype(y)) {}
+
+struct M;
+struct S{
+S operator()();
+S* operator->();
+int N;
+int M;
+} s; // expected-note {{here}}
+
+void test() {
+auto(s)()->N; // cxx23-warning {{expression result unused}} \
+  // cxx23-warning {{before C++23}} \
+  // cxx20-error {{unknown type name 'N'}}
+auto(s)()->M; // expected-error {{redefinition of 's' as different kind of symbol}}
+}
+
+void test_paren() {
+int a = (auto(0)); // cxx23-warning {{before C++23}} \
+   // cxx20-error {{expected expression}} \
+   // cxx20-error {{expected ')'}} \
+   // cxx20-note  {{to match this '('}}
+int b = (auto{0}); // cxx23-warning {{before C++23}} \
+   // cxx20-error {{expected expression}} \
+   // cxx20-error {{expected ')'}} \
+   // cxx20-note  {{to match this '('}}
+}
Index: clang/test/Parser/cxx1z-decomposition.cpp
===
--- clang/test/Parser/cxx1z-decomposition.cpp
+++ clang/test/Parser/cxx1z-decomposition.cpp
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -std=c++17 %s -verify -fcxx-exceptions
+// RUN: %clang_cc1 -std=c++17 %s -verify=expected,cxx17 -fcxx-exceptions
+// RUN: %clang_cc1 -std=c++2b %s -verify=expected,cxx2b -fcxx-exceptions
 // RUN: not %clang_cc1 -std=c++17 %s -emit-llvm-only -fcxx-exceptions
 
 struct S { int a, b, c; };
@@ -30,7 +31,7 @@
 namespace OtherDecl {
   // A parameter-declaration is not a simple-declaration.
   // This parses as an array declaration.
-  void f(auto [a, b, c]); // expected-error {{'auto' not allowed in function prototype}} expected-error {{'a'}}
+  void f(auto [a, b, c]); // cxx17-error {{'auto' not allowed in function prototype}} expected-error {{'a'}}
 
   void g() {
 // A condition is allowed as a Clang extension.
@@ -57,7 +58,7 @@
 namespace GoodSpecifiers {
   void f() {
 int n[1];
-const volatile auto &[a] = n;
+const volatile auto &[a] = n; // cxx2b-warning {{volatile qualifier in structured binding declaration is deprecated}}
   }
 }
 
@@ -67,8 +68,8 @@
   struct S { int n; } s;
   void f() {
 // storage-class-specifiers
-static auto &[a] = n; // expected-warning {{declared 'static' is a C++20 extension}}
-thread_local auto &[b] = n; // expected-warning {{declared 'thread_local' is a C++20 extension}}
+static auto &[a] = n; // cxx17-warning {{declared 'static' is a C++20 extension}}
+thread_local auto &[b] = n; // cxx17-warning {{declared 'thread_local' is a C++20 extension}}
 extern auto &[c] = n; // expected-error {{cannot be declared 'extern'}} expected-error {{declaration of block scope identifier with linkage cannot have an initializer}}
 struct S {
   mutable auto &[d] = n; // expected-error {{not permitted in this context}}
@@ -85,16 +86,19 @@
   }
 
   static constexpr inline thread_local auto &[j1] = n; // expected-error {{cannot be declared with 'constexpr inline' specifiers}}
-  static thread_local auto &[j2] = n; // expected-warning {{declared with 'static thread_local' specifiers is a C++20 extension}}
+  static thread_local auto &[j2] = n; // cxx17-warning {{declared with 'static thread_local' specifiers is a C++20 extension}}
 
   inline auto &[k] = n; // expected-error {{cannot be declared 'inline'}}
 
   const int K = 5;
+  auto ([c]) = s; // expected-error {{decomposition declaration cannot be declared with parenthes

[PATCH] D141714: Fix ast print of variables with attributes

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

It looks like several comments are left unaddressed, are you planning on making 
the suggested changes?




Comment at: clang/lib/AST/DeclPrinter.cpp:52-58
+enum AttrPrintLoc {
+  SIDE_NONE = 0,
+  SIDE_LEFT = 1,
+  SIDE_MIDDLE = 2,
+  SIDE_RIGHT = 4,
+  SIDE_ANY = SIDE_LEFT | SIDE_MIDDLE | SIDE_RIGHT,
+};

giulianobelinassi wrote:
> aaron.ballman wrote:
> > aaron.ballman wrote:
> > > 
> > I think we should use an `enum class` just so we don't steal these 
> > identifiers at the global scope within this file, WDYT?
> Unfortunately that would result in necessary auxiliary code to do an bitwise 
> '&' operation, so I don't think this is a good idea. Although I've explicitly 
> now access those constants by using the AttrPrintLoc:: keyword rather than 
> directly referencing the constant directly.
We have helper functionality for that, see `LLVM_MARK_AS_BITMASK_ENUM` from 
https://github.com/llvm/llvm-project/blob/main/llvm/include/llvm/ADT/BitmaskEnum.h




Comment at: clang/test/Analysis/blocks.mm:81
 // ANALYZER-NEXT:   2: [B1.1] (CXXConstructExpr, [B1.3], 
StructWithCopyConstructor)
-// CHECK-NEXT:   3: StructWithCopyConstructor s(5) 
__attribute__((blocks("byref")));
+// CHECK-NEXT:   3: StructWithCopyConstructor s 
__attribute__((blocks("byref")))(5);
 // CHECK-NEXT:   4: ^{ }

giulianobelinassi wrote:
> aaron.ballman wrote:
> > I can't quite tell if this change is good, bad, or just different.
> This indeed doesn't look good, but for what it is worth it is still corretly 
> accepted by clang and gcc.
I think this is a regression in terms of readability, but perhaps it's one we 
can live with.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141714

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


[clang] ba9eaf5 - Update __cplusplus for C++23, add C++23 diag group alias.

2023-05-15 Thread Erich Keane via cfe-commits

Author: Erich Keane
Date: 2023-05-15T07:48:52-07:00
New Revision: ba9eaf59a8a3bb0713956da3bfb3492669971a62

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

LOG: Update __cplusplus for C++23, add C++23 diag group alias.

This came up during the C++26 flag discussion, so split this out into a
separate patch.

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticGroups.td
clang/lib/Frontend/InitPreprocessor.cpp
clang/test/Preprocessor/init.c

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index 2ba42f9b73763..1a792f1cf6e8b 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -1116,6 +1116,7 @@ def : DiagGroup<"c++0x-extensions", [CXX11]>;
 def : DiagGroup<"c++1y-extensions", [CXX14]>;
 def : DiagGroup<"c++1z-extensions", [CXX17]>;
 def : DiagGroup<"c++2a-extensions", [CXX20]>;
+def : DiagGroup<"c++2b-extensions", [CXX23]>;
 
 def DelegatingCtorCycles :
   DiagGroup<"delegating-ctor-cycles">;

diff  --git a/clang/lib/Frontend/InitPreprocessor.cpp 
b/clang/lib/Frontend/InitPreprocessor.cpp
index 0c4e73ed931c9..822109c389360 100644
--- a/clang/lib/Frontend/InitPreprocessor.cpp
+++ b/clang/lib/Frontend/InitPreprocessor.cpp
@@ -451,9 +451,8 @@ static void InitializeStandardPredefinedMacros(const 
TargetInfo &TI,
   Builder.defineMacro("__STDC_VERSION__", "199409L");
   } else {
 //   -- __cplusplus
-// FIXME: Use correct value for C++23.
 if (LangOpts.CPlusPlus23)
-  Builder.defineMacro("__cplusplus", "202101L");
+  Builder.defineMacro("__cplusplus", "202302L");
 //  [C++20] The integer literal 202002L.
 else if (LangOpts.CPlusPlus20)
   Builder.defineMacro("__cplusplus", "202002L");

diff  --git a/clang/test/Preprocessor/init.c b/clang/test/Preprocessor/init.c
index 9d27f12b9861c..661808e34c872 100644
--- a/clang/test/Preprocessor/init.c
+++ b/clang/test/Preprocessor/init.c
@@ -16,7 +16,7 @@
 // CXX2B:#define __GXX_EXPERIMENTAL_CXX0X__ 1
 // CXX2B:#define __GXX_RTTI 1
 // CXX2B:#define __GXX_WEAK__ 1
-// CXX2B:#define __cplusplus 202101L
+// CXX2B:#define __cplusplus 202302L
 // CXX2B:#define __private_extern__ extern
 //
 // RUN: %clang_cc1 -x c++ -fgnuc-version=4.2.1 -std=c++20 -E -dM < /dev/null | 
FileCheck -match-full-lines -check-prefix CXX2A %s
@@ -139,7 +139,7 @@
 //
 // GXX2B:#define __GNUG__ 4
 // GXX2B:#define __GXX_WEAK__ 1
-// GXX2B:#define __cplusplus 202101L
+// GXX2B:#define __cplusplus 202302L
 // GXX2B:#define __private_extern__ extern
 //
 // RUN: %clang_cc1 -x c++ -fgnuc-version=4.2.1 -std=gnu++20 -E -dM < /dev/null 
| FileCheck -match-full-lines -check-prefix GXX2A %s



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


[PATCH] D148088: [RFC][clangd] Move preamble index out of document open critical path

2023-05-15 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/Preamble.cpp:694
 Result->MainIsIncludeGuarded = CapturedInfo.isMainFileIncludeGuarded();
-return Result;
+CapturedCtx.emplace(CapturedInfo.takeLife());
+return std::make_pair(Result, CapturedCtx);

kuganv wrote:
> kadircet wrote:
> > what about just keeping the callback (with a different signature) and 
> > calling it here? e.g.:
> > ```
> > PreambleCallback(CapturedInfo.takeLife());
> > ```
> > 
> > that way we don't need to change the return type and also control if we 
> > received a valid object on every call site (since callback will only be 
> > invoked on success)
> > what about just keeping the callback (with a different signature) and 
> > calling it here? e.g.:
> > ```
> > PreambleCallback(CapturedInfo.takeLife());
> > ```
> > 
> > that way we don't need to change the return type and also control if we 
> > received a valid object on every call site (since callback will only be 
> > invoked on success)
> 
> Apologies for the misunderstanding.  Just to be clear, you prefer indexing in 
> UpdateIndexCallbacks using the thread Tasks that also indexes in indexStdlib? 
> In this implementation, I am calling the index action in preamble thread. I 
> will revise it.
> Apologies for the misunderstanding. Just to be clear, you prefer indexing in 
> UpdateIndexCallbacks using the thread Tasks that also indexes in indexStdlib? 
> In this implementation, I am calling the index action in preamble thread. I 
> will revise it.

Yes, i guess that's the reason why I was confused while looking at the code. 
Sorry if I give the impression that suggests doing the indexing on 
`PreambleThread`, but I think both in my initial comment:

>> As for AsyncTaskRunner to use, since this indexing task only depends on the 
>> file-index, which is owned by ClangdServer, I don't think there's any need 
>> to introduce a new taskrunner into TUScheduler and block its destruction. We 
>> can just re-use the existing TaskRunner inside parsingcallbacks, in which we 
>> run stdlib indexing tasks.

and in the follow up;

>> I think we can just change the signature for PreambleParsedCallback to pass 
>> along refcounted objects. forgot to mention in the first comment, but we 
>> should also change the CanonicalIncludes to be a shared_ptr so that it can 
>> outlive the PreambleData. We should invoke the callback inside buildPreamble 
>> after a successful build. Afterwards we should also change the signature for 
>> onPreambleAST to take AST, PP and CanonicalIncludes as ref-counted objects 
>> again and PreambleThread::build should just forward objects received from 
>> PreambleParsedCallback. Afterwards inside the 
>> UpdateIndexCallbacks::onPreambleAST we can just invoke indexing on Tasks if 
>> it's present or synchronously in the absence of it.

I was pointing towards running this inside the `Tasks` in 
`UpdateIndexCallbacks`.

---

There's definitely some upsides to running that indexing on the preamble thread 
as well (which is what we do today) but I think the extra sequencing 
requirements (make sure to first notify the ASTPeer and then issue preamble 
callbacks) we put into TUScheduler (which is already quite complex) is probably 
not worth it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148088

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


[PATCH] D149447: [clang][analyzer] Improve documentation of StdCLibraryFunctionArgs checker (NFC)

2023-05-15 Thread Balázs Kéri via Phabricator via cfe-commits
balazske updated this revision to Diff 522192.
balazske added a comment.

Applied review suggestions, removed the list of functions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149447

Files:
  clang/docs/analyzer/checkers.rst

Index: clang/docs/analyzer/checkers.rst
===
--- clang/docs/analyzer/checkers.rst
+++ clang/docs/analyzer/checkers.rst
@@ -2432,17 +2432,57 @@
 
 .. code-block:: c
 
+  #define EOF -1
   void test_alnum_concrete(int v) {
 int ret = isalnum(256); // \
-// warning: Function argument constraint is not satisfied
+// warning: Function argument outside of allowed range
 (void)ret;
   }
 
-If the argument's value is unknown then the value is assumed to hold the proper value range.
+  void buffer_size_violation(FILE *file) {
+enum { BUFFER_SIZE = 1024 };
+wchar_t wbuf[BUFFER_SIZE];
+
+const size_t size = sizeof(*wbuf);   // 4
+const size_t nitems = sizeof(wbuf);  // 4096
+
+// Below we receive a warning because the 3rd parameter should be the
+// number of elements to read, not the size in bytes. This case is a known
+// vulnerability described by the ARR38-C SEI-CERT rule.
+fread(wbuf, size, nitems, file);
+  }
+
+You can think of this checker as defining restrictions (pre- and postconditions)
+on standard library functions. Preconditions are checked, and when they are
+violated, a warning is emitted. Post conditions are added to the analysis, e.g.
+that the return value must be no greater than 255.
+
+These are the possible checks on the values passed as function arguments:
+ - The argument has an allowed range (or multiple ranges) of values. The checker
+   can detect if a passed value is outside of the allowed range and show the
+   actual and allowed values.
+ - The argument has pointer type and is not allowed to be null pointer. Many
+   (but not all) standard functions can produce undefined behavior if a null
+   pointer is passed, these cases can be detected by the checker.
+ - The argument is a pointer to a memory block and the minimal size of this
+   buffer is determined by another argument to the function, or by
+   multiplication of two arguments (like at function ``fread``), or is a fixed
+   value (for example ``asctime_r`` requires at least a buffer of size 26). The
+   checker can detect if the buffer size is too small and in optimal case show
+   the size of the buffer and the values of the corresponding arguments.
+
+If the user disables the checker then the argument violation warning is
+suppressed. However, the assumption about the argument is still modeled.
+For instance, if the argument to a function must be in between 0 and 255.
+If the value of the argument is unknown, the analyzer will assume that it is in
+this interval, even if warnings for this checker are disabled. Similarly, if a
+function mustn't be called with a null pointer but it is, analysis will stop on
+that execution path (similarly to a division by zero), with or without a
+warning. If the null value of the argument can not be proven, the analyzer will
+assume that it is non-null.
 
 .. code-block:: c
 
-  #define EOF -1
   int test_alnum_symbolic(int x) {
 int ret = isalnum(x);
 // after the call, ret is assumed to be in the range [-1, 255]
@@ -2453,55 +2493,27 @@
 return ret;
   }
 
-If the user disables the checker then the argument violation warning is
-suppressed. However, the assumption about the argument is still modeled. This
-is because exploring an execution path that already contains undefined behavior
-is not valuable.
-
-There are different kind of constraints modeled: range constraint, not null
-constraint, buffer size constraint. A **range constraint** requires the
-argument's value to be in a specific range, see ``isalnum`` as an example above.
-A **not null constraint** requires the pointer argument to be non-null.
-
-A **buffer size** constraint specifies the minimum size of the buffer
-argument. The size might be a known constant. For example, ``asctime_r`` requires
-that the buffer argument's size must be greater than or equal to ``26`` bytes. In
-other cases, the size is denoted by another argument or as a multiplication of
-two arguments.
-For instance, ``size_t fread(void *ptr, size_t size, size_t nmemb, FILE *stream)``.
-Here, ``ptr`` is the buffer, and its minimum size is ``size * nmemb``
-
-.. code-block:: c
-
-  void buffer_size_constraint_violation(FILE *file) {
-enum { BUFFER_SIZE = 1024 };
-wchar_t wbuf[BUFFER_SIZE];
-
-const size_t size = sizeof(*wbuf);   // 4
-const size_t nitems = sizeof(wbuf);  // 4096
-
-// Below we receive a warning because the 3rd parameter should be the
-// number of elements to read, not the size in bytes. This case is a known
-// vulnerability described by the ARR38-C SEI-CERT rule.
-fread(wbuf, size, nit

[PATCH] D150520: [clang] Convert a few tests to opaque pointers

2023-05-15 Thread Amy Kwan via Phabricator via cfe-commits
amyk added a comment.

Hi, I just wanted to give a heads up that it appears that this patch is causing 
failures on some of the PPC buildbots.
In particular, the `const-str-array-decay.cl` appears to be failing. The 
failing build can be seen in: 
https://lab.llvm.org/buildbot/#/builders/36/builds/33110


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150520

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


[PATCH] D141714: Fix ast print of variables with attributes

2023-05-15 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: clang/lib/AST/DeclPrinter.cpp:270
+
+  // FIXME: Find a way to use the AttrList.inc. We use if-else statements
+  // to classify each of them.

I think this is something we need to just do the right way, right away.  The 
below is completely unsustainable, and is just going to encourage us to spend 
the next few years messing with this if/else-if tree.  I'll leave final 
judgement to Aaron, but just making this its own function dependent on 
TableGen'ed files seems like what we should be doing from the start.



Comment at: clang/test/Analysis/blocks.mm:81
 // ANALYZER-NEXT:   2: [B1.1] (CXXConstructExpr, [B1.3], 
StructWithCopyConstructor)
-// CHECK-NEXT:   3: StructWithCopyConstructor s(5) 
__attribute__((blocks("byref")));
+// CHECK-NEXT:   3: StructWithCopyConstructor s 
__attribute__((blocks("byref")))(5);
 // CHECK-NEXT:   4: ^{ }

aaron.ballman wrote:
> giulianobelinassi wrote:
> > aaron.ballman wrote:
> > > I can't quite tell if this change is good, bad, or just different.
> > This indeed doesn't look good, but for what it is worth it is still 
> > corretly accepted by clang and gcc.
> I think this is a regression in terms of readability, but perhaps it's one we 
> can live with.
So I have a BIG concern here.  The primary purpose of AST print is to be 
readable.  I don't think we should be willing to compromise that for what is, 
to the project, a non-goal.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141714

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


[PATCH] D137706: [clang][Interp] Implement IntegralToPointer casts

2023-05-15 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder abandoned this revision.
tbaeder added a comment.

I've already abandoned this locally, pretty sure I'll end up taking another 
approach.


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

https://reviews.llvm.org/D137706

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


[PATCH] D149447: [clang][analyzer] Improve documentation of StdCLibraryFunctionArgs checker (NFC)

2023-05-15 Thread Balázs Kéri via Phabricator via cfe-commits
balazske marked 2 inline comments as done.
balazske added inline comments.



Comment at: clang/docs/analyzer/checkers.rst:2490-2523
+**List of checked functions**
+
+``fgetc``, ``fread``, ``fwrite``, ``getc``, ``getchar``, ``getdelim``,
+``getenv``, ``getline``, ``isalnum``, ``isalpha``, ``isascii``, ``isblank``,
+``isdigit``, ``isgraph``, ``islower``, ``isprint``, ``ispunct``, ``isspace``,
+``isupper``, ``isxdigit``, ``read``, ``toascii``, ``tolower``, ``toupper``,
+``write``

Szelethus wrote:
> We should create an option or something the //actual// list of functions we 
> model. This is the prime example of unsustainable documenting.
Such function lists are used at documentation of other checkers, but I am not 
sure if it is good to add such a long list here. Probably the 
"DisplayLoadedSummaries" option of `apiModeling.StdCLibraryFunctions` checker 
can be used, this lists only the actually found functions (that have available 
declaration and are enabled), and the console output needs to be observed to 
see the list. And this option is currently not documented.



Comment at: clang/docs/analyzer/checkers.rst:2542
+modeling (and emit diagnostics) of additional functions that are defined in the
+POSIX standard. This option is disabled by default. Note that this option
+belongs to a separate built-in checker ``apiModeling.StdCLibraryFunctions`` and

Szelethus wrote:
> Isn't this something that we either do or do not enable by default? My memory 
> betrays me.
Currently ModelPOSIX is false by default.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149447

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


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

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

Ping


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

https://reviews.llvm.org/D147621

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


[PATCH] D147875: [clang][Diagnostics] Show line numbers when printing code snippets

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

Ping


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

https://reviews.llvm.org/D147875

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


[PATCH] D150040: [clang][Interp] Call invalid destructors

2023-05-15 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/D150040/new/

https://reviews.llvm.org/D150040

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


[PATCH] D150520: [clang] Convert a few tests to opaque pointers

2023-05-15 Thread Sergei Barannikov via Phabricator via cfe-commits
barannikov88 added a comment.

In D150520#4342429 , @amyk wrote:

> Hi, I just wanted to give a heads up that it appears that this patch is 
> causing failures on some of the PPC buildbots.
> In particular, the `const-str-array-decay.cl` appears to be failing. The 
> failing build can be seen in: 
> https://lab.llvm.org/buildbot/#/builders/36/builds/33110

Thanks!
I will be able to address this issue within a few hours. If it can't wait, 
please revert it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150520

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


[PATCH] D150352: [clang][dataflow] Don't analyze templated declarations.

2023-05-15 Thread Mikael Holmén via Phabricator via cfe-commits
uabelho added a comment.

Hello,

  
../../clang-tools-extra/clang-tidy/bugprone/UncheckedOptionalAccessCheck.cpp:43:27:
 error: 'build' is deprecated: Use the version that takes a const Decl & 
instead [-Werror,-Wdeprecated-declarations]
ControlFlowContext::build(&FuncDecl, *FuncDecl.getBody(), ASTCtx);
^
  ../../clang/include/clang/Analysis/FlowSensitive/ControlFlowContext.h:41:3: 
note: 'build' has been explicitly marked deprecated here
LLVM_DEPRECATED("Use the version that takes a const Decl & instead", "")
^
  ../include/llvm/Support/Compiler.h:143:50: note: expanded from macro 
'LLVM_DEPRECATED'
  #define LLVM_DEPRECATED(MSG, FIX) __attribute__((deprecated(MSG, FIX)))
   ^
  1 error generated.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150352

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


[PATCH] D150450: Add C++26 compile flags.

2023-05-15 Thread Erich Keane via Phabricator via cfe-commits
erichkeane marked 8 inline comments as done.
erichkeane added inline comments.



Comment at: clang/docs/CommandGuide/clang.rst:206-210
+   Working draft for ISO C++ 2026
+
+  | ``gnu++2c``
+
+   Working draft for ISO C++ 2026 with GNU extensions

aaron.ballman wrote:
> We shouldn't call it `ISO C++ 2026` until it's published by ISO. (I don't 
> have strong opinions about 2c vs 26 in there, but since we need to update it 
> anyway when 26 is released, I figured it'd be easier to find again with 2c.)
Ah, I just copied from what we had for C++23 before the flip.  But this makes 
sense, I chose `2c` for the reason you mentioned.



Comment at: clang/lib/Frontend/InitPreprocessor.cpp:456
+  // FIXME: Use correct value for C++26.
+  Builder.defineMacro("__cplusplus", "202402L");
+else if (LangOpts.CPlusPlus23)

aaron.ballman wrote:
> This value is fine by me, but we should probably coordinate with the GCC 
> folks so we don't wind up with two different values between us.
Email sent to GCC maintainer (aaron copied!).



Comment at: clang/www/cxx_status.html:1568
 
+C++2c implementation status
+

aaron.ballman wrote:
> cor3ntin wrote:
> > h-vetinari wrote:
> > > The longer this page gets, the more I feel it should be sorted in reverse 
> > > chronological order of the standard versions. It's bothersome IMO to keep 
> > > scrolling past almost-fully implemented standards (currently the tables 
> > > for C++17 & C++20) before getting to see the status of the latest & 
> > > greatest. 
> > > 
> > > https://en.cppreference.com/w/cpp/compiler_support is sorted in reverse 
> > > order as well.
> > This sounds like an excellent improvement.
> > Erich, would you rather do that in this pr, or i can submit a different 
> > patch afterwards?
> I love the idea, and I think it should be done in a separate patch.
Corentin: you're welcome to do it in a different patch, but I like the idea as 
well!


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

https://reviews.llvm.org/D150450

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


[PATCH] D150450: Add C++26 compile flags.

2023-05-15 Thread Mark de Wever via Phabricator via cfe-commits
Mordante added inline comments.



Comment at: clang/docs/CommandGuide/clang.rst:206-210
+   Working draft for ISO C++ 2026
+
+  | ``gnu++2c``
+
+   Working draft for ISO C++ 2026 with GNU extensions

erichkeane wrote:
> aaron.ballman wrote:
> > We shouldn't call it `ISO C++ 2026` until it's published by ISO. (I don't 
> > have strong opinions about 2c vs 26 in there, but since we need to update 
> > it anyway when 26 is released, I figured it'd be easier to find again with 
> > 2c.)
> Ah, I just copied from what we had for C++23 before the flip.  But this makes 
> sense, I chose `2c` for the reason you mentioned.
Note that before D149553 similar wording was used for C++2b "Working draft for 
ISO C++ 2023".


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

https://reviews.llvm.org/D150450

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


[PATCH] D150450: Add C++26 compile flags.

2023-05-15 Thread Erich Keane via Phabricator via cfe-commits
erichkeane updated this revision to Diff 522199.
erichkeane added a comment.

Aarons comments, split 23 changes into a separate patch and rebased.


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

https://reviews.llvm.org/D150450

Files:
  clang/docs/CommandGuide/clang.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Basic/LangStandard.h
  clang/include/clang/Basic/LangStandards.def
  clang/lib/Basic/LangOptions.cpp
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/test/Driver/cl-options.c
  clang/test/Driver/unknown-std.cpp
  clang/test/Preprocessor/init.c
  clang/www/OpenProjects.html
  clang/www/cxx_status.html

Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -65,6 +65,11 @@
  -std=c++23
  Partial
 
+
+ C++2c
+ -std=c++2c
+ Partial
+
 
 
 The Clang community is continually striving to improve C++ standards
@@ -1560,6 +1565,25 @@
 
 
 
+C++2c implementation status
+
+
+Clang has support for some of the features of the C++ standard following
+C++23, informally referred to as C++26.
+
+You can use Clang in C++2c mode with the -std=c++2c option.
+
+
+List of features and minimum Clang version with support
+
+ 
+Language Feature
+C++26 Proposal
+Available in Clang?
+ 
+ 
+ 
+
 Defect reports
 
 Clang generally aims to implement resolutions to Defect Reports (bug fixes
Index: clang/www/OpenProjects.html
===
--- clang/www/OpenProjects.html
+++ clang/www/OpenProjects.html
@@ -123,7 +123,7 @@
 
 
 
-Continue work on C++20, C++23, and C2x support:
+Continue work on C++20, C++23, C++2c, and C2x support:
   There are still several C++20 features to complete, and work has begun on
   supporting the latest language standards. Please see the
   C++ status report page to find out what is
Index: clang/test/Preprocessor/init.c
===
--- clang/test/Preprocessor/init.c
+++ clang/test/Preprocessor/init.c
@@ -8,6 +8,15 @@
 // BLOCKS:#define __BLOCKS__ 1
 // BLOCKS:#define __block __attribute__((__blocks__(byref)))
 //
+// RUN: %clang_cc1 -x c++ -fgnuc-version=4.2.1 -std=c++26 -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix CXX26 %s
+// RUN: %clang_cc1 -x c++ -fgnuc-version=4.2.1 -std=c++2c -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix CXX26 %s
+//
+// CXX26:#define __GNUG__ 4
+// CXX26:#define __GXX_EXPERIMENTAL_CXX0X__ 1
+// CXX26:#define __GXX_RTTI 1
+// CXX26:#define __GXX_WEAK__ 1
+// CXX26:#define __cplusplus 202402L
+// CXX26:#define __private_extern__ extern
 //
 // RUN: %clang_cc1 -x c++ -fgnuc-version=4.2.1 -std=c++23 -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix CXX2B %s
 // RUN: %clang_cc1 -x c++ -fgnuc-version=4.2.1 -std=c++2b -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix CXX2B %s
@@ -134,6 +143,14 @@
 // RUN: %clang_cc1 -ffreestanding -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix FREESTANDING %s
 // FREESTANDING:#define __STDC_HOSTED__ 0
 //
+// RUN: %clang_cc1 -x c++ -fgnuc-version=4.2.1 -std=gnu++26 -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix GXX26 %s
+// RUN: %clang_cc1 -x c++ -fgnuc-version=4.2.1 -std=gnu++2c -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix GXX26 %s
+//
+// GXX26:#define __GNUG__ 4
+// GXX26:#define __GXX_WEAK__ 1
+// GXX26:#define __cplusplus 202402L
+// GXX26:#define __private_extern__ extern
+//
 // RUN: %clang_cc1 -x c++ -fgnuc-version=4.2.1 -std=gnu++23 -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix GXX2B %s
 // RUN: %clang_cc1 -x c++ -fgnuc-version=4.2.1 -std=gnu++2b -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix GXX2B %s
 //
Index: clang/test/Driver/unknown-std.cpp
===
--- clang/test/Driver/unknown-std.cpp
+++ clang/test/Driver/unknown-std.cpp
@@ -19,6 +19,8 @@
 // CHECK-NEXT: note: use 'gnu++20' for 'ISO C++ 2020 DIS with GNU extensions' standard
 // CHECK-NEXT: note: use 'c++23' for 'ISO C++ 2023 DIS' standard
 // CHECK-NEXT: note: use 'gnu++23' for 'ISO C++ 2023 DIS with GNU extensions' standard
+// CHECK-NEXT: note: use 'c++2c' or 'c++26' for 'Working draft for C++2c' standard
+// CHECK-NEXT: note: use 'gnu++2c' or 'gnu++26' for 'Working draft for C++2c with GNU extensions' standard
 // CUDA-NEXT: note: use 'cuda' for 'NVIDIA CUDA(tm)' standard
 
 // Make sure that no other output is present.
Index: clang/test/Driver/cl-options.c
===
--- clang/test/Driver/cl-options.c
+++ clang/test/Driver/cl-options.c
@@ -604,7 +604,7 @@
 // STDCXX20: -std=c++20
 
 // RUN: %clang_cl -fmsc-ver

[PATCH] D150111: [clang][Interp] Implement lambda static invokers

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

Ping


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

https://reviews.llvm.org/D150111

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


[PATCH] D150226: [Clang] Remove ability to downgrade warning on the diagnostic for setting a non fixed enum to a value outside the range of the enumeration values

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

In D150226#4340166 , @manojgupta 
wrote:

> https://github.com/bminor/binutils-gdb/blob/master/include/diagnostics.h
>
> gdb only suppresses the warning. So this patch will likely break gdb.
>
> As per commit: 
> https://github.com/bminor/binutils-gdb/commit/ae61525fcf456ab395d55c45492a106d1275873a
>
>   Since the current code does what we want, and I don't see any way of doing 
> it
>   differently, ignore -Wenum-constexpr-conversion around it.

Hmmm, I'm not certain, but I *think* this does the right thing: 
`std::is_signed_v() : 
std::declval>())>;`

https://godbolt.org/z/MWY4e1e9e


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

https://reviews.llvm.org/D150226

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


[PATCH] D150528: [Clang] Fix the diagnoses when the argument to alignas is an incomplete type

2023-05-15 Thread Yurong via Phabricator via cfe-commits
yronglin updated this revision to Diff 522201.
yronglin added a comment.

Address comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150528

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/TreeTransform.h
  clang/test/Sema/sizeless-1.c
  clang/test/SemaCXX/attr-cxx0x.cpp
  clang/test/SemaCXX/builtin-align-cxx.cpp
  clang/test/SemaCXX/sizeless-1.cpp

Index: clang/test/SemaCXX/sizeless-1.cpp
===
--- clang/test/SemaCXX/sizeless-1.cpp
+++ clang/test/SemaCXX/sizeless-1.cpp
@@ -73,7 +73,7 @@
   svint8_t __attribute__((aligned(4))) aligned_int8_2; // expected-error {{'aligned' attribute cannot be applied to sizeless type 'svint8_t'}}
   svint8_t _Alignas(int) aligned_int8_3;   // expected-error {{'_Alignas' attribute cannot be applied to sizeless type 'svint8_t'}}
 
-  int _Alignas(svint8_t) aligned_int; // expected-error {{invalid application of 'alignof' to sizeless type 'svint8_t'}}
+  int _Alignas(svint8_t) aligned_int; // expected-error {{invalid application of '_Alignas' to sizeless type 'svint8_t'}}
 
   // Using pointers to sizeless data isn't wrong here, but because the
   // type is incomplete, it doesn't provide any alignment guarantees.
Index: clang/test/SemaCXX/builtin-align-cxx.cpp
===
--- clang/test/SemaCXX/builtin-align-cxx.cpp
+++ clang/test/SemaCXX/builtin-align-cxx.cpp
@@ -238,3 +238,6 @@
 static_assert(!__builtin_is_aligned(static_cast(7), static_cast(4)), "");
 static_assert(!__builtin_is_aligned(static_cast(7), static_cast(4)), "");
 static_assert(!__builtin_is_aligned(static_cast(7), static_cast(4)), "");
+
+// Check the diagnostic message
+_Alignas(void) char align_void_array[1]; // expected-error {{invalid application of '_Alignas' to an incomplete type 'void'}}
Index: clang/test/SemaCXX/attr-cxx0x.cpp
===
--- clang/test/SemaCXX/attr-cxx0x.cpp
+++ clang/test/SemaCXX/attr-cxx0x.cpp
@@ -50,3 +50,6 @@
 void func(void);
 
 alignas(4) auto PR19252 = 0;
+
+// Check the diagnostic message
+class alignas(void) AlignasVoid {}; // expected-error {{invalid application of 'alignas' to an incomplete type 'void'}}
Index: clang/test/Sema/sizeless-1.c
===
--- clang/test/Sema/sizeless-1.c
+++ clang/test/Sema/sizeless-1.c
@@ -64,7 +64,7 @@
   svint8_t __attribute__((aligned(4))) aligned_int8_2; // expected-error {{'aligned' attribute cannot be applied to sizeless type 'svint8_t'}}
   svint8_t _Alignas(int) aligned_int8_3;   // expected-error {{'_Alignas' attribute cannot be applied to sizeless type 'svint8_t'}}
 
-  int _Alignas(svint8_t) aligned_int; // expected-error {{invalid application of 'alignof' to sizeless type 'svint8_t'}}
+  int _Alignas(svint8_t) aligned_int; // expected-error {{invalid application of '_Alignas' to sizeless type 'svint8_t'}}
 
   // Using pointers to sizeless data isn't wrong here, but because the
   // type is incomplete, it doesn't provide any alignment guarantees.
Index: clang/lib/Sema/TreeTransform.h
===
--- clang/lib/Sema/TreeTransform.h
+++ clang/lib/Sema/TreeTransform.h
@@ -2674,7 +2674,8 @@
  SourceLocation OpLoc,
  UnaryExprOrTypeTrait ExprKind,
  SourceRange R) {
-return getSema().CreateUnaryExprOrTypeTraitExpr(TInfo, OpLoc, ExprKind, R);
+return getSema().CreateUnaryExprOrTypeTraitExpr(
+TInfo, OpLoc, ExprKind, getTraitSpelling(ExprKind), R);
   }
 
   /// Build a new sizeof, alignof or vec step expression with an
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -4373,7 +4373,8 @@
 bool Sema::CheckUnaryExprOrTypeTraitOperand(QualType ExprType,
 SourceLocation OpLoc,
 SourceRange ExprRange,
-UnaryExprOrTypeTrait ExprKind) {
+UnaryExprOrTypeTrait ExprKind,
+StringRef KWName) {
   if (ExprType->isDependentType())
 return false;
 
@@ -4403,12 +4404,11 @@
 
   if (RequireCompleteSizedType(
   OpLoc, ExprType, diag::err_sizeof_alignof_incomplete_or_sizeless_type,
-  getTraitSpelling(ExprKind), ExprRange))
+  KWName, ExprRange))
 return true;
 
   if (ExprType->isFunctionType()) {
-Diag(OpLoc, diag::err_si

[PATCH] D150579: [*]: fix syntax errors in HTML files

2023-05-15 Thread Mohammed Keyvanzadeh via Phabricator via cfe-commits
VoltrexMaster created this revision.
VoltrexMaster added reviewers: Amir, samsonov, STL_MSFT, jordan_rose, rsmith.
Herald added a reviewer: bollu.
Herald added subscribers: Enna1, wenlei, jvesely, arphaman.
Herald added a project: All.
VoltrexMaster requested review of this revision.
Herald added projects: clang, Sanitizers, LLVM, clang-tools-extra.
Herald added subscribers: cfe-commits, llvm-commits, Sanitizers.

Fix many syntax errors in all HTML files in the project.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D150579

Files:
  clang-tools-extra/docs/_templates/clangd_redirect.html
  clang/docs/LibASTMatchersReference.html
  clang/www/OpenProjects.html
  clang/www/analyzer/alpha_checks.html
  clang/www/analyzer/available_checks.html
  clang/www/analyzer/checker_dev_manual.html
  clang/www/analyzer/codechecker.html
  clang/www/analyzer/command-line.html
  clang/www/analyzer/faq.html
  clang/www/analyzer/implicit_checks.html
  clang/www/analyzer/open_projects.html
  clang/www/analyzer/potential_checkers.html
  clang/www/analyzer/release_notes.html
  clang/www/analyzer/scan-build.html
  clang/www/c_dr_status.html
  clang/www/c_status.html
  clang/www/compatibility.html
  clang/www/cxx_status.html
  clang/www/diagnostics.html
  compiler-rt/www/index.html
  libclc/www/index.html
  llvm/test/tools/llvm-original-di-preservation/Inputs/expected-compressed.html
  llvm/test/tools/llvm-original-di-preservation/Inputs/expected-sample.html
  llvm/test/tools/llvm-original-di-preservation/Inputs/expected-skipped.html
  llvm/test/tools/opt-viewer/Outputs/basic/basic_or.c.html
  llvm/test/tools/opt-viewer/Outputs/basic/basic_or.h.html
  llvm/test/tools/opt-viewer/Outputs/basic/index.html
  llvm/test/tools/opt-viewer/Outputs/filter/basic_or.c.html
  llvm/test/tools/opt-viewer/Outputs/filter/basic_or.h.html
  llvm/test/tools/opt-viewer/Outputs/filter/index.html
  llvm/test/tools/opt-viewer/Outputs/suppress/index.html
  llvm/test/tools/opt-viewer/Outputs/suppress/s.swift.html
  llvm/test/tools/opt-viewer/Outputs/unicode-function-name/index.html
  llvm/test/tools/opt-viewer/Outputs/unicode-function-name/s.swift.html
  polly/www/changelog.html
  polly/www/get_started.html
  polly/www/index.html
  polly/www/publications.html
  polly/www/todo.html

Index: polly/www/todo.html
===
--- polly/www/todo.html
+++ polly/www/todo.html
@@ -24,7 +24,7 @@
 Phase 1 - Get Something Working (Finished October 2010)
 
 
- Individual Phases
+ Individual Phases
 
  Phase 4
 
@@ -43,6 +43,7 @@
 
 
 
+
      - Add isl C++ bindings generator to isl
  Open
 
@@ -60,6 +61,7 @@
 
 
 
+
      - Optimize isl_int for small integers
  Done
 
@@ -71,6 +73,7 @@
 
 
 
+
      - Reconsider pass-ordering (move Polly later)
  Open
 
@@ -182,7 +185,7 @@
 integer wrapping
  Done
  Johannes
-
 
  
  Optimize Julia
@@ -194,6 +197,7 @@
Owner 
 
 
+
 
 Integrate Polly into Julia
  Open
@@ -211,6 +215,7 @@
 
 
 
+
      - Actually eliminate statements
  Done
 
@@ -226,6 +231,7 @@
Owner 
 
 
+
 
 Multi-level tiling
  Open
@@ -243,6 +249,7 @@
  Done
 
 
+
 
 Loop interchange after vectorization to maximize stride-one accesses
  Open
@@ -431,7 +438,7 @@
 
  Tobias, Andreas
 
-
+
 
 
 
@@ -553,36 +560,37 @@
Owner 
 
 
+
  Region detection
- Done
+ Done
 Ether
 
 
  Access Functions
- Done
+ Done
 John, Ether
 
 
  Alias sets
- Done
+ Done
 Ether
 
 
  Scalar evolution to affine expression
- Done
+ Done
 
 
 Ether
 
 
  SCoP extraction
- Done
+ Done
 Tobias, Ether
 
 
 
  SCoPs to polyhedral model
- Done
+ Done
 Tobias, Ether
 
  
@@ -594,7 +602,7 @@
 
 
  Define polyhedral description
- Done
+ Done
 Tobias
 
 
@@ -607,7 +615,7 @@
 
 
  Create LLVM-IR using CLooG
- Done
+ Done
  Tobias
 
 
@@ -621,12 +629,12 @@
 
  Setup git repositories
 
- Done
+ Done
  Tobias
 
 
  Add CLooG/isl to build system
- Done
+ Done
  Tobias
 
 
Index: polly/www/publications.html
===
--- polly/www/publications.html
+++ polly/www/publications.html
@@ -183,7 +183,7 @@
   Muthu Manikandan Baskaran, J. Ramanujam and P. Sadayappan
   CC 2010
   
-  Putting Automatic Polyhedral Compilation for GPGPU to Work
+  Putting Automatic Polyhedral Compilation for GPGPU to Work
   Soufiane Baghdadi, Armin Größlinger, and Albert Cohen. 
   In Proc. of Compilers for Parallel Computers (CPC), 2010.
   
Index: polly/www/index.html
===
--- polly/www/index.html
+++ polly/www/index.html
@@ -57,6 +57,7 @@
 The performance evaluation of GEMM
 
   
+  
   2017
   January
   
@@ -95,23 +96,23 @@
   Schedule trees: A tree-based mathematical program description
   that enables us to perform loop transformations on an abstract level,
   while issues like the generation of the correct loop structure and loop
-  bounds will be taken care of by our AST generator.
+  bounds will

[PATCH] D150528: [Clang] Fix the diagnoses when the argument to alignas is an incomplete type

2023-05-15 Thread Yurong via Phabricator via cfe-commits
yronglin marked 3 inline comments as done.
yronglin added a comment.

Thanks a lot for your review @aaron.ballman ! BTW, does the most good approach 
is that we just add a new `ParsedAttribute` with `TypeSourceInfo` but not an 
`UnaryExprOrTypeTraitExpr`?




Comment at: clang/docs/ReleaseNotes.rst:279-281
+- Clang now correctly diagnoses when the argument to alignas is an incomplete 
type.
+  (`#55175: `_,
+  Incorrect mention of 'alignof' in a diagnostic about 'alignas').

aaron.ballman wrote:
> 
+1, and add _Alignas



Comment at: clang/lib/Sema/SemaExpr.cpp:4714
+/// [dcl.align] An alignment-specifier of the form alignas(type-id) has the 
same
+/// effect as alignas(​alignof(type-id)).
+ExprResult Sema::ActOnAlignasTypeArgument(StringRef KWName, ParsedType Ty,

aaron.ballman wrote:
> It looks like a zero-width joiner was added here around the `!` that should 
> be removed.
Thanks, removed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150528

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


[PATCH] D146030: [clang][Interp] Handle LambdaExprs

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

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

https://reviews.llvm.org/D146030

Files:
  clang/lib/AST/Interp/ByteCodeEmitter.cpp
  clang/lib/AST/Interp/ByteCodeEmitter.h
  clang/lib/AST/Interp/ByteCodeExprGen.cpp
  clang/lib/AST/Interp/ByteCodeExprGen.h
  clang/lib/AST/Interp/EvalEmitter.h
  clang/lib/AST/Interp/Interp.h
  clang/test/AST/Interp/lambda.cpp

Index: clang/test/AST/Interp/lambda.cpp
===
--- /dev/null
+++ clang/test/AST/Interp/lambda.cpp
@@ -0,0 +1,109 @@
+// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -verify -std=c++20 %s
+// RUN: %clang_cc1 -verify=ref -std=c++20 %s
+
+constexpr int a = 12;
+constexpr int f = [c = a]() { return c; }();
+static_assert(f == a);
+
+
+constexpr int inc() {
+  int a = 10;
+  auto f = [&a]() {
+++a;
+  };
+
+  f();f();
+
+  return a;
+}
+static_assert(inc() == 12);
+
+constexpr int add(int a, int b) {
+  auto doIt = [a, b](int c) {
+return a + b + c;
+  };
+
+  return doIt(2);
+}
+static_assert(add(4, 5) == 11);
+
+
+constexpr int add2(int a, int b) {
+  auto doIt = [a, b](int c) {
+auto bar = [a]() { return a; };
+auto bar2 = [b]() { return b; };
+
+return bar() + bar2() + c;
+  };
+
+  return doIt(2);
+}
+static_assert(add2(4, 5) == 11);
+
+
+constexpr int div(int a, int b) {
+  auto f = [=]() {
+return a / b; // expected-note {{division by zero}} \
+  // ref-note {{division by zero}}
+  };
+
+  return f(); // expected-note {{in call to '&f->operator()()'}} \
+  // ref-note {{in call to '&f->operator()()'}}
+}
+static_assert(div(8, 2) == 4);
+static_assert(div(8, 0) == 4); // expected-error {{not an integral constant expression}} \
+   // expected-note {{in call to 'div(8, 0)'}} \
+   // ref-error {{not an integral constant expression}} \
+   // ref-note {{in call to 'div(8, 0)'}}
+
+
+struct F {
+  float f;
+};
+
+constexpr float captureStruct() {
+  F someF = {1.0};
+
+  auto p = [someF]() {
+return someF.f;
+  };
+
+  return p();
+}
+
+static_assert(captureStruct() == 1.0);
+
+
+int constexpr FunCase() {
+return [x = 10] {
+   decltype(x) y; // type int b/c not odr use
+  // refers to original init-capture
+   auto &z = x; // type const int & b/c odr use
+ // refers to lambdas copy of x
+y = 10; // Ok
+//z = 10; // Ill-formed
+return y;
+}();
+}
+
+constexpr int WC = FunCase();
+
+
+namespace LambdaParams {
+  template
+  constexpr void callThis(T t) {
+return t();
+  }
+
+  constexpr int foo() {
+int a = 0;
+auto f = [&a]() { ++a; };
+
+callThis(f);
+
+return a;
+  }
+  /// FIXME: This should work in the new interpreter.
+  static_assert(foo() == 1); // expected-error {{not an integral constant expression}}
+}
+
Index: clang/lib/AST/Interp/Interp.h
===
--- clang/lib/AST/Interp/Interp.h
+++ clang/lib/AST/Interp/Interp.h
@@ -850,6 +850,7 @@
   const Pointer &Field = Obj.atField(I);
   if (!CheckStore(S, OpPC, Field))
 return false;
+  Field.initialize();
   Field.deref() = Value;
   return true;
 }
Index: clang/lib/AST/Interp/EvalEmitter.h
===
--- clang/lib/AST/Interp/EvalEmitter.h
+++ clang/lib/AST/Interp/EvalEmitter.h
@@ -76,6 +76,10 @@
 
   /// Parameter indices.
   llvm::DenseMap Params;
+  /// Lambda captures.
+  /// Map from Decl* to [Offset, IsReference] pair.
+  llvm::DenseMap> LambdaCaptures;
+  unsigned LambdaThisCapture;
   /// Local descriptors.
   llvm::SmallVector, 2> Descriptors;
 
Index: clang/lib/AST/Interp/ByteCodeExprGen.h
===
--- clang/lib/AST/Interp/ByteCodeExprGen.h
+++ clang/lib/AST/Interp/ByteCodeExprGen.h
@@ -93,6 +93,7 @@
   bool VisitMaterializeTemporaryExpr(const MaterializeTemporaryExpr *E);
   bool VisitCompoundLiteralExpr(const CompoundLiteralExpr *E);
   bool VisitTypeTraitExpr(const TypeTraitExpr *E);
+  bool VisitLambdaExpr(const LambdaExpr *E);
 
 protected:
   bool visitExpr(const Expr *E) override;
Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp
===
--- clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -949,6 +949,43 @@
   return this->emitConstBool(E->getValue(), E);
 }
 
+template 
+bool ByteCodeExprGen::VisitLambdaExpr(const LambdaExpr *E) {
+  // XXX We assume here that a pointer-to-initialize is on the stack.
+
+  const Record *R = P.getOrCreateRecord(E->getLambdaClass());
+
+  auto *CaptureInitIt = E->capture_init_begin();
+  // Initialize all fields (which represent lambda captures) of the
+  // record wi

[PATCH] D89046: [AST] Build recovery expression by default for all language.

2023-05-15 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added a comment.
Herald added a project: All.

Hello folks, it looks like this PR is linked to a crash bug: 
https://github.com/llvm/llvm-project/issues/62711


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89046

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


[PATCH] D141714: Fix ast print of variables with attributes

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



Comment at: clang/lib/AST/DeclPrinter.cpp:270
+
+  // FIXME: Find a way to use the AttrList.inc. We use if-else statements
+  // to classify each of them.

erichkeane wrote:
> I think this is something we need to just do the right way, right away.  The 
> below is completely unsustainable, and is just going to encourage us to spend 
> the next few years messing with this if/else-if tree.  I'll leave final 
> judgement to Aaron, but just making this its own function dependent on 
> TableGen'ed files seems like what we should be doing from the start.
As much as I hate to obligate anyone to get involved in tablegen to solve a 
problem, I share the concern that this is not an extensible approach. I think 
@giulianobelinassi should move forward by trying to emit this from 
ClangAttrEmitter.cpp if at all possible.



Comment at: clang/test/Analysis/blocks.mm:81
 // ANALYZER-NEXT:   2: [B1.1] (CXXConstructExpr, [B1.3], 
StructWithCopyConstructor)
-// CHECK-NEXT:   3: StructWithCopyConstructor s(5) 
__attribute__((blocks("byref")));
+// CHECK-NEXT:   3: StructWithCopyConstructor s 
__attribute__((blocks("byref")))(5);
 // CHECK-NEXT:   4: ^{ }

erichkeane wrote:
> aaron.ballman wrote:
> > giulianobelinassi wrote:
> > > aaron.ballman wrote:
> > > > I can't quite tell if this change is good, bad, or just different.
> > > This indeed doesn't look good, but for what it is worth it is still 
> > > corretly accepted by clang and gcc.
> > I think this is a regression in terms of readability, but perhaps it's one 
> > we can live with.
> So I have a BIG concern here.  The primary purpose of AST print is to be 
> readable.  I don't think we should be willing to compromise that for what is, 
> to the project, a non-goal.
I think this issue would be resolved by going with a tablegen approach -- this 
attribute exists because of the `__block` keyword, so ideally, we wouldn't even 
be printing `__attribute__` here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141714

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


[clang] 9715af4 - [AIX][clang] Storage Locations for Constant Pointers

2023-05-15 Thread Qiongsi Wu via cfe-commits

Author: Qiongsi Wu
Date: 2023-05-15T11:31:00-04:00
New Revision: 9715af434579022b5ef31781be40b722d7e63bee

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

LOG: [AIX][clang] Storage Locations for Constant Pointers

This patch adds clang options `-mxcoff-roptr` and `-mno-xcoff-roptr` to specify 
storage locations for constant pointers on AIX.

When the `-mxcoff-roptr` option is in effect, constant pointers, virtual 
function tables, and virtual type tables are placed in read-only storage. When 
the `-mno-xcoff-roptr` option is in effect, pointers, virtual function tables, 
and virtual type tables are placed are placed in read/write storage.

This patch depends on https://reviews.llvm.org/D144189.

Reviewed By: hubert.reinterpretcast, stephenpeckham

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

Added: 
clang/test/CodeGen/PowerPC/aix-roptr.c
clang/test/Driver/ppc-roptr.c

Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/Basic/CodeGenOptions.def
clang/include/clang/Basic/DiagnosticDriverKinds.td
clang/include/clang/Driver/Options.td
clang/lib/CodeGen/BackendUtil.cpp
clang/lib/Driver/ToolChains/AIX.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/lib/Frontend/CompilerInvocation.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 00edb842ae715..7e8dca8b31871 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -543,6 +543,12 @@ AIX Support
   This option is an alternative to the `--build-id=0xHEXSTRING` GNU linker 
option
   which is currently not supported by the AIX linker.
 
+- Introduced the ``-mxcoff-roptr`` option to place constant objects with
+  relocatable address values in the read-only data section. This option should
+  be used with the ``-fdata-sections`` option, and is not supported with
+  ``-fno-data-sections``. When ``-mxcoff-roptr`` is in effect at link time,
+  read-only data sections with relocatable address values that resolve to
+  imported symbols are made writable.
 
 WebAssembly Support
 ^^^

diff  --git a/clang/include/clang/Basic/CodeGenOptions.def 
b/clang/include/clang/Basic/CodeGenOptions.def
index 7151fe9d65682..c026d8e30551f 100644
--- a/clang/include/clang/Basic/CodeGenOptions.def
+++ b/clang/include/clang/Basic/CodeGenOptions.def
@@ -52,6 +52,7 @@ CODEGENOPT(UniqueBasicBlockSectionNames, 1, 1) ///< Set for 
-funique-basic-block
///< Produce unique section 
names with
///< basic block sections.
 CODEGENOPT(EnableAIXExtendedAltivecABI, 1, 0) ///< Set for -mabi=vec-extabi. 
Enables the extended Altivec ABI on AIX.
+CODEGENOPT(XCOFFReadOnlyPointers, 1, 0) ///< Set for -mxcoff-roptr.
 ENUM_CODEGENOPT(FramePointer, FramePointerKind, 2, FramePointerKind::None) /// 
frame-pointer: all,non-leaf,none
 
 CODEGENOPT(ClearASTBeforeBackend , 1, 0) ///< Free the AST before running 
backend code generation. Only works with -disable-free.

diff  --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index 27dcc0dd59f37..8a5a3ad3b7fcf 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -649,6 +649,8 @@ def err_drv_invalid_object_mode : Error<
   "OBJECT_MODE setting %0 is not recognized and is not a valid setting">;
 
 def err_aix_unsupported_tls_model : Error<"TLS model '%0' is not yet supported 
on AIX">;
+def err_roptr_requires_data_sections: Error<"-mxcoff-roptr is supported only 
with -fdata-sections">;
+def err_roptr_cannot_build_shared: Error<"-mxcoff-roptr is not supported with 
-shared">;
 
 def err_invalid_cxx_abi : Error<"invalid C++ ABI name '%0'">;
 def err_unsupported_cxx_abi : Error<"C++ ABI '%0' is not supported on target 
triple '%1'">;

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index ac2c3c2fa718b..9d765cc6329b8 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3907,6 +3907,9 @@ def maix_struct_return : Flag<["-"], 
"maix-struct-return">,
 def msvr4_struct_return : Flag<["-"], "msvr4-struct-return">,
   Group, Flags<[CC1Option]>,
   HelpText<"Return small structs in registers (PPC32 only)">;
+def mxcoff_roptr : Flag<["-"], "mxcoff-roptr">, Group, 
Flags<[CC1Option]>,
+  HelpText<"Place constant objects with relocatable address values in the RO 
data section and add -bforceimprw to the linker flags (AIX only)">;
+def mno_xcoff_roptr : Flag<["-"], "mno-xcoff-roptr">, Group;
 
 def mvx : Flag<["-"], "mvx">, Group;
 def mno_vx : Flag<["-"], "mno-vx">, 

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

2023-05-15 Thread Qiongsi Wu via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9715af434579: [AIX][clang] Storage Locations for Constant 
Pointers (authored by qiongsiwu1).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144190

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

Index: clang/test/Driver/ppc-roptr.c
===
--- /dev/null
+++ clang/test/Driver/ppc-roptr.c
@@ -0,0 +1,46 @@
+// RUN: %clang -### --target=powerpc-ibm-aix-xcoff -mxcoff-roptr %s 2>&1 | \
+// RUN: FileCheck %s --check-prefixes=ROPTR,LINK
+// RUN: %clang -### --target=powerpc-ibm-aix-xcoff -c -mxcoff-roptr %s 2>&1 | \
+// RUN: FileCheck %s --check-prefix=ROPTR
+// RUN: %clang -### --target=powerpc-ibm-aix-xcoff -mxcoff-roptr -mno-xcoff-roptr %s 2>&1 | \
+// RUN: FileCheck %s --check-prefix=NO_ROPTR
+
+// RUN: %clang -### --target=powerpc64-ibm-aix-xcoff -mxcoff-roptr %s 2>&1 | \
+// RUN: FileCheck %s --check-prefixes=ROPTR,LINK
+// RUN: %clang -### --target=powerpc64-ibm-aix-xcoff -S -mxcoff-roptr %s 2>&1 | \
+// RUN: FileCheck %s --check-prefix=ROPTR
+// RUN: %clang -### --target=powerpc-ibm-aix-xcoff %s 2>&1 | \
+// RUN: FileCheck %s --check-prefix=NO_ROPTR
+// RUN: %clang -### --target=powerpc64-ibm-aix-xcoff -mxcoff-roptr -flto %s 2>&1 | \
+// RUN: FileCheck %s --check-prefixes=ROPTR,LINK,LTO_ROPTR
+// RUN: touch %t.o
+// RUN: %clang -### --target=powerpc64-ibm-aix-xcoff -mxcoff-roptr %t.o 2>&1 | \
+// RUN: FileCheck %s --check-prefix=LINK
+
+// RUN: %clang -### --target=powerpc64le-unknown-linux-gnu -mxcoff-roptr \
+// RUN: %s 2>&1 | FileCheck %s --check-prefix=TARGET_ROPTR_ERR
+// RUN: %clang -### --target=powerpc64le-unknown-linux-gnu -mno-xcoff-roptr \
+// RUN: %s 2>&1 | FileCheck %s --check-prefix=TARGET_NOROPTR_ERR
+// RUN: touch %t.o
+// RUN: %clang -### --target=powerpc64-ibm-aix-xcoff -mxcoff-roptr -shared \
+// RUN: %t.o 2>&1 | FileCheck %s --check-prefix=SHARED_ERR
+// RUN: %clang -### --target=powerpc64le-unknown-linux-gnu -mxcoff-roptr -flto \
+// RUN: %t.o 2>&1 | FileCheck %s --check-prefix=TARGET_ROPTR_ERR
+// RUN: %clang -### --target=powerpc64-ibm-aix-xcoff -mxcoff-roptr -flto -fno-data-sections \
+// RUN: %t.o 2>&1 | FileCheck %s --check-prefix=DATA_SECTION_ERR
+// RUN: %clang -### --target=powerpc64-ibm-aix-xcoff -mno-xcoff-roptr -flto -fno-data-sections \
+// RUN: %t.o 2>&1 | FileCheck %s --check-prefix=NO_DATA_SECTION_ERR
+// RUN: %clang -### --target=powerpc64le-unknown-linux-gnu -mno-xcoff-roptr -flto \
+// RUN: %t.o 2>&1 | FileCheck %s --check-prefix=TARGET_NOROPTR_ERR
+
+// ROPTR: "-mxcoff-roptr"
+// LINK: "-bforceimprw"
+// LTO_ROPTR: "-bplugin_opt:-mxcoff-roptr"
+// NO_ROPTR-NOT: "-mxcoff-roptr"
+// NO_ROPTR-NOT: "-bforceimprw"
+
+// DATA_SECTION_ERR: error: -mxcoff-roptr is supported only with -fdata-sections
+// NO_DATA_SECTION_ERR-NOT: error: -mxcoff-roptr is supported only with -fdata-sections
+// TARGET_ROPTR_ERR: error: unsupported option '-mxcoff-roptr' for target 'powerpc64le-unknown-linux-gnu'
+// TARGET_NOROPTR_ERR: error: unsupported option '-mno-xcoff-roptr' for target 'powerpc64le-unknown-linux-gnu'
+// SHARED_ERR: error: -mxcoff-roptr is not supported with -shared
Index: clang/test/CodeGen/PowerPC/aix-roptr.c
===
--- /dev/null
+++ clang/test/CodeGen/PowerPC/aix-roptr.c
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -triple=powerpc-ibm-aix-xcoff -mxcoff-roptr -fdata-sections \
+// RUN: -S <%s | FileCheck %s --check-prefix=CHECK32
+// RUN: %clang_cc1 -triple=powerpc64-ibm-aix-xcoff -mxcoff-roptr -fdata-sections \
+// RUN: -S <%s | FileCheck %s --check-prefix=CHECK64
+// RUN: not %clang_cc1 -triple=powerpc-ibm-aix-xcoff -mxcoff-roptr \
+// RUN: -S <%s 2>&1 | FileCheck %s --check-prefix=DATA_SECTION_ERR
+// RUN: not %clang_cc1 -triple=powerpc64-ibm-aix-xcoff -mxcoff-roptr \
+// RUN: -S <%s 2>&1 | FileCheck %s --check-prefix=DATA_SECTION_ERR
+// RUN: not %clang_cc1 -triple=powerpc64le-unknown-linux-gnu -mxcoff-roptr \
+// RUN: %s 2>&1 | FileCheck %s --check-prefix=TARGET_ROPTR_ERR
+
+char c1 = 10;
+char* const c1_ptr = &c1;
+// CHECK32: .csect c1_ptr[RO],2
+// CHECK32-NEXT:	.globl	c1_ptr[RO]
+// CHECK32-NEXT:	.align	2
+// CHECK32-NEXT:	.vbyte	4, c1[RW]
+
+// CHECK64: .csect c1_ptr[RO],3
+// CHECK64-NEXT:	.globl	c1_ptr[RO]
+// CHECK64-NEXT:	

[PATCH] D150528: [Clang] Fix the diagnoses when the argument to alignas is an incomplete type

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

In D150528#4342535 , @yronglin wrote:

> Thanks a lot for your review @aaron.ballman ! BTW, does the most good 
> approach is that we just add a new `ParsedAttribute` with `TypeSourceInfo` 
> but not an `UnaryExprOrTypeTraitExpr`, and only do a sema check same as 
> `alignof(type-id)`?

Because you've already got a `ParsedAttr`, I think you'd use this constructor: 
https://github.com/llvm/llvm-project/blob/main/clang/include/clang/Sema/ParsedAttr.h#L274
 and move the call to `GetTypeFromParser()` until later, but it should still be 
modelled as a `UnaryExprOrTypeTraitExpr`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150528

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


[PATCH] D147321: [RFC][Flang][OMPIRBuilder] Add nounwind attribute to the LLVM IR

2023-05-15 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added inline comments.



Comment at: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp:5063
+  }
+}
+

Style `F`



Comment at: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp:5063
+  }
+}
+

jdoerfert wrote:
> Style `F`
Why does this belong here? We should do it like clang, one function at a time, 
or in a generic place. This is not OpenMP specific at all.



Comment at: llvm/lib/IR/IRBuilder.cpp:1426
+}
+
 IRBuilderDefaultInserter::~IRBuilderDefaultInserter() = default;

No llvm::


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

https://reviews.llvm.org/D147321

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


[PATCH] D150450: Add C++26 compile flags.

2023-05-15 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: clang/lib/Frontend/InitPreprocessor.cpp:456
+  // FIXME: Use correct value for C++26.
+  Builder.defineMacro("__cplusplus", "202402L");
+else if (LangOpts.CPlusPlus23)

erichkeane wrote:
> aaron.ballman wrote:
> > This value is fine by me, but we should probably coordinate with the GCC 
> > folks so we don't wind up with two different values between us.
> Email sent to GCC maintainer (aaron copied!).
GCC is going to go with 202400L, so that is what we're going to do.



Comment at: clang/lib/Frontend/InitPreprocessor.cpp:456
+  // FIXME: Use correct value for C++26.
+  Builder.defineMacro("__cplusplus", "202102L");
+// FIXME: Use correct value for C++23, and update C++26 to be 'one more'.

cor3ntin wrote:
> cor3ntin wrote:
> > erichkeane wrote:
> > > At the moment, I just chose '1 more than c++23', but that hasn't been set 
> > > yet.  Once we have the final value, we should make this 1 more than 23's 
> > > official value.
> > A value lesser than 202401L seems super confusing to me
> In the DIS __cplusplus is 202302L
GCC is going to go with 202400L, so that is what we're going to do.


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

https://reviews.llvm.org/D150450

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


[PATCH] D150450: Add C++26 compile flags.

2023-05-15 Thread Erich Keane via Phabricator via cfe-commits
erichkeane updated this revision to Diff 522214.
erichkeane added a comment.

change __cplusplus to match GCC's plan.


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

https://reviews.llvm.org/D150450

Files:
  clang/docs/CommandGuide/clang.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Basic/LangStandard.h
  clang/include/clang/Basic/LangStandards.def
  clang/lib/Basic/LangOptions.cpp
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/test/Driver/cl-options.c
  clang/test/Driver/unknown-std.cpp
  clang/test/Preprocessor/init.c
  clang/www/OpenProjects.html
  clang/www/cxx_status.html

Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -65,6 +65,11 @@
  -std=c++23
  Partial
 
+
+ C++2c
+ -std=c++2c
+ Partial
+
 
 
 The Clang community is continually striving to improve C++ standards
@@ -1560,6 +1565,25 @@
 
 
 
+C++2c implementation status
+
+
+Clang has support for some of the features of the C++ standard following
+C++23, informally referred to as C++26.
+
+You can use Clang in C++2c mode with the -std=c++2c option.
+
+
+List of features and minimum Clang version with support
+
+ 
+Language Feature
+C++26 Proposal
+Available in Clang?
+ 
+ 
+ 
+
 Defect reports
 
 Clang generally aims to implement resolutions to Defect Reports (bug fixes
Index: clang/www/OpenProjects.html
===
--- clang/www/OpenProjects.html
+++ clang/www/OpenProjects.html
@@ -123,7 +123,7 @@
 
 
 
-Continue work on C++20, C++23, and C2x support:
+Continue work on C++20, C++23, C++2c, and C2x support:
   There are still several C++20 features to complete, and work has begun on
   supporting the latest language standards. Please see the
   C++ status report page to find out what is
Index: clang/test/Preprocessor/init.c
===
--- clang/test/Preprocessor/init.c
+++ clang/test/Preprocessor/init.c
@@ -8,6 +8,15 @@
 // BLOCKS:#define __BLOCKS__ 1
 // BLOCKS:#define __block __attribute__((__blocks__(byref)))
 //
+// RUN: %clang_cc1 -x c++ -fgnuc-version=4.2.1 -std=c++26 -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix CXX26 %s
+// RUN: %clang_cc1 -x c++ -fgnuc-version=4.2.1 -std=c++2c -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix CXX26 %s
+//
+// CXX26:#define __GNUG__ 4
+// CXX26:#define __GXX_EXPERIMENTAL_CXX0X__ 1
+// CXX26:#define __GXX_RTTI 1
+// CXX26:#define __GXX_WEAK__ 1
+// CXX26:#define __cplusplus 202402L
+// CXX26:#define __private_extern__ extern
 //
 // RUN: %clang_cc1 -x c++ -fgnuc-version=4.2.1 -std=c++23 -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix CXX2B %s
 // RUN: %clang_cc1 -x c++ -fgnuc-version=4.2.1 -std=c++2b -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix CXX2B %s
@@ -134,6 +143,14 @@
 // RUN: %clang_cc1 -ffreestanding -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix FREESTANDING %s
 // FREESTANDING:#define __STDC_HOSTED__ 0
 //
+// RUN: %clang_cc1 -x c++ -fgnuc-version=4.2.1 -std=gnu++26 -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix GXX26 %s
+// RUN: %clang_cc1 -x c++ -fgnuc-version=4.2.1 -std=gnu++2c -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix GXX26 %s
+//
+// GXX26:#define __GNUG__ 4
+// GXX26:#define __GXX_WEAK__ 1
+// GXX26:#define __cplusplus 202402L
+// GXX26:#define __private_extern__ extern
+//
 // RUN: %clang_cc1 -x c++ -fgnuc-version=4.2.1 -std=gnu++23 -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix GXX2B %s
 // RUN: %clang_cc1 -x c++ -fgnuc-version=4.2.1 -std=gnu++2b -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix GXX2B %s
 //
Index: clang/test/Driver/unknown-std.cpp
===
--- clang/test/Driver/unknown-std.cpp
+++ clang/test/Driver/unknown-std.cpp
@@ -19,6 +19,8 @@
 // CHECK-NEXT: note: use 'gnu++20' for 'ISO C++ 2020 DIS with GNU extensions' standard
 // CHECK-NEXT: note: use 'c++23' for 'ISO C++ 2023 DIS' standard
 // CHECK-NEXT: note: use 'gnu++23' for 'ISO C++ 2023 DIS with GNU extensions' standard
+// CHECK-NEXT: note: use 'c++2c' or 'c++26' for 'Working draft for C++2c' standard
+// CHECK-NEXT: note: use 'gnu++2c' or 'gnu++26' for 'Working draft for C++2c with GNU extensions' standard
 // CUDA-NEXT: note: use 'cuda' for 'NVIDIA CUDA(tm)' standard
 
 // Make sure that no other output is present.
Index: clang/test/Driver/cl-options.c
===
--- clang/test/Driver/cl-options.c
+++ clang/test/Driver/cl-options.c
@@ -604,7 +604,7 @@
 // STDCXX20: -std=c++20
 
 // RUN: %clang_cl -fmsc-version=1900 -TP -std:c++latest 

[PATCH] D150450: Add C++26 compile flags.

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

LGTM, thank you Erich!


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

https://reviews.llvm.org/D150450

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


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

2023-05-15 Thread Qiongsi Wu via Phabricator via cfe-commits
qiongsiwu1 added a comment.

This patch is causing some buildbot failures. Specifically

https://lab.llvm.org/buildbot/#/builders/139/builds/40652
https://lab.llvm.org/buildbot/#/builders/258/builds/810

I am looking into them. Please revert if this cannot wait. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144190

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


[PATCH] D144654: [Lex] Warn when defining or undefining any builtin macro

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

I've gone with handling the _GNU_SOURCE problem in the clang-tidy tests by 
re-using the list of feature test macros in shouldWarnOnMacroDef, and not 
warning if there's a match.


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

https://reviews.llvm.org/D144654

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Lex/PPDirectives.cpp
  clang/test/Lexer/builtin_redef.c
  clang/test/Preprocessor/macro-reserved.c
  clang/test/Preprocessor/macro-reserved.cpp

Index: clang/test/Preprocessor/macro-reserved.cpp
===
--- clang/test/Preprocessor/macro-reserved.cpp
+++ clang/test/Preprocessor/macro-reserved.cpp
@@ -12,7 +12,7 @@
 #undef _HAVE_X
 #undef X__Y
 
-#undef __cplusplus
+#undef __cplusplus // expected-warning {{undefining builtin macro}}
 #define __cplusplus
 
 // allowlisted definitions
Index: clang/test/Preprocessor/macro-reserved.c
===
--- clang/test/Preprocessor/macro-reserved.c
+++ clang/test/Preprocessor/macro-reserved.c
@@ -6,6 +6,7 @@
 #define __cplusplus
 #define _HAVE_X 0
 #define X__Y
+#define __STDC__ 1 // expected-warning {{redefining builtin macro}}
 
 #undef for
 #undef final
@@ -13,6 +14,7 @@
 #undef __cplusplus
 #undef _HAVE_X
 #undef X__Y
+#undef __STDC_HOSTED__ // expected-warning {{undefining builtin macro}}
 
 // allowlisted definitions
 #define while while
Index: clang/test/Lexer/builtin_redef.c
===
--- clang/test/Lexer/builtin_redef.c
+++ clang/test/Lexer/builtin_redef.c
@@ -1,12 +1,24 @@
-// RUN: %clang_cc1 %s -D__TIME__=1234 -U__DATE__ -E 2>&1 | FileCheck %s --check-prefix=CHECK-OUT
-// RUN: %clang_cc1 %s -D__TIME__=1234 -U__DATE__ -E 2>&1 | FileCheck %s --check-prefix=CHECK-WARN
-// RUN: not %clang_cc1 %s -D__TIME__=1234 -U__DATE__ -E 2>&1 -pedantic-errors | FileCheck %s --check-prefix=CHECK-ERR
+// RUN: %clang_cc1 %s -D__TIME__=1234 -U__DATE__ -D__STDC__=1 -U__STDC_HOSTED__ -E 2>&1 | FileCheck %s --check-prefix=CHECK-OUT
+// RUN: %clang_cc1 %s -D__TIME__=1234 -U__DATE__ -D__STDC__=1 -U__STDC_HOSTED__ -E 2>&1 | FileCheck %s --check-prefix=CHECK-WARN
+// RUN: not %clang_cc1 %s -D__TIME__=1234 -U__DATE__ -D__STDC__=1 -U__STDC_HOSTED__ -E 2>&1 -pedantic-errors | FileCheck %s --check-prefix=CHECK-ERR
 
 // CHECK-WARN: :{{.*}} warning: redefining builtin macro
+// CHECK-WARN-NEXT: #define __TIME__ 1234
 // CHECK-WARN: :{{.*}} warning: undefining builtin macro
+// CHECK-WARN-NEXT: #undef __DATE__
+// CHECK-WARN: :{{.*}} warning: redefining builtin macro
+// CHECK-WARN-NEXT: #define __STDC__ 1
+// CHECK-WARN: :{{.*}} warning: undefining builtin macro
+// CHECK-WARN-NEXT: #undef __STDC_HOSTED__
 
 // CHECK-ERR: :{{.*}} error: redefining builtin macro
+// CHECK-ERR-NEXT: #define __TIME__ 1234
+// CHECK-ERR: :{{.*}} error: undefining builtin macro
+// CHECK-ERR-NEXT: #undef __DATE__
+// CHECK-ERR: :{{.*}} error: redefining builtin macro
+// CHECK-ERR-NEXT: #define __STDC__ 1
 // CHECK-ERR: :{{.*}} error: undefining builtin macro
+// CHECK-ERR-NEXT: #undef __STDC_HOSTED__
 
 int n = __TIME__;
 __DATE__
Index: clang/lib/Lex/PPDirectives.cpp
===
--- clang/lib/Lex/PPDirectives.cpp
+++ clang/lib/Lex/PPDirectives.cpp
@@ -109,52 +109,52 @@
   PED_Elifndef
 };
 
+static bool isFeatureTestMacro(StringRef MacroName) {
+  // list from:
+  // - https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_macros.html
+  // - https://docs.microsoft.com/en-us/cpp/c-runtime-library/security-features-in-the-crt?view=msvc-160
+  // - man 7 feature_test_macros
+  // The list must be sorted for correct binary search.
+  static constexpr StringRef ReservedMacro[] = {
+  "_ATFILE_SOURCE",
+  "_BSD_SOURCE",
+  "_CRT_NONSTDC_NO_WARNINGS",
+  "_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES",
+  "_CRT_SECURE_NO_WARNINGS",
+  "_FILE_OFFSET_BITS",
+  "_FORTIFY_SOURCE",
+  "_GLIBCXX_ASSERTIONS",
+  "_GLIBCXX_CONCEPT_CHECKS",
+  "_GLIBCXX_DEBUG",
+  "_GLIBCXX_DEBUG_PEDANTIC",
+  "_GLIBCXX_PARALLEL",
+  "_GLIBCXX_PARALLEL_ASSERTIONS",
+  "_GLIBCXX_SANITIZE_VECTOR",
+  "_GLIBCXX_USE_CXX11_ABI",
+  "_GLIBCXX_USE_DEPRECATED",
+  "_GNU_SOURCE",
+  "_ISOC11_SOURCE",
+  "_ISOC95_SOURCE",
+  "_ISOC99_SOURCE",
+  "_LARGEFILE64_SOURCE",
+  "_POSIX_C_SOURCE",
+  "_REENTRANT",
+  "_SVID_SOURCE",
+  "_THREAD_SAFE",
+  "_XOPEN_SOURCE",
+  "_XOPEN_SOURCE_EXTENDED",
+  "__STDCPP_WANT_MATH_SPEC_FUNCS__",
+  "__STDC_FORMAT_MACROS",
+  };
+  return std::binary_search(std::begin(ReservedMacro), std::end(ReservedMacro),
+MacroName);
+}
+
 static MacroDiag shouldWarnOnMacroDef(Preprocessor &PP, IdentifierInfo *II) {
   const 

  1   2   3   >