[PATCH] D156821: [CodeGen] [ubsan] Respect integer overflow handling in abs builtin

2023-08-08 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

The overall approach here seems reasonable.  I mean, technically the undefined 
behavior is happening in the library, but detecting it early seems like a good 
idea.

This approach does have a significant limitation, though: CGBuiltin won't 
detect cases that involve taking the address of abs().  So ubsan won't end up 
picking up undefined behavior in such calls, and -fwrapv won't apply.  Maybe 
that's rare enough we don't really care, though.

Needs a release note.

Do we want to update ubsan documentation to reflect this?




Comment at: clang/lib/CodeGen/CGBuiltin.cpp:2697
+bool SanitizeBuiltin = SanOpts.has(SanitizerKind::Builtin);
+bool SanitizeOverflow = SanOpts.has(SanitizerKind::SignedIntegerOverflow);
+

Putting the behavior under both "builtin" and "signed-integer-overflow" feels a 
little weird; is there any precedent for that?



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:2702
+case LangOptions::SOB_Defined:
+  Result = Builder.CreateBinaryIntrinsic(
+  Intrinsic::abs, EmitScalarExpr(E->getArg(0)), Builder.getFalse(),

Can we land the change to directly generate calls to llvm.abs() in the default 
case separately? This might end up impacting generated code for a variety of 
workloads, and I'd prefer to have a more clear bisect point.


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

https://reviews.llvm.org/D156821

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


[PATCH] D157434: [include-cleaner] Add a simple heuristic to handle token-pasting symbols.

2023-08-08 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: kadircet.
Herald added a project: All.
hokein requested review of this revision.
Herald added a project: clang-tools-extra.

include-cleaner didn't report the usage of token-pasting symbols, as
these symbols are spelled in a "scratch space" file which is not a real
file, thus we have some false postives of unused includes for these
symbols (e.g. ABSL_FLAG).

This patch adds a simple heuristic to handle this case, we use the
expansion location as a "proxy" reference location, this should work
well on token-pasting formed from macro arguemtns.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D157434

Files:
  clang-tools-extra/include-cleaner/lib/Analysis.cpp
  clang-tools-extra/include-cleaner/lib/HTMLReport.cpp
  clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp


Index: clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp
===
--- clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp
+++ clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp
@@ -197,6 +197,31 @@
   Pair(Code.point("4"), UnorderedElementsAre(MainFile;
 }
 
+TEST_F(WalkUsedTest, TokenPasting) {
+  llvm::Annotations Code(R"cpp(
+#define DEFINE_FLAG(name) int FLAG_##name = 0;
+#define MY_FLAG(name) DEFINE_FLAG(MY_##name)
+
+#define PASTED_TOKEN X##2
+
+$1^DEFINE_FLAG(abc);
+$2^MY_FLAG(abc);
+
+int $3^TPASTED_TOKEN = 3;
+  )cpp");
+  Inputs.Code = Code.code();
+
+  TestAST AST(Inputs);
+  auto  = AST.sourceManager();
+  auto MainFile = Header(SM.getFileEntryForID(SM.getMainFileID()));
+
+  EXPECT_THAT(offsetToProviders(AST, SM),
+  UnorderedElementsAre(
+  Pair(Code.point("1"), UnorderedElementsAre(MainFile)),
+  Pair(Code.point("2"), UnorderedElementsAre(MainFile)),
+  Pair(Code.point("3"), UnorderedElementsAre(MainFile;
+}
+
 class AnalyzeTest : public testing::Test {
 protected:
   TestInputs Inputs;
Index: clang-tools-extra/include-cleaner/lib/HTMLReport.cpp
===
--- clang-tools-extra/include-cleaner/lib/HTMLReport.cpp
+++ clang-tools-extra/include-cleaner/lib/HTMLReport.cpp
@@ -519,6 +519,9 @@
   const auto& SM = Ctx.getSourceManager();
   for (Decl *Root : Roots)
 walkAST(*Root, [&](SourceLocation Loc, const NamedDecl , RefType T) {
+  if (SM.isWrittenInScratchSpace( SM.getSpellingLoc(Loc)))
+Loc = SM.getExpansionLoc(Loc);
+
   if(!SM.isWrittenInMainFile(SM.getSpellingLoc(Loc)))
 return;
   R.addRef(SymbolReference{D, Loc, T});
Index: clang-tools-extra/include-cleaner/lib/Analysis.cpp
===
--- clang-tools-extra/include-cleaner/lib/Analysis.cpp
+++ clang-tools-extra/include-cleaner/lib/Analysis.cpp
@@ -40,6 +40,15 @@
   tooling::stdlib::Recognizer Recognizer;
   for (auto *Root : ASTRoots) {
 walkAST(*Root, [&](SourceLocation Loc, NamedDecl , RefType RT) {
+  // If the symbol is spelled as a token paste, it spelling location points
+  // to  file which is not a real file. We fallback to use
+  // the expansion location, this herustic is based on the assumption that
+  // most of token pastings are formed with the macro arguement, and it can
+  // allow us to detect uses of symbol defined by the common macro like
+  // `ABSL_FLAG`.
+  if (SM.isWrittenInScratchSpace(SM.getSpellingLoc(Loc)))
+Loc = SM.getExpansionLoc(Loc);
+
   auto FID = SM.getFileID(SM.getSpellingLoc(Loc));
   if (FID != SM.getMainFileID() && FID != SM.getPreambleFileID())
 return;


Index: clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp
===
--- clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp
+++ clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp
@@ -197,6 +197,31 @@
   Pair(Code.point("4"), UnorderedElementsAre(MainFile;
 }
 
+TEST_F(WalkUsedTest, TokenPasting) {
+  llvm::Annotations Code(R"cpp(
+#define DEFINE_FLAG(name) int FLAG_##name = 0;
+#define MY_FLAG(name) DEFINE_FLAG(MY_##name)
+
+#define PASTED_TOKEN X##2
+
+$1^DEFINE_FLAG(abc);
+$2^MY_FLAG(abc);
+
+int $3^TPASTED_TOKEN = 3;
+  )cpp");
+  Inputs.Code = Code.code();
+
+  TestAST AST(Inputs);
+  auto  = AST.sourceManager();
+  auto MainFile = Header(SM.getFileEntryForID(SM.getMainFileID()));
+
+  EXPECT_THAT(offsetToProviders(AST, SM),
+  UnorderedElementsAre(
+  Pair(Code.point("1"), UnorderedElementsAre(MainFile)),
+  Pair(Code.point("2"), UnorderedElementsAre(MainFile)),
+  Pair(Code.point("3"), UnorderedElementsAre(MainFile;
+}
+
 class AnalyzeTest : public testing::Test {
 protected:
   TestInputs Inputs;
Index: 

[PATCH] D157435: [Sema] Do not emit -Wmissing-variable-declarations for register variables

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

LGTM aside from some minor nits.




Comment at: clang/docs/ReleaseNotes.rst:126-127
   of a base class is not called in the constructor of its derived class.
+- Clang no longer emits `-Wmissing-variable-declarations` for variables 
declared
+  with the `register` storage class.
 

Sphinx fixes



Comment at: clang/test/Sema/warn-missing-variable-declarations-register.c:2
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -Wmissing-variable-declarations 
-fsyntax-only -verify %s
+// REQUIRES: x86-registered-target
+// expected-no-diagnostics

nickdesaulniers wrote:
> @aaron.ballman do we need this REQUIRES clause?
Nope, no need for `REQUIRES` here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157435

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


[PATCH] D157428: [clang-tidy] `readability-implicit-bool-conversion.AllowIntegerConditions` ignores `DoStmt`s

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



Comment at: clang-tools-extra/docs/ReleaseNotes.rst:199-202
+- Improved :doc:`readability-implicit-bool-conversion
+  ` check to take do-while loops into
+  account for the ``AllowIntegerConditions`` and ``AllowPointerConditions``
+  options.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157428

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


[PATCH] D157436: [clang-tidy] `performance-faster-string-find` generates incorrect fixes for single quote character literals

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

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157436

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


[clang-tools-extra] f263f45 - [clang-tidy] `readability-implicit-bool-conversion.AllowIntegerConditions` ignores `DoStmt`s

2023-08-08 Thread Fabian Wolff via cfe-commits

Author: Fabian Wolff
Date: 2023-08-08T23:07:10+02:00
New Revision: f263f45ba6494c7516a11b1af920d6ca98e79d2b

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

LOG: [clang-tidy] `readability-implicit-bool-conversion.AllowIntegerConditions` 
ignores `DoStmt`s

Reviewed By: PiotrZSL

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

Added: 


Modified: 
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-allow-in-conditions.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/readability/ImplicitBoolConversionCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/ImplicitBoolConversionCheck.cpp
index 863ac4dbbf4c6d..99b792b90a3ca9 100644
--- a/clang-tools-extra/clang-tidy/readability/ImplicitBoolConversionCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/ImplicitBoolConversionCheck.cpp
@@ -228,7 +228,8 @@ bool isCastAllowedInCondition(const ImplicitCastExpr *Cast,
   if (!S)
 return false;
   if (isa(S) || isa(S) || isa(S) ||
-  isa(S) || isa(S))
+  isa(S) || isa(S) ||
+  isa(S))
 return true;
   if (isa(S) || isa(S) ||
   isUnaryLogicalNotOperator(S) ||

diff  --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index dbd2fbf6de6d42..78d3dab48f5306 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -196,6 +196,11 @@ Changes in existing checks
   ` check to emit proper
   warnings when a type forward declaration precedes its definition.
 
+- Improved :doc:`readability-implicit-bool-conversion
+  ` check to take
+  do-while loops into account for the `AllowIntegerConditions` and
+  `AllowPointerConditions` options.
+
 Removed checks
 ^^
 

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/readability/implicit-bool-conversion-allow-in-conditions.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/readability/implicit-bool-conversion-allow-in-conditions.cpp
index f17b4dcacdb61b..e393e297140cbd 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/readability/implicit-bool-conversion-allow-in-conditions.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/readability/implicit-bool-conversion-allow-in-conditions.cpp
@@ -38,6 +38,9 @@ void implicitConversionIntegerToBoolInConditionalsIsAllowed() 
{
   while (functionReturningInt()) {}
   while (functionReturningPointer()) {}
   while (functionReturningInt() && !functionReturningPointer() || 
(!functionReturningInt() && functionReturningPointer())) {}
+  do {} while (functionReturningInt());
+  do {} while (functionReturningPointer());
+  do {} while (functionReturningInt() && !functionReturningPointer() || 
(!functionReturningInt() && functionReturningPointer()));
   int value1 = functionReturningInt() ? 1 : 2;
   int value2 = !functionReturningInt() ? 1 : 2;
   int value3 = (functionReturningInt() && functionReturningPointer() || 
!functionReturningInt()) ? 1 : 2;



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


[PATCH] D157438: [OpenMP] Ensure wrapper headers are included on both host and device

2023-08-08 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added inline comments.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:1190-1191
 // the resource directory at clang/lib/Headers/llvm_libc_wrappers.
-if (C.getActiveOffloadKinds() == Action::OFK_None) {
+if ((getToolChain().getTriple().isNVPTX() ||
+ getToolChain().getTriple().isAMDGCN()) &&
+C.getActiveOffloadKinds() == Action::OFK_None) {

arsenm wrote:
> can we do something better than this NVPTX||AMDGCN checks
This is more or less "Are we one of the GPUs `libc` supports". This is for 
cross-compiling so there's no existing infrastructure.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157438

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


[PATCH] D157331: [clang] Implement C23

2023-08-08 Thread Aditya Kumar via Phabricator via cfe-commits
hiraditya added inline comments.



Comment at: clang/test/Headers/stdckdint.cpp:1
+// RUN: %clang_cc1 -emit-llvm -fgnuc-version=4.2.1 -std=gnu++11 %s -o - | 
FileCheck %s
+

seems like we don't have a -std=gnu23, or -std=c23 standard flag for this in 
clang yet.

https://godbolt.org/z/7dKnGEWWE

we probably need it before testing stdckdint i guess?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157331

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


[PATCH] D157440: [clang][ConstExprEmitter] handle BinaryOperators that don't have signedness or overflow concerns for integrals

2023-08-08 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers updated this revision to Diff 548358.
nickdesaulniers edited the summary of this revision.
nickdesaulniers added a comment.

- use const &
- add link to issue tracker


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157440

Files:
  clang/lib/CodeGen/CGExprConstant.cpp


Index: clang/lib/CodeGen/CGExprConstant.cpp
===
--- clang/lib/CodeGen/CGExprConstant.cpp
+++ clang/lib/CodeGen/CGExprConstant.cpp
@@ -1401,6 +1401,64 @@
 return nullptr;
   }
 
+  llvm::Constant *VisitBinaryOperator(BinaryOperator *B, QualType T) {
+// Can we attempt to handle this opcode?
+switch (B->getOpcode()) {
+default:
+  return nullptr;
+case BO_And:
+case BO_Xor:
+case BO_Or:
+case BO_EQ:
+case BO_NE:
+  break;
+}
+
+// Constant evaluate LHS
+Expr *LHS = B->getLHS();
+llvm::Constant *LHSC = Visit(LHS, T);
+
+// Only handle integers for now.
+if (!LHSC || !isa(LHSC))
+  return nullptr;
+
+// Constant evaluate RHS
+Expr *RHS = B->getRHS();
+llvm::Constant *RHSC = Visit(RHS, T);
+
+// Only handle integers for now.
+if (!RHSC || !isa(RHSC))
+  return nullptr;
+
+const llvm::APInt  = cast(RHSC)->getValue();
+const llvm::APInt  = cast(LHSC)->getValue();
+llvm::APInt Ret;
+
+// Fold
+switch (B->getOpcode()) {
+default:
+  // Should have return earlier.
+  llvm_unreachable("unhandled BinaryOperator kind");
+case BO_And:
+  Ret = L & R;
+  break;
+case BO_Xor:
+  Ret = L ^ R;
+  break;
+case BO_Or:
+  Ret = L | R;
+  break;
+case BO_EQ:
+  Ret = L == R;
+  break;
+case BO_NE:
+  Ret = L != R;
+  break;
+}
+
+return llvm::ConstantInt::get(CGM.getLLVMContext(), Ret);
+  }
+
   // Utility methods
   llvm::Type *ConvertType(QualType T) {
 return CGM.getTypes().ConvertType(T);


Index: clang/lib/CodeGen/CGExprConstant.cpp
===
--- clang/lib/CodeGen/CGExprConstant.cpp
+++ clang/lib/CodeGen/CGExprConstant.cpp
@@ -1401,6 +1401,64 @@
 return nullptr;
   }
 
+  llvm::Constant *VisitBinaryOperator(BinaryOperator *B, QualType T) {
+// Can we attempt to handle this opcode?
+switch (B->getOpcode()) {
+default:
+  return nullptr;
+case BO_And:
+case BO_Xor:
+case BO_Or:
+case BO_EQ:
+case BO_NE:
+  break;
+}
+
+// Constant evaluate LHS
+Expr *LHS = B->getLHS();
+llvm::Constant *LHSC = Visit(LHS, T);
+
+// Only handle integers for now.
+if (!LHSC || !isa(LHSC))
+  return nullptr;
+
+// Constant evaluate RHS
+Expr *RHS = B->getRHS();
+llvm::Constant *RHSC = Visit(RHS, T);
+
+// Only handle integers for now.
+if (!RHSC || !isa(RHSC))
+  return nullptr;
+
+const llvm::APInt  = cast(RHSC)->getValue();
+const llvm::APInt  = cast(LHSC)->getValue();
+llvm::APInt Ret;
+
+// Fold
+switch (B->getOpcode()) {
+default:
+  // Should have return earlier.
+  llvm_unreachable("unhandled BinaryOperator kind");
+case BO_And:
+  Ret = L & R;
+  break;
+case BO_Xor:
+  Ret = L ^ R;
+  break;
+case BO_Or:
+  Ret = L | R;
+  break;
+case BO_EQ:
+  Ret = L == R;
+  break;
+case BO_NE:
+  Ret = L != R;
+  break;
+}
+
+return llvm::ConstantInt::get(CGM.getLLVMContext(), Ret);
+  }
+
   // Utility methods
   llvm::Type *ConvertType(QualType T) {
 return CGM.getTypes().ConvertType(T);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D153914: [clang-cl] Enable concatenation of predefined identifiers

2023-08-08 Thread Richard Dzenis via Phabricator via cfe-commits
RIscRIpt added a comment.

In D153914#4570148 , @cor3ntin wrote:

> We will commit on your behalf, what name/email do you want us to use? 
> Thanks!

Thanks for asking; keep the name/email as-is in the commit you see: `Author: 
Richard Dzenis `




Comment at: clang/lib/Sema/Sema.cpp:1494-1505
+Decl *Sema::getCurLocalScopeDecl() {
+  if (const BlockScopeInfo *BSI = getCurBlock())
+return BSI->TheDecl;
+  else if (const LambdaScopeInfo *LSI = getCurLambda())
+return LSI->CallOperator;
+  else if (const CapturedRegionScopeInfo *CSI = getCurCapturedRegion())
+return CSI->TheCapturedDecl;

aaron.ballman wrote:
> Made the function `const` because it's not writing to any fields, removed 
> `else` because of preceding `return`.
I would love to, and I tried. But unfortunately it's not possible without 
introducing more changes: all the member functions (except 
`getCurFunctionOrMethodDecl()`) are non-const.
Removed `else`.



Comment at: clang/lib/Sema/SemaExpr.cpp:1998-2000
+if (isa(currentDecl)) {
+  Diag(Tok.getLocation(), diag::ext_predef_outside_function);
+}

aaron.ballman wrote:
> This will miss the diagnostic if the current declaration is a namespace 
> instead of at file scope, right?
Right. But `getCurLocalScopeDecl()` returns function scope at most. See Note in 
a code comment above.



Comment at: clang/lib/Sema/SemaExpr.cpp:2001-2004
+OS << '"'
+   << Lexer::Stringify(PredefinedExpr::ComputeName(
+  getPredefinedExprKind(Tok.getKind()), currentDecl))
+   << '"';

tahonermann wrote:
> RIscRIpt wrote:
> > tahonermann wrote:
> > > A diagnostic is issued if the call to `getCurScopeDecl()` returned a 
> > > translation unit declaration (at least in Microsoft mode). Does it make 
> > > sense to pass a pointer to a `TranslationUnitDecl` here?
> > Shortly, yes, kind of. `ComputeName` can handle `TranslationUnitDecl` in 
> > which case it returns an empty string. This way we implicitly (without 
> > additional code) create empty string-literal Tokens which can be handled in 
> > `StringLiteralParser`. And we cannot pass non-string-literal tokens into 
> > `StringLiteralParser`.
> Ah, ok. And I see it even differentiates what name is produced for 
> `__PRETTY_FUNCTION__`. That leaves me wondering what the right behavior 
> should be at class and namespace scope, but maybe I'm better off not asking 
> questions I don't want to know the answer to.
> A diagnostic is issued if the call to `getCurScopeDecl()` returned a 
> translation unit declaration (at least in Microsoft mode). Does it make sense 
> to pass a pointer to a `TranslationUnitDecl` here?




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153914

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


[PATCH] D142569: [OpenMP] Introduce kernel environment

2023-08-08 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
doru1004 added a comment.

The changes in this patch do not actually work correctly with kernels that 
really need to be in Generic mode. The ExecMode value recovered in the 
kmpc_kernel_init function is 3 in the case where it needs to be 1.

The problem lies with the OpenMPOpt changes since disabling them makes 
everything work again.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142569

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


[PATCH] D138810: [RISCV] Support vector crypto extension C intrinsics

2023-08-08 Thread Brandon Wu via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2a05a5215f69: [RISCV] Support vector crypto extension C 
intrinsics (authored by 4vtomat).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138810

Files:
  clang/include/clang/Basic/riscv_vector.td
  clang/include/clang/Basic/riscv_vector_common.td
  clang/include/clang/Support/RISCVVIntrinsicUtils.h
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Support/RISCVVIntrinsicUtils.cpp
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaesdf.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaesdm.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaesef.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaesem.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaeskf1.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaeskf2.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaesz.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vandn.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vbrev.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vbrev8.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vclmul.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vclmulh.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vclz.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vcpopv.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vctz.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vghsh.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vgmul.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vrev8.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vrol.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vror.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsha2ch.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsha2cl.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsha2ms.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsm3c.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsm3me.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsm4k.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsm4r.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vwsll.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vaesdf.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vaesdm.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vaesef.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vaesem.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vaeskf1.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vaeskf2.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vaesz.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vandn.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vbrev.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vbrev8.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vclmul.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vclmulh.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vclz.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vcpopv.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vctz.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vghsh.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vgmul.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vrev8.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vrol.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vror.c
  

[PATCH] D157467: [RISCV] Add missing REQUIRES for zvk-invalid.c test

2023-08-08 Thread Brandon Wu via Phabricator via cfe-commits
4vtomat created this revision.
Herald added subscribers: jobnoorman, VincentWu, vkmr, luismarques, 
sameer.abuasal, s.egerton, Jim, benna, psnobl, rogfer01, shiva0217, kito-cheng, 
simoncook, asb, arichardson.
Herald added a project: All.
4vtomat requested review of this revision.
Herald added subscribers: cfe-commits, wangpc, eopXD.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D157467

Files:
  clang/test/Sema/zvk-invalid.c


Index: clang/test/Sema/zvk-invalid.c
===
--- clang/test/Sema/zvk-invalid.c
+++ clang/test/Sema/zvk-invalid.c
@@ -1,3 +1,4 @@
+// REQUIRES: riscv-registered-target
 // RUN: %clang_cc1 -triple riscv64 -target-feature +v %s -fsyntax-only -verify
 
 #include 


Index: clang/test/Sema/zvk-invalid.c
===
--- clang/test/Sema/zvk-invalid.c
+++ clang/test/Sema/zvk-invalid.c
@@ -1,3 +1,4 @@
+// REQUIRES: riscv-registered-target
 // RUN: %clang_cc1 -triple riscv64 -target-feature +v %s -fsyntax-only -verify
 
 #include 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D138810: [RISCV] Support vector crypto extension C intrinsics

2023-08-08 Thread Brandon Wu via Phabricator via cfe-commits
4vtomat added a comment.

In D138810#4571579 , @dyung wrote:

> The test you added clang/test/Sema/zvk-invalid.c is failing on bots, for 
> example https://lab.llvm.org/buildbot/#/builders/139/builds/47055.
>
> Is the test missing a `REQUIRES: riscv-registered-target` line by any chance?

Yeah, you are right, I will have a patch to fix it, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138810

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


[PATCH] D157296: [AST][Coroutine] Fix CoyieldExpr missing end loc

2023-08-08 Thread Ding Fei via Phabricator via cfe-commits
danix800 added a comment.

I'll finish this patch when CI build succeeds.

For future improvement I might start with the idea
of marking those generated inner exprs as implicit,
this seems to be easier.


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

https://reviews.llvm.org/D157296

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


[PATCH] D153536: [Clang] Implement P2169 A nice placeholder with no name

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

In D153536#4570513 , @vitalybuka 
wrote:

> This patch brakes https://lab.llvm.org/buildbot/#/builders/168/builds/14997
> Not sure what is wrong there, probably the test need to be updated. Can you 
> please take a look?

I'm a bit confused -- the linked bot is green and the failures to either side 
of the linked run are both failing for the same reason (which seems to be 
unrelated to the changes in this patch). It looks like this bot went red here: 
https://lab.llvm.org/buildbot/#/builders/168/builds/14944 and hasn't reliably 
come back to green.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153536

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


[PATCH] D157331: [clang] Implement C23

2023-08-08 Thread Zijun Zhao via Phabricator via cfe-commits
ZijunZhao added inline comments.



Comment at: clang/test/Headers/stdckdint.cpp:1
+// RUN: %clang_cc1 -emit-llvm -fgnuc-version=4.2.1 -std=gnu++11 %s -o - | 
FileCheck %s
+

enh wrote:
> hiraditya wrote:
> > seems like we don't have a -std=gnu23, or -std=c23 standard flag for this 
> > in clang yet.
> > 
> > https://godbolt.org/z/7dKnGEWWE
> > 
> > we probably need it before testing stdckdint i guess?
> other headers just use > and the previous version. (though see stdalign.h if 
> you're looking for some random cleanup to do!)
> seems like we don't have a -std=gnu23, or -std=c23 standard flag for this in 
> clang yet.

In the local testing, `-std=c++23` works  and all tests pass 




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157331

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


[PATCH] D157129: [NFC] Fix unnecessary copy with auto.

2023-08-08 Thread Srividya Sundaram via Phabricator via cfe-commits
srividya-sundaram added a comment.

In D157129#4564766 , @steakhal wrote:

> I went over the patch and I found only a single debatable case for taking by 
> reference.
> To clarify why I would prefer taking by value: value semantics is good for 
> local reasoning; thus improves maintainability. We should only deviate from 
> that when there is actual benefit for doing so.
> Static analysis tools, such as Coverity, have false-positives. Some rules are 
> better than others.
> As a static analysis tool developer myself, I'd recommend carefully 
> evaluating the findings before taking action for resolving them.
> And if you find anything interesting, tool vendors are generally happy to 
> receive feedback about their tool. I guess, they should as well understand 
> that taking a pointer by reference doesn't improve anything.

Thank you, @steakhal for the detailed feedback.
Based on your comments, and after discussing with @tahonermann, I am abandoning 
this patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157129

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


[clang-tools-extra] 5b95d17 - [clang-tidy] `performance-faster-string-find` generates incorrect fixes for single quote character literals

2023-08-08 Thread Fabian Wolff via cfe-commits

Author: Fabian Wolff
Date: 2023-08-09T00:55:45+02:00
New Revision: 5b95d17da1f0719f0af711e032d36b18fcb92070

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

LOG: [clang-tidy] `performance-faster-string-find` generates incorrect fixes 
for single quote character literals

Reviewed By: PiotrZSL

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/performance/FasterStringFindCheck.cpp
clang-tools-extra/docs/ReleaseNotes.rst

clang-tools-extra/test/clang-tidy/checkers/performance/faster-string-find.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/performance/FasterStringFindCheck.cpp 
b/clang-tools-extra/clang-tidy/performance/FasterStringFindCheck.cpp
index d932b5fb936cb2..ca4f6ad409b08c 100644
--- a/clang-tools-extra/clang-tidy/performance/FasterStringFindCheck.cpp
+++ b/clang-tools-extra/clang-tidy/performance/FasterStringFindCheck.cpp
@@ -26,14 +26,20 @@ std::optional makeCharacterLiteral(const 
StringLiteral *Literal) {
 Literal->outputString(OS);
   }
   // Now replace the " with '.
-  auto Pos = Result.find_first_of('"');
-  if (Pos == Result.npos)
+  auto OpenPos = Result.find_first_of('"');
+  if (OpenPos == Result.npos)
 return std::nullopt;
-  Result[Pos] = '\'';
-  Pos = Result.find_last_of('"');
-  if (Pos == Result.npos)
+  Result[OpenPos] = '\'';
+
+  auto ClosePos = Result.find_last_of('"');
+  if (ClosePos == Result.npos)
 return std::nullopt;
-  Result[Pos] = '\'';
+  Result[ClosePos] = '\'';
+
+  // "'" is OK, but ''' is not, so add a backslash
+  if ((ClosePos - OpenPos) == 2 && Result[OpenPos + 1] == '\'')
+Result.replace(OpenPos + 1, 1, "\\'");
+
   return Result;
 }
 

diff  --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index 78d3dab48f5306..c4b09bae18ec37 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -188,6 +188,10 @@ Changes in existing checks
   ` to support for-loops with
   iterators initialized by free functions like ``begin``, ``end``, or ``size``.
 
+- Improved :doc:`performance-faster-string-find
+  ` check to properly escape
+  single quotes.
+
 - Improved :doc:`performanc-noexcept-swap
   ` check to enforce a stricter
   match with the swap function signature, eliminating false-positives.

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/performance/faster-string-find.cpp 
b/clang-tools-extra/test/clang-tidy/checkers/performance/faster-string-find.cpp
index dc625024fd1bc9..b50d175cff3b70 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/performance/faster-string-find.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/performance/faster-string-find.cpp
@@ -56,13 +56,21 @@ void StringFind() {
   // CHECK-MESSAGES: [[@LINE-1]]:12: warning: 'find' called with a string 
literal
   // CHECK-FIXES: Str.find('a', 1);
 
-  // Doens't work with strings smaller or larger than 1 char.
+  // Doesn't work with strings smaller or larger than 1 char.
   Str.find("");
   Str.find("ab");
 
   // Doesn't do anything with the 3 argument overload.
   Str.find("a", 1, 1);
 
+  // Single quotes are escaped properly
+  Str.find("'");
+  // CHECK-MESSAGES: [[@LINE-1]]:12: warning: 'find' called with a string 
literal
+  // CHECK-FIXES: Str.find('\'');
+  Str.find("\'");
+  // CHECK-MESSAGES: [[@LINE-1]]:12: warning: 'find' called with a string 
literal
+  // CHECK-FIXES: Str.find('\'');
+
   // Other methods that can also be replaced
   Str.rfind("a");
   // CHECK-MESSAGES: [[@LINE-1]]:13: warning: 'rfind' called with a string 
literal



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


[PATCH] D157436: [clang-tidy] `performance-faster-string-find` generates incorrect fixes for single quote character literals

2023-08-08 Thread Fabian Wolff 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 rG5b95d17da1f0: [clang-tidy] `performance-faster-string-find` 
generates incorrect fixes for… (authored by fwolff).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157436

Files:
  clang-tools-extra/clang-tidy/performance/FasterStringFindCheck.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/test/clang-tidy/checkers/performance/faster-string-find.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/performance/faster-string-find.cpp
===
--- 
clang-tools-extra/test/clang-tidy/checkers/performance/faster-string-find.cpp
+++ 
clang-tools-extra/test/clang-tidy/checkers/performance/faster-string-find.cpp
@@ -56,13 +56,21 @@
   // CHECK-MESSAGES: [[@LINE-1]]:12: warning: 'find' called with a string 
literal
   // CHECK-FIXES: Str.find('a', 1);
 
-  // Doens't work with strings smaller or larger than 1 char.
+  // Doesn't work with strings smaller or larger than 1 char.
   Str.find("");
   Str.find("ab");
 
   // Doesn't do anything with the 3 argument overload.
   Str.find("a", 1, 1);
 
+  // Single quotes are escaped properly
+  Str.find("'");
+  // CHECK-MESSAGES: [[@LINE-1]]:12: warning: 'find' called with a string 
literal
+  // CHECK-FIXES: Str.find('\'');
+  Str.find("\'");
+  // CHECK-MESSAGES: [[@LINE-1]]:12: warning: 'find' called with a string 
literal
+  // CHECK-FIXES: Str.find('\'');
+
   // Other methods that can also be replaced
   Str.rfind("a");
   // CHECK-MESSAGES: [[@LINE-1]]:13: warning: 'rfind' called with a string 
literal
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -188,6 +188,10 @@
   ` to support for-loops with
   iterators initialized by free functions like ``begin``, ``end``, or ``size``.
 
+- Improved :doc:`performance-faster-string-find
+  ` check to properly escape
+  single quotes.
+
 - Improved :doc:`performanc-noexcept-swap
   ` check to enforce a stricter
   match with the swap function signature, eliminating false-positives.
Index: clang-tools-extra/clang-tidy/performance/FasterStringFindCheck.cpp
===
--- clang-tools-extra/clang-tidy/performance/FasterStringFindCheck.cpp
+++ clang-tools-extra/clang-tidy/performance/FasterStringFindCheck.cpp
@@ -26,14 +26,20 @@
 Literal->outputString(OS);
   }
   // Now replace the " with '.
-  auto Pos = Result.find_first_of('"');
-  if (Pos == Result.npos)
+  auto OpenPos = Result.find_first_of('"');
+  if (OpenPos == Result.npos)
 return std::nullopt;
-  Result[Pos] = '\'';
-  Pos = Result.find_last_of('"');
-  if (Pos == Result.npos)
+  Result[OpenPos] = '\'';
+
+  auto ClosePos = Result.find_last_of('"');
+  if (ClosePos == Result.npos)
 return std::nullopt;
-  Result[Pos] = '\'';
+  Result[ClosePos] = '\'';
+
+  // "'" is OK, but ''' is not, so add a backslash
+  if ((ClosePos - OpenPos) == 2 && Result[OpenPos + 1] == '\'')
+Result.replace(OpenPos + 1, 1, "\\'");
+
   return Result;
 }
 


Index: clang-tools-extra/test/clang-tidy/checkers/performance/faster-string-find.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/performance/faster-string-find.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/performance/faster-string-find.cpp
@@ -56,13 +56,21 @@
   // CHECK-MESSAGES: [[@LINE-1]]:12: warning: 'find' called with a string literal
   // CHECK-FIXES: Str.find('a', 1);
 
-  // Doens't work with strings smaller or larger than 1 char.
+  // Doesn't work with strings smaller or larger than 1 char.
   Str.find("");
   Str.find("ab");
 
   // Doesn't do anything with the 3 argument overload.
   Str.find("a", 1, 1);
 
+  // Single quotes are escaped properly
+  Str.find("'");
+  // CHECK-MESSAGES: [[@LINE-1]]:12: warning: 'find' called with a string literal
+  // CHECK-FIXES: Str.find('\'');
+  Str.find("\'");
+  // CHECK-MESSAGES: [[@LINE-1]]:12: warning: 'find' called with a string literal
+  // CHECK-FIXES: Str.find('\'');
+
   // Other methods that can also be replaced
   Str.rfind("a");
   // CHECK-MESSAGES: [[@LINE-1]]:13: warning: 'rfind' called with a string literal
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -188,6 +188,10 @@
   ` to support for-loops with
   iterators initialized by free functions like ``begin``, ``end``, or ``size``.
 
+- Improved :doc:`performance-faster-string-find
+  ` check to properly escape
+  single quotes.
+
 - Improved 

[PATCH] D157452: [RFC][Clang][Codegen] `std::type_info` needs special care with explicit address spaces

2023-08-08 Thread Alex Voicu via Phabricator via cfe-commits
AlexVlx created this revision.
AlexVlx added reviewers: rjmccall, efriedma, yaxunl, arsenm.
AlexVlx added a project: clang.
Herald added a project: All.
AlexVlx requested review of this revision.
Herald added subscribers: cfe-commits, wdng.

After https://reviews.llvm.org/D153092, for targets that use a non-default AS 
for globals, an "interesting" situation arises around `typeid` and its paired 
type, `type_info`:

- on the AST level, the `type_info` interface is defined with default / generic 
addresses, be it for function arguments, or for `this`;
- in IR, `type_info` values are globals, and thus pointers to `type_info` 
values are pointers to global

This leads to a mismatch between the function signature / formal type of the 
argument, and its actual type. Currently we try to handle such mismatches via 
bitcast, but that is wrong in this case, since an ascast is required. 
**However**, I'm not convinced this is the right way to address it, I've just 
not found a better / less noisy one (yet?); the other alternative would be to 
special case codegen for typeinfo itself, and adjust the IR function signatures 
there. That's less centralised and doesn't actually seem correct, since 
`type_info` has a C++(mangled) interface, and we'd be basically lying about the 
type. Hopefully I'm missing some obvious and significantly more tidy solution - 
hence the RFC.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D157452

Files:
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGExprCXX.cpp
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/test/CodeGenCXX/typeid-cxx11-with-address-space.cpp
  clang/test/CodeGenCXX/typeid-with-address-space.cpp
  clang/test/CodeGenCXX/typeinfo
  clang/test/CodeGenCXX/typeinfo-with-address-space.cpp

Index: clang/test/CodeGenCXX/typeinfo-with-address-space.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/typeinfo-with-address-space.cpp
@@ -0,0 +1,51 @@
+// RUN: %clang_cc1 -I%S %s -triple amdgcn-amd-amdhsa -emit-llvm -o - | FileCheck %s -check-prefix=AS
+// RUN: %clang_cc1 -I%S %s -triple x86_64-linux-gnu -emit-llvm -o - | FileCheck %s -check-prefix=NO-AS
+#include 
+
+class A {
+virtual void f() = 0;
+};
+
+class B : A {
+void f() override;
+};
+
+// AS: @_ZTISt9type_info = external addrspace(1) constant ptr addrspace(1)
+// NO-AS: @_ZTISt9type_info = external constant ptr
+// AS: @_ZTIi = external addrspace(1) constant ptr addrspace(1)
+// NO-AS: @_ZTIi = external constant ptr
+// AS: @_ZTVN10__cxxabiv117__class_type_infoE = external addrspace(1) global ptr addrspace(1)
+// NO-AS: @_ZTVN10__cxxabiv117__class_type_infoE = external global ptr
+// AS: @_ZTS1A = linkonce_odr addrspace(1) constant [3 x i8] c"1A\00", comdat, align 1
+// NO-AS: @_ZTS1A = linkonce_odr constant [3 x i8] c"1A\00", comdat, align 1
+// AS: @_ZTI1A = linkonce_odr addrspace(1) constant { ptr addrspace(1), ptr addrspace(1) } { ptr addrspace(1) getelementptr inbounds (ptr addrspace(1), ptr addrspace(1) @_ZTVN10__cxxabiv117__class_type_infoE, i64 2), ptr addrspace(1) @_ZTS1A }, comdat, align 8
+// NO-AS: @_ZTI1A = linkonce_odr constant { ptr, ptr } { ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv117__class_type_infoE, i64 2), ptr @_ZTS1A }, comdat, align 8
+// AS: @_ZTIf = external addrspace(1) constant ptr addrspace(1)
+// NO-AS: @_ZTIf = external constant ptr
+
+unsigned long Fn(B& b) {
+// AS: %3 = addrspacecast ptr addrspace(1) %2 to ptr
+// AS-NEXT: %call = call noundef zeroext i1 @_ZNKSt9type_infoeqERKS_(ptr {{.*}} addrspacecast (ptr addrspace(1) @_ZTISt9type_info to ptr), ptr {{.*}} %3)
+// NO-AS: %call = call noundef zeroext i1 @_ZNKSt9type_infoeqERKS_(ptr {{.*}} @_ZTISt9type_info, ptr {{.*}} %2)
+if (typeid(std::type_info) == typeid(b))
+return 42;
+// AS: %7 = addrspacecast ptr addrspace(1) %6 to ptr
+// AS-NEXT: %call2 = call noundef zeroext i1 @_ZNKSt9type_infoneERKS_(ptr {{.*}} addrspacecast (ptr addrspace(1) @_ZTIi to ptr), ptr {{.*}} %7)
+// NO-AS: %call2 = call noundef zeroext i1 @_ZNKSt9type_infoneERKS_(ptr {{.*}} @_ZTIi, ptr {{.*}} %5)
+if (typeid(int) != typeid(b))
+return 1712;
+// AS: %11 = addrspacecast ptr addrspace(1) %10 to ptr
+// AS-NEXT: %call7 = call noundef ptr @_ZNKSt9type_info4nameEv(ptr {{.*}} %11)
+// NO-AS: %call7 = call noundef ptr @_ZNKSt9type_info4nameEv(ptr {{.*}} %8)
+if (typeid(A).name() == typeid(b).name())
+return 0;
+// AS: %15 = addrspacecast ptr addrspace(1) %14 to ptr
+// AS-NEXT: %call11 = call noundef zeroext i1 @_ZNKSt9type_info6beforeERKS_(ptr {{.*}} %15, ptr {{.*}} addrspacecast (ptr addrspace(1) @_ZTIf to ptr))
+// NO-AS:   %call11 = call noundef zeroext i1 @_ZNKSt9type_info6beforeERKS_(ptr {{.*}} %11, ptr {{.*}} @_ZTIf)
+if (typeid(b).before(typeid(float)))
+return 1;
+// AS: %19 = addrspacecast ptr addrspace(1) %18 to ptr
+// AS-NEXT: %call15 = call noundef i64 @_ZNKSt9type_info9hash_codeEv(ptr {{.*}} %19)
+// NO-AS: 

[PATCH] D153536: [Clang] Implement P2169 A nice placeholder with no name

2023-08-08 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

> Thanks! We might need someone from clangd to help here. The logs do not have 
> any information explaining what's failing with the test, and looking at the 
> test code, I struggle to see how these changes would impact that test. We've 
> had some significant issues with flaky clangd tests 
> (https://github.com/clangd/clangd/issues/1712), so it's possible this is 
> happenstance.

I tried to debug that, and it looks like false Asan report. Maybe a bug in 
FakeStack::GC related code.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153536

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


[PATCH] D157054: [clang] NFC: Use compile-time option spelling when generating command line

2023-08-08 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 updated this revision to Diff 548425.
jansvoboda11 added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157054

Files:
  clang/lib/Frontend/CompilerInvocation.cpp


Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -615,7 +615,7 @@
 static void GenerateArg(ArgumentConsumer Consumer,
 llvm::opt::OptSpecifier OptSpecifier) {
   Option Opt = getDriverOptTable().getOption(OptSpecifier);
-  denormalizeSimpleFlag(Consumer, Opt.getPrefix() + Opt.getName(),
+  denormalizeSimpleFlag(Consumer, Opt.getPrefixedName(),
 Option::OptionClass::FlagClass, 0);
 }
 
@@ -623,8 +623,7 @@
 llvm::opt::OptSpecifier OptSpecifier,
 const Twine ) {
   Option Opt = getDriverOptTable().getOption(OptSpecifier);
-  denormalizeString(Consumer, Opt.getPrefix() + Opt.getName(), Opt.getKind(), 
0,
-Value);
+  denormalizeString(Consumer, Opt.getPrefixedName(), Opt.getKind(), 0, Value);
 }
 
 // Parse command line arguments into CompilerInvocation.


Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -615,7 +615,7 @@
 static void GenerateArg(ArgumentConsumer Consumer,
 llvm::opt::OptSpecifier OptSpecifier) {
   Option Opt = getDriverOptTable().getOption(OptSpecifier);
-  denormalizeSimpleFlag(Consumer, Opt.getPrefix() + Opt.getName(),
+  denormalizeSimpleFlag(Consumer, Opt.getPrefixedName(),
 Option::OptionClass::FlagClass, 0);
 }
 
@@ -623,8 +623,7 @@
 llvm::opt::OptSpecifier OptSpecifier,
 const Twine ) {
   Option Opt = getDriverOptTable().getOption(OptSpecifier);
-  denormalizeString(Consumer, Opt.getPrefix() + Opt.getName(), Opt.getKind(), 0,
-Value);
+  denormalizeString(Consumer, Opt.getPrefixedName(), Opt.getKind(), 0, Value);
 }
 
 // Parse command line arguments into CompilerInvocation.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D153114: [clangd] [C++20] [Modules] Support C++20 modules for clangd

2023-08-08 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added a comment.

Got it. The explanation makes sense. A well designed and scaling solution is 
what I (and probably every one) want.

Then from the expectation, the difference between supporting header modules and 
C++20 named modules from the **user** side may be:

- For supporting header modules in clangd, it is mainly a speed issue and some 
corner cases.
- For supporting C++20 named modules in clangd, it will be pretty hard for 
users to use named modules in practice.

In another word, it may not be super bad for not supporting header modules in 
clangd. But it is super bad for named modules. So I am wondering if we can have 
an expectation for the time points to support named modules (even only 
experimentally) in clangd. For example, may it be a reasonable expectation that 
we can have named modules support in clangd in clang18? Clang18 will be 
released in the first week of March 2024. So that's still roughly 7 months away 
from now. I guess the time span may be sufficient. How do you feel about this? 
And if we have consensus on that, then we will need to move forward from the 
patch if we don't have solution in December at least. Since it takes time to 
review and experiment this further.

BTW, I don't mind someone else to take this job away completely as long as we 
can get the support in time since I am not a clangd developer : )


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

https://reviews.llvm.org/D153114

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


[PATCH] D157332: [clang] Make init for empty no_unique_address fields a no-op write

2023-08-08 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

In D157332#4570290 , @crtrott wrote:

> Question: does this bug potentially affect code generation for 
> AMD/NVIDIA/Intel GPUs?

I believe the easiest way to test that is to try compiling `struct S {}; S 
ret() { return S(); }` into IR and checking the signature - if it returns void, 
the target should be immune to this bug, otherwise the bug probably is present.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157332

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


[PATCH] D157119: cmake: add missing dependencies on ClangDriverOptions tablegen

2023-08-08 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

In D157119#4569967 , @vitalybuka 
wrote:

> In D157119#4569725 , @jroelofs 
> wrote:
>
>> Flaky test? Here's a later build where it succeeds, but the change has 
>> nothing to do with clangd: 
>> https://lab.llvm.org/buildbot/#/builders/168/builds/14997
>
> No, I manually requested a revision in the blame range.
> I am bisecting on VM forked from the bot. Can reproduce there.
> I will update the bug in a few hours.

Sorry, this patch is not to blame.
D153536  is the cause.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157119

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


[clang] 6a4779c - [NFC] Fix static analyzer concern

2023-08-08 Thread Elizabeth Andrews via cfe-commits

Author: Elizabeth Andrews
Date: 2023-08-08T13:28:15-07:00
New Revision: 6a4779cc235c171f7a5049726f58e14a2cc4e6c8

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

LOG: [NFC] Fix static analyzer concern

Fix static analyzer concern about potential null value
dereference. findBackingIvar() dereferences Prop. PR
checks that Prop exists before calling the function.

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

Added: 


Modified: 
clang/lib/Analysis/BodyFarm.cpp

Removed: 




diff  --git a/clang/lib/Analysis/BodyFarm.cpp b/clang/lib/Analysis/BodyFarm.cpp
index b989b8422cfc82..13ec9b65c9f0b2 100644
--- a/clang/lib/Analysis/BodyFarm.cpp
+++ b/clang/lib/Analysis/BodyFarm.cpp
@@ -806,7 +806,7 @@ static Stmt *createObjCPropertyGetter(ASTContext ,
 
   if (!IVar) {
 Prop = MD->findPropertyDecl();
-IVar = findBackingIvar(Prop);
+IVar = Prop ? findBackingIvar(Prop) : nullptr;
   }
 
   if (!IVar || !Prop)



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


[PATCH] D157429: [NFC] [Clang] Fix static analyzer concern

2023-08-08 Thread Elizabeth Andrews 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 rG6a4779cc235c: [NFC] Fix static analyzer concern (authored by 
eandrews).
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D157429?vs=548317=548332#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157429

Files:
  clang/lib/Analysis/BodyFarm.cpp


Index: clang/lib/Analysis/BodyFarm.cpp
===
--- clang/lib/Analysis/BodyFarm.cpp
+++ clang/lib/Analysis/BodyFarm.cpp
@@ -806,7 +806,7 @@
 
   if (!IVar) {
 Prop = MD->findPropertyDecl();
-IVar = findBackingIvar(Prop);
+IVar = Prop ? findBackingIvar(Prop) : nullptr;
   }
 
   if (!IVar || !Prop)


Index: clang/lib/Analysis/BodyFarm.cpp
===
--- clang/lib/Analysis/BodyFarm.cpp
+++ clang/lib/Analysis/BodyFarm.cpp
@@ -806,7 +806,7 @@
 
   if (!IVar) {
 Prop = MD->findPropertyDecl();
-IVar = findBackingIvar(Prop);
+IVar = Prop ? findBackingIvar(Prop) : nullptr;
   }
 
   if (!IVar || !Prop)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D157428: [clang-tidy] `readability-implicit-bool-conversion.AllowIntegerConditions` ignores `DoStmt`s

2023-08-08 Thread Fabian Wolff 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 rGf263f45ba649: [clang-tidy] 
`readability-implicit-bool-conversion.AllowIntegerConditions`… (authored by 
fwolff).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157428

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-allow-in-conditions.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/readability/implicit-bool-conversion-allow-in-conditions.cpp
===
--- 
clang-tools-extra/test/clang-tidy/checkers/readability/implicit-bool-conversion-allow-in-conditions.cpp
+++ 
clang-tools-extra/test/clang-tidy/checkers/readability/implicit-bool-conversion-allow-in-conditions.cpp
@@ -38,6 +38,9 @@
   while (functionReturningInt()) {}
   while (functionReturningPointer()) {}
   while (functionReturningInt() && !functionReturningPointer() || 
(!functionReturningInt() && functionReturningPointer())) {}
+  do {} while (functionReturningInt());
+  do {} while (functionReturningPointer());
+  do {} while (functionReturningInt() && !functionReturningPointer() || 
(!functionReturningInt() && functionReturningPointer()));
   int value1 = functionReturningInt() ? 1 : 2;
   int value2 = !functionReturningInt() ? 1 : 2;
   int value3 = (functionReturningInt() && functionReturningPointer() || 
!functionReturningInt()) ? 1 : 2;
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -196,6 +196,11 @@
   ` check to emit proper
   warnings when a type forward declaration precedes its definition.
 
+- Improved :doc:`readability-implicit-bool-conversion
+  ` check to take
+  do-while loops into account for the `AllowIntegerConditions` and
+  `AllowPointerConditions` options.
+
 Removed checks
 ^^
 
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
@@ -228,7 +228,8 @@
   if (!S)
 return false;
   if (isa(S) || isa(S) || isa(S) ||
-  isa(S) || isa(S))
+  isa(S) || isa(S) ||
+  isa(S))
 return true;
   if (isa(S) || isa(S) ||
   isUnaryLogicalNotOperator(S) ||


Index: clang-tools-extra/test/clang-tidy/checkers/readability/implicit-bool-conversion-allow-in-conditions.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability/implicit-bool-conversion-allow-in-conditions.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability/implicit-bool-conversion-allow-in-conditions.cpp
@@ -38,6 +38,9 @@
   while (functionReturningInt()) {}
   while (functionReturningPointer()) {}
   while (functionReturningInt() && !functionReturningPointer() || (!functionReturningInt() && functionReturningPointer())) {}
+  do {} while (functionReturningInt());
+  do {} while (functionReturningPointer());
+  do {} while (functionReturningInt() && !functionReturningPointer() || (!functionReturningInt() && functionReturningPointer()));
   int value1 = functionReturningInt() ? 1 : 2;
   int value2 = !functionReturningInt() ? 1 : 2;
   int value3 = (functionReturningInt() && functionReturningPointer() || !functionReturningInt()) ? 1 : 2;
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -196,6 +196,11 @@
   ` check to emit proper
   warnings when a type forward declaration precedes its definition.
 
+- Improved :doc:`readability-implicit-bool-conversion
+  ` check to take
+  do-while loops into account for the `AllowIntegerConditions` and
+  `AllowPointerConditions` options.
+
 Removed checks
 ^^
 
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
@@ -228,7 +228,8 @@
   if (!S)
 return false;
   if (isa(S) || isa(S) || isa(S) ||
-  isa(S) || isa(S))
+  isa(S) || isa(S) ||
+  isa(S))
 return true;
   if (isa(S) || isa(S) ||
   isUnaryLogicalNotOperator(S) ||
___

[PATCH] D157438: [OpenMP] Ensure wrapper headers are included on both host and device

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



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:1190-1191
 // the resource directory at clang/lib/Headers/llvm_libc_wrappers.
-if (C.getActiveOffloadKinds() == Action::OFK_None) {
+if ((getToolChain().getTriple().isNVPTX() ||
+ getToolChain().getTriple().isAMDGCN()) &&
+C.getActiveOffloadKinds() == Action::OFK_None) {

can we do something better than this NVPTX||AMDGCN checks


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157438

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


[PATCH] D157440: [clang][ConstExprEmitter] handle BinaryOperators that don't have signedness or overflow concerns for integrals

2023-08-08 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers created this revision.
Herald added a project: All.
nickdesaulniers requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Handles binary operators: & ^ | == !=

Check that each side evaluates to a ConstantInt then combine the
results.

We probably can reuse DataRecursiveIntBinOpEvaluator or
handleIntIntBinOp from ExprConstant.cpp for the rest, or even these
cases as well.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D157440

Files:
  clang/lib/CodeGen/CGExprConstant.cpp


Index: clang/lib/CodeGen/CGExprConstant.cpp
===
--- clang/lib/CodeGen/CGExprConstant.cpp
+++ clang/lib/CodeGen/CGExprConstant.cpp
@@ -1401,6 +1401,64 @@
 return nullptr;
   }
 
+  llvm::Constant *VisitBinaryOperator(BinaryOperator *B, QualType T) {
+// Can we attempt to handle this opcode?
+switch (B->getOpcode()) {
+default:
+  return nullptr;
+case BO_And:
+case BO_Xor:
+case BO_Or:
+case BO_EQ:
+case BO_NE:
+  break;
+}
+
+// Constant evaluate LHS
+Expr *LHS = B->getLHS();
+llvm::Constant *LHSC = Visit(LHS, T);
+
+// Only handle integers for now.
+if (!LHSC || !isa(LHSC))
+  return nullptr;
+
+// Constant evaluate RHS
+Expr *RHS = B->getRHS();
+llvm::Constant *RHSC = Visit(RHS, T);
+
+// Only handle integers for now.
+if (!RHSC || !isa(RHSC))
+  return nullptr;
+
+const llvm::APInt R = cast(RHSC)->getValue();
+const llvm::APInt L = cast(LHSC)->getValue();
+llvm::APInt Ret;
+
+// Fold
+switch (B->getOpcode()) {
+default:
+  // Should have return earlier.
+  llvm_unreachable("unhandled BinaryOperator kind");
+case BO_And:
+  Ret = L & R;
+  break;
+case BO_Xor:
+  Ret = L ^ R;
+  break;
+case BO_Or:
+  Ret = L | R;
+  break;
+case BO_EQ:
+  Ret = L == R;
+  break;
+case BO_NE:
+  Ret = L != R;
+  break;
+}
+
+return llvm::ConstantInt::get(CGM.getLLVMContext(), Ret);
+  }
+
   // Utility methods
   llvm::Type *ConvertType(QualType T) {
 return CGM.getTypes().ConvertType(T);


Index: clang/lib/CodeGen/CGExprConstant.cpp
===
--- clang/lib/CodeGen/CGExprConstant.cpp
+++ clang/lib/CodeGen/CGExprConstant.cpp
@@ -1401,6 +1401,64 @@
 return nullptr;
   }
 
+  llvm::Constant *VisitBinaryOperator(BinaryOperator *B, QualType T) {
+// Can we attempt to handle this opcode?
+switch (B->getOpcode()) {
+default:
+  return nullptr;
+case BO_And:
+case BO_Xor:
+case BO_Or:
+case BO_EQ:
+case BO_NE:
+  break;
+}
+
+// Constant evaluate LHS
+Expr *LHS = B->getLHS();
+llvm::Constant *LHSC = Visit(LHS, T);
+
+// Only handle integers for now.
+if (!LHSC || !isa(LHSC))
+  return nullptr;
+
+// Constant evaluate RHS
+Expr *RHS = B->getRHS();
+llvm::Constant *RHSC = Visit(RHS, T);
+
+// Only handle integers for now.
+if (!RHSC || !isa(RHSC))
+  return nullptr;
+
+const llvm::APInt R = cast(RHSC)->getValue();
+const llvm::APInt L = cast(LHSC)->getValue();
+llvm::APInt Ret;
+
+// Fold
+switch (B->getOpcode()) {
+default:
+  // Should have return earlier.
+  llvm_unreachable("unhandled BinaryOperator kind");
+case BO_And:
+  Ret = L & R;
+  break;
+case BO_Xor:
+  Ret = L ^ R;
+  break;
+case BO_Or:
+  Ret = L | R;
+  break;
+case BO_EQ:
+  Ret = L == R;
+  break;
+case BO_NE:
+  Ret = L != R;
+  break;
+}
+
+return llvm::ConstantInt::get(CGM.getLLVMContext(), Ret);
+  }
+
   // Utility methods
   llvm::Type *ConvertType(QualType T) {
 return CGM.getTypes().ConvertType(T);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D153914: [clang-cl] Enable concatenation of predefined identifiers

2023-08-08 Thread Richard Dzenis via Phabricator via cfe-commits
RIscRIpt updated this revision to Diff 548366.
RIscRIpt marked 4 inline comments as done.
RIscRIpt added a comment.

Address review comments, rebase onto main


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153914

Files:
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Lex/LiteralSupport.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Lex/LiteralSupport.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Parse/ParseExpr.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/Sema/ms_predefined_expr.cpp
  clang/test/Sema/ms_wide_predefined_expr.cpp

Index: clang/test/Sema/ms_wide_predefined_expr.cpp
===
--- clang/test/Sema/ms_wide_predefined_expr.cpp
+++ /dev/null
@@ -1,28 +0,0 @@
-// RUN: %clang_cc1 %s -fsyntax-only -Wno-unused-value -Wmicrosoft -verify -fms-extensions
-// expected-no-diagnostics
-
-// Wide character predefined identifiers
-#define _STR2WSTR(str) L##str
-#define STR2WSTR(str) _STR2WSTR(str)
-void abcdefghi12(void) {
- const wchar_t (*ss)[12] = (__FUNCTION__);
- static int arr[sizeof(STR2WSTR(__FUNCTION__))==12*sizeof(wchar_t) ? 1 : -1];
- const wchar_t (*ss2)[31] = (__FUNCSIG__);
- static int arr2[sizeof(STR2WSTR(__FUNCSIG__))==31*sizeof(wchar_t) ? 1 : -1];
-}
-
-namespace PR13206 {
-void foo(const wchar_t *);
-
-template class A {
-public:
- void method() {
-  foo(L__FUNCTION__);
- }
-};
-
-void bar() {
- A x;
- x.method();
-}
-}
Index: clang/test/Sema/ms_predefined_expr.cpp
===
--- clang/test/Sema/ms_predefined_expr.cpp
+++ clang/test/Sema/ms_predefined_expr.cpp
@@ -1,9 +1,170 @@
 // RUN: %clang_cc1 %s -fsyntax-only -Wmicrosoft -verify -fms-extensions
 
-void f() {
+using size_t = __SIZE_TYPE__;
+
+// Test array initialization
+void array_init() {
  const char a[] = __FUNCTION__; // expected-warning{{initializing an array from a '__FUNCTION__' predefined identifier is a Microsoft extension}}
  const char b[] = __FUNCDNAME__; // expected-warning{{initializing an array from a '__FUNCDNAME__' predefined identifier is a Microsoft extension}}
  const char c[] = __FUNCSIG__; // expected-warning{{initializing an array from a '__FUNCSIG__' predefined identifier is a Microsoft extension}}
  const char d[] = __func__; // expected-warning{{initializing an array from a '__func__' predefined identifier is a Microsoft extension}}
  const char e[] = __PRETTY_FUNCTION__; // expected-warning{{initializing an array from a '__PRETTY_FUNCTION__' predefined identifier is a Microsoft extension}}
+ const wchar_t f[] = L__FUNCTION__; // expected-warning{{initializing an array from a 'L__FUNCTION__' predefined identifier is a Microsoft extension}}
+ const wchar_t g[] = L__FUNCSIG__; // expected-warning{{initializing an array from a 'L__FUNCSIG__' predefined identifier is a Microsoft extension}}
+}
+
+// Test function local identifiers outside of a function
+const char* g_function = __FUNCTION__;// expected-warning{{predefined identifier is only valid inside function}}
+const char* g_function_lconcat = "" __FUNCTION__; // expected-warning{{predefined identifier is only valid inside function}} \
+  // expected-warning{{expansion of predefined identifier '__FUNCTION__' to a string literal is a Microsoft extension}}
+const char* g_function_rconcat = __FUNCTION__ ""; // expected-warning{{predefined identifier is only valid inside function}} \
+  // expected-warning{{expansion of predefined identifier '__FUNCTION__' to a string literal is a Microsoft extension}}
+
+namespace NS
+{
+  const char* function = __FUNCTION__;// expected-warning{{predefined identifier is only valid inside function}}
+  const char* function_lconcat = "" __FUNCTION__; // expected-warning{{predefined identifier is only valid inside function}} \
+  // expected-warning{{expansion of predefined identifier '__FUNCTION__' to a string literal is a Microsoft extension}}
+  const char* function_rconcat = __FUNCTION__ ""; // expected-warning{{predefined identifier is only valid inside function}} \
+  // expected-warning{{expansion of predefined identifier '__FUNCTION__' to a string literal is a Microsoft extension}}
+
+  struct S
+  {
+static constexpr const char* function = __FUNCTION__;// expected-warning{{predefined identifier is only valid inside function}}
+static constexpr const char* function_lconcat = "" __FUNCTION__; // expected-warning{{predefined identifier is only valid inside function}} \
+ // expected-warning{{expansion of predefined 

[PATCH] D138810: [RISCV] Support vector crypto extension C intrinsics

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

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138810

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


[PATCH] D157441: [-Wunsafe-buffer-usage] Use `Strategy` to determine whether to fix a parameter

2023-08-08 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

Ooo nice!!

> Extend PointerAssignmentGadget and PointerInitGadget to generate fix-its for 
> cases where the left-hand side has won't fix strategy and the right-hand side 
> has std::span strategy.

Hmm, is this intertwined with other changes, or is this completely separate? 
Also my head appears to be blank; did we reach any conclusion about the nature 
of "single" RHS-es and usefulness of annotating them as such? Which could be an 
approach that would encourage people to propagate more bounds in the backwards 
direction by default.




Comment at: clang/lib/Analysis/UnsafeBufferUsage.cpp:1507
+if (S.lookup(RightVD) == Strategy::Kind::Span) {
+  const ASTContext  = // FIXME: we need ASTContext to be passed in!
+  RightVD->getASTContext();

`MatchFinder::MatchResult.Context` is what you're probably looking for, so it's 
already kinda passed in. You can stash it in a member variable in the base 
class `Gadget` and have it readily available everywhere, i.e.

```lang=diff
 class Gadget {
 public:
-  Gadget(Kind K) : K(K) {}
+  Gadget(Kind K, const MatchResult ) : K(K), Context(*Result.Context) {
+assert(Context);
+  }

 private:
   Kind K;
+  const ASTContext 
 };

 class FixableGadget : public Gadget {
 public:
-  FixableGadget(Kind K) : Gadget(K) {}
+  FixableGadget(Kind K, const MatchResult ) : Gadget(K, Result) {}
 };

 class PointerAssignmentGadget {
   PointerAssignmentGadget(const MatchResult )
-  : FixableGadget(Kind::PointerAssignment),
+  : FixableGadget(Kind::PointerAssignment, Result),
 PtrLHS(Result.Nodes.getNodeAs(PointerAssignLHSTag)),
 PtrRHS(Result.Nodes.getNodeAs(PointerAssignRHSTag)) {}
 };
```
(the change in individual gadget classes is really tiny!)



Comment at: clang/lib/Analysis/UnsafeBufferUsage.cpp:2688-2714
   // Remove a `FixableGadget` if the associated variable is not in the graph
   // computed above.  We do not want to generate fix-its for such variables,
   // since they are neither warned nor reachable from a warned one.
   //
   // Note a variable is not warned if it is not directly used in any unsafe
   // operation. A variable `v` is NOT reachable from an unsafe variable, if it
   // does not exist another variable `u` such that `u` is warned and fixing `u`

This entire loop can probably go away as soon as we stop relying on 
`FixablesForAllVars` and treat groups separately.

Then we can probably even have different Strategy objects for different groups, 
so `getNaiveStrategy()` could also be invoked per-group?



Comment at: clang/lib/Analysis/UnsafeBufferUsage.cpp:2726
 FixItsForVariableGroup =
 getFixIts(FixablesForAllVars, NaiveStrategy, D->getASTContext(), D,
   Tracker, Handler, VarGrpMgr);

I guess the next step is to call this function separately for each group?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157441

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


[PATCH] D153059: [-Wunsafe-buffer-usage] Group parameter fix-its

2023-08-08 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

Ok I think this looks great and almost good to go. I love how the core change 
in the grouping algorithm is actually tiny and simple!




Comment at: clang/lib/Analysis/UnsafeBufferUsage.cpp:1891-1892
+  for (unsigned i = 0; i < NumParms; i++) {
+if (!ParmsMask[i])
+  continue;
+

ziqingluo-90 wrote:
> NoQ wrote:
> > Speaking of [[ https://reviews.llvm.org/D156762#inline-1517322 |my comment 
> > on the other patch]].
> > 
> > Can we simply ask `Strategy` about the strategy for `FD->getParamDecl(i)` 
> > instead of passing a mask?
> > 
> > Eventually we'll have to do that anyway, given how different parameters can 
> > be assigned different strategies.
> Yes.  I think using `Strategy` is the correct way to do it.  
> 
> Can I make it a follow-up patch?  I noticed that this line needs to be fixed:
> ```
>   Strategy NaiveStrategy = getNaiveStrategy(UnsafeVars);
> ```
> The `UnsafeVars` is the set of variables associated to all matched 
> `FixableGadget`s.  There can be variables that is safe and do not need fix.  
> Their strategy is set to `std::span` currently which is not correct.  With 
> this line being fixed, we can have examples like
> ```
> void f(int * p) {
>   int * q;
>q = p;
>p[5] = 5;
> }
> ```
> where `q`'s strategy is `WONTFIX` and `p`'s strategy is `std::span`.  The 
> expression `q = p` can be fixed to `q = p.data()`.  It  currently has an 
> empty fix-it, which is incorrect.
Yes sure!



Comment at: clang/lib/Analysis/UnsafeBufferUsage.cpp:2364-2366
+if (!VarGrpMap.count(Var))
+  return std::nullopt;
+return Groups[VarGrpMap.at(Var)];

The usual idiom to avoid double lookup: use `find()` to extract an iterator, 
compare it to `end()` to see if the item was found, and if it was then 
dereference the iterator.

I wouldn't use `at()` given that the whole point of `.at()` is to throw 
exceptions, while LLVM is compiled with `-fno-exceptions`.



Comment at: clang/lib/Sema/AnalysisBasedWarnings.cpp:2281
   FD << listVariableGroupAsString(Variable, VarGroupForVD)
- << (VarGroupForVD.size() > 1);
+ << (VarGroupForVD.size() > 1) << ND->getNameAsString();
   for (const auto  : Fixes) {

IIRC we're supposed to stuff `ND` directly into the stream and it'll figure out 
on its own how to name it, or how to put quotes around it. See how there's no 
quotes around `%2`!


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

https://reviews.llvm.org/D153059

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


[PATCH] D157066: [clang][modules][deps] Create more efficient API for visitation of `ModuleFile` inputs

2023-08-08 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai accepted this revision.
vsapsai added a comment.

The existing `FilenameAsRequested` usage looks good to me. Unfortunately, don't 
know how to make sure all places where `FilenameAsRequested` is required 
instead of `Filename` are updated.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157066

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


[clang] 201c105 - [NFC] [C++20] [Modules] Adopt a test case from MSVC

2023-08-08 Thread Chuanqi Xu via cfe-commits

Author: Chuanqi Xu
Date: 2023-08-09T11:14:43+08:00
New Revision: 201c10537a3c1ad4a86b840834c204575d10d589

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

LOG: [NFC] [C++20] [Modules] Adopt a test case from MSVC

Add a test case from MSVC
(https://developercommunity.visualstudio.com/t/c20-modules-unresolved-external-symbol/10049210)
to cover more tests.

Added: 

clang/test/Modules/seperated-member-function-definition-for-template-class.cppm

Modified: 


Removed: 




diff  --git 
a/clang/test/Modules/seperated-member-function-definition-for-template-class.cppm
 
b/clang/test/Modules/seperated-member-function-definition-for-template-class.cppm
new file mode 100644
index 00..e32da39d9df1af
--- /dev/null
+++ 
b/clang/test/Modules/seperated-member-function-definition-for-template-class.cppm
@@ -0,0 +1,52 @@
+// This comes from the issue report of MSVC
+// 
(https://developercommunity.visualstudio.com/t/c20-modules-unresolved-external-symbol/10049210).
+//
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: split-file %s %t
+//
+// RUN: %clang_cc1 -std=c++20 %t/base.cppm -emit-module-interface -o 
%t/package-base.pcm
+// RUN: %clang_cc1 -std=c++20 %t/child.cppm -emit-module-interface -o 
%t/package-child.pcm \
+// RUN: -fprebuilt-module-path=%t
+// RUN: %clang_cc1 -std=c++20 %t/package.cppm -emit-module-interface -o 
%t/package.pcm \
+// RUN: -fprebuilt-module-path=%t
+// RUN: %clang_cc1 -std=c++20 %t/use.cpp -fsyntax-only -verify 
-fprebuilt-module-path=%t
+
+//--- base.cppm
+export module package:base;
+
+export struct child;
+
+export
+template struct base
+{
+   child getChild();
+};
+
+
+//--- child.cppm
+export module package:child;
+
+import :base;
+
+export struct child : base {};
+
+template
+child base::getChild() { return {}; }
+
+//--- package.cppm
+export module package;
+
+export import :base;
+export import :child;
+
+//--- use.cpp
+// expected-no-diagnostics
+import package;
+
+int use()
+{
+   base{}.getChild();
+   base{}.getChild();
+   return 0;
+}



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


[PATCH] D157429: [NFC] [Clang] Fix static analyzer concern

2023-08-08 Thread Elizabeth Andrews via Phabricator via cfe-commits
eandrews created this revision.
eandrews added reviewers: aaron.ballman, tahonermann.
Herald added subscribers: manas, ASDenysPetrov, dkrupp, donat.nagy, Szelethus, 
a.sidorin, baloghadamsoftware.
Herald added a reviewer: NoQ.
Herald added a project: All.
eandrews requested review of this revision.

Fix static analyzer concern about potential null value dereference. 
findBackingIvar() dereferences Prop. PR checks that Prop exists before calling 
the function.


https://reviews.llvm.org/D157429

Files:
  clang/lib/Analysis/BodyFarm.cpp


Index: clang/lib/Analysis/BodyFarm.cpp
===
--- clang/lib/Analysis/BodyFarm.cpp
+++ clang/lib/Analysis/BodyFarm.cpp
@@ -806,7 +806,7 @@
 
   if (!IVar) {
 Prop = MD->findPropertyDecl();
-IVar = findBackingIvar(Prop);
+IVar = Prop? findBackingIvar(Prop) : nullptr;
   }
 
   if (!IVar || !Prop)


Index: clang/lib/Analysis/BodyFarm.cpp
===
--- clang/lib/Analysis/BodyFarm.cpp
+++ clang/lib/Analysis/BodyFarm.cpp
@@ -806,7 +806,7 @@
 
   if (!IVar) {
 Prop = MD->findPropertyDecl();
-IVar = findBackingIvar(Prop);
+IVar = Prop? findBackingIvar(Prop) : nullptr;
   }
 
   if (!IVar || !Prop)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D157428: [clang-tidy] `readability-implicit-bool-conversion.AllowIntegerConditions` ignores `DoStmt`s

2023-08-08 Thread Fabian Wolff via Phabricator via cfe-commits
fwolff created this revision.
fwolff added reviewers: PiotrZSL, aaron.ballman.
fwolff added a project: clang-tools-extra.
Herald added subscribers: carlosgalvezp, xazax.hun.
Herald added a reviewer: njames93.
Herald added a project: All.
fwolff requested review of this revision.
Herald added a subscriber: cfe-commits.

Fixes a simple oversight which currently causes the `AllowIntegerConditions` 
option of the `readability-implicit-bool-conversion` check to not apply to 
do-while loop conditions, for no apparent reason.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D157428

Files:
  clang-tools-extra/clang-tidy/readability/ImplicitBoolConversionCheck.cpp
  
clang-tools-extra/test/clang-tidy/checkers/readability/implicit-bool-conversion-allow-in-conditions.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/readability/implicit-bool-conversion-allow-in-conditions.cpp
===
--- 
clang-tools-extra/test/clang-tidy/checkers/readability/implicit-bool-conversion-allow-in-conditions.cpp
+++ 
clang-tools-extra/test/clang-tidy/checkers/readability/implicit-bool-conversion-allow-in-conditions.cpp
@@ -38,6 +38,9 @@
   while (functionReturningInt()) {}
   while (functionReturningPointer()) {}
   while (functionReturningInt() && !functionReturningPointer() || 
(!functionReturningInt() && functionReturningPointer())) {}
+  do {} while (functionReturningInt());
+  do {} while (functionReturningPointer());
+  do {} while (functionReturningInt() && !functionReturningPointer() || 
(!functionReturningInt() && functionReturningPointer()));
   int value1 = functionReturningInt() ? 1 : 2;
   int value2 = !functionReturningInt() ? 1 : 2;
   int value3 = (functionReturningInt() && functionReturningPointer() || 
!functionReturningInt()) ? 1 : 2;
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
@@ -228,7 +228,8 @@
   if (!S)
 return false;
   if (isa(S) || isa(S) || isa(S) ||
-  isa(S) || isa(S))
+  isa(S) || isa(S) ||
+  isa(S))
 return true;
   if (isa(S) || isa(S) ||
   isUnaryLogicalNotOperator(S) ||


Index: clang-tools-extra/test/clang-tidy/checkers/readability/implicit-bool-conversion-allow-in-conditions.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability/implicit-bool-conversion-allow-in-conditions.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability/implicit-bool-conversion-allow-in-conditions.cpp
@@ -38,6 +38,9 @@
   while (functionReturningInt()) {}
   while (functionReturningPointer()) {}
   while (functionReturningInt() && !functionReturningPointer() || (!functionReturningInt() && functionReturningPointer())) {}
+  do {} while (functionReturningInt());
+  do {} while (functionReturningPointer());
+  do {} while (functionReturningInt() && !functionReturningPointer() || (!functionReturningInt() && functionReturningPointer()));
   int value1 = functionReturningInt() ? 1 : 2;
   int value2 = !functionReturningInt() ? 1 : 2;
   int value3 = (functionReturningInt() && functionReturningPointer() || !functionReturningInt()) ? 1 : 2;
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
@@ -228,7 +228,8 @@
   if (!S)
 return false;
   if (isa(S) || isa(S) || isa(S) ||
-  isa(S) || isa(S))
+  isa(S) || isa(S) ||
+  isa(S))
 return true;
   if (isa(S) || isa(S) ||
   isUnaryLogicalNotOperator(S) ||
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] df5137e - [HLSL] add pow library function

2023-08-08 Thread Joshua Batista via cfe-commits

Author: Joshua Batista
Date: 2023-08-08T13:07:36-07:00
New Revision: df5137e984a607248cd31ed67aa3822e8ac2a083

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

LOG: [HLSL] add pow library function

This change exposes the pow library function for HLSL, only available for 
floating point types.
The pow function is supported for all scalar, vector, and matrix types that 
contain floating point types.

The full documentation of the HLSL pow function is available here:
https://learn.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-pow

Reviewed By: bogner

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

Added: 
clang/test/CodeGenHLSL/builtins/pow.hlsl

Modified: 
clang/lib/Headers/hlsl/hlsl_intrinsics.h

Removed: 




diff  --git a/clang/lib/Headers/hlsl/hlsl_intrinsics.h 
b/clang/lib/Headers/hlsl/hlsl_intrinsics.h
index 6f1aa5f26294ef..22d9ec24e6a210 100644
--- a/clang/lib/Headers/hlsl/hlsl_intrinsics.h
+++ b/clang/lib/Headers/hlsl/hlsl_intrinsics.h
@@ -532,5 +532,36 @@ 
__attribute__((clang_builtin_alias(__builtin_elementwise_bitreverse)))
 uint64_t3 reversebits(uint64_t3);
 __attribute__((clang_builtin_alias(__builtin_elementwise_bitreverse)))
 uint64_t4 reversebits(uint64_t4);
+
+// pow builtins
+#ifdef __HLSL_ENABLE_16_BIT
+__attribute__((clang_builtin_alias(__builtin_elementwise_pow)))
+half pow(half, half);
+__attribute__((clang_builtin_alias(__builtin_elementwise_pow)))
+half2 pow(half2, half2);
+__attribute__((clang_builtin_alias(__builtin_elementwise_pow)))
+half3 pow(half3, half3);
+__attribute__((clang_builtin_alias(__builtin_elementwise_pow)))
+half4 pow(half4, half4);
+#endif
+
+__attribute__((clang_builtin_alias(__builtin_elementwise_pow))) float
+pow(float, float);
+__attribute__((clang_builtin_alias(__builtin_elementwise_pow)))
+float2 pow(float2, float2);
+__attribute__((clang_builtin_alias(__builtin_elementwise_pow)))
+float3 pow(float3, float3);
+__attribute__((clang_builtin_alias(__builtin_elementwise_pow)))
+float4 pow(float4, float4);
+
+__attribute__((clang_builtin_alias(__builtin_elementwise_pow))) double
+pow(double, double);
+__attribute__((clang_builtin_alias(__builtin_elementwise_pow)))
+double2 pow(double2, double2);
+__attribute__((clang_builtin_alias(__builtin_elementwise_pow)))
+double3 pow(double3, double3);
+__attribute__((clang_builtin_alias(__builtin_elementwise_pow)))
+double4 pow(double4, double4);
+
 } // namespace hlsl
 #endif //_HLSL_HLSL_INTRINSICS_H_

diff  --git a/clang/test/CodeGenHLSL/builtins/pow.hlsl 
b/clang/test/CodeGenHLSL/builtins/pow.hlsl
new file mode 100644
index 00..bb186f75d86ac3
--- /dev/null
+++ b/clang/test/CodeGenHLSL/builtins/pow.hlsl
@@ -0,0 +1,89 @@
+// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \
+// RUN:   dxil-pc-shadermodel6.3-library %s -fnative-half-type \
+// RUN:   -emit-llvm -disable-llvm-passes -O3 -o - | FileCheck %s
+// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \
+// RUN:   dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \
+// RUN:   -D__HLSL_ENABLE_16_BIT -o - | FileCheck %s --check-prefix=NO_HALF
+
+// CHECK: define noundef half @
+// CHECK: call half @llvm.pow.f16(
+// NO_HALF: define noundef float @"?test_pow_half@@YA$halff@$halff@0@Z"(
+// NO_HALF: call float @llvm.pow.f32(
+half test_pow_half(half p0, half p1)
+{
+return pow(p0, p1);
+}
+// CHECK: define noundef <2 x half> 
@"?test_pow_half2@@YAT?$__vector@$f16@$01@__clang@@T12@0@Z"(
+// CHECK: call <2 x half> @llvm.pow.v2f16
+// NO_HALF: define noundef <2 x float> 
@"?test_pow_float2@@YAT?$__vector@M$01@__clang@@T12@0@Z"(
+// NO_HALF: call <2 x float> @llvm.pow.v2f32(
+half2 test_pow_half2(half2 p0, half2 p1)
+{
+return pow(p0, p1);
+}
+// CHECK: define noundef <3 x half> 
@"?test_pow_half3@@YAT?$__vector@$f16@$02@__clang@@T12@0@Z"(
+// CHECK: call <3 x half> @llvm.pow.v3f16
+// NO_HALF: define noundef <3 x float> 
@"?test_pow_float3@@YAT?$__vector@M$02@__clang@@T12@0@Z"(
+// NO_HALF: call <3 x float> @llvm.pow.v3f32(
+half3 test_pow_half3(half3 p0, half3 p1)
+{
+return pow(p0, p1);
+}
+// CHECK: define noundef <4 x half> 
@"?test_pow_half4@@YAT?$__vector@$f16@$03@__clang@@T12@0@Z"(
+// CHECK: call <4 x half> @llvm.pow.v4f16
+// NO_HALF: define noundef <4 x float> 
@"?test_pow_float4@@YAT?$__vector@M$03@__clang@@T12@0@Z"(
+// NO_HALF: call <4 x float> @llvm.pow.v4f32(
+half4 test_pow_half4(half4 p0, half4 p1)
+{
+return pow(p0, p1);
+}
+
+// CHECK: define noundef float @"?test_pow_float@@YAMMM@Z"(
+// CHECK: call float @llvm.pow.f32(
+float test_pow_float(float p0, float p1)
+{
+return pow(p0, p1);
+}
+// CHECK: define noundef <2 x float> 
@"?test_pow_float2@@YAT?$__vector@M$01@__clang@@T12@0@Z"(
+// CHECK: call <2 x 

[PATCH] D156178: [HLSL] add pow library function

2023-08-08 Thread Joshua Batista 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 rGdf5137e984a6: [HLSL] add pow library function (authored by 
bob80905).

Changed prior to commit:
  https://reviews.llvm.org/D156178?vs=548296=548322#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156178

Files:
  clang/lib/Headers/hlsl/hlsl_intrinsics.h
  clang/test/CodeGenHLSL/builtins/pow.hlsl

Index: clang/test/CodeGenHLSL/builtins/pow.hlsl
===
--- /dev/null
+++ clang/test/CodeGenHLSL/builtins/pow.hlsl
@@ -0,0 +1,89 @@
+// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \
+// RUN:   dxil-pc-shadermodel6.3-library %s -fnative-half-type \
+// RUN:   -emit-llvm -disable-llvm-passes -O3 -o - | FileCheck %s
+// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \
+// RUN:   dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \
+// RUN:   -D__HLSL_ENABLE_16_BIT -o - | FileCheck %s --check-prefix=NO_HALF
+
+// CHECK: define noundef half @
+// CHECK: call half @llvm.pow.f16(
+// NO_HALF: define noundef float @"?test_pow_half@@YA$halff@$halff@0@Z"(
+// NO_HALF: call float @llvm.pow.f32(
+half test_pow_half(half p0, half p1)
+{
+return pow(p0, p1);
+}
+// CHECK: define noundef <2 x half> @"?test_pow_half2@@YAT?$__vector@$f16@$01@__clang@@T12@0@Z"(
+// CHECK: call <2 x half> @llvm.pow.v2f16
+// NO_HALF: define noundef <2 x float> @"?test_pow_float2@@YAT?$__vector@M$01@__clang@@T12@0@Z"(
+// NO_HALF: call <2 x float> @llvm.pow.v2f32(
+half2 test_pow_half2(half2 p0, half2 p1)
+{
+return pow(p0, p1);
+}
+// CHECK: define noundef <3 x half> @"?test_pow_half3@@YAT?$__vector@$f16@$02@__clang@@T12@0@Z"(
+// CHECK: call <3 x half> @llvm.pow.v3f16
+// NO_HALF: define noundef <3 x float> @"?test_pow_float3@@YAT?$__vector@M$02@__clang@@T12@0@Z"(
+// NO_HALF: call <3 x float> @llvm.pow.v3f32(
+half3 test_pow_half3(half3 p0, half3 p1)
+{
+return pow(p0, p1);
+}
+// CHECK: define noundef <4 x half> @"?test_pow_half4@@YAT?$__vector@$f16@$03@__clang@@T12@0@Z"(
+// CHECK: call <4 x half> @llvm.pow.v4f16
+// NO_HALF: define noundef <4 x float> @"?test_pow_float4@@YAT?$__vector@M$03@__clang@@T12@0@Z"(
+// NO_HALF: call <4 x float> @llvm.pow.v4f32(
+half4 test_pow_half4(half4 p0, half4 p1)
+{
+return pow(p0, p1);
+}
+
+// CHECK: define noundef float @"?test_pow_float@@YAMMM@Z"(
+// CHECK: call float @llvm.pow.f32(
+float test_pow_float(float p0, float p1)
+{
+return pow(p0, p1);
+}
+// CHECK: define noundef <2 x float> @"?test_pow_float2@@YAT?$__vector@M$01@__clang@@T12@0@Z"(
+// CHECK: call <2 x float> @llvm.pow.v2f32
+float2 test_pow_float2(float2 p0, float2 p1)
+{
+return pow(p0, p1);
+}
+// CHECK: define noundef <3 x float> @"?test_pow_float3@@YAT?$__vector@M$02@__clang@@T12@0@Z"(
+// CHECK: call <3 x float> @llvm.pow.v3f32
+float3 test_pow_float3(float3 p0, float3 p1)
+{
+return pow(p0, p1);
+}
+// CHECK: define noundef <4 x float> @"?test_pow_float4@@YAT?$__vector@M$03@__clang@@T12@0@Z"(
+// CHECK: call <4 x float> @llvm.pow.v4f32
+float4 test_pow_float4(float4 p0, float4 p1)
+{
+return pow(p0, p1);
+}
+
+// CHECK: define noundef double @"?test_pow_double@@YANNN@Z"(
+// CHECK: call double @llvm.pow.f64(
+double test_pow_double(double p0, double p1)
+{
+return pow(p0, p1);
+}
+// CHECK: define noundef <2 x double> @"?test_pow_double2@@YAT?$__vector@N$01@__clang@@T12@0@Z"(
+// CHECK: call <2 x double> @llvm.pow.v2f64
+double2 test_pow_double2(double2 p0, double2 p1)
+{
+return pow(p0, p1);
+}
+// CHECK: define noundef <3 x double> @"?test_pow_double3@@YAT?$__vector@N$02@__clang@@T12@0@Z"(
+// CHECK: call <3 x double> @llvm.pow.v3f64
+double3 test_pow_double3(double3 p0, double3 p1)
+{
+return pow(p0, p1);
+}
+// CHECK: define noundef <4 x double> @"?test_pow_double4@@YAT?$__vector@N$03@__clang@@T12@0@Z"(
+// CHECK: call <4 x double> @llvm.pow.v4f64
+double4 test_pow_double4(double4 p0, double4 p1)
+{
+return pow(p0, p1);
+}
Index: clang/lib/Headers/hlsl/hlsl_intrinsics.h
===
--- clang/lib/Headers/hlsl/hlsl_intrinsics.h
+++ clang/lib/Headers/hlsl/hlsl_intrinsics.h
@@ -532,5 +532,36 @@
 uint64_t3 reversebits(uint64_t3);
 __attribute__((clang_builtin_alias(__builtin_elementwise_bitreverse)))
 uint64_t4 reversebits(uint64_t4);
+
+// pow builtins
+#ifdef __HLSL_ENABLE_16_BIT
+__attribute__((clang_builtin_alias(__builtin_elementwise_pow)))
+half pow(half, half);
+__attribute__((clang_builtin_alias(__builtin_elementwise_pow)))
+half2 pow(half2, half2);
+__attribute__((clang_builtin_alias(__builtin_elementwise_pow)))
+half3 pow(half3, half3);
+__attribute__((clang_builtin_alias(__builtin_elementwise_pow)))
+half4 pow(half4, half4);
+#endif
+

[PATCH] D157436: [clang-tidy] `performance-faster-string-find` generates incorrect fixes for single quote character literals

2023-08-08 Thread Fabian Wolff via Phabricator via cfe-commits
fwolff created this revision.
fwolff added reviewers: PiotrZSL, carlosgalvezp.
fwolff added a project: clang-tools-extra.
Herald added a subscriber: xazax.hun.
Herald added a reviewer: njames93.
Herald added a project: All.
fwolff requested review of this revision.
Herald added a subscriber: cfe-commits.

`"'"` is turned into `'''` but should be turned into `'\''`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D157436

Files:
  clang-tools-extra/clang-tidy/performance/FasterStringFindCheck.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/test/clang-tidy/checkers/performance/faster-string-find.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/performance/faster-string-find.cpp
===
--- 
clang-tools-extra/test/clang-tidy/checkers/performance/faster-string-find.cpp
+++ 
clang-tools-extra/test/clang-tidy/checkers/performance/faster-string-find.cpp
@@ -56,13 +56,21 @@
   // CHECK-MESSAGES: [[@LINE-1]]:12: warning: 'find' called with a string 
literal
   // CHECK-FIXES: Str.find('a', 1);
 
-  // Doens't work with strings smaller or larger than 1 char.
+  // Doesn't work with strings smaller or larger than 1 char.
   Str.find("");
   Str.find("ab");
 
   // Doesn't do anything with the 3 argument overload.
   Str.find("a", 1, 1);
 
+  // Single quotes are escaped properly
+  Str.find("'");
+  // CHECK-MESSAGES: [[@LINE-1]]:12: warning: 'find' called with a string 
literal
+  // CHECK-FIXES: Str.find('\'');
+  Str.find("\'");
+  // CHECK-MESSAGES: [[@LINE-1]]:12: warning: 'find' called with a string 
literal
+  // CHECK-FIXES: Str.find('\'');
+
   // Other methods that can also be replaced
   Str.rfind("a");
   // CHECK-MESSAGES: [[@LINE-1]]:13: warning: 'rfind' called with a string 
literal
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -196,6 +196,10 @@
   ` check to emit proper
   warnings when a type forward declaration precedes its definition.
 
+- Fixed a bug in :doc:`performance-faster-string-find
+  ` which generated incorrect fixes by not
+  escaping single quotes properly.
+
 Removed checks
 ^^
 
Index: clang-tools-extra/clang-tidy/performance/FasterStringFindCheck.cpp
===
--- clang-tools-extra/clang-tidy/performance/FasterStringFindCheck.cpp
+++ clang-tools-extra/clang-tidy/performance/FasterStringFindCheck.cpp
@@ -26,14 +26,20 @@
 Literal->outputString(OS);
   }
   // Now replace the " with '.
-  auto Pos = Result.find_first_of('"');
-  if (Pos == Result.npos)
+  auto OpenPos = Result.find_first_of('"');
+  if (OpenPos == Result.npos)
 return std::nullopt;
-  Result[Pos] = '\'';
-  Pos = Result.find_last_of('"');
-  if (Pos == Result.npos)
+  Result[OpenPos] = '\'';
+
+  auto ClosePos = Result.find_last_of('"');
+  if (ClosePos == Result.npos)
 return std::nullopt;
-  Result[Pos] = '\'';
+  Result[ClosePos] = '\'';
+
+  // "'" is OK, but ''' is not, so add a backslash
+  if (ClosePos - OpenPos == 2 && Result[OpenPos + 1] == '\'')
+Result.replace(OpenPos + 1, 1, "\\'");
+
   return Result;
 }
 


Index: clang-tools-extra/test/clang-tidy/checkers/performance/faster-string-find.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/performance/faster-string-find.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/performance/faster-string-find.cpp
@@ -56,13 +56,21 @@
   // CHECK-MESSAGES: [[@LINE-1]]:12: warning: 'find' called with a string literal
   // CHECK-FIXES: Str.find('a', 1);
 
-  // Doens't work with strings smaller or larger than 1 char.
+  // Doesn't work with strings smaller or larger than 1 char.
   Str.find("");
   Str.find("ab");
 
   // Doesn't do anything with the 3 argument overload.
   Str.find("a", 1, 1);
 
+  // Single quotes are escaped properly
+  Str.find("'");
+  // CHECK-MESSAGES: [[@LINE-1]]:12: warning: 'find' called with a string literal
+  // CHECK-FIXES: Str.find('\'');
+  Str.find("\'");
+  // CHECK-MESSAGES: [[@LINE-1]]:12: warning: 'find' called with a string literal
+  // CHECK-FIXES: Str.find('\'');
+
   // Other methods that can also be replaced
   Str.rfind("a");
   // CHECK-MESSAGES: [[@LINE-1]]:13: warning: 'rfind' called with a string literal
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -196,6 +196,10 @@
   ` check to emit proper
   warnings when a type forward declaration precedes its definition.
 
+- Fixed a bug in :doc:`performance-faster-string-find
+  ` which generated incorrect fixes by not
+  escaping single quotes properly.
+
 Removed checks
 ^^
 
Index: 

[PATCH] D157438: [OpenMP] Ensure wrapper headers are included on both host and device

2023-08-08 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 created this revision.
jhuber6 added reviewers: jdoerfert, tianshilei1992, tra, JonChesterfield, 
yaxunl, sivachandra.
Herald added a subscriber: guansong.
Herald added a project: All.
jhuber6 requested review of this revision.
Herald added subscribers: cfe-commits, jplehr, sstefan1, MaskRay.
Herald added a project: clang.

For the in-progress GPU `libc` project we are relying on overlay headers to
handle the interfacing between the `libc` project and the host `libc`.
We need this to be included on both the host and device so they agree
one what is present on the device, otherwise we will end up with random
errors. For whatever reason this was not being included on the host
although it previously worked. This patch ensures that it's included on
both.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D157438

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/gpu-libc-headers.c


Index: clang/test/Driver/gpu-libc-headers.c
===
--- clang/test/Driver/gpu-libc-headers.c
+++ clang/test/Driver/gpu-libc-headers.c
@@ -8,6 +8,7 @@
 // RUN: -fopenmp-targets=nvptx64-nvidia-cuda 
-Xopenmp-target=nvptx64-nvidia-cuda --offload-arch=sm_70  \
 // RUN: -nogpulib %s 2>&1 | FileCheck %s --check-prefix=CHECK-HEADERS
 // CHECK-HEADERS: "-cc1"{{.*}}"-internal-isystem" 
"{{.*}}include{{.*}}llvm_libc_wrappers"{{.*}}"-isysroot" "./"
+// CHECK-HEADERS: "-cc1"{{.*}}"-internal-isystem" 
"{{.*}}include{{.*}}llvm_libc_wrappers"{{.*}}"-isysroot" "./"
 
 // RUN:   %clang -### --target=amdgcn-amd-amdhsa -mcpu=gfx1030 -nogpulib \
 // RUN: -nogpuinc %s 2>&1 | FileCheck %s 
--check-prefix=CHECK-HEADERS-DISABLED
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -1183,14 +1183,13 @@
   // with ones created by the 'libc' project if present.
   if (!Args.hasArg(options::OPT_nostdinc) &&
   !Args.hasArg(options::OPT_nogpuinc) &&
-  !Args.hasArg(options::OPT_nobuiltininc) &&
-  (getToolChain().getTriple().isNVPTX() ||
-   getToolChain().getTriple().isAMDGCN())) {
-
+  !Args.hasArg(options::OPT_nobuiltininc)) {
 // Without an offloading language we will include these headers directly.
 // Offloading languages will instead only use the declarations stored in
 // the resource directory at clang/lib/Headers/llvm_libc_wrappers.
-if (C.getActiveOffloadKinds() == Action::OFK_None) {
+if ((getToolChain().getTriple().isNVPTX() ||
+ getToolChain().getTriple().isAMDGCN()) &&
+C.getActiveOffloadKinds() == Action::OFK_None) {
   SmallString<128> P(llvm::sys::path::parent_path(D.InstalledDir));
   llvm::sys::path::append(P, "include");
   llvm::sys::path::append(P, "gpu-none-llvm");


Index: clang/test/Driver/gpu-libc-headers.c
===
--- clang/test/Driver/gpu-libc-headers.c
+++ clang/test/Driver/gpu-libc-headers.c
@@ -8,6 +8,7 @@
 // RUN: -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target=nvptx64-nvidia-cuda --offload-arch=sm_70  \
 // RUN: -nogpulib %s 2>&1 | FileCheck %s --check-prefix=CHECK-HEADERS
 // CHECK-HEADERS: "-cc1"{{.*}}"-internal-isystem" "{{.*}}include{{.*}}llvm_libc_wrappers"{{.*}}"-isysroot" "./"
+// CHECK-HEADERS: "-cc1"{{.*}}"-internal-isystem" "{{.*}}include{{.*}}llvm_libc_wrappers"{{.*}}"-isysroot" "./"
 
 // RUN:   %clang -### --target=amdgcn-amd-amdhsa -mcpu=gfx1030 -nogpulib \
 // RUN: -nogpuinc %s 2>&1 | FileCheck %s --check-prefix=CHECK-HEADERS-DISABLED
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -1183,14 +1183,13 @@
   // with ones created by the 'libc' project if present.
   if (!Args.hasArg(options::OPT_nostdinc) &&
   !Args.hasArg(options::OPT_nogpuinc) &&
-  !Args.hasArg(options::OPT_nobuiltininc) &&
-  (getToolChain().getTriple().isNVPTX() ||
-   getToolChain().getTriple().isAMDGCN())) {
-
+  !Args.hasArg(options::OPT_nobuiltininc)) {
 // Without an offloading language we will include these headers directly.
 // Offloading languages will instead only use the declarations stored in
 // the resource directory at clang/lib/Headers/llvm_libc_wrappers.
-if (C.getActiveOffloadKinds() == Action::OFK_None) {
+if ((getToolChain().getTriple().isNVPTX() ||
+ getToolChain().getTriple().isAMDGCN()) &&
+C.getActiveOffloadKinds() == Action::OFK_None) {
   SmallString<128> P(llvm::sys::path::parent_path(D.InstalledDir));
   llvm::sys::path::append(P, "include");
   llvm::sys::path::append(P, "gpu-none-llvm");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org

[PATCH] D157040: [OpenMP][IR] Set correct alignment for internal variables

2023-08-08 Thread Hao Jin via Phabricator via cfe-commits
erjin updated this revision to Diff 548344.
erjin added a comment.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

se


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157040

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
  llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp


Index: llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
===
--- llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
+++ llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
@@ -2744,7 +2744,15 @@
   PointerType *CriticalNamePtrTy =
   PointerType::getUnqual(ArrayType::get(Type::getInt32Ty(Ctx), 8));
   EXPECT_EQ(CriticalEndCI->getArgOperand(2), 
CriticalEntryCI->getArgOperand(2));
-  EXPECT_EQ(CriticalEndCI->getArgOperand(2)->getType(), CriticalNamePtrTy);
+  GlobalVariable *GV =
+  dyn_cast(CriticalEndCI->getArgOperand(2));
+  ASSERT_NE(GV, nullptr);
+  EXPECT_EQ(GV->getType(), CriticalNamePtrTy);
+  const DataLayout  = M->getDataLayout();
+  const llvm::Align TypeAlign = DL.getABITypeAlign(CriticalNamePtrTy);
+  const llvm::Align PtrAlign = 
DL.getPointerABIAlignment(GV->getAddressSpace());
+  if (const llvm::MaybeAlign Alignment = GV->getAlign())
+EXPECT_EQ(*Alignment, std::max(TypeAlign, PtrAlign));
 }
 
 TEST_F(OpenMPIRBuilderTest, OrderedDirectiveDependSource) {
Index: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
===
--- llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -4493,7 +4493,10 @@
 M, Ty, /*IsConstant=*/false, GlobalValue::CommonLinkage,
 Constant::getNullValue(Ty), Elem.first(),
 /*InsertBefore=*/nullptr, GlobalValue::NotThreadLocal, AddressSpace);
-GV->setAlignment(M.getDataLayout().getABITypeAlign(Ty));
+const DataLayout  = M.getDataLayout();
+const llvm::Align TypeAlign = DL.getABITypeAlign(Ty);
+const llvm::Align PtrAlign = DL.getPointerABIAlignment(AddressSpace);
+GV->setAlignment(std::max(TypeAlign, PtrAlign));
 Elem.second = GV;
   }
 
Index: clang/lib/CodeGen/CGOpenMPRuntime.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -2161,11 +2161,7 @@
 llvm::Value *CGOpenMPRuntime::getCriticalRegionLock(StringRef CriticalName) {
   std::string Prefix = Twine("gomp_critical_user_", CriticalName).str();
   std::string Name = getName({Prefix, "var"});
-  llvm::GlobalVariable *G = 
OMPBuilder.getOrCreateInternalVariable(KmpCriticalNameTy, Name);
-  llvm::Align PtrAlign = 
OMPBuilder.M.getDataLayout().getPointerABIAlignment(G->getAddressSpace());
-  if (PtrAlign > llvm::Align(G->getAlignment()))
-G->setAlignment(PtrAlign);
-  return G;
+  return OMPBuilder.getOrCreateInternalVariable(KmpCriticalNameTy, Name);
 }
 
 namespace {


Index: llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
===
--- llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
+++ llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
@@ -2744,7 +2744,15 @@
   PointerType *CriticalNamePtrTy =
   PointerType::getUnqual(ArrayType::get(Type::getInt32Ty(Ctx), 8));
   EXPECT_EQ(CriticalEndCI->getArgOperand(2), CriticalEntryCI->getArgOperand(2));
-  EXPECT_EQ(CriticalEndCI->getArgOperand(2)->getType(), CriticalNamePtrTy);
+  GlobalVariable *GV =
+  dyn_cast(CriticalEndCI->getArgOperand(2));
+  ASSERT_NE(GV, nullptr);
+  EXPECT_EQ(GV->getType(), CriticalNamePtrTy);
+  const DataLayout  = M->getDataLayout();
+  const llvm::Align TypeAlign = DL.getABITypeAlign(CriticalNamePtrTy);
+  const llvm::Align PtrAlign = DL.getPointerABIAlignment(GV->getAddressSpace());
+  if (const llvm::MaybeAlign Alignment = GV->getAlign())
+EXPECT_EQ(*Alignment, std::max(TypeAlign, PtrAlign));
 }
 
 TEST_F(OpenMPIRBuilderTest, OrderedDirectiveDependSource) {
Index: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
===
--- llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -4493,7 +4493,10 @@
 M, Ty, /*IsConstant=*/false, GlobalValue::CommonLinkage,
 Constant::getNullValue(Ty), Elem.first(),
 /*InsertBefore=*/nullptr, GlobalValue::NotThreadLocal, AddressSpace);
-GV->setAlignment(M.getDataLayout().getABITypeAlign(Ty));
+const DataLayout  = M.getDataLayout();
+const llvm::Align TypeAlign = DL.getABITypeAlign(Ty);
+const llvm::Align PtrAlign = DL.getPointerABIAlignment(AddressSpace);
+GV->setAlignment(std::max(TypeAlign, PtrAlign));
 Elem.second = GV;
   }
 
Index: clang/lib/CodeGen/CGOpenMPRuntime.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ 

[PATCH] D155858: Add a concept AST node.

2023-08-08 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a subscriber: aaron.ballman.
hokein added a comment.

adding @aaron.ballman, who might have opinion on this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155858

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


[PATCH] D157428: [clang-tidy] `readability-implicit-bool-conversion.AllowIntegerConditions` ignores `DoStmt`s

2023-08-08 Thread Fabian Wolff via Phabricator via cfe-commits
fwolff marked an inline comment as done.
fwolff added a comment.

Thanks for reviewing this @PiotrZSL!

In D157428#4570497 , @PiotrZSL wrote:

> What about switchStmt ?

The `AllowIntegerConditions` and `AllowPointerConditions` options only apply to 
`int -> bool` conversions, whereas switch statements have integral conditions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157428

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


[PATCH] D154014: [SpecialCaseList] Use Globs instead of Regex

2023-08-08 Thread Ellis Hoag via Phabricator via cfe-commits
ellis updated this revision to Diff 548349.
ellis added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154014

Files:
  clang/docs/SanitizerSpecialCaseList.rst
  clang/lib/Basic/ProfileList.cpp
  clang/lib/Basic/SanitizerSpecialCaseList.cpp
  llvm/include/llvm/Support/SpecialCaseList.h
  llvm/lib/Support/SpecialCaseList.cpp
  llvm/unittests/Support/SpecialCaseListTest.cpp

Index: llvm/unittests/Support/SpecialCaseListTest.cpp
===
--- llvm/unittests/Support/SpecialCaseListTest.cpp
+++ llvm/unittests/Support/SpecialCaseListTest.cpp
@@ -10,8 +10,11 @@
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/VirtualFileSystem.h"
+#include "gmock/gmock.h"
 #include "gtest/gtest.h"
 
+using testing::HasSubstr;
+using testing::StartsWith;
 using namespace llvm;
 
 namespace {
@@ -19,24 +22,32 @@
 class SpecialCaseListTest : public ::testing::Test {
 protected:
   std::unique_ptr makeSpecialCaseList(StringRef List,
-   std::string ) {
-std::unique_ptr MB = MemoryBuffer::getMemBuffer(List);
+   std::string ,
+   bool UseGlobs = true) {
+auto S = List.str();
+if (UseGlobs)
+  S = (Twine("#!special-case-list-v2\n") + S).str();
+std::unique_ptr MB = MemoryBuffer::getMemBuffer(S);
 return SpecialCaseList::create(MB.get(), Error);
   }
 
-  std::unique_ptr makeSpecialCaseList(StringRef List) {
+  std::unique_ptr makeSpecialCaseList(StringRef List,
+   bool UseGlobs = true) {
 std::string Error;
-auto SCL = makeSpecialCaseList(List, Error);
+auto SCL = makeSpecialCaseList(List, Error, UseGlobs);
 assert(SCL);
 assert(Error == "");
 return SCL;
   }
 
-  std::string makeSpecialCaseListFile(StringRef Contents) {
+  std::string makeSpecialCaseListFile(StringRef Contents,
+  bool UseGlobs = true) {
 int FD;
 SmallString<64> Path;
 sys::fs::createTemporaryFile("SpecialCaseListTest", "temp", FD, Path);
 raw_fd_ostream OF(FD, true, true);
+if (UseGlobs)
+  OF << "#!special-case-list-v2\n";
 OF << Contents;
 OF.close();
 return std::string(Path.str());
@@ -59,10 +70,10 @@
   EXPECT_FALSE(SCL->inSection("", "fun", "hello"));
   EXPECT_FALSE(SCL->inSection("", "src", "hello", "category"));
 
-  EXPECT_EQ(3u, SCL->inSectionBlame("", "src", "hello"));
-  EXPECT_EQ(4u, SCL->inSectionBlame("", "src", "bye"));
-  EXPECT_EQ(5u, SCL->inSectionBlame("", "src", "hi", "category"));
-  EXPECT_EQ(6u, SCL->inSectionBlame("", "src", "", "category"));
+  EXPECT_EQ(4u, SCL->inSectionBlame("", "src", "hello"));
+  EXPECT_EQ(5u, SCL->inSectionBlame("", "src", "bye"));
+  EXPECT_EQ(6u, SCL->inSectionBlame("", "src", "hi", "category"));
+  EXPECT_EQ(7u, SCL->inSectionBlame("", "src", "", "category"));
   EXPECT_EQ(0u, SCL->inSectionBlame("", "src", "hi"));
   EXPECT_EQ(0u, SCL->inSectionBlame("", "fun", "hello"));
   EXPECT_EQ(0u, SCL->inSectionBlame("", "src", "hello", "category"));
@@ -74,31 +85,29 @@
  "\n"
  "[not valid\n",
  Error));
-  EXPECT_TRUE(
-  ((StringRef)Error).startswith("malformed section header on line 3:"));
+  EXPECT_THAT(Error, StartsWith("malformed section header on line 4:"));
 
   EXPECT_EQ(nullptr, makeSpecialCaseList("\n\n\n"
  "[not valid\n",
  Error));
-  EXPECT_TRUE(
-  ((StringRef)Error).startswith("malformed section header on line 4:"));
+  EXPECT_THAT(Error, StartsWith("malformed section header on line 5:"));
 }
 
-TEST_F(SpecialCaseListTest, SectionRegexErrorHandling) {
+TEST_F(SpecialCaseListTest, SectionGlobErrorHandling) {
   std::string Error;
   EXPECT_EQ(makeSpecialCaseList("[address", Error), nullptr);
-  EXPECT_TRUE(((StringRef)Error).startswith("malformed section header "));
+  EXPECT_THAT(Error, StartsWith("malformed section header "));
 
   EXPECT_EQ(makeSpecialCaseList("[[]", Error), nullptr);
-  EXPECT_TRUE(((StringRef)Error).startswith("malformed regex for section [: "));
+  EXPECT_EQ(Error, "malformed section at line 2: '[': invalid glob pattern: [");
 
   EXPECT_EQ(makeSpecialCaseList("src:=", Error), nullptr);
-  EXPECT_TRUE(((StringRef)Error).endswith("Supplied regexp was blank"));
+  EXPECT_THAT(Error, HasSubstr("Supplied glob was blank"));
 }
 
 TEST_F(SpecialCaseListTest, Section) {
   std::unique_ptr SCL = makeSpecialCaseList("src:global\n"
- "[sect1|sect2]\n"
+

[PATCH] D155824: [LoongArch] Support -march=native and -mtune=

2023-08-08 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay accepted this revision.
MaskRay added a comment.

Some test suggestions




Comment at: clang/lib/Basic/Targets/LoongArch.cpp:203
+  StringRef ArchName = getCPU();
+  Builder.defineMacro("__loongarch_arch", Twine("\"") + ArchName + 
Twine("\""));
+

Use the `Twine(char)` constructor.



Comment at: clang/test/Driver/loongarch-mtune-error.c:1
+// RUN: not %clang --target=loongarch64 -mtune=invalidcpu -fsyntax-only %s 
2>&1 | FileCheck %s
+// RUN: not %clang --target=loongarch64 -mtune=generic -fsyntax-only %s 2>&1 | 
FileCheck %s

Use `-###` to test the driver. Consider merging this test into the 
`loongarch-mtune.c`. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155824

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


[PATCH] D157029: [llvm] Construct option's prefixed name at compile-time

2023-08-08 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 updated this revision to Diff 548423.
jansvoboda11 added a comment.

Rebase, remove unnecessary changes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157029

Files:
  clang-tools-extra/clangd/CompileCommands.cpp
  clang/lib/Driver/Driver.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Tooling/Tooling.cpp
  llvm/include/llvm/Option/OptTable.h
  llvm/include/llvm/Option/Option.h
  llvm/lib/Option/OptTable.cpp
  llvm/unittests/Option/OptionMarshallingTest.cpp
  llvm/utils/TableGen/OptParserEmitter.cpp

Index: llvm/utils/TableGen/OptParserEmitter.cpp
===
--- llvm/utils/TableGen/OptParserEmitter.cpp
+++ llvm/utils/TableGen/OptParserEmitter.cpp
@@ -34,30 +34,14 @@
   return OS;
 }
 
-static std::string getOptionSpelling(const Record , size_t ) {
+static std::string getOptionPrefixedName(const Record ) {
   std::vector Prefixes = R.getValueAsListOfStrings("Prefixes");
   StringRef Name = R.getValueAsString("Name");
 
-  if (Prefixes.empty()) {
-PrefixLength = 0;
+  if (Prefixes.empty())
 return Name.str();
-  }
-
-  PrefixLength = Prefixes[0].size();
-  return (Twine(Prefixes[0]) + Twine(Name)).str();
-}
 
-static std::string getOptionSpelling(const Record ) {
-  size_t PrefixLength;
-  return getOptionSpelling(R, PrefixLength);
-}
-
-static void emitNameUsingSpelling(raw_ostream , const Record ) {
-  size_t PrefixLength;
-  OS << "llvm::StringLiteral(";
-  write_cstring(
-  OS, StringRef(getOptionSpelling(R, PrefixLength)).substr(PrefixLength));
-  OS << ")";
+  return (Prefixes[0] + Twine(Name)).str();
 }
 
 class MarshallingInfo {
@@ -105,8 +89,6 @@
   }
 
   void emit(raw_ostream ) const {
-write_cstring(OS, StringRef(getOptionSpelling(R)));
-OS << ", ";
 OS << ShouldParse;
 OS << ", ";
 OS << ShouldAlwaysEmit;
@@ -346,8 +328,8 @@
 std::vector RPrefixes = R.getValueAsListOfStrings("Prefixes");
 OS << Prefixes[PrefixKeyT(RPrefixes.begin(), RPrefixes.end())] << ", ";
 
-// The option string.
-emitNameUsingSpelling(OS, R);
+// The option prefixed name.
+write_cstring(OS, getOptionPrefixedName(R));
 
 // The option identifier name.
 OS << ", " << getOptionName(R);
Index: llvm/unittests/Option/OptionMarshallingTest.cpp
===
--- llvm/unittests/Option/OptionMarshallingTest.cpp
+++ llvm/unittests/Option/OptionMarshallingTest.cpp
@@ -10,7 +10,7 @@
 #include "gtest/gtest.h"
 
 struct OptionWithMarshallingInfo {
-  llvm::StringRef Name;
+  llvm::StringLiteral PrefixedName;
   const char *KeyPath;
   const char *ImpliedCheck;
   const char *ImpliedValue;
@@ -18,20 +18,20 @@
 
 static const OptionWithMarshallingInfo MarshallingTable[] = {
 #define OPTION_WITH_MARSHALLING(   \
-PREFIX_TYPE, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,\
-HELPTEXT, METAVAR, VALUES, SPELLING, SHOULD_PARSE, ALWAYS_EMIT, KEYPATH,   \
+PREFIX_TYPE, PREFIXED_NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS,  \
+PARAM, HELPTEXT, METAVAR, VALUES, SHOULD_PARSE, ALWAYS_EMIT, KEYPATH,  \
 DEFAULT_VALUE, IMPLIED_CHECK, IMPLIED_VALUE, NORMALIZER, DENORMALIZER, \
 MERGER, EXTRACTOR, TABLE_INDEX)\
-  {NAME, #KEYPATH, #IMPLIED_CHECK, #IMPLIED_VALUE},
+  {PREFIXED_NAME, #KEYPATH, #IMPLIED_CHECK, #IMPLIED_VALUE},
 #include "Opts.inc"
 #undef OPTION_WITH_MARSHALLING
 };
 
 TEST(OptionMarshalling, EmittedOrderSameAsDefinitionOrder) {
-  ASSERT_STREQ(MarshallingTable[0].Name.data(), "marshalled-flag-d");
-  ASSERT_STREQ(MarshallingTable[1].Name.data(), "marshalled-flag-c");
-  ASSERT_STREQ(MarshallingTable[2].Name.data(), "marshalled-flag-b");
-  ASSERT_STREQ(MarshallingTable[3].Name.data(), "marshalled-flag-a");
+  ASSERT_EQ(MarshallingTable[0].PrefixedName, "-marshalled-flag-d");
+  ASSERT_EQ(MarshallingTable[1].PrefixedName, "-marshalled-flag-c");
+  ASSERT_EQ(MarshallingTable[2].PrefixedName, "-marshalled-flag-b");
+  ASSERT_EQ(MarshallingTable[3].PrefixedName, "-marshalled-flag-a");
 }
 
 TEST(OptionMarshalling, EmittedSpecifiedKeyPath) {
Index: llvm/lib/Option/OptTable.cpp
===
--- llvm/lib/Option/OptTable.cpp
+++ llvm/lib/Option/OptTable.cpp
@@ -59,7 +59,7 @@
   if ( == )
 return false;
 
-  if (int N = StrCmpOptionName(A.Name, B.Name))
+  if (int N = StrCmpOptionName(A.getName(), B.getName()))
 return N < 0;
 
   for (size_t I = 0, K = std::min(A.Prefixes.size(), B.Prefixes.size()); I != K;
@@ -77,7 +77,7 @@
 
 // Support lower_bound between info and an option name.
 static inline bool operator<(const OptTable::Info , StringRef Name) {
-  return StrCmpOptionNameIgnoreCase(I.Name, Name) < 0;
+  return StrCmpOptionNameIgnoreCase(I.getName(), Name) < 

[PATCH] D155824: [LoongArch] Support -march=native and -mtune=

2023-08-08 Thread Lu Weining via Phabricator via cfe-commits
SixWeining updated this revision to Diff 548442.
SixWeining marked an inline comment as done.
SixWeining added a comment.

Address @MaskRay's comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155824

Files:
  clang/lib/Basic/Targets/LoongArch.cpp
  clang/lib/Basic/Targets/LoongArch.h
  clang/lib/Driver/ToolChains/Arch/LoongArch.cpp
  clang/lib/Driver/ToolChains/Arch/LoongArch.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/loongarch-march-error.c
  clang/test/Driver/loongarch-march.c
  clang/test/Driver/loongarch-mtune.c
  clang/test/Preprocessor/init-loongarch.c
  llvm/include/llvm/TargetParser/LoongArchTargetParser.h
  llvm/lib/Target/LoongArch/LoongArch.td
  llvm/lib/TargetParser/LoongArchTargetParser.cpp
  llvm/test/CodeGen/LoongArch/cpus-invalid.ll
  llvm/test/CodeGen/LoongArch/cpus.ll

Index: llvm/test/CodeGen/LoongArch/cpus.ll
===
--- /dev/null
+++ llvm/test/CodeGen/LoongArch/cpus.ll
@@ -0,0 +1,20 @@
+;; This tests that llc accepts all valid LoongArch CPUs.
+;; Note the 'generic' names have been tested in cpu-name-generic.ll.
+
+; RUN: llc < %s --mtriple=loongarch64 --mcpu=loongarch64 2>&1 | FileCheck %s
+; RUN: llc < %s --mtriple=loongarch64 --mcpu=la464 2>&1 | FileCheck %s
+; RUN: llc < %s --mtriple=loongarch64 2>&1 | FileCheck %s
+
+; CHECK-NOT: {{.*}} is not a recognized processor for this target
+
+define void @f() {
+  ret void
+}
+
+define void @tune_cpu_loongarch64() "tune-cpu"="loongarch64" {
+  ret void
+}
+
+define void @tune_cpu_la464() "tune-cpu"="la464" {
+  ret void
+}
Index: llvm/test/CodeGen/LoongArch/cpus-invalid.ll
===
--- /dev/null
+++ llvm/test/CodeGen/LoongArch/cpus-invalid.ll
@@ -0,0 +1,7 @@
+; RUN: llc < %s --mtriple=loongarch64 --mattr=+64bit --mcpu=invalidcpu 2>&1 | FileCheck %s
+
+; CHECK: {{.*}} is not a recognized processor for this target
+
+define void @f() {
+  ret void
+}
Index: llvm/lib/TargetParser/LoongArchTargetParser.cpp
===
--- llvm/lib/TargetParser/LoongArchTargetParser.cpp
+++ llvm/lib/TargetParser/LoongArchTargetParser.cpp
@@ -46,3 +46,15 @@
   }
   return false;
 }
+
+bool LoongArch::isValidCPUName(StringRef Name) { return isValidArchName(Name); }
+
+void LoongArch::fillValidCPUList(SmallVectorImpl ) {
+  for (const auto A : AllArchs)
+Values.emplace_back(A.Name);
+}
+
+StringRef LoongArch::getDefaultArch(bool Is64Bit) {
+  // TODO: use a real 32-bit arch name.
+  return Is64Bit ? "loongarch64" : "";
+}
Index: llvm/lib/Target/LoongArch/LoongArch.td
===
--- llvm/lib/Target/LoongArch/LoongArch.td
+++ llvm/lib/Target/LoongArch/LoongArch.td
@@ -117,6 +117,11 @@
 def : ProcessorModel<"generic-la32", NoSchedModel, [Feature32Bit]>;
 def : ProcessorModel<"generic-la64", NoSchedModel, [Feature64Bit, FeatureUAL]>;
 
+// Generic 64-bit processor with double-precision floating-point support.
+def : ProcessorModel<"loongarch64", NoSchedModel, [Feature64Bit,
+   FeatureUAL,
+   FeatureBasicD]>;
+
 // Support generic for compatibility with other targets. The triple will be used
 // to change to the appropriate la32/la64 version.
 def : ProcessorModel<"generic", NoSchedModel, []>;
Index: llvm/include/llvm/TargetParser/LoongArchTargetParser.h
===
--- llvm/include/llvm/TargetParser/LoongArchTargetParser.h
+++ llvm/include/llvm/TargetParser/LoongArchTargetParser.h
@@ -66,9 +66,12 @@
 
 bool isValidArchName(StringRef Arch);
 bool getArchFeatures(StringRef Arch, std::vector );
+bool isValidCPUName(StringRef TuneCPU);
+void fillValidCPUList(SmallVectorImpl );
+StringRef getDefaultArch(bool Is64Bit);
 
 } // namespace LoongArch
 
 } // namespace llvm
 
-#endif // LLVM_SUPPORT_LOONGARCHTARGETPARSER_H
+#endif // LLVM_TARGETPARSER_LOONGARCHTARGETPARSER_H
Index: clang/test/Preprocessor/init-loongarch.c
===
--- clang/test/Preprocessor/init-loongarch.c
+++ clang/test/Preprocessor/init-loongarch.c
@@ -787,3 +787,23 @@
 // LA64-FPU0-LP64S: #define __loongarch_lp64 1
 // LA64-FPU0-LP64S-NOT: #define __loongarch_single_float
 // LA64-FPU0-LP64S: #define __loongarch_soft_float 1
+
+/// Check __loongarch_arch and __loongarch_tune.
+
+// RUN: %clang --target=loongarch64 -x c -E -dM %s -o - | \
+// RUN:   FileCheck --match-full-lines --check-prefix=ARCH-TUNE -DARCH=loongarch64 -DTUNE=loongarch64 %s
+// RUN: %clang --target=loongarch64 -x c -E -dM %s -o - -march=loongarch64 | \
+// RUN:   FileCheck --match-full-lines --check-prefix=ARCH-TUNE -DARCH=loongarch64 

[PATCH] D155824: [LoongArch] Support -march=native and -mtune=

2023-08-08 Thread Lu Weining via Phabricator via cfe-commits
SixWeining marked an inline comment as done.
SixWeining added inline comments.



Comment at: clang/lib/Basic/Targets/LoongArch.cpp:203
+  StringRef ArchName = getCPU();
+  Builder.defineMacro("__loongarch_arch", Twine("\"") + ArchName + 
Twine("\""));
+

MaskRay wrote:
> Use the `Twine(char)` constructor.
Thanks.



Comment at: clang/test/Driver/loongarch-mtune-error.c:1
+// RUN: not %clang --target=loongarch64 -mtune=invalidcpu -fsyntax-only %s 
2>&1 | FileCheck %s
+// RUN: not %clang --target=loongarch64 -mtune=generic -fsyntax-only %s 2>&1 | 
FileCheck %s

MaskRay wrote:
> Use `-###` to test the driver. Consider merging this test into the 
> `loongarch-mtune.c`. 
Done. Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155824

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


[PATCH] D157428: [clang-tidy] `readability-implicit-bool-conversion.AllowIntegerConditions` ignores `DoStmt`s

2023-08-08 Thread Fabian Wolff via Phabricator via cfe-commits
fwolff updated this revision to Diff 548342.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157428

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-allow-in-conditions.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/readability/implicit-bool-conversion-allow-in-conditions.cpp
===
--- 
clang-tools-extra/test/clang-tidy/checkers/readability/implicit-bool-conversion-allow-in-conditions.cpp
+++ 
clang-tools-extra/test/clang-tidy/checkers/readability/implicit-bool-conversion-allow-in-conditions.cpp
@@ -38,6 +38,9 @@
   while (functionReturningInt()) {}
   while (functionReturningPointer()) {}
   while (functionReturningInt() && !functionReturningPointer() || 
(!functionReturningInt() && functionReturningPointer())) {}
+  do {} while (functionReturningInt());
+  do {} while (functionReturningPointer());
+  do {} while (functionReturningInt() && !functionReturningPointer() || 
(!functionReturningInt() && functionReturningPointer()));
   int value1 = functionReturningInt() ? 1 : 2;
   int value2 = !functionReturningInt() ? 1 : 2;
   int value3 = (functionReturningInt() && functionReturningPointer() || 
!functionReturningInt()) ? 1 : 2;
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -196,6 +196,11 @@
   ` check to emit proper
   warnings when a type forward declaration precedes its definition.
 
+- Improved :doc:`readability-implicit-bool-conversion
+  ` check to take
+  do-while loops into account for the `AllowIntegerConditions` and
+  `AllowPointerConditions` options.
+
 Removed checks
 ^^
 
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
@@ -228,7 +228,8 @@
   if (!S)
 return false;
   if (isa(S) || isa(S) || isa(S) ||
-  isa(S) || isa(S))
+  isa(S) || isa(S) ||
+  isa(S))
 return true;
   if (isa(S) || isa(S) ||
   isUnaryLogicalNotOperator(S) ||


Index: clang-tools-extra/test/clang-tidy/checkers/readability/implicit-bool-conversion-allow-in-conditions.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability/implicit-bool-conversion-allow-in-conditions.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability/implicit-bool-conversion-allow-in-conditions.cpp
@@ -38,6 +38,9 @@
   while (functionReturningInt()) {}
   while (functionReturningPointer()) {}
   while (functionReturningInt() && !functionReturningPointer() || (!functionReturningInt() && functionReturningPointer())) {}
+  do {} while (functionReturningInt());
+  do {} while (functionReturningPointer());
+  do {} while (functionReturningInt() && !functionReturningPointer() || (!functionReturningInt() && functionReturningPointer()));
   int value1 = functionReturningInt() ? 1 : 2;
   int value2 = !functionReturningInt() ? 1 : 2;
   int value3 = (functionReturningInt() && functionReturningPointer() || !functionReturningInt()) ? 1 : 2;
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -196,6 +196,11 @@
   ` check to emit proper
   warnings when a type forward declaration precedes its definition.
 
+- Improved :doc:`readability-implicit-bool-conversion
+  ` check to take
+  do-while loops into account for the `AllowIntegerConditions` and
+  `AllowPointerConditions` options.
+
 Removed checks
 ^^
 
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
@@ -228,7 +228,8 @@
   if (!S)
 return false;
   if (isa(S) || isa(S) || isa(S) ||
-  isa(S) || isa(S))
+  isa(S) || isa(S) ||
+  isa(S))
 return true;
   if (isa(S) || isa(S) ||
   isUnaryLogicalNotOperator(S) ||
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D157436: [clang-tidy] `performance-faster-string-find` generates incorrect fixes for single quote character literals

2023-08-08 Thread Fabian Wolff via Phabricator via cfe-commits
fwolff updated this revision to Diff 548347.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157436

Files:
  clang-tools-extra/clang-tidy/performance/FasterStringFindCheck.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/test/clang-tidy/checkers/performance/faster-string-find.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/performance/faster-string-find.cpp
===
--- 
clang-tools-extra/test/clang-tidy/checkers/performance/faster-string-find.cpp
+++ 
clang-tools-extra/test/clang-tidy/checkers/performance/faster-string-find.cpp
@@ -56,13 +56,21 @@
   // CHECK-MESSAGES: [[@LINE-1]]:12: warning: 'find' called with a string 
literal
   // CHECK-FIXES: Str.find('a', 1);
 
-  // Doens't work with strings smaller or larger than 1 char.
+  // Doesn't work with strings smaller or larger than 1 char.
   Str.find("");
   Str.find("ab");
 
   // Doesn't do anything with the 3 argument overload.
   Str.find("a", 1, 1);
 
+  // Single quotes are escaped properly
+  Str.find("'");
+  // CHECK-MESSAGES: [[@LINE-1]]:12: warning: 'find' called with a string 
literal
+  // CHECK-FIXES: Str.find('\'');
+  Str.find("\'");
+  // CHECK-MESSAGES: [[@LINE-1]]:12: warning: 'find' called with a string 
literal
+  // CHECK-FIXES: Str.find('\'');
+
   // Other methods that can also be replaced
   Str.rfind("a");
   // CHECK-MESSAGES: [[@LINE-1]]:13: warning: 'rfind' called with a string 
literal
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -188,6 +188,10 @@
   ` to support for-loops with
   iterators initialized by free functions like ``begin``, ``end``, or ``size``.
 
+- Improved :doc:`performance-faster-string-find
+  ` check to properly escape
+  single quotes.
+
 - Improved :doc:`performanc-noexcept-swap
   ` check to enforce a stricter
   match with the swap function signature, eliminating false-positives.
Index: clang-tools-extra/clang-tidy/performance/FasterStringFindCheck.cpp
===
--- clang-tools-extra/clang-tidy/performance/FasterStringFindCheck.cpp
+++ clang-tools-extra/clang-tidy/performance/FasterStringFindCheck.cpp
@@ -26,14 +26,20 @@
 Literal->outputString(OS);
   }
   // Now replace the " with '.
-  auto Pos = Result.find_first_of('"');
-  if (Pos == Result.npos)
+  auto OpenPos = Result.find_first_of('"');
+  if (OpenPos == Result.npos)
 return std::nullopt;
-  Result[Pos] = '\'';
-  Pos = Result.find_last_of('"');
-  if (Pos == Result.npos)
+  Result[OpenPos] = '\'';
+
+  auto ClosePos = Result.find_last_of('"');
+  if (ClosePos == Result.npos)
 return std::nullopt;
-  Result[Pos] = '\'';
+  Result[ClosePos] = '\'';
+
+  // "'" is OK, but ''' is not, so add a backslash
+  if ((ClosePos - OpenPos) == 2 && Result[OpenPos + 1] == '\'')
+Result.replace(OpenPos + 1, 1, "\\'");
+
   return Result;
 }
 


Index: clang-tools-extra/test/clang-tidy/checkers/performance/faster-string-find.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/performance/faster-string-find.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/performance/faster-string-find.cpp
@@ -56,13 +56,21 @@
   // CHECK-MESSAGES: [[@LINE-1]]:12: warning: 'find' called with a string literal
   // CHECK-FIXES: Str.find('a', 1);
 
-  // Doens't work with strings smaller or larger than 1 char.
+  // Doesn't work with strings smaller or larger than 1 char.
   Str.find("");
   Str.find("ab");
 
   // Doesn't do anything with the 3 argument overload.
   Str.find("a", 1, 1);
 
+  // Single quotes are escaped properly
+  Str.find("'");
+  // CHECK-MESSAGES: [[@LINE-1]]:12: warning: 'find' called with a string literal
+  // CHECK-FIXES: Str.find('\'');
+  Str.find("\'");
+  // CHECK-MESSAGES: [[@LINE-1]]:12: warning: 'find' called with a string literal
+  // CHECK-FIXES: Str.find('\'');
+
   // Other methods that can also be replaced
   Str.rfind("a");
   // CHECK-MESSAGES: [[@LINE-1]]:13: warning: 'rfind' called with a string literal
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -188,6 +188,10 @@
   ` to support for-loops with
   iterators initialized by free functions like ``begin``, ``end``, or ``size``.
 
+- Improved :doc:`performance-faster-string-find
+  ` check to properly escape
+  single quotes.
+
 - Improved :doc:`performanc-noexcept-swap
   ` check to enforce a stricter
   match with the swap function signature, eliminating false-positives.
Index: clang-tools-extra/clang-tidy/performance/FasterStringFindCheck.cpp

[PATCH] D155383: [clang][AST] TextNodeDumper learned to output exception specifications

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

In D155383#4507928 , @strimo378 wrote:

> There are many ast-dump tests about decls but there are nearly no other type 
> tests.

We should still be adding tests for these changes, to ensure we don't regress 
the behavior later by accident. It also helps the code reviewers to see what 
the output looks like and whether we spot any concerns with it.




Comment at: clang/lib/AST/TextNodeDumper.cpp:1549
+  case EST_DynamicNone:
+OS << " exceptionspec_dynamicnone";
+break;





Comment at: clang/lib/AST/TextNodeDumper.cpp:1555
+  case EST_MSAny:
+OS << " exceptionspec_msany";
+break;





Comment at: clang/lib/AST/TextNodeDumper.cpp:1561
+  case EST_BasicNoexcept:
+OS << " exceptionspec_basicnoexcept";
+break;





Comment at: clang/lib/AST/TextNodeDumper.cpp:1564
+  case EST_DependentNoexcept:
+OS << " exceptionspec_dependentnoexcept";
+break;





Comment at: clang/lib/AST/TextNodeDumper.cpp:1567
+  case EST_NoexceptFalse:
+OS << " exceptionspec_noexceptfalse";
+break;





Comment at: clang/lib/AST/TextNodeDumper.cpp:1570
+  case EST_NoexceptTrue:
+OS << " exceptionspec_noexcepttrue";
+break;




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155383

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


[PATCH] D157331: [clang] Implement C23

2023-08-08 Thread Aditya Kumar via Phabricator via cfe-commits
hiraditya added inline comments.



Comment at: clang/lib/Headers/stdckdint.h:13
+
+#if defined(__GNUC__)
+#define ckd_add(R, A, B) __builtin_add_overflow((A), (B), (R))

xbolva00 wrote:
> yabinc wrote:
> > enh wrote:
> > > enh wrote:
> > > > enh wrote:
> > > > > ZijunZhao wrote:
> > > > > > enh wrote:
> > > > > > > is this ever _not_ set for clang?
> > > > > > https://github.com/llvm/llvm-project/blob/main/clang/lib/Headers/stdbool.h#L23
> > > > > > I think it is set?
> > > > > i get an error from
> > > > > ```
> > > > > /tmp$ cat x.c
> > > > > #if defined(__GNUC__)
> > > > > #error foo
> > > > > #endif
> > > > > ```
> > > > > regardless of whether i compile with -std=c11 or -std=gnu11.
> > > > > neither -ansi nor -pedantic seem to stop it either.
> > > > it does look like it _should_ be possible to not have it set though? 
> > > > llvm/llvm-project/clang/lib/Frontend/InitPreprocessor.cpp has:
> > > > ```
> > > >   if (LangOpts.GNUCVersion != 0) {
> > > > // Major, minor, patch, are given two decimal places each, so 4.2.1 
> > > > becomes
> > > > // 40201.
> > > > unsigned GNUCMajor = LangOpts.GNUCVersion / 100 / 100;
> > > > unsigned GNUCMinor = LangOpts.GNUCVersion / 100 % 100;
> > > > unsigned GNUCPatch = LangOpts.GNUCVersion % 100;
> > > > Builder.defineMacro("__GNUC__", Twine(GNUCMajor));
> > > > Builder.defineMacro("__GNUC_MINOR__", Twine(GNUCMinor));
> > > > Builder.defineMacro("__GNUC_PATCHLEVEL__", Twine(GNUCPatch));
> > > > Builder.defineMacro("__GXX_ABI_VERSION", "1002");
> > > > 
> > > > if (LangOpts.CPlusPlus) {
> > > >   Builder.defineMacro("__GNUG__", Twine(GNUCMajor));
> > > >   Builder.defineMacro("__GXX_WEAK__");
> > > > }
> > > >   }
> > > > ```
> > > /me wonders whether the right test here is actually `#if 
> > > __has_feature(__builtin_add_overflow)` (etc)...
> > > 
> > > but at this point, you definitely need an llvm person :-)
> > From 
> > https://clang.llvm.org/docs/LanguageExtensions.html#checked-arithmetic-builtins,
> >  we can check them with
> >  __has_builtin(__builtin_add_overflow) && 
> > __has_builtin(__builtin_sub_overflow) && 
> > __has_builtin(__builtin_mul_overflow).
> > I saw some code also checks if __GNUC__ >= 5:
> > 
> > // The __GNUC__ checks can not be removed until we depend on GCC >= 10.1
> > // which is the first version that returns true for 
> > __has_builtin(__builtin_add_overflow)
> > #if __GNUC__ >= 5 || __has_builtin(__builtin_add_overflow)
> > 
> > I guess we don't need to support real gcc using this header here. So maybe 
> > only checking __has_builtin is enough?
> > 
> > By the way, if __builtin_add_overflow may not appear on some targets, do we 
> > need to modify tests to specify triple like "-triple 
> > "x86_64-unknown-unknown"" in 
> > https://github.com/llvm/llvm-project/blob/main/clang/test/CodeGen/builtins-overflow.c#L5
> >  ?
> > 
> #ifndef __has_builtin // Optional of course.
>   #define __has_builtin(x) 0  // Compatibility with non-clang compilers.
> #endif
> 
> ...
> #if __has_builtin(__builtin_trap)
>   __builtin_trap();
> #else
>   abort();
> #endif
> /me wonders whether the right test here is actually #if 
> __has_feature(__builtin_add_overflow) (etc)...

i think that should be added.

I guess we also need a with `__STDC_VERSION__ > 202000L`? in princple we'd have 
a C23 number for it but i'm not sure if that has been added to clang yet.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157331

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


[PATCH] D157441: [-Wunsafe-buffer-usage] Use `Strategy` to determine whether to fix a parameter

2023-08-08 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 created this revision.
ziqingluo-90 added reviewers: t-rasmud, NoQ, jkorous, malavikasamak.
Herald added a project: All.
ziqingluo-90 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

- Use `Strategy` to determine whether to fix a parameter.
- Fix the `Strategy` construction so that only variables on the graph are 
assigned the `std::span` strategy
- Extend `PointerAssignmentGadget` and `PointerInitGadget` to generate fix-its 
for cases where the left-hand side has `won't fix` strategy and the right-hand 
side has `std::span` strategy.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D157441

Files:
  clang/include/clang/Analysis/Analyses/UnsafeBufferUsage.h
  clang/lib/Analysis/UnsafeBufferUsage.cpp
  clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-multi-parm-span.cpp
  clang/test/SemaCXX/warn-unsafe-buffer-usage-multi-decl-ptr-init.cpp
  clang/test/SemaCXX/warn-unsafe-buffer-usage-multi-decl-warnings.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
@@ -36,9 +36,11 @@
 void * voidPtrCall(void);
 char * charPtrCall(void);
 
-void testArraySubscripts(int *p, int **pp) {
-// expected-warning@-1{{'p' is an unsafe pointer used for buffer access}}
-// expected-warning@-2{{'pp' is an unsafe pointer used for buffer access}}
+void testArraySubscripts(int *p, int **pp) { // expected-warning{{'p' is an unsafe pointer used for buffer access}} \
+	expected-warning{{'pp' is an unsafe pointer used for buffer access}} \
+expected-note{{change type of 'p' to 'std::span' to preserve bounds information, and change 'pp' to safe types to make function 'testArraySubscripts' bounds-safe}} \
+expected-note{{change type of 'pp' to 'std::span' to preserve bounds information, and change 'p' to safe types to make function 'testArraySubscripts' bounds-safe}}
+  
   foo(p[1], // expected-note{{used in buffer access here}}
   pp[1][1], // expected-note{{used in buffer access here}}
 // expected-warning@-1{{unsafe buffer access}}
Index: clang/test/SemaCXX/warn-unsafe-buffer-usage-multi-decl-warnings.cpp
===
--- clang/test/SemaCXX/warn-unsafe-buffer-usage-multi-decl-warnings.cpp
+++ clang/test/SemaCXX/warn-unsafe-buffer-usage-multi-decl-warnings.cpp
@@ -65,7 +65,8 @@
 
 void rhs_span2() {
   int *q = new int[6];
-  int *p = q;  // expected-warning{{'p' is an unsafe pointer used for buffer access}}
+  int *p = q;  // expected-warning{{'p' is an unsafe pointer used for buffer access}} \
+	  expected-note{{change type of 'p' to 'std::span' to preserve bounds information, and change 'q' to 'std::span' to propagate bounds information between them}}
   p[5] = 10;  // expected-note{{used in buffer access here}}
   int *r = q;
 }
Index: clang/test/SemaCXX/warn-unsafe-buffer-usage-multi-decl-ptr-init.cpp
===
--- clang/test/SemaCXX/warn-unsafe-buffer-usage-multi-decl-ptr-init.cpp
+++ clang/test/SemaCXX/warn-unsafe-buffer-usage-multi-decl-ptr-init.cpp
@@ -25,7 +25,8 @@
 // FIXME: Suggest fixits for p, q, and r since span a valid fixit for r.
 void rhs_span3() {
   int *q = new int[6];
-  int *p = q;  // expected-warning{{'p' is an unsafe pointer used for buffer access}}
+  int *p = q;  // expected-warning{{'p' is an unsafe pointer used for buffer access}} \
+	  expected-note{{change type of 'p' to 'std::span' to preserve bounds information, and change 'q' to 'std::span' to propagate bounds information between them}}
   p[5] = 10;  // expected-note{{used in buffer access here}}
   int *r = q;
 }
Index: clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-multi-parm-span.cpp
===
--- clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-multi-parm-span.cpp
+++ clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-multi-parm-span.cpp
@@ -2,11 +2,12 @@
 // RUN: %clang_cc1 -std=c++20 -Wunsafe-buffer-usage -fdiagnostics-parseable-fixits -fblocks -fsafe-buffer-usage-suggestions \
 // RUN:%s 2>&1 | FileCheck %s
 
-// FIXME: what about possible diagnostic message non-determinism?
-
 // CHECK-NOT: fix-it:{{.*}}:{[[@LINE+1]]:
 void parmsNoFix(int *p, int *q) {
   int * a = new int[10];
+  // CHECK: fix-it:{{.*}}:{[[@LINE+3]]:3-[[@LINE+3]]:12}:"std::span b"
+  // CHECK: fix-it:{{.*}}:{[[@LINE+2]]:13-[[@LINE+2]]:13}:"{"
+  // CHECK: fix-it:{{.*}}:{[[@LINE+1]]:24-[[@LINE+1]]:24}:", 10}"  
   int * b = new int[10]; //expected-warning{{'b' is an unsafe pointer used for buffer access}} \

[PATCH] D157331: [clang] Implement C23

2023-08-08 Thread Elliott Hughes via Phabricator via cfe-commits
enh added inline comments.



Comment at: clang/test/Headers/stdckdint.cpp:1
+// RUN: %clang_cc1 -emit-llvm -fgnuc-version=4.2.1 -std=gnu++11 %s -o - | 
FileCheck %s
+

ZijunZhao wrote:
> enh wrote:
> > ZijunZhao wrote:
> > > enh wrote:
> > > > hiraditya wrote:
> > > > > seems like we don't have a -std=gnu23, or -std=c23 standard flag for 
> > > > > this in clang yet.
> > > > > 
> > > > > https://godbolt.org/z/7dKnGEWWE
> > > > > 
> > > > > we probably need it before testing stdckdint i guess?
> > > > other headers just use > and the previous version. (though see 
> > > > stdalign.h if you're looking for some random cleanup to do!)
> > > > seems like we don't have a -std=gnu23, or -std=c23 standard flag for 
> > > > this in clang yet.
> > > 
> > > In the local testing, `-std=c++23` works  and all tests pass 
> > > 
> > > 
> > C23 != C++23... they don't even really coordinate with one another... talk 
> > to hboehm about that some time :-)
> ohhh I think `gnu++23` != `gnu23` either  
correct. the "c" or "c++" part means "standard stuff" and replacing it with 
"gnu" or "gnu++" means "standard stuff _and_ extensions".


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157331

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


[PATCH] D157331: [clang] Implement C23

2023-08-08 Thread Aditya Kumar via Phabricator via cfe-commits
hiraditya added inline comments.



Comment at: clang/lib/Headers/stdckdint.h:13
+
+#if defined(__GNUC__)
+#define ckd_add(R, A, B) __builtin_add_overflow((A), (B), (R))

enh wrote:
> hiraditya wrote:
> > xbolva00 wrote:
> > > yabinc wrote:
> > > > enh wrote:
> > > > > enh wrote:
> > > > > > enh wrote:
> > > > > > > ZijunZhao wrote:
> > > > > > > > enh wrote:
> > > > > > > > > is this ever _not_ set for clang?
> > > > > > > > https://github.com/llvm/llvm-project/blob/main/clang/lib/Headers/stdbool.h#L23
> > > > > > > > I think it is set?
> > > > > > > i get an error from
> > > > > > > ```
> > > > > > > /tmp$ cat x.c
> > > > > > > #if defined(__GNUC__)
> > > > > > > #error foo
> > > > > > > #endif
> > > > > > > ```
> > > > > > > regardless of whether i compile with -std=c11 or -std=gnu11.
> > > > > > > neither -ansi nor -pedantic seem to stop it either.
> > > > > > it does look like it _should_ be possible to not have it set 
> > > > > > though? llvm/llvm-project/clang/lib/Frontend/InitPreprocessor.cpp 
> > > > > > has:
> > > > > > ```
> > > > > >   if (LangOpts.GNUCVersion != 0) {
> > > > > > // Major, minor, patch, are given two decimal places each, so 
> > > > > > 4.2.1 becomes
> > > > > > // 40201.
> > > > > > unsigned GNUCMajor = LangOpts.GNUCVersion / 100 / 100;
> > > > > > unsigned GNUCMinor = LangOpts.GNUCVersion / 100 % 100;
> > > > > > unsigned GNUCPatch = LangOpts.GNUCVersion % 100;
> > > > > > Builder.defineMacro("__GNUC__", Twine(GNUCMajor));
> > > > > > Builder.defineMacro("__GNUC_MINOR__", Twine(GNUCMinor));
> > > > > > Builder.defineMacro("__GNUC_PATCHLEVEL__", Twine(GNUCPatch));
> > > > > > Builder.defineMacro("__GXX_ABI_VERSION", "1002");
> > > > > > 
> > > > > > if (LangOpts.CPlusPlus) {
> > > > > >   Builder.defineMacro("__GNUG__", Twine(GNUCMajor));
> > > > > >   Builder.defineMacro("__GXX_WEAK__");
> > > > > > }
> > > > > >   }
> > > > > > ```
> > > > > /me wonders whether the right test here is actually `#if 
> > > > > __has_feature(__builtin_add_overflow)` (etc)...
> > > > > 
> > > > > but at this point, you definitely need an llvm person :-)
> > > > From 
> > > > https://clang.llvm.org/docs/LanguageExtensions.html#checked-arithmetic-builtins,
> > > >  we can check them with
> > > >  __has_builtin(__builtin_add_overflow) && 
> > > > __has_builtin(__builtin_sub_overflow) && 
> > > > __has_builtin(__builtin_mul_overflow).
> > > > I saw some code also checks if __GNUC__ >= 5:
> > > > 
> > > > // The __GNUC__ checks can not be removed until we depend on GCC >= 10.1
> > > > // which is the first version that returns true for 
> > > > __has_builtin(__builtin_add_overflow)
> > > > #if __GNUC__ >= 5 || __has_builtin(__builtin_add_overflow)
> > > > 
> > > > I guess we don't need to support real gcc using this header here. So 
> > > > maybe only checking __has_builtin is enough?
> > > > 
> > > > By the way, if __builtin_add_overflow may not appear on some targets, 
> > > > do we need to modify tests to specify triple like "-triple 
> > > > "x86_64-unknown-unknown"" in 
> > > > https://github.com/llvm/llvm-project/blob/main/clang/test/CodeGen/builtins-overflow.c#L5
> > > >  ?
> > > > 
> > > #ifndef __has_builtin // Optional of course.
> > >   #define __has_builtin(x) 0  // Compatibility with non-clang compilers.
> > > #endif
> > > 
> > > ...
> > > #if __has_builtin(__builtin_trap)
> > >   __builtin_trap();
> > > #else
> > >   abort();
> > > #endif
> > > /me wonders whether the right test here is actually #if 
> > > __has_feature(__builtin_add_overflow) (etc)...
> > 
> > i think that should be added.
> > 
> > I guess we also need a with `__STDC_VERSION__ > 202000L`? in princple we'd 
> > have a C23 number for it but i'm not sure if that has been added to clang 
> > yet.
> > i think that should be added.
> 
> i was advising the opposite --- now this is a standard C23 feature, any 
> architectures where __builtin_*_overflow doesn't work need to be found and 
> fixed. and we'll do that quicker if we unconditionally expose these and (more 
> importantly!) run the tests.
> 
> > I guess we also need a with __STDC_VERSION__ > 202000L?
> 
> _personally_ i think that's silly because you can't hide the header file, so 
> it doesn't make any sense to just have it empty if someone's actually 
> #included it. we don't do this anywhere in bionic for example, for this 
> reason. but obviously that's an llvm decision, and it does look like the 
> other similar headers _do_ have this check, so, yeah, probably.
> i was advising the opposite -- now this is a standard C23 feature, any 
> architectures where __builtin

you're right. it seems like `__builtin_add_overflow` is expected to be defined 
by default 
(https://github.com/llvm/llvm-project/blob/main/clang/test/Sema/builtins-overflow.c#L4).

> and it does look like the other similar headers _do_ have this check, so, 
> yeah, probably.

yeah, Several headers have checks 

[PATCH] D157297: [clang] Fixes compile error like error: expected unqualified-id for ::_tzcnt_u32(mask);

2023-08-08 Thread Phoebe Wang via Phabricator via cfe-commits
pengfei added a comment.

The description is not clear to me. You should describe the reason rather than 
phenomenon.

My understanding is double colon cannot operator cannot resolve functions with 
parentheses. But I didn't find enough proof in Google. It'd be more persuasive 
if you can find it and add to the description.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157297

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


[PATCH] D157428: [clang-tidy] `readability-implicit-bool-conversion.AllowIntegerConditions` ignores `DoStmt`s

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

Missing release notes, except that looks fine.
What about switchStmt ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157428

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


[PATCH] D153536: [Clang] Implement P2169 A nice placeholder with no name

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

In D153536#4570561 , @vitalybuka 
wrote:

> In D153536#4570534 , @aaron.ballman 
> wrote:
>
>> In D153536#4570513 , @vitalybuka 
>> wrote:
>>
>>> This patch brakes https://lab.llvm.org/buildbot/#/builders/168/builds/14997
>>> Not sure what is wrong there, probably the test need to be updated. Can you 
>>> please take a look?
>>
>> I'm a bit confused -- the linked bot is green and the failures to either 
>> side of the linked run are both failing for the same reason (which seems to 
>> be unrelated to the changes in this patch). It looks like this bot went red 
>> here: https://lab.llvm.org/buildbot/#/builders/168/builds/14944 and hasn't 
>> reliably come back to green.
>
> Sorry copy-pasted wrong url. This green is manual request on revision before 
> this patch.
>
> Correct failure https://lab.llvm.org/buildbot/#/builders/168/builds/14944
> So it's persistently red after that.
>
> If anyone wondering, I've bisected to this patch on buildbot host.
> For whatever reason does not reproduce on my workstation.

Thanks! We might need someone from clangd to help here. The logs do not have 
any information explaining what's failing with the test, and looking at the 
test code, I struggle to see how these changes would impact that test. We've 
had some significant issues with flaky clangd tests 
(https://github.com/clangd/clangd/issues/1712), so it's possible this is 
happenstance.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153536

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


[PATCH] D157435: [Sema] Do not emit -Wmissing-variable-declarations for register variables

2023-08-08 Thread Nathan Chancellor via Phabricator via cfe-commits
nathanchance created this revision.
nathanchance added reviewers: aaron.ballman, nickdesaulniers.
Herald added a subscriber: pengfei.
Herald added a project: All.
nathanchance requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

When building the Linux kernel with -Wmissing-variable-declarations,
there are several instances of warnings around variables declared with
register storage:

  arch/x86/include/asm/asm.h:208:24: warning: no previous extern declaration 
for non-static variable 'current_stack_pointer' 
[-Wmissing-variable-declarations]
  register unsigned long current_stack_pointer asm(_ASM_SP);
 ^
  arch/x86/include/asm/asm.h:208:10: note: declare 'static' if the variable is 
not intended to be used outside of this translation unit
  register unsigned long current_stack_pointer asm(_ASM_SP);
   ^
  1 warning generated.

The suggestion is invalid, as the variable cannot have both static and
register storage. Do not emit -Wmissing-variable-declarations for
register variables.

Closes: https://github.com/llvm/llvm-project/issues/64509
Link: https://lore.kernel.org/202308081050.szew4cq5-...@intel.com/


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D157435

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaDecl.cpp
  clang/test/Sema/warn-missing-variable-declarations-register.c


Index: clang/test/Sema/warn-missing-variable-declarations-register.c
===
--- /dev/null
+++ clang/test/Sema/warn-missing-variable-declarations-register.c
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -Wmissing-variable-declarations 
-fsyntax-only -verify %s
+// REQUIRES: x86-registered-target
+// expected-no-diagnostics
+
+register unsigned long current_stack_pointer asm("rsp");
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -14144,6 +14144,7 @@
   var->getDeclContext()->getRedeclContext()->isFileContext() &&
   var->isExternallyVisible() && var->hasLinkage() &&
   !var->isInline() && !var->getDescribedVarTemplate() &&
+  var->getStorageClass() != SC_Register &&
   !isa(var) &&
   !isTemplateInstantiation(var->getTemplateSpecializationKind()) &&
   !getDiagnostics().isIgnored(diag::warn_missing_variable_declarations,
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -123,6 +123,8 @@
   template-specialization function calls.
 - Clang contexpr evaluator now displays notes as well as an error when a 
constructor
   of a base class is not called in the constructor of its derived class.
+- Clang no longer emits `-Wmissing-variable-declarations` for variables 
declared
+  with the `register` storage class.
 
 Bug Fixes in This Version
 -


Index: clang/test/Sema/warn-missing-variable-declarations-register.c
===
--- /dev/null
+++ clang/test/Sema/warn-missing-variable-declarations-register.c
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -Wmissing-variable-declarations -fsyntax-only -verify %s
+// REQUIRES: x86-registered-target
+// expected-no-diagnostics
+
+register unsigned long current_stack_pointer asm("rsp");
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -14144,6 +14144,7 @@
   var->getDeclContext()->getRedeclContext()->isFileContext() &&
   var->isExternallyVisible() && var->hasLinkage() &&
   !var->isInline() && !var->getDescribedVarTemplate() &&
+  var->getStorageClass() != SC_Register &&
   !isa(var) &&
   !isTemplateInstantiation(var->getTemplateSpecializationKind()) &&
   !getDiagnostics().isIgnored(diag::warn_missing_variable_declarations,
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -123,6 +123,8 @@
   template-specialization function calls.
 - Clang contexpr evaluator now displays notes as well as an error when a constructor
   of a base class is not called in the constructor of its derived class.
+- Clang no longer emits `-Wmissing-variable-declarations` for variables declared
+  with the `register` storage class.
 
 Bug Fixes in This Version
 -
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D157432: [clang][ConstExprEmitter] handle Unary Not on integers

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



Comment at: clang/lib/CodeGen/CGExprConstant.cpp:1402
+return nullptr;
+  }
+

A lot of these visitor methods for UnaryOperator are going to look almost the 
same; I think I might prefer to have a `VisitUnaryOperator` method instead, and 
simply switch on the kind of operator.

But perhaps, I should flush out more of these methods, then do such 
refactoring?  WDYT @efriedma 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157432

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


[PATCH] D157428: [clang-tidy] `readability-implicit-bool-conversion.AllowIntegerConditions` ignores `DoStmt`s

2023-08-08 Thread Fabian Wolff via Phabricator via cfe-commits
fwolff updated this revision to Diff 548334.
fwolff added a comment.

Mention this change in the release notes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157428

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-allow-in-conditions.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/readability/implicit-bool-conversion-allow-in-conditions.cpp
===
--- 
clang-tools-extra/test/clang-tidy/checkers/readability/implicit-bool-conversion-allow-in-conditions.cpp
+++ 
clang-tools-extra/test/clang-tidy/checkers/readability/implicit-bool-conversion-allow-in-conditions.cpp
@@ -38,6 +38,9 @@
   while (functionReturningInt()) {}
   while (functionReturningPointer()) {}
   while (functionReturningInt() && !functionReturningPointer() || 
(!functionReturningInt() && functionReturningPointer())) {}
+  do {} while (functionReturningInt());
+  do {} while (functionReturningPointer());
+  do {} while (functionReturningInt() && !functionReturningPointer() || 
(!functionReturningInt() && functionReturningPointer()));
   int value1 = functionReturningInt() ? 1 : 2;
   int value2 = !functionReturningInt() ? 1 : 2;
   int value3 = (functionReturningInt() && functionReturningPointer() || 
!functionReturningInt()) ? 1 : 2;
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -196,6 +196,11 @@
   ` check to emit proper
   warnings when a type forward declaration precedes its definition.
 
+- Improved :doc:`readability-implicit-bool-conversion
+  ` check to take do-while loops into
+  account for the ``AllowIntegerConditions`` and ``AllowPointerConditions``
+  options.
+
 Removed checks
 ^^
 
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
@@ -228,7 +228,8 @@
   if (!S)
 return false;
   if (isa(S) || isa(S) || isa(S) ||
-  isa(S) || isa(S))
+  isa(S) || isa(S) ||
+  isa(S))
 return true;
   if (isa(S) || isa(S) ||
   isUnaryLogicalNotOperator(S) ||


Index: clang-tools-extra/test/clang-tidy/checkers/readability/implicit-bool-conversion-allow-in-conditions.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability/implicit-bool-conversion-allow-in-conditions.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability/implicit-bool-conversion-allow-in-conditions.cpp
@@ -38,6 +38,9 @@
   while (functionReturningInt()) {}
   while (functionReturningPointer()) {}
   while (functionReturningInt() && !functionReturningPointer() || (!functionReturningInt() && functionReturningPointer())) {}
+  do {} while (functionReturningInt());
+  do {} while (functionReturningPointer());
+  do {} while (functionReturningInt() && !functionReturningPointer() || (!functionReturningInt() && functionReturningPointer()));
   int value1 = functionReturningInt() ? 1 : 2;
   int value2 = !functionReturningInt() ? 1 : 2;
   int value3 = (functionReturningInt() && functionReturningPointer() || !functionReturningInt()) ? 1 : 2;
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -196,6 +196,11 @@
   ` check to emit proper
   warnings when a type forward declaration precedes its definition.
 
+- Improved :doc:`readability-implicit-bool-conversion
+  ` check to take do-while loops into
+  account for the ``AllowIntegerConditions`` and ``AllowPointerConditions``
+  options.
+
 Removed checks
 ^^
 
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
@@ -228,7 +228,8 @@
   if (!S)
 return false;
   if (isa(S) || isa(S) || isa(S) ||
-  isa(S) || isa(S))
+  isa(S) || isa(S) ||
+  isa(S))
 return true;
   if (isa(S) || isa(S) ||
   isUnaryLogicalNotOperator(S) ||
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D155850: [Clang][CodeGen][RFC] Add codegen support for C++ Parallel Algorithm Offload

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



Comment at: clang/lib/CodeGen/BackendUtil.cpp:1101-1102
+MPM.addPass(StdParAcceleratorCodeSelectionPass());
+}
+else if (LangOpts.HIPStdParInterposeAlloc) {
+  MPM.addPass(StdParAllocationInterpositionPass());

Formatting


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

https://reviews.llvm.org/D155850

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


[PATCH] D157436: [clang-tidy] `performance-faster-string-find` generates incorrect fixes for single quote character literals

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



Comment at: 
clang-tools-extra/clang-tidy/performance/FasterStringFindCheck.cpp:40
+  // "'" is OK, but ''' is not, so add a backslash
+  if (ClosePos - OpenPos == 2 && Result[OpenPos + 1] == '\'')
+Result.replace(OpenPos + 1, 1, "\\'");





Comment at: clang-tools-extra/docs/ReleaseNotes.rst:199-201
+- Fixed a bug in :doc:`performance-faster-string-find
+  ` which generated incorrect fixes by not
+  escaping single quotes properly.

And put it before performanc-noexcept-swap, other alternative would be to call 
it "Improve XYZ check to properly escape single quote characters. or something 
like that


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157436

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


[PATCH] D157435: [Sema] Do not emit -Wmissing-variable-declarations for register variables

2023-08-08 Thread Nathan Chancellor via Phabricator via cfe-commits
nathanchance updated this revision to Diff 548337.
nathanchance added a comment.

- Update formatting in release notes
- Add GCC bug link to commit message
- Remove unnecessary REQUIRES: in test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157435

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaDecl.cpp
  clang/test/Sema/warn-missing-variable-declarations-register.c


Index: clang/test/Sema/warn-missing-variable-declarations-register.c
===
--- /dev/null
+++ clang/test/Sema/warn-missing-variable-declarations-register.c
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -Wmissing-variable-declarations 
-fsyntax-only -verify %s
+// expected-no-diagnostics
+
+register unsigned long current_stack_pointer asm("rsp");
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -14144,6 +14144,7 @@
   var->getDeclContext()->getRedeclContext()->isFileContext() &&
   var->isExternallyVisible() && var->hasLinkage() &&
   !var->isInline() && !var->getDescribedVarTemplate() &&
+  var->getStorageClass() != SC_Register &&
   !isa(var) &&
   !isTemplateInstantiation(var->getTemplateSpecializationKind()) &&
   !getDiagnostics().isIgnored(diag::warn_missing_variable_declarations,
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -123,6 +123,8 @@
   template-specialization function calls.
 - Clang contexpr evaluator now displays notes as well as an error when a 
constructor
   of a base class is not called in the constructor of its derived class.
+- Clang no longer emits ``-Wmissing-variable-declarations`` for variables 
declared
+  with the ``register`` storage class.
 
 Bug Fixes in This Version
 -


Index: clang/test/Sema/warn-missing-variable-declarations-register.c
===
--- /dev/null
+++ clang/test/Sema/warn-missing-variable-declarations-register.c
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -Wmissing-variable-declarations -fsyntax-only -verify %s
+// expected-no-diagnostics
+
+register unsigned long current_stack_pointer asm("rsp");
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -14144,6 +14144,7 @@
   var->getDeclContext()->getRedeclContext()->isFileContext() &&
   var->isExternallyVisible() && var->hasLinkage() &&
   !var->isInline() && !var->getDescribedVarTemplate() &&
+  var->getStorageClass() != SC_Register &&
   !isa(var) &&
   !isTemplateInstantiation(var->getTemplateSpecializationKind()) &&
   !getDiagnostics().isIgnored(diag::warn_missing_variable_declarations,
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -123,6 +123,8 @@
   template-specialization function calls.
 - Clang contexpr evaluator now displays notes as well as an error when a constructor
   of a base class is not called in the constructor of its derived class.
+- Clang no longer emits ``-Wmissing-variable-declarations`` for variables declared
+  with the ``register`` storage class.
 
 Bug Fixes in This Version
 -
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D157428: [clang-tidy] `readability-implicit-bool-conversion.AllowIntegerConditions` ignores `DoStmt`s

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

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157428

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


[PATCH] D157384: [clang] Added Attr::getVariety function

2023-08-08 Thread Timo Stripf via Phabricator via cfe-commits
strimo378 abandoned this revision.
strimo378 added a comment.

@aaron.ballman Thank you for the information. Strange that I missed that ... I 
even used the function somewhere else o_O


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157384

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


[PATCH] D157331: [clang] Implement C23

2023-08-08 Thread Elliott Hughes via Phabricator via cfe-commits
enh added inline comments.



Comment at: clang/lib/Headers/stdckdint.h:13
+
+#if defined(__GNUC__)
+#define ckd_add(R, A, B) __builtin_add_overflow((A), (B), (R))

hiraditya wrote:
> xbolva00 wrote:
> > yabinc wrote:
> > > enh wrote:
> > > > enh wrote:
> > > > > enh wrote:
> > > > > > ZijunZhao wrote:
> > > > > > > enh wrote:
> > > > > > > > is this ever _not_ set for clang?
> > > > > > > https://github.com/llvm/llvm-project/blob/main/clang/lib/Headers/stdbool.h#L23
> > > > > > > I think it is set?
> > > > > > i get an error from
> > > > > > ```
> > > > > > /tmp$ cat x.c
> > > > > > #if defined(__GNUC__)
> > > > > > #error foo
> > > > > > #endif
> > > > > > ```
> > > > > > regardless of whether i compile with -std=c11 or -std=gnu11.
> > > > > > neither -ansi nor -pedantic seem to stop it either.
> > > > > it does look like it _should_ be possible to not have it set though? 
> > > > > llvm/llvm-project/clang/lib/Frontend/InitPreprocessor.cpp has:
> > > > > ```
> > > > >   if (LangOpts.GNUCVersion != 0) {
> > > > > // Major, minor, patch, are given two decimal places each, so 
> > > > > 4.2.1 becomes
> > > > > // 40201.
> > > > > unsigned GNUCMajor = LangOpts.GNUCVersion / 100 / 100;
> > > > > unsigned GNUCMinor = LangOpts.GNUCVersion / 100 % 100;
> > > > > unsigned GNUCPatch = LangOpts.GNUCVersion % 100;
> > > > > Builder.defineMacro("__GNUC__", Twine(GNUCMajor));
> > > > > Builder.defineMacro("__GNUC_MINOR__", Twine(GNUCMinor));
> > > > > Builder.defineMacro("__GNUC_PATCHLEVEL__", Twine(GNUCPatch));
> > > > > Builder.defineMacro("__GXX_ABI_VERSION", "1002");
> > > > > 
> > > > > if (LangOpts.CPlusPlus) {
> > > > >   Builder.defineMacro("__GNUG__", Twine(GNUCMajor));
> > > > >   Builder.defineMacro("__GXX_WEAK__");
> > > > > }
> > > > >   }
> > > > > ```
> > > > /me wonders whether the right test here is actually `#if 
> > > > __has_feature(__builtin_add_overflow)` (etc)...
> > > > 
> > > > but at this point, you definitely need an llvm person :-)
> > > From 
> > > https://clang.llvm.org/docs/LanguageExtensions.html#checked-arithmetic-builtins,
> > >  we can check them with
> > >  __has_builtin(__builtin_add_overflow) && 
> > > __has_builtin(__builtin_sub_overflow) && 
> > > __has_builtin(__builtin_mul_overflow).
> > > I saw some code also checks if __GNUC__ >= 5:
> > > 
> > > // The __GNUC__ checks can not be removed until we depend on GCC >= 10.1
> > > // which is the first version that returns true for 
> > > __has_builtin(__builtin_add_overflow)
> > > #if __GNUC__ >= 5 || __has_builtin(__builtin_add_overflow)
> > > 
> > > I guess we don't need to support real gcc using this header here. So 
> > > maybe only checking __has_builtin is enough?
> > > 
> > > By the way, if __builtin_add_overflow may not appear on some targets, do 
> > > we need to modify tests to specify triple like "-triple 
> > > "x86_64-unknown-unknown"" in 
> > > https://github.com/llvm/llvm-project/blob/main/clang/test/CodeGen/builtins-overflow.c#L5
> > >  ?
> > > 
> > #ifndef __has_builtin // Optional of course.
> >   #define __has_builtin(x) 0  // Compatibility with non-clang compilers.
> > #endif
> > 
> > ...
> > #if __has_builtin(__builtin_trap)
> >   __builtin_trap();
> > #else
> >   abort();
> > #endif
> > /me wonders whether the right test here is actually #if 
> > __has_feature(__builtin_add_overflow) (etc)...
> 
> i think that should be added.
> 
> I guess we also need a with `__STDC_VERSION__ > 202000L`? in princple we'd 
> have a C23 number for it but i'm not sure if that has been added to clang yet.
> i think that should be added.

i was advising the opposite --- now this is a standard C23 feature, any 
architectures where __builtin_*_overflow doesn't work need to be found and 
fixed. and we'll do that quicker if we unconditionally expose these and (more 
importantly!) run the tests.

> I guess we also need a with __STDC_VERSION__ > 202000L?

_personally_ i think that's silly because you can't hide the header file, so it 
doesn't make any sense to just have it empty if someone's actually #included 
it. we don't do this anywhere in bionic for example, for this reason. but 
obviously that's an llvm decision, and it does look like the other similar 
headers _do_ have this check, so, yeah, probably.



Comment at: clang/test/Headers/stdckdint.cpp:1
+// RUN: %clang_cc1 -emit-llvm -fgnuc-version=4.2.1 -std=gnu++11 %s -o - | 
FileCheck %s
+

hiraditya wrote:
> seems like we don't have a -std=gnu23, or -std=c23 standard flag for this in 
> clang yet.
> 
> https://godbolt.org/z/7dKnGEWWE
> 
> we probably need it before testing stdckdint i guess?
other headers just use > and the previous version. (though see stdalign.h if 
you're looking for some random cleanup to do!)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157331


[PATCH] D157438: [OpenMP] Ensure wrapper headers are included on both host and device

2023-08-08 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl accepted this revision.
yaxunl added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157438

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


[PATCH] D156762: [-Wunsafe-buffer-usage][NFC] Refactor `getFixIts`---where fix-its are generated

2023-08-08 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.

I see you've started to address the big comment in D157441 
, so, LGTM, thanks a lot for splitting stuff 
up!

I have one tiny stylistic nitpick.




Comment at: clang/lib/Analysis/UnsafeBufferUsage.cpp:2158-2159
+ [](const VarDecl *GrpMember) -> bool {
+   return FixItsForVariable.find(GrpMember) ==
+  FixItsForVariable.end();
+ })) {

(also indentation does a lot of heavy lifting here, maybe let's stash the 
`any_of` into a variable?)
(also we have `using namespace llvm` at the beginning of the file, so `llvm::` 
might be redundant)



Comment at: clang/lib/Analysis/UnsafeBufferUsage.cpp:2219
+  // cannot be fixed...
+  eraseVarsForUnfixableGroupMates(FixItsForVariable, VarGrpMgr);
+  // Now `FixItsForVariable` gets further reduced: a variable is in

ziqingluo-90 wrote:
> NoQ wrote:
> > NoQ wrote:
> > > Architecturally speaking, I think I just realized something confusing 
> > > about our code.
> > > 
> > > We already have variable groups well-defined at the Strategy phase, i.e. 
> > > before we call `getFixIts()`, but then `getFixIts()` continues to reason 
> > > about all variables collectively and indiscriminately. It continues to 
> > > use entities such as the `FixItsForVariable` map which contain fixits for 
> > > variables from *all* groups, not just the ones that are currently 
> > > relevant. Then it re-introduces per-group data structures such as 
> > > `ParmsNeedFixMask` on an ad-hoc basis, and it tries to compute them this 
> > > way using the global, indiscriminate data structures.
> > > 
> > > I'm starting to suspect that the code would start making a lot more sense 
> > > if we invoke `getFixIts()` separately for each variable group. So that 
> > > each such invocation produced a single collective fixit for the group, or 
> > > failed doing so.
> > > 
> > > This way we might be able to avoid sending steganographic messages 
> > > through `FixItsForVariable`, but instead say directly "these are the 
> > > variables that we're currently focusing on". It is the responsibility of 
> > > the `Strategy` class to answer "should this variable be fixed?"; we 
> > > shouldn't direct that question to any other data structures.
> > > 
> > > And if a group fails at any point, just early-return `None` and proceed 
> > > directly to the next getFixIts() invocation for the next group. We don't 
> > > need to separately record which individual variables have failed. In 
> > > particular, `eraseVarsForUnfixableGroupMates()` would become a simple 
> > > early return.
> > > 
> > > It probably also makes sense to store groups themselves inside the 
> > > `Strategy` class. After all, fixing variables together is a form of 
> > > strategy.
> > (I don't think this needs to be addressed in the current patch, but this 
> > could help us untangle the code in general.)
> This makes absolute sense!  Each group is independent for fix-it generation.  
> Moreover, when we support more strategy kinds, the constraint solving for a 
> proper strategy will also be group-based.
> the constraint solving for a proper strategy will also be group-based.

Hmm, my head-nomenclature (like head-canon but nomenclature) says that grouping 
is a sub-task of solving for strategy. I.e., we take "strategy constraints" of 
the form
```
'p' is any safe type => 'q' is any safe type
```
and solve these constraints by crawling through the implication graph.

But all the solving subtasks below grouping should probably indeed be separate!


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

https://reviews.llvm.org/D156762

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


[clang] 61709bb - [OpenMP] Ensure wrapper headers are included on both host and device

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

Author: Joseph Huber
Date: 2023-08-08T19:07:47-05:00
New Revision: 61709bbae37af4e01cf93c6d112ba984bbd9a7ea

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

LOG: [OpenMP] Ensure wrapper headers are included on both host and device

For the in-progress GPU `libc` project we are relying on overlay headers to
handle the interfacing between the `libc` project and the host `libc`.
We need this to be included on both the host and device so they agree
one what is present on the device, otherwise we will end up with random
errors. For whatever reason this was not being included on the host
although it previously worked. This patch ensures that it's included on
both.

Reviewed By: yaxunl

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/Driver/gpu-libc-headers.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index c5155735000490..1a76e6d8d76bce 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -1183,14 +1183,13 @@ void Clang::AddPreprocessingOptions(Compilation , 
const JobAction ,
   // with ones created by the 'libc' project if present.
   if (!Args.hasArg(options::OPT_nostdinc) &&
   !Args.hasArg(options::OPT_nogpuinc) &&
-  !Args.hasArg(options::OPT_nobuiltininc) &&
-  (getToolChain().getTriple().isNVPTX() ||
-   getToolChain().getTriple().isAMDGCN())) {
-
+  !Args.hasArg(options::OPT_nobuiltininc)) {
 // Without an offloading language we will include these headers directly.
 // Offloading languages will instead only use the declarations stored in
 // the resource directory at clang/lib/Headers/llvm_libc_wrappers.
-if (C.getActiveOffloadKinds() == Action::OFK_None) {
+if ((getToolChain().getTriple().isNVPTX() ||
+ getToolChain().getTriple().isAMDGCN()) &&
+C.getActiveOffloadKinds() == Action::OFK_None) {
   SmallString<128> P(llvm::sys::path::parent_path(D.InstalledDir));
   llvm::sys::path::append(P, "include");
   llvm::sys::path::append(P, "gpu-none-llvm");

diff  --git a/clang/test/Driver/gpu-libc-headers.c 
b/clang/test/Driver/gpu-libc-headers.c
index c6361b4b892d39..74e9a764dfcb35 100644
--- a/clang/test/Driver/gpu-libc-headers.c
+++ b/clang/test/Driver/gpu-libc-headers.c
@@ -8,6 +8,7 @@
 // RUN: -fopenmp-targets=nvptx64-nvidia-cuda 
-Xopenmp-target=nvptx64-nvidia-cuda --offload-arch=sm_70  \
 // RUN: -nogpulib %s 2>&1 | FileCheck %s --check-prefix=CHECK-HEADERS
 // CHECK-HEADERS: "-cc1"{{.*}}"-internal-isystem" 
"{{.*}}include{{.*}}llvm_libc_wrappers"{{.*}}"-isysroot" "./"
+// CHECK-HEADERS: "-cc1"{{.*}}"-internal-isystem" 
"{{.*}}include{{.*}}llvm_libc_wrappers"{{.*}}"-isysroot" "./"
 
 // RUN:   %clang -### --target=amdgcn-amd-amdhsa -mcpu=gfx1030 -nogpulib \
 // RUN: -nogpuinc %s 2>&1 | FileCheck %s 
--check-prefix=CHECK-HEADERS-DISABLED



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


[PATCH] D157438: [OpenMP] Ensure wrapper headers are included on both host and device

2023-08-08 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 rG61709bbae37a: [OpenMP] Ensure wrapper headers are included 
on both host and device (authored by jhuber6).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157438

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/gpu-libc-headers.c


Index: clang/test/Driver/gpu-libc-headers.c
===
--- clang/test/Driver/gpu-libc-headers.c
+++ clang/test/Driver/gpu-libc-headers.c
@@ -8,6 +8,7 @@
 // RUN: -fopenmp-targets=nvptx64-nvidia-cuda 
-Xopenmp-target=nvptx64-nvidia-cuda --offload-arch=sm_70  \
 // RUN: -nogpulib %s 2>&1 | FileCheck %s --check-prefix=CHECK-HEADERS
 // CHECK-HEADERS: "-cc1"{{.*}}"-internal-isystem" 
"{{.*}}include{{.*}}llvm_libc_wrappers"{{.*}}"-isysroot" "./"
+// CHECK-HEADERS: "-cc1"{{.*}}"-internal-isystem" 
"{{.*}}include{{.*}}llvm_libc_wrappers"{{.*}}"-isysroot" "./"
 
 // RUN:   %clang -### --target=amdgcn-amd-amdhsa -mcpu=gfx1030 -nogpulib \
 // RUN: -nogpuinc %s 2>&1 | FileCheck %s 
--check-prefix=CHECK-HEADERS-DISABLED
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -1183,14 +1183,13 @@
   // with ones created by the 'libc' project if present.
   if (!Args.hasArg(options::OPT_nostdinc) &&
   !Args.hasArg(options::OPT_nogpuinc) &&
-  !Args.hasArg(options::OPT_nobuiltininc) &&
-  (getToolChain().getTriple().isNVPTX() ||
-   getToolChain().getTriple().isAMDGCN())) {
-
+  !Args.hasArg(options::OPT_nobuiltininc)) {
 // Without an offloading language we will include these headers directly.
 // Offloading languages will instead only use the declarations stored in
 // the resource directory at clang/lib/Headers/llvm_libc_wrappers.
-if (C.getActiveOffloadKinds() == Action::OFK_None) {
+if ((getToolChain().getTriple().isNVPTX() ||
+ getToolChain().getTriple().isAMDGCN()) &&
+C.getActiveOffloadKinds() == Action::OFK_None) {
   SmallString<128> P(llvm::sys::path::parent_path(D.InstalledDir));
   llvm::sys::path::append(P, "include");
   llvm::sys::path::append(P, "gpu-none-llvm");


Index: clang/test/Driver/gpu-libc-headers.c
===
--- clang/test/Driver/gpu-libc-headers.c
+++ clang/test/Driver/gpu-libc-headers.c
@@ -8,6 +8,7 @@
 // RUN: -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target=nvptx64-nvidia-cuda --offload-arch=sm_70  \
 // RUN: -nogpulib %s 2>&1 | FileCheck %s --check-prefix=CHECK-HEADERS
 // CHECK-HEADERS: "-cc1"{{.*}}"-internal-isystem" "{{.*}}include{{.*}}llvm_libc_wrappers"{{.*}}"-isysroot" "./"
+// CHECK-HEADERS: "-cc1"{{.*}}"-internal-isystem" "{{.*}}include{{.*}}llvm_libc_wrappers"{{.*}}"-isysroot" "./"
 
 // RUN:   %clang -### --target=amdgcn-amd-amdhsa -mcpu=gfx1030 -nogpulib \
 // RUN: -nogpuinc %s 2>&1 | FileCheck %s --check-prefix=CHECK-HEADERS-DISABLED
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -1183,14 +1183,13 @@
   // with ones created by the 'libc' project if present.
   if (!Args.hasArg(options::OPT_nostdinc) &&
   !Args.hasArg(options::OPT_nogpuinc) &&
-  !Args.hasArg(options::OPT_nobuiltininc) &&
-  (getToolChain().getTriple().isNVPTX() ||
-   getToolChain().getTriple().isAMDGCN())) {
-
+  !Args.hasArg(options::OPT_nobuiltininc)) {
 // Without an offloading language we will include these headers directly.
 // Offloading languages will instead only use the declarations stored in
 // the resource directory at clang/lib/Headers/llvm_libc_wrappers.
-if (C.getActiveOffloadKinds() == Action::OFK_None) {
+if ((getToolChain().getTriple().isNVPTX() ||
+ getToolChain().getTriple().isAMDGCN()) &&
+C.getActiveOffloadKinds() == Action::OFK_None) {
   SmallString<128> P(llvm::sys::path::parent_path(D.InstalledDir));
   llvm::sys::path::append(P, "include");
   llvm::sys::path::append(P, "gpu-none-llvm");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D157410: [Flang] Enable Rpass flag

2023-08-08 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/lib/Driver/ToolChains/Flang.cpp:521
 
+  // -R[no-]group[=regexp] and -R[no-]everything flags
+  Args.AddAllArgs(CmdArgs, options::OPT_R_Group);

These are options, not flags (boolean).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157410

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


[clang] adb76c3 - [RISCV] Add missing REQUIRES for zvk-invalid.c test

2023-08-08 Thread via cfe-commits

Author: 4vtomat
Date: 2023-08-08T18:45:37-07:00
New Revision: adb76c31ec42a12690ae0c86edd368f7f066480d

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

LOG: [RISCV] Add missing REQUIRES for zvk-invalid.c test

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

Added: 


Modified: 
clang/test/Sema/zvk-invalid.c

Removed: 




diff  --git a/clang/test/Sema/zvk-invalid.c b/clang/test/Sema/zvk-invalid.c
index 14325424f04c8a..13e505d5201b52 100644
--- a/clang/test/Sema/zvk-invalid.c
+++ b/clang/test/Sema/zvk-invalid.c
@@ -1,3 +1,4 @@
+// REQUIRES: riscv-registered-target
 // RUN: %clang_cc1 -triple riscv64 -target-feature +v %s -fsyntax-only -verify
 
 #include 



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


[PATCH] D157467: [RISCV] Add missing REQUIRES for zvk-invalid.c test

2023-08-08 Thread Brandon Wu via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGadb76c31ec42: [RISCV] Add missing REQUIRES for zvk-invalid.c 
test (authored by 4vtomat).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157467

Files:
  clang/test/Sema/zvk-invalid.c


Index: clang/test/Sema/zvk-invalid.c
===
--- clang/test/Sema/zvk-invalid.c
+++ clang/test/Sema/zvk-invalid.c
@@ -1,3 +1,4 @@
+// REQUIRES: riscv-registered-target
 // RUN: %clang_cc1 -triple riscv64 -target-feature +v %s -fsyntax-only -verify
 
 #include 


Index: clang/test/Sema/zvk-invalid.c
===
--- clang/test/Sema/zvk-invalid.c
+++ clang/test/Sema/zvk-invalid.c
@@ -1,3 +1,4 @@
+// REQUIRES: riscv-registered-target
 // RUN: %clang_cc1 -triple riscv64 -target-feature +v %s -fsyntax-only -verify
 
 #include 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] f62c925 - [LoongArch] Support -march=native and -mtune=

2023-08-08 Thread Weining Lu via cfe-commits

Author: Weining Lu
Date: 2023-08-09T10:29:50+08:00
New Revision: f62c9252fc0f1fa0a0f02033659db052c2202a4c

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

LOG: [LoongArch] Support -march=native and -mtune=

As described in [1][2], `-mtune=` is used to select the type of target
microarchitecture, defaults to the value of `-march`. The set of
possible values should be a superset of `-march` values. Currently
possible values of `-march=` and `-mtune=` are `native`, `loongarch64`
and `la464`.

D136146 has supported `-march={loongarch64,la464}` and this patch adds
support for `-march=native` and `-mtune=`.

A new ProcessorModel called `loongarch64` is defined in LoongArch.td
to support `-mtune=loongarch64`.

`llvm::sys::getHostCPUName()` returns `generic` on unknown or future
LoongArch CPUs, e.g. the not yet added `la664`, leading to
`llvm::LoongArch::isValidArchName()` failing to parse the arch name.
In this case, use `loongarch64` as the default arch name for 64-bit
CPUs.

Two preprocessor macros are defined based on user-provided `-march=`
and `-mtune=` options and the defaults.
- __loongarch_arch
- __loongarch_tune
Note that, to work with `-fno-integrated-cc1` we leverage cc1 options
`-target-cpu` and `-tune-cpu` to pass driver options `-march=` and
`-mtune=` respectively because cc1 needs these information to define
macros in `LoongArchTargetInfo::getTargetDefines`.

[1]: 
https://github.com/loongson/LoongArch-Documentation/blob/2023.04.20/docs/LoongArch-toolchain-conventions-EN.adoc
[2]: 
https://github.com/loongson/la-softdev-convention/blob/v0.1/la-softdev-convention.adoc

Reviewed By: xen0n, wangleiat, steven_wu, MaskRay

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

Added: 
clang/test/Driver/loongarch-mtune.c
llvm/test/CodeGen/LoongArch/cpus-invalid.ll
llvm/test/CodeGen/LoongArch/cpus.ll

Modified: 
clang/lib/Basic/Targets/LoongArch.cpp
clang/lib/Basic/Targets/LoongArch.h
clang/lib/Driver/ToolChains/Arch/LoongArch.cpp
clang/lib/Driver/ToolChains/Arch/LoongArch.h
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/test/Driver/loongarch-march-error.c
clang/test/Driver/loongarch-march.c
clang/test/Preprocessor/init-loongarch.c
llvm/include/llvm/TargetParser/LoongArchTargetParser.h
llvm/lib/Target/LoongArch/LoongArch.td
llvm/lib/TargetParser/LoongArchTargetParser.cpp

Removed: 




diff  --git a/clang/lib/Basic/Targets/LoongArch.cpp 
b/clang/lib/Basic/Targets/LoongArch.cpp
index 6958479cd7c42d..4448a2ae10a172 100644
--- a/clang/lib/Basic/Targets/LoongArch.cpp
+++ b/clang/lib/Basic/Targets/LoongArch.cpp
@@ -15,7 +15,7 @@
 #include "clang/Basic/MacroBuilder.h"
 #include "clang/Basic/TargetBuiltins.h"
 #include "llvm/Support/raw_ostream.h"
-#include "llvm/TargetParser/TargetParser.h"
+#include "llvm/TargetParser/LoongArchTargetParser.h"
 
 using namespace clang;
 using namespace clang::targets;
@@ -198,7 +198,15 @@ void LoongArchTargetInfo::getTargetDefines(const 
LangOptions ,
   else
 Builder.defineMacro("__loongarch_frlen", "0");
 
-  // TODO: define __loongarch_arch and __loongarch_tune.
+  // Define __loongarch_arch.
+  StringRef ArchName = getCPU();
+  Builder.defineMacro("__loongarch_arch", Twine('"') + ArchName + Twine('"'));
+
+  // Define __loongarch_tune.
+  StringRef TuneCPU = getTargetOpts().TuneCPU;
+  if (TuneCPU.empty())
+TuneCPU = ArchName;
+  Builder.defineMacro("__loongarch_tune", Twine('"') + TuneCPU + Twine('"'));
 
   StringRef ABI = getABI();
   if (ABI == "lp64d" || ABI == "lp64f" || ABI == "lp64s")
@@ -270,3 +278,12 @@ bool LoongArchTargetInfo::handleTargetFeatures(
   }
   return true;
 }
+
+bool LoongArchTargetInfo::isValidCPUName(StringRef Name) const {
+  return llvm::LoongArch::isValidCPUName(Name);
+}
+
+void LoongArchTargetInfo::fillValidCPUList(
+SmallVectorImpl ) const {
+  llvm::LoongArch::fillValidCPUList(Values);
+}

diff  --git a/clang/lib/Basic/Targets/LoongArch.h 
b/clang/lib/Basic/Targets/LoongArch.h
index 52c4ce4253689e..34143f462a2472 100644
--- a/clang/lib/Basic/Targets/LoongArch.h
+++ b/clang/lib/Basic/Targets/LoongArch.h
@@ -24,6 +24,7 @@ namespace targets {
 class LLVM_LIBRARY_VISIBILITY LoongArchTargetInfo : public TargetInfo {
 protected:
   std::string ABI;
+  std::string CPU;
   bool HasFeatureD;
   bool HasFeatureF;
 
@@ -40,6 +41,15 @@ class LLVM_LIBRARY_VISIBILITY LoongArchTargetInfo : public 
TargetInfo {
 WIntType = UnsignedInt;
   }
 
+  bool setCPU(const std::string ) override {
+if (!isValidCPUName(Name))
+  return false;
+CPU = Name;
+return true;
+  }
+
+  StringRef getCPU() const { return CPU; }
+
   StringRef getABI() const override { return ABI; }
 
   void getTargetDefines(const 

[PATCH] D155824: [LoongArch] Support -march=native and -mtune=

2023-08-08 Thread Lu Weining via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
SixWeining marked an inline comment as done.
Closed by commit rGf62c9252fc0f: [LoongArch] Support -march=native and -mtune= 
(authored by SixWeining).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155824

Files:
  clang/lib/Basic/Targets/LoongArch.cpp
  clang/lib/Basic/Targets/LoongArch.h
  clang/lib/Driver/ToolChains/Arch/LoongArch.cpp
  clang/lib/Driver/ToolChains/Arch/LoongArch.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/loongarch-march-error.c
  clang/test/Driver/loongarch-march.c
  clang/test/Driver/loongarch-mtune.c
  clang/test/Preprocessor/init-loongarch.c
  llvm/include/llvm/TargetParser/LoongArchTargetParser.h
  llvm/lib/Target/LoongArch/LoongArch.td
  llvm/lib/TargetParser/LoongArchTargetParser.cpp
  llvm/test/CodeGen/LoongArch/cpus-invalid.ll
  llvm/test/CodeGen/LoongArch/cpus.ll

Index: llvm/test/CodeGen/LoongArch/cpus.ll
===
--- /dev/null
+++ llvm/test/CodeGen/LoongArch/cpus.ll
@@ -0,0 +1,20 @@
+;; This tests that llc accepts all valid LoongArch CPUs.
+;; Note the 'generic' names have been tested in cpu-name-generic.ll.
+
+; RUN: llc < %s --mtriple=loongarch64 --mcpu=loongarch64 2>&1 | FileCheck %s
+; RUN: llc < %s --mtriple=loongarch64 --mcpu=la464 2>&1 | FileCheck %s
+; RUN: llc < %s --mtriple=loongarch64 2>&1 | FileCheck %s
+
+; CHECK-NOT: {{.*}} is not a recognized processor for this target
+
+define void @f() {
+  ret void
+}
+
+define void @tune_cpu_loongarch64() "tune-cpu"="loongarch64" {
+  ret void
+}
+
+define void @tune_cpu_la464() "tune-cpu"="la464" {
+  ret void
+}
Index: llvm/test/CodeGen/LoongArch/cpus-invalid.ll
===
--- /dev/null
+++ llvm/test/CodeGen/LoongArch/cpus-invalid.ll
@@ -0,0 +1,7 @@
+; RUN: llc < %s --mtriple=loongarch64 --mattr=+64bit --mcpu=invalidcpu 2>&1 | FileCheck %s
+
+; CHECK: {{.*}} is not a recognized processor for this target
+
+define void @f() {
+  ret void
+}
Index: llvm/lib/TargetParser/LoongArchTargetParser.cpp
===
--- llvm/lib/TargetParser/LoongArchTargetParser.cpp
+++ llvm/lib/TargetParser/LoongArchTargetParser.cpp
@@ -46,3 +46,15 @@
   }
   return false;
 }
+
+bool LoongArch::isValidCPUName(StringRef Name) { return isValidArchName(Name); }
+
+void LoongArch::fillValidCPUList(SmallVectorImpl ) {
+  for (const auto A : AllArchs)
+Values.emplace_back(A.Name);
+}
+
+StringRef LoongArch::getDefaultArch(bool Is64Bit) {
+  // TODO: use a real 32-bit arch name.
+  return Is64Bit ? "loongarch64" : "";
+}
Index: llvm/lib/Target/LoongArch/LoongArch.td
===
--- llvm/lib/Target/LoongArch/LoongArch.td
+++ llvm/lib/Target/LoongArch/LoongArch.td
@@ -117,6 +117,11 @@
 def : ProcessorModel<"generic-la32", NoSchedModel, [Feature32Bit]>;
 def : ProcessorModel<"generic-la64", NoSchedModel, [Feature64Bit, FeatureUAL]>;
 
+// Generic 64-bit processor with double-precision floating-point support.
+def : ProcessorModel<"loongarch64", NoSchedModel, [Feature64Bit,
+   FeatureUAL,
+   FeatureBasicD]>;
+
 // Support generic for compatibility with other targets. The triple will be used
 // to change to the appropriate la32/la64 version.
 def : ProcessorModel<"generic", NoSchedModel, []>;
Index: llvm/include/llvm/TargetParser/LoongArchTargetParser.h
===
--- llvm/include/llvm/TargetParser/LoongArchTargetParser.h
+++ llvm/include/llvm/TargetParser/LoongArchTargetParser.h
@@ -66,9 +66,12 @@
 
 bool isValidArchName(StringRef Arch);
 bool getArchFeatures(StringRef Arch, std::vector );
+bool isValidCPUName(StringRef TuneCPU);
+void fillValidCPUList(SmallVectorImpl );
+StringRef getDefaultArch(bool Is64Bit);
 
 } // namespace LoongArch
 
 } // namespace llvm
 
-#endif // LLVM_SUPPORT_LOONGARCHTARGETPARSER_H
+#endif // LLVM_TARGETPARSER_LOONGARCHTARGETPARSER_H
Index: clang/test/Preprocessor/init-loongarch.c
===
--- clang/test/Preprocessor/init-loongarch.c
+++ clang/test/Preprocessor/init-loongarch.c
@@ -787,3 +787,23 @@
 // LA64-FPU0-LP64S: #define __loongarch_lp64 1
 // LA64-FPU0-LP64S-NOT: #define __loongarch_single_float
 // LA64-FPU0-LP64S: #define __loongarch_soft_float 1
+
+/// Check __loongarch_arch and __loongarch_tune.
+
+// RUN: %clang --target=loongarch64 -x c -E -dM %s -o - | \
+// RUN:   FileCheck --match-full-lines --check-prefix=ARCH-TUNE -DARCH=loongarch64 -DTUNE=loongarch64 %s
+// RUN: %clang --target=loongarch64 -x c -E 

[clang-tools-extra] ebb0a21 - [GlobPattern] Update invalid glob pattern diagnostic for unmatched '['

2023-08-08 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2023-08-08T20:25:10-07:00
New Revision: ebb0a210995dcf69d9696f8e14629e1378e63a21

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

LOG: [GlobPattern] Update invalid glob pattern diagnostic for unmatched '['

Update this diagnostic to mention the reason (unmatched '['), matching
the other diagnostic about stray '\'. The original pattern is omitted,
as some users may mention the original pattern in another position, not
repeating it.

Added: 


Modified: 
clang-tools-extra/test/pp-trace/pp-trace-filter.cpp
lld/Common/Strings.cpp
lld/ELF/Driver.cpp
lld/test/ELF/dead-reloc-in-nonalloc.s
lld/test/ELF/remap-inputs.test
lld/test/ELF/shuffle-sections.s
lld/test/ELF/undefined-glob.s
lld/test/ELF/version-script-complex-wildcards.s
lld/test/ELF/warn-backrefs.s
llvm/lib/Support/GlobPattern.cpp
llvm/test/tools/llvm-ifs/exclude.test
llvm/test/tools/llvm-objcopy/ELF/wildcard-syntax.test

Removed: 




diff  --git a/clang-tools-extra/test/pp-trace/pp-trace-filter.cpp 
b/clang-tools-extra/test/pp-trace/pp-trace-filter.cpp
index 1cd2ce7ef14d73..8f090ab0bb79aa 100644
--- a/clang-tools-extra/test/pp-trace/pp-trace-filter.cpp
+++ b/clang-tools-extra/test/pp-trace/pp-trace-filter.cpp
@@ -14,4 +14,4 @@ int i = M;
 // CHECK-NOT:  - Callback: EndOfMainFile
 // CHECK:  ...
 
-// INVALID: error: invalid glob pattern: [
+// INVALID: error: invalid glob pattern, unmatched '['

diff  --git a/lld/Common/Strings.cpp b/lld/Common/Strings.cpp
index db22c06eb17e28..41cbbf36f38cb0 100644
--- a/lld/Common/Strings.cpp
+++ b/lld/Common/Strings.cpp
@@ -27,7 +27,7 @@ SingleStringMatcher::SingleStringMatcher(StringRef Pattern) {
   } else {
 Expected Glob = GlobPattern::create(Pattern);
 if (!Glob) {
-  error(toString(Glob.takeError()));
+  error(toString(Glob.takeError()) + ": " + Pattern);
   return;
 }
 ExactMatch = false;

diff  --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp
index 8ce2f481f2df6d..1759598b6d9705 100644
--- a/lld/ELF/Driver.cpp
+++ b/lld/ELF/Driver.cpp
@@ -1114,7 +1114,7 @@ static bool remapInputs(StringRef line, const Twine 
) {
   else if (Expected pat = GlobPattern::create(fields[0]))
 config->remapInputsWildcards.emplace_back(std::move(*pat), fields[1]);
   else {
-error(location + ": " + toString(pat.takeError()));
+error(location + ": " + toString(pat.takeError()) + ": " + fields[0]);
 return true;
   }
   return false;
@@ -1415,7 +1415,7 @@ static void readConfigs(opt::InputArgList ) {
 else if (Expected pat = GlobPattern::create(kv.first))
   config->shuffleSections.emplace_back(std::move(*pat), uint32_t(v));
 else
-  error(errPrefix + toString(pat.takeError()));
+  error(errPrefix + toString(pat.takeError()) + ": " + kv.first);
   }
 
   auto reports = {std::make_pair("bti-report", >zBtiReport),
@@ -1453,7 +1453,7 @@ static void readConfigs(opt::InputArgList ) {
 else if (Expected pat = GlobPattern::create(kv.first))
   config->deadRelocInNonAlloc.emplace_back(std::move(*pat), v);
 else
-  error(errPrefix + toString(pat.takeError()));
+  error(errPrefix + toString(pat.takeError()) + ": " + kv.first);
   }
 
   cl::ResetAllOptionOccurrences();
@@ -1610,7 +1610,8 @@ static void readConfigs(opt::InputArgList ) {
 if (Expected pat = GlobPattern::create(pattern))
   config->warnBackrefsExclude.push_back(std::move(*pat));
 else
-  error(arg->getSpelling() + ": " + toString(pat.takeError()));
+  error(arg->getSpelling() + ": " + toString(pat.takeError()) + ": " +
+pattern);
   }
 
   // For -no-pie and -pie, --export-dynamic-symbol specifies defined symbols
@@ -1968,7 +1969,7 @@ static void handleUndefined(Symbol *sym, const char 
*option) {
 static void handleUndefinedGlob(StringRef arg) {
   Expected pat = GlobPattern::create(arg);
   if (!pat) {
-error("--undefined-glob: " + toString(pat.takeError()));
+error("--undefined-glob: " + toString(pat.takeError()) + ": " + arg);
 return;
   }
 

diff  --git a/lld/test/ELF/dead-reloc-in-nonalloc.s 
b/lld/test/ELF/dead-reloc-in-nonalloc.s
index 9e93a0cf32afdd..3857ead6e55d01 100644
--- a/lld/test/ELF/dead-reloc-in-nonalloc.s
+++ b/lld/test/ELF/dead-reloc-in-nonalloc.s
@@ -46,7 +46,7 @@
 
 # RUN: not ld.lld -z dead-reloc-in-nonalloc='['=0 2>&1 | FileCheck %s 
--check-prefix=INVALID
 
-# INVALID: error: -z dead-reloc-in-nonalloc=: invalid glob pattern: [
+# INVALID: error: -z dead-reloc-in-nonalloc=: invalid glob pattern, unmatched 
'[': [
 
 .globl _start
 _start:

diff  --git a/lld/test/ELF/remap-inputs.test b/lld/test/ELF/remap-inputs.test
index 8a2d2e98910649..0f9cafa987ac9e 100644
--- a/lld/test/ELF/remap-inputs.test
+++ 

[PATCH] D155387: [Clang] Fix member lookup so that we don't ignore ambiguous lookups in some cases

2023-08-08 Thread James Y Knight via Phabricator via cfe-commits
jyknight added a comment.

In D155387#4557834 , @hctim wrote:

> I found an issue with building Android using this patch. I've reduced it down 
> to the following problem where the evaluation of the `std::visit` is believed 
> to be non-exhaustive, but it seems like it is? Would you mind taking a look? 
> Admittedly, my knowledge in this area of the cxx stdlib is not so great.

Your example code is invalid, and Clang is now correctly diagnosing that. You 
can fix the problem by adding `using V::operator()...;` inside `struct Visitor`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155387

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


[PATCH] D157429: [NFC] [Clang] Fix static analyzer concern

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

LGTM with a small formatting nit.




Comment at: clang/lib/Analysis/BodyFarm.cpp:809
 Prop = MD->findPropertyDecl();
-IVar = findBackingIvar(Prop);
+IVar = Prop? findBackingIvar(Prop) : nullptr;
   }

Formatting.


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

https://reviews.llvm.org/D157429

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


[PATCH] D157429: [NFC] [Clang] Fix static analyzer concern

2023-08-08 Thread Elizabeth Andrews via Phabricator via cfe-commits
eandrews added a comment.

In D157429#4570540 , @aaron.ballman 
wrote:

> LGTM with a small formatting nit.

Thanks for the review! I committed the patch after fixing the formatting


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157429

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


[PATCH] D155850: [Clang][CodeGen][RFC] Add codegen support for C++ Parallel Algorithm Offload

2023-08-08 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl accepted this revision.
yaxunl added a comment.

LGTM from HIP side. Thanks.


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

https://reviews.llvm.org/D155850

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


[PATCH] D157201: [Clang] Support qualified name as member designator in offsetof

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

Thank you for working on this!




Comment at: clang/docs/ReleaseNotes.rst:59
 
+- Improved `__builtin_offsetof` support, allowing qualified name in member 
designator.
 

You should also link to https://github.com/llvm/llvm-project/issues/64154 here 
to tie it back to a bug report.



Comment at: clang/include/clang/Sema/Sema.h:6038
 SourceLocation LocStart, LocEnd;
 bool isBrackets;  // true if [expr], false if .ident
+bool isQualifier;

I think we should combine `isBrackets` and `isQualifier` since a component 
can't be both at the same time anyway. e.g.,
```
enum {
  Brackets,   // U.E is valid
  Identifier, // U.IdentInfo is valid
  Qualifier,  // Nothing in U is valid
} Kind;
```



Comment at: clang/test/Sema/offsetof.c:77-79
+struct X2 { int a; };
+int x2[__builtin_offsetof(struct X2, X2::a) == 0 ? 1 : -1];
+int x3[__builtin_offsetof(struct X2, X2::X2) == 0 ? 1 : -1]; // 
expected-error{{no member named 'X2'}}

Neither of these should be valid in C -- there is no way to name subobjects in 
C like there is in C++.



Comment at: clang/test/SemaCXX/offsetof.cpp:104
+struct X2 { int a; static int static_a; };
+int x2[__builtin_offsetof(struct X2, X2::static_a) == 0 ? 1 : -1]; // 
expected-error{{no member named 'static_a'}}

It'd be good to add the `int x2[__builtin_offsetof(struct X2, X2::a) == 0 ? 1 : 
-1];` test here from the C test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157201

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


[PATCH] D157441: [-Wunsafe-buffer-usage] Use `Strategy` to determine whether to fix a parameter

2023-08-08 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 added inline comments.



Comment at: clang/lib/Analysis/UnsafeBufferUsage.cpp:1624
 // Inserts the [0]
-std::optional EndOfOperand =
-getEndCharLoc(BaseDeclRefExpr, SM, Ctx.getLangOpts());
-if (EndOfOperand) {
+if (auto LocPastOperand =
+getPastLoc(BaseDeclRefExpr, SM, Ctx.getLangOpts())) {

NFC.  Just noticed that `getPastLoc` is the better function to call here.



Comment at: clang/lib/Analysis/UnsafeBufferUsage.cpp:2719
+  Strategy NaiveStrategy = getNaiveStrategy(
+  llvm::make_range(VisitedVars.begin(), VisitedVars.end()));
   VariableGroupsManagerImpl VarGrpMgr(Groups, VarGrpMap, GrpsUnionForParms);

`VisitedVars` are the set of variables on the computed graph.  The previous 
`UnsafeVars` is a superset of it, including safe variables that have 
`FixableGadget`s discovered.  We do not want to assign strategies other than 
`Won't fix` to those safe variables.



Comment at: 
clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-multi-parm-span.cpp:31
 
-  b = a;
+  b = a;// CHECK-NOT: fix-it:{{.*}}:{[[@LINE]]
   b[5] = 5; // expected-note{{used in buffer access here}}

Both `b` and `a` will be changed to have `std::span` type.  So this assignment 
needs no fix-it. Same reason applies to similar changes in the rest of this 
test file.



Comment at: 
clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-multi-parm-span.cpp:83
+  x = p;  // CHECK-NOT: fix-it:{{.*}}:{[[@LINE]]
+  y = x;  // CHECK: fix-it:{{.*}}:{[[@LINE]]:8-[[@LINE]]:8}:".data()"
   // `x` needs to be fixed so does the pointer assigned to `x`, i.e.,`p`

`y` does not have to be changed to a safe-type while `x` does.  So we need to 
fix this assignment.   Same reason applies to similar changes in the rest of 
this test file.



Comment at: 
clang/test/SemaCXX/warn-unsafe-buffer-usage-multi-decl-ptr-init.cpp:29
+  int *p = q;  // expected-warning{{'p' is an unsafe pointer used for buffer 
access}} \
+ expected-note{{change type of 'p' to 'std::span' to preserve 
bounds information, and change 'q' to 'std::span' to propagate bounds 
information between them}}
   p[5] = 10;  // expected-note{{used in buffer access here}}

We now support to fix ` int *r = q`.  So all the unsafe variables can be fixed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157441

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


[PATCH] D157445: [CodeGen][UBSan] getUBSanFunctionTypeHash does not handle the attributed function case correctly, leading to an assertion failure. This patch desugars the QualType if it is of Attribu

2023-08-08 Thread Usama Hameed via Phabricator via cfe-commits
usama54321 created this revision.
Herald added a project: All.
usama54321 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

rdar://113144087


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D157445

Files:
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/test/CodeGen/ubsan-function-attributed.c


Index: clang/test/CodeGen/ubsan-function-attributed.c
===
--- /dev/null
+++ clang/test/CodeGen/ubsan-function-attributed.c
@@ -0,0 +1,3 @@
+// RUN: %clang_cc1 -emit-llvm -triple x86_64 -std=c17 -fsanitize=function %s 
-o /dev/null
+
+long __attribute__((ms_abi)) f() {}
Index: clang/lib/CodeGen/CodeGenFunction.cpp
===
--- clang/lib/CodeGen/CodeGenFunction.cpp
+++ clang/lib/CodeGen/CodeGenFunction.cpp
@@ -570,6 +570,9 @@
 
 llvm::ConstantInt *
 CodeGenFunction::getUBSanFunctionTypeHash(QualType Ty) const {
+  if (isa(Ty))
+Ty = Ty.getDesugaredType(getContext());
+
   // Remove any (C++17) exception specifications, to allow calling e.g. a
   // noexcept function through a non-noexcept pointer.
   if (!isa(Ty))


Index: clang/test/CodeGen/ubsan-function-attributed.c
===
--- /dev/null
+++ clang/test/CodeGen/ubsan-function-attributed.c
@@ -0,0 +1,3 @@
+// RUN: %clang_cc1 -emit-llvm -triple x86_64 -std=c17 -fsanitize=function %s -o /dev/null
+
+long __attribute__((ms_abi)) f() {}
Index: clang/lib/CodeGen/CodeGenFunction.cpp
===
--- clang/lib/CodeGen/CodeGenFunction.cpp
+++ clang/lib/CodeGen/CodeGenFunction.cpp
@@ -570,6 +570,9 @@
 
 llvm::ConstantInt *
 CodeGenFunction::getUBSanFunctionTypeHash(QualType Ty) const {
+  if (isa(Ty))
+Ty = Ty.getDesugaredType(getContext());
+
   // Remove any (C++17) exception specifications, to allow calling e.g. a
   // noexcept function through a non-noexcept pointer.
   if (!isa(Ty))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D157331: [clang] Implement C23

2023-08-08 Thread Zijun Zhao via Phabricator via cfe-commits
ZijunZhao added inline comments.



Comment at: clang/test/Headers/stdckdint.cpp:1
+// RUN: %clang_cc1 -emit-llvm -fgnuc-version=4.2.1 -std=gnu++11 %s -o - | 
FileCheck %s
+

enh wrote:
> ZijunZhao wrote:
> > enh wrote:
> > > hiraditya wrote:
> > > > seems like we don't have a -std=gnu23, or -std=c23 standard flag for 
> > > > this in clang yet.
> > > > 
> > > > https://godbolt.org/z/7dKnGEWWE
> > > > 
> > > > we probably need it before testing stdckdint i guess?
> > > other headers just use > and the previous version. (though see stdalign.h 
> > > if you're looking for some random cleanup to do!)
> > > seems like we don't have a -std=gnu23, or -std=c23 standard flag for this 
> > > in clang yet.
> > 
> > In the local testing, `-std=c++23` works  and all tests pass 
> > 
> > 
> C23 != C++23... they don't even really coordinate with one another... talk to 
> hboehm about that some time :-)
ohhh I think `gnu++23` != `gnu23` either  


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157331

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


[PATCH] D157296: [AST][Coroutine] Fix CoyieldExpr missing end loc

2023-08-08 Thread Ding Fei via Phabricator via cfe-commits
danix800 updated this revision to Diff 548434.
danix800 edited the summary of this revision.
danix800 added a comment.

Cleanup duplicated boilerplate testcase code. Append a few extra child nodes of 
`CoyieldExpr` dumped in testcase.


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

https://reviews.llvm.org/D157296

Files:
  clang/lib/Sema/SemaCoroutine.cpp
  clang/test/AST/Inputs/std-coroutine.h
  clang/test/AST/coroutine-co_yield-source-range.cpp


Index: clang/test/AST/coroutine-co_yield-source-range.cpp
===
--- /dev/null
+++ clang/test/AST/coroutine-co_yield-source-range.cpp
@@ -0,0 +1,49 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 %s -std=c++20 \
+// RUN:-fsyntax-only -ast-dump | FileCheck %s
+
+#include "Inputs/std-coroutine.h"
+
+using namespace std;
+
+struct Chat {
+  struct promise_type {
+std::suspend_always initial_suspend() { return {}; }
+Chat get_return_object() {
+  return std::coroutine_handle::from_promise(*this);
+}
+std::suspend_always yield_value(int m) { return {}; }
+std::suspend_always final_suspend() noexcept { return {}; }
+std::suspend_always return_value(int) { return {}; }
+void unhandled_exception() {}
+
+auto await_transform(int s) {
+  struct awaiter {
+promise_type *promise;
+bool await_ready() { return true; }
+int await_resume() { return promise->message; }
+void await_suspend(std::coroutine_handle<>) {}
+  };
+
+  return awaiter{this};
+}
+int message;
+  };
+
+  Chat(std::coroutine_handle promise);
+
+  std::coroutine_handle handle;
+};
+
+Chat f(int s)  {
+  // CHECK:  CoyieldExpr {{.*}} 
+  // CHECK-NEXT:   CXXMemberCallExpr {{.*}}  {{.*}}
+  // CHECK-NEXT: MemberExpr {{.*}}  {{.*}}
+  // CHECK-NEXT:   DeclRefExpr {{.*}}  {{.*}}
+  // CHECK-NEXT: ImplicitCastExpr {{.*}}  {{.*}}
+  // CHECK-NEXT:   DeclRefExpr {{.*}}  {{.*}}
+  co_yield s;
+  // CHECK:  CoreturnStmt {{.*}} 
+  co_return s;
+  // CHECK:  CoawaitExpr {{.*}}  'int'
+  co_await s;
+}
Index: clang/test/AST/Inputs/std-coroutine.h
===
--- clang/test/AST/Inputs/std-coroutine.h
+++ clang/test/AST/Inputs/std-coroutine.h
@@ -55,9 +55,9 @@
 };
 
 struct suspend_always {
-  bool await_ready() { return false; }
-  void await_suspend(coroutine_handle<>) {}
-  void await_resume() {}
+  bool await_ready() noexcept { return false; }
+  void await_suspend(coroutine_handle<>) noexcept {}
+  void await_resume() noexcept {}
 };
 
 struct suspend_never {
Index: clang/lib/Sema/SemaCoroutine.cpp
===
--- clang/lib/Sema/SemaCoroutine.cpp
+++ clang/lib/Sema/SemaCoroutine.cpp
@@ -318,7 +318,8 @@
 return ExprError();
   }
 
-  return S.BuildCallExpr(nullptr, Result.get(), Loc, Args, Loc, nullptr);
+  auto EndLoc = Args.empty() ? Loc : Args.back()->getEndLoc();
+  return S.BuildCallExpr(nullptr, Result.get(), Loc, Args, EndLoc, nullptr);
 }
 
 // See if return type is coroutine-handle and if so, invoke builtin coro-resume


Index: clang/test/AST/coroutine-co_yield-source-range.cpp
===
--- /dev/null
+++ clang/test/AST/coroutine-co_yield-source-range.cpp
@@ -0,0 +1,49 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 %s -std=c++20 \
+// RUN:-fsyntax-only -ast-dump | FileCheck %s
+
+#include "Inputs/std-coroutine.h"
+
+using namespace std;
+
+struct Chat {
+  struct promise_type {
+std::suspend_always initial_suspend() { return {}; }
+Chat get_return_object() {
+  return std::coroutine_handle::from_promise(*this);
+}
+std::suspend_always yield_value(int m) { return {}; }
+std::suspend_always final_suspend() noexcept { return {}; }
+std::suspend_always return_value(int) { return {}; }
+void unhandled_exception() {}
+
+auto await_transform(int s) {
+  struct awaiter {
+promise_type *promise;
+bool await_ready() { return true; }
+int await_resume() { return promise->message; }
+void await_suspend(std::coroutine_handle<>) {}
+  };
+
+  return awaiter{this};
+}
+int message;
+  };
+
+  Chat(std::coroutine_handle promise);
+
+  std::coroutine_handle handle;
+};
+
+Chat f(int s)  {
+  // CHECK:  CoyieldExpr {{.*}} 
+  // CHECK-NEXT:   CXXMemberCallExpr {{.*}}  {{.*}}
+  // CHECK-NEXT: MemberExpr {{.*}}  {{.*}}
+  // CHECK-NEXT:   DeclRefExpr {{.*}}  {{.*}}
+  // CHECK-NEXT: ImplicitCastExpr {{.*}}  {{.*}}
+  // CHECK-NEXT:   DeclRefExpr {{.*}}  {{.*}}
+  co_yield s;
+  // CHECK:  CoreturnStmt {{.*}} 
+  co_return s;
+  // CHECK:  CoawaitExpr {{.*}}  'int'
+  co_await s;
+}
Index: clang/test/AST/Inputs/std-coroutine.h
===
--- 

[PATCH] D157420: [clang] Enable constexpr on LZCNT/POPCNT MS extension intrinsics

2023-08-08 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added reviewers: erichkeane, aaron.ballman.
RKSimon added a comment.

Please can you add them to the constexpr lists in LanguageExtensions.rst ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157420

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


[PATCH] D153536: [Clang] Implement P2169 A nice placeholder with no name

2023-08-08 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

This patch brakes https://lab.llvm.org/buildbot/#/builders/168/builds/14997
Not sure what is wrong there, probably the test need to be updated. Can you 
please take a look?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153536

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


[PATCH] D155997: [Phase Ordering] Don't speculate in SimplifyCFG before PGO annotation

2023-08-08 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks added a comment.

can we try not gating this on PGO as suggested? minimizing differences between 
pipelines is nice, and as mentioned it'll help with other cases




Comment at: llvm/test/Transforms/PhaseOrdering/simplifycfg-speculate-blocks.ll:1
+;; Check that SimplifyCFG does not attempt speculation until after PGO is
+;; annotated in the IR, and then does not perform it when unprofitable.

nikic wrote:
> aeubanks wrote:
> > hmm typically these phase ordering tests use 
> > `llvm/utils/update_test_checks.py`, but that doesn't support the 
> > llvm-profdata RUN line. I think a non-update_test_checks test is probably 
> > fine for this, @nikic does that make sense?
> > 
> > 
> I thought UTC supports unrecognized commands (by just executing them)... If 
> not, a non-UTC test is fine.
`update_test_checks.py` doesn't handle `%t` (maybe that's an improvement we 
could make to the script)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155997

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


[PATCH] D153536: [Clang] Implement P2169 A nice placeholder with no name

2023-08-08 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

In D153536#4570534 , @aaron.ballman 
wrote:

> In D153536#4570513 , @vitalybuka 
> wrote:
>
>> This patch brakes https://lab.llvm.org/buildbot/#/builders/168/builds/14997
>> Not sure what is wrong there, probably the test need to be updated. Can you 
>> please take a look?
>
> I'm a bit confused -- the linked bot is green and the failures to either side 
> of the linked run are both failing for the same reason (which seems to be 
> unrelated to the changes in this patch). It looks like this bot went red 
> here: https://lab.llvm.org/buildbot/#/builders/168/builds/14944 and hasn't 
> reliably come back to green.

Sorry copy-pasted wrong url. This green is manual request on revision before 
this patch.

Correct failure https://lab.llvm.org/buildbot/#/builders/168/builds/14944
So it's persistently red after that.

If anyone wondering, I've bisected to this patch on buildbot host.
For whatever reason does not reproduce on my workstation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153536

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


[PATCH] D157420: [clang] Enable constexpr on LZCNT/POPCNT MS extension intrinsics

2023-08-08 Thread Alejandro Aguirre via Phabricator via cfe-commits
alexguirre updated this revision to Diff 548323.
alexguirre added a comment.

Added __lzcnt / __popcnt to the constexpr lists in LanguageExtensions.rst


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157420

Files:
  clang/docs/LanguageExtensions.rst
  clang/include/clang/Basic/Builtins.def
  clang/lib/AST/ExprConstant.cpp
  clang/test/CodeGen/ms-intrinsics-other.c

Index: clang/test/CodeGen/ms-intrinsics-other.c
===
--- clang/test/CodeGen/ms-intrinsics-other.c
+++ clang/test/CodeGen/ms-intrinsics-other.c
@@ -14,6 +14,27 @@
 // RUN: -triple armv7--darwin -Oz -emit-llvm %s -o - \
 // RUN: | FileCheck %s --check-prefix=CHECK-ARM
 
+// RUN: %clang_cc1 -x c++ -std=c++11 \
+// RUN: -ffreestanding -fms-extensions -Wno-implicit-function-declaration \
+// RUN: -triple x86_64--darwin -Oz -emit-llvm %s -o - \
+// RUN: | FileCheck %s
+// RUN: %clang_cc1 -x c++ -std=c++11 \
+// RUN: -ffreestanding -fms-extensions -Wno-implicit-function-declaration \
+// RUN: -triple x86_64--linux -Oz -emit-llvm %s -o - \
+// RUN: | FileCheck %s
+// RUN: %clang_cc1 -x c++ -std=c++11 \
+// RUN: -ffreestanding -fms-extensions -Wno-implicit-function-declaration \
+// RUN: -triple aarch64--darwin -Oz -emit-llvm %s -o - \
+// RUN: | FileCheck %s --check-prefix=CHECK-ARM-ARM64
+// RUN: %clang_cc1 -x c++ -std=c++11 \
+// RUN: -ffreestanding -fms-extensions -Wno-implicit-function-declaration \
+// RUN: -triple aarch64--darwin -Oz -emit-llvm %s -o - \
+// RUN: | FileCheck %s --check-prefix=CHECK-ARM
+// RUN: %clang_cc1 -x c++ -std=c++11 \
+// RUN: -ffreestanding -fms-extensions -Wno-implicit-function-declaration \
+// RUN: -triple armv7--darwin -Oz -emit-llvm %s -o - \
+// RUN: | FileCheck %s --check-prefix=CHECK-ARM
+
 // LP64 targets use 'long' as 'int' for MS intrinsics (-fms-extensions)
 #ifdef __LP64__
 #define LONG int
@@ -21,6 +42,10 @@
 #define LONG long
 #endif
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 unsigned char test_BitScanForward(unsigned LONG *Index, unsigned LONG Mask) {
   return _BitScanForward(Index, Mask);
 }
@@ -416,3 +441,36 @@
 // CHECK-ARM: ret i32 [[RESULT]]
 // CHECK-ARM: }
 #endif
+
+#ifdef __cplusplus
+}
+#endif
+
+
+// Test constexpr handling.
+#if defined(__cplusplus) && (__cplusplus >= 201103L)
+
+char popcnt16_0[__popcnt16(0x) == 0 ? 1 : -1];
+char popcnt16_1[__popcnt16(0x10F0) == 5 ? 1 : -1];
+
+char popcnt_0[__popcnt(0x) == 0 ? 1 : -1];
+char popcnt_1[__popcnt(0x10F0) == 5 ? 1 : -1];
+
+char popcnt64_0[__popcnt64(0xULL) == 0 ? 1 : -1];
+char popcnt64_1[__popcnt64(0xF0F1ULL) == 9 ? 1 : -1];
+
+#define BITSIZE(x) (sizeof(x) * 8)
+char lzcnt16_0[__lzcnt16(1) == BITSIZE(short) - 1 ? 1 : -1];
+char lzcnt16_1[__lzcnt16(1 << (BITSIZE(short) - 1)) == 0 ? 1 : -1];
+char lzcnt16_2[__lzcnt16(0) == BITSIZE(short) ? 1 : -1];
+
+char lzcnt_0[__lzcnt(1) == BITSIZE(int) - 1 ? 1 : -1];
+char lzcnt_1[__lzcnt(1 << (BITSIZE(int) - 1)) == 0 ? 1 : -1];
+char lzcnt_2[__lzcnt(0) == BITSIZE(int) ? 1 : -1];
+
+char lzcnt64_0[__lzcnt64(1ULL) == BITSIZE(__int64) - 1 ? 1 : -1];
+char lzcnt64_1[__lzcnt64(1ULL << (BITSIZE(__int64) - 1)) == 0 ? 1 : -1];
+char lzcnt64_2[__lzcnt64(0ULL) == BITSIZE(__int64) ? 1 : -1];
+#undef BITSIZE
+
+#endif
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -12123,11 +12123,21 @@
   case Builtin::BI__builtin_clz:
   case Builtin::BI__builtin_clzl:
   case Builtin::BI__builtin_clzll:
-  case Builtin::BI__builtin_clzs: {
+  case Builtin::BI__builtin_clzs:
+  case Builtin::BI__lzcnt16: // Microsoft variants of count leading-zeroes
+  case Builtin::BI__lzcnt:
+  case Builtin::BI__lzcnt64: {
 APSInt Val;
 if (!EvaluateInteger(E->getArg(0), Val, Info))
   return false;
-if (!Val)
+
+// When the argument is 0, the result of GCC builtins is undefined, whereas
+// for Microsoft intrinsics, the result is the bit-width of the argument.
+bool ZeroIsUndefined = BuiltinOp != Builtin::BI__lzcnt16 &&
+   BuiltinOp != Builtin::BI__lzcnt &&
+   BuiltinOp != Builtin::BI__lzcnt64;
+
+if (ZeroIsUndefined && !Val)
   return Error(E);
 
 return Success(Val.countl_zero(), E);
@@ -12266,7 +12276,10 @@
 
   case Builtin::BI__builtin_popcount:
   case Builtin::BI__builtin_popcountl:
-  case Builtin::BI__builtin_popcountll: {
+  case Builtin::BI__builtin_popcountll:
+  case Builtin::BI__popcnt16: // Microsoft variants of popcount
+  case Builtin::BI__popcnt:
+  case Builtin::BI__popcnt64: {
 APSInt Val;
 if (!EvaluateInteger(E->getArg(0), Val, Info))
   return false;
Index: 

[PATCH] D153536: [Clang] Implement P2169 A nice placeholder with no name

2023-08-08 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

Not a test update

The second line of the test triggers:

RUN: not --crash clangd -lit-test -sync=0 < %s 2> %t.async.err
==

  Signalled while building preamble
Filename: =
  ==2319884==ERROR: AddressSanitizer: stack-use-after-return on address 
0x7f310f6eb210 at pc 0x55a3ecaab9f5 bp 0x7f3115c49920 sp 0x7f3115c49918
  READ of size 1 at 0x7f310f6eb210 thread T3
  #0 0x55a3ecaab9f4 in __is_long 
/b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/include/c++/v1/string:1734:33
  #1 0x55a3ecaab9f4 in __get_pointer 
/b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/include/c++/v1/string:1869:17
  #2 0x55a3ecaab9f4 in data 
/b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/include/c++/v1/string:1559:73
  #3 0x55a3ecaab9f4 in operator<< 
/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/include/llvm/Support/raw_ostream.h:249:22
  #4 0x55a3ecaab9f4 in clang::clangd::(anonymous 
namespace)::crashDumpCompileCommand(llvm::raw_ostream&, 
clang::tooling::CompileCommand const&) 
/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang-tools-extra/clangd/TUScheduler.cpp:1012:24
  #5 0x55a3ecaab285 in clang::clangd::(anonymous 
namespace)::crashDumpParseInputs(llvm::raw_ostream&, clang::clangd::ParseInputs 
const&) 
/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang-tools-extra/clangd/TUScheduler.cpp:1038:3
  #6 0x55a3ecec1c9d in operator() 
/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/include/llvm/ADT/FunctionExtras.h:382:12
  #7 0x55a3ecec1c9d in 
clang::clangd::ThreadCrashReporter::runCrashHandlers() 
/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang-tools-extra/clangd/support/ThreadCrashReporter.cpp:30:5
  #8 0x55a3ebacfd78 in operator() 
/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang-tools-extra/clangd/tool/ClangdMain.cpp:717:9
  #9 0x55a3ebacfd78 in clang::clangd::clangdMain(int, 
char**)::$_0::__invoke(void*) 
/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang-tools-extra/clangd/tool/ClangdMain.cpp:716:7
  #10 0x55a3e87c27ba in llvm::sys::RunSignalHandlers() 
/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/Support/Signals.cpp:103:5
  #11 0x55a3e87cbd01 in SignalHandler(int) 
/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/Support/Unix/Signals.inc:403:3
  #12 0x7f3115a3bcef  (/lib/x86_64-linux-gnu/libc.so.6+0x3bcef) (BuildId: 
d1704d25fbbb72fa95d517b883131828c0883fe9)
  #13 0x7f3115a9226a in pthread_kill 
(/lib/x86_64-linux-gnu/libc.so.6+0x9226a) (BuildId: 
d1704d25fbbb72fa95d517b883131828c0883fe9)
  #14 0x7f3115a3bc45 in raise (/lib/x86_64-linux-gnu/libc.so.6+0x3bc45) 
(BuildId: d1704d25fbbb72fa95d517b883131828c0883fe9)
  #15 0x7f3115a227fb in abort (/lib/x86_64-linux-gnu/libc.so.6+0x227fb) 
(BuildId: d1704d25fbbb72fa95d517b883131828c0883fe9)
  #16 0x55a3e869c429 in llvm::report_fatal_error(llvm::Twine const&, bool) 
/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/Support/ErrorHandling.cpp:123:5
  #17 0x55a3e869c014 in llvm::report_fatal_error(char const*, bool) 
/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/Support/ErrorHandling.cpp:83:3
  #18 0x55a3e9a2bb12 in (anonymous 
namespace)::PragmaDebugHandler::HandlePragma(clang::Preprocessor&, 
clang::PragmaIntroducer, clang::Token&) 
/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/lib/Lex/Pragma.cpp:1102:9
  #19 0x55a3e9a0f270 in 
clang::Preprocessor::HandlePragmaDirective(clang::PragmaIntroducer) 
/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/lib/Lex/Pragma.cpp:178:19
  #20 0x55a3e98e92a1 in clang::Preprocessor::HandleDirective(clang::Token&) 
/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/lib/Lex/PPDirectives.cpp:1265:14
  #21 0x55a3e98a427a in clang::Lexer::LexTokenInternal(clang::Token&, bool) 
/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/lib/Lex/Lexer.cpp:4362:7
  #22 0x55a3e989754c in clang::Lexer::Lex(clang::Token&) 
/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/lib/Lex/Lexer.cpp:3578:24
  #23 0x55a3e9a5fb72 in clang::Preprocessor::Lex(clang::Token&) 
/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/lib/Lex/Preprocessor.cpp:886:33
  #24 0x55a3eee8d7ef in ConsumeToken 
/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/include/clang/Parse/Parser.h:504:8
  #25 0x55a3eee8d7ef in clang::Parser::Initialize() 
/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/lib/Parse/Parser.cpp:568:3
  #26 0x55a3eee7732f in clang::ParseAST(clang::Sema&, bool, bool) 

[PATCH] D153536: [Clang] Implement P2169 A nice placeholder with no name

2023-08-08 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added a subscriber: sammccall.
cor3ntin added a comment.

Looking at the failing test 
(`clang-tools-extra/clangd/test/crash-preamble.test`), I'd be very surprising 
if it is related to a front end change like this PR. Any idea @sammccall  ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153536

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


[clang] ea72a4e - [CUDA][HIP] Fix template argument deduction

2023-08-08 Thread Yaxun Liu via cfe-commits

Author: Yaxun (Sam) Liu
Date: 2023-08-08T17:39:01-04:00
New Revision: ea72a4e6547feaa82e132746c6777b3b69aed0d5

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

LOG: [CUDA][HIP] Fix template argument deduction

nvcc allows using std::malloc and std::free in device code.
When std::malloc or std::free is passed as a template
function argument with template argument deduction,
there is no diagnostics. e.g.

__global__ void kern() {
void *p = std::malloc(1);
std::free(p);
}
int main()
{

std::shared_ptr a;
a = std::shared_ptr(
  (float*)std::malloc(sizeof(float) * 100),
  std::free
);
return 0;
}
However, the same code fails to compile with clang
(https://godbolt.org/z/1roGvo6YY). The reason is
that clang does not have logic to choose a function
argument from an overloaded set of candidates
based on host/device attributes for template argument
deduction.

Currently, clang does have a logic to choose a candidate
based on the constraints of the candidates. This patch
extends that logic to account for the CUDA host/device-based
preference.

Reviewed by: Artem Belevich

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

Added: 
clang/test/SemaCUDA/template-arg-deduction.cu

Modified: 
clang/lib/Sema/SemaOverload.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index 3b14fb6b66e450..5d0299dfa752f9 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -12770,6 +12770,13 @@ Sema::resolveAddressOfSingleOverloadCandidate(Expr *E, 
DeclAccessPair ) {
   DeclAccessPair DAP;
   SmallVector AmbiguousDecls;
 
+  // Return positive for better, negative for worse, 0 for equal preference.
+  auto CheckCUDAPreference = [&](FunctionDecl *FD1, FunctionDecl *FD2) {
+FunctionDecl *Caller = getCurFunctionDecl(/*AllowLambda=*/true);
+return static_cast(IdentifyCUDAPreference(Caller, FD1)) -
+   static_cast(IdentifyCUDAPreference(Caller, FD2));
+  };
+
   auto CheckMoreConstrained = [&](FunctionDecl *FD1,
   FunctionDecl *FD2) -> std::optional {
 if (FunctionDecl *MF = FD1->getInstantiatedFromMemberFunction())
@@ -12800,9 +12807,31 @@ Sema::resolveAddressOfSingleOverloadCandidate(Expr *E, 
DeclAccessPair ) {
 if (!checkAddressOfFunctionIsAvailable(FD))
   continue;
 
+// If we found a better result, update Result.
+auto FoundBetter = [&]() {
+  IsResultAmbiguous = false;
+  DAP = I.getPair();
+  Result = FD;
+};
+
 // We have more than one result - see if it is more constrained than the
 // previous one.
 if (Result) {
+  // Check CUDA preference first. If the candidates have 
diff erennt CUDA
+  // preference, choose the one with higher CUDA preference. Otherwise,
+  // choose the one with more constraints.
+  if (getLangOpts().CUDA) {
+int PreferenceByCUDA = CheckCUDAPreference(FD, Result);
+// FD has 
diff erent preference than Result.
+if (PreferenceByCUDA != 0) {
+  // FD is more preferable than Result.
+  if (PreferenceByCUDA > 0)
+FoundBetter();
+  continue;
+}
+  }
+  // FD has the same CUDA prefernece than Result. Continue check
+  // constraints.
   std::optional MoreConstrainedThanPrevious =
   CheckMoreConstrained(FD, Result);
   if (!MoreConstrainedThanPrevious) {
@@ -12814,9 +12843,7 @@ Sema::resolveAddressOfSingleOverloadCandidate(Expr *E, 
DeclAccessPair ) {
 continue;
   // FD is more constrained - replace Result with it.
 }
-IsResultAmbiguous = false;
-DAP = I.getPair();
-Result = FD;
+FoundBetter();
   }
 
   if (IsResultAmbiguous)
@@ -12826,9 +12853,15 @@ Sema::resolveAddressOfSingleOverloadCandidate(Expr *E, 
DeclAccessPair ) {
 SmallVector ResultAC;
 // We skipped over some ambiguous declarations which might be ambiguous 
with
 // the selected result.
-for (FunctionDecl *Skipped : AmbiguousDecls)
+for (FunctionDecl *Skipped : AmbiguousDecls) {
+  // If skipped candidate has 
diff erent CUDA preference than the result,
+  // there is no ambiguity. Otherwise check whether they have 
diff erent
+  // constraints.
+  if (getLangOpts().CUDA && CheckCUDAPreference(Skipped, Result) != 0)
+continue;
   if (!CheckMoreConstrained(Skipped, Result))
 return nullptr;
+}
 Pair = DAP;
   }
   return Result;

diff  --git a/clang/test/SemaCUDA/template-arg-deduction.cu 
b/clang/test/SemaCUDA/template-arg-deduction.cu
new file mode 100644
index 00..22ff34fabdb08f
--- /dev/null
+++ b/clang/test/SemaCUDA/template-arg-deduction.cu
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -triple 

[PATCH] D154300: [CUDA][HIP] Fix template argument deduction

2023-08-08 Thread Yaxun Liu 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 rGea72a4e6547f: [CUDA][HIP] Fix template argument deduction 
(authored by yaxunl).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154300

Files:
  clang/lib/Sema/SemaOverload.cpp
  clang/test/SemaCUDA/template-arg-deduction.cu

Index: clang/test/SemaCUDA/template-arg-deduction.cu
===
--- /dev/null
+++ clang/test/SemaCUDA/template-arg-deduction.cu
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -fsyntax-only -fcuda-is-device -verify %s
+
+// expected-no-diagnostics
+
+#include "Inputs/cuda.h"
+
+void foo();
+__device__ void foo();
+
+template
+void host_temp(F f);
+
+template
+__device__ void device_temp(F f);
+
+void host_caller() {
+  host_temp(foo);
+}
+
+__global__ void kernel_caller() {
+  device_temp(foo);
+}
+
+__device__ void device_caller() {
+  device_temp(foo);
+}
Index: clang/lib/Sema/SemaOverload.cpp
===
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -12770,6 +12770,13 @@
   DeclAccessPair DAP;
   SmallVector AmbiguousDecls;
 
+  // Return positive for better, negative for worse, 0 for equal preference.
+  auto CheckCUDAPreference = [&](FunctionDecl *FD1, FunctionDecl *FD2) {
+FunctionDecl *Caller = getCurFunctionDecl(/*AllowLambda=*/true);
+return static_cast(IdentifyCUDAPreference(Caller, FD1)) -
+   static_cast(IdentifyCUDAPreference(Caller, FD2));
+  };
+
   auto CheckMoreConstrained = [&](FunctionDecl *FD1,
   FunctionDecl *FD2) -> std::optional {
 if (FunctionDecl *MF = FD1->getInstantiatedFromMemberFunction())
@@ -12800,9 +12807,31 @@
 if (!checkAddressOfFunctionIsAvailable(FD))
   continue;
 
+// If we found a better result, update Result.
+auto FoundBetter = [&]() {
+  IsResultAmbiguous = false;
+  DAP = I.getPair();
+  Result = FD;
+};
+
 // We have more than one result - see if it is more constrained than the
 // previous one.
 if (Result) {
+  // Check CUDA preference first. If the candidates have differennt CUDA
+  // preference, choose the one with higher CUDA preference. Otherwise,
+  // choose the one with more constraints.
+  if (getLangOpts().CUDA) {
+int PreferenceByCUDA = CheckCUDAPreference(FD, Result);
+// FD has different preference than Result.
+if (PreferenceByCUDA != 0) {
+  // FD is more preferable than Result.
+  if (PreferenceByCUDA > 0)
+FoundBetter();
+  continue;
+}
+  }
+  // FD has the same CUDA prefernece than Result. Continue check
+  // constraints.
   std::optional MoreConstrainedThanPrevious =
   CheckMoreConstrained(FD, Result);
   if (!MoreConstrainedThanPrevious) {
@@ -12814,9 +12843,7 @@
 continue;
   // FD is more constrained - replace Result with it.
 }
-IsResultAmbiguous = false;
-DAP = I.getPair();
-Result = FD;
+FoundBetter();
   }
 
   if (IsResultAmbiguous)
@@ -12826,9 +12853,15 @@
 SmallVector ResultAC;
 // We skipped over some ambiguous declarations which might be ambiguous with
 // the selected result.
-for (FunctionDecl *Skipped : AmbiguousDecls)
+for (FunctionDecl *Skipped : AmbiguousDecls) {
+  // If skipped candidate has different CUDA preference than the result,
+  // there is no ambiguity. Otherwise check whether they have different
+  // constraints.
+  if (getLangOpts().CUDA && CheckCUDAPreference(Skipped, Result) != 0)
+continue;
   if (!CheckMoreConstrained(Skipped, Result))
 return nullptr;
+}
 Pair = DAP;
   }
   return Result;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D157438: [OpenMP] Ensure wrapper headers are included on both host and device

2023-08-08 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added inline comments.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:1190-1191
 // the resource directory at clang/lib/Headers/llvm_libc_wrappers.
-if (C.getActiveOffloadKinds() == Action::OFK_None) {
+if ((getToolChain().getTriple().isNVPTX() ||
+ getToolChain().getTriple().isAMDGCN()) &&
+C.getActiveOffloadKinds() == Action::OFK_None) {

jhuber6 wrote:
> arsenm wrote:
> > can we do something better than this NVPTX||AMDGCN checks
> This is more or less "Are we one of the GPUs `libc` supports". This is for 
> cross-compiling so there's no existing infrastructure.
maybe add a variable bool HasGPULibC as it is also used in other places below


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157438

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


[PATCH] D157331: [clang] Implement C23

2023-08-08 Thread Elliott Hughes via Phabricator via cfe-commits
enh added inline comments.



Comment at: clang/test/Headers/stdckdint.cpp:1
+// RUN: %clang_cc1 -emit-llvm -fgnuc-version=4.2.1 -std=gnu++11 %s -o - | 
FileCheck %s
+

ZijunZhao wrote:
> enh wrote:
> > hiraditya wrote:
> > > seems like we don't have a -std=gnu23, or -std=c23 standard flag for this 
> > > in clang yet.
> > > 
> > > https://godbolt.org/z/7dKnGEWWE
> > > 
> > > we probably need it before testing stdckdint i guess?
> > other headers just use > and the previous version. (though see stdalign.h 
> > if you're looking for some random cleanup to do!)
> > seems like we don't have a -std=gnu23, or -std=c23 standard flag for this 
> > in clang yet.
> 
> In the local testing, `-std=c++23` works  and all tests pass 
> 
> 
C23 != C++23... they don't even really coordinate with one another... talk to 
hboehm about that some time :-)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157331

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


  1   2   3   >