[PATCH] D151785: [clangd] Desugar template parameter aliases in type hints

2023-06-13 Thread Nathan Ridge via Phabricator via cfe-commits
nridge accepted this revision.
nridge added a comment.
This revision is now accepted and ready to land.

Thanks, LGTM!




Comment at: clang-tools-extra/clangd/InlayHints.cpp:196
+// Determines if any intermediate type in desugaring QualType QT is of
+// substituted template parameter. Ignore pointer or reference wrappers.
+bool isSugaredTemplateParameter(QualType QT) {

nit: "of substituted template parameter" --> "a substituted template parmeter" 

(or "of substituted template parameter type")


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151785

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


[PATCH] D152696: Prevent deadlocks in death tests.

2023-06-13 Thread Martin Böhme via Phabricator via cfe-commits
mboehme updated this revision to Diff 530789.
mboehme added a comment.

Set the `death_test_style` flag globally in TestMain.cpp instead of each
individual test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152696

Files:
  third-party/unittest/UnitTestMain/TestMain.cpp


Index: third-party/unittest/UnitTestMain/TestMain.cpp
===
--- third-party/unittest/UnitTestMain/TestMain.cpp
+++ third-party/unittest/UnitTestMain/TestMain.cpp
@@ -29,6 +29,10 @@
 true /* Disable crash reporting 
*/);
   }
 
+  // Use the "threadsafe" test style for death tests -- the "fast" test style
+  // can cause deadlocks.
+  testing::GTEST_FLAG(death_test_style) = "threadsafe";
+
   // Initialize both gmock and gtest.
   testing::InitGoogleMock(&argc, argv);
 


Index: third-party/unittest/UnitTestMain/TestMain.cpp
===
--- third-party/unittest/UnitTestMain/TestMain.cpp
+++ third-party/unittest/UnitTestMain/TestMain.cpp
@@ -29,6 +29,10 @@
 true /* Disable crash reporting */);
   }
 
+  // Use the "threadsafe" test style for death tests -- the "fast" test style
+  // can cause deadlocks.
+  testing::GTEST_FLAG(death_test_style) = "threadsafe";
+
   // Initialize both gmock and gtest.
   testing::InitGoogleMock(&argc, argv);
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D152696: Prevent deadlocks in death tests.

2023-06-13 Thread Hans Wennborg via Phabricator via cfe-commits
hans accepted this revision.
hans 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/D152696/new/

https://reviews.llvm.org/D152696

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


[PATCH] D152520: [clangd] Unify printing policy for type hints

2023-06-13 Thread Nathan Ridge via Phabricator via cfe-commits
nridge accepted this revision.
nridge 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/D152520/new/

https://reviews.llvm.org/D152520

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


[PATCH] D152074: [6/11][Clang][RISCV] Expand all variants for strided segment load

2023-06-13 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/D152074/new/

https://reviews.llvm.org/D152074

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


[PATCH] D152075: [7/11][Clang][RISCV] Expand all variants for strided segment store

2023-06-13 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/D152075/new/

https://reviews.llvm.org/D152075

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


[PATCH] D152076: [8/11][Clang][RISCV] Expand all variants for indexed strided segment load

2023-06-13 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/D152076/new/

https://reviews.llvm.org/D152076

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


[clang] ee72e2b - [Sema] Remove unused isNonTypeNestedNameSpecifier

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

Author: Kazu Hirata
Date: 2023-06-13T00:24:40-07:00
New Revision: ee72e2b3939a82a29345c7e53929a3a769a78735

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

LOG: [Sema] Remove unused isNonTypeNestedNameSpecifier

The last use was removed by:

  commit 04f131da0b19abff611773c03be9bafb53c753ce
  Author: Richard Smith 
  Date:   Fri Jan 24 15:14:25 2020 -0800

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

Added: 


Modified: 
clang/include/clang/Sema/Sema.h
clang/lib/Sema/SemaCXXScopeSpec.cpp

Removed: 




diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 7d54452e72a3c..d088aea401c68 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -6994,9 +6994,6 @@ class Sema final {
 }
   };
 
-  bool isNonTypeNestedNameSpecifier(Scope *S, CXXScopeSpec &SS,
-NestedNameSpecInfo &IdInfo);
-
   bool BuildCXXNestedNameSpecifier(Scope *S,
NestedNameSpecInfo &IdInfo,
bool EnteringContext,

diff  --git a/clang/lib/Sema/SemaCXXScopeSpec.cpp 
b/clang/lib/Sema/SemaCXXScopeSpec.cpp
index b11f4f1b7cdd9..f37ba5cf4c109 100644
--- a/clang/lib/Sema/SemaCXXScopeSpec.cpp
+++ b/clang/lib/Sema/SemaCXXScopeSpec.cpp
@@ -415,51 +415,6 @@ NamedDecl *Sema::FindFirstQualifierInScope(Scope *S, 
NestedNameSpecifier *NNS) {
   return nullptr;
 }
 
-bool Sema::isNonTypeNestedNameSpecifier(Scope *S, CXXScopeSpec &SS,
-NestedNameSpecInfo &IdInfo) {
-  QualType ObjectType = GetTypeFromParser(IdInfo.ObjectType);
-  LookupResult Found(*this, IdInfo.Identifier, IdInfo.IdentifierLoc,
- LookupNestedNameSpecifierName);
-
-  // Determine where to perform name lookup
-  DeclContext *LookupCtx = nullptr;
-  bool isDependent = false;
-  if (!ObjectType.isNull()) {
-// This nested-name-specifier occurs in a member access expression, e.g.,
-// x->B::f, and we are looking into the type of the object.
-assert(!SS.isSet() && "ObjectType and scope specifier cannot coexist");
-LookupCtx = computeDeclContext(ObjectType);
-isDependent = ObjectType->isDependentType();
-  } else if (SS.isSet()) {
-// This nested-name-specifier occurs after another nested-name-specifier,
-// so long into the context associated with the prior 
nested-name-specifier.
-LookupCtx = computeDeclContext(SS, false);
-isDependent = isDependentScopeSpecifier(SS);
-Found.setContextRange(SS.getRange());
-  }
-
-  if (LookupCtx) {
-// Perform "qualified" name lookup into the declaration context we
-// computed, which is either the type of the base of a member access
-// expression or the declaration context associated with a prior
-// nested-name-specifier.
-
-// The declaration context must be complete.
-if (!LookupCtx->isDependentContext() &&
-RequireCompleteDeclContext(SS, LookupCtx))
-  return false;
-
-LookupQualifiedName(Found, LookupCtx);
-  } else if (isDependent) {
-return false;
-  } else {
-LookupName(Found, S);
-  }
-  Found.suppressDiagnostics();
-
-  return Found.getAsSingle();
-}
-
 namespace {
 
 // Callback to only accept typo corrections that can be a valid C++ member



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


[clang] c493394 - [clang] Use DenseMapBase::lookup (NFC)

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

Author: Kazu Hirata
Date: 2023-06-13T00:24:43-07:00
New Revision: c4933940f76bb775c33b70f4543d30c2e595ef1f

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

LOG: [clang] Use DenseMapBase::lookup (NFC)

Added: 


Modified: 
clang/lib/Analysis/ThreadSafetyCommon.cpp
clang/lib/ExtractAPI/API.cpp
clang/lib/Lex/PreprocessingRecord.cpp
clang/lib/Serialization/ModuleManager.cpp
clang/tools/libclang/CXIndexDataConsumer.cpp

Removed: 




diff  --git a/clang/lib/Analysis/ThreadSafetyCommon.cpp 
b/clang/lib/Analysis/ThreadSafetyCommon.cpp
index a771149f15912..b8286cef396c0 100644
--- a/clang/lib/Analysis/ThreadSafetyCommon.cpp
+++ b/clang/lib/Analysis/ThreadSafetyCommon.cpp
@@ -69,12 +69,7 @@ static bool isIncompletePhi(const til::SExpr *E) {
 
 using CallingContext = SExprBuilder::CallingContext;
 
-til::SExpr *SExprBuilder::lookupStmt(const Stmt *S) {
-  auto It = SMap.find(S);
-  if (It != SMap.end())
-return It->second;
-  return nullptr;
-}
+til::SExpr *SExprBuilder::lookupStmt(const Stmt *S) { return SMap.lookup(S); }
 
 til::SCFG *SExprBuilder::buildCFG(CFGWalker &Walker) {
   Walker.walk(*this);

diff  --git a/clang/lib/ExtractAPI/API.cpp b/clang/lib/ExtractAPI/API.cpp
index 553b7bbe710f8..10e79b37de739 100644
--- a/clang/lib/ExtractAPI/API.cpp
+++ b/clang/lib/ExtractAPI/API.cpp
@@ -249,10 +249,7 @@ APIRecord *APISet::findRecordForUSR(StringRef USR) const {
   if (USR.empty())
 return nullptr;
 
-  auto It = USRBasedLookupTable.find(USR);
-  if (It != USRBasedLookupTable.end())
-return It->second;
-  return nullptr;
+  return USRBasedLookupTable.lookup(USR);
 }
 
 StringRef APISet::recordUSR(const Decl *D) {

diff  --git a/clang/lib/Lex/PreprocessingRecord.cpp 
b/clang/lib/Lex/PreprocessingRecord.cpp
index 85eb57f616116..aab6a2bed89d9 100644
--- a/clang/lib/Lex/PreprocessingRecord.cpp
+++ b/clang/lib/Lex/PreprocessingRecord.cpp
@@ -381,12 +381,7 @@ PreprocessingRecord::getLoadedPreprocessedEntity(unsigned 
Index) {
 
 MacroDefinitionRecord *
 PreprocessingRecord::findMacroDefinition(const MacroInfo *MI) {
-  llvm::DenseMap::iterator Pos =
-  MacroDefinitions.find(MI);
-  if (Pos == MacroDefinitions.end())
-return nullptr;
-
-  return Pos->second;
+  return MacroDefinitions.lookup(MI);
 }
 
 void PreprocessingRecord::addMacroExpansion(const Token &Id,

diff  --git a/clang/lib/Serialization/ModuleManager.cpp 
b/clang/lib/Serialization/ModuleManager.cpp
index 81dd54692d77e..5b099b740e1d3 100644
--- a/clang/lib/Serialization/ModuleManager.cpp
+++ b/clang/lib/Serialization/ModuleManager.cpp
@@ -59,11 +59,7 @@ ModuleFile *ModuleManager::lookupByModuleName(StringRef 
Name) const {
 }
 
 ModuleFile *ModuleManager::lookup(const FileEntry *File) const {
-  auto Known = Modules.find(File);
-  if (Known == Modules.end())
-return nullptr;
-
-  return Known->second;
+  return Modules.lookup(File);
 }
 
 std::unique_ptr

diff  --git a/clang/tools/libclang/CXIndexDataConsumer.cpp 
b/clang/tools/libclang/CXIndexDataConsumer.cpp
index 006e55500798e..83f1f72cb7850 100644
--- a/clang/tools/libclang/CXIndexDataConsumer.cpp
+++ b/clang/tools/libclang/CXIndexDataConsumer.cpp
@@ -970,12 +970,7 @@ void CXIndexDataConsumer::addContainerInMap(const 
DeclContext *DC,
 }
 
 CXIdxClientEntity CXIndexDataConsumer::getClientEntity(const Decl *D) const {
-  if (!D)
-return nullptr;
-  EntityMapTy::const_iterator I = EntityMap.find(D);
-  if (I == EntityMap.end())
-return nullptr;
-  return I->second;
+  return D ? EntityMap.lookup(D) : nullptr;
 }
 
 void CXIndexDataConsumer::setClientEntity(const Decl *D, CXIdxClientEntity 
client) {
@@ -1079,25 +1074,11 @@ CXIndexDataConsumer::getEntityContainer(const Decl *D) 
const {
 
 CXIdxClientContainer
 CXIndexDataConsumer::getClientContainerForDC(const DeclContext *DC) const {
-  if (!DC)
-return nullptr;
-
-  ContainerMapTy::const_iterator I = ContainerMap.find(DC);
-  if (I == ContainerMap.end())
-return nullptr;
-
-  return I->second;
+  return DC ? ContainerMap.lookup(DC) : nullptr;
 }
 
 CXIdxClientFile CXIndexDataConsumer::getIndexFile(const FileEntry *File) {
-  if (!File)
-return nullptr;
-
-  FileMapTy::iterator FI = FileMap.find(File);
-  if (FI != FileMap.end())
-return FI->second;
-
-  return nullptr;
+  return File ? FileMap.lookup(File) : nullptr;
 }
 
 CXIdxLoc CXIndexDataConsumer::getIndexLoc(SourceLocation Loc) const {



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


[clang] 6639717 - [Driver] Remove unused declaration addTranslatorArgs

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

Author: Kazu Hirata
Date: 2023-06-13T00:24:46-07:00
New Revision: 6639717de8365e50983b057cdc3396d77d1374c1

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

LOG: [Driver] Remove unused declaration addTranslatorArgs

The declaration was added without a use by:

  commit 49682f14bf3fb8db5e2721d9896b27bb4c2bd635
  Author: Henry Linjamäki 
  Date:   Wed Nov 17 11:23:49 2021 +0300

Added: 


Modified: 
clang/lib/Driver/ToolChains/SPIRV.h

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/SPIRV.h 
b/clang/lib/Driver/ToolChains/SPIRV.h
index bb2904f761289..3cd613d9aac29 100644
--- a/clang/lib/Driver/ToolChains/SPIRV.h
+++ b/clang/lib/Driver/ToolChains/SPIRV.h
@@ -17,9 +17,6 @@ namespace driver {
 namespace tools {
 namespace SPIRV {
 
-void addTranslatorArgs(const llvm::opt::ArgList &InArgs,
-   llvm::opt::ArgStringList &OutArgs);
-
 void constructTranslateCommand(Compilation &C, const Tool &T,
const JobAction &JA, const InputInfo &Output,
const InputInfo &Input,



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


[PATCH] D152634: [Sema] Remove unused isNonTypeNestedNameSpecifier

2023-06-13 Thread Kazu Hirata via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGee72e2b3939a: [Sema] Remove unused 
isNonTypeNestedNameSpecifier (authored by kazu).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152634

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaCXXScopeSpec.cpp


Index: clang/lib/Sema/SemaCXXScopeSpec.cpp
===
--- clang/lib/Sema/SemaCXXScopeSpec.cpp
+++ clang/lib/Sema/SemaCXXScopeSpec.cpp
@@ -415,51 +415,6 @@
   return nullptr;
 }
 
-bool Sema::isNonTypeNestedNameSpecifier(Scope *S, CXXScopeSpec &SS,
-NestedNameSpecInfo &IdInfo) {
-  QualType ObjectType = GetTypeFromParser(IdInfo.ObjectType);
-  LookupResult Found(*this, IdInfo.Identifier, IdInfo.IdentifierLoc,
- LookupNestedNameSpecifierName);
-
-  // Determine where to perform name lookup
-  DeclContext *LookupCtx = nullptr;
-  bool isDependent = false;
-  if (!ObjectType.isNull()) {
-// This nested-name-specifier occurs in a member access expression, e.g.,
-// x->B::f, and we are looking into the type of the object.
-assert(!SS.isSet() && "ObjectType and scope specifier cannot coexist");
-LookupCtx = computeDeclContext(ObjectType);
-isDependent = ObjectType->isDependentType();
-  } else if (SS.isSet()) {
-// This nested-name-specifier occurs after another nested-name-specifier,
-// so long into the context associated with the prior 
nested-name-specifier.
-LookupCtx = computeDeclContext(SS, false);
-isDependent = isDependentScopeSpecifier(SS);
-Found.setContextRange(SS.getRange());
-  }
-
-  if (LookupCtx) {
-// Perform "qualified" name lookup into the declaration context we
-// computed, which is either the type of the base of a member access
-// expression or the declaration context associated with a prior
-// nested-name-specifier.
-
-// The declaration context must be complete.
-if (!LookupCtx->isDependentContext() &&
-RequireCompleteDeclContext(SS, LookupCtx))
-  return false;
-
-LookupQualifiedName(Found, LookupCtx);
-  } else if (isDependent) {
-return false;
-  } else {
-LookupName(Found, S);
-  }
-  Found.suppressDiagnostics();
-
-  return Found.getAsSingle();
-}
-
 namespace {
 
 // Callback to only accept typo corrections that can be a valid C++ member
Index: clang/include/clang/Sema/Sema.h
===
--- clang/include/clang/Sema/Sema.h
+++ clang/include/clang/Sema/Sema.h
@@ -6994,9 +6994,6 @@
 }
   };
 
-  bool isNonTypeNestedNameSpecifier(Scope *S, CXXScopeSpec &SS,
-NestedNameSpecInfo &IdInfo);
-
   bool BuildCXXNestedNameSpecifier(Scope *S,
NestedNameSpecInfo &IdInfo,
bool EnteringContext,


Index: clang/lib/Sema/SemaCXXScopeSpec.cpp
===
--- clang/lib/Sema/SemaCXXScopeSpec.cpp
+++ clang/lib/Sema/SemaCXXScopeSpec.cpp
@@ -415,51 +415,6 @@
   return nullptr;
 }
 
-bool Sema::isNonTypeNestedNameSpecifier(Scope *S, CXXScopeSpec &SS,
-NestedNameSpecInfo &IdInfo) {
-  QualType ObjectType = GetTypeFromParser(IdInfo.ObjectType);
-  LookupResult Found(*this, IdInfo.Identifier, IdInfo.IdentifierLoc,
- LookupNestedNameSpecifierName);
-
-  // Determine where to perform name lookup
-  DeclContext *LookupCtx = nullptr;
-  bool isDependent = false;
-  if (!ObjectType.isNull()) {
-// This nested-name-specifier occurs in a member access expression, e.g.,
-// x->B::f, and we are looking into the type of the object.
-assert(!SS.isSet() && "ObjectType and scope specifier cannot coexist");
-LookupCtx = computeDeclContext(ObjectType);
-isDependent = ObjectType->isDependentType();
-  } else if (SS.isSet()) {
-// This nested-name-specifier occurs after another nested-name-specifier,
-// so long into the context associated with the prior nested-name-specifier.
-LookupCtx = computeDeclContext(SS, false);
-isDependent = isDependentScopeSpecifier(SS);
-Found.setContextRange(SS.getRange());
-  }
-
-  if (LookupCtx) {
-// Perform "qualified" name lookup into the declaration context we
-// computed, which is either the type of the base of a member access
-// expression or the declaration context associated with a prior
-// nested-name-specifier.
-
-// The declaration context must be complete.
-if (!LookupCtx->isDependentContext() &&
-RequireCompleteDeclContext(SS, LookupCtx))
-  return false;
-
-LookupQualifiedName(Found, LookupCtx);
-  } else if (isDependent) {
-return false;
-  } else {
-LookupName(Found, S);
-  }
-  Found.suppressDiagnostics();
-
-  ret

[clang] 249bd21 - [StaticAnalyzer] Remove several unused declarations

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

Author: Kazu Hirata
Date: 2023-06-13T00:24:44-07:00
New Revision: 249bd21c937144686b75a38565b49c6ea51a20bf

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

LOG: [StaticAnalyzer] Remove several unused declarations

The function definition of GenerateAutoTransition was removed by:

  commit b1d3d968725baf28a00b12aad760434036cbe704
  Author: Anna Zaks 
  Date:   Thu Oct 27 00:59:23 2011 +

The function definitions of enqueueEndOfPath and GenerateCallExitNode
were removed by:

  commit 0ec04bf73885df3e10bd7fcd5c8ce901cad7d76c
  Author: Anna Zaks 
  Date:   Thu Oct 27 00:59:28 2011 +

Added: 


Modified: 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h

Removed: 




diff  --git 
a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h 
b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
index 6e1db128e918c..b59917e9dfc9f 100644
--- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
+++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
@@ -239,11 +239,6 @@ class ExprEngine {
 return {blockPtr, currStmtIdx};
   }
 
-  void GenerateAutoTransition(ExplodedNode *N);
-  void enqueueEndOfPath(ExplodedNodeSet &S);
-  void GenerateCallExitNode(ExplodedNode *N);
-
-
   /// Dump graph to the specified filename.
   /// If filename is empty, generate a temporary one.
   /// \return The filename the graph is written into.



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


[clang] 9567cfd - [StaticAnalyzer] Remove unused function hasGlobalsOrParametersStorage

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

Author: Kazu Hirata
Date: 2023-06-13T00:24:47-07:00
New Revision: 9567cfd03432e3ac27201af6f5b479dda28cbf0c

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

LOG: [StaticAnalyzer] Remove unused function hasGlobalsOrParametersStorage

The last use was removed by:

  commit e2e37b9afc0a0a66a1594377a88221e115d95348
  Author: Ted Kremenek 
  Date:   Thu Jul 28 23:08:02 2011 +

Added: 


Modified: 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
clang/lib/StaticAnalyzer/Core/MemRegion.cpp

Removed: 




diff  --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h 
b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
index e982384b3fb00..9c4730a0b46f8 100644
--- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
+++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
@@ -136,8 +136,6 @@ class MemRegion : public llvm::FoldingSetNode {
   /// It might return null.
   const SymbolicRegion *getSymbolicBase() const;
 
-  bool hasGlobalsOrParametersStorage() const;
-
   bool hasStackStorage() const;
 
   bool hasStackNonParametersStorage() const;

diff  --git a/clang/lib/StaticAnalyzer/Core/MemRegion.cpp 
b/clang/lib/StaticAnalyzer/Core/MemRegion.cpp
index 7cda64d6a028a..5f054129c669c 100644
--- a/clang/lib/StaticAnalyzer/Core/MemRegion.cpp
+++ b/clang/lib/StaticAnalyzer/Core/MemRegion.cpp
@@ -1285,10 +1285,6 @@ bool MemRegion::hasStackParametersStorage() const {
   return isa(getMemorySpace());
 }
 
-bool MemRegion::hasGlobalsOrParametersStorage() const {
-  return isa(getMemorySpace());
-}
-
 // Strips away all elements and fields.
 // Returns the base region of them.
 const MemRegion *MemRegion::getBaseRegion() const {



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


[clang] a89895a - [Sema] Remove unused member variable MSVCGuidDecl

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

Author: Kazu Hirata
Date: 2023-06-13T00:24:49-07:00
New Revision: a89895ab5742819394e9af7f485e9188f8b24aa4

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

LOG: [Sema] Remove unused member variable MSVCGuidDecl

The last use was removed by:

  commit bab6df86aefc5ea4aa3895da7cf46be37add676d
  Author: Richard Smith 
  Date:   Sat Apr 11 22:15:29 2020 -0700

Added: 


Modified: 
clang/include/clang/Sema/Sema.h
clang/lib/Sema/Sema.cpp

Removed: 




diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index d088aea401c68..115157eaa99a3 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -1158,9 +1158,6 @@ class Sema final {
   /// The C++ "type_info" declaration, which is defined in \.
   RecordDecl *CXXTypeInfoDecl;
 
-  /// The MSVC "_GUID" struct, which is defined in MSVC header files.
-  RecordDecl *MSVCGuidDecl;
-
   /// The C++ "std::source_location::__impl" struct, defined in
   /// \.
   RecordDecl *StdSourceLocationImplDecl;

diff  --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp
index 532fb834bcf4f..e6507d8808011 100644
--- a/clang/lib/Sema/Sema.cpp
+++ b/clang/lib/Sema/Sema.cpp
@@ -203,9 +203,8 @@ Sema::Sema(Preprocessor &pp, ASTContext &ctxt, ASTConsumer 
&consumer,
   VisContext(nullptr), PragmaAttributeCurrentTargetDecl(nullptr),
   IsBuildingRecoveryCallExpr(false), LateTemplateParser(nullptr),
   LateTemplateParserCleanup(nullptr), OpaqueParser(nullptr), 
IdResolver(pp),
-  StdInitializerList(nullptr),
-  StdCoroutineTraitsCache(nullptr), CXXTypeInfoDecl(nullptr),
-  MSVCGuidDecl(nullptr), StdSourceLocationImplDecl(nullptr),
+  StdInitializerList(nullptr), StdCoroutineTraitsCache(nullptr),
+  CXXTypeInfoDecl(nullptr), StdSourceLocationImplDecl(nullptr),
   NSNumberDecl(nullptr), NSValueDecl(nullptr), NSStringDecl(nullptr),
   StringWithUTF8StringMethod(nullptr),
   ValueWithBytesObjCTypeMethod(nullptr), NSArrayDecl(nullptr),



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


[PATCH] D152077: [9/11][Clang][RISCV] Expand all variants for indexed strided segment store

2023-06-13 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/D152077/new/

https://reviews.llvm.org/D152077

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


[PATCH] D152226: [FunctionAttrs] Propagate some func/arg/ret attributes from caller to callsite (WIP)

2023-06-13 Thread Noah Goldstein via Phabricator via cfe-commits
goldstein.w.n marked 8 inline comments as done.
goldstein.w.n added inline comments.



Comment at: llvm/include/llvm/Transforms/Utils/InferCallsiteAttrs.h:28
+  // relatively high value is okay.
+  static constexpr unsigned kMaxChecks = UINT_MAX;
+

arsenm wrote:
> Does changing this to something meaningful change the compile time results?
lowered to 100, doesn't seem to help:
https://llvm-compile-time-tracker.com/compare.php?from=79feb6e78b818e33ec69abdc58c5f713d691554f&to=79e0b7e6f0547de9ad534c02869437160028af01&stat=instructions:u

Lowered to 10, doesn't seem to help either:
https://llvm-compile-time-tracker.com/compare.php?from=79feb6e78b818e33ec69abdc58c5f713d691554f&to=9e3f35bc8b6f0f261698ba1ce18229d1b8d9cdb6&stat=instructions%3Au

I'll drop unless you think there is a reason to keep it around.



Comment at: llvm/include/llvm/Transforms/Utils/InferCallsiteAttrs.h:63
+  bool checkCallerHasFnAttr(Attribute::AttrKind Attr) const {
+return (CxtCB && CxtCB->hasFnAttr(Attr)) || Caller->hasFnAttribute(Attr);
+  };

arsenm wrote:
> Without looking at the rest of the context I would assume CxtB is always 
> valid if the class is valid and all the null checks should be dropped
Not quite, so `CxtB` is used to specify propagation of function attributes from 
a specific callsite. This may be useful in inline. i.e if we have:

foo -> bar -> baz
and
fiz -> bar -> buz

If `bar` in `foo` is getting inlined, we can propagate not only the function 
attributes of `bar`, but also the callsite attributes of that specific call to 
`bar` to any callsites (so `baz`).

At the moment its always null in fact.



Comment at: llvm/lib/Transforms/Utils/InferCallsiteAttrs.cpp:343
+  // have derived from an argument. Finally, allocas/leaked mallocs in general
+  // are difficult (so we avoid them entirely). Callsites can arbitrarily
+  // store pointers in allocas for use later without violating a nocapture

arsenm wrote:
> 
I think callsite is regularly refererred to as singular word (in other files 
too) so prefer to keep as is. That okay?



Comment at: llvm/lib/Transforms/Utils/InferCallsiteAttrs.cpp:357
+  // the caller will apply to the callsites throw. If the caller has a landing
+  // padd, its possible for the callsite to capture a pointer in a throw that
+  // is later cleared by the caller.

arsenm wrote:
> 
did 'pad' -> 'padd' but prefer to keep callsite as one word



Comment at: llvm/lib/Transforms/Utils/InferCallsiteAttrs.cpp:692
+  else
+memset(&CurFnInfo, kMaybe, sizeof(CurFnInfo));
+  Caller = ParentFunc;

arsenm wrote:
> Not very C++y, use the default constructor?
If `PreserveCache` is true, then we can redo same function (non-sequentially) 
and get saved analysis. If you think this is meaningless and we will always do 
one-off functions I can change to just construct with a caller (although I 
think for inlining this might come up).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152226

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


[PATCH] D152226: [FunctionAttrs] Propagate some func/arg/ret attributes from caller to callsite (WIP)

2023-06-13 Thread Noah Goldstein via Phabricator via cfe-commits
goldstein.w.n updated this revision to Diff 530798.
goldstein.w.n added a comment.

fixes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152226

Files:
  clang/test/CodeGen/LoongArch/inline-asm-constraints.c
  clang/test/CodeGen/LoongArch/inline-asm-operand-modifiers.c
  clang/test/CodeGen/LoongArch/intrinsic-la32.c
  clang/test/CodeGen/LoongArch/intrinsic-la64.c
  clang/test/CodeGen/PowerPC/builtins-ppc-build-pair-mma.c
  clang/test/CodeGen/PowerPC/builtins-ppc-pair-mma.c
  
clang/test/CodeGen/PowerPC/builtins-ppc-xlcompat-LoadReseve-StoreCond-64bit-only.c
  clang/test/CodeGen/PowerPC/builtins-ppc-xlcompat-LoadReseve-StoreCond.c
  clang/test/CodeGen/PowerPC/ppc64-inline-asm.c
  clang/test/CodeGen/RISCV/riscv-inline-asm.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vwrite-csr.c
  clang/test/CodeGen/X86/fma-builtins-constrained.c
  clang/test/CodeGen/X86/ms-x86-intrinsics.c
  clang/test/CodeGen/aarch64-bf16-ldst-intrinsics.c
  clang/test/CodeGen/aarch64-ls64-inline-asm.c
  clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_ldnt1.c
  clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_ldnt1sb.c
  clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_ldnt1sh.c
  clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_ldnt1sw.c
  clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_ldnt1ub.c
  clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_ldnt1uh.c
  clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_ldnt1uw.c
  clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_stnt1.c
  clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_stnt1b.c
  clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_stnt1h.c
  clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_stnt1w.c
  clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_whilege.c
  clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_whilegt.c
  clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_whilerw-bfloat.c
  clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_whilerw.c
  clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_whilewr-bfloat.c
  clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_whilewr.c
  
clang/test/CodeGen/aarch64_neon_sve_bridge_intrinsics/acle_neon_sve_bridge_dup_neonq.c
  
clang/test/CodeGen/aarch64_neon_sve_bridge_intrinsics/acle_neon_sve_bridge_get_neonq.c
  
clang/test/CodeGen/aarch64_neon_sve_bridge_intrinsics/acle_neon_sve_bridge_set_neonq.c
  clang/test/CodeGen/attr-arm-sve-vector-bits-cast.c
  clang/test/CodeGen/attr-riscv-rvv-vector-bits-call.c
  clang/test/CodeGen/attr-riscv-rvv-vector-bits-cast.c
  clang/test/CodeGen/msp430-builtins.c
  clang/test/CodeGen/nofpclass.c
  clang/test/Headers/wasm.c
  llvm/include/llvm/Transforms/Utils/InferCallsiteAttrs.h
  llvm/lib/Transforms/IPO/FunctionAttrs.cpp
  llvm/lib/Transforms/Utils/CMakeLists.txt
  llvm/lib/Transforms/Utils/InferCallsiteAttrs.cpp
  llvm/test/Other/cgscc-devirt-iteration.ll
  llvm/test/Transforms/FunctionAttrs/nonnull.ll
  llvm/test/Transforms/FunctionAttrs/readattrs.ll
  llvm/test/Transforms/FunctionAttrs/willreturn-callsites.ll
  llvm/test/Transforms/MergeFunc/mergefunc-preserve-debug-info.ll
  llvm/test/Transforms/PhaseOrdering/X86/loop-idiom-vs-indvars.ll
  llvm/test/Transforms/PhaseOrdering/memset-tail.ll

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


[PATCH] D152764: [clang-tidy] Reserved-identifier: Improved AllowedIdentifiers option to support regular expressions

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

Except pointed out issues, looks fine.




Comment at: 
clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.cpp:49-50
+  for (const auto &Identifier : AllowedIdentifiers) {
+if (!llvm::Regex(Identifier).isValid())
+  configurationDiag("Invalid allowed identifier regex '%0'") << Identifier;
+AllowedIdentifiersRegex.emplace_back(Identifier.str());

avoid double compilation of regexp.
Simply:
```
AllowedIdentifiersRegex.emplace_back(Identifier.str());
if (!AllowedIdentifiersRegex.back().isValid()) {
   AllowedIdentifiersRegex.pop_back();
configurationDiag("Invalid allowed identifier regex '%0'") << Identifier;
}
```



Comment at: clang-tools-extra/docs/ReleaseNotes.rst:414-416
+- Improved option `AllowedIdentifiers` from :doc:`bugprone-reserved-identifier
+  ` to support regular
+  expressions.

Sort this entry by full check name.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152764

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


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

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

The CI failure is unrelated and I suppose should be already fixed by aa28875 
.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147717

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


[PATCH] D152782: [CodeGen] Remove unused declaration/function GetOrCreateRTTIProxyGlobalVariable

2023-06-13 Thread Kazu Hirata via Phabricator via cfe-commits
kazu created this revision.
Herald added a project: All.
kazu requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The last use removed by:

  commit 46f366494f3ca8cc98daa6fb4f29c7c446c176b6
  Author: Fangrui Song 
  Date:   Sat May 20 08:24:20 2023 -0700

This patch also removes RTTIProxyMap, which becomes unused once I
remove GetOrCreateRTTIProxyGlobalVariable.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152782

Files:
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenModule.h


Index: clang/lib/CodeGen/CodeGenModule.h
===
--- clang/lib/CodeGen/CodeGenModule.h
+++ clang/lib/CodeGen/CodeGenModule.h
@@ -590,8 +590,6 @@
   MetadataTypeMap VirtualMetadataIdMap;
   MetadataTypeMap GeneralizedMetadataIdMap;
 
-  llvm::DenseMap RTTIProxyMap;
-
   // Helps squashing blocks of TopLevelStmtDecl into a single llvm::Function
   // when used with -fincremental-extensions.
   std::pair, const TopLevelStmtDecl *>
@@ -1503,9 +1501,6 @@
   std::vector
   getMostBaseClasses(const CXXRecordDecl *RD);
 
-  llvm::GlobalVariable *
-  GetOrCreateRTTIProxyGlobalVariable(llvm::Constant *Addr);
-
   /// Get the declaration of std::terminate for the platform.
   llvm::FunctionCallee getTerminateFn();
 
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -2028,22 +2028,6 @@
   return MostBases.takeVector();
 }
 
-llvm::GlobalVariable *
-CodeGenModule::GetOrCreateRTTIProxyGlobalVariable(llvm::Constant *Addr) {
-  auto It = RTTIProxyMap.find(Addr);
-  if (It != RTTIProxyMap.end())
-return It->second;
-
-  auto *FTRTTIProxy = new llvm::GlobalVariable(
-  TheModule, Addr->getType(),
-  /*isConstant=*/true, llvm::GlobalValue::PrivateLinkage, Addr,
-  "__llvm_rtti_proxy");
-  FTRTTIProxy->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global);
-
-  RTTIProxyMap[Addr] = FTRTTIProxy;
-  return FTRTTIProxy;
-}
-
 void CodeGenModule::SetLLVMFunctionAttributesForDefinition(const Decl *D,
llvm::Function *F) {
   llvm::AttrBuilder B(F->getContext());


Index: clang/lib/CodeGen/CodeGenModule.h
===
--- clang/lib/CodeGen/CodeGenModule.h
+++ clang/lib/CodeGen/CodeGenModule.h
@@ -590,8 +590,6 @@
   MetadataTypeMap VirtualMetadataIdMap;
   MetadataTypeMap GeneralizedMetadataIdMap;
 
-  llvm::DenseMap RTTIProxyMap;
-
   // Helps squashing blocks of TopLevelStmtDecl into a single llvm::Function
   // when used with -fincremental-extensions.
   std::pair, const TopLevelStmtDecl *>
@@ -1503,9 +1501,6 @@
   std::vector
   getMostBaseClasses(const CXXRecordDecl *RD);
 
-  llvm::GlobalVariable *
-  GetOrCreateRTTIProxyGlobalVariable(llvm::Constant *Addr);
-
   /// Get the declaration of std::terminate for the platform.
   llvm::FunctionCallee getTerminateFn();
 
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -2028,22 +2028,6 @@
   return MostBases.takeVector();
 }
 
-llvm::GlobalVariable *
-CodeGenModule::GetOrCreateRTTIProxyGlobalVariable(llvm::Constant *Addr) {
-  auto It = RTTIProxyMap.find(Addr);
-  if (It != RTTIProxyMap.end())
-return It->second;
-
-  auto *FTRTTIProxy = new llvm::GlobalVariable(
-  TheModule, Addr->getType(),
-  /*isConstant=*/true, llvm::GlobalValue::PrivateLinkage, Addr,
-  "__llvm_rtti_proxy");
-  FTRTTIProxy->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global);
-
-  RTTIProxyMap[Addr] = FTRTTIProxy;
-  return FTRTTIProxy;
-}
-
 void CodeGenModule::SetLLVMFunctionAttributesForDefinition(const Decl *D,
llvm::Function *F) {
   llvm::AttrBuilder B(F->getContext());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D151761: clang-format: Add AlignConsecutiveShortCaseStatements

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

In D151761#4410998 , 
@HazardyKnusperkeks wrote:

> In D151761#4410158 , @galenelias 
> wrote:
>
>> Yah, I think leaving it open would be my preference at this point.  Not sure 
>> how to properly document that though?  Just be explicit in the tests?  
>> Mention it in `alignConsecutiveShortCaseStatements`?  Should it be 
>> documented in the generated documentation (that feels a bit heavy)?
>
> It will be a known issue, and thus it should be documented explicitly in my 
> opinion. Otherwise there will be bug reports. So I would do:
>
> - Mention it in the options documentation.
> - Add a FIXME comment where the fix most likely would be applied.
> - Comment on test cases that they have to be changed once this is fixed - or 
> add tests which are within an `#if 0`, don't know what @MyDeveloperDay or 
> @owenpan like better.

I prefer the latter, and IIRC @MyDeveloperDay doesn't use the former.


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

https://reviews.llvm.org/D151761

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


[clang] bba6ea8 - [C++20] Claim full support for consteval again

2023-06-13 Thread Mariya Podchishchaeva via cfe-commits

Author: Mariya Podchishchaeva
Date: 2023-06-13T03:50:24-04:00
New Revision: bba6ea8c2d56faad49936b95a57c7499095b920b

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

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

After resolving several outstanding issues now is the time to mark it as
fully supported.

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

Reviewed By: aaron.ballman, cor3ntin, #clang-language-wg

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

Added: 


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

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 32f41382a35cb..a6b4a79b00a19 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -111,6 +111,7 @@ C++20 Feature Support
   SFINAE.
 - Clang now supports `requires cplusplus20` for module maps.
 - Implemented missing parts of `P2002R1: Consistent comparison operators 
`_
+- Clang now defines `__cpp_consteval` macro.
 
 C++23 Feature Support
 ^

diff  --git a/clang/lib/Frontend/InitPreprocessor.cpp 
b/clang/lib/Frontend/InitPreprocessor.cpp
index 2d5be2b6242b8..31f9077703cba 100644
--- a/clang/lib/Frontend/InitPreprocessor.cpp
+++ b/clang/lib/Frontend/InitPreprocessor.cpp
@@ -683,7 +683,7 @@ static void InitializeCPlusPlusFeatureTestMacros(const 
LangOptions &LangOpts,
 // Refer to the discussion of this at https://reviews.llvm.org/D128619.
 Builder.defineMacro("__cpp_concepts", "201907L");
 Builder.defineMacro("__cpp_conditional_explicit", "201806L");
-// Builder.defineMacro("__cpp_consteval", "202211L");
+Builder.defineMacro("__cpp_consteval", "202211L");
 Builder.defineMacro("__cpp_constexpr_dynamic_alloc", "201907L");
 Builder.defineMacro("__cpp_constinit", "201907L");
 Builder.defineMacro("__cpp_impl_coroutine", "201902L");

diff  --git a/clang/test/Lexer/cxx-features.cpp 
b/clang/test/Lexer/cxx-features.cpp
index 5d157ea2fac1c..6d4cb25044c62 100644
--- a/clang/test/Lexer/cxx-features.cpp
+++ b/clang/test/Lexer/cxx-features.cpp
@@ -78,8 +78,7 @@
 #error "wrong value for __cpp_conditional_explicit"
 #endif
 
-#if check(consteval, 0, 0, 0, 0, 0, 0)
-// FIXME: 201811 in C++20
+#if check(consteval, 0, 0, 0, 0, 202211, 202211)
 #error "wrong value for __cpp_consteval"
 #endif
 

diff  --git a/clang/www/cxx_status.html b/clang/www/cxx_status.html
index 9bcb02d520873..d2ef73f821ceb 100755
--- a/clang/www/cxx_status.html
+++ b/clang/www/cxx_status.html
@@ -643,14 +643,7 @@ C++20 implementation status
 
   Immediate functions (consteval)
   https://wg21.link/p1073r3";>P1073R3
-  
-Clang 15 (Partial)
-  Clang still incorrectly defers some consteval executions to runtime,
-  resulting in CodeGen crashes. Additionally, Clang does not properly
-  handle default arguments in consteval functions under all
-  circumstances.
-
-  
+  Clang 17
 

 https://wg21.link/p1937r2";>P1937R2



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


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

2023-06-13 Thread Mariya Podchishchaeva 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 rGbba6ea8c2d56: [C++20] Claim full support for consteval again 
(authored by Fznamznon).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147717

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


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

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


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

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

[PATCH] D152226: [FunctionAttrs] Propagate some func/arg/ret attributes from caller to callsite (WIP)

2023-06-13 Thread Nikita Popov via Phabricator via cfe-commits
nikic added inline comments.



Comment at: llvm/lib/Transforms/Utils/InferCallsiteAttrs.cpp:597
+  // callsite violating the constraint.
+  if (checkCallerDoesNotAccessMemory() && !CB->doesNotAccessMemory()) {
+// Wait until we know we actually need it to do potentially expensive

For these you generally want to query `getMemoryEffects()` on the caller/callee 
once and then work on that representation, instead of doing separate queries 
for everything. This may allow more precise handling and likely reduces the 
compile-time impact, as doing these attribute lookups is quite expensive.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152226

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


[PATCH] D152078: [10/11][Clang][RISCV] Expand all variants for vget on tuple types

2023-06-13 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/D152078/new/

https://reviews.llvm.org/D152078

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


[PATCH] D152079: [11/11][Clang][RISCV] Expand all variants for vset on tuple types

2023-06-13 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/D152079/new/

https://reviews.llvm.org/D152079

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


[PATCH] D152785: [COFF] Support -gsplit-dwarf for COFF on Windows

2023-06-13 Thread Haohai, Wen via Phabricator via cfe-commits
HaohaiWen created this revision.
Herald added a subscriber: hiraditya.
Herald added a project: All.
HaohaiWen requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, jplehr, sstefan1, MaskRay, 
aheejin.
Herald added a reviewer: jdoerfert.
Herald added projects: clang, LLVM.

D152340  has split WinCOFFObjectWriter to 
WinCOFFWriter. This patch adds
another WinCOFFWriter as DwoWriter to write Dwo sections to dwo file.
Driver options are also updated accordingly to support -gsplit-dwarf in
CL mode.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152785

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/split-debug.c
  llvm/include/llvm/MC/MCWinCOFFObjectWriter.h
  llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
  llvm/lib/MC/MCAsmBackend.cpp
  llvm/lib/MC/WinCOFFObjectWriter.cpp
  llvm/test/DebugInfo/COFF/dwarf-headers.ll
  llvm/test/DebugInfo/COFF/fission-cu.ll
  llvm/test/DebugInfo/COFF/fission-sections.ll

Index: llvm/test/DebugInfo/COFF/fission-sections.ll
===
--- /dev/null
+++ llvm/test/DebugInfo/COFF/fission-sections.ll
@@ -0,0 +1,42 @@
+; RUN: llc -split-dwarf-file=baz.dwo -split-dwarf-output=%t.dwo -O0 %s -mtriple=x86_64-unknown-windows-msvc -filetype=obj -o %t
+; RUN: llvm-objdump -h %t | FileCheck --check-prefix=OBJ %s
+; RUN: llvm-objdump -h %t.dwo | FileCheck --check-prefix=DWO %s
+
+; This test is derived from test/DebugInfo/X86/fission-cu.ll
+; But it checks that the output objects have the expected sections
+
+source_filename = "test/DebugInfo/X86/fission-cu.ll"
+
+@a = common global i32 0, align 4, !dbg !0
+
+!llvm.dbg.cu = !{!4}
+!llvm.module.flags = !{!7}
+
+!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
+!1 = !DIGlobalVariable(name: "a", scope: null, file: !2, line: 1, type: !3, isLocal: false, isDefinition: true)
+!2 = !DIFile(filename: "baz.c", directory: "e:\\llvm-project\\tmp")
+!3 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
+!4 = distinct !DICompileUnit(language: DW_LANG_C99, file: !2, producer: "clang version 3.3 (trunk 169021) (llvm/trunk 169020)", isOptimized: false, runtimeVersion: 0, splitDebugFilename: "baz.dwo", emissionKind: FullDebug, enums: !5, retainedTypes: !5, globals: !6, imports: !5)
+!5 = !{}
+!6 = !{!0}
+!7 = !{i32 1, !"Debug Info Version", i32 3}
+
+; CHECK-LABEL: Sections:
+
+; OBJ: Idx Name
+; OBJ-NEXT:  0 .text
+; OBJ-NEXT:  1 .data
+; OBJ-NEXT:  2 .bss
+; OBJ-NEXT:  3 .debug_abbrev
+; OBJ-NEXT:  4 .debug_info
+; OBJ-NEXT:  5 .debug_str
+; OBJ-NEXT:  6 .debug_addr
+; OBJ-NEXT:  7 .debug_pubnames
+; OBJ-NEXT:  8 .debug_pubtypes
+; OBJ-NEXT:  9 .debug_line
+
+; DWO:  Idx Name
+; DWO-NEXT:   0 .debug_str.dwo
+; DWO-NEXT:   1 .debug_str_offsets.dwo
+; DWO-NEXT:   2 .debug_info.dwo
+; DWO-NEXT:   3 .debug_abbrev.dwo
Index: llvm/test/DebugInfo/COFF/fission-cu.ll
===
--- /dev/null
+++ llvm/test/DebugInfo/COFF/fission-cu.ll
@@ -0,0 +1,121 @@
+; RUN: llc -split-dwarf-file=baz.dwo -O0 %s -mtriple=x86_64-unknown-windows-msvc -filetype=obj -o %t
+; RUN: llvm-dwarfdump -v -all %t | FileCheck %s
+; RUN: llvm-readobj --relocations %t | FileCheck --check-prefix=OBJ %s
+; RUN: llvm-objdump -h %t | FileCheck --check-prefix=HDR %s
+
+; This test is derived from test/DebugInfo/X86/fission-cu.ll
+
+source_filename = "test/DebugInfo/X86/fission-cu.ll"
+
+@a = common global i32 0, align 4, !dbg !0
+
+!llvm.dbg.cu = !{!4}
+!llvm.module.flags = !{!7}
+
+!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
+!1 = !DIGlobalVariable(name: "a", scope: null, file: !2, line: 1, type: !3, isLocal: false, isDefinition: true)
+!2 = !DIFile(filename: "baz.c", directory: "e:\\llvm-project\\tmp")
+!3 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
+!4 = distinct !DICompileUnit(language: DW_LANG_C99, file: !2, producer: "clang version 3.3 (trunk 169021) (llvm/trunk 169020)", isOptimized: false, runtimeVersion: 0, splitDebugFilename: "baz.dwo", emissionKind: FullDebug, enums: !5, retainedTypes: !5, globals: !6, imports: !5)
+!5 = !{}
+; Check that the skeleton compile unit contains the proper attributes:
+; This DIE has the following attributes: DW_AT_comp_dir, DW_AT_stmt_list,
+; DW_AT_low_pc, DW_AT_high_pc, DW_AT_ranges, DW_AT_dwo_name, DW_AT_dwo_id,
+; DW_AT_ranges_base, DW_AT_addr_base.
+
+; CHECK: .debug_abbrev contents:
+; CHECK: Abbrev table for offset: 0x
+; CHECK: [1] DW_TAG_compile_unit DW_CHILDREN_no
+; CHECK: DW_AT_stmt_list DW_FORM_sec_offset
+; CHECK: DW_AT_comp_dir  DW_FORM_strp
+; CHECK: DW_AT_GNU_dwo_name  DW_FORM_strp
+; CHECK: DW_AT_GNU_dwo_idDW_FORM_data8
+
+; Check that we're using the right forms.
+; CHECK: .debug_abbrev.dwo contents:
+; 

[PATCH] D150997: [llvm] Split out DenseMapInfo specialization

2023-06-13 Thread Elliot Goodrich via Phabricator via cfe-commits
IncludeGuardian updated this revision to Diff 530819.

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

https://reviews.llvm.org/D150997

Files:
  clang-tools-extra/include-cleaner/include/clang-include-cleaner/Types.h
  flang/include/flang/Optimizer/HLFIR/HLFIROps.h
  llvm/include/llvm/ADT/DenseMapInfo.h
  llvm/include/llvm/CodeGen/CallingConvLower.h
  llvm/include/llvm/ExecutionEngine/Orc/LLJIT.h
  llvm/include/llvm/Object/DXContainer.h
  llvm/include/llvm/Transforms/Scalar/SROA.h
  llvm/unittests/ADT/DenseMapTest.cpp
  mlir/include/mlir/IR/AsmState.h
  mlir/include/mlir/Transforms/SROA.h

Index: mlir/include/mlir/Transforms/SROA.h
===
--- mlir/include/mlir/Transforms/SROA.h
+++ mlir/include/mlir/Transforms/SROA.h
@@ -13,9 +13,10 @@
 #include "mlir/Interfaces/MemorySlotInterfaces.h"
 #include "mlir/Support/LogicalResult.h"
 #include "llvm/ADT/Statistic.h"
+#include 

 namespace mlir {

 /// Statistics collected while applying SROA.
 struct SROAStatistics {
   /// Total amount of memory slots destructured.
Index: mlir/include/mlir/IR/AsmState.h
===
--- mlir/include/mlir/IR/AsmState.h
+++ mlir/include/mlir/IR/AsmState.h
@@ -20,20 +20,21 @@
 #include "llvm/ADT/StringMap.h"

 #include 
+#include 

 namespace mlir {
 class AsmResourcePrinter;
 class AsmDialectResourceHandle;
 class Operation;

 namespace detail {
 class AsmStateImpl;
 } // namespace detail

 //===--===//
 // Resources
 //===--===//

 /// The following classes enable support for parsing and printing resources
 /// within MLIR assembly formats. Resources are a mechanism by which dialects,
 /// and external clients, may attach additional information when parsing or
Index: llvm/unittests/ADT/DenseMapTest.cpp
===
--- llvm/unittests/ADT/DenseMapTest.cpp
+++ llvm/unittests/ADT/DenseMapTest.cpp
@@ -8,20 +8,21 @@

 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/DenseMapInfo.h"
+#include "llvm/ADT/DenseMapInfoVariant.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 #include 
 #include 
 #include 
 #include 

 using namespace llvm;

 namespace {

 uint32_t getTestKey(int i, uint32_t *) { return i; }
 uint32_t getTestValue(int i, uint32_t *) { return 42 + i; }

 uint32_t *getTestKey(int i, uint32_t **) {
   static uint32_t dummy_arr1[8192];
   assert(i < 8192 && "Only support 8192 dummy keys.");
Index: llvm/include/llvm/Transforms/Scalar/SROA.h
===
--- llvm/include/llvm/Transforms/Scalar/SROA.h
+++ llvm/include/llvm/Transforms/Scalar/SROA.h
@@ -21,10 +21,11 @@
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/IR/PassManager.h"
 #include "llvm/IR/ValueHandle.h"
+#include 
 #include 

 namespace llvm {

 class AllocaInst;
 class LoadInst;
 class StoreInst;
Index: llvm/include/llvm/Object/DXContainer.h
===
--- llvm/include/llvm/Object/DXContainer.h
+++ llvm/include/llvm/Object/DXContainer.h
@@ -21,13 +21,14 @@
 #include "llvm/Support/Error.h"
 #include "llvm/Support/MemoryBufferRef.h"
 #include "llvm/TargetParser/Triple.h"
+#include 

 namespace llvm {
 namespace object {

 namespace DirectX {
 class PSVRuntimeInfo {

   // This class provides a view into the underlying resource array. The Resource
   // data is little-endian encoded and may not be properly aligned to read
   // directly from. The dereference operator creates a copy of the data and byte
Index: llvm/include/llvm/ExecutionEngine/Orc/LLJIT.h
===
--- llvm/include/llvm/ExecutionEngine/Orc/LLJIT.h
+++ llvm/include/llvm/ExecutionEngine/Orc/LLJIT.h
@@ -22,74 +22,75 @@
 #include "llvm/ExecutionEngine/Orc/ThreadSafeModule.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/ThreadPool.h"
+#include 

 namespace llvm {
 namespace orc {

 class LLJITBuilderState;
 class LLLazyJITBuilderState;
 class ObjectTransformLayer;
 class ExecutorProcessControl;

 /// A pre-fabricated ORC JIT stack that can serve as an alternative to MCJIT.
 ///
 /// Create instances using LLJITBuilder.
 class LLJIT {
   template  friend class LLJITBuilderSetters;

   friend Expected setUpGenericLLVMIRPlatform(LLJIT &J);

 public:
   /// Initializer support for LLJIT.
   class PlatformSupport {
   public:
 virtual ~PlatformSupport();

 virtual Error initialize(JITDylib &JD) = 0;

 virtual Error deinitialize(JITDylib &JD) = 0;

   protected:
 static void setInitTransform(LLJIT &J,
  IRTransformLayer::TransformFunction T);
   };

   /// Destruct this instance. If a multi-threaded instance, waits for all
   /// compile threads to complete.

[PATCH] D152788: [Clang] Show type in enum out of range diagnostic

2023-06-13 Thread Dimitry Andric via Phabricator via cfe-commits
dim created this revision.
dim added reviewers: aaron.ballman, erichkeane, shafik, thakis.
Herald added a project: All.
dim requested review of this revision.
Herald added a project: clang.

When the diagnostic for an out of range enum value is printed, it
currently does not show the actual enum type in question, for example:

  v8/src/base/bit-field.h:43:29: error: integer value 7 is outside the valid 
range of values [0, 3] for this enumeration type [-Wenum-constexpr-conversion]
static constexpr T kMax = static_cast(kNumValues - 1);
  ^

This can make it cumbersome to find the cause for the problem. Add the
enum type to the diagnostic message, to make it easier.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152788

Files:
  clang/include/clang/Basic/DiagnosticASTKinds.td
  clang/lib/AST/ExprConstant.cpp
  clang/test/SemaCXX/constant-expression-cxx11.cpp
  clang/test/SemaCXX/cxx2a-consteval.cpp

Index: clang/test/SemaCXX/cxx2a-consteval.cpp
===
--- clang/test/SemaCXX/cxx2a-consteval.cpp
+++ clang/test/SemaCXX/cxx2a-consteval.cpp
@@ -900,7 +900,7 @@
 namespace GH50055 {
 enum E {e1=0, e2=1};
 consteval int testDefaultArgForParam(E eParam = (E)-1) {
-// expected-error@-1 {{integer value -1 is outside the valid range of values [0, 1] for this enumeration type}}
+// expected-error@-1 {{integer value -1 is outside the valid range of values [0, 1] for the enumeration type 'E'}}
   return (int)eParam;
 }
 
Index: clang/test/SemaCXX/constant-expression-cxx11.cpp
===
--- clang/test/SemaCXX/constant-expression-cxx11.cpp
+++ clang/test/SemaCXX/constant-expression-cxx11.cpp
@@ -2440,38 +2440,38 @@
 void testValueInRangeOfEnumerationValues() {
   constexpr E1 x1 = static_cast(-8);
   constexpr E1 x2 = static_cast(8);
-  // expected-error@-1 {{integer value 8 is outside the valid range of values [-8, 7] for this enumeration type}}
+  // expected-error@-1 {{integer value 8 is outside the valid range of values [-8, 7] for the enumeration type 'E1'}}
   E1 x2b = static_cast(8); // ok, not a constant expression context
 
   constexpr E2 x3 = static_cast(-8);
-  // expected-error@-1 {{integer value -8 is outside the valid range of values [0, 7] for this enumeration type}}
+  // expected-error@-1 {{integer value -8 is outside the valid range of values [0, 7] for the enumeration type 'E2'}}
   constexpr E2 x4 = static_cast(0);
   constexpr E2 x5 = static_cast(8);
-  // expected-error@-1 {{integer value 8 is outside the valid range of values [0, 7] for this enumeration type}}
+  // expected-error@-1 {{integer value 8 is outside the valid range of values [0, 7] for the enumeration type 'E2'}}
 
   constexpr E3 x6 = static_cast(-2048);
   constexpr E3 x7 = static_cast(-8);
   constexpr E3 x8 = static_cast(0);
   constexpr E3 x9 = static_cast(8);
   constexpr E3 x10 = static_cast(2048);
-  // expected-error@-1 {{integer value 2048 is outside the valid range of values [-2048, 2047] for this enumeration type}}
+  // expected-error@-1 {{integer value 2048 is outside the valid range of values [-2048, 2047] for the enumeration type 'E3'}}
 
   constexpr E4 x11 = static_cast(0);
   constexpr E4 x12 = static_cast(1);
   constexpr E4 x13 = static_cast(2);
-  // expected-error@-1 {{integer value 2 is outside the valid range of values [0, 1] for this enumeration type}}
+  // expected-error@-1 {{integer value 2 is outside the valid range of values [0, 1] for the enumeration type 'E4'}}
 
   constexpr EEmpty x14 = static_cast(0);
   constexpr EEmpty x15 = static_cast(1);
   constexpr EEmpty x16 = static_cast(2);
-  // expected-error@-1 {{integer value 2 is outside the valid range of values [0, 1] for this enumeration type}}
+  // expected-error@-1 {{integer value 2 is outside the valid range of values [0, 1] for the enumeration type 'EEmpty'}}
 
   constexpr EFixed x17 = static_cast(100);
   constexpr EScoped x18 = static_cast(100);
 
   constexpr EMaxInt x19 = static_cast(__INT_MAX__-1);
   constexpr EMaxInt x20 = static_cast((long)__INT_MAX__+1);
-  // expected-error@-1 {{integer value 2147483648 is outside the valid range of values [-2147483648, 2147483647] for this enumeration type}}
+  // expected-error@-1 {{integer value 2147483648 is outside the valid range of values [-2147483648, 2147483647] for the enumeration type 'EMaxInt'}}
 
   const NumberType neg_one = (NumberType) ((NumberType) 0 - (NumberType) 1); // ok, not a constant expression context
 }
@@ -2494,4 +2494,4 @@
 GH50055::E2 GlobalInitNotCE1 = (GH50055::E2)-1; // ok, not a constant expression context
 GH50055::E2 GlobalInitNotCE2 = GH50055::testDefaultArgForParam(); // ok, not a constant expression context
 constexpr GH50055::E2 GlobalInitCE = (GH50055::E2)-1;
-// expected-error@-1 {{integer value -1 is outside the valid range of values [0, 7] for this enumeration type}}
+// expected-error@-1 {{in

[PATCH] D152785: [COFF] Support -gsplit-dwarf for COFF on Windows

2023-06-13 Thread Haohai, Wen via Phabricator via cfe-commits
HaohaiWen updated this revision to Diff 530825.
HaohaiWen added a comment.

Fix typo


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152785

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/split-debug.c
  llvm/include/llvm/MC/MCWinCOFFObjectWriter.h
  llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
  llvm/lib/MC/MCAsmBackend.cpp
  llvm/lib/MC/WinCOFFObjectWriter.cpp
  llvm/test/DebugInfo/COFF/dwarf-headers.ll
  llvm/test/DebugInfo/COFF/fission-cu.ll
  llvm/test/DebugInfo/COFF/fission-sections.ll

Index: llvm/test/DebugInfo/COFF/fission-sections.ll
===
--- /dev/null
+++ llvm/test/DebugInfo/COFF/fission-sections.ll
@@ -0,0 +1,42 @@
+; RUN: llc -split-dwarf-file=baz.dwo -split-dwarf-output=%t.dwo -O0 %s -mtriple=x86_64-unknown-windows-msvc -filetype=obj -o %t
+; RUN: llvm-objdump -h %t | FileCheck --check-prefix=OBJ %s
+; RUN: llvm-objdump -h %t.dwo | FileCheck --check-prefix=DWO %s
+
+; This test is derived from test/DebugInfo/X86/fission-cu.ll
+; But it checks that the output objects have the expected sections
+
+source_filename = "test/DebugInfo/X86/fission-cu.ll"
+
+@a = common global i32 0, align 4, !dbg !0
+
+!llvm.dbg.cu = !{!4}
+!llvm.module.flags = !{!7}
+
+!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
+!1 = !DIGlobalVariable(name: "a", scope: null, file: !2, line: 1, type: !3, isLocal: false, isDefinition: true)
+!2 = !DIFile(filename: "baz.c", directory: "e:\\llvm-project\\tmp")
+!3 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
+!4 = distinct !DICompileUnit(language: DW_LANG_C99, file: !2, producer: "clang version 3.3 (trunk 169021) (llvm/trunk 169020)", isOptimized: false, runtimeVersion: 0, splitDebugFilename: "baz.dwo", emissionKind: FullDebug, enums: !5, retainedTypes: !5, globals: !6, imports: !5)
+!5 = !{}
+!6 = !{!0}
+!7 = !{i32 1, !"Debug Info Version", i32 3}
+
+; CHECK-LABEL: Sections:
+
+; OBJ: Idx Name
+; OBJ-NEXT:  0 .text
+; OBJ-NEXT:  1 .data
+; OBJ-NEXT:  2 .bss
+; OBJ-NEXT:  3 .debug_abbrev
+; OBJ-NEXT:  4 .debug_info
+; OBJ-NEXT:  5 .debug_str
+; OBJ-NEXT:  6 .debug_addr
+; OBJ-NEXT:  7 .debug_pubnames
+; OBJ-NEXT:  8 .debug_pubtypes
+; OBJ-NEXT:  9 .debug_line
+
+; DWO:  Idx Name
+; DWO-NEXT:   0 .debug_str.dwo
+; DWO-NEXT:   1 .debug_str_offsets.dwo
+; DWO-NEXT:   2 .debug_info.dwo
+; DWO-NEXT:   3 .debug_abbrev.dwo
Index: llvm/test/DebugInfo/COFF/fission-cu.ll
===
--- /dev/null
+++ llvm/test/DebugInfo/COFF/fission-cu.ll
@@ -0,0 +1,121 @@
+; RUN: llc -split-dwarf-file=baz.dwo -O0 %s -mtriple=x86_64-unknown-windows-msvc -filetype=obj -o %t
+; RUN: llvm-dwarfdump -v -all %t | FileCheck %s
+; RUN: llvm-readobj --relocations %t | FileCheck --check-prefix=OBJ %s
+; RUN: llvm-objdump -h %t | FileCheck --check-prefix=HDR %s
+
+; This test is derived from test/DebugInfo/X86/fission-cu.ll
+
+source_filename = "test/DebugInfo/X86/fission-cu.ll"
+
+@a = common global i32 0, align 4, !dbg !0
+
+!llvm.dbg.cu = !{!4}
+!llvm.module.flags = !{!7}
+
+!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
+!1 = !DIGlobalVariable(name: "a", scope: null, file: !2, line: 1, type: !3, isLocal: false, isDefinition: true)
+!2 = !DIFile(filename: "baz.c", directory: "e:\\llvm-project\\tmp")
+!3 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
+!4 = distinct !DICompileUnit(language: DW_LANG_C99, file: !2, producer: "clang version 3.3 (trunk 169021) (llvm/trunk 169020)", isOptimized: false, runtimeVersion: 0, splitDebugFilename: "baz.dwo", emissionKind: FullDebug, enums: !5, retainedTypes: !5, globals: !6, imports: !5)
+!5 = !{}
+; Check that the skeleton compile unit contains the proper attributes:
+; This DIE has the following attributes: DW_AT_comp_dir, DW_AT_stmt_list,
+; DW_AT_low_pc, DW_AT_high_pc, DW_AT_ranges, DW_AT_dwo_name, DW_AT_dwo_id,
+; DW_AT_ranges_base, DW_AT_addr_base.
+
+; CHECK: .debug_abbrev contents:
+; CHECK: Abbrev table for offset: 0x
+; CHECK: [1] DW_TAG_compile_unit DW_CHILDREN_no
+; CHECK: DW_AT_stmt_list DW_FORM_sec_offset
+; CHECK: DW_AT_comp_dir  DW_FORM_strp
+; CHECK: DW_AT_GNU_dwo_name  DW_FORM_strp
+; CHECK: DW_AT_GNU_dwo_idDW_FORM_data8
+
+; Check that we're using the right forms.
+; CHECK: .debug_abbrev.dwo contents:
+; CHECK: Abbrev table for offset: 0x
+; CHECK: [1] DW_TAG_compile_unit DW_CHILDREN_yes
+; CHECK: DW_AT_producer  DW_FORM_GNU_str_index
+; CHECK: DW_AT_language  DW_FORM_data2
+; CHECK: DW_AT_name  DW_FORM_GNU_str_index
+; CHECK: DW_AT_GNU_dwo_name  DW_FORM_GNU_str_index
+; CHECK-NOT: DW_AT_low_pc
+; CHECK-NOT: DW_AT_stmt_list
+; CHECK-NOT: DW_AT_comp_dir
+; CHECK: DW_AT_GNU_dwo_idDW_FORM_data8

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

2023-06-13 Thread Takuya Shimizu via Phabricator via cfe-commits
hazohelet added a comment.

In D152707#4413899 , @tbaeder wrote:

> Precommit-CI also found some problems on Windows

It's a littile surprising to me that clang outputs different diagnostics on 
windows. I suspect it might be related to the clang driver, so I'll try 
`%clang_cc1` as you suggested, and if it still fails on windows, I'll split the 
test into separate files to have completely same inputs as already-working 
tests in `test/Sema`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152707

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


[PATCH] D152628: [RISCV] Add __builtin_riscv_zip/unzip for Zbkb to match gcc.

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

I'm not super familiar with these builtins so this might be a silly question 
why are the new builtins added in this patch LiLi (long int) rather than ZiZi 
(int32_t) like the old `_32` suffixed builtins?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152628

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


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

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

Rebased past rG34d7acd444b8 
 (which 
conflicted with it, though trivially) and attempted to fix the clang-format 
complaint in pre-merge checks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152433

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

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

[PATCH] D152627: [RISCV] Change the immediate argument to Zk* intrinsics/builtins from i8 to i32.

2023-06-13 Thread Alex Bradbury via Phabricator via cfe-commits
asb accepted this revision.
asb added a comment.
This revision is now accepted and ready to land.

LGTM. llvm/test/Bitcode is the other place the autoupgrade tests could go, but 
it looks like it's not used any more frequently for such tests than 
llvm/test/CodeGen/$tgt/.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152627

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


[PATCH] D152792: [Tooling/Inclusion] Add missing PRI family macros.

2023-06-13 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.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152792

Files:
  clang/lib/Tooling/Inclusions/Stdlib/StdSpecialSymbolMap.inc

Index: clang/lib/Tooling/Inclusions/Stdlib/StdSpecialSymbolMap.inc
===
--- clang/lib/Tooling/Inclusions/Stdlib/StdSpecialSymbolMap.inc
+++ clang/lib/Tooling/Inclusions/Stdlib/StdSpecialSymbolMap.inc
@@ -404,3 +404,314 @@
 SYMBOL(NULL, None, )
 SYMBOL(NULL, None, )
 SYMBOL(NULL, None, )
+
+// Theres are macros that not spelled out in page linked from the index.
+// Extracted from https://en.cppreference.com/w/cpp/header/cinttypes
+SYMBOL(PRId8, None, )
+SYMBOL(PRId8, None, )
+SYMBOL(PRId16, None, )
+SYMBOL(PRId16, None, )
+SYMBOL(PRId32, None, )
+SYMBOL(PRId32, None, )
+SYMBOL(PRId64, None, )
+SYMBOL(PRId64, None, )
+SYMBOL(PRIdLEAST8, None, )
+SYMBOL(PRIdLEAST8, None, )
+SYMBOL(PRIdLEAST16, None, )
+SYMBOL(PRIdLEAST16, None, )
+SYMBOL(PRIdLEAST32, None, )
+SYMBOL(PRIdLEAST32, None, )
+SYMBOL(PRIdLEAST64, None, )
+SYMBOL(PRIdLEAST64, None, )
+SYMBOL(PRIdFAST8, None, )
+SYMBOL(PRIdFAST8, None, )
+SYMBOL(PRIdFAST16, None, )
+SYMBOL(PRIdFAST16, None, )
+SYMBOL(PRIdFAST32, None, )
+SYMBOL(PRIdFAST32, None, )
+SYMBOL(PRIdFAST64, None, )
+SYMBOL(PRIdFAST64, None, )
+SYMBOL(PRIdMAX, None, )
+SYMBOL(PRIdMAX, None, )
+SYMBOL(PRIdPTR, None, )
+SYMBOL(PRIdPTR, None, )
+SYMBOL(PRIi8, None, )
+SYMBOL(PRIi8, None, )
+SYMBOL(PRIi16, None, )
+SYMBOL(PRIi16, None, )
+SYMBOL(PRIi32, None, )
+SYMBOL(PRIi32, None, )
+SYMBOL(PRIi64, None, )
+SYMBOL(PRIi64, None, )
+SYMBOL(PRIiLEAST8, None, )
+SYMBOL(PRIiLEAST8, None, )
+SYMBOL(PRIiLEAST16, None, )
+SYMBOL(PRIiLEAST16, None, )
+SYMBOL(PRIiLEAST32, None, )
+SYMBOL(PRIiLEAST32, None, )
+SYMBOL(PRIiLEAST64, None, )
+SYMBOL(PRIiLEAST64, None, )
+SYMBOL(PRIiFAST8, None, )
+SYMBOL(PRIiFAST8, None, )
+SYMBOL(PRIiFAST16, None, )
+SYMBOL(PRIiFAST16, None, )
+SYMBOL(PRIiFAST32, None, )
+SYMBOL(PRIiFAST32, None, )
+SYMBOL(PRIiFAST64, None, )
+SYMBOL(PRIiFAST64, None, )
+SYMBOL(PRIiMAX, None, )
+SYMBOL(PRIiMAX, None, )
+SYMBOL(PRIiPTR, None, )
+SYMBOL(PRIiPTR, None, )
+SYMBOL(PRIu8, None, )
+SYMBOL(PRIu8, None, )
+SYMBOL(PRIu16, None, )
+SYMBOL(PRIu16, None, )
+SYMBOL(PRIu32, None, )
+SYMBOL(PRIu32, None, )
+SYMBOL(PRIu64, None, )
+SYMBOL(PRIu64, None, )
+SYMBOL(PRIuLEAST8, None, )
+SYMBOL(PRIuLEAST8, None, )
+SYMBOL(PRIuLEAST16, None, )
+SYMBOL(PRIuLEAST16, None, )
+SYMBOL(PRIuLEAST32, None, )
+SYMBOL(PRIuLEAST32, None, )
+SYMBOL(PRIuLEAST64, None, )
+SYMBOL(PRIuLEAST64, None, )
+SYMBOL(PRIuFAST8, None, )
+SYMBOL(PRIuFAST8, None, )
+SYMBOL(PRIuFAST16, None, )
+SYMBOL(PRIuFAST16, None, )
+SYMBOL(PRIuFAST32, None, )
+SYMBOL(PRIuFAST32, None, )
+SYMBOL(PRIuFAST64, None, )
+SYMBOL(PRIuFAST64, None, )
+SYMBOL(PRIuMAX, None, )
+SYMBOL(PRIuMAX, None, )
+SYMBOL(PRIuPTR, None, )
+SYMBOL(PRIuPTR, None, )
+SYMBOL(PRIo8, None, )
+SYMBOL(PRIo8, None, )
+SYMBOL(PRIo16, None, )
+SYMBOL(PRIo16, None, )
+SYMBOL(PRIo32, None, )
+SYMBOL(PRIo32, None, )
+SYMBOL(PRIo64, None, )
+SYMBOL(PRIo64, None, )
+SYMBOL(PRIoLEAST8, None, )
+SYMBOL(PRIoLEAST8, None, )
+SYMBOL(PRIoLEAST16, None, )
+SYMBOL(PRIoLEAST16, None, )
+SYMBOL(PRIoLEAST32, None, )
+SYMBOL(PRIoLEAST32, None, )
+SYMBOL(PRIoLEAST64, None, )
+SYMBOL(PRIoLEAST64, None, )
+SYMBOL(PRIoFAST8, None, )
+SYMBOL(PRIoFAST8, None, )
+SYMBOL(PRIoFAST16, None, )
+SYMBOL(PRIoFAST16, None, )
+SYMBOL(PRIoFAST32, None, )
+SYMBOL(PRIoFAST32, None, )
+SYMBOL(PRIoFAST64, None, )
+SYMBOL(PRIoFAST64, None, )
+SYMBOL(PRIoMAX, None, )
+SYMBOL(PRIoMAX, None, )
+SYMBOL(PRIoPTR, None, )
+SYMBOL(PRIoPTR, None, )
+SYMBOL(PRIx8, None, )
+SYMBOL(PRIx8, None, )
+SYMBOL(PRIx16, None, )
+SYMBOL(PRIx16, None, )
+SYMBOL(PRIx32, None, )
+SYMBOL(PRIx32, None, )
+SYMBOL(PRIx64, None, )
+SYMBOL(PRIx64, None, )
+SYMBOL(PRIxLEAST8, None, )
+SYMBOL(PRIxLEAST8, None, )
+SYMBOL(PRIxLEAST16, None, )
+SYMBOL(PRIxLEAST16, None, )
+SYMBOL(PRIxLEAST32, None, )
+SYMBOL(PRIxLEAST32, None, )
+SYMBOL(PRIxLEAST64, None, )
+SYMBOL(PRIxLEAST64, None, )
+SYMBOL(PRIxFAST8, None, )
+SYMBOL(PRIxFAST8, None, )
+SYMBOL(PRIxFAST16, None, )
+SYMBOL(PRIxFAST16, None, )
+SYMBOL(PRIxFAST32, None, )
+SYMBOL(PRIxFAST32, None, )
+SYMBOL(PRIxFAST64, None, )
+SYMBOL(PRIxFAST64, None, )
+SYMBOL(PRIxMAX, None, )
+SYMBOL(PRIxMAX, None, )
+SYMBOL(PRIxPTR, None, )
+SYMBOL(PRIxPTR, None, )
+SYMBOL(PRIX8, None, )
+SYMBOL(PRIX8, None, )
+SYMBOL(PRIX16, None, )
+SYMBOL(PRIX16, None, )
+SYMBOL(PRIX32, None, )
+SYMBOL(PRIX32, None, )
+SYMBOL(PRIX64, None, )
+SYMBOL(PRIX64, None, )
+SYMBOL(PRIXLEAST8, None, )
+SYMBOL(PRIXLEAST8, None, )
+SYMBOL(PRIXLEAST16, None, )
+SYMBOL(PRIXLEAST16, None, )
+SYMBOL(PRIXLEAST32, None, )
+SYMBOL(PRIXLEAST32, None, )
+SYMBOL(PRIXLEAST64, None, )
+SYMBOL(PRIXLEAST64, None, )
+SYMBOL(PRIXFAST8, None, )
+SYMBOL(PRIXFAST8, None, )
+SYMBOL

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

2023-06-13 Thread Takuya Shimizu via Phabricator via cfe-commits
hazohelet updated this revision to Diff 530834.
hazohelet added a comment.

- Change `%clang` to `%clang_cc1 -fcxx-exceptions` in the test


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

https://reviews.llvm.org/D152707

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

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

[PATCH] D152793: [RISCV] Add MC layer support for Zicfisslp.

2023-06-13 Thread Yeting Kuo via Phabricator via cfe-commits
fakepaper56 created this revision.
Herald added subscribers: jobnoorman, luke, vporpo, VincentWu, vkmr, 
frasercrmck, luismarques, apazos, sameer.abuasal, s.egerton, Jim, benna, 
psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, 
edward-jones, zzheng, jrtc27, shiva0217, kito-cheng, niosHD, sabuasal, 
simoncook, johnrusso, rbar, asb, hiraditya, arichardson.
Herald added a project: All.
fakepaper56 requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, pcwang-thead, eopXD, 
MaskRay.
Herald added projects: clang, LLVM.

The patch adds the instructions in Zicfisslp extension. Zicfisslp extension is
to support shadow stack and landing pad for better control flow integrity.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152793

Files:
  clang/test/Preprocessor/riscv-target-features.c
  llvm/lib/Support/RISCVISAInfo.cpp
  llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
  llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h
  llvm/lib/Target/RISCV/RISCVFeatures.td
  llvm/lib/Target/RISCV/RISCVInstrInfo.td
  llvm/lib/Target/RISCV/RISCVInstrInfoZicfisslp.td
  llvm/lib/Target/RISCV/RISCVRegisterInfo.td
  llvm/test/MC/RISCV/attribute-arch.s
  llvm/test/MC/RISCV/zicfisslp-invalid.s
  llvm/test/MC/RISCV/zicfisslp-valid.s

Index: llvm/test/MC/RISCV/zicfisslp-valid.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/zicfisslp-valid.s
@@ -0,0 +1,120 @@
+# RUN: llvm-mc %s -triple=riscv32 -mattr=+experimental-zicfisslp,+c -riscv-no-aliases -show-encoding \
+# RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s
+# RUN: llvm-mc %s -triple=riscv64 -mattr=+experimental-zicfisslp,+c -riscv-no-aliases -show-encoding \
+# RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s
+# RUN: llvm-mc -filetype=obj -triple=riscv32 -mattr=+experimental-zicfisslp,+c < %s \
+# RUN: | llvm-objdump --mattr=+experimental-zicfisslp -M no-aliases -d -r - \
+# RUN: | FileCheck --check-prefix=CHECK-ASM-AND-OBJ %s
+# RUN: llvm-mc -filetype=obj -triple=riscv64 -mattr=+experimental-zicfisslp,+c < %s \
+# RUN: | llvm-objdump --mattr=+experimental-zicfisslp -M no-aliases -d -r - \
+# RUN: | FileCheck --check-prefix=CHECK-ASM-AND-OBJ %s
+#
+# RUN: not llvm-mc -triple riscv32 -riscv-no-aliases -show-encoding < %s 2>&1 \
+# RUN: | FileCheck -check-prefixes=CHECK-NO-EXT %s
+# RUN: not llvm-mc -triple riscv64 -riscv-no-aliases -show-encoding < %s 2>&1 \
+# RUN: | FileCheck -check-prefixes=CHECK-NO-EXT %s
+
+# CHECK-ASM-AND-OBJ: ssload x1
+# CHECK-ASM: encoding: [0x73,0xc0,0xc0,0x81]
+# CHECK-NO-EXT: error: instruction requires the following: 'Zicfisslp' (Shadow-stack and Landing-pads)
+ssload x1
+
+# CHECK-ASM-AND-OBJ: ssload x1
+# CHECK-ASM: encoding: [0x73,0xc0,0xc0,0x81]
+# CHECK-NO-EXT: error: instruction requires the following: 'Zicfisslp' (Shadow-stack and Landing-pads)
+ssload ra
+
+# CHECK-ASM-AND-OBJ: ssload x5
+# CHECK-ASM: encoding: [0x73,0xc0,0xc2,0x81]
+# CHECK-NO-EXT: error: instruction requires the following: 'Zicfisslp' (Shadow-stack and Landing-pads)
+ssload x5
+
+# CHECK-ASM-AND-OBJ: ssload x5
+# CHECK-ASM: encoding: [0x73,0xc0,0xc2,0x81]
+# CHECK-NO-EXT: error: instruction requires the following: 'Zicfisslp' (Shadow-stack and Landing-pads)
+ssload t0
+
+# CHECK-ASM-AND-OBJ: sspopchk x1
+# CHECK-ASM: encoding: [0xf3,0x40,0xc0,0x81]
+# CHECK-NO-EXT: error: instruction requires the following: 'Zicfisslp' (Shadow-stack and Landing-pads)
+sspopchk x1
+
+# CHECK-ASM-AND-OBJ: sspopchk x1
+# CHECK-ASM: encoding: [0xf3,0x40,0xc0,0x81]
+# CHECK-NO-EXT: error: instruction requires the following: 'Zicfisslp' (Shadow-stack and Landing-pads)
+sspopchk ra
+
+# CHECK-ASM-AND-OBJ: sspopchk x5
+# CHECK-ASM: encoding: [0xf3,0x42,0xc0,0x81]
+# CHECK-NO-EXT: error: instruction requires the following: 'Zicfisslp' (Shadow-stack and Landing-pads)
+sspopchk x5
+
+# CHECK-ASM-AND-OBJ: sspopchk x5
+# CHECK-ASM: encoding: [0xf3,0x42,0xc0,0x81]
+# CHECK-NO-EXT: error: instruction requires the following: 'Zicfisslp' (Shadow-stack and Landing-pads)
+sspopchk t0
+
+# CHECK-ASM-AND-OBJ: sspinc 4
+# CHECK-ASM: encoding: [0x73,0x40,0xd2,0x81]
+# CHECK-NO-EXT: error: instruction requires the following: 'Zicfisslp' (Shadow-stack and Landing-pads)
+sspinc 4
+
+# CHECK-ASM-AND-OBJ: sspush ra
+# CHECK-ASM: encoding: [0x73,0x40,0x10,0x8a]
+# CHECK-NO-EXT: error: instruction requires the following: 'Zicfisslp' (Shadow-stack and Landing-pads)
+sspush x1
+
+# CHECK-ASM-AND-OBJ: sspush ra
+# CHECK-ASM: encoding: [0x73,0x40,0x10,0x8a]
+# CHECK-NO-EXT: error: instruction requires the following: 'Zicfisslp' (Shadow-stack and Landing-pads)
+sspush ra
+
+# check-asm-and-obj: sspush t0
+# check-asm: encoding: [0x73,0x40,0x50,0x8a]
+# check-no-ext: error: instruction requires the following: 'zicfisslp' (shadow-stack and landing-pads)
+sspush x5
+
+# check-asm-

[PATCH] D152793: [RISCV] Add MC layer support for Zicfisslp.

2023-06-13 Thread Yeting Kuo via Phabricator via cfe-commits
fakepaper56 added a comment.

The patch might be too early to be posted. My idea is to make people easier to 
develop shadow-stack/landing-pads.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152793

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


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

2023-06-13 Thread Stephen Tozer via Phabricator via cfe-commits
StephenTozer added a comment.

In D152708#4414402 , @dblaikie wrote:

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

For what it's worth, we haven't tested this with any larger programs, so this 
is more of a rough estimate of size, but the .debug_line section increased in 
size on the order of 50% for our small test cases. On the other hand, I think 
that in larger programs the .debug_line section is likely be significantly 
smaller than the .debug_info section anyway, so if you are interested in 
producing inline frames without using .debug_info it is probably an improvement 
in most respects - as an example with a single-source input, `flops.c` (taken 
from the LLVM test suite repo), the .debug_line section increased from 3338 to 
4758 bytes, and the overall size of the DWARF output from 9467 to 10893.

> Are there any known (or vague/unknown) limitations on the implementation with 
> respect to the actual output/on-disk representation?

Possibly, but not outside of the proposal itself - this patch was written over 
the span of 4 days so doubtless there are inefficiencies in the code itself and 
there may be bugs in the output (especially if you try it on a larger 
codebase), but in theory the output follows the spec faithfully and shouldn't 
be wasting up space. With that said, the main cause of the size increase isn't 
really the additional information, but the fact that the TLLT does repeat 
itself a lot by design; generally speaking most instructions are not inlined 
callsites, and so the additional information for those lines (the context and 
subprogram fields) has a much smaller impact on size than the fact that we are 
emitting the `(InstructionAddress, SourceLocation)` pair twice for every 
instruction.

We didn't dig deeper into why the representation needs to be split into two 
separate line number programs rather than either a single line table with some 
additional column to convey the Instruction->SourceLocation attribution, or 
keeping two line tables but using a single line number program that can either 
emit Logical and Actual rows simultaneously. Either of these methods would 
reduce the repetition.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152708

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


[PATCH] D116016: [Clang] [PowerPC] Emit module flag for current float abi

2023-06-13 Thread Qiu Chaofan via Phabricator via cfe-commits
qiucf updated this revision to Diff 530843.
qiucf marked an inline comment as done.
qiucf edited the summary of this revision.
qiucf removed a reviewer: jsji.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116016

Files:
  clang/lib/CodeGen/CodeGenTypes.cpp
  clang/lib/CodeGen/CodeGenTypes.h
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGen/ppc64-float-abi-attr.c

Index: clang/test/CodeGen/ppc64-float-abi-attr.c
===
--- /dev/null
+++ clang/test/CodeGen/ppc64-float-abi-attr.c
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -triple powerpc64le-unknown-linux-gnu %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -triple powerpc64le-unknown-linux-gnu %s -emit-llvm -mabi=ieeelongdouble -o - | FileCheck %s --check-prefix=IEEE
+// RUN: %clang_cc1 -triple powerpc64le-unknown-linux-gnu %s -emit-llvm -mlong-double-64 -o - | FileCheck %s --check-prefix=LDBL64
+// RUN: %clang_cc1 -triple powerpc64le-unknown-linux-gnu %s -emit-llvm -DNOLDBL -o - | FileCheck %s --check-prefix=NOLDBL
+
+#ifndef NOLDBL
+long double foo(long double a, long double b) {
+  return a + b;
+}
+#endif
+
+int bar() { return 1; }
+
+// CHECK: ![[#]] = !{i32 1, !"float-abi", !"doubledouble"}
+// IEEE: ![[#]] = !{i32 1, !"float-abi", !"ieeequad"}
+// LDBL64: ![[#]] = !{i32 1, !"float-abi", !"ieeedouble"}
+// NOLDBL-NOT: ![[#]] = !{i32 1, !"float-abi"
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -5045,6 +5045,10 @@
 
   bool initDwarfEHRegSizeTable(CodeGen::CodeGenFunction &CGF,
llvm::Value *Address) const override;
+
+  void emitTargetMetadata(CodeGen::CodeGenModule &CGM,
+  const llvm::MapVector
+  &MangledDeclNames) const override;
 };
 
 class PPC64TargetCodeGenInfo : public TargetCodeGenInfo {
@@ -5470,6 +5474,24 @@
  /*IsAIX*/ false);
 }
 
+void PPC64_SVR4_TargetCodeGenInfo::emitTargetMetadata(
+CodeGen::CodeGenModule &CGM,
+const llvm::MapVector &MangledDeclNames) const {
+  if (CGM.getTypes().isLongDoubleReferenced()) {
+llvm::LLVMContext &Ctx = CGM.getLLVMContext();
+const auto *flt = &CGM.getTarget().getLongDoubleFormat();
+if (flt == &llvm::APFloat::PPCDoubleDouble())
+  CGM.getModule().addModuleFlag(llvm::Module::Error, "float-abi",
+llvm::MDString::get(Ctx, "doubledouble"));
+else if (flt == &llvm::APFloat::IEEEquad())
+  CGM.getModule().addModuleFlag(llvm::Module::Error, "float-abi",
+llvm::MDString::get(Ctx, "ieeequad"));
+else if (flt == &llvm::APFloat::IEEEdouble())
+  CGM.getModule().addModuleFlag(llvm::Module::Error, "float-abi",
+llvm::MDString::get(Ctx, "ieeedouble"));
+  }
+}
+
 bool
 PPC64TargetCodeGenInfo::initDwarfEHRegSizeTable(CodeGen::CodeGenFunction &CGF,
 llvm::Value *Address) const {
Index: clang/lib/CodeGen/CodeGenTypes.h
===
--- clang/lib/CodeGen/CodeGenTypes.h
+++ clang/lib/CodeGen/CodeGenTypes.h
@@ -90,6 +90,9 @@
   /// a recursive struct conversion, set this to true.
   bool SkippedLayout;
 
+  /// True if any instance of long double types are used.
+  bool LongDoubleReferenced;
+
   SmallVector DeferredRecords;
 
   /// This map keeps cache of llvm::Types and maps clang::Type to
@@ -306,6 +309,7 @@
   bool isRecordBeingLaidOut(const Type *Ty) const {
 return RecordsBeingLaidOut.count(Ty);
   }
+  bool isLongDoubleReferenced() const { return LongDoubleReferenced; }
   unsigned getTargetAddressSpace(QualType T) const;
 };
 
Index: clang/lib/CodeGen/CodeGenTypes.cpp
===
--- clang/lib/CodeGen/CodeGenTypes.cpp
+++ clang/lib/CodeGen/CodeGenTypes.cpp
@@ -34,6 +34,7 @@
 Target(cgm.getTarget()), TheCXXABI(cgm.getCXXABI()),
 TheABIInfo(cgm.getTargetCodeGenInfo().getABIInfo()) {
   SkippedLayout = false;
+  LongDoubleReferenced = false;
 }
 
 CodeGenTypes::~CodeGenTypes() {
@@ -529,10 +530,12 @@
   Context.getLangOpts().NativeHalfType ||
   !Context.getTargetInfo().useFP16ConversionIntrinsics());
   break;
+case BuiltinType::LongDouble:
+  LongDoubleReferenced = true;
+  LLVM_FALLTHROUGH;
 case BuiltinType::BFloat16:
 case BuiltinType::Float:
 case BuiltinType::Double:
-case BuiltinType::LongDouble:
 case BuiltinType::Float128:
 case BuiltinType::Ibm128:
   ResultType = getTypeForFormat(getLLVMContext(),
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin

[PATCH] D152796: [clang][Sema] Fix diagnostic message for unused constant varialbe templates

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

BEFORE this patch, unused const-qualified variable templates such as `template 
 const double var_t = 0;` were diagnosed as `unused variable 
'var_t'`
This patch fixes this message to `unused variable template 'var_t'`


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152796

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/Sema.cpp
  clang/test/SemaCXX/warn-unused-filescoped.cpp


Index: clang/test/SemaCXX/warn-unused-filescoped.cpp
===
--- clang/test/SemaCXX/warn-unused-filescoped.cpp
+++ clang/test/SemaCXX/warn-unused-filescoped.cpp
@@ -155,8 +155,7 @@
   int y = sizeof(d);
 
   namespace {
-  // FIXME: Should be "unused variable template 'var_t'" instead.
-  template  const double var_t = 0; // expected-warning {{unused 
variable 'var_t'}}
+  template  const double var_t = 0; // expected-warning {{unused 
variable template 'var_t'}}
   template <> const double var_t = 0;  // expected-warning {{variable 
'var_t' is not needed and will not be emitted}}
   int z = sizeof(var_t);   // expected-warning {{unused 
variable 'z'}}
   } // namespace
Index: clang/lib/Sema/Sema.cpp
===
--- clang/lib/Sema/Sema.cpp
+++ clang/lib/Sema/Sema.cpp
@@ -1380,6 +1380,9 @@
 if (DiagD->isReferenced()) {
   Diag(DiagD->getLocation(), diag::warn_unneeded_internal_decl)
   << /*variable*/ 1 << DiagD;
+} else if (DiagD->getDescribedVarTemplate()) {
+  Diag(DiagD->getLocation(), diag::warn_unused_template)
+  << /*variable*/ 1 << DiagD;
 } else if (DiagD->getType().isConstQualified()) {
   const SourceManager &SM = SourceMgr;
   if (SM.getMainFileID() != SM.getFileID(DiagD->getLocation()) ||
@@ -1387,11 +1390,7 @@
 Diag(DiagD->getLocation(), diag::warn_unused_const_variable)
 << DiagD;
 } else {
-  if (DiagD->getDescribedVarTemplate())
-Diag(DiagD->getLocation(), diag::warn_unused_template)
-<< /*variable*/ 1 << DiagD;
-  else
-Diag(DiagD->getLocation(), diag::warn_unused_variable) << DiagD;
+  Diag(DiagD->getLocation(), diag::warn_unused_variable) << DiagD;
 }
   }
 }
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -340,6 +340,8 @@
   can be controlled using ``-fcaret-diagnostics-max-lines=``.
 - Clang no longer emits ``-Wunused-variable`` warnings for variables declared
   with ``__attribute__((cleanup(...)))`` to match GCC's behavior.
+- Clang now diagnoses unused const-qualified variable template as
+  "unused variable template" rather than "unused variable".
 
 Bug Fixes in This Version
 -


Index: clang/test/SemaCXX/warn-unused-filescoped.cpp
===
--- clang/test/SemaCXX/warn-unused-filescoped.cpp
+++ clang/test/SemaCXX/warn-unused-filescoped.cpp
@@ -155,8 +155,7 @@
   int y = sizeof(d);
 
   namespace {
-  // FIXME: Should be "unused variable template 'var_t'" instead.
-  template  const double var_t = 0; // expected-warning {{unused variable 'var_t'}}
+  template  const double var_t = 0; // expected-warning {{unused variable template 'var_t'}}
   template <> const double var_t = 0;  // expected-warning {{variable 'var_t' is not needed and will not be emitted}}
   int z = sizeof(var_t);   // expected-warning {{unused variable 'z'}}
   } // namespace
Index: clang/lib/Sema/Sema.cpp
===
--- clang/lib/Sema/Sema.cpp
+++ clang/lib/Sema/Sema.cpp
@@ -1380,6 +1380,9 @@
 if (DiagD->isReferenced()) {
   Diag(DiagD->getLocation(), diag::warn_unneeded_internal_decl)
   << /*variable*/ 1 << DiagD;
+} else if (DiagD->getDescribedVarTemplate()) {
+  Diag(DiagD->getLocation(), diag::warn_unused_template)
+  << /*variable*/ 1 << DiagD;
 } else if (DiagD->getType().isConstQualified()) {
   const SourceManager &SM = SourceMgr;
   if (SM.getMainFileID() != SM.getFileID(DiagD->getLocation()) ||
@@ -1387,11 +1390,7 @@
 Diag(DiagD->getLocation(), diag::warn_unused_const_variable)
 << DiagD;
 } else {
-  if (DiagD->getDescribedVarTemplate())
-Diag(DiagD->getLocation(), diag::warn_unused_template)
-<< /*variable*/ 1 << DiagD;
-  else
-Diag(DiagD->getLocat

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

2023-06-13 Thread Ties Stuij via Phabricator via cfe-commits
stuij added a comment.

In D149444#4415306 , @MaskRay wrote:

> Normally we implement the feature in llvm/ first, and the `clang/lib/Driver` 
> change should be the last patch.

Yes good point. I won't commit it yet. For this feature we're using Phab as a 
vehicle to swap patches, so we're reviewing these upstream as they become 
available.




Comment at: clang/test/Driver/arm-execute-only.c:1
-// RUN: not %clang -c -target thumbv6m-eabi -mexecute-only %s 2>&1 | \
+// RUN: %clang -c -### --target=thumbv6m-eabi -mexecute-only %s 2>&1 | \
+// RUN:   FileCheck -allow-empty --check-prefix CHECK-EXECUTE-ONLY %s

MaskRay wrote:
> If you don't check -cc1 options with FileCheck, you can also replace `-###` 
> with `-fdriver-only -Werror` and drop two `-NOT:` patterns below. You can 
> play with some examples to see its effect:)
> 
> If the `clang -c -fdriver-only -Werror` command gives no output, you can use 
> `... 2>&1 | count 0`
Very useful info. Thanks for the tips!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149444

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


[PATCH] D151785: [clangd] Desugar template parameter aliases in type hints

2023-06-13 Thread Younan Zhang via Phabricator via cfe-commits
zyounan updated this revision to Diff 530850.
zyounan marked an inline comment as done.
zyounan added a comment.

Final update


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151785

Files:
  clang-tools-extra/clangd/InlayHints.cpp
  clang-tools-extra/clangd/unittests/InlayHintTests.cpp

Index: clang-tools-extra/clangd/unittests/InlayHintTests.cpp
===
--- clang-tools-extra/clangd/unittests/InlayHintTests.cpp
+++ clang-tools-extra/clangd/unittests/InlayHintTests.cpp
@@ -1417,6 +1417,82 @@
   ExpectedHint{": int", "h"}, ExpectedHint{": int", "i"});
 }
 
+TEST(TypeHints, SubstTemplateParameterAliases) {
+  assertTypeHints(
+  R"cpp(
+  template  struct allocator {};
+
+  template 
+  struct vector_base {
+using pointer = T*;
+  };
+
+  template 
+  struct internal_iterator_type_template_we_dont_expect {};
+
+  struct my_iterator {};
+
+  template >
+  struct vector : vector_base {
+using base = vector_base;
+typedef T value_type;
+typedef base::pointer pointer;
+using allocator_type = A;
+using size_type = int;
+using iterator = internal_iterator_type_template_we_dont_expect;
+using non_template_iterator = my_iterator;
+
+value_type& operator[](int index) { return elements[index]; }
+const value_type& at(int index) const { return elements[index]; }
+pointer data() { return &elements[0]; }
+allocator_type get_allocator() { return A(); }
+size_type size() const { return 10; }
+iterator begin() { return iterator(); }
+non_template_iterator end() { return non_template_iterator(); }
+
+T elements[10];
+  };
+
+  vector array;
+
+  auto $no_modifier[[by_value]] = array[3];
+  auto* $ptr_modifier[[ptr]] = &array[3];
+  auto& $ref_modifier[[ref]] = array[3];
+  auto& $at[[immutable]] = array.at(3);
+
+  auto $data[[data]] = array.data();
+  auto $allocator[[alloc]] = array.get_allocator();
+  auto $size[[size]] = array.size();
+  auto $begin[[begin]] = array.begin();
+  auto $end[[end]] = array.end();
+
+
+  // If the type alias is not of substituted template parameter type,
+  // do not show desugared type.
+  using VeryLongLongTypeName = my_iterator;
+  using Short = VeryLongLongTypeName;
+
+  auto $short_name[[my_value]] = Short();
+
+  // Same applies with templates.
+  template 
+  using basic_static_vector = vector;
+  template 
+  using static_vector = basic_static_vector>;
+
+  auto $vector_name[[vec]] = static_vector();
+  )cpp",
+  ExpectedHint{": int", "no_modifier"},
+  ExpectedHint{": int *", "ptr_modifier"},
+  ExpectedHint{": int &", "ref_modifier"},
+  ExpectedHint{": const int &", "at"}, ExpectedHint{": int *", "data"},
+  ExpectedHint{": allocator", "allocator"},
+  ExpectedHint{": size_type", "size"}, ExpectedHint{": iterator", "begin"},
+  ExpectedHint{": non_template_iterator", "end"},
+  ExpectedHint{": Short", "short_name"},
+  ExpectedHint{": static_vector", "vector_name"});
+}
+
 TEST(DesignatorHints, Basic) {
   assertDesignatorHints(R"cpp(
 struct S { int x, y, z; };
Index: clang-tools-extra/clangd/InlayHints.cpp
===
--- clang-tools-extra/clangd/InlayHints.cpp
+++ clang-tools-extra/clangd/InlayHints.cpp
@@ -11,10 +11,12 @@
 #include "HeuristicResolver.h"
 #include "ParsedAST.h"
 #include "SourceCode.h"
+#include "clang/AST/ASTDiagnostic.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclarationName.h"
 #include "clang/AST/ExprCXX.h"
 #include "clang/AST/RecursiveASTVisitor.h"
+#include "clang/AST/Type.h"
 #include "clang/Basic/Builtins.h"
 #include "clang/Basic/SourceManager.h"
 #include "llvm/ADT/ScopeExit.h"
@@ -190,6 +192,64 @@
   return Designators;
 }
 
+// Determines if any intermediate type in desugaring QualType QT is of
+// substituted template parameter type. Ignore pointer or reference wrappers.
+bool isSugaredTemplateParameter(QualType QT) {
+  static auto PeelWrappers = [](QualType QT) {
+// Neither `PointerType` nor `ReferenceType` is considered as sugared
+// type. Peel it.
+QualType Next;
+while (!(Next = QT->getPointeeType()).isNull())
+  QT = Next;
+return QT;
+  };
+  while (true) {
+QualType Desugared =
+PeelWrappers(QT->getLocallyUnqualifiedSingleStepDesugaredType());
+if (Desugared == QT)
+  break;
+if (Desugared->getAs())
+  return true;
+QT = Desugared;
+  }
+  return false;
+}
+
+// A simple wrapper for `clang::desugarForDiagnostic` that provides optional
+// semantic.
+std::optional desugar(ASTContext &AST, QualType QT) {
+  bool ShouldAKA;
+  auto Desugared = clang::desugarForDiagnostic(AST, QT, ShouldAKA);
+  if (!ShouldAKA)
+return std::nullopt;
+  return Desugared;
+}
+
+// Apply a series of heuristic methods to determine whether or not a QualType QT
+// is suitabl

[PATCH] D151785: [clangd] Desugar template parameter aliases in type hints

2023-06-13 Thread Younan Zhang via Phabricator via cfe-commits
zyounan updated this revision to Diff 530851.
zyounan added a comment.

Oops. Remove extra debugging statement


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151785

Files:
  clang-tools-extra/clangd/InlayHints.cpp
  clang-tools-extra/clangd/unittests/InlayHintTests.cpp

Index: clang-tools-extra/clangd/unittests/InlayHintTests.cpp
===
--- clang-tools-extra/clangd/unittests/InlayHintTests.cpp
+++ clang-tools-extra/clangd/unittests/InlayHintTests.cpp
@@ -1417,6 +1417,82 @@
   ExpectedHint{": int", "h"}, ExpectedHint{": int", "i"});
 }
 
+TEST(TypeHints, SubstTemplateParameterAliases) {
+  assertTypeHints(
+  R"cpp(
+  template  struct allocator {};
+
+  template 
+  struct vector_base {
+using pointer = T*;
+  };
+
+  template 
+  struct internal_iterator_type_template_we_dont_expect {};
+
+  struct my_iterator {};
+
+  template >
+  struct vector : vector_base {
+using base = vector_base;
+typedef T value_type;
+typedef base::pointer pointer;
+using allocator_type = A;
+using size_type = int;
+using iterator = internal_iterator_type_template_we_dont_expect;
+using non_template_iterator = my_iterator;
+
+value_type& operator[](int index) { return elements[index]; }
+const value_type& at(int index) const { return elements[index]; }
+pointer data() { return &elements[0]; }
+allocator_type get_allocator() { return A(); }
+size_type size() const { return 10; }
+iterator begin() { return iterator(); }
+non_template_iterator end() { return non_template_iterator(); }
+
+T elements[10];
+  };
+
+  vector array;
+
+  auto $no_modifier[[by_value]] = array[3];
+  auto* $ptr_modifier[[ptr]] = &array[3];
+  auto& $ref_modifier[[ref]] = array[3];
+  auto& $at[[immutable]] = array.at(3);
+
+  auto $data[[data]] = array.data();
+  auto $allocator[[alloc]] = array.get_allocator();
+  auto $size[[size]] = array.size();
+  auto $begin[[begin]] = array.begin();
+  auto $end[[end]] = array.end();
+
+
+  // If the type alias is not of substituted template parameter type,
+  // do not show desugared type.
+  using VeryLongLongTypeName = my_iterator;
+  using Short = VeryLongLongTypeName;
+
+  auto $short_name[[my_value]] = Short();
+
+  // Same applies with templates.
+  template 
+  using basic_static_vector = vector;
+  template 
+  using static_vector = basic_static_vector>;
+
+  auto $vector_name[[vec]] = static_vector();
+  )cpp",
+  ExpectedHint{": int", "no_modifier"},
+  ExpectedHint{": int *", "ptr_modifier"},
+  ExpectedHint{": int &", "ref_modifier"},
+  ExpectedHint{": const int &", "at"}, ExpectedHint{": int *", "data"},
+  ExpectedHint{": allocator", "allocator"},
+  ExpectedHint{": size_type", "size"}, ExpectedHint{": iterator", "begin"},
+  ExpectedHint{": non_template_iterator", "end"},
+  ExpectedHint{": Short", "short_name"},
+  ExpectedHint{": static_vector", "vector_name"});
+}
+
 TEST(DesignatorHints, Basic) {
   assertDesignatorHints(R"cpp(
 struct S { int x, y, z; };
Index: clang-tools-extra/clangd/InlayHints.cpp
===
--- clang-tools-extra/clangd/InlayHints.cpp
+++ clang-tools-extra/clangd/InlayHints.cpp
@@ -11,10 +11,12 @@
 #include "HeuristicResolver.h"
 #include "ParsedAST.h"
 #include "SourceCode.h"
+#include "clang/AST/ASTDiagnostic.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclarationName.h"
 #include "clang/AST/ExprCXX.h"
 #include "clang/AST/RecursiveASTVisitor.h"
+#include "clang/AST/Type.h"
 #include "clang/Basic/Builtins.h"
 #include "clang/Basic/SourceManager.h"
 #include "llvm/ADT/ScopeExit.h"
@@ -190,6 +192,64 @@
   return Designators;
 }
 
+// Determines if any intermediate type in desugaring QualType QT is of
+// substituted template parameter type. Ignore pointer or reference wrappers.
+bool isSugaredTemplateParameter(QualType QT) {
+  static auto PeelWrappers = [](QualType QT) {
+// Neither `PointerType` nor `ReferenceType` is considered as sugared
+// type. Peel it.
+QualType Next;
+while (!(Next = QT->getPointeeType()).isNull())
+  QT = Next;
+return QT;
+  };
+  while (true) {
+QualType Desugared =
+PeelWrappers(QT->getLocallyUnqualifiedSingleStepDesugaredType());
+if (Desugared == QT)
+  break;
+if (Desugared->getAs())
+  return true;
+QT = Desugared;
+  }
+  return false;
+}
+
+// A simple wrapper for `clang::desugarForDiagnostic` that provides optional
+// semantic.
+std::optional desugar(ASTContext &AST, QualType QT) {
+  bool ShouldAKA;
+  auto Desugared = clang::desugarForDiagnostic(AST, QT, ShouldAKA);
+  if (!ShouldAKA)
+return std::nullopt;
+  return Desugared;
+}
+
+// Apply a series of heuristic methods to determine whether or not a QualType QT
+// is suitable for desugaring

[PATCH] D148697: [clang-tidy] Add more checks for functions which should be noexcept

2023-06-13 Thread André Schackier via Phabricator via cfe-commits
AMS21 added a comment.

Patch is now open for 2+ weeks. If there are no more reviews, I would kindly 
ask for someone to push this on my behalf.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148697

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


[PATCH] D150997: [llvm] Split out DenseMapInfo specialization

2023-06-13 Thread Elliot Goodrich via Phabricator via cfe-commits
IncludeGuardian updated this revision to Diff 530855.

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

https://reviews.llvm.org/D150997

Files:
  clang-tools-extra/include-cleaner/include/clang-include-cleaner/Types.h
  flang/include/flang/Optimizer/HLFIR/HLFIROps.h
  llvm/include/llvm/ADT/DenseMapInfo.h
  llvm/include/llvm/CodeGen/CallingConvLower.h
  llvm/include/llvm/ExecutionEngine/Orc/LLJIT.h
  llvm/include/llvm/Object/DXContainer.h
  llvm/include/llvm/Transforms/Scalar/SROA.h
  llvm/unittests/ADT/DenseMapTest.cpp
  mlir/include/mlir/IR/AsmState.h
  mlir/include/mlir/Transforms/SROA.h

Index: mlir/include/mlir/Transforms/SROA.h
===
--- mlir/include/mlir/Transforms/SROA.h
+++ mlir/include/mlir/Transforms/SROA.h
@@ -13,9 +13,10 @@
 #include "mlir/Interfaces/MemorySlotInterfaces.h"
 #include "mlir/Support/LogicalResult.h"
 #include "llvm/ADT/Statistic.h"
+#include 

 namespace mlir {

 /// Statistics collected while applying SROA.
 struct SROAStatistics {
   /// Total amount of memory slots destructured.
Index: mlir/include/mlir/IR/AsmState.h
===
--- mlir/include/mlir/IR/AsmState.h
+++ mlir/include/mlir/IR/AsmState.h
@@ -20,20 +20,21 @@
 #include "llvm/ADT/StringMap.h"

 #include 
+#include 

 namespace mlir {
 class AsmResourcePrinter;
 class AsmDialectResourceHandle;
 class Operation;

 namespace detail {
 class AsmStateImpl;
 } // namespace detail

 //===--===//
 // Resources
 //===--===//

 /// The following classes enable support for parsing and printing resources
 /// within MLIR assembly formats. Resources are a mechanism by which dialects,
 /// and external clients, may attach additional information when parsing or
Index: llvm/unittests/ADT/DenseMapTest.cpp
===
--- llvm/unittests/ADT/DenseMapTest.cpp
+++ llvm/unittests/ADT/DenseMapTest.cpp
@@ -8,20 +8,21 @@

 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/DenseMapInfo.h"
+#include "llvm/ADT/DenseMapInfoVariant.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 #include 
 #include 
 #include 
 #include 

 using namespace llvm;

 namespace {

 uint32_t getTestKey(int i, uint32_t *) { return i; }
 uint32_t getTestValue(int i, uint32_t *) { return 42 + i; }

 uint32_t *getTestKey(int i, uint32_t **) {
   static uint32_t dummy_arr1[8192];
   assert(i < 8192 && "Only support 8192 dummy keys.");
Index: llvm/include/llvm/Transforms/Scalar/SROA.h
===
--- llvm/include/llvm/Transforms/Scalar/SROA.h
+++ llvm/include/llvm/Transforms/Scalar/SROA.h
@@ -21,10 +21,11 @@
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/IR/PassManager.h"
 #include "llvm/IR/ValueHandle.h"
+#include 
 #include 

 namespace llvm {

 class AllocaInst;
 class LoadInst;
 class StoreInst;
Index: llvm/include/llvm/Object/DXContainer.h
===
--- llvm/include/llvm/Object/DXContainer.h
+++ llvm/include/llvm/Object/DXContainer.h
@@ -21,13 +21,14 @@
 #include "llvm/Support/Error.h"
 #include "llvm/Support/MemoryBufferRef.h"
 #include "llvm/TargetParser/Triple.h"
+#include 

 namespace llvm {
 namespace object {

 namespace DirectX {
 class PSVRuntimeInfo {

   // This class provides a view into the underlying resource array. The Resource
   // data is little-endian encoded and may not be properly aligned to read
   // directly from. The dereference operator creates a copy of the data and byte
Index: llvm/include/llvm/ExecutionEngine/Orc/LLJIT.h
===
--- llvm/include/llvm/ExecutionEngine/Orc/LLJIT.h
+++ llvm/include/llvm/ExecutionEngine/Orc/LLJIT.h
@@ -22,74 +22,75 @@
 #include "llvm/ExecutionEngine/Orc/ThreadSafeModule.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/ThreadPool.h"
+#include 

 namespace llvm {
 namespace orc {

 class LLJITBuilderState;
 class LLLazyJITBuilderState;
 class ObjectTransformLayer;
 class ExecutorProcessControl;

 /// A pre-fabricated ORC JIT stack that can serve as an alternative to MCJIT.
 ///
 /// Create instances using LLJITBuilder.
 class LLJIT {
   template  friend class LLJITBuilderSetters;

   friend Expected setUpGenericLLVMIRPlatform(LLJIT &J);

 public:
   /// Initializer support for LLJIT.
   class PlatformSupport {
   public:
 virtual ~PlatformSupport();

 virtual Error initialize(JITDylib &JD) = 0;

 virtual Error deinitialize(JITDylib &JD) = 0;

   protected:
 static void setInitTransform(LLJIT &J,
  IRTransformLayer::TransformFunction T);
   };

   /// Destruct this instance. If a multi-threaded instance, waits for all
   /// compile threads to complete.

[clang] 5160f6f - Revert "[Driver] Mark m_x86_Features_Group options as TargetSpecific"

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

Author: Hans Wennborg
Date: 2023-06-13T12:50:51+02:00
New Revision: 5160f6fefb0021a0b23e99c7cf621a330241c211

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

LOG: Revert "[Driver] Mark m_x86_Features_Group options as TargetSpecific"

This broke cross-builds of llvm from x86_64 to arm64 mac, see
comment on
https://github.com/llvm/llvm-project/commit/1d6c3e29f6aa45914faa7be00a939b8f550f38e9

> so that they get an error on non-x86 targets.
> Follow-up to D151590.
>
> As a workaround for https://github.com/llvm/llvm-project/issues/63270, we 
> don't
> report an error for -msse4.2.

This reverts commit 1d6c3e29f6aa45914faa7be00a939b8f550f38e9.

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/test/Driver/x86-target-features.c

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 849308142b8ec..e2cc71bd869a9 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -4772,7 +4772,6 @@ foreach i = {0-7} in
 } // let Flags = [TargetSpecific]
 
 // X86 feature flags
-let Flags = [TargetSpecific] in {
 def mx87 : Flag<["-"], "mx87">, Group;
 def mno_x87 : Flag<["-"], "mno-x87">, Group;
 def m80387 : Flag<["-"], "m80387">, Alias;
@@ -4806,11 +4805,7 @@ def mssse3 : Flag<["-"], "mssse3">, 
Group;
 def mno_ssse3 : Flag<["-"], "mno-ssse3">, Group;
 def msse4_1 : Flag<["-"], "msse4.1">, Group;
 def mno_sse4_1 : Flag<["-"], "mno-sse4.1">, Group;
-} // let Flags = [TargetSpecific]
-// TODO: Make -msse4.2 TargetSpecific after
-// https://github.com/llvm/llvm-project/issues/63270 is fixed.
 def msse4_2 : Flag<["-"], "msse4.2">, Group;
-let Flags = [TargetSpecific] in {
 def mno_sse4_2 : Flag<["-"], "mno-sse4.2">, Group;
 def msse4 : Flag<["-"], "msse4">, Alias;
 // -mno-sse4 turns off sse4.1 which has the effect of turning off everything
@@ -4983,7 +4978,6 @@ def mretpoline_external_thunk : Flag<["-"], 
"mretpoline-external-thunk">, Group<
 def mno_retpoline_external_thunk : Flag<["-"], 
"mno-retpoline-external-thunk">, Group;
 def mvzeroupper : Flag<["-"], "mvzeroupper">, Group;
 def mno_vzeroupper : Flag<["-"], "mno-vzeroupper">, 
Group;
-} // let Flags = [TargetSpecific]
 
 // These are legacy user-facing driver-level option spellings. They are always
 // aliases for options that are spelled using the more common Unix / GNU flag

diff  --git a/clang/test/Driver/x86-target-features.c 
b/clang/test/Driver/x86-target-features.c
index f34b0f8340897..71bdd2a9c2981 100644
--- a/clang/test/Driver/x86-target-features.c
+++ b/clang/test/Driver/x86-target-features.c
@@ -354,13 +354,6 @@
 // CRC32: "-target-feature" "+crc32"
 // NO-CRC32: "-target-feature" "-crc32"
 
-// RUN: %clang -### --target=aarch64 -mcrc32 -msse4.1 -msse4.2 -mno-sgx %s 
2>&1 | FileCheck --check-prefix=NONX86 %s
-// NONX86:  error: unsupported option '-mcrc32' for target 'aarch64'
-// NONX86-NEXT: error: unsupported option '-msse4.1' for target 'aarch64'
-/// TODO: This warning is a workaround for 
https://github.com/llvm/llvm-project/issues/63270
-// NONX86-NEXT: warning: argument unused during compilation: '-msse4.2' 
[-Wunused-command-line-argument]
-// NONX86-NEXT: error: unsupported option '-mno-sgx' for target 'aarch64'
-
 // RUN: %clang --target=i386 -march=i386 -mharden-sls=return %s -### -o %t.o 
2>&1 | FileCheck -check-prefixes=SLS-RET,NO-SLS %s
 // RUN: %clang --target=i386 -march=i386 -mharden-sls=indirect-jmp %s -### -o 
%t.o 2>&1 | FileCheck -check-prefixes=SLS-IJMP,NO-SLS %s
 // RUN: %clang --target=i386 -march=i386 -mharden-sls=none -mharden-sls=all %s 
-### -o %t.o 2>&1 | FileCheck -check-prefixes=SLS-IJMP,SLS-RET %s



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


[PATCH] D152435: [analyzer][CStringChecker] Adjust the invalidation operation on the super region of the destination buffer during string copy

2023-06-13 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

Thanks for the elaborated answer on the GH issue. Now it makes sense. And the 
fix is align with the observations, which is good.
I only have concerns about the code quality of the modifier code. It was 
already in pretty bad shape, and I cannot say we improve it with this patch.
However, I can also see that it might require a bit engineering to refactor it 
into something cleaner, so I won't object if you push back.

Thanks for the patch!




Comment at: clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp:263-280
+  enum class InvalidationKind {
+// Invalidate the source buffer for escaping pointers.
+IK_SrcInvalidation,
+
+// Invalidate the destination buffer determined by characters copied.
+IK_DstInvalidationBySize,
+

I don't think this is the cleanest way to achieve this.
To me, it feels like it might make sense to have distinct invalidation 
functions for each scenario and mentally share the same overload-set.
Right now, the API looks really complicated: using enum values along with 
default parameters. Not to speak of how many parameters it accepts.
However, I won't object this time given that it was already pretty bad, and 
unreadable - so in that sense, it's not much worse this way and it was not the 
point to improve the quality of the code.



Comment at: clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp:992
 
-  QualType sizeTy = Size->getType();
+  QualType sizeTy = Size.getType(C.getASTContext());
   QualType PtrTy = Ctx.getPointerType(Ctx.CharTy);

The type of the `SVal` might not be always accurate.
in fact, we try to move away from using that in the future - whenever possible.
Consequently, I'd prefer passing down the type as an additional parameter 
instead, or just keeping the `Expr` along with the corresponding `SVal`.



Comment at: clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp:1071-1088
+if (InvalidationKind::IK_SrcInvalidation == Kind) {
   ITraits.setTrait(R->getBaseRegion(),
RegionAndSymbolInvalidationTraits::TK_PreserveContents);
   ITraits.setTrait(R, 
RegionAndSymbolInvalidationTraits::TK_SuppressEscape);
   CausesPointerEscape = true;
-} else {
-  const MemRegion::Kind& K = R->getKind();
-  if (K == MemRegion::FieldRegionKind)
-if (Size && IsFirstBufInBound(C, state, E, Size)) {
-  // If destination buffer is a field region and access is in bound,
-  // do not invalidate its super region.
-  ITraits.setTrait(
-  R,
-  
RegionAndSymbolInvalidationTraits::TK_DoNotInvalidateSuperRegion);
-}
+} else if (MemRegion::FieldRegionKind == R->getKind()) {
+  if (InvalidationKind::IK_DstAlwaysEscapeSuperRegion == Kind) {

Again, it's not your fault, but this code just looks insane.
I'm not surprised it had a bug, and likely it still has.



Comment at: clang/test/Analysis/issue-55019.c:3
+
+// RUN: %clang_analyze_cc1 %s -verify -Wno-strict-prototypes \
+// RUN:   -analyzer-checker=core \

Why do you need the `Wno-strict-prototypes`? Can we make it work with it?



Comment at: clang/test/Analysis/issue-55019.c:8
+
+#include "Inputs/system-header-simulator.h"
+void *malloc(size_t);

~~I guess this include is only for the `size_t`, right?
In c++, you could use `using size_t = decltype(sizeof(int));` to define it.~~

Ah, I see that it's for c function declarations. If that's the case, have you 
considered adding the `malloc` and `free` declarations to that header?



Comment at: clang/test/Analysis/issue-55019.c:26
+  clang_analyzer_dump(x.ptr); // expected-warning {{HeapSymRegion}}
+  memset(x.arr, 0, SIZE);
+  clang_analyzer_dump(x.ptr); // expected-warning {{HeapSymRegion}}

I believe you can use the `sizeof(x.arr)` instead.



Comment at: clang/test/Analysis/issue-55019.c:28
+  clang_analyzer_dump(x.ptr); // expected-warning {{HeapSymRegion}}
+  free(x.ptr);// no-warning
+}

I would rather use `no-leak-warning` here to be more specific about what we 
don't expect.



Comment at: clang/test/Analysis/issue-55019.cpp:1-4
+// Refer issue 55019 for more details.
+
+// RUN: %clang_analyze_cc1 %s -verify \
+// RUN:   -analyzer-checker=core,debug.ExprInspection

I think you can just append the C file to this one.
This shouldn't make a difference. And if it does, you can still guard that test 
code using macro `ifndef` trickery in addition to distinct `-verify=xxx` 
prefixes.



Comment at: clang/test/Analysis/issue-55019.cpp:24-26
+  // FIXME: As we cannot know whether the copy overflows, we will invalidate 
the
+  // entire object. Modify the verify direction from SymRegion to HeapSymRegion
+  // when the size if modeled in CStringChecker

[clang-tools-extra] 7d68f2e - [clangd] Desugar template parameter aliases in type hints

2023-06-13 Thread Younan Zhang via cfe-commits

Author: Younan Zhang
Date: 2023-06-13T19:15:24+08:00
New Revision: 7d68f2ef411ea2188666c2f67a8ee8b923adb12d

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

LOG: [clangd] Desugar template parameter aliases in type hints

This patch alleviates https://github.com/clangd/clangd/issues/1298.

Containers in C++ such as `std::vector` or `llvm::SmallVector`,
introduce a series of type aliases to adapt to generic algorithms.

Currently, If we write an declarator involving expressions with
these containers and `auto` placeholder, we probably obtain opaque
type alias like following:

```
std::vector v = {1, 2, 3};
auto value = v[1]; // hint for `value`: value_type
auto *ptr = &v[0]; // hint for `ptr`: value_type *
```

These hints are useless for most of the time. It would be nice if we
desugar the type of `value_type` and print `int`, `int *` respectively
in this situation. But note we can't always prefer desugared type
since user might introduce type-aliases for brevity, where printing
sugared types makes more sense.

This patch introduces a heuristic method that displays the desugared
type that is an alias of template parameter. It merges
analogous method `shouldPrintCanonicalType` into `maybeDesugar` as well.

Previous commit for shouldPrintCanonicalType: dde8a0fe91cc

Reviewed By: nridge

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

Added: 


Modified: 
clang-tools-extra/clangd/InlayHints.cpp
clang-tools-extra/clangd/unittests/InlayHintTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/InlayHints.cpp 
b/clang-tools-extra/clangd/InlayHints.cpp
index 5c78b4ca7c043..f81b51550ac9b 100644
--- a/clang-tools-extra/clangd/InlayHints.cpp
+++ b/clang-tools-extra/clangd/InlayHints.cpp
@@ -11,10 +11,12 @@
 #include "HeuristicResolver.h"
 #include "ParsedAST.h"
 #include "SourceCode.h"
+#include "clang/AST/ASTDiagnostic.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclarationName.h"
 #include "clang/AST/ExprCXX.h"
 #include "clang/AST/RecursiveASTVisitor.h"
+#include "clang/AST/Type.h"
 #include "clang/Basic/Builtins.h"
 #include "clang/Basic/SourceManager.h"
 #include "llvm/ADT/ScopeExit.h"
@@ -190,6 +192,64 @@ getDesignators(const InitListExpr *Syn) {
   return Designators;
 }
 
+// Determines if any intermediate type in desugaring QualType QT is of
+// substituted template parameter type. Ignore pointer or reference wrappers.
+bool isSugaredTemplateParameter(QualType QT) {
+  static auto PeelWrappers = [](QualType QT) {
+// Neither `PointerType` nor `ReferenceType` is considered as sugared
+// type. Peel it.
+QualType Next;
+while (!(Next = QT->getPointeeType()).isNull())
+  QT = Next;
+return QT;
+  };
+  while (true) {
+QualType Desugared =
+PeelWrappers(QT->getLocallyUnqualifiedSingleStepDesugaredType());
+if (Desugared == QT)
+  break;
+if (Desugared->getAs())
+  return true;
+QT = Desugared;
+  }
+  return false;
+}
+
+// A simple wrapper for `clang::desugarForDiagnostic` that provides optional
+// semantic.
+std::optional desugar(ASTContext &AST, QualType QT) {
+  bool ShouldAKA;
+  auto Desugared = clang::desugarForDiagnostic(AST, QT, ShouldAKA);
+  if (!ShouldAKA)
+return std::nullopt;
+  return Desugared;
+}
+
+// Apply a series of heuristic methods to determine whether or not a QualType 
QT
+// is suitable for desugaring (e.g. getting the real name behind the 
using-alias
+// name). If so, return the desugared type. Otherwise, return the unchanged
+// parameter QT.
+//
+// This could be refined further. See
+// https://github.com/clangd/clangd/issues/1298.
+QualType maybeDesugar(ASTContext &AST, QualType QT) {
+  // Prefer desugared type for name that aliases the template parameters.
+  // This can prevent things like printing opaque `: type` when accessing std
+  // containers.
+  if (isSugaredTemplateParameter(QT))
+return desugar(AST, QT).value_or(QT);
+
+  // Prefer desugared type for `decltype(expr)` specifiers.
+  if (QT->isDecltypeType())
+return QT.getCanonicalType();
+  if (const AutoType *AT = QT->getContainedAutoType())
+if (!AT->getDeducedType().isNull() &&
+AT->getDeducedType()->isDecltypeType())
+  return QT.getCanonicalType();
+
+  return QT;
+}
+
 class InlayHintVisitor : public RecursiveASTVisitor {
 public:
   InlayHintVisitor(std::vector &Results, ParsedAST &AST,
@@ -663,22 +723,7 @@ class InlayHintVisitor : public 
RecursiveASTVisitor {
  sourceLocToPosition(SM, Spelled->back().endLocation())};
   }
 
-  static bool shouldPrintCanonicalType(QualType QT) {
-// The sugared type is more useful in some cases, and the canonical
-// type in other cases. For now, prefer the sugared type unless
-// we are printing `decltype

[PATCH] D151785: [clangd] Desugar template parameter aliases in type hints

2023-06-13 Thread Younan Zhang 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 rG7d68f2ef411e: [clangd] Desugar template parameter aliases in 
type hints (authored by zyounan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151785

Files:
  clang-tools-extra/clangd/InlayHints.cpp
  clang-tools-extra/clangd/unittests/InlayHintTests.cpp

Index: clang-tools-extra/clangd/unittests/InlayHintTests.cpp
===
--- clang-tools-extra/clangd/unittests/InlayHintTests.cpp
+++ clang-tools-extra/clangd/unittests/InlayHintTests.cpp
@@ -1417,6 +1417,82 @@
   ExpectedHint{": int", "h"}, ExpectedHint{": int", "i"});
 }
 
+TEST(TypeHints, SubstTemplateParameterAliases) {
+  assertTypeHints(
+  R"cpp(
+  template  struct allocator {};
+
+  template 
+  struct vector_base {
+using pointer = T*;
+  };
+
+  template 
+  struct internal_iterator_type_template_we_dont_expect {};
+
+  struct my_iterator {};
+
+  template >
+  struct vector : vector_base {
+using base = vector_base;
+typedef T value_type;
+typedef base::pointer pointer;
+using allocator_type = A;
+using size_type = int;
+using iterator = internal_iterator_type_template_we_dont_expect;
+using non_template_iterator = my_iterator;
+
+value_type& operator[](int index) { return elements[index]; }
+const value_type& at(int index) const { return elements[index]; }
+pointer data() { return &elements[0]; }
+allocator_type get_allocator() { return A(); }
+size_type size() const { return 10; }
+iterator begin() { return iterator(); }
+non_template_iterator end() { return non_template_iterator(); }
+
+T elements[10];
+  };
+
+  vector array;
+
+  auto $no_modifier[[by_value]] = array[3];
+  auto* $ptr_modifier[[ptr]] = &array[3];
+  auto& $ref_modifier[[ref]] = array[3];
+  auto& $at[[immutable]] = array.at(3);
+
+  auto $data[[data]] = array.data();
+  auto $allocator[[alloc]] = array.get_allocator();
+  auto $size[[size]] = array.size();
+  auto $begin[[begin]] = array.begin();
+  auto $end[[end]] = array.end();
+
+
+  // If the type alias is not of substituted template parameter type,
+  // do not show desugared type.
+  using VeryLongLongTypeName = my_iterator;
+  using Short = VeryLongLongTypeName;
+
+  auto $short_name[[my_value]] = Short();
+
+  // Same applies with templates.
+  template 
+  using basic_static_vector = vector;
+  template 
+  using static_vector = basic_static_vector>;
+
+  auto $vector_name[[vec]] = static_vector();
+  )cpp",
+  ExpectedHint{": int", "no_modifier"},
+  ExpectedHint{": int *", "ptr_modifier"},
+  ExpectedHint{": int &", "ref_modifier"},
+  ExpectedHint{": const int &", "at"}, ExpectedHint{": int *", "data"},
+  ExpectedHint{": allocator", "allocator"},
+  ExpectedHint{": size_type", "size"}, ExpectedHint{": iterator", "begin"},
+  ExpectedHint{": non_template_iterator", "end"},
+  ExpectedHint{": Short", "short_name"},
+  ExpectedHint{": static_vector", "vector_name"});
+}
+
 TEST(DesignatorHints, Basic) {
   assertDesignatorHints(R"cpp(
 struct S { int x, y, z; };
Index: clang-tools-extra/clangd/InlayHints.cpp
===
--- clang-tools-extra/clangd/InlayHints.cpp
+++ clang-tools-extra/clangd/InlayHints.cpp
@@ -11,10 +11,12 @@
 #include "HeuristicResolver.h"
 #include "ParsedAST.h"
 #include "SourceCode.h"
+#include "clang/AST/ASTDiagnostic.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclarationName.h"
 #include "clang/AST/ExprCXX.h"
 #include "clang/AST/RecursiveASTVisitor.h"
+#include "clang/AST/Type.h"
 #include "clang/Basic/Builtins.h"
 #include "clang/Basic/SourceManager.h"
 #include "llvm/ADT/ScopeExit.h"
@@ -190,6 +192,64 @@
   return Designators;
 }
 
+// Determines if any intermediate type in desugaring QualType QT is of
+// substituted template parameter type. Ignore pointer or reference wrappers.
+bool isSugaredTemplateParameter(QualType QT) {
+  static auto PeelWrappers = [](QualType QT) {
+// Neither `PointerType` nor `ReferenceType` is considered as sugared
+// type. Peel it.
+QualType Next;
+while (!(Next = QT->getPointeeType()).isNull())
+  QT = Next;
+return QT;
+  };
+  while (true) {
+QualType Desugared =
+PeelWrappers(QT->getLocallyUnqualifiedSingleStepDesugaredType());
+if (Desugared == QT)
+  break;
+if (Desugared->getAs())
+  return true;
+QT = Desugared;
+  }
+  return false;
+}
+
+// A simple wrapper for `clang::desugarForDiagnostic` that provides optional
+// semantic.
+std::optional desugar(ASTContext &AST, QualType QT) {
+  bool ShouldAKA;
+  auto Desugared = clang::desugarForDiagnostic(AST, QT, ShouldAKA);
+  if (!ShouldAKA)
+return std::nullopt;
+  re

[PATCH] D152689: [NFC] Remove dead conditionals

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

LGTM!


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

https://reviews.llvm.org/D152689

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


[clang] c91ee29 - [Tooling/Inclusion] Add missing PRI family macros.

2023-06-13 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2023-06-13T13:33:53+02:00
New Revision: c91ee293f93b2547b75361b03fb6c85e0c19ed95

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

LOG: [Tooling/Inclusion] Add missing PRI family macros.

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

Added: 


Modified: 
clang/lib/Tooling/Inclusions/Stdlib/StdSpecialSymbolMap.inc

Removed: 




diff  --git a/clang/lib/Tooling/Inclusions/Stdlib/StdSpecialSymbolMap.inc 
b/clang/lib/Tooling/Inclusions/Stdlib/StdSpecialSymbolMap.inc
index 13a8d310a95be..c8da9f266ba1d 100644
--- a/clang/lib/Tooling/Inclusions/Stdlib/StdSpecialSymbolMap.inc
+++ b/clang/lib/Tooling/Inclusions/Stdlib/StdSpecialSymbolMap.inc
@@ -404,3 +404,314 @@ SYMBOL(NULL, None, )
 SYMBOL(NULL, None, )
 SYMBOL(NULL, None, )
 SYMBOL(NULL, None, )
+
+// Theres are macros that not spelled out in page linked from the index.
+// Extracted from https://en.cppreference.com/w/cpp/header/cinttypes
+SYMBOL(PRId8, None, )
+SYMBOL(PRId8, None, )
+SYMBOL(PRId16, None, )
+SYMBOL(PRId16, None, )
+SYMBOL(PRId32, None, )
+SYMBOL(PRId32, None, )
+SYMBOL(PRId64, None, )
+SYMBOL(PRId64, None, )
+SYMBOL(PRIdLEAST8, None, )
+SYMBOL(PRIdLEAST8, None, )
+SYMBOL(PRIdLEAST16, None, )
+SYMBOL(PRIdLEAST16, None, )
+SYMBOL(PRIdLEAST32, None, )
+SYMBOL(PRIdLEAST32, None, )
+SYMBOL(PRIdLEAST64, None, )
+SYMBOL(PRIdLEAST64, None, )
+SYMBOL(PRIdFAST8, None, )
+SYMBOL(PRIdFAST8, None, )
+SYMBOL(PRIdFAST16, None, )
+SYMBOL(PRIdFAST16, None, )
+SYMBOL(PRIdFAST32, None, )
+SYMBOL(PRIdFAST32, None, )
+SYMBOL(PRIdFAST64, None, )
+SYMBOL(PRIdFAST64, None, )
+SYMBOL(PRIdMAX, None, )
+SYMBOL(PRIdMAX, None, )
+SYMBOL(PRIdPTR, None, )
+SYMBOL(PRIdPTR, None, )
+SYMBOL(PRIi8, None, )
+SYMBOL(PRIi8, None, )
+SYMBOL(PRIi16, None, )
+SYMBOL(PRIi16, None, )
+SYMBOL(PRIi32, None, )
+SYMBOL(PRIi32, None, )
+SYMBOL(PRIi64, None, )
+SYMBOL(PRIi64, None, )
+SYMBOL(PRIiLEAST8, None, )
+SYMBOL(PRIiLEAST8, None, )
+SYMBOL(PRIiLEAST16, None, )
+SYMBOL(PRIiLEAST16, None, )
+SYMBOL(PRIiLEAST32, None, )
+SYMBOL(PRIiLEAST32, None, )
+SYMBOL(PRIiLEAST64, None, )
+SYMBOL(PRIiLEAST64, None, )
+SYMBOL(PRIiFAST8, None, )
+SYMBOL(PRIiFAST8, None, )
+SYMBOL(PRIiFAST16, None, )
+SYMBOL(PRIiFAST16, None, )
+SYMBOL(PRIiFAST32, None, )
+SYMBOL(PRIiFAST32, None, )
+SYMBOL(PRIiFAST64, None, )
+SYMBOL(PRIiFAST64, None, )
+SYMBOL(PRIiMAX, None, )
+SYMBOL(PRIiMAX, None, )
+SYMBOL(PRIiPTR, None, )
+SYMBOL(PRIiPTR, None, )
+SYMBOL(PRIu8, None, )
+SYMBOL(PRIu8, None, )
+SYMBOL(PRIu16, None, )
+SYMBOL(PRIu16, None, )
+SYMBOL(PRIu32, None, )
+SYMBOL(PRIu32, None, )
+SYMBOL(PRIu64, None, )
+SYMBOL(PRIu64, None, )
+SYMBOL(PRIuLEAST8, None, )
+SYMBOL(PRIuLEAST8, None, )
+SYMBOL(PRIuLEAST16, None, )
+SYMBOL(PRIuLEAST16, None, )
+SYMBOL(PRIuLEAST32, None, )
+SYMBOL(PRIuLEAST32, None, )
+SYMBOL(PRIuLEAST64, None, )
+SYMBOL(PRIuLEAST64, None, )
+SYMBOL(PRIuFAST8, None, )
+SYMBOL(PRIuFAST8, None, )
+SYMBOL(PRIuFAST16, None, )
+SYMBOL(PRIuFAST16, None, )
+SYMBOL(PRIuFAST32, None, )
+SYMBOL(PRIuFAST32, None, )
+SYMBOL(PRIuFAST64, None, )
+SYMBOL(PRIuFAST64, None, )
+SYMBOL(PRIuMAX, None, )
+SYMBOL(PRIuMAX, None, )
+SYMBOL(PRIuPTR, None, )
+SYMBOL(PRIuPTR, None, )
+SYMBOL(PRIo8, None, )
+SYMBOL(PRIo8, None, )
+SYMBOL(PRIo16, None, )
+SYMBOL(PRIo16, None, )
+SYMBOL(PRIo32, None, )
+SYMBOL(PRIo32, None, )
+SYMBOL(PRIo64, None, )
+SYMBOL(PRIo64, None, )
+SYMBOL(PRIoLEAST8, None, )
+SYMBOL(PRIoLEAST8, None, )
+SYMBOL(PRIoLEAST16, None, )
+SYMBOL(PRIoLEAST16, None, )
+SYMBOL(PRIoLEAST32, None, )
+SYMBOL(PRIoLEAST32, None, )
+SYMBOL(PRIoLEAST64, None, )
+SYMBOL(PRIoLEAST64, None, )
+SYMBOL(PRIoFAST8, None, )
+SYMBOL(PRIoFAST8, None, )
+SYMBOL(PRIoFAST16, None, )
+SYMBOL(PRIoFAST16, None, )
+SYMBOL(PRIoFAST32, None, )
+SYMBOL(PRIoFAST32, None, )
+SYMBOL(PRIoFAST64, None, )
+SYMBOL(PRIoFAST64, None, )
+SYMBOL(PRIoMAX, None, )
+SYMBOL(PRIoMAX, None, )
+SYMBOL(PRIoPTR, None, )
+SYMBOL(PRIoPTR, None, )
+SYMBOL(PRIx8, None, )
+SYMBOL(PRIx8, None, )
+SYMBOL(PRIx16, None, )
+SYMBOL(PRIx16, None, )
+SYMBOL(PRIx32, None, )
+SYMBOL(PRIx32, None, )
+SYMBOL(PRIx64, None, )
+SYMBOL(PRIx64, None, )
+SYMBOL(PRIxLEAST8, None, )
+SYMBOL(PRIxLEAST8, None, )
+SYMBOL(PRIxLEAST16, None, )
+SYMBOL(PRIxLEAST16, None, )
+SYMBOL(PRIxLEAST32, None, )
+SYMBOL(PRIxLEAST32, None, )
+SYMBOL(PRIxLEAST64, None, )
+SYMBOL(PRIxLEAST64, None, )
+SYMBOL(PRIxFAST8, None, )
+SYMBOL(PRIxFAST8, None, )
+SYMBOL(PRIxFAST16, None, )
+SYMBOL(PRIxFAST16, None, )
+SYMBOL(PRIxFAST32, None, )
+SYMBOL(PRIxFAST32, None, )
+SYMBOL(PRIxFAST64, None, )
+SYMBOL(PRIxFAST64, None, )
+SYMBOL(PRIxMAX, None, )
+SYMBOL(PRIxMAX, None, )
+SYMBOL(PRIxPTR, None, )
+SYMBOL(PRIxPTR, None, )
+SYMBOL(PRIX8, None, )
+SYMBOL(PRIX8, None, )
+SYMBOL(PRIX16, None, )
+SYMBOL(PRIX16, None, )
+SYMBOL(PRIX32, None, )
+SYMBO

[PATCH] D152792: [Tooling/Inclusion] Add missing PRI family macros.

2023-06-13 Thread Haojian Wu via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc91ee293f93b: [Tooling/Inclusion] Add missing PRI family 
macros. (authored by hokein).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152792

Files:
  clang/lib/Tooling/Inclusions/Stdlib/StdSpecialSymbolMap.inc

Index: clang/lib/Tooling/Inclusions/Stdlib/StdSpecialSymbolMap.inc
===
--- clang/lib/Tooling/Inclusions/Stdlib/StdSpecialSymbolMap.inc
+++ clang/lib/Tooling/Inclusions/Stdlib/StdSpecialSymbolMap.inc
@@ -404,3 +404,314 @@
 SYMBOL(NULL, None, )
 SYMBOL(NULL, None, )
 SYMBOL(NULL, None, )
+
+// Theres are macros that not spelled out in page linked from the index.
+// Extracted from https://en.cppreference.com/w/cpp/header/cinttypes
+SYMBOL(PRId8, None, )
+SYMBOL(PRId8, None, )
+SYMBOL(PRId16, None, )
+SYMBOL(PRId16, None, )
+SYMBOL(PRId32, None, )
+SYMBOL(PRId32, None, )
+SYMBOL(PRId64, None, )
+SYMBOL(PRId64, None, )
+SYMBOL(PRIdLEAST8, None, )
+SYMBOL(PRIdLEAST8, None, )
+SYMBOL(PRIdLEAST16, None, )
+SYMBOL(PRIdLEAST16, None, )
+SYMBOL(PRIdLEAST32, None, )
+SYMBOL(PRIdLEAST32, None, )
+SYMBOL(PRIdLEAST64, None, )
+SYMBOL(PRIdLEAST64, None, )
+SYMBOL(PRIdFAST8, None, )
+SYMBOL(PRIdFAST8, None, )
+SYMBOL(PRIdFAST16, None, )
+SYMBOL(PRIdFAST16, None, )
+SYMBOL(PRIdFAST32, None, )
+SYMBOL(PRIdFAST32, None, )
+SYMBOL(PRIdFAST64, None, )
+SYMBOL(PRIdFAST64, None, )
+SYMBOL(PRIdMAX, None, )
+SYMBOL(PRIdMAX, None, )
+SYMBOL(PRIdPTR, None, )
+SYMBOL(PRIdPTR, None, )
+SYMBOL(PRIi8, None, )
+SYMBOL(PRIi8, None, )
+SYMBOL(PRIi16, None, )
+SYMBOL(PRIi16, None, )
+SYMBOL(PRIi32, None, )
+SYMBOL(PRIi32, None, )
+SYMBOL(PRIi64, None, )
+SYMBOL(PRIi64, None, )
+SYMBOL(PRIiLEAST8, None, )
+SYMBOL(PRIiLEAST8, None, )
+SYMBOL(PRIiLEAST16, None, )
+SYMBOL(PRIiLEAST16, None, )
+SYMBOL(PRIiLEAST32, None, )
+SYMBOL(PRIiLEAST32, None, )
+SYMBOL(PRIiLEAST64, None, )
+SYMBOL(PRIiLEAST64, None, )
+SYMBOL(PRIiFAST8, None, )
+SYMBOL(PRIiFAST8, None, )
+SYMBOL(PRIiFAST16, None, )
+SYMBOL(PRIiFAST16, None, )
+SYMBOL(PRIiFAST32, None, )
+SYMBOL(PRIiFAST32, None, )
+SYMBOL(PRIiFAST64, None, )
+SYMBOL(PRIiFAST64, None, )
+SYMBOL(PRIiMAX, None, )
+SYMBOL(PRIiMAX, None, )
+SYMBOL(PRIiPTR, None, )
+SYMBOL(PRIiPTR, None, )
+SYMBOL(PRIu8, None, )
+SYMBOL(PRIu8, None, )
+SYMBOL(PRIu16, None, )
+SYMBOL(PRIu16, None, )
+SYMBOL(PRIu32, None, )
+SYMBOL(PRIu32, None, )
+SYMBOL(PRIu64, None, )
+SYMBOL(PRIu64, None, )
+SYMBOL(PRIuLEAST8, None, )
+SYMBOL(PRIuLEAST8, None, )
+SYMBOL(PRIuLEAST16, None, )
+SYMBOL(PRIuLEAST16, None, )
+SYMBOL(PRIuLEAST32, None, )
+SYMBOL(PRIuLEAST32, None, )
+SYMBOL(PRIuLEAST64, None, )
+SYMBOL(PRIuLEAST64, None, )
+SYMBOL(PRIuFAST8, None, )
+SYMBOL(PRIuFAST8, None, )
+SYMBOL(PRIuFAST16, None, )
+SYMBOL(PRIuFAST16, None, )
+SYMBOL(PRIuFAST32, None, )
+SYMBOL(PRIuFAST32, None, )
+SYMBOL(PRIuFAST64, None, )
+SYMBOL(PRIuFAST64, None, )
+SYMBOL(PRIuMAX, None, )
+SYMBOL(PRIuMAX, None, )
+SYMBOL(PRIuPTR, None, )
+SYMBOL(PRIuPTR, None, )
+SYMBOL(PRIo8, None, )
+SYMBOL(PRIo8, None, )
+SYMBOL(PRIo16, None, )
+SYMBOL(PRIo16, None, )
+SYMBOL(PRIo32, None, )
+SYMBOL(PRIo32, None, )
+SYMBOL(PRIo64, None, )
+SYMBOL(PRIo64, None, )
+SYMBOL(PRIoLEAST8, None, )
+SYMBOL(PRIoLEAST8, None, )
+SYMBOL(PRIoLEAST16, None, )
+SYMBOL(PRIoLEAST16, None, )
+SYMBOL(PRIoLEAST32, None, )
+SYMBOL(PRIoLEAST32, None, )
+SYMBOL(PRIoLEAST64, None, )
+SYMBOL(PRIoLEAST64, None, )
+SYMBOL(PRIoFAST8, None, )
+SYMBOL(PRIoFAST8, None, )
+SYMBOL(PRIoFAST16, None, )
+SYMBOL(PRIoFAST16, None, )
+SYMBOL(PRIoFAST32, None, )
+SYMBOL(PRIoFAST32, None, )
+SYMBOL(PRIoFAST64, None, )
+SYMBOL(PRIoFAST64, None, )
+SYMBOL(PRIoMAX, None, )
+SYMBOL(PRIoMAX, None, )
+SYMBOL(PRIoPTR, None, )
+SYMBOL(PRIoPTR, None, )
+SYMBOL(PRIx8, None, )
+SYMBOL(PRIx8, None, )
+SYMBOL(PRIx16, None, )
+SYMBOL(PRIx16, None, )
+SYMBOL(PRIx32, None, )
+SYMBOL(PRIx32, None, )
+SYMBOL(PRIx64, None, )
+SYMBOL(PRIx64, None, )
+SYMBOL(PRIxLEAST8, None, )
+SYMBOL(PRIxLEAST8, None, )
+SYMBOL(PRIxLEAST16, None, )
+SYMBOL(PRIxLEAST16, None, )
+SYMBOL(PRIxLEAST32, None, )
+SYMBOL(PRIxLEAST32, None, )
+SYMBOL(PRIxLEAST64, None, )
+SYMBOL(PRIxLEAST64, None, )
+SYMBOL(PRIxFAST8, None, )
+SYMBOL(PRIxFAST8, None, )
+SYMBOL(PRIxFAST16, None, )
+SYMBOL(PRIxFAST16, None, )
+SYMBOL(PRIxFAST32, None, )
+SYMBOL(PRIxFAST32, None, )
+SYMBOL(PRIxFAST64, None, )
+SYMBOL(PRIxFAST64, None, )
+SYMBOL(PRIxMAX, None, )
+SYMBOL(PRIxMAX, None, )
+SYMBOL(PRIxPTR, None, )
+SYMBOL(PRIxPTR, None, )
+SYMBOL(PRIX8, None, )
+SYMBOL(PRIX8, None, )
+SYMBOL(PRIX16, None, )
+SYMBOL(PRIX16, None, )
+SYMBOL(PRIX32, None, )
+SYMBOL(PRIX32, None, )
+SYMBOL(PRIX64, None, )
+SYMBOL(PRIX64, None, )
+SYMBOL(PRIXLEAST8, None, )
+SYMBOL(PRIXLEAST8, None, )
+SYMBOL(PRIXLEAST16, None, )
+SYMBOL(PRIXLEAST16, None, )
+SYMBOL(PRIXLEAST32, None, )
+SYMBOL(PRI

[PATCH] D146987: [Assignment Tracking] Enable by default

2023-06-13 Thread Orlando Cazalet-Hyams via Phabricator via cfe-commits
Orlando added a comment.

> Looks like this is causing a crash on current main: 
> https://github.com/llvm/llvm-project/issues/62838

That was fixed in D151326 . I think we should 
be okay to re-enable this now. The first assertion was a bit of an edge case; I 
hadn't handled negative out of bounds accesses. The second issue ocurred due to 
DW_ATE_complex_float not being supported in a helper function, on a code path 
only hit with assignment tracking as a result of trying harder to preserve 
variable locations.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146987

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


[PATCH] D152801: [include-cleaner] Don't apply PreferredHeader hings for standard headers.

2023-06-13 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.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152801

Files:
  clang-tools-extra/include-cleaner/lib/FindHeaders.cpp
  clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp


Index: clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp
===
--- clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp
+++ clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp
@@ -486,5 +486,16 @@
   }
 }
 
+TEST_F(HeadersForSymbolTest, StandardHeaders) {
+  Inputs.Code = "void assert();";
+  buildAST();
+  EXPECT_THAT(
+  headersFor("assert"),
+  // Respect the ordering from the stdlib mapping.
+  UnorderedElementsAre(tooling::stdlib::Header::named(""),
+   tooling::stdlib::Header::named("")));
+}
+
+
 } // namespace
 } // namespace clang::include_cleaner
Index: clang-tools-extra/include-cleaner/lib/FindHeaders.cpp
===
--- clang-tools-extra/include-cleaner/lib/FindHeaders.cpp
+++ clang-tools-extra/include-cleaner/lib/FindHeaders.cpp
@@ -248,6 +248,10 @@
   // Add name match hints to deduplicated providers.
   llvm::StringRef SymbolName = symbolName(S);
   for (auto &H : Headers) {
+// Don't apply name match hints to standard headers as the standard headers
+// are already ranked in the stdlib mapping.
+if (H.kind() == Header::Standard)
+  continue;
 if (nameMatch(SymbolName, H))
   H.Hint |= Hints::PreferredHeader;
   }


Index: clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp
===
--- clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp
+++ clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp
@@ -486,5 +486,16 @@
   }
 }
 
+TEST_F(HeadersForSymbolTest, StandardHeaders) {
+  Inputs.Code = "void assert();";
+  buildAST();
+  EXPECT_THAT(
+  headersFor("assert"),
+  // Respect the ordering from the stdlib mapping.
+  UnorderedElementsAre(tooling::stdlib::Header::named(""),
+   tooling::stdlib::Header::named("")));
+}
+
+
 } // namespace
 } // namespace clang::include_cleaner
Index: clang-tools-extra/include-cleaner/lib/FindHeaders.cpp
===
--- clang-tools-extra/include-cleaner/lib/FindHeaders.cpp
+++ clang-tools-extra/include-cleaner/lib/FindHeaders.cpp
@@ -248,6 +248,10 @@
   // Add name match hints to deduplicated providers.
   llvm::StringRef SymbolName = symbolName(S);
   for (auto &H : Headers) {
+// Don't apply name match hints to standard headers as the standard headers
+// are already ranked in the stdlib mapping.
+if (H.kind() == Header::Standard)
+  continue;
 if (nameMatch(SymbolName, H))
   H.Hint |= Hints::PreferredHeader;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] de6da6a - Reapply D146987 "[Assignment Tracking] Enable by default"

2023-06-13 Thread via cfe-commits

Author: OCHyams
Date: 2023-06-13T12:43:46+01:00
New Revision: de6da6ad55d3ca945195d1cb109cb8efdf40a52a

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

LOG: Reapply D146987 "[Assignment Tracking] Enable by default"

See https://discourse.llvm.org/t/rfc-enable-assignment-tracking/69399

This sets the -Xclang -fexperimental-assignment-tracking flag to the value
enabled which means it will be enabled so long as none of the following are
true: it's an LTO build, LLDB debugger tuning has been specified, or it's an O0
build (no work is done in any case if -g is not specified or -gmlt is used).

This reverts commit 9e7f14a8211c82dca64bd6b22d1c450d4c6d3e5b which reverts
https://reviews.llvm.org/D146987

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/test/CodeGen/assignment-tracking/flag.cpp

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index e2cc71bd869a9..8f5db34551c07 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -5937,7 +5937,7 @@ def fexperimental_assignment_tracking_EQ : Joined<["-"], 
"fexperimental-assignme
   Group, CodeGenOpts<"EnableAssignmentTracking">,
   NormalizedValuesScope<"CodeGenOptions::AssignmentTrackingOpts">,
   Values<"disabled,enabled,forced">, 
NormalizedValues<["Disabled","Enabled","Forced"]>,
-  MarshallingInfoEnum, "Disabled">;
+  MarshallingInfoEnum, "Enabled">;
 
 } // let Flags = [CC1Option, NoDriverOption]
 

diff  --git a/clang/test/CodeGen/assignment-tracking/flag.cpp 
b/clang/test/CodeGen/assignment-tracking/flag.cpp
index aa1f054dae4d7..3bd974fe07c6c 100644
--- a/clang/test/CodeGen/assignment-tracking/flag.cpp
+++ b/clang/test/CodeGen/assignment-tracking/flag.cpp
@@ -8,10 +8,10 @@
 // RUN: -emit-llvm  %s -o - -fexperimental-assignment-tracking=disabled 
-O1\
 // RUN: | FileCheck %s --check-prefixes=DISABLE
 
- Disabled by default:
+ Enabled by default:
 // RUN: %clang_cc1 -triple x86_64-none-linux-gnu -debug-info-kind=standalone   
\
 // RUN: -emit-llvm  %s -o - -O1
\
-// RUN: | FileCheck %s --check-prefixes=DISABLE
+// RUN: | FileCheck %s --check-prefixes=ENABLE
 
  Disabled at O0 unless forced.
 // RUN: %clang_cc1 -triple x86_64-none-linux-gnu -debug-info-kind=standalone   
\



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


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

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



Comment at: clang/lib/Sema/Sema.cpp:1350
   continue; // Deleted functions are supposed to be unused.
+SourceRange DiagRange = SourceRange(DiagD->getLocation());
+if (const ASTTemplateArgumentListInfo *ASTTAL =

Does `DiagD->getSourceRange()` not give you the same results?



Comment at: clang/lib/Sema/Sema.cpp:1384
   DiagD = cast(*I);
+SourceRange DiagRange = SourceRange(DiagD->getLocation());
+if (const auto *VTSD = dyn_cast(DiagD))




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

https://reviews.llvm.org/D152707

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


[PATCH] D152788: [Clang] Show type in enum out of range diagnostic

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

Thank you for this, I like the changes! Can you add a test showing template 
instantiation (the case that you were struggling to identify the enumeration 
from) and a release note?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152788

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


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

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

Rebased


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150860

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

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

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

2023-06-13 Thread Takuya Shimizu via Phabricator via cfe-commits
hazohelet added inline comments.



Comment at: clang/lib/Sema/Sema.cpp:1350
   continue; // Deleted functions are supposed to be unused.
+SourceRange DiagRange = SourceRange(DiagD->getLocation());
+if (const ASTTemplateArgumentListInfo *ASTTAL =

aaron.ballman wrote:
> Does `DiagD->getSourceRange()` not give you the same results?
`FunctionDecl::getSourceRange` also covers the return type and the function 
body if it exists, so we cannot use it here.


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

https://reviews.llvm.org/D152707

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


[PATCH] D142630: [clang][Interp] Implement virtual function calls

2023-06-13 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




Comment at: clang/test/AST/Interp/records.cpp:650
+};
+#endif

tbaeder wrote:
> aaron.ballman wrote:
> > We should also have test cases for calling virtual functions from within a 
> > constructor and a destructor, as that has special semantics. e.g., 
> > https://godbolt.org/z/snaj1zfM5
> That's broken right now of course. I'l add the test and adjust the expected 
> output. I'll probably have to save a few bits for "things we're currently 
> doing" (like evaluating a constructor), but in a later patch.
> 
> FWIW, I expanded your test a bit: https://godbolt.org/z/vq5xT3xvq and it only 
> fails in clang - with a reference:
> ```
>   // CWG issue 1517: we're constructing a base class of the object described 
> by
>   // 'This', so that object has not yet begun its period of construction and
>   // any polymorphic operation on it results in undefined behavior.
> ```
Handled in a follow-up is fine by me, thanks!


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

https://reviews.llvm.org/D142630

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


[PATCH] D152802: [clang-tidy] Fix crash in `modernize-use-default-member-init`

2023-06-13 Thread André Schackier via Phabricator via cfe-commits
AMS21 created this revision.
AMS21 added reviewers: PiotrZSL, njames93, carlosgalvezp.
Herald added a subscriber: xazax.hun.
Herald added a project: All.
AMS21 requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

This was causes by `getValueOfValueInit` unconditionally calling
`getScalarTypeKind` on the member type, which would then trigger an
assertions since arrays are not scalar type.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152802

Files:
  clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/test/clang-tidy/checkers/modernize/use-default-member-init.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/modernize/use-default-member-init.cpp
===
--- 
clang-tools-extra/test/clang-tidy/checkers/modernize/use-default-member-init.cpp
+++ 
clang-tools-extra/test/clang-tidy/checkers/modernize/use-default-member-init.cpp
@@ -482,3 +482,17 @@
   // CHECK-FIXES:  {{^  }}EmptyBracedIntDefault()  {}
   // CHECK-FIXES-NEXT: {{^  }}int m_i{};
 };
+
+namespace PR63285 {
+
+class ArrayValueInit {
+  double bar[1];
+  ArrayValueInit() : bar() {}
+};
+
+class ArrayBraceInit {
+  double bar[1];
+  ArrayBraceInit() : bar{} {}
+};
+
+} // namespace PR63285
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -325,6 +325,10 @@
   constructors toward hand written constructors so that they are skipped if 
more
   than one exists.
 
+- Fixed crash in :doc:`modernize-use-default-member-init
+  ` with array members 
which
+  are value initialized.
+
 - Fixed false positive in :doc:`modernize-use-equals-default
   ` check for special member
   functions containing macros or preprocessor directives, and out-of-line 
special
Index: clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
===
--- clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
+++ clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
@@ -267,18 +267,25 @@
   CharSourceRange InitRange =
   CharSourceRange::getCharRange(LParenEnd, Init->getRParenLoc());
 
-  bool ValueInit = isa(Init->getInit());
-  bool CanAssign = UseAssignment && (!ValueInit || 
!Init->getInit()->getType()->isEnumeralType());
+  const Expr *InitExpression = Init->getInit();
+  const QualType InitType = InitExpression->getType();
+
+  // We do not handle array types at the moment
+  if (isa(InitType)) {
+return;
+  }
+
+  const bool ValueInit = isa(InitExpression);
+  const bool CanAssign =
+  UseAssignment && (!ValueInit || !InitType->isEnumeralType());
 
   auto Diag =
   diag(Field->getLocation(), "use default member initializer for %0")
-  << Field
-  << FixItHint::CreateInsertion(FieldEnd, CanAssign ? " = " : "{")
+  << Field << FixItHint::CreateInsertion(FieldEnd, CanAssign ? " = " : "{")
   << FixItHint::CreateInsertionFromRange(FieldEnd, InitRange);
 
   if (CanAssign && ValueInit)
-Diag << FixItHint::CreateInsertion(
-FieldEnd, getValueOfValueInit(Init->getInit()->getType()));
+Diag << FixItHint::CreateInsertion(FieldEnd, 
getValueOfValueInit(InitType));
 
   if (!CanAssign)
 Diag << FixItHint::CreateInsertion(FieldEnd, "}");
@@ -294,8 +301,7 @@
 return;
 
   diag(Init->getSourceLocation(), "member initializer for %0 is redundant")
-  << Field
-  << FixItHint::CreateRemoval(Init->getSourceRange());
+  << Field << FixItHint::CreateRemoval(Init->getSourceRange());
 }
 
 } // namespace clang::tidy::modernize


Index: clang-tools-extra/test/clang-tidy/checkers/modernize/use-default-member-init.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/modernize/use-default-member-init.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/modernize/use-default-member-init.cpp
@@ -482,3 +482,17 @@
   // CHECK-FIXES:  {{^  }}EmptyBracedIntDefault()  {}
   // CHECK-FIXES-NEXT: {{^  }}int m_i{};
 };
+
+namespace PR63285 {
+
+class ArrayValueInit {
+  double bar[1];
+  ArrayValueInit() : bar() {}
+};
+
+class ArrayBraceInit {
+  double bar[1];
+  ArrayBraceInit() : bar{} {}
+};
+
+} // namespace PR63285
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -325,6 +325,10 @@
   constructors toward hand written constructors so that they are skipped if more
   than one exists.
 
+- Fixed crash in :doc:`modernize-use-default-member-init
+  ` with array members which
+  are value initialized.
+
 - Fixed false positive in :doc:`moder

[PATCH] D152520: [clangd] Unify printing policy for type hints

2023-06-13 Thread Younan Zhang via Phabricator via cfe-commits
zyounan updated this revision to Diff 530867.
zyounan added a comment.

Rebase onto D151785 .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152520

Files:
  clang-tools-extra/clangd/InlayHints.cpp
  clang-tools-extra/clangd/unittests/InlayHintTests.cpp

Index: clang-tools-extra/clangd/unittests/InlayHintTests.cpp
===
--- clang-tools-extra/clangd/unittests/InlayHintTests.cpp
+++ clang-tools-extra/clangd/unittests/InlayHintTests.cpp
@@ -1347,8 +1347,11 @@
 struct A {};
 A foo();
 auto $var[[var]] = foo();
+A bar[1];
+auto [$binding[[value]]] = bar;
   )cpp",
-  ExpectedHint{": A", "var"});
+  ExpectedHint{": A", "var"},
+  ExpectedHint{": A", "binding"});
 }
 
 TEST(TypeHints, Deduplication) {
Index: clang-tools-extra/clangd/InlayHints.cpp
===
--- clang-tools-extra/clangd/InlayHints.cpp
+++ clang-tools-extra/clangd/InlayHints.cpp
@@ -258,8 +258,7 @@
 Cfg(Cfg), RestrictRange(std::move(RestrictRange)),
 MainFileID(AST.getSourceManager().getMainFileID()),
 Resolver(AST.getHeuristicResolver()),
-TypeHintPolicy(this->AST.getPrintingPolicy()),
-StructuredBindingPolicy(this->AST.getPrintingPolicy()) {
+TypeHintPolicy(this->AST.getPrintingPolicy()) {
 bool Invalid = false;
 llvm::StringRef Buf =
 AST.getSourceManager().getBufferData(MainFileID, &Invalid);
@@ -269,14 +268,8 @@
 TypeHintPolicy.AnonymousTagLocations =
 false; // do not print lambda locations
 
-// For structured bindings, print canonical types. This is important because
-// for bindings that use the tuple_element protocol, the non-canonical types
-// would be "tuple_element::type".
-// For "auto", we often prefer sugared types.
 // Not setting PrintCanonicalTypes for "auto" allows
 // SuppressDefaultTemplateArgs (set by default) to have an effect.
-StructuredBindingPolicy = TypeHintPolicy;
-StructuredBindingPolicy.PrintCanonicalTypes = true;
   }
 
   bool VisitTypeLoc(TypeLoc TL) {
@@ -358,8 +351,12 @@
 // but show hints for the individual bindings.
 if (auto *DD = dyn_cast(D)) {
   for (auto *Binding : DD->bindings()) {
-addTypeHint(Binding->getLocation(), Binding->getType(), /*Prefix=*/": ",
-StructuredBindingPolicy);
+// For structured bindings, print canonical types. This is important
+// because for bindings that use the tuple_element protocol, the
+// non-canonical types would be "tuple_element::type".
+if (auto Type = Binding->getType(); !Type.isNull())
+  addTypeHint(Binding->getLocation(), Type.getCanonicalType(),
+  /*Prefix=*/": ");
   }
   return true;
 }
@@ -724,22 +721,17 @@
   }
 
   void addTypeHint(SourceRange R, QualType T, llvm::StringRef Prefix) {
-addTypeHint(R, T, Prefix, TypeHintPolicy);
-  }
-
-  void addTypeHint(SourceRange R, QualType T, llvm::StringRef Prefix,
-   const PrintingPolicy &Policy) {
 if (!Cfg.InlayHints.DeducedTypes || T.isNull())
   return;
 
 // The sugared type is more useful in some cases, and the canonical
 // type in other cases.
 auto Desugared = maybeDesugar(AST, T);
-std::string TypeName = Desugared.getAsString(Policy);
+std::string TypeName = Desugared.getAsString(TypeHintPolicy);
 if (T != Desugared && !shouldPrintTypeHint(TypeName)) {
   // If the desugared type is too long to display, fallback to the sugared
   // type.
-  TypeName = T.getAsString(Policy);
+  TypeName = T.getAsString(TypeHintPolicy);
 }
 if (shouldPrintTypeHint(TypeName))
   addInlayHint(R, HintSide::Right, InlayHintKind::Type, Prefix, TypeName,
@@ -764,14 +756,7 @@
   FileID MainFileID;
   StringRef MainFileBuf;
   const HeuristicResolver *Resolver;
-  // We want to suppress default template arguments, but otherwise print
-  // canonical types. Unfortunately, they're conflicting policies so we can't
-  // have both. For regular types, suppressing template arguments is more
-  // important, whereas printing canonical types is crucial for structured
-  // bindings, so we use two separate policies. (See the constructor where
-  // the policies are initialized for more details.)
   PrintingPolicy TypeHintPolicy;
-  PrintingPolicy StructuredBindingPolicy;
 };
 
 } // namespace
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2023-06-13 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.

LG aside from the few suggested changes and moving the header to the Inputs 
directory.




Comment at: clang/lib/Sema/Sema.cpp:1350
   continue; // Deleted functions are supposed to be unused.
+SourceRange DiagRange = SourceRange(DiagD->getLocation());
+if (const ASTTemplateArgumentListInfo *ASTTAL =

hazohelet wrote:
> aaron.ballman wrote:
> > Does `DiagD->getSourceRange()` not give you the same results?
> `FunctionDecl::getSourceRange` also covers the return type and the function 
> body if it exists, so we cannot use it here.
Ah, okay, that makes sense. Thank you!


I think we should consider adding `SourceRange` accessors for various 
interesting ranges like this so that we don't need to use ad hoc solutions in 
various places.




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

tbaeder wrote:
> Moving this file to `Inputs/` would make sense I think.
+1


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

https://reviews.llvm.org/D152707

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


[PATCH] D152752: [MS] Fix passing aligned records by value in some cases

2023-06-13 Thread Nikita Popov via Phabricator via cfe-commits
nikic accepted this revision.
nikic 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/D152752/new/

https://reviews.llvm.org/D152752

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


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

2023-06-13 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham added a comment.

Right, this seems to be passing tests now, so I think @nickdesaulniers's issue 
is fixed, and I've also split up the tests as @MaskRay suggested.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152433

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


[PATCH] D152473: [clang-format] Add test case for issue 63170

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

Part of my concern was that the reversion removed a unit test, which 
effectively regressed a different fix, I'm not comfortable with that.

I think we can resolve the original problem with the following fix.

  diff --git a/clang/lib/Format/UnwrappedLineFormatter.cpp 
b/clang/lib/Format/UnwrappedLineFormatter.cpp
  index 33be74dfe1b9..4876d8cdcf0c 100644
  --- a/clang/lib/Format/UnwrappedLineFormatter.cpp
  +++ b/clang/lib/Format/UnwrappedLineFormatter.cpp
  @@ -1489,6 +1489,7 @@ void UnwrappedLineFormatter::formatFirstToken(
  
 // Insert or remove empty line after access specifiers.
 if (PreviousLine && PreviousLine->First->isAccessSpecifier() &&
  +  !RootToken.Finalized &&
 (!PreviousLine->InPPDirective || !RootToken.HasUnescapedNewline)) {
   // EmptyLineBeforeAccessModifier is handling the case when two access
   // modifiers follow each other.






Comment at: clang/unittests/Format/FormatTest.cpp:12859
Style);
-  verifyFormat("struct foo {\n"
-   "#ifdef FOO\n"

removing a test, only hides another regression, this should have been left 
really, and a fix worked.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152473

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


[PATCH] D146148: Float_t and double_t types shouldn't be modified by #pragma clang fp eval_method

2023-06-13 Thread Zahira Ammarguellat via Phabricator via cfe-commits
zahiraam added a comment.

@rjmccall any chance we get your feedback on this please? Thanks.


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

https://reviews.llvm.org/D146148

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


[PATCH] D152804: [clang-format] Propose a new solution to - Fix overlapping replacements before PPDirectives

2023-06-13 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay created this revision.
MyDeveloperDay added a reviewer: owenpan.
MyDeveloperDay added projects: clang, clang-format.
Herald added a project: All.
Herald added reviewers: rymiel, HazardyKnusperkeks.
MyDeveloperDay requested review of this revision.

Propose a new solution to

D151954: [clang-format] Fix overlapping whitespace replacements before 
PPDirective 

That was reverted as part of

D152473: [clang-format] Add test case for issue 63170 



Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152804

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


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -12857,6 +12857,39 @@
"};\n",
Style);
 
+  verifyFormat("struct foo {\n"
+   "#ifdef FOO1\n"
+   "#else\n"
+   "private:\n"
+   "\n"
+   "#endif\n"
+   "};",
+   "struct foo {\n"
+   "#ifdef FOO1\n"
+   "#else\n"
+   "private:\n"
+   "\n"
+   "#endif\n"
+   "};",
+   Style);
+
+  verifyFormat("struct foo {\n"
+   "#ifdef FOO2\n"
+   "#else\n"
+   "private:\n"
+   "\n"
+   "#endif\n"
+   "};",
+   "struct foo {\n"
+   "#ifdef FOO2\n"
+   "#else\n"
+   "private:\n"
+   "\n"
+   "\n"
+   "#endif\n"
+   "};",
+   Style);
+
   Style.EmptyLineAfterAccessModifier = FormatStyle::ELAAMS_Always;
   verifyFormat("struct foo {\n"
"private:\n"
Index: clang/lib/Format/UnwrappedLineFormatter.cpp
===
--- clang/lib/Format/UnwrappedLineFormatter.cpp
+++ clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -1489,6 +1489,7 @@
 
   // Insert or remove empty line after access specifiers.
   if (PreviousLine && PreviousLine->First->isAccessSpecifier() &&
+  !RootToken.Finalized &&
   (!PreviousLine->InPPDirective || !RootToken.HasUnescapedNewline)) {
 // EmptyLineBeforeAccessModifier is handling the case when two access
 // modifiers follow each other.


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -12857,6 +12857,39 @@
"};\n",
Style);
 
+  verifyFormat("struct foo {\n"
+   "#ifdef FOO1\n"
+   "#else\n"
+   "private:\n"
+   "\n"
+   "#endif\n"
+   "};",
+   "struct foo {\n"
+   "#ifdef FOO1\n"
+   "#else\n"
+   "private:\n"
+   "\n"
+   "#endif\n"
+   "};",
+   Style);
+
+  verifyFormat("struct foo {\n"
+   "#ifdef FOO2\n"
+   "#else\n"
+   "private:\n"
+   "\n"
+   "#endif\n"
+   "};",
+   "struct foo {\n"
+   "#ifdef FOO2\n"
+   "#else\n"
+   "private:\n"
+   "\n"
+   "\n"
+   "#endif\n"
+   "};",
+   Style);
+
   Style.EmptyLineAfterAccessModifier = FormatStyle::ELAAMS_Always;
   verifyFormat("struct foo {\n"
"private:\n"
Index: clang/lib/Format/UnwrappedLineFormatter.cpp
===
--- clang/lib/Format/UnwrappedLineFormatter.cpp
+++ clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -1489,6 +1489,7 @@
 
   // Insert or remove empty line after access specifiers.
   if (PreviousLine && PreviousLine->First->isAccessSpecifier() &&
+  !RootToken.Finalized &&
   (!PreviousLine->InPPDirective || !RootToken.HasUnescapedNewline)) {
 // EmptyLineBeforeAccessModifier is handling the case when two access
 // modifiers follow each other.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D152804: [clang-format] Propose a new solution to - Fix overlapping replacements before PPDirectives

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

ok this still doesn't resolve the original 
https://github.com/llvm/llvm-project/issues/62892


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152804

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


[PATCH] D152802: [clang-tidy] Fix crash in `modernize-use-default-member-init`

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



Comment at: 
clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp:274-276
+  if (isa(InitType)) {
+return;
+  }

instead of ignoring array types, better would be just not provide FixItHints 
for them, so WRN would stil be emited.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152802

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


[PATCH] D152804: [clang-format] Propose a new solution to - Fix overlapping replacements before PPDirectives

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

but it does seem to resolve https://github.com/llvm/llvm-project/issues/63170


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152804

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


[PATCH] D152796: [clang][Sema] Fix diagnostic message for unused constant varialbe templates

2023-06-13 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder accepted this revision.
tbaeder added a comment.
This revision is now accepted and ready to land.

Makes sense. LGTM provided precommit CI comes back green.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152796

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


[PATCH] D152801: [include-cleaner] Don't apply PreferredHeader hings for standard headers.

2023-06-13 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet accepted this revision.
kadircet added a comment.
This revision is now accepted and ready to land.

thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152801

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


[PATCH] D149867: [Clang][M68k] Add Clang support for the new M68k_RTD CC

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

This should also come with a release note for the changes.




Comment at: clang/lib/AST/ASTContext.cpp:11998-11999
+  return CC_X86StdCall;
+else if (T.getArch() == llvm::Triple::m68k)
+  return CC_M68kRTD;
+  }

This looks wrong to me -- if the language option is calling for stdcall, saying 
"here's m68k_rtd instead" does not match caller expectations.



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:559
+emitError |= DefaultCC == LangOptions::DCC_StdCall &&
+ Arch != llvm::Triple::m68k && Arch != llvm::Triple::x86;
 emitError |= (DefaultCC == LangOptions::DCC_VectorCall ||

Maybe it's too early in the morning for me to be thinking clearly, but this is 
wrong for m68k, isn't it? If the default calling convention is stdcall and the 
architecture is m68k, we want to emit the error, don't we?

I don't see test coverage for the change.



Comment at: clang/lib/Sema/SemaType.cpp:7960-7961
 if (FnP && FnP->isVariadic()) {
-  // stdcall and fastcall are ignored with a warning for GCC and MS
-  // compatibility.
-  if (CC == CC_X86StdCall || CC == CC_X86FastCall)
+  // stdcall, fastcall, and m68k's RTD are ignored with a warning for GCC
+  // and MS compatibility.
+  if (CC == CC_X86StdCall || CC == CC_X86FastCall || CC == CC_M68kRTD)

Missing test coverage, but also, MSVC supports m68k RTD? I would assume we'd 
error on this situation given how we document the attribute as not supporting 
this.



Comment at: clang/test/CodeGen/mrtd.c:4
 
-// CHECK: mrtd.c:10:3: warning: function with no prototype cannot use the 
stdcall calling convention
+// CHECK: mrtd.c:13:3: warning: function with no prototype cannot use the 
stdcall calling convention
 

myhsu wrote:
> jrtc27 wrote:
> > Ew... this should be using -verify and `// expected-warning {{...}}`, then 
> > the line number is relative to the comment's location. Or, really, it 
> > should be in the Sema test...
> > 
> > Plus is it correct to call this stdcall on m68k? The GCC manpage only 
> > mentions it in the x86 option description, not the m68k one.
> Now this check is moved to `test/Sema/m68k-mrtd.c`
This check should be removed here -- we don't typically test diagnostic 
behavior from codegen tests unless the diagnostic is only emitted during 
codegen.



Comment at: clang/test/Sema/m68k-mrtd.c:4-9
+#ifdef MRTD
+// expected-error@+3 {{function with no prototype cannot use the m68k_rtd 
calling convention}}
+#endif
+void foo(int arg) {
+  bar(arg);
+}

A better way to do this is to use `-verify=mrtd` on the line enabling rtd, and 
using `// rtd-error {{whatever}}` on the line being diagnosed. (Same comment 
applies throughout the file.)

Huh, I was unaware that implicit function declarations are using something 
other than the default calling convention (which is C, not m68k_rtd). Is this 
intentional?



Comment at: clang/test/Sema/m68k-mrtd.c:45
+extern void (*d)(int, ...);
+__attribute__((m68k_rtd)) extern void (*d)(int, ...);

Missing tests for:

* Function without a prototype
* Applying the attribute to a non-function
* Providing arguments to the attribute
* What should happen for C++ and things like member functions?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149867

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


[PATCH] D142823: Intrinsics: Allow tablegen to mark parameters with dereferenceable

2023-06-13 Thread Nikita Popov via Phabricator via cfe-commits
nikic accepted this revision.
nikic added a comment.
This revision is now accepted and ready to land.

LGTM


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

https://reviews.llvm.org/D142823

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


[PATCH] D151373: [libclang] Expose arguments of clang::annotate{_type}

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

I think precommit CI may have found a relevant failure:

   TEST 'Clang :: Index/IBOutletCollection.m' FAILED 

  Script:
  --
  : 'RUN: at line 8';   
c:\ws\w5\llvm-project\premerge-checks\build\bin\c-index-test.exe 
-cursor-at=C:\ws\w5\llvm-project\premerge-checks\clang\test\Index\IBOutletCollection.m:4:24
 C:\ws\w5\llvm-project\premerge-checks\clang\test\Index\IBOutletCollection.m | 
c:\ws\w5\llvm-project\premerge-checks\build\bin\filecheck.exe 
-check-prefix=CHECK-CURSOR 
C:\ws\w5\llvm-project\premerge-checks\clang\test\Index\IBOutletCollection.m
  : 'RUN: at line 11';   
c:\ws\w5\llvm-project\premerge-checks\build\bin\c-index-test.exe 
-test-annotate-tokens=C:\ws\w5\llvm-project\premerge-checks\clang\test\Index\IBOutletCollection.m:4:1:5:1
 C:\ws\w5\llvm-project\premerge-checks\clang\test\Index\IBOutletCollection.m | 
c:\ws\w5\llvm-project\premerge-checks\build\bin\filecheck.exe 
-check-prefix=CHECK-TOK 
C:\ws\w5\llvm-project\premerge-checks\clang\test\Index\IBOutletCollection.m
  --
  Exit Code: 1
   
  Command Output (stdout):
  --
  $ ":" "RUN: at line 8"
  $ "c:\ws\w5\llvm-project\premerge-checks\build\bin\c-index-test.exe" 
"-cursor-at=C:\ws\w5\llvm-project\premerge-checks\clang\test\Index\IBOutletCollection.m:4:24"
 "C:\ws\w5\llvm-project\premerge-checks\clang\test\Index\IBOutletCollection.m"
  $ "c:\ws\w5\llvm-project\premerge-checks\build\bin\filecheck.exe" 
"-check-prefix=CHECK-CURSOR" 
"C:\ws\w5\llvm-project\premerge-checks\clang\test\Index\IBOutletCollection.m"
  # command stderr:
  
C:\ws\w5\llvm-project\premerge-checks\clang\test\Index\IBOutletCollection.m:9:18:
 error: CHECK-CURSOR: expected string not found in input
  // CHECK-CURSOR: ObjCClassRef=Test:3:12
   ^
  :1:1: note: scanning from here
  4:3 attribute(iboutletcollection)= [IBOutletCollection=ObjCInterface] 
Extent=[4:3 - 4:27]
  ^
  :1:54: note: possible intended match here
  4:3 attribute(iboutletcollection)= [IBOutletCollection=ObjCInterface] 
Extent=[4:3 - 4:27]
   ^
   
  Input file: 
  Check file: 
C:\ws\w5\llvm-project\premerge-checks\clang\test\Index\IBOutletCollection.m
   
  -dump-input=help explains the following input dump.
   
  Input was:
  <<
 1: 4:3 attribute(iboutletcollection)= 
[IBOutletCollection=ObjCInterface] Extent=[4:3 - 4:27]
  check:9'0 
X~
 error: no match found
  check:9'1  ?  
   possible intended match
  >>
   
  error: command failed with exit status: 1
   
  --
   
  




Comment at: clang/unittests/libclang/LibclangTest.cpp:1176
+TEST_F(LibclangParseTest, ExposedAnnotateArgs) {
+  // TODO
+  const char testSource[] = R"cpp(

Spurious comment?



Comment at: clang/unittests/libclang/LibclangTest.cpp:1178
+  const char testSource[] = R"cpp(
+int [[clang::annotate_type("category_type", 42)]] f;
+

We don't seem to be testing this?


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

https://reviews.llvm.org/D151373

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


[PATCH] D152813: [clang][dataflow] Create `Value`s for integer literals.

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

This patch includes a test that fails without the fix.

I discovered that we weren't creating `Value`s for integer literals when, in a
different patch, I tried to overwrite the value of a struct field with a literal
for the purposes of a test and was surprised to find that the struct compared
the same before and after the assignment.

This functionality therefore seems useful at least for tests, but is probably
also useful for actual analysis of code.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152813

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


Index: clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
@@ -811,6 +811,31 @@
   });
 }
 
+TEST(TransferTest, BinaryOperatorAssignLiteral) {
+  std::string Code = R"(
+void target() {
+  int Foo = 1;
+  // [[before]]
+  Foo = 2;
+  // [[after]]
+}
+  )";
+  runDataflow(
+  Code,
+  [](const llvm::StringMap> &Results,
+ ASTContext &ASTCtx) {
+const Environment &Before =
+getEnvironmentAtAnnotation(Results, "before");
+const Environment &After = getEnvironmentAtAnnotation(Results, 
"after");
+
+const auto &ValBefore =
+getValueForDecl(ASTCtx, Before, "Foo");
+const auto &ValAfter =
+getValueForDecl(ASTCtx, After, "Foo");
+EXPECT_NE(&ValBefore, &ValAfter);
+  });
+}
+
 TEST(TransferTest, VarDeclInitAssign) {
   std::string Code = R"(
 void target() {
Index: clang/lib/Analysis/FlowSensitive/Transfer.cpp
===
--- clang/lib/Analysis/FlowSensitive/Transfer.cpp
+++ clang/lib/Analysis/FlowSensitive/Transfer.cpp
@@ -775,6 +775,11 @@
 Env.setValueStrict(*S, Env.getBoolLiteralValue(S->getValue()));
   }
 
+  void VisitIntegerLiteral(const IntegerLiteral *S) {
+if (Value *Val = Env.createValue(S->getType()))
+  Env.setValueStrict(*S, *Val);
+  }
+
   void VisitParenExpr(const ParenExpr *S) {
 // The CFG does not contain `ParenExpr` as top-level statements in basic
 // blocks, however manual traversal to sub-expressions may encounter them.


Index: clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
@@ -811,6 +811,31 @@
   });
 }
 
+TEST(TransferTest, BinaryOperatorAssignLiteral) {
+  std::string Code = R"(
+void target() {
+  int Foo = 1;
+  // [[before]]
+  Foo = 2;
+  // [[after]]
+}
+  )";
+  runDataflow(
+  Code,
+  [](const llvm::StringMap> &Results,
+ ASTContext &ASTCtx) {
+const Environment &Before =
+getEnvironmentAtAnnotation(Results, "before");
+const Environment &After = getEnvironmentAtAnnotation(Results, "after");
+
+const auto &ValBefore =
+getValueForDecl(ASTCtx, Before, "Foo");
+const auto &ValAfter =
+getValueForDecl(ASTCtx, After, "Foo");
+EXPECT_NE(&ValBefore, &ValAfter);
+  });
+}
+
 TEST(TransferTest, VarDeclInitAssign) {
   std::string Code = R"(
 void target() {
Index: clang/lib/Analysis/FlowSensitive/Transfer.cpp
===
--- clang/lib/Analysis/FlowSensitive/Transfer.cpp
+++ clang/lib/Analysis/FlowSensitive/Transfer.cpp
@@ -775,6 +775,11 @@
 Env.setValueStrict(*S, Env.getBoolLiteralValue(S->getValue()));
   }
 
+  void VisitIntegerLiteral(const IntegerLiteral *S) {
+if (Value *Val = Env.createValue(S->getType()))
+  Env.setValueStrict(*S, *Val);
+  }
+
   void VisitParenExpr(const ParenExpr *S) {
 // The CFG does not contain `ParenExpr` as top-level statements in basic
 // blocks, however manual traversal to sub-expressions may encounter them.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] 5cdb906 - [clangd] Unify printing policy for type hints

2023-06-13 Thread Younan Zhang via cfe-commits

Author: Younan Zhang
Date: 2023-06-13T21:31:10+08:00
New Revision: 5cdb906f1e4093600f99aab8660e1536514a57e8

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

LOG: [clangd] Unify printing policy for type hints

(This patch addresses the comment from 
https://reviews.llvm.org/D151785#4402460.)

Previously, we used a special printing policy that enabled `PrintCanonicalTypes`
to print type hints for structure bindings. This was intended to
eliminate type aliases like `tuple_element::type`. However, this also
caused TypePrinter to print default template arguments, which could
result in losing the ability to see types like `std::basic_string`
if the fully expanded template-id exceeded the default inlay hint threshold.

Simply getting the canonical type at the call site could help us get rid of
the side effect.

This also merges overloaded `addTypeHint` into one function without
`PrintingPolicy`.

Reviewed By: nridge

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

Added: 


Modified: 
clang-tools-extra/clangd/InlayHints.cpp
clang-tools-extra/clangd/unittests/InlayHintTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/InlayHints.cpp 
b/clang-tools-extra/clangd/InlayHints.cpp
index f81b51550ac9b..416a01f4737bc 100644
--- a/clang-tools-extra/clangd/InlayHints.cpp
+++ b/clang-tools-extra/clangd/InlayHints.cpp
@@ -258,8 +258,7 @@ class InlayHintVisitor : public 
RecursiveASTVisitor {
 Cfg(Cfg), RestrictRange(std::move(RestrictRange)),
 MainFileID(AST.getSourceManager().getMainFileID()),
 Resolver(AST.getHeuristicResolver()),
-TypeHintPolicy(this->AST.getPrintingPolicy()),
-StructuredBindingPolicy(this->AST.getPrintingPolicy()) {
+TypeHintPolicy(this->AST.getPrintingPolicy()) {
 bool Invalid = false;
 llvm::StringRef Buf =
 AST.getSourceManager().getBufferData(MainFileID, &Invalid);
@@ -269,14 +268,8 @@ class InlayHintVisitor : public 
RecursiveASTVisitor {
 TypeHintPolicy.AnonymousTagLocations =
 false; // do not print lambda locations
 
-// For structured bindings, print canonical types. This is important 
because
-// for bindings that use the tuple_element protocol, the non-canonical 
types
-// would be "tuple_element::type".
-// For "auto", we often prefer sugared types.
 // Not setting PrintCanonicalTypes for "auto" allows
 // SuppressDefaultTemplateArgs (set by default) to have an effect.
-StructuredBindingPolicy = TypeHintPolicy;
-StructuredBindingPolicy.PrintCanonicalTypes = true;
   }
 
   bool VisitTypeLoc(TypeLoc TL) {
@@ -358,8 +351,12 @@ class InlayHintVisitor : public 
RecursiveASTVisitor {
 // but show hints for the individual bindings.
 if (auto *DD = dyn_cast(D)) {
   for (auto *Binding : DD->bindings()) {
-addTypeHint(Binding->getLocation(), Binding->getType(), /*Prefix=*/": 
",
-StructuredBindingPolicy);
+// For structured bindings, print canonical types. This is important
+// because for bindings that use the tuple_element protocol, the
+// non-canonical types would be "tuple_element::type".
+if (auto Type = Binding->getType(); !Type.isNull())
+  addTypeHint(Binding->getLocation(), Type.getCanonicalType(),
+  /*Prefix=*/": ");
   }
   return true;
 }
@@ -724,22 +721,17 @@ class InlayHintVisitor : public 
RecursiveASTVisitor {
   }
 
   void addTypeHint(SourceRange R, QualType T, llvm::StringRef Prefix) {
-addTypeHint(R, T, Prefix, TypeHintPolicy);
-  }
-
-  void addTypeHint(SourceRange R, QualType T, llvm::StringRef Prefix,
-   const PrintingPolicy &Policy) {
 if (!Cfg.InlayHints.DeducedTypes || T.isNull())
   return;
 
 // The sugared type is more useful in some cases, and the canonical
 // type in other cases.
 auto Desugared = maybeDesugar(AST, T);
-std::string TypeName = Desugared.getAsString(Policy);
+std::string TypeName = Desugared.getAsString(TypeHintPolicy);
 if (T != Desugared && !shouldPrintTypeHint(TypeName)) {
   // If the desugared type is too long to display, fallback to the sugared
   // type.
-  TypeName = T.getAsString(Policy);
+  TypeName = T.getAsString(TypeHintPolicy);
 }
 if (shouldPrintTypeHint(TypeName))
   addInlayHint(R, HintSide::Right, InlayHintKind::Type, Prefix, TypeName,
@@ -764,14 +756,7 @@ class InlayHintVisitor : public 
RecursiveASTVisitor {
   FileID MainFileID;
   StringRef MainFileBuf;
   const HeuristicResolver *Resolver;
-  // We want to suppress default template arguments, but otherwise print
-  // canonical types. Unfortunately, they're conflicting policies so we can't
-  // have both. For regular types, supp

[PATCH] D152520: [clangd] Unify printing policy for type hints

2023-06-13 Thread Younan Zhang 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 rG5cdb906f1e40: [clangd] Unify printing policy for type hints 
(authored by zyounan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152520

Files:
  clang-tools-extra/clangd/InlayHints.cpp
  clang-tools-extra/clangd/unittests/InlayHintTests.cpp

Index: clang-tools-extra/clangd/unittests/InlayHintTests.cpp
===
--- clang-tools-extra/clangd/unittests/InlayHintTests.cpp
+++ clang-tools-extra/clangd/unittests/InlayHintTests.cpp
@@ -1347,8 +1347,11 @@
 struct A {};
 A foo();
 auto $var[[var]] = foo();
+A bar[1];
+auto [$binding[[value]]] = bar;
   )cpp",
-  ExpectedHint{": A", "var"});
+  ExpectedHint{": A", "var"},
+  ExpectedHint{": A", "binding"});
 }
 
 TEST(TypeHints, Deduplication) {
Index: clang-tools-extra/clangd/InlayHints.cpp
===
--- clang-tools-extra/clangd/InlayHints.cpp
+++ clang-tools-extra/clangd/InlayHints.cpp
@@ -258,8 +258,7 @@
 Cfg(Cfg), RestrictRange(std::move(RestrictRange)),
 MainFileID(AST.getSourceManager().getMainFileID()),
 Resolver(AST.getHeuristicResolver()),
-TypeHintPolicy(this->AST.getPrintingPolicy()),
-StructuredBindingPolicy(this->AST.getPrintingPolicy()) {
+TypeHintPolicy(this->AST.getPrintingPolicy()) {
 bool Invalid = false;
 llvm::StringRef Buf =
 AST.getSourceManager().getBufferData(MainFileID, &Invalid);
@@ -269,14 +268,8 @@
 TypeHintPolicy.AnonymousTagLocations =
 false; // do not print lambda locations
 
-// For structured bindings, print canonical types. This is important because
-// for bindings that use the tuple_element protocol, the non-canonical types
-// would be "tuple_element::type".
-// For "auto", we often prefer sugared types.
 // Not setting PrintCanonicalTypes for "auto" allows
 // SuppressDefaultTemplateArgs (set by default) to have an effect.
-StructuredBindingPolicy = TypeHintPolicy;
-StructuredBindingPolicy.PrintCanonicalTypes = true;
   }
 
   bool VisitTypeLoc(TypeLoc TL) {
@@ -358,8 +351,12 @@
 // but show hints for the individual bindings.
 if (auto *DD = dyn_cast(D)) {
   for (auto *Binding : DD->bindings()) {
-addTypeHint(Binding->getLocation(), Binding->getType(), /*Prefix=*/": ",
-StructuredBindingPolicy);
+// For structured bindings, print canonical types. This is important
+// because for bindings that use the tuple_element protocol, the
+// non-canonical types would be "tuple_element::type".
+if (auto Type = Binding->getType(); !Type.isNull())
+  addTypeHint(Binding->getLocation(), Type.getCanonicalType(),
+  /*Prefix=*/": ");
   }
   return true;
 }
@@ -724,22 +721,17 @@
   }
 
   void addTypeHint(SourceRange R, QualType T, llvm::StringRef Prefix) {
-addTypeHint(R, T, Prefix, TypeHintPolicy);
-  }
-
-  void addTypeHint(SourceRange R, QualType T, llvm::StringRef Prefix,
-   const PrintingPolicy &Policy) {
 if (!Cfg.InlayHints.DeducedTypes || T.isNull())
   return;
 
 // The sugared type is more useful in some cases, and the canonical
 // type in other cases.
 auto Desugared = maybeDesugar(AST, T);
-std::string TypeName = Desugared.getAsString(Policy);
+std::string TypeName = Desugared.getAsString(TypeHintPolicy);
 if (T != Desugared && !shouldPrintTypeHint(TypeName)) {
   // If the desugared type is too long to display, fallback to the sugared
   // type.
-  TypeName = T.getAsString(Policy);
+  TypeName = T.getAsString(TypeHintPolicy);
 }
 if (shouldPrintTypeHint(TypeName))
   addInlayHint(R, HintSide::Right, InlayHintKind::Type, Prefix, TypeName,
@@ -764,14 +756,7 @@
   FileID MainFileID;
   StringRef MainFileBuf;
   const HeuristicResolver *Resolver;
-  // We want to suppress default template arguments, but otherwise print
-  // canonical types. Unfortunately, they're conflicting policies so we can't
-  // have both. For regular types, suppressing template arguments is more
-  // important, whereas printing canonical types is crucial for structured
-  // bindings, so we use two separate policies. (See the constructor where
-  // the policies are initialized for more details.)
   PrintingPolicy TypeHintPolicy;
-  PrintingPolicy StructuredBindingPolicy;
 };
 
 } // namespace
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D152802: [clang-tidy] Fix crash in `modernize-use-default-member-init`

2023-06-13 Thread André Schackier via Phabricator via cfe-commits
AMS21 updated this revision to Diff 530892.
AMS21 marked an inline comment as done.
AMS21 added a comment.

Still issue a warning just no fixit


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152802

Files:
  clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/test/clang-tidy/checkers/modernize/use-default-member-init-assignment.cpp
  
clang-tools-extra/test/clang-tidy/checkers/modernize/use-default-member-init.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/modernize/use-default-member-init.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/modernize/use-default-member-init.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/modernize/use-default-member-init.cpp
@@ -482,3 +482,19 @@
   // CHECK-FIXES:  {{^  }}EmptyBracedIntDefault()  {}
   // CHECK-FIXES-NEXT: {{^  }}int m_i{};
 };
+
+namespace PR63285 {
+
+class ArrayValueInit {
+  double m_array[1];
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: use default member initializer for 'm_array' [modernize-use-default-member-init]
+  ArrayValueInit() : m_array() {}
+};
+
+class ArrayBraceInit {
+  double m_array[1];
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: use default member initializer for 'm_array' [modernize-use-default-member-init]
+  ArrayBraceInit() : m_array{} {}
+};
+
+} // namespace PR63285
Index: clang-tools-extra/test/clang-tidy/checkers/modernize/use-default-member-init-assignment.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/modernize/use-default-member-init-assignment.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/modernize/use-default-member-init-assignment.cpp
@@ -190,3 +190,19 @@
 
 NegativeTemplate nti;
 NegativeTemplate ntd;
+
+namespace PR63285 {
+
+class ArrayValueInit {
+  double m_array[1];
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: use default member initializer for 'm_array' [modernize-use-default-member-init]
+  ArrayValueInit() : m_array() {}
+};
+
+class ArrayBraceInit {
+  double m_array[1];
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: use default member initializer for 'm_array' [modernize-use-default-member-init]
+  ArrayBraceInit() : m_array{} {}
+};
+
+} // namespace PR63285
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -325,6 +325,10 @@
   constructors toward hand written constructors so that they are skipped if more
   than one exists.
 
+- Fixed crash in :doc:`modernize-use-default-member-init
+  ` with array members which
+  are value initialized.
+
 - Fixed false positive in :doc:`modernize-use-equals-default
   ` check for special member
   functions containing macros or preprocessor directives, and out-of-line special
Index: clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
===
--- clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
+++ clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
@@ -267,18 +267,26 @@
   CharSourceRange InitRange =
   CharSourceRange::getCharRange(LParenEnd, Init->getRParenLoc());
 
-  bool ValueInit = isa(Init->getInit());
-  bool CanAssign = UseAssignment && (!ValueInit || !Init->getInit()->getType()->isEnumeralType());
+  const Expr *InitExpression = Init->getInit();
+  const QualType InitType = InitExpression->getType();
+
+  const bool ValueInit = isa(InitExpression);
+  const bool CanAssign =
+  UseAssignment && (!ValueInit || !InitType->isEnumeralType());
 
   auto Diag =
   diag(Field->getLocation(), "use default member initializer for %0")
-  << Field
-  << FixItHint::CreateInsertion(FieldEnd, CanAssign ? " = " : "{")
-  << FixItHint::CreateInsertionFromRange(FieldEnd, InitRange);
+  << Field;
+
+  // Don't create FixItHint for arrays
+  if (isa(InitType))
+return;
+
+  Diag << FixItHint::CreateInsertion(FieldEnd, CanAssign ? " = " : "{")
+   << FixItHint::CreateInsertionFromRange(FieldEnd, InitRange);
 
   if (CanAssign && ValueInit)
-Diag << FixItHint::CreateInsertion(
-FieldEnd, getValueOfValueInit(Init->getInit()->getType()));
+Diag << FixItHint::CreateInsertion(FieldEnd, getValueOfValueInit(InitType));
 
   if (!CanAssign)
 Diag << FixItHint::CreateInsertion(FieldEnd, "}");
@@ -294,8 +302,7 @@
 return;
 
   diag(Init->getSourceLocation(), "member initializer for %0 is redundant")
-  << Field
-  << FixItHint::CreateRemoval(Init->getSourceRange());
+  << Field << FixItHint::CreateRemoval(Init->getSourceRange());
 }
 
 } // namespace clang::tidy::modernize
___
cfe-comm

[PATCH] D152802: [clang-tidy] Fix crash in `modernize-use-default-member-init`

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

Maybe we should still support arrays in some way


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152802

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


[PATCH] D152802: [clang-tidy] Fix crash in `modernize-use-default-member-init`

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



Comment at: 
clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp:273
+
+  const bool ValueInit = isa(InitExpression);
+  const bool CanAssign =

```const bool ValueInit = isa(InitExpression) && 
!isa(InitType);```
This should do a trick.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152802

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


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

2023-06-13 Thread Manuel Brito via Phabricator via cfe-commits
ManuelJBrito added a comment.

In D149548#4413762 , @uweigand wrote:

> In D149548#4413639 , @nlopes wrote:
>
>> If a vector is fully initialized with `insertvector` (i.e., one operation 
>> per index), then the value of the base vector is irrelevant. It can be 
>> poison.
>> Poison in vectors is element-wise.  doesn't propagate to 
>> .
>
> OK, that should be fine for SystemZ then.  Thanks!

Thanks! I'll move forward then.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149548

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


[PATCH] D152632: [Clang] Add warnings for CWG2521

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



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:411
+  "identifier '%0' preceded by space(s) in the literal operator declaration "
+  "is deprecated">, InGroup, DefaultIgnore;
 def warn_reserved_module_name : Warning<

Oye, I'm of two minds about `DefaultIgnore`.

On the one hand, this is going to fire *a lot*: 
https://sourcegraph.com/search?q=context:global+operator%5B%5B:space:%5D%5D*%5C%22%5C%22%5B%5B:space:%5D%5D%5BA-Za-z0-9_%5D%2B&patternType=regexp&case=yes&sm=1&groupBy=repo

On the other hand, if we don't warn about it being deprecated, users won't know 
about it, which makes it harder to do anything about it the longer we silently 
allow it. (We have plenty of experience with this particular flavor of pain.)

I think we should warn about this by default. It's under its own warning group, 
so users who want to ignore the warning and live dangerously can do so. And it 
will be silenced in system headers automatically, so issuing the diagnostic 
should generally be actionable for users.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:9268-9271
 def warn_user_literal_reserved : Warning<
-  "user-defined literal suffixes not starting with '_' are reserved"
+  "user-defined literal suffixes containing '__' or not starting with '_' are 
reserved"
   "%select{; no literal will invoke this operator|}0">,
   InGroup;

Hmmm, you've moved things in the right direction, but I think this should also 
live under the `-Wreserved-identifier` group given that it's about reserved 
identifiers.



Comment at: clang/lib/Sema/SemaDeclCXX.cpp:16448
 = FnDecl->getDeclName().getCXXLiteralIdentifier()->getName();
-  if (LiteralName[0] != '_' &&
+  if ((LiteralName[0] != '_' || LiteralName.contains("__")) &&
   !getSourceManager().isInSystemHeader(FnDecl->getLocation())) {

I think we should use `IdentifierInfo::isReserved()` to determine why it's 
reserved.



Comment at: clang/lib/Sema/SemaExprCXX.cpp:512-517
+  Diag(Loc, diag::warn_deprecated_literal_operator_id)
+  << II->getName()
   << FixItHint::CreateReplacement(
  Name.getSourceRange(),
  (StringRef("operator\"\"") + II->getName()).str());
 }

Hmmm this means we're issuing two diagnostics -- missing an `else` here?



Comment at: clang/test/CXX/drs/dr17xx.cpp:129
   float operator ""_E(const char *);
   // expected-error@+2 {{invalid suffix on literal; C++11 requires a space 
between literal and identifier}}
+  // expected-warning@+1 {{user-defined literal suffixes containing '__' or 
not starting with '_' are reserved; no literal will invoke this operator}}

So we give an error if there's not a space, but then give a deprecation warning 
when there is a space?


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

https://reviews.llvm.org/D152632

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


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

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

In D150226#4408980 , @dblaikie wrote:

> In D150226#4408563 , @erichkeane 
> wrote:
>
>> In D150226#4408381 , 
>> @aaron.ballman wrote:
>>
>>> In D150226#4404808 , @rupprecht 
>>> wrote:
>>>
 I suppose including this warning in `ShowInSystemHeader` with your diff 
 above would be a good first step anyway, right? If we're about to make it 
 a hard error anyway, then making it a `ShowInSystemHeader` error first 
 would ease that transition.
>>>
>>> Yes and no.
>>>
>>> If we're going to turn something into a hard error, letting folks 
>>> implementing system headers know about it is important, so from that 
>>> perspective, it makes sense to enable the diagnostic in system headers. 
>>> However, *users* have no choice in their system headers (oftentimes) which 
>>> makes the diagnostic unactionable for them as they're not going to (and 
>>> shouldn't have to) modify system headers, so from that perspective, 
>>> enabling the diagnostic in a system header introduces friction.
>>>
>>> If this diagnostic is showing up in system headers, I think we would likely 
>>> need to consider adding a compatibility hack to allow Clang to still 
>>> consume that system header while erroring when outside of that system 
>>> header (we've done this before to keep STL implementations working, for 
>>> example). Between this need and the friction it causes users to have an 
>>> unactionable diagnostic, I think we probably should not enable 
>>> `ShowInSystemHeader`.
>>
>> It seems to me that if our concern is breaking system headers, we need to do 
>> that with better testing.  Some sort of 'diagnostic group' for "This is 
>> going to become an error *SOON*" mixed with us/vendors running that on 
>> platforms we consider significant enough to not break.  But just diagnosing 
>> on arbitrary users with no choice on how to fix the headers doesn't seem 
>> appropriate.
>
> I think that's the request here: 
> https://github.com/llvm/llvm-project/issues/63180

+1, I think that request is a reasonable idea to help maintainers of system 
headers.

It sounds like we're in agreement that we should not enable 
`ShowInSystemHeaders` for this, but it's not clear whether we've got agreement 
yet that we can land this change right now. I think it's acceptable to kick the 
can down the road by another release or so if we feel we need to, but there is 
a hard stop to that at some point (some folks won't fix their code until 
they're forced to do so, and there's not much we can do about those cases).


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

https://reviews.llvm.org/D150226

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


[PATCH] D125171: [clang-format] Add a new clang-format option AlwaysBreakBeforeFunctionParameters

2023-06-13 Thread jonathan molinatto via Phabricator via cfe-commits
jrmolin added inline comments.



Comment at: clang/unittests/Format/FormatTest.cpp:25716
+   "int param2,\n"
+   "int param3);\n",
+   Style);

H-G-Hristov wrote:
> Does this work with `BAS_BlockIndent`? I don't see any related tests.
How do you want me to test it? I'm happy to, if that means this will get merged 
at some point. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125171

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


[PATCH] D145284: WIP [clang] adds capabilities for SARIF to be written to file

2023-06-13 Thread Vaibhav Yenamandra via Phabricator via cfe-commits
vaibhav.y added inline comments.



Comment at: clang/lib/Tooling/SarifLinker.cpp:21
+
+namespace llvm::sarif_linker {
+[[noreturn]] void ReportErrorAndExit(llvm::errc error_code, StringRef Message) 
{

Is this for link diagnostics reported as SARIF?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145284

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


[PATCH] D150803: [WebAssembly] Add a new `wasm_async` clang attribute for marking async functions.

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

Aside from the suggested changes, the Clang bits LGTM




Comment at: clang/lib/Sema/SemaDeclAttr.cpp:7636-7639
+static void handleWebAssemblyAsyncAttr(Sema &S, Decl *D, const ParsedAttr &AL) 
{
+  D->addAttr(::new (S.Context) WebAssemblyAsyncAttr(S.Context, AL));
+}
+

This can be removed entirely (see edit below).



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:8747
+  case ParsedAttr::AT_WebAssemblyAsync:
+handleWebAssemblyAsyncAttr(S, D, AL);
+break;




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150803

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


[PATCH] D152525: [clang][Diagnostics] Don't expand label fixit to the next line

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

In D152525#4408902 , @tbaeder wrote:

> As far as the fixit goes, I guess the previous version was better, since it 
> didn't leave an empty line behind?

Yes, but that's a formatting-related concern with the output, and we 
traditionally leave that to another tool like clang-format to address.

LGTM, but add a release note since there technically is a change in behavior 
with the fix-it?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152525

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


[PATCH] D150358: [clang][Interp] Remove args from called functions in more cases

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



Comment at: clang/test/AST/Interp/functions.cpp:262
+namespace CallWithArgs {
+  /// This used to call problems during checkPotentialConstantExpression() 
runs.
+  constexpr void g(int a) {}

tbaeder wrote:
> aaron.ballman wrote:
> > 
> Question regarding this: IIRC it was @MaskRay who once told me to use `///` 
> comments for everything that's not a `RUN` or `expected` line. If you look 
> further up, I think I stuck to that (mostly). Should I continue doing that or 
> not?
Oh yeah, you did mostly stick to that; then ignore my suggestion. However, we 
have no policy regarding `//` vs `///` vs `/**/`, so it's pretty much a 
case-by-case basis, but in general we use `//` for all comments unless there's 
a specific reason not to.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150358

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


[PATCH] D152818: [Clang] Fix assertion when pragma FENV_ACCESS is used with a throw function.

2023-06-13 Thread Zahira Ammarguellat via Phabricator via cfe-commits
zahiraam created this revision.
zahiraam added a reviewer: aaron.ballman.
Herald added a project: All.
zahiraam requested review of this revision.
Herald added a project: clang.

See issue here: https://godbolt.org/z/aYME8KTdn


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152818

Files:
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/test/CodeGen/pragma-fenv_access.cpp


Index: clang/test/CodeGen/pragma-fenv_access.cpp
===
--- /dev/null
+++ clang/test/CodeGen/pragma-fenv_access.cpp
@@ -0,0 +1,71 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fcxx-exceptions \
+// RUN: -fexceptions -emit-llvm -o - %s | FileCheck %s
+
+// expected-no-diagnostics
+
+char b;
+template  using d = c;
+template  void e();
+template  auto g(f k) { auto pt = *k; }
+class n {
+public:
+  n(char *);
+};
+template  using i = aa;
+template  constexpr bool j = true;
+struct o {
+  using l = char;
+  using ac = l *;
+};
+template  class p {
+public:
+  m ad;
+};
+template  struct ae;
+template  class q {
+public:
+  using ac = o::ac;
+  void r() { g(af.h); }
+  struct {
+ac h;
+  } af;
+};
+class s {
+  using ag = i;
+  using ah = q, o, ae>>;
+
+public:
+  s(char *);
+  char *t() { ai.ad.r(); }
+  p ai;
+};
+using aj = s;
+class ak : n {
+public:
+  using al = n;
+  ak(aj k) : al(k.t()) {}
+};
+class u : ak {
+protected:
+  u() : ak(0) {}
+};
+class am : u {};
+class v {
+public:
+  class w : am {
+  public:
+w(aj) {}
+  };
+};
+class x : v {
+protected:
+  void y() { throw w(&b); }
+};
+class z : x {
+public:
+  z() { y(); }
+};
+#pragma STDC FENV_ACCESS ON
+void a() { z(); }
+
+// CHECK: define dso_local void @_Z1av()
Index: clang/lib/CodeGen/CodeGenFunction.cpp
===
--- clang/lib/CodeGen/CodeGenFunction.cpp
+++ clang/lib/CodeGen/CodeGenFunction.cpp
@@ -161,6 +161,7 @@
   assert((CGF.CurFuncDecl == nullptr || CGF.Builder.getIsFPConstrained() ||
   isa(CGF.CurFuncDecl) ||
   isa(CGF.CurFuncDecl) ||
+  isa(CGF.CurFuncDecl) ||
   (NewExceptionBehavior == llvm::fp::ebIgnore &&
NewRoundingBehavior == llvm::RoundingMode::NearestTiesToEven)) &&
  "FPConstrained should be enabled on entire function");


Index: clang/test/CodeGen/pragma-fenv_access.cpp
===
--- /dev/null
+++ clang/test/CodeGen/pragma-fenv_access.cpp
@@ -0,0 +1,71 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fcxx-exceptions \
+// RUN: -fexceptions -emit-llvm -o - %s | FileCheck %s
+
+// expected-no-diagnostics
+
+char b;
+template  using d = c;
+template  void e();
+template  auto g(f k) { auto pt = *k; }
+class n {
+public:
+  n(char *);
+};
+template  using i = aa;
+template  constexpr bool j = true;
+struct o {
+  using l = char;
+  using ac = l *;
+};
+template  class p {
+public:
+  m ad;
+};
+template  struct ae;
+template  class q {
+public:
+  using ac = o::ac;
+  void r() { g(af.h); }
+  struct {
+ac h;
+  } af;
+};
+class s {
+  using ag = i;
+  using ah = q, o, ae>>;
+
+public:
+  s(char *);
+  char *t() { ai.ad.r(); }
+  p ai;
+};
+using aj = s;
+class ak : n {
+public:
+  using al = n;
+  ak(aj k) : al(k.t()) {}
+};
+class u : ak {
+protected:
+  u() : ak(0) {}
+};
+class am : u {};
+class v {
+public:
+  class w : am {
+  public:
+w(aj) {}
+  };
+};
+class x : v {
+protected:
+  void y() { throw w(&b); }
+};
+class z : x {
+public:
+  z() { y(); }
+};
+#pragma STDC FENV_ACCESS ON
+void a() { z(); }
+
+// CHECK: define dso_local void @_Z1av()
Index: clang/lib/CodeGen/CodeGenFunction.cpp
===
--- clang/lib/CodeGen/CodeGenFunction.cpp
+++ clang/lib/CodeGen/CodeGenFunction.cpp
@@ -161,6 +161,7 @@
   assert((CGF.CurFuncDecl == nullptr || CGF.Builder.getIsFPConstrained() ||
   isa(CGF.CurFuncDecl) ||
   isa(CGF.CurFuncDecl) ||
+  isa(CGF.CurFuncDecl) ||
   (NewExceptionBehavior == llvm::fp::ebIgnore &&
NewRoundingBehavior == llvm::RoundingMode::NearestTiesToEven)) &&
  "FPConstrained should be enabled on entire function");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D152818: [Clang] Fix assertion when pragma FENV_ACCESS is used with a throw function.

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

Has the test case been obfuscated on purpose?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152818

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


[PATCH] D152818: [Clang] Fix assertion when pragma FENV_ACCESS is used with a throw function.

2023-06-13 Thread Zahira Ammarguellat via Phabricator via cfe-commits
zahiraam added a comment.

In D152818#4417644 , @tbaeder wrote:

> Has the test case been obfuscated on purpose?

This is a smaller reproducible from creduce. Didn't know if it would be OK to 
have an include in a LIT test?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152818

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


[PATCH] D152818: [Clang] Fix assertion when pragma FENV_ACCESS is used with a throw function.

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

In D152818#4417649 , @zahiraam wrote:

> In D152818#4417644 , @tbaeder wrote:
>
>> Has the test case been obfuscated on purpose?
>
> This is a smaller reproducible from creduce. Didn't know if it would be OK to 
> have an include in a LIT test?

Okay, not sure if we have a policy regarding that. Just looking at it, I don't 
think anyone understands what it's doing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152818

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


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

2023-06-13 Thread Takuya Shimizu via Phabricator via cfe-commits
hazohelet updated this revision to Diff 530912.
hazohelet added a comment.

Address review comments

- Move the test header to `Inputs` folder
- Remove explicit constructor call of `SourceRange`


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

https://reviews.llvm.org/D152707

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

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

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

2023-06-13 Thread Takuya Shimizu via Phabricator via cfe-commits
hazohelet marked 3 inline comments as done.
hazohelet added a comment.

Thanks for the review.
I'll check the pre-commit CI result before landing this just in case.


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

https://reviews.llvm.org/D152707

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


[PATCH] D152818: [Clang] Fix assertion when pragma FENV_ACCESS is used with a throw function.

2023-06-13 Thread Zahira Ammarguellat via Phabricator via cfe-commits
zahiraam added a comment.

In D152818#4417683 , @tbaeder wrote:

> In D152818#4417649 , @zahiraam 
> wrote:
>
>> In D152818#4417644 , @tbaeder 
>> wrote:
>>
>>> Has the test case been obfuscated on purpose?
>>
>> This is a smaller reproducible from creduce. Didn't know if it would be OK 
>> to have an include in a LIT test?
>
> Okay, not sure if we have a policy regarding that. Just looking at it, I 
> don't think anyone understands what it's doing.

It's definitely related to the use of the pragma and the throw function. I 
could put the "fstream" header in an Inputs folder? I see an #include  
in Analysis/z3/Inputs/MockZ3_solver_check.c.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152818

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


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

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



Comment at: clang/lib/CodeGen/CGCall.cpp:2052-2106
+void clang::CodeGen::mergeDefaultFunctionDefinitionAttributes(
+llvm::Function &F, const CodeGenOptions CodeGenOpts,
+const LangOptions &LangOpts, const TargetOptions &TargetOpts,
+bool WillInternalize) {
+
+  llvm::AttrBuilder FuncAttrs(F.getContext());
+  if (!TargetOpts.CPU.empty())

can we reorder these functions to minimize the diffs? Also some comments about 
the difference among these functions may help.



Comment at: clang/lib/CodeGen/CodeGenAction.cpp:266
 // Links each entry in LinkModules into our module.  Returns true on error.
-bool LinkInModules() {
+bool LinkInModules(llvm::Module *M = nullptr) {
   for (auto &LM : LinkModules) {

Removing the default argument may make the code clearer


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152391

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


[PATCH] D149000: Update with warning message for comparison to NULL pointer

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



Comment at: clang/lib/Sema/SemaChecking.cpp:14726
 
-  if (UnaryOperator *UO = dyn_cast(E)) {
+  if (UnaryOperator *UO = dyn_cast(E->IgnoreParenCasts())) {
 if (UO->getOpcode() != UO_AddrOf)

aaron.ballman wrote:
> 
The issue with the failing precommit CI test is because you're ignoring parens 
and casts with your changes, and to resolve the problem from the issue you 
should be ignoring parens alone.

Try replacing `IgnoreParenCasts()` with `IgnoreParens()` and things should work 
better.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149000

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


  1   2   3   >