[PATCH] D147422: [clang-format] NFC Document the other space before colon option

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

In D147422#4242115 , @sstwcw wrote:

> It looks like a line break gets inserted in arrays.  Does that mean the 
> option doesn't affect arrays?

It matters only if `BreakArrays` is set to false.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147422

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


[PATCH] D147422: [clang-format] NFC Document the other space before colon option

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

In D147422#4240024 , @MyDeveloperDay 
wrote:

> In D147422#4240021 , @owenpan wrote:
>
>> Should we extend `SpacesInContainerLiterals` so that it controls JSON colons 
>> too? If yes, then we don't need `SpaceBeforeJsonColon`. Otherwise, IMO we 
>> should leave the doc alone.
>
> My concern for `SpacesInContainerLiterals` is that it impacts arrays contents 
> too '[ 1, 2, 3 ]'.

It already affects JSON arrays if `BreakArrays` is set to false:

  $ cat foo.json
  [1, 2, 3]
  $ clang-format -style='{BreakArrays: false}' foo.json
  [ 1, 2, 3 ]


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147422

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


[PATCH] D141215: [clang-repl] Introduce Value to capture expression results

2023-04-04 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev added inline comments.



Comment at: clang/include/clang/Sema/Sema.h:2211
 
+  std::optional> 
ValuePrintingTransformer;
+

Instead of doing this, we could implement an ASTConsumer which the Interpreter 
can attach to Sema and listen for `HandleTopLevelDecl`. If we encounter a 
`TopLevelStmtDecl` we add our facilities and pass it to CodeGen.



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:7226
+  // assert(DeferredDeclsToEmit.empty() &&
+  //"Should have emitted all decls deferred to emit.");
   assert(NewBuilder->DeferredDecls.empty() &&

That should probably be a separate review with a testcase.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141215

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


[PATCH] D143128: [-Wunsafe-buffer-usage] Fix-Its transforming `[any]` to `()[any]`

2023-04-04 Thread Eric Gullufsen via Phabricator via cfe-commits
emgullufsen added a comment.

Just a heads up it seems like a lot of premerge checks builds are now showing 
this test as failing on Windows x64:

  
  Failed Tests (1):
Clang :: 
SemaCXX/warn-unsafe-buffer-usage-fixits-addressof-arraysubscript.cpp

Here are some links from buildkite for a few of the builds that failed on this 
test:
https://buildkite.com/llvm-project/premerge-checks/builds/145054 

https://buildkite.com/llvm-project/premerge-checks/builds/145048 

https://buildkite.com/llvm-project/premerge-checks/builds/145044 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143128

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


[PATCH] D147525: [X86] Add AMX_COMPLEX to Graniterapids

2023-04-04 Thread Xiang Zhang via Phabricator via cfe-commits
xiangzhangllvm accepted this revision.
xiangzhangllvm added a comment.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147525

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


[PATCH] D147551: [clang-tidy] Fix init-list handling in readability-implicit-bool-conversion

2023-04-04 Thread Chris Cotter via Phabricator via cfe-commits
ccotter accepted this revision.
ccotter 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/D147551/new/

https://reviews.llvm.org/D147551

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


[clang] e5144d9 - Fix a few clang-tidy warnings (container empty checks, function decl/def param naming)

2023-04-04 Thread David Blaikie via cfe-commits

Author: David Blaikie
Date: 2023-04-05T01:06:41Z
New Revision: e5144d9d2dd26a67f576d2f5772b3cf0486245f4

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

LOG: Fix a few clang-tidy warnings (container empty checks, function decl/def 
param naming)

Added: 


Modified: 
clang/lib/Basic/Targets/X86.h
clang/lib/Sema/SemaChecking.cpp
llvm/lib/Target/X86/X86ExpandPseudo.cpp
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/lib/Target/X86/X86LowerAMXType.cpp

Removed: 




diff  --git a/clang/lib/Basic/Targets/X86.h b/clang/lib/Basic/Targets/X86.h
index 9a563db496dcd..6cefda7fa49f6 100644
--- a/clang/lib/Basic/Targets/X86.h
+++ b/clang/lib/Basic/Targets/X86.h
@@ -206,9 +206,9 @@ class LLVM_LIBRARY_VISIBILITY X86TargetInfo : public 
TargetInfo {
 return RegName.equals("esp") || RegName.equals("rsp");
   }
 
-  bool validateCpuSupports(StringRef Name) const override;
+  bool validateCpuSupports(StringRef FeatureStr) const override;
 
-  bool validateCpuIs(StringRef Name) const override;
+  bool validateCpuIs(StringRef FeatureStr) const override;
 
   bool validateCPUSpecificCPUDispatch(StringRef Name) const override;
 

diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index af67552cba39b..16f29be4947fb 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -4594,7 +4594,7 @@ bool Sema::CheckRISCVBuiltinFunctionCall(const TargetInfo 
,
 std::string FeatureStr = OF.str();
 FeatureStr[0] = std::toupper(FeatureStr[0]);
 // Combine strings.
-FeatureStrs += FeatureStrs == "" ? "" : ", ";
+FeatureStrs += FeatureStrs.empty() ? "" : ", ";
 FeatureStrs += "'";
 FeatureStrs += FeatureStr;
 FeatureStrs += "'";
@@ -9506,13 +9506,13 @@ void CheckFormatHandler::HandlePosition(const char 
*startPos,
getSpecifierRange(startPos, posLen));
 }
 
-void
-CheckFormatHandler::HandleInvalidPosition(const char *startPos, unsigned 
posLen,
- analyze_format_string::PositionContext p) 
{
-  EmitFormatDiagnostic(S.PDiag(diag::warn_format_invalid_positional_specifier)
- << (unsigned) p,
-   getLocationOfByte(startPos), /*IsStringLocation*/true,
-   getSpecifierRange(startPos, posLen));
+void CheckFormatHandler::HandleInvalidPosition(
+const char *startSpecifier, unsigned specifierLen,
+analyze_format_string::PositionContext p) {
+  EmitFormatDiagnostic(
+  S.PDiag(diag::warn_format_invalid_positional_specifier) << (unsigned)p,
+  getLocationOfByte(startSpecifier), /*IsStringLocation*/ true,
+  getSpecifierRange(startSpecifier, specifierLen));
 }
 
 void CheckFormatHandler::HandleZeroPosition(const char *startPos,
@@ -9557,7 +9557,7 @@ void CheckFormatHandler::DoneProcessing() {
 
 void UncoveredArgHandler::Diagnose(Sema , bool IsFunctionCall,
const Expr *ArgExpr) {
-  assert(hasUncoveredArg() && DiagnosticExprs.size() > 0 &&
+  assert(hasUncoveredArg() && !DiagnosticExprs.empty() &&
  "Invalid state");
 
   if (!ArgExpr)
@@ -16620,14 +16620,13 @@ static bool findRetainCycleOwner(Sema , Expr *e, 
RetainCycleOwner ) {
 namespace {
 
   struct FindCaptureVisitor : EvaluatedExprVisitor {
-ASTContext 
 VarDecl *Variable;
 Expr *Capturer = nullptr;
 bool VarWillBeReased = false;
 
 FindCaptureVisitor(ASTContext , VarDecl *variable)
 : EvaluatedExprVisitor(Context),
-  Context(Context), Variable(variable) {}
+  Variable(variable) {}
 
 void VisitDeclRefExpr(DeclRefExpr *ref) {
   if (ref->getDecl() == Variable && !Capturer)

diff  --git a/llvm/lib/Target/X86/X86ExpandPseudo.cpp 
b/llvm/lib/Target/X86/X86ExpandPseudo.cpp
index 21ad08fb5f0af..085fa9280b0ea 100644
--- a/llvm/lib/Target/X86/X86ExpandPseudo.cpp
+++ b/llvm/lib/Target/X86/X86ExpandPseudo.cpp
@@ -49,7 +49,7 @@ class X86ExpandPseudo : public MachineFunctionPass {
   const X86MachineFunctionInfo *X86FI = nullptr;
   const X86FrameLowering *X86FL = nullptr;
 
-  bool runOnMachineFunction(MachineFunction ) override;
+  bool runOnMachineFunction(MachineFunction ) override;
 
   MachineFunctionProperties getRequiredProperties() const override {
 return MachineFunctionProperties().set(
@@ -77,7 +77,7 @@ class X86ExpandPseudo : public MachineFunctionPass {
   /// placed into separate block guarded by check for al register(for SystemV
   /// abi).
   void ExpandVastartSaveXmmRegs(
-  MachineBasicBlock *MBB,
+  MachineBasicBlock *EntryBlk,
   MachineBasicBlock::iterator VAStartPseudoInstr) const;
 };
 char X86ExpandPseudo::ID = 0;

diff  --git 

[PATCH] D146399: [AIX][Clang][K] Create `-K` Option for AIX.

2023-04-04 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added a comment.

In D146399#4244479 , @francii wrote:

> Do we need a test case for the diagnostic? If we are only supporting one 
> target, which triple would be used for the test?

I think we do need a test case for the diagnostic. I suspect it should be in a 
separate file.
Unlike a lot of the options work we did for AIX, this is adding a new option 
(not processing an existing one).
I suggest `powerpc64-unknown-linux-gnu` for the triple.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146399

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


[PATCH] D147579: [nvptx-arch] Dynamically load `libcuda.so.1` directly instead

2023-04-04 Thread Joseph Huber via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGad6a7d7dc9a2: [nvptx-arch] Dynamically load `libcuda.so.1` 
directly instead (authored by jhuber6).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147579

Files:
  clang/tools/nvptx-arch/NVPTXArch.cpp


Index: clang/tools/nvptx-arch/NVPTXArch.cpp
===
--- clang/tools/nvptx-arch/NVPTXArch.cpp
+++ clang/tools/nvptx-arch/NVPTXArch.cpp
@@ -49,7 +49,7 @@
 CUresult (*cuDeviceGet)(CUdevice *, int);
 CUresult (*cuDeviceGetAttribute)(int *, CUdevice_attribute, CUdevice);
 
-constexpr const char *DynamicCudaPath = "libcuda.so";
+constexpr const char *DynamicCudaPath = "libcuda.so.1";
 
 llvm::Error loadCUDA() {
   std::string ErrMsg;


Index: clang/tools/nvptx-arch/NVPTXArch.cpp
===
--- clang/tools/nvptx-arch/NVPTXArch.cpp
+++ clang/tools/nvptx-arch/NVPTXArch.cpp
@@ -49,7 +49,7 @@
 CUresult (*cuDeviceGet)(CUdevice *, int);
 CUresult (*cuDeviceGetAttribute)(int *, CUdevice_attribute, CUdevice);
 
-constexpr const char *DynamicCudaPath = "libcuda.so";
+constexpr const char *DynamicCudaPath = "libcuda.so.1";
 
 llvm::Error loadCUDA() {
   std::string ErrMsg;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] ad6a7d7 - [nvptx-arch] Dynamically load `libcuda.so.1` directly instead

2023-04-04 Thread Joseph Huber via cfe-commits

Author: Joseph Huber
Date: 2023-04-04T19:50:31-05:00
New Revision: ad6a7d7dc9a2055ac3a4658d90ec86d78c3199b5

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

LOG: [nvptx-arch] Dynamically load `libcuda.so.1` directly instead

This patch loads the CUDA driver library directly via its real
`DT_SONAME`. This prevents the filesystem from needing to reload it in
cases when it's already loaded.

Reviewed By: tra

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

Added: 


Modified: 
clang/tools/nvptx-arch/NVPTXArch.cpp

Removed: 




diff  --git a/clang/tools/nvptx-arch/NVPTXArch.cpp 
b/clang/tools/nvptx-arch/NVPTXArch.cpp
index 4cfc58681cba3..b053fcc6e0bdd 100644
--- a/clang/tools/nvptx-arch/NVPTXArch.cpp
+++ b/clang/tools/nvptx-arch/NVPTXArch.cpp
@@ -49,7 +49,7 @@ CUresult (*cuGetErrorString)(CUresult, const char **);
 CUresult (*cuDeviceGet)(CUdevice *, int);
 CUresult (*cuDeviceGetAttribute)(int *, CUdevice_attribute, CUdevice);
 
-constexpr const char *DynamicCudaPath = "libcuda.so";
+constexpr const char *DynamicCudaPath = "libcuda.so.1";
 
 llvm::Error loadCUDA() {
   std::string ErrMsg;



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


[PATCH] D146897: [clang:diagnostics] Turning off warn_self_assignment_overloaded for user-defined compound assignments

2023-04-04 Thread Xiang Li via Phabricator via cfe-commits
python3kgae updated this revision to Diff 510976.
python3kgae added a comment.

skip warning on field for compound assignment when isImplicitCXXThis matches.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146897

Files:
  clang/lib/Sema/SemaExpr.cpp
  clang/test/SemaCXX/warn-self-assign-field-overloaded.cpp
  clang/test/SemaCXX/warn-self-assign-overloaded.cpp

Index: clang/test/SemaCXX/warn-self-assign-overloaded.cpp
===
--- clang/test/SemaCXX/warn-self-assign-overloaded.cpp
+++ clang/test/SemaCXX/warn-self-assign-overloaded.cpp
@@ -53,15 +53,15 @@
 
 #ifndef DUMMY
   a *= a;
-  a /= a; // expected-warning {{explicitly assigning}}
-  a %= a; // expected-warning {{explicitly assigning}}
+  a /= a;
+  a %= a;
   a += a;
-  a -= a; // expected-warning {{explicitly assigning}}
+  a -= a;
   a <<= a;
   a >>= a;
-  a &= a; // expected-warning {{explicitly assigning}}
-  a |= a; // expected-warning {{explicitly assigning}}
-  a ^= a; // expected-warning {{explicitly assigning}}
+  a &= a;
+  a |= a;
+  a ^= a;
 #endif
 }
 
Index: clang/test/SemaCXX/warn-self-assign-field-overloaded.cpp
===
--- clang/test/SemaCXX/warn-self-assign-field-overloaded.cpp
+++ clang/test/SemaCXX/warn-self-assign-field-overloaded.cpp
@@ -58,15 +58,49 @@
 
 #ifndef DUMMY
 a *= a;
-a /= a; // expected-warning {{assigning field to itself}}
-a %= a; // expected-warning {{assigning field to itself}}
+a /= a;
+a %= a;
 a += a;
-a -= a; // expected-warning {{assigning field to itself}}
+a -= a;
 a <<= a;
 a >>= a;
-a &= a; // expected-warning {{assigning field to itself}}
-a |= a; // expected-warning {{assigning field to itself}}
-a ^= a; // expected-warning {{assigning field to itself}}
+a &= a;
+a |= a;
+a ^= a;
+
+this->a *= a;
+this->a /= a; // expected-warning {{assigning field to itself}}
+this->a %= a; // expected-warning {{assigning field to itself}}
+this->a += a;
+this->a -= a; // expected-warning {{assigning field to itself}}
+this->a <<= a;
+this->a >>= a;
+this->a &= a; // expected-warning {{assigning field to itself}}
+this->a |= a; // expected-warning {{assigning field to itself}}
+this->a ^= a; // expected-warning {{assigning field to itself}}
+
+a *= this->a;
+a /= this->a; // expected-warning {{assigning field to itself}}
+a %= this->a; // expected-warning {{assigning field to itself}}
+a += this->a;
+a -= this->a; // expected-warning {{assigning field to itself}}
+a <<= this->a;
+a >>= this->a;
+a &= this->a; // expected-warning {{assigning field to itself}}
+a |= this->a; // expected-warning {{assigning field to itself}}
+a ^= this->a; // expected-warning {{assigning field to itself}}
+
+this->a *= this->a;
+this->a /= this->a;
+this->a %= this->a;
+this->a += this->a;
+this->a -= this->a;
+this->a <<= this->a;
+this->a >>= this->a;
+this->a &= this->a;
+this->a |= this->a;
+this->a ^= this->a;
+
 #endif
   }
 
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -14099,7 +14099,7 @@
 }
 
 static void CheckIdentityFieldAssignment(Expr *LHSExpr, Expr *RHSExpr,
- SourceLocation Loc,
+ bool IsCompound, SourceLocation Loc,
  Sema ) {
   if (Sema.inTemplateInstantiation())
 return;
@@ -14116,6 +14116,10 @@
   if (ML && MR) {
 if (!(isa(ML->getBase()) && isa(MR->getBase(
   return;
+// For compound case, only warning on this->x -= x or x -= this->x.
+if (IsCompound && ML->getBase()->isImplicitCXXThis() ==
+  MR->getBase()->isImplicitCXXThis())
+  return;
 const ValueDecl *LHSDecl =
 cast(ML->getMemberDecl()->getCanonicalDecl());
 const ValueDecl *RHSDecl =
@@ -14127,7 +14131,7 @@
 if (const ReferenceType *RefTy = LHSDecl->getType()->getAs())
   if (RefTy->getPointeeType().isVolatileQualified())
 return;
-
+
 Sema.Diag(Loc, diag::warn_identity_field_assign) << 0;
   }
 
@@ -14171,7 +14175,8 @@
   if (CompoundType.isNull()) {
 Expr *RHSCheck = RHS.get();
 
-CheckIdentityFieldAssignment(LHSExpr, RHSCheck, Loc, *this);
+CheckIdentityFieldAssignment(LHSExpr, RHSCheck, /*IsCompound*/ false, Loc,
+ *this);
 
 QualType LHSTy(LHSType);
 ConvTy = CheckSingleAssignmentConstraints(LHSTy, RHS);
@@ -15644,14 +15649,17 @@
Expr *LHS, Expr *RHS) {
   switch (Opc) {
   case BO_Assign:
+// Skip diagnose on compound assignment.
+

[PATCH] D146242: [ARM] Fixing ABI mismatch for packed structs and fields

2023-04-04 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:2118
+  if (Packed)
+UnadjustedAlignment = std::max(UnadjustedAlignment, UnpackedFieldAlign);
   UpdateAlignment(FieldAlign, UnpackedFieldAlign, PreferredAlign);

I've always felt the data flow in this function was excessively convoluted.  
Let's puzzle it out to figure out what's going on.  Ignoring the AIX stuff 
which I assume can't coincide with AArch64, we've got:

```
UnpackedFieldAlign = min(max(TyAlign, MaxAlignmentInChars), MaxFieldAlignment)
PackedFieldAlign = min(max(1, MaxAlignmentInChars), MaxFieldAlignment)
FieldAlign = FieldPacked ? PackedFieldAlign : UnpackedFieldAlign
```

where `MaxAlignmentInChars` is the highest value of all the alignment 
attributes on the field and `MaxFieldAlignment` is the value of `#pragma pack` 
that was active at the time of the struct definition.

Note that this gives us `PackedFieldAlign <= FieldAlign <= UnpackedFieldAlign`.

So:
1. I think it's wrong to be checking `Packed` instead of `FieldPacked` here.  
But:
2. If `FieldPacked`, then because `UnpackedFieldAlign >= FieldAlign`, the net 
effect of these three lines is `UnadjustedAlignment = 
std::max(UnadjustedAlignment, UnpackedFieldAlign)`.
3. If `!FieldPacked`, then `UnpackedFieldAlign == FieldAlign`, so the net 
effect of these three lines is *also* `UnadjustedAlignment = 
std::max(UnadjustedAlignment, UnpackedFieldAlign)`.
4. So actually you don't need to check `FieldPacked` at all; you should remove 
the old line and just do your new one unconditionally.

Also, AAPCS64 seems to define UnadjustedAlignment as the "natural alignment", 
and there's a doc comment saying it's the max of the type alignments.  That 
makes me wonder if we should really be considering either the `aligned` 
attribute or `#pragma pack` in this computation at all; maybe we should just be 
looking at the type alignment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146242

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


[PATCH] D147209: [clang][lit] Make LIT aware of env CLANG_CRASH_DIAGNOSTICS_DIR.

2023-04-04 Thread Michael Platings via Phabricator via cfe-commits
michaelplatings added a comment.

It looks like the failing tests already go to some effort to set each of TMP, 
TEMP & TMPDIR so perhaps they should be simplified to just set 
CLANG_CRASH_DIAGNOSTICS_DIR instead.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147209

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


[PATCH] D147580: [Clang] Refactor "Designators" to be more similar [NFC]

2023-04-04 Thread Bill Wendling via Phabricator via cfe-commits
void created this revision.
void added reviewers: aaron.ballman, rjmccall, rsmith, dblaikie, shafik.
Herald added a subscriber: martong.
Herald added a project: All.
void requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This makes the two interfaces for designators more similar so that it's
easier to merge them together in a future refactoring.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D147580

Files:
  clang/include/clang/AST/Expr.h
  clang/include/clang/Sema/Designator.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/Expr.cpp
  clang/lib/AST/StmtPrinter.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/Parse/ParseInit.cpp
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp

Index: clang/lib/Serialization/ASTWriterStmt.cpp
===
--- clang/lib/Serialization/ASTWriterStmt.cpp
+++ clang/lib/Serialization/ASTWriterStmt.cpp
@@ -1098,13 +1098,13 @@
   Record.AddSourceLocation(D.getFieldLoc());
 } else if (D.isArrayDesignator()) {
   Record.push_back(serialization::DESIG_ARRAY);
-  Record.push_back(D.getFirstExprIndex());
+  Record.push_back(D.getArrayIndex());
   Record.AddSourceLocation(D.getLBracketLoc());
   Record.AddSourceLocation(D.getRBracketLoc());
 } else {
   assert(D.isArrayRangeDesignator() && "Unknown designator");
   Record.push_back(serialization::DESIG_ARRAY_RANGE);
-  Record.push_back(D.getFirstExprIndex());
+  Record.push_back(D.getArrayIndex());
   Record.AddSourceLocation(D.getLBracketLoc());
   Record.AddSourceLocation(D.getEllipsisLoc());
   Record.AddSourceLocation(D.getRBracketLoc());
Index: clang/lib/Serialization/ASTReaderStmt.cpp
===
--- clang/lib/Serialization/ASTReaderStmt.cpp
+++ clang/lib/Serialization/ASTReaderStmt.cpp
@@ -1216,8 +1216,8 @@
   auto *Field = readDeclAs();
   SourceLocation DotLoc = readSourceLocation();
   SourceLocation FieldLoc = readSourceLocation();
-  Designators.push_back(Designator(Field->getIdentifier(), DotLoc,
-   FieldLoc));
+  Designators.push_back(Designator::CreateFieldDesignator(
+  Field->getIdentifier(), DotLoc, FieldLoc));
   Designators.back().setField(Field);
   break;
 }
@@ -1226,7 +1226,8 @@
   const IdentifierInfo *Name = Record.readIdentifier();
   SourceLocation DotLoc = readSourceLocation();
   SourceLocation FieldLoc = readSourceLocation();
-  Designators.push_back(Designator(Name, DotLoc, FieldLoc));
+  Designators.push_back(Designator::CreateFieldDesignator(Name, DotLoc,
+  FieldLoc));
   break;
 }
 
@@ -1234,7 +1235,9 @@
   unsigned Index = Record.readInt();
   SourceLocation LBracketLoc = readSourceLocation();
   SourceLocation RBracketLoc = readSourceLocation();
-  Designators.push_back(Designator(Index, LBracketLoc, RBracketLoc));
+  Designators.push_back(Designator::CreateArrayDesignator(Index,
+  LBracketLoc,
+  RBracketLoc));
   break;
 }
 
@@ -1243,8 +1246,8 @@
   SourceLocation LBracketLoc = readSourceLocation();
   SourceLocation EllipsisLoc = readSourceLocation();
   SourceLocation RBracketLoc = readSourceLocation();
-  Designators.push_back(Designator(Index, LBracketLoc, EllipsisLoc,
-   RBracketLoc));
+  Designators.push_back(Designator::CreateArrayRangeDesignator(
+  Index, LBracketLoc, EllipsisLoc, RBracketLoc));
   break;
 }
 }
Index: clang/lib/Sema/TreeTransform.h
===
--- clang/lib/Sema/TreeTransform.h
+++ clang/lib/Sema/TreeTransform.h
@@ -11661,9 +11661,8 @@
   bool ExprChanged = false;
   for (const DesignatedInitExpr::Designator  : E->designators()) {
 if (D.isFieldDesignator()) {
-  Desig.AddDesignator(Designator::getField(D.getFieldName(),
-   D.getDotLoc(),
-   D.getFieldLoc()));
+  Desig.AddDesignator(Designator::CreateFieldDesignator(
+  D.getFieldName(), D.getDotLoc(), D.getFieldLoc()));
   if (D.getField()) {
 FieldDecl *Field = cast_or_null(
 getDerived().TransformDecl(D.getFieldLoc(), D.getField()));
@@ -11686,7 +11685,7 @@
 return ExprError();
 
   Desig.AddDesignator(
-  Designator::getArray(Index.get(), D.getLBracketLoc()));
+  Designator::CreateArrayDesignator(Index.get(), D.getLBracketLoc()));
 
   

[PATCH] D147579: [nvptx-arch] Dynamically load `libcuda.so.1` directly instead

2023-04-04 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 created this revision.
jhuber6 added a reviewer: tra.
Herald added subscribers: mattd, gchakrabarti, asavonic, yaxunl.
Herald added a project: All.
jhuber6 requested review of this revision.
Herald added subscribers: cfe-commits, jholewinski.
Herald added a project: clang.

This patch loads the CUDA driver library directly via its real
`DT_SONAME`. This prevents the filesystem from needing to reload it in
cases when it's already loaded.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D147579

Files:
  clang/tools/nvptx-arch/NVPTXArch.cpp


Index: clang/tools/nvptx-arch/NVPTXArch.cpp
===
--- clang/tools/nvptx-arch/NVPTXArch.cpp
+++ clang/tools/nvptx-arch/NVPTXArch.cpp
@@ -49,7 +49,7 @@
 CUresult (*cuDeviceGet)(CUdevice *, int);
 CUresult (*cuDeviceGetAttribute)(int *, CUdevice_attribute, CUdevice);
 
-constexpr const char *DynamicCudaPath = "libcuda.so";
+constexpr const char *DynamicCudaPath = "libcuda.so.1";
 
 llvm::Error loadCUDA() {
   std::string ErrMsg;


Index: clang/tools/nvptx-arch/NVPTXArch.cpp
===
--- clang/tools/nvptx-arch/NVPTXArch.cpp
+++ clang/tools/nvptx-arch/NVPTXArch.cpp
@@ -49,7 +49,7 @@
 CUresult (*cuDeviceGet)(CUdevice *, int);
 CUresult (*cuDeviceGetAttribute)(int *, CUdevice_attribute, CUdevice);
 
-constexpr const char *DynamicCudaPath = "libcuda.so";
+constexpr const char *DynamicCudaPath = "libcuda.so.1";
 
 llvm::Error loadCUDA() {
   std::string ErrMsg;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D147209: [clang][lit] Make LIT aware of env CLANG_CRASH_DIAGNOSTICS_DIR.

2023-04-04 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added a comment.

Hi. I think this led to some test failures on our builder at 
https://luci-milo.appspot.com/ui/p/fuchsia/builders/toolchain.ci/clang-linux-x64/b8784708268307261009/overview:

  Script:
  --
  : 'RUN: at line 4';   rm -rf 
/b/s/w/ir/x/w/staging/llvm_build/tools/clang/test/Driver/Output/crmdir
  : 'RUN: at line 5';   mkdir -p 
/b/s/w/ir/x/w/staging/llvm_build/tools/clang/test/Driver/Output/crmdir/i 
/b/s/w/ir/x/w/staging/llvm_build/tools/clang/test/Driver/Output/crmdir/m
  : 'RUN: at line 7';   env FORCE_CLANG_DIAGNOSTICS_CRASH= 
TMPDIR=/b/s/w/ir/x/w/staging/llvm_build/tools/clang/test/Driver/Output/crmdir 
TEMP=/b/s/w/ir/x/w/staging/llvm_build/tools/clang/test/Driver/Output/crmdir 
TMP=/b/s/w/ir/x/w/staging/llvm_build/tools/clang/test/Driver/Output/crmdir  not 
/b/s/w/ir/x/w/staging/llvm_build/bin/clang -fsyntax-only 
/b/s/w/ir/x/w/llvm-llvm-project/clang/test/Driver/crash-report-modules.m -I 
/b/s/w/ir/x/w/llvm-llvm-project/clang/test/Driver/Inputs/module -isysroot 
/b/s/w/ir/x/w/staging/llvm_build/tools/clang/test/Driver/Output/crash-report-modules.m.tmp/i/
  -fmodules 
-fmodules-cache-path=/b/s/w/ir/x/w/staging/llvm_build/tools/clang/test/Driver/Output/crmdir/m/
 -DFOO=BAR 2>&1 | /b/s/w/ir/x/w/staging/llvm_build/bin/FileCheck 
/b/s/w/ir/x/w/llvm-llvm-project/clang/test/Driver/crash-report-modules.m
  : 'RUN: at line 11';   /b/s/w/ir/x/w/staging/llvm_build/bin/FileCheck 
--check-prefix=CHECKSRC 
/b/s/w/ir/x/w/llvm-llvm-project/clang/test/Driver/crash-report-modules.m 
-input-file 
/b/s/w/ir/x/w/staging/llvm_build/tools/clang/test/Driver/Output/crmdir/crash-report-*.m
  : 'RUN: at line 12';   /b/s/w/ir/x/w/staging/llvm_build/bin/FileCheck 
--check-prefix=CHECKSH 
/b/s/w/ir/x/w/llvm-llvm-project/clang/test/Driver/crash-report-modules.m 
-input-file 
/b/s/w/ir/x/w/staging/llvm_build/tools/clang/test/Driver/Output/crmdir/crash-report-*.sh
  --
  Exit Code: 2
  
  Command Output (stderr):
  --
  Could not open input file 
'/b/s/w/ir/x/w/staging/llvm_build/tools/clang/test/Driver/Output/crmdir/crash-report-*.m':
 No such file or directory
  --

I think perhaps since we define `CLANG_CRASH_DIAGNOSTICS_DIR` as an env, tests 
that produce crash reports place them there, but those tests also expect the 
crash report to be in a temp dir `%T`, so perhaps some tests need to be updated 
along side this? Would you be able to take a look and fix or revert?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147209

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


[PATCH] D144304: [-Wunsafe-buffer-usage] Add a Fixable for pointer pre-increment

2023-04-04 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 marked an inline comment as done.
ziqingluo-90 added inline comments.



Comment at: 
clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-addressof-arraysubscript.cpp:19
   bool a = (bool) [5];
-  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:19-[[@LINE-1]]:24}:"(p.data() + 5)"
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:19-[[@LINE-1]]:24}:"()[5]"
   bool b = (bool) [x];

NoQ wrote:
> These changes look unrelated, probably accidentally included from another 
> patch 樂
oh yes,  need a rebase.


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

https://reviews.llvm.org/D144304

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


[PATCH] D147577: [Format/ObjC] Support NS_ERROR_ENUM in ObjC language guesser

2023-04-04 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay accepted this revision.
MyDeveloperDay 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/D147577/new/

https://reviews.llvm.org/D147577

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


[PATCH] D147577: [Format/ObjC] Support NS_ERROR_ENUM in ObjC language guesser

2023-04-04 Thread Ben Hamilton via Phabricator via cfe-commits
benhamilton created this revision.
benhamilton added reviewers: sammccall, MyDeveloperDay.
Herald added projects: All, clang, clang-format.
Herald added a subscriber: cfe-commits.
Herald added reviewers: rymiel, HazardyKnusperkeks, owenpan.
benhamilton requested review of this revision.

Apple added a new NS_ERROR_ENUM macro to help define enums for
NSError codes.

This updates libformat's Objective-C language-guessing heuristic
to detect the new macro as well as related NSError types.

Tested: New tests added.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D147577

Files:
  clang/lib/Format/Format.cpp
  clang/lib/Format/FormatToken.h
  clang/unittests/Format/FormatTestObjC.cpp


Index: clang/unittests/Format/FormatTestObjC.cpp
===
--- clang/unittests/Format/FormatTestObjC.cpp
+++ clang/unittests/Format/FormatTestObjC.cpp
@@ -89,6 +89,11 @@
   ASSERT_TRUE((bool)Style);
   EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language);
 
+  Style =
+  getStyle("{}", "a.h", "none", "typedef NS_ERROR_ENUM(int, Foo) {};\n");
+  ASSERT_TRUE((bool)Style);
+  EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language);
+
   Style = getStyle("{}", "a.h", "none", "enum Foo {};");
   ASSERT_TRUE((bool)Style);
   EXPECT_EQ(FormatStyle::LK_Cpp, Style->Language);
Index: clang/lib/Format/FormatToken.h
===
--- clang/lib/Format/FormatToken.h
+++ clang/lib/Format/FormatToken.h
@@ -949,6 +949,7 @@
 kw_CF_OPTIONS = ("CF_OPTIONS");
 kw_NS_CLOSED_ENUM = ("NS_CLOSED_ENUM");
 kw_NS_ENUM = ("NS_ENUM");
+kw_NS_ERROR_ENUM = ("NS_ERROR_ENUM");
 kw_NS_OPTIONS = ("NS_OPTIONS");
 
 kw_as = ("as");
@@ -1334,6 +1335,7 @@
   IdentifierInfo *kw_CF_OPTIONS;
   IdentifierInfo *kw_NS_CLOSED_ENUM;
   IdentifierInfo *kw_NS_ENUM;
+  IdentifierInfo *kw_NS_ERROR_ENUM;
   IdentifierInfo *kw_NS_OPTIONS;
   IdentifierInfo *kw___except;
   IdentifierInfo *kw___has_include;
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -2699,6 +2699,8 @@
 "NSDecimalNumber",
 "NSDictionary",
 "NSEdgeInsets",
+"NSError",
+"NSErrorDomain",
 "NSHashTable",
 "NSIndexPath",
 "NSIndexSet",
@@ -2760,6 +2762,7 @@
 FormatTok->TokenText)) ||
 FormatTok->is(TT_ObjCStringLiteral) ||
 FormatTok->isOneOf(Keywords.kw_NS_CLOSED_ENUM, Keywords.kw_NS_ENUM,
+   Keywords.kw_NS_ERROR_ENUM,
Keywords.kw_NS_OPTIONS, TT_ObjCBlockLBrace,
TT_ObjCBlockLParen, TT_ObjCDecl, TT_ObjCForIn,
TT_ObjCMethodExpr, TT_ObjCMethodSpecifier,


Index: clang/unittests/Format/FormatTestObjC.cpp
===
--- clang/unittests/Format/FormatTestObjC.cpp
+++ clang/unittests/Format/FormatTestObjC.cpp
@@ -89,6 +89,11 @@
   ASSERT_TRUE((bool)Style);
   EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language);
 
+  Style =
+  getStyle("{}", "a.h", "none", "typedef NS_ERROR_ENUM(int, Foo) {};\n");
+  ASSERT_TRUE((bool)Style);
+  EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language);
+
   Style = getStyle("{}", "a.h", "none", "enum Foo {};");
   ASSERT_TRUE((bool)Style);
   EXPECT_EQ(FormatStyle::LK_Cpp, Style->Language);
Index: clang/lib/Format/FormatToken.h
===
--- clang/lib/Format/FormatToken.h
+++ clang/lib/Format/FormatToken.h
@@ -949,6 +949,7 @@
 kw_CF_OPTIONS = ("CF_OPTIONS");
 kw_NS_CLOSED_ENUM = ("NS_CLOSED_ENUM");
 kw_NS_ENUM = ("NS_ENUM");
+kw_NS_ERROR_ENUM = ("NS_ERROR_ENUM");
 kw_NS_OPTIONS = ("NS_OPTIONS");
 
 kw_as = ("as");
@@ -1334,6 +1335,7 @@
   IdentifierInfo *kw_CF_OPTIONS;
   IdentifierInfo *kw_NS_CLOSED_ENUM;
   IdentifierInfo *kw_NS_ENUM;
+  IdentifierInfo *kw_NS_ERROR_ENUM;
   IdentifierInfo *kw_NS_OPTIONS;
   IdentifierInfo *kw___except;
   IdentifierInfo *kw___has_include;
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -2699,6 +2699,8 @@
 "NSDecimalNumber",
 "NSDictionary",
 "NSEdgeInsets",
+"NSError",
+"NSErrorDomain",
 "NSHashTable",
 "NSIndexPath",
 "NSIndexSet",
@@ -2760,6 +2762,7 @@
 FormatTok->TokenText)) ||
 FormatTok->is(TT_ObjCStringLiteral) ||
 FormatTok->isOneOf(Keywords.kw_NS_CLOSED_ENUM, Keywords.kw_NS_ENUM,
+   Keywords.kw_NS_ERROR_ENUM,
Keywords.kw_NS_OPTIONS, TT_ObjCBlockLBrace,
TT_ObjCBlockLParen, TT_ObjCDecl, 

[PATCH] D147572: [Clang][OpenMP] Fix failure with team-wide allocated variable

2023-04-04 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
doru1004 updated this revision to Diff 510943.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147572

Files:
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
  clang/test/OpenMP/target_team_variable_codegen.cpp


Index: clang/test/OpenMP/target_team_variable_codegen.cpp
===
--- /dev/null
+++ clang/test/OpenMP/target_team_variable_codegen.cpp
@@ -0,0 +1,57 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --check-globals --prefix-filecheck-ir-name _ --global-value-regex 
"llvm.compiler.used" "_[0-9a-zA-Z]+A[0-9a-zA-Z]+pi[0-9a-zA-Z]+" 
"_[0-9a-zA-Z]+anotherPi" --version 2
+// REQUIRES: amdgpu-registered-target
+
+
+// Test target codegen - host bc file has to be created first.
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-fopenmp-targets=amdgcn-amd-amdhsa -emit-llvm-bc %s -o %t-ppc-host-amd.bc
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple amdgcn-amd-amdhsa 
-fopenmp-targets=amdgcn-amd-amdhsa -emit-llvm %s -fopenmp-target-debug 
-fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host-amd.bc -o - | 
FileCheck %s --check-prefix=CHECK-AMD
+
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host-nvidia.bc
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown 
-fopenmp-targets=nvptx64-unknown-unknown -emit-llvm %s -fopenmp-target-debug 
-fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host-nvidia.bc -o - | 
FileCheck %s --check-prefix=CHECK-NVIDIA
+
+// expected-no-diagnostics
+
+#ifndef HEADER
+#define HEADER
+
+typedef enum omp_allocator_handle_t {
+  omp_null_allocator = 0,
+  omp_default_mem_alloc = 1,
+  omp_large_cap_mem_alloc = 2,
+  omp_const_mem_alloc = 3,
+  omp_high_bw_mem_alloc = 4,
+  omp_low_lat_mem_alloc = 5,
+  omp_cgroup_mem_alloc = 6,
+  omp_pteam_mem_alloc = 7,
+  omp_thread_mem_alloc = 8,
+  KMP_ALLOCATOR_MAX_HANDLE = __UINTPTR_MAX__
+} omp_allocator_handle_t;
+
+//.
+// CHECK-AMD: @local_a = internal addrspace(3) global [10 x i32] poison, align 
4
+//.
+// CHECK-NVIDIA: @local_a = internal addrspace(3) global [10 x i32] 
zeroinitializer, align 4
+//.
+int main()
+{
+   int N = 1;
+   int *a = new int[N];
+#pragma omp target data map(tofrom:a[:N])
+   {
+#pragma omp target teams distribute parallel for
+for(int i = 0; i < N; i++)
+{
+  int local_a[10];
+#pragma omp allocate(local_a) allocator(omp_pteam_mem_alloc)
+  for(int j = 0; j < 10; j++)
+   local_a[j] = a[(i + j) % N];
+  a[i] = local_a[0];
+}
+   }
+  return a[17];
+}
+
+#endif
+ NOTE: These prefixes are unused and the list is autogenerated. Do not add 
tests below this line:
+// CHECK-AMD: {{.*}}
+// CHECK-NVIDIA: {{.*}}
Index: clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
@@ -3351,7 +3351,9 @@
 llvm::Type *VarTy = CGF.ConvertTypeForMem(VD->getType());
 auto *GV = new llvm::GlobalVariable(
 CGM.getModule(), VarTy, /*isConstant=*/false,
-llvm::GlobalValue::InternalLinkage, 
llvm::Constant::getNullValue(VarTy),
+llvm::GlobalValue::InternalLinkage,
+CGM.getTriple().isAMDGCN() ? llvm::PoisonValue::get(VarTy)
+   : llvm::Constant::getNullValue(VarTy),
 VD->getName(),
 /*InsertBefore=*/nullptr, llvm::GlobalValue::NotThreadLocal,
 CGM.getContext().getTargetAddressSpace(AS));


Index: clang/test/OpenMP/target_team_variable_codegen.cpp
===
--- /dev/null
+++ clang/test/OpenMP/target_team_variable_codegen.cpp
@@ -0,0 +1,57 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --check-globals --prefix-filecheck-ir-name _ --global-value-regex "llvm.compiler.used" "_[0-9a-zA-Z]+A[0-9a-zA-Z]+pi[0-9a-zA-Z]+" "_[0-9a-zA-Z]+anotherPi" --version 2
+// REQUIRES: amdgpu-registered-target
+
+
+// Test target codegen - host bc file has to be created first.
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=amdgcn-amd-amdhsa -emit-llvm-bc %s -o %t-ppc-host-amd.bc
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple amdgcn-amd-amdhsa -fopenmp-targets=amdgcn-amd-amdhsa -emit-llvm %s -fopenmp-target-debug -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host-amd.bc -o - | FileCheck %s --check-prefix=CHECK-AMD
+
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host-nvidia.bc
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown 

[PATCH] D147572: [Clang][OpenMP] Fix failure with team-wide allocated variable

2023-04-04 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
doru1004 added inline comments.



Comment at: llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp:303
+if (GV->hasInitializer() && !(isa(GV->getInitializer()) ||
+  isa(GV->getInitializer( {
   OutContext.reportError({},

arsenm wrote:
> Isa covers PoisonValue already 
Perfect! I'll revert this part.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147572

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


[PATCH] D147572: [Clang][OpenMP] Fix failure with team-wide allocated variable

2023-04-04 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added inline comments.



Comment at: llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp:303
+if (GV->hasInitializer() && !(isa(GV->getInitializer()) ||
+  isa(GV->getInitializer( {
   OutContext.reportError({},

Isa covers PoisonValue already 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147572

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


[PATCH] D147209: [clang][lit] Make LIT aware of env CLANG_CRASH_DIAGNOSTICS_DIR.

2023-04-04 Thread Francesco Petrogalli via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG029212617ca8: [clang][lit] Make LIT aware of env 
CLANG_CRASH_DIAGNOSTICS_DIR. (authored by fpetrogalli).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147209

Files:
  clang/test/lit.cfg.py


Index: clang/test/lit.cfg.py
===
--- clang/test/lit.cfg.py
+++ clang/test/lit.cfg.py
@@ -284,6 +284,10 @@
 config.substitutions.append(('llvm-nm', 'env OBJECT_MODE=any llvm-nm'))
 config.substitutions.append(('llvm-ar', 'env OBJECT_MODE=any llvm-ar'))
 
+# Pass the crash diagnostic dir set in the os environment to LIT.
+if 'CLANG_CRASH_DIAGNOSTICS_DIR' in os.environ:
+config.environment['CLANG_CRASH_DIAGNOSTICS_DIR'] = 
os.environ['CLANG_CRASH_DIAGNOSTICS_DIR']
+
 # It is not realistically possible to account for all options that could
 # possibly be present in system and user configuration files, so disable
 # default configs for the test runs.


Index: clang/test/lit.cfg.py
===
--- clang/test/lit.cfg.py
+++ clang/test/lit.cfg.py
@@ -284,6 +284,10 @@
 config.substitutions.append(('llvm-nm', 'env OBJECT_MODE=any llvm-nm'))
 config.substitutions.append(('llvm-ar', 'env OBJECT_MODE=any llvm-ar'))
 
+# Pass the crash diagnostic dir set in the os environment to LIT.
+if 'CLANG_CRASH_DIAGNOSTICS_DIR' in os.environ:
+config.environment['CLANG_CRASH_DIAGNOSTICS_DIR'] = os.environ['CLANG_CRASH_DIAGNOSTICS_DIR']
+
 # It is not realistically possible to account for all options that could
 # possibly be present in system and user configuration files, so disable
 # default configs for the test runs.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 0292126 - [clang][lit] Make LIT aware of env CLANG_CRASH_DIAGNOSTICS_DIR.

2023-04-04 Thread Francesco Petrogalli via cfe-commits

Author: Francesco Petrogalli
Date: 2023-04-05T00:08:14+02:00
New Revision: 029212617ca8bdedd949d17bf2d33750605ea607

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

LOG: [clang][lit] Make LIT aware of env CLANG_CRASH_DIAGNOSTICS_DIR.

This is useful for retriving crash reports of LIT runs when the
temporary folder is not accessible.

Reviewed By: michaelplatings

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

Added: 


Modified: 
clang/test/lit.cfg.py

Removed: 




diff  --git a/clang/test/lit.cfg.py b/clang/test/lit.cfg.py
index e9bfaf2e9677..7c5a55c8e313 100644
--- a/clang/test/lit.cfg.py
+++ b/clang/test/lit.cfg.py
@@ -284,6 +284,10 @@ def exclude_unsupported_files_for_aix(dirname):
 config.substitutions.append(('llvm-nm', 'env OBJECT_MODE=any llvm-nm'))
 config.substitutions.append(('llvm-ar', 'env OBJECT_MODE=any llvm-ar'))
 
+# Pass the crash diagnostic dir set in the os environment to LIT.
+if 'CLANG_CRASH_DIAGNOSTICS_DIR' in os.environ:
+config.environment['CLANG_CRASH_DIAGNOSTICS_DIR'] = 
os.environ['CLANG_CRASH_DIAGNOSTICS_DIR']
+
 # It is not realistically possible to account for all options that could
 # possibly be present in system and user configuration files, so disable
 # default configs for the test runs.



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


[PATCH] D147073: [Coverage] Handle invalid end location of an expression/statement.

2023-04-04 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu updated this revision to Diff 510938.
zequanwu added a comment.

Split to another patch: D147569 .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147073

Files:
  clang/lib/CodeGen/CoverageMappingGen.cpp
  clang/test/CoverageMapping/invalid_location.cpp


Index: clang/test/CoverageMapping/invalid_location.cpp
===
--- /dev/null
+++ clang/test/CoverageMapping/invalid_location.cpp
@@ -0,0 +1,40 @@
+// RUN: %clang_cc1 -mllvm -emptyline-comment-coverage=false 
-fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping 
-emit-llvm-only -std=c++20 -stdlib=libc++ -triple %itanium_abi_triple %s | 
FileCheck %s
+
+namespace std { template  class initializer_list {}; }
+
+template  struct T {
+  T(std::initializer_list, int = int());
+  bool b;
+};
+
+template  struct S1 {
+  static void foo() {
+class C;
+0 ? T{} : T{};
+0 ? 1 : 2;
+  }
+};
+
+void bar() {
+  S1::foo();
+}
+
+
+// CHECK:  _ZN2S1IiE3fooEv:
+// CHECK-NEXT:   File 0, 11:21 -> 15:4 = #0
+// CHECK-NEXT:   File 0, 13:5 -> 13:6 = #0
+// CHECK-NEXT:   Branch,File 0, 13:5 -> 13:6 = 0, 0
+// CHECK-NEXT:   Gap,File 0, 13:8 -> 13:9 = #1
+// FIXME: It's supposed to have two different counters for true and false
+//branches at line 13 as it has for line 14, shown below. It's missing
+//now because 'T{}' doesn't have a valid end location for now.
+//Once it's fixed, correct the following two "CHECK-NETX" and #3 and #2
+//may need to swap positions.
+// CHECK-NETX:   File 0, 13:9 -> 13:14 = #3
+// CHECK-NETX:   File 0, 13:18 -> 13:23 = (#0 - #3)
+
+// CHECK-NEXT:   File 0, 14:5 -> 14:6 = #0
+// CHECK-NEXT:   Branch,File 0, 14:5 -> 14:6 = 0, 0
+// CHECK-NEXT:   Gap,File 0, 14:8 -> 14:9 = #2
+// CHECK-NEXT:   File 0, 14:9 -> 14:10 = #2
+// CHECK-NEXT:   File 0, 14:13 -> 14:14 = (#0 - #2)
Index: clang/lib/CodeGen/CoverageMappingGen.cpp
===
--- clang/lib/CodeGen/CoverageMappingGen.cpp
+++ clang/lib/CodeGen/CoverageMappingGen.cpp
@@ -602,6 +602,13 @@
   MostRecentLocation = *StartLoc;
 }
 
+// If either location is invalid, set it to std::nullopt to avoid
+// letting users of RegionStack think that region has a valid start/end
+// location.
+if (StartLoc && StartLoc->isInvalid())
+  StartLoc = std::nullopt;
+if (EndLoc && EndLoc->isInvalid())
+  EndLoc = std::nullopt;
 RegionStack.emplace_back(Count, FalseCount, StartLoc, EndLoc);
 
 return RegionStack.size() - 1;
@@ -624,7 +631,8 @@
 assert(RegionStack.size() >= ParentIndex && "parent not in stack");
 while (RegionStack.size() > ParentIndex) {
   SourceMappingRegion  = RegionStack.back();
-  if (Region.hasStartLoc()) {
+  if (Region.hasStartLoc() &&
+  (Region.hasEndLoc() || RegionStack[ParentIndex].hasEndLoc())) {
 SourceLocation StartLoc = Region.getBeginLoc();
 SourceLocation EndLoc = Region.hasEndLoc()
 ? Region.getEndLoc()
@@ -691,7 +699,7 @@
 assert(SM.isWrittenInSameFile(Region.getBeginLoc(), EndLoc));
 assert(SpellingRegion(SM, Region).isInSourceOrder());
 SourceRegions.push_back(Region);
-}
+  }
   RegionStack.pop_back();
 }
   }
@@ -891,6 +899,8 @@
   /// Find a valid gap range between \p AfterLoc and \p BeforeLoc.
   std::optional findGapAreaBetween(SourceLocation AfterLoc,
 SourceLocation BeforeLoc) {
+if (AfterLoc.isInvalid() || BeforeLoc.isInvalid())
+  return std::nullopt;
 // If AfterLoc is in function-like macro, use the right parenthesis
 // location.
 if (AfterLoc.isMacroID()) {


Index: clang/test/CoverageMapping/invalid_location.cpp
===
--- /dev/null
+++ clang/test/CoverageMapping/invalid_location.cpp
@@ -0,0 +1,40 @@
+// RUN: %clang_cc1 -mllvm -emptyline-comment-coverage=false -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -std=c++20 -stdlib=libc++ -triple %itanium_abi_triple %s | FileCheck %s
+
+namespace std { template  class initializer_list {}; }
+
+template  struct T {
+  T(std::initializer_list, int = int());
+  bool b;
+};
+
+template  struct S1 {
+  static void foo() {
+class C;
+0 ? T{} : T{};
+0 ? 1 : 2;
+  }
+};
+
+void bar() {
+  S1::foo();
+}
+
+
+// CHECK:  _ZN2S1IiE3fooEv:
+// CHECK-NEXT:   File 0, 11:21 -> 15:4 = #0
+// CHECK-NEXT:   File 0, 13:5 -> 13:6 = #0
+// CHECK-NEXT:   Branch,File 0, 13:5 -> 13:6 = 0, 0
+// CHECK-NEXT:   Gap,File 0, 13:8 -> 13:9 = #1
+// FIXME: It's supposed to have two different counters for true and false
+//branches at line 13 as it has for line 14, shown below. It's missing
+//

[PATCH] D147572: [Clang][OpenMP] Fix failure with team-wide allocated variable

2023-04-04 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
doru1004 marked an inline comment as done.
doru1004 added inline comments.



Comment at: clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp:3355
+llvm::GlobalValue::InternalLinkage,
+CGM.getTriple().isAMDGCN() ? llvm::UndefValue::get(VarTy)
+   : llvm::Constant::getNullValue(VarTy),

nlopes wrote:
> Please use poison instead of undef wherever possible as we are tying to 
> remove undef. The replacement is usually safe when you just need a 
> placeholder.
> Thank you!
I've made the change as requested, this also means that I had to add another 
check in `AMDGPUAsmPrinter.cpp`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147572

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


[PATCH] D147572: [Clang][OpenMP] Fix failure with team-wide allocated variable

2023-04-04 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
doru1004 updated this revision to Diff 510934.
Herald added subscribers: llvm-commits, kosarev, foad, kerbowa, hiraditya, 
jvesely, arsenm.
Herald added a project: LLVM.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147572

Files:
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
  clang/test/OpenMP/target_team_variable_codegen.cpp
  llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp


Index: llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
===
--- llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
+++ llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
@@ -299,7 +299,8 @@
 
 void AMDGPUAsmPrinter::emitGlobalVariable(const GlobalVariable *GV) {
   if (GV->getAddressSpace() == AMDGPUAS::LOCAL_ADDRESS) {
-if (GV->hasInitializer() && !isa(GV->getInitializer())) {
+if (GV->hasInitializer() && !(isa(GV->getInitializer()) ||
+  isa(GV->getInitializer( {
   OutContext.reportError({},
  Twine(GV->getName()) +
  ": unsupported initializer for address 
space");
Index: clang/test/OpenMP/target_team_variable_codegen.cpp
===
--- /dev/null
+++ clang/test/OpenMP/target_team_variable_codegen.cpp
@@ -0,0 +1,57 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --check-globals --prefix-filecheck-ir-name _ --global-value-regex 
"llvm.compiler.used" "_[0-9a-zA-Z]+A[0-9a-zA-Z]+pi[0-9a-zA-Z]+" 
"_[0-9a-zA-Z]+anotherPi" --version 2
+// REQUIRES: amdgpu-registered-target
+
+
+// Test target codegen - host bc file has to be created first.
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-fopenmp-targets=amdgcn-amd-amdhsa -emit-llvm-bc %s -o %t-ppc-host-amd.bc
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple amdgcn-amd-amdhsa 
-fopenmp-targets=amdgcn-amd-amdhsa -emit-llvm %s -fopenmp-target-debug 
-fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host-amd.bc -o - | 
FileCheck %s --check-prefix=CHECK-AMD
+
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host-nvidia.bc
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown 
-fopenmp-targets=nvptx64-unknown-unknown -emit-llvm %s -fopenmp-target-debug 
-fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host-nvidia.bc -o - | 
FileCheck %s --check-prefix=CHECK-NVIDIA
+
+// expected-no-diagnostics
+
+#ifndef HEADER
+#define HEADER
+
+typedef enum omp_allocator_handle_t {
+  omp_null_allocator = 0,
+  omp_default_mem_alloc = 1,
+  omp_large_cap_mem_alloc = 2,
+  omp_const_mem_alloc = 3,
+  omp_high_bw_mem_alloc = 4,
+  omp_low_lat_mem_alloc = 5,
+  omp_cgroup_mem_alloc = 6,
+  omp_pteam_mem_alloc = 7,
+  omp_thread_mem_alloc = 8,
+  KMP_ALLOCATOR_MAX_HANDLE = __UINTPTR_MAX__
+} omp_allocator_handle_t;
+
+//.
+// CHECK-AMD: @local_a = internal addrspace(3) global [10 x i32] poison, align 
4
+//.
+// CHECK-NVIDIA: @local_a = internal addrspace(3) global [10 x i32] 
zeroinitializer, align 4
+//.
+int main()
+{
+   int N = 1;
+   int *a = new int[N];
+#pragma omp target data map(tofrom:a[:N])
+   {
+#pragma omp target teams distribute parallel for
+for(int i = 0; i < N; i++)
+{
+  int local_a[10];
+#pragma omp allocate(local_a) allocator(omp_pteam_mem_alloc)
+  for(int j = 0; j < 10; j++)
+   local_a[j] = a[(i + j) % N];
+  a[i] = local_a[0];
+}
+   }
+  return a[17];
+}
+
+#endif
+ NOTE: These prefixes are unused and the list is autogenerated. Do not add 
tests below this line:
+// CHECK-AMD: {{.*}}
+// CHECK-NVIDIA: {{.*}}
Index: clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
@@ -3351,7 +3351,9 @@
 llvm::Type *VarTy = CGF.ConvertTypeForMem(VD->getType());
 auto *GV = new llvm::GlobalVariable(
 CGM.getModule(), VarTy, /*isConstant=*/false,
-llvm::GlobalValue::InternalLinkage, 
llvm::Constant::getNullValue(VarTy),
+llvm::GlobalValue::InternalLinkage,
+CGM.getTriple().isAMDGCN() ? llvm::PoisonValue::get(VarTy)
+   : llvm::Constant::getNullValue(VarTy),
 VD->getName(),
 /*InsertBefore=*/nullptr, llvm::GlobalValue::NotThreadLocal,
 CGM.getContext().getTargetAddressSpace(AS));


Index: llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
===
--- llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
+++ llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
@@ -299,7 +299,8 @@
 
 void AMDGPUAsmPrinter::emitGlobalVariable(const GlobalVariable *GV) {
   if (GV->getAddressSpace() 

[PATCH] D146669: [-Wunsafe-buffer-usage] Hide fixits/suggestions behind an extra flag, -fsafe-buffer-usage-suggestions.

2023-04-04 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ updated this revision to Diff 510933.
NoQ added a comment.

- Rebase! (I'll update related revisions soon but not immediately, need to make 
sense out of them first.)
- Eliminate the `EmitFixits` mode as discussed above.


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

https://reviews.llvm.org/D146669

Files:
  clang/include/clang/Analysis/Analyses/UnsafeBufferUsage.h
  clang/include/clang/Basic/DiagnosticOptions.def
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Driver/Options.td
  clang/lib/Analysis/UnsafeBufferUsage.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Sema/AnalysisBasedWarnings.cpp
  clang/test/SemaCXX/unsafe-buffer-usage-diag-type.cpp
  
clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-addressof-arraysubscript.cpp
  
clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-assign-to-array-subscr-on-ptr.cpp
  clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-deref-simple-ptr-arith.cpp
  clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-local-var-span.cpp
  clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-pointer-access.cpp
  clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-pointer-deref.cpp
  clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-pre-increment.cpp
  clang/test/SemaCXX/warn-unsafe-buffer-usage-function-attr.cpp
  clang/test/SemaCXX/warn-unsafe-buffer-usage-pragma-fixit.cpp
  clang/test/SemaCXX/warn-unsafe-buffer-usage-pragma.cpp
  clang/test/SemaCXX/warn-unsafe-buffer-usage-suggestions-flag.cpp
  clang/test/SemaCXX/warn-unsafe-buffer-usage.cpp

Index: clang/test/SemaCXX/warn-unsafe-buffer-usage.cpp
===
--- clang/test/SemaCXX/warn-unsafe-buffer-usage.cpp
+++ clang/test/SemaCXX/warn-unsafe-buffer-usage.cpp
@@ -1,4 +1,6 @@
-// RUN: %clang_cc1 -std=c++20 -Wno-all -Wunsafe-buffer-usage -fblocks -include %s -verify %s
+// RUN: %clang_cc1 -std=c++20 -Wno-all -Wunsafe-buffer-usage \
+// RUN:-fsafe-buffer-usage-suggestions \
+// RUN:-fblocks -include %s -verify %s
 
 // RUN: %clang -x c++ -fsyntax-only -fblocks -include %s %s 2>&1 | FileCheck --allow-empty %s
 // RUN: %clang_cc1 -std=c++11 -fblocks -include %s %s 2>&1 | FileCheck --allow-empty %s
Index: clang/test/SemaCXX/warn-unsafe-buffer-usage-suggestions-flag.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/warn-unsafe-buffer-usage-suggestions-flag.cpp
@@ -0,0 +1,66 @@
+// Test the -cc1 flag. There's no -fno-... option in -cc1 invocations,
+// just the positive option.
+
+// RUN: %clang_cc1 -std=c++20 -Wunsafe-buffer-usage -verify=OFF %s
+// RUN: %clang_cc1 -std=c++20 -Wunsafe-buffer-usage -verify=ON %s \
+// RUN:-fsafe-buffer-usage-suggestions
+
+// Test driver flags. Now there's both -f... and -fno-... to worry about.
+
+// RUN: %clang -fsyntax-only -std=c++20 -Wunsafe-buffer-usage \
+// RUN:-Xclang -verify=OFF %s
+// RUN: %clang -fsyntax-only -std=c++20 -Wunsafe-buffer-usage \
+// RUN:-fsafe-buffer-usage-suggestions \
+// RUN:-Xclang -verify=ON %s
+// RUN: %clang -fsyntax-only -std=c++20 -Wunsafe-buffer-usage \
+// RUN:-fno-safe-buffer-usage-suggestions \
+// RUN:-Xclang -verify=OFF %s
+
+// In case of driver flags, last flag takes precedence.
+
+// RUN: %clang -fsyntax-only -std=c++20 -Wunsafe-buffer-usage \
+// RUN:-fsafe-buffer-usage-suggestions \
+// RUN:-fno-safe-buffer-usage-suggestions \
+// RUN:-Xclang -verify=OFF %s
+// RUN: %clang -fsyntax-only -std=c++20 -Wunsafe-buffer-usage \
+// RUN:-fno-safe-buffer-usage-suggestions \
+// RUN:-fsafe-buffer-usage-suggestions \
+// RUN:-Xclang -verify=ON %s
+
+// Passing through -Xclang.
+
+// RUN: %clang -fsyntax-only -std=c++20 -Wunsafe-buffer-usage \
+// RUN:-Xclang -fsafe-buffer-usage-suggestions \
+// RUN:-Xclang -verify=ON %s
+
+// -Xclang flags take precedence over driver flags.
+
+// RUN: %clang -fsyntax-only -std=c++20 -Wunsafe-buffer-usage \
+// RUN:-Xclang -fsafe-buffer-usage-suggestions \
+// RUN:-fno-safe-buffer-usage-suggestions \
+// RUN:-Xclang -verify=ON %s
+// RUN: %clang -fsyntax-only -std=c++20 -Wunsafe-buffer-usage \
+// RUN:-fno-safe-buffer-usage-suggestions \
+// RUN:-Xclang -fsafe-buffer-usage-suggestions \
+// RUN:-Xclang -verify=ON %s
+
+[[clang::unsafe_buffer_usage]] void bar(int *);
+
+void foo(int *x) { // \
+  // ON-warning{{'x' is an unsafe pointer used for buffer access}}
+  // FIXME: Better "OFF" warning?
+  x[5] = 10; // \
+  // ON-note{{used in buffer access here}} \
+  // OFF-warning{{unsafe buffer access}} \
+  // OFF-note   {{pass -fsafe-buffer-usage-suggestions to receive code hardening suggestions}}
+
+  x += 5;  // \
+  // ON-note{{used in pointer arithmetic here}} \
+  // OFF-warning{{unsafe pointer arithmetic}} \
+  // OFF-note   {{pass -fsafe-buffer-usage-suggestions 

[PATCH] D146399: [AIX][Clang][K] Create `-K` Option for AIX.

2023-04-04 Thread Michael Francis via Phabricator via cfe-commits
francii added a comment.

In D146399#4243803 , 
@hubert.reinterpretcast wrote:

> @francii, what happens when `-K` is used on a pure-compile (`-c`) invocation? 
> Do we get an "unused" message? Should we be testing that?
> I think we should be testing the diagnostic for the "wrong target" usage as 
> well?

When compiling with `-c`, we will get the "unused" message. I will include a 
test case for it.

Do we need a test case for the diagnostic? If we are only supporting one 
target, which triple would be used for the test?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146399

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


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

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

> @probinson Sounds like Sony's solution also changes the `DW_AT_type` to a 
> non-canonical form. Do you still have concerns with the direction of this 
> patch? Would it cause any problems for you downstream?

Sorry for the late reply. Looking at the patch I don't think it will cause us 
any trouble. The 2 solutions should be able to live happily side by side.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145803

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


[PATCH] D147209: [clang][lit] Make LIT aware of env CLANG_CRASH_DIAGNOSTICS_DIR.

2023-04-04 Thread Michael Platings via Phabricator via cfe-commits
michaelplatings accepted this revision.
michaelplatings added a comment.
This revision is now accepted and ready to land.

Looks useful, and matches the behaviour I would have expected anyway. The 
buildkite libcxx tests already rely on being able to pass this variable 
through, so the same seems desirable for the clang tests. LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147209

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


[PATCH] D147572: [Clang][OpenMP] Fix failure with team-wide allocated variable

2023-04-04 Thread Nuno Lopes via Phabricator via cfe-commits
nlopes added inline comments.



Comment at: clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp:3355
+llvm::GlobalValue::InternalLinkage,
+CGM.getTriple().isAMDGCN() ? llvm::UndefValue::get(VarTy)
+   : llvm::Constant::getNullValue(VarTy),

Please use poison instead of undef wherever possible as we are tying to remove 
undef. The replacement is usually safe when you just need a placeholder.
Thank you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147572

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


[PATCH] D147572: [Clang][OpenMP] Fix failure with team-wide allocated variable

2023-04-04 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
doru1004 created this revision.
doru1004 added reviewers: ronl, carlo.bertolli, jhuber6, jdoerfert, dhruvachak, 
gregrodgers.
doru1004 added a project: OpenMP.
Herald added subscribers: sunshaoce, nlopes, guansong, arichardson, yaxunl.
Herald added a project: All.
doru1004 requested review of this revision.
Herald added subscribers: cfe-commits, jplehr, sstefan1.
Herald added a project: clang.

This patch aims to resolve issue: 
https://github.com/llvm/llvm-project/issues/60345

The following code:

  #include 
  #include 
  #include 
  
  
  int main()
  {
int N =1<<30;
int *a = new int[N];
  #pragma omp target data map(tofrom:a[:N])
{
 #pragma omp target teams distribute parallel for
  for(int i = 0; i < N; i++)
  {
   int local_a[10];
 #pragma omp allocate(local_a) allocator(omp_pteam_mem_alloc)
for(int j = 0; j < 10; j++)
local_a[j] = a[(i+j)%N];
a[i] = local_a[0];
}
}
  std::cout << a[0] << "\n";
  }

Fails with the following linker errors:

  clang-linker-wrapper: error: :0: local_a: unsupported initializer 
for address space
  
  clang-linker-wrapper: error: Errors encountered inside the LTO pipeline.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D147572

Files:
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
  clang/test/OpenMP/target_team_variable_codegen.cpp


Index: clang/test/OpenMP/target_team_variable_codegen.cpp
===
--- /dev/null
+++ clang/test/OpenMP/target_team_variable_codegen.cpp
@@ -0,0 +1,57 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --check-globals --prefix-filecheck-ir-name _ --global-value-regex 
"llvm.compiler.used" "_[0-9a-zA-Z]+A[0-9a-zA-Z]+pi[0-9a-zA-Z]+" 
"_[0-9a-zA-Z]+anotherPi" --version 2
+// REQUIRES: amdgpu-registered-target
+
+
+// Test target codegen - host bc file has to be created first.
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-fopenmp-targets=amdgcn-amd-amdhsa -emit-llvm-bc %s -o %t-ppc-host-amd.bc
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple amdgcn-amd-amdhsa 
-fopenmp-targets=amdgcn-amd-amdhsa -emit-llvm %s -fopenmp-target-debug 
-fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host-amd.bc -o - | 
FileCheck %s --check-prefix=CHECK-AMD
+
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host-nvidia.bc
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown 
-fopenmp-targets=nvptx64-unknown-unknown -emit-llvm %s -fopenmp-target-debug 
-fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host-nvidia.bc -o - | 
FileCheck %s --check-prefix=CHECK-NVIDIA
+
+// expected-no-diagnostics
+
+#ifndef HEADER
+#define HEADER
+
+typedef enum omp_allocator_handle_t {
+  omp_null_allocator = 0,
+  omp_default_mem_alloc = 1,
+  omp_large_cap_mem_alloc = 2,
+  omp_const_mem_alloc = 3,
+  omp_high_bw_mem_alloc = 4,
+  omp_low_lat_mem_alloc = 5,
+  omp_cgroup_mem_alloc = 6,
+  omp_pteam_mem_alloc = 7,
+  omp_thread_mem_alloc = 8,
+  KMP_ALLOCATOR_MAX_HANDLE = __UINTPTR_MAX__
+} omp_allocator_handle_t;
+
+//.
+// CHECK-AMD: @local_a = internal addrspace(3) global [10 x i32] undef, align 4
+//.
+// CHECK-NVIDIA: @local_a = internal addrspace(3) global [10 x i32] 
zeroinitializer, align 4
+//.
+int main()
+{
+   int N = 1;
+   int *a = new int[N];
+#pragma omp target data map(tofrom:a[:N])
+   {
+#pragma omp target teams distribute parallel for
+for(int i = 0; i < N; i++)
+{
+  int local_a[10];
+#pragma omp allocate(local_a) allocator(omp_pteam_mem_alloc)
+  for(int j = 0; j < 10; j++)
+   local_a[j] = a[(i + j) % N];
+  a[i] = local_a[0];
+}
+   }
+  return a[17];
+}
+
+#endif
+ NOTE: These prefixes are unused and the list is autogenerated. Do not add 
tests below this line:
+// CHECK-AMD: {{.*}}
+// CHECK-NVIDIA: {{.*}}
Index: clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
@@ -3351,7 +3351,9 @@
 llvm::Type *VarTy = CGF.ConvertTypeForMem(VD->getType());
 auto *GV = new llvm::GlobalVariable(
 CGM.getModule(), VarTy, /*isConstant=*/false,
-llvm::GlobalValue::InternalLinkage, 
llvm::Constant::getNullValue(VarTy),
+llvm::GlobalValue::InternalLinkage,
+CGM.getTriple().isAMDGCN() ? llvm::UndefValue::get(VarTy)
+   : llvm::Constant::getNullValue(VarTy),
 VD->getName(),
 /*InsertBefore=*/nullptr, llvm::GlobalValue::NotThreadLocal,
 CGM.getContext().getTargetAddressSpace(AS));


Index: clang/test/OpenMP/target_team_variable_codegen.cpp

[PATCH] D147417: [clang-tidy] Do not emit bugprone-exception-escape warnings from coroutines

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

" clang-tidy already warns with bugprone-exception-escape on the destructor of 
Evil even when it is marked noexcept(false)"
https://reviews.llvm.org/D145865


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147417

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


[PATCH] D147569: [Coverage] Fix crash when visiting PseudoObjectExpr.

2023-04-04 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu updated this revision to Diff 510918.
zequanwu added a comment.

Add the crash repro as test case.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147569

Files:
  clang/lib/CodeGen/CoverageMappingGen.cpp
  clang/test/CoverageMapping/if.cpp
  clang/test/CoverageMapping/strong_order.cpp

Index: clang/test/CoverageMapping/strong_order.cpp
===
--- /dev/null
+++ clang/test/CoverageMapping/strong_order.cpp
@@ -0,0 +1,53 @@
+// RUN: %clang_cc1 -mllvm -emptyline-comment-coverage=false -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -std=c++2b -triple %itanium_abi_triple -main-file-name if.cpp %s
+
+// No crash for following example.
+// See https://github.com/llvm/llvm-project/issues/45481
+namespace std {
+class strong_ordering;
+
+// Mock how STD defined unspecified parameters for the operators below.
+struct _CmpUnspecifiedParam {
+  consteval
+  _CmpUnspecifiedParam(int _CmpUnspecifiedParam::*) noexcept {}
+};
+
+struct strong_ordering {
+  signed char value;
+
+  friend constexpr bool operator==(strong_ordering v,
+   _CmpUnspecifiedParam) noexcept {
+return v.value == 0;
+  }
+  friend constexpr bool operator<(strong_ordering v,
+  _CmpUnspecifiedParam) noexcept {
+return v.value < 0;
+  }
+  friend constexpr bool operator>(strong_ordering v,
+  _CmpUnspecifiedParam) noexcept {
+return v.value > 0;
+  }
+  friend constexpr bool operator>=(strong_ordering v,
+   _CmpUnspecifiedParam) noexcept {
+return v.value >= 0;
+  }
+  static const strong_ordering equal, greater, less;
+};
+constexpr strong_ordering strong_ordering::equal = {0};
+constexpr strong_ordering strong_ordering::greater = {1};
+constexpr strong_ordering strong_ordering::less = {-1};
+} // namespace std
+
+struct S {
+friend bool operator<(const S&, const S&);
+friend bool operator==(const S&, const S&);
+};
+
+struct MyStruct {
+friend bool operator==(MyStruct const& lhs, MyStruct const& rhs) = delete;
+friend std::strong_ordering operator<=>(MyStruct const& lhs, MyStruct const& rhs) = default;
+S value;
+};
+
+void foo(MyStruct bar){
+(void)(bar <=> bar);
+}
Index: clang/test/CoverageMapping/if.cpp
===
--- clang/test/CoverageMapping/if.cpp
+++ clang/test/CoverageMapping/if.cpp
@@ -1,6 +1,14 @@
-// RUN: %clang_cc1 -mllvm -emptyline-comment-coverage=false -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -std=c++2b -triple %itanium_abi_triple -main-file-name if.cpp %s | FileCheck %s
+// RUN: %clang_cc1 -fms-extensions -mllvm -emptyline-comment-coverage=false -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -std=c++2b -triple %itanium_abi_triple -main-file-name if.cpp %s | FileCheck %s
 
 int nop() { return 0; }
+struct S {
+   int i;
+   int putprop(int j) {
+  i = j;
+  return i;
+   }
+   __declspec(property(put = putprop)) int the_prop;
+};
 
 // CHECK-LABEL: _Z3foov:
 // CHECK-NEXT: [[@LINE+3]]:12 -> [[@LINE+8]]:2 = #0
@@ -70,7 +78,17 @@
   constexpr int c_i = check_consteval(0);
   check_consteval(i);
 
-  return 0;
+  // GH-45481
+  S s;
+  s.the_prop = 0? 1 : 2;// CHECK-NEXT: File 0, [[@LINE]]:16 -> [[@LINE]]:17 = #0
+// CHECK-NEXT: Branch,File 0, [[@LINE-1]]:16 -> [[@LINE-1]]:17 = 0, 0
+// CHECK-NEXT: Gap,File 0, [[@LINE-2]]:18 -> [[@LINE-2]]:19 = #7
+// CHECK-NEXT: File 0, [[@LINE-3]]:19 -> [[@LINE-3]]:20 = #7
+// CHECK-NEXT: File 0, [[@LINE-4]]:23 -> [[@LINE-4]]:24 = (#0 - #7)
+  if (s.the_prop = 1) { // CHECK-NEXT: File 0, [[@LINE]]:7 -> [[@LINE]]:21 = #0
+ return 1;  // CHECK-NEXT: Branch,File 0, [[@LINE-1]]:7 -> [[@LINE-1]]:21 = #8, (#0 - #8)
+  } // CHECK-NEXT: Gap,File 0, [[@LINE-2]]:22 -> [[@LINE-2]]:23 = #8
+// CHECK-NEXT: File 0, [[@LINE-3]]:23 -> [[@LINE-1]]:4 = #8
 }
 
 #define FOO true
Index: clang/lib/CodeGen/CoverageMappingGen.cpp
===
--- clang/lib/CodeGen/CoverageMappingGen.cpp
+++ clang/lib/CodeGen/CoverageMappingGen.cpp
@@ -1566,6 +1566,15 @@
 // Lambdas are treated as their own functions for now, so we shouldn't
 // propagate counts into them.
   }
+
+  void VisitPseudoObjectExpr(const PseudoObjectExpr *POE) {
+// Just visit syntatic expression as this is what users actually write.
+VisitStmt(POE->getSyntacticForm());
+  }
+
+  void VisitOpaqueValueExpr(const 

[PATCH] D147569: [Coverage] Fix crash when visiting PseudoObjectExpr.

2023-04-04 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu created this revision.
zequanwu added reviewers: aaron.ballman, gulfem, hans.
Herald added a project: All.
zequanwu requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This is a split of D147073 .

Fixes #45481


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D147569

Files:
  clang/lib/CodeGen/CoverageMappingGen.cpp
  clang/test/CoverageMapping/if.cpp


Index: clang/test/CoverageMapping/if.cpp
===
--- clang/test/CoverageMapping/if.cpp
+++ clang/test/CoverageMapping/if.cpp
@@ -1,6 +1,14 @@
-// RUN: %clang_cc1 -mllvm -emptyline-comment-coverage=false 
-fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping 
-emit-llvm-only -std=c++2b -triple %itanium_abi_triple -main-file-name if.cpp 
%s | FileCheck %s
+// RUN: %clang_cc1 -fms-extensions -mllvm -emptyline-comment-coverage=false 
-fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping 
-emit-llvm-only -std=c++2b -triple %itanium_abi_triple -main-file-name if.cpp 
%s | FileCheck %s
 
 int nop() { return 0; }
+struct S {
+   int i;
+   int putprop(int j) {
+  i = j;
+  return i;
+   }
+   __declspec(property(put = putprop)) int the_prop;
+};
 
 // CHECK-LABEL: _Z3foov:
 // CHECK-NEXT: [[@LINE+3]]:12 -> [[@LINE+8]]:2 
= #0
@@ -70,7 +78,17 @@
   constexpr int c_i = check_consteval(0);
   check_consteval(i);
 
-  return 0;
+  // GH-45481
+  S s;
+  s.the_prop = 0? 1 : 2;// CHECK-NEXT: File 0, [[@LINE]]:16 -> 
[[@LINE]]:17 = #0
+// CHECK-NEXT: Branch,File 0, [[@LINE-1]]:16 
-> [[@LINE-1]]:17 = 0, 0
+// CHECK-NEXT: Gap,File 0, [[@LINE-2]]:18 -> 
[[@LINE-2]]:19 = #7
+// CHECK-NEXT: File 0, [[@LINE-3]]:19 -> 
[[@LINE-3]]:20 = #7
+// CHECK-NEXT: File 0, [[@LINE-4]]:23 -> 
[[@LINE-4]]:24 = (#0 - #7)
+  if (s.the_prop = 1) { // CHECK-NEXT: File 0, [[@LINE]]:7 -> 
[[@LINE]]:21 = #0
+ return 1;  // CHECK-NEXT: Branch,File 0, [[@LINE-1]]:7 -> 
[[@LINE-1]]:21 = #8, (#0 - #8)
+  } // CHECK-NEXT: Gap,File 0, [[@LINE-2]]:22 -> 
[[@LINE-2]]:23 = #8
+// CHECK-NEXT: File 0, [[@LINE-3]]:23 -> 
[[@LINE-1]]:4 = #8
 }
 
 #define FOO true
Index: clang/lib/CodeGen/CoverageMappingGen.cpp
===
--- clang/lib/CodeGen/CoverageMappingGen.cpp
+++ clang/lib/CodeGen/CoverageMappingGen.cpp
@@ -1566,6 +1566,15 @@
 // Lambdas are treated as their own functions for now, so we shouldn't
 // propagate counts into them.
   }
+
+  void VisitPseudoObjectExpr(const PseudoObjectExpr *POE) {
+// Just visit syntatic expression as this is what users actually write.
+VisitStmt(POE->getSyntacticForm());
+  }
+
+  void VisitOpaqueValueExpr(const OpaqueValueExpr* OVE) {
+Visit(OVE->getSourceExpr());
+  }
 };
 
 } // end anonymous namespace


Index: clang/test/CoverageMapping/if.cpp
===
--- clang/test/CoverageMapping/if.cpp
+++ clang/test/CoverageMapping/if.cpp
@@ -1,6 +1,14 @@
-// RUN: %clang_cc1 -mllvm -emptyline-comment-coverage=false -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -std=c++2b -triple %itanium_abi_triple -main-file-name if.cpp %s | FileCheck %s
+// RUN: %clang_cc1 -fms-extensions -mllvm -emptyline-comment-coverage=false -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -std=c++2b -triple %itanium_abi_triple -main-file-name if.cpp %s | FileCheck %s
 
 int nop() { return 0; }
+struct S {
+   int i;
+   int putprop(int j) {
+  i = j;
+  return i;
+   }
+   __declspec(property(put = putprop)) int the_prop;
+};
 
 // CHECK-LABEL: _Z3foov:
 // CHECK-NEXT: [[@LINE+3]]:12 -> [[@LINE+8]]:2 = #0
@@ -70,7 +78,17 @@
   constexpr int c_i = check_consteval(0);
   check_consteval(i);
 
-  return 0;
+  // GH-45481
+  S s;
+  s.the_prop = 0? 1 : 2;// CHECK-NEXT: File 0, [[@LINE]]:16 -> [[@LINE]]:17 = #0
+// CHECK-NEXT: Branch,File 0, [[@LINE-1]]:16 -> [[@LINE-1]]:17 = 0, 0
+// CHECK-NEXT: Gap,File 0, [[@LINE-2]]:18 -> [[@LINE-2]]:19 = #7
+// CHECK-NEXT: File 0, [[@LINE-3]]:19 -> [[@LINE-3]]:20 = #7
+// CHECK-NEXT: File 0, [[@LINE-4]]:23 -> [[@LINE-4]]:24 = (#0 - #7)
+  if (s.the_prop = 1) { // CHECK-NEXT: File 0, [[@LINE]]:7 -> [[@LINE]]:21 = #0
+ return 1;  // CHECK-NEXT: Branch,File 0, [[@LINE-1]]:7 -> [[@LINE-1]]:21 = #8, (#0 - #8)
+  } // CHECK-NEXT: Gap,File 0, 

[PATCH] D146376: Update static_assert message for redundant cases

2023-04-04 Thread Krishna Narayanan via Phabricator via cfe-commits
Krishna-13-cyber updated this revision to Diff 510909.
Krishna-13-cyber added a comment.

- Updated with release note
- I had tried adding more text to the `expected-error` but it already gives a 
diagnostic of `static assertion failed due to requirement` currently. If I try 
additions to `{{failed}}` then we get **error diagnostics expected but not 
seen**.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146376

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/SemaCXX/static-assert.cpp


Index: clang/test/SemaCXX/static-assert.cpp
===
--- clang/test/SemaCXX/static-assert.cpp
+++ clang/test/SemaCXX/static-assert.cpp
@@ -258,8 +258,14 @@
   constexpr bool invert(bool b) {
 return !b;
   }
+
+  static_assert(invert(true) || invert(true), ""); // expected-error {{failed}}
   static_assert(invert(true) == invert(false), ""); // expected-error 
{{failed}} \
 // expected-note 
{{evaluates to 'false == true'}}
+  static_assert(true && false, ""); // expected-error {{failed}}
+  static_assert(invert(true) || invert(true) || false, ""); // expected-error 
{{failed}}
+  static_assert((true && invert(true)) || false, ""); // expected-error 
{{failed}}
+  static_assert(true && invert(false) && invert(true), ""); // expected-error 
{{failed}}
 
   /// No notes here since we compare a bool expression with a bool literal.
   static_assert(invert(true) == true, ""); // expected-error {{failed}}
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -16715,7 +16715,8 @@
 /// Try to print more useful information about a failed static_assert
 /// with expression \E
 void Sema::DiagnoseStaticAssertDetails(const Expr *E) {
-  if (const auto *Op = dyn_cast(E)) {
+  if (const auto *Op = dyn_cast(E);
+  Op && Op->getOpcode() != BO_LOr) {
 const Expr *LHS = Op->getLHS()->IgnoreParenImpCasts();
 const Expr *RHS = Op->getRHS()->IgnoreParenImpCasts();
 
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -179,6 +179,9 @@
 - Clang now avoids duplicate warnings on unreachable ``[[fallthrough]];`` 
statements
   previously issued from ``-Wunreachable-code`` and 
``-Wunreachable-code-fallthrough``
   by prioritizing ``-Wunreachable-code-fallthrough``.
+- Clang now avoids unnecessary diagnostic warnings for obvious expressions in
+  the case of binary operators with logical OR operations.
+  (`#57906 `_)
 
 Bug Fixes in This Version
 -


Index: clang/test/SemaCXX/static-assert.cpp
===
--- clang/test/SemaCXX/static-assert.cpp
+++ clang/test/SemaCXX/static-assert.cpp
@@ -258,8 +258,14 @@
   constexpr bool invert(bool b) {
 return !b;
   }
+
+  static_assert(invert(true) || invert(true), ""); // expected-error {{failed}}
   static_assert(invert(true) == invert(false), ""); // expected-error {{failed}} \
 // expected-note {{evaluates to 'false == true'}}
+  static_assert(true && false, ""); // expected-error {{failed}}
+  static_assert(invert(true) || invert(true) || false, ""); // expected-error {{failed}}
+  static_assert((true && invert(true)) || false, ""); // expected-error {{failed}}
+  static_assert(true && invert(false) && invert(true), ""); // expected-error {{failed}}
 
   /// No notes here since we compare a bool expression with a bool literal.
   static_assert(invert(true) == true, ""); // expected-error {{failed}}
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -16715,7 +16715,8 @@
 /// Try to print more useful information about a failed static_assert
 /// with expression \E
 void Sema::DiagnoseStaticAssertDetails(const Expr *E) {
-  if (const auto *Op = dyn_cast(E)) {
+  if (const auto *Op = dyn_cast(E);
+  Op && Op->getOpcode() != BO_LOr) {
 const Expr *LHS = Op->getLHS()->IgnoreParenImpCasts();
 const Expr *RHS = Op->getRHS()->IgnoreParenImpCasts();
 
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -179,6 +179,9 @@
 - Clang now avoids duplicate warnings on unreachable ``[[fallthrough]];`` statements
   previously issued from ``-Wunreachable-code`` and ``-Wunreachable-code-fallthrough``
   by prioritizing ``-Wunreachable-code-fallthrough``.
+- Clang now avoids unnecessary diagnostic 

[PATCH] D143128: [-Wunsafe-buffer-usage] Fix-Its transforming `[any]` to `()[any]`

2023-04-04 Thread Ziqing Luo 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 rG87b5807d3802: [-Wunsafe-buffer-usage] Fix-Its transforming 
`DRE[any]` to `DRE.data()[any]` (authored by ziqingluo-90).

Changed prior to commit:
  https://reviews.llvm.org/D143128?vs=503193=510914#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143128

Files:
  clang/include/clang/Analysis/Analyses/UnsafeBufferUsage.h
  clang/include/clang/Analysis/Analyses/UnsafeBufferUsageGadgets.def
  clang/lib/Analysis/UnsafeBufferUsage.cpp
  
clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-addressof-arraysubscript.cpp

Index: clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-addressof-arraysubscript.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-addressof-arraysubscript.cpp
@@ -0,0 +1,83 @@
+// RUN: %clang_cc1 -std=c++20 -Wunsafe-buffer-usage -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
+
+int f(unsigned long, void *);
+
+[[clang::unsafe_buffer_usage]]
+int unsafe_f(unsigned long, void *);
+
+void address_to_integer(int x) {
+  int * p = new int[10];
+  unsigned long n = (unsigned long) [5];
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:37-[[@LINE-1]]:42}:"()[5]"
+  unsigned long m = (unsigned long) [x];
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:37-[[@LINE-1]]:42}:"()[x]"
+}
+
+void call_argument(int x) {
+  int * p = new int[10];
+
+  f((unsigned long) [5], [x]);
+  // CHECK-DAG: fix-it:"{{.*}}":{[[@LINE-1]]:21-[[@LINE-1]]:26}:"()[5]"
+  // CHECK-DAG: fix-it:"{{.*}}":{[[@LINE-2]]:28-[[@LINE-2]]:33}:"()[x]"
+}
+
+void ignore_unsafe_calls(int x) {
+  // Cannot fix `[x]` for now as it is an argument of an unsafe
+  // call. So no fix for variable `p`.
+  int * p = new int[10];
+  // CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-1]]
+  unsafe_f((unsigned long) [5],
+	   // CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-1]]
+	   [x]);
+
+  int * q = new int[10];
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:12}:"std::span q"
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:13-[[@LINE-2]]:13}:"{"
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:24-[[@LINE-3]]:24}:", 10}"
+  unsafe_f((unsigned long) [5],
+	   // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:28-[[@LINE-1]]:33}:"()[5]"
+	   (void*)0);
+}
+
+void odd_subscript_form() {
+  int * p = new int[10];
+  unsigned long n = (unsigned long) &5[p];
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:37-[[@LINE-1]]:42}:"()[5]"
+}
+
+void index_is_zero() {
+  int * p = new int[10];
+  int n = p[5];
+
+  f((unsigned long)[0],
+// CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:20-[[@LINE-1]]:25}:"p.data()"
+[0]);
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:5-[[@LINE-1]]:10}:"p.data()"
+}
+
+// CHECK-NOT: fix-it
+// To test multiple function declarations, each of which carries
+// different incomplete informations:
+[[clang::unsafe_buffer_usage]]
+void unsafe_g(void*);
+
+void unsafe_g(void*);
+
+void multiple_unsafe_fundecls() {
+  int * p = new int[10];
+
+  unsafe_g([5]);
+}
+
+void unsafe_h(void*);
+
+[[clang::unsafe_buffer_usage]]
+void unsafe_h(void*);
+
+void unsafe_h(void* p) { ((char*)p)[10]; }
+
+void multiple_unsafe_fundecls2() {
+  int * p = new int[10];
+
+  unsafe_h([5]);
+}
Index: clang/lib/Analysis/UnsafeBufferUsage.cpp
===
--- clang/lib/Analysis/UnsafeBufferUsage.cpp
+++ clang/lib/Analysis/UnsafeBufferUsage.cpp
@@ -15,6 +15,7 @@
 #include "llvm/ADT/SmallVector.h"
 #include 
 #include 
+#include 
 
 using namespace llvm;
 using namespace clang;
@@ -112,6 +113,15 @@
   bool Matches;
 };
 
+// Because we're dealing with raw pointers, let's define what we mean by that.
+static auto hasPointerType() {
+return hasType(hasCanonicalType(pointerType()));
+}
+
+static auto hasArrayType() {
+return hasType(hasCanonicalType(arrayType()));
+}
+  
 AST_MATCHER_P(Stmt, forEveryDescendant, internal::Matcher, innerMatcher) {
   const DynTypedMatcher  = static_cast(innerMatcher);
 
@@ -145,6 +155,30 @@
 ));
 // clang-format off
 }
+
+
+// Returns a matcher that matches any expression `e` such that `InnerMatcher`
+// matches `e` and `e` is in an Unspecified Pointer Context (UPC).
+static internal::Matcher
+isInUnspecifiedPointerContext(internal::Matcher InnerMatcher) {
+  // A UPC can be
+  // 1. an argument of a function call (except the callee has [[unsafe_...]]
+  // attribute), or
+  // 2. the operand of a cast operation; or
+  // ...
+  auto CallArgMatcher =
+  callExpr(hasAnyArgument(allOf(
+   hasPointerType() /* array also decays to pointer type*/,
+   InnerMatcher)),
+   unless(callee(functionDecl(hasAttr(attr::UnsafeBufferUsage);
+  auto CastOperandMatcher =
+  explicitCastExpr(hasCastKind(CastKind::CK_PointerToIntegral),
+   

[clang] 87b5807 - [-Wunsafe-buffer-usage] Fix-Its transforming `[any]` to `()[any]`

2023-04-04 Thread via cfe-commits

Author: ziqingluo-90
Date: 2023-04-04T13:26:45-07:00
New Revision: 87b5807d3802b932c06d83c4287014872aa2caab

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

LOG: [-Wunsafe-buffer-usage] Fix-Its transforming `[any]` to 
`()[any]`

For an expression of the form `[any]` under an Unspecified
Pointer Context (UPC), we generate a fix-it for it with respect to a
strategy. In case the strategy is `std::span` (it is the only supported
one for now), the fix-it replaces the expression with
`()[any]`.

A UPC includes at least the contexts where
- the expression is being casted to an integer; and
- the expression is an argument of a call to a function that is not marked 
unsafe.

Reviewed by: NoQ, malavikasamak, t-rasmud, jkorous

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

Added: 

clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-addressof-arraysubscript.cpp

Modified: 
clang/include/clang/Analysis/Analyses/UnsafeBufferUsage.h
clang/include/clang/Analysis/Analyses/UnsafeBufferUsageGadgets.def
clang/lib/Analysis/UnsafeBufferUsage.cpp

Removed: 




diff  --git a/clang/include/clang/Analysis/Analyses/UnsafeBufferUsage.h 
b/clang/include/clang/Analysis/Analyses/UnsafeBufferUsage.h
index 8957ab664ed9..f78cf2c57689 100644
--- a/clang/include/clang/Analysis/Analyses/UnsafeBufferUsage.h
+++ b/clang/include/clang/Analysis/Analyses/UnsafeBufferUsage.h
@@ -43,7 +43,7 @@ class UnsafeBufferUsageHandler {
 
   /// Returns the text indicating that the user needs to provide input there:
   virtual std::string
-  getUserFillPlaceHolder(StringRef HintTextToUser = "placeholder") {
+  getUserFillPlaceHolder(StringRef HintTextToUser = "placeholder") const {
 std::string s = std::string("<# ");
 s += HintTextToUser;
 s += " #>";

diff  --git 
a/clang/include/clang/Analysis/Analyses/UnsafeBufferUsageGadgets.def 
b/clang/include/clang/Analysis/Analyses/UnsafeBufferUsageGadgets.def
index a8485682c1d1..f0c99a767071 100644
--- a/clang/include/clang/Analysis/Analyses/UnsafeBufferUsageGadgets.def
+++ b/clang/include/clang/Analysis/Analyses/UnsafeBufferUsageGadgets.def
@@ -30,9 +30,10 @@ WARNING_GADGET(Decrement)
 WARNING_GADGET(ArraySubscript)
 WARNING_GADGET(PointerArithmetic)
 WARNING_GADGET(UnsafeBufferUsageAttr)
-FIXABLE_GADGET(ULCArraySubscript)
+FIXABLE_GADGET(ULCArraySubscript)  // `DRE[any]` in an Unspecified 
Lvalue Context
 FIXABLE_GADGET(DerefSimplePtrArithFixable)
 FIXABLE_GADGET(PointerDereference)
+FIXABLE_GADGET(UPCAddressofArraySubscript) // '[any]' in an Unspecified 
Pointer Context
 
 #undef FIXABLE_GADGET
 #undef WARNING_GADGET

diff  --git a/clang/lib/Analysis/UnsafeBufferUsage.cpp 
b/clang/lib/Analysis/UnsafeBufferUsage.cpp
index 4a8358af68ec..1ef276ab9044 100644
--- a/clang/lib/Analysis/UnsafeBufferUsage.cpp
+++ b/clang/lib/Analysis/UnsafeBufferUsage.cpp
@@ -15,6 +15,7 @@
 #include "llvm/ADT/SmallVector.h"
 #include 
 #include 
+#include 
 
 using namespace llvm;
 using namespace clang;
@@ -112,6 +113,15 @@ class MatchDescendantVisitor
   bool Matches;
 };
 
+// Because we're dealing with raw pointers, let's define what we mean by that.
+static auto hasPointerType() {
+return hasType(hasCanonicalType(pointerType()));
+}
+
+static auto hasArrayType() {
+return hasType(hasCanonicalType(arrayType()));
+}
+  
 AST_MATCHER_P(Stmt, forEveryDescendant, internal::Matcher, innerMatcher) 
{
   const DynTypedMatcher  = static_cast(innerMatcher);
 
@@ -145,6 +155,30 @@ static auto 
isInUnspecifiedLvalueContext(internal::Matcher innerMatcher) {
 ));
 // clang-format off
 }
+
+
+// Returns a matcher that matches any expression `e` such that `InnerMatcher`
+// matches `e` and `e` is in an Unspecified Pointer Context (UPC).
+static internal::Matcher
+isInUnspecifiedPointerContext(internal::Matcher InnerMatcher) {
+  // A UPC can be
+  // 1. an argument of a function call (except the callee has [[unsafe_...]]
+  // attribute), or
+  // 2. the operand of a cast operation; or
+  // ...
+  auto CallArgMatcher =
+  callExpr(hasAnyArgument(allOf(
+   hasPointerType() /* array also decays to pointer type*/,
+   InnerMatcher)),
+   unless(callee(functionDecl(hasAttr(attr::UnsafeBufferUsage);
+  auto CastOperandMatcher =
+  explicitCastExpr(hasCastKind(CastKind::CK_PointerToIntegral),
+   castSubExpr(allOf(hasPointerType(), InnerMatcher)));
+
+ return stmt(anyOf(CallArgMatcher, CastOperandMatcher));
+  // FIXME: any more cases? (UPC excludes the RHS of an assignment.  For now we
+  // don't have to check that.)
+}
 } // namespace clang::ast_matchers
 
 namespace {
@@ -159,15 +193,6 @@ using FixItList = SmallVector;
 class Strategy;
 } // namespace
 
-// Because we're dealing with raw 

[PATCH] D147417: [clang-tidy] Do not emit bugprone-exception-escape warnings from coroutines

2023-04-04 Thread Deniz Evrenci via Phabricator via cfe-commits
denizevrenci added inline comments.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape-coro.cpp:75-79
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:11: warning: an exception may be thrown 
in function 'b_ShouldNotDiag' which should not throw exceptions
+  if (b == 0)
+throw b;
+
+  co_return a / b;

ChuanqiXu wrote:
> denizevrenci wrote:
> > ChuanqiXu wrote:
> > > I don't understand why we shouldn't emit the warning here. Since the 
> > > function is marked `noexcept` but it may throw actually in 
> > > `unhandled_exception`. I think it is meaningful to warn for this.
> > Right, I now see that this behavior is different between Clang's 
> > `-Wexceptions` and Clang Tidy's `bugprone-exception-escape`. The former 
> > does not warn on this code, the latter does.
> > 
> > ```
> > int foo() {
> >   throw 1;
> > }
> > 
> > int bar() noexcept {
> >   return foo();
> > }
> > ```
> > 
> > We need to treat coroutines differently and check whether `task::task`, 
> > `promise::promise`,  `promise::initial_suspend`, 
> > `promise::get_return_object`, and `promise::unhandled_exception` can throw 
> > instead of the body of the coroutine.
> I investigated the exception issue in coroutines before: 
> https://reviews.llvm.org/D108277. And it is much more complex than I thought. 
> The short conclusion here is that the coroutine is still may throw even if 
> all the promise's method wouldn't throw. For example:
> 
> ```
> struct Evil {
> ~Evil() noexcept(false) { throw 32; }
> };
> 
> task foo() noexcept { // all promise's method of task wouldn't throw
> throw Evil;
> }
> ```
> 
> And in the above example, foo() may throw actually. Although the implicit 
> `catch` block of `foo()` will catch `Evil`, the exception in the destructor 
> of `Evil` will be thrown again.
> 
> So we can't be sure that a coroutine wouldn't throw even if all of its 
> promise's method wouldn't throw.
It looks like the function `foo` can throw until the first suspension point in 
the coroutine. If `promise::initial_suspend` is `std::suspend_always`, then it 
will not throw. Of course, determining this statically is quite complicated.
But I also think that this is a rather niche example,  it looks like clang-tidy 
already warns with `bugprone-exception-escape` on the destructor of `Evil` even 
when it is marked `noexcept(false)`. I assume this is due to the other
complications brought by throwing from destructors. Would that not be the 
appropriate place to warn about this anyway?

For example, the code below terminates because the destructor of `Evil` gets 
called while there is an active exception.
```
task foo() { // all promise's method of task wouldn't throw
Evil e;
throw 1;
co_return;
}
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147417

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


[PATCH] D144304: [-Wunsafe-buffer-usage] Add a Fixable for pointer pre-increment

2023-04-04 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added a comment.
This revision is now accepted and ready to land.

LGTM!




Comment at: 
clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-addressof-arraysubscript.cpp:19
   bool a = (bool) [5];
-  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:19-[[@LINE-1]]:24}:"(p.data() + 5)"
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:19-[[@LINE-1]]:24}:"()[5]"
   bool b = (bool) [x];

These changes look unrelated, probably accidentally included from another patch 
樂



Comment at: clang/test/SemaCXX/warn-unsafe-buffer-usage.cpp:37
 
-void testArraySubscripts(int *p, int **pp) {
+void testArraySubscripts(int *p, int **pp) { // expected-note{{change type of 
'pp' to 'std::span' to preserve bounds information}}
 // expected-warning@-1{{'p' is an unsafe pointer used for buffer access}}

These also seem unrelated.


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

https://reviews.llvm.org/D144304

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


[PATCH] D147564: [clang] Mark CWG536 as N/A

2023-04-04 Thread Vlad Serebrennikov via Phabricator via cfe-commits
Endill created this revision.
Endill added a reviewer: clang-language-wg.
Herald added a project: All.
Endill requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

P1787 : CWG536 (long partially resolved) is resolved 
by specifying that unqualified lookup occurs for any kind of unqualified-id as 
an id-expression.
Wording: An unqualified name is a name that <...>. Unless otherwise specified, 
such a name undergoes unqualified name lookup from the point where it appears. 
([basic.lookup.unqual]/4)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D147564

Files:
  clang/test/CXX/drs/dr5xx.cpp
  clang/www/cxx_dr_status.html


Index: clang/www/cxx_dr_status.html
===
--- clang/www/cxx_dr_status.html
+++ clang/www/cxx_dr_status.html
@@ -3255,7 +3255,7 @@
 https://wg21.link/cwg536;>536
 CD6
 Problems in the description of id-expressions
-Unknown
+N/A
   
   
 https://wg21.link/cwg537;>537
Index: clang/test/CXX/drs/dr5xx.cpp
===
--- clang/test/CXX/drs/dr5xx.cpp
+++ clang/test/CXX/drs/dr5xx.cpp
@@ -417,6 +417,7 @@
 #endif
 }
 
+// dr536: na
 // dr537: na
 // dr538: na
 


Index: clang/www/cxx_dr_status.html
===
--- clang/www/cxx_dr_status.html
+++ clang/www/cxx_dr_status.html
@@ -3255,7 +3255,7 @@
 https://wg21.link/cwg536;>536
 CD6
 Problems in the description of id-expressions
-Unknown
+N/A
   
   
 https://wg21.link/cwg537;>537
Index: clang/test/CXX/drs/dr5xx.cpp
===
--- clang/test/CXX/drs/dr5xx.cpp
+++ clang/test/CXX/drs/dr5xx.cpp
@@ -417,6 +417,7 @@
 #endif
 }
 
+// dr536: na
 // dr537: na
 // dr538: na
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D146897: [clang:diagnostics] Turning off warn_self_assignment_overloaded for user-defined compound assignments

2023-04-04 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: clang/lib/Sema/SemaExpr.cpp:15656
   case BO_XorAssign:
-DiagnoseSelfAssignment(S, LHS, RHS, OpLoc, false);
 CheckIdentityFieldAssignment(LHS, RHS, OpLoc, S);
 break;

python3kgae wrote:
> rsmith wrote:
> > This is the same thing, but for `this->x += this->x`. I think we should 
> > also suppress those warnings for compound assignment, except when one of 
> > the operands is an implicit member access and one is an explicit member 
> > access (`this->x += x;` should still warn if the latter `x` is also 
> > interpreted as `this->x`).
> For case like this:
> 
> ```
> class Vector {
> public:
> Vector& operator+=(const Vector ) { return *this; }
> Vector& operator-=(const Vector ) { return *this; }
> };
> 
> class A {
> public:
>   A(){}
>   Vector x;
>   void foo() {
>  this->x -= this->x;
>  this->x -= x;
>  this->x += this->x;
>  this->x += x;
>   }
> };
> ```
> clang will report 2 warning:
> 
> ```
> :14:14: warning: assigning field to itself [-Wself-assign-field]
>  this->x -= this->x;
>  ^
> :15:14: warning: assigning field to itself [-Wself-assign-field]
>  this->x -= x;
> ```
> 
> Do you mean we should make it report warning on this->x -= x; and this->x += 
> x; ?
Let's not add any new warnings. Pretend my comment was about `-=`, not `+=`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146897

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


[PATCH] D146042: [clang-format] Fix numerous issues with "LambdaBodyIndentation: OuterScope" option

2023-04-04 Thread Jon Phillips via Phabricator via cfe-commits
jp4a50 marked 2 inline comments as done.
jp4a50 added a comment.

In D146042#4239182 , @owenpan wrote:

> In D146042#4204651 , @jp4a50 wrote:
>
>> I'm confident that the patch will indent all those examples correctly when 
>> they are at block scope which is the only place those snippets will actually 
>> be valid code. I added an exception (see comment in 
>> ContinuationIndenter.cpp) to the code to disable `OuterScope`'s behaviour 
>> when the line's indentation level is 0 (i.e. statements at namespace scope) 
>> because otherwise you can end up with things like:
>>
>>   Namespace::Foo::Foo(
>> Arg arg1, Arg arg2,
>> Arg arg3, Arg arg4)
>> : init1{arg1},
>>   init2{[arg2]() {
>> return arg2;
>>   }},
>>   init3{arg3},
>>   init4{arg4} {}
>
> Sorry that I missed it.

NP - as I say, I've removed this special casing for now since it is 
controversial to include it in a patch claiming to simply fix bugs.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146042

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


[PATCH] D147531: [clang] Reset track of immediate function context when entering new function

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

LGTM, thank you for the fix!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147531

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


[PATCH] D147563: [clang-tidy] Deprecate cert-dcl21-cpp

2023-04-04 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko accepted this revision.
Eugene.Zelenko added a comment.
This revision is now accepted and ready to land.

I think will be good idea to track deprecated features on GitHub issues with 
something like `deprecate in XYZ` label(s).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147563

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


[PATCH] D146042: [clang-format] Fix numerous issues with "LambdaBodyIndentation: OuterScope" option

2023-04-04 Thread Jon Phillips via Phabricator via cfe-commits
jp4a50 updated this revision to Diff 510901.
jp4a50 added a comment.

Tidy up docs and tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146042

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

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -22009,9 +22009,9 @@
   verifyFormat("void test() {\n"
"  (\n"
"  []() -> auto {\n"
-   "int b = 32;\n"
-   "return 3;\n"
-   "  },\n"
+   "int b = 32;\n"
+   "return 3;\n"
+   "  },\n"
"  foo, bar)\n"
"  .foo();\n"
"}",
@@ -22025,17 +22025,82 @@
"  .bar();\n"
"}",
Style);
-  Style = getGoogleStyle();
-  Style.LambdaBodyIndentation = FormatStyle::LBI_OuterScope;
-  verifyFormat("#define A   \\\n"
-   "  [] {  \\\n"
-   "xxx(\\\n"
-   "x); \\\n"
-   "  }",
-   Style);
-  // TODO: The current formatting has a minor issue that's not worth fixing
-  // right now whereby the closing brace is indented relative to the signature
-  // instead of being aligned. This only happens with macros.
+  verifyFormat("#define A  \\\n"
+   "  [] { \\\n"
+   "xxx(   \\\n"
+   "x);\\\n"
+   "  }",
+   Style);
+  verifyFormat("void foo() {\n"
+   "  aFunction(1, b(c(foo, bar, baz, [](d) {\n"
+   "auto f = e(d);\n"
+   "return f;\n"
+   "  })));\n"
+   "}",
+   Style);
+  Style.AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak;
+  verifyFormat("void foo() {\n"
+   "  aFunction(\n"
+   "  1, b(c(\n"
+   " [](d) -> Foo {\n"
+   "auto f = e(d);\n"
+   "return f;\n"
+   "  },\n"
+   " foo, Bar{},\n"
+   " [] {\n"
+   "auto g = h();\n"
+   "return g;\n"
+   "  },\n"
+   " baz)));\n"
+   "}",
+   Style);
+  verifyFormat("void foo() {\n"
+   "  aFunction(1, b(c(foo, Bar{}, baz, [](d) -> Foo {\n"
+   "auto f = e(\n"
+   "foo,\n"
+   "[&] {\n"
+   "  auto g = h();\n"
+   "  return g;\n"
+   "},\n"
+   "qux,\n"
+   "[&] -> Bar {\n"
+   "  auto i = j();\n"
+   "  return i;\n"
+   "});\n"
+   "return f;\n"
+   "  })));\n"
+   "}",
+   Style);
+  verifyFormat("Namespace::Foo::Foo(\n"
+   "LongClassName bar, AnotherLongClassName baz)\n"
+   ": baz{baz}, func{[&] {\n"
+   "  auto qux = bar;\n"
+   "  return aFunkyFunctionCall(qux);\n"
+   "}} {}",
+   Style);
+  Style.BreakBeforeBraces = FormatStyle::BS_Custom;
+  Style.BraceWrapping.BeforeLambdaBody = true;
+  verifyFormat("void foo() {\n"
+   "  aFunction(\n"
+   "  1, b(c(foo, Bar{}, baz,\n"
+   " [](d) -> Foo\n"
+   "  {\n"
+   "auto f = e(\n"
+   "[&]\n"
+   "{\n"
+   "  auto g = h();\n"
+   "  return g;\n"
+   "},\n"
+   "qux,\n"
+   "[&] -> Bar\n"
+   "{\n"
+   "  auto i = j();\n"
+   "  return i;\n"
+   "});\n"
+   "return f;\n"
+   "  })));\n"
+   "}",
+   Style);
 }
 
 TEST_F(FormatTest, LambdaWithLineComments) {
Index: clang/lib/Format/UnwrappedLineFormatter.cpp
===
--- clang/lib/Format/UnwrappedLineFormatter.cpp
+++ clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -1003,17 +1003,6 @@
 
   int 

[PATCH] D147563: [clang-tidy] Deprecate cert-dcl21-cpp

2023-04-04 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp created this revision.
Herald added subscribers: PiotrZSL, xazax.hun.
Herald added a reviewer: njames93.
Herald added a project: All.
carlosgalvezp requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

It is no longer part of the CERT standard. Looking at the
CERT webpage, we can see it has been moved to the Void
section:
https://wiki.sei.cmu.edu/confluence/display/cplusplus/5+The+Void


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D147563

Files:
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/cert/dcl21-cpp.rst


Index: clang-tools-extra/docs/clang-tidy/checks/cert/dcl21-cpp.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/cert/dcl21-cpp.rst
+++ clang-tools-extra/docs/clang-tidy/checks/cert/dcl21-cpp.rst
@@ -3,6 +3,10 @@
 cert-dcl21-cpp
 ==
 
+.. note::
+  This check is deprecated since it's no longer part of the CERT standard.
+  It will be removed in :program:`clang-tidy` version 19.
+
 This check flags postfix ``operator++`` and ``operator--`` declarations
 if the return type is not a const object. This also warns if the return type
 is a reference type.
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -183,6 +183,9 @@
   ` check to also cover constructor
   initializers.
 
+- Deprecated :doc:`cert-dcl21-cpp
+  ` check.
+
 - Deprecated check-local options `HeaderFileExtensions`
   in :doc:`google-build-namespaces
   ` check.


Index: clang-tools-extra/docs/clang-tidy/checks/cert/dcl21-cpp.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/cert/dcl21-cpp.rst
+++ clang-tools-extra/docs/clang-tidy/checks/cert/dcl21-cpp.rst
@@ -3,6 +3,10 @@
 cert-dcl21-cpp
 ==
 
+.. note::
+  This check is deprecated since it's no longer part of the CERT standard.
+  It will be removed in :program:`clang-tidy` version 19.
+
 This check flags postfix ``operator++`` and ``operator--`` declarations
 if the return type is not a const object. This also warns if the return type
 is a reference type.
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -183,6 +183,9 @@
   ` check to also cover constructor
   initializers.
 
+- Deprecated :doc:`cert-dcl21-cpp
+  ` check.
+
 - Deprecated check-local options `HeaderFileExtensions`
   in :doc:`google-build-namespaces
   ` check.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D147561: [clang] don't serialize MODULE_DIRECTORY with ModuleFileHomeIsCwd

2023-04-04 Thread Keith Smiley via Phabricator via cfe-commits
keith accepted this revision.
keith added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/test/Modules/module-file-home-is-cwd.m:7-8
 // RUN: -o %t/mod.pcm
 // RUN: llvm-bcanalyzer --dump --disable-histogram %t/mod.pcm | FileCheck %s
+// RUN: llvm-bcanalyzer --dump --disable-histogram %t/mod.pcm | FileCheck %s 
--check-prefix=INPUT
 

Instead of doing 2 invocations you can do `--check-prefixes=CHECK,INPUT`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147561

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


[PATCH] D147561: [clang] don't serialize MODULE_DIRECTORY with ModuleFileHomeIsCwd

2023-04-04 Thread Richard Howell via Phabricator via cfe-commits
rmaz created this revision.
Herald added a project: All.
rmaz requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Fix a bug in the MODULE_DIRECTORY serialization logic
that would cause MODULE_DIRECTORY to be serialized when
`-fmodule-file-home-is-cwd` is specified.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D147561

Files:
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/Modules/module-file-home-is-cwd.m


Index: clang/test/Modules/module-file-home-is-cwd.m
===
--- clang/test/Modules/module-file-home-is-cwd.m
+++ clang/test/Modules/module-file-home-is-cwd.m
@@ -5,11 +5,12 @@
 // RUN: -fmodules-embed-all-files %S/Inputs/normal-module-map/module.map \
 // RUN: -o %t/mod.pcm
 // RUN: llvm-bcanalyzer --dump --disable-histogram %t/mod.pcm | FileCheck %s
+// RUN: llvm-bcanalyzer --dump --disable-histogram %t/mod.pcm | FileCheck %s 
--check-prefix=INPUT
 
-// CHECK:  blob data = 
'Inputs{{/|\\}}normal-module-map{{/|\\}}module.map'
-// CHECK:  blob data = 
'Inputs{{/|\\}}normal-module-map{{/|\\}}a2.h'
-// CHECK:  blob data = 
'Inputs{{/|\\}}normal-module-map{{/|\\}}a1.h'
 // CHECK-NOT: MODULE_DIRECTORY
+// INPUT:  blob data = 
'Inputs{{/|\\}}normal-module-map{{/|\\}}module.map'
+// INPUT:  blob data = 
'Inputs{{/|\\}}normal-module-map{{/|\\}}a2.h'
+// INPUT:  blob data = 
'Inputs{{/|\\}}normal-module-map{{/|\\}}a1.h'
 
 @import libA;
 
Index: clang/lib/Serialization/ASTWriter.cpp
===
--- clang/lib/Serialization/ASTWriter.cpp
+++ clang/lib/Serialization/ASTWriter.cpp
@@ -1288,11 +1288,11 @@
 // If the home of the module is the current working directory, then we
 // want to pick up the cwd of the build process loading the module, not
 // our cwd, when we load this module.
-if (!(PP.getHeaderSearchInfo()
+if (!PP.getHeaderSearchInfo().getHeaderSearchOpts().ModuleFileHomeIsCwd &&
+(!PP.getHeaderSearchInfo()
   .getHeaderSearchOpts()
   .ModuleMapFileHomeIsCwd ||
-  PP.getHeaderSearchInfo().getHeaderSearchOpts().ModuleFileHomeIsCwd) 
||
-WritingModule->Directory->getName() != StringRef(".")) {
+ WritingModule->Directory->getName() != StringRef("."))) {
   // Module directory.
   auto Abbrev = std::make_shared();
   Abbrev->Add(BitCodeAbbrevOp(MODULE_DIRECTORY));


Index: clang/test/Modules/module-file-home-is-cwd.m
===
--- clang/test/Modules/module-file-home-is-cwd.m
+++ clang/test/Modules/module-file-home-is-cwd.m
@@ -5,11 +5,12 @@
 // RUN: -fmodules-embed-all-files %S/Inputs/normal-module-map/module.map \
 // RUN: -o %t/mod.pcm
 // RUN: llvm-bcanalyzer --dump --disable-histogram %t/mod.pcm | FileCheck %s
+// RUN: llvm-bcanalyzer --dump --disable-histogram %t/mod.pcm | FileCheck %s --check-prefix=INPUT
 
-// CHECK:  blob data = 'Inputs{{/|\\}}normal-module-map{{/|\\}}module.map'
-// CHECK:  blob data = 'Inputs{{/|\\}}normal-module-map{{/|\\}}a2.h'
-// CHECK:  blob data = 'Inputs{{/|\\}}normal-module-map{{/|\\}}a1.h'
 // CHECK-NOT: MODULE_DIRECTORY
+// INPUT:  blob data = 'Inputs{{/|\\}}normal-module-map{{/|\\}}module.map'
+// INPUT:  blob data = 'Inputs{{/|\\}}normal-module-map{{/|\\}}a2.h'
+// INPUT:  blob data = 'Inputs{{/|\\}}normal-module-map{{/|\\}}a1.h'
 
 @import libA;
 
Index: clang/lib/Serialization/ASTWriter.cpp
===
--- clang/lib/Serialization/ASTWriter.cpp
+++ clang/lib/Serialization/ASTWriter.cpp
@@ -1288,11 +1288,11 @@
 // If the home of the module is the current working directory, then we
 // want to pick up the cwd of the build process loading the module, not
 // our cwd, when we load this module.
-if (!(PP.getHeaderSearchInfo()
+if (!PP.getHeaderSearchInfo().getHeaderSearchOpts().ModuleFileHomeIsCwd &&
+(!PP.getHeaderSearchInfo()
   .getHeaderSearchOpts()
   .ModuleMapFileHomeIsCwd ||
-  PP.getHeaderSearchInfo().getHeaderSearchOpts().ModuleFileHomeIsCwd) ||
-WritingModule->Directory->getName() != StringRef(".")) {
+ WritingModule->Directory->getName() != StringRef("."))) {
   // Module directory.
   auto Abbrev = std::make_shared();
   Abbrev->Add(BitCodeAbbrevOp(MODULE_DIRECTORY));
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D147175: [clang] Add __is_trivially_equality_comparable

2023-04-04 Thread Nikolas Klauser via Phabricator via cfe-commits
philnik updated this revision to Diff 510887.
philnik added a comment.

Remove formatting changes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147175

Files:
  clang/docs/LanguageExtensions.rst
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/AST/Type.h
  clang/include/clang/Basic/TokenKinds.def
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/Type.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/SemaCXX/type-traits.cpp
  libcxx/include/__algorithm/equal.h
  libcxx/include/__string/constexpr_c_functions.h
  libcxx/include/__type_traits/is_equality_comparable.h
  libcxx/test/libcxx/type_traits/is_trivially_comparable.compile.pass.cpp

Index: libcxx/test/libcxx/type_traits/is_trivially_comparable.compile.pass.cpp
===
--- libcxx/test/libcxx/type_traits/is_trivially_comparable.compile.pass.cpp
+++ libcxx/test/libcxx/type_traits/is_trivially_comparable.compile.pass.cpp
@@ -13,32 +13,32 @@
 enum Enum : int {};
 enum class EnumClass : int {};
 
-static_assert(std::__is_trivially_equality_comparable::value, "");
-static_assert(std::__is_trivially_equality_comparable::value, "");
-static_assert(std::__is_trivially_equality_comparable::value, "");
+static_assert(std::__libcpp_is_trivially_equality_comparable::value, "");
+static_assert(std::__libcpp_is_trivially_equality_comparable::value, "");
+static_assert(std::__libcpp_is_trivially_equality_comparable::value, "");
 
-static_assert(std::__is_trivially_equality_comparable::value, "");
-static_assert(std::__is_trivially_equality_comparable::value, "");
-static_assert(!std::__is_trivially_equality_comparable::value, "");
+static_assert(std::__libcpp_is_trivially_equality_comparable::value, "");
+static_assert(std::__libcpp_is_trivially_equality_comparable::value, "");
+static_assert(!std::__libcpp_is_trivially_equality_comparable::value, "");
 
-static_assert(!std::__is_trivially_equality_comparable::value, "");
-static_assert(!std::__is_trivially_equality_comparable::value, "");
+static_assert(!std::__libcpp_is_trivially_equality_comparable::value, "");
+static_assert(!std::__libcpp_is_trivially_equality_comparable::value, "");
 
-static_assert(std::__is_trivially_equality_comparable::value, "");
-static_assert(std::__is_trivially_equality_comparable::value, "");
-static_assert(!std::__is_trivially_equality_comparable::value, "");
+static_assert(std::__libcpp_is_trivially_equality_comparable::value, "");
+static_assert(std::__libcpp_is_trivially_equality_comparable::value, "");
+static_assert(!std::__libcpp_is_trivially_equality_comparable::value, "");
 
-static_assert(!std::__is_trivially_equality_comparable::value, "");
-static_assert(!std::__is_trivially_equality_comparable::value, "");
+static_assert(!std::__libcpp_is_trivially_equality_comparable::value, "");
+static_assert(!std::__libcpp_is_trivially_equality_comparable::value, "");
 
-static_assert(!std::__is_trivially_equality_comparable::value, "");
-static_assert(!std::__is_trivially_equality_comparable::value, "");
+static_assert(!std::__libcpp_is_trivially_equality_comparable::value, "");
+static_assert(!std::__libcpp_is_trivially_equality_comparable::value, "");
 
-static_assert(!std::__is_trivially_equality_comparable::value, "");
+static_assert(!std::__libcpp_is_trivially_equality_comparable::value, "");
 
-static_assert(!std::__is_trivially_equality_comparable::value, "");
-static_assert(!std::__is_trivially_equality_comparable::value, "");
-static_assert(!std::__is_trivially_equality_comparable::value, "");
+static_assert(!std::__libcpp_is_trivially_equality_comparable::value, "");
+static_assert(!std::__libcpp_is_trivially_equality_comparable::value, "");
+static_assert(!std::__libcpp_is_trivially_equality_comparable::value, "");
 
 struct S {
   char c;
@@ -51,8 +51,8 @@
 struct VirtualBase : virtual S {};
 struct NonVirtualBase : S, S2 {};
 
-static_assert(!std::__is_trivially_equality_comparable::value, "");
-static_assert(!std::__is_trivially_equality_comparable::value, "");
+static_assert(!std::__libcpp_is_trivially_equality_comparable::value, "");
+static_assert(!std::__libcpp_is_trivially_equality_comparable::value, "");
 
 // This is trivially_equality_comparable, but we can't detect it currently
-static_assert(!std::__is_trivially_equality_comparable::value, "");
+static_assert(!std::__libcpp_is_trivially_equality_comparable::value, "");
Index: libcxx/include/__type_traits/is_equality_comparable.h
===
--- libcxx/include/__type_traits/is_equality_comparable.h
+++ libcxx/include/__type_traits/is_equality_comparable.h
@@ -43,14 +43,14 @@
 //   always compared.
 
 template 
-struct __is_trivially_equality_comparable
+struct __libcpp_is_trivially_equality_comparable
 : integral_constant::value && is_integral<_Tp>::value &&
   

[PATCH] D146101: [clang-format] Add BracedInitializerIndentWidth option.

2023-04-04 Thread Jon Phillips via Phabricator via cfe-commits
jp4a50 added inline comments.



Comment at: clang/include/clang/Format/Format.h:949
+  /// If unset, ``ContinuationIndentWidth`` is used.
+  /// \code
+  ///   AlignAfterOpenBracket: AlwaysBreak

owenpan wrote:
> HazardyKnusperkeks wrote:
> > jp4a50 wrote:
> > > MyDeveloperDay wrote:
> > > > did you check generating the html from the rst? I can never remember if 
> > > > we need a newline before the \code
> > > Nope - how do I do that exactly? I would guess a newline is not needed 
> > > based on other examples.
> > > did you check generating the html from the rst? I can never remember if 
> > > we need a newline before the \code
> > 
> > 
> > Nope - how do I do that exactly? I would guess a newline is not needed 
> > based on other examples.
> 
> See D147327#4236718.
HTML looks good.



Comment at: clang/lib/Format/ContinuationIndenter.cpp:1659
   opensProtoMessageField(Current, Style)) {
+const FormatToken *NextNonComment = Current.getNextNonComment();
 if (Current.opensBlockOrBlockTypeList(Style)) {

HazardyKnusperkeks wrote:
> Why did you move it?
I originally needed it in the new `else if` block since I was checking if it 
was a designated initializer period but the condition has since changed. Thanks 
for spotting. I've moved it back.



Comment at: clang/lib/Format/ContinuationIndenter.cpp:1664-1668
+  const auto BracedInitializerIndentWidth =
+  Style.BracedInitializerIndentWidth
+  ? *Style.BracedInitializerIndentWidth
+  : Style.ContinuationIndentWidth;
+  NewIndent = CurrentState.LastSpace + BracedInitializerIndentWidth;

HazardyKnusperkeks wrote:
> You can keep the local variable if you want, but please use `value_or`, it 
> expresses the intent better.
Have used `.value_or()` and got rid of temp variable since it's more concise 
now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146101

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


[PATCH] D146101: [clang-format] Add BracedInitializerIndentWidth option.

2023-04-04 Thread Jon Phillips via Phabricator via cfe-commits
jp4a50 updated this revision to Diff 510886.
jp4a50 added a comment.

Minor review comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146101

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/docs/ReleaseNotes.rst
  clang/docs/tools/dump_format_style.py
  clang/include/clang/Format/Format.h
  clang/lib/Format/ContinuationIndenter.cpp
  clang/lib/Format/Format.cpp
  clang/unittests/Format/ConfigParseTest.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -4855,6 +4855,191 @@
"[5] = ee};");
 }
 
+TEST_F(FormatTest, BracedInitializerIndentWidth) {
+  auto Style = getLLVMStyleWithColumns(60);
+  Style.BinPackArguments = true;
+  Style.AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak;
+  Style.BracedInitializerIndentWidth = 6;
+
+  // Non-initializing braces are unaffected by BracedInitializerIndentWidth.
+  verifyFormat("enum class {\n"
+   "  One,\n"
+   "  Two,\n"
+   "};\n",
+   Style);
+  verifyFormat("class Foo {\n"
+   "  Foo() {}\n"
+   "  void bar();\n"
+   "};\n",
+   Style);
+  verifyFormat("void foo() {\n"
+   "  auto bar = baz;\n"
+   "  return baz;\n"
+   "};\n",
+   Style);
+  verifyFormat("auto foo = [&] {\n"
+   "  auto bar = baz;\n"
+   "  return baz;\n"
+   "};\n",
+   Style);
+  verifyFormat("{\n"
+   "  auto bar = baz;\n"
+   "  return baz;\n"
+   "};\n",
+   Style);
+  // Non-brace initialization is unaffected by BracedInitializerIndentWidth.
+  verifyFormat("SomeClass clazz(\n"
+   "\"xx\", \"yy\",\n"
+   "\"zz\");\n",
+   Style);
+
+  // The following types of initialization are all affected by
+  // BracedInitializerIndentWidth. Aggregate initialization.
+  verifyFormat("int LongVariable[2] = {\n"
+   "  1000, 2000};",
+   Style);
+  verifyFormat("SomeStruct s{\n"
+   "  \"\", \"\",\n"
+   "  \"\"};\n",
+   Style);
+  // Designated initializers.
+  verifyFormat("int LongVariable[1] = {\n"
+   "  [0] = 1000, [1] = 2000};",
+   Style);
+  verifyFormat("SomeStruct s{\n"
+   "  .foo = \"x\",\n"
+   "  .bar = \"y\",\n"
+   "  .baz = \"z\"};\n",
+   Style);
+  // List initialization.
+  verifyFormat("SomeStruct s{\n"
+   "  \"x\",\n"
+   "  \"y\",\n"
+   "  \"z\",\n"
+   "};\n",
+   Style);
+  verifyFormat("SomeStruct{\n"
+   "  \"x\",\n"
+   "  \"y\",\n"
+   "  \"z\",\n"
+   "};\n",
+   Style);
+  verifyFormat("new SomeStruct{\n"
+   "  \"x\",\n"
+   "  \"y\",\n"
+   "  \"z\",\n"
+   "};\n",
+   Style);
+  // Member initializer.
+  verifyFormat("class SomeClass {\n"
+   "  SomeStruct s{\n"
+   "\"x\",\n"
+   "\"y\",\n"
+   "\"z\",\n"
+   "  };\n"
+   "};\n",
+   Style);
+  // Constructor member initializer.
+  verifyFormat("SomeClass::SomeClass : strct{\n"
+   " \"x\",\n"
+   " \"y\",\n"
+   " \"z\",\n"
+   "   } {}\n",
+   Style);
+  // Copy initialization.
+  verifyFormat("SomeStruct s = SomeStruct{\n"
+   "  \"x\",\n"
+   "  \"y\",\n"
+   "  \"z\",\n"
+   "};\n",
+   Style);
+  // Copy list initialization.
+  verifyFormat("SomeStruct s = {\n"
+   "  \"x\",\n"
+   "  \"y\",\n"
+   "  \"z\",\n"
+   "};\n",
+   Style);
+  // Assignment operand initialization.
+  verifyFormat("s = {\n"
+   "  \"x\",\n"
+   " 

[PATCH] D147556: [clang-format] Add BracedInitializerIndentWidth option.

2023-04-04 Thread Jon Phillips via Phabricator via cfe-commits
jp4a50 abandoned this revision.
jp4a50 added a comment.

Sorry - this is a duplicate of https://reviews.llvm.org/D146101 created by 
accident. Closing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147556

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


[PATCH] D141215: [clang-repl] Introduce Value to capture expression results

2023-04-04 Thread Jun Zhang via Phabricator via cfe-commits
junaire updated this revision to Diff 510885.
junaire added a comment.

Update


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141215

Files:
  clang/include/clang/AST/Decl.h
  clang/include/clang/Basic/TokenKinds.def
  clang/include/clang/Interpreter/Interpreter.h
  clang/include/clang/Interpreter/Value.h
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/Sema.h
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Frontend/PrintPreprocessedOutput.cpp
  clang/lib/Interpreter/CMakeLists.txt
  clang/lib/Interpreter/IncrementalExecutor.cpp
  clang/lib/Interpreter/IncrementalExecutor.h
  clang/lib/Interpreter/IncrementalParser.cpp
  clang/lib/Interpreter/IncrementalParser.h
  clang/lib/Interpreter/Interpreter.cpp
  clang/lib/Interpreter/InterpreterUtils.cpp
  clang/lib/Interpreter/InterpreterUtils.h
  clang/lib/Interpreter/Value.cpp
  clang/lib/Lex/PPLexerChange.cpp
  clang/lib/Parse/ParseCXXInlineMethods.cpp
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseStmt.cpp
  clang/lib/Parse/Parser.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/tools/clang-repl/CMakeLists.txt
  clang/unittests/Interpreter/CMakeLists.txt
  clang/unittests/Interpreter/InterpreterTest.cpp

Index: clang/unittests/Interpreter/InterpreterTest.cpp
===
--- clang/unittests/Interpreter/InterpreterTest.cpp
+++ clang/unittests/Interpreter/InterpreterTest.cpp
@@ -17,6 +17,7 @@
 #include "clang/AST/Mangle.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/TextDiagnosticPrinter.h"
+#include "clang/Interpreter/Value.h"
 #include "clang/Sema/Lookup.h"
 #include "clang/Sema/Sema.h"
 
@@ -33,6 +34,10 @@
 #define CLANG_INTERPRETER_NO_SUPPORT_EXEC
 #endif
 
+int Global = 42;
+int getGlobal() { return Global; }
+void setGlobal(int val) { Global = val; }
+
 namespace {
 using Args = std::vector;
 static std::unique_ptr
@@ -276,8 +281,7 @@
   std::vector Args = {"-fno-delayed-template-parsing"};
   std::unique_ptr Interp = createInterpreter(Args);
 
-  llvm::cantFail(Interp->Parse("void* operator new(__SIZE_TYPE__, void* __p);"
-   "extern \"C\" int printf(const char*,...);"
+  llvm::cantFail(Interp->Parse("extern \"C\" int printf(const char*,...);"
"class A {};"
"struct B {"
"  template"
@@ -314,4 +318,38 @@
   free(NewA);
 }
 
+TEST(InterpreterTest, Value) {
+  std::unique_ptr Interp = createInterpreter();
+
+  Value V1;
+  llvm::cantFail(Interp->ParseAndExecute("int x = 42;"));
+  llvm::cantFail(Interp->ParseAndExecute("x", ));
+  EXPECT_EQ(V1.getInt(), 42);
+  EXPECT_TRUE(V1.getType()->isIntegerType());
+
+  Value V2;
+  llvm::cantFail(Interp->ParseAndExecute("double y = 3.14;"));
+  llvm::cantFail(Interp->ParseAndExecute("y", ));
+  EXPECT_EQ(V2.getAs(), 3.14);
+  EXPECT_TRUE(V2.getType()->isFloatingType());
+  EXPECT_EQ(V2.castAs(), 3);
+
+  llvm::cantFail(Interp->ParseAndExecute("int getGlobal();"));
+  llvm::cantFail(Interp->ParseAndExecute("void setGlobal(int);"));
+  Value V3;
+  llvm::cantFail(Interp->ParseAndExecute("getGlobal()", ));
+  EXPECT_EQ(V3.getInt(), 42);
+  EXPECT_TRUE(V3.getType()->isIntegerType());
+
+  // Change the global from the compiled code.
+  setGlobal(43);
+  Value V4;
+  llvm::cantFail(Interp->ParseAndExecute("getGlobal()", ));
+  EXPECT_EQ(V4.getInt(), 43);
+  EXPECT_TRUE(V4.getType()->isIntegerType());
+
+  // Change the global from the interpreted code.
+  llvm::cantFail(Interp->ParseAndExecute("setGlobal(44);"));
+  EXPECT_EQ(getGlobal(), 44);
+}
 } // end anonymous namespace
Index: clang/unittests/Interpreter/CMakeLists.txt
===
--- clang/unittests/Interpreter/CMakeLists.txt
+++ clang/unittests/Interpreter/CMakeLists.txt
@@ -22,3 +22,5 @@
 if(NOT WIN32)
   add_subdirectory(ExceptionTests)
 endif()
+
+export_executable_symbols(ClangReplInterpreterTests)
Index: clang/tools/clang-repl/CMakeLists.txt
===
--- clang/tools/clang-repl/CMakeLists.txt
+++ clang/tools/clang-repl/CMakeLists.txt
@@ -12,6 +12,7 @@
   )
 
 clang_target_link_libraries(clang-repl PRIVATE
+  clangAST
   clangBasic
   clangFrontend
   clangInterpreter
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -19849,6 +19849,15 @@
   Context.getTranslationUnitDecl()->addDecl(New);
   return New;
 }
+Decl *Sema::SynthesizeDeclForValuePrinting(Stmt *S) {
+  Expr *E = cast(S);
+  if (ValuePrintingTransformer) {
+Decl *D = (*ValuePrintingTransformer)(E);
+Context.getTranslationUnitDecl()->addDecl(D);
+return D;
+  }
+  return nullptr;
+}
 
 void Sema::ActOnPragmaRedefineExtname(IdentifierInfo* Name,
  

[PATCH] D146389: [clang-repl][CUDA] Initial interactive CUDA support for clang-repl

2023-04-04 Thread Simeon Ehrig via Phabricator via cfe-commits
SimeonEhrig added inline comments.



Comment at: clang/tools/clang-repl/ClangRepl.cpp:135
+std::move(CI), std::move(DeviceCI), OffloadArch,
+"/tmp/clang-repl.fatbin"));
+

v.g.vassilev wrote:
> To cover the case where platforms have no `/tmp` we could use 
> `fs::createTemporaryFile`. However, some platforms have read-only file 
> systems. What do we do there?
Actual, we can avoid temporary files completely. The reason, why the fatbinary 
code is written to a file is the following code in the code generator of the 
CUDA runtime functions:

https://github.com/llvm/llvm-project/blob/d9d840cdaf51a9795930750d1b91d614a3849137/clang/lib/CodeGen/CGCUDANV.cpp#L722-L732

In the past, I avoided to change the code, because this was an extra Clang 
patch for Cling.

Maybe we can use the llvm virtualFileSystem: 
https://llvm.org/doxygen/classllvm_1_1vfs_1_1InMemoryFileSystem.html
But this is just an idea. I have no experience, if this is working for us.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146389

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


[PATCH] D147556: [clang-format] Add BracedInitializerIndentWidth option.

2023-04-04 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added a comment.

Um, was this a mistake? What is with D146101 ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147556

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


[PATCH] D147556: [clang-format] Add BracedInitializerIndentWidth option.

2023-04-04 Thread Jon Phillips via Phabricator via cfe-commits
jp4a50 created this revision.
Herald added projects: All, clang, clang-format.
Herald added a subscriber: cfe-commits.
Herald added reviewers: rymiel, HazardyKnusperkeks, owenpan, MyDeveloperDay.
jp4a50 requested review of this revision.

The option allows users to specify how many columns to use to indent
the contents of braced init lists.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D147556

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/docs/ReleaseNotes.rst
  clang/docs/tools/dump_format_style.py
  clang/include/clang/Format/Format.h
  clang/lib/Format/ContinuationIndenter.cpp
  clang/lib/Format/Format.cpp
  clang/unittests/Format/ConfigParseTest.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -4855,6 +4855,191 @@
"[5] = ee};");
 }
 
+TEST_F(FormatTest, BracedInitializerIndentWidth) {
+  auto Style = getLLVMStyleWithColumns(60);
+  Style.BinPackArguments = true;
+  Style.AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak;
+  Style.BracedInitializerIndentWidth = 6;
+
+  // Non-initializing braces are unaffected by BracedInitializerIndentWidth.
+  verifyFormat("enum class {\n"
+   "  One,\n"
+   "  Two,\n"
+   "};\n",
+   Style);
+  verifyFormat("class Foo {\n"
+   "  Foo() {}\n"
+   "  void bar();\n"
+   "};\n",
+   Style);
+  verifyFormat("void foo() {\n"
+   "  auto bar = baz;\n"
+   "  return baz;\n"
+   "};\n",
+   Style);
+  verifyFormat("auto foo = [&] {\n"
+   "  auto bar = baz;\n"
+   "  return baz;\n"
+   "};\n",
+   Style);
+  verifyFormat("{\n"
+   "  auto bar = baz;\n"
+   "  return baz;\n"
+   "};\n",
+   Style);
+  // Non-brace initialization is unaffected by BracedInitializerIndentWidth.
+  verifyFormat("SomeClass clazz(\n"
+   "\"xx\", \"yy\",\n"
+   "\"zz\");\n",
+   Style);
+
+  // The following types of initialization are all affected by
+  // BracedInitializerIndentWidth. Aggregate initialization.
+  verifyFormat("int LongVariable[2] = {\n"
+   "  1000, 2000};",
+   Style);
+  verifyFormat("SomeStruct s{\n"
+   "  \"\", \"\",\n"
+   "  \"\"};\n",
+   Style);
+  // Designated initializers.
+  verifyFormat("int LongVariable[1] = {\n"
+   "  [0] = 1000, [1] = 2000};",
+   Style);
+  verifyFormat("SomeStruct s{\n"
+   "  .foo = \"x\",\n"
+   "  .bar = \"y\",\n"
+   "  .baz = \"z\"};\n",
+   Style);
+  // List initialization.
+  verifyFormat("SomeStruct s{\n"
+   "  \"x\",\n"
+   "  \"y\",\n"
+   "  \"z\",\n"
+   "};\n",
+   Style);
+  verifyFormat("SomeStruct{\n"
+   "  \"x\",\n"
+   "  \"y\",\n"
+   "  \"z\",\n"
+   "};\n",
+   Style);
+  verifyFormat("new SomeStruct{\n"
+   "  \"x\",\n"
+   "  \"y\",\n"
+   "  \"z\",\n"
+   "};\n",
+   Style);
+  // Member initializer.
+  verifyFormat("class SomeClass {\n"
+   "  SomeStruct s{\n"
+   "\"x\",\n"
+   "\"y\",\n"
+   "\"z\",\n"
+   "  };\n"
+   "};\n",
+   Style);
+  // Constructor member initializer.
+  verifyFormat("SomeClass::SomeClass : strct{\n"
+   " \"x\",\n"
+   " \"y\",\n"
+   " \"z\",\n"
+   "   } {}\n",
+   Style);
+  // Copy initialization.
+  verifyFormat("SomeStruct s = SomeStruct{\n"
+   "  \"x\",\n"
+   "  \"y\",\n"
+   "  \"z\",\n"
+   "};\n",
+   Style);
+  // Copy list initialization.
+  verifyFormat("SomeStruct s = {\n"
+   "  \"x\",\n"
+   "  \"y\",\n"
+   "  

[PATCH] D146897: [clang:diagnostics] Turning off warn_self_assignment_overloaded for user-defined compound assignments

2023-04-04 Thread Xiang Li via Phabricator via cfe-commits
python3kgae added inline comments.



Comment at: clang/lib/Sema/SemaExpr.cpp:15656
   case BO_XorAssign:
-DiagnoseSelfAssignment(S, LHS, RHS, OpLoc, false);
 CheckIdentityFieldAssignment(LHS, RHS, OpLoc, S);
 break;

rsmith wrote:
> This is the same thing, but for `this->x += this->x`. I think we should also 
> suppress those warnings for compound assignment, except when one of the 
> operands is an implicit member access and one is an explicit member access 
> (`this->x += x;` should still warn if the latter `x` is also interpreted as 
> `this->x`).
For case like this:

```
class Vector {
public:
Vector& operator+=(const Vector ) { return *this; }
Vector& operator-=(const Vector ) { return *this; }
};

class A {
public:
  A(){}
  Vector x;
  void foo() {
 this->x -= this->x;
 this->x -= x;
 this->x += this->x;
 this->x += x;
  }
};
```
clang will report 2 warning:

```
:14:14: warning: assigning field to itself [-Wself-assign-field]
 this->x -= this->x;
 ^
:15:14: warning: assigning field to itself [-Wself-assign-field]
 this->x -= x;
```

Do you mean we should make it report warning on this->x -= x; and this->x += x; 
?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146897

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


[PATCH] D147530: [clang] Add test for CWG191

2023-04-04 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik accepted this revision.
shafik 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/D147530/new/

https://reviews.llvm.org/D147530

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


[PATCH] D147554: [clang] Mark CWG562 as N/A

2023-04-04 Thread Vlad Serebrennikov via Phabricator via cfe-commits
Endill created this revision.
Endill added a reviewer: clang-language-wg.
Herald added a project: All.
Endill requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

P1787 : CWG562 is resolved by defining lookup as 
occurring from a program point.
Wording: A single search in a scope S for a name N from a program point P finds 
all declarations that precede P to which any name that is the same as N 
([basic.pre]) is bound in S. ([basic.lookup]/2)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D147554

Files:
  clang/test/CXX/drs/dr5xx.cpp
  clang/www/cxx_dr_status.html


Index: clang/www/cxx_dr_status.html
===
--- clang/www/cxx_dr_status.html
+++ clang/www/cxx_dr_status.html
@@ -3413,7 +3413,7 @@
 https://wg21.link/cwg562;>562
 CD6
 qualified-ids in non-expression contexts
-Unknown
+N/A
   
   
 https://wg21.link/cwg563;>563
Index: clang/test/CXX/drs/dr5xx.cpp
===
--- clang/test/CXX/drs/dr5xx.cpp
+++ clang/test/CXX/drs/dr5xx.cpp
@@ -3,6 +3,7 @@
 // RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors
 // RUN: %clang_cc1 -std=c++17 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors
 // RUN: %clang_cc1 -std=c++20 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors
+// RUN: %clang_cc1 -std=c++2b %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors
 
 // FIXME: This is included to avoid a diagnostic with no source location
 // pointing at the implicit operator new. We can't match such a diagnostic
@@ -643,6 +644,8 @@
   }
 }
 
+// dr562: na
+
 namespace dr564 { // dr564: yes
   extern "C++" void f(int);
   void f(int); // ok


Index: clang/www/cxx_dr_status.html
===
--- clang/www/cxx_dr_status.html
+++ clang/www/cxx_dr_status.html
@@ -3413,7 +3413,7 @@
 https://wg21.link/cwg562;>562
 CD6
 qualified-ids in non-expression contexts
-Unknown
+N/A
   
   
 https://wg21.link/cwg563;>563
Index: clang/test/CXX/drs/dr5xx.cpp
===
--- clang/test/CXX/drs/dr5xx.cpp
+++ clang/test/CXX/drs/dr5xx.cpp
@@ -3,6 +3,7 @@
 // RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
 // RUN: %clang_cc1 -std=c++17 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
 // RUN: %clang_cc1 -std=c++20 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++2b %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
 
 // FIXME: This is included to avoid a diagnostic with no source location
 // pointing at the implicit operator new. We can't match such a diagnostic
@@ -643,6 +644,8 @@
   }
 }
 
+// dr562: na
+
 namespace dr564 { // dr564: yes
   extern "C++" void f(int);
   void f(int); // ok
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D147551: [clang-tidy] Fix init-list handling in readability-implicit-bool-conversion

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

Adds support for explicit casts using initListExpr,
for example: int{boolValue} constructions.

Fixes: #47000


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D147551

Files:
  clang-tools-extra/clang-tidy/readability/ImplicitBoolConversionCheck.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/test/clang-tidy/checkers/readability/implicit-bool-conversion.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/readability/implicit-bool-conversion.cpp
===
--- 
clang-tools-extra/test/clang-tidy/checkers/readability/implicit-bool-conversion.cpp
+++ 
clang-tools-extra/test/clang-tidy/checkers/readability/implicit-bool-conversion.cpp
@@ -471,3 +471,10 @@
 }
 
 } // namespace ignore_1bit_bitfields
+
+namespace PR47000 {
+  int to_int(bool x) { return int{x}; }
+
+  using IntType = int;
+  int to_int2(bool x) { return IntType{x}; }
+}
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -237,6 +237,10 @@
   behavior of using `i` as the prefix for enum tags, set the 
`EnumConstantPrefix`
   option to `i` instead of using `EnumConstantHungarianPrefix`.
 
+- Fixed a false positive in :doc:`readability-implicit-bool-conversion
+  ` check warning would
+  be unnecessarily emitted for explicit cast using direct list initialization.
+
 - Added support to optionally ignore user-defined literals in
   
:doc:`readability-magic-numbers`.
 
Index: clang-tools-extra/clang-tidy/readability/ImplicitBoolConversionCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/ImplicitBoolConversionCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/ImplicitBoolConversionCheck.cpp
@@ -262,7 +262,10 @@
   expr(anyOf(allOf(isMacroExpansion(), unless(isNULLMacroExpansion())),
  has(ignoringImplicit(
  memberExpr(hasDeclaration(fieldDecl(hasBitWidth(1)),
- hasParent(explicitCastExpr(;
+ hasParent(explicitCastExpr()),
+ expr(hasType(qualType().bind("type")),
+  hasParent(initListExpr(hasParent(explicitCastExpr(
+  hasType(qualType(equalsBoundNode("type"));
   auto ImplicitCastFromBool = implicitCastExpr(
   anyOf(hasCastKind(CK_IntegralCast), hasCastKind(CK_IntegralToFloating),
 // Prior to C++11 cast from bool literal to pointer was allowed.
@@ -290,7 +293,7 @@
unless(ExceptionCases), unless(has(BoolXor)),
// Retrieve also parent statement, to check if we need
// additional parens in replacement.
-   anyOf(hasParent(stmt().bind("parentStmt")), anything()),
+   optionally(hasParent(stmt().bind("parentStmt"))),
unless(isInTemplateInstantiation()),
unless(hasAncestor(functionTemplateDecl(
.bind("implicitCastToBool")),


Index: clang-tools-extra/test/clang-tidy/checkers/readability/implicit-bool-conversion.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability/implicit-bool-conversion.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability/implicit-bool-conversion.cpp
@@ -471,3 +471,10 @@
 }
 
 } // namespace ignore_1bit_bitfields
+
+namespace PR47000 {
+  int to_int(bool x) { return int{x}; }
+
+  using IntType = int;
+  int to_int2(bool x) { return IntType{x}; }
+}
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -237,6 +237,10 @@
   behavior of using `i` as the prefix for enum tags, set the `EnumConstantPrefix`
   option to `i` instead of using `EnumConstantHungarianPrefix`.
 
+- Fixed a false positive in :doc:`readability-implicit-bool-conversion
+  ` check warning would
+  be unnecessarily emitted for explicit cast using direct list initialization.
+
 - Added support to optionally ignore user-defined literals in
   :doc:`readability-magic-numbers`.
 
Index: clang-tools-extra/clang-tidy/readability/ImplicitBoolConversionCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/ImplicitBoolConversionCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/ImplicitBoolConversionCheck.cpp
@@ -262,7 +262,10 @@
   

[PATCH] D147175: [clang] Add __is_trivially_equality_comparable

2023-04-04 Thread Nikolas Klauser via Phabricator via cfe-commits
philnik updated this revision to Diff 510865.
philnik marked 5 inline comments as done.
philnik added a comment.

Address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147175

Files:
  clang/docs/LanguageExtensions.rst
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/AST/Type.h
  clang/include/clang/Basic/TokenKinds.def
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/Type.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/SemaCXX/type-traits.cpp
  libcxx/include/__algorithm/equal.h
  libcxx/include/__string/constexpr_c_functions.h
  libcxx/include/__type_traits/is_equality_comparable.h
  libcxx/test/libcxx/type_traits/is_trivially_comparable.compile.pass.cpp

Index: libcxx/test/libcxx/type_traits/is_trivially_comparable.compile.pass.cpp
===
--- libcxx/test/libcxx/type_traits/is_trivially_comparable.compile.pass.cpp
+++ libcxx/test/libcxx/type_traits/is_trivially_comparable.compile.pass.cpp
@@ -13,32 +13,32 @@
 enum Enum : int {};
 enum class EnumClass : int {};
 
-static_assert(std::__is_trivially_equality_comparable::value, "");
-static_assert(std::__is_trivially_equality_comparable::value, "");
-static_assert(std::__is_trivially_equality_comparable::value, "");
+static_assert(std::__libcpp_is_trivially_equality_comparable::value, "");
+static_assert(std::__libcpp_is_trivially_equality_comparable::value, "");
+static_assert(std::__libcpp_is_trivially_equality_comparable::value, "");
 
-static_assert(std::__is_trivially_equality_comparable::value, "");
-static_assert(std::__is_trivially_equality_comparable::value, "");
-static_assert(!std::__is_trivially_equality_comparable::value, "");
+static_assert(std::__libcpp_is_trivially_equality_comparable::value, "");
+static_assert(std::__libcpp_is_trivially_equality_comparable::value, "");
+static_assert(!std::__libcpp_is_trivially_equality_comparable::value, "");
 
-static_assert(!std::__is_trivially_equality_comparable::value, "");
-static_assert(!std::__is_trivially_equality_comparable::value, "");
+static_assert(!std::__libcpp_is_trivially_equality_comparable::value, "");
+static_assert(!std::__libcpp_is_trivially_equality_comparable::value, "");
 
-static_assert(std::__is_trivially_equality_comparable::value, "");
-static_assert(std::__is_trivially_equality_comparable::value, "");
-static_assert(!std::__is_trivially_equality_comparable::value, "");
+static_assert(std::__libcpp_is_trivially_equality_comparable::value, "");
+static_assert(std::__libcpp_is_trivially_equality_comparable::value, "");
+static_assert(!std::__libcpp_is_trivially_equality_comparable::value, "");
 
-static_assert(!std::__is_trivially_equality_comparable::value, "");
-static_assert(!std::__is_trivially_equality_comparable::value, "");
+static_assert(!std::__libcpp_is_trivially_equality_comparable::value, "");
+static_assert(!std::__libcpp_is_trivially_equality_comparable::value, "");
 
-static_assert(!std::__is_trivially_equality_comparable::value, "");
-static_assert(!std::__is_trivially_equality_comparable::value, "");
+static_assert(!std::__libcpp_is_trivially_equality_comparable::value, "");
+static_assert(!std::__libcpp_is_trivially_equality_comparable::value, "");
 
-static_assert(!std::__is_trivially_equality_comparable::value, "");
+static_assert(!std::__libcpp_is_trivially_equality_comparable::value, "");
 
-static_assert(!std::__is_trivially_equality_comparable::value, "");
-static_assert(!std::__is_trivially_equality_comparable::value, "");
-static_assert(!std::__is_trivially_equality_comparable::value, "");
+static_assert(!std::__libcpp_is_trivially_equality_comparable::value, "");
+static_assert(!std::__libcpp_is_trivially_equality_comparable::value, "");
+static_assert(!std::__libcpp_is_trivially_equality_comparable::value, "");
 
 struct S {
   char c;
@@ -51,8 +51,8 @@
 struct VirtualBase : virtual S {};
 struct NonVirtualBase : S, S2 {};
 
-static_assert(!std::__is_trivially_equality_comparable::value, "");
-static_assert(!std::__is_trivially_equality_comparable::value, "");
+static_assert(!std::__libcpp_is_trivially_equality_comparable::value, "");
+static_assert(!std::__libcpp_is_trivially_equality_comparable::value, "");
 
 // This is trivially_equality_comparable, but we can't detect it currently
-static_assert(!std::__is_trivially_equality_comparable::value, "");
+static_assert(!std::__libcpp_is_trivially_equality_comparable::value, "");
Index: libcxx/include/__type_traits/is_equality_comparable.h
===
--- libcxx/include/__type_traits/is_equality_comparable.h
+++ libcxx/include/__type_traits/is_equality_comparable.h
@@ -43,14 +43,14 @@
 //   always compared.
 
 template 
-struct __is_trivially_equality_comparable
+struct __libcpp_is_trivially_equality_comparable
 : integral_constant::value && 

[PATCH] D147175: [clang] Add __is_trivially_equality_comparable

2023-04-04 Thread Nikolas Klauser via Phabricator via cfe-commits
philnik added a comment.

In D147175#4240572 , @aaron.ballman 
wrote:

> Hmmm, is this effectively `std::has_unique_object_representations` (ensuring 
> that all bits of the object representation contribute to the value)?

These two traits are indeed very similar. The main difference is that 
`has_unique_object_representations` requires that the type is trivially 
copyable, and `__is_trivially_equality_comparable` requires a defaulted 
equality comparison operator.




Comment at: clang/lib/AST/Type.cpp:2640
+
+  return false;
+}

aaron.ballman wrote:
> I think this might be missing cases, like complex integers, scoped 
> enumerations, vector types?, pointer types, atomic versions of these types...
I think this should be covered by the switch to using 
`hasUniqueObjectRepresentation`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147175

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


[PATCH] D146389: [clang-repl][CUDA] Initial interactive CUDA support for clang-repl

2023-04-04 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev added inline comments.



Comment at: clang/tools/clang-repl/ClangRepl.cpp:137
+
+ExitOnErr(Interp->LoadDynamicLibrary("libcudart.so"));
+  } else

tra wrote:
> v.g.vassilev wrote:
> > tra wrote:
> > > Is there any doc describing the big picture approach to CUDA REPL 
> > > implementation and how all the pieces tie together?
> > > 
> > > From the patch I see that we will compile GPU side of the code to PTX, 
> > > pack it into fatbinary, but it's not clear now do we get from there to 
> > > actually launching the kernels. Loading libcudart.so here also does not 
> > > appear to be tied to anything else. I do not see any direct API calls, 
> > > and the host-side compilation appears to be done w.o passing the GPU 
> > > binary to it, which would normally trigger generation of the glue code to 
> > > register the kernels with CUDA runtime. I may be missing something, too.
> > > 
> > > I assume the gaps will be filled in in future patches, but I'm still 
> > > curious about the overall plan.
> > > 
> > > 
> > Hi @tra, thanks for asking. Our reference implementation was done in Cling 
> > a while ago by @SimeonEhrig. One of his talks which I think describes well 
> > the big picture could be found here: 
> > https://compiler-research.org/meetings/#caas_04Mar2021
> Cling does ring the bell. The slides from the link above do look OK.
> 
There is also a video.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146389

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


[PATCH] D146389: [clang-repl][CUDA] Initial interactive CUDA support for clang-repl

2023-04-04 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

> Initial interactive CUDA support for clang-repl

What should a user expect to be supported, functionality wise? I assume it 
should cover parsing and compilation. I'm not so sure about the execution. 
Should it be expected to actually launch kernels, or will that come in a future 
patch?




Comment at: clang/tools/clang-repl/ClangRepl.cpp:137
+
+ExitOnErr(Interp->LoadDynamicLibrary("libcudart.so"));
+  } else

v.g.vassilev wrote:
> tra wrote:
> > Is there any doc describing the big picture approach to CUDA REPL 
> > implementation and how all the pieces tie together?
> > 
> > From the patch I see that we will compile GPU side of the code to PTX, pack 
> > it into fatbinary, but it's not clear now do we get from there to actually 
> > launching the kernels. Loading libcudart.so here also does not appear to be 
> > tied to anything else. I do not see any direct API calls, and the host-side 
> > compilation appears to be done w.o passing the GPU binary to it, which 
> > would normally trigger generation of the glue code to register the kernels 
> > with CUDA runtime. I may be missing something, too.
> > 
> > I assume the gaps will be filled in in future patches, but I'm still 
> > curious about the overall plan.
> > 
> > 
> Hi @tra, thanks for asking. Our reference implementation was done in Cling a 
> while ago by @SimeonEhrig. One of his talks which I think describes well the 
> big picture could be found here: 
> https://compiler-research.org/meetings/#caas_04Mar2021
Cling does ring the bell. The slides from the link above do look OK.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146389

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


[PATCH] D146897: [clang:diagnostics] Turning off warn_self_assignment_overloaded for user-defined compound assignments

2023-04-04 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: clang/lib/Sema/SemaExpr.cpp:15656
   case BO_XorAssign:
-DiagnoseSelfAssignment(S, LHS, RHS, OpLoc, false);
 CheckIdentityFieldAssignment(LHS, RHS, OpLoc, S);
 break;

This is the same thing, but for `this->x += this->x`. I think we should also 
suppress those warnings for compound assignment, except when one of the 
operands is an implicit member access and one is an explicit member access 
(`this->x += x;` should still warn if the latter `x` is also interpreted as 
`this->x`).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146897

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


[PATCH] D147549: [clang] Add test for CWG255

2023-04-04 Thread Vlad Serebrennikov via Phabricator via cfe-commits
Endill created this revision.
Endill added a reviewer: clang-language-wg.
Herald added a project: All.
Endill requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

P1787 : CWG255 (partially resolved by N3778 is 
resolved by generally specifying the restriction to usual deallocation 
functions.
Wording: In any case, any declarations other than of usual deallocation 
functions ([basic.stc.dynamic.deallocation]) are discarded. ([expr.delete]/9)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D147549

Files:
  clang/test/CXX/drs/dr2xx.cpp
  clang/www/cxx_dr_status.html


Index: clang/www/cxx_dr_status.html
===
--- clang/www/cxx_dr_status.html
+++ clang/www/cxx_dr_status.html
@@ -1568,7 +1568,7 @@
 https://wg21.link/cwg255;>255
 CD6
 Placement deallocation functions and lookup ambiguity
-Unknown
+Yes
   
   
 https://wg21.link/cwg256;>256
Index: clang/test/CXX/drs/dr2xx.cpp
===
--- clang/test/CXX/drs/dr2xx.cpp
+++ clang/test/CXX/drs/dr2xx.cpp
@@ -3,6 +3,7 @@
 // RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors
 // RUN: %clang_cc1 -std=c++17 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors
 // RUN: %clang_cc1 -std=c++20 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors
+// RUN: %clang_cc1 -std=c++2b %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors
 
 // PR13819 -- __SIZE_TYPE__ is incompatible.
 typedef __SIZE_TYPE__ size_t; // expected-error 0-1 {{extension}}
@@ -692,6 +693,14 @@
   A::type n; // expected-note {{instantiation of}}
 }
 
+namespace dr255 { // dr255: yes
+struct S {
+  void operator delete(void *){};
+  void operator delete(void *, int){};
+};
+void f(S *p) { delete p; }
+} // namespace dr255
+
 // dr256: dup 624
 
 namespace dr257 { // dr257: yes


Index: clang/www/cxx_dr_status.html
===
--- clang/www/cxx_dr_status.html
+++ clang/www/cxx_dr_status.html
@@ -1568,7 +1568,7 @@
 https://wg21.link/cwg255;>255
 CD6
 Placement deallocation functions and lookup ambiguity
-Unknown
+Yes
   
   
 https://wg21.link/cwg256;>256
Index: clang/test/CXX/drs/dr2xx.cpp
===
--- clang/test/CXX/drs/dr2xx.cpp
+++ clang/test/CXX/drs/dr2xx.cpp
@@ -3,6 +3,7 @@
 // RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
 // RUN: %clang_cc1 -std=c++17 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
 // RUN: %clang_cc1 -std=c++20 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++2b %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
 
 // PR13819 -- __SIZE_TYPE__ is incompatible.
 typedef __SIZE_TYPE__ size_t; // expected-error 0-1 {{extension}}
@@ -692,6 +693,14 @@
   A::type n; // expected-note {{instantiation of}}
 }
 
+namespace dr255 { // dr255: yes
+struct S {
+  void operator delete(void *){};
+  void operator delete(void *, int){};
+};
+void f(S *p) { delete p; }
+} // namespace dr255
+
 // dr256: dup 624
 
 namespace dr257 { // dr257: yes
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D146389: [clang-repl][CUDA] Initial interactive CUDA support for clang-repl

2023-04-04 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev added a subscriber: SimeonEhrig.
v.g.vassilev added inline comments.



Comment at: clang/tools/clang-repl/ClangRepl.cpp:137
+
+ExitOnErr(Interp->LoadDynamicLibrary("libcudart.so"));
+  } else

tra wrote:
> Is there any doc describing the big picture approach to CUDA REPL 
> implementation and how all the pieces tie together?
> 
> From the patch I see that we will compile GPU side of the code to PTX, pack 
> it into fatbinary, but it's not clear now do we get from there to actually 
> launching the kernels. Loading libcudart.so here also does not appear to be 
> tied to anything else. I do not see any direct API calls, and the host-side 
> compilation appears to be done w.o passing the GPU binary to it, which would 
> normally trigger generation of the glue code to register the kernels with 
> CUDA runtime. I may be missing something, too.
> 
> I assume the gaps will be filled in in future patches, but I'm still curious 
> about the overall plan.
> 
> 
Hi @tra, thanks for asking. Our reference implementation was done in Cling a 
while ago by @SimeonEhrig. One of his talks which I think describes well the 
big picture could be found here: 
https://compiler-research.org/meetings/#caas_04Mar2021


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146389

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


[PATCH] D146389: [clang-repl][CUDA] Initial interactive CUDA support for clang-repl

2023-04-04 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: clang/tools/clang-repl/ClangRepl.cpp:27
+static llvm::cl::opt CudaEnabled("cuda", llvm::cl::Hidden);
+static llvm::cl::opt OffloadArch("offload-arch", 
llvm::cl::Hidden);
+

Where will clang-repl find CUDA headers? Generally speaking `--cuda-path` is 
essential for CUDA compilation as it's fairly common for users to have more 
than one CUDA SDK versions installed, or to have them installed in a 
non-default location.



Comment at: clang/tools/clang-repl/ClangRepl.cpp:137
+
+ExitOnErr(Interp->LoadDynamicLibrary("libcudart.so"));
+  } else

Is there any doc describing the big picture approach to CUDA REPL 
implementation and how all the pieces tie together?

From the patch I see that we will compile GPU side of the code to PTX, pack it 
into fatbinary, but it's not clear now do we get from there to actually 
launching the kernels. Loading libcudart.so here also does not appear to be 
tied to anything else. I do not see any direct API calls, and the host-side 
compilation appears to be done w.o passing the GPU binary to it, which would 
normally trigger generation of the glue code to register the kernels with CUDA 
runtime. I may be missing something, too.

I assume the gaps will be filled in in future patches, but I'm still curious 
about the overall plan.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146389

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


[PATCH] D102107: [OpenMP] Codegen aggregate for outlined function captures

2023-04-04 Thread Dhruva Chakrabarti via Phabricator via cfe-commits
dhruvachak added a comment.

In D102107#4243260 , @jhuber6 wrote:

> Fixed the Clang tests. Haven't touched the LLVM ones because this breaks 
> SPMDzation and state machine rewrites completely in those tests. Someone who 
> knows what this patch changes should look into what needs to be updated to 
> make those tests match whatever form SPDMzation expects now. Also for some 
> bizarre reason this patch breaks adding `alwaysinline` on `kmpc_parallel_51`.

I hadn't looked into whether OpenMPOpt was working ok, so did not realize this 
breakage. @jdoerfert If you get a chance, please look into this problem ^^.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102107

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


[PATCH] D146399: [AIX][Clang][K] Create `-K` Option for AIX.

2023-04-04 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added a comment.

@francii, what happens when `-K` is used on a pure-compile (`-c`) invocation? 
Do we get an "unused" message? Should we be testing that?
I think we should be testing the diagnostic for the "wrong target" usage as 
well?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146399

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


[PATCH] D145441: [AMDGPU] Define data layout entries for buffers

2023-04-04 Thread Krzysztof Drewniak via Phabricator via cfe-commits
krzysz00 updated this revision to Diff 510848.
krzysz00 added a comment.

Rebase data layout changes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145441

Files:
  clang/lib/Basic/Targets/AMDGPU.cpp
  clang/test/CodeGen/target-data.c
  clang/test/CodeGenOpenCL/amdgpu-env-amdgcn.cl
  llvm/docs/AMDGPUUsage.rst
  llvm/lib/IR/AutoUpgrade.cpp
  llvm/lib/Target/AMDGPU/AMDGPU.h
  llvm/lib/Target/AMDGPU/AMDGPUAliasAnalysis.cpp
  llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
  llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp
  llvm/lib/Target/AMDGPU/SIISelLowering.cpp
  llvm/test/CodeGen/AMDGPU/GlobalISel/buffer-atomic-fadd.f32-no-rtn.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/buffer-atomic-fadd.f32-rtn.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/buffer-atomic-fadd.f64.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/buffer-atomic-fadd.v2f16-no-rtn.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/buffer-atomic-fadd.v2f16-rtn.ll
  
llvm/test/CodeGen/AMDGPU/GlobalISel/irtranslator-non-integral-address-spaces.ll
  
llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-llvm.amdgcn.image.atomic.dim.a16.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-llvm.amdgcn.image.dim.a16.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-llvm.amdgcn.image.load.2d.d16.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-llvm.amdgcn.image.load.2d.ll
  
llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-llvm.amdgcn.image.load.2darraymsaa.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-llvm.amdgcn.image.load.3d.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-llvm.amdgcn.image.sample.a16.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-llvm.amdgcn.image.sample.d.ll
  
llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-llvm.amdgcn.image.sample.g16.a16.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-llvm.amdgcn.image.sample.g16.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-llvm.amdgcn.image.store.2d.d16.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.image.atomic.dim.mir
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.raw.buffer.atomic.add.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.raw.buffer.atomic.cmpswap.ll
  
llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.raw.buffer.atomic.fadd-with-ret.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.raw.buffer.atomic.fadd.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.raw.buffer.load.format.f16.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.raw.buffer.load.format.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.raw.buffer.load.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.raw.buffer.store.format.f16.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.raw.buffer.store.format.f32.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.raw.buffer.store.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.raw.tbuffer.load.f16.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.raw.tbuffer.load.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.raw.tbuffer.store.f16.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.raw.tbuffer.store.i8.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.raw.tbuffer.store.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.struct.buffer.atomic.add.ll
  
llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.struct.buffer.atomic.cmpswap.ll
  
llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.struct.buffer.atomic.fadd-with-ret.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.struct.buffer.atomic.fadd.ll
  
llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.struct.buffer.load.format.f16.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.struct.buffer.load.format.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.struct.buffer.load.ll
  
llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.struct.buffer.store.format.f16.ll
  
llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.struct.buffer.store.format.f32.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.struct.buffer.store.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.struct.tbuffer.load.f16.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.struct.tbuffer.load.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/regbankselect-amdgcn.image.load.1d.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/regbankselect-amdgcn.image.sample.1d.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/regbankselect-amdgcn.raw.buffer.load.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/regbankselect-amdgcn.struct.buffer.load.ll
  
llvm/test/CodeGen/AMDGPU/GlobalISel/regbankselect-amdgcn.struct.buffer.store.ll
  llvm/test/CodeGen/AMDGPU/addrspacecast-captured.ll
  llvm/test/CodeGen/AMDGPU/annotate-kernel-features-hsa.ll
  llvm/test/CodeGen/AMDGPU/buffer-atomic-fadd.f32-no-rtn.ll
  llvm/test/CodeGen/AMDGPU/buffer-atomic-fadd.f32-rtn.ll
  llvm/test/CodeGen/AMDGPU/buffer-atomic-fadd.f64.ll
  llvm/test/CodeGen/AMDGPU/buffer-atomic-fadd.v2f16-no-rtn.ll
  llvm/test/CodeGen/AMDGPU/buffer-atomic-fadd.v2f16-rtn.ll
  llvm/test/CodeGen/AMDGPU/buffer-intrinsics-mmo-offsets.ll
  

[PATCH] D146759: [ExtractAPI] Remove extra attributes in property declaration fragments

2023-04-04 Thread Zixu Wang via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG32b53cf9d0c8: [ExtractAPI] Remove extra attributes in 
property declaration fragments (authored by Unique_Usman, committed by zixuw).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146759

Files:
  clang/lib/ExtractAPI/DeclarationFragments.cpp
  clang/test/ExtractAPI/objc_category.m
  clang/test/ExtractAPI/objc_id_protocol.m
  clang/test/ExtractAPI/objc_interface.m
  clang/test/ExtractAPI/objc_property.m

Index: clang/test/ExtractAPI/objc_property.m
===
--- clang/test/ExtractAPI/objc_property.m
+++ clang/test/ExtractAPI/objc_property.m
@@ -161,38 +161,6 @@
   "kind": "keyword",
   "spelling": "class"
 },
-{
-  "kind": "text",
-  "spelling": ", "
-},
-{
-  "kind": "keyword",
-  "spelling": "atomic"
-},
-{
-  "kind": "text",
-  "spelling": ", "
-},
-{
-  "kind": "keyword",
-  "spelling": "assign"
-},
-{
-  "kind": "text",
-  "spelling": ", "
-},
-{
-  "kind": "keyword",
-  "spelling": "unsafe_unretained"
-},
-{
-  "kind": "text",
-  "spelling": ", "
-},
-{
-  "kind": "keyword",
-  "spelling": "readwrite"
-},
 {
   "kind": "text",
   "spelling": ") "
@@ -255,39 +223,7 @@
 },
 {
   "kind": "text",
-  "spelling": " ("
-},
-{
-  "kind": "keyword",
-  "spelling": "atomic"
-},
-{
-  "kind": "text",
-  "spelling": ", "
-},
-{
-  "kind": "keyword",
-  "spelling": "assign"
-},
-{
-  "kind": "text",
-  "spelling": ", "
-},
-{
-  "kind": "keyword",
-  "spelling": "unsafe_unretained"
-},
-{
-  "kind": "text",
-  "spelling": ", "
-},
-{
-  "kind": "keyword",
-  "spelling": "readwrite"
-},
-{
-  "kind": "text",
-  "spelling": ") "
+  "spelling": " "
 },
 {
   "kind": "typeIdentifier",
@@ -353,38 +289,6 @@
   "kind": "keyword",
   "spelling": "class"
 },
-{
-  "kind": "text",
-  "spelling": ", "
-},
-{
-  "kind": "keyword",
-  "spelling": "atomic"
-},
-{
-  "kind": "text",
-  "spelling": ", "
-},
-{
-  "kind": "keyword",
-  "spelling": "assign"
-},
-{
-  "kind": "text",
-  "spelling": ", "
-},
-{
-  "kind": "keyword",
-  "spelling": "unsafe_unretained"
-},
-{
-  "kind": "text",
-  "spelling": ", "
-},
-{
-  "kind": "keyword",
-  "spelling": "readwrite"
-},
 {
   "kind": "text",
   "spelling": ") "
@@ -447,39 +351,7 @@
 },
 {
   "kind": "text",
-  "spelling": " ("
-},
-{
-  "kind": "keyword",
-  "spelling": "atomic"
-},
-{
-  "kind": "text",
-  "spelling": ", "
-},
-{
-  "kind": "keyword",
-  "spelling": "assign"
-},
-{
-  "kind": "text",
-  "spelling": ", "
-},
-{
-  "kind": "keyword",
-  "spelling": "unsafe_unretained"
-},
-{
-  "kind": "text",
-  "spelling": ", "
-},
-{
-  "kind": "keyword",
-  "spelling": "readwrite"
-},
-{
-  "kind": "text",
-  "spelling": ") "
+  "spelling": " "
 },
 {
   "kind": "typeIdentifier",
@@ -595,38 +467,6 @@
   "kind": "keyword",
   "spelling": "class"
 },
-{
-  "kind": "text",
-  "spelling": ", "
-},
-{
-  "kind": "keyword",
-  "spelling": "atomic"
-},
-{
-  "kind": "text",
-  "spelling": ", "
-},
-{
-  "kind": "keyword",
-  "spelling": "assign"
-},
-{
-  "kind": "text",
-  "spelling": ", "
-},
-{
-  "kind": "keyword",
-  "spelling": "unsafe_unretained"
-},
-{
-  "kind": "text",
-  "spelling": ", "
-},
-{
-  "kind": "keyword",
-  "spelling": "readwrite"
-},
 {
   

[clang] 32b53cf - [ExtractAPI] Remove extra attributes in property declaration fragments

2023-04-04 Thread Zixu Wang via cfe-commits

Author: Usman Akinyemi
Date: 2023-04-04T10:00:34-07:00
New Revision: 32b53cf9d0c8c0e01ce5b0e7d5c717202a98cdf5

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

LOG: [ExtractAPI] Remove extra attributes in property declaration fragments

Use `getPropertyAttributesAsWritten` instead of `getPropertyAttributes`
to get property attributes actually specified in the source code.
Resolves issue #61478.

https://reviews.llvm.org/D146759

Reviewed By: zixuw, dang

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

Added: 


Modified: 
clang/lib/ExtractAPI/DeclarationFragments.cpp
clang/test/ExtractAPI/objc_category.m
clang/test/ExtractAPI/objc_id_protocol.m
clang/test/ExtractAPI/objc_interface.m
clang/test/ExtractAPI/objc_property.m

Removed: 




diff  --git a/clang/lib/ExtractAPI/DeclarationFragments.cpp 
b/clang/lib/ExtractAPI/DeclarationFragments.cpp
index 912e58a0c6e82..da75a701b405e 100644
--- a/clang/lib/ExtractAPI/DeclarationFragments.cpp
+++ b/clang/lib/ExtractAPI/DeclarationFragments.cpp
@@ -638,7 +638,7 @@ DeclarationFragments 
DeclarationFragmentsBuilder::getFragmentsForObjCProperty(
   // Build the Objective-C property keyword.
   Fragments.append("@property", DeclarationFragments::FragmentKind::Keyword);
 
-  const auto Attributes = Property->getPropertyAttributes();
+  const auto Attributes = Property->getPropertyAttributesAsWritten();
   // Build the attributes if there is any associated with the property.
   if (Attributes != ObjCPropertyAttribute::kind_noattr) {
 // No leading comma for the first attribute.

diff  --git a/clang/test/ExtractAPI/objc_category.m 
b/clang/test/ExtractAPI/objc_category.m
index 185016dfe848c..3323d75f40392 100644
--- a/clang/test/ExtractAPI/objc_category.m
+++ b/clang/test/ExtractAPI/objc_category.m
@@ -282,39 +282,7 @@ + (void)ClassMethod;
 },
 {
   "kind": "text",
-  "spelling": " ("
-},
-{
-  "kind": "keyword",
-  "spelling": "atomic"
-},
-{
-  "kind": "text",
-  "spelling": ", "
-},
-{
-  "kind": "keyword",
-  "spelling": "assign"
-},
-{
-  "kind": "text",
-  "spelling": ", "
-},
-{
-  "kind": "keyword",
-  "spelling": "unsafe_unretained"
-},
-{
-  "kind": "text",
-  "spelling": ", "
-},
-{
-  "kind": "keyword",
-  "spelling": "readwrite"
-},
-{
-  "kind": "text",
-  "spelling": ") "
+  "spelling": " "
 },
 {
   "kind": "typeIdentifier",

diff  --git a/clang/test/ExtractAPI/objc_id_protocol.m 
b/clang/test/ExtractAPI/objc_id_protocol.m
index 551e908ae4fdd..02f4cde772d48 100644
--- a/clang/test/ExtractAPI/objc_id_protocol.m
+++ b/clang/test/ExtractAPI/objc_id_protocol.m
@@ -122,14 +122,6 @@ @interface MyInterface
   "kind": "text",
   "spelling": " ("
 },
-{
-  "kind": "keyword",
-  "spelling": "atomic"
-},
-{
-  "kind": "text",
-  "spelling": ", "
-},
 {
   "kind": "keyword",
   "spelling": "copy"
@@ -206,30 +198,6 @@ @interface MyInterface
   "kind": "text",
   "spelling": " ("
 },
-{
-  "kind": "keyword",
-  "spelling": "atomic"
-},
-{
-  "kind": "text",
-  "spelling": ", "
-},
-{
-  "kind": "keyword",
-  "spelling": "assign"
-},
-{
-  "kind": "text",
-  "spelling": ", "
-},
-{
-  "kind": "keyword",
-  "spelling": "unsafe_unretained"
-},
-{
-  "kind": "text",
-  "spelling": ", "
-},
 {
   "kind": "keyword",
   "spelling": "readwrite"

diff  --git a/clang/test/ExtractAPI/objc_interface.m 
b/clang/test/ExtractAPI/objc_interface.m
index 159e97a193a13..3f53546866513 100644
--- a/clang/test/ExtractAPI/objc_interface.m
+++ b/clang/test/ExtractAPI/objc_interface.m
@@ -432,14 +432,6 @@ - (char)getIvar;
   "kind": "text",
   "spelling": " ("
 },
-{
-  "kind": "keyword",
-  "spelling": "atomic"
-},
-{
-  "kind": "text",
-  "spelling": ", "
-},
 {
   "kind": "keyword",
   "spelling": "readonly"

diff  --git a/clang/test/ExtractAPI/objc_property.m 
b/clang/test/ExtractAPI/objc_property.m
index f09a5ad724238..9c69a1156bffd 100644
--- a/clang/test/ExtractAPI/objc_property.m
+++ b/clang/test/ExtractAPI/objc_property.m
@@ -161,38 +161,6 @@ @interface 

[PATCH] D147531: [clang] Reset track of immediate function context when entering new function

2023-04-04 Thread Mariya Podchishchaeva via Phabricator via cfe-commits
Fznamznon marked 2 inline comments as done.
Fznamznon added inline comments.



Comment at: clang/lib/Sema/SemaDecl.cpp:15186
+  // different handling.
+  ExprEvalContexts.back().InImmediateFunctionContext = FD->isConsteval();
+

cor3ntin wrote:
> shafik wrote:
> > I am a bit concerned that we are updating `InImmediateFunctionContext` 
> > outside of `PushExpressionEvaluationContext`. So we are now spreading the 
> > logic outside of where it was originally contained.
> > 
> > I am wondering if instead inside of `PushExpressionEvaluationContext` we 
> > could set `InImmediateFunctionContext` like so:
> > 
> > ```
> > ExprEvalContexts.back().InImmediateFunctionContext =
> >   ExprEvalContexts[ExprEvalContexts.size() - 2]
> >   .isImmediateFunctionContext() || NewContext == 
> > ImmediateFunctionContext;
> > ```
> > 
> > or something along those lines.
> Here `isImmediateFunctionContext()` will be true, we want it to be false
> 
> If we wanted to do somelink like what you are suggesting, we'd need something 
> like a new `EnteringFunctionDefinitionContext` boolean parameter to  
> PushExpressionEvaluationContext. so that
> InImmediateFunctionContext is only set to the outer context value when 
> `EnteringFunctionDefinitionContext`would be false
> 
> Given that we should only get in that situation from 
> `ActOnStartOfFunctionDef`, I'm not sure that would be a better design
Thanks, @cor3ntin .
This is the exact reason why I implemented the fix this way.



Comment at: clang/test/CodeGenCXX/cxx20-consteval-crash.cpp:120
+
+namespace GH61142 {
+

aaron.ballman wrote:
> Would it make sense to add some CHECK lines to check the actual codegen is 
> sensible?
Well, the assertion was due to consteval function reaching codegen, so I added 
checks that it doesn't appear in the IR in any way.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147531

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


[PATCH] D147531: [clang] Reset track of immediate function context when entering new function

2023-04-04 Thread Mariya Podchishchaeva via Phabricator via cfe-commits
Fznamznon updated this revision to Diff 510843.
Fznamznon added a comment.

Fix grammar, add checks to the test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147531

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaDecl.cpp
  clang/test/CodeGenCXX/cxx20-consteval-crash.cpp


Index: clang/test/CodeGenCXX/cxx20-consteval-crash.cpp
===
--- clang/test/CodeGenCXX/cxx20-consteval-crash.cpp
+++ clang/test/CodeGenCXX/cxx20-consteval-crash.cpp
@@ -116,3 +116,27 @@
 }
 
 } // namespace GH60166
+
+namespace GH61142 {
+
+template 
+struct Test {
+  constexpr static void bar() {
+foo();
+  }
+  consteval static void foo() {};
+};
+
+consteval void a() {
+  Test::bar();
+}
+
+void b() {
+  Test::bar();
+}
+
+// Make sure consteval function is not emitted.
+// CHECK-NOT: call {{.*}}foo{{.*}}()
+// CHECK-NOT: define {{.*}}foo{{.*}}()
+
+} // namespace GH61142
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -15175,6 +15175,15 @@
 FD->isConsteval() ? 
ExpressionEvaluationContext::ImmediateFunctionContext
   : ExprEvalContexts.back().Context);
 
+  // Each ExpressionEvaluationContextRecord also keeps track of whether the
+  // context is nested in an immediate function context, so smaller contexts
+  // that appear inside immediate functions (like variable initializers) are
+  // considered to be inside an immediate function context even though by
+  // themselves they are not immediate function contexts. But when a new
+  // function is entered, we need to reset this tracking, since the entered
+  // function might be not an immediate function.
+  ExprEvalContexts.back().InImmediateFunctionContext = FD->isConsteval();
+
   // Check for defining attributes before the check for redefinition.
   if (const auto *Attr = FD->getAttr()) {
 Diag(Attr->getLocation(), diag::err_alias_is_definition) << FD << 0;
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -271,6 +271,9 @@
   (`#60887 `_)
 - Fix incorrect merging of lambdas across modules.
   (`#60985 `_)
+- Fix the assertion hit when a template consteval function appears in a nested
+  consteval/constexpr call chain.
+  (`#61142 `_)
 
 
 Bug Fixes to Compiler Builtins


Index: clang/test/CodeGenCXX/cxx20-consteval-crash.cpp
===
--- clang/test/CodeGenCXX/cxx20-consteval-crash.cpp
+++ clang/test/CodeGenCXX/cxx20-consteval-crash.cpp
@@ -116,3 +116,27 @@
 }
 
 } // namespace GH60166
+
+namespace GH61142 {
+
+template 
+struct Test {
+  constexpr static void bar() {
+foo();
+  }
+  consteval static void foo() {};
+};
+
+consteval void a() {
+  Test::bar();
+}
+
+void b() {
+  Test::bar();
+}
+
+// Make sure consteval function is not emitted.
+// CHECK-NOT: call {{.*}}foo{{.*}}()
+// CHECK-NOT: define {{.*}}foo{{.*}}()
+
+} // namespace GH61142
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -15175,6 +15175,15 @@
 FD->isConsteval() ? ExpressionEvaluationContext::ImmediateFunctionContext
   : ExprEvalContexts.back().Context);
 
+  // Each ExpressionEvaluationContextRecord also keeps track of whether the
+  // context is nested in an immediate function context, so smaller contexts
+  // that appear inside immediate functions (like variable initializers) are
+  // considered to be inside an immediate function context even though by
+  // themselves they are not immediate function contexts. But when a new
+  // function is entered, we need to reset this tracking, since the entered
+  // function might be not an immediate function.
+  ExprEvalContexts.back().InImmediateFunctionContext = FD->isConsteval();
+
   // Check for defining attributes before the check for redefinition.
   if (const auto *Attr = FD->getAttr()) {
 Diag(Attr->getLocation(), diag::err_alias_is_definition) << FD << 0;
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -271,6 +271,9 @@
   (`#60887 `_)
 - Fix incorrect merging of lambdas across modules.
   (`#60985 `_)
+- Fix the assertion hit when a template consteval function appears in a nested
+  consteval/constexpr call chain.
+  (`#61142 

[PATCH] D147531: [clang] Reset track of immediate function context when entering new function

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



Comment at: clang/lib/Sema/SemaDecl.cpp:15186
+  // different handling.
+  ExprEvalContexts.back().InImmediateFunctionContext = FD->isConsteval();
+

shafik wrote:
> I am a bit concerned that we are updating `InImmediateFunctionContext` 
> outside of `PushExpressionEvaluationContext`. So we are now spreading the 
> logic outside of where it was originally contained.
> 
> I am wondering if instead inside of `PushExpressionEvaluationContext` we 
> could set `InImmediateFunctionContext` like so:
> 
> ```
> ExprEvalContexts.back().InImmediateFunctionContext =
>   ExprEvalContexts[ExprEvalContexts.size() - 2]
>   .isImmediateFunctionContext() || NewContext == 
> ImmediateFunctionContext;
> ```
> 
> or something along those lines.
Here `isImmediateFunctionContext()` will be true, we want it to be false

If we wanted to do somelink like what you are suggesting, we'd need something 
like a new `EnteringFunctionDefinitionContext` boolean parameter to  
PushExpressionEvaluationContext. so that
InImmediateFunctionContext is only set to the outer context value when 
`EnteringFunctionDefinitionContext`would be false

Given that we should only get in that situation from `ActOnStartOfFunctionDef`, 
I'm not sure that would be a better design


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147531

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


[PATCH] D147531: [clang] Reset track of immediate function context when entering new function

2023-04-04 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added inline comments.



Comment at: clang/lib/Sema/SemaDecl.cpp:15186
+  // different handling.
+  ExprEvalContexts.back().InImmediateFunctionContext = FD->isConsteval();
+

I am a bit concerned that we are updating `InImmediateFunctionContext` outside 
of `PushExpressionEvaluationContext`. So we are now spreading the logic outside 
of where it was originally contained.

I am wondering if instead inside of `PushExpressionEvaluationContext` we could 
set `InImmediateFunctionContext` like so:

```
ExprEvalContexts.back().InImmediateFunctionContext =
  ExprEvalContexts[ExprEvalContexts.size() - 2]
  .isImmediateFunctionContext() || NewContext == 
ImmediateFunctionContext;
```

or something along those lines.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147531

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


[PATCH] D147531: [clang] Reset track of immediate function context when entering new function

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



Comment at: clang/docs/ReleaseNotes.rst:273-274
 - Fix incorrect merging of lambdas across modules.
   (`#60985 `_)
+- Fix assertion hit when template consteval function appears in nested
+  consteval/constexpr call chain.





Comment at: clang/test/CodeGenCXX/cxx20-consteval-crash.cpp:120
+
+namespace GH61142 {
+

Would it make sense to add some CHECK lines to check the actual codegen is 
sensible?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147531

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


[PATCH] D146389: [clang-repl][CUDA] Initial interactive CUDA support for clang-repl

2023-04-04 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev added a comment.

Thanks for working on this!




Comment at: clang/lib/Interpreter/Offload.cpp:1
+//===-- Offload.cpp - CUDA Offloading ---*- C++ 
-*-===//
+//

How about `DeviceOffload.cpp`?



Comment at: clang/tools/clang-repl/ClangRepl.cpp:135
+std::move(CI), std::move(DeviceCI), OffloadArch,
+"/tmp/clang-repl.fatbin"));
+

To cover the case where platforms have no `/tmp` we could use 
`fs::createTemporaryFile`. However, some platforms have read-only file systems. 
What do we do there?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146389

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


[PATCH] D147497: [AArch64] Use fneg instead of fsub -0.0, X Cin IR expansion of __builtin_neon_vfmsh_f16.

2023-04-04 Thread Craig Topper 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 rG0109f8d1e3bf: [AArch64] Use fneg instead of fsub -0.0, X Cin 
IR expansion of… (authored by craig.topper).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147497

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/aarch64-v8.2a-fp16-intrinsics-constrained.c
  clang/test/CodeGen/aarch64-v8.2a-fp16-intrinsics.c


Index: clang/test/CodeGen/aarch64-v8.2a-fp16-intrinsics.c
===
--- clang/test/CodeGen/aarch64-v8.2a-fp16-intrinsics.c
+++ clang/test/CodeGen/aarch64-v8.2a-fp16-intrinsics.c
@@ -652,7 +652,7 @@
 }
 
 // CHECK-LABEL: test_vfmsh_f16
-// CHECK:  [[SUB:%.*]] = fsub half 0xH8000, %b
+// CHECK:  [[SUB:%.*]] = fneg half %b
 // CHECK:  [[ADD:%.*]] = call half @llvm.fma.f16(half [[SUB]], half %c, half 
%a)
 // CHECK:  ret half [[ADD]]
 float16_t test_vfmsh_f16(float16_t a, float16_t b, float16_t c) {
Index: clang/test/CodeGen/aarch64-v8.2a-fp16-intrinsics-constrained.c
===
--- clang/test/CodeGen/aarch64-v8.2a-fp16-intrinsics-constrained.c
+++ clang/test/CodeGen/aarch64-v8.2a-fp16-intrinsics-constrained.c
@@ -290,8 +290,7 @@
 }
 
 // COMMON-LABEL: test_vfmsh_f16
-// UNCONSTRAINED:  [[SUB:%.*]] = fsub half 0xH8000, %b
-// CONSTRAINED:[[SUB:%.*]] = call half 
@llvm.experimental.constrained.fsub.f16(half 0xH8000, half %b, metadata 
!"round.tonearest", metadata !"fpexcept.strict")
+// COMMONIR:  [[SUB:%.*]] = fneg half %b
 // UNCONSTRAINED:  [[ADD:%.*]] = call half @llvm.fma.f16(half [[SUB]], half 
%c, half %a)
 // CONSTRAINED:[[ADD:%.*]] = call half 
@llvm.experimental.constrained.fma.f16(half [[SUB]], half %c, half %a, metadata 
!"round.tonearest", metadata !"fpexcept.strict")
 // COMMONIR:   ret half [[ADD]]
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -10965,14 +10965,12 @@
 *this, Intrinsic::fma, Intrinsic::experimental_constrained_fma, HalfTy,
 {EmitScalarExpr(E->getArg(1)), EmitScalarExpr(E->getArg(2)), Ops[0]});
   case NEON::BI__builtin_neon_vfmsh_f16: {
-// FIXME: This should be an fneg instruction:
-Value *Zero = llvm::ConstantFP::getZeroValueForNegation(HalfTy);
-Value* Sub = Builder.CreateFSub(Zero, EmitScalarExpr(E->getArg(1)), 
"vsubh");
+Value* Neg = Builder.CreateFNeg(EmitScalarExpr(E->getArg(1)), "vsubh");
 
 // NEON intrinsic puts accumulator first, unlike the LLVM fma.
 return emitCallMaybeConstrainedFPBuiltin(
 *this, Intrinsic::fma, Intrinsic::experimental_constrained_fma, HalfTy,
-{Sub, EmitScalarExpr(E->getArg(2)), Ops[0]});
+{Neg, EmitScalarExpr(E->getArg(2)), Ops[0]});
   }
   case NEON::BI__builtin_neon_vaddd_s64:
   case NEON::BI__builtin_neon_vaddd_u64:


Index: clang/test/CodeGen/aarch64-v8.2a-fp16-intrinsics.c
===
--- clang/test/CodeGen/aarch64-v8.2a-fp16-intrinsics.c
+++ clang/test/CodeGen/aarch64-v8.2a-fp16-intrinsics.c
@@ -652,7 +652,7 @@
 }
 
 // CHECK-LABEL: test_vfmsh_f16
-// CHECK:  [[SUB:%.*]] = fsub half 0xH8000, %b
+// CHECK:  [[SUB:%.*]] = fneg half %b
 // CHECK:  [[ADD:%.*]] = call half @llvm.fma.f16(half [[SUB]], half %c, half %a)
 // CHECK:  ret half [[ADD]]
 float16_t test_vfmsh_f16(float16_t a, float16_t b, float16_t c) {
Index: clang/test/CodeGen/aarch64-v8.2a-fp16-intrinsics-constrained.c
===
--- clang/test/CodeGen/aarch64-v8.2a-fp16-intrinsics-constrained.c
+++ clang/test/CodeGen/aarch64-v8.2a-fp16-intrinsics-constrained.c
@@ -290,8 +290,7 @@
 }
 
 // COMMON-LABEL: test_vfmsh_f16
-// UNCONSTRAINED:  [[SUB:%.*]] = fsub half 0xH8000, %b
-// CONSTRAINED:[[SUB:%.*]] = call half @llvm.experimental.constrained.fsub.f16(half 0xH8000, half %b, metadata !"round.tonearest", metadata !"fpexcept.strict")
+// COMMONIR:  [[SUB:%.*]] = fneg half %b
 // UNCONSTRAINED:  [[ADD:%.*]] = call half @llvm.fma.f16(half [[SUB]], half %c, half %a)
 // CONSTRAINED:[[ADD:%.*]] = call half @llvm.experimental.constrained.fma.f16(half [[SUB]], half %c, half %a, metadata !"round.tonearest", metadata !"fpexcept.strict")
 // COMMONIR:   ret half [[ADD]]
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -10965,14 +10965,12 @@
 *this, Intrinsic::fma, Intrinsic::experimental_constrained_fma, HalfTy,
 {EmitScalarExpr(E->getArg(1)), EmitScalarExpr(E->getArg(2)), Ops[0]});
   case NEON::BI__builtin_neon_vfmsh_f16: {
-// FIXME: This should be 

[clang] 0109f8d - [AArch64] Use fneg instead of fsub -0.0, X Cin IR expansion of __builtin_neon_vfmsh_f16.

2023-04-04 Thread Craig Topper via cfe-commits

Author: Craig Topper
Date: 2023-04-04T09:01:24-07:00
New Revision: 0109f8d1e3bf64e4b23db6e2f284185207e46541

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

LOG: [AArch64] Use fneg instead of fsub -0.0, X Cin IR expansion of 
__builtin_neon_vfmsh_f16.

Addresses the FIXME and removes the only in tree use of
llvm::ConstantFP::getZeroValueForNegation for an FP type.

Reviewed By: dmgreen, SjoerdMeijer

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

Added: 


Modified: 
clang/lib/CodeGen/CGBuiltin.cpp
clang/test/CodeGen/aarch64-v8.2a-fp16-intrinsics-constrained.c
clang/test/CodeGen/aarch64-v8.2a-fp16-intrinsics.c

Removed: 




diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index f399b0770143..1d79d9a14635 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -10965,14 +10965,12 @@ Value 
*CodeGenFunction::EmitAArch64BuiltinExpr(unsigned BuiltinID,
 *this, Intrinsic::fma, Intrinsic::experimental_constrained_fma, HalfTy,
 {EmitScalarExpr(E->getArg(1)), EmitScalarExpr(E->getArg(2)), Ops[0]});
   case NEON::BI__builtin_neon_vfmsh_f16: {
-// FIXME: This should be an fneg instruction:
-Value *Zero = llvm::ConstantFP::getZeroValueForNegation(HalfTy);
-Value* Sub = Builder.CreateFSub(Zero, EmitScalarExpr(E->getArg(1)), 
"vsubh");
+Value* Neg = Builder.CreateFNeg(EmitScalarExpr(E->getArg(1)), "vsubh");
 
 // NEON intrinsic puts accumulator first, unlike the LLVM fma.
 return emitCallMaybeConstrainedFPBuiltin(
 *this, Intrinsic::fma, Intrinsic::experimental_constrained_fma, HalfTy,
-{Sub, EmitScalarExpr(E->getArg(2)), Ops[0]});
+{Neg, EmitScalarExpr(E->getArg(2)), Ops[0]});
   }
   case NEON::BI__builtin_neon_vaddd_s64:
   case NEON::BI__builtin_neon_vaddd_u64:

diff  --git a/clang/test/CodeGen/aarch64-v8.2a-fp16-intrinsics-constrained.c 
b/clang/test/CodeGen/aarch64-v8.2a-fp16-intrinsics-constrained.c
index 198c4523d651..536713402b5d 100644
--- a/clang/test/CodeGen/aarch64-v8.2a-fp16-intrinsics-constrained.c
+++ b/clang/test/CodeGen/aarch64-v8.2a-fp16-intrinsics-constrained.c
@@ -290,8 +290,7 @@ float16_t test_vfmah_f16(float16_t a, float16_t b, 
float16_t c) {
 }
 
 // COMMON-LABEL: test_vfmsh_f16
-// UNCONSTRAINED:  [[SUB:%.*]] = fsub half 0xH8000, %b
-// CONSTRAINED:[[SUB:%.*]] = call half 
@llvm.experimental.constrained.fsub.f16(half 0xH8000, half %b, metadata 
!"round.tonearest", metadata !"fpexcept.strict")
+// COMMONIR:  [[SUB:%.*]] = fneg half %b
 // UNCONSTRAINED:  [[ADD:%.*]] = call half @llvm.fma.f16(half [[SUB]], half 
%c, half %a)
 // CONSTRAINED:[[ADD:%.*]] = call half 
@llvm.experimental.constrained.fma.f16(half [[SUB]], half %c, half %a, metadata 
!"round.tonearest", metadata !"fpexcept.strict")
 // COMMONIR:   ret half [[ADD]]

diff  --git a/clang/test/CodeGen/aarch64-v8.2a-fp16-intrinsics.c 
b/clang/test/CodeGen/aarch64-v8.2a-fp16-intrinsics.c
index b374ba1ab097..d745a7789326 100644
--- a/clang/test/CodeGen/aarch64-v8.2a-fp16-intrinsics.c
+++ b/clang/test/CodeGen/aarch64-v8.2a-fp16-intrinsics.c
@@ -652,7 +652,7 @@ float16_t test_vfmah_f16(float16_t a, float16_t b, 
float16_t c) {
 }
 
 // CHECK-LABEL: test_vfmsh_f16
-// CHECK:  [[SUB:%.*]] = fsub half 0xH8000, %b
+// CHECK:  [[SUB:%.*]] = fneg half %b
 // CHECK:  [[ADD:%.*]] = call half @llvm.fma.f16(half [[SUB]], half %c, half 
%a)
 // CHECK:  ret half [[ADD]]
 float16_t test_vfmsh_f16(float16_t a, float16_t b, float16_t c) {



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


[PATCH] D41416: [modules] [pch] Do not deserialize all lazy template specializations when looking for one.

2023-04-04 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev added inline comments.



Comment at: clang/lib/Serialization/ASTWriterDecl.cpp:288
+  }
+  for (auto  : LazySpecializations) {
+Record.push_back(SpecInfo.DeclID);

We should not store the lazy specialization information as an array of items 
because that makes the search slow. Instead we should use the `OnDiskHashTable` 
approach which we use already to store the identifier data.


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

https://reviews.llvm.org/D41416

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


[PATCH] D41416: [modules] [pch] Do not deserialize all lazy template specializations when looking for one.

2023-04-04 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added a reviewer: ChuanqiXu.
ChuanqiXu added a comment.

Add me as a reviewer to add this to my stack.


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

https://reviews.llvm.org/D41416

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


[PATCH] D144003: [clang][analyzer] Improve bug reports of StdLibraryFunctionsChecker.

2023-04-04 Thread Balázs Kéri via Phabricator via cfe-commits
balazske updated this revision to Diff 510816.
balazske marked 3 inline comments as done.
balazske added a comment.

I decided to add back `DescriptionKind` and make possible to use a message like
"should not be NULL". Now all generated strings in functions `describe` and
`describeArgumentValue` start with "should be" or "is" to make this consistent.
The messages are now in form "is ... but should be ..." which sounds at some 
times
too trivial but acceptable as generated message.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144003

Files:
  clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
  clang/test/Analysis/std-c-library-functions-arg-constraints-note-tags.cpp
  clang/test/Analysis/std-c-library-functions-arg-constraints-notes.cpp
  clang/test/Analysis/std-c-library-functions-arg-constraints-tracking-notes.c
  clang/test/Analysis/std-c-library-functions-arg-constraints.c
  clang/test/Analysis/std-c-library-functions-arg-constraints.cpp
  clang/test/Analysis/stream-note.c
  clang/test/Analysis/stream-stdlibraryfunctionargs.c

Index: clang/test/Analysis/stream-stdlibraryfunctionargs.c
===
--- clang/test/Analysis/stream-stdlibraryfunctionargs.c
+++ clang/test/Analysis/stream-stdlibraryfunctionargs.c
@@ -42,7 +42,7 @@
 
 void test_fread(void) {
   FILE *fp = tmpfile();
-  size_t ret = fread(buf, size, n, fp); // stdargs-warning{{The 4th argument to 'fread' should not be NULL}}
+  size_t ret = fread(buf, size, n, fp); // stdargs-warning{{The 4th argument to 'fread' is NULL but should not be NULL}}
   clang_analyzer_eval(fp != NULL); // any-warning{{TRUE}}
   clang_analyzer_eval(ret <= n); // any-warning{{TRUE}}
   clang_analyzer_eval(ret == n); // any-warning{{TRUE}} any-warning{{FALSE}}
@@ -52,7 +52,7 @@
 
 void test_fwrite(void) {
   FILE *fp = tmpfile();
-  size_t ret = fwrite(buf, size, n, fp); // stdargs-warning{{The 4th argument to 'fwrite' should not be NULL}}
+  size_t ret = fwrite(buf, size, n, fp); // stdargs-warning{{The 4th argument to 'fwrite' is NULL but should not be NULL}}
   clang_analyzer_eval(fp != NULL); // any-warning{{TRUE}}
   clang_analyzer_eval(ret <= n); // any-warning{{TRUE}}
   clang_analyzer_eval(ret == n); // any-warning{{TRUE}} any-warning{{FALSE}}
Index: clang/test/Analysis/stream-note.c
===
--- clang/test/Analysis/stream-note.c
+++ clang/test/Analysis/stream-note.c
@@ -88,8 +88,8 @@
 fclose(F);
 return;
   }
-  fclose(F); // stdargs-warning {{The 1st argument to 'fclose' should not be NULL}}
- // stdargs-note@-1 {{The 1st argument to 'fclose' should not be NULL}}
+  fclose(F); // stdargs-warning {{The 1st argument to 'fclose' is NULL but should not be NULL}}
+ // stdargs-note@-1 {{The 1st argument to 'fclose' is NULL but should not be NULL}}
 }
 
 void check_eof_notes_feof_after_feof(void) {
Index: clang/test/Analysis/std-c-library-functions-arg-constraints.cpp
===
--- clang/test/Analysis/std-c-library-functions-arg-constraints.cpp
+++ clang/test/Analysis/std-c-library-functions-arg-constraints.cpp
@@ -14,5 +14,5 @@
 
 void test_arg_constraint_on_fun_with_default_param() {
   __defaultparam(nullptr); // \
-  // expected-warning{{The 1st argument to '__defaultparam' should not be NULL}}
+  // expected-warning{{The 1st argument to '__defaultparam' is NULL but should not be NULL}}
 }
Index: clang/test/Analysis/std-c-library-functions-arg-constraints.c
===
--- clang/test/Analysis/std-c-library-functions-arg-constraints.c
+++ clang/test/Analysis/std-c-library-functions-arg-constraints.c
@@ -30,9 +30,9 @@
 
 void test_alnum_concrete(int v) {
   int ret = isalnum(256); // \
-  // report-warning{{The 1st argument to 'isalnum' should be an unsigned char value or EOF}} \
-  // bugpath-warning{{The 1st argument to 'isalnum' should be an unsigned char value or EOF}} \
-  // bugpath-note{{The 1st argument to 'isalnum' should be an unsigned char value or EOF}}
+  // report-warning{{The 1st argument to 'isalnum' is 256 but should be an unsigned char value or EOF}} \
+  // bugpath-warning{{The 1st argument to 'isalnum' is 256 but should be an unsigned char value or EOF}} \
+  // bugpath-note{{The 1st argument to 'isalnum' is 256 but should be an unsigned char value or EOF}}
   (void)ret;
 }
 
@@ -55,9 +55,9 @@
 // bugpath-note{{Taking true branch}}
 
 int ret = isalnum(x); // \
-// report-warning{{The 1st argument to 'isalnum' should be an unsigned char value or EOF}} \
-// bugpath-warning{{The 1st argument to 'isalnum' should be an unsigned char value or EOF}} \
-// bugpath-note{{The 1st argument to 'isalnum' should be an unsigned char value or EOF}}
+// report-warning{{The 1st 

[PATCH] D141700: AMDGPU: Move enqueued block handling into clang

2023-04-04 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added inline comments.



Comment at: llvm/lib/Target/AMDGPU/AMDGPUHSAMetadataStreamer.cpp:299
+
+  Attrs.mRuntimeHandle = getEnqueuedBlockSymbolName(TM, Func);
 }

kzhuravl wrote:
> Do we really need/want to update code object v2?
as long as the code is here yes. Not updating it would mean maintaining two 
paths in the implementation. This is just changing the internal representation 


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

https://reviews.llvm.org/D141700

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


[PATCH] D141700: AMDGPU: Move enqueued block handling into clang

2023-04-04 Thread Konstantin Zhuravlyov via Phabricator via cfe-commits
kzhuravl added a comment.

Overall looks good.




Comment at: llvm/lib/Target/AMDGPU/AMDGPUHSAMetadataStreamer.cpp:299
+
+  Attrs.mRuntimeHandle = getEnqueuedBlockSymbolName(TM, Func);
 }

Do we really need/want to update code object v2?


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

https://reviews.llvm.org/D141700

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


[PATCH] D147531: [clang] Reset track of immediate function context when entering new function

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

I reworked the comment a bit otherwise LGTM.




Comment at: clang/lib/Sema/SemaDecl.cpp:15178-15185
+  // Each ExpressionEvaluationContextRecord also keeps track on whether the
+  // context is nested in an immediate function context, so smaller contexts
+  // that appear inside immediate functions (like variable initializers) are
+  // considered to be inside an immediate function context even though by
+  // themselves they are not immediate function contexts. But when the new
+  // function is entered, we need to reset this tracking, since entered 
function
+  // might be not an immediate one and therefore everything inside of it needs




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147531

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


[PATCH] D147477: [clang][modules] Handle explicit modules when checking for .Private -> _Private

2023-04-04 Thread Ben Langmuir via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8ec36e6956cb: [clang][modules] Handle explicit modules when 
checking for .Private - _Private (authored by benlangmuir).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147477

Files:
  clang/lib/Frontend/CompilerInstance.cpp
  clang/test/Modules/implicit-private-with-submodule-explicit.m


Index: clang/test/Modules/implicit-private-with-submodule-explicit.m
===
--- /dev/null
+++ clang/test/Modules/implicit-private-with-submodule-explicit.m
@@ -0,0 +1,31 @@
+// Checks that the use of .Private to refer to _Private modules works with an
+// explicit module.
+
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+
+// RUN: %clang_cc1 -x objective-c -fmodules -fno-implicit-modules -emit-module 
-fmodule-name=A %t/module.modulemap -o %t/A.pcm
+// RUN: %clang_cc1 -x objective-c -fmodules -fno-implicit-modules -emit-module 
-fmodule-name=A_Private %t/module.modulemap -o %t/A_Private.pcm
+
+// Check lazily-loaded module
+// RUN: %clang_cc1 -x objective-c -verify -fmodules -fno-implicit-modules 
-fmodule-file=A=%t/A.pcm -fmodule-file=A_Private=%t/A_Private.pcm -fsyntax-only 
%t/tu.m
+
+// Check eagerly-loaded module
+// RUN: %clang_cc1 -x objective-c -verify -fmodules -fno-implicit-modules 
-fmodule-file=%t/A.pcm -fmodule-file=%t/A_Private.pcm -fsyntax-only %t/tu.m
+
+//--- module.modulemap
+module A { header "a.h" }
+module A_Private { header "priv.h" }
+
+//--- a.h
+
+//--- priv.h
+void priv(void);
+
+//--- tu.m
+@import A.Private; // expected-warning{{no submodule named 'Private' in module 
'A'; using top level 'A_Private'}}
+// expected-note@*:* {{defined here}}
+
+void tu(void) {
+  priv();
+}
\ No newline at end of file
Index: clang/lib/Frontend/CompilerInstance.cpp
===
--- clang/lib/Frontend/CompilerInstance.cpp
+++ clang/lib/Frontend/CompilerInstance.cpp
@@ -2026,8 +2026,12 @@
   PrivateModule, PP->getIdentifierInfo(Module->Name)->getTokenID());
   PrivPath.push_back(std::make_pair(, Path[0].second));
 
+  std::string FileName;
+  // If there is a modulemap module or prebuilt module, load it.
   if (PP->getHeaderSearchInfo().lookupModule(PrivateModule, ImportLoc, 
true,
- !IsInclusionDirective))
+ !IsInclusionDirective) ||
+  selectModuleSource(nullptr, PrivateModule, FileName, BuiltModules,
+ PP->getHeaderSearchInfo()) != MS_ModuleNotFound)
 Sub = loadModule(ImportLoc, PrivPath, Visibility, 
IsInclusionDirective);
   if (Sub) {
 MapPrivateSubModToTopLevel = true;


Index: clang/test/Modules/implicit-private-with-submodule-explicit.m
===
--- /dev/null
+++ clang/test/Modules/implicit-private-with-submodule-explicit.m
@@ -0,0 +1,31 @@
+// Checks that the use of .Private to refer to _Private modules works with an
+// explicit module.
+
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+
+// RUN: %clang_cc1 -x objective-c -fmodules -fno-implicit-modules -emit-module -fmodule-name=A %t/module.modulemap -o %t/A.pcm
+// RUN: %clang_cc1 -x objective-c -fmodules -fno-implicit-modules -emit-module -fmodule-name=A_Private %t/module.modulemap -o %t/A_Private.pcm
+
+// Check lazily-loaded module
+// RUN: %clang_cc1 -x objective-c -verify -fmodules -fno-implicit-modules -fmodule-file=A=%t/A.pcm -fmodule-file=A_Private=%t/A_Private.pcm -fsyntax-only %t/tu.m
+
+// Check eagerly-loaded module
+// RUN: %clang_cc1 -x objective-c -verify -fmodules -fno-implicit-modules -fmodule-file=%t/A.pcm -fmodule-file=%t/A_Private.pcm -fsyntax-only %t/tu.m
+
+//--- module.modulemap
+module A { header "a.h" }
+module A_Private { header "priv.h" }
+
+//--- a.h
+
+//--- priv.h
+void priv(void);
+
+//--- tu.m
+@import A.Private; // expected-warning{{no submodule named 'Private' in module 'A'; using top level 'A_Private'}}
+// expected-note@*:* {{defined here}}
+
+void tu(void) {
+  priv();
+}
\ No newline at end of file
Index: clang/lib/Frontend/CompilerInstance.cpp
===
--- clang/lib/Frontend/CompilerInstance.cpp
+++ clang/lib/Frontend/CompilerInstance.cpp
@@ -2026,8 +2026,12 @@
   PrivateModule, PP->getIdentifierInfo(Module->Name)->getTokenID());
   PrivPath.push_back(std::make_pair(, Path[0].second));
 
+  std::string FileName;
+  // If there is a modulemap module or prebuilt module, load it.
   if (PP->getHeaderSearchInfo().lookupModule(PrivateModule, ImportLoc, true,
- !IsInclusionDirective))
+ !IsInclusionDirective) ||
+  

[clang] 8ec36e6 - [clang][modules] Handle explicit modules when checking for .Private -> _Private

2023-04-04 Thread Ben Langmuir via cfe-commits

Author: Ben Langmuir
Date: 2023-04-04T08:12:10-07:00
New Revision: 8ec36e6956cb03d80f3fee8e593808c43a8a1ec3

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

LOG: [clang][modules] Handle explicit modules when checking for .Private -> 
_Private

While we eventually want to remove the mapping from .Private to _Private
modules, until we do, ensure that it behaves the same for explicit
modules.

rdar://107449872

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

Added: 
clang/test/Modules/implicit-private-with-submodule-explicit.m

Modified: 
clang/lib/Frontend/CompilerInstance.cpp

Removed: 




diff  --git a/clang/lib/Frontend/CompilerInstance.cpp 
b/clang/lib/Frontend/CompilerInstance.cpp
index 691f779b5966c..51fe77630bf7a 100644
--- a/clang/lib/Frontend/CompilerInstance.cpp
+++ b/clang/lib/Frontend/CompilerInstance.cpp
@@ -2026,8 +2026,12 @@ CompilerInstance::loadModule(SourceLocation ImportLoc,
   PrivateModule, PP->getIdentifierInfo(Module->Name)->getTokenID());
   PrivPath.push_back(std::make_pair(, Path[0].second));
 
+  std::string FileName;
+  // If there is a modulemap module or prebuilt module, load it.
   if (PP->getHeaderSearchInfo().lookupModule(PrivateModule, ImportLoc, 
true,
- !IsInclusionDirective))
+ !IsInclusionDirective) ||
+  selectModuleSource(nullptr, PrivateModule, FileName, BuiltModules,
+ PP->getHeaderSearchInfo()) != MS_ModuleNotFound)
 Sub = loadModule(ImportLoc, PrivPath, Visibility, 
IsInclusionDirective);
   if (Sub) {
 MapPrivateSubModToTopLevel = true;

diff  --git a/clang/test/Modules/implicit-private-with-submodule-explicit.m 
b/clang/test/Modules/implicit-private-with-submodule-explicit.m
new file mode 100644
index 0..a2e9950ec3181
--- /dev/null
+++ b/clang/test/Modules/implicit-private-with-submodule-explicit.m
@@ -0,0 +1,31 @@
+// Checks that the use of .Private to refer to _Private modules works with an
+// explicit module.
+
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+
+// RUN: %clang_cc1 -x objective-c -fmodules -fno-implicit-modules -emit-module 
-fmodule-name=A %t/module.modulemap -o %t/A.pcm
+// RUN: %clang_cc1 -x objective-c -fmodules -fno-implicit-modules -emit-module 
-fmodule-name=A_Private %t/module.modulemap -o %t/A_Private.pcm
+
+// Check lazily-loaded module
+// RUN: %clang_cc1 -x objective-c -verify -fmodules -fno-implicit-modules 
-fmodule-file=A=%t/A.pcm -fmodule-file=A_Private=%t/A_Private.pcm -fsyntax-only 
%t/tu.m
+
+// Check eagerly-loaded module
+// RUN: %clang_cc1 -x objective-c -verify -fmodules -fno-implicit-modules 
-fmodule-file=%t/A.pcm -fmodule-file=%t/A_Private.pcm -fsyntax-only %t/tu.m
+
+//--- module.modulemap
+module A { header "a.h" }
+module A_Private { header "priv.h" }
+
+//--- a.h
+
+//--- priv.h
+void priv(void);
+
+//--- tu.m
+@import A.Private; // expected-warning{{no submodule named 'Private' in module 
'A'; using top level 'A_Private'}}
+// expected-note@*:* {{defined here}}
+
+void tu(void) {
+  priv();
+}
\ No newline at end of file



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


[PATCH] D146389: [clang-repl][CUDA] Initial interactive CUDA support for clang-repl

2023-04-04 Thread Anubhab Ghosh via Phabricator via cfe-commits
argentite created this revision.
Herald added subscribers: mattd, carlosgalvezp, yaxunl.
Herald added a project: All.
argentite updated this revision to Diff 507049.
argentite added a comment.
argentite updated this revision to Diff 510808.
argentite edited the summary of this revision.
argentite added reviewers: v.g.vassilev, sgraenitz, lhames.
argentite published this revision for review.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Use full name of CUDA library


argentite added a comment.

Clear LinkModules on every interpreter iteration


CUDA support can be enabled in clang-repl with --cuda flag.
Device code linking is not yet supported. inline must be used with all
__device__ functions.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D146389

Files:
  clang/include/clang/Interpreter/Interpreter.h
  clang/lib/CodeGen/CodeGenAction.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Interpreter/CMakeLists.txt
  clang/lib/Interpreter/IncrementalParser.cpp
  clang/lib/Interpreter/IncrementalParser.h
  clang/lib/Interpreter/Interpreter.cpp
  clang/lib/Interpreter/Offload.cpp
  clang/lib/Interpreter/Offload.h
  clang/tools/clang-repl/ClangRepl.cpp

Index: clang/tools/clang-repl/ClangRepl.cpp
===
--- clang/tools/clang-repl/ClangRepl.cpp
+++ clang/tools/clang-repl/ClangRepl.cpp
@@ -23,6 +23,9 @@
 #include "llvm/Support/TargetSelect.h" // llvm::Initialize*
 #include 
 
+static llvm::cl::opt CudaEnabled("cuda", llvm::cl::Hidden);
+static llvm::cl::opt OffloadArch("offload-arch", llvm::cl::Hidden);
+
 static llvm::cl::list
 ClangArgs("Xcc",
   llvm::cl::desc("Argument to pass to the CompilerInvocation"),
@@ -90,9 +93,29 @@
 return 0;
   }
 
+  std::unique_ptr DeviceCI;
+  if (CudaEnabled) {
+// initialize NVPTX backend
+LLVMInitializeNVPTXTargetInfo();
+LLVMInitializeNVPTXTarget();
+LLVMInitializeNVPTXTargetMC();
+LLVMInitializeNVPTXAsmPrinter();
+
+auto DeviceArgv = ClangArgv;
+
+DeviceCI = ExitOnErr(
+clang::IncrementalCudaCompilerBuilder::createDevice(DeviceArgv));
+  }
+
   // FIXME: Investigate if we could use runToolOnCodeWithArgs from tooling. It
   // can replace the boilerplate code for creation of the compiler instance.
-  auto CI = ExitOnErr(clang::IncrementalCompilerBuilder::create(ClangArgv));
+  std::unique_ptr CI;
+  if (CudaEnabled) {
+CI = ExitOnErr(clang::IncrementalCudaCompilerBuilder::createHost(
+ClangArgv, "/tmp/clang-repl.fatbin"));
+  } else {
+CI = ExitOnErr(clang::IncrementalCompilerBuilder::createCpp(ClangArgv));
+  }
 
   // Set an error handler, so that any LLVM backend diagnostics go through our
   // error handler.
@@ -102,7 +125,19 @@
   // Load any requested plugins.
   CI->LoadRequestedPlugins();
 
-  auto Interp = ExitOnErr(clang::Interpreter::create(std::move(CI)));
+  std::unique_ptr Interp;
+  if (CudaEnabled) {
+if (OffloadArch.empty()) {
+  OffloadArch = "sm_35";
+}
+Interp = ExitOnErr(clang::Interpreter::createWithCUDA(
+std::move(CI), std::move(DeviceCI), OffloadArch,
+"/tmp/clang-repl.fatbin"));
+
+ExitOnErr(Interp->LoadDynamicLibrary("libcudart.so"));
+  } else
+Interp = ExitOnErr(clang::Interpreter::create(std::move(CI)));
+
   for (const std::string  : OptInputs) {
 if (auto Err = Interp->ParseAndExecute(input))
   llvm::logAllUnhandledErrors(std::move(Err), llvm::errs(), "error: ");
Index: clang/lib/Interpreter/Offload.h
===
--- /dev/null
+++ clang/lib/Interpreter/Offload.h
@@ -0,0 +1,47 @@
+//===--- Offload.h - CUDA Offloading *- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file implements classes required for offloading to CUDA devices.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_LIB_INTERPRETER_OFFLOAD_H
+#define LLVM_CLANG_LIB_INTERPRETER_OFFLOAD_H
+
+#include "IncrementalParser.h"
+
+namespace clang {
+
+class DeviceCodeInlinerAction;
+
+class IncrementalCUDADeviceParser : public IncrementalParser {
+public:
+  IncrementalCUDADeviceParser(std::unique_ptr Instance,
+  llvm::LLVMContext , llvm::StringRef Arch,
+  llvm::StringRef FatbinFile, llvm::Error );
+
+  llvm::Expected
+  Parse(llvm::StringRef Input) override;
+
+  // Generate PTX for the last PTU
+  llvm::Expected GeneratePTX();
+
+  // Write last PTX to the fatbinary file
+  llvm::Error WriteFatbinary() const;
+
+  ~IncrementalCUDADeviceParser();
+
+protected:
+  int SMVersion;
+  std::string 

[PATCH] D147531: [clang] Reset track of immediate function context when entering new function

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



Comment at: clang/lib/Sema/SemaDecl.cpp:15177
   : ExprEvalContexts.back().Context);
+ExprEvalContexts.back().InImmediateFunctionContext = FD->isConsteval();
 

cor3ntin wrote:
> I think it might be worth adding a comment there to explain why this is 
> necessary.
> I think i convinced myself this make sense and is almost certainly the 
> correct fix but it would, I think, benefit from some more explanation for 
> future reference.
> 
> 
Sure, done. Hope it turned out helpful.



Comment at: clang/test/CodeGenCXX/cxx20-consteval-crash.cpp:138
+
+} // namespace GH61142

cor3ntin wrote:
> 
> Just to make sure, did you check that this fixes the other examples in the 
> issue? I was afraid i reduced too much
Yes, it helps to fix them. I checked even the original big one.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147531

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


[PATCH] D147531: [clang] Reset track of immediate function context when entering new function

2023-04-04 Thread Mariya Podchishchaeva via Phabricator via cfe-commits
Fznamznon updated this revision to Diff 510807.
Fznamznon added a comment.

Add a comment, rebase, fix format


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147531

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaDecl.cpp
  clang/test/CodeGenCXX/cxx20-consteval-crash.cpp


Index: clang/test/CodeGenCXX/cxx20-consteval-crash.cpp
===
--- clang/test/CodeGenCXX/cxx20-consteval-crash.cpp
+++ clang/test/CodeGenCXX/cxx20-consteval-crash.cpp
@@ -116,3 +116,23 @@
 }
 
 } // namespace GH60166
+
+namespace GH61142 {
+
+template 
+struct Test {
+  constexpr static void g() {
+f();
+  }
+  consteval static void f() {};
+};
+
+consteval void a() {
+  Test::g();
+}
+
+void b() {
+  Test::g();
+}
+
+} // namespace GH61142
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -15175,6 +15175,16 @@
 FD->isConsteval() ? 
ExpressionEvaluationContext::ImmediateFunctionContext
   : ExprEvalContexts.back().Context);
 
+  // Each ExpressionEvaluationContextRecord also keeps track on whether the
+  // context is nested in an immediate function context, so smaller contexts
+  // that appear inside immediate functions (like variable initializers) are
+  // considered to be inside an immediate function context even though by
+  // themselves they are not immediate function contexts. But when the new
+  // function is entered, we need to reset this tracking, since entered 
function
+  // might be not an immediate one and therefore everything inside of it needs
+  // different handling.
+  ExprEvalContexts.back().InImmediateFunctionContext = FD->isConsteval();
+
   // Check for defining attributes before the check for redefinition.
   if (const auto *Attr = FD->getAttr()) {
 Diag(Attr->getLocation(), diag::err_alias_is_definition) << FD << 0;
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -271,6 +271,9 @@
   (`#60887 `_)
 - Fix incorrect merging of lambdas across modules.
   (`#60985 `_)
+- Fix assertion hit when template consteval function appears in nested
+  consteval/constexpr call chain.
+  (`#61142 `_)
 
 
 Bug Fixes to Compiler Builtins


Index: clang/test/CodeGenCXX/cxx20-consteval-crash.cpp
===
--- clang/test/CodeGenCXX/cxx20-consteval-crash.cpp
+++ clang/test/CodeGenCXX/cxx20-consteval-crash.cpp
@@ -116,3 +116,23 @@
 }
 
 } // namespace GH60166
+
+namespace GH61142 {
+
+template 
+struct Test {
+  constexpr static void g() {
+f();
+  }
+  consteval static void f() {};
+};
+
+consteval void a() {
+  Test::g();
+}
+
+void b() {
+  Test::g();
+}
+
+} // namespace GH61142
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -15175,6 +15175,16 @@
 FD->isConsteval() ? ExpressionEvaluationContext::ImmediateFunctionContext
   : ExprEvalContexts.back().Context);
 
+  // Each ExpressionEvaluationContextRecord also keeps track on whether the
+  // context is nested in an immediate function context, so smaller contexts
+  // that appear inside immediate functions (like variable initializers) are
+  // considered to be inside an immediate function context even though by
+  // themselves they are not immediate function contexts. But when the new
+  // function is entered, we need to reset this tracking, since entered function
+  // might be not an immediate one and therefore everything inside of it needs
+  // different handling.
+  ExprEvalContexts.back().InImmediateFunctionContext = FD->isConsteval();
+
   // Check for defining attributes before the check for redefinition.
   if (const auto *Attr = FD->getAttr()) {
 Diag(Attr->getLocation(), diag::err_alias_is_definition) << FD << 0;
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -271,6 +271,9 @@
   (`#60887 `_)
 - Fix incorrect merging of lambdas across modules.
   (`#60985 `_)
+- Fix assertion hit when template consteval function appears in nested
+  consteval/constexpr call chain.
+  (`#61142 `_)
 
 
 Bug Fixes to Compiler Builtins
___
cfe-commits mailing list

[clang] 74cc438 - [clang-format] Add option for having one port per line in Verilog

2023-04-04 Thread via cfe-commits

Author: sstwcw
Date: 2023-04-04T14:51:22Z
New Revision: 74cc4389f37d753bf07f1b4a4a4c5e09433d9231

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

LOG: [clang-format] Add option for having one port per line in Verilog

We added the option `VerilogBreakBetweenInstancePorts` to put ports on
separate lines in module instantiations.  We made it default to true
because style guides mostly recommend it that way for example:

https://github.com/lowRISC/style-guides/blob/master/VerilogCodingStyle.md#module-instantiation

Reviewed By: HazardyKnusperkeks

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

Added: 


Modified: 
clang/docs/ClangFormatStyleOptions.rst
clang/include/clang/Format/Format.h
clang/lib/Format/Format.cpp
clang/lib/Format/FormatToken.h
clang/lib/Format/TokenAnnotator.cpp
clang/unittests/Format/ConfigParseTest.cpp
clang/unittests/Format/FormatTestVerilog.cpp
clang/unittests/Format/TokenAnnotatorTest.cpp

Removed: 




diff  --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index 4078019f82bad..527bdff5f5b56 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -5302,6 +5302,22 @@ the configuration (without a prefix: ``Auto``).
 
 
 
+.. _VerilogBreakBetweenInstancePorts:
+
+**VerilogBreakBetweenInstancePorts** (``Boolean``) :versionbadge:`clang-format 
17` :ref:`¶ `
+  For Verilog, put each port on its own line in module instantiations.
+
+  .. code-block:: c++
+
+ true:
+ ffnand ff1(.q(),
+.qbar(out1),
+.clear(in1),
+.preset(in2));
+
+ false:
+ ffnand ff1(.q(), .qbar(out1), .clear(in1), .preset(in2));
+
 .. _WhitespaceSensitiveMacros:
 
 **WhitespaceSensitiveMacros** (``List of Strings``) 
:versionbadge:`clang-format 11` :ref:`¶ `

diff  --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index 85daa50b5bac8..755621ec53d63 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -4219,6 +4219,20 @@ struct FormatStyle {
   /// \version 3.7
   UseTabStyle UseTab;
 
+  /// For Verilog, put each port on its own line in module instantiations.
+  /// \code
+  ///true:
+  ///ffnand ff1(.q(),
+  ///   .qbar(out1),
+  ///   .clear(in1),
+  ///   .preset(in2));
+  ///
+  ///false:
+  ///ffnand ff1(.q(), .qbar(out1), .clear(in1), .preset(in2));
+  /// \endcode
+  /// \version 17
+  bool VerilogBreakBetweenInstancePorts;
+
   /// A vector of macros which are whitespace-sensitive and should not
   /// be touched.
   ///
@@ -4388,6 +4402,8 @@ struct FormatStyle {
StatementAttributeLikeMacros == R.StatementAttributeLikeMacros &&
StatementMacros == R.StatementMacros && TabWidth == R.TabWidth &&
TypenameMacros == R.TypenameMacros && UseTab == R.UseTab &&
+   VerilogBreakBetweenInstancePorts ==
+   R.VerilogBreakBetweenInstancePorts &&
WhitespaceSensitiveMacros == R.WhitespaceSensitiveMacros;
   }
 

diff  --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 97c4867fcb449..248d3684d01f2 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -1038,6 +1038,8 @@ template <> struct MappingTraits {
 IO.mapOptional("TabWidth", Style.TabWidth);
 IO.mapOptional("TypenameMacros", Style.TypenameMacros);
 IO.mapOptional("UseTab", Style.UseTab);
+IO.mapOptional("VerilogBreakBetweenInstancePorts",
+   Style.VerilogBreakBetweenInstancePorts);
 IO.mapOptional("WhitespaceSensitiveMacros",
Style.WhitespaceSensitiveMacros);
 IO.mapOptional("Macros", Style.Macros);
@@ -1462,6 +1464,7 @@ FormatStyle getLLVMStyle(FormatStyle::LanguageKind 
Language) {
   LLVMStyle.StatementMacros.push_back("QT_REQUIRE_VERSION");
   LLVMStyle.TabWidth = 8;
   LLVMStyle.UseTab = FormatStyle::UT_Never;
+  LLVMStyle.VerilogBreakBetweenInstancePorts = true;
   LLVMStyle.WhitespaceSensitiveMacros.push_back("BOOST_PP_STRINGIZE");
   LLVMStyle.WhitespaceSensitiveMacros.push_back("CF_SWIFT_NAME");
   LLVMStyle.WhitespaceSensitiveMacros.push_back("NS_SWIFT_NAME");

diff  --git a/clang/lib/Format/FormatToken.h b/clang/lib/Format/FormatToken.h
index 59d4a871f7eca..dc136428082e0 100644
--- a/clang/lib/Format/FormatToken.h
+++ b/clang/lib/Format/FormatToken.h
@@ -152,6 +152,9 @@ namespace format {
* In 'logic [1:0] x[1:0]', only the first '['. This way we can have space   
\
* before the first bracket but not the second. */   
\
   TYPE(VerilogDimensionedTypeName) 
\
+  /* list of port 

[PATCH] D147327: [clang-format] Add option for having one port per line in Verilog

2023-04-04 Thread sstwcw 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 rG74cc4389f37d: [clang-format] Add option for having one port 
per line in Verilog (authored by sstwcw).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147327

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/lib/Format/FormatToken.h
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/ConfigParseTest.cpp
  clang/unittests/Format/FormatTestVerilog.cpp
  clang/unittests/Format/TokenAnnotatorTest.cpp

Index: clang/unittests/Format/TokenAnnotatorTest.cpp
===
--- clang/unittests/Format/TokenAnnotatorTest.cpp
+++ clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -1645,6 +1645,18 @@
   EXPECT_TOKEN_PRECEDENCE(Tokens[1], prec::Assignment);
   EXPECT_TOKEN(Tokens[3], tok::lessequal, TT_BinaryOperator);
   EXPECT_TOKEN_PRECEDENCE(Tokens[3], prec::Relational);
+
+  // Port lists in module instantiation.
+  Tokens = Annotate("module_x instance_1(port_1), instance_2(port_2);");
+  ASSERT_EQ(Tokens.size(), 12u);
+  EXPECT_TOKEN(Tokens[2], tok::l_paren, TT_VerilogInstancePortLParen);
+  EXPECT_TOKEN(Tokens[7], tok::l_paren, TT_VerilogInstancePortLParen);
+  Tokens = Annotate("module_x #(parameter) instance_1(port_1), "
+"instance_2(port_2);");
+  ASSERT_EQ(Tokens.size(), 16u);
+  EXPECT_TOKEN(Tokens[2], tok::l_paren, TT_VerilogInstancePortLParen);
+  EXPECT_TOKEN(Tokens[6], tok::l_paren, TT_VerilogInstancePortLParen);
+  EXPECT_TOKEN(Tokens[11], tok::l_paren, TT_VerilogInstancePortLParen);
 }
 
 TEST_F(TokenAnnotatorTest, UnderstandConstructors) {
Index: clang/unittests/Format/FormatTestVerilog.cpp
===
--- clang/unittests/Format/FormatTestVerilog.cpp
+++ clang/unittests/Format/FormatTestVerilog.cpp
@@ -673,6 +673,77 @@
"  x = x;");
 }
 
+TEST_F(FormatTestVerilog, Instantiation) {
+  // Without ports.
+  verifyFormat("ffnand ff1;");
+  // With named ports.
+  verifyFormat("ffnand ff1(.qbar(out1),\n"
+   "   .clear(in1),\n"
+   "   .preset(in2));");
+  // With wildcard.
+  verifyFormat("ffnand ff1(.qbar(out1),\n"
+   "   .clear(in1),\n"
+   "   .preset(in2),\n"
+   "   .*);");
+  verifyFormat("ffnand ff1(.*,\n"
+   "   .qbar(out1),\n"
+   "   .clear(in1),\n"
+   "   .preset(in2));");
+  // With unconnected ports.
+  verifyFormat("ffnand ff1(.q(),\n"
+   "   .qbar(out1),\n"
+   "   .clear(in1),\n"
+   "   .preset(in2));");
+  verifyFormat("ffnand ff1(.q(),\n"
+   "   .qbar(),\n"
+   "   .clear(),\n"
+   "   .preset());");
+  verifyFormat("ffnand ff1(,\n"
+   "   .qbar(out1),\n"
+   "   .clear(in1),\n"
+   "   .preset(in2));");
+  // With positional ports.
+  verifyFormat("ffnand ff1(out1,\n"
+   "   in1,\n"
+   "   in2);");
+  verifyFormat("ffnand ff1(,\n"
+   "   out1,\n"
+   "   in1,\n"
+   "   in2);");
+  // Multiple instantiations.
+  verifyFormat("ffnand ff1(.q(),\n"
+   "   .qbar(out1),\n"
+   "   .clear(in1),\n"
+   "   .preset(in2)),\n"
+   "   ff1(.q(),\n"
+   "   .qbar(out1),\n"
+   "   .clear(in1),\n"
+   "   .preset(in2));");
+  verifyFormat("ffnand //\n"
+   "ff1(.q(),\n"
+   ".qbar(out1),\n"
+   ".clear(in1),\n"
+   ".preset(in2)),\n"
+   "ff1(.q(),\n"
+   ".qbar(out1),\n"
+   ".clear(in1),\n"
+   ".preset(in2));");
+  // With breaking between instance ports disabled.
+  auto Style = getDefaultStyle();
+  Style.VerilogBreakBetweenInstancePorts = false;
+  verifyFormat("ffnand ff1;", Style);
+  verifyFormat("ffnand ff1(.qbar(out1), .clear(in1), .preset(in2), .*);",
+   Style);
+  verifyFormat("ffnand ff1(out1, in1, in2);", Style);
+  verifyFormat("ffnand ff1(.q(), .qbar(out1), .clear(in1), .preset(in2)),\n"
+   "   ff1(.q(), .qbar(out1), .clear(in1), .preset(in2));",
+   Style);
+  verifyFormat("ffnand //\n"
+   "ff1(.q(), .qbar(out1), .clear(in1), .preset(in2)),\n"
+   "ff1(.q(), .qbar(out1), .clear(in1), .preset(in2));",
+   Style);
+}
+
 

[PATCH] D147535: [clang][Interp] Don't create global variables more than once

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

  just because we're being told to evaluate it twice. This sometimes
  happens when a variable is evaluated again during codegen.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D147535

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


Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp
===
--- clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -1564,7 +1564,11 @@
   std::optional VarT = classify(VD->getType());
 
   if (shouldBeGloballyIndexed(VD)) {
-std::optional GlobalIndex = P.getOrCreateGlobal(VD, Init);
+// We've already seen and initialized this global.
+if (P.getGlobal(VD))
+  return true;
+
+std::optional GlobalIndex = P.createGlobal(VD, Init);
 
 if (!GlobalIndex)
   return this->bail(VD);


Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp
===
--- clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -1564,7 +1564,11 @@
   std::optional VarT = classify(VD->getType());
 
   if (shouldBeGloballyIndexed(VD)) {
-std::optional GlobalIndex = P.getOrCreateGlobal(VD, Init);
+// We've already seen and initialized this global.
+if (P.getGlobal(VD))
+  return true;
+
+std::optional GlobalIndex = P.createGlobal(VD, Init);
 
 if (!GlobalIndex)
   return this->bail(VD);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D147534: [clang][Interp] Make sure we have a variable scope for initializers

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

  Otherwise, we run into an assertion when trying to use the current
  variable scope while creating temporaries for constructor initializers.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D147534

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


Index: clang/test/AST/Interp/records.cpp
===
--- clang/test/AST/Interp/records.cpp
+++ clang/test/AST/Interp/records.cpp
@@ -252,6 +252,26 @@
 constexpr S s;
 static_assert(s.m() == 1, "");
 
+namespace InitializerTemporaries {
+  class Bar {
+  private:
+int a;
+
+  public:
+constexpr Bar() : a(10) {}
+constexpr int getA() const { return a; }
+  };
+
+  class Foo {
+  public:
+int a;
+
+constexpr Foo() : a(Bar().getA()) {}
+  };
+  constexpr Foo F;
+  static_assert(F.a == 10, "");
+}
+
 #if __cplusplus >= 201703L
 namespace BaseInit {
   class _A {public: int a;};
Index: clang/lib/AST/Interp/ByteCodeStmtGen.cpp
===
--- clang/lib/AST/Interp/ByteCodeStmtGen.cpp
+++ clang/lib/AST/Interp/ByteCodeStmtGen.cpp
@@ -94,6 +94,9 @@
   // Classify the return type.
   ReturnType = this->classify(F->getReturnType());
 
+  // Scope needed for the initializers.
+  BlockScope Scope(this);
+
   // Constructor. Set up field initializers.
   if (const auto Ctor = dyn_cast(F)) {
 const RecordDecl *RD = Ctor->getParent();


Index: clang/test/AST/Interp/records.cpp
===
--- clang/test/AST/Interp/records.cpp
+++ clang/test/AST/Interp/records.cpp
@@ -252,6 +252,26 @@
 constexpr S s;
 static_assert(s.m() == 1, "");
 
+namespace InitializerTemporaries {
+  class Bar {
+  private:
+int a;
+
+  public:
+constexpr Bar() : a(10) {}
+constexpr int getA() const { return a; }
+  };
+
+  class Foo {
+  public:
+int a;
+
+constexpr Foo() : a(Bar().getA()) {}
+  };
+  constexpr Foo F;
+  static_assert(F.a == 10, "");
+}
+
 #if __cplusplus >= 201703L
 namespace BaseInit {
   class _A {public: int a;};
Index: clang/lib/AST/Interp/ByteCodeStmtGen.cpp
===
--- clang/lib/AST/Interp/ByteCodeStmtGen.cpp
+++ clang/lib/AST/Interp/ByteCodeStmtGen.cpp
@@ -94,6 +94,9 @@
   // Classify the return type.
   ReturnType = this->classify(F->getReturnType());
 
+  // Scope needed for the initializers.
+  BlockScope Scope(this);
+
   // Constructor. Set up field initializers.
   if (const auto Ctor = dyn_cast(F)) {
 const RecordDecl *RD = Ctor->getParent();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D102107: [OpenMP] Codegen aggregate for outlined function captures

2023-04-04 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 updated this revision to Diff 510797.
jhuber6 added a comment.
Herald added subscribers: kbarton, nemanjai.

Fixed the Clang tests. Haven't touched the LLVM ones because this breaks 
SPMDzation and state machine rewrites completely in those tests. Someone who 
knows what this patch changes should look into what needs to be updated to make 
those tests match whatever form SPDMzation expects now. Also for some bizarre 
reason this patch breaks adding `alwaysinline` on `kmpc_parallel_51`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102107

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.h
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.h
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/AST/ast-dump-openmp-distribute-parallel-for-simd.c
  clang/test/AST/ast-dump-openmp-distribute-parallel-for.c
  clang/test/AST/ast-dump-openmp-target-teams-distribute-parallel-for-simd.c
  clang/test/AST/ast-dump-openmp-target-teams-distribute-parallel-for.c
  clang/test/AST/ast-dump-openmp-teams-distribute-parallel-for-simd.c
  clang/test/AST/ast-dump-openmp-teams-distribute-parallel-for.c
  clang/test/CodeGen/PowerPC/ppc64le-varargs-f128.c
  clang/test/OpenMP/amdgpu_target_with_aligned_attribute.c
  clang/test/OpenMP/bug54082.c
  clang/test/OpenMP/bug60602.cpp
  clang/test/OpenMP/cancel_codegen.cpp
  clang/test/OpenMP/cancellation_point_codegen.cpp
  clang/test/OpenMP/debug-info-complex-byval.cpp
  clang/test/OpenMP/debug-info-openmp-array.cpp
  clang/test/OpenMP/debug_threadprivate_copyin.c
  clang/test/OpenMP/declare_target_codegen_globalization.cpp
  clang/test/OpenMP/declare_target_constexpr_codegen.cpp
  clang/test/OpenMP/declare_variant_construct_codegen_1.c
  clang/test/OpenMP/distribute_codegen.cpp
  clang/test/OpenMP/distribute_firstprivate_codegen.cpp
  clang/test/OpenMP/distribute_lastprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_firstprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_if_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_lastprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_num_threads_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_private_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_proc_bind_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_reduction_task_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_firstprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_if_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_lastprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_num_threads_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_private_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_proc_bind_codegen.cpp
  clang/test/OpenMP/distribute_private_codegen.cpp
  clang/test/OpenMP/distribute_simd_codegen.cpp
  clang/test/OpenMP/distribute_simd_firstprivate_codegen.cpp
  clang/test/OpenMP/distribute_simd_lastprivate_codegen.cpp
  clang/test/OpenMP/distribute_simd_private_codegen.cpp
  clang/test/OpenMP/distribute_simd_reduction_codegen.cpp
  clang/test/OpenMP/for_firstprivate_codegen.cpp
  clang/test/OpenMP/for_lastprivate_codegen.cpp
  clang/test/OpenMP/for_linear_codegen.cpp
  clang/test/OpenMP/for_private_codegen.cpp
  clang/test/OpenMP/for_reduction_codegen.cpp
  clang/test/OpenMP/for_reduction_codegen_UDR.cpp
  clang/test/OpenMP/for_reduction_task_codegen.cpp
  clang/test/OpenMP/irbuilder_safelen.cpp
  clang/test/OpenMP/irbuilder_safelen_order_concurrent.cpp
  clang/test/OpenMP/irbuilder_simd_aligned.cpp
  clang/test/OpenMP/irbuilder_simdlen.cpp
  clang/test/OpenMP/irbuilder_simdlen_safelen.cpp
  clang/test/OpenMP/master_taskloop_in_reduction_codegen.cpp
  clang/test/OpenMP/master_taskloop_simd_in_reduction_codegen.cpp
  clang/test/OpenMP/metadirective_device_kind_codegen.c
  clang/test/OpenMP/metadirective_device_kind_codegen.cpp
  clang/test/OpenMP/metadirective_implementation_codegen.cpp
  clang/test/OpenMP/nested_loop_codegen.cpp
  clang/test/OpenMP/nvptx_SPMD_codegen.cpp
  clang/test/OpenMP/nvptx_allocate_codegen.cpp
  clang/test/OpenMP/nvptx_data_sharing.cpp
  clang/test/OpenMP/nvptx_distribute_parallel_generic_mode_codegen.cpp
  clang/test/OpenMP/nvptx_lambda_capturing.cpp
  clang/test/OpenMP/nvptx_lambda_pointer_capturing.cpp
  clang/test/OpenMP/nvptx_multi_target_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_nested_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_parallel_for_codegen.cpp
  clang/test/OpenMP/nvptx_target_codegen.cpp
  clang/test/OpenMP/nvptx_target_parallel_codegen.cpp
  

[PATCH] D147531: [clang] Reset track of immediate function context when entering new function

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

Thanks, for working on this
Congrats on finding the underlying issue, it must not have been easy!




Comment at: clang/lib/Sema/SemaDecl.cpp:15177
   : ExprEvalContexts.back().Context);
+ExprEvalContexts.back().InImmediateFunctionContext = FD->isConsteval();
 

I think it might be worth adding a comment there to explain why this is 
necessary.
I think i convinced myself this make sense and is almost certainly the correct 
fix but it would, I think, benefit from some more explanation for future 
reference.





Comment at: clang/test/CodeGenCXX/cxx20-consteval-crash.cpp:138
+
+} // namespace GH61142


Just to make sure, did you check that this fixes the other examples in the 
issue? I was afraid i reduced too much


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147531

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


  1   2   >