[PATCH] D151397: [3/3][RISCV][POC] Model vxrm in C intrinsics for RVV fixed-point instruction vaadd, vasub

2023-06-12 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 530408.
eopXD added a comment.

Add semantic checking for the vxrm paramter.
Test case are added 
`CodeGen/RISCV/rvv-intrinsics-handcrafted/{vaadd/vaaddu/vasub/vasubu}`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151397

Files:
  clang/include/clang/Basic/riscv_vector.td
  clang/lib/Sema/SemaChecking.cpp
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaadd.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaaddu.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vasub.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vasubu.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vaadd.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vaaddu.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vasub.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vasubu.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vaadd.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vaaddu.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vasub.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vasubu.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/overloaded/vaadd.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/overloaded/vaaddu.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/overloaded/vasub.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/overloaded/vasubu.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vaadd-out-of-range.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vaaddu-out-of-range.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vasub-out-of-range.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vasubu-out-of-range.c
  llvm/include/llvm/IR/IntrinsicsRISCV.td
  llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td
  llvm/test/CodeGen/RISCV/rvv/masked-tama.ll
  llvm/test/CodeGen/RISCV/rvv/masked-tamu.ll
  llvm/test/CodeGen/RISCV/rvv/masked-tuma.ll
  llvm/test/CodeGen/RISCV/rvv/masked-tumu.ll
  llvm/test/CodeGen/RISCV/rvv/vaadd.ll
  llvm/test/CodeGen/RISCV/rvv/vaaddu.ll
  llvm/test/CodeGen/RISCV/rvv/vasub.ll
  llvm/test/CodeGen/RISCV/rvv/vasubu.ll

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


[PATCH] D152443: Add operator style options to clang-format

2023-06-12 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

did you cover the case where I have a namespaced, static

  foo::Bar->operator==()
  foo::Bar->m_oper->operator==()
  foo::Bar->m_oper.operator==()
  foo::Bar.operator==()




Comment at: clang/lib/Format/TokenAnnotator.cpp:4207-4210
+if (!Token->hasWhitespaceBefore()) { // Skip until we reach whitespace
+  Token = Token->Previous;
+  continue;
+}

I don't quite understand what case needs this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152443

___
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-06-12 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet accepted this revision.
kadircet added a comment.
This revision is now accepted and ready to land.

thanks a lot for bearing with me, LGTM!

let me know if i should land this for you.




Comment at: clang-tools-extra/clangd/ClangdServer.cpp:165
   bool CollectInactiveRegions;
+  const ClangdServer::Options &Opts;
 };

nit: no need to store a reference to whole Options struct, you can have single 
boolean.


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] D152090: [clang][Driver] Add -fcaret-diagnostics-max-lines= as a driver option

2023-06-12 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder marked an inline comment as done.
tbaeder added inline comments.



Comment at: clang/include/clang/Driver/Options.td:2303
+  Group, Flags<[NoXarchOption, CC1Option, CoreOption]>,
+  HelpText<"Set the maximum number of source lines to show in a caret 
diagnostic">,
+  MarshallingInfoInt, 
"DiagnosticOptions::DefaultSnippetLineLimit">;

MaskRay wrote:
> MaskRay wrote:
> > Add ` (0 = no limit)` if useful
> `NoXarchOption` emits an error if an option is used after `-Xarch_*`. The 
> feature only applies to a small set of options (e.g. `-o`) and is not very 
> useful for most options, but `NoXarchOption` was improperly named 
> `DriverOption` and lured some contributors to add `NoXarchOption` to options 
> that should not have the flag.
> 
> For `fcaret-diagnostics-max-lines=`, we should remove `NoXarchOption`.
Removed it, thanks for the explanation. I guess this should be removed from 
`-fmacro-backtrace-limit` as well?


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

https://reviews.llvm.org/D152090

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


[PATCH] D145767: [Verifier][NFC] Refactor check for associated metadata to allow multiple operands on AIX

2023-06-12 Thread Ting Wang via Phabricator via cfe-commits
tingwang planned changes to this revision.
tingwang added a comment.

Hi Matt @arsenm, thank you for your comments, and I will incorporate your 
suggestions in the next version.

Since the review process of dependent patch https://reviews.llvm.org/D125095 
didn't get any progress for a long time, I'm worried that discussing the 
verification logic maybe a little bit early. I plan to suspend this patch until 
I got any progress on D125095 . Thank you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145767

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


[PATCH] D152683: [clang][dataflow] Model pointer value for builtin functions.

2023-06-12 Thread Martin Böhme via Phabricator via cfe-commits
mboehme created this revision.
Herald added subscribers: martong, xazax.hun.
Herald added a reviewer: NoQ.
Herald added a project: All.
mboehme requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This fixes a false positive in the Crubit nullability verification.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152683

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


Index: clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
@@ -5327,4 +5327,37 @@
   });
 }
 
+// Check that the pointer that a builtin function decays to is associated with
+// a value.
+TEST(TransferTest, BuiltinFunctionModeled) {
+  std::string Code = R"(
+void target() {
+  __builtin_expect(0, 0);
+  // [[p]]
+}
+  )";
+  runDataflow(
+  Code,
+  [](const llvm::StringMap> &Results,
+ ASTContext &ASTCtx) {
+using ast_matchers::selectFirst;
+using ast_matchers::match;
+using ast_matchers::traverse;
+using ast_matchers::implicitCastExpr;
+using ast_matchers::hasCastKind;
+
+const Environment &Env = getEnvironmentAtAnnotation(Results, "p");
+
+auto *ImplicitCast = selectFirst(
+"implicit_cast",
+match(traverse(TK_AsIs,
+   implicitCastExpr(hasCastKind(CK_BuiltinFnToFnPtr))
+   .bind("implicit_cast")),
+  ASTCtx));
+
+ASSERT_THAT(ImplicitCast, NotNull());
+EXPECT_THAT(Env.getValueStrict(*ImplicitCast), NotNull());
+  });
+}
+
 } // namespace
Index: clang/lib/Analysis/FlowSensitive/Transfer.cpp
===
--- clang/lib/Analysis/FlowSensitive/Transfer.cpp
+++ clang/lib/Analysis/FlowSensitive/Transfer.cpp
@@ -400,7 +400,8 @@
   Env.setValue(Loc, NullPointerVal);
   break;
 }
-case CK_FunctionToPointerDecay: {
+case CK_FunctionToPointerDecay:
+case CK_BuiltinFnToFnPtr: {
   StorageLocation *PointeeLoc =
   Env.getStorageLocation(*SubExpr, SkipPast::Reference);
   if (PointeeLoc == nullptr)


Index: clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
@@ -5327,4 +5327,37 @@
   });
 }
 
+// Check that the pointer that a builtin function decays to is associated with
+// a value.
+TEST(TransferTest, BuiltinFunctionModeled) {
+  std::string Code = R"(
+void target() {
+  __builtin_expect(0, 0);
+  // [[p]]
+}
+  )";
+  runDataflow(
+  Code,
+  [](const llvm::StringMap> &Results,
+ ASTContext &ASTCtx) {
+using ast_matchers::selectFirst;
+using ast_matchers::match;
+using ast_matchers::traverse;
+using ast_matchers::implicitCastExpr;
+using ast_matchers::hasCastKind;
+
+const Environment &Env = getEnvironmentAtAnnotation(Results, "p");
+
+auto *ImplicitCast = selectFirst(
+"implicit_cast",
+match(traverse(TK_AsIs,
+   implicitCastExpr(hasCastKind(CK_BuiltinFnToFnPtr))
+   .bind("implicit_cast")),
+  ASTCtx));
+
+ASSERT_THAT(ImplicitCast, NotNull());
+EXPECT_THAT(Env.getValueStrict(*ImplicitCast), NotNull());
+  });
+}
+
 } // namespace
Index: clang/lib/Analysis/FlowSensitive/Transfer.cpp
===
--- clang/lib/Analysis/FlowSensitive/Transfer.cpp
+++ clang/lib/Analysis/FlowSensitive/Transfer.cpp
@@ -400,7 +400,8 @@
   Env.setValue(Loc, NullPointerVal);
   break;
 }
-case CK_FunctionToPointerDecay: {
+case CK_FunctionToPointerDecay:
+case CK_BuiltinFnToFnPtr: {
   StorageLocation *PointeeLoc =
   Env.getStorageLocation(*SubExpr, SkipPast::Reference);
   if (PointeeLoc == nullptr)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D152436: [clang][analyzer] Move checker alpha.unix.StdCLibraryFunctions out of alpha.

2023-06-12 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

In D152436#4411912 , @steakhal wrote:

> In D152436#4408811 , @balazske 
> wrote:
>
>> In D152436#4408301 , @steakhal 
>> wrote:
>>
>>> I looked at the TPs, and if the violation was introduced by an assumption 
>>> (instead of an assignment), then it's really hard to spot which assumption 
>>> is important for the bug.
>>> I wonder if we could add the `TrackConstraintBRVisitor` to the bugreport to 
>>> "highlight" that particular assumption/place.
>>
>> The question is first if this problem must be fixed before the checker comes 
>> out of alpha state. If yes I try to make another patch with this fix. I 
>> tried this previously but do not remember exactly what the problem was.
>
> WIthout an explicit note message there, I don't see how could we advertise 
> this as a "mature" checker.

Is it possible to hide functions hindered by this problem behing an 
off-by-default flag?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152436

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


[PATCH] D152369: [clang][dataflow][NFC] Expand comments on losing values in optional checker.

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

libcxx failures look unrelated (this is a comment-only change that doesn't 
touch libcxx)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152369

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


[clang] bbeda83 - [clang][dataflow][NFC] Expand comments on losing values in optional checker.

2023-06-12 Thread Martin Braenne via cfe-commits

Author: Martin Braenne
Date: 2023-06-12T08:46:34Z
New Revision: bbeda83090adcb3609f9c1331b2345e7fa547f90

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

LOG: [clang][dataflow][NFC] Expand comments on losing values in optional 
checker.

While working on the ongoing migration to strict handling of value
categories (see https://discourse.llvm.org/t/70086), I ran into issues related
to losing the value associated with an optional.

This issue is hinted at in the existing comments, but the issue didn't become
sufficiently clear to me from those, so I thought it would be worth capturing
more details, along with ideas for how this issue might be fixed.

Reviewed By: ymandel

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

Added: 


Modified: 
clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp

Removed: 




diff  --git 
a/clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp 
b/clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp
index 1095fd49e8600..a239d54674e96 100644
--- a/clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp
+++ b/clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp
@@ -315,11 +315,16 @@ StorageLocation 
*maybeInitializeOptionalValueMember(QualType Q,
 auto &ValueLoc = ValuePtr->getPointeeLoc();
 if (Env.getValue(ValueLoc) == nullptr) {
   // The property was previously set, but the value has been lost. This can
-  // happen, for example, because of an environment merge (where the two
-  // environments mapped the property to 
diff erent values, which resulted in
-  // them both being discarded), or when two blocks in the CFG, with 
neither
-  // a dominator of the other, visit the same optional value, or even when 
a
-  // block is revisited during testing to collect per-statement state.
+  // happen in various situations, for example:
+  // - Because of an environment merge (where the two environments mapped
+  //   the property to 
diff erent values, which resulted in them both being
+  //   discarded).
+  // - When two blocks in the CFG, with neither a dominator of the other,
+  //   visit the same optional value. (FIXME: This is something we can and
+  //   should fix -- see also the lengthy FIXME below.)
+  // - Or even when a block is revisited during testing to collect
+  //   per-statement state.
+  //
   // FIXME: This situation means that the optional contents are not shared
   // between branches and the like. Practically, this lack of sharing
   // reduces the precision of the model when the contents are relevant to
@@ -340,6 +345,51 @@ StorageLocation 
*maybeInitializeOptionalValueMember(QualType Q,
   auto &ValueLoc = Env.createStorageLocation(Ty);
   Env.setValue(ValueLoc, *ValueVal);
   auto &ValuePtr = Env.create(ValueLoc);
+  // FIXME:
+  // The change we make to the `value` property below may become visible to
+  // other blocks that aren't successors of the current block and therefore
+  // don't see the change we made above mapping `ValueLoc` to `ValueVal`. For
+  // example:
+  //
+  //   void target(optional oo, bool b) {
+  // // `oo` is associated with a `StructValue` here, which we will call
+  // // `OptionalVal`.
+  //
+  // // The `has_value` property is set on `OptionalVal` (but not the
+  // // `value` property yet).
+  // if (!oo.has_value()) return;
+  //
+  // if (b) {
+  //   // Let's assume we transfer the `if` branch first.
+  //   //
+  //   // This causes us to call `maybeInitializeOptionalValueMember()`,
+  //   // which causes us to set the `value` property on `OptionalVal`
+  //   // (which had not been set until this point). This `value` property
+  //   // refers to a `PointerValue`, which in turn refers to a
+  //   // StorageLocation` that is associated to an `IntegerValue`.
+  //   oo.value();
+  // } else {
+  //   // Let's assume we transfer the `else` branch after the `if` branch.
+  //   //
+  //   // We see the `value` property that the `if` branch set on
+  //   // `OptionalVal`, but in the environment for this block, the
+  //   // `StorageLocation` in the `PointerValue` is not associated with 
any
+  //   // `Value`.
+  //   oo.value();
+  // }
+  //   }
+  //
+  // This situation is currently "saved" by the code above that checks whether
+  // the `value` property is already set, and if, the `ValueLoc` is not
+  // associated with a `ValueVal`, creates a new `ValueVal`.
+  //
+  // However, what we should really do is to make sure that the change to the
+  // `value` property does not "leak" to other blocks that are not succ

[PATCH] D152369: [clang][dataflow][NFC] Expand comments on losing values in optional checker.

2023-06-12 Thread Martin Böhme via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGbbeda83090ad: [clang][dataflow][NFC] Expand comments on 
losing values in optional checker. (authored by mboehme).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152369

Files:
  clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp


Index: clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp
===
--- clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp
+++ clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp
@@ -315,11 +315,16 @@
 auto &ValueLoc = ValuePtr->getPointeeLoc();
 if (Env.getValue(ValueLoc) == nullptr) {
   // The property was previously set, but the value has been lost. This can
-  // happen, for example, because of an environment merge (where the two
-  // environments mapped the property to different values, which resulted 
in
-  // them both being discarded), or when two blocks in the CFG, with 
neither
-  // a dominator of the other, visit the same optional value, or even when 
a
-  // block is revisited during testing to collect per-statement state.
+  // happen in various situations, for example:
+  // - Because of an environment merge (where the two environments mapped
+  //   the property to different values, which resulted in them both being
+  //   discarded).
+  // - When two blocks in the CFG, with neither a dominator of the other,
+  //   visit the same optional value. (FIXME: This is something we can and
+  //   should fix -- see also the lengthy FIXME below.)
+  // - Or even when a block is revisited during testing to collect
+  //   per-statement state.
+  //
   // FIXME: This situation means that the optional contents are not shared
   // between branches and the like. Practically, this lack of sharing
   // reduces the precision of the model when the contents are relevant to
@@ -340,6 +345,51 @@
   auto &ValueLoc = Env.createStorageLocation(Ty);
   Env.setValue(ValueLoc, *ValueVal);
   auto &ValuePtr = Env.create(ValueLoc);
+  // FIXME:
+  // The change we make to the `value` property below may become visible to
+  // other blocks that aren't successors of the current block and therefore
+  // don't see the change we made above mapping `ValueLoc` to `ValueVal`. For
+  // example:
+  //
+  //   void target(optional oo, bool b) {
+  // // `oo` is associated with a `StructValue` here, which we will call
+  // // `OptionalVal`.
+  //
+  // // The `has_value` property is set on `OptionalVal` (but not the
+  // // `value` property yet).
+  // if (!oo.has_value()) return;
+  //
+  // if (b) {
+  //   // Let's assume we transfer the `if` branch first.
+  //   //
+  //   // This causes us to call `maybeInitializeOptionalValueMember()`,
+  //   // which causes us to set the `value` property on `OptionalVal`
+  //   // (which had not been set until this point). This `value` property
+  //   // refers to a `PointerValue`, which in turn refers to a
+  //   // StorageLocation` that is associated to an `IntegerValue`.
+  //   oo.value();
+  // } else {
+  //   // Let's assume we transfer the `else` branch after the `if` branch.
+  //   //
+  //   // We see the `value` property that the `if` branch set on
+  //   // `OptionalVal`, but in the environment for this block, the
+  //   // `StorageLocation` in the `PointerValue` is not associated with 
any
+  //   // `Value`.
+  //   oo.value();
+  // }
+  //   }
+  //
+  // This situation is currently "saved" by the code above that checks whether
+  // the `value` property is already set, and if, the `ValueLoc` is not
+  // associated with a `ValueVal`, creates a new `ValueVal`.
+  //
+  // However, what we should really do is to make sure that the change to the
+  // `value` property does not "leak" to other blocks that are not successors
+  // of this block. To do this, instead of simply setting the `value` property
+  // on the existing `OptionalVal`, we should create a new `Value` for the
+  // optional, set the property on that, and associate the storage location 
that
+  // is currently associated with the existing `OptionalVal` with the newly
+  // created `Value` instead.
   OptionalVal.setProperty("value", ValuePtr);
   return &ValueLoc;
 }


Index: clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp
===
--- clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp
+++ clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp
@@ -315,11 +315,16 @@
 auto &ValueLoc = ValuePtr->ge

[PATCH] D152685: [clangd] Decouple IncludeCleaner implementation from Config

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

This should help managing tests as we change defaults in configs.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152685

Files:
  clang-tools-extra/clangd/IncludeCleaner.cpp
  clang-tools-extra/clangd/IncludeCleaner.h
  clang-tools-extra/clangd/ParsedAST.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
@@ -7,7 +7,6 @@
 //===--===//
 
 #include "Annotations.h"
-#include "Config.h"
 #include "Diagnostics.h"
 #include "IncludeCleaner.h"
 #include "ParsedAST.h"
@@ -45,7 +44,8 @@
 using ::testing::Pointee;
 using ::testing::UnorderedElementsAre;
 
-Matcher withFix(std::vector<::testing::Matcher> FixMatcheres) {
+Matcher
+withFix(std::vector<::testing::Matcher> FixMatcheres) {
   return Field(&Diag::Fixes, testing::UnorderedElementsAreArray(FixMatcheres));
 }
 
@@ -62,7 +62,6 @@
 }
 MATCHER_P(FixMessage, Message, "") { return arg.Message == Message; }
 
-
 std::string guard(llvm::StringRef Code) {
   return "#pragma once\n" + Code.str();
 }
@@ -174,11 +173,6 @@
 }
 
 TEST(IncludeCleaner, GenerateMissingHeaderDiags) {
-  Config Cfg;
-  Cfg.Diagnostics.MissingIncludes = Config::IncludesPolicy::Strict;
-  Cfg.Diagnostics.Includes.IgnoreHeader = {
-  [](llvm::StringRef Header) { return Header.ends_with("buzz.h"); }};
-  WithContextValue Ctx(Config::Key, std::move(Cfg));
   Annotations MainFile(R"cpp(
 #include "a.h"
 #include "all.h"
@@ -250,8 +244,11 @@
   TU.Code = MainFile.code();
   ParsedAST AST = TU.build();
 
-  std::vector Diags =
-  issueIncludeCleanerDiagnostics(AST, TU.Code);
+  auto Findings = computeIncludeCleanerFindings(AST);
+  Findings.UnusedIncludes.clear();
+  std::vector Diags = issueIncludeCleanerDiagnostics(
+  AST, TU.Code, Findings,
+  {[](llvm::StringRef Header) { return Header.ends_with("buzz.h"); }});
   EXPECT_THAT(
   Diags,
   UnorderedElementsAre(
@@ -279,9 +276,11 @@
   AllOf(
   Diag(MainFile.range("vector"),
"No header providing \"std::vector\" is directly included"),
-  withFix({Fix(MainFile.range("insert_vector"),
-   "#include \n", "#include "),
-   FixMessage("add all missing includes"),})),
+  withFix({
+  Fix(MainFile.range("insert_vector"), "#include \n",
+  "#include "),
+  FixMessage("add all missing includes"),
+  })),
   AllOf(Diag(MainFile.range("FOO"),
  "No header providing \"FOO\" is directly included"),
 withFix({Fix(MainFile.range("insert_foo"),
@@ -320,11 +319,7 @@
 // IWYU pragma: private, include "public.h"
 void foo() {}
   )cpp");
-  Config Cfg;
-  Cfg.Diagnostics.UnusedIncludes = Config::IncludesPolicy::Strict;
-  WithContextValue Ctx(Config::Key, std::move(Cfg));
   ParsedAST AST = TU.build();
-  EXPECT_THAT(AST.getDiagnostics(), llvm::ValueIs(IsEmpty()));
   IncludeCleanerFindings Findings = computeIncludeCleanerFindings(AST);
   EXPECT_THAT(Findings.UnusedIncludes, IsEmpty());
 }
@@ -347,7 +342,6 @@
   )cpp");
   ParsedAST AST = TU.build();
 
-  EXPECT_THAT(AST.getDiagnostics(), llvm::ValueIs(IsEmpty()));
   IncludeCleanerFindings Findings = computeIncludeCleanerFindings(AST);
   EXPECT_THAT(Findings.UnusedIncludes,
   ElementsAre(Pointee(writtenInclusion("\"foo.h\"";
@@ -368,13 +362,10 @@
   )cpp";
   TU.ExtraArgs.emplace_back("-xobjective-c");
 
-  Config Cfg;
-
-  Cfg.Diagnostics.UnusedIncludes = Config::IncludesPolicy::Strict;
-  Cfg.Diagnostics.MissingIncludes = Config::IncludesPolicy::Strict;
-  WithContextValue Ctx(Config::Key, std::move(Cfg));
   ParsedAST AST = TU.build();
-  EXPECT_THAT(AST.getDiagnostics(), llvm::ValueIs(IsEmpty()));
+  IncludeCleanerFindings Findings = computeIncludeCleanerFindings(AST);
+  EXPECT_THAT(Findings.MissingIncludes, IsEmpty());
+  EXPECT_THAT(Findings.UnusedIncludes, IsEmpty());
 }
 
 TEST(IncludeCleaner, UmbrellaUsesPrivate) {
@@ -387,11 +378,7 @@
 void foo() {}
   )cpp");
   TU.Filename = "public.h";
-  Config Cfg;
-  Cfg.Diagnostics.UnusedIncludes = Config::IncludesPolicy::Strict;
-  WithContextValue Ctx(Config::Key, std::move(Cfg));
   ParsedAST AST = TU.build();
-  EXPECT_THAT(AST.getDiagnostics(), llvm::ValueIs(IsEmpty()));
   IncludeCleanerFindings Findings = computeIncludeCleanerFindings(AST);
   EXPECT_THAT(F

[PATCH] D152686: [clangd] Enforce strict unused includes by default

2023-06-12 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: hokein.
Herald added subscribers: ChuanqiXu, arphaman.
Herald added a project: All.
kadircet requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

Depends on D152685 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152686

Files:
  clang-tools-extra/clangd/Config.h
  clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
  clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
  clang-tools-extra/clangd/unittests/ParsedASTTests.cpp

Index: clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
===
--- clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
+++ clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
@@ -15,6 +15,7 @@
 #include "AST.h"
 #include "Annotations.h"
 #include "Compiler.h"
+#include "Config.h"
 #include "Diagnostics.h"
 #include "Headers.h"
 #include "ParsedAST.h"
@@ -23,6 +24,7 @@
 #include "TestFS.h"
 #include "TestTU.h"
 #include "TidyProvider.h"
+#include "support/Context.h"
 #include "clang/AST/DeclTemplate.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/SourceManager.h"
@@ -33,6 +35,7 @@
 #include "gmock/gmock-matchers.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
+#include 
 
 namespace clang {
 namespace clangd {
@@ -513,6 +516,13 @@
 //   size is part of the lookup key for HeaderFileInfo, and we don't want to
 //   rely on the preamble's HFI being looked up when parsing the main file.
 TEST(ParsedASTTest, HeaderGuardsSelfInclude) {
+  // Disable include cleaner diagnostics to prevent them from interfering with
+  // other diagnostics.
+  Config Cfg;
+  Cfg.Diagnostics.MissingIncludes = Config::IncludesPolicy::None;
+  Cfg.Diagnostics.UnusedIncludes = Config::IncludesPolicy::None;
+  WithContextValue Ctx(Config::Key, std::move(Cfg));
+
   TestTU TU;
   TU.ImplicitHeaderGuard = false;
   TU.Filename = "self.h";
Index: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
===
--- clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -6,6 +6,7 @@
 //
 //===--===//
 
+#include "/usr/local/google/home/kadircet/repos/llvm/clang-tools-extra/clang-tidy/ClangTidyOptions.h"
 #include "Annotations.h"
 #include "Config.h"
 #include "Diagnostics.h"
@@ -18,18 +19,28 @@
 #include "TestTU.h"
 #include "TidyProvider.h"
 #include "index/MemIndex.h"
+#include "index/Ref.h"
+#include "index/Relation.h"
+#include "index/Symbol.h"
 #include "support/Context.h"
 #include "support/Path.h"
+#include "clang/AST/Decl.h"
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/DiagnosticSema.h"
+#include "clang/Basic/LLVM.h"
+#include "clang/Basic/Specifiers.h"
+#include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/JSON.h"
 #include "llvm/Support/ScopedPrinter.h"
 #include "llvm/Support/TargetSelect.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
-#include 
+#include 
 #include 
+#include 
+#include 
+#include 
 
 namespace clang {
 namespace clangd {
@@ -42,6 +53,7 @@
 using ::testing::ElementsAre;
 using ::testing::Field;
 using ::testing::IsEmpty;
+using ::testing::Not;
 using ::testing::Pair;
 using ::testing::SizeIs;
 using ::testing::UnorderedElementsAre;
@@ -889,7 +901,8 @@
 int symbol;
   )cpp");
   TU.Filename = "foo.h";
-  EXPECT_THAT(*TU.build().getDiagnostics(), IsEmpty());
+  EXPECT_THAT(*TU.build().getDiagnostics(),
+  Not(Contains(diagName("pp_including_mainfile_in_preamble";
   EXPECT_THAT(TU.build().getLocalTopLevelDecls(), SizeIs(1));
 }
 
@@ -1597,9 +1610,9 @@
   TU.AdditionalFiles = {{"a.h", "#include \"b.h\""},
 {"b.h", "no_type_spec; // error-ok"}};
   EXPECT_THAT(*TU.build().getDiagnostics(),
-  UnorderedElementsAre(
-  Diag(Main.range(), "in included file: a type specifier is "
- "required for all declarations")));
+  UnorderedElementsAre(Diag(Main.range(),
+"in included file: a type specifier is "
+"required for all declarations")));
 }
 
 TEST(DiagsInHeaders, DiagInMultipleHeaders) {
@@ -1628,9 +1641,8 @@
   {"a.h", "#include \"b.h\"\n"},
   {"b.h", "#ifndef X\n#define X\nno_type_spec; // error-ok\n#endif"}};
   EXPECT_THAT(*TU.build().getDiagnostics(),
-  UnorderedElementsAre(Diag(Main.range(),
-"in included file: a type specifier is "
-"required for all declarations")));
+  Contains(Diag(Main.range(), "in included file: a type specifier "
+   

[PATCH] D152687: [clangd] Turn on missing-include diags by default

2023-06-12 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
Herald added a subscriber: arphaman.
Herald added a project: All.
kadircet requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

By disabling include-cleaner analysis for Diagnostics tests by default.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152687

Files:
  clang-tools-extra/clangd/Config.h
  clang-tools-extra/clangd/unittests/ClangdTests.cpp
  clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp

Index: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
===
--- clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -6,7 +6,7 @@
 //
 //===--===//
 
-#include "/usr/local/google/home/kadircet/repos/llvm/clang-tools-extra/clang-tidy/ClangTidyOptions.h"
+#include "../clang-tidy/ClangTidyOptions.h"
 #include "Annotations.h"
 #include "Config.h"
 #include "Diagnostics.h"
@@ -38,6 +38,7 @@
 #include "gtest/gtest.h"
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -150,7 +151,17 @@
   return M;
 }
 
-TEST(DiagnosticsTest, DiagnosticRanges) {
+class DiagnosticsTest : public ::testing::Test {
+  std::optional Ctx;
+  void SetUp() override {
+Config Cfg;
+Cfg.Diagnostics.MissingIncludes = Config::IncludesPolicy::None;
+Cfg.Diagnostics.UnusedIncludes = Config::IncludesPolicy::None;
+Ctx.emplace(Config::Key, std::move(Cfg));
+  }
+};
+
+TEST_F(DiagnosticsTest, DiagnosticRanges) {
   // Check we report correct ranges, including various edge-cases.
   Annotations Test(R"cpp(
 // error-ok
@@ -214,7 +225,7 @@
 // fires for the full expression range (see tweaks/PopulateSwitchTests.cpp).
 // The quickfix flow only works end-to-end if the tweak can be triggered on
 // the diagnostic's range.
-TEST(DiagnosticsTest, WSwitch) {
+TEST_F(DiagnosticsTest, WSwitch) {
   Annotations Test(R"cpp(
 enum A { X };
 struct B { A a; };
@@ -229,7 +240,7 @@
"enumeration value 'X' not handled in switch")));
 }
 
-TEST(DiagnosticsTest, FlagsMatter) {
+TEST_F(DiagnosticsTest, FlagsMatter) {
   Annotations Test("[[void]] main() {} // error-ok");
   auto TU = TestTU::withCode(Test.code());
   EXPECT_THAT(*TU.build().getDiagnostics(),
@@ -245,7 +256,7 @@
   withFix(Fix(Test.range(), "int", "change return type to 'int'");
 }
 
-TEST(DiagnosticsTest, DiagnosticPreamble) {
+TEST_F(DiagnosticsTest, DiagnosticPreamble) {
   Annotations Test(R"cpp(
 #include $[["not-found.h"]] // error-ok
   )cpp");
@@ -257,7 +268,7 @@
   diagSource(Diag::Clang), diagName("pp_file_not_found";
 }
 
-TEST(DiagnosticsTest, DeduplicatedClangTidyDiagnostics) {
+TEST_F(DiagnosticsTest, DeduplicatedClangTidyDiagnostics) {
   Annotations Test(R"cpp(
 float foo = [[0.1f]];
   )cpp");
@@ -295,7 +306,7 @@
   diagSource(Diag::ClangTidy);
 }
 
-TEST(DiagnosticsTest, ClangTidy) {
+TEST_F(DiagnosticsTest, ClangTidy) {
   Annotations Test(R"cpp(
 #include $deprecated[["assert.h"]]
 
@@ -356,7 +367,7 @@
"function 'bar' is within a recursive call chain";
 }
 
-TEST(DiagnosticsTest, ClangTidyEOF) {
+TEST_F(DiagnosticsTest, ClangTidyEOF) {
   // clang-format off
   Annotations Test(R"cpp(
   [[#]]include 
@@ -373,7 +384,7 @@
 diagSource(Diag::ClangTidy), diagName("llvm-include-order");
 }
 
-TEST(DiagnosticTest, TemplatesInHeaders) {
+TEST_F(DiagnosticsTest, TemplatesInHeaders) {
   // Diagnostics from templates defined in headers are placed at the expansion.
   Annotations Main(R"cpp(
 Derived [[y]]; // error-ok
@@ -393,7 +404,7 @@
   "'Derived' requested here");
 }
 
-TEST(DiagnosticTest, MakeUnique) {
+TEST_F(DiagnosticsTest, MakeUnique) {
   // We usually miss diagnostics from header functions as we don't parse them.
   // std::make_unique is an exception.
   Annotations Main(R"cpp(
@@ -418,7 +429,7 @@
"no matching constructor for initialization of 'S'")));
 }
 
-TEST(DiagnosticTest, MakeShared) {
+TEST_F(DiagnosticsTest, MakeShared) {
   // We usually miss diagnostics from header functions as we don't parse them.
   // std::make_shared is only parsed when --parse-forwarding-functions is set
   Annotations Main(R"cpp(
@@ -444,7 +455,7 @@
"no matching constructor for initialization of 'S'")));
 }
 
-TEST(DiagnosticTest, NoMultipleDiagnosticInFlight) {
+TEST_F(DiagnosticsTest, NoMultipleDiagnosticInFlight) {
   Annotations Main(R"cpp(
 template  struct Foo {
   T *begin();
@@ -471,7 +482,7 @@
   diagSource(Diag::ClangTidy), diagName("modernize-loop-convert");
 }
 
-TEST(DiagnosticTest, RespectsDiagnosticConfig) {
+TEST_F(DiagnosticsTest, RespectsDiagnosticConfig

[PATCH] D150124: [index][clangd] Consider labels when indexing function bodies

2023-06-12 Thread Christian Kandeler via Phabricator via cfe-commits
ckandeler added a comment.

ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150124

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


[PATCH] D152689: [NFC] Remove dead conditionals

2023-06-12 Thread Sindhu Chittireddy via Phabricator via cfe-commits
schittir created this revision.
schittir added reviewers: tahonermann, aaron.ballman, erichkeane.
Herald added a subscriber: hiraditya.
Herald added a project: All.
schittir requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

Patch contains changes to remove obvious dead code.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152689

Files:
  clang/lib/CodeGen/CGObjCMac.cpp
  clang/lib/Sema/SemaOverload.cpp
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp


Index: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
===
--- llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -2120,8 +2120,7 @@
 // Avoid incrementing past stop since it could overflow.
 Value *CountIfTwo = Builder.CreateAdd(
 Builder.CreateUDiv(Builder.CreateSub(Span, One), Incr), One);
-Value *OneCmp = Builder.CreateICmp(
-InclusiveStop ? CmpInst::ICMP_ULT : CmpInst::ICMP_ULE, Span, Incr);
+Value *OneCmp = Builder.CreateICmp(CmpInst::ICMP_ULE, Span, Incr);
 CountIfLooping = Builder.CreateSelect(OneCmp, One, CountIfTwo);
   }
   Value *TripCount = Builder.CreateSelect(ZeroCmp, Zero, CountIfLooping,
Index: clang/lib/Sema/SemaOverload.cpp
===
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -10865,7 +10865,7 @@
   if (FromExpr && isa(FromExpr)) {
 S.Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_list_argument)
 << (unsigned)FnKindPair.first << (unsigned)FnKindPair.second << FnDesc
-<< (FromExpr ? FromExpr->getSourceRange() : SourceRange()) << FromTy
+<< FromExpr->getSourceRange() << FromTy
 << ToTy << (unsigned)isObjectArgument << I + 1
 << (Conv.Bad.Kind == BadConversionSequence::too_few_initializers ? 1
 : Conv.Bad.Kind == BadConversionSequence::too_many_initializers
Index: clang/lib/CodeGen/CGObjCMac.cpp
===
--- clang/lib/CodeGen/CGObjCMac.cpp
+++ clang/lib/CodeGen/CGObjCMac.cpp
@@ -3809,15 +3809,9 @@
   ivarList.fillPlaceholderWithInt(countSlot, ObjCTypes.IntTy, count);
 
   llvm::GlobalVariable *GV;
-  if (ForClass)
-GV =
-CreateMetadataVar("OBJC_CLASS_VARIABLES_" + ID->getName(), ivarList,
-  "__OBJC,__class_vars,regular,no_dead_strip",
-  CGM.getPointerAlign(), true);
-  else
-GV = CreateMetadataVar("OBJC_INSTANCE_VARIABLES_" + ID->getName(), 
ivarList,
-   "__OBJC,__instance_vars,regular,no_dead_strip",
-   CGM.getPointerAlign(), true);
+  GV = CreateMetadataVar("OBJC_INSTANCE_VARIABLES_" + ID->getName(), ivarList,
+ "__OBJC,__instance_vars,regular,no_dead_strip",
+ CGM.getPointerAlign(), true);
   return llvm::ConstantExpr::getBitCast(GV, ObjCTypes.IvarListPtrTy);
 }
 


Index: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
===
--- llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -2120,8 +2120,7 @@
 // Avoid incrementing past stop since it could overflow.
 Value *CountIfTwo = Builder.CreateAdd(
 Builder.CreateUDiv(Builder.CreateSub(Span, One), Incr), One);
-Value *OneCmp = Builder.CreateICmp(
-InclusiveStop ? CmpInst::ICMP_ULT : CmpInst::ICMP_ULE, Span, Incr);
+Value *OneCmp = Builder.CreateICmp(CmpInst::ICMP_ULE, Span, Incr);
 CountIfLooping = Builder.CreateSelect(OneCmp, One, CountIfTwo);
   }
   Value *TripCount = Builder.CreateSelect(ZeroCmp, Zero, CountIfLooping,
Index: clang/lib/Sema/SemaOverload.cpp
===
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -10865,7 +10865,7 @@
   if (FromExpr && isa(FromExpr)) {
 S.Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_list_argument)
 << (unsigned)FnKindPair.first << (unsigned)FnKindPair.second << FnDesc
-<< (FromExpr ? FromExpr->getSourceRange() : SourceRange()) << FromTy
+<< FromExpr->getSourceRange() << FromTy
 << ToTy << (unsigned)isObjectArgument << I + 1
 << (Conv.Bad.Kind == BadConversionSequence::too_few_initializers ? 1
 : Conv.Bad.Kind == BadConversionSequence::too_many_initializers
Index: clang/lib/CodeGen/CGObjCMac.cpp
===
--- clang/lib/CodeGen/CGObjCMac.cpp
+++ clang/lib/CodeGen/CGObjCMac.cpp
@@ -3809,15 +3809,9 @@
   ivarList.fillPlaceholderWithInt(countSlot, ObjCTypes.IntTy, count);
 
   llvm::GlobalVariable *GV;
-  if (ForClass)
-GV =
-CreateMetadataVar("OBJC_CLASS_VARIABLES_" + ID->getName(), ivarList,
-  "__OBJC,_

[PATCH] D147717: [C++20][NFC] Claim full support for consteval again

2023-06-12 Thread Mariya Podchishchaeva via Phabricator via cfe-commits
Fznamznon updated this revision to Diff 530434.
Fznamznon added a comment.

Rebase, update value of macro since P2564  is 
implemented now


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147717

Files:
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/test/Lexer/cxx-features.cpp
  clang/www/cxx_status.html


Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -643,14 +643,7 @@
 
   Immediate functions (consteval)
   https://wg21.link/p1073r3";>P1073R3
-  
-Clang 15 (Partial)
-  Clang still incorrectly defers some consteval executions to runtime,
-  resulting in CodeGen crashes. Additionally, Clang does not properly
-  handle default arguments in consteval functions under all
-  circumstances.
-
-  
+  Clang 17
 

 https://wg21.link/p1937r2";>P1937R2
Index: clang/test/Lexer/cxx-features.cpp
===
--- clang/test/Lexer/cxx-features.cpp
+++ clang/test/Lexer/cxx-features.cpp
@@ -78,8 +78,7 @@
 #error "wrong value for __cpp_conditional_explicit"
 #endif
 
-#if check(consteval, 0, 0, 0, 0, 0, 0)
-// FIXME: 201811 in C++20
+#if check(consteval, 0, 0, 0, 0, 202211, 202211)
 #error "wrong value for __cpp_consteval"
 #endif
 
Index: clang/lib/Frontend/InitPreprocessor.cpp
===
--- clang/lib/Frontend/InitPreprocessor.cpp
+++ clang/lib/Frontend/InitPreprocessor.cpp
@@ -683,7 +683,7 @@
 // Refer to the discussion of this at https://reviews.llvm.org/D128619.
 Builder.defineMacro("__cpp_concepts", "201907L");
 Builder.defineMacro("__cpp_conditional_explicit", "201806L");
-// Builder.defineMacro("__cpp_consteval", "202211L");
+Builder.defineMacro("__cpp_consteval", "202211L");
 Builder.defineMacro("__cpp_constexpr_dynamic_alloc", "201907L");
 Builder.defineMacro("__cpp_constinit", "201907L");
 Builder.defineMacro("__cpp_impl_coroutine", "201902L");


Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -643,14 +643,7 @@
 
   Immediate functions (consteval)
   https://wg21.link/p1073r3";>P1073R3
-  
-Clang 15 (Partial)
-  Clang still incorrectly defers some consteval executions to runtime,
-  resulting in CodeGen crashes. Additionally, Clang does not properly
-  handle default arguments in consteval functions under all
-  circumstances.
-
-  
+  Clang 17
 

 https://wg21.link/p1937r2";>P1937R2
Index: clang/test/Lexer/cxx-features.cpp
===
--- clang/test/Lexer/cxx-features.cpp
+++ clang/test/Lexer/cxx-features.cpp
@@ -78,8 +78,7 @@
 #error "wrong value for __cpp_conditional_explicit"
 #endif
 
-#if check(consteval, 0, 0, 0, 0, 0, 0)
-// FIXME: 201811 in C++20
+#if check(consteval, 0, 0, 0, 0, 202211, 202211)
 #error "wrong value for __cpp_consteval"
 #endif
 
Index: clang/lib/Frontend/InitPreprocessor.cpp
===
--- clang/lib/Frontend/InitPreprocessor.cpp
+++ clang/lib/Frontend/InitPreprocessor.cpp
@@ -683,7 +683,7 @@
 // Refer to the discussion of this at https://reviews.llvm.org/D128619.
 Builder.defineMacro("__cpp_concepts", "201907L");
 Builder.defineMacro("__cpp_conditional_explicit", "201806L");
-// Builder.defineMacro("__cpp_consteval", "202211L");
+Builder.defineMacro("__cpp_consteval", "202211L");
 Builder.defineMacro("__cpp_constexpr_dynamic_alloc", "201907L");
 Builder.defineMacro("__cpp_constinit", "201907L");
 Builder.defineMacro("__cpp_impl_coroutine", "201902L");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D147717: [C++20] Claim full support for consteval again

2023-06-12 Thread Mariya Podchishchaeva via Phabricator via cfe-commits
Fznamznon added a comment.

https://github.com/llvm/llvm-project/issues/62886 has been fixed, I'm trying to 
figure out or at least reduce https://github.com/llvm/llvm-project/issues/60709 
so it doesn't have headers included, but no progress so far.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147717

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


[PATCH] D152685: [clangd] Decouple IncludeCleaner implementation from Config

2023-06-12 Thread Haojian Wu via Phabricator via cfe-commits
hokein accepted this revision.
hokein added a comment.
This revision is now accepted and ready to land.

Thanks, this looks good!




Comment at: clang-tools-extra/clangd/IncludeCleaner.h:60
+issueIncludeCleanerDiagnostics(ParsedAST &AST, llvm::StringRef Code,
+   IncludeCleanerFindings Findings,
+   HeaderFilter IgnoreHeader = {});

nit: `const IncludeCleanerFindings&`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152685

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


[PATCH] D152686: [clangd] Enforce strict unused includes by default

2023-06-12 Thread Haojian Wu via Phabricator via cfe-commits
hokein accepted this revision.
hokein added inline comments.
This revision is now accepted and ready to land.



Comment at: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp:9
 
+#include 
"/usr/local/google/home/kadircet/repos/llvm/clang-tools-extra/clang-tidy/ClangTidyOptions.h"
 #include "Annotations.h"

nit: this spelling is incorrect, looks like a bug in the tooling spelling logic.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152686

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


[PATCH] D147227: [clangd] Support Config in TestTU.

2023-06-12 Thread Haojian Wu via Phabricator via cfe-commits
hokein abandoned this revision.
hokein added a comment.

abandon this in favour of https://reviews.llvm.org/D152685/


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147227

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


[clang-tools-extra] 031ffc3 - [clangd] Decouple IncludeCleaner implementation from Config

2023-06-12 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2023-06-12T11:38:58+02:00
New Revision: 031ffc3e064525731914eff2ea0dfab1ff34cce1

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

LOG: [clangd] Decouple IncludeCleaner implementation from Config

This should help managing tests as we change defaults in configs.

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

Added: 


Modified: 
clang-tools-extra/clangd/IncludeCleaner.cpp
clang-tools-extra/clangd/IncludeCleaner.h
clang-tools-extra/clangd/ParsedAST.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 fa30592e75807..95585a61c023d 100644
--- a/clang-tools-extra/clangd/IncludeCleaner.cpp
+++ b/clang-tools-extra/clangd/IncludeCleaner.cpp
@@ -7,7 +7,6 @@
 
//===--===//
 
 #include "IncludeCleaner.h"
-#include "Config.h"
 #include "Diagnostics.h"
 #include "Headers.h"
 #include "ParsedAST.h"
@@ -48,7 +47,6 @@
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
-#include "llvm/ADT/StringSet.h"
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/ErrorHandling.h"
@@ -62,8 +60,7 @@
 #include 
 #include 
 
-namespace clang {
-namespace clangd {
+namespace clang::clangd {
 
 static bool AnalyzeStdlib = false;
 void setIncludeCleanerAnalyzesStdlib(bool B) { AnalyzeStdlib = B; }
@@ -84,20 +81,19 @@ clangd::Range getDiagnosticRange(llvm::StringRef Code, 
unsigned HashOffset) {
   return Result;
 }
 
-bool isFilteredByConfig(const Config &Cfg, llvm::StringRef HeaderPath) {
+bool isIgnored(llvm::StringRef HeaderPath, HeaderFilter IgnoreHeaders) {
   // Convert the path to Unix slashes and try to match against the filter.
   llvm::SmallString<64> NormalizedPath(HeaderPath);
   llvm::sys::path::native(NormalizedPath, llvm::sys::path::Style::posix);
-  for (auto &Filter : Cfg.Diagnostics.Includes.IgnoreHeader) {
+  for (auto &Filter : IgnoreHeaders) {
 if (Filter(NormalizedPath))
   return true;
   }
   return false;
 }
 
-static bool mayConsiderUnused(const Inclusion &Inc, ParsedAST &AST,
-  const Config &Cfg,
-  const include_cleaner::PragmaIncludes *PI) {
+bool mayConsiderUnused(const Inclusion &Inc, ParsedAST &AST,
+   const include_cleaner::PragmaIncludes *PI) {
   // FIXME(kirillbobyrev): We currently do not support the umbrella headers.
   // System headers are likely to be standard library headers.
   // Until we have good support for umbrella headers, don't warn about them.
@@ -133,11 +129,6 @@ static bool mayConsiderUnused(const Inclusion &Inc, 
ParsedAST &AST,
  FE->getName());
 return false;
   }
-
-  if (isFilteredByConfig(Cfg, Inc.Resolved)) {
-dlog("{0} header is filtered out by the configuration", FE->getName());
-return false;
-  }
   return true;
 }
 
@@ -166,15 +157,8 @@ std::string getSymbolName(const include_cleaner::Symbol 
&Sym) {
 
 std::vector generateMissingIncludeDiagnostics(
 ParsedAST &AST, llvm::ArrayRef MissingIncludes,
-llvm::StringRef Code) {
+llvm::StringRef Code, HeaderFilter IgnoreHeaders) {
   std::vector Result;
-  const Config &Cfg = Config::current();
-  if (Cfg.Diagnostics.MissingIncludes != Config::IncludesPolicy::Strict ||
-  Cfg.Diagnostics.SuppressAll ||
-  Cfg.Diagnostics.Suppress.contains("missing-includes")) {
-return Result;
-  }
-
   const SourceManager &SM = AST.getSourceManager();
   const FileEntry *MainFile = SM.getFileEntryForID(SM.getMainFileID());
 
@@ -191,7 +175,7 @@ std::vector generateMissingIncludeDiagnostics(
   for (const auto &SymbolWithMissingInclude : MissingIncludes) {
 llvm::StringRef ResolvedPath =
 getResolvedPath(SymbolWithMissingInclude.Providers.front());
-if (isFilteredByConfig(Cfg, ResolvedPath)) {
+if (isIgnored(ResolvedPath, IgnoreHeaders)) {
   dlog("IncludeCleaner: not diagnosing missing include {0}, filtered by "
"config",
ResolvedPath);
@@ -252,15 +236,11 @@ std::vector generateMissingIncludeDiagnostics(
 
 std::vector generateUnusedIncludeDiagnostics(
 PathRef FileName, llvm::ArrayRef UnusedIncludes,
-llvm::StringRef Code) {
+llvm::StringRef Code, HeaderFilter IgnoreHeaders) {
   std::vector Result;
-  const Config &Cfg = Config::current();
-  if (Cfg.Diagnostics.UnusedIncludes == Config::IncludesPolicy::None ||
-  Cfg.Diagnostics.SuppressAll ||
-  Cfg.Diagnostics.Suppress.contains("unused-includes")) {
-return Result;
-  }
   for (const auto *Inc : UnusedIncludes) {
+if (isIgn

[PATCH] D147233: [clangd] Enable unused-include diagnostic by default.

2023-06-12 Thread Haojian Wu via Phabricator via cfe-commits
hokein abandoned this revision.
hokein added a comment.

Abandon in favour of https://reviews.llvm.org/D152686.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147233

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


[PATCH] D152685: [clangd] Decouple IncludeCleaner implementation from Config

2023-06-12 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
kadircet marked an inline comment as done.
Closed by commit rG031ffc3e0645: [clangd] Decouple IncludeCleaner 
implementation from Config (authored by kadircet).

Changed prior to commit:
  https://reviews.llvm.org/D152685?vs=530428&id=530439#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152685

Files:
  clang-tools-extra/clangd/IncludeCleaner.cpp
  clang-tools-extra/clangd/IncludeCleaner.h
  clang-tools-extra/clangd/ParsedAST.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
@@ -7,7 +7,6 @@
 //===--===//
 
 #include "Annotations.h"
-#include "Config.h"
 #include "Diagnostics.h"
 #include "IncludeCleaner.h"
 #include "ParsedAST.h"
@@ -45,7 +44,8 @@
 using ::testing::Pointee;
 using ::testing::UnorderedElementsAre;
 
-Matcher withFix(std::vector<::testing::Matcher> FixMatcheres) {
+Matcher
+withFix(std::vector<::testing::Matcher> FixMatcheres) {
   return Field(&Diag::Fixes, testing::UnorderedElementsAreArray(FixMatcheres));
 }
 
@@ -62,7 +62,6 @@
 }
 MATCHER_P(FixMessage, Message, "") { return arg.Message == Message; }
 
-
 std::string guard(llvm::StringRef Code) {
   return "#pragma once\n" + Code.str();
 }
@@ -174,11 +173,6 @@
 }
 
 TEST(IncludeCleaner, GenerateMissingHeaderDiags) {
-  Config Cfg;
-  Cfg.Diagnostics.MissingIncludes = Config::IncludesPolicy::Strict;
-  Cfg.Diagnostics.Includes.IgnoreHeader = {
-  [](llvm::StringRef Header) { return Header.ends_with("buzz.h"); }};
-  WithContextValue Ctx(Config::Key, std::move(Cfg));
   Annotations MainFile(R"cpp(
 #include "a.h"
 #include "all.h"
@@ -250,8 +244,11 @@
   TU.Code = MainFile.code();
   ParsedAST AST = TU.build();
 
-  std::vector Diags =
-  issueIncludeCleanerDiagnostics(AST, TU.Code);
+  auto Findings = computeIncludeCleanerFindings(AST);
+  Findings.UnusedIncludes.clear();
+  std::vector Diags = issueIncludeCleanerDiagnostics(
+  AST, TU.Code, Findings,
+  {[](llvm::StringRef Header) { return Header.ends_with("buzz.h"); }});
   EXPECT_THAT(
   Diags,
   UnorderedElementsAre(
@@ -279,9 +276,11 @@
   AllOf(
   Diag(MainFile.range("vector"),
"No header providing \"std::vector\" is directly included"),
-  withFix({Fix(MainFile.range("insert_vector"),
-   "#include \n", "#include "),
-   FixMessage("add all missing includes"),})),
+  withFix({
+  Fix(MainFile.range("insert_vector"), "#include \n",
+  "#include "),
+  FixMessage("add all missing includes"),
+  })),
   AllOf(Diag(MainFile.range("FOO"),
  "No header providing \"FOO\" is directly included"),
 withFix({Fix(MainFile.range("insert_foo"),
@@ -320,11 +319,7 @@
 // IWYU pragma: private, include "public.h"
 void foo() {}
   )cpp");
-  Config Cfg;
-  Cfg.Diagnostics.UnusedIncludes = Config::IncludesPolicy::Strict;
-  WithContextValue Ctx(Config::Key, std::move(Cfg));
   ParsedAST AST = TU.build();
-  EXPECT_THAT(AST.getDiagnostics(), llvm::ValueIs(IsEmpty()));
   IncludeCleanerFindings Findings = computeIncludeCleanerFindings(AST);
   EXPECT_THAT(Findings.UnusedIncludes, IsEmpty());
 }
@@ -347,7 +342,6 @@
   )cpp");
   ParsedAST AST = TU.build();
 
-  EXPECT_THAT(AST.getDiagnostics(), llvm::ValueIs(IsEmpty()));
   IncludeCleanerFindings Findings = computeIncludeCleanerFindings(AST);
   EXPECT_THAT(Findings.UnusedIncludes,
   ElementsAre(Pointee(writtenInclusion("\"foo.h\"";
@@ -368,13 +362,10 @@
   )cpp";
   TU.ExtraArgs.emplace_back("-xobjective-c");
 
-  Config Cfg;
-
-  Cfg.Diagnostics.UnusedIncludes = Config::IncludesPolicy::Strict;
-  Cfg.Diagnostics.MissingIncludes = Config::IncludesPolicy::Strict;
-  WithContextValue Ctx(Config::Key, std::move(Cfg));
   ParsedAST AST = TU.build();
-  EXPECT_THAT(AST.getDiagnostics(), llvm::ValueIs(IsEmpty()));
+  IncludeCleanerFindings Findings = computeIncludeCleanerFindings(AST);
+  EXPECT_THAT(Findings.MissingIncludes, IsEmpty());
+  EXPECT_THAT(Findings.UnusedIncludes, IsEmpty());
 }
 
 TEST(IncludeCleaner, UmbrellaUsesPrivate) {
@@ -387,11 +378,7 @@
 void foo() {}
   )cpp");
   TU.Filename = "public.h";
-  Config Cfg;
-  Cfg.Diagnostics.UnusedIncludes = Config::IncludesPolicy::Strict;
-  WithContextValue Ctx(Config::Key, std::move(Cfg));
   ParsedAST AST = TU.build();
-  EXPECT_THAT(AST.getDiagnostics(), llvm::ValueIs(IsEmpty()));
   IncludeCleanerFindings Findings = computeIncludeCl

[clang-tools-extra] ea20f33 - [clangd] Enforce strict unused includes by default

2023-06-12 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2023-06-12T11:47:03+02:00
New Revision: ea20f339d91f57694899c29198f2dfb41bf9a03a

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

LOG: [clangd] Enforce strict unused includes by default

Depends on D152685

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

Added: 


Modified: 
clang-tools-extra/clangd/Config.h
clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
clang-tools-extra/clangd/unittests/ParsedASTTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/Config.h 
b/clang-tools-extra/clangd/Config.h
index 4c6fad25384a8..78fcec1582f00 100644
--- a/clang-tools-extra/clangd/Config.h
+++ b/clang-tools-extra/clangd/Config.h
@@ -108,7 +108,7 @@ struct Config {
 /// Enable emitting diagnostics using stale preambles.
 bool AllowStalePreamble = false;
 
-IncludesPolicy UnusedIncludes = IncludesPolicy::None;
+IncludesPolicy UnusedIncludes = IncludesPolicy::Strict;
 IncludesPolicy MissingIncludes = IncludesPolicy::None;
 
 /// IncludeCleaner will not diagnose usages of these headers matched by

diff  --git a/clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp 
b/clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
index 45dacba5822b7..f0ba582187fd5 100644
--- a/clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
+++ b/clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
@@ -246,22 +246,19 @@ TEST_F(ConfigCompileTests, PathSpecMatch) {
 }
 
 TEST_F(ConfigCompileTests, DiagnosticsIncludeCleaner) {
-  // Defaults to None.
+  // Defaults to Strict.
   EXPECT_TRUE(compileAndApply());
-  EXPECT_EQ(Conf.Diagnostics.UnusedIncludes,
-Config::IncludesPolicy::None);
+  EXPECT_EQ(Conf.Diagnostics.UnusedIncludes, Config::IncludesPolicy::Strict);
 
   Frag = {};
   Frag.Diagnostics.UnusedIncludes.emplace("None");
   EXPECT_TRUE(compileAndApply());
-  EXPECT_EQ(Conf.Diagnostics.UnusedIncludes,
-Config::IncludesPolicy::None);
+  EXPECT_EQ(Conf.Diagnostics.UnusedIncludes, Config::IncludesPolicy::None);
 
   Frag = {};
   Frag.Diagnostics.UnusedIncludes.emplace("Strict");
   EXPECT_TRUE(compileAndApply());
-  EXPECT_EQ(Conf.Diagnostics.UnusedIncludes,
-Config::IncludesPolicy::Strict);
+  EXPECT_EQ(Conf.Diagnostics.UnusedIncludes, Config::IncludesPolicy::Strict);
 
   Frag = {};
   EXPECT_TRUE(Conf.Diagnostics.Includes.IgnoreHeader.empty())

diff  --git a/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp 
b/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
index 552f4f4ecf886..62b5c466ee77c 100644
--- a/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ b/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -6,6 +6,7 @@
 //
 
//===--===//
 
+#include "../clang-tidy/ClangTidyOptions.h"
 #include "Annotations.h"
 #include "Config.h"
 #include "Diagnostics.h"
@@ -18,18 +19,28 @@
 #include "TestTU.h"
 #include "TidyProvider.h"
 #include "index/MemIndex.h"
+#include "index/Ref.h"
+#include "index/Relation.h"
+#include "index/Symbol.h"
 #include "support/Context.h"
 #include "support/Path.h"
+#include "clang/AST/Decl.h"
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/DiagnosticSema.h"
+#include "clang/Basic/LLVM.h"
+#include "clang/Basic/Specifiers.h"
+#include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/JSON.h"
 #include "llvm/Support/ScopedPrinter.h"
 #include "llvm/Support/TargetSelect.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
-#include 
+#include 
 #include 
+#include 
+#include 
+#include 
 
 namespace clang {
 namespace clangd {
@@ -42,6 +53,7 @@ using ::testing::Each;
 using ::testing::ElementsAre;
 using ::testing::Field;
 using ::testing::IsEmpty;
+using ::testing::Not;
 using ::testing::Pair;
 using ::testing::SizeIs;
 using ::testing::UnorderedElementsAre;
@@ -889,7 +901,8 @@ TEST(DiagnosticsTest, RecursivePreamblePragmaOnce) {
 int symbol;
   )cpp");
   TU.Filename = "foo.h";
-  EXPECT_THAT(*TU.build().getDiagnostics(), IsEmpty());
+  EXPECT_THAT(*TU.build().getDiagnostics(),
+  Not(Contains(diagName("pp_including_mainfile_in_preamble";
   EXPECT_THAT(TU.build().getLocalTopLevelDecls(), SizeIs(1));
 }
 
@@ -1597,9 +1610,9 @@ TEST(DiagsInHeaders, DiagInTransitiveInclude) {
   TU.AdditionalFiles = {{"a.h", "#include \"b.h\""},
 {"b.h", "no_type_spec; // error-ok"}};
   EXPECT_THAT(*TU.build().getDiagnostics(),
-  UnorderedElementsAre(
-  Diag(Main.range(), "in included file: a type specifier is "
- "required for all declarations")));
+   

[PATCH] D152686: [clangd] Enforce strict unused includes by default

2023-06-12 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
kadircet marked an inline comment as done.
Closed by commit rGea20f339d91f: [clangd] Enforce strict unused includes by 
default (authored by kadircet).

Changed prior to commit:
  https://reviews.llvm.org/D152686?vs=530429&id=530441#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152686

Files:
  clang-tools-extra/clangd/Config.h
  clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
  clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
  clang-tools-extra/clangd/unittests/ParsedASTTests.cpp

Index: clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
===
--- clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
+++ clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
@@ -15,6 +15,7 @@
 #include "AST.h"
 #include "Annotations.h"
 #include "Compiler.h"
+#include "Config.h"
 #include "Diagnostics.h"
 #include "Headers.h"
 #include "ParsedAST.h"
@@ -23,6 +24,7 @@
 #include "TestFS.h"
 #include "TestTU.h"
 #include "TidyProvider.h"
+#include "support/Context.h"
 #include "clang/AST/DeclTemplate.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/SourceManager.h"
@@ -33,6 +35,7 @@
 #include "gmock/gmock-matchers.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
+#include 
 
 namespace clang {
 namespace clangd {
@@ -513,6 +516,13 @@
 //   size is part of the lookup key for HeaderFileInfo, and we don't want to
 //   rely on the preamble's HFI being looked up when parsing the main file.
 TEST(ParsedASTTest, HeaderGuardsSelfInclude) {
+  // Disable include cleaner diagnostics to prevent them from interfering with
+  // other diagnostics.
+  Config Cfg;
+  Cfg.Diagnostics.MissingIncludes = Config::IncludesPolicy::None;
+  Cfg.Diagnostics.UnusedIncludes = Config::IncludesPolicy::None;
+  WithContextValue Ctx(Config::Key, std::move(Cfg));
+
   TestTU TU;
   TU.ImplicitHeaderGuard = false;
   TU.Filename = "self.h";
Index: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
===
--- clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -6,6 +6,7 @@
 //
 //===--===//
 
+#include "../clang-tidy/ClangTidyOptions.h"
 #include "Annotations.h"
 #include "Config.h"
 #include "Diagnostics.h"
@@ -18,18 +19,28 @@
 #include "TestTU.h"
 #include "TidyProvider.h"
 #include "index/MemIndex.h"
+#include "index/Ref.h"
+#include "index/Relation.h"
+#include "index/Symbol.h"
 #include "support/Context.h"
 #include "support/Path.h"
+#include "clang/AST/Decl.h"
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/DiagnosticSema.h"
+#include "clang/Basic/LLVM.h"
+#include "clang/Basic/Specifiers.h"
+#include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/JSON.h"
 #include "llvm/Support/ScopedPrinter.h"
 #include "llvm/Support/TargetSelect.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
-#include 
+#include 
 #include 
+#include 
+#include 
+#include 
 
 namespace clang {
 namespace clangd {
@@ -42,6 +53,7 @@
 using ::testing::ElementsAre;
 using ::testing::Field;
 using ::testing::IsEmpty;
+using ::testing::Not;
 using ::testing::Pair;
 using ::testing::SizeIs;
 using ::testing::UnorderedElementsAre;
@@ -889,7 +901,8 @@
 int symbol;
   )cpp");
   TU.Filename = "foo.h";
-  EXPECT_THAT(*TU.build().getDiagnostics(), IsEmpty());
+  EXPECT_THAT(*TU.build().getDiagnostics(),
+  Not(Contains(diagName("pp_including_mainfile_in_preamble";
   EXPECT_THAT(TU.build().getLocalTopLevelDecls(), SizeIs(1));
 }
 
@@ -1597,9 +1610,9 @@
   TU.AdditionalFiles = {{"a.h", "#include \"b.h\""},
 {"b.h", "no_type_spec; // error-ok"}};
   EXPECT_THAT(*TU.build().getDiagnostics(),
-  UnorderedElementsAre(
-  Diag(Main.range(), "in included file: a type specifier is "
- "required for all declarations")));
+  UnorderedElementsAre(Diag(Main.range(),
+"in included file: a type specifier is "
+"required for all declarations")));
 }
 
 TEST(DiagsInHeaders, DiagInMultipleHeaders) {
@@ -1628,9 +1641,8 @@
   {"a.h", "#include \"b.h\"\n"},
   {"b.h", "#ifndef X\n#define X\nno_type_spec; // error-ok\n#endif"}};
   EXPECT_THAT(*TU.build().getDiagnostics(),
-  UnorderedElementsAre(Diag(Main.range(),
-"in included file: a type specifier is "
-"required for all declarations")));
+  Contains(Diag(Main.range(), "in included fi

[PATCH] D152625: [clang-tidy] run-clang-tidy: forward warnings-as-errors argument

2023-06-12 Thread Maxim Kolesnikov via Phabricator via cfe-commits
indev29 added a comment.

@PiotrZSL could you please commit? I don't think I have access yet.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152625

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


[clang] 8a19af5 - [Clang] Remove uses of PointerType::getWithSamePointeeType (NFC)

2023-06-12 Thread Nikita Popov via cfe-commits

Author: Nikita Popov
Date: 2023-06-12T12:18:28+02:00
New Revision: 8a19af513d549c173b5919fe697828c84cecc396

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

LOG: [Clang] Remove uses of PointerType::getWithSamePointeeType (NFC)

No longer relevant with opaque pointers.

Added: 


Modified: 
clang/lib/CodeGen/CGAtomic.cpp
clang/lib/CodeGen/CGCall.cpp
clang/lib/CodeGen/CGClass.cpp
clang/lib/CodeGen/CGDeclCXX.cpp
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
clang/lib/CodeGen/CodeGenFunction.cpp
clang/lib/CodeGen/TargetInfo.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGAtomic.cpp b/clang/lib/CodeGen/CGAtomic.cpp
index e2d23a7252613..95f943d4bd67f 100644
--- a/clang/lib/CodeGen/CGAtomic.cpp
+++ b/clang/lib/CodeGen/CGAtomic.cpp
@@ -1097,8 +1097,7 @@ RValue CodeGenFunction::EmitAtomicExpr(AtomicExpr *E) {
   if (AS == LangAS::opencl_generic)
 return V;
   auto DestAS = getContext().getTargetAddressSpace(LangAS::opencl_generic);
-  auto T = llvm::cast(V->getType());
-  auto *DestType = llvm::PointerType::getWithSamePointeeType(T, DestAS);
+  auto *DestType = llvm::PointerType::get(getLLVMContext(), DestAS);
 
   return getTargetHooks().performAddrSpaceCast(
   *this, V, AS, LangAS::opencl_generic, DestType, false);

diff  --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index d39131828c066..8bb8e2bb3969e 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -5130,9 +5130,8 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo 
&CallInfo,
   I->copyInto(*this, AI);
 } else {
   // Skip the extra memcpy call.
-  auto *T = llvm::PointerType::getWithSamePointeeType(
-  cast(V->getType()),
-  CGM.getDataLayout().getAllocaAddrSpace());
+  auto *T = llvm::PointerType::get(
+  CGM.getLLVMContext(), CGM.getDataLayout().getAllocaAddrSpace());
 
   llvm::Value *Val = getTargetHooks().performAddrSpaceCast(
   *this, V, LangAS::Default, CGM.getASTAllocaAddressSpace(), T,

diff  --git a/clang/lib/CodeGen/CGClass.cpp b/clang/lib/CodeGen/CGClass.cpp
index 3238c31d2451f..8a71289270e28 100644
--- a/clang/lib/CodeGen/CGClass.cpp
+++ b/clang/lib/CodeGen/CGClass.cpp
@@ -2132,8 +2132,8 @@ void CodeGenFunction::EmitCXXConstructorCall(const 
CXXConstructorDecl *D,
 
   if (SlotAS != ThisAS) {
 unsigned TargetThisAS = getContext().getTargetAddressSpace(ThisAS);
-llvm::Type *NewType = llvm::PointerType::getWithSamePointeeType(
-This.getType(), TargetThisAS);
+llvm::Type *NewType =
+llvm::PointerType::get(getLLVMContext(), TargetThisAS);
 ThisPtr = getTargetHooks().performAddrSpaceCast(*this, This.getPointer(),
 ThisAS, SlotAS, NewType);
   }

diff  --git a/clang/lib/CodeGen/CGDeclCXX.cpp b/clang/lib/CodeGen/CGDeclCXX.cpp
index 04e42153519ae..bf5013e521097 100644
--- a/clang/lib/CodeGen/CGDeclCXX.cpp
+++ b/clang/lib/CodeGen/CGDeclCXX.cpp
@@ -199,8 +199,8 @@ void CodeGenFunction::EmitCXXGlobalVarDeclInit(const 
VarDecl &D,
   unsigned ActualAddrSpace = GV->getAddressSpace();
   llvm::Constant *DeclPtr = GV;
   if (ActualAddrSpace != ExpectedAddrSpace) {
-llvm::PointerType *PTy = llvm::PointerType::getWithSamePointeeType(
-GV->getType(), ExpectedAddrSpace);
+llvm::PointerType *PTy =
+llvm::PointerType::get(getLLVMContext(), ExpectedAddrSpace);
 DeclPtr = llvm::ConstantExpr::getAddrSpaceCast(DeclPtr, PTy);
   }
 

diff  --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index a5a5ed1c98ae0..099c706e84ab2 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -1918,8 +1918,7 @@ bool 
CGOpenMPRuntime::emitDeclareTargetVarDefinition(const VarDecl *VD,
   llvm::Constant *AddrInAS0 = Addr;
   if (Addr->getAddressSpace() != 0)
 AddrInAS0 = llvm::ConstantExpr::getAddrSpaceCast(
-Addr, llvm::PointerType::getWithSamePointeeType(
-  cast(Addr->getType()), 0));
+Addr, llvm::PointerType::get(CGM.getLLVMContext(), 0));
   CtorCGF.EmitAnyExprToMem(Init,
Address(AddrInAS0, Addr->getValueType(),
CGM.getContext().getDeclAlign(VD)),
@@ -1969,8 +1968,7 @@ bool 
CGOpenMPRuntime::emitDeclareTargetVarDefinition(const VarDecl *VD,
   llvm::Constant *AddrInAS0 = Addr;
   if (Addr->getAddressSpace() != 0)
 AddrInAS0 = llvm::ConstantExpr::getAddrSpaceCast(
-Addr, llvm::PointerType::getWithSamePointeeType(
-  cast(Addr->getTy

[clang] 5cc721b - [clang][Driver] Add -fcaret-diagnostics-max-lines= as a driver option

2023-06-12 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2023-06-12T12:44:25+02:00
New Revision: 5cc721b3f96e40524cd95e7d4aabb6727de83ee3

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

LOG: [clang][Driver] Add -fcaret-diagnostics-max-lines= as a driver option

Since https://reviews.llvm.org/D147875 landed, setting different values
(or reverting to the old default of 1) is more important than before,
so promote this option to a driver flag.

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

Added: 
clang/test/Driver/caret-diagnostics-max-lines.cpp

Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/FixIt/fixit-function-call.cpp
clang/test/Misc/caret-diags-multiline.cpp
clang/test/Sema/caret-diags-complex-init.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index f0744c5c8310c..32f41382a35cb 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -230,9 +230,11 @@ New Compiler Flags
 --
 - The flag ``-std=c++23`` has been added. This behaves the same as the existing
   flag ``-std=c++2b``.
-
 - ``-dumpdir`` has been implemented to specify auxiliary and dump output
   filenames for features like ``-gsplit-dwarf``.
+- ``-fcaret-diagnostics-max-lines=`` has been added as a driver options, which
+  lets users control the maximum number of source lines printed for a
+  caret diagnostic.
 
 Deprecated Compiler Flags
 -

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 36baebed78099..590787cb5da6e 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -2312,6 +2312,11 @@ def fmacro_backtrace_limit_EQ : Joined<["-"], 
"fmacro-backtrace-limit=">,
   Group, Flags<[NoXarchOption, CC1Option, CoreOption]>,
   HelpText<"Set the maximum number of entries to print in a macro expansion 
backtrace (0 = no limit)">,
   MarshallingInfoInt, 
"DiagnosticOptions::DefaultMacroBacktraceLimit">;
+def fcaret_diagnostics_max_lines_EQ :
+  Joined<["-"], "fcaret-diagnostics-max-lines=">,
+  Group, Flags<[CC1Option, CoreOption]>,
+  HelpText<"Set the maximum number of source lines to show in a caret 
diagnostic (0 = no limit).">,
+  MarshallingInfoInt, 
"DiagnosticOptions::DefaultSnippetLineLimit">;
 defm merge_all_constants : BoolFOption<"merge-all-constants",
   CodeGenOpts<"MergeAllConstants">, DefaultFalse,
   PosFlag, NegFlag,
@@ -6003,10 +6008,6 @@ def ftabstop : Separate<["-"], "ftabstop">, 
MetaVarName<"">,
 def ferror_limit : Separate<["-"], "ferror-limit">, MetaVarName<"">,
   HelpText<"Set the maximum number of errors to emit before stopping (0 = no 
limit).">,
   MarshallingInfoInt>;
-def fcaret_diagnostics_max_lines :
-  Separate<["-"], "fcaret-diagnostics-max-lines">, MetaVarName<"">,
-  HelpText<"Set the maximum number of source lines to show in a caret 
diagnostic">,
-  MarshallingInfoInt, 
"DiagnosticOptions::DefaultSnippetLineLimit">;
 def verify_EQ : CommaJoined<["-"], "verify=">,
   MetaVarName<"">,
   HelpText<"Verify diagnostic output using comment directives that start with"

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index c3c6c6a4db11d..317036fc62a60 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -6062,6 +6062,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction 
&JA,
   Args.AddLastArg(CmdArgs, options::OPT_fmacro_backtrace_limit_EQ);
   Args.AddLastArg(CmdArgs, options::OPT_ftemplate_backtrace_limit_EQ);
   Args.AddLastArg(CmdArgs, options::OPT_fspell_checking_limit_EQ);
+  Args.AddLastArg(CmdArgs, options::OPT_fcaret_diagnostics_max_lines_EQ);
 
   // Pass -fmessage-length=.
   unsigned MessageLength = 0;

diff  --git a/clang/test/Driver/caret-diagnostics-max-lines.cpp 
b/clang/test/Driver/caret-diagnostics-max-lines.cpp
new file mode 100644
index 0..9c9df7e6ac681
--- /dev/null
+++ b/clang/test/Driver/caret-diagnostics-max-lines.cpp
@@ -0,0 +1,3 @@
+//RUN: %clang++ -### -fcaret-diagnostics-max-lines=2 %s 2>&1 | FileCheck %s
+
+// CHECK: "-fcaret-diagnostics-max-lines=2"

diff  --git a/clang/test/FixIt/fixit-function-call.cpp 
b/clang/test/FixIt/fixit-function-call.cpp
index 17c50adffc4a2..5d5634c3e8b8c 100644
--- a/clang/test/FixIt/fixit-function-call.cpp
+++ b/clang/test/FixIt/fixit-function-call.cpp
@@ -1,4 +1,4 @@
-// RUN: not %clang_cc1 -fdiagnostics-parseable-fixits 
-fno-diagnostics-show-line-numbers -fcaret-diagnostics-max-lines 1 -x c++ %s 2> 
%t
+// RUN: not %clang_cc1 -fdiagnostics-parseable-fixits 
-fno-diagnostics-show-line-numbers -fcaret-diagnostics-max-lines=1 -x c++ %s 2> 
%t
 // R

[PATCH] D152090: [clang][Driver] Add -fcaret-diagnostics-max-lines= as a driver option

2023-06-12 Thread Timm Bäder via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
tbaeder marked an inline comment as done.
Closed by commit rG5cc721b3f96e: [clang][Driver] Add 
-fcaret-diagnostics-max-lines= as a driver option (authored by tbaeder).

Changed prior to commit:
  https://reviews.llvm.org/D152090?vs=530168&id=530448#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152090

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/caret-diagnostics-max-lines.cpp
  clang/test/FixIt/fixit-function-call.cpp
  clang/test/Misc/caret-diags-multiline.cpp
  clang/test/Sema/caret-diags-complex-init.cpp


Index: clang/test/Sema/caret-diags-complex-init.cpp
===
--- clang/test/Sema/caret-diags-complex-init.cpp
+++ clang/test/Sema/caret-diags-complex-init.cpp
@@ -1,4 +1,4 @@
-// RUN: not %clang_cc1 -std=c++11 -fsyntax-only 
-fno-diagnostics-show-line-numbers -fcaret-diagnostics-max-lines 5 %s 2>&1 | 
FileCheck %s -strict-whitespace
+// RUN: not %clang_cc1 -std=c++11 -fsyntax-only 
-fno-diagnostics-show-line-numbers -fcaret-diagnostics-max-lines=5 %s 2>&1 | 
FileCheck %s -strict-whitespace
 
 
 //CHECK: {{.*}}: error: excess elements in scalar initializer
Index: clang/test/Misc/caret-diags-multiline.cpp
===
--- clang/test/Misc/caret-diags-multiline.cpp
+++ clang/test/Misc/caret-diags-multiline.cpp
@@ -1,4 +1,4 @@
-// RUN: not %clang_cc1 -std=c++11 -fno-diagnostics-show-line-numbers 
-fcaret-diagnostics-max-lines 5 -Wsometimes-uninitialized %s 2>&1 | FileCheck 
%s --strict-whitespace
+// RUN: not %clang_cc1 -std=c++11 -fno-diagnostics-show-line-numbers 
-fcaret-diagnostics-max-lines=5 -Wsometimes-uninitialized %s 2>&1 | FileCheck 
%s --strict-whitespace
 
 void line(int);
 
Index: clang/test/FixIt/fixit-function-call.cpp
===
--- clang/test/FixIt/fixit-function-call.cpp
+++ clang/test/FixIt/fixit-function-call.cpp
@@ -1,4 +1,4 @@
-// RUN: not %clang_cc1 -fdiagnostics-parseable-fixits 
-fno-diagnostics-show-line-numbers -fcaret-diagnostics-max-lines 1 -x c++ %s 2> 
%t
+// RUN: not %clang_cc1 -fdiagnostics-parseable-fixits 
-fno-diagnostics-show-line-numbers -fcaret-diagnostics-max-lines=1 -x c++ %s 2> 
%t
 // RUN: FileCheck %s < %t
 // PR5941
 // END.
Index: clang/test/Driver/caret-diagnostics-max-lines.cpp
===
--- /dev/null
+++ clang/test/Driver/caret-diagnostics-max-lines.cpp
@@ -0,0 +1,3 @@
+//RUN: %clang++ -### -fcaret-diagnostics-max-lines=2 %s 2>&1 | FileCheck %s
+
+// CHECK: "-fcaret-diagnostics-max-lines=2"
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6062,6 +6062,7 @@
   Args.AddLastArg(CmdArgs, options::OPT_fmacro_backtrace_limit_EQ);
   Args.AddLastArg(CmdArgs, options::OPT_ftemplate_backtrace_limit_EQ);
   Args.AddLastArg(CmdArgs, options::OPT_fspell_checking_limit_EQ);
+  Args.AddLastArg(CmdArgs, options::OPT_fcaret_diagnostics_max_lines_EQ);
 
   // Pass -fmessage-length=.
   unsigned MessageLength = 0;
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2312,6 +2312,11 @@
   Group, Flags<[NoXarchOption, CC1Option, CoreOption]>,
   HelpText<"Set the maximum number of entries to print in a macro expansion 
backtrace (0 = no limit)">,
   MarshallingInfoInt, 
"DiagnosticOptions::DefaultMacroBacktraceLimit">;
+def fcaret_diagnostics_max_lines_EQ :
+  Joined<["-"], "fcaret-diagnostics-max-lines=">,
+  Group, Flags<[CC1Option, CoreOption]>,
+  HelpText<"Set the maximum number of source lines to show in a caret 
diagnostic (0 = no limit).">,
+  MarshallingInfoInt, 
"DiagnosticOptions::DefaultSnippetLineLimit">;
 defm merge_all_constants : BoolFOption<"merge-all-constants",
   CodeGenOpts<"MergeAllConstants">, DefaultFalse,
   PosFlag, NegFlag,
@@ -6003,10 +6008,6 @@
 def ferror_limit : Separate<["-"], "ferror-limit">, MetaVarName<"">,
   HelpText<"Set the maximum number of errors to emit before stopping (0 = no 
limit).">,
   MarshallingInfoInt>;
-def fcaret_diagnostics_max_lines :
-  Separate<["-"], "fcaret-diagnostics-max-lines">, MetaVarName<"">,
-  HelpText<"Set the maximum number of source lines to show in a caret 
diagnostic">,
-  MarshallingInfoInt, 
"DiagnosticOptions::DefaultSnippetLineLimit">;
 def verify_EQ : CommaJoined<["-"], "verify=">,
   MetaVarName<"">,
   HelpText<"Verify diagnostic output using comment directives that start 

[PATCH] D152696: Prevent deadlocks in death tests.

2023-06-12 Thread Martin Böhme via Phabricator via cfe-commits
mboehme created this revision.
Herald added a subscriber: thopre.
Herald added a project: All.
mboehme requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

We have recently started seeing deadlocks in death tests while running in an
internal test environment.

Per the documentation here, there are issues with death tests in the presence of
threads:

https://github.com/google/googletest/blob/main/docs/advanced.md#death-tests-and-threads

To avoid the deadlocks, I first tried appending `DeathTest` to the relevant
test suite names, which has the effect of running these test suites before all
other tests. However, this did not prevent the deadlocks.

This patch therefore uses the option of setting the `death_test_style` flag to
`"threadsafe"` (see description in the page linked above under "Death Test
Styles"), and this prevents the deadlocks.

As the page linked above notes, "flags are saved before each test and restored
afterwards", so the flag affects only the tests where it is set. This is
important because the "threadsafe" death test style "trades increased test
execution time (potentially dramatically so) for improved thread safety", so we
likely don't want to set it for all tests. The tests where I've added the flag
don't appear to suffer a significantly increated execution time.

This patch changes a number of unit tests across LLVM and Clang. As this patch
fixes a test infrastructure issue and doesn't affect the behavior of the tests
themselves, it seemed appropriate to change all death tests in a single patch.
However, if reviewers would prefer me to split this up into separate patches
form LLVM and Clang, I'm happy to do that.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152696

Files:
  clang/unittests/ASTMatchers/ASTMatchersInternalTest.cpp
  clang/unittests/ASTMatchers/Dynamic/VariantValueTest.cpp
  clang/unittests/Basic/FileManagerTest.cpp
  clang/unittests/Basic/LineOffsetMappingTest.cpp
  clang/unittests/Basic/SarifTest.cpp
  clang/unittests/Lex/LexerTest.cpp
  clang/unittests/Serialization/InMemoryModuleCacheTest.cpp
  clang/unittests/Tooling/TransformerTest.cpp
  llvm/unittests/ADT/APFloatTest.cpp
  llvm/unittests/ADT/APIntTest.cpp
  llvm/unittests/ADT/APSIntTest.cpp
  llvm/unittests/ADT/AnyTest.cpp
  llvm/unittests/ADT/BumpPtrListTest.cpp
  llvm/unittests/ADT/IteratorTest.cpp
  llvm/unittests/ADT/STLExtrasTest.cpp
  llvm/unittests/ADT/SequenceTest.cpp
  llvm/unittests/ADT/SmallVectorTest.cpp
  llvm/unittests/AsmParser/AsmParserTest.cpp
  llvm/unittests/BinaryFormat/MsgPackWriterTest.cpp
  llvm/unittests/CodeGen/GlobalISel/MachineIRBuilderTest.cpp
  llvm/unittests/CodeGen/LowLevelTypeTest.cpp
  llvm/unittests/CodeGen/MachineInstrBundleIteratorTest.cpp
  llvm/unittests/FileCheck/FileCheckTest.cpp
  llvm/unittests/IR/ConstantsTest.cpp
  llvm/unittests/IR/MetadataTest.cpp
  llvm/unittests/IR/ValueHandleTest.cpp
  llvm/unittests/IR/ValueTest.cpp
  llvm/unittests/Support/DataExtractorTest.cpp
  llvm/unittests/Support/ErrorTest.cpp
  llvm/unittests/Support/Path.cpp
  llvm/unittests/Support/YAMLIOTest.cpp
  llvm/unittests/Support/raw_pwrite_stream_test.cpp
  llvm/unittests/Transforms/Utils/ValueMapperTest.cpp

Index: llvm/unittests/Transforms/Utils/ValueMapperTest.cpp
===
--- llvm/unittests/Transforms/Utils/ValueMapperTest.cpp
+++ llvm/unittests/Transforms/Utils/ValueMapperTest.cpp
@@ -265,6 +265,8 @@
 #ifdef GTEST_HAS_DEATH_TEST
 #ifndef NDEBUG
 TEST(ValueMapperTest, mapMetadataLocalAsMetadata) {
+  testing::GTEST_FLAG(death_test_style) = "threadsafe";
+
   LLVMContext C;
   FunctionType *FTy =
   FunctionType::get(Type::getVoidTy(C), Type::getInt8Ty(C), false);
Index: llvm/unittests/Support/raw_pwrite_stream_test.cpp
===
--- llvm/unittests/Support/raw_pwrite_stream_test.cpp
+++ llvm/unittests/Support/raw_pwrite_stream_test.cpp
@@ -38,6 +38,8 @@
 
 #ifdef GTEST_HAS_DEATH_TEST
 #ifndef NDEBUG
+  testing::GTEST_FLAG(death_test_style) = "threadsafe";
+
   EXPECT_DEATH(OS.pwrite("12345", 5, 0),
"We don't support extending the stream");
 #endif
@@ -74,6 +76,8 @@
 
 #ifdef GTEST_HAS_DEATH_TEST
 #ifndef NDEBUG
+  testing::GTEST_FLAG(death_test_style) = "threadsafe";
+
   EXPECT_DEATH(OS.pwrite("12345", 5, 0),
"We don't support extending the stream");
 #endif
Index: llvm/unittests/Support/YAMLIOTest.cpp
===
--- llvm/unittests/Support/YAMLIOTest.cpp
+++ llvm/unittests/Support/YAMLIOTest.cpp
@@ -3064,6 +3064,8 @@
   Output yout(ostr);
 #ifdef GTEST_HAS_DEATH_TEST
 #ifndef NDEBUG
+  testing::GTEST_FLAG(death_test_style) = "threadsafe";
+
   EXPECT_DEATH(yout << node, "plain scalar documents are not supported");
 #endif
 #endif
Index: llvm/unittests/Support/Path.cpp
===

[PATCH] D152443: Add operator style options to clang-format

2023-06-12 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added inline comments.



Comment at: clang/lib/Format/TokenAnnotator.cpp:4203
   return true;
-
-if (Left.is(tok::kw_operator))
-  return Right.is(tok::coloncolon);
+// Operator overloads, calls and address-of expressions
+if (Left.is(tok::kw_operator)) {





Comment at: clang/lib/Format/TokenAnnotator.cpp:4211
+}
+Token = Token->Previous; // Skip one more token and check if it exists
+if (!Token)

Token could be null here already.



Comment at: clang/lib/Format/TokenAnnotator.cpp:4213
+if (!Token)
+  return Right.is(tok::coloncolon);
+// This handles all overload cases; type/type*/type&/type&&/type<>

This would be `operator::`, or not?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152443

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


[PATCH] D152625: [clang-tidy] run-clang-tidy: forward warnings-as-errors argument

2023-06-12 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL added a comment.

In D152625#4413242 , @indev29 wrote:

> @PiotrZSL could you please commit? I don't think I have access yet.

Author & Email please for git, under which should it be delivered.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152625

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


[PATCH] D152697: AMDGPU: Add llvm.amdgcn.log intrinsic

2023-06-12 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm created this revision.
arsenm added reviewers: AMDGPU, foad, rampitec, Pierre-vh, cdevadas, jhuber6.
Herald added subscribers: StephenFan, kerbowa, hiraditya, tpr, dstuttard, 
yaxunl, jvesely, kzhuravl.
Herald added a project: All.
arsenm requested review of this revision.
Herald added a subscriber: wdng.
Herald added a project: LLVM.

This will map directly to the hardware instruction which does not
handle denormals for f32. This will allow moving the generic intrinsic
to be lowered correctly. Also handles selecting the f16 version, but
there's no reason to use it over the generic intrinsic.


https://reviews.llvm.org/D152697

Files:
  clang/include/clang/Basic/BuiltinsAMDGPU.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGenOpenCL/builtins-amdgcn.cl
  llvm/docs/ReleaseNotes.rst
  llvm/include/llvm/IR/IntrinsicsAMDGPU.td
  llvm/lib/Target/AMDGPU/AMDGPUISelLowering.cpp
  llvm/lib/Target/AMDGPU/AMDGPUISelLowering.h
  llvm/lib/Target/AMDGPU/AMDGPUInstrInfo.td
  llvm/lib/Target/AMDGPU/AMDGPURegisterBankInfo.cpp
  llvm/lib/Target/AMDGPU/R600Instructions.td
  llvm/lib/Target/AMDGPU/SIISelLowering.cpp
  llvm/lib/Target/AMDGPU/VOP1Instructions.td
  llvm/test/CodeGen/AMDGPU/fcanonicalize-elimination.ll
  llvm/test/CodeGen/AMDGPU/llvm.amdgcn.log.ll

Index: llvm/test/CodeGen/AMDGPU/llvm.amdgcn.log.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AMDGPU/llvm.amdgcn.log.ll
@@ -0,0 +1,79 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 2
+; RUN: llc -global-isel=0 -mtriple=amdgcn-amd-amdhsa -mcpu=fiji < %s | FileCheck -check-prefixes=GCN,SDAG %s
+; RUN: llc -global-isel=1 -mtriple=amdgcn-amd-amdhsa -mcpu=fiji < %s | FileCheck -check-prefixes=GCN,GISEL %s
+
+define float @v_log_f32(float %src)  {
+; GCN-LABEL: v_log_f32:
+; GCN:   ; %bb.0:
+; GCN-NEXT:s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
+; GCN-NEXT:v_log_f32_e32 v0, v0
+; GCN-NEXT:s_setpc_b64 s[30:31]
+  %log = call float @llvm.amdgcn.log.f32(float %src)
+  ret float %log
+}
+
+define float @v_fabs_log_f32(float %src)  {
+; GCN-LABEL: v_fabs_log_f32:
+; GCN:   ; %bb.0:
+; GCN-NEXT:s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
+; GCN-NEXT:v_log_f32_e64 v0, |v0|
+; GCN-NEXT:s_setpc_b64 s[30:31]
+  %fabs.src = call float @llvm.fabs.f32(float %src)
+  %log = call float @llvm.amdgcn.log.f32(float %fabs.src)
+  ret float %log
+}
+
+define float @v_fneg_fabs_log_f32(float %src)  {
+; GCN-LABEL: v_fneg_fabs_log_f32:
+; GCN:   ; %bb.0:
+; GCN-NEXT:s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
+; GCN-NEXT:v_log_f32_e64 v0, -|v0|
+; GCN-NEXT:s_setpc_b64 s[30:31]
+  %fabs.src = call float @llvm.fabs.f32(float %src)
+  %neg.fabs.src = fneg float %fabs.src
+  %log = call float @llvm.amdgcn.log.f32(float %neg.fabs.src)
+  ret float %log
+}
+
+define half @v_log_f16(half %src)  {
+; GCN-LABEL: v_log_f16:
+; GCN:   ; %bb.0:
+; GCN-NEXT:s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
+; GCN-NEXT:v_log_f16_e32 v0, v0
+; GCN-NEXT:s_setpc_b64 s[30:31]
+  %log = call half @llvm.amdgcn.log.f16(half %src)
+  ret half %log
+}
+
+define half @v_fabs_log_f16(half %src)  {
+; GCN-LABEL: v_fabs_log_f16:
+; GCN:   ; %bb.0:
+; GCN-NEXT:s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
+; GCN-NEXT:v_log_f16_e64 v0, |v0|
+; GCN-NEXT:s_setpc_b64 s[30:31]
+  %fabs.src = call half @llvm.fabs.f16(half %src)
+  %log = call half @llvm.amdgcn.log.f16(half %fabs.src)
+  ret half %log
+}
+
+define half @v_fneg_fabs_log_f16(half %src)  {
+; GCN-LABEL: v_fneg_fabs_log_f16:
+; GCN:   ; %bb.0:
+; GCN-NEXT:s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
+; GCN-NEXT:v_log_f16_e64 v0, -|v0|
+; GCN-NEXT:s_setpc_b64 s[30:31]
+  %fabs.src = call half @llvm.fabs.f16(half %src)
+  %neg.fabs.src = fneg half %fabs.src
+  %log = call half @llvm.amdgcn.log.f16(half %neg.fabs.src)
+  ret half %log
+}
+
+declare half @llvm.amdgcn.log.f16(half) #0
+declare float @llvm.amdgcn.log.f32(float) #0
+declare float @llvm.fabs.f32(float) #0
+declare half @llvm.fabs.f16(half) #0
+
+attributes #0 = { nounwind readnone speculatable willreturn }
+;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
+; GISEL: {{.*}}
+; SDAG: {{.*}}
Index: llvm/test/CodeGen/AMDGPU/fcanonicalize-elimination.ll
===
--- llvm/test/CodeGen/AMDGPU/fcanonicalize-elimination.ll
+++ llvm/test/CodeGen/AMDGPU/fcanonicalize-elimination.ll
@@ -872,6 +872,16 @@
   ret float %canonicalized
 }
 
+; GCN-LABEL: {{^}}v_test_canonicalize_amdgcn_log:
+; GCN: s_waitcnt
+; GCN-NEXT: v_log_f32
+; GCN-NEXT: s_setpc_b64
+define float @v_test_canonicalize_amdgcn_log(float %a) {
+  %log = call float @llvm.amdgcn.log.f32(float %a)
+  %canonicalized = call float @llvm.canonicalize.f32(float %log)
+  ret float %canonicalized
+}
+
 ; Avoid failing the test on FreeBSD11.0 which will match the GCN-NOT

[PATCH] D147218: [OpenMP][Flang][MLIR] Lowering of OpenMP requires directive from parse tree to MLIR

2023-06-12 Thread Sergio Afonso via Phabricator via cfe-commits
skatrak added a comment.

Thank you for the feedback. I expect I will be able to refactor the 
`analyzeOpenMPDeclarative()` function to OpenMP.cpp as suggested, but I'll 
bring that together with other changes to make it integrate cleanly with the 
latest changes to D149337 . Since that patch 
now moves a big part of the gathering of 'requires' clauses to the prior 
semantics step, this patch can be simplified to rely on that.




Comment at: flang/lib/Lower/Bridge.cpp:271
+bridge{bridge}, foldingContext{bridge.createFoldingContext()},
+ompRequiresFlags{mlir::omp::ClauseRequires::none} {}
   virtual ~FirConverter() = default;

kiranchandramohan wrote:
> Is this set anywhere? If not is it required? Can this be made available 
> through the bridge?
The `ompRequiresFlags` field is set by the `analyzeOpenMPDeclarative` method, 
called for each 'omp requires' directive in the PFT.

I'm not sure if I understand what you mean by making this available through the 
bridge. Do you suggest creating a public method to access these flags?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147218

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


[PATCH] D152625: [clang-tidy] run-clang-tidy: forward warnings-as-errors argument

2023-06-12 Thread Maxim Kolesnikov via Phabricator via cfe-commits
indev29 added a comment.

In D152625#4413366 , @PiotrZSL wrote:

> In D152625#4413242 , @indev29 wrote:
>
>> @PiotrZSL could you please commit? I don't think I have access yet.
>
> Author & Email please for git, under which should it be delivered.

`indev `


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152625

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


[clang] a8ad413 - [RFC][clangd] Move preamble index out of document open critical path

2023-06-12 Thread Ivan Murashko via cfe-commits

Author: Kugan Vivekanandarajah
Date: 2023-06-12T12:56:41+01:00
New Revision: a8ad413f0d18c07a4adaa0d547e0096874d809c5

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

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

We would like to move the preamble index out of the critical path.
This patch is an RFC to get feedback on the correct implementation and 
potential pitfalls to keep into consideration.

I am not entirely sure if the lazy AST initialisation would create using 
Preamble AST in parallel. I tried with tsan enabled clangd but it seems to work 
OK (at least for the cases I tried)

Reviewed By: kadircet

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

Added: 


Modified: 
clang-tools-extra/clangd/ClangdServer.cpp
clang-tools-extra/clangd/ClangdServer.h
clang-tools-extra/clangd/ParsedAST.cpp
clang-tools-extra/clangd/Preamble.cpp
clang-tools-extra/clangd/Preamble.h
clang-tools-extra/clangd/TUScheduler.cpp
clang-tools-extra/clangd/TUScheduler.h
clang-tools-extra/clangd/tool/Check.cpp
clang-tools-extra/clangd/unittests/FileIndexTests.cpp
clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
clang-tools-extra/clangd/unittests/TestWorkspace.cpp
clang/include/clang/Frontend/CompilerInstance.h

Removed: 




diff  --git a/clang-tools-extra/clangd/ClangdServer.cpp 
b/clang-tools-extra/clangd/ClangdServer.cpp
index cd3a52249dfb7..7b4224a20cec3 100644
--- a/clang-tools-extra/clangd/ClangdServer.cpp
+++ b/clang-tools-extra/clangd/ClangdServer.cpp
@@ -62,22 +62,38 @@ struct UpdateIndexCallbacks : public ParsingCallbacks {
   UpdateIndexCallbacks(FileIndex *FIndex,
ClangdServer::Callbacks *ServerCallbacks,
const ThreadsafeFS &TFS, AsyncTaskRunner *Tasks,
-   bool CollectInactiveRegions)
-  : FIndex(FIndex), ServerCallbacks(ServerCallbacks), TFS(TFS),
-Stdlib{std::make_shared()}, Tasks(Tasks),
-CollectInactiveRegions(CollectInactiveRegions) {}
-
-  void onPreambleAST(PathRef Path, llvm::StringRef Version,
- const CompilerInvocation &CI, ASTContext &Ctx,
- Preprocessor &PP,
- const CanonicalIncludes &CanonIncludes) override {
-// If this preamble uses a standard library we haven't seen yet, index it.
-if (FIndex)
-  if (auto Loc = Stdlib->add(*CI.getLangOpts(), PP.getHeaderSearchInfo()))
-indexStdlib(CI, std::move(*Loc));
+   bool CollectInactiveRegions,
+   const ClangdServer::Options &Opts)
+  : FIndex(FIndex), ServerCallbacks(ServerCallbacks),
+TFS(TFS), Stdlib{std::make_shared()}, Tasks(Tasks),
+CollectInactiveRegions(CollectInactiveRegions), Opts(Opts) {}
+
+  void onPreambleAST(
+  PathRef Path, llvm::StringRef Version, CapturedASTCtx ASTCtx,
+  const std::shared_ptr CanonIncludes) override {
+
+if (!FIndex)
+  return;
+
+auto &PP = ASTCtx.getPreprocessor();
+auto &CI = ASTCtx.getCompilerInvocation();
+if (auto Loc = Stdlib->add(*CI.getLangOpts(), PP.getHeaderSearchInfo()))
+  indexStdlib(CI, std::move(*Loc));
+
+// FIndex outlives the UpdateIndexCallbacks.
+auto Task = [FIndex(FIndex), Path(Path.str()), Version(Version.str()),
+ ASTCtx(std::move(ASTCtx)),
+ CanonIncludes(CanonIncludes)]() mutable {
+  trace::Span Tracer("PreambleIndexing");
+  FIndex->updatePreamble(Path, Version, ASTCtx.getASTContext(),
+ ASTCtx.getPreprocessor(), *CanonIncludes);
+};
 
-if (FIndex)
-  FIndex->updatePreamble(Path, Version, Ctx, PP, CanonIncludes);
+if (Opts.AsyncPreambleIndexing && Tasks) {
+  Tasks->runAsync("Preamble indexing for:" + Path + Version,
+  std::move(Task));
+} else
+  Task();
   }
 
   void indexStdlib(const CompilerInvocation &CI, StdLibLocation Loc) {
@@ -146,6 +162,7 @@ struct UpdateIndexCallbacks : public ParsingCallbacks {
   std::shared_ptr Stdlib;
   AsyncTaskRunner *Tasks;
   bool CollectInactiveRegions;
+  const ClangdServer::Options &Opts;
 };
 
 class DraftStoreFS : public ThreadsafeFS {
@@ -210,7 +227,7 @@ ClangdServer::ClangdServer(const GlobalCompilationDatabase 
&CDB,
 std::make_unique(
 DynamicIdx.get(), Callbacks, TFS,
 IndexTasks ? &*IndexTasks : nullptr,
-PublishInactiveRegions));
+PublishInactiveRegions, Opts));
   // Adds an index to the stack, at higher priority than existing indexes.
   auto AddIndex = [&](SymbolIndex *Idx) {
 if (this->Index != nullptr) {

diff  -

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

2023-06-12 Thread Ivan Murashko 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 rGa8ad413f0d18: [RFC][clangd] Move preamble index out of 
document open critical path (authored by kuganv, committed by ivanmurashko).

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/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/ParsedAST.cpp
  clang-tools-extra/clangd/Preamble.cpp
  clang-tools-extra/clangd/Preamble.h
  clang-tools-extra/clangd/TUScheduler.cpp
  clang-tools-extra/clangd/TUScheduler.h
  clang-tools-extra/clangd/tool/Check.cpp
  clang-tools-extra/clangd/unittests/FileIndexTests.cpp
  clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
  clang-tools-extra/clangd/unittests/TestWorkspace.cpp
  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/TestWorkspace.cpp
===
--- clang-tools-extra/clangd/unittests/TestWorkspace.cpp
+++ clang-tools-extra/clangd/unittests/TestWorkspace.cpp
@@ -21,11 +21,14 @@
   continue;
 TU.Code = Input.second.Code;
 TU.Filename = Input.first().str();
-TU.preamble([&](ASTContext &Ctx, Preprocessor &PP,
-const CanonicalIncludes &CanonIncludes) {
-  Index->updatePreamble(testPath(Input.first()), "null", Ctx, PP,
-CanonIncludes);
-});
+TU.preamble(
+[&](CapturedASTCtx ASTCtx,
+const std::shared_ptr CanonIncludes) {
+  auto &Ctx = ASTCtx.getASTContext();
+  auto &PP = ASTCtx.getPreprocessor();
+  Index->updatePreamble(testPath(Input.first()), "null", Ctx, PP,
+*CanonIncludes);
+});
 ParsedAST MainAST = TU.build();
 Index->updateMain(testPath(Input.first()), MainAST);
   }
Index: clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
===
--- clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
+++ clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
@@ -1129,9 +1129,9 @@
   public:
 BlockPreambleThread(llvm::StringRef BlockVersion, Notification &N)
 : BlockVersion(BlockVersion), N(N) {}
-void onPreambleAST(PathRef Path, llvm::StringRef Version,
-   const CompilerInvocation &, ASTContext &Ctx,
-   Preprocessor &, const CanonicalIncludes &) override {
+void
+onPreambleAST(PathRef Path, llvm::StringRef Version, CapturedASTCtx,
+  const std::sha

[PATCH] D147717: [C++20] Claim full support for consteval again

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

LGTM (though I wonder if we should add a release note as well)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147717

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


[PATCH] D152689: [NFC] Remove dead conditionals

2023-06-12 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a subscriber: rjmccall.
aaron.ballman added a comment.

The other two changes LGTM, but the objc changes bring up a question about what 
the correct fix is.




Comment at: clang/lib/CodeGen/CGObjCMac.cpp:3812
   llvm::GlobalVariable *GV;
-  if (ForClass)
-GV =

I agree this is dead code (see line 3777-3778 above), but @rjmccall is it a bug 
that we bail out with a null value (e.g, is the correct fix to remove the above 
lines)?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152689

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


[PATCH] D152697: AMDGPU: Add llvm.amdgcn.log intrinsic

2023-06-12 Thread Jay Foad via Phabricator via cfe-commits
foad accepted this revision.
foad added a comment.
This revision is now accepted and ready to land.

Seems fine.


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

https://reviews.llvm.org/D152697

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


[clang] 3f31d32 - [clang][dataflow] Model pointer value for builtin functions.

2023-06-12 Thread Martin Braenne via cfe-commits

Author: Martin Braenne
Date: 2023-06-12T12:23:18Z
New Revision: 3f31d3204bd2726fa8e5c56ea27c8bba0074790e

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

LOG: [clang][dataflow] Model pointer value for builtin functions.

This fixes a false positive in the Crubit nullability verification.

Reviewed By: gribozavr2

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

Added: 


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

Removed: 




diff  --git a/clang/lib/Analysis/FlowSensitive/Transfer.cpp 
b/clang/lib/Analysis/FlowSensitive/Transfer.cpp
index 8547e5049261f..e0cb872cfa372 100644
--- a/clang/lib/Analysis/FlowSensitive/Transfer.cpp
+++ b/clang/lib/Analysis/FlowSensitive/Transfer.cpp
@@ -400,7 +400,8 @@ class TransferVisitor : public 
ConstStmtVisitor {
   Env.setValue(Loc, NullPointerVal);
   break;
 }
-case CK_FunctionToPointerDecay: {
+case CK_FunctionToPointerDecay:
+case CK_BuiltinFnToFnPtr: {
   StorageLocation *PointeeLoc =
   Env.getStorageLocation(*SubExpr, SkipPast::Reference);
   if (PointeeLoc == nullptr)

diff  --git a/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp 
b/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
index 1a2442f0b12db..7077f7344a858 100644
--- a/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
+++ b/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
@@ -5327,4 +5327,37 @@ TEST(TransferTest, FunctionToPointerDecayHasValue) {
   });
 }
 
+// Check that the pointer that a builtin function decays to is associated with
+// a value.
+TEST(TransferTest, BuiltinFunctionModeled) {
+  std::string Code = R"(
+void target() {
+  __builtin_expect(0, 0);
+  // [[p]]
+}
+  )";
+  runDataflow(
+  Code,
+  [](const llvm::StringMap> &Results,
+ ASTContext &ASTCtx) {
+using ast_matchers::selectFirst;
+using ast_matchers::match;
+using ast_matchers::traverse;
+using ast_matchers::implicitCastExpr;
+using ast_matchers::hasCastKind;
+
+const Environment &Env = getEnvironmentAtAnnotation(Results, "p");
+
+auto *ImplicitCast = selectFirst(
+"implicit_cast",
+match(traverse(TK_AsIs,
+   implicitCastExpr(hasCastKind(CK_BuiltinFnToFnPtr))
+   .bind("implicit_cast")),
+  ASTCtx));
+
+ASSERT_THAT(ImplicitCast, NotNull());
+EXPECT_THAT(Env.getValueStrict(*ImplicitCast), NotNull());
+  });
+}
+
 } // namespace



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


[PATCH] D152683: [clang][dataflow] Model pointer value for builtin functions.

2023-06-12 Thread Martin Böhme via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3f31d3204bd2: [clang][dataflow] Model pointer value for 
builtin functions. (authored by mboehme).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152683

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


Index: clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
@@ -5327,4 +5327,37 @@
   });
 }
 
+// Check that the pointer that a builtin function decays to is associated with
+// a value.
+TEST(TransferTest, BuiltinFunctionModeled) {
+  std::string Code = R"(
+void target() {
+  __builtin_expect(0, 0);
+  // [[p]]
+}
+  )";
+  runDataflow(
+  Code,
+  [](const llvm::StringMap> &Results,
+ ASTContext &ASTCtx) {
+using ast_matchers::selectFirst;
+using ast_matchers::match;
+using ast_matchers::traverse;
+using ast_matchers::implicitCastExpr;
+using ast_matchers::hasCastKind;
+
+const Environment &Env = getEnvironmentAtAnnotation(Results, "p");
+
+auto *ImplicitCast = selectFirst(
+"implicit_cast",
+match(traverse(TK_AsIs,
+   implicitCastExpr(hasCastKind(CK_BuiltinFnToFnPtr))
+   .bind("implicit_cast")),
+  ASTCtx));
+
+ASSERT_THAT(ImplicitCast, NotNull());
+EXPECT_THAT(Env.getValueStrict(*ImplicitCast), NotNull());
+  });
+}
+
 } // namespace
Index: clang/lib/Analysis/FlowSensitive/Transfer.cpp
===
--- clang/lib/Analysis/FlowSensitive/Transfer.cpp
+++ clang/lib/Analysis/FlowSensitive/Transfer.cpp
@@ -400,7 +400,8 @@
   Env.setValue(Loc, NullPointerVal);
   break;
 }
-case CK_FunctionToPointerDecay: {
+case CK_FunctionToPointerDecay:
+case CK_BuiltinFnToFnPtr: {
   StorageLocation *PointeeLoc =
   Env.getStorageLocation(*SubExpr, SkipPast::Reference);
   if (PointeeLoc == nullptr)


Index: clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
@@ -5327,4 +5327,37 @@
   });
 }
 
+// Check that the pointer that a builtin function decays to is associated with
+// a value.
+TEST(TransferTest, BuiltinFunctionModeled) {
+  std::string Code = R"(
+void target() {
+  __builtin_expect(0, 0);
+  // [[p]]
+}
+  )";
+  runDataflow(
+  Code,
+  [](const llvm::StringMap> &Results,
+ ASTContext &ASTCtx) {
+using ast_matchers::selectFirst;
+using ast_matchers::match;
+using ast_matchers::traverse;
+using ast_matchers::implicitCastExpr;
+using ast_matchers::hasCastKind;
+
+const Environment &Env = getEnvironmentAtAnnotation(Results, "p");
+
+auto *ImplicitCast = selectFirst(
+"implicit_cast",
+match(traverse(TK_AsIs,
+   implicitCastExpr(hasCastKind(CK_BuiltinFnToFnPtr))
+   .bind("implicit_cast")),
+  ASTCtx));
+
+ASSERT_THAT(ImplicitCast, NotNull());
+EXPECT_THAT(Env.getValueStrict(*ImplicitCast), NotNull());
+  });
+}
+
 } // namespace
Index: clang/lib/Analysis/FlowSensitive/Transfer.cpp
===
--- clang/lib/Analysis/FlowSensitive/Transfer.cpp
+++ clang/lib/Analysis/FlowSensitive/Transfer.cpp
@@ -400,7 +400,8 @@
   Env.setValue(Loc, NullPointerVal);
   break;
 }
-case CK_FunctionToPointerDecay: {
+case CK_FunctionToPointerDecay:
+case CK_BuiltinFnToFnPtr: {
   StorageLocation *PointeeLoc =
   Env.getStorageLocation(*SubExpr, SkipPast::Reference);
   if (PointeeLoc == nullptr)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] 2499bee - [clang-tidy] run-clang-tidy: forward warnings-as-errors argument

2023-06-12 Thread Piotr Zegar via cfe-commits

Author: indev
Date: 2023-06-12T12:24:08Z
New Revision: 2499beeb5a3d3d2062b14be8ae0f967ef44968ba

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

LOG: [clang-tidy] run-clang-tidy: forward warnings-as-errors argument

Forward `warnings-as-errors` argument to clang-tidy.

Reviewed By: PiotrZSL

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/tool/run-clang-tidy.py

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py 
b/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
index 53dc851149fd7..e0c2d63d2024c 100755
--- a/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
+++ b/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
@@ -105,6 +105,7 @@ def get_tidy_invocation(
 line_filter,
 use_color,
 plugins,
+warnings_as_errors,
 ):
 """Gets a command line for clang-tidy."""
 start = [clang_tidy_binary]
@@ -141,6 +142,8 @@ def get_tidy_invocation(
 start.append("-config=" + config)
 for plugin in plugins:
 start.append("-load=" + plugin)
+if warnings_as_errors:
+start.append("--warnings-as-errors=" + warnings_as_errors)
 start.append(f)
 return start
 
@@ -224,6 +227,7 @@ def run_tidy(args, clang_tidy_binary, tmpdir, build_path, 
queue, lock, failed_fi
 args.line_filter,
 args.use_color,
 args.plugins,
+args.warnings_as_errors,
 )
 
 proc = subprocess.Popen(
@@ -363,6 +367,11 @@ def main():
 default=[],
 help="Load the specified plugin in clang-tidy.",
 )
+parser.add_argument(
+"-warnings-as-errors",
+default=None,
+help="Upgrades warnings to errors. Same format as " "'-checks'",
+)
 args = parser.parse_args()
 
 db_path = "compile_commands.json"
@@ -399,6 +408,7 @@ def main():
 args.line_filter,
 args.use_color,
 args.plugins,
+args.warnings_as_errors,
 )
 invocation.append("-list-checks")
 invocation.append("-")



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


[PATCH] D152625: [clang-tidy] run-clang-tidy: forward warnings-as-errors argument

2023-06-12 Thread Piotr Zegar via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2499beeb5a3d: [clang-tidy] run-clang-tidy: forward 
warnings-as-errors argument (authored by indev29, committed by PiotrZSL).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152625

Files:
  clang-tools-extra/clang-tidy/tool/run-clang-tidy.py


Index: clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
===
--- clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
+++ clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
@@ -105,6 +105,7 @@
 line_filter,
 use_color,
 plugins,
+warnings_as_errors,
 ):
 """Gets a command line for clang-tidy."""
 start = [clang_tidy_binary]
@@ -141,6 +142,8 @@
 start.append("-config=" + config)
 for plugin in plugins:
 start.append("-load=" + plugin)
+if warnings_as_errors:
+start.append("--warnings-as-errors=" + warnings_as_errors)
 start.append(f)
 return start
 
@@ -224,6 +227,7 @@
 args.line_filter,
 args.use_color,
 args.plugins,
+args.warnings_as_errors,
 )
 
 proc = subprocess.Popen(
@@ -363,6 +367,11 @@
 default=[],
 help="Load the specified plugin in clang-tidy.",
 )
+parser.add_argument(
+"-warnings-as-errors",
+default=None,
+help="Upgrades warnings to errors. Same format as " "'-checks'",
+)
 args = parser.parse_args()
 
 db_path = "compile_commands.json"
@@ -399,6 +408,7 @@
 args.line_filter,
 args.use_color,
 args.plugins,
+args.warnings_as_errors,
 )
 invocation.append("-list-checks")
 invocation.append("-")


Index: clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
===
--- clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
+++ clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
@@ -105,6 +105,7 @@
 line_filter,
 use_color,
 plugins,
+warnings_as_errors,
 ):
 """Gets a command line for clang-tidy."""
 start = [clang_tidy_binary]
@@ -141,6 +142,8 @@
 start.append("-config=" + config)
 for plugin in plugins:
 start.append("-load=" + plugin)
+if warnings_as_errors:
+start.append("--warnings-as-errors=" + warnings_as_errors)
 start.append(f)
 return start
 
@@ -224,6 +227,7 @@
 args.line_filter,
 args.use_color,
 args.plugins,
+args.warnings_as_errors,
 )
 
 proc = subprocess.Popen(
@@ -363,6 +367,11 @@
 default=[],
 help="Load the specified plugin in clang-tidy.",
 )
+parser.add_argument(
+"-warnings-as-errors",
+default=None,
+help="Upgrades warnings to errors. Same format as " "'-checks'",
+)
 args = parser.parse_args()
 
 db_path = "compile_commands.json"
@@ -399,6 +408,7 @@
 args.line_filter,
 args.use_color,
 args.plugins,
+args.warnings_as_errors,
 )
 invocation.append("-list-checks")
 invocation.append("-")
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D147717: [C++20] Claim full support for consteval again

2023-06-12 Thread Mariya Podchishchaeva via Phabricator via cfe-commits
Fznamznon added a comment.

In D147717#4413522 , @aaron.ballman 
wrote:

> LGTM (though I wonder if we should add a release note as well)

I can add a note saying that the macro is now defined. Is somewhere under `C++ 
Language Changes` title the right place to do that?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147717

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


[PATCH] D147717: [C++20] Claim full support for consteval again

2023-06-12 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D147717#4413593 , @Fznamznon wrote:

> In D147717#4413522 , @aaron.ballman 
> wrote:
>
>> LGTM (though I wonder if we should add a release note as well)
>
> I can add a note saying that the macro is now defined. Is somewhere under 
> `C++ Language Changes` title the right place to do that?

Yeah, probably in the C++20 section specifically.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147717

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


[PATCH] D149548: [IR] Update to use new shufflevector semantics

2023-06-12 Thread Ulrich Weigand via Phabricator via cfe-commits
uweigand added a comment.

So the semantics of the `vec_promote(a, b)` intrinsic is defined as:

> Returns a vector with a in element position b. The result is a vector with a 
> in element position b. [...] The other elements of the vector are undefined.

This is currently implemented by using `insertvector` to place `a` at position 
`b` into a source vector that is `undef`.   The effect should be that when 
using element `b` of that vector, we are guaranteed to get `a`, while using any 
other element is undefined behavior (just like accessing an uninitialized 
variable).

To be honest, I'm not sure how exactly the LLVM IR semantics changes here when 
using a `poison` source vector instead of `undef`.  I seem to recall that 
`poison` propagates over operations - is it true that the result of 
`insertvector` on a `poison` vector is itself `poison`?  If so, then this 
change would break semantics.   However, if the result is a vector with `a` in 
element `b`, and `poison` only in the other elements, then I guess this would 
still preserve the expected semantics.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149548

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


[PATCH] D147717: [C++20] Claim full support for consteval again

2023-06-12 Thread Mariya Podchishchaeva via Phabricator via cfe-commits
Fznamznon updated this revision to Diff 530477.
Fznamznon added a comment.

Rebase, add a release note


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147717

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/test/Lexer/cxx-features.cpp
  clang/www/cxx_status.html


Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -643,14 +643,7 @@
 
   Immediate functions (consteval)
   https://wg21.link/p1073r3";>P1073R3
-  
-Clang 15 (Partial)
-  Clang still incorrectly defers some consteval executions to runtime,
-  resulting in CodeGen crashes. Additionally, Clang does not properly
-  handle default arguments in consteval functions under all
-  circumstances.
-
-  
+  Clang 17
 

 https://wg21.link/p1937r2";>P1937R2
Index: clang/test/Lexer/cxx-features.cpp
===
--- clang/test/Lexer/cxx-features.cpp
+++ clang/test/Lexer/cxx-features.cpp
@@ -78,8 +78,7 @@
 #error "wrong value for __cpp_conditional_explicit"
 #endif
 
-#if check(consteval, 0, 0, 0, 0, 0, 0)
-// FIXME: 201811 in C++20
+#if check(consteval, 0, 0, 0, 0, 202211, 202211)
 #error "wrong value for __cpp_consteval"
 #endif
 
Index: clang/lib/Frontend/InitPreprocessor.cpp
===
--- clang/lib/Frontend/InitPreprocessor.cpp
+++ clang/lib/Frontend/InitPreprocessor.cpp
@@ -683,7 +683,7 @@
 // Refer to the discussion of this at https://reviews.llvm.org/D128619.
 Builder.defineMacro("__cpp_concepts", "201907L");
 Builder.defineMacro("__cpp_conditional_explicit", "201806L");
-// Builder.defineMacro("__cpp_consteval", "202211L");
+Builder.defineMacro("__cpp_consteval", "202211L");
 Builder.defineMacro("__cpp_constexpr_dynamic_alloc", "201907L");
 Builder.defineMacro("__cpp_constinit", "201907L");
 Builder.defineMacro("__cpp_impl_coroutine", "201902L");
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -111,6 +111,7 @@
   SFINAE.
 - Clang now supports `requires cplusplus20` for module maps.
 - Implemented missing parts of `P2002R1: Consistent comparison operators 
`_
+- Clang now defines `__cpp_consteval` macro.
 
 C++23 Feature Support
 ^


Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -643,14 +643,7 @@
 
   Immediate functions (consteval)
   https://wg21.link/p1073r3";>P1073R3
-  
-Clang 15 (Partial)
-  Clang still incorrectly defers some consteval executions to runtime,
-  resulting in CodeGen crashes. Additionally, Clang does not properly
-  handle default arguments in consteval functions under all
-  circumstances.
-
-  
+  Clang 17
 

 https://wg21.link/p1937r2";>P1937R2
Index: clang/test/Lexer/cxx-features.cpp
===
--- clang/test/Lexer/cxx-features.cpp
+++ clang/test/Lexer/cxx-features.cpp
@@ -78,8 +78,7 @@
 #error "wrong value for __cpp_conditional_explicit"
 #endif
 
-#if check(consteval, 0, 0, 0, 0, 0, 0)
-// FIXME: 201811 in C++20
+#if check(consteval, 0, 0, 0, 0, 202211, 202211)
 #error "wrong value for __cpp_consteval"
 #endif
 
Index: clang/lib/Frontend/InitPreprocessor.cpp
===
--- clang/lib/Frontend/InitPreprocessor.cpp
+++ clang/lib/Frontend/InitPreprocessor.cpp
@@ -683,7 +683,7 @@
 // Refer to the discussion of this at https://reviews.llvm.org/D128619.
 Builder.defineMacro("__cpp_concepts", "201907L");
 Builder.defineMacro("__cpp_conditional_explicit", "201806L");
-// Builder.defineMacro("__cpp_consteval", "202211L");
+Builder.defineMacro("__cpp_consteval", "202211L");
 Builder.defineMacro("__cpp_constexpr_dynamic_alloc", "201907L");
 Builder.defineMacro("__cpp_constinit", "201907L");
 Builder.defineMacro("__cpp_impl_coroutine", "201902L");
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -111,6 +111,7 @@
   SFINAE.
 - Clang now supports `requires cplusplus20` for module maps.
 - Implemented missing parts of `P2002R1: Consistent comparison operators `_
+- Clang now defines `__cpp_consteval` macro.
 
 C++23 Feature Support
 ^
___
cfe-commits mail

[PATCH] D152696: Prevent deadlocks in death tests.

2023-06-12 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

I'm no expert here, but I went to check what Chromium does, and it seems to set 
the death_test_style to "threadsafe" for the whole test suite: 
https://source.chromium.org/chromium/chromium/src/+/main:base/test/test_suite.cc;l=367

> As the page linked above notes, "flags are saved before each test and restored
> afterwards", so the flag affects only the tests where it is set. This is
> important because the "threadsafe" death test style "trades increased test
> execution time (potentially dramatically so) for improved thread safety", so 
> we
> likely don't want to set it for all tests. The tests where I've added the flag
> don't appear to suffer a significantly increated execution time.

I assume the flag only affects death tests though, and we probably do want it 
on all of those, so perhaps we could just set it once in 
third-party/unittest/UnitTestMain/TestMain.cpp ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152696

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


[PATCH] D149548: [IR] Update to use new shufflevector semantics

2023-06-12 Thread Nuno Lopes via Phabricator via cfe-commits
nlopes added a comment.

In D149548#4413598 , @uweigand wrote:

> So the semantics of the `vec_promote(a, b)` intrinsic is defined as:
>
>> Returns a vector with a in element position b. The result is a vector with a 
>> in element position b. [...] The other elements of the vector are undefined.
>
> This is currently implemented by using `insertvector` to place `a` at 
> position `b` into a source vector that is `undef`.   The effect should be 
> that when using element `b` of that vector, we are guaranteed to get `a`, 
> while using any other element is undefined behavior (just like accessing an 
> uninitialized variable).
>
> To be honest, I'm not sure how exactly the LLVM IR semantics changes here 
> when using a `poison` source vector instead of `undef`.  I seem to recall 
> that `poison` propagates over operations - is it true that the result of 
> `insertvector` on a `poison` vector is itself `poison`?  If so, then this 
> change would break semantics.   However, if the result is a vector with `a` 
> in element `b`, and `poison` only in the other elements, then I guess this 
> would still preserve the expected semantics.

If a vector is fully initialized with `insertvector` (i.e., one operation per 
index), then the value of the base vector is irrelevant. It can be poison.
Poison in vectors is element-wise.  doesn't propagate to .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149548

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


[PATCH] D152707: [clang][Sema] Provide source range to several Wunused warnings

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

When the diagnosed function/variable is a template specialization, the source 
range covers the specialization arguments.
e.g.

  warning: unused function 'func' [-Wunused-function]
  template <> int func () {}
  ^

This comes in line with the printed text in the warning message. In the above 
case, `func`


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152707

Files:
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/test/Misc/diag-unused-source-ranges.cpp
  clang/test/Misc/diag-unused-source-ranges.h

Index: clang/test/Misc/diag-unused-source-ranges.h
===
--- /dev/null
+++ clang/test/Misc/diag-unused-source-ranges.h
@@ -0,0 +1 @@
+static void thing(void) {}
Index: clang/test/Misc/diag-unused-source-ranges.cpp
===
--- /dev/null
+++ clang/test/Misc/diag-unused-source-ranges.cpp
@@ -0,0 +1,124 @@
+// RUN: %clang -fsyntax-only -Wunused -Wunused-template -Wunused-exception-parameter -Wunused-member-function -fdiagnostics-print-source-range-info %s 2>&1 | FileCheck %s --strict-whitespace
+#include "diag-unused-source-ranges.h"
+
+#define CAT(a, b) a ## b
+
+// CHECK:  :{55:15-55:20}: warning: unused exception parameter 'param'
+// CHECK-NEXT:   catch (int ¶m) {}
+// CHECK-NEXT:   ^{{$}}
+
+// CHECK:  :{53:7-53:12}: warning: unused variable 'local'
+// CHECK-NEXT:   int local = 0;
+// CHECK-NEXT:   ^{{$}}
+
+// CHECK:  In file included from
+// CHECK-NEXT: :{1:13-1:18}: warning: 'static' function 'thing' declared in header file should be declared 'static inline'
+// CHECK-NEXT:   static void thing(void) {}
+// CHECK-NEXT:   ^{{$}}
+
+namespace {
+class A {
+  // CHECK:  :{[[@LINE+3]]:10-[[@LINE+3]]:14}: warning: member function 'func' is not needed
+  // CHECK-NEXT:   void func() {}
+  // CHECK-NEXT:^~~~{{$}}
+void func() {}
+  // CHECK:  :{[[@LINE+3]]:32-[[@LINE+3]]:37}: warning: unused function template
+  // CHECK-NEXT:   void templ(T) {}
+  // CHECK-NEXT:^{{$}}
+template  void templ(T) {}
+  // CHECK:  :{[[@LINE+3]]:22-[[@LINE+3]]:32}: warning: member function 'templ' is not needed
+  // CHECK-NEXT:   void templ(int) {}
+  // CHECK-NEXT:^~{{$}}
+template <> void templ(int) {}
+  // CHECK:  :{[[@LINE+3]]:22-[[@LINE+3]]:27}: warning: member function 'templ' is not needed
+  // CHECK-NEXT:   void templ(float) {}
+  // CHECK-NEXT:^{{$}}
+template <> void templ(float) {}
+
+  // CHECK:  :{[[@LINE+4]]:10-[[@LINE+4]]:13}: warning: unused function template
+  // CHECK-NEXT:   void foo() {
+  // CHECK-NEXT:^~~{{$}}
+template 
+void foo() {
+  func();
+  templ(0);
+  templ(0.0f);
+  templ(0.0);
+}
+};
+// CHECK:  :{[[@LINE+3]]:12-[[@LINE+3]]:23}: warning: unused function 'unused_func'
+// CHECK-NEXT:   static int unused_func(int aaa, char bbb) {
+// CHECK-NEXT:  ^~~{{$}}
+static int unused_func(int aaa, char bbb) {
+  int local = 0;
+  try{}
+  catch (int ¶m) {}
+  return 0;
+}
+
+// CHECK:  :{[[@LINE+4]]:6-[[@LINE+4]]:16}: warning: unused function template
+// CHECK-NEXT:   auto arrow_decl(T a, T b) ->
+// CHECK-NEXT:^~{{$}}
+template 
+auto arrow_decl(T a, T b) -> decltype(a + b) { thing(); return a + b; }
+
+// CHECK:  :{[[@LINE+4]]:6-[[@LINE+4]]:21}: warning: unused function 'arrow_decl'
+// CHECK-NEXT:   auto arrow_decl(int a, int b) ->
+// CHECK-NEXT:^~~{{$}}
+template <>
+auto arrow_decl(int a, int b) -> int { return a + b; }
+
+
+// CHECK:  :{[[@LINE+4]]:10-[[@LINE+4]]:20}: warning: unused function template
+// CHECK-NEXT:   static T func_templ(int bbb, T ccc) {
+// CHECK-NEXT:^~{{$}}
+template 
+static T func_templ(int bbb, T ccc) {
+  return ccc;
+}
+
+// CHECK:  :{[[@LINE+3]]:17-[[@LINE+3]]:32}: warning: function 'func_templ' is not needed
+// CHECK-NEXT:   int func_templ(int bbb, int ccc) {
+// CHECK-NEXT:   ^~~{{$}}
+template <> int func_templ(int bbb, int ccc) {
+  return bbb;
+}
+
+// CHECK:  :{[[@LINE+3]]:35-[[@LINE+3]]:47}: warning: unused function template
+// CHECK-NEXT:   static void never_called() {
+// CHECK-NEXT:   ^~~~{{$}}
+template  static void never_called() {
+  func_templ(0, 0);
+}
+
+// CHECK:  :{[[@LINE+3]]:22-[[@LINE+3]]:31}: warning: unused variable template
+// CHECK-NEXT:   int var_templ =
+// CHECK-NEXT:   ^{{$}}
+template  int var_templ = n * var_templ;
+// CHECK:  :{[[@LINE+3]]:17-[[@LINE+3]]:29}: warning: variable 'var_templ<0>' is not needed
+// CHECK-NEXT:   int var_templ<0> =
+// C

[PATCH] D150848: [clang-format] Respect ColumnLimit 0 lines breaks in inline asm

2023-06-12 Thread Emilia Kond via Phabricator via cfe-commits
rymiel updated this revision to Diff 530486.
rymiel added a comment.

Apply suggestions from review


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150848

Files:
  clang/lib/Format/ContinuationIndenter.cpp
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -4617,6 +4617,24 @@
 format("__asm   {\n"
"}\n"
"int   i;"));
+
+  auto Style = getLLVMStyleWithColumns(0);
+  const StringRef Code1{"asm(\"xyz\" : \"=a\"(a), \"=d\"(b) : \"a\"(data));"};
+  const StringRef Code2{"asm(\"xyz\"\n"
+": \"=a\"(a), \"=d\"(b)\n"
+": \"a\"(data));"};
+  const StringRef Code3{"asm(\"xyz\" : \"=a\"(a), \"=d\"(b)\n"
+": \"a\"(data));"};
+
+  Style.BreakBeforeInlineASMColon = FormatStyle::BBIAS_OnlyMultiline;
+  verifyFormat(Code1, Style);
+  EXPECT_EQ(Code2, format(Code2, Style));
+  EXPECT_EQ(Code3, format(Code3, Style));
+
+  Style.BreakBeforeInlineASMColon = FormatStyle::BBIAS_Always;
+  EXPECT_EQ(Code2, format(Code1, Style));
+  EXPECT_EQ(Code2, format(Code2, Style));
+  EXPECT_EQ(Code2, format(Code3, Style));
 }
 
 TEST_F(FormatTest, FormatTryCatch) {
Index: clang/lib/Format/ContinuationIndenter.cpp
===
--- clang/lib/Format/ContinuationIndenter.cpp
+++ clang/lib/Format/ContinuationIndenter.cpp
@@ -357,7 +357,8 @@
   if (Current.MustBreakBefore ||
   (Current.is(TT_InlineASMColon) &&
(Style.BreakBeforeInlineASMColon == FormatStyle::BBIAS_Always ||
-Style.BreakBeforeInlineASMColon == FormatStyle::BBIAS_OnlyMultiline))) 
{
+(Style.BreakBeforeInlineASMColon == FormatStyle::BBIAS_OnlyMultiline &&
+ Style.ColumnLimit > 0 {
 return true;
   }
   if (CurrentState.BreakBeforeClosingBrace &&


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -4617,6 +4617,24 @@
 format("__asm   {\n"
"}\n"
"int   i;"));
+
+  auto Style = getLLVMStyleWithColumns(0);
+  const StringRef Code1{"asm(\"xyz\" : \"=a\"(a), \"=d\"(b) : \"a\"(data));"};
+  const StringRef Code2{"asm(\"xyz\"\n"
+": \"=a\"(a), \"=d\"(b)\n"
+": \"a\"(data));"};
+  const StringRef Code3{"asm(\"xyz\" : \"=a\"(a), \"=d\"(b)\n"
+": \"a\"(data));"};
+
+  Style.BreakBeforeInlineASMColon = FormatStyle::BBIAS_OnlyMultiline;
+  verifyFormat(Code1, Style);
+  EXPECT_EQ(Code2, format(Code2, Style));
+  EXPECT_EQ(Code3, format(Code3, Style));
+
+  Style.BreakBeforeInlineASMColon = FormatStyle::BBIAS_Always;
+  EXPECT_EQ(Code2, format(Code1, Style));
+  EXPECT_EQ(Code2, format(Code2, Style));
+  EXPECT_EQ(Code2, format(Code3, Style));
 }
 
 TEST_F(FormatTest, FormatTryCatch) {
Index: clang/lib/Format/ContinuationIndenter.cpp
===
--- clang/lib/Format/ContinuationIndenter.cpp
+++ clang/lib/Format/ContinuationIndenter.cpp
@@ -357,7 +357,8 @@
   if (Current.MustBreakBefore ||
   (Current.is(TT_InlineASMColon) &&
(Style.BreakBeforeInlineASMColon == FormatStyle::BBIAS_Always ||
-Style.BreakBeforeInlineASMColon == FormatStyle::BBIAS_OnlyMultiline))) {
+(Style.BreakBeforeInlineASMColon == FormatStyle::BBIAS_OnlyMultiline &&
+ Style.ColumnLimit > 0 {
 return true;
   }
   if (CurrentState.BreakBeforeClosingBrace &&
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D152708: [RFC][Draft] Enable primitive support for Two-Level Line Tables in LLVM

2023-06-12 Thread Stephen Tozer via Phabricator via cfe-commits
StephenTozer created this revision.
StephenTozer added a project: debug-info.
Herald added subscribers: ormris, hiraditya.
Herald added a project: All.
StephenTozer requested review of this revision.
Herald added subscribers: llvm-commits, lldb-commits, cfe-commits, jplehr, 
sstefan1, MaskRay.
Herald added a reviewer: jdoerfert.
Herald added projects: clang, LLDB, LLVM.

NOTE: This is not intended to be merged into LLVM, as the implementation is 
incomplete and hacked-in and **is not being actively developed**; the intention 
is simply to provide a basic working implementation that can be analyzed and 
potentially expanded on by any interested parties. For more information see 
this discourse post.

This patch implements the Two-Level Line Tables (TLLT) proposal 
 currently aiming for Dwarf 6. This 
proposal allows the line table, which is DWARF's data structure used to map 
instructions to source locations and vice versa, to be emitted as a pair of 
tables instead of one, one of which maps source locations to instructions (the 
Logicals table) and the other of which maps instructions to source locations 
(the Actuals table). The proposal then extends the Logicals table by adding a 
context column, allowing entries in that table that represent inlined 
instructions to refer to another Logicals entry as being the inlined call 
location for that instruction, creating records for an inlined call stack in 
the line table and allowing the inlined callsites to be mapped to an 
instruction in the debugger.

This solves one of the current weaknesses in DWARF debugging, which is the 
inability to set breakpoints or step onto inlined callsites. However, there are 
other proposals (such as Location View Numbering 
) that could achieve the same thing, 
and the costs of TLLT in storage size and design complexity may make it a 
non-ideal solution to this problem. We currently have no plans to develop this 
implementation further, but this small demo may be useful to other developers 
who have an interest in pursuing this, and it is still possible that a good 
case may be made for TLLT as the best solution to the problem of representing 
inlined callsites.

As mentioned in the header, this patch was the result of aiming to get a basic 
functioning implementation in a very short time; it is not intended to be 
merged and is not of suitable quality, particularly in LLDB (with which we have 
no familiarity).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152708

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  lldb/include/lldb/Symbol/LineTable.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/source/Symbol/LineTable.cpp
  llvm/include/llvm/BinaryFormat/Dwarf.def
  llvm/include/llvm/CodeGen/CommandFlags.h
  llvm/include/llvm/DebugInfo/DWARF/DWARFDebugLine.h
  llvm/include/llvm/DebugInfo/DWARF/DWARFFormValue.h
  llvm/include/llvm/MC/MCContext.h
  llvm/include/llvm/MC/MCDwarf.h
  llvm/include/llvm/MC/MCStreamer.h
  llvm/include/llvm/Target/TargetOptions.h
  llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
  llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h
  llvm/lib/CodeGen/CommandFlags.cpp
  llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
  llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
  llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
  llvm/lib/MC/MCContext.cpp
  llvm/lib/MC/MCDwarf.cpp
  llvm/lib/MC/MCStreamer.cpp

Index: llvm/lib/MC/MCStreamer.cpp
===
--- llvm/lib/MC/MCStreamer.cpp
+++ llvm/lib/MC/MCStreamer.cpp
@@ -268,6 +268,18 @@
   Discriminator);
 }
 
+void MCStreamer::emitDwarfLogicalLocDirective(
+unsigned FileNo, unsigned Line, unsigned Column, unsigned Flags,
+unsigned Isa, unsigned Discriminator, StringRef FileName, unsigned Context,
+StringRef FunctionName) {
+  getContext().addCurrentDwarfLogicalLoc(FileNo, Line, Column, Flags, Isa,
+ Discriminator, Context, FunctionName);
+}
+
+void MCStreamer::emitDwarfActualLocDirective(unsigned Line, unsigned Flags) {
+  getContext().setCurrentDwarfActualLoc(Line, Flags);
+}
+
 MCSymbol *MCStreamer::getDwarfLineTableSymbol(unsigned CUID) {
   MCDwarfLineTable &Table = getContext().getMCDwarfLineTable(CUID);
   if (!Table.getLabel()) {
Index: llvm/lib/MC/MCDwarf.cpp
===
--- llvm/lib/MC/MCDwarf.cpp
+++ llvm/lib/MC/MCDwarf.cpp
@@ -92,28 +92,69 @@
 // a line entry made for it is made.
 //
 void MCDwarfLineEntry::make(MCStreamer *MCOS, MCSection *Section) {
-  if (!MCOS->getContext().getDwarfLocSeen())
-return;
+  uint16_t VersionNumber = MCOS->getContext().getDwarfVersion();
+  // If we're emi

[PATCH] D152090: [clang][Driver] Add -fcaret-diagnostics-max-lines= as a driver option

2023-06-12 Thread Tom Weaver via Phabricator via cfe-commits
TWeaver added a comment.

Hello and good afternoon from the UK,

It looks as though this change has caused the following buildbot to start 
failing (it's temporarily on staging server so you may not have seen it on the 
public build bot page):

https://lab.llvm.org/staging/#/builders/204/builds/2141

Are you able to take a look?

Thanks,
Tom W


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152090

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


[PATCH] D152391: [Clang] Allow bitcode linking when the input is LLVM-IR

2023-06-12 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added a comment.

ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152391

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


[PATCH] D149548: [IR] Update to use new shufflevector semantics

2023-06-12 Thread Ulrich Weigand via Phabricator via cfe-commits
uweigand added a comment.

In D149548#4413639 , @nlopes wrote:

> If a vector is fully initialized with `insertvector` (i.e., one operation per 
> index), then the value of the base vector is irrelevant. It can be poison.
> Poison in vectors is element-wise.  doesn't propagate to  poison>.

OK, that should be fine for SystemZ then.  Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149548

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


[clang] aa28875 - [clang][tests] Replace a %clang++ with %clang

2023-06-12 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2023-06-12T15:42:26+02:00
New Revision: aa28875a745d4d70f491b59e1b50f592994c923b

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

LOG: [clang][tests] Replace a %clang++ with %clang

%clang++ does not work on windows, see e.g.:

https://lab.llvm.org/staging/#/builders/204/builds/2141

Added: 


Modified: 
clang/test/Driver/caret-diagnostics-max-lines.cpp

Removed: 




diff  --git a/clang/test/Driver/caret-diagnostics-max-lines.cpp 
b/clang/test/Driver/caret-diagnostics-max-lines.cpp
index 9c9df7e6ac681..cd49b31b8b139 100644
--- a/clang/test/Driver/caret-diagnostics-max-lines.cpp
+++ b/clang/test/Driver/caret-diagnostics-max-lines.cpp
@@ -1,3 +1,3 @@
-//RUN: %clang++ -### -fcaret-diagnostics-max-lines=2 %s 2>&1 | FileCheck %s
+//RUN: %clang -### -fcaret-diagnostics-max-lines=2 %s 2>&1 | FileCheck %s
 
 // CHECK: "-fcaret-diagnostics-max-lines=2"



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


[PATCH] D152083: [clang] Warning for uninitialized elements in fixed-size arrays

2023-06-12 Thread Louis Burda via Phabricator via cfe-commits
Sinitax updated this revision to Diff 530501.
Sinitax added a comment.

Rebase patch against branch main.


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

https://reviews.llvm.org/D152083

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaInit.cpp
  clang/test/Sema/warn-incomplete-initializer-list.c

Index: clang/test/Sema/warn-incomplete-initializer-list.c
===
--- /dev/null
+++ clang/test/Sema/warn-incomplete-initializer-list.c
@@ -0,0 +1,51 @@
+// RUN: %clang_cc1 -fsyntax-only -Wincomplete-initializer-list -verify -std=c99 %s
+
+// missing array initializer in between
+enum {
+	FOO1_A,
+	FOO1_MISSING,
+	FOO1_B,
+	FOO1_COUNT
+};
+const char *foo1[] = { // expected-warning{{incomplete initializer list}}
+	[FOO1_A] = "a",
+	[FOO1_B] = "b",
+};
+
+// missing array initializer at end
+enum {
+	FOO2_A,
+	FOO2_B,
+	FOO2_MISSING,
+	FOO2_COUNT
+};
+const char *foo2[FOO2_COUNT] = { //expected-warning{{incomplete initializer list}}
+	[FOO2_A] = "a",
+	[FOO2_B] = "b",
+};
+
+// complete array initializer
+int foo3[4] = { 1, 1, 1, 1 };
+
+// missing struct initializer in between
+struct {
+	int a, b, c, d;
+} bar1 = {
+	.a = 1,
+	.b = 1,
+	.d = 1
+};
+
+// missing struct initializer at end
+struct {
+	int a, b, c, d;
+} bar2 = {
+	.a = 1,
+	.b = 1,
+	.c = 1
+};
+
+// complete struct initializer
+struct {
+	int a, b, c, d;
+} bar3 = { 1, 1, 1, 1 };
Index: clang/lib/Sema/SemaInit.cpp
===
--- clang/lib/Sema/SemaInit.cpp
+++ clang/lib/Sema/SemaInit.cpp
@@ -986,6 +986,21 @@
 if (RequiresSecondPass && !hadError)
   FillInEmptyInitializations(Entity, FullyStructuredList,
  RequiresSecondPass, nullptr, 0);
+
+if (T->isArrayType() && VerifyOnly) {
+  const auto *CAType = dyn_cast(T);
+  if (CAType && FullyStructuredList->getNumInits() <
+CAType->getSize().getZExtValue()) {
+S.Diag(IL->getBeginLoc(), diag::warn_incomplete_array_initializer_list)
+<< IL->getSourceRange();
+  } else {
+auto inits = FullyStructuredList->inits();
+if (llvm::find(inits, nullptr) != inits.end())
+  S.Diag(IL->getBeginLoc(),
+ diag::warn_incomplete_array_initializer_list)
+  << IL->getSourceRange();
+  }
+}
   }
   if (hadError && FullyStructuredList)
 FullyStructuredList->markError();
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -2223,6 +2223,9 @@
   "reference %0 is not yet bound to a value when used within its own"
   " initialization">,
   InGroup;
+def warn_incomplete_array_initializer_list : Warning<
+  "incomplete array initializer list">,
+  InGroup, DefaultIgnore;
 def warn_uninit_var : Warning<
   "variable %0 is uninitialized when %select{used here|captured by block}1">,
   InGroup, DefaultIgnore;
Index: clang/include/clang/Basic/DiagnosticGroups.td
===
--- clang/include/clang/Basic/DiagnosticGroups.td
+++ clang/include/clang/Basic/DiagnosticGroups.td
@@ -734,6 +734,7 @@
 def Uninitialized  : DiagGroup<"uninitialized", [UninitializedSometimes,
  UninitializedStaticSelfInit,
  UninitializedConstReference]>;
+def IncompleteArrayInitializerList : DiagGroup<"incomplete-array-initializer-list">;
 def IgnoredPragmaIntrinsic : DiagGroup<"ignored-pragma-intrinsic">;
 // #pragma optimize is often used to avoid to work around MSVC codegen bugs or
 // to disable inlining. It's not completely clear what alternative to suggest
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -199,7 +199,6 @@
 
 bool b = nullptr; // Was incorrectly rejected by Clang, is now accepted.
 
-
 Non-comprehensive list of changes in this release
 -
 - Clang now saves the address of ABI-indirect function parameters on the stack,
@@ -339,6 +338,8 @@
   can be controlled using ``-fcaret-diagnostics-max-lines=``.
 - Clang no longer emits ``-Wunused-variable`` warnings for variables declared
   with ``__attribute__((cleanup(...)))`` to match GCC's behavior.
+- Add ``-Wincomplete-array-initializer-list`` warning to detect missing
+  elements in initializer lists assigned to array types.
 
 Bug Fixes in This Version
 -
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org

[PATCH] D152708: [RFC][Draft] Enable primitive support for Two-Level Line Tables in LLVM

2023-06-12 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl added a comment.

Thanks for prototyping this!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152708

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


[PATCH] D149444: [ARM] Allow codegen for Armv6m eXecute-Only (XO) sections

2023-06-12 Thread Ties Stuij via Phabricator via cfe-commits
stuij updated this revision to Diff 530505.
stuij marked 2 inline comments as done.
stuij added a comment.

addressed review comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149444

Files:
  clang/lib/Driver/ToolChains/Arch/ARM.cpp
  clang/test/Driver/arm-execute-only.c
  llvm/lib/Target/ARM/ARMSubtarget.cpp


Index: llvm/lib/Target/ARM/ARMSubtarget.cpp
===
--- llvm/lib/Target/ARM/ARMSubtarget.cpp
+++ llvm/lib/Target/ARM/ARMSubtarget.cpp
@@ -187,10 +187,12 @@
   // Assert this for now to make the change obvious.
   assert(hasV6T2Ops() || !hasThumb2());
 
-  // Execute only support requires movt support
   if (genExecuteOnly()) {
-NoMovt = false;
-assert(hasV8MBaselineOps() && "Cannot generate execute-only code for this 
target");
+// Execute only support for >= v8-M Baseline requires movt support
+if (hasV8MBaselineOps())
+  NoMovt = false;
+if (!hasV6MOps())
+  report_fatal_error("Cannot generate execute-only code for this target");
   }
 
   // Keep a pointer to static instruction cost data for the specified CPU.
Index: clang/test/Driver/arm-execute-only.c
===
--- clang/test/Driver/arm-execute-only.c
+++ clang/test/Driver/arm-execute-only.c
@@ -1,19 +1,24 @@
-// RUN: not %clang -c -target thumbv6m-eabi -mexecute-only %s 2>&1 | \
+// RUN: %clang -c -### --target=thumbv6m-eabi -mexecute-only %s 2>&1 | \
+// RUN:   FileCheck -allow-empty --check-prefix CHECK-EXECUTE-ONLY %s
+// CHECK-EXECUTE-ONLY-NOT: warning:
+// CHECK-EXECUTE-ONLY-NOT: error:
+
+// RUN: %clang -### -c --target=thumbv6-eabi -mexecute-only %s 2>&1 |\
 // RUN:   FileCheck --check-prefix CHECK-EXECUTE-ONLY-NOT-SUPPORTED %s
-// CHECK-EXECUTE-ONLY-NOT-SUPPORTED: error: execute only is not supported for 
the thumbv6m sub-architecture
+// CHECK-EXECUTE-ONLY-NOT-SUPPORTED: error: execute only is not supported for 
the armv6 sub-architecture
 
-// RUN: not %clang -target armv8m.main-eabi -mexecute-only -mno-movt %s 2>&1 \
+// RUN: %clang -### --target=armv8m.main-eabi -mexecute-only -mno-movt %s 2>&1 
\
 // RUN:| FileCheck %s -check-prefix CHECK-EXECUTE-ONLY-NO-MOVT
 // CHECK-EXECUTE-ONLY-NO-MOVT: error: option '-mexecute-only' cannot be 
specified with '-mno-movt'
 
-// RUN: %clang -target armv7m-eabi -x assembler -mexecute-only %s -c -### 2>&1 
\
+// RUN: %clang -### --target=armv7m-eabi -x assembler -mexecute-only %s -c 
-### 2>&1 \
 // RUN:| FileCheck %s --check-prefix=CHECK-NO-EXECUTE-ONLY-ASM
 // CHECK-NO-EXECUTE-ONLY-ASM: warning: argument unused during compilation: 
'-mexecute-only'
 
 // -mpure-code flag for GCC compatibility
-// RUN: not %clang -c -target thumbv6m-eabi -mpure-code %s 2>&1 | \
+// RUN: %clang -### -c --target=armv6-eabi -mpure-code %s 2>&1 | \
 // RUN:   FileCheck --check-prefix CHECK-EXECUTE-ONLY-NOT-SUPPORTED %s
 
-// RUN: not %clang -target armv8m.main-eabi -mpure-code -mno-movt %s 2>&1 \
+// RUN: %clang -### -target armv8m.main-eabi -mpure-code -mno-movt %s 2>&1 \
 // RUN:| FileCheck %s -check-prefix CHECK-PURE-CODE-NO-MOVT
 // CHECK-PURE-CODE-NO-MOVT: error: option '-mpure-code' cannot be specified 
with '-mno-movt'
Index: clang/lib/Driver/ToolChains/Arch/ARM.cpp
===
--- clang/lib/Driver/ToolChains/Arch/ARM.cpp
+++ clang/lib/Driver/ToolChains/Arch/ARM.cpp
@@ -790,7 +790,8 @@
 if (Arg *A = Args.getLastArg(options::OPT_mexecute_only, 
options::OPT_mno_execute_only)) {
   if (A->getOption().matches(options::OPT_mexecute_only)) {
 if (getARMSubArchVersionNumber(Triple) < 7 &&
-llvm::ARM::parseArch(Triple.getArchName()) != 
llvm::ARM::ArchKind::ARMV6T2)
+llvm::ARM::parseArch(Triple.getArchName()) != 
llvm::ARM::ArchKind::ARMV6T2 &&
+llvm::ARM::parseArch(Triple.getArchName()) != 
llvm::ARM::ArchKind::ARMV6M)
   D.Diag(diag::err_target_unsupported_execute_only) << 
Triple.getArchName();
 else if (Arg *B = Args.getLastArg(options::OPT_mno_movt))
   D.Diag(diag::err_opt_not_valid_with_opt)


Index: llvm/lib/Target/ARM/ARMSubtarget.cpp
===
--- llvm/lib/Target/ARM/ARMSubtarget.cpp
+++ llvm/lib/Target/ARM/ARMSubtarget.cpp
@@ -187,10 +187,12 @@
   // Assert this for now to make the change obvious.
   assert(hasV6T2Ops() || !hasThumb2());
 
-  // Execute only support requires movt support
   if (genExecuteOnly()) {
-NoMovt = false;
-assert(hasV8MBaselineOps() && "Cannot generate execute-only code for this target");
+// Execute only support for >= v8-M Baseline requires movt support
+if (hasV8MBaselineOps())
+  NoMovt = false;
+if (!hasV6MOps())
+  report_fatal_error("Cannot generate execute-only code for this target");
   }
 
   // Keep a 

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

2023-06-12 Thread Akash Banerjee via Phabricator via cfe-commits
TIFitis updated this revision to Diff 530508.
TIFitis marked 4 inline comments as done.
TIFitis added a comment.

Addressed reviewer comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149872

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp

Index: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
===
--- llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -4419,6 +4419,256 @@
 Builder.CreatePointerCast(Info.RTArgs.MappersArray, VoidPtrPtrTy);
 }
 
+void OpenMPIRBuilder::emitNonContiguousDescriptor(InsertPointTy AllocaIP,
+  InsertPointTy CodeGenIP,
+  MapInfosTy &CombinedInfo,
+  TargetDataInfo &Info) {
+  MapInfosTy::StructNonContiguousInfo &NonContigInfo =
+  CombinedInfo.NonContigInfo;
+
+  // Build an array of struct descriptor_dim and then assign it to
+  // offload_args.
+  //
+  // struct descriptor_dim {
+  //  uint64_t offset;
+  //  uint64_t count;
+  //  uint64_t stride
+  // };
+  Type *Int64Ty = Builder.getInt64Ty();
+  StructType *DimTy = StructType::create(
+  M.getContext(), ArrayRef({Int64Ty, Int64Ty, Int64Ty}),
+  "struct.descriptor_dim");
+
+  enum { OffsetFD = 0, CountFD, StrideFD };
+  // We need two index variable here since the size of "Dims" is the same as
+  // the size of Components, however, the size of offset, count, and stride is
+  // equal to the size of base declaration that is non-contiguous.
+  for (unsigned I = 0, L = 0, E = NonContigInfo.Dims.size(); I < E; ++I) {
+// Skip emitting ir if dimension size is 1 since it cannot be
+// non-contiguous.
+if (NonContigInfo.Dims[I] == 1)
+  continue;
+Builder.restoreIP(AllocaIP);
+ArrayType *ArrayTy = ArrayType::get(DimTy, NonContigInfo.Dims[I]);
+AllocaInst *DimsAddr =
+Builder.CreateAlloca(ArrayTy, /* ArraySize = */ nullptr, "dims");
+Builder.restoreIP(CodeGenIP);
+for (unsigned II = 0, EE = NonContigInfo.Dims[I]; II < EE; ++II) {
+  unsigned RevIdx = EE - II - 1;
+  Value *DimsLVal = Builder.CreateInBoundsGEP(
+  DimsAddr->getAllocatedType(), DimsAddr,
+  {Builder.getInt64(0), Builder.getInt64(II)});
+  // Offset
+  Value *OffsetLVal = Builder.CreateStructGEP(DimTy, DimsLVal, OffsetFD);
+  Builder.CreateAlignedStore(
+  NonContigInfo.Offsets[L][RevIdx], OffsetLVal,
+  M.getDataLayout().getPrefTypeAlign(OffsetLVal->getType()));
+  // Count
+  Value *CountLVal = Builder.CreateStructGEP(DimTy, DimsLVal, CountFD);
+  Builder.CreateAlignedStore(
+  NonContigInfo.Counts[L][RevIdx], CountLVal,
+  M.getDataLayout().getPrefTypeAlign(CountLVal->getType()));
+  // Stride
+  Value *StrideLVal = Builder.CreateStructGEP(DimTy, DimsLVal, StrideFD);
+  Builder.CreateAlignedStore(
+  NonContigInfo.Strides[L][RevIdx], StrideLVal,
+  M.getDataLayout().getPrefTypeAlign(CountLVal->getType()));
+}
+// args[I] = &dims
+Builder.restoreIP(CodeGenIP);
+Value *DAddr = Builder.CreatePointerBitCastOrAddrSpaceCast(
+DimsAddr, Builder.getInt8PtrTy());
+Value *P = Builder.CreateConstInBoundsGEP2_32(
+ArrayType::get(Builder.getInt8PtrTy(), Info.NumberOfPtrs),
+Info.RTArgs.PointersArray, 0, I);
+Builder.CreateAlignedStore(
+DAddr, P, M.getDataLayout().getPrefTypeAlign(Builder.getInt8PtrTy()));
+++L;
+  }
+}
+
+void OpenMPIRBuilder::emitOffloadingArrays(
+InsertPointTy AllocaIP, InsertPointTy CodeGenIP, MapInfosTy &CombinedInfo,
+TargetDataInfo &Info, bool IsNonContiguous,
+function_ref DeviceAddrCB,
+function_ref CustomMapperCB) {
+
+  // Reset the array information.
+  Info.clearArrayInfo();
+  Info.NumberOfPtrs = CombinedInfo.BasePointers.size();
+
+  if (Info.NumberOfPtrs == 0)
+return;
+
+  Builder.restoreIP(AllocaIP);
+  // Detect if we have any capture size requiring runtime evaluation of the
+  // size so that a constant array could be eventually used.
+  ArrayType *PointerArrayType =
+  ArrayType::get(Builder.getInt8PtrTy(), Info.NumberOfPtrs);
+
+  Info.RTArgs.BasePointersArray = Builder.CreateAlloca(
+  PointerArrayType, /* ArraySize = */ nullptr, ".offload_baseptrs");
+
+  Info.RTArgs.PointersArray = Builder.CreateAlloca(
+  PointerArrayType, /* ArraySize = */ nullptr, ".offload_ptrs");
+  AllocaInst *MappersArray = Builder.CreateAlloca(
+  PointerArrayType, /* ArraySize = */ nullptr, ".offload_mappers");
+  Info.RTArgs.MappersArray = MappersArray;
+
+  // If we don't have any VLA types or other types that require runtime
+  // evaluation, we can use a constant array fo

[PATCH] D152090: [clang][Driver] Add -fcaret-diagnostics-max-lines= as a driver option

2023-06-12 Thread Tom Weaver via Phabricator via cfe-commits
TWeaver added a comment.

Thanks for the fix! 👍


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152090

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


[clang] 3401a5f - [OpenMP][OMPIRBuilder] Migrate emitOffloadingArrays and EmitNonContiguousDescriptor from Clang

2023-06-12 Thread Akash Banerjee via cfe-commits

Author: Akash Banerjee
Date: 2023-06-12T15:43:09+01:00
New Revision: 3401a5f7584a2f12a90a7538aee2ae37038c82a9

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

LOG: [OpenMP][OMPIRBuilder] Migrate emitOffloadingArrays and 
EmitNonContiguousDescriptor from Clang

This patch migrates the emitOffloadingArrays and EmitNonContiguousDescriptor 
functions from Clang codegen to OpenMPIRBuilder.

Reviewed By: jdoerfert

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

Added: 


Modified: 
clang/lib/CodeGen/CGOpenMPRuntime.cpp
llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index 099c706e84ab2..994189277aff6 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -8969,74 +8969,6 @@ class MappableExprsHandler {
 };
 } // anonymous namespace
 
-static void emitNonContiguousDescriptor(
-CodeGenFunction &CGF, MappableExprsHandler::MapCombinedInfoTy 
&CombinedInfo,
-CGOpenMPRuntime::TargetDataInfo &Info) {
-  CodeGenModule &CGM = CGF.CGM;
-  MappableExprsHandler::MapCombinedInfoTy::StructNonContiguousInfo
-  &NonContigInfo = CombinedInfo.NonContigInfo;
-
-  // Build an array of struct descriptor_dim and then assign it to
-  // offload_args.
-  //
-  // struct descriptor_dim {
-  //  uint64_t offset;
-  //  uint64_t count;
-  //  uint64_t stride
-  // };
-  ASTContext &C = CGF.getContext();
-  QualType Int64Ty = C.getIntTypeForBitwidth(/*DestWidth=*/64, /*Signed=*/0);
-  RecordDecl *RD;
-  RD = C.buildImplicitRecord("descriptor_dim");
-  RD->startDefinition();
-  addFieldToRecordDecl(C, RD, Int64Ty);
-  addFieldToRecordDecl(C, RD, Int64Ty);
-  addFieldToRecordDecl(C, RD, Int64Ty);
-  RD->completeDefinition();
-  QualType DimTy = C.getRecordType(RD);
-
-  enum { OffsetFD = 0, CountFD, StrideFD };
-  // We need two index variable here since the size of "Dims" is the same as 
the
-  // size of Components, however, the size of offset, count, and stride is 
equal
-  // to the size of base declaration that is non-contiguous.
-  for (unsigned I = 0, L = 0, E = NonContigInfo.Dims.size(); I < E; ++I) {
-// Skip emitting ir if dimension size is 1 since it cannot be
-// non-contiguous.
-if (NonContigInfo.Dims[I] == 1)
-  continue;
-llvm::APInt Size(/*numBits=*/32, NonContigInfo.Dims[I]);
-QualType ArrayTy =
-C.getConstantArrayType(DimTy, Size, nullptr, ArrayType::Normal, 0);
-Address DimsAddr = CGF.CreateMemTemp(ArrayTy, "dims");
-for (unsigned II = 0, EE = NonContigInfo.Dims[I]; II < EE; ++II) {
-  unsigned RevIdx = EE - II - 1;
-  LValue DimsLVal = CGF.MakeAddrLValue(
-  CGF.Builder.CreateConstArrayGEP(DimsAddr, II), DimTy);
-  // Offset
-  LValue OffsetLVal = CGF.EmitLValueForField(
-  DimsLVal, *std::next(RD->field_begin(), OffsetFD));
-  CGF.EmitStoreOfScalar(NonContigInfo.Offsets[L][RevIdx], OffsetLVal);
-  // Count
-  LValue CountLVal = CGF.EmitLValueForField(
-  DimsLVal, *std::next(RD->field_begin(), CountFD));
-  CGF.EmitStoreOfScalar(NonContigInfo.Counts[L][RevIdx], CountLVal);
-  // Stride
-  LValue StrideLVal = CGF.EmitLValueForField(
-  DimsLVal, *std::next(RD->field_begin(), StrideFD));
-  CGF.EmitStoreOfScalar(NonContigInfo.Strides[L][RevIdx], StrideLVal);
-}
-// args[I] = &dims
-Address DAddr = CGF.Builder.CreatePointerBitCastOrAddrSpaceCast(
-DimsAddr, CGM.Int8PtrTy, CGM.Int8Ty);
-llvm::Value *P = CGF.Builder.CreateConstInBoundsGEP2_32(
-llvm::ArrayType::get(CGM.VoidPtrTy, Info.NumberOfPtrs),
-Info.RTArgs.PointersArray, 0, I);
-Address PAddr(P, CGM.VoidPtrTy, CGF.getPointerAlign());
-CGF.Builder.CreateStore(DAddr.getPointer(), PAddr);
-++L;
-  }
-}
-
 // Try to extract the base declaration from a `this->x` expression if possible.
 static ValueDecl *getDeclFromThisExpr(const Expr *E) {
   if (!E)
@@ -9099,190 +9031,42 @@ static void emitOffloadingArrays(
   Info.clearArrayInfo();
   Info.NumberOfPtrs = CombinedInfo.BasePointers.size();
 
-  if (Info.NumberOfPtrs) {
-// Detect if we have any capture size requiring runtime evaluation of the
-// size so that a constant array could be eventually used.
-
-llvm::APInt PointerNumAP(32, Info.NumberOfPtrs, /*isSigned=*/true);
-QualType PointerArrayType = Ctx.getConstantArrayType(
-Ctx.VoidPtrTy, PointerNumAP, nullptr, ArrayType::Normal,
-/*IndexTypeQuals=*/0);
-
-Info.RTArgs.BasePointersArray =
-CGF.CreateMemTemp(PointerArrayType, ".offload_baseptrs").getPointer();
-Info.RTArgs.PointersArray =
-CGF.CreateMemTe

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

2023-06-12 Thread Akash Banerjee 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 rG3401a5f7584a: [OpenMP][OMPIRBuilder] Migrate 
emitOffloadingArrays and… (authored by TIFitis).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149872

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp

Index: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
===
--- llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -4419,6 +4419,256 @@
 Builder.CreatePointerCast(Info.RTArgs.MappersArray, VoidPtrPtrTy);
 }
 
+void OpenMPIRBuilder::emitNonContiguousDescriptor(InsertPointTy AllocaIP,
+  InsertPointTy CodeGenIP,
+  MapInfosTy &CombinedInfo,
+  TargetDataInfo &Info) {
+  MapInfosTy::StructNonContiguousInfo &NonContigInfo =
+  CombinedInfo.NonContigInfo;
+
+  // Build an array of struct descriptor_dim and then assign it to
+  // offload_args.
+  //
+  // struct descriptor_dim {
+  //  uint64_t offset;
+  //  uint64_t count;
+  //  uint64_t stride
+  // };
+  Type *Int64Ty = Builder.getInt64Ty();
+  StructType *DimTy = StructType::create(
+  M.getContext(), ArrayRef({Int64Ty, Int64Ty, Int64Ty}),
+  "struct.descriptor_dim");
+
+  enum { OffsetFD = 0, CountFD, StrideFD };
+  // We need two index variable here since the size of "Dims" is the same as
+  // the size of Components, however, the size of offset, count, and stride is
+  // equal to the size of base declaration that is non-contiguous.
+  for (unsigned I = 0, L = 0, E = NonContigInfo.Dims.size(); I < E; ++I) {
+// Skip emitting ir if dimension size is 1 since it cannot be
+// non-contiguous.
+if (NonContigInfo.Dims[I] == 1)
+  continue;
+Builder.restoreIP(AllocaIP);
+ArrayType *ArrayTy = ArrayType::get(DimTy, NonContigInfo.Dims[I]);
+AllocaInst *DimsAddr =
+Builder.CreateAlloca(ArrayTy, /* ArraySize = */ nullptr, "dims");
+Builder.restoreIP(CodeGenIP);
+for (unsigned II = 0, EE = NonContigInfo.Dims[I]; II < EE; ++II) {
+  unsigned RevIdx = EE - II - 1;
+  Value *DimsLVal = Builder.CreateInBoundsGEP(
+  DimsAddr->getAllocatedType(), DimsAddr,
+  {Builder.getInt64(0), Builder.getInt64(II)});
+  // Offset
+  Value *OffsetLVal = Builder.CreateStructGEP(DimTy, DimsLVal, OffsetFD);
+  Builder.CreateAlignedStore(
+  NonContigInfo.Offsets[L][RevIdx], OffsetLVal,
+  M.getDataLayout().getPrefTypeAlign(OffsetLVal->getType()));
+  // Count
+  Value *CountLVal = Builder.CreateStructGEP(DimTy, DimsLVal, CountFD);
+  Builder.CreateAlignedStore(
+  NonContigInfo.Counts[L][RevIdx], CountLVal,
+  M.getDataLayout().getPrefTypeAlign(CountLVal->getType()));
+  // Stride
+  Value *StrideLVal = Builder.CreateStructGEP(DimTy, DimsLVal, StrideFD);
+  Builder.CreateAlignedStore(
+  NonContigInfo.Strides[L][RevIdx], StrideLVal,
+  M.getDataLayout().getPrefTypeAlign(CountLVal->getType()));
+}
+// args[I] = &dims
+Builder.restoreIP(CodeGenIP);
+Value *DAddr = Builder.CreatePointerBitCastOrAddrSpaceCast(
+DimsAddr, Builder.getInt8PtrTy());
+Value *P = Builder.CreateConstInBoundsGEP2_32(
+ArrayType::get(Builder.getInt8PtrTy(), Info.NumberOfPtrs),
+Info.RTArgs.PointersArray, 0, I);
+Builder.CreateAlignedStore(
+DAddr, P, M.getDataLayout().getPrefTypeAlign(Builder.getInt8PtrTy()));
+++L;
+  }
+}
+
+void OpenMPIRBuilder::emitOffloadingArrays(
+InsertPointTy AllocaIP, InsertPointTy CodeGenIP, MapInfosTy &CombinedInfo,
+TargetDataInfo &Info, bool IsNonContiguous,
+function_ref DeviceAddrCB,
+function_ref CustomMapperCB) {
+
+  // Reset the array information.
+  Info.clearArrayInfo();
+  Info.NumberOfPtrs = CombinedInfo.BasePointers.size();
+
+  if (Info.NumberOfPtrs == 0)
+return;
+
+  Builder.restoreIP(AllocaIP);
+  // Detect if we have any capture size requiring runtime evaluation of the
+  // size so that a constant array could be eventually used.
+  ArrayType *PointerArrayType =
+  ArrayType::get(Builder.getInt8PtrTy(), Info.NumberOfPtrs);
+
+  Info.RTArgs.BasePointersArray = Builder.CreateAlloca(
+  PointerArrayType, /* ArraySize = */ nullptr, ".offload_baseptrs");
+
+  Info.RTArgs.PointersArray = Builder.CreateAlloca(
+  PointerArrayType, /* ArraySize = */ nullptr, ".offload_ptrs");
+  AllocaInst *MappersArray = Builder.CreateAlloca(
+  PointerArrayType, /* ArraySize = */ nullptr, ".offload_mappers");
+  Info.RTArgs.MappersArray = MappersArray;
+
+  // If we don't hav

[PATCH] D152707: [clang][Sema] Provide source range to several Wunused warnings

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



Comment at: clang/test/Misc/diag-unused-source-ranges.cpp:1
+// RUN: %clang -fsyntax-only -Wunused -Wunused-template 
-Wunused-exception-parameter -Wunused-member-function 
-fdiagnostics-print-source-range-info %s 2>&1 | FileCheck %s --strict-whitespace
+#include "diag-unused-source-ranges.h"

Should be `%clang_cc1` I think.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152707

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


[PATCH] D152707: [clang][Sema] Provide source range to several Wunused warnings

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

Precommit-CI also found some problems on Windows


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152707

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


[PATCH] D152627: [RISCV] Change the immediate argument to Zvk intrinsics/builtins to i8.

2023-06-12 Thread Alex Bradbury via Phabricator via cfe-commits
asb added a comment.

The patch title should indicate "from i8 to i32" or similar?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152627

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


[PATCH] D152707: [clang][Sema] Provide source range to several Wunused warnings

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



Comment at: clang/test/Misc/diag-unused-source-ranges.h:1
+static void thing(void) {}

Moving this file to `Inputs/` would make sense I think.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152707

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


[clang] 583371b - [FlowSensitive] Use {DenseMapBase, StringMap}::lookup (NFC)

2023-06-12 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2023-06-12T08:11:01-07:00
New Revision: 583371be4d341b92de8fe2fa0261b88c404ed31d

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

LOG: [FlowSensitive] Use {DenseMapBase,StringMap}::lookup (NFC)

Added: 


Modified: 
clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h
clang/include/clang/Analysis/FlowSensitive/Value.h
clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp

Removed: 




diff  --git 
a/clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h 
b/clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h
index 9695884c00c98..3a149b5ff397f 100644
--- a/clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h
+++ b/clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h
@@ -111,8 +111,7 @@ class DataflowAnalysisContext {
   /// Returns the storage location assigned to `D` or null if `D` has no
   /// assigned storage location.
   StorageLocation *getStorageLocation(const ValueDecl &D) const {
-auto It = DeclToLoc.find(&D);
-return It == DeclToLoc.end() ? nullptr : It->second;
+return DeclToLoc.lookup(&D);
   }
 
   /// Assigns `Loc` as the storage location of `E`.
@@ -129,8 +128,7 @@ class DataflowAnalysisContext {
   /// Returns the storage location assigned to `E` or null if `E` has no
   /// assigned storage location.
   StorageLocation *getStorageLocation(const Expr &E) const {
-auto It = ExprToLoc.find(&ignoreCFGOmittedNodes(E));
-return It == ExprToLoc.end() ? nullptr : It->second;
+return ExprToLoc.lookup(&ignoreCFGOmittedNodes(E));
   }
 
   /// Returns a pointer value that represents a null pointer. Calls with

diff  --git a/clang/include/clang/Analysis/FlowSensitive/Value.h 
b/clang/include/clang/Analysis/FlowSensitive/Value.h
index 861a9963e6689..fd8d6ee2f1e0d 100644
--- a/clang/include/clang/Analysis/FlowSensitive/Value.h
+++ b/clang/include/clang/Analysis/FlowSensitive/Value.h
@@ -63,8 +63,7 @@ class Value {
   /// Returns the value of the synthetic property with the given `Name` or null
   /// if the property isn't assigned a value.
   Value *getProperty(llvm::StringRef Name) const {
-auto It = Properties.find(Name);
-return It == Properties.end() ? nullptr : It->second;
+return Properties.lookup(Name);
   }
 
   /// Assigns `Val` as the value of the synthetic property with the given
@@ -302,12 +301,7 @@ class StructValue final : public Value {
 
   /// Returns the child value that is assigned for `D` or null if the child is
   /// not initialized.
-  Value *getChild(const ValueDecl &D) const {
-auto It = Children.find(&D);
-if (It == Children.end())
-  return nullptr;
-return It->second;
-  }
+  Value *getChild(const ValueDecl &D) const { return Children.lookup(&D); }
 
   /// Assigns `Val` as the child value for `D`.
   void setChild(const ValueDecl &D, Value &Val) { Children[&D] = &Val; }

diff  --git a/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp 
b/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
index ee1a78472586d..4f5a877f71d03 100644
--- a/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
+++ b/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
@@ -761,8 +761,7 @@ void Environment::setValueStrict(const Expr &E, Value &Val) 
{
 }
 
 Value *Environment::getValue(const StorageLocation &Loc) const {
-  auto It = LocToVal.find(&Loc);
-  return It == LocToVal.end() ? nullptr : It->second;
+  return LocToVal.lookup(&Loc);
 }
 
 Value *Environment::getValue(const ValueDecl &D) const {



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


[clang] b18ca72 - Revert "[Driver] Mark many target-specific driver-only options as TargetSpecific"

2023-06-12 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2023-06-12T17:18:09+02:00
New Revision: b18ca7296ef16700fadac98abe7fac8c8b44b4da

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

LOG: Revert "[Driver] Mark many target-specific driver-only options as 
TargetSpecific"

This broke building the TSan runtime on Mac, see comment on
https://github.com/llvm/llvm-project/commit/5548843d692a92a7840f14002debc3cebcb3cdc3

> so that they get an error on other targets. This change uses let statements to
> apply `Flags = [TargetSpecific]` to options (mostly -m*) without specifying 
> `Flags`.
> Follow-up to D151590.
>
> For some options, e.g. -mdefault-build-attributes (D31813), -mbranch-likely
> (D38168), -mfpu=/-mabi= (6890b9b71e525020ab58d436336664beede71575), a warning
> seems desired in at least certain cases. This is not the best practice, but 
> this
> change works around them by not applying `Flags = [TargetSpecific]`.
>
> (
> For Intel CPU errata -malign-branch= family options, we also drop the unneeded
> NotXarchOption flag. This flag reports an error if the option is used with
> -Xarch_*. This error reporting does not seem very useful.
> )

This reverts commit 5548843d692a92a7840f14002debc3cebcb3cdc3.

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/test/Driver/munaligned-access-unused.c
clang/test/Driver/x86-malign-branch.c

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 590787cb5da6e..dd98201d15201 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -251,10 +251,6 @@ def flang_ignored_w_Group : OptionGroup<"">,
 def clang_ignored_legacy_options_Group : OptionGroup<"">,
   Group, Flags<[Ignored]>;
 
-def LongDouble_Group : OptionGroup<"">, Group,
-  DocName<"Long double flags">,
-  DocBrief<[{Selects the long double implementation}]>;
-
 // Retired with clang-5.0
 def : Flag<["-"], "fslp-vectorize-aggressive">, 
Group;
 def : Flag<["-"], "fno-slp-vectorize-aggressive">, 
Group;
@@ -3512,39 +3508,36 @@ def mno_iamcu : Flag<["-"], "mno-iamcu">, 
Group, Flags<[NoXarchOption,
 def malign_functions_EQ : Joined<["-"], "malign-functions=">, 
Group;
 def malign_loops_EQ : Joined<["-"], "malign-loops=">, 
Group;
 def malign_jumps_EQ : Joined<["-"], "malign-jumps=">, 
Group;
-
-let Flags = [TargetSpecific] in {
-def malign_branch_EQ : CommaJoined<["-"], "malign-branch=">, Group,
+def malign_branch_EQ : CommaJoined<["-"], "malign-branch=">, Group, 
Flags<[NoXarchOption]>,
   HelpText<"Specify types of branches to align">;
-def malign_branch_boundary_EQ : Joined<["-"], "malign-branch-boundary=">, 
Group,
+def malign_branch_boundary_EQ : Joined<["-"], "malign-branch-boundary=">, 
Group, Flags<[NoXarchOption]>,
   HelpText<"Specify the boundary's size to align branches">;
-def mpad_max_prefix_size_EQ : Joined<["-"], "mpad-max-prefix-size=">, 
Group,
+def mpad_max_prefix_size_EQ : Joined<["-"], "mpad-max-prefix-size=">, 
Group, Flags<[NoXarchOption]>,
   HelpText<"Specify maximum number of prefixes to use for padding">;
-def mbranches_within_32B_boundaries : Flag<["-"], 
"mbranches-within-32B-boundaries">, Group,
+def mbranches_within_32B_boundaries : Flag<["-"], 
"mbranches-within-32B-boundaries">, Flags<[NoXarchOption]>, Group,
   HelpText<"Align selected branches (fused, jcc, jmp) within 32-byte 
boundary">;
 def mfancy_math_387 : Flag<["-"], "mfancy-math-387">, 
Group;
 def mlong_calls : Flag<["-"], "mlong-calls">, Group,
   HelpText<"Generate branches with extended addressability, usually via 
indirect jumps.">;
-} // let Flags = [TargetSpecific]
 def mdouble_EQ : Joined<["-"], "mdouble=">, Group,
   MetaVarName<", Values<"32,64">, Flags<[CC1Option]>,
   HelpText<"Force double to be  bits">,
   MarshallingInfoInt, "0">;
+def LongDouble_Group : OptionGroup<"">, Group,
+  DocName<"Long double flags">,
+  DocBrief<[{Selects the long double implementation}]>;
 def mlong_double_64 : Flag<["-"], "mlong-double-64">, Group, 
Flags<[CC1Option]>,
   HelpText<"Force long double to be 64 bits">;
 def mlong_double_80 : Flag<["-"], "mlong-double-80">, Group, 
Flags<[CC1Option]>,
   HelpText<"Force long double to be 80 bits, padded to 128 bits for storage">;
 def mlong_double_128 : Flag<["-"], "mlong-double-128">, 
Group, Flags<[CC1Option]>,
   HelpText<"Force long double to be 128 bits">;
-let Flags = [TargetSpecific] in {
 def mno_long_calls : Flag<["-"], "mno-long-calls">, Group,
   HelpText<"Restore the default behaviour of not generating long calls">;
-} // let Flags = [TargetSpecific]
 def mexecute_only : Flag<["-"], "mexecute-only">, Group,
   HelpText<"Disallow generation of data access to code sections (ARM only)">;
 def mno_execute_only : Flag<["-"], "mno-execute-only">, 
Group,
 

[PATCH] D146557: [MLIR][OpenMP] Refactoring createTargetData in OMPIRBuilder

2023-06-12 Thread Akash Banerjee via Phabricator via cfe-commits
TIFitis updated this revision to Diff 530518.
TIFitis marked 5 inline comments as done and an inline comment as not done.
TIFitis added a comment.

Addressed reviewer comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146557

Files:
  llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
  llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
  mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
  mlir/test/Target/LLVMIR/omptarget-llvm.mlir

Index: mlir/test/Target/LLVMIR/omptarget-llvm.mlir
===
--- mlir/test/Target/LLVMIR/omptarget-llvm.mlir
+++ mlir/test/Target/LLVMIR/omptarget-llvm.mlir
@@ -11,29 +11,28 @@
   llvm.return
 }
 
+// CHECK: @.offload_sizes = private unnamed_addr constant [1 x i64] [i64 4]
 // CHECK: @.offload_maptypes = private unnamed_addr constant [1 x i64] [i64 3]
 // CHECK-LABEL: define void @_QPopenmp_target_data() {
 // CHECK: %[[VAL_0:.*]] = alloca [1 x ptr], align 8
 // CHECK: %[[VAL_1:.*]] = alloca [1 x ptr], align 8
-// CHECK: %[[VAL_2:.*]] = alloca [1 x i64], align 8
+// CHECK: %[[VAL_2:.*]] = alloca [1 x ptr], align 8
 // CHECK: %[[VAL_3:.*]] = alloca i32, i64 1, align 4
 // CHECK: br label %[[VAL_4:.*]]
-// CHECK:   [[VAL_4]]:
-// CHECK: %[[VAL_5:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_0]], i32 0, i32 0
-// CHECK: store ptr %[[VAL_3]], ptr %[[VAL_5]], align 8
-// CHECK: %[[VAL_6:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_1]], i32 0, i32 0
+// CHECK:   entry:; preds = %[[VAL_5:.*]]
+// CHECK: %[[VAL_6:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_0]], i32 0, i32 0
 // CHECK: store ptr %[[VAL_3]], ptr %[[VAL_6]], align 8
-// CHECK: %[[VAL_7:.*]] = getelementptr inbounds [1 x i64], ptr %[[VAL_2]], i32 0, i32 0
-// CHECK: store i64 ptrtoint (ptr getelementptr (ptr, ptr null, i32 1) to i64), ptr %[[VAL_7]], align 4
-// CHECK: %[[VAL_8:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_0]], i32 0, i32 0
-// CHECK: %[[VAL_9:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_1]], i32 0, i32 0
-// CHECK: %[[VAL_10:.*]] = getelementptr inbounds [1 x i64], ptr %[[VAL_2]], i32 0, i32 0
-// CHECK: call void @__tgt_target_data_begin_mapper(ptr @2, i64 -1, i32 1, ptr %[[VAL_8]], ptr %[[VAL_9]], ptr %[[VAL_10]], ptr @.offload_maptypes, ptr @.offload_mapnames, ptr null)
+// CHECK: %[[VAL_7:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_1]], i32 0, i32 0
+// CHECK: store ptr %[[VAL_3]], ptr %[[VAL_7]], align 8
+// CHECK: %[[VAL_8:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_2]], i64 0, i64 0
+// CHECK: store ptr null, ptr %[[VAL_8]], align 8
+// CHECK: %[[VAL_9:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_0]], i32 0, i32 0
+// CHECK: %[[VAL_10:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_1]], i32 0, i32 0
+// CHECK: call void @__tgt_target_data_begin_mapper(ptr @2, i64 -1, i32 1, ptr %[[VAL_9]], ptr %[[VAL_10]], ptr @.offload_sizes, ptr @.offload_maptypes, ptr null, ptr null)
 // CHECK: store i32 99, ptr %[[VAL_3]], align 4
 // CHECK: %[[VAL_11:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_0]], i32 0, i32 0
 // CHECK: %[[VAL_12:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_1]], i32 0, i32 0
-// CHECK: %[[VAL_13:.*]] = getelementptr inbounds [1 x i64], ptr %[[VAL_2]], i32 0, i32 0
-// CHECK: call void @__tgt_target_data_end_mapper(ptr @2, i64 -1, i32 1, ptr %[[VAL_11]], ptr %[[VAL_12]], ptr %[[VAL_13]], ptr @.offload_maptypes, ptr @.offload_mapnames, ptr null)
+// CHECK: call void @__tgt_target_data_end_mapper(ptr @2, i64 -1, i32 1, ptr %[[VAL_11]], ptr %[[VAL_12]], ptr @.offload_sizes, ptr @.offload_maptypes, ptr null, ptr null)
 // CHECK: ret void
 
 // -
@@ -51,35 +50,34 @@
   llvm.return
 }
 
+// CHECK: @.offload_sizes = private unnamed_addr constant [1 x i64] [i64 4096]
 // CHECK: @.offload_maptypes = private unnamed_addr constant [1 x i64] [i64 2]
 // CHECK-LABEL: define void @_QPopenmp_target_data_region
 // CHECK: (ptr %[[ARG_0:.*]]) {
 // CHECK: %[[VAL_0:.*]] = alloca [1 x ptr], align 8
 // CHECK: %[[VAL_1:.*]] = alloca [1 x ptr], align 8
-// CHECK: %[[VAL_2:.*]] = alloca [1 x i64], align 8
+// CHECK: %[[VAL_2:.*]] = alloca [1 x ptr], align 8
 // CHECK: br label %[[VAL_3:.*]]
-// CHECK:   [[VAL_3]]:
-// CHECK: %[[VAL_4:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_0]], i32 0, i32 0
-// CHECK: store ptr %[[VAL_5:.*]], ptr %[[VAL_4]], align 8
-// CHECK: %[[VAL_6:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VA

[PATCH] D146557: [MLIR][OpenMP] Refactoring createTargetData in OMPIRBuilder

2023-06-12 Thread Akash Banerjee via Phabricator via cfe-commits
TIFitis added inline comments.



Comment at: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp:4727
+  Builder.ClearInsertionPoint();
+}
+

jdoerfert wrote:
> This function doesn't make sense to me. For one, I don't know what a "unreal 
> block" is. Nor would I have expected a block with terminator to be silently 
> not touched. It might just be a documentation issue (in the header). I would 
> avoid duplicating the comment here again.
I've removed the comment here and updated it in the header file.

The current comment was taken directly from Clang. I've updated it say exactly 
what it does.



Comment at: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp:4785
+  EmitBlock(ContBlock, CurFn, /*IsFinished=*/true);
+}
+

jdoerfert wrote:
> CFG Utils have helpers for these things. Do we not use them on purpose?
If you are pointing at the `SplitBlockAndInsertIfThen` like functions in 
`llvm/lib/Transforms/Utils/BasicBlockUtils.cpp` then they require the current 
BB to be well formed with a terminator which it is not in this case.

Earlier we were adding an Unreachable inst and removing it later, however this 
function I think does a much cleaner job of handling all the cases including 
region code gen.

Also, it is not apparent in this patch but future patches including some from 
Jan in review make use of the emitBlock and emitBranch functions directly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146557

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


[PATCH] D152713: [clang-tidy] Correct sizeof/alignas handling in misc-redundant-expression

2023-06-12 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL created this revision.
PiotrZSL added reviewers: njames93, carlosgalvezp, Izaron, fwolff.
Herald added a subscriber: xazax.hun.
Herald added a project: All.
PiotrZSL requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

Fixed issue with the comparison of UnaryExprOrTypeTraitExpr
objects in which only the argument type was checked, without
considering the kind of expression. This led to false positives when
using sizeof(x) and alignof(x) expressions, as only the
comparison x = x was performed without checking if sizeof
was equal to alignof.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152713

Files:
  clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/test/clang-tidy/checkers/misc/redundant-expression.cpp


Index: clang-tools-extra/test/clang-tidy/checkers/misc/redundant-expression.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/misc/redundant-expression.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/misc/redundant-expression.cpp
@@ -843,3 +843,15 @@
 
   return 2;
 }
+
+namespace PR63096 {
+
+struct alignas(sizeof(int)) X {
+  int x;
+};
+
+static_assert(alignof(X) == sizeof(X));
+static_assert(sizeof(X) == sizeof(X));
+// CHECK-MESSAGES: :[[@LINE-1]]:25: warning: both sides of operator are 
equivalent
+
+}
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -306,6 +306,10 @@
   ` to avoid warning on
   declarations inside anonymous namespaces.
 
+- Fixed false-positive in :doc:`misc-redundant-expression
+  ` check where expressions like
+  ``alignof`` or ``sizeof`` were incorrectly flagged as identical.
+
 - Improved :doc:`misc-unused-parameters
   ` check with new `IgnoreVirtual`
   option to optionally ignore virtual methods.
Index: clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
===
--- clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
+++ clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
@@ -144,8 +144,9 @@
 const auto *RightUnaryExpr =
 cast(Right);
 if (LeftUnaryExpr->isArgumentType() && RightUnaryExpr->isArgumentType())
-  return LeftUnaryExpr->getArgumentType() ==
- RightUnaryExpr->getArgumentType();
+  return LeftUnaryExpr->getKind() == RightUnaryExpr->getKind() &&
+ LeftUnaryExpr->getArgumentType() ==
+ RightUnaryExpr->getArgumentType();
 if (!LeftUnaryExpr->isArgumentType() && !RightUnaryExpr->isArgumentType())
   return areEquivalentExpr(LeftUnaryExpr->getArgumentExpr(),
RightUnaryExpr->getArgumentExpr());


Index: clang-tools-extra/test/clang-tidy/checkers/misc/redundant-expression.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/misc/redundant-expression.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/misc/redundant-expression.cpp
@@ -843,3 +843,15 @@
 
   return 2;
 }
+
+namespace PR63096 {
+
+struct alignas(sizeof(int)) X {
+  int x;
+};
+
+static_assert(alignof(X) == sizeof(X));
+static_assert(sizeof(X) == sizeof(X));
+// CHECK-MESSAGES: :[[@LINE-1]]:25: warning: both sides of operator are equivalent
+
+}
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -306,6 +306,10 @@
   ` to avoid warning on
   declarations inside anonymous namespaces.
 
+- Fixed false-positive in :doc:`misc-redundant-expression
+  ` check where expressions like
+  ``alignof`` or ``sizeof`` were incorrectly flagged as identical.
+
 - Improved :doc:`misc-unused-parameters
   ` check with new `IgnoreVirtual`
   option to optionally ignore virtual methods.
Index: clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
===
--- clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
+++ clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
@@ -144,8 +144,9 @@
 const auto *RightUnaryExpr =
 cast(Right);
 if (LeftUnaryExpr->isArgumentType() && RightUnaryExpr->isArgumentType())
-  return LeftUnaryExpr->getArgumentType() ==
- RightUnaryExpr->getArgumentType();
+  return LeftUnaryExpr->getKind() == RightUnaryExpr->getKind() &&
+ LeftUnaryExpr->getArgumentType() ==
+ RightUnaryExpr->getArgumentType();
 if (!LeftUnaryExpr->isArgumentType() && !RightUnaryExpr->isArgumentType())
   return areEquiv

[PATCH] D150860: [OpenMP] Change clang emitTargetDataCalls to use OMPIRBuilder

2023-06-12 Thread Akash Banerjee via Phabricator via cfe-commits
TIFitis updated this revision to Diff 530533.
TIFitis marked an inline comment as done.
TIFitis added a comment.

Rebased


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150860

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/test/OpenMP/target_data_codegen.cpp
  clang/test/OpenMP/target_data_use_device_ptr_codegen.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp

Index: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
===
--- llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -4085,7 +4085,9 @@
 function_ref GenMapInfoCB,
 omp::RuntimeFunction *MapperFunc,
 function_ref
-BodyGenCB) {
+BodyGenCB,
+function_ref DeviceAddrCB,
+function_ref CustomMapperCB) {
   if (!updateToLocation(Loc))
 return InsertPointTy();
 
@@ -4096,9 +4098,9 @@
   // arguments of the runtime call by reference because they are used in the
   // closing of the region.
   auto BeginThenGen = [&](InsertPointTy UnusedIP, InsertPointTy CodeGenIP) {
-emitOffloadingArrays(AllocaIP, Builder.saveIP(),
- GenMapInfoCB(Builder.saveIP()), Info,
- /*IsNonContiguous=*/true);
+emitOffloadingArrays(
+AllocaIP, Builder.saveIP(), GenMapInfoCB(Builder.saveIP()), Info,
+/*IsNonContiguous=*/true, DeviceAddrCB, CustomMapperCB);
 
 TargetDataRTArgs RTArgs;
 emitOffloadingArraysArgument(Builder, RTArgs, Info);
Index: llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
===
--- llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
+++ llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
@@ -2021,6 +2021,10 @@
   /// \param Info Stores all information realted to the Target Data directive.
   /// \param GenMapInfoCB Callback that populates the MapInfos and returns.
   /// \param BodyGenCB Optional Callback to generate the region code.
+  /// \param DeviceAddrCB Optional callback to generate code related to
+  /// use_device_ptr and use_device_addr.
+  /// \param CustomMapperCB Optional callback to generate code related to
+  /// custom mappers.
   OpenMPIRBuilder::InsertPointTy createTargetData(
   const LocationDescription &Loc, InsertPointTy AllocaIP,
   InsertPointTy CodeGenIP, Value *DeviceID, Value *IfCond,
@@ -2029,7 +2033,9 @@
   omp::RuntimeFunction *MapperFunc = nullptr,
   function_ref
-  BodyGenCB = nullptr);
+  BodyGenCB = nullptr,
+  function_ref DeviceAddrCB = nullptr,
+  function_ref CustomMapperCB = nullptr);
 
   using TargetBodyGenCallbackTy = function_ref;
Index: clang/test/OpenMP/target_data_use_device_ptr_codegen.cpp
===
--- clang/test/OpenMP/target_data_use_device_ptr_codegen.cpp
+++ clang/test/OpenMP/target_data_use_device_ptr_codegen.cpp
@@ -131,7 +131,6 @@
 ++l;
   }
   // CK1: [[BEND]]:
-  // CK1: [[CMP:%.+]] = icmp ne ptr %{{.+}}, null
   // CK1: br i1 [[CMP]], label %[[BTHEN:.+]], label %[[BELSE:.+]]
 
   // CK1: [[BTHEN]]:
Index: clang/test/OpenMP/target_data_codegen.cpp
===
--- clang/test/OpenMP/target_data_codegen.cpp
+++ clang/test/OpenMP/target_data_codegen.cpp
@@ -63,9 +63,7 @@
 
   // CK1: %{{.+}} = add nsw i32 %{{[^,]+}}, 1
 
-  // CK1-DAG: call void @__tgt_target_data_end_mapper(ptr @{{.+}}, i64 [[DEV:%[^,]+]], i32 1, ptr [[GEPBP:%.+]], ptr [[GEPP:%.+]], ptr [[SIZE00]], ptr [[MTYPE00]], ptr null, ptr null)
-  // CK1-DAG: [[DEV]] = sext i32 [[DEVi32:%[^,]+]] to i64
-  // CK1-DAG: [[DEVi32]] = load i32, ptr %{{[^,]+}},
+  // CK1-DAG: call void @__tgt_target_data_end_mapper(ptr @{{.+}}, i64 [[DEV]], i32 1, ptr [[GEPBP:%.+]], ptr [[GEPP:%.+]], ptr [[SIZE00]], ptr [[MTYPE00]], ptr null, ptr null)
   // CK1-DAG: [[GEPBP]] = getelementptr inbounds {{.+}}[[BP]]
 // CK1-DAG: [[GEPP]] = getelementptr inbounds {{.+}}[[P]]
   #pragma omp target data if(1+3-5) device(arg) map(from: gc)
@@ -354,11 +352,11 @@
 }
 
 // Region 00
+// CK2-DAG: [[DEV:%[^,]+]] = sext i32 [[DEVi32:%[^,]+]] to i64
+// CK2-DAG: [[DEVi32]] = load i32, ptr %{{[^,]+}},
 // CK2: br i1 %{{[^,]+}}, label %[[IFTHEN:[^,]+]], label %[[IFELSE:[^,]+]]
 // CK2: [[IFTHEN]]
-// CK2-DAG: call void @__tgt_target_data_begin_mapper(ptr @{{.+}}, i64 [[DEV:%[^,]+]], i32 2, ptr [[GEPBP:%.+]], ptr [[GEPP:%.+]], ptr [[GEPS:%[^,]+]], ptr [[MTYPE00]], ptr null, ptr null)
-// CK2-DAG: [[DEV]] = sext i32 [[DEVi32:%[^,]+]] to i64
-// CK2-DAG: [[DEVi32]] = load i32, ptr %{{[^,]+}},
+// CK2-DAG: call void @__tgt_target_data_begin_mapper(ptr @{{.+}}, i64 [[DEV]], i32 2, ptr [[GEPBP:%.+]], ptr [[GEPP:%.+]], ptr [[GEPS:%[^,]+]], ptr [[MTYPE00]], ptr null, ptr null)
 // CK2-DAG: [[GEPBP]] = getelementptr inboun

[PATCH] D152720: [clangd][ObjC] Support ObjC class rename from implementation decls

2023-06-12 Thread David Goldman via Phabricator via cfe-commits
dgoldman created this revision.
dgoldman added a reviewer: kadircet.
Herald added a subscriber: arphaman.
Herald added a project: All.
dgoldman requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152720

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


Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -840,6 +840,16 @@
   foo('x');
 }
   )cpp",
+
+  // ObjC class.
+  R"cpp(
+@interface [[Fo^o]]
+@end
+@implementation [[F^oo]]
+@end
+
+void func([[Foo]] *f) {}
+  )cpp",
   };
   llvm::StringRef NewName = "NewName";
   for (llvm::StringRef T : Tests) {
@@ -1468,7 +1478,7 @@
 
 TEST(CrossFileRenameTests, WithUpToDateIndex) {
   MockCompilationDatabase CDB;
-  CDB.ExtraClangFlags = {"-xc++"};
+  CDB.ExtraClangFlags = {"-xobjective-c++"};
   // rename is runnning on all "^" points in FooH, and "[[]]" ranges are the
   // expected rename occurrences.
   struct Case {
@@ -1677,6 +1687,20 @@
 }
   )cpp",
   },
+  {
+  // Objective-C classes.
+  R"cpp(
+@interface [[Fo^o]]
+@end
+  )cpp",
+  R"cpp(
+#include "foo.h"
+@implementation [[F^oo]]
+@end
+
+void func([[Foo]] *f) {}
+  )cpp",
+  },
   };
 
   trace::TestTracer Tracer;
Index: clang-tools-extra/clangd/FindTarget.cpp
===
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -707,6 +707,14 @@
   /*IsDecl=*/true,
   {OCID->getCategoryDecl()}});
 }
+
+void VisitObjCImplementationDecl(const ObjCImplementationDecl *OIMD) {
+  if (const auto *CI = OIMD->getClassInterface())
+Refs.push_back(ReferenceLoc{NestedNameSpecifierLoc(),
+OIMD->getLocation(),
+/*IsDecl=*/true,
+{CI}});
+}
   };
 
   Visitor V{Resolver};


Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -840,6 +840,16 @@
   foo('x');
 }
   )cpp",
+
+  // ObjC class.
+  R"cpp(
+@interface [[Fo^o]]
+@end
+@implementation [[F^oo]]
+@end
+
+void func([[Foo]] *f) {}
+  )cpp",
   };
   llvm::StringRef NewName = "NewName";
   for (llvm::StringRef T : Tests) {
@@ -1468,7 +1478,7 @@
 
 TEST(CrossFileRenameTests, WithUpToDateIndex) {
   MockCompilationDatabase CDB;
-  CDB.ExtraClangFlags = {"-xc++"};
+  CDB.ExtraClangFlags = {"-xobjective-c++"};
   // rename is runnning on all "^" points in FooH, and "[[]]" ranges are the
   // expected rename occurrences.
   struct Case {
@@ -1677,6 +1687,20 @@
 }
   )cpp",
   },
+  {
+  // Objective-C classes.
+  R"cpp(
+@interface [[Fo^o]]
+@end
+  )cpp",
+  R"cpp(
+#include "foo.h"
+@implementation [[F^oo]]
+@end
+
+void func([[Foo]] *f) {}
+  )cpp",
+  },
   };
 
   trace::TestTracer Tracer;
Index: clang-tools-extra/clangd/FindTarget.cpp
===
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -707,6 +707,14 @@
   /*IsDecl=*/true,
   {OCID->getCategoryDecl()}});
 }
+
+void VisitObjCImplementationDecl(const ObjCImplementationDecl *OIMD) {
+  if (const auto *CI = OIMD->getClassInterface())
+Refs.push_back(ReferenceLoc{NestedNameSpecifierLoc(),
+OIMD->getLocation(),
+/*IsDecl=*/true,
+{CI}});
+}
   };
 
   Visitor V{Resolver};
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D152433: [ARM,AArch64] Add a full set of -mtp= options.

2023-06-12 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham updated this revision to Diff 530544.
simon_tatham added a comment.

Fixed the isReadTPSoft predicate (sorry – I always get confused by when 
Tablegen autogenerates those predicates and when it doesn't), and reorganised 
the tests.

I couldn't find any existing test file, so I made a new pair 
`arm-thread-pointer.c` and `aarch64-thread-pointer.c` and moved all the TP 
tests out into there.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152433

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Arch/AArch64.cpp
  clang/lib/Driver/ToolChains/Arch/ARM.cpp
  clang/lib/Driver/ToolChains/Arch/ARM.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/aarch64-thread-pointer.c
  clang/test/Driver/arm-thread-pointer.c
  clang/test/Driver/clang-translation.c
  llvm/lib/Target/AArch64/AArch64.td
  llvm/lib/Target/AArch64/AArch64ExpandPseudoInsts.cpp
  llvm/lib/Target/ARM/ARM.td
  llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp
  llvm/lib/Target/ARM/ARMInstrInfo.td
  llvm/lib/Target/ARM/ARMInstrThumb2.td
  llvm/lib/Target/ARM/ARMPredicates.td
  llvm/lib/Target/ARM/ARMSubtarget.h
  llvm/test/CodeGen/AArch64/arm64-builtins-linux.ll
  llvm/test/CodeGen/ARM/readtp.ll
  llvm/test/CodeGen/ARM/stack-guard-tls.ll
  llvm/test/CodeGen/ARM/thread_pointer.ll

Index: llvm/test/CodeGen/ARM/thread_pointer.ll
===
--- llvm/test/CodeGen/ARM/thread_pointer.ll
+++ llvm/test/CodeGen/ARM/thread_pointer.ll
@@ -1,7 +1,11 @@
 ; RUN: llc -mtriple arm-linux-gnueabi -o - %s | FileCheck %s -check-prefix=CHECK-SOFT
-; RUN: llc -mtriple arm-linux-gnueabi -mattr=+read-tp-hard -o - %s | FileCheck %s -check-prefix=CHECK-HARD
+; RUN: llc -mtriple arm-linux-gnueabi -mattr=+read-tp-tpidrurw -o - %s | FileCheck %s -check-prefix=CHECK-TPIDRURW
+; RUN: llc -mtriple arm-linux-gnueabi -mattr=+read-tp-tpidruro -o - %s | FileCheck %s -check-prefix=CHECK-TPIDRURO
+; RUN: llc -mtriple arm-linux-gnueabi -mattr=+read-tp-tpidrprw -o - %s | FileCheck %s -check-prefix=CHECK-TPIDRPRW
 ; RUN: llc -mtriple thumbv7-linux-gnueabi -o - %s | FileCheck %s -check-prefix=CHECK-SOFT
-; RUN: llc -mtriple thumbv7-linux-gnueabi -mattr=+read-tp-hard -o - %s | FileCheck %s -check-prefix=CHECK-HARD
+; RUN: llc -mtriple thumbv7-linux-gnueabi -mattr=+read-tp-tpidrurw -o - %s | FileCheck %s -check-prefix=CHECK-TPIDRURW
+; RUN: llc -mtriple thumbv7-linux-gnueabi -mattr=+read-tp-tpidruro -o - %s | FileCheck %s -check-prefix=CHECK-TPIDRURO
+; RUN: llc -mtriple thumbv7-linux-gnueabi -mattr=+read-tp-tpidrprw -o - %s | FileCheck %s -check-prefix=CHECK-TPIDRPRW
 
 declare ptr @llvm.thread.pointer()
 
@@ -11,6 +15,8 @@
   ret ptr %tmp1
 }
 
-; CHECK-SOFT: bl __aeabi_read_tp
-; CHECK-HARD: mrc p15, #0, {{r[0-9]+}}, c13, c0, #3
+; CHECK-SOFT: bl __aeabi_read_tp
+; CHECK-TPIDRURW: mrc p15, #0, {{r[0-9]+}}, c13, c0, #2
+; CHECK-TPIDRURO: mrc p15, #0, {{r[0-9]+}}, c13, c0, #3
+; CHECK-TPIDRPRW: mrc p15, #0, {{r[0-9]+}}, c13, c0, #4
 
Index: llvm/test/CodeGen/ARM/stack-guard-tls.ll
===
--- llvm/test/CodeGen/ARM/stack-guard-tls.ll
+++ llvm/test/CodeGen/ARM/stack-guard-tls.ll
@@ -1,13 +1,13 @@
 ; RUN: split-file %s %t
 ; RUN: cat %t/main.ll %t/a.ll > %t/a2.ll
 ; RUN: cat %t/main.ll %t/b.ll > %t/b2.ll
-; RUN: llc %t/a2.ll -mtriple=armv7-unknown-linux-gnueabihf -mattr=+read-tp-hard -o - | \
+; RUN: llc %t/a2.ll -mtriple=armv7-unknown-linux-gnueabihf -mattr=+read-tp-tpidruro -o - | \
 ; RUN: FileCheck --check-prefixes=CHECK,CHECK-SMALL %s
-; RUN: llc %t/a2.ll -mtriple=thumbv7-unknown-linux-gnueabihf -mattr=+read-tp-hard -o - | \
+; RUN: llc %t/a2.ll -mtriple=thumbv7-unknown-linux-gnueabihf -mattr=+read-tp-tpidruro -o - | \
 ; RUN: FileCheck --check-prefixes=CHECK,CHECK-SMALL %s
-; RUN: llc %t/b2.ll -mtriple=armv7-unknown-linux-gnueabihf -mattr=+read-tp-hard -o - | \
+; RUN: llc %t/b2.ll -mtriple=armv7-unknown-linux-gnueabihf -mattr=+read-tp-tpidruro -o - | \
 ; RUN: FileCheck --check-prefixes=CHECK,CHECK-LARGE %s
-; RUN: llc %t/b2.ll -mtriple=thumbv7-unknown-linux-gnueabihf -mattr=+read-tp-hard -o - | \
+; RUN: llc %t/b2.ll -mtriple=thumbv7-unknown-linux-gnueabihf -mattr=+read-tp-tpidruro -o - | \
 ; RUN: FileCheck --check-prefixes=CHECK,CHECK-LARGE %s
 
 ;--- main.ll
Index: llvm/test/CodeGen/ARM/readtp.ll
===
--- llvm/test/CodeGen/ARM/readtp.ll
+++ llvm/test/CodeGen/ARM/readtp.ll
@@ -1,6 +1,10 @@
-; RUN: llc -mtriple=armeb-linux-gnueabihf -O2 -mattr=+read-tp-hard %s -o - | FileCheck %s -check-prefix=CHECK-HARD
+; RUN: llc -mtriple=armeb-linux-gnueabihf -O2 -mattr=+read-tp-tpidrurw %s -o - | FileCheck %s -check-prefix=CHECK-TPIDRURW
+; RUN: llc -mtriple=armeb-linux-gnueabihf -O2 -mattr=+read-tp-tpidruro %s -o - | FileCheck %s -check-prefix=CHECK-TPIDRURO
+; RUN: llc -mtriple=armeb-linux-gnu

[PATCH] D152554: [OpenMP] Migrate deviice code privatization from Clang CodeGen to OMPIRBuilder

2023-06-12 Thread Akash Banerjee via Phabricator via cfe-commits
TIFitis updated this revision to Diff 530548.
TIFitis added a comment.

Rebased


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152554

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.h
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/test/OpenMP/target_data_use_device_ptr_codegen.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp

Index: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
===
--- llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -4086,7 +4086,7 @@
 omp::RuntimeFunction *MapperFunc,
 function_ref
 BodyGenCB,
-function_ref DeviceAddrCB,
+function_ref DeviceAddrCB,
 function_ref CustomMapperCB) {
   if (!updateToLocation(Loc))
 return InsertPointTy();
@@ -4128,6 +4128,14 @@
 
   Builder.CreateCall(beginMapperFunc, OffloadingArgs);
 
+  for (auto DeviceMap : Info.DevicePtrInfoMap) {
+if (isa(DeviceMap.second.second)) {
+  auto *LI =
+  Builder.CreateLoad(Builder.getPtrTy(), DeviceMap.second.first);
+  Builder.CreateStore(LI, DeviceMap.second.second);
+}
+  }
+
   // If device pointer privatization is required, emit the body of the
   // region here. It will have to be duplicated: with and without
   // privatization.
@@ -4539,7 +4547,7 @@
 void OpenMPIRBuilder::emitOffloadingArrays(
 InsertPointTy AllocaIP, InsertPointTy CodeGenIP, MapInfosTy &CombinedInfo,
 TargetDataInfo &Info, bool IsNonContiguous,
-function_ref DeviceAddrCB,
+function_ref DeviceAddrCB,
 function_ref CustomMapperCB) {
 
   // Reset the array information.
@@ -4674,9 +4682,21 @@
 BPVal, BP, M.getDataLayout().getPrefTypeAlign(Builder.getInt8PtrTy()));
 
 if (Info.requiresDevicePointerInfo()) {
-  assert(DeviceAddrCB &&
- "DeviceAddrCB missing for DevicePtr code generation");
-  DeviceAddrCB(I, BP, BPVal);
+if (CombinedInfo.DevicePointers[I] == DeviceInfoTy::Pointer) {
+  CodeGenIP = Builder.saveIP();
+  Builder.restoreIP(AllocaIP);
+  Info.DevicePtrInfoMap[BPVal] = {
+  BP, Builder.CreateAlloca(Builder.getPtrTy())};
+  Builder.restoreIP(CodeGenIP);
+  assert(DeviceAddrCB &&
+  "DeviceAddrCB missing for DevicePtr code generation");
+  DeviceAddrCB(I, Info.DevicePtrInfoMap[BPVal].second);
+} else if (CombinedInfo.DevicePointers[I] == DeviceInfoTy::Address) {
+  Info.DevicePtrInfoMap[BPVal] = {BP, BP};
+  assert(DeviceAddrCB &&
+  "DeviceAddrCB missing for DevicePtr code generation");
+  DeviceAddrCB(I, BP);
+}
 }
 
 Value *PVal = CombinedInfo.Pointers[I];
Index: llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
===
--- llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
+++ llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
@@ -1566,6 +1566,9 @@
   public:
 TargetDataRTArgs RTArgs;
 
+SmallMapVector, 4>
+DevicePtrInfoMap;
+
 /// Indicate whether any user-defined mapper exists.
 bool HasMapper = false;
 /// The total number of pointers passed to the runtime library.
@@ -1592,7 +1595,9 @@
 bool separateBeginEndCalls() { return SeparateBeginEndCalls; }
   };
 
+  enum class DeviceInfoTy { None, Pointer, Address };
   using MapValuesArrayTy = SmallVector;
+  using MapDeviceInfoArrayTy = SmallVector;
   using MapFlagsArrayTy = SmallVector;
   using MapNamesArrayTy = SmallVector;
   using MapDimArrayTy = SmallVector;
@@ -1611,6 +1616,7 @@
 };
 MapValuesArrayTy BasePointers;
 MapValuesArrayTy Pointers;
+MapDeviceInfoArrayTy DevicePointers;
 MapValuesArrayTy Sizes;
 MapFlagsArrayTy Types;
 MapNamesArrayTy Names;
@@ -1621,6 +1627,8 @@
   BasePointers.append(CurInfo.BasePointers.begin(),
   CurInfo.BasePointers.end());
   Pointers.append(CurInfo.Pointers.begin(), CurInfo.Pointers.end());
+  DevicePointers.append(CurInfo.DevicePointers.begin(),
+CurInfo.DevicePointers.end());
   Sizes.append(CurInfo.Sizes.begin(), CurInfo.Sizes.end());
   Types.append(CurInfo.Types.begin(), CurInfo.Types.end());
   Names.append(CurInfo.Names.begin(), CurInfo.Names.end());
@@ -1657,7 +1665,7 @@
   void emitOffloadingArrays(
   InsertPointTy AllocaIP, InsertPointTy CodeGenIP, MapInfosTy &CombinedInfo,
   TargetDataInfo &Info, bool IsNonContiguous = false,
-  function_ref DeviceAddrCB = nullptr,
+  function_ref DeviceAddrCB = nullptr,
   function_ref CustomMapperCB = nullptr);
 
   /// Creates offloading entry for the provided entry ID \a ID, address \a
@@ -2034,7 +2042

[PATCH] D144999: [Clang][MC][MachO]Only emits compact-unwind format for "canonical" personality symbols. For the rest, use DWARFs.

2023-06-12 Thread Michael Buch via Phabricator via cfe-commits
Michael137 added a comment.

In D144999#4409671 , @oontvoo wrote:

> P.S This might have the same root-cause with the previous comment and could 
> be fixed by D152540  as well.
> (not able to repro the failures yet - don't have arm64 readily available, 
> will test it later this evening. but on linux x86-64 and macos x86-64, ninja 
> check-debuginfo passed for me)

FYI, still failing with D152540 . I'm able to 
repro this on my arm64 machine.

The repro without running dexter is as follows:

  ./bin/clang++ 
cross-project-tests/debuginfo-tests/dexter-tests/optnone-struct-and-methods.cpp 
-g -O0 -o test.out
  ./bin/lldb test.out -o "br se -l 87" -o run -o s -o s -o s -o s -o "expr 
_data.b.other_b"
  (lldb) expr _data.b.other_b 
  (A::B) $0 = 0x10d50 

We would however expect the value to be `B_VALUE`

The backtrace also looks wonky:

  (lldb) bt
  * thread #1, queue = 'com.apple.main-thread', stop reason = step in
* frame #0: 0x00013d18 test.out`(anonymous 
namespace)::A::getData(this=0x000100011910) at 
optnone-struct-and-methods.cpp:87:5
  frame #1: 0x000187185058 dyld`start + 2224


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144999

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


[clang] ed506dd - [DebugMetadata] Simplify handling subprogram's retainedNodes field. NFCI (1/7)

2023-06-12 Thread Vladislav Dzhidzhoev via cfe-commits

Author: Vladislav Dzhidzhoev
Date: 2023-06-12T18:38:47+02:00
New Revision: ed506dd6cecd9653cf9202bfe195891a33482852

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

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

RFC 
https://discourse.llvm.org/t/rfc-dwarfdebug-fix-and-improve-handling-imported-entities-types-and-static-local-in-subprogram-and-lexical-block-scopes/68544

Currently, `retainedNodes` tracks function-local variables and labels.
To support function-local import, types and static variables (which are globals
in LLVM IR), subsequent patches use the same field. So this patch makes
preliminary refactoring of the code tracking local entities to apply future
functional changes lucidly and cleanly.

No functional changes intended.

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

Authored-by: Kristina Bessonova 

Added: 


Modified: 
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
llvm/test/Bindings/OCaml/debuginfo.ml

Removed: 




diff  --git a/clang/test/CodeGen/attr-btf_tag-disubprogram-callsite.c 
b/clang/test/CodeGen/attr-btf_tag-disubprogram-callsite.c
index e3bfd71a56aad..5bbb05e6b8098 100644
--- a/clang/test/CodeGen/attr-btf_tag-disubprogram-callsite.c
+++ b/clang/test/CodeGen/attr-btf_tag-disubprogram-callsite.c
@@ -13,7 +13,7 @@ int foo2(struct t1 *arg) {
   return foo(arg);
 }
 
-// CHECK: ![[#]] = !DISubprogram(name: "foo", scope: ![[#]], file: ![[#]], 
line: [[#]], type: ![[#]], flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, 
retainedNodes: ![[#]], annotations: ![[ANNOT:[0-9]+]])
+// CHECK: ![[#]] = !DISubprogram(name: "foo", scope: ![[#]], file: ![[#]], 
line: [[#]], type: ![[#]], flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, 
annotations: ![[ANNOT:[0-9]+]])
 // CHECK: ![[ANNOT]] = !{![[TAG1:[0-9]+]], ![[TAG2:[0-9]+]]}
 // CHECK: ![[TAG1]] = !{!"btf_decl_tag", !"tag1"}
 // CHECK: ![[TAG2]] = !{!"btf_decl_tag", !"tag2"}

diff  --git a/clang/test/CodeGenCXX/aix-static-init-debug-info.cpp 
b/clang/test/CodeGenCXX/aix-static-init-debug-info.cpp
index a35ca27e10d2a..6453e4379ae9a 100644
--- a/clang/test/CodeGenCXX/aix-static-init-debug-info.cpp
+++ b/clang/test/CodeGenCXX/aix-static-init-debug-info.cpp
@@ -52,15 +52,15 @@ X v;
 // CHECK:   ret void
 // CHECK: }
 
-// CHECK: ![[DBGVAR16]] = distinct !DISubprogram(name: 
"__cxx_global_var_init", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, type: 
!{{[0-9]+}}, flags: DIFlagArtificial, spFlags: DISPFlagLocalToUnit | 
DISPFlagDefinition, unit: !{{[0-9]+}}, retainedNodes: !{{[0-9]+}})
+// CHECK: ![[DBGVAR16]] = distinct !DISubprogram(name: 
"__cxx_global_var_init", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, type: 
!{{[0-9]+}}, flags: DIFlagArtificial, spFlags: DISPFlagLocalToUnit | 
DISPFlagDefinition, unit: !{{[0-9]+}})
 // CHECK: ![[DBGVAR19]] = !DILocation(line: 14, column: 3, scope: 
![[DBGVAR16]])
 // CHECK: ![[DBGVAR19b]] = !DILocation(line: 0, scope: ![[DBGVAR16]])
-// CHECK: ![[DBGVAR20]] = distinct !DISubprogram(name: "__dtor_v", scope: 
!{{[0-9]+}}, file: !{{[0-9]+}}, line: 14, type: !{{[0-9]+}}, scopeLine: 14, 
flags: DIFlagArtificial, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition, 
unit: !{{[0-9]+}}, retainedNodes: !{{[0-9]+}})
+// CHECK: ![[DBGVAR20]] = distinct !DISubprogram(name: "__dtor_v", scope: 
!{{[0-9]+}}, file: !{{[0-9]+}}, line: 14, type: !{{[0-9]+}}, scopeLine: 14, 
flags: DIFlagArtificial, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition, 
unit: !{{[0-9]+}})
 // CHECK: ![[DBGVAR21b]] = !DILocation(line: 0, scope: ![[DBGVAR20]])
 // CHECK: ![[DBGVAR21]] = !DILocation(line: 14, column: 3, scope: 
![[DBGVAR20]])
-// CHECK: ![[DBGVAR22]] = distinct !DISubprogram(linkageName: "__finalize_v", 
scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: 14, type: !{{[0-9]+}}, scopeLine: 
14, flags: DIFlagArtificial, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition, 
unit: !{{[0-9]+}}, retainedNodes: !{{[0-9]+}})
+// CHECK: ![[DBGVAR22]] = distinct !DISubprogram(linkageName: "__finalize_v", 
scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: 14, type: !{{[0-9]+}}, scopeLine: 
14, flags: DIFlagArtificial, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition, 
unit: !{{[0-9]+}})
 // CHECK: ![[DBGVAR24]] = !DILocation(line: 14, column: 3, scope: 
![[DBGVAR22]])
-// CHECK: ![[DBGVAR25]] = distinct !DISubprogram(linkageName: 
"_GLOBAL__sub_I__", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, type: !{{[0-9]+}}, 
flags: DIFlagArtificial, spFlags: DISPFlagLocalToUni

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

2023-06-12 Thread Vladislav Dzhidzhoev via Phabricator via cfe-commits
dzhidzhoev added a comment.

Updated DebugInfo test of OCaml binding.

In D143984#4409015 , @dblaikie wrote:

> When we migrated to github we gained higher fidelity for attributing authors 
> (we can now commit on someone's behalf but have the commit author properly 
> recorded as the real author - we couldn't do that back on Subversion) - but I 
> think it's meant that fail-mail from bots goes to that author, and not to the 
> committer. Ideally it'd go to both - so, as it stands now, being a 
> commiter-but-not-author is tricky, because you don't get the feedback on the 
> commit you made. You might watch buildbots manually, or at least bhe 
> responsive to other people complaining on the reviews like this.

Thanks! We agreed to use Authored-by attribute.


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] D152570: [clang] Fix filename remapping in template arguments

2023-06-12 Thread Dan McGregor via Phabricator via cfe-commits
dankm updated this revision to Diff 530563.
dankm added a comment.

Rebase and hopefully fix builds.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152570

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/AST/Expr.cpp
  clang/test/CodeGenCXX/file-prefix-map-lambda.cpp


Index: clang/test/CodeGenCXX/file-prefix-map-lambda.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/file-prefix-map-lambda.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fmacro-prefix-map=%p=./UNLIKELY_PATH/empty -S %s 
-emit-llvm -o - | FileCheck %s
+
+template
+auto lambdatest(f&& cb) {
+  const char *s = __PRETTY_FUNCTION__;
+  return s;
+}
+
+int main() {
+  auto *s = lambdatest([](){});
+// CHECK: @"__PRETTY_FUNCTION__._Z10lambdatestIZ4mainE3$_0EDaOT_" = private 
unnamed_addr constant [{{[0-9]+}} x i8] c"auto lambdatest(f &&) [f = (lambda at 
./UNLIKELY_PATH/empty{{/|}}{{.*}}.cpp:10:24)]\00", align 1
+
+  return 0;
+}
Index: clang/lib/AST/Expr.cpp
===
--- clang/lib/AST/Expr.cpp
+++ clang/lib/AST/Expr.cpp
@@ -786,7 +786,21 @@
 Out << "static ";
 }
 
+class PrettyCallbacks final : public PrintingCallbacks {
+public:
+  PrettyCallbacks(const LangOptions &LO) : LO(LO) {}
+  std::string remapPath(StringRef Path) const override {
+SmallString<128> p(Path);
+LO.remapPathPrefix(p);
+return std::string(p);
+  }
+
+private:
+  const LangOptions &LO;
+};
 PrintingPolicy Policy(Context.getLangOpts());
+PrettyCallbacks PrettyCB(Context.getLangOpts());
+Policy.Callbacks = &PrettyCB;
 std::string Proto;
 llvm::raw_string_ostream POut(Proto);
 
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -497,6 +497,8 @@
 - CallExpr built for C error-recovery now is always type-dependent. Fixes a
   crash when we encounter a unresolved TypoExpr during diagnostic emission.
   (`#50244 _`).
+- Fix lambdas in template arguments not respecting ``-fmacro-prefix-map``
+  (`#63219 `_)
 
 Bug Fixes to Compiler Builtins
 ^^


Index: clang/test/CodeGenCXX/file-prefix-map-lambda.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/file-prefix-map-lambda.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fmacro-prefix-map=%p=./UNLIKELY_PATH/empty -S %s -emit-llvm -o - | FileCheck %s
+
+template
+auto lambdatest(f&& cb) {
+  const char *s = __PRETTY_FUNCTION__;
+  return s;
+}
+
+int main() {
+  auto *s = lambdatest([](){});
+// CHECK: @"__PRETTY_FUNCTION__._Z10lambdatestIZ4mainE3$_0EDaOT_" = private unnamed_addr constant [{{[0-9]+}} x i8] c"auto lambdatest(f &&) [f = (lambda at ./UNLIKELY_PATH/empty{{/|}}{{.*}}.cpp:10:24)]\00", align 1
+
+  return 0;
+}
Index: clang/lib/AST/Expr.cpp
===
--- clang/lib/AST/Expr.cpp
+++ clang/lib/AST/Expr.cpp
@@ -786,7 +786,21 @@
 Out << "static ";
 }
 
+class PrettyCallbacks final : public PrintingCallbacks {
+public:
+  PrettyCallbacks(const LangOptions &LO) : LO(LO) {}
+  std::string remapPath(StringRef Path) const override {
+SmallString<128> p(Path);
+LO.remapPathPrefix(p);
+return std::string(p);
+  }
+
+private:
+  const LangOptions &LO;
+};
 PrintingPolicy Policy(Context.getLangOpts());
+PrettyCallbacks PrettyCB(Context.getLangOpts());
+Policy.Callbacks = &PrettyCB;
 std::string Proto;
 llvm::raw_string_ostream POut(Proto);
 
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -497,6 +497,8 @@
 - CallExpr built for C error-recovery now is always type-dependent. Fixes a
   crash when we encounter a unresolved TypoExpr during diagnostic emission.
   (`#50244 _`).
+- Fix lambdas in template arguments not respecting ``-fmacro-prefix-map``
+  (`#63219 `_)
 
 Bug Fixes to Compiler Builtins
 ^^
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D151820: [clang][WebAssembly] Fix __BIGGEST_ALIGNMENT__ under emscripten

2023-06-12 Thread Sam Clegg via Phabricator via cfe-commits
sbc100 added a comment.

Can we land this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151820

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


[PATCH] D142388: [clang] Add builtin_nondeterministic_value

2023-06-12 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D142388#4412521 , @rsmith wrote:

> I have a concern with the name of this builtin. People are going to assume it 
> produces a nondeterministic value, and use it for seeding random number 
> generators and similar, and will be surprised when the value produced is 
> actually deterministic, and, worse, might leak information on the stack that 
> was left behind by some previous function call. Can we give this a name that 
> doesn't suggest that it produces its value nondeterministically?

That's a fair point; do you have a suggestion for a name? (I had suggested 
`__builtin_unspecified_value()` but perhaps that is too focused on the term of 
art.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142388

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


[PATCH] D152708: [RFC][Draft] Enable primitive support for Two-Level Line Tables in LLVM

2023-06-12 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

Really appreciate you providing this prototype.

> This solves one of the current weaknesses in DWARF debugging, which is the 
> inability to set breakpoints or step onto inlined callsites. However, there 
> are other proposals (such as Location View Numbering) that could achieve the 
> same thing, and the costs of TLLT in storage size and design complexity may 
> make it a non-ideal solution to this problem.

FWIW, one of the major motivations for this was not only to include the stop 
points, but also to allow symbolizing including stack frames - so you'd need to 
know that all the inlined instructions come from the inlined call site. I 
think, maybe, my vague understanding of Location View Numbering wouldn't cover 
that case, and only covers the "how do I describe the variable when I'm stopped 
at this synthetic location that exists just before or after the call", for 
instance?

It is unfortunate to hear that TLLT are a significant size increase, though not 
entirely surprising - it's a bunch of extra info to encode. I'll be glad to 
have this example to experiment with.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152708

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


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

2023-06-12 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D152246#4412333 , @aaronpuchert 
wrote:

> That's a tough one. The change seems to be correct, and makes more patterns 
> visible. Of course I wonder how it comes that we see calls of a function 
> pointer with a uniquely determined value, as that would seem like 
> obfuscation. Maybe you can show an example how this might look like in 
> practice?
>
> Another issue (that of course you can't know about) is that I'm not sure 
> about the `LocalVariableMap`. It's currently only used to find a try-acquire 
> function return value from a branch, not in the core analysis and can 
> apparently be quite expensive 
>  for long functions with 
> exception handling edges. I'd like to get rid of it, unless we decide to use 
> it for resolving aliases more widely. But I'm wary of alias analysis, because 
> we don't want to reimplement the static analyzer, and we also want to be more 
> predictable, maybe even provide correctness guarantees. Alias analysis ends 
> in undecidable territory quite early on, and using heuristics would sacrifice 
> predictability.

That's good to know, thank you for bringing this up! I agree that we likely 
don't want to do alias analysis. The way `CallExpr` implements 
`getCalleeDecl()` is to check whether the callee expression (after ignoring 
implicit casts and dereference operators) references a declaration of some kind 
(`DeclRefExpr`, `MemberExpr`, `BlockExpr`) and if so, report back the 
declaration found. So it does not do any sort of tricky dataflow analysis and 
only handles relatively simple cases like: `void func() {} void (*fp)() = func; 
fp();`

> The relatively strict "dumb" analysis that we're doing today seems to work 
> well enough for the purpose of tracking locks, though we can look through 
> local references. (Their pointee doesn't change. Though it doesn't always 
> work .) My hope would be 
> that we can leave it at that and don't build a fully-fledged alias analysis.
>
> I'd like if we could address the issue here by moving to type attributes. 
> These would of course be "sugar", i.e. dropped on canonicalization, as we 
> don't want them to affect overloading etc. But that would still allow more 
> than declaration attributes, like in this case, warning if we drop the 
> attribute on assignment. Of course that's big project though, and it's not 
> clear if it'll work out. The paper 
> 
>  by @delesley and @aaron.ballman briefly says that non-sugared attributes 
> would probably not work, and there is a talk 
>  where @delesley says something 
> along the lines of "we'd really like to integrate this into the type system, 
> but it would be quite difficult".

Yeah, I seem to recall this adding enough overhead to the type system for it to 
be problematic. I think we were lamenting that Clang doesn't have a pluggable 
type system and we'd love to see one added, but that's a big, experimental 
undertaking.


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

https://reviews.llvm.org/D152246

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


[PATCH] D152708: [RFC][Draft] Enable primitive support for Two-Level Line Tables in LLVM

2023-06-12 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

Are there any known (or vague/unknown) limitations on the implementation with 
respect to the actual output/on-disk representation? (like, would doing some 
kind of size analysis of the output when using this patch/feature lead to 
incorrect conclusions about the cost of the feature?)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152708

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


[PATCH] D152634: [Sema] Remove unused isNonTypeNestedNameSpecifier

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

LGTM, thank you for the cleanup!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152634

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


[PATCH] D142388: [clang] Add builtin_nondeterministic_value

2023-06-12 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added a comment.

https://reviews.llvm.org/D136737 used 'builtin_unspecified_value' which could 
be okay.

Are we sure we want to expose this intrinsic as it can be easily misused (as 
mentioned, as random generator) and/or cause security issues? Maybe only allow 
it in system headers (original motivation in https://reviews.llvm.org/D136737)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142388

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


[PATCH] D142388: [clang] Add builtin_nondeterministic_value

2023-06-12 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added inline comments.



Comment at: clang/docs/LanguageExtensions.rst:3087
+
+``__builtin_nondeterministic_value`` returns a valid nondeterministic value of 
the same type as the provided argument.
+

This text really sells this new builtin as a random value generator..


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142388

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


[PATCH] D152689: [NFC] Remove dead conditionals

2023-06-12 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/lib/CodeGen/CGObjCMac.cpp:3812
   llvm::GlobalVariable *GV;
-  if (ForClass)
-GV =

aaron.ballman wrote:
> I agree this is dead code (see line 3777-3778 above), but @rjmccall is it a 
> bug that we bail out with a null value (e.g, is the correct fix to remove the 
> above lines)?
No, I don't think this is a bug, and that would not be the right fix anyway.  
`ForClass` means we're building the metaclass, and subclasses do not introduce 
new ivars in the metaclass.  The comment is saying that GCC declares ivars for 
the class structure when emitting metaclasses for root classes, but if we 
haven't been doing that for 15 years, I don't see a reason to start.  Certainly 
the runtime doesn't require it in order to work.  So the patch as written looks 
good.

For what it's worth, this code is all but dead for more basic reasons. 
`CGObjCMac` is the legacy ObjC ABI, which is no longer used on any platform 
that's even vaguely supported by Apple.  The last platform we shipped using 
this ABI was i386 macOS; we haven't sold Macs that only supported i386 since 
2006, and we dropped the i386 userspace entirely in macOS Catalina (2019).  So 
the only reason for this code to exist is to allow people to either compile 
programs for very old hardware or intentionally use a 32-bit ABI on newer 
hardware running an old OS.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152689

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


[PATCH] D152279: [Driver] Default -msmall-data-limit= to 0

2023-06-12 Thread Aditya Kumar via Phabricator via cfe-commits
hiraditya added a comment.

In D152279#4406896 , @MaskRay wrote:

> In D152279#4405901 , @asb wrote:
>
>> One of the key things we've been discussing on this at the LLVM call is that 
>> we probably want to keep the small data limit for embedded targets.
>
> It'd be useful to hear from some concrete embedded target users, whether they 
> customize `-msmall-data-limit=`, whether they are happy with 
> `-msmall-data-limit=8`, or whether they are just unaware of this threshold.
>
> If an embedded system typically customizes compiler driver options a lot, I 
> think they can consider adding `-msmall-data-limit=` (with a value suitable 
> for their use cases) in a configuration file 
> , not 
> letting their use cases dictate Linux systems.
>
> I putting up the patch partly came from my stance finding UX of this option 
> is really confusing and misleading. I wish that the embedded target users can 
> give me compelling arguments to keep `-msmall-data-limit=8` (and not another 
> value).

The default of 8 is probably to make it consistent with gcc. Here is text from 
man gcc 

  -msmall-data
  -mlarge-data
  When -mexplicit-relocs is in effect, static data is accessed
  via gp-relative relocations.  When -msmall-data is used,
  objects 8 bytes long or smaller are placed in a small data
  area (the ".sdata" and ".sbss" sections) and are accessed via
  16-bit relocations off of the $gp register.  This limits the
  size of the small data area to 64KB, but allows the variables
  to be directly accessed via a single instruction.
  
  The default is -mlarge-data.  With this option the data area
  is limited to just below 2GB.  Programs that require more
  than 2GB of data must use "malloc" or "mmap" to allocate the
  data in the heap instead of in the program's data segment.
  
  When generating code for shared libraries, -fpic implies
  -msmall-data and -fPIC implies -mlarge-data.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152279

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


[PATCH] D152732: [clang][dataflow] Support limits on the SAT solver to force timeouts.

2023-06-12 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel created this revision.
ymandel added reviewers: kinu, xazax.hun, mboehme, sgatev.
Herald added a subscriber: martong.
Herald added a reviewer: NoQ.
Herald added a project: All.
ymandel requested review of this revision.
Herald added a project: clang.

This patch allows the client of a `WatchedLiteralsSolver` to specify a
computation limit on the use of the solver. After the limit is exhausted, the
SAT solver times out.

Fixes issues #60265.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152732

Files:
  clang/include/clang/Analysis/FlowSensitive/WatchedLiteralsSolver.h
  clang/lib/Analysis/FlowSensitive/WatchedLiteralsSolver.cpp
  clang/unittests/Analysis/FlowSensitive/SolverTest.cpp

Index: clang/unittests/Analysis/FlowSensitive/SolverTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/SolverTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/SolverTest.cpp
@@ -360,4 +360,22 @@
   expectUnsatisfiable(solve({XImplY, XAndNotY}));
 }
 
+TEST(SolverTest, LowTimeoutResultsInTimedOut) {
+  WatchedLiteralsSolver solver(10);
+  ConstraintContext Ctx;
+  auto X = Ctx.atom();
+  auto Y = Ctx.atom();
+  auto Z = Ctx.atom();
+  auto W = Ctx.atom();
+
+  // !(X v Y) <=> !X ^ !Y
+  auto A = Ctx.iff(Ctx.neg(Ctx.disj(X, Y)), Ctx.conj(Ctx.neg(X), Ctx.neg(Y)));
+
+  // !(Z ^ W) <=> !Z v !W
+  auto B = Ctx.iff(Ctx.neg(Ctx.conj(Z, W)), Ctx.disj(Ctx.neg(Z), Ctx.neg(W)));
+
+  // A ^ B
+  EXPECT_EQ(solver.solve({A, B}).getStatus(), Solver::Result::Status::TimedOut);
+}
+
 } // namespace
Index: clang/lib/Analysis/FlowSensitive/WatchedLiteralsSolver.cpp
===
--- clang/lib/Analysis/FlowSensitive/WatchedLiteralsSolver.cpp
+++ clang/lib/Analysis/FlowSensitive/WatchedLiteralsSolver.cpp
@@ -458,9 +458,15 @@
 }
   }
 
-  Solver::Result solve() && {
+  // Returns the `Result` and the number of iterations "remaining" from
+  // `MaxIterations` (that is, `MaxIterations` - iterations in this call).
+  std::pair solve(std::int64_t MaxIterations) && {
 size_t I = 0;
 while (I < ActiveVars.size()) {
+  if (MaxIterations == 0)
+return std::make_pair(Solver::Result::TimedOut(), 0);
+  --MaxIterations;
+
   // Assert that the following invariants hold:
   // 1. All active variables are unassigned.
   // 2. All active variables form watched literals.
@@ -487,7 +493,7 @@
 // If the root level is reached, then all possible assignments lead to
 // a conflict.
 if (Level == 0)
-  return Solver::Result::Unsatisfiable();
+  return std::make_pair(Solver::Result::Unsatisfiable(), MaxIterations);
 
 // Otherwise, take the other branch at the most recent level where a
 // decision was made.
@@ -544,7 +550,7 @@
 ++I;
   }
 }
-return Solver::Result::Satisfiable(buildSolution());
+return std::make_pair(Solver::Result::Satisfiable(buildSolution()), MaxIterations);
   }
 
 private:
@@ -713,8 +719,12 @@
 };
 
 Solver::Result WatchedLiteralsSolver::solve(llvm::DenseSet Vals) {
-  return Vals.empty() ? Solver::Result::Satisfiable({{}})
-  : WatchedLiteralsSolverImpl(Vals).solve();
+  if (Vals.empty())
+return Solver::Result::Satisfiable({{}});
+  auto [Res, Iterations] =
+  WatchedLiteralsSolverImpl(Vals).solve(MaxIterations);
+  MaxIterations = Iterations;
+  return Res;
 }
 
 } // namespace dataflow
Index: clang/include/clang/Analysis/FlowSensitive/WatchedLiteralsSolver.h
===
--- clang/include/clang/Analysis/FlowSensitive/WatchedLiteralsSolver.h
+++ clang/include/clang/Analysis/FlowSensitive/WatchedLiteralsSolver.h
@@ -17,6 +17,7 @@
 #include "clang/Analysis/FlowSensitive/Solver.h"
 #include "clang/Analysis/FlowSensitive/Value.h"
 #include "llvm/ADT/DenseSet.h"
+#include 
 
 namespace clang {
 namespace dataflow {
@@ -27,7 +28,24 @@
 /// single "watched" literal per clause, and uses a set of "active" variables
 /// for unit propagation.
 class WatchedLiteralsSolver : public Solver {
+  // Count of the iterations of the main loop of the solver. This spans *all*
+  // calls to the underlying solver across the life of this object. It is
+  // reduced with every (non-trivial) call to the solver.
+  //
+  // We give control over the abstract count of iterations instead of concrete
+  // measurements like CPU cycles or time to ensure deterministic results.
+  std::int64_t MaxIterations = std::numeric_limits::max();
+
 public:
+  WatchedLiteralsSolver() = default;
+
+  // `Work` specifies a computational limit on the solver. Units of "work"
+  // roughly correspond to attempts to assign a value to a single
+  // variable. Since the algorithm is exponential in the number of variables,
+  // this is the most direct (abstract) unit to target.
+  explicit WatchedLiteralsSolver(std::int64_t WorkLimit)
+  

[PATCH] D152734: [HIP] Fix HIP path detection

2023-06-12 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.
yaxunl added a reviewer: tra.
Herald added subscribers: kerbowa, jvesely.
Herald added a project: All.
yaxunl requested review of this revision.
Herald added a subscriber: MaskRay.

Fix two issues:

1. `--hip-path` should not do rigorous checking, i.e. if .hipVersion exists it 
will use it, otherwise it will not error out but assumes the default HIP 
version. This is to be consistent with --rocm-path behavior.

2. when HIP_PATH is empty, it should be ignored. This is to be consistent with 
ROCM_PATH behavior.


https://reviews.llvm.org/D152734

Files:
  clang/lib/Driver/ToolChains/AMDGPU.cpp
  clang/test/Driver/hip-version.hip
  clang/test/Driver/rocm-detect.hip

Index: clang/test/Driver/rocm-detect.hip
===
--- clang/test/Driver/rocm-detect.hip
+++ clang/test/Driver/rocm-detect.hip
@@ -32,11 +32,38 @@
 // RUN: rm -rf %t/myhip
 // RUN: mkdir -p %t/myhip
 // RUN: cp -r %S/Inputs/rocm/bin %t/myhip
+
+// Test HIP_PATH overrides ROCM_PATH.
 // RUN: env ROCM_PATH=%S/Inputs/rocm HIP_PATH=%t/myhip \
 // RUN:   %clang -### -target x86_64-linux-gnu --offload-arch=gfx1010 --hip-link \
 // RUN:   --print-rocm-search-dirs %s 2>&1 \
 // RUN:   | FileCheck -check-prefixes=ROCM-ENV,HIP-PATH %s
 
+// Test --hip-path overrides ROCM_PATH.
+// RUN: env ROCM_PATH=%S/Inputs/rocm \
+// RUN:   %clang -### -target x86_64-linux-gnu --offload-arch=gfx1010 --hip-link \
+// RUN:   --hip-path=%t/myhip \
+// RUN:   --print-rocm-search-dirs %s 2>&1 \
+// RUN:   | FileCheck -check-prefixes=ROCM-ENV,HIP-PATH %s
+
+// Test --hip-path overrides --rocm-path.
+// RUN: %clang -### -target x86_64-linux-gnu --offload-arch=gfx1010 --hip-link \
+// RUN:   --hip-path=%t/myhip --rocm-path=%S/Inputs/rocm \
+// RUN:   --print-rocm-search-dirs %s 2>&1 \
+// RUN:   | FileCheck -check-prefixes=ROCM-ENV,HIP-PATH %s
+
+// Test HIP_PATH overrides --rocm-path.
+// RUN: env HIP_PATH=%t/myhip %clang -### -target x86_64-linux-gnu --offload-arch=gfx1010 --hip-link \
+// RUN:   --rocm-path=%S/Inputs/rocm \
+// RUN:   --print-rocm-search-dirs %s 2>&1 \
+// RUN:   | FileCheck -check-prefixes=ROCM-ENV,HIP-PATH %s
+
+// Test empty HIP_PATH does not override --rocm-path.
+// RUN: env HIP_PATH= \
+// RUN:   %clang -### -target x86_64-linux-gnu --offload-arch=gfx1010 --hip-link \
+// RUN:   --rocm-path=%S/Inputs/rocm --print-rocm-search-dirs %s 2>&1 \
+// RUN:   | FileCheck -check-prefixes=ROCM-PATH %s
+
 // Test --hip-path option overrides environment variable HIP_PATH.
 
 // RUN: rm -rf %t/myhip
@@ -106,6 +133,11 @@
 // HIP-PATH: "-idirafter" "[[HIP_PATH:.*/myhip]]/include"
 // HIP-PATH: "-L[[HIP_PATH]]/lib" "-lamdhip64"
 
+// ROCM-PATH: ROCm installation search path: [[ROCM_PATH:.*/Inputs/rocm]]
+// ROCM-PATH: "-mlink-builtin-bitcode" "[[ROCM_PATH]]/amdgcn/bitcode/oclc_isa_version_1010.bc"
+// ROCM-PATH: "-idirafter" "[[ROCM_PATH]]/include"
+// ROCM-PATH: "-L[[ROCM_PATH]]/lib" "-lamdhip64"
+
 // ROCM-REL: ROCm installation search path: {{.*}}/opt/rocm
 // ROCM-REL: ROCm installation search path: {{.*}}/opt/rocm-3.10.0
 
Index: clang/test/Driver/hip-version.hip
===
--- clang/test/Driver/hip-version.hip
+++ clang/test/Driver/hip-version.hip
@@ -5,10 +5,19 @@
 // RUN: %clang -v --rocm-path=%S/Inputs/rocm 2>&1 \
 // RUN:   | FileCheck -check-prefixes=FOUND %s
 
+// RUN: env ROCM_PATH=%S/Inputs/rocm %clang -v 2>&1 \
+// RUN:   | FileCheck -check-prefixes=FOUND %s
+
 // RUN: %clang -v --rocm-path=%S/Inputs/rocm 2>&1 \
 // RUN:   --target=amdgcn-amd-amdhsa \
 // RUN:   | FileCheck -check-prefixes=FOUND %s
 
+// RUN: %clang -v --hip-path=%S/Inputs/rocm 2>&1 \
+// RUN:   | FileCheck -check-prefixes=FOUND %s
+
+// RUN: env HIP_PATH=%S/Inputs/rocm %clang -v 2>&1 \
+// RUN:   | FileCheck -check-prefixes=FOUND %s
+
 // RUN: rm -rf %t/Inputs
 // RUN: mkdir -p %t/Inputs
 // RUN: cp -r %S/Inputs/rocm %t/Inputs
@@ -24,6 +33,11 @@
 // RUN: %clang -v --rocm-path=%S 2>&1 \
 // RUN:   | FileCheck -check-prefixes=DEFAULT %s
 
+// When --hip-path is set and .hipVersion is not found, use default version
+
+// RUN: %clang -v --hip-path=%S 2>&1 \
+// RUN:   | FileCheck -check-prefixes=DEFAULT %s
+
 // RUN: %clang -v --rocm-path=%S 2>&1 \
 // RUN:   --target=amdgcn-amd-amdhsa \
 // RUN:   | FileCheck -check-prefixes=DEFAULT %s
Index: clang/lib/Driver/ToolChains/AMDGPU.cpp
===
--- clang/lib/Driver/ToolChains/AMDGPU.cpp
+++ clang/lib/Driver/ToolChains/AMDGPU.cpp
@@ -432,12 +432,13 @@
 void RocmInstallationDetector::detectHIPRuntime() {
   SmallVector HIPSearchDirs;
   if (!HIPPathArg.empty())
-HIPSearchDirs.emplace_back(HIPPathArg.str(), /*StrictChecking=*/true);
+HIPSearchDirs.emplace_back(HIPPathArg.str());
   else if (std::optional HIPPathEnv =
llvm::sys::Process::GetEnv("HIP_PATH")) {
 if (!HIPPathEnv->empty())
   HIPSearchDirs.emplace_back(st

[PATCH] D152054: [OpenMP] Codegen support for thread_limit on target directive

2023-06-12 Thread Sandeep via Phabricator via cfe-commits
sandeepkosuri updated this revision to Diff 530591.
sandeepkosuri added a comment.

Updated `target_codegen.cpp` test case to incorporate my changes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152054

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.h
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/test/OpenMP/target_codegen.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
  openmp/runtime/src/kmp.h
  openmp/runtime/src/kmp_csupport.cpp
  openmp/runtime/src/kmp_ftn_entry.h
  openmp/runtime/src/kmp_global.cpp
  openmp/runtime/src/kmp_runtime.cpp
  openmp/runtime/test/target/target_thread_limit.cpp

Index: openmp/runtime/test/target/target_thread_limit.cpp
===
--- /dev/null
+++ openmp/runtime/test/target/target_thread_limit.cpp
@@ -0,0 +1,81 @@
+// RUN: %libomp-cxx-compile -fopenmp-version=51
+// RUN: %libomp-run | FileCheck %s --check-prefix OMP51
+
+#include 
+#include 
+
+void foo() {
+#pragma omp parallel num_threads(10)
+  { printf("\ntarget: foo(): parallel num_threads(10)"); }
+}
+
+int main(void) {
+
+  int tl = 4;
+  printf("\nmain: thread_limit = %d", omp_get_thread_limit());
+  // OMP51: main: thread_limit = {{[0-9]+}}
+
+#pragma omp target thread_limit(tl)
+  {
+printf("\ntarget: thread_limit = %d", omp_get_thread_limit());
+// OMP51: target: thread_limit = 4
+// check whether thread_limit is honoured
+#pragma omp parallel
+{ printf("\ntarget: parallel"); }
+// OMP51: target: parallel
+// OMP51: target: parallel
+// OMP51: target: parallel
+// OMP51: target: parallel
+
+// check whether num_threads is honoured
+#pragma omp parallel num_threads(2)
+{ printf("\ntarget: parallel num_threads(2)"); }
+// OMP51: target: parallel num_threads(2)
+// OMP51: target: parallel num_threads(2)
+
+// check whether thread_limit is honoured when there is a conflicting
+// num_threads
+#pragma omp parallel num_threads(10)
+{ printf("\ntarget: parallel num_threads(10)"); }
+// OMP51: target: parallel num_threads(10)
+// OMP51: target: parallel num_threads(10)
+// OMP51: target: parallel num_threads(10)
+// OMP51: target: parallel num_threads(10)
+
+// check whether threads are limited across functions
+foo();
+// OMP51: target: foo(): parallel num_threads(10)
+// OMP51: target: foo(): parallel num_threads(10)
+// OMP51: target: foo(): parallel num_threads(10)
+// OMP51: target: foo(): parallel num_threads(10)
+  }
+
+// checking consecutive target regions with different thread_limits
+#pragma omp target thread_limit(3)
+  {
+printf("\nsecond target: thread_limit = %d", omp_get_thread_limit());
+// OMP51: second target: thread_limit = 3
+#pragma omp parallel
+{ printf("\nsecond target: parallel"); }
+// OMP51: second target: parallel
+// OMP51: second target: parallel
+// OMP51: second target: parallel
+  }
+
+// confirm that thread_limit's effects are limited to target region
+  printf("\nmain: thread_limit = %d", omp_get_thread_limit());
+// OMP51: main: thread_limit = {{[0-9]+}}
+#pragma omp parallel num_threads(10)
+  { printf("\nmain: parallel num_threads(10)"); }
+  // OMP51: main: parallel num_threads(10)
+  // OMP51: main: parallel num_threads(10)
+  // OMP51: main: parallel num_threads(10)
+  // OMP51: main: parallel num_threads(10)
+  // OMP51: main: parallel num_threads(10)
+  // OMP51: main: parallel num_threads(10)
+  // OMP51: main: parallel num_threads(10)
+  // OMP51: main: parallel num_threads(10)
+  // OMP51: main: parallel num_threads(10)
+  // OMP51: main: parallel num_threads(10)
+  return 0;
+}
Index: openmp/runtime/src/kmp_runtime.cpp
===
--- openmp/runtime/src/kmp_runtime.cpp
+++ openmp/runtime/src/kmp_runtime.cpp
@@ -1867,6 +1867,7 @@
   int nthreads;
   int master_active;
   int master_set_numthreads;
+  int task_thread_limit = 0;
   int level;
   int active_level;
   int teams_level;
@@ -1905,6 +1906,8 @@
 root = master_th->th.th_root;
 master_active = root->r.r_active;
 master_set_numthreads = master_th->th.th_set_nproc;
+task_thread_limit =
+master_th->th.th_current_task->td_icvs.task_thread_limit;
 
 #if OMPT_SUPPORT
 ompt_data_t ompt_parallel_data = ompt_data_none;
@@ -1995,6 +1998,11 @@
  ? master_set_numthreads
  // TODO: get nproc directly from current task
  : get__nproc_2(parent_team, master_tid);
+  // Use the thread_limit set for the current target task if exists, else go
+  // with the deduced nthreads
+  nthreads = task_thread_limit > 0 && task_thread_limit < nthreads
+ ? task_thread_limit
+ : nthreads;
   // Check if we need to take forkjoin lock? (no need for serialized
   // parallel out of teams construct

[PATCH] D152732: [clang][dataflow] Support limits on the SAT solver to force timeouts.

2023-06-12 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun accepted this revision.
xazax.hun added a comment.
This revision is now accepted and ready to land.

Huge +1, I think most solvers need to have some resource limits in place as the 
runtime can explode. I am just not 100% what is the best approach here, putting 
a global limit on the solver instance vs having a limit per query. Any thoughts 
on that?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152732

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


[PATCH] D146557: [MLIR][OpenMP] Refactoring createTargetData in OMPIRBuilder

2023-06-12 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added inline comments.



Comment at: llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h:1487
+  // possible, or else at the end of the function.
+  void emitBlock(BasicBlock *BB, Function *CurFn, bool IsFinished = false);
+

This does not mention the deletion stuff, etc.



Comment at: llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h:2009
 
+  enum BodyGenTy { Priv, DupNoPriv, NoPriv };
+

documentation, what do they mean



Comment at: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp:4155
+Constant *SrcLocStr = getOrCreateSrcLocStr(Loc, SrcLocStrSize);
+Value *srcLocInfo = getOrCreateIdent(SrcLocStr, SrcLocStrSize);
+

Style, also elsewhere.



Comment at: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp:4741
+  if (IsFinished && BB->use_empty()) {
+delete BB;
+return;

you should not just delete BB. eraseFromParent is a better way. That said, it 
is also weird you would delete something in an "emit" function.



Comment at: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp:4758-4760
+  if (isa(Cond)) {
+bool CondConstant =
+cast(Cond)->getUniqueInteger().getSExtValue();





Comment at: 
mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp:1357-1362
+int64_t getSizeInBytes(DataLayout &DL, const mlir::Type &type) {
+  if (isa(type))
+return DL.getTypeSize(cast(type).getElementType());
+
+  return -1;
+}

TIFitis wrote:
> @jdoerfert Is this way of getting the size correct? It seems to work for 
> basic types and arrays which is what we support for now.
I don't know about mlir, if the DL has a "store size" use that.
That said, the size should potentially come from the user/front-end.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146557

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


[PATCH] D152732: [clang][dataflow] Support limits on the SAT solver to force timeouts.

2023-06-12 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel added a comment.

In D152732#4414661 , @xazax.hun wrote:

> Huge +1, I think most solvers need to have some resource limits in place as 
> the runtime can explode. I am just not 100% what is the best approach here, 
> putting a global limit on the solver instance vs having a limit per query. 
> Any thoughts on that?

Excellent question. Ultimately what matters for a user is the global limit. So, 
in that sense, a global limit makes sense. But, it also makes it harder (in 
principle) to pinpoint the problem, because you could have it timeout on a 
small query right after a large query that was actually responsible for 
consuming the resources. That said, I'm guessing in practice it's binary, 
because of the exponential: either a single call exhausts all resources or it 
barely uses them. I suspect we'll ~never hit the case I described. So, I'm 
inclined to start global (to keep it simple) and then refine if necessary. As 
you probably noticed, this patch actually has both -- the user specifies the 
global limit, but the implementation is local. So, changing this would be easy.

That said, I should note that it's not global for a TU - just for a function, 
at least given the way we currently implement our clang-tidy checks. So, that 
seems a reasonable compromise.

WDYT?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152732

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


[PATCH] D152732: [clang][dataflow] Support limits on the SAT solver to force timeouts.

2023-06-12 Thread Kinuko Yasuda via Phabricator via cfe-commits
kinu added a comment.

LGTM as well, I was initially thinking about having a local limit per query 
(which could be easier to pinpoint the particular query that explodes), but 
per-solver instance limit could make sense as a starter too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152732

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


[PATCH] D152072: [4/11][Clang][RISCV] Expand all variants for unit stride segment store

2023-06-12 Thread Craig Topper via Phabricator via cfe-commits
craig.topper accepted this revision.
craig.topper added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152072

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


[PATCH] D152732: [clang][dataflow] Support limits on the SAT solver to force timeouts.

2023-06-12 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment.

In D152732#4414707 , @ymandel wrote:

> Ultimately what matters for a user is the global limit.

I am not 100% sure about that. While it is true that the user cares about the 
process not hanging, but global vs local limits can have observable effects on 
the analysis results. With a global limit, after a query exhausted all the 
budget, for all intents and purposes we continue the analysis without a solver 
for the rest of the function and all queries would just time out, even the 
simple ones. With a local limit, the solver might time out for a couple of 
queries, but we keep the precision for the simple queries. That being said, it 
is possible that the scenario where we have a few big queries that blows the 
solver up but the rest of them are simple just does not happen that much. Also, 
a local timeout produces less reliable worst case runtime results. This makes 
me think it might be possible that we want both, but this decision is probably 
better made when we have some evidence that we actually need both. So, I am ok 
with committing this as is for now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152732

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


  1   2   >