[clang] b178cec - [clang][NFC] Annotate most of `clang/Basic` headers with `preferred_type`

2023-11-06 Thread Vlad Serebrennikov via cfe-commits

Author: Vlad Serebrennikov
Date: 2023-11-06T14:18:26+03:00
New Revision: b178cec84f95210db615cfa0a84e78585445f16b

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

LOG: [clang][NFC] Annotate most of `clang/Basic` headers with `preferred_type`

This patch doesn't touch `CodeGenOptions.h`, `DiagnosticOptions.h`, 
`LangOptions.h`, `IdentifierTable.h`.

Added: 


Modified: 
clang/include/clang/Basic/AttributeCommonInfo.h
clang/include/clang/Basic/Diagnostic.h
clang/include/clang/Basic/DiagnosticIDs.h
clang/include/clang/Basic/Module.h
clang/include/clang/Basic/ParsedAttrInfo.h
clang/include/clang/Basic/SourceManager.h
clang/include/clang/Basic/Specifiers.h
clang/include/clang/Basic/TargetInfo.h

Removed: 




diff  --git a/clang/include/clang/Basic/AttributeCommonInfo.h 
b/clang/include/clang/Basic/AttributeCommonInfo.h
index 7dc05418498d0ae..908e0c71544279c 100644
--- a/clang/include/clang/Basic/AttributeCommonInfo.h
+++ b/clang/include/clang/Basic/AttributeCommonInfo.h
@@ -74,11 +74,16 @@ class AttributeCommonInfo {
   SourceRange AttrRange;
   const SourceLocation ScopeLoc;
   // Corresponds to the Kind enum.
+  LLVM_PREFERRED_TYPE(Kind)
   unsigned AttrKind : 16;
   /// Corresponds to the Syntax enum.
+  LLVM_PREFERRED_TYPE(Syntax)
   unsigned SyntaxUsed : 4;
+  LLVM_PREFERRED_TYPE(bool)
   unsigned SpellingIndex : 4;
+  LLVM_PREFERRED_TYPE(bool)
   unsigned IsAlignas : 1;
+  LLVM_PREFERRED_TYPE(bool)
   unsigned IsRegularKeywordAttribute : 1;
 
 protected:
@@ -123,9 +128,12 @@ class AttributeCommonInfo {
 : SyntaxUsed(SyntaxUsed), SpellingIndex(SpellingNotCalculated),
   IsAlignas(0), IsRegularKeywordAttribute(0) {}
 
+LLVM_PREFERRED_TYPE(Syntax)
 unsigned SyntaxUsed : 4;
 unsigned SpellingIndex : 4;
+LLVM_PREFERRED_TYPE(bool)
 unsigned IsAlignas : 1;
+LLVM_PREFERRED_TYPE(bool)
 unsigned IsRegularKeywordAttribute : 1;
   };
 

diff  --git a/clang/include/clang/Basic/Diagnostic.h 
b/clang/include/clang/Basic/Diagnostic.h
index 3df037b793b3946..0c7836c2ea569cc 100644
--- a/clang/include/clang/Basic/Diagnostic.h
+++ b/clang/include/clang/Basic/Diagnostic.h
@@ -314,18 +314,23 @@ class DiagnosticsEngine : public 
RefCountedBase {
 // "Global" configuration state that can actually vary between modules.
 
 // Ignore all warnings: -w
+LLVM_PREFERRED_TYPE(bool)
 unsigned IgnoreAllWarnings : 1;
 
 // Enable all warnings.
+LLVM_PREFERRED_TYPE(bool)
 unsigned EnableAllWarnings : 1;
 
 // Treat warnings like errors.
+LLVM_PREFERRED_TYPE(bool)
 unsigned WarningsAsErrors : 1;
 
 // Treat errors like fatal errors.
+LLVM_PREFERRED_TYPE(bool)
 unsigned ErrorsAsFatal : 1;
 
 // Suppress warnings in system headers.
+LLVM_PREFERRED_TYPE(bool)
 unsigned SuppressSystemWarnings : 1;
 
 // Map extensions to warnings or errors?
@@ -1822,12 +1827,17 @@ class ForwardingDiagnosticConsumer : public 
DiagnosticConsumer {
 struct TemplateDiffTypes {
   intptr_t FromType;
   intptr_t ToType;
+  LLVM_PREFERRED_TYPE(bool)
   unsigned PrintTree : 1;
+  LLVM_PREFERRED_TYPE(bool)
   unsigned PrintFromType : 1;
+  LLVM_PREFERRED_TYPE(bool)
   unsigned ElideType : 1;
+  LLVM_PREFERRED_TYPE(bool)
   unsigned ShowColors : 1;
 
   // The printer sets this variable to true if the template 
diff  was used.
+  LLVM_PREFERRED_TYPE(bool)
   unsigned TemplateDiffUsed : 1;
 };
 

diff  --git a/clang/include/clang/Basic/DiagnosticIDs.h 
b/clang/include/clang/Basic/DiagnosticIDs.h
index 06ef1c6904c31d1..0cdda42793f6f0a 100644
--- a/clang/include/clang/Basic/DiagnosticIDs.h
+++ b/clang/include/clang/Basic/DiagnosticIDs.h
@@ -100,11 +100,17 @@ namespace clang {
   }
 
 class DiagnosticMapping {
+  LLVM_PREFERRED_TYPE(diag::Severity)
   unsigned Severity : 3;
+  LLVM_PREFERRED_TYPE(bool)
   unsigned IsUser : 1;
+  LLVM_PREFERRED_TYPE(bool)
   unsigned IsPragma : 1;
+  LLVM_PREFERRED_TYPE(bool)
   unsigned HasNoWarningAsError : 1;
+  LLVM_PREFERRED_TYPE(bool)
   unsigned HasNoErrorAsFatal : 1;
+  LLVM_PREFERRED_TYPE(bool)
   unsigned WasUpgradedFromWarning : 1;
 
 public:

diff  --git a/clang/include/clang/Basic/Module.h 
b/clang/include/clang/Basic/Module.h
index 6a7423938bdb8fa..239eb5a637f3ecf 100644
--- a/clang/include/clang/Basic/Module.h
+++ b/clang/include/clang/Basic/Module.h
@@ -298,50 +298,62 @@ class alignas(8) Module {
   /// Whether this module has declared itself unimportable, either because
   /// it's missing a requirement from \p Requirements or because it's been
   /// shadowed by another module.
+  LLVM_PREFERRED_TYPE(bool)
   unsigned IsUnimportable : 1;
 
   /// Whether we tried and failed to load a module file for this module.
+  LLVM_PREFERRED_TYPE(bool)
   unsigned HasIn

[clang] [clang-tools-extra] [clang][NFC] Refactor `CXXNewExpr::InitializationStyle` (PR #71322)

2023-11-06 Thread Vlad Serebrennikov via cfe-commits

https://github.com/Endilll updated 
https://github.com/llvm/llvm-project/pull/71322

>From 40d25b8009f1c8734a99fd1350adaced6884cc7f Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov 
Date: Sun, 5 Nov 2023 18:53:48 +0300
Subject: [PATCH 1/5] [clang][NFC] Refacator `CXXNewExpr::InitializationStyle`

This patch converts `CXXNewExpr::InitializationStyle` into a scoped enum at 
namespace scope. It also affirms the status quo by adding a new enumerator to 
represent implicit initializer.
---
 .../modernize/MakeSmartPtrCheck.cpp   |  7 +--
 clang/include/clang/AST/ExprCXX.h | 48 +++
 clang/lib/AST/ExprCXX.cpp | 12 ++---
 clang/lib/AST/ItaniumMangle.cpp   |  4 +-
 clang/lib/AST/JSONNodeDumper.cpp  |  7 +--
 clang/lib/AST/StmtPrinter.cpp |  6 +--
 clang/lib/AST/StmtProfile.cpp |  2 +-
 clang/lib/Sema/SemaExprCXX.cpp| 22 -
 8 files changed, 58 insertions(+), 50 deletions(-)

diff --git a/clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp 
b/clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp
index 71fd8eca300c1b2..616e57efa76ded5 100644
--- a/clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp
@@ -323,7 +323,8 @@ bool MakeSmartPtrCheck::replaceNew(DiagnosticBuilder &Diag,
 return false;
   };
   switch (New->getInitializationStyle()) {
-  case CXXNewExpr::NoInit: {
+  case CXXNewInitializationStyle::None:
+  case CXXNewInitializationStyle::Implicit: {
 if (ArraySizeExpr.empty()) {
   Diag << FixItHint::CreateRemoval(SourceRange(NewStart, NewEnd));
 } else {
@@ -334,7 +335,7 @@ bool MakeSmartPtrCheck::replaceNew(DiagnosticBuilder &Diag,
 }
 break;
   }
-  case CXXNewExpr::CallInit: {
+  case CXXNewInitializationStyle::Call: {
 // FIXME: Add fixes for constructors with parameters that can be created
 // with a C++11 braced-init-list (e.g. std::vector, std::map).
 // Unlike ordinal cases, braced list can not be deduced in
@@ -371,7 +372,7 @@ bool MakeSmartPtrCheck::replaceNew(DiagnosticBuilder &Diag,
 }
 break;
   }
-  case CXXNewExpr::ListInit: {
+  case CXXNewInitializationStyle::List: {
 // Range of the substring that we do not want to remove.
 SourceRange InitRange;
 if (const auto *NewConstruct = New->getConstructExpr()) {
diff --git a/clang/include/clang/AST/ExprCXX.h 
b/clang/include/clang/AST/ExprCXX.h
index a106bafcfa3e021..d713bcf8eb70258 100644
--- a/clang/include/clang/AST/ExprCXX.h
+++ b/clang/include/clang/AST/ExprCXX.h
@@ -2206,6 +2206,20 @@ class CXXScalarValueInitExpr : public Expr {
   }
 };
 
+enum class CXXNewInitializationStyle {
+  /// New-expression has no initializer as written.
+  None,
+
+  /// New-expression has no written initializer, but has an implicit one.
+  Implicit,
+
+  /// New-expression has a C++98 paren-delimited initializer.
+  Call,
+
+  /// New-expression has a C++11 list-initializer.
+  List
+};
+
 /// Represents a new-expression for memory allocation and constructor
 /// calls, e.g: "new CXXNewExpr(foo)".
 class CXXNewExpr final
@@ -2259,25 +2273,12 @@ class CXXNewExpr final
 return isParenTypeId();
   }
 
-public:
-  enum InitializationStyle {
-/// New-expression has no initializer as written.
-NoInit,
-
-/// New-expression has a C++98 paren-delimited initializer.
-CallInit,
-
-/// New-expression has a C++11 list-initializer.
-ListInit
-  };
-
-private:
   /// Build a c++ new expression.
   CXXNewExpr(bool IsGlobalNew, FunctionDecl *OperatorNew,
  FunctionDecl *OperatorDelete, bool ShouldPassAlignment,
  bool UsualArrayDeleteWantsSize, ArrayRef PlacementArgs,
  SourceRange TypeIdParens, std::optional ArraySize,
- InitializationStyle InitializationStyle, Expr *Initializer,
+ CXXNewInitializationStyle InitializationStyle, Expr *Initializer,
  QualType Ty, TypeSourceInfo *AllocatedTypeInfo, SourceRange Range,
  SourceRange DirectInitRange);
 
@@ -2292,7 +2293,7 @@ class CXXNewExpr final
  FunctionDecl *OperatorDelete, bool ShouldPassAlignment,
  bool UsualArrayDeleteWantsSize, ArrayRef PlacementArgs,
  SourceRange TypeIdParens, std::optional ArraySize,
- InitializationStyle InitializationStyle, Expr *Initializer,
+ CXXNewInitializationStyle InitializationStyle, Expr *Initializer,
  QualType Ty, TypeSourceInfo *AllocatedTypeInfo, SourceRange Range,
  SourceRange DirectInitRange);
 
@@ -2388,15 +2389,20 @@ class CXXNewExpr final
 
   /// Whether this new-expression has any initializer at all.
   bool hasInitializer() const {
-return CXXNewExprBits.StoredInitializationStyle > 0;
+switch(getInitializationStyle()) {
+case CXXNewInitializationStyle::None:
+  return true;
+case CXXNewInitializationStyle::Implicit:
+   

[clang] [clang-tools-extra] [clang][NFC] Refactor `CXXNewExpr::InitializationStyle` (PR #71322)

2023-11-06 Thread Vlad Serebrennikov via cfe-commits


@@ -2008,22 +2008,23 @@ ExprResult Sema::BuildCXXNew(SourceRange Range, bool 
UseGlobal,
   SourceRange TypeRange = AllocTypeInfo->getTypeLoc().getSourceRange();
   SourceLocation StartLoc = Range.getBegin();
 
-  CXXNewExpr::InitializationStyle initStyle;
+  CXXNewInitializationStyle initStyle;

Endilll wrote:

Done!

https://github.com/llvm/llvm-project/pull/71322
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] [clang][NFC] Refactor `CXXNewExpr::InitializationStyle` (PR #71322)

2023-11-06 Thread Vlad Serebrennikov via cfe-commits


@@ -2034,18 +2035,19 @@ ExprResult Sema::BuildCXXNew(SourceRange Range, bool 
UseGlobal,
   // - If the new-initializer is omitted, the object is default-
   //   initialized (8.5); if no initialization is performed,
   //   the object has indeterminate value
-  = initStyle == CXXNewExpr::NoInit
+  = initStyle == CXXNewInitializationStyle::None ||
+initStyle == CXXNewInitializationStyle::Implicit
 ? InitializationKind::CreateDefault(TypeRange.getBegin())
-// - Otherwise, the new-initializer is interpreted according to
-// the
-//   initialization rules of 8.5 for direct-initialization.
-: initStyle == CXXNewExpr::ListInit
-  ? InitializationKind::CreateDirectList(
-TypeRange.getBegin(), Initializer->getBeginLoc(),
-Initializer->getEndLoc())
-  : InitializationKind::CreateDirect(TypeRange.getBegin(),
- 
DirectInitRange.getBegin(),
- DirectInitRange.getEnd());
+// - Otherwise, the new-initializer is interpreted according to
+// the
+//   initialization rules of 8.5 for direct-initialization.
+: initStyle == CXXNewInitializationStyle::List
+? InitializationKind::CreateDirectList(TypeRange.getBegin(),
+   Initializer->getBeginLoc(),
+   Initializer->getEndLoc())
+: InitializationKind::CreateDirect(TypeRange.getBegin(),
+   DirectInitRange.getBegin(),
+   DirectInitRange.getEnd());

Endilll wrote:

Because `InitializationKind` doesn't have default constructor, I had to resort 
to immediately invoked lambda expression (IILE). I think it is an improvement, 
but I haven't seen IILE in Clang code base before, so I'm not sure.

https://github.com/llvm/llvm-project/pull/71322
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang] [clang][NFC] Refactor `CXXNewExpr::InitializationStyle` (PR #71322)

2023-11-06 Thread Vlad Serebrennikov via cfe-commits

https://github.com/Endilll ready_for_review 
https://github.com/llvm/llvm-project/pull/71322
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang] [clang][NFC] Refactor `CXXNewExpr::InitializationStyle` (PR #71322)

2023-11-06 Thread Vlad Serebrennikov via cfe-commits

https://github.com/Endilll closed 
https://github.com/llvm/llvm-project/pull/71322
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang] Revert "[clang][NFC] Refactor `CXXNewExpr::InitializationStyle`" (PR #71395)

2023-11-06 Thread Vlad Serebrennikov via cfe-commits

https://github.com/Endilll created 
https://github.com/llvm/llvm-project/pull/71395

Reverts llvm/llvm-project#71322

>From 40921a217a4bda5ce739561606a4e16677ee48f5 Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov 
Date: Mon, 6 Nov 2023 17:53:21 +0400
Subject: [PATCH] Revert "[clang][NFC] Refactor
 `CXXNewExpr::InitializationStyle` (#71322)"

This reverts commit ace4489397d17abfb20d36de1404cfbe102401a7.
---
 .../modernize/MakeSmartPtrCheck.cpp   |  7 +--
 clang/include/clang/AST/ExprCXX.h | 48 +++
 clang/lib/AST/ExprCXX.cpp | 29 +
 clang/lib/AST/ItaniumMangle.cpp   |  5 +-
 clang/lib/AST/JSONNodeDumper.cpp  | 12 +---
 clang/lib/AST/StmtPrinter.cpp |  7 +--
 clang/lib/AST/StmtProfile.cpp |  2 +-
 clang/lib/Sema/SemaExprCXX.cpp| 60 +--
 8 files changed, 74 insertions(+), 96 deletions(-)

diff --git a/clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp 
b/clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp
index 616e57efa76ded5..71fd8eca300c1b2 100644
--- a/clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp
@@ -323,8 +323,7 @@ bool MakeSmartPtrCheck::replaceNew(DiagnosticBuilder &Diag,
 return false;
   };
   switch (New->getInitializationStyle()) {
-  case CXXNewInitializationStyle::None:
-  case CXXNewInitializationStyle::Implicit: {
+  case CXXNewExpr::NoInit: {
 if (ArraySizeExpr.empty()) {
   Diag << FixItHint::CreateRemoval(SourceRange(NewStart, NewEnd));
 } else {
@@ -335,7 +334,7 @@ bool MakeSmartPtrCheck::replaceNew(DiagnosticBuilder &Diag,
 }
 break;
   }
-  case CXXNewInitializationStyle::Call: {
+  case CXXNewExpr::CallInit: {
 // FIXME: Add fixes for constructors with parameters that can be created
 // with a C++11 braced-init-list (e.g. std::vector, std::map).
 // Unlike ordinal cases, braced list can not be deduced in
@@ -372,7 +371,7 @@ bool MakeSmartPtrCheck::replaceNew(DiagnosticBuilder &Diag,
 }
 break;
   }
-  case CXXNewInitializationStyle::List: {
+  case CXXNewExpr::ListInit: {
 // Range of the substring that we do not want to remove.
 SourceRange InitRange;
 if (const auto *NewConstruct = New->getConstructExpr()) {
diff --git a/clang/include/clang/AST/ExprCXX.h 
b/clang/include/clang/AST/ExprCXX.h
index 37d310ef967d9c0..a106bafcfa3e021 100644
--- a/clang/include/clang/AST/ExprCXX.h
+++ b/clang/include/clang/AST/ExprCXX.h
@@ -2206,20 +2206,6 @@ class CXXScalarValueInitExpr : public Expr {
   }
 };
 
-enum class CXXNewInitializationStyle {
-  /// New-expression has no initializer as written.
-  None,
-
-  /// New-expression has no written initializer, but has an implicit one.
-  Implicit,
-
-  /// New-expression has a C++98 paren-delimited initializer.
-  Call,
-
-  /// New-expression has a C++11 list-initializer.
-  List
-};
-
 /// Represents a new-expression for memory allocation and constructor
 /// calls, e.g: "new CXXNewExpr(foo)".
 class CXXNewExpr final
@@ -2273,12 +2259,25 @@ class CXXNewExpr final
 return isParenTypeId();
   }
 
+public:
+  enum InitializationStyle {
+/// New-expression has no initializer as written.
+NoInit,
+
+/// New-expression has a C++98 paren-delimited initializer.
+CallInit,
+
+/// New-expression has a C++11 list-initializer.
+ListInit
+  };
+
+private:
   /// Build a c++ new expression.
   CXXNewExpr(bool IsGlobalNew, FunctionDecl *OperatorNew,
  FunctionDecl *OperatorDelete, bool ShouldPassAlignment,
  bool UsualArrayDeleteWantsSize, ArrayRef PlacementArgs,
  SourceRange TypeIdParens, std::optional ArraySize,
- CXXNewInitializationStyle InitializationStyle, Expr *Initializer,
+ InitializationStyle InitializationStyle, Expr *Initializer,
  QualType Ty, TypeSourceInfo *AllocatedTypeInfo, SourceRange Range,
  SourceRange DirectInitRange);
 
@@ -2293,7 +2292,7 @@ class CXXNewExpr final
  FunctionDecl *OperatorDelete, bool ShouldPassAlignment,
  bool UsualArrayDeleteWantsSize, ArrayRef PlacementArgs,
  SourceRange TypeIdParens, std::optional ArraySize,
- CXXNewInitializationStyle InitializationStyle, Expr *Initializer,
+ InitializationStyle InitializationStyle, Expr *Initializer,
  QualType Ty, TypeSourceInfo *AllocatedTypeInfo, SourceRange Range,
  SourceRange DirectInitRange);
 
@@ -2389,20 +2388,15 @@ class CXXNewExpr final
 
   /// Whether this new-expression has any initializer at all.
   bool hasInitializer() const {
-switch (getInitializationStyle()) {
-case CXXNewInitializationStyle::None:
-  return false;
-case CXXNewInitializationStyle::Implicit:
-case CXXNewInitializationStyle::Call:
-case CXXNewInitializationStyle::List:
-  return true;
-}
+return CXX

[clang] [clang-tools-extra] Revert "[clang][NFC] Refactor `CXXNewExpr::InitializationStyle`" (PR #71395)

2023-11-06 Thread Vlad Serebrennikov via cfe-commits

https://github.com/Endilll closed 
https://github.com/llvm/llvm-project/pull/71395
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang] [clang][NFC] Refactor `CXXNewExpr::InitializationStyle` (PR #71322)

2023-11-06 Thread Vlad Serebrennikov via cfe-commits

Endilll wrote:

I've seen those exact test failures locally, but since precommit CI was fine, I 
landed this PR and kept a close eye on the bots.
Me and Aaron are also wondering now how did it pass CI, and what's wrong with 
changes here.
I'm sorry @zmodem that we got you involved.

> It catches 
> (https://buildkite.com/llvm-project/github-pull-requests/builds/12931#018ba4b7-1e05-425f-a30d-46ac33f582b6),
>  you just didn't wait for a results (or ignored them) and forced a merge.

Me and Aaron seen them, and deemed them unrelated. For a comparison, here is a 
list of tests that fails locally for me (and post-commit bots seem to agree):
```
Failed Tests (49):
  Clang :: Analysis/NewDelete-checker-test.cpp
  Clang :: Analysis/bstring.cpp
  Clang :: Analysis/cfg.cpp
  Clang :: Analysis/ctor-array.cpp
  Clang :: Analysis/cxxctr-array-evalcall-analysis-order.cpp
  Clang :: Analysis/dtor-array.cpp
  Clang :: Analysis/dump_egraph.cpp
  Clang :: Analysis/exploded-graph-rewriter/dynamic_types.cpp
  Clang :: Analysis/flexible-array-member.cpp
  Clang :: Analysis/handle_constructors_with_new_array.cpp
  Clang :: Analysis/more-dtors-cfg-output.cpp
  Clang :: Analysis/new-ctor-conservative.cpp
  Clang :: Analysis/new-ctor-inlined.cpp
  Clang :: Analysis/this-pointer.cpp
  Clang :: CXX/dcl.dcl/dcl.spec/dcl.constexpr/p9.cpp
  Clang :: CXX/drs/dr1748.cpp
  Clang :: CodeGen/available-externally-hidden.cpp
  Clang :: CodeGen/debug-prefix-map.cpp
  Clang :: CodeGen/split-lto-unit-input.cpp
  Clang :: CodeGen/tbaa-for-vptr.cpp
  Clang :: CodeGenCUDA/member-init.cu
  Clang :: CodeGenCXX/attr-disable-tail-calls.cpp
  Clang :: CodeGenCXX/catch-undef-behavior.cpp
  Clang :: CodeGenCXX/cfi-ms-vbase-derived-cast.cpp
  Clang :: CodeGenCXX/code-seg.cpp
  Clang :: CodeGenCXX/ctor-dtor-alias.cpp
  Clang :: CodeGenCXX/cxx1z-aligned-allocation.cpp
  Clang :: CodeGenCXX/cxx2a-destroying-delete.cpp
  Clang :: CodeGenCXX/default-arguments.cpp
  Clang :: CodeGenCXX/destructors.cpp
  Clang :: CodeGenCXX/exceptions.cpp
  Clang :: CodeGenCXX/invariant.group-for-vptrs.cpp
  Clang :: CodeGenCXX/key-function-vtable.cpp
  Clang :: CodeGenCXX/microsoft-abi-structors-delayed-template.cpp
  Clang :: CodeGenCXX/new-overflow.cpp
  Clang :: CodeGenCXX/new.cpp
  Clang :: CodeGenCXX/static-init.cpp
  Clang :: CodeGenCXX/strict-vtable-pointers.cpp
  Clang :: CodeGenCXX/type-metadata-thinlto.cpp
  Clang :: CodeGenCXX/ubsan-new-checks.cpp
  Clang :: CodeGenCXX/ubsan-suppress-checks.cpp
  Clang :: CodeGenCXX/vtable-assume-load-address-space.cpp
  Clang :: CodeGenCXX/vtable-assume-load.cpp
  Clang :: CodeGenCXX/vtable-available-externally.cpp
  Clang :: CodeGenObjCXX/arc-new-delete.mm
  Clang :: CodeGenObjCXX/destroy.mm
  Clang :: LibClang/symbols.test
  Clang :: SemaCXX/constant-expression-cxx2a.cpp
  Clang :: SemaCXX/constexpr-turing-cxx2a.cpp
```

https://github.com/llvm/llvm-project/pull/71322
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] [clang][NFC] Refactor `CXXNewExpr::InitializationStyle` (re-land) (PR #71417)

2023-11-06 Thread Vlad Serebrennikov via cfe-commits

https://github.com/Endilll created 
https://github.com/llvm/llvm-project/pull/71417

This patch converts CXXNewExpr::InitializationStyle into a scoped enum at 
namespace scope. It also affirms the status quo by adding a new enumerator to 
represent implicit initializer.

This is a re-land of https://github.com/llvm/llvm-project/pull/71322

>From 40d25b8009f1c8734a99fd1350adaced6884cc7f Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov 
Date: Sun, 5 Nov 2023 18:53:48 +0300
Subject: [PATCH 1/6] [clang][NFC] Refacator `CXXNewExpr::InitializationStyle`

This patch converts `CXXNewExpr::InitializationStyle` into a scoped enum at 
namespace scope. It also affirms the status quo by adding a new enumerator to 
represent implicit initializer.
---
 .../modernize/MakeSmartPtrCheck.cpp   |  7 +--
 clang/include/clang/AST/ExprCXX.h | 48 +++
 clang/lib/AST/ExprCXX.cpp | 12 ++---
 clang/lib/AST/ItaniumMangle.cpp   |  4 +-
 clang/lib/AST/JSONNodeDumper.cpp  |  7 +--
 clang/lib/AST/StmtPrinter.cpp |  6 +--
 clang/lib/AST/StmtProfile.cpp |  2 +-
 clang/lib/Sema/SemaExprCXX.cpp| 22 -
 8 files changed, 58 insertions(+), 50 deletions(-)

diff --git a/clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp 
b/clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp
index 71fd8eca300c1b2..616e57efa76ded5 100644
--- a/clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp
@@ -323,7 +323,8 @@ bool MakeSmartPtrCheck::replaceNew(DiagnosticBuilder &Diag,
 return false;
   };
   switch (New->getInitializationStyle()) {
-  case CXXNewExpr::NoInit: {
+  case CXXNewInitializationStyle::None:
+  case CXXNewInitializationStyle::Implicit: {
 if (ArraySizeExpr.empty()) {
   Diag << FixItHint::CreateRemoval(SourceRange(NewStart, NewEnd));
 } else {
@@ -334,7 +335,7 @@ bool MakeSmartPtrCheck::replaceNew(DiagnosticBuilder &Diag,
 }
 break;
   }
-  case CXXNewExpr::CallInit: {
+  case CXXNewInitializationStyle::Call: {
 // FIXME: Add fixes for constructors with parameters that can be created
 // with a C++11 braced-init-list (e.g. std::vector, std::map).
 // Unlike ordinal cases, braced list can not be deduced in
@@ -371,7 +372,7 @@ bool MakeSmartPtrCheck::replaceNew(DiagnosticBuilder &Diag,
 }
 break;
   }
-  case CXXNewExpr::ListInit: {
+  case CXXNewInitializationStyle::List: {
 // Range of the substring that we do not want to remove.
 SourceRange InitRange;
 if (const auto *NewConstruct = New->getConstructExpr()) {
diff --git a/clang/include/clang/AST/ExprCXX.h 
b/clang/include/clang/AST/ExprCXX.h
index a106bafcfa3e021..d713bcf8eb70258 100644
--- a/clang/include/clang/AST/ExprCXX.h
+++ b/clang/include/clang/AST/ExprCXX.h
@@ -2206,6 +2206,20 @@ class CXXScalarValueInitExpr : public Expr {
   }
 };
 
+enum class CXXNewInitializationStyle {
+  /// New-expression has no initializer as written.
+  None,
+
+  /// New-expression has no written initializer, but has an implicit one.
+  Implicit,
+
+  /// New-expression has a C++98 paren-delimited initializer.
+  Call,
+
+  /// New-expression has a C++11 list-initializer.
+  List
+};
+
 /// Represents a new-expression for memory allocation and constructor
 /// calls, e.g: "new CXXNewExpr(foo)".
 class CXXNewExpr final
@@ -2259,25 +2273,12 @@ class CXXNewExpr final
 return isParenTypeId();
   }
 
-public:
-  enum InitializationStyle {
-/// New-expression has no initializer as written.
-NoInit,
-
-/// New-expression has a C++98 paren-delimited initializer.
-CallInit,
-
-/// New-expression has a C++11 list-initializer.
-ListInit
-  };
-
-private:
   /// Build a c++ new expression.
   CXXNewExpr(bool IsGlobalNew, FunctionDecl *OperatorNew,
  FunctionDecl *OperatorDelete, bool ShouldPassAlignment,
  bool UsualArrayDeleteWantsSize, ArrayRef PlacementArgs,
  SourceRange TypeIdParens, std::optional ArraySize,
- InitializationStyle InitializationStyle, Expr *Initializer,
+ CXXNewInitializationStyle InitializationStyle, Expr *Initializer,
  QualType Ty, TypeSourceInfo *AllocatedTypeInfo, SourceRange Range,
  SourceRange DirectInitRange);
 
@@ -2292,7 +2293,7 @@ class CXXNewExpr final
  FunctionDecl *OperatorDelete, bool ShouldPassAlignment,
  bool UsualArrayDeleteWantsSize, ArrayRef PlacementArgs,
  SourceRange TypeIdParens, std::optional ArraySize,
- InitializationStyle InitializationStyle, Expr *Initializer,
+ CXXNewInitializationStyle InitializationStyle, Expr *Initializer,
  QualType Ty, TypeSourceInfo *AllocatedTypeInfo, SourceRange Range,
  SourceRange DirectInitRange);
 
@@ -2388,15 +2389,20 @@ class CXXNewExpr final
 
   /// Whether this new-expression has any initiali

[clang-tools-extra] [clang] [clang][NFC] Refactor `CXXNewExpr::InitializationStyle` (re-land) (PR #71417)

2023-11-06 Thread Vlad Serebrennikov via cfe-commits

https://github.com/Endilll closed 
https://github.com/llvm/llvm-project/pull/71417
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 7ec8a6f - [clang][NFC] Annotate `Stmt.h` with `preferred_type`

2023-11-06 Thread Vlad Serebrennikov via cfe-commits

Author: Vlad Serebrennikov
Date: 2023-11-06T21:02:14+03:00
New Revision: 7ec8a6fd31d8ddb161b06067fb6b7f9026a460df

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

LOG: [clang][NFC] Annotate `Stmt.h` with `preferred_type`

This helps debuggers to display values in bit-fields in a more helpful way.

Added: 


Modified: 
clang/include/clang/AST/Stmt.h

Removed: 




diff  --git a/clang/include/clang/AST/Stmt.h b/clang/include/clang/AST/Stmt.h
index 9fb49e99da1073f..da7b37ce0e1211f 100644
--- a/clang/include/clang/AST/Stmt.h
+++ b/clang/include/clang/AST/Stmt.h
@@ -13,15 +13,20 @@
 #ifndef LLVM_CLANG_AST_STMT_H
 #define LLVM_CLANG_AST_STMT_H
 
+#include "clang/AST/APValue.h"
 #include "clang/AST/DeclGroup.h"
 #include "clang/AST/DependenceFlags.h"
+#include "clang/AST/OperationKinds.h"
 #include "clang/AST/StmtIterator.h"
 #include "clang/Basic/CapturedStmt.h"
 #include "clang/Basic/IdentifierTable.h"
 #include "clang/Basic/LLVM.h"
+#include "clang/Basic/Lambda.h"
 #include "clang/Basic/LangOptions.h"
+#include "clang/Basic/OperatorKinds.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/Specifiers.h"
+#include "clang/Basic/TypeTraits.h"
 #include "llvm/ADT/APFloat.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/BitmaskEnum.h"
@@ -62,6 +67,13 @@ class SourceManager;
 class StringLiteral;
 class Token;
 class VarDecl;
+enum class CharacterLiteralKind;
+enum class ConstantResultStorageKind;
+enum class CXXConstructionKind;
+enum class CXXNewInitializationStyle;
+enum class PredefinedIdentKind;
+enum class SourceLocIdentKind;
+enum class StringLiteralKind;
 
 
//===--===//
 // AST classes for statements.
@@ -103,6 +115,7 @@ class alignas(void *) Stmt {
 friend class Stmt;
 
 /// The statement class.
+LLVM_PREFERRED_TYPE(StmtClass)
 unsigned sClass : 8;
   };
   enum { NumStmtBits = 8 };
@@ -112,6 +125,7 @@ class alignas(void *) Stmt {
 friend class ASTStmtWriter;
 friend class NullStmt;
 
+LLVM_PREFERRED_TYPE(StmtBitfields)
 unsigned : NumStmtBits;
 
 /// True if the null statement was preceded by an empty macro, e.g:
@@ -119,6 +133,7 @@ class alignas(void *) Stmt {
 ///   #define CALL(x)
 ///   CALL(0);
 /// @endcode
+LLVM_PREFERRED_TYPE(bool)
 unsigned HasLeadingEmptyMacro : 1;
 
 /// The location of the semi-colon.
@@ -129,10 +144,12 @@ class alignas(void *) Stmt {
 friend class ASTStmtReader;
 friend class CompoundStmt;
 
+LLVM_PREFERRED_TYPE(StmtBitfields)
 unsigned : NumStmtBits;
 
 /// True if the compound statement has one or more pragmas that set some
 /// floating-point features.
+LLVM_PREFERRED_TYPE(bool)
 unsigned HasFPFeatures : 1;
 
 unsigned NumStmts;
@@ -141,6 +158,7 @@ class alignas(void *) Stmt {
   class LabelStmtBitfields {
 friend class LabelStmt;
 
+LLVM_PREFERRED_TYPE(StmtBitfields)
 unsigned : NumStmtBits;
 
 SourceLocation IdentLoc;
@@ -150,6 +168,7 @@ class alignas(void *) Stmt {
 friend class ASTStmtReader;
 friend class AttributedStmt;
 
+LLVM_PREFERRED_TYPE(StmtBitfields)
 unsigned : NumStmtBits;
 
 /// Number of attributes.
@@ -163,18 +182,23 @@ class alignas(void *) Stmt {
 friend class ASTStmtReader;
 friend class IfStmt;
 
+LLVM_PREFERRED_TYPE(StmtBitfields)
 unsigned : NumStmtBits;
 
 /// Whether this is a constexpr if, or a consteval if, or neither.
+LLVM_PREFERRED_TYPE(IfStatementKind)
 unsigned Kind : 3;
 
 /// True if this if statement has storage for an else statement.
+LLVM_PREFERRED_TYPE(bool)
 unsigned HasElse : 1;
 
 /// True if this if statement has storage for a variable declaration.
+LLVM_PREFERRED_TYPE(bool)
 unsigned HasVar : 1;
 
 /// True if this if statement has storage for an init statement.
+LLVM_PREFERRED_TYPE(bool)
 unsigned HasInit : 1;
 
 /// The location of the "if".
@@ -184,17 +208,21 @@ class alignas(void *) Stmt {
   class SwitchStmtBitfields {
 friend class SwitchStmt;
 
+LLVM_PREFERRED_TYPE(StmtBitfields)
 unsigned : NumStmtBits;
 
 /// True if the SwitchStmt has storage for an init statement.
+LLVM_PREFERRED_TYPE(bool)
 unsigned HasInit : 1;
 
 /// True if the SwitchStmt has storage for a condition variable.
+LLVM_PREFERRED_TYPE(bool)
 unsigned HasVar : 1;
 
 /// If the SwitchStmt is a switch on an enum value, records whether all
 /// the enum values were covered by CaseStmts.  The coverage information
 /// value is meant to be a hint for possible clients.
+LLVM_PREFERRED_TYPE(bool)
 unsigned AllEnumCasesCovered : 1;
 
 /// The location of the "switch".
@@ -205,9 +233,11 @@ cl

[clang] 60f7fa1 - [clang][NFC] Refactor `Comment::CommentKind`

2023-11-06 Thread Vlad Serebrennikov via cfe-commits

Author: Vlad Serebrennikov
Date: 2023-11-06T22:17:03+03:00
New Revision: 60f7fa123d77ecf8e138be35ad8880622586fa03

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

LOG: [clang][NFC] Refactor `Comment::CommentKind`

This patch converts `Comment::CommentKind` into a scoped enum at namespace 
scope, making it eligible for forward declaring. This is useful for e.g. 
annotating bit-fields with `preferred_type`.

Added: 


Modified: 
clang/include/clang/AST/Comment.h
clang/include/clang/AST/CommentVisitor.h
clang/lib/AST/Comment.cpp
clang/lib/Index/CommentToXML.cpp
clang/tools/libclang/CXComment.cpp

Removed: 




diff  --git a/clang/include/clang/AST/Comment.h 
b/clang/include/clang/AST/Comment.h
index 0b68c11316649aa..7cbed3600d28287 100644
--- a/clang/include/clang/AST/Comment.h
+++ b/clang/include/clang/AST/Comment.h
@@ -47,6 +47,17 @@ enum CommandMarkerKind {
   CMK_At = 1
 };
 
+enum class CommentKind {
+  None = 0,
+#define COMMENT(CLASS, PARENT) CLASS,
+#define COMMENT_RANGE(BASE, FIRST, LAST)   
\
+  First##BASE##Constant = FIRST, Last##BASE##Constant = LAST,
+#define LAST_COMMENT_RANGE(BASE, FIRST, LAST)  
\
+  First##BASE##Constant = FIRST, Last##BASE##Constant = LAST
+#define ABSTRACT_COMMENT(COMMENT)
+#include "clang/AST/CommentNodes.inc"
+};
+
 /// Any part of the comment.
 /// Abstract class.
 class Comment {
@@ -183,17 +194,6 @@ class Comment {
   }
 
 public:
-  enum CommentKind {
-NoCommentKind = 0,
-#define COMMENT(CLASS, PARENT) CLASS##Kind,
-#define COMMENT_RANGE(BASE, FIRST, LAST) \
-First##BASE##Constant=FIRST##Kind, Last##BASE##Constant=LAST##Kind,
-#define LAST_COMMENT_RANGE(BASE, FIRST, LAST) \
-First##BASE##Constant=FIRST##Kind, Last##BASE##Constant=LAST##Kind
-#define ABSTRACT_COMMENT(COMMENT)
-#include "clang/AST/CommentNodes.inc"
-  };
-
   struct Argument {
 SourceRange Range;
 StringRef Text;
@@ -203,7 +203,7 @@ class Comment {
   SourceLocation LocBegin,
   SourceLocation LocEnd) :
   Loc(LocBegin), Range(SourceRange(LocBegin, LocEnd)) {
-CommentBits.Kind = K;
+CommentBits.Kind = llvm::to_underlying(K);
   }
 
   CommentKind getCommentKind() const {
@@ -249,8 +249,9 @@ class InlineContentComment : public Comment {
 
 public:
   static bool classof(const Comment *C) {
-return C->getCommentKind() >= FirstInlineContentCommentConstant &&
-   C->getCommentKind() <= LastInlineContentCommentConstant;
+return C->getCommentKind() >=
+   CommentKind::FirstInlineContentCommentConstant &&
+   C->getCommentKind() <= 
CommentKind::LastInlineContentCommentConstant;
   }
 
   void addTrailingNewline() {
@@ -267,16 +268,14 @@ class TextComment : public InlineContentComment {
   StringRef Text;
 
 public:
-  TextComment(SourceLocation LocBegin,
-  SourceLocation LocEnd,
-  StringRef Text) :
-  InlineContentComment(TextCommentKind, LocBegin, LocEnd),
-  Text(Text) {
+  TextComment(SourceLocation LocBegin, SourceLocation LocEnd, StringRef Text)
+  : InlineContentComment(CommentKind::TextComment, LocBegin, LocEnd),
+Text(Text) {
 TextCommentBits.IsWhitespaceValid = false;
   }
 
   static bool classof(const Comment *C) {
-return C->getCommentKind() == TextCommentKind;
+return C->getCommentKind() == CommentKind::TextComment;
   }
 
   child_iterator child_begin() const { return nullptr; }
@@ -316,19 +315,18 @@ class InlineCommandComment : public InlineContentComment {
   ArrayRef Args;
 
 public:
-  InlineCommandComment(SourceLocation LocBegin,
-   SourceLocation LocEnd,
-   unsigned CommandID,
-   RenderKind RK,
-   ArrayRef Args) :
-  InlineContentComment(InlineCommandCommentKind, LocBegin, LocEnd),
-  Args(Args) {
+  InlineCommandComment(SourceLocation LocBegin, SourceLocation LocEnd,
+   unsigned CommandID, RenderKind RK,
+   ArrayRef Args)
+  : InlineContentComment(CommentKind::InlineCommandComment, LocBegin,
+ LocEnd),
+Args(Args) {
 InlineCommandCommentBits.RenderKind = RK;
 InlineCommandCommentBits.CommandID = CommandID;
   }
 
   static bool classof(const Comment *C) {
-return C->getCommentKind() == InlineCommandCommentKind;
+return C->getCommentKind() == CommentKind::InlineCommandComment;
   }
 
   child_iterator child_begin() const { return nullptr; }
@@ -386,8 +384,8 @@ class HTMLTagComment : public InlineContentComment {
 
 public:
   static bool classof(const Comment *C) {
-return C->getCommentKind() >= FirstHTMLTagCommentConstant &&
-   C->getCom

[clang] 565e21b - [clang][NFC] Refactor `InlineCommandComment::RenderKind`

2023-11-06 Thread Vlad Serebrennikov via cfe-commits

Author: Vlad Serebrennikov
Date: 2023-11-06T22:39:26+03:00
New Revision: 565e21b3e079e53c4fcf47d2ec898dbc248fbd3a

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

LOG: [clang][NFC] Refactor `InlineCommandComment::RenderKind`

This patch converts `InlineCommandComment::RenderKind` to a scoped enum at 
namespace scope, making it eligible for forward declaring. This is useful for 
e.g. annotating bit-fields with `preferred_type`.

Added: 


Modified: 
clang/include/clang/AST/Comment.h
clang/include/clang/AST/CommentSema.h
clang/lib/AST/CommentSema.cpp
clang/lib/AST/JSONNodeDumper.cpp
clang/lib/AST/TextNodeDumper.cpp
clang/lib/Index/CommentToXML.cpp
clang/tools/libclang/CXComment.cpp

Removed: 




diff  --git a/clang/include/clang/AST/Comment.h 
b/clang/include/clang/AST/Comment.h
index 7cbed3600d28287..06effad42db45e6 100644
--- a/clang/include/clang/AST/Comment.h
+++ b/clang/include/clang/AST/Comment.h
@@ -297,31 +297,24 @@ class TextComment : public InlineContentComment {
   bool isWhitespaceNoCache() const;
 };
 
+/// The most appropriate rendering mode for this command, chosen on command
+/// semantics in Doxygen.
+enum InlineCommandRenderKind { Normal, Bold, Monospaced, Emphasized, Anchor };
+
 /// A command with word-like arguments that is considered inline content.
 class InlineCommandComment : public InlineContentComment {
-public:
-  /// The most appropriate rendering mode for this command, chosen on command
-  /// semantics in Doxygen.
-  enum RenderKind {
-RenderNormal,
-RenderBold,
-RenderMonospaced,
-RenderEmphasized,
-RenderAnchor
-  };
-
 protected:
   /// Command arguments.
   ArrayRef Args;
 
 public:
   InlineCommandComment(SourceLocation LocBegin, SourceLocation LocEnd,
-   unsigned CommandID, RenderKind RK,
+   unsigned CommandID, InlineCommandRenderKind RK,
ArrayRef Args)
   : InlineContentComment(CommentKind::InlineCommandComment, LocBegin,
  LocEnd),
 Args(Args) {
-InlineCommandCommentBits.RenderKind = RK;
+InlineCommandCommentBits.RenderKind = llvm::to_underlying(RK);
 InlineCommandCommentBits.CommandID = CommandID;
   }
 
@@ -345,8 +338,9 @@ class InlineCommandComment : public InlineContentComment {
 return SourceRange(getBeginLoc().getLocWithOffset(-1), getEndLoc());
   }
 
-  RenderKind getRenderKind() const {
-return static_cast(InlineCommandCommentBits.RenderKind);
+  InlineCommandRenderKind getRenderKind() const {
+return static_cast(
+InlineCommandCommentBits.RenderKind);
   }
 
   unsigned getNumArgs() const {

diff  --git a/clang/include/clang/AST/CommentSema.h 
b/clang/include/clang/AST/CommentSema.h
index 5d8df7dbf385a12..03f13283ac0d977 100644
--- a/clang/include/clang/AST/CommentSema.h
+++ b/clang/include/clang/AST/CommentSema.h
@@ -244,8 +244,7 @@ class Sema {
   StringRef Typo,
   const TemplateParameterList *TemplateParameters);
 
-  InlineCommandComment::RenderKind
-  getInlineCommandRenderKind(StringRef Name) const;
+  InlineCommandRenderKind getInlineCommandRenderKind(StringRef Name) const;
 };
 
 } // end namespace comments

diff  --git a/clang/lib/AST/CommentSema.cpp b/clang/lib/AST/CommentSema.cpp
index 0512d6af5ce..6f68577954137f3 100644
--- a/clang/lib/AST/CommentSema.cpp
+++ b/clang/lib/AST/CommentSema.cpp
@@ -380,9 +380,7 @@ InlineContentComment 
*Sema::actOnUnknownCommand(SourceLocation LocBegin,
 unsigned CommandID) {
   ArrayRef Args;
   return new (Allocator) InlineCommandComment(
-  LocBegin, LocEnd, CommandID,
-  InlineCommandComment::RenderNormal,
-  Args);
+  LocBegin, LocEnd, CommandID, InlineCommandRenderKind::Normal, Args);
 }
 
 TextComment *Sema::actOnText(SourceLocation LocBegin,
@@ -1108,16 +1106,15 @@ StringRef Sema::correctTypoInTParamReference(
   return StringRef();
 }
 
-InlineCommandComment::RenderKind
-Sema::getInlineCommandRenderKind(StringRef Name) const {
+InlineCommandRenderKind Sema::getInlineCommandRenderKind(StringRef Name) const 
{
   assert(Traits.getCommandInfo(Name)->IsInlineCommand);
 
-  return llvm::StringSwitch(Name)
-  .Case("b", InlineCommandComment::RenderBold)
-  .Cases("c", "p", InlineCommandComment::RenderMonospaced)
-  .Cases("a", "e", "em", InlineCommandComment::RenderEmphasized)
-  .Case("anchor", InlineCommandComment::RenderAnchor)
-  .Default(InlineCommandComment::RenderNormal);
+  return llvm::StringSwitch(Name)
+  .Case("b", InlineCommandRenderKind::Bold)
+  .Cases("c", "p

[clang] f2d8a0a - [clang][NFC] Refactor `ParamCommandComment::PassDirection`

2023-11-06 Thread Vlad Serebrennikov via cfe-commits

Author: Vlad Serebrennikov
Date: 2023-11-06T22:55:51+03:00
New Revision: f2d8a0ac1dd1fe55b2c3b358c525fbc01b0121ed

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

LOG: [clang][NFC] Refactor `ParamCommandComment::PassDirection`

This patch converts `ParamCommandComment::PassDirection` to a scoped enum at 
namespace scope, making it eligible for forward declaring. This is useful for 
e.g. annotating bit-fields with `preferred_type`.

Added: 


Modified: 
clang/include/clang/AST/Comment.h
clang/lib/AST/Comment.cpp
clang/lib/AST/CommentSema.cpp
clang/lib/AST/JSONNodeDumper.cpp
clang/lib/Index/CommentToXML.cpp
clang/tools/libclang/CXComment.cpp
clang/unittests/AST/CommentParser.cpp

Removed: 




diff  --git a/clang/include/clang/AST/Comment.h 
b/clang/include/clang/AST/Comment.h
index 06effad42db45e6..d501ce1822862d9 100644
--- a/clang/include/clang/AST/Comment.h
+++ b/clang/include/clang/AST/Comment.h
@@ -675,6 +675,8 @@ class BlockCommandComment : public BlockContentComment {
   }
 };
 
+enum class ParamCommandPassDirection { In, Out, InOut };
+
 /// Doxygen \\param command.
 class ParamCommandComment : public BlockCommandComment {
 private:
@@ -692,7 +694,8 @@ class ParamCommandComment : public BlockCommandComment {
   : BlockCommandComment(CommentKind::ParamCommandComment, LocBegin, LocEnd,
 CommandID, CommandMarker),
 ParamIndex(InvalidParamIndex) {
-ParamCommandCommentBits.Direction = In;
+ParamCommandCommentBits.Direction =
+llvm::to_underlying(ParamCommandPassDirection::In);
 ParamCommandCommentBits.IsDirectionExplicit = false;
   }
 
@@ -700,24 +703,19 @@ class ParamCommandComment : public BlockCommandComment {
 return C->getCommentKind() == CommentKind::ParamCommandComment;
   }
 
-  enum PassDirection {
-In,
-Out,
-InOut
-  };
-
-  static const char *getDirectionAsString(PassDirection D);
+  static const char *getDirectionAsString(ParamCommandPassDirection D);
 
-  PassDirection getDirection() const LLVM_READONLY {
-return static_cast(ParamCommandCommentBits.Direction);
+  ParamCommandPassDirection getDirection() const LLVM_READONLY {
+return static_cast(
+ParamCommandCommentBits.Direction);
   }
 
   bool isDirectionExplicit() const LLVM_READONLY {
 return ParamCommandCommentBits.IsDirectionExplicit;
   }
 
-  void setDirection(PassDirection Direction, bool Explicit) {
-ParamCommandCommentBits.Direction = Direction;
+  void setDirection(ParamCommandPassDirection Direction, bool Explicit) {
+ParamCommandCommentBits.Direction = llvm::to_underlying(Direction);
 ParamCommandCommentBits.IsDirectionExplicit = Explicit;
   }
 

diff  --git a/clang/lib/AST/Comment.cpp b/clang/lib/AST/Comment.cpp
index 0a2d310e5b48911..cce8b12170f21fd 100644
--- a/clang/lib/AST/Comment.cpp
+++ b/clang/lib/AST/Comment.cpp
@@ -187,13 +187,14 @@ static bool getFunctionTypeLoc(TypeLoc TL, 
FunctionTypeLoc &ResFTL) {
   return false;
 }
 
-const char *ParamCommandComment::getDirectionAsString(PassDirection D) {
+const char *
+ParamCommandComment::getDirectionAsString(ParamCommandPassDirection D) {
   switch (D) {
-  case ParamCommandComment::In:
+  case ParamCommandPassDirection::In:
 return "[in]";
-  case ParamCommandComment::Out:
+  case ParamCommandPassDirection::Out:
 return "[out]";
-  case ParamCommandComment::InOut:
+  case ParamCommandPassDirection::InOut:
 return "[in,out]";
   }
   llvm_unreachable("unknown PassDirection");

diff  --git a/clang/lib/AST/CommentSema.cpp b/clang/lib/AST/CommentSema.cpp
index 6f68577954137f3..bc01baa1d917b57 100644
--- a/clang/lib/AST/CommentSema.cpp
+++ b/clang/lib/AST/CommentSema.cpp
@@ -219,12 +219,12 @@ void Sema::checkContainerDecl(const BlockCommandComment 
*Comment) {
 
 /// Turn a string into the corresponding PassDirection or -1 if it's not
 /// valid.
-static int getParamPassDirection(StringRef Arg) {
-  return llvm::StringSwitch(Arg)
-  .Case("[in]", ParamCommandComment::In)
-  .Case("[out]", ParamCommandComment::Out)
-  .Cases("[in,out]", "[out,in]", ParamCommandComment::InOut)
-  .Default(-1);
+static ParamCommandPassDirection getParamPassDirection(StringRef Arg) {
+  return llvm::StringSwitch(Arg)
+  .Case("[in]", ParamCommandPassDirection::In)
+  .Case("[out]", ParamCommandPassDirection::Out)
+  .Cases("[in,out]", "[out,in]", ParamCommandPassDirection::InOut)
+  .Default(static_cast(-1));
 }
 
 void Sema::actOnParamCommandDirectionArg(ParamCommandComment *Command,
@@ -232,25 +232,25 @@ void 
Sema::actOnParamCommandDirectionArg(ParamCommandComment *Command,
  SourceLocation ArgLocEnd,
  StringR

[clang] 088932d - [clang][NFC] Annotate `AST/Comment.h` with `preferred_type`

2023-11-06 Thread Vlad Serebrennikov via cfe-commits

Author: Vlad Serebrennikov
Date: 2023-11-06T23:08:39+03:00
New Revision: 088932d8ef1f80ba9e1349ce7cda95accd2f745e

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

LOG: [clang][NFC] Annotate `AST/Comment.h` with `preferred_type`

Also declare `InlineCommandRenderKind` as scoped enum, which 
565e21b3e079e53c4fcf47d2ec898dbc248fbd3a
forgot to do.

Added: 


Modified: 
clang/include/clang/AST/Comment.h

Removed: 




diff  --git a/clang/include/clang/AST/Comment.h 
b/clang/include/clang/AST/Comment.h
index d501ce1822862d9..dd9906727293fce 100644
--- a/clang/include/clang/AST/Comment.h
+++ b/clang/include/clang/AST/Comment.h
@@ -27,6 +27,8 @@ class TemplateParameterList;
 
 namespace comments {
 class FullComment;
+enum class InlineCommandRenderKind;
+enum class ParamCommandPassDirection;
 
 /// Describes the syntax that was used in a documentation command.
 ///
@@ -72,6 +74,7 @@ class Comment {
 friend class Comment;
 
 /// Type of this AST node.
+LLVM_PREFERRED_TYPE(CommentKind)
 unsigned Kind : 8;
   };
   enum { NumCommentBits = 8 };
@@ -79,10 +82,12 @@ class Comment {
   class InlineContentCommentBitfields {
 friend class InlineContentComment;
 
+LLVM_PREFERRED_TYPE(CommentBitfields)
 unsigned : NumCommentBits;
 
 /// True if there is a newline after this inline content node.
 /// (There is no separate AST node for a newline.)
+LLVM_PREFERRED_TYPE(bool)
 unsigned HasTrailingNewline : 1;
   };
   enum { NumInlineContentCommentBits = NumCommentBits + 1 };
@@ -90,12 +95,15 @@ class Comment {
   class TextCommentBitfields {
 friend class TextComment;
 
+LLVM_PREFERRED_TYPE(InlineContentCommentBitfields)
 unsigned : NumInlineContentCommentBits;
 
 /// True if \c IsWhitespace field contains a valid value.
+LLVM_PREFERRED_TYPE(bool)
 mutable unsigned IsWhitespaceValid : 1;
 
 /// True if this comment AST node contains only whitespace.
+LLVM_PREFERRED_TYPE(bool)
 mutable unsigned IsWhitespace : 1;
   };
   enum { NumTextCommentBits = NumInlineContentCommentBits + 2 };
@@ -103,10 +111,13 @@ class Comment {
   class InlineCommandCommentBitfields {
 friend class InlineCommandComment;
 
+LLVM_PREFERRED_TYPE(InlineContentCommentBitfields)
 unsigned : NumInlineContentCommentBits;
 
+LLVM_PREFERRED_TYPE(InlineCommandRenderKind)
 unsigned RenderKind : 3;
 
+LLVM_PREFERRED_TYPE(CommandTraits::KnownCommandIDs)
 unsigned CommandID : CommandInfo::NumCommandIDBits;
   };
   enum { NumInlineCommandCommentBits = NumInlineContentCommentBits + 3 +
@@ -115,9 +126,11 @@ class Comment {
   class HTMLTagCommentBitfields {
 friend class HTMLTagComment;
 
+LLVM_PREFERRED_TYPE(InlineContentCommentBitfields)
 unsigned : NumInlineContentCommentBits;
 
 /// True if we found that this tag is malformed in some way.
+LLVM_PREFERRED_TYPE(bool)
 unsigned IsMalformed : 1;
   };
   enum { NumHTMLTagCommentBits = NumInlineContentCommentBits + 1 };
@@ -125,10 +138,12 @@ class Comment {
   class HTMLStartTagCommentBitfields {
 friend class HTMLStartTagComment;
 
+LLVM_PREFERRED_TYPE(HTMLTagCommentBitfields)
 unsigned : NumHTMLTagCommentBits;
 
 /// True if this tag is self-closing (e. g., ).  This is based on tag
 /// spelling in comment (plain  would not set this flag).
+LLVM_PREFERRED_TYPE(bool)
 unsigned IsSelfClosing : 1;
   };
   enum { NumHTMLStartTagCommentBits = NumHTMLTagCommentBits + 1 };
@@ -136,12 +151,15 @@ class Comment {
   class ParagraphCommentBitfields {
 friend class ParagraphComment;
 
+LLVM_PREFERRED_TYPE(CommentBitfields)
 unsigned : NumCommentBits;
 
 /// True if \c IsWhitespace field contains a valid value.
+LLVM_PREFERRED_TYPE(bool)
 mutable unsigned IsWhitespaceValid : 1;
 
 /// True if this comment AST node contains only whitespace.
+LLVM_PREFERRED_TYPE(bool)
 mutable unsigned IsWhitespace : 1;
   };
   enum { NumParagraphCommentBits = NumCommentBits + 2 };
@@ -149,12 +167,15 @@ class Comment {
   class BlockCommandCommentBitfields {
 friend class BlockCommandComment;
 
+LLVM_PREFERRED_TYPE(CommentBitfields)
 unsigned : NumCommentBits;
 
+LLVM_PREFERRED_TYPE(CommandTraits::KnownCommandIDs)
 unsigned CommandID : CommandInfo::NumCommandIDBits;
 
 /// Describes the syntax that was used in a documentation command.
 /// Contains values from CommandMarkerKind enum.
+LLVM_PREFERRED_TYPE(CommandMarkerKind)
 unsigned CommandMarker : 1;
   };
   enum { NumBlockCommandCommentBits = NumCommentBits +
@@ -163,12 +184,15 @@ class Comment {
   class ParamCommandCommentBitfields {
 friend class ParamCommandComment;
 
+LLVM_PREFERRED_TYPE(BlockCommandCommentBitfields)
 uns

[clang] b6f2597 - Add missing `llvm::to_underlying` in `AST/CommentParser.cpp` unit test

2023-11-06 Thread Vlad Serebrennikov via cfe-commits

Author: Vlad Serebrennikov
Date: 2023-11-06T23:27:13+03:00
New Revision: b6f2597a45f426f3a276c1c59f7ff5521b6dcc89

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

LOG: Add missing `llvm::to_underlying` in `AST/CommentParser.cpp` unit test

This fixed a test failure introduced in 
f2d8a0ac1dd1fe55b2c3b358c525fbc01b0121ed.

Added: 


Modified: 
clang/unittests/AST/CommentParser.cpp

Removed: 




diff  --git a/clang/unittests/AST/CommentParser.cpp 
b/clang/unittests/AST/CommentParser.cpp
index 1368f56d0f8eddc..c3479672ae2a3cf 100644
--- a/clang/unittests/AST/CommentParser.cpp
+++ b/clang/unittests/AST/CommentParser.cpp
@@ -193,8 +193,9 @@ HasParamCommandAt(const Comment *C, const CommandTraits 
&Traits, size_t Idx,
 
   if (PCC->getDirection() != Direction)
 return ::testing::AssertionFailure()
-<< "ParamCommandComment has direction " << PCC->getDirection() << ", "
-   "expected " << Direction;
+   << "ParamCommandComment has direction "
+   << llvm::to_underlying(PCC->getDirection()) << ", expected "
+   << llvm::to_underlying(Direction);
 
   if (PCC->isDirectionExplicit() != IsDirectionExplicit)
 return ::testing::AssertionFailure()



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


[clang] [clang-tools-extra] [clang][NFC] Refactor `CXXNewExpr::InitializationStyle` (PR #71322)

2023-11-07 Thread Vlad Serebrennikov via cfe-commits

Endilll wrote:

> If you see failures locally, it's best to understand where they coming from: 
> even if it passes on bots it just means we have a hole in our test coverage.

Sure, but it wasn't the first time I've seen local test failures that doesn't 
reproduce anywhere else (`Clang :: LibClang/symbols.test`). By the time I 
merged this PR, me and Aaron have spent hours staring at the changes without 
any progress. So we wanted an additional confirmation that this is not in the 
same as `Clang :: LibClang/symbols.test` failure, especially looking at 
pre-commit CI that reported just a several seemingly unrelated clang-tidy 
failures. I hope it is acceptable that we decided not to spend even more time 
before trying this PR out on wider range of buildbots.

https://github.com/llvm/llvm-project/pull/71322
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] fb8ff4c - [clang][NFC] Add a missing comment to #71322 changes

2023-11-07 Thread Vlad Serebrennikov via cfe-commits

Author: Vlad Serebrennikov
Date: 2023-11-07T22:24:59+03:00
New Revision: fb8ff4cdaecb7fe498d4e3a9cbcb33d40cccd29a

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

LOG: [clang][NFC] Add a missing comment to #71322 changes

It was an unfortunate oversight from my side to forget to include this comment 
into the PR.

Added: 


Modified: 
clang/lib/Sema/SemaExprCXX.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index 67bc847ff2a60e6..023411c7edc946b 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -2443,6 +2443,11 @@ ExprResult Sema::BuildCXXNew(SourceRange Range, bool 
UseGlobal,
   FullInit = Binder->getSubExpr();
 
 Initializer = FullInit.get();
+// We don't know that we're generating an implicit initializer until now, 
so
+// we have to update the initialization style as well.
+//
+// FIXME: it would be nice to determine the correct initialization style
+// earlier so InitStyle doesn't need adjusting.
 if (InitStyle == CXXNewInitializationStyle::None && Initializer) {
   InitStyle = CXXNewInitializationStyle::Implicit;
 }



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


[clang] 5e09c4e - [clang][NFC] Partially annotate `IdentifierInfo` with `preferred_type`

2023-11-08 Thread Vlad Serebrennikov via cfe-commits

Author: Vlad Serebrennikov
Date: 2023-11-08T15:44:46+03:00
New Revision: 5e09c4e6a865707ed26f9a893dbef8b499591459

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

LOG: [clang][NFC] Partially annotate `IdentifierInfo` with `preferred_type`

This patch leaves `ObjCOrBuiltinID` alone, because of performance concerns with 
potential refactoring that would enable correct types in debug info.

Added: 


Modified: 
clang/include/clang/Basic/IdentifierTable.h

Removed: 




diff  --git a/clang/include/clang/Basic/IdentifierTable.h 
b/clang/include/clang/Basic/IdentifierTable.h
index 2eafe5938406749..0898e7d39dd7dee 100644
--- a/clang/include/clang/Basic/IdentifierTable.h
+++ b/clang/include/clang/Basic/IdentifierTable.h
@@ -110,6 +110,7 @@ class alignas(IdentifierInfoAlignment) IdentifierInfo {
   friend class IdentifierTable;
 
   // Front-end token ID or tok::identifier.
+  LLVM_PREFERRED_TYPE(tok::TokenKind)
   unsigned TokenID : 9;
 
   // ObjC keyword ('protocol' in '@protocol') or builtin (__builtin_inf).
@@ -118,58 +119,75 @@ class alignas(IdentifierInfoAlignment) IdentifierInfo {
   unsigned ObjCOrBuiltinID : ObjCOrBuiltinIDBits;
 
   // True if there is a #define for this.
+  LLVM_PREFERRED_TYPE(bool)
   unsigned HasMacro : 1;
 
   // True if there was a #define for this.
+  LLVM_PREFERRED_TYPE(bool)
   unsigned HadMacro : 1;
 
   // True if the identifier is a language extension.
+  LLVM_PREFERRED_TYPE(bool)
   unsigned IsExtension : 1;
 
   // True if the identifier is a keyword in a newer or proposed Standard.
+  LLVM_PREFERRED_TYPE(bool)
   unsigned IsFutureCompatKeyword : 1;
 
   // True if the identifier is poisoned.
+  LLVM_PREFERRED_TYPE(bool)
   unsigned IsPoisoned : 1;
 
   // True if the identifier is a C++ operator keyword.
+  LLVM_PREFERRED_TYPE(bool)
   unsigned IsCPPOperatorKeyword : 1;
 
   // Internal bit set by the member function RecomputeNeedsHandleIdentifier.
   // See comment about RecomputeNeedsHandleIdentifier for more info.
+  LLVM_PREFERRED_TYPE(bool)
   unsigned NeedsHandleIdentifier : 1;
 
   // True if the identifier was loaded (at least partially) from an AST file.
+  LLVM_PREFERRED_TYPE(bool)
   unsigned IsFromAST : 1;
 
   // True if the identifier has changed from the definition
   // loaded from an AST file.
+  LLVM_PREFERRED_TYPE(bool)
   unsigned ChangedAfterLoad : 1;
 
   // True if the identifier's frontend information has changed from the
   // definition loaded from an AST file.
+  LLVM_PREFERRED_TYPE(bool)
   unsigned FEChangedAfterLoad : 1;
 
   // True if revertTokenIDToIdentifier was called.
+  LLVM_PREFERRED_TYPE(bool)
   unsigned RevertedTokenID : 1;
 
   // True if there may be additional information about
   // this identifier stored externally.
+  LLVM_PREFERRED_TYPE(bool)
   unsigned OutOfDate : 1;
 
   // True if this is the 'import' contextual keyword.
+  LLVM_PREFERRED_TYPE(bool)
   unsigned IsModulesImport : 1;
 
   // True if this is a mangled OpenMP variant name.
+  LLVM_PREFERRED_TYPE(bool)
   unsigned IsMangledOpenMPVariantName : 1;
 
   // True if this is a deprecated macro.
+  LLVM_PREFERRED_TYPE(bool)
   unsigned IsDeprecatedMacro : 1;
 
   // True if this macro is unsafe in headers.
+  LLVM_PREFERRED_TYPE(bool)
   unsigned IsRestrictExpansion : 1;
 
   // True if this macro is final.
+  LLVM_PREFERRED_TYPE(bool)
   unsigned IsFinal : 1;
 
   // 22 bits left in a 64-bit word.



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


[clang] [clang] Refactor `IdentifierInfo::ObjcOrBuiltinID` (PR #71709)

2023-11-08 Thread Vlad Serebrennikov via cfe-commits

https://github.com/Endilll created 
https://github.com/llvm/llvm-project/pull/71709

This patch refactors how values are stored inside 
`IdentifierInfo::ObjcOrBuiltinID` bit-field, and annotates it with 
`preferred_type`. In order to make the value easier to interpret by debuggers, 
a new `ObjCKeywordOrInterestingOrBuiltin` is added. Previous "layout" of this 
fields couldn't be represented with this new enum, because it skipped over some 
arbitrary enumerators, so a new "layout" was invented based on 
`ObjCKeywordOrInterestingOrBuiltin` enum. I believe the new layout is simpler 
than the new one.

>From 2823d38544d18213b5bf48c67e4eedd52acce850 Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov 
Date: Wed, 8 Nov 2023 20:30:37 +0300
Subject: [PATCH] [clang] Refactor `IdentifierInfo::ObjcOrBuiltinID`

This patch refactors how values are stored inside 
`IdentifierInfo::ObjcOrBuiltinID` bit-field, and annotates it with 
`preferred_type`. In order to make the value easier to interpret by debuggers, 
a new `ObjCKeywordOrInterestingOrBuiltin` is added. Previous "layout" of this 
fields couldn't be represented with this new enum, because it skipped over some 
arbitrary enumerators, so a new "layout" was invented based on 
`ObjCKeywordOrInterestingOrBuiltin` enum. I believe the new layout is simpler 
than the new one.
---
 clang/include/clang/Basic/IdentifierTable.h | 117 
 1 file changed, 73 insertions(+), 44 deletions(-)

diff --git a/clang/include/clang/Basic/IdentifierTable.h 
b/clang/include/clang/Basic/IdentifierTable.h
index 0898e7d39dd7dee..fa76228da2b143a 100644
--- a/clang/include/clang/Basic/IdentifierTable.h
+++ b/clang/include/clang/Basic/IdentifierTable.h
@@ -15,6 +15,7 @@
 #ifndef LLVM_CLANG_BASIC_IDENTIFIERTABLE_H
 #define LLVM_CLANG_BASIC_IDENTIFIERTABLE_H
 
+#include "clang/Basic/Builtins.h"
 #include "clang/Basic/DiagnosticIDs.h"
 #include "clang/Basic/LLVM.h"
 #include "clang/Basic/TokenKinds.h"
@@ -86,19 +87,26 @@ enum { IdentifierInfoAlignment = 8 };
 static constexpr int ObjCOrBuiltinIDBits = 16;
 
 /// The "layout" of ObjCOrBuiltinID is:
-///  - The first value (0) represents "not a special identifier".
-///  - The next (NUM_OBJC_KEYWORDS - 1) values represent ObjCKeywordKinds (not
-///including objc_not_keyword).
-///  - The next (NUM_INTERESTING_IDENTIFIERS - 1) values represent
-///InterestingIdentifierKinds (not including not_interesting).
-///  - The rest of the values represent builtin IDs (not including NotBuiltin).
-static constexpr int FirstObjCKeywordID = 1;
-static constexpr int LastObjCKeywordID =
-FirstObjCKeywordID + tok::NUM_OBJC_KEYWORDS - 2;
-static constexpr int FirstInterestingIdentifierID = LastObjCKeywordID + 1;
-static constexpr int LastInterestingIdentifierID =
-FirstInterestingIdentifierID + tok::NUM_INTERESTING_IDENTIFIERS - 2;
-static constexpr int FirstBuiltinID = LastInterestingIdentifierID + 1;
+///  - ObjCKeywordKind enumerators
+///  - InterestingIdentifierKind enumerators
+///  - Builtin::ID enumerators
+///  - NonSpecialIdentifier
+enum class ObjCKeywordOrInterestingOrBuiltin {
+#define OBJC_AT_KEYWORD(X) objc_##X,
+#include "clang/Basic/TokenKinds.def"
+  NUM_OBJC_KEYWORDS,
+
+#define INTERESTING_IDENTIFIER(X) X,
+#include "clang/Basic/TokenKinds.def"
+  NUM_OBJC_KEYWORDS_AND_INTERESTING_IDENTIFIERS,
+
+  NotBuiltin,
+#define BUILTIN(ID, TYPE, ATTRS) BI##ID,
+#include "clang/Basic/Builtins.def"
+  FirstTSBuiltin,
+
+  NonSpecialIdentifier = 65534
+};
 
 /// One of these records is kept for each identifier that
 /// is lexed.  This contains information about whether the token was 
\#define'd,
@@ -113,9 +121,7 @@ class alignas(IdentifierInfoAlignment) IdentifierInfo {
   LLVM_PREFERRED_TYPE(tok::TokenKind)
   unsigned TokenID : 9;
 
-  // ObjC keyword ('protocol' in '@protocol') or builtin (__builtin_inf).
-  // First NUM_OBJC_KEYWORDS values are for Objective-C,
-  // the remaining values are for builtins.
+  LLVM_PREFERRED_TYPE(ObjCKeywordOrInterestingOrBuiltin)
   unsigned ObjCOrBuiltinID : ObjCOrBuiltinIDBits;
 
   // True if there is a #define for this.
@@ -198,13 +204,16 @@ class alignas(IdentifierInfoAlignment) IdentifierInfo {
   llvm::StringMapEntry *Entry = nullptr;
 
   IdentifierInfo()
-  : TokenID(tok::identifier), ObjCOrBuiltinID(0), HasMacro(false),
-HadMacro(false), IsExtension(false), IsFutureCompatKeyword(false),
-IsPoisoned(false), IsCPPOperatorKeyword(false),
-NeedsHandleIdentifier(false), IsFromAST(false), 
ChangedAfterLoad(false),
-FEChangedAfterLoad(false), RevertedTokenID(false), OutOfDate(false),
-IsModulesImport(false), IsMangledOpenMPVariantName(false),
-IsDeprecatedMacro(false), IsRestrictExpansion(false), IsFinal(false) {}
+  : TokenID(tok::identifier),
+ObjCOrBuiltinID(llvm::to_underlying(
+ObjCKeywordOrInterestingOrBuiltin::NonSpecialIdentifier)),
+HasMacro(false), HadMacro(false), IsExtension(false),
+I

[clang] [clang] Refactor `IdentifierInfo::ObjcOrBuiltinID` (PR #71709)

2023-11-08 Thread Vlad Serebrennikov via cfe-commits

Endilll wrote:

@ChuanqiXu9 Can I use some of your help? This PR breaks two module tests:
```
  Clang :: Modules/cxx20-hu-04.cpp
  Clang :: Modules/cxx20-module-file-info-macros.cpp
```
Apparently I somehow break import or export of header unit macros.

In `cxx20-module-file-info-macros.cpp`, the following part of the test breaks, 
because there are no macro definitions in the output:
https://github.com/llvm/llvm-project/blob/e3c120a585d2740bd1a4de23112fccd82013adbc/clang/test/Modules/cxx20-module-file-info-macros.cpp#L51-L58

In `cxx20-hu-04.cpp`, the following part of the test:
https://github.com/llvm/llvm-project/blob/e3c120a585d2740bd1a4de23112fccd82013adbc/clang/test/Modules/cxx20-hu-04.cpp#L83-L94
produces some unexpected diagnostic:
```
error: 'expected-error' diagnostics expected but not seen:
  File importer-01.cpp Line 9: use of undeclared identifier 'bar'
error: 'expected-error' diagnostics seen but not expected:
  File importer-01.cpp Line 5: use of undeclared identifier 'FORTYTWO'
  File importer-01.cpp Line 9: use of undeclared identifier 'FORTYTWO'
error: 'expected-note' diagnostics expected but not seen:
  File * Line * (directive at importer-01.cpp:10): 'baz' declared here
4 errors generated.
```
which is again a missing macro definition.
Me and Aaron have been trying to debug this, but to no avail.

https://github.com/llvm/llvm-project/pull/71709
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Refactor `IdentifierInfo::ObjcOrBuiltinID` (PR #71709)

2023-11-09 Thread Vlad Serebrennikov via cfe-commits


@@ -86,19 +87,26 @@ enum { IdentifierInfoAlignment = 8 };
 static constexpr int ObjCOrBuiltinIDBits = 16;
 
 /// The "layout" of ObjCOrBuiltinID is:
-///  - The first value (0) represents "not a special identifier".
-///  - The next (NUM_OBJC_KEYWORDS - 1) values represent ObjCKeywordKinds (not
-///including objc_not_keyword).
-///  - The next (NUM_INTERESTING_IDENTIFIERS - 1) values represent
-///InterestingIdentifierKinds (not including not_interesting).
-///  - The rest of the values represent builtin IDs (not including NotBuiltin).
-static constexpr int FirstObjCKeywordID = 1;
-static constexpr int LastObjCKeywordID =
-FirstObjCKeywordID + tok::NUM_OBJC_KEYWORDS - 2;
-static constexpr int FirstInterestingIdentifierID = LastObjCKeywordID + 1;
-static constexpr int LastInterestingIdentifierID =
-FirstInterestingIdentifierID + tok::NUM_INTERESTING_IDENTIFIERS - 2;
-static constexpr int FirstBuiltinID = LastInterestingIdentifierID + 1;
+///  - ObjCKeywordKind enumerators
+///  - InterestingIdentifierKind enumerators
+///  - Builtin::ID enumerators
+///  - NonSpecialIdentifier
+enum class ObjCKeywordOrInterestingOrBuiltin {
+#define OBJC_AT_KEYWORD(X) objc_##X,
+#include "clang/Basic/TokenKinds.def"
+  NUM_OBJC_KEYWORDS,

Endilll wrote:

Not just this enumerator, but all OjbC keywords and interesting identifiers. I 
consider this a feature, actually, because debuggers would show enumerator name 
that both makes sense and useful while displaying `ObjCOrBuiltinID` bit-fields. 
Having `ObjCKeywordOrInterestingOrBuiltin` as a scoped enum should prevent name 
collisions with any other enum. enumeratrion

https://github.com/llvm/llvm-project/pull/71709
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Refactor `IdentifierInfo::ObjcOrBuiltinID` (PR #71709)

2023-11-09 Thread Vlad Serebrennikov via cfe-commits

Endilll wrote:

> Oh, I didn't look into the identifier's system before. I took a while to look 
> at the patch but I failed to understand it and I failed to find the 
> relationships between this patch and header units...

Yeah, the part this PR touches in not the most straightforward one. Thank you 
for you time!

https://github.com/llvm/llvm-project/pull/71709
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] e77bfaa - [clang][NFC] Fill in historical data on when C++ DRs 500-599 were fixed

2023-12-04 Thread Vlad Serebrennikov via cfe-commits

Author: Vlad Serebrennikov
Date: 2023-12-05T00:42:13+03:00
New Revision: e77bfaaf9d66748fc2dc3a710a0c9b4665dd3034

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

LOG: [clang][NFC] Fill in historical data on when C++ DRs 500-599 were fixed

Added: 


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

Removed: 




diff  --git a/clang/test/CXX/drs/dr5xx.cpp b/clang/test/CXX/drs/dr5xx.cpp
index a3563481eac68..204d07f04f4e5 100644
--- a/clang/test/CXX/drs/dr5xx.cpp
+++ b/clang/test/CXX/drs/dr5xx.cpp
@@ -381,7 +381,7 @@ namespace dr532 { // dr532: 3.5
 
 // dr533: na
 
-namespace dr534 { // dr534: yes
+namespace dr534 { // dr534: 2.9
   struct S {};
   template void operator+(S, T);
   template void operator+(S, T*) {} // expected-error 
{{function template partial spec}}
@@ -511,7 +511,7 @@ namespace dr542 { // dr542: yes
 #endif
 }
 
-namespace dr543 { // dr543: yes
+namespace dr543 { // dr543: 3.0
   // In C++98+DR543, this is valid because value-initialization doesn't call a
   // trivial default constructor, so we never notice that defining the
   // constructor would be ill-formed.
@@ -544,7 +544,7 @@ namespace dr546 { // dr546: yes
   template void A::f() { T::error; }
 }
 
-namespace dr547 { // dr547: yes
+namespace dr547 { // dr547: 3.2
   template struct X;
   template struct X {};
   template X f(T C::*) { return X(); }
@@ -607,7 +607,7 @@ namespace dr553 {
 // dr554: na
 // dr556: na
 
-namespace dr557 { // dr557: yes
+namespace dr557 { // dr557: 3.1
   template struct S {
 friend void f(S *);
 friend void g(S > *);
@@ -618,7 +618,7 @@ namespace dr557 { // dr557: yes
   }
 }
 
-namespace dr558 { // dr558: yes
+namespace dr558 { // dr558: 2.9
   wchar_t a = L'\uD7FF';
   wchar_t b = L'\xD7FF';
   wchar_t c = L'\uD800'; // expected-error {{invalid universal character}}
@@ -674,7 +674,7 @@ namespace dr566 { // dr566: yes
 
 // dr567: na
 
-namespace dr568 { // dr568: yes c++11
+namespace dr568 { // dr568: 3.0 c++11
   // FIXME: This is a DR issue against C++98, so should probably apply there
   // too.
   struct x { int y; };
@@ -762,7 +762,7 @@ namespace dr573 { // dr573: no
   template struct T;
 }
 
-namespace dr574 { // dr574: yes
+namespace dr574 { // dr574: 3.0
   struct A {
 A &operator=(const A&) const; // expected-note {{
diff erent qualifiers}}
   };
@@ -827,13 +827,13 @@ namespace dr575 { // dr575: yes
   void *p = h((void*)0);
 }
 
-namespace dr576 { // dr576: yes
+namespace dr576 { // dr576: 3.5
   typedef void f() {} // expected-error {{function definition declared 
'typedef'}}
   void f(typedef int n); // expected-error {{invalid storage class}}
   void f(char c) { typedef int n; }
 }
 
-namespace dr577 { // dr577: yes
+namespace dr577 { // dr577: 3.5
   typedef void V;
   typedef const void CV;
   void a(void);
@@ -910,7 +910,7 @@ namespace dr583 { // dr583: 4
 
 // dr584: na
 
-namespace dr585 { // dr585: yes
+namespace dr585 { // dr585: 3.0
   template struct T;
   struct A {
 friend T;
@@ -938,7 +938,7 @@ namespace dr585 { // dr585: yes
 
 // dr586: na
 
-namespace dr587 { // dr587: yes
+namespace dr587 { // dr587: 3.2
   template void f(bool b, const T x, T y) {
 const T *p = &(b ? x : y);
   }

diff  --git a/clang/www/cxx_dr_status.html b/clang/www/cxx_dr_status.html
index 4d918224ded46..0d315a82eeaba 100755
--- a/clang/www/cxx_dr_status.html
+++ b/clang/www/cxx_dr_status.html
@@ -3243,7 +3243,7 @@ C++ defect report implementation 
status
 https://cplusplus.github.io/CWG/issues/534.html";>534
 CD1
 template-names and operator-function-ids
-Yes
+Clang 2.9
   
   
 https://cplusplus.github.io/CWG/issues/535.html";>535
@@ -3299,7 +3299,7 @@ C++ defect report implementation 
status
 https://cplusplus.github.io/CWG/issues/543.html";>543
 CD1
 Value initialization and default constructors
-Yes
+Clang 3.0
   
   
 https://cplusplus.github.io/CWG/issues/544.html";>544
@@ -3323,7 +3323,7 @@ C++ defect report implementation 
status
 https://cplusplus.github.io/CWG/issues/547.html";>547
 C++11
 Partial specialization on member function types
-Yes
+Clang 3.2
   
   
 https://cplusplus.github.io/CWG/issues/548.html";>548
@@ -3383,13 +3383,13 @@ C++ defect report implementation 
status
 https://cplusplus.github.io/CWG/issues/557.html";>557
 CD1
 Does argument-dependent lookup cause template instantiation?
-Yes
+Clang 3.1
   
   
 https://cplusplus.github.io/CWG/issues/558.html";>558
 CD1
 Excluded characters in universal character names
-Yes
+Clang 2.9
   
   
 https://cplusplus.github.io/CWG/issues/559.html";>559
@@ -3449,7 +3449,7 @@ C++ defect report implementation 
status
 https://cplusplus.github.io/

[clang] [clang][NFC] Refactor expected directives in C++ DRs 500-599 (PR #74373)

2023-12-04 Thread Vlad Serebrennikov via cfe-commits

https://github.com/Endilll created 
https://github.com/llvm/llvm-project/pull/74373

This patch continues the work started with 
ea5b1ef016d020c37f903d6c7d4f623be975dab8. See that commit and its corresponding 
PR for details.

>From 1e5ede1925b8cfdae93415abfddb930aaaf3241e Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov 
Date: Tue, 5 Dec 2023 00:37:51 +0300
Subject: [PATCH]  [clang][NFC] Refactor expected directives in C++ DRs 500-599

This patch continues the work started with 
ea5b1ef016d020c37f903d6c7d4f623be975dab8. See that commit and its corresponding 
PR for details.
---
 clang/test/CXX/drs/dr5xx.cpp | 595 +--
 1 file changed, 361 insertions(+), 234 deletions(-)

diff --git a/clang/test/CXX/drs/dr5xx.cpp b/clang/test/CXX/drs/dr5xx.cpp
index 204d07f04f4e5..21a6646d4abcf 100644
--- a/clang/test/CXX/drs/dr5xx.cpp
+++ b/clang/test/CXX/drs/dr5xx.cpp
@@ -1,20 +1,21 @@
-// RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors
-// RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors
-// RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors
-// RUN: %clang_cc1 -std=c++17 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors
-// RUN: %clang_cc1 -std=c++20 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors
-// RUN: %clang_cc1 -std=c++23 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors
+// RUN: %clang_cc1 -std=c++98 %s 
-verify=expected,cxx98-11,cxx98-14,cxx98-17,cxx98 -fexceptions -fcxx-exceptions 
-pedantic-errors
+// RUN: %clang_cc1 -std=c++11 %s 
-verify=expected,cxx98-11,cxx98-14,cxx98-17,since-cxx11 -fexceptions 
-fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++14 %s 
-verify=expected,cxx98-14,cxx98-17,since-cxx11 -fexceptions -fcxx-exceptions 
-pedantic-errors
+// RUN: %clang_cc1 -std=c++17 %s 
-verify=expected,since-cxx17,cxx98-17,since-cxx11 -fexceptions -fcxx-exceptions 
-pedantic-errors
+// RUN: %clang_cc1 -std=c++20 %s 
-verify=expected,since-cxx20,since-cxx17,since-cxx11 -fexceptions 
-fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++23 %s 
-verify=expected,since-cxx23,since-cxx20,since-cxx17,since-cxx11 -fexceptions 
-fcxx-exceptions -pedantic-errors
 
 // FIXME: This is included to avoid a diagnostic with no source location
 // pointing at the implicit operator new. We can't match such a diagnostic
 // with -verify.
 __extension__ typedef __SIZE_TYPE__ size_t;
-void *operator new(size_t); // expected-error 0-1{{missing exception spec}} 
expected-note{{candidate}}
+void *operator new(size_t); // #dr5xx-global-operator-new
+// cxx98-error@-1 {{'operator new' is missing exception specification 
'throw(std::bad_alloc)'}}
 #if __cplusplus > 201402L
 namespace std {
   enum class align_val_t : size_t {};
 }
-void *operator new(size_t, std::align_val_t); // expected-note{{candidate}}
+void *operator new(size_t, std::align_val_t); // 
#dr5xx-global-operator-new-aligned
 #endif
 
 namespace dr500 { // dr500: dup 372
@@ -33,7 +34,8 @@ namespace dr501 { // dr501: yes
   struct A {
 friend void f() {}
 void g() {
-  void (*p)() = &f; // expected-error {{undeclared identifier}}
+  void (*p)() = &f;
+  // expected-error@-1 {{use of undeclared identifier 'f'}}
 }
   };
 }
@@ -45,7 +47,8 @@ namespace dr502 { // dr502: yes
 void q1() { f(e); }
 void q2() { Q arr[sizeof(E)]; f(arr); }
 void q3() { Q arr[e]; f(arr); }
-void sanity() { Q arr[1]; f(arr); } // expected-error {{undeclared 
identifier 'f'}}
+void sanity() { Q arr[1]; f(arr); }
+// expected-error@-1 {{use of undeclared identifier 'f'}}
   };
   int f(A::E);
   template int f(Q (&)[N]);
@@ -53,14 +56,22 @@ namespace dr502 { // dr502: yes
 }
 
 namespace dr505 { // dr505: yes
-  const char *exts = "\e\(\{\[\%"; // expected-error 5{{use of non-standard 
escape}}
-  const char *unknown = "\Q"; // expected-error {{unknown escape sequence}}
+  const char *exts = "\e\(\{\[\%";
+  // expected-error@-1 {{use of non-standard escape character '\e'}}
+  // expected-error@-2 {{use of non-standard escape character '\('}}
+  // expected-error@-3 {{use of non-standard escape character '\{'}}
+  // expected-error@-4 {{use of non-standard escape character '\['}}
+  // expected-error@-5 {{use of non-standard escape character '\%'}}
+  const char *unknown = "\Q";
+  // expected-error@-1 {{unknown escape sequence '\Q'}}
 }
 
 namespace dr506 { // dr506: yes
   struct NonPod { ~NonPod(); };
   void f(...);
-  void g(NonPod np) { f(np); } // expected-error {{cannot pass}}
+  void g(NonPod np) { f(np); }
+  // cxx98-error@-1 {{cannot pass object of non-POD type 'NonPod' through 
variadic function; call will abort at runtime}}
+  // since-cxx11-error@-2 {{cannot pass object of non-trivial type 'NonPod' 
through variadic function; call will abort at runtime}}
 }
 
 // FIXME: Add tests here once DR260 is resolved.
@@ -71,15 +82,13 @@ namespace dr506 { // dr

[clang] [clang][NFC] Refactor expected directives in C++ DRs 500-599 (PR #74373)

2023-12-04 Thread Vlad Serebrennikov via cfe-commits

Endilll wrote:

This PR is created to check the patch against CI.

https://github.com/llvm/llvm-project/pull/74373
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][NFC] Refactor expected directives in C++ DRs 500-599 (PR #74373)

2023-12-04 Thread Vlad Serebrennikov via cfe-commits

https://github.com/Endilll closed 
https://github.com/llvm/llvm-project/pull/74373
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 94708fb - [clang][NFC] Fill in historical data on when C++ DRs 600-699 were fixed

2023-12-05 Thread Vlad Serebrennikov via cfe-commits

Author: Vlad Serebrennikov
Date: 2023-12-05T17:16:10+03:00
New Revision: 94708fbc0fa06b18c9b263ecb78d20a95a194e7f

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

LOG: [clang][NFC] Fill in historical data on when C++ DRs 600-699 were fixed

Added: 


Modified: 
clang/test/CXX/drs/dr6xx.cpp
clang/www/cxx_dr_status.html

Removed: 




diff  --git a/clang/test/CXX/drs/dr6xx.cpp b/clang/test/CXX/drs/dr6xx.cpp
index c5cd478c5e331..4cba1f057cb27 100644
--- a/clang/test/CXX/drs/dr6xx.cpp
+++ b/clang/test/CXX/drs/dr6xx.cpp
@@ -5,7 +5,7 @@
 // RUN: %clang_cc1 -std=c++20 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors -fno-spell-checking
 // RUN: %clang_cc1 -std=c++23 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors -fno-spell-checking
 
-namespace dr600 { // dr600: yes
+namespace dr600 { // dr600: 2.8
 struct S {
   void f(int);
 
@@ -82,7 +82,7 @@ namespace dr603 { // dr603: yes
 // dr604: na
 // dr605 needs IRGen test
 
-namespace dr606 { // dr606: yes
+namespace dr606 { // dr606: 3.0
 #if __cplusplus >= 201103L
   template struct S {};
   template void f(S &&); // expected-note {{expects an rvalue}}
@@ -266,7 +266,7 @@ namespace dr627 { // dr627: yes
 
 // dr628: na
 
-namespace dr629 { // dr629: yes
+namespace dr629 { // dr629: 2.9
   typedef int T;
   int n = 1;
   void f() {
@@ -399,7 +399,7 @@ namespace dr638 { // dr638: no
   };
 }
 
-namespace dr639 { // dr639: yes
+namespace dr639 { // dr639: 3.3
   void f(int i) {
 void((i = 0) + (i = 0)); // expected-warning {{unsequenced}}
   }
@@ -462,7 +462,7 @@ namespace dr642 { // dr642: yes
 }
 
 #if __cplusplus >= 201103L
-namespace dr643 { // dr643: yes
+namespace dr643 { // dr643: 3.2
   struct A {
 int x;
 auto f() -> decltype(this->x);
@@ -522,7 +522,7 @@ namespace dr646 { // dr646: sup 981
 #endif
 
 #if __cplusplus >= 201103L
-namespace dr647 { // dr647: yes
+namespace dr647 { // dr647: 3.1
   // This is partially superseded by dr1358.
   struct A {
 constexpr virtual void f() const;
@@ -594,7 +594,7 @@ namespace dr648 { // dr648: yes
 #endif
 
 #if __cplusplus >= 201103L
-namespace dr649 { // dr649: yes
+namespace dr649 { // dr649: 3.5
 alignas(0x2) int n;   // expected-error {{requested alignment}}1
 struct alignas(0x2) X {}; // expected-error {{requested alignment}}
 struct Y {
@@ -728,7 +728,7 @@ namespace dr657 { // dr657: partial
 // dr658 FIXME: add codegen test
 
 #if __cplusplus >= 201103L
-namespace dr659 { // dr659: yes
+namespace dr659 { // dr659: 3.0
   static_assert(alignof(char) == alignof(char&), "");
   static_assert(alignof(int) == alignof(int&), "");
   int n = alignof(int(&)()); // expected-error {{application of 'alignof' to a 
function type}}
@@ -738,7 +738,7 @@ namespace dr659 { // dr659: yes
 #endif
 
 #if __cplusplus >= 201103L
-namespace dr660 { // dr660: yes
+namespace dr660 { // dr660: 3.0
   enum : int { a };
   enum class { b }; // expected-error {{requires a name}}
   auto x = a;
@@ -779,7 +779,7 @@ namespace dr664 { // dr664: yes
 }
 #endif
 
-namespace dr665 { // dr665: yes
+namespace dr665 { // dr665: 2.8
   struct A { virtual ~A(); };
   struct B : A {} *b;
   struct C : private A {} *c; // expected-note {{here}}
@@ -799,7 +799,7 @@ namespace dr665 { // dr665: yes
   }
 }
 
-namespace dr666 { // dr666: yes
+namespace dr666 { // dr666: 2.8
   struct P { friend P operator*(P, P); P(int); } p(0);
 
   template int f();
@@ -816,7 +816,7 @@ namespace dr666 { // dr666: yes
 
 // Triviality is entirely 
diff erent in C++98.
 #if __cplusplus >= 201103L
-namespace dr667 { // dr667: yes
+namespace dr667 { // dr667: 8
   struct A {
 A() = default; // expected-warning {{explicitly defaulted default 
constructor is implicitly deleted}} expected-note{{replace 'default'}}
 int &r; // expected-note {{because field 'r' of reference type 'int &' 
would not be initialized}}
@@ -868,7 +868,7 @@ namespace dr669 { // dr669: yes
 }
 #endif
 
-namespace dr671 { // dr671: yes
+namespace dr671 { // dr671: 2.9
   enum class E { e }; // expected-error 0-1 {{C++11}}
   E e = static_cast(0);
   int n = static_cast(E::e); // expected-error 0-1 {{C++11}}
@@ -1064,7 +1064,7 @@ namespace dr685 { // dr685: yes
   int x = k(g);
 }
 
-namespace dr686 { // dr686: yes
+namespace dr686 { // dr686: 3.0
   void f() {
 (void)dynamic_cast(0); // expected-error {{incomplete}} 
expected-note {{forward}}
 (void)dynamic_cast(0); // expected-error {{cannot be defined 
in a type specifier}}
@@ -1190,7 +1190,7 @@ namespace dr692 { // dr692: 16
   }
 }
 
-namespace dr696 { // dr696: yes
+namespace dr696 { // dr696: 3.1
   void f(const int*);
   void g() {
 const int N = 10; // expected-note 1+{{here}}

diff  --git a/clang/www/cxx_dr_status.html b/clang/www/cxx_dr_s

[clang] [clang][NFC] Refactor expected directives in C++ DRs 600-699 (PR #74477)

2023-12-05 Thread Vlad Serebrennikov via cfe-commits

https://github.com/Endilll created 
https://github.com/llvm/llvm-project/pull/74477

[clang][NFC] Refactor expected directives in C++ DRs 600-699

This patch continues the work started with 
https://github.com/llvm/llvm-project/commit/ea5b1ef016d020c37f903d6c7d4f623be975dab8.
 See that commit and its corresponding PR for details.

>From 12cc446ecd55936518cb3e8b13c4840bc008d2c8 Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov 
Date: Tue, 5 Dec 2023 17:14:37 +0300
Subject: [PATCH]  [clang][NFC] Refactor expected directives in C++ DRs 600-699

This patch continues the work started with 
ea5b1ef016d020c37f903d6c7d4f623be975dab8. See that commit and its corresponding 
PR for details.
---
 clang/test/CXX/drs/dr6xx.cpp | 656 ++-
 1 file changed, 418 insertions(+), 238 deletions(-)

diff --git a/clang/test/CXX/drs/dr6xx.cpp b/clang/test/CXX/drs/dr6xx.cpp
index 4cba1f057cb27..37694e3647c63 100644
--- a/clang/test/CXX/drs/dr6xx.cpp
+++ b/clang/test/CXX/drs/dr6xx.cpp
@@ -1,22 +1,24 @@
-// RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors -fno-spell-checking
-// RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors -fno-spell-checking
-// RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors -fno-spell-checking
-// RUN: %clang_cc1 -std=c++17 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors -fno-spell-checking
-// RUN: %clang_cc1 -std=c++20 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors -fno-spell-checking
-// RUN: %clang_cc1 -std=c++23 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors -fno-spell-checking
+// RUN: %clang_cc1 -std=c++98 %s -verify=expected,cxx98-17,cxx98-14,cxx98 
-fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking
+// RUN: %clang_cc1 -std=c++11 %s 
-verify=expected,cxx98-17,cxx11-17,cxx98-14,since-cxx11,cxx11 -fexceptions 
-fcxx-exceptions -pedantic-errors -fno-spell-checking
+// RUN: %clang_cc1 -std=c++14 %s 
-verify=expected,cxx98-17,cxx11-17,cxx98-14,since-cxx11 -fexceptions 
-fcxx-exceptions -pedantic-errors -fno-spell-checking
+// RUN: %clang_cc1 -std=c++17 %s 
-verify=expected,cxx98-17,cxx11-17,since-cxx11 -fexceptions -fcxx-exceptions 
-pedantic-errors -fno-spell-checking
+// RUN: %clang_cc1 -std=c++20 %s -verify=expected,since-cxx11 -fexceptions 
-fcxx-exceptions -pedantic-errors -fno-spell-checking
+// RUN: %clang_cc1 -std=c++23 %s -verify=expected,since-cxx11 -fexceptions 
-fcxx-exceptions -pedantic-errors -fno-spell-checking
 
 namespace dr600 { // dr600: 2.8
 struct S {
   void f(int);
 
 private:
-  void f(double); // expected-note {{declared private here}}
+  void f(double); // #dr600-f-double
 };
 
 void g(S *sp) {
   sp->f(2);
   // access control is applied after overload resolution
-  sp->f(2.2); // expected-error {{is a private member}}
+  sp->f(2.2);
+  // expected-error@-1 {{'f' is a private member of 'dr600::S'}}
+  //   expected-note@#dr600-f-double {{declared private here}}
 }
 } // namespace dr600
 
@@ -41,7 +43,8 @@ namespace dr601 { // dr601: yes
 #endif
 
 #if __INT_MAX__ == 0x7FFF
-_Static_assert(0x8000 < -1, "0x8000 should be unsigned"); // 
expected-error {{C11}}
+_Static_assert(0x8000 < -1, "0x8000 should be unsigned");
+// expected-error@-1 {{'_Static_assert' is a C11 extension}}
 #endif
 
 #if MAX > 0x && 0x8000 < -1
@@ -49,7 +52,7 @@ _Static_assert(0x8000 < -1, "0x8000 should be 
unsigned"); // expected-er
 #endif
 
 #if __cplusplus >= 201103L && __LLONG_MAX__ == 0x7FFF
-static_assert(0x8000 < -1, "0x8000 should be 
unsigned"); // expected-error {{C11}}
+static_assert(0x8000 < -1, "0x8000 should be 
unsigned");
 #endif
 
 #undef MAX
@@ -74,9 +77,7 @@ namespace dr603 { // dr603: yes
   template struct S {};
   typedef S<'\001'> S1;
   typedef S<(1ul << __CHAR_BIT__) + 1> S1;
-#if __cplusplus >= 201103L
-  // expected-error@-2 {{cannot be narrowed}}
-#endif
+  // since-cxx11-error@-1 {{cannot be narrowed}}
 }
 
 // dr604: na
@@ -85,14 +86,18 @@ namespace dr603 { // dr603: yes
 namespace dr606 { // dr606: 3.0
 #if __cplusplus >= 201103L
   template struct S {};
-  template void f(S &&); // expected-note {{expects an rvalue}}
+  template void f(S &&); // #dr606-f
   template void g(T &&);
-  template void h(const T &&); // expected-note {{expects an 
rvalue}}
+  template void h(const T &&); // #dr606-h
 
   void test(S s) {
-f(s); // expected-error {{no match}}
+f(s);
+// since-cxx11-error@-1 {{no matching function for call to 'f'}}
+//   since-cxx11-note@#dr606-f {{candidate function [with T = int] not 
viable: expects an rvalue for 1st argument}}
 g(s);
-h(s); // expected-error {{no match}}
+h(s);
+// since-cxx11-error@-1 {{no matching function for call to 'h'}}
+//   since-cxx11-note@#dr606-h {{candidate function [with T = 
dr606::S] not viabl

[clang] [clang][NFC] Refactor expected directives in C++ DRs 600-699 (PR #74477)

2023-12-05 Thread Vlad Serebrennikov via cfe-commits

Endilll wrote:

This PR is created to check the patch against CI.

https://github.com/llvm/llvm-project/pull/74477
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][NFC] Refactor expected directives in C++ DRs 600-699 (PR #74477)

2023-12-05 Thread Vlad Serebrennikov via cfe-commits

https://github.com/Endilll updated 
https://github.com/llvm/llvm-project/pull/74477

>From 12cc446ecd55936518cb3e8b13c4840bc008d2c8 Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov 
Date: Tue, 5 Dec 2023 17:14:37 +0300
Subject: [PATCH 1/2]  [clang][NFC] Refactor expected directives in C++ DRs
 600-699

This patch continues the work started with 
ea5b1ef016d020c37f903d6c7d4f623be975dab8. See that commit and its corresponding 
PR for details.
---
 clang/test/CXX/drs/dr6xx.cpp | 656 ++-
 1 file changed, 418 insertions(+), 238 deletions(-)

diff --git a/clang/test/CXX/drs/dr6xx.cpp b/clang/test/CXX/drs/dr6xx.cpp
index 4cba1f057cb27..37694e3647c63 100644
--- a/clang/test/CXX/drs/dr6xx.cpp
+++ b/clang/test/CXX/drs/dr6xx.cpp
@@ -1,22 +1,24 @@
-// RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors -fno-spell-checking
-// RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors -fno-spell-checking
-// RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors -fno-spell-checking
-// RUN: %clang_cc1 -std=c++17 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors -fno-spell-checking
-// RUN: %clang_cc1 -std=c++20 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors -fno-spell-checking
-// RUN: %clang_cc1 -std=c++23 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors -fno-spell-checking
+// RUN: %clang_cc1 -std=c++98 %s -verify=expected,cxx98-17,cxx98-14,cxx98 
-fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking
+// RUN: %clang_cc1 -std=c++11 %s 
-verify=expected,cxx98-17,cxx11-17,cxx98-14,since-cxx11,cxx11 -fexceptions 
-fcxx-exceptions -pedantic-errors -fno-spell-checking
+// RUN: %clang_cc1 -std=c++14 %s 
-verify=expected,cxx98-17,cxx11-17,cxx98-14,since-cxx11 -fexceptions 
-fcxx-exceptions -pedantic-errors -fno-spell-checking
+// RUN: %clang_cc1 -std=c++17 %s 
-verify=expected,cxx98-17,cxx11-17,since-cxx11 -fexceptions -fcxx-exceptions 
-pedantic-errors -fno-spell-checking
+// RUN: %clang_cc1 -std=c++20 %s -verify=expected,since-cxx11 -fexceptions 
-fcxx-exceptions -pedantic-errors -fno-spell-checking
+// RUN: %clang_cc1 -std=c++23 %s -verify=expected,since-cxx11 -fexceptions 
-fcxx-exceptions -pedantic-errors -fno-spell-checking
 
 namespace dr600 { // dr600: 2.8
 struct S {
   void f(int);
 
 private:
-  void f(double); // expected-note {{declared private here}}
+  void f(double); // #dr600-f-double
 };
 
 void g(S *sp) {
   sp->f(2);
   // access control is applied after overload resolution
-  sp->f(2.2); // expected-error {{is a private member}}
+  sp->f(2.2);
+  // expected-error@-1 {{'f' is a private member of 'dr600::S'}}
+  //   expected-note@#dr600-f-double {{declared private here}}
 }
 } // namespace dr600
 
@@ -41,7 +43,8 @@ namespace dr601 { // dr601: yes
 #endif
 
 #if __INT_MAX__ == 0x7FFF
-_Static_assert(0x8000 < -1, "0x8000 should be unsigned"); // 
expected-error {{C11}}
+_Static_assert(0x8000 < -1, "0x8000 should be unsigned");
+// expected-error@-1 {{'_Static_assert' is a C11 extension}}
 #endif
 
 #if MAX > 0x && 0x8000 < -1
@@ -49,7 +52,7 @@ _Static_assert(0x8000 < -1, "0x8000 should be 
unsigned"); // expected-er
 #endif
 
 #if __cplusplus >= 201103L && __LLONG_MAX__ == 0x7FFF
-static_assert(0x8000 < -1, "0x8000 should be 
unsigned"); // expected-error {{C11}}
+static_assert(0x8000 < -1, "0x8000 should be 
unsigned");
 #endif
 
 #undef MAX
@@ -74,9 +77,7 @@ namespace dr603 { // dr603: yes
   template struct S {};
   typedef S<'\001'> S1;
   typedef S<(1ul << __CHAR_BIT__) + 1> S1;
-#if __cplusplus >= 201103L
-  // expected-error@-2 {{cannot be narrowed}}
-#endif
+  // since-cxx11-error@-1 {{cannot be narrowed}}
 }
 
 // dr604: na
@@ -85,14 +86,18 @@ namespace dr603 { // dr603: yes
 namespace dr606 { // dr606: 3.0
 #if __cplusplus >= 201103L
   template struct S {};
-  template void f(S &&); // expected-note {{expects an rvalue}}
+  template void f(S &&); // #dr606-f
   template void g(T &&);
-  template void h(const T &&); // expected-note {{expects an 
rvalue}}
+  template void h(const T &&); // #dr606-h
 
   void test(S s) {
-f(s); // expected-error {{no match}}
+f(s);
+// since-cxx11-error@-1 {{no matching function for call to 'f'}}
+//   since-cxx11-note@#dr606-f {{candidate function [with T = int] not 
viable: expects an rvalue for 1st argument}}
 g(s);
-h(s); // expected-error {{no match}}
+h(s);
+// since-cxx11-error@-1 {{no matching function for call to 'h'}}
+//   since-cxx11-note@#dr606-h {{candidate function [with T = 
dr606::S] not viable: expects an rvalue for 1st argument}}
 
 g(test);
 h(test); // ok, an rvalue reference can bind to a function lvalue
@@ -152,33 +157,32 @@ namespace dr613 { // dr613: yes c++11
   B &g(int);
 
   int an1 = sizeof(A::n);
+  // cxx98-e

[clang] [clang][NFC] Refactor expected directives in C++ DRs 600-699 (PR #74477)

2023-12-05 Thread Vlad Serebrennikov via cfe-commits

https://github.com/Endilll updated 
https://github.com/llvm/llvm-project/pull/74477

>From 12cc446ecd55936518cb3e8b13c4840bc008d2c8 Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov 
Date: Tue, 5 Dec 2023 17:14:37 +0300
Subject: [PATCH 1/3]  [clang][NFC] Refactor expected directives in C++ DRs
 600-699

This patch continues the work started with 
ea5b1ef016d020c37f903d6c7d4f623be975dab8. See that commit and its corresponding 
PR for details.
---
 clang/test/CXX/drs/dr6xx.cpp | 656 ++-
 1 file changed, 418 insertions(+), 238 deletions(-)

diff --git a/clang/test/CXX/drs/dr6xx.cpp b/clang/test/CXX/drs/dr6xx.cpp
index 4cba1f057cb27..37694e3647c63 100644
--- a/clang/test/CXX/drs/dr6xx.cpp
+++ b/clang/test/CXX/drs/dr6xx.cpp
@@ -1,22 +1,24 @@
-// RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors -fno-spell-checking
-// RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors -fno-spell-checking
-// RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors -fno-spell-checking
-// RUN: %clang_cc1 -std=c++17 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors -fno-spell-checking
-// RUN: %clang_cc1 -std=c++20 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors -fno-spell-checking
-// RUN: %clang_cc1 -std=c++23 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors -fno-spell-checking
+// RUN: %clang_cc1 -std=c++98 %s -verify=expected,cxx98-17,cxx98-14,cxx98 
-fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking
+// RUN: %clang_cc1 -std=c++11 %s 
-verify=expected,cxx98-17,cxx11-17,cxx98-14,since-cxx11,cxx11 -fexceptions 
-fcxx-exceptions -pedantic-errors -fno-spell-checking
+// RUN: %clang_cc1 -std=c++14 %s 
-verify=expected,cxx98-17,cxx11-17,cxx98-14,since-cxx11 -fexceptions 
-fcxx-exceptions -pedantic-errors -fno-spell-checking
+// RUN: %clang_cc1 -std=c++17 %s 
-verify=expected,cxx98-17,cxx11-17,since-cxx11 -fexceptions -fcxx-exceptions 
-pedantic-errors -fno-spell-checking
+// RUN: %clang_cc1 -std=c++20 %s -verify=expected,since-cxx11 -fexceptions 
-fcxx-exceptions -pedantic-errors -fno-spell-checking
+// RUN: %clang_cc1 -std=c++23 %s -verify=expected,since-cxx11 -fexceptions 
-fcxx-exceptions -pedantic-errors -fno-spell-checking
 
 namespace dr600 { // dr600: 2.8
 struct S {
   void f(int);
 
 private:
-  void f(double); // expected-note {{declared private here}}
+  void f(double); // #dr600-f-double
 };
 
 void g(S *sp) {
   sp->f(2);
   // access control is applied after overload resolution
-  sp->f(2.2); // expected-error {{is a private member}}
+  sp->f(2.2);
+  // expected-error@-1 {{'f' is a private member of 'dr600::S'}}
+  //   expected-note@#dr600-f-double {{declared private here}}
 }
 } // namespace dr600
 
@@ -41,7 +43,8 @@ namespace dr601 { // dr601: yes
 #endif
 
 #if __INT_MAX__ == 0x7FFF
-_Static_assert(0x8000 < -1, "0x8000 should be unsigned"); // 
expected-error {{C11}}
+_Static_assert(0x8000 < -1, "0x8000 should be unsigned");
+// expected-error@-1 {{'_Static_assert' is a C11 extension}}
 #endif
 
 #if MAX > 0x && 0x8000 < -1
@@ -49,7 +52,7 @@ _Static_assert(0x8000 < -1, "0x8000 should be 
unsigned"); // expected-er
 #endif
 
 #if __cplusplus >= 201103L && __LLONG_MAX__ == 0x7FFF
-static_assert(0x8000 < -1, "0x8000 should be 
unsigned"); // expected-error {{C11}}
+static_assert(0x8000 < -1, "0x8000 should be 
unsigned");
 #endif
 
 #undef MAX
@@ -74,9 +77,7 @@ namespace dr603 { // dr603: yes
   template struct S {};
   typedef S<'\001'> S1;
   typedef S<(1ul << __CHAR_BIT__) + 1> S1;
-#if __cplusplus >= 201103L
-  // expected-error@-2 {{cannot be narrowed}}
-#endif
+  // since-cxx11-error@-1 {{cannot be narrowed}}
 }
 
 // dr604: na
@@ -85,14 +86,18 @@ namespace dr603 { // dr603: yes
 namespace dr606 { // dr606: 3.0
 #if __cplusplus >= 201103L
   template struct S {};
-  template void f(S &&); // expected-note {{expects an rvalue}}
+  template void f(S &&); // #dr606-f
   template void g(T &&);
-  template void h(const T &&); // expected-note {{expects an 
rvalue}}
+  template void h(const T &&); // #dr606-h
 
   void test(S s) {
-f(s); // expected-error {{no match}}
+f(s);
+// since-cxx11-error@-1 {{no matching function for call to 'f'}}
+//   since-cxx11-note@#dr606-f {{candidate function [with T = int] not 
viable: expects an rvalue for 1st argument}}
 g(s);
-h(s); // expected-error {{no match}}
+h(s);
+// since-cxx11-error@-1 {{no matching function for call to 'h'}}
+//   since-cxx11-note@#dr606-h {{candidate function [with T = 
dr606::S] not viable: expects an rvalue for 1st argument}}
 
 g(test);
 h(test); // ok, an rvalue reference can bind to a function lvalue
@@ -152,33 +157,32 @@ namespace dr613 { // dr613: yes c++11
   B &g(int);
 
   int an1 = sizeof(A::n);
+  // cxx98-e

[clang] [clang][NFC] Refactor expected directives in C++ DRs 600-699 (PR #74477)

2023-12-05 Thread Vlad Serebrennikov via cfe-commits

https://github.com/Endilll closed 
https://github.com/llvm/llvm-project/pull/74477
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Move documentation about -verify from a header to public docs (PR #73694)

2023-12-06 Thread Vlad Serebrennikov via cfe-commits

Endilll wrote:

@AaronBallman After moving the docs, none of the code blocks are rendering:
https://clang.llvm.org/docs/InternalsManual.html#verifying-diagnostics

https://github.com/llvm/llvm-project/pull/73694
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Move documentation about -verify from a header to public docs (PR #73694)

2023-12-06 Thread Vlad Serebrennikov via cfe-commits

Endilll wrote:

It would also be nice to fix the link to full `-verify` docs in 
https://clang.llvm.org/docs/InternalsManual.html#the-diagnosticconsumer-interface

https://github.com/llvm/llvm-project/pull/73694
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Strict aliasing warning ala GCC [PR50066] (PR #74155)

2023-12-06 Thread Vlad Serebrennikov via cfe-commits


@@ -498,3 +498,137 @@ 
CodeGenTBAA::mergeTBAAInfoForMemoryTransfer(TBAAAccessInfo DestInfo,
   // access type regardless of their base types.
   return TBAAAccessInfo::getMayAliasInfo();
 }
+
+// Determine the aliasing kind bit-converting from type Src to type Dst.
+CodeGenTBAA::AliasingKind CodeGenTBAA::getAliasingKind(QualType &Dst,
+   QualType &Src) {
+  assert(!Src->isVoidType() && !Dst->isVoidType());
+  if (TypeHasMayAlias(Src) || TypeHasMayAlias(Dst))
+return AK_Ok;
+
+  Src = QualType{Src->getBaseElementTypeUnsafe(), 0};
+  Dst = QualType{Dst->getBaseElementTypeUnsafe(), 0};
+
+  auto *SrcDecl = Src->getAsRecordDecl();
+  auto *DstDecl = Dst->getAsRecordDecl();
+
+  const llvm::MDNode *AnyTBAA = getChar();
+  const llvm::MDNode *SrcTBAA = nullptr;
+  const llvm::MDNode *DstTBAA = nullptr;
+
+  if (!SrcDecl) {
+SrcTBAA = getTypeInfo(Src);
+if (!SrcTBAA || SrcTBAA == AnyTBAA)
+  return AK_Ok;
+  }
+  if (!DstDecl) {
+DstTBAA = getTypeInfo(Dst);
+if (!DstTBAA || DstTBAA == AnyTBAA)
+  return AK_Ok;
+  }
+
+  auto IsAncestor = [](const llvm::MDNode *Ancestor,
+   const llvm::MDNode *Descendant) {
+assert(Ancestor != Descendant && "Identical TBAA");
+while (Descendant->getNumOperands() != 1) {
+  Descendant = cast(Descendant->getOperand(1));
+  if (Descendant == Ancestor)
+return true;
+}
+return false;
+  };
+
+  assert(SrcTBAA != AnyTBAA && DstTBAA != AnyTBAA &&

Endilll wrote:

Sure, I'm not insisting.

https://github.com/llvm/llvm-project/pull/74155
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Strict aliasing warning ala GCC [PR50066] (PR #74155)

2023-12-06 Thread Vlad Serebrennikov via cfe-commits


@@ -37,6 +38,27 @@ class ASTConsumer {
 
   friend class SemaConsumer;
 
+public:
+  /// Allow type-based aliasing information to be interrogated by the AST
+  /// producer (for diagnostics).
+  class TypeAliasing {

Endilll wrote:

Sorry I didn't make myself clear enough. I thought that `TypeAliasing` exists 
for the sole purpose of providing a scope for unscoped enumeration, so my idea 
was that this whole class can be replaces with a scoped enum.

https://github.com/llvm/llvm-project/pull/74155
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Strict aliasing warning ala GCC [PR50066] (PR #74155)

2023-12-06 Thread Vlad Serebrennikov via cfe-commits


@@ -498,3 +498,137 @@ 
CodeGenTBAA::mergeTBAAInfoForMemoryTransfer(TBAAAccessInfo DestInfo,
   // access type regardless of their base types.
   return TBAAAccessInfo::getMayAliasInfo();
 }
+
+// Determine the aliasing kind bit-converting from type Src to type Dst.
+CodeGenTBAA::AliasingKind CodeGenTBAA::getAliasingKind(QualType &Dst,
+   QualType &Src) {
+  assert(!Src->isVoidType() && !Dst->isVoidType());
+  if (TypeHasMayAlias(Src) || TypeHasMayAlias(Dst))
+return AK_Ok;
+
+  Src = QualType{Src->getBaseElementTypeUnsafe(), 0};
+  Dst = QualType{Dst->getBaseElementTypeUnsafe(), 0};
+
+  auto *SrcDecl = Src->getAsRecordDecl();
+  auto *DstDecl = Dst->getAsRecordDecl();
+
+  const llvm::MDNode *AnyTBAA = getChar();
+  const llvm::MDNode *SrcTBAA = nullptr;
+  const llvm::MDNode *DstTBAA = nullptr;
+
+  if (!SrcDecl) {
+SrcTBAA = getTypeInfo(Src);
+if (!SrcTBAA || SrcTBAA == AnyTBAA)

Endilll wrote:

Are you sure `signed char` is allowed to alias everything, like `char` and 
`unsigned char`? It's not there in the strict aliasing rule.

https://github.com/llvm/llvm-project/pull/74155
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] c79f94d - [clang][NFC] Fill in historical data on when C++ DRs 700-1999 were fixed

2023-12-07 Thread Vlad Serebrennikov via cfe-commits

Author: Vlad Serebrennikov
Date: 2023-12-08T00:38:42+03:00
New Revision: c79f94d85121347d28f894d837f173f90f368e92

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

LOG: [clang][NFC] Fill in historical data on when C++ DRs 700-1999 were fixed

Added: 


Modified: 
clang/test/CXX/drs/dr11xx.cpp
clang/test/CXX/drs/dr12xx.cpp
clang/test/CXX/drs/dr13xx.cpp
clang/test/CXX/drs/dr14xx.cpp
clang/test/CXX/drs/dr15xx.cpp
clang/test/CXX/drs/dr16xx.cpp
clang/test/CXX/drs/dr18xx.cpp
clang/test/CXX/drs/dr19xx.cpp
clang/test/CXX/drs/dr25xx.cpp
clang/test/CXX/drs/dr412.cpp
clang/test/CXX/drs/dr8xx.cpp
clang/test/CXX/drs/dr9xx.cpp
clang/www/cxx_dr_status.html

Removed: 




diff  --git a/clang/test/CXX/drs/dr11xx.cpp b/clang/test/CXX/drs/dr11xx.cpp
index 23756ff1927ec..2e35535a18c4a 100644
--- a/clang/test/CXX/drs/dr11xx.cpp
+++ b/clang/test/CXX/drs/dr11xx.cpp
@@ -4,7 +4,7 @@
 // RUN: %clang_cc1 -std=c++17 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors
 // RUN: %clang_cc1 -std=c++2a %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors
 
-namespace dr { // dr: yes
+namespace dr { // dr: 3.2
 namespace example1 {
 template  struct set;
 

diff  --git a/clang/test/CXX/drs/dr12xx.cpp b/clang/test/CXX/drs/dr12xx.cpp
index c23a515ba56cb..339712be45b38 100644
--- a/clang/test/CXX/drs/dr12xx.cpp
+++ b/clang/test/CXX/drs/dr12xx.cpp
@@ -81,7 +81,7 @@ void g() {
 #endif
 
 #if __cplusplus >= 201103L
-namespace dr1227 { // dr1227: yes
+namespace dr1227 { // dr1227: 3.0
 template  struct A { using X = typename T::X; }; // expected-error 
{{type 'int' cannot be used prior to '::' because it has no members}}
 template  typename T::X f(typename A::X);
 template  void f(...) { }

diff  --git a/clang/test/CXX/drs/dr13xx.cpp b/clang/test/CXX/drs/dr13xx.cpp
index 3510695954e27..abee100961602 100644
--- a/clang/test/CXX/drs/dr13xx.cpp
+++ b/clang/test/CXX/drs/dr13xx.cpp
@@ -14,7 +14,7 @@ namespace std {
 }
 
 #if __cplusplus >= 201103L
-namespace dr1305 { // dr1305: yes
+namespace dr1305 { // dr1305: 3.0
 struct Incomplete; // expected-note {{forward declaration of 
'dr1305::Incomplete'}}
 struct Complete {};
 
@@ -297,7 +297,7 @@ namespace dr1346 { // dr1346: 3.5
 #endif
 }
 
-namespace dr1347 { // dr1347: yes
+namespace dr1347 { // dr1347: 3.1
   auto x = 5, *y = &x; // expected-error 0-1{{extension}}
   auto z = y, *q = y; // expected-error {{'auto' deduced as 'int *' in 
declaration of 'z' and deduced as 'int' in declaration of 'q'}} expected-error 
0-1{{extension}}
 #if __cplusplus >= 201103L
@@ -306,7 +306,7 @@ namespace dr1347 { // dr1347: yes
 #endif
 }
 
-namespace dr1358 { // dr1358: yes
+namespace dr1358 { // dr1358: 3.1
 #if __cplusplus >= 201103L
   struct Lit { constexpr operator int() const { return 0; } };
   struct NonLit { NonLit(); operator int(); }; // expected-note 2{{no 
constexpr constructors}}

diff  --git a/clang/test/CXX/drs/dr14xx.cpp b/clang/test/CXX/drs/dr14xx.cpp
index ea41a03d3587a..7dd7da95d034d 100644
--- a/clang/test/CXX/drs/dr14xx.cpp
+++ b/clang/test/CXX/drs/dr14xx.cpp
@@ -484,11 +484,11 @@ namespace dr1467 {  // dr1467: 3.7 c++11
 #endif
 } // dr1467
 
-namespace dr1479 { // dr1479: yes
+namespace dr1479 { // dr1479: 3.1
   int operator"" _a(const char*, std::size_t = 0); // expected-error {{literal 
operator cannot have a default argument}}
 }
 
-namespace dr1482 { // dr1482: yes
+namespace dr1482 { // dr1482: 3.0
// NB: sup 2516, test reused there
 #if __cplusplus >= 201103L
 template  struct S {

diff  --git a/clang/test/CXX/drs/dr15xx.cpp b/clang/test/CXX/drs/dr15xx.cpp
index c588891a75d6a..a53b14694998b 100644
--- a/clang/test/CXX/drs/dr15xx.cpp
+++ b/clang/test/CXX/drs/dr15xx.cpp
@@ -233,7 +233,7 @@ namespace std_example {
 #endif  // __cplusplus >= 201103L
 }
 
-namespace dr1550 { // dr1550: yes
+namespace dr1550 { // dr1550: 3.4
   int f(bool b, int n) {
 return (b ? (throw 0) : n) + (b ? n : (throw 0));
   }

diff  --git a/clang/test/CXX/drs/dr16xx.cpp b/clang/test/CXX/drs/dr16xx.cpp
index 463353dab3b16..cbf0b487ba155 100644
--- a/clang/test/CXX/drs/dr16xx.cpp
+++ b/clang/test/CXX/drs/dr16xx.cpp
@@ -68,7 +68,7 @@ namespace dr1631 {  // dr1631: 3.7
 #endif
 }
 
-namespace dr1638 { // dr1638: yes
+namespace dr1638 { // dr1638: 3.1
 #if __cplusplus >= 201103L
   template struct A {
 enum class E; // expected-note {{previous}}

diff  --git a/clang/test/CXX/drs/dr18xx.cpp b/clang/test/CXX/drs/dr18xx.cpp
index 7ac2673738228..49c1167220875 100644
--- a/clang/test/CXX/drs/dr18xx.cpp
+++ b/clang/test/CXX/drs/dr18xx.cpp
@@ -62,7 +62,7 @@ namespace dr1815 { // dr1815: no
 #endif
 }
 
-namespace dr1821 { // dr1821: yes
+namespace dr1821 { // dr1821: 2.9
 

[clang] [clang][NFC] Refactor expected directives in C++ DRs 700-1999 (PR #74767)

2023-12-07 Thread Vlad Serebrennikov via cfe-commits

Endilll wrote:

This PR is created to check the patch against CI.

https://github.com/llvm/llvm-project/pull/74767
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][NFC] Refactor expected directives in C++ DRs 700-1999 (PR #74767)

2023-12-08 Thread Vlad Serebrennikov via cfe-commits

https://github.com/Endilll closed 
https://github.com/llvm/llvm-project/pull/74767
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 57eb205 - [clang][NFC] Fill in historical data on when C++ DRs 2000-2799 were fixed

2023-12-09 Thread Vlad Serebrennikov via cfe-commits

Author: Vlad Serebrennikov
Date: 2023-12-09T11:12:54+03:00
New Revision: 57eb2054e308da7fb394375dedf8d7b627d1b528

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

LOG: [clang][NFC] Fill in historical data on when C++ DRs 2000-2799 were fixed

Added: 


Modified: 
clang/test/CXX/drs/dr2390.cpp
clang/test/CXX/drs/dr2406.cpp
clang/test/CXX/drs/dr26xx.cpp
clang/www/cxx_dr_status.html

Removed: 




diff  --git a/clang/test/CXX/drs/dr2390.cpp b/clang/test/CXX/drs/dr2390.cpp
index d8ab1e9a1b3853..3931365b568ceb 100644
--- a/clang/test/CXX/drs/dr2390.cpp
+++ b/clang/test/CXX/drs/dr2390.cpp
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -E -P %s -o - | FileCheck %s
 
-// dr2390: yes
+// dr2390: 14
 
 namespace PR48462 {
 // Test that macro expansion of the builtin argument works.

diff  --git a/clang/test/CXX/drs/dr2406.cpp b/clang/test/CXX/drs/dr2406.cpp
index 7ea0870fb70b38..0ab198e6f1498e 100644
--- a/clang/test/CXX/drs/dr2406.cpp
+++ b/clang/test/CXX/drs/dr2406.cpp
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -x c++ %s  -verify
 
-// dr2406: yes
+// dr2406: 5
 
 void fallthrough(int n) {
   void g(), h(), i();

diff  --git a/clang/test/CXX/drs/dr26xx.cpp b/clang/test/CXX/drs/dr26xx.cpp
index 8517cd5872b183..1d702e66bf8c7f 100644
--- a/clang/test/CXX/drs/dr26xx.cpp
+++ b/clang/test/CXX/drs/dr26xx.cpp
@@ -2,7 +2,7 @@
 // RUN: %clang_cc1 -std=c++2b -triple x86_64-unknown-unknown %s -verify
 
 
-namespace dr2621 { // dr2621: yes
+namespace dr2621 { // dr2621: 16
 enum class E { a };
 namespace One {
 using E_t = E;
@@ -101,7 +101,7 @@ int y = dr2640_a\N{LOTUS}); // expected-error {{character 
 not allowed
 
   // dr2642: na
 
-namespace dr2644 { // dr2644: yes
+namespace dr2644 { // dr2644: 8
 
 auto z = [a = 42](int a) { // expected-error {{a lambda parameter cannot 
shadow an explicitly captured entity}} \
// expected-note {{variable 'a' is explicitly 
captured here}}
@@ -111,7 +111,7 @@ auto z = [a = 42](int a) { // expected-error {{a lambda 
parameter cannot shadow
 }
 
 #if __cplusplus >= 202302L
-namespace dr2650 { // dr2650: yes
+namespace dr2650 { // dr2650: 17
 template  struct S {};
 template  int f(S*); // expected-note {{type 'X' of non-type 
template parameter is not a structural type}}
 class X {

diff  --git a/clang/www/cxx_dr_status.html b/clang/www/cxx_dr_status.html
index 3f519ff06742fd..d09cf616899ad4 100755
--- a/clang/www/cxx_dr_status.html
+++ b/clang/www/cxx_dr_status.html
@@ -14147,7 +14147,7 @@ C++ defect report implementation 
status
 https://cplusplus.github.io/CWG/issues/2390.html";>2390
 CD5
 Is the argument of __has_cpp_attribute macro-expanded?
-Yes
+Clang 14
   
   
 https://cplusplus.github.io/CWG/issues/2391.html";>2391
@@ -14243,7 +14243,7 @@ C++ defect report implementation 
status
 https://cplusplus.github.io/CWG/issues/2406.html";>2406
 CD5
 [[fallthrough]] attribute and iteration statements
-Yes
+Clang 5
   
   
 https://cplusplus.github.io/CWG/issues/2407.html";>2407
@@ -15533,7 +15533,7 @@ C++ defect report implementation 
status
 https://cplusplus.github.io/CWG/issues/2621.html";>2621
 C++23
 Kind of lookup for using enum declarations
-Yes
+Clang 16
   
   
 https://cplusplus.github.io/CWG/issues/2622.html";>2622
@@ -15671,7 +15671,7 @@ C++ defect report implementation 
status
 https://cplusplus.github.io/CWG/issues/2644.html";>2644
 C++23
 Incorrect comment in example
-Yes
+Clang 8
   
   
 https://cplusplus.github.io/CWG/issues/2645.html";>2645
@@ -15707,7 +15707,7 @@ C++ defect report implementation 
status
 https://cplusplus.github.io/CWG/issues/2650.html";>2650
 C++23
 Incorrect example for ill-formed non-type template arguments
-Yes
+Clang 17
   
   
 https://cplusplus.github.io/CWG/issues/2651.html";>2651



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


[clang] [clang][NFC] Refactor expected directives in C++ DRs 2000-2799 (PR #74921)

2023-12-09 Thread Vlad Serebrennikov via cfe-commits

https://github.com/Endilll created 
https://github.com/llvm/llvm-project/pull/74921

This patch continues the work started with 
ea5b1ef016d020c37f903d6c7d4f623be975dab8. See that commit and its corresponding 
PR for details.

>From 436502773b1720e0511f4371c7a04079e7d38215 Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov 
Date: Sat, 9 Dec 2023 11:12:19 +0300
Subject: [PATCH] [clang][NFC] Refactor expected directives in C++ DRs
 2000-2799

This patch continues the work started with 
ea5b1ef016d020c37f903d6c7d4f623be975dab8. See that commit and its corresponding 
PR for details.
---
 clang/test/CXX/drs/dr20xx.cpp | 219 +-
 clang/test/CXX/drs/dr21xx.cpp | 141 ++
 clang/test/CXX/drs/dr22xx.cpp |  37 +++---
 clang/test/CXX/drs/dr2354.cpp |  10 --
 clang/test/CXX/drs/dr23xx.cpp |  57 ++---
 clang/test/CXX/drs/dr2406.cpp |  30 -
 clang/test/CXX/drs/dr24xx.cpp |  51 +++-
 clang/test/CXX/drs/dr25xx.cpp | 106 
 clang/test/CXX/drs/dr26xx.cpp | 121 ---
 clang/test/CXX/drs/dr27xx.cpp |  25 +++-
 10 files changed, 499 insertions(+), 298 deletions(-)
 delete mode 100644 clang/test/CXX/drs/dr2354.cpp
 delete mode 100644 clang/test/CXX/drs/dr2406.cpp

diff --git a/clang/test/CXX/drs/dr20xx.cpp b/clang/test/CXX/drs/dr20xx.cpp
index 4f81b0b413d4bd..60ee7684440f54 100644
--- a/clang/test/CXX/drs/dr20xx.cpp
+++ b/clang/test/CXX/drs/dr20xx.cpp
@@ -1,13 +1,14 @@
-// RUN: %clang_cc1 -std=c++98 -triple x86_64-unknown-unknown %s -verify 
-fexceptions -fcxx-exceptions -pedantic-errors \
-// RUN:-Wno-variadic-macros -Wno-c11-extensions
-// RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown %s -verify 
-fexceptions -fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s -verify 
-fexceptions -fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-unknown %s -verify 
-fexceptions -fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-unknown %s -verify 
-fexceptions -fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++23 -triple x86_64-unknown-unknown %s -verify 
-fexceptions -fcxx-exceptions -pedantic-errors
-
-#if __cplusplus < 201103L
-#define static_assert(...) _Static_assert(__VA_ARGS__)
+// RUN: %clang_cc1 -std=c++98 -triple x86_64-unknown-unknown %s 
-verify=expected,cxx98 -fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown %s 
-verify=expected,since-cxx11,cxx11 -fexceptions -fcxx-exceptions 
-pedantic-errors
+// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s 
-verify=expected,since-cxx11,since-cxx14 -fexceptions -fcxx-exceptions 
-pedantic-errors
+// RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-unknown %s 
-verify=expected,since-cxx11,since-cxx14 -fexceptions -fcxx-exceptions 
-pedantic-errors
+// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-unknown %s 
-verify=expected,since-cxx11,since-cxx14,since-cxx20 -fexceptions 
-fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++23 -triple x86_64-unknown-unknown %s 
-verify=expected,since-cxx11,since-cxx14,since-cxx20 -fexceptions 
-fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++2c -triple x86_64-unknown-unknown %s 
-verify=expected,since-cxx11,since-cxx14,since-cxx20 -fexceptions 
-fcxx-exceptions -pedantic-errors
+
+#if __cplusplus == 199711L
+#define static_assert(...) __extension__ _Static_assert(__VA_ARGS__)
+// cxx98-error@-1 {{variadic macros are a C99 feature}}
 #endif
 
 namespace dr2007 { // dr2007: 3.4
@@ -15,8 +16,12 @@ template struct A { typename T::error e; };
 template struct B { };
 B > b1;
 B > b2 = b1;
-int a = b2[0]; // expected-error {{does not provide a subscript operator}}
-int b = __builtin_addressof(b2)->foo; // expected-error {{no member}}
+int a = b2[0];
+// cxx98-error@-1 {{type 'B >' does not provide a subscript operator}}
+// since-cxx11-error@-2 {{type 'B>' does not provide a subscript 
operator}}
+int b = __builtin_addressof(b2)->foo;
+// cxx98-error@-1 {{no member named 'foo' in 'dr2007::B >'}}
+// since-cxx11-error@-2 {{no member named 'foo' in 
'dr2007::B>'}}
 }
 
 // dr2009: na
@@ -24,45 +29,69 @@ int b = __builtin_addressof(b2)->foo; // expected-error 
{{no member}}
 namespace dr2026 { // dr2026: 11
   template struct X {};
 
-  const int a = a + 1; // expected-warning {{uninitialized}} expected-note 
{{here}} expected-note 0-1{{outside its lifetime}}
-  X xa; // expected-error {{constant expression}} expected-note 
{{initializer of 'a'}}
+  const int a = a + 1; // #dr2026-a
+  // expected-warning@-1 {{variable 'a' is uninitialized when used within its 
own initialization}}
+  X xa; // #dr2026-xa
+  // cxx98-error@-1 {{non-type template argument of type 'int' is not an 
integral constant expression}}
+  //   cxx98-note@-2 {{initializer of 'a' is not a constant expression}}
+  //   cxx98-note@#dr2026-a {{declared here}

[clang] [clang][NFC] Refactor expected directives in C++ DRs 2000-2799 (PR #74921)

2023-12-09 Thread Vlad Serebrennikov via cfe-commits

Endilll wrote:

This PR is created to check the patch against CI.

https://github.com/llvm/llvm-project/pull/74921
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Adjust TargetInfo bitfield (PR #74893)

2023-12-09 Thread Vlad Serebrennikov via cfe-commits

Endilll wrote:

Yeah, I shouldn't have annotated this bit-field. Nice catch!

https://github.com/llvm/llvm-project/pull/74893
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Adjust TargetInfo bitfield (PR #74893)

2023-12-09 Thread Vlad Serebrennikov via cfe-commits

https://github.com/Endilll approved this pull request.


https://github.com/llvm/llvm-project/pull/74893
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][NFC] Refactor expected directives in C++ DRs 2000-2799 (PR #74921)

2023-12-09 Thread Vlad Serebrennikov via cfe-commits

https://github.com/Endilll closed 
https://github.com/llvm/llvm-project/pull/74921
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-cl] Add support for [[msvc::constexpr]] C++11 attribute (PR #71300)

2023-12-09 Thread Vlad Serebrennikov via cfe-commits

https://github.com/Endilll closed 
https://github.com/llvm/llvm-project/pull/71300
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-cl] Add support for [[msvc::constexpr]] C++11 attribute (PR #71300)

2023-12-09 Thread Vlad Serebrennikov via cfe-commits


@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -fms-compatibility -fms-compatibility-version=19.33 
-std=c++20 -verify=supported %s

Endilll wrote:

Judging by the failure 
https://lab.llvm.org/buildbot/#/builders/60/builds/15037, you might want to 
test for specific triples.

https://github.com/llvm/llvm-project/pull/71300
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-cl] Add support for [[msvc::constexpr]] C++11 attribute (PR #71300)

2023-12-09 Thread Vlad Serebrennikov via cfe-commits

https://github.com/Endilll edited 
https://github.com/llvm/llvm-project/pull/71300
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-cl] Add support for [[msvc::constexpr]] C++11 attribute (PR #71300)

2023-12-09 Thread Vlad Serebrennikov via cfe-commits

https://github.com/Endilll commented:

Some bots are not happy with one of the tests. I contacted you on Discord about 
your next steps.

I'll have to revert the patch if I won't hear from you soon.

https://github.com/llvm/llvm-project/pull/71300
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Fix '__cdecl' CC is not supported for this target (PR #74932)

2023-12-09 Thread Vlad Serebrennikov via cfe-commits

https://github.com/Endilll approved this pull request.

LGTM, but let's wait for CI to pass.

https://github.com/llvm/llvm-project/pull/74932
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Fix '__cdecl' CC is not supported for this target (PR #74932)

2023-12-09 Thread Vlad Serebrennikov via cfe-commits

https://github.com/Endilll closed 
https://github.com/llvm/llvm-project/pull/74932
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[llvm] [clang] [mlir] [libcxx] [llvm][Support] Enable `TimeTraceProfiler` to accept deferred detail string (PR #74935)

2023-12-09 Thread Vlad Serebrennikov via cfe-commits

https://github.com/Endilll updated 
https://github.com/llvm/llvm-project/pull/74935

>From 4e8f48947d59474e07e08cdc98e4a6fb2e3c80c1 Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov 
Date: Sat, 9 Dec 2023 17:21:35 +0300
Subject: [PATCH 1/2] [llvm][Support] Enable `TimeTraceProfiler` to accept
 deferred detail string

This patch enables `TimeTraceProfiler` and `TimeTraceScope` to accept detail 
string, which is not yet available at the time new trace entry is created. This 
is important for Clang parser use cases, e.g. when parsing a class member we 
don't yet know name of.
---
 llvm/include/llvm/Support/TimeProfiler.h | 35 
 llvm/lib/Support/TimeProfiler.cpp| 34 +++
 2 files changed, 52 insertions(+), 17 deletions(-)

diff --git a/llvm/include/llvm/Support/TimeProfiler.h 
b/llvm/include/llvm/Support/TimeProfiler.h
index 454a65f70231f..5b8af16ed4a9a 100644
--- a/llvm/include/llvm/Support/TimeProfiler.h
+++ b/llvm/include/llvm/Support/TimeProfiler.h
@@ -86,6 +86,8 @@ class raw_pwrite_stream;
 struct TimeTraceProfiler;
 TimeTraceProfiler *getTimeTraceProfilerInstance();
 
+struct TimeTraceProfilerEntry;
+
 /// Initialize the time trace profiler.
 /// This sets up the global \p TimeTraceProfilerInstance
 /// variable to be the profiler instance.
@@ -120,18 +122,29 @@ Error timeTraceProfilerWrite(StringRef PreferredFileName,
 /// Profiler copies the string data, so the pointers can be given into
 /// temporaries. Time sections can be hierarchical; every Begin must have a
 /// matching End pair but they can nest.
-void timeTraceProfilerBegin(StringRef Name, StringRef Detail);
-void timeTraceProfilerBegin(StringRef Name,
+TimeTraceProfilerEntry* timeTraceProfilerBegin(StringRef Name, StringRef 
Detail);
+TimeTraceProfilerEntry* timeTraceProfilerBegin(StringRef Name,
 llvm::function_ref Detail);
 
 /// Manually end the last time section.
 void timeTraceProfilerEnd();
 
+/// Set detail string for an existing trace entry.
+/// This function sets \p Detail string for an entry previously created by
+/// `timeTraceProfilerBegin`. String is handled in the same way as
+/// `timeTraceProfilerBegin` does. This is useful when contents of
+/// \p Detail is not (fully) known at the time trace entry is created.
+void timeTraceProfilerEntrySetDetail(TimeTraceProfilerEntry* Entry, StringRef 
Detail);
+void timeTraceProfilerEntrySetDetail(TimeTraceProfilerEntry* Entry, 
llvm::function_ref Detail);
+
 /// The TimeTraceScope is a helper class to call the begin and end functions
 /// of the time trace profiler.  When the object is constructed, it begins
 /// the section; and when it is destroyed, it stops it. If the time profiler
 /// is not initialized, the overhead is a single branch.
-struct TimeTraceScope {
+class TimeTraceScope {
+  TimeTraceProfilerEntry* Entry;
+
+public:
 
   TimeTraceScope() = delete;
   TimeTraceScope(const TimeTraceScope &) = delete;
@@ -141,20 +154,30 @@ struct TimeTraceScope {
 
   TimeTraceScope(StringRef Name) {
 if (getTimeTraceProfilerInstance() != nullptr)
-  timeTraceProfilerBegin(Name, StringRef(""));
+  Entry = timeTraceProfilerBegin(Name, StringRef(""));
   }
   TimeTraceScope(StringRef Name, StringRef Detail) {
 if (getTimeTraceProfilerInstance() != nullptr)
-  timeTraceProfilerBegin(Name, Detail);
+  Entry = timeTraceProfilerBegin(Name, Detail);
   }
   TimeTraceScope(StringRef Name, llvm::function_ref Detail) {
 if (getTimeTraceProfilerInstance() != nullptr)
-  timeTraceProfilerBegin(Name, Detail);
+  Entry = timeTraceProfilerBegin(Name, Detail);
   }
   ~TimeTraceScope() {
 if (getTimeTraceProfilerInstance() != nullptr)
   timeTraceProfilerEnd();
   }
+  void setDetail(StringRef Detail) {
+if (Entry != nullptr) {
+  timeTraceProfilerEntrySetDetail(Entry, Detail);
+}
+  }
+  void setDetail(llvm::function_ref Detail) {
+if (Entry != nullptr) {
+  timeTraceProfilerEntrySetDetail(Entry, Detail);
+}
+  }
 };
 
 } // end namespace llvm
diff --git a/llvm/lib/Support/TimeProfiler.cpp 
b/llvm/lib/Support/TimeProfiler.cpp
index 4d625b3eb5b17..bd8a04ed8962d 100644
--- a/llvm/lib/Support/TimeProfiler.cpp
+++ b/llvm/lib/Support/TimeProfiler.cpp
@@ -64,12 +64,14 @@ using CountAndDurationType = std::pair;
 using NameAndCountAndDurationType =
 std::pair;
 
+} // anonymous namespace
+
 /// Represents an open or completed time section entry to be captured.
-struct TimeTraceProfilerEntry {
+struct llvm::TimeTraceProfilerEntry {
   const TimePointType Start;
   TimePointType End;
   const std::string Name;
-  const std::string Detail;
+  std::string Detail;
 
   TimeTraceProfilerEntry(TimePointType &&S, TimePointType &&E, std::string &&N,
  std::string &&Dt)
@@ -92,8 +94,6 @@ struct TimeTraceProfilerEntry {
   }
 };
 
-} // anonymous namespace
-
 struct llvm::TimeTraceProfiler {
   TimeTraceProfiler(unsigned TimeTraceGranularity = 0, St

[mlir] [llvm] [libcxx] [clang] [llvm][Support] Enable `TimeTraceProfiler` to accept deferred detail string (PR #74935)

2023-12-09 Thread Vlad Serebrennikov via cfe-commits

https://github.com/Endilll converted_to_draft 
https://github.com/llvm/llvm-project/pull/74935
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Refactor `IdentifierInfo::ObjcOrBuiltinID` (PR #71709)

2023-11-16 Thread Vlad Serebrennikov via cfe-commits

https://github.com/Endilll updated 
https://github.com/llvm/llvm-project/pull/71709

>From 2823d38544d18213b5bf48c67e4eedd52acce850 Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov 
Date: Wed, 8 Nov 2023 20:30:37 +0300
Subject: [PATCH 1/2] [clang] Refactor `IdentifierInfo::ObjcOrBuiltinID`

This patch refactors how values are stored inside 
`IdentifierInfo::ObjcOrBuiltinID` bit-field, and annotates it with 
`preferred_type`. In order to make the value easier to interpret by debuggers, 
a new `ObjCKeywordOrInterestingOrBuiltin` is added. Previous "layout" of this 
fields couldn't be represented with this new enum, because it skipped over some 
arbitrary enumerators, so a new "layout" was invented based on 
`ObjCKeywordOrInterestingOrBuiltin` enum. I believe the new layout is simpler 
than the new one.
---
 clang/include/clang/Basic/IdentifierTable.h | 117 
 1 file changed, 73 insertions(+), 44 deletions(-)

diff --git a/clang/include/clang/Basic/IdentifierTable.h 
b/clang/include/clang/Basic/IdentifierTable.h
index 0898e7d39dd7dee..fa76228da2b143a 100644
--- a/clang/include/clang/Basic/IdentifierTable.h
+++ b/clang/include/clang/Basic/IdentifierTable.h
@@ -15,6 +15,7 @@
 #ifndef LLVM_CLANG_BASIC_IDENTIFIERTABLE_H
 #define LLVM_CLANG_BASIC_IDENTIFIERTABLE_H
 
+#include "clang/Basic/Builtins.h"
 #include "clang/Basic/DiagnosticIDs.h"
 #include "clang/Basic/LLVM.h"
 #include "clang/Basic/TokenKinds.h"
@@ -86,19 +87,26 @@ enum { IdentifierInfoAlignment = 8 };
 static constexpr int ObjCOrBuiltinIDBits = 16;
 
 /// The "layout" of ObjCOrBuiltinID is:
-///  - The first value (0) represents "not a special identifier".
-///  - The next (NUM_OBJC_KEYWORDS - 1) values represent ObjCKeywordKinds (not
-///including objc_not_keyword).
-///  - The next (NUM_INTERESTING_IDENTIFIERS - 1) values represent
-///InterestingIdentifierKinds (not including not_interesting).
-///  - The rest of the values represent builtin IDs (not including NotBuiltin).
-static constexpr int FirstObjCKeywordID = 1;
-static constexpr int LastObjCKeywordID =
-FirstObjCKeywordID + tok::NUM_OBJC_KEYWORDS - 2;
-static constexpr int FirstInterestingIdentifierID = LastObjCKeywordID + 1;
-static constexpr int LastInterestingIdentifierID =
-FirstInterestingIdentifierID + tok::NUM_INTERESTING_IDENTIFIERS - 2;
-static constexpr int FirstBuiltinID = LastInterestingIdentifierID + 1;
+///  - ObjCKeywordKind enumerators
+///  - InterestingIdentifierKind enumerators
+///  - Builtin::ID enumerators
+///  - NonSpecialIdentifier
+enum class ObjCKeywordOrInterestingOrBuiltin {
+#define OBJC_AT_KEYWORD(X) objc_##X,
+#include "clang/Basic/TokenKinds.def"
+  NUM_OBJC_KEYWORDS,
+
+#define INTERESTING_IDENTIFIER(X) X,
+#include "clang/Basic/TokenKinds.def"
+  NUM_OBJC_KEYWORDS_AND_INTERESTING_IDENTIFIERS,
+
+  NotBuiltin,
+#define BUILTIN(ID, TYPE, ATTRS) BI##ID,
+#include "clang/Basic/Builtins.def"
+  FirstTSBuiltin,
+
+  NonSpecialIdentifier = 65534
+};
 
 /// One of these records is kept for each identifier that
 /// is lexed.  This contains information about whether the token was 
\#define'd,
@@ -113,9 +121,7 @@ class alignas(IdentifierInfoAlignment) IdentifierInfo {
   LLVM_PREFERRED_TYPE(tok::TokenKind)
   unsigned TokenID : 9;
 
-  // ObjC keyword ('protocol' in '@protocol') or builtin (__builtin_inf).
-  // First NUM_OBJC_KEYWORDS values are for Objective-C,
-  // the remaining values are for builtins.
+  LLVM_PREFERRED_TYPE(ObjCKeywordOrInterestingOrBuiltin)
   unsigned ObjCOrBuiltinID : ObjCOrBuiltinIDBits;
 
   // True if there is a #define for this.
@@ -198,13 +204,16 @@ class alignas(IdentifierInfoAlignment) IdentifierInfo {
   llvm::StringMapEntry *Entry = nullptr;
 
   IdentifierInfo()
-  : TokenID(tok::identifier), ObjCOrBuiltinID(0), HasMacro(false),
-HadMacro(false), IsExtension(false), IsFutureCompatKeyword(false),
-IsPoisoned(false), IsCPPOperatorKeyword(false),
-NeedsHandleIdentifier(false), IsFromAST(false), 
ChangedAfterLoad(false),
-FEChangedAfterLoad(false), RevertedTokenID(false), OutOfDate(false),
-IsModulesImport(false), IsMangledOpenMPVariantName(false),
-IsDeprecatedMacro(false), IsRestrictExpansion(false), IsFinal(false) {}
+  : TokenID(tok::identifier),
+ObjCOrBuiltinID(llvm::to_underlying(
+ObjCKeywordOrInterestingOrBuiltin::NonSpecialIdentifier)),
+HasMacro(false), HadMacro(false), IsExtension(false),
+IsFutureCompatKeyword(false), IsPoisoned(false),
+IsCPPOperatorKeyword(false), NeedsHandleIdentifier(false),
+IsFromAST(false), ChangedAfterLoad(false), FEChangedAfterLoad(false),
+RevertedTokenID(false), OutOfDate(false), IsModulesImport(false),
+IsMangledOpenMPVariantName(false), IsDeprecatedMacro(false),
+IsRestrictExpansion(false), IsFinal(false) {}
 
 public:
   IdentifierInfo(const IdentifierInfo &) = delete;
@@ -332,42 +341,62 @@ class alignas(IdentifierInfoAlignment

[clang] [clang] Refactor `IdentifierInfo::ObjcOrBuiltinID` (PR #71709)

2023-11-16 Thread Vlad Serebrennikov via cfe-commits

Endilll wrote:

Finally got past previous test failures. But the following tests started to 
fail:
```
  Clang :: AST/HLSL/pch.hlsl
  Clang :: PCH/__va_list_tag-typedef.c
  Clang :: PCH/builtin-is-constant-evaluated.cpp
  Clang-Unit :: Lex/./LexTests/failed_to_discover_tests_from_gtest
```
Here is full test output (don't mind `LibClang/symbols.test`, that's my local 
failure):
https://gist.github.com/Endilll/5d63e138b59af121067d30c77752c437

https://github.com/llvm/llvm-project/pull/71709
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Fix to attribute plugins reaching an unreachable (PR #70877)

2023-11-16 Thread Vlad Serebrennikov via cfe-commits

Endilll wrote:

This was fixed by e11148fda6d8c0eec496463adb46fd6f03a91081
I checked the logs, and exactly the part that this commit fixed is failing.

https://github.com/llvm/llvm-project/pull/70877
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Fix to attribute plugins reaching an unreachable (PR #70877)

2023-11-16 Thread Vlad Serebrennikov via cfe-commits

Endilll wrote:

> https://github.com/amykhuang/llvm-project/tree/attr-plugin
> This branch is [2 commits 
> ahead](https://github.com/amykhuang/llvm-project/compare/llvm:llvm-project:main...attr-plugin),
>  [1684 commits 
> behind](https://github.com/amykhuang/llvm-project/compare/attr-plugin...llvm:llvm-project:main)
>  llvm:main.

Yeah, this branch is missing all November commits, include aforementioned fix.

https://github.com/llvm/llvm-project/pull/70877
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Refactor `IdentifierInfo::ObjcOrBuiltinID` (PR #71709)

2023-11-17 Thread Vlad Serebrennikov via cfe-commits

https://github.com/Endilll updated 
https://github.com/llvm/llvm-project/pull/71709

>From 2823d38544d18213b5bf48c67e4eedd52acce850 Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov 
Date: Wed, 8 Nov 2023 20:30:37 +0300
Subject: [PATCH 1/3] [clang] Refactor `IdentifierInfo::ObjcOrBuiltinID`

This patch refactors how values are stored inside 
`IdentifierInfo::ObjcOrBuiltinID` bit-field, and annotates it with 
`preferred_type`. In order to make the value easier to interpret by debuggers, 
a new `ObjCKeywordOrInterestingOrBuiltin` is added. Previous "layout" of this 
fields couldn't be represented with this new enum, because it skipped over some 
arbitrary enumerators, so a new "layout" was invented based on 
`ObjCKeywordOrInterestingOrBuiltin` enum. I believe the new layout is simpler 
than the new one.
---
 clang/include/clang/Basic/IdentifierTable.h | 117 
 1 file changed, 73 insertions(+), 44 deletions(-)

diff --git a/clang/include/clang/Basic/IdentifierTable.h 
b/clang/include/clang/Basic/IdentifierTable.h
index 0898e7d39dd7dee..fa76228da2b143a 100644
--- a/clang/include/clang/Basic/IdentifierTable.h
+++ b/clang/include/clang/Basic/IdentifierTable.h
@@ -15,6 +15,7 @@
 #ifndef LLVM_CLANG_BASIC_IDENTIFIERTABLE_H
 #define LLVM_CLANG_BASIC_IDENTIFIERTABLE_H
 
+#include "clang/Basic/Builtins.h"
 #include "clang/Basic/DiagnosticIDs.h"
 #include "clang/Basic/LLVM.h"
 #include "clang/Basic/TokenKinds.h"
@@ -86,19 +87,26 @@ enum { IdentifierInfoAlignment = 8 };
 static constexpr int ObjCOrBuiltinIDBits = 16;
 
 /// The "layout" of ObjCOrBuiltinID is:
-///  - The first value (0) represents "not a special identifier".
-///  - The next (NUM_OBJC_KEYWORDS - 1) values represent ObjCKeywordKinds (not
-///including objc_not_keyword).
-///  - The next (NUM_INTERESTING_IDENTIFIERS - 1) values represent
-///InterestingIdentifierKinds (not including not_interesting).
-///  - The rest of the values represent builtin IDs (not including NotBuiltin).
-static constexpr int FirstObjCKeywordID = 1;
-static constexpr int LastObjCKeywordID =
-FirstObjCKeywordID + tok::NUM_OBJC_KEYWORDS - 2;
-static constexpr int FirstInterestingIdentifierID = LastObjCKeywordID + 1;
-static constexpr int LastInterestingIdentifierID =
-FirstInterestingIdentifierID + tok::NUM_INTERESTING_IDENTIFIERS - 2;
-static constexpr int FirstBuiltinID = LastInterestingIdentifierID + 1;
+///  - ObjCKeywordKind enumerators
+///  - InterestingIdentifierKind enumerators
+///  - Builtin::ID enumerators
+///  - NonSpecialIdentifier
+enum class ObjCKeywordOrInterestingOrBuiltin {
+#define OBJC_AT_KEYWORD(X) objc_##X,
+#include "clang/Basic/TokenKinds.def"
+  NUM_OBJC_KEYWORDS,
+
+#define INTERESTING_IDENTIFIER(X) X,
+#include "clang/Basic/TokenKinds.def"
+  NUM_OBJC_KEYWORDS_AND_INTERESTING_IDENTIFIERS,
+
+  NotBuiltin,
+#define BUILTIN(ID, TYPE, ATTRS) BI##ID,
+#include "clang/Basic/Builtins.def"
+  FirstTSBuiltin,
+
+  NonSpecialIdentifier = 65534
+};
 
 /// One of these records is kept for each identifier that
 /// is lexed.  This contains information about whether the token was 
\#define'd,
@@ -113,9 +121,7 @@ class alignas(IdentifierInfoAlignment) IdentifierInfo {
   LLVM_PREFERRED_TYPE(tok::TokenKind)
   unsigned TokenID : 9;
 
-  // ObjC keyword ('protocol' in '@protocol') or builtin (__builtin_inf).
-  // First NUM_OBJC_KEYWORDS values are for Objective-C,
-  // the remaining values are for builtins.
+  LLVM_PREFERRED_TYPE(ObjCKeywordOrInterestingOrBuiltin)
   unsigned ObjCOrBuiltinID : ObjCOrBuiltinIDBits;
 
   // True if there is a #define for this.
@@ -198,13 +204,16 @@ class alignas(IdentifierInfoAlignment) IdentifierInfo {
   llvm::StringMapEntry *Entry = nullptr;
 
   IdentifierInfo()
-  : TokenID(tok::identifier), ObjCOrBuiltinID(0), HasMacro(false),
-HadMacro(false), IsExtension(false), IsFutureCompatKeyword(false),
-IsPoisoned(false), IsCPPOperatorKeyword(false),
-NeedsHandleIdentifier(false), IsFromAST(false), 
ChangedAfterLoad(false),
-FEChangedAfterLoad(false), RevertedTokenID(false), OutOfDate(false),
-IsModulesImport(false), IsMangledOpenMPVariantName(false),
-IsDeprecatedMacro(false), IsRestrictExpansion(false), IsFinal(false) {}
+  : TokenID(tok::identifier),
+ObjCOrBuiltinID(llvm::to_underlying(
+ObjCKeywordOrInterestingOrBuiltin::NonSpecialIdentifier)),
+HasMacro(false), HadMacro(false), IsExtension(false),
+IsFutureCompatKeyword(false), IsPoisoned(false),
+IsCPPOperatorKeyword(false), NeedsHandleIdentifier(false),
+IsFromAST(false), ChangedAfterLoad(false), FEChangedAfterLoad(false),
+RevertedTokenID(false), OutOfDate(false), IsModulesImport(false),
+IsMangledOpenMPVariantName(false), IsDeprecatedMacro(false),
+IsRestrictExpansion(false), IsFinal(false) {}
 
 public:
   IdentifierInfo(const IdentifierInfo &) = delete;
@@ -332,42 +341,62 @@ class alignas(IdentifierInfoAlignment

[clang] [clang] Refactor `IdentifierInfo::ObjcOrBuiltinID` (PR #71709)

2023-11-17 Thread Vlad Serebrennikov via cfe-commits

Endilll wrote:

Aaron suggested to me offline that `IsInterestingIdentifier` that I recently 
changed could be implemented in a simpler way retaining the intent. That's what 
the latest update about.

https://github.com/llvm/llvm-project/pull/71709
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Implement P2308R1 - Template Parameter Initialization. (PR #73103)

2023-11-22 Thread Vlad Serebrennikov via cfe-commits


@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -std=c++98 -triple x86_64-unknown-unknown %s -verify 
-fexceptions -fcxx-exceptions -pedantic-errors \

Endilll wrote:

Is triple necessary for the test?

https://github.com/llvm/llvm-project/pull/73103
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Implement P2308R1 - Template Parameter Initialization. (PR #73103)

2023-11-22 Thread Vlad Serebrennikov via cfe-commits

https://github.com/Endilll edited 
https://github.com/llvm/llvm-project/pull/73103
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Implement P2308R1 - Template Parameter Initialization. (PR #73103)

2023-11-22 Thread Vlad Serebrennikov via cfe-commits

https://github.com/Endilll approved this pull request.

DR test side looks good, except for a small nit.

https://github.com/llvm/llvm-project/pull/73103
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-format] Change LLVM style to BreakAfterAttributes == ABS_Leave (PR #70360)

2023-10-28 Thread Vlad Serebrennikov via cfe-commits

https://github.com/Endilll closed 
https://github.com/llvm/llvm-project/pull/70360
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][NFC] Annotate `Type` bit-fields with `clang::preferred_type` (PR #70349)

2023-10-29 Thread Vlad Serebrennikov via cfe-commits

https://github.com/Endilll updated 
https://github.com/llvm/llvm-project/pull/70349

>From 7329f68092d5f8f5a5978e5a6cbad6ada87d4fe8 Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov 
Date: Thu, 26 Oct 2023 16:09:25 +0300
Subject: [PATCH 1/4] [clang][NFC] Annotate `Type` bit-fields with
 `clang::preferred_type`

---
 clang/include/clang/AST/DeclBase.h|  2 +-
 clang/include/clang/AST/DependenceFlags.h |  2 +-
 clang/include/clang/AST/Type.h| 46 ++-
 clang/include/clang/Basic/Linkage.h   |  2 +-
 4 files changed, 47 insertions(+), 5 deletions(-)

diff --git a/clang/include/clang/AST/DeclBase.h 
b/clang/include/clang/AST/DeclBase.h
index 978e4255e877ec2..0307691fdd480bf 100644
--- a/clang/include/clang/AST/DeclBase.h
+++ b/clang/include/clang/AST/DeclBase.h
@@ -49,7 +49,7 @@ class ExternalSourceSymbolAttr;
 class FunctionDecl;
 class FunctionType;
 class IdentifierInfo;
-enum Linkage : unsigned char;
+enum Linkage : unsigned;
 class LinkageSpecDecl;
 class Module;
 class NamedDecl;
diff --git a/clang/include/clang/AST/DependenceFlags.h 
b/clang/include/clang/AST/DependenceFlags.h
index 3b3c1afb096addd..e91b6ff35b34966 100644
--- a/clang/include/clang/AST/DependenceFlags.h
+++ b/clang/include/clang/AST/DependenceFlags.h
@@ -49,7 +49,7 @@ struct ExprDependenceScope {
 using ExprDependence = ExprDependenceScope::ExprDependence;
 
 struct TypeDependenceScope {
-  enum TypeDependence : uint8_t {
+  enum TypeDependence : unsigned {
 /// Whether this type contains an unexpanded parameter pack
 /// (for C++11 variadic templates)
 UnexpandedPack = 1,
diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index 1e8e1303e65f6ba..f24b1dccc240785 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -1611,22 +1611,28 @@ class alignas(TypeAlignment) Type : public 
ExtQualsTypeCommonBase {
 template  friend class TypePropertyCache;
 
 /// TypeClass bitfield - Enum that specifies what subclass this belongs to.
+[[clang::preferred_type(TypeClass)]]
 unsigned TC : 8;
 
 /// Store information on the type dependency.
+[[clang::preferred_type(TypeDependence)]]
 unsigned Dependence : llvm::BitWidth;
 
 /// True if the cache (i.e. the bitfields here starting with
 /// 'Cache') is valid.
+[[clang::preferred_type(bool)]]
 mutable unsigned CacheValid : 1;
 
 /// Linkage of this type.
+[[clang::preferred_type(Linkage)]]
 mutable unsigned CachedLinkage : 3;
 
 /// Whether this type involves and local or unnamed types.
+[[clang::preferred_type(bool)]]
 mutable unsigned CachedLocalOrUnnamed : 1;
 
 /// Whether this type comes from an AST file.
+[[clang::preferred_type(bool)]]
 mutable unsigned FromAST : 1;
 
 bool isCacheValid() const {
@@ -1652,10 +1658,12 @@ class alignas(TypeAlignment) Type : public 
ExtQualsTypeCommonBase {
   class ArrayTypeBitfields {
 friend class ArrayType;
 
+[[clang::preferred_type(TypeBitfields)]]
 unsigned : NumTypeBits;
 
 /// CVR qualifiers from declarations like
 /// 'int X[static restrict 4]'. For function parameters only.
+[[clang::preferred_type(Qualifiers)]]
 unsigned IndexTypeQuals : 3;
 
 /// Storage class qualifiers from declarations like
@@ -1671,12 +1679,14 @@ class alignas(TypeAlignment) Type : public 
ExtQualsTypeCommonBase {
 unsigned : NumArrayTypeBits;
 
 /// Whether we have a stored size expression.
+[[clang::preferred_type(bool)]]
 unsigned HasStoredSizeExpr : 1;
   };
 
   class BuiltinTypeBitfields {
 friend class BuiltinType;
 
+[[clang::preferred_type(TypeBitfields)]]
 unsigned : NumTypeBits;
 
 /// The kind (BuiltinType::Kind) of builtin type this is.
@@ -1691,15 +1701,18 @@ class alignas(TypeAlignment) Type : public 
ExtQualsTypeCommonBase {
 friend class FunctionProtoType;
 friend class FunctionType;
 
+[[clang::preferred_type(TypeBitfields)]]
 unsigned : NumTypeBits;
 
 /// Extra information which affects how the function is called, like
 /// regparm and the calling convention.
+[[clang::preferred_type(CallingConv)]]
 unsigned ExtInfo : 13;
 
 /// The ref-qualifier associated with a \c FunctionProtoType.
 ///
 /// This is a value of type \c RefQualifierKind.
+[[clang::preferred_type(RefQualifierKind)]]
 unsigned RefQualifier : 2;
 
 /// Used only by FunctionProtoType, put here to pack with the
@@ -1708,8 +1721,10 @@ class alignas(TypeAlignment) Type : public 
ExtQualsTypeCommonBase {
 ///
 /// C++ 8.3.5p4: The return type, the parameter type list and the
 /// cv-qualifier-seq, [...], are part of the function type.
+[[clang::preferred_type(Qualifiers)]]
 unsigned FastTypeQuals : Qualifiers::FastWidth;
 /// Whether this function has extended Qualifiers.
+[[clang::preferred_type(bool)]]
 unsigned HasExtQuals : 1;
 
 /// The number of parameters 

[clang] [clang] Remove diagnostic that came with `[[clang::preferred_type]]` (PR #70632)

2023-10-30 Thread Vlad Serebrennikov via cfe-commits

https://github.com/Endilll created 
https://github.com/llvm/llvm-project/pull/70632

https://github.com/llvm/llvm-project/pull/69104 introduce a diagnostic that 
checked underlying type of an enum against type of bit-field that is annotated 
with `[[clang::preferred_type]]`. When I tried to introduce this annotation in 
https://github.com/llvm/llvm-project/pull/70349, it turned out to be too 
chatty, despite effort to avoid that.

>From 63ca596224b3150b4225279bd3b07ce42a7fa86c Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov 
Date: Mon, 30 Oct 2023 10:44:28 +0300
Subject: [PATCH] [clang] Remove diagnostic that came with
 [[clang::preferred_type]]

---
 clang/include/clang/Basic/DiagnosticGroups.td |  1 -
 .../clang/Basic/DiagnosticSemaKinds.td|  3 ---
 clang/lib/Sema/SemaDeclAttr.cpp   | 22 ---
 3 files changed, 26 deletions(-)

diff --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index 9a8f3f03b39d165..4c4820d17b7184c 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -54,7 +54,6 @@ def BitFieldConstantConversion : 
DiagGroup<"bitfield-constant-conversion",

[SingleBitBitFieldConstantConversion]>;
 def BitFieldEnumConversion : DiagGroup<"bitfield-enum-conversion">;
 def BitFieldWidth : DiagGroup<"bitfield-width">;
-def BitFieldType : DiagGroup<"bitfield-type">;
 def CompoundTokenSplitByMacro : DiagGroup<"compound-token-split-by-macro">;
 def CompoundTokenSplitBySpace : DiagGroup<"compound-token-split-by-space">;
 def CompoundTokenSplit : DiagGroup<"compound-token-split",
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 453bd8a9a340425..70831fa0d91f2e3 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -3167,9 +3167,6 @@ def err_invalid_branch_protection_spec : Error<
   "invalid or misplaced branch protection specification '%0'">;
 def warn_unsupported_branch_protection_spec : Warning<
   "unsupported branch protection specification '%0'">, 
InGroup;
-def warn_attribute_underlying_type_mismatch : Warning<
-  "underlying type %0 of enumeration %1 doesn't match bit-field type %2">,
-  InGroup;
 
 def warn_unsupported_target_attribute
 : Warning<"%select{unsupported|duplicate|unknown}0%select{| CPU|"
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index fc4e3ccf29a6051..03ec8ece0e4e124 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -5928,28 +5928,6 @@ static void handlePreferredTypeAttr(Sema &S, Decl *D, 
const ParsedAttr &AL) {
   S.RequireCompleteType(ParmTSI->getTypeLoc().getBeginLoc(), QT,
 diag::err_incomplete_type);
 
-  if (QT->isEnumeralType()) {
-auto IsCorrespondingType = [&](QualType LHS, QualType RHS) {
-  assert(LHS != RHS);
-  if (LHS->isSignedIntegerType())
-return LHS == S.getASTContext().getCorrespondingSignedType(RHS);
-  return LHS == S.getASTContext().getCorrespondingUnsignedType(RHS);
-};
-QualType BitfieldType =
-cast(D)->getType()->getCanonicalTypeUnqualified();
-QualType EnumUnderlyingType = QT->getAs()
-  ->getDecl()
-  ->getIntegerType()
-  ->getCanonicalTypeUnqualified();
-if (EnumUnderlyingType != BitfieldType &&
-!IsCorrespondingType(EnumUnderlyingType, BitfieldType)) {
-  S.Diag(ParmTSI->getTypeLoc().getBeginLoc(),
- diag::warn_attribute_underlying_type_mismatch)
-  << EnumUnderlyingType << QT << BitfieldType;
-  return;
-}
-  }
-
   D->addAttr(::new (S.Context) PreferredTypeAttr(S.Context, AL, ParmTSI));
 }
 

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


[clang] [clang] Remove diagnostic that came with `[[clang::preferred_type]]` (PR #70632)

2023-10-30 Thread Vlad Serebrennikov via cfe-commits


@@ -5928,28 +5928,6 @@ static void handlePreferredTypeAttr(Sema &S, Decl *D, 
const ParsedAttr &AL) {
   S.RequireCompleteType(ParmTSI->getTypeLoc().getBeginLoc(), QT,
 diag::err_incomplete_type);
 
-  if (QT->isEnumeralType()) {
-auto IsCorrespondingType = [&](QualType LHS, QualType RHS) {
-  assert(LHS != RHS);
-  if (LHS->isSignedIntegerType())
-return LHS == S.getASTContext().getCorrespondingSignedType(RHS);
-  return LHS == S.getASTContext().getCorrespondingUnsignedType(RHS);
-};
-QualType BitfieldType =
-cast(D)->getType()->getCanonicalTypeUnqualified();
-QualType EnumUnderlyingType = QT->getAs()
-  ->getDecl()
-  ->getIntegerType()
-  ->getCanonicalTypeUnqualified();
-if (EnumUnderlyingType != BitfieldType &&
-!IsCorrespondingType(EnumUnderlyingType, BitfieldType)) {

Endilll wrote:

> Another solution would be to compare the number of bits of the greater 
> enumerator with the number of bits in the bitfield.

I've had this idea myself, but it's defeated by likes of 
https://github.com/llvm/llvm-project/blob/e79f0506cf6fd32ed466fdd2ccbb68dcacbb4bf5/clang/include/clang/AST/DeclarationName.h#L174-L185
where `UncommonNameKindOffset` is an enumerator that is not there to be stored 
in memory.

https://github.com/llvm/llvm-project/pull/70632
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Remove diagnostic that came with `[[clang::preferred_type]]` (PR #70632)

2023-10-30 Thread Vlad Serebrennikov via cfe-commits


@@ -5928,28 +5928,6 @@ static void handlePreferredTypeAttr(Sema &S, Decl *D, 
const ParsedAttr &AL) {
   S.RequireCompleteType(ParmTSI->getTypeLoc().getBeginLoc(), QT,
 diag::err_incomplete_type);
 
-  if (QT->isEnumeralType()) {
-auto IsCorrespondingType = [&](QualType LHS, QualType RHS) {
-  assert(LHS != RHS);
-  if (LHS->isSignedIntegerType())
-return LHS == S.getASTContext().getCorrespondingSignedType(RHS);
-  return LHS == S.getASTContext().getCorrespondingUnsignedType(RHS);
-};
-QualType BitfieldType =
-cast(D)->getType()->getCanonicalTypeUnqualified();
-QualType EnumUnderlyingType = QT->getAs()
-  ->getDecl()
-  ->getIntegerType()
-  ->getCanonicalTypeUnqualified();
-if (EnumUnderlyingType != BitfieldType &&
-!IsCorrespondingType(EnumUnderlyingType, BitfieldType)) {

Endilll wrote:

> I think we should keep the diagnostics, but only emit it when the type of the 
> enum has a sizeof that is greater than the type of the bitfields.

We can do that, but it's going to miss so much that I'm not sure it's worth our 
time at all.

https://github.com/llvm/llvm-project/pull/70632
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Remove diagnostic that came with `[[clang::preferred_type]]` (PR #70632)

2023-10-30 Thread Vlad Serebrennikov via cfe-commits

Endilll wrote:

> Why doesn't this result in any changes to tests? I would expect having to 
> remove them, right?

There was a single test that was relying on sign mismatch, and then during code 
review we made the diagnostic to ignore signness. So it ended up merged without 
test case where this diagnostic was triggered.

https://github.com/llvm/llvm-project/pull/70632
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 49fd28d - [clang][NFC] Refactor `ArrayType::ArraySizeModifier`

2023-10-31 Thread Vlad Serebrennikov via cfe-commits

Author: Vlad Serebrennikov
Date: 2023-10-31T18:06:34+03:00
New Revision: 49fd28d9601dde429436655ec74234e895c60b89

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

LOG: [clang][NFC] Refactor `ArrayType::ArraySizeModifier`

This patch moves `ArraySizeModifier` before `Type` declaration so that it's 
complete at `ArrayTypeBitfields` declaration. It's also converted to scoped 
enum along the way.

Added: 


Modified: 
clang/include/clang/AST/ASTContext.h
clang/include/clang/AST/PropertiesBase.td
clang/include/clang/AST/Type.h
clang/include/clang/Sema/Sema.h
clang/lib/AST/ASTContext.cpp
clang/lib/AST/ExprConstant.cpp
clang/lib/AST/JSONNodeDumper.cpp
clang/lib/AST/ODRHash.cpp
clang/lib/AST/ScanfFormatString.cpp
clang/lib/AST/TextNodeDumper.cpp
clang/lib/AST/Type.cpp
clang/lib/AST/TypePrinter.cpp
clang/lib/CodeGen/CGAtomic.cpp
clang/lib/CodeGen/CGBuiltin.cpp
clang/lib/CodeGen/CGCall.cpp
clang/lib/CodeGen/CGDebugInfo.cpp
clang/lib/CodeGen/CGObjC.cpp
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
clang/lib/CodeGen/CGStmtOpenMP.cpp
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/CodeGen/Targets/XCore.cpp
clang/lib/ExtractAPI/DeclarationFragments.cpp
clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp
clang/lib/Frontend/Rewrite/RewriteObjC.cpp
clang/lib/Index/USRGeneration.cpp
clang/lib/Sema/Sema.cpp
clang/lib/Sema/SemaChecking.cpp
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaExpr.cpp
clang/lib/Sema/SemaExprCXX.cpp
clang/lib/Sema/SemaInit.cpp
clang/lib/Sema/SemaOpenMP.cpp
clang/lib/Sema/SemaOverload.cpp
clang/lib/Sema/SemaType.cpp
clang/lib/Sema/TreeTransform.h

Removed: 




diff  --git a/clang/include/clang/AST/ASTContext.h 
b/clang/include/clang/AST/ASTContext.h
index 8ad0514ee2ce227..24d22a9c692cd34 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -1430,8 +1430,7 @@ class ASTContext : public RefCountedBase {
   /// Return a non-unique reference to the type for a variable array of
   /// the specified element type.
   QualType getVariableArrayType(QualType EltTy, Expr *NumElts,
-ArrayType::ArraySizeModifier ASM,
-unsigned IndexTypeQuals,
+ArraySizeModifier ASM, unsigned IndexTypeQuals,
 SourceRange Brackets) const;
 
   /// Return a non-unique reference to the type for a dependently-sized
@@ -1440,21 +1439,19 @@ class ASTContext : public RefCountedBase {
   /// FIXME: We will need these to be uniqued, or at least comparable, at some
   /// point.
   QualType getDependentSizedArrayType(QualType EltTy, Expr *NumElts,
-  ArrayType::ArraySizeModifier ASM,
+  ArraySizeModifier ASM,
   unsigned IndexTypeQuals,
   SourceRange Brackets) const;
 
   /// Return a unique reference to the type for an incomplete array of
   /// the specified element type.
-  QualType getIncompleteArrayType(QualType EltTy,
-  ArrayType::ArraySizeModifier ASM,
+  QualType getIncompleteArrayType(QualType EltTy, ArraySizeModifier ASM,
   unsigned IndexTypeQuals) const;
 
   /// Return the unique reference to the type for a constant array of
   /// the specified element type.
   QualType getConstantArrayType(QualType EltTy, const llvm::APInt &ArySize,
-const Expr *SizeExpr,
-ArrayType::ArraySizeModifier ASM,
+const Expr *SizeExpr, ArraySizeModifier ASM,
 unsigned IndexTypeQuals) const;
 
   /// Return a type for a constant array for a string literal of the

diff  --git a/clang/include/clang/AST/PropertiesBase.td 
b/clang/include/clang/AST/PropertiesBase.td
index c6fe790e1964b05..129e6e0136964f8 100644
--- a/clang/include/clang/AST/PropertiesBase.td
+++ b/clang/include/clang/AST/PropertiesBase.td
@@ -74,7 +74,7 @@ def APInt : PropertyType<"llvm::APInt"> { let PassByReference 
= 1; }
 def APSInt : PropertyType<"llvm::APSInt"> { let PassByReference = 1; }
 def APValue : PropertyType { let PassByReference = 1; }
 def APValueKind : EnumPropertyType<"APValue::ValueKind">;
-def ArraySizeModifier : EnumPropertyType<"ArrayType::ArraySizeModifier">;
+def ArraySizeModifier : EnumPropertyType<"ArraySizeModifier">;
 def AttrKind : EnumPropertyType<"attr::Kind">;
 def AutoTypeKeyword : EnumPropertyType;
 def Bool : PropertyType<"bool">;

diff  --git a/clang/include/

[llvm] [clang] [clang][NFC] Annotate `Type` bit-fields with `clang::preferred_type` (PR #70349)

2023-10-31 Thread Vlad Serebrennikov via cfe-commits


@@ -49,7 +49,7 @@ struct ExprDependenceScope {
 using ExprDependence = ExprDependenceScope::ExprDependence;
 
 struct TypeDependenceScope {
-  enum TypeDependence : uint8_t {
+  enum TypeDependence : unsigned {

Endilll wrote:

Yeah, I'm putting this on hold for a bit, and refactor enumerations in NFC 
commits, so that this PR lands without "holes" because some enums are not 
complete at the point where I put `preferred_type`. After that underlying type 
changes this PR does shouldn't be necessary anymore.

https://github.com/llvm/llvm-project/pull/70349
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] f5f4c5b - [clang][NFC] Follow up to ArraySizeModifier refactoring

2023-10-31 Thread Vlad Serebrennikov via cfe-commits

Author: Vlad Serebrennikov
Date: 2023-10-31T18:21:36+03:00
New Revision: f5f4c5b313fc809b9b1b9d600d0ec3cec0d12941

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

LOG: [clang][NFC] Follow up to ArraySizeModifier refactoring

This addresses issues found by 
https://lab.llvm.org/buildbot/#/builders/68/builds/62599 introduced in 
d71ac4b05bcf2804368ec7217a13c2c47fce7479

Added: 


Modified: 
clang-tools-extra/clangd/Hover.cpp
libcxxabi/test/test_demangle.pass.cpp
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/Hover.cpp 
b/clang-tools-extra/clangd/Hover.cpp
index 933c69294b40926..7f7b5513dff6fee 100644
--- a/clang-tools-extra/clangd/Hover.cpp
+++ b/clang-tools-extra/clangd/Hover.cpp
@@ -686,9 +686,9 @@ getPredefinedExprHoverContents(const PredefinedExpr &PE, 
ASTContext &Ctx,
 HI.Type = printType(Name->getType(), Ctx, PP);
   } else {
 // Inside templates, the approximate type `const char[]` is still useful.
-QualType StringType = Ctx.getIncompleteArrayType(
-Ctx.CharTy.withConst(), ArrayType::ArraySizeModifier::Normal,
-/*IndexTypeQuals=*/0);
+QualType StringType = Ctx.getIncompleteArrayType(Ctx.CharTy.withConst(),
+ ArraySizeModifier::Normal,
+ /*IndexTypeQuals=*/0);
 HI.Type = printType(StringType, Ctx, PP);
   }
   return HI;

diff  --git a/libcxxabi/test/test_demangle.pass.cpp 
b/libcxxabi/test/test_demangle.pass.cpp
index 77741a952850ab9..3bfdc04ced50b36 100644
--- a/libcxxabi/test/test_demangle.pass.cpp
+++ b/libcxxabi/test/test_demangle.pass.cpp
@@ -5989,7 +5989,7 @@ const char* cases[][2] =
 
{"_ZN5clang13TreeTransformIN12_GLOBAL__N_129CurrentInstantiationRebuilderEE13TransformTypeERNS_14TypeLocBuilderENS_7TypeLocE",
 "clang::TreeTransform<(anonymous 
namespace)::CurrentInstantiationRebuilder>::TransformType(clang::TypeLocBuilder&,
 clang::TypeLoc)"},
 
{"_ZN5clang13TreeTransformIN12_GLOBAL__N_129CurrentInstantiationRebuilderEE27TransformFunctionTypeParamsENS_14SourceLocationEPPNS_11ParmVarDeclEjPKNS_8QualTypeERN4llvm15SmallVectorImplIS8_EEPNSC_IS6_EE",
 "clang::TreeTransform<(anonymous 
namespace)::CurrentInstantiationRebuilder>::TransformFunctionTypeParams(clang::SourceLocation,
 clang::ParmVarDecl**, unsigned int, clang::QualType const*, 
llvm::SmallVectorImpl&, 
llvm::SmallVectorImpl*)"},
 
{"_ZN5clang13TreeTransformIN12_GLOBAL__N_129CurrentInstantiationRebuilderEE26TransformFunctionTypeParamEPNS_11ParmVarDeclEN4llvm8OptionalIjEE",
 "clang::TreeTransform<(anonymous 
namespace)::CurrentInstantiationRebuilder>::TransformFunctionTypeParam(clang::ParmVarDecl*,
 llvm::Optional)"},
-
{"_ZN5clang13TreeTransformIN12_GLOBAL__N_129CurrentInstantiationRebuilderEE16RebuildArrayTypeENS_8QualTypeENS_9ArrayType17ArraySizeModifierEPKN4llvm5APIntEPNS_4ExprEjNS_11SourceRangeE",
 "clang::TreeTransform<(anonymous 
namespace)::CurrentInstantiationRebuilder>::RebuildArrayType(clang::QualType, 
clang::ArrayType::ArraySizeModifier, llvm::APInt const*, clang::Expr*, unsigned 
int, clang::SourceRange)"},
+
{"_ZN5clang13TreeTransformIN12_GLOBAL__N_129CurrentInstantiationRebuilderEE16RebuildArrayTypeENS_8QualTypeENS_9ArrayType17ArraySizeModifierEPKN4llvm5APIntEPNS_4ExprEjNS_11SourceRangeE",
 "clang::TreeTransform<(anonymous 
namespace)::CurrentInstantiationRebuilder>::RebuildArrayType(clang::QualType, 
clang::ArraySizeModifier, llvm::APInt const*, clang::Expr*, unsigned int, 
clang::SourceRange)"},
 
{"_ZN5clang13TreeTransformIN12_GLOBAL__N_129CurrentInstantiationRebuilderEE22TransformReferenceTypeERNS_14TypeLocBuilderENS_16ReferenceTypeLocE",
 "clang::TreeTransform<(anonymous 
namespace)::CurrentInstantiationRebuilder>::TransformReferenceType(clang::TypeLocBuilder&,
 clang::ReferenceTypeLoc)"},
 
{"_ZN5clang13TreeTransformIN12_GLOBAL__N_129CurrentInstantiationRebuilderEE26TransformTemplateArgumentsINS_33TemplateArgumentLocInventIteratorIS2_PKNS_16TemplateArgumentEbT_SA_RNS_24TemplateArgumentListInfoE",
 "bool clang::TreeTransform<(anonymous 
namespace)::CurrentInstantiationRebuilder>::TransformTemplateArguments>(clang::TemplateArgumentLocInventIterator<(anonymous 
namespace)::CurrentInstantiationRebuilder, clang::TemplateArgument const*>, 
clang::TemplateArgumentLocInventIterator<(anonymous 
namespace)::CurrentInstantiationRebuilder, clang::TemplateArgument const*>, 
clang::TemplateArgumentListInfo&)"},
 
{"_ZN5clang13TreeTransformIN12_GLOBAL__N_129CurrentInstantiationRebuilderEE25TransformTemplateArgumentERKNS_19TemplateArgumentLocERS4_",
 "clang::TreeTransform<(anonymous 
namespace)::CurrentInstantiationRebuilder>::TransformTemplateArgument(clang::T

[clang] 4ad2ada - [clang][NFC] Refactor ElaboratedTypeKeyword

2023-10-31 Thread Vlad Serebrennikov via cfe-commits

Author: Vlad Serebrennikov
Date: 2023-10-31T20:46:07+03:00
New Revision: 4ad2ada5216ee2bb3c334a3233a9ab51f2521b82

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

LOG: [clang][NFC] Refactor ElaboratedTypeKeyword

This patch moves ElaboratedTypeKeyword before `Type` definition so that the 
enum is complete where bit-field for it is declared. It also converts it to 
scoped enum and removes `ETK_` prefix.

Added: 


Modified: 
clang-tools-extra/clang-tidy/modernize/UseConstraintsCheck.cpp
clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp
clang/include/clang/AST/Type.h
clang/include/clang/AST/TypeLoc.h
clang/lib/AST/ASTContext.cpp
clang/lib/AST/ASTStructuralEquivalence.cpp
clang/lib/AST/ItaniumMangle.cpp
clang/lib/AST/ODRHash.cpp
clang/lib/AST/QualTypeNames.cpp
clang/lib/AST/Type.cpp
clang/lib/AST/TypePrinter.cpp
clang/lib/ExtractAPI/DeclarationFragments.cpp
clang/lib/Sema/SemaCXXScopeSpec.cpp
clang/lib/Sema/SemaCoroutine.cpp
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaDeclCXX.cpp
clang/lib/Sema/SemaExpr.cpp
clang/lib/Sema/SemaExprCXX.cpp
clang/lib/Sema/SemaTemplate.cpp
clang/lib/Sema/SemaTemplateInstantiate.cpp
clang/lib/Sema/SemaType.cpp
clang/lib/Sema/TreeTransform.h

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/modernize/UseConstraintsCheck.cpp 
b/clang-tools-extra/clang-tidy/modernize/UseConstraintsCheck.cpp
index 310b5bf9affa15f..6d7d1d6b87c60ac 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseConstraintsCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseConstraintsCheck.cpp
@@ -53,7 +53,7 @@ matchEnableIfSpecializationImplTypename(TypeLoc TheType) {
   if (const auto Dep = TheType.getAs()) {
 const IdentifierInfo *Identifier = Dep.getTypePtr()->getIdentifier();
 if (!Identifier || Identifier->getName() != "type" ||
-Dep.getTypePtr()->getKeyword() != ETK_Typename) {
+Dep.getTypePtr()->getKeyword() != ElaboratedTypeKeyword::Typename) {
   return std::nullopt;
 }
 TheType = Dep.getQualifierLoc().getTypeLoc();
@@ -105,7 +105,7 @@ matchEnableIfSpecializationImplTrait(TypeLoc TheType) {
 if (const auto *AliasedType =
 dyn_cast(Specialization->getAliasedType())) {
   if (AliasedType->getIdentifier()->getName() != "type" ||
-  AliasedType->getKeyword() != ETK_Typename) {
+  AliasedType->getKeyword() != ElaboratedTypeKeyword::Typename) {
 return std::nullopt;
   }
 } else {

diff  --git 
a/clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp 
b/clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp
index 5a456c58fb5cc53..9774e988d71e264 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp
@@ -98,7 +98,8 @@ struct UnqualNameVisitor : public 
RecursiveASTVisitor {
   return false;
 const auto *T = TL.getTypePtr();
 return TraverseTypeLoc(TL.getNamedTypeLoc(),
-   T->getKeyword() != ETK_None || T->getQualifier());
+   T->getKeyword() != ElaboratedTypeKeyword::None ||
+   T->getQualifier());
   }
 
   bool VisitDeclRefExpr(DeclRefExpr *S) {

diff  --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index 080a5b045ed4da9..233f607849ce7a8 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -1575,6 +1575,32 @@ enum class AutoTypeKeyword {
 /// 'static' is only allowed on function parameters.
 enum class ArraySizeModifier { Normal, Static, Star };
 
+/// The elaboration keyword that precedes a qualified type name or
+/// introduces an elaborated-type-specifier.
+enum class ElaboratedTypeKeyword {
+  /// The "struct" keyword introduces the elaborated-type-specifier.
+  Struct,
+
+  /// The "__interface" keyword introduces the elaborated-type-specifier.
+  Interface,
+
+  /// The "union" keyword introduces the elaborated-type-specifier.
+  Union,
+
+  /// The "class" keyword introduces the elaborated-type-specifier.
+  Class,
+
+  /// The "enum" keyword introduces the elaborated-type-specifier.
+  Enum,
+
+  /// The "typename" keyword precedes the qualified type name, e.g.,
+  /// \c typename T::type.
+  Typename,
+
+  /// No keyword precedes the qualified type name.
+  None
+};
+
 /// The base class of the type hierarchy.
 ///
 /// A central concept with types is that each type always has a canonical
@@ -5659,32 +5685,6 @@ enum TagTypeKind {
   TTK_Enum
 };
 
-/// The elaboration keyword that precedes a qualified type name or
-/// introduces an elaborated-type-specifier.
-enum ElaboratedTypeKeyword {
- 

[clang] ae7b20b - [clang][NFC] Refactor `VectorType::VectorKind`

2023-10-31 Thread Vlad Serebrennikov via cfe-commits

Author: Vlad Serebrennikov
Date: 2023-10-31T21:50:18+03:00
New Revision: ae7b20b583fab1325d8b51fe5f2eaf612de8b95e

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

LOG: [clang][NFC] Refactor `VectorType::VectorKind`

This patch moves `VectorKind` to namespace scope, and make it complete at the 
point its bit-field is declared. It also converts it to a scoped enum.

Added: 


Modified: 
clang/include/clang/AST/ASTContext.h
clang/include/clang/AST/PropertiesBase.td
clang/include/clang/AST/Type.h
clang/lib/AST/ASTContext.cpp
clang/lib/AST/ItaniumMangle.cpp
clang/lib/AST/JSONNodeDumper.cpp
clang/lib/AST/ODRHash.cpp
clang/lib/AST/TextNodeDumper.cpp
clang/lib/AST/Type.cpp
clang/lib/AST/TypePrinter.cpp
clang/lib/CodeGen/CGDebugInfo.cpp
clang/lib/CodeGen/CGExprScalar.cpp
clang/lib/CodeGen/Targets/AArch64.cpp
clang/lib/CodeGen/Targets/RISCV.cpp
clang/lib/Sema/SemaCast.cpp
clang/lib/Sema/SemaChecking.cpp
clang/lib/Sema/SemaDeclAttr.cpp
clang/lib/Sema/SemaExpr.cpp
clang/lib/Sema/SemaExprCXX.cpp
clang/lib/Sema/SemaInit.cpp
clang/lib/Sema/SemaType.cpp
clang/lib/Sema/TreeTransform.h
libcxxabi/test/test_demangle.pass.cpp

Removed: 




diff  --git a/clang/include/clang/AST/ASTContext.h 
b/clang/include/clang/AST/ASTContext.h
index 24d22a9c692cd34..e5f78dfdc22ab1b 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -1493,12 +1493,12 @@ class ASTContext : public RefCountedBase {
   ///
   /// \pre \p VectorType must be a built-in type.
   QualType getVectorType(QualType VectorType, unsigned NumElts,
- VectorType::VectorKind VecKind) const;
+ VectorKind VecKind) const;
   /// Return the unique reference to the type for a dependently sized vector of
   /// the specified element type.
   QualType getDependentVectorType(QualType VectorType, Expr *SizeExpr,
   SourceLocation AttrLoc,
-  VectorType::VectorKind VecKind) const;
+  VectorKind VecKind) const;
 
   /// Return the unique reference to an extended vector type
   /// of the specified element type and size.

diff  --git a/clang/include/clang/AST/PropertiesBase.td 
b/clang/include/clang/AST/PropertiesBase.td
index 129e6e0136964f8..d86c4eba6a22511 100644
--- a/clang/include/clang/AST/PropertiesBase.td
+++ b/clang/include/clang/AST/PropertiesBase.td
@@ -142,7 +142,7 @@ def TypeOfKind : EnumPropertyType<"TypeOfKind">;
 def UInt32 : CountPropertyType<"uint32_t">;
 def UInt64 : CountPropertyType<"uint64_t">;
 def UnaryTypeTransformKind : EnumPropertyType<"UnaryTransformType::UTTKind">;
-def VectorKind : EnumPropertyType<"VectorType::VectorKind">;
+def VectorKind : EnumPropertyType<"VectorKind">;
 
 def ExceptionSpecInfo : PropertyType<"FunctionProtoType::ExceptionSpecInfo"> {
   let BufferElementTypes = [ QualType ];

diff  --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index 233f607849ce7a8..a15ed46cae0ee54 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -1601,6 +1601,35 @@ enum class ElaboratedTypeKeyword {
   None
 };
 
+enum class VectorKind {
+  /// not a target-specific vector type
+  Generic,
+
+  /// is AltiVec vector
+  AltiVecVector,
+
+  /// is AltiVec 'vector Pixel'
+  AltiVecPixel,
+
+  /// is AltiVec 'vector bool ...'
+  AltiVecBool,
+
+  /// is ARM Neon vector
+  Neon,
+
+  /// is ARM Neon polynomial vector
+  NeonPoly,
+
+  /// is AArch64 SVE fixed-length data vector
+  SveFixedLengthData,
+
+  /// is AArch64 SVE fixed-length predicate vector
+  SveFixedLengthPredicate,
+
+  /// is RISC-V RVV fixed-length data vector
+  RVVFixedLengthData,
+};
+
 /// The base class of the type hierarchy.
 ///
 /// A central concept with types is that each type always has a canonical
@@ -3452,36 +3481,6 @@ class DependentSizedExtVectorType : public Type, public 
llvm::FoldingSetNode {
 /// Since the constructor takes the number of vector elements, the
 /// client is responsible for converting the size into the number of elements.
 class VectorType : public Type, public llvm::FoldingSetNode {
-public:
-  enum VectorKind {
-/// not a target-specific vector type
-GenericVector,
-
-/// is AltiVec vector
-AltiVecVector,
-
-/// is AltiVec 'vector Pixel'
-AltiVecPixel,
-
-/// is AltiVec 'vector bool ...'
-AltiVecBool,
-
-/// is ARM Neon vector
-NeonVector,
-
-/// is ARM Neon polynomial vector
-NeonPolyVector,
-
-/// is AArch64 SVE fixed-length data vector
-SveFixedLengthDataVector,
-
-/// is AArch64 SVE fixed-length predicate vector
-SveFixedLengthPredicateVector,

[llvm] [clang] [clang-tools-extra] [clang][NFC] Annotate `Type` bit-fields with `clang::preferred_type` (PR #70349)

2023-10-31 Thread Vlad Serebrennikov via cfe-commits

https://github.com/Endilll updated 
https://github.com/llvm/llvm-project/pull/70349

>From 7329f68092d5f8f5a5978e5a6cbad6ada87d4fe8 Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov 
Date: Thu, 26 Oct 2023 16:09:25 +0300
Subject: [PATCH 1/4] [clang][NFC] Annotate `Type` bit-fields with
 `clang::preferred_type`

---
 clang/include/clang/AST/DeclBase.h|  2 +-
 clang/include/clang/AST/DependenceFlags.h |  2 +-
 clang/include/clang/AST/Type.h| 46 ++-
 clang/include/clang/Basic/Linkage.h   |  2 +-
 4 files changed, 47 insertions(+), 5 deletions(-)

diff --git a/clang/include/clang/AST/DeclBase.h 
b/clang/include/clang/AST/DeclBase.h
index 978e4255e877ec2..0307691fdd480bf 100644
--- a/clang/include/clang/AST/DeclBase.h
+++ b/clang/include/clang/AST/DeclBase.h
@@ -49,7 +49,7 @@ class ExternalSourceSymbolAttr;
 class FunctionDecl;
 class FunctionType;
 class IdentifierInfo;
-enum Linkage : unsigned char;
+enum Linkage : unsigned;
 class LinkageSpecDecl;
 class Module;
 class NamedDecl;
diff --git a/clang/include/clang/AST/DependenceFlags.h 
b/clang/include/clang/AST/DependenceFlags.h
index 3b3c1afb096addd..e91b6ff35b34966 100644
--- a/clang/include/clang/AST/DependenceFlags.h
+++ b/clang/include/clang/AST/DependenceFlags.h
@@ -49,7 +49,7 @@ struct ExprDependenceScope {
 using ExprDependence = ExprDependenceScope::ExprDependence;
 
 struct TypeDependenceScope {
-  enum TypeDependence : uint8_t {
+  enum TypeDependence : unsigned {
 /// Whether this type contains an unexpanded parameter pack
 /// (for C++11 variadic templates)
 UnexpandedPack = 1,
diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index 1e8e1303e65f6ba..f24b1dccc240785 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -1611,22 +1611,28 @@ class alignas(TypeAlignment) Type : public 
ExtQualsTypeCommonBase {
 template  friend class TypePropertyCache;
 
 /// TypeClass bitfield - Enum that specifies what subclass this belongs to.
+[[clang::preferred_type(TypeClass)]]
 unsigned TC : 8;
 
 /// Store information on the type dependency.
+[[clang::preferred_type(TypeDependence)]]
 unsigned Dependence : llvm::BitWidth;
 
 /// True if the cache (i.e. the bitfields here starting with
 /// 'Cache') is valid.
+[[clang::preferred_type(bool)]]
 mutable unsigned CacheValid : 1;
 
 /// Linkage of this type.
+[[clang::preferred_type(Linkage)]]
 mutable unsigned CachedLinkage : 3;
 
 /// Whether this type involves and local or unnamed types.
+[[clang::preferred_type(bool)]]
 mutable unsigned CachedLocalOrUnnamed : 1;
 
 /// Whether this type comes from an AST file.
+[[clang::preferred_type(bool)]]
 mutable unsigned FromAST : 1;
 
 bool isCacheValid() const {
@@ -1652,10 +1658,12 @@ class alignas(TypeAlignment) Type : public 
ExtQualsTypeCommonBase {
   class ArrayTypeBitfields {
 friend class ArrayType;
 
+[[clang::preferred_type(TypeBitfields)]]
 unsigned : NumTypeBits;
 
 /// CVR qualifiers from declarations like
 /// 'int X[static restrict 4]'. For function parameters only.
+[[clang::preferred_type(Qualifiers)]]
 unsigned IndexTypeQuals : 3;
 
 /// Storage class qualifiers from declarations like
@@ -1671,12 +1679,14 @@ class alignas(TypeAlignment) Type : public 
ExtQualsTypeCommonBase {
 unsigned : NumArrayTypeBits;
 
 /// Whether we have a stored size expression.
+[[clang::preferred_type(bool)]]
 unsigned HasStoredSizeExpr : 1;
   };
 
   class BuiltinTypeBitfields {
 friend class BuiltinType;
 
+[[clang::preferred_type(TypeBitfields)]]
 unsigned : NumTypeBits;
 
 /// The kind (BuiltinType::Kind) of builtin type this is.
@@ -1691,15 +1701,18 @@ class alignas(TypeAlignment) Type : public 
ExtQualsTypeCommonBase {
 friend class FunctionProtoType;
 friend class FunctionType;
 
+[[clang::preferred_type(TypeBitfields)]]
 unsigned : NumTypeBits;
 
 /// Extra information which affects how the function is called, like
 /// regparm and the calling convention.
+[[clang::preferred_type(CallingConv)]]
 unsigned ExtInfo : 13;
 
 /// The ref-qualifier associated with a \c FunctionProtoType.
 ///
 /// This is a value of type \c RefQualifierKind.
+[[clang::preferred_type(RefQualifierKind)]]
 unsigned RefQualifier : 2;
 
 /// Used only by FunctionProtoType, put here to pack with the
@@ -1708,8 +1721,10 @@ class alignas(TypeAlignment) Type : public 
ExtQualsTypeCommonBase {
 ///
 /// C++ 8.3.5p4: The return type, the parameter type list and the
 /// cv-qualifier-seq, [...], are part of the function type.
+[[clang::preferred_type(Qualifiers)]]
 unsigned FastTypeQuals : Qualifiers::FastWidth;
 /// Whether this function has extended Qualifiers.
+[[clang::preferred_type(bool)]]
 unsigned HasExtQuals : 1;
 
 /// The number of parameters 

[llvm] [clang] [clang-tools-extra] [clang][NFC] Annotate `Type` bit-fields with `clang::preferred_type` (PR #70349)

2023-10-31 Thread Vlad Serebrennikov via cfe-commits

https://github.com/Endilll updated 
https://github.com/llvm/llvm-project/pull/70349

>From 7329f68092d5f8f5a5978e5a6cbad6ada87d4fe8 Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov 
Date: Thu, 26 Oct 2023 16:09:25 +0300
Subject: [PATCH 1/5] [clang][NFC] Annotate `Type` bit-fields with
 `clang::preferred_type`

---
 clang/include/clang/AST/DeclBase.h|  2 +-
 clang/include/clang/AST/DependenceFlags.h |  2 +-
 clang/include/clang/AST/Type.h| 46 ++-
 clang/include/clang/Basic/Linkage.h   |  2 +-
 4 files changed, 47 insertions(+), 5 deletions(-)

diff --git a/clang/include/clang/AST/DeclBase.h 
b/clang/include/clang/AST/DeclBase.h
index 978e4255e877ec2..0307691fdd480bf 100644
--- a/clang/include/clang/AST/DeclBase.h
+++ b/clang/include/clang/AST/DeclBase.h
@@ -49,7 +49,7 @@ class ExternalSourceSymbolAttr;
 class FunctionDecl;
 class FunctionType;
 class IdentifierInfo;
-enum Linkage : unsigned char;
+enum Linkage : unsigned;
 class LinkageSpecDecl;
 class Module;
 class NamedDecl;
diff --git a/clang/include/clang/AST/DependenceFlags.h 
b/clang/include/clang/AST/DependenceFlags.h
index 3b3c1afb096addd..e91b6ff35b34966 100644
--- a/clang/include/clang/AST/DependenceFlags.h
+++ b/clang/include/clang/AST/DependenceFlags.h
@@ -49,7 +49,7 @@ struct ExprDependenceScope {
 using ExprDependence = ExprDependenceScope::ExprDependence;
 
 struct TypeDependenceScope {
-  enum TypeDependence : uint8_t {
+  enum TypeDependence : unsigned {
 /// Whether this type contains an unexpanded parameter pack
 /// (for C++11 variadic templates)
 UnexpandedPack = 1,
diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index 1e8e1303e65f6ba..f24b1dccc240785 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -1611,22 +1611,28 @@ class alignas(TypeAlignment) Type : public 
ExtQualsTypeCommonBase {
 template  friend class TypePropertyCache;
 
 /// TypeClass bitfield - Enum that specifies what subclass this belongs to.
+[[clang::preferred_type(TypeClass)]]
 unsigned TC : 8;
 
 /// Store information on the type dependency.
+[[clang::preferred_type(TypeDependence)]]
 unsigned Dependence : llvm::BitWidth;
 
 /// True if the cache (i.e. the bitfields here starting with
 /// 'Cache') is valid.
+[[clang::preferred_type(bool)]]
 mutable unsigned CacheValid : 1;
 
 /// Linkage of this type.
+[[clang::preferred_type(Linkage)]]
 mutable unsigned CachedLinkage : 3;
 
 /// Whether this type involves and local or unnamed types.
+[[clang::preferred_type(bool)]]
 mutable unsigned CachedLocalOrUnnamed : 1;
 
 /// Whether this type comes from an AST file.
+[[clang::preferred_type(bool)]]
 mutable unsigned FromAST : 1;
 
 bool isCacheValid() const {
@@ -1652,10 +1658,12 @@ class alignas(TypeAlignment) Type : public 
ExtQualsTypeCommonBase {
   class ArrayTypeBitfields {
 friend class ArrayType;
 
+[[clang::preferred_type(TypeBitfields)]]
 unsigned : NumTypeBits;
 
 /// CVR qualifiers from declarations like
 /// 'int X[static restrict 4]'. For function parameters only.
+[[clang::preferred_type(Qualifiers)]]
 unsigned IndexTypeQuals : 3;
 
 /// Storage class qualifiers from declarations like
@@ -1671,12 +1679,14 @@ class alignas(TypeAlignment) Type : public 
ExtQualsTypeCommonBase {
 unsigned : NumArrayTypeBits;
 
 /// Whether we have a stored size expression.
+[[clang::preferred_type(bool)]]
 unsigned HasStoredSizeExpr : 1;
   };
 
   class BuiltinTypeBitfields {
 friend class BuiltinType;
 
+[[clang::preferred_type(TypeBitfields)]]
 unsigned : NumTypeBits;
 
 /// The kind (BuiltinType::Kind) of builtin type this is.
@@ -1691,15 +1701,18 @@ class alignas(TypeAlignment) Type : public 
ExtQualsTypeCommonBase {
 friend class FunctionProtoType;
 friend class FunctionType;
 
+[[clang::preferred_type(TypeBitfields)]]
 unsigned : NumTypeBits;
 
 /// Extra information which affects how the function is called, like
 /// regparm and the calling convention.
+[[clang::preferred_type(CallingConv)]]
 unsigned ExtInfo : 13;
 
 /// The ref-qualifier associated with a \c FunctionProtoType.
 ///
 /// This is a value of type \c RefQualifierKind.
+[[clang::preferred_type(RefQualifierKind)]]
 unsigned RefQualifier : 2;
 
 /// Used only by FunctionProtoType, put here to pack with the
@@ -1708,8 +1721,10 @@ class alignas(TypeAlignment) Type : public 
ExtQualsTypeCommonBase {
 ///
 /// C++ 8.3.5p4: The return type, the parameter type list and the
 /// cv-qualifier-seq, [...], are part of the function type.
+[[clang::preferred_type(Qualifiers)]]
 unsigned FastTypeQuals : Qualifiers::FastWidth;
 /// Whether this function has extended Qualifiers.
+[[clang::preferred_type(bool)]]
 unsigned HasExtQuals : 1;
 
 /// The number of parameters 

[llvm] [clang] [clang-tools-extra] [clang][NFC] Annotate `Type` bit-fields with `clang::preferred_type` (PR #70349)

2023-10-31 Thread Vlad Serebrennikov via cfe-commits

https://github.com/Endilll edited 
https://github.com/llvm/llvm-project/pull/70349
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] b120fe8 - [clang][NFC] Refactor `ArgPassingKind`

2023-11-01 Thread Vlad Serebrennikov via cfe-commits

Author: Vlad Serebrennikov
Date: 2023-11-01T11:49:59+03:00
New Revision: b120fe8d3288c4dca1b5427ca34839ce8833f71c

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

LOG: [clang][NFC] Refactor `ArgPassingKind`

This patch moves `RecordDecl::ArgPassingKind` to DeclBase.h to namespace scope, 
so that it's complete at the time bit-field is declared.

Added: 


Modified: 
clang/include/clang/AST/Decl.h
clang/include/clang/AST/DeclBase.h
clang/lib/AST/Decl.cpp
clang/lib/AST/DeclCXX.cpp
clang/lib/CodeGen/CGCall.cpp
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaDeclCXX.cpp
clang/lib/Serialization/ASTReaderDecl.cpp
clang/lib/Serialization/ASTWriter.cpp
clang/lib/Serialization/ASTWriterDecl.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp

Removed: 




diff  --git a/clang/include/clang/AST/Decl.h b/clang/include/clang/AST/Decl.h
index 7f076cc77ea82cb..1c2158f51aa184d 100644
--- a/clang/include/clang/AST/Decl.h
+++ b/clang/include/clang/AST/Decl.h
@@ -4069,28 +4069,6 @@ class RecordDecl : public TagDecl {
 public:
   friend class DeclContext;
   friend class ASTDeclReader;
-  /// Enum that represents the 
diff erent ways arguments are passed to and
-  /// returned from function calls. This takes into account the target-specific
-  /// and version-specific rules along with the rules determined by the
-  /// language.
-  enum ArgPassingKind : unsigned {
-/// The argument of this type can be passed directly in registers.
-APK_CanPassInRegs,
-
-/// The argument of this type cannot be passed directly in registers.
-/// Records containing this type as a subobject are not forced to be passed
-/// indirectly. This value is used only in C++. This value is required by
-/// C++ because, in uncommon situations, it is possible for a class to have
-/// only trivial copy/move constructors even when one of its subobjects has
-/// a non-trivial copy/move constructor (if e.g. the corresponding 
copy/move
-/// constructor in the derived class is deleted).
-APK_CannotPassInRegs,
-
-/// The argument of this type cannot be passed directly in registers.
-/// Records containing this type as a subobject are forced to be passed
-/// indirectly.
-APK_CanNeverPassInRegs
-  };
 
 protected:
   RecordDecl(Kind DK, TagKind TK, const ASTContext &C, DeclContext *DC,
@@ -4215,7 +4193,7 @@ class RecordDecl : public TagDecl {
   /// it must have at least one trivial, non-deleted copy or move constructor.
   /// FIXME: This should be set as part of completeDefinition.
   bool canPassInRegisters() const {
-return getArgPassingRestrictions() == APK_CanPassInRegs;
+return getArgPassingRestrictions() == ArgPassingKind::CanPassInRegs;
   }
 
   ArgPassingKind getArgPassingRestrictions() const {
@@ -4223,7 +4201,7 @@ class RecordDecl : public TagDecl {
   }
 
   void setArgPassingRestrictions(ArgPassingKind Kind) {
-RecordDeclBits.ArgPassingRestrictions = Kind;
+RecordDeclBits.ArgPassingRestrictions = llvm::to_underlying(Kind);
   }
 
   bool isParamDestroyedInCallee() const {

diff  --git a/clang/include/clang/AST/DeclBase.h 
b/clang/include/clang/AST/DeclBase.h
index 978e4255e877ec2..ba6dadd7d3563c3 100644
--- a/clang/include/clang/AST/DeclBase.h
+++ b/clang/include/clang/AST/DeclBase.h
@@ -1399,6 +1399,29 @@ enum class DeductionCandidate : unsigned char {
   Aggregate,
 };
 
+/// Enum that represents the 
diff erent ways arguments are passed to and
+/// returned from function calls. This takes into account the target-specific
+/// and version-specific rules along with the rules determined by the
+/// language.
+enum class ArgPassingKind {
+  /// The argument of this type can be passed directly in registers.
+  CanPassInRegs,
+
+  /// The argument of this type cannot be passed directly in registers.
+  /// Records containing this type as a subobject are not forced to be passed
+  /// indirectly. This value is used only in C++. This value is required by
+  /// C++ because, in uncommon situations, it is possible for a class to have
+  /// only trivial copy/move constructors even when one of its subobjects has
+  /// a non-trivial copy/move constructor (if e.g. the corresponding copy/move
+  /// constructor in the derived class is deleted).
+  CannotPassInRegs,
+
+  /// The argument of this type cannot be passed directly in registers.
+  /// Records containing this type as a subobject are forced to be passed
+  /// indirectly.
+  CanNeverPassInRegs
+};
+
 /// DeclContext - This is used only as base class of specific decl types that
 /// can act as declaration contexts. These decls are (only the top classes
 /// that directly derive from DeclContext are mentioned, not their subclasses):

diff  --git a/clan

[clang] 50dec54 - [clang][NFC] Refactor `OMPDeclareReductionDecl::InitKind`

2023-11-01 Thread Vlad Serebrennikov via cfe-commits

Author: Vlad Serebrennikov
Date: 2023-11-01T12:40:13+03:00
New Revision: 50dec541f328a251c2830421f354e4439e635def

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

LOG: [clang][NFC] Refactor `OMPDeclareReductionDecl::InitKind`

This patch moves `OMPDeclareReductionDecl::InitKind` to DeclBase.h, so that 
it's complete at the point where corresponding bit-field is declared. This 
patch also converts it to scoped enum named `OMPDeclareReductionInitKind`

Added: 


Modified: 
clang/include/clang/AST/DeclBase.h
clang/include/clang/AST/DeclOpenMP.h
clang/lib/AST/DeclOpenMP.cpp
clang/lib/AST/DeclPrinter.cpp
clang/lib/AST/TextNodeDumper.cpp
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/lib/Sema/SemaOpenMP.cpp
clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
clang/lib/Serialization/ASTReaderDecl.cpp
clang/lib/Serialization/ASTWriterDecl.cpp

Removed: 




diff  --git a/clang/include/clang/AST/DeclBase.h 
b/clang/include/clang/AST/DeclBase.h
index ba6dadd7d3563c3..7b743edf9452526 100644
--- a/clang/include/clang/AST/DeclBase.h
+++ b/clang/include/clang/AST/DeclBase.h
@@ -1422,6 +1422,12 @@ enum class ArgPassingKind {
   CanNeverPassInRegs
 };
 
+enum class OMPDeclareReductionInitKind {
+  Call,   // Initialized by function call.
+  Direct, // omp_priv()
+  Copy// omp_priv = 
+};
+
 /// DeclContext - This is used only as base class of specific decl types that
 /// can act as declaration contexts. These decls are (only the top classes
 /// that directly derive from DeclContext are mentioned, not their subclasses):

diff  --git a/clang/include/clang/AST/DeclOpenMP.h 
b/clang/include/clang/AST/DeclOpenMP.h
index dd63a4f5d680cf5..2bbd159f59a3536 100644
--- a/clang/include/clang/AST/DeclOpenMP.h
+++ b/clang/include/clang/AST/DeclOpenMP.h
@@ -171,14 +171,7 @@ class OMPThreadPrivateDecl final : public 
OMPDeclarativeDirective {
 class OMPDeclareReductionDecl final : public ValueDecl, public DeclContext {
   // This class stores some data in DeclContext::OMPDeclareReductionDeclBits
   // to save some space. Use the provided accessors to access it.
-public:
-  enum InitKind {
-CallInit,   // Initialized by function call.
-DirectInit, // omp_priv()
-CopyInit// omp_priv = 
-  };
 
-private:
   friend class ASTDeclReader;
   /// Combiner for declare reduction construct.
   Expr *Combiner = nullptr;
@@ -239,8 +232,9 @@ class OMPDeclareReductionDecl final : public ValueDecl, 
public DeclContext {
   Expr *getInitializer() { return Initializer; }
   const Expr *getInitializer() const { return Initializer; }
   /// Get initializer kind.
-  InitKind getInitializerKind() const {
-return static_cast(OMPDeclareReductionDeclBits.InitializerKind);
+  OMPDeclareReductionInitKind getInitializerKind() const {
+return static_cast(
+OMPDeclareReductionDeclBits.InitializerKind);
   }
   /// Get Orig variable of the initializer.
   Expr *getInitOrig() { return Orig; }
@@ -249,9 +243,9 @@ class OMPDeclareReductionDecl final : public ValueDecl, 
public DeclContext {
   Expr *getInitPriv() { return Priv; }
   const Expr *getInitPriv() const { return Priv; }
   /// Set initializer expression for the declare reduction construct.
-  void setInitializer(Expr *E, InitKind IK) {
+  void setInitializer(Expr *E, OMPDeclareReductionInitKind IK) {
 Initializer = E;
-OMPDeclareReductionDeclBits.InitializerKind = IK;
+OMPDeclareReductionDeclBits.InitializerKind = llvm::to_underlying(IK);
   }
   /// Set initializer Orig and Priv vars.
   void setInitializerData(Expr *OrigE, Expr *PrivE) {

diff  --git a/clang/lib/AST/DeclOpenMP.cpp b/clang/lib/AST/DeclOpenMP.cpp
index e29fc564fd34ac5..ac5780f82dbbb23 100644
--- a/clang/lib/AST/DeclOpenMP.cpp
+++ b/clang/lib/AST/DeclOpenMP.cpp
@@ -104,7 +104,7 @@ OMPDeclareReductionDecl::OMPDeclareReductionDecl(
 QualType Ty, OMPDeclareReductionDecl *PrevDeclInScope)
 : ValueDecl(DK, DC, L, Name, Ty), DeclContext(DK), Combiner(nullptr),
   PrevDeclInScope(PrevDeclInScope) {
-  setInitializer(nullptr, CallInit);
+  setInitializer(nullptr, OMPDeclareReductionInitKind::Call);
 }
 
 void OMPDeclareReductionDecl::anchor() {}

diff  --git a/clang/lib/AST/DeclPrinter.cpp b/clang/lib/AST/DeclPrinter.cpp
index daa219b43c4e6cf..98fba958064a106 100644
--- a/clang/lib/AST/DeclPrinter.cpp
+++ b/clang/lib/AST/DeclPrinter.cpp
@@ -1866,17 +1866,17 @@ void 
DeclPrinter::VisitOMPDeclareReductionDecl(OMPDeclareReductionDecl *D) {
 if (auto *Init = D->getInitializer()) {
   Out << " initializer(";
   switch (D->getInitializerKind()) {
-  case OMPDeclareReductionDecl::DirectInit:
+  case OMPDeclareReductionInitKind::Direct:
 Out << "omp_priv(";
 break;
-  case OMPDeclareReductionDecl::CopyI

[clang] aaba376 - [clang][NFC] Refactor `ObjCMethodDecl::ImplementationControl`

2023-11-01 Thread Vlad Serebrennikov via cfe-commits

Author: Vlad Serebrennikov
Date: 2023-11-01T13:40:11+03:00
New Revision: aaba3761db84032541712899964714f3184e8b3d

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

LOG: [clang][NFC] Refactor `ObjCMethodDecl::ImplementationControl`

This patch moves `ObjCMethodDecl::ImplementationControl` to a DeclBase.h so 
that it's complete at the point where corresponsing bit-field is declared. This 
patch also converts it to a scoped enum `clang::ObjCImplementationControl`.

Added: 


Modified: 
clang/include/clang/AST/DeclBase.h
clang/include/clang/AST/DeclObjC.h
clang/lib/ARCMigrate/ObjCMT.cpp
clang/lib/AST/DeclObjC.cpp
clang/lib/AST/ODRDiagsEmitter.cpp
clang/lib/AST/ODRHash.cpp
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp
clang/lib/Sema/SemaDeclObjC.cpp
clang/lib/Sema/SemaExprObjC.cpp
clang/lib/Sema/SemaObjCProperty.cpp
clang/lib/Sema/SemaPseudoObject.cpp
clang/lib/Serialization/ASTReaderDecl.cpp
clang/lib/Serialization/ASTWriterDecl.cpp
clang/tools/libclang/CIndex.cpp

lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp

Removed: 




diff  --git a/clang/include/clang/AST/DeclBase.h 
b/clang/include/clang/AST/DeclBase.h
index 7b743edf9452526..6f2c5b96554a9d1 100644
--- a/clang/include/clang/AST/DeclBase.h
+++ b/clang/include/clang/AST/DeclBase.h
@@ -1428,6 +1428,8 @@ enum class OMPDeclareReductionInitKind {
   Copy// omp_priv = 
 };
 
+enum class ObjCImplementationControl { None, Required, Optional };
+
 /// DeclContext - This is used only as base class of specific decl types that
 /// can act as declaration contexts. These decls are (only the top classes
 /// that directly derive from DeclContext are mentioned, not their subclasses):

diff  --git a/clang/include/clang/AST/DeclObjC.h 
b/clang/include/clang/AST/DeclObjC.h
index ee8ec7a6a016ba3..2b205bee51de18e 100644
--- a/clang/include/clang/AST/DeclObjC.h
+++ b/clang/include/clang/AST/DeclObjC.h
@@ -139,10 +139,6 @@ class ObjCMethodDecl : public NamedDecl, public 
DeclContext {
   // This class stores some data in DeclContext::ObjCMethodDeclBits
   // to save some space. Use the provided accessors to access it.
 
-public:
-  enum ImplementationControl { None, Required, Optional };
-
-private:
   /// Return type of this method.
   QualType MethodDeclType;
 
@@ -168,14 +164,14 @@ class ObjCMethodDecl : public NamedDecl, public 
DeclContext {
   /// constructed by createImplicitParams.
   ImplicitParamDecl *CmdDecl = nullptr;
 
-  ObjCMethodDecl(SourceLocation beginLoc, SourceLocation endLoc,
- Selector SelInfo, QualType T, TypeSourceInfo *ReturnTInfo,
- DeclContext *contextDecl, bool isInstance = true,
- bool isVariadic = false, bool isPropertyAccessor = false,
- bool isSynthesizedAccessorStub = false,
- bool isImplicitlyDeclared = false, bool isDefined = false,
- ImplementationControl impControl = None,
- bool HasRelatedResultType = false);
+  ObjCMethodDecl(
+  SourceLocation beginLoc, SourceLocation endLoc, Selector SelInfo,
+  QualType T, TypeSourceInfo *ReturnTInfo, DeclContext *contextDecl,
+  bool isInstance = true, bool isVariadic = false,
+  bool isPropertyAccessor = false, bool isSynthesizedAccessorStub = false,
+  bool isImplicitlyDeclared = false, bool isDefined = false,
+  ObjCImplementationControl impControl = ObjCImplementationControl::None,
+  bool HasRelatedResultType = false);
 
   SelectorLocationsKind getSelLocsKind() const {
 return static_cast(ObjCMethodDeclBits.SelLocsKind);
@@ -235,7 +231,7 @@ class ObjCMethodDecl : public NamedDecl, public DeclContext 
{
  bool isVariadic = false, bool isPropertyAccessor = false,
  bool isSynthesizedAccessorStub = false,
  bool isImplicitlyDeclared = false, bool isDefined = false,
- ImplementationControl impControl = None,
+ ObjCImplementationControl impControl = 
ObjCImplementationControl::None,
  bool HasRelatedResultType = false);
 
   static ObjCMethodDecl *CreateDeserialized(ASTContext &C, unsigned ID);
@@ -495,16 +491,17 @@ class ObjCMethodDecl : public NamedDecl, public 
DeclContext {
   const ObjCPropertyDecl *findPropertyDecl(bool CheckOverrides = true) const;
 
   // Related to protocols declared in  \@protocol
-  void setDeclImplementation(ImplementationControl ic) {
-ObjCMethodDeclBits.DeclImplementation = ic;
+  void setDeclImplementation(ObjCImplementationControl ic) {
+ObjCMethodDeclBits.DeclImplementation = llvm::to_underlying(ic);
   }
 
-  ImplementationControl getImplementa

[clang] 6576120 - [clang][NFC] Refactor `LinkageSpecDecl::LanguageIDs`

2023-11-01 Thread Vlad Serebrennikov via cfe-commits

Author: Vlad Serebrennikov
Date: 2023-11-01T16:44:34+03:00
New Revision: 65761200ce4e1f366e8418652efdafd2f744291b

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

LOG: [clang][NFC] Refactor `LinkageSpecDecl::LanguageIDs`

This patch converts `LinkageSpecDecl::LanguageIDs` into scoped enum, and moves 
it to namespace scope, so that it can be forward-declared where required.

Added: 


Modified: 
clang/include/clang/AST/DeclBase.h
clang/include/clang/AST/DeclCXX.h
clang/lib/AST/DeclBase.cpp
clang/lib/AST/DeclCXX.cpp
clang/lib/AST/DeclPrinter.cpp
clang/lib/AST/JSONNodeDumper.cpp
clang/lib/AST/TextNodeDumper.cpp
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaDeclCXX.cpp
clang/lib/Sema/SemaModule.cpp
clang/lib/Serialization/ASTReaderDecl.cpp
clang/lib/Serialization/ASTWriterDecl.cpp
lldb/source/Plugins/ExpressionParser/Clang/NameSearchContext.cpp

Removed: 




diff  --git a/clang/include/clang/AST/DeclBase.h 
b/clang/include/clang/AST/DeclBase.h
index 6f2c5b96554a9d1..32b6aed6397668c 100644
--- a/clang/include/clang/AST/DeclBase.h
+++ b/clang/include/clang/AST/DeclBase.h
@@ -1430,6 +1430,8 @@ enum class OMPDeclareReductionInitKind {
 
 enum class ObjCImplementationControl { None, Required, Optional };
 
+enum class LinkageSpecLanguageIDs;
+
 /// DeclContext - This is used only as base class of specific decl types that
 /// can act as declaration contexts. These decls are (only the top classes
 /// that directly derive from DeclContext are mentioned, not their subclasses):

diff  --git a/clang/include/clang/AST/DeclCXX.h 
b/clang/include/clang/AST/DeclCXX.h
index 5eaae6bdd2bc63e..df1dc5a401f39a5 100644
--- a/clang/include/clang/AST/DeclCXX.h
+++ b/clang/include/clang/AST/DeclCXX.h
@@ -2897,6 +2897,12 @@ class CXXConversionDecl : public CXXMethodDecl {
   static bool classofKind(Kind K) { return K == CXXConversion; }
 };
 
+/// Represents the language in a linkage specification.
+///
+/// The values are part of the serialization ABI for
+/// ASTs and cannot be changed without altering that ABI.
+enum class LinkageSpecLanguageIDs { C = 1, CXX = 2 };
+
 /// Represents a linkage specification.
 ///
 /// For example:
@@ -2907,14 +2913,7 @@ class LinkageSpecDecl : public Decl, public DeclContext {
   virtual void anchor();
   // This class stores some data in DeclContext::LinkageSpecDeclBits to save
   // some space. Use the provided accessors to access it.
-public:
-  /// Represents the language in a linkage specification.
-  ///
-  /// The values are part of the serialization ABI for
-  /// ASTs and cannot be changed without altering that ABI.
-  enum LanguageIDs { lang_c = 1, lang_cxx = 2 };
 
-private:
   /// The source location for the extern keyword.
   SourceLocation ExternLoc;
 
@@ -2922,22 +2921,25 @@ class LinkageSpecDecl : public Decl, public DeclContext 
{
   SourceLocation RBraceLoc;
 
   LinkageSpecDecl(DeclContext *DC, SourceLocation ExternLoc,
-  SourceLocation LangLoc, LanguageIDs lang, bool HasBraces);
+  SourceLocation LangLoc, LinkageSpecLanguageIDs lang,
+  bool HasBraces);
 
 public:
   static LinkageSpecDecl *Create(ASTContext &C, DeclContext *DC,
  SourceLocation ExternLoc,
- SourceLocation LangLoc, LanguageIDs Lang,
- bool HasBraces);
+ SourceLocation LangLoc,
+ LinkageSpecLanguageIDs Lang, bool HasBraces);
   static LinkageSpecDecl *CreateDeserialized(ASTContext &C, unsigned ID);
 
   /// Return the language specified by this linkage specification.
-  LanguageIDs getLanguage() const {
-return static_cast(LinkageSpecDeclBits.Language);
+  LinkageSpecLanguageIDs getLanguage() const {
+return static_cast(LinkageSpecDeclBits.Language);
   }
 
   /// Set the language specified by this linkage specification.
-  void setLanguage(LanguageIDs L) { LinkageSpecDeclBits.Language = L; }
+  void setLanguage(LinkageSpecLanguageIDs L) {
+LinkageSpecDeclBits.Language = llvm::to_underlying(L);
+  }
 
   /// Determines whether this linkage specification had braces in
   /// its syntactic form.

diff  --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp
index a3847a73faf8183..3fd4751d6d1f31d 100644
--- a/clang/lib/AST/DeclBase.cpp
+++ b/clang/lib/AST/DeclBase.cpp
@@ -1320,7 +1320,7 @@ bool DeclContext::isTransparentContext() const {
 }
 
 static bool isLinkageSpecContext(const DeclContext *DC,
- LinkageSpecDecl::LanguageIDs ID) {
+ LinkageSpecLanguageIDs ID) {
   while (DC->getDeclKind() != Decl::Translati

[clang-tools-extra] 008af1c - [clang][NFC] Fix leftovers from `LinkageSpecDecl::LanguageIDs` refactoring

2023-11-01 Thread Vlad Serebrennikov via cfe-commits

Author: Vlad Serebrennikov
Date: 2023-11-01T17:00:55+03:00
New Revision: 008af1c9f4cd0188a69bf42b821749154a8142c8

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

LOG: [clang][NFC] Fix leftovers from `LinkageSpecDecl::LanguageIDs` refactoring

This fixes bot failure 
https://lab.llvm.org/buildbot/#/builders/139/builds/52622 introduced by 
65761200ce4e1f366e8418652efdafd2f744291b

Added: 


Modified: 
clang-tools-extra/clang-tidy/modernize/DeprecatedHeadersCheck.cpp
clang-tools-extra/modularize/Modularize.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/modernize/DeprecatedHeadersCheck.cpp 
b/clang-tools-extra/clang-tidy/modernize/DeprecatedHeadersCheck.cpp
index 9dacf1562429ce1..030a781e2099be7 100644
--- a/clang-tools-extra/clang-tidy/modernize/DeprecatedHeadersCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/DeprecatedHeadersCheck.cpp
@@ -57,7 +57,7 @@ class ExternCRefutationVisitor
   bool shouldVisitLambdaBody() const { return false; }
 
   bool VisitLinkageSpecDecl(LinkageSpecDecl *LinkSpecDecl) const {
-if (LinkSpecDecl->getLanguage() != LinkageSpecDecl::lang_c ||
+if (LinkSpecDecl->getLanguage() != LinkageSpecLanguageIDs::C ||
 !LinkSpecDecl->hasBraces())
   return true;
 

diff  --git a/clang-tools-extra/modularize/Modularize.cpp 
b/clang-tools-extra/modularize/Modularize.cpp
index a7db1df1a1d2542..daa9c048279e03f 100644
--- a/clang-tools-extra/modularize/Modularize.cpp
+++ b/clang-tools-extra/modularize/Modularize.cpp
@@ -574,10 +574,10 @@ class CollectEntitiesVisitor
 SourceRange BlockRange = D->getSourceRange();
 const char *LinkageLabel;
 switch (D->getLanguage()) {
-case LinkageSpecDecl::lang_c:
+case LinkageSpecLanguageIDs::C:
   LinkageLabel = "extern \"C\" {}";
   break;
-case LinkageSpecDecl::lang_cxx:
+case LinkageSpecLanguageIDs::CXX:
   LinkageLabel = "extern \"C++\" {}";
   break;
 }



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


[clang] [clang][NFC] Improve locality of recently refactored enums (PR #70943)

2023-11-01 Thread Vlad Serebrennikov via cfe-commits

https://github.com/Endilll created 
https://github.com/llvm/llvm-project/pull/70943

This patch moves definition of recently refactored enums closer to the types 
where they were originally defined. Since they are scoped enums at namespace 
scope now, they can be forward-declared.

Refactorings in question are:
aaba3761db84032541712899964714f3184e8b3d
50dec541f328a251c2830421f354e4439e635def
b120fe8d3288c4dca1b5427ca34839ce8833f71c
ae7b20b583fab1325d8b51fe5f2eaf612de8b95e
4ad2ada5216ee2bb3c334a3233a9ab51f2521b82
49fd28d9601dde429436655ec74234e895c60b89

I'm going to land this as soon as pre-commit CI goes green, possibly not 
waiting for slow windows bot.

>From dc0737c7ee6df7c4228ecf263696bf13c951e941 Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov 
Date: Wed, 1 Nov 2023 17:49:42 +0300
Subject: [PATCH] [clang][NFC] Improve locality of recently refactored enums

This patch moves definition of recently refactored enums closer to the types 
where they were originally defined. Since they are scoped enums at namespace 
scope now, they can be forward-declared.
---
 clang/include/clang/AST/Decl.h   |  23 +
 clang/include/clang/AST/DeclBase.h   |  34 +---
 clang/include/clang/AST/DeclObjC.h   |   2 +
 clang/include/clang/AST/DeclOpenMP.h |   6 ++
 clang/include/clang/AST/Type.h   | 123 ++-
 5 files changed, 97 insertions(+), 91 deletions(-)

diff --git a/clang/include/clang/AST/Decl.h b/clang/include/clang/AST/Decl.h
index 1c2158f51aa184d..d9b00b1628ab25c 100644
--- a/clang/include/clang/AST/Decl.h
+++ b/clang/include/clang/AST/Decl.h
@@ -4059,6 +4059,29 @@ class EnumDecl : public TagDecl {
   static bool classofKind(Kind K) { return K == Enum; }
 };
 
+/// Enum that represents the different ways arguments are passed to and
+/// returned from function calls. This takes into account the target-specific
+/// and version-specific rules along with the rules determined by the
+/// language.
+enum class ArgPassingKind {
+  /// The argument of this type can be passed directly in registers.
+  CanPassInRegs,
+
+  /// The argument of this type cannot be passed directly in registers.
+  /// Records containing this type as a subobject are not forced to be passed
+  /// indirectly. This value is used only in C++. This value is required by
+  /// C++ because, in uncommon situations, it is possible for a class to have
+  /// only trivial copy/move constructors even when one of its subobjects has
+  /// a non-trivial copy/move constructor (if e.g. the corresponding copy/move
+  /// constructor in the derived class is deleted).
+  CannotPassInRegs,
+
+  /// The argument of this type cannot be passed directly in registers.
+  /// Records containing this type as a subobject are forced to be passed
+  /// indirectly.
+  CanNeverPassInRegs
+};
+
 /// Represents a struct/union/class.  For example:
 ///   struct X;  // Forward declaration, no "body".
 ///   union Y { int A, B; }; // Has body with members A and B (FieldDecls).
diff --git a/clang/include/clang/AST/DeclBase.h 
b/clang/include/clang/AST/DeclBase.h
index 32b6aed6397668c..6704c0cd41ecd3d 100644
--- a/clang/include/clang/AST/DeclBase.h
+++ b/clang/include/clang/AST/DeclBase.h
@@ -1399,37 +1399,9 @@ enum class DeductionCandidate : unsigned char {
   Aggregate,
 };
 
-/// Enum that represents the different ways arguments are passed to and
-/// returned from function calls. This takes into account the target-specific
-/// and version-specific rules along with the rules determined by the
-/// language.
-enum class ArgPassingKind {
-  /// The argument of this type can be passed directly in registers.
-  CanPassInRegs,
-
-  /// The argument of this type cannot be passed directly in registers.
-  /// Records containing this type as a subobject are not forced to be passed
-  /// indirectly. This value is used only in C++. This value is required by
-  /// C++ because, in uncommon situations, it is possible for a class to have
-  /// only trivial copy/move constructors even when one of its subobjects has
-  /// a non-trivial copy/move constructor (if e.g. the corresponding copy/move
-  /// constructor in the derived class is deleted).
-  CannotPassInRegs,
-
-  /// The argument of this type cannot be passed directly in registers.
-  /// Records containing this type as a subobject are forced to be passed
-  /// indirectly.
-  CanNeverPassInRegs
-};
-
-enum class OMPDeclareReductionInitKind {
-  Call,   // Initialized by function call.
-  Direct, // omp_priv()
-  Copy// omp_priv = 
-};
-
-enum class ObjCImplementationControl { None, Required, Optional };
-
+enum class ArgPassingKind;
+enum class OMPDeclareReductionInitKind;
+enum class ObjCImplementationControl;
 enum class LinkageSpecLanguageIDs;
 
 /// DeclContext - This is used only as base class of specific decl types that
diff --git a/clang/include/clang/AST/DeclObjC.h 
b/clang/include/clang/AST/DeclObjC.h
index 2b205bee51de18e..e0b31c58c39a2c5 100644
--- a/clang/inc

[clang] [clang][NFC] Improve locality of recently refactored enums (PR #70943)

2023-11-01 Thread Vlad Serebrennikov via cfe-commits

https://github.com/Endilll closed 
https://github.com/llvm/llvm-project/pull/70943
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [lldb] [clang][NFC] Rename ArgPassingKind to RecordArgPassingKind (PR #70955)

2023-11-01 Thread Vlad Serebrennikov via cfe-commits

https://github.com/Endilll created 
https://github.com/llvm/llvm-project/pull/70955

During the recent refactoring (b120fe8d3288c4dca1b5427ca34839ce8833f71c) this 
enum was moved out of `RecordDecl`. During post-commit review it was found out 
that its association with `RecordDecl` should be expressed in the name.

I'm planning to land this as soon as CI passes, probably without waiting for 
Windows bot.

>From 99013f89d8a5d62828e351e49a11d04fe13645ae Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov 
Date: Wed, 1 Nov 2023 19:24:22 +0300
Subject: [PATCH] [clang][NFC] Rename ArgPassingKind to RecordArgPassingKind

During the recent refactoring (b120fe8d3288c4dca1b5427ca34839ce8833f71c) this 
enum was moved out of `RecordDecl`. During post-commit review it was found out 
that its association with `RecordDecl` should be expresses in the name.
---
 clang/include/clang/AST/Decl.h| 11 ++-
 clang/include/clang/AST/DeclBase.h|  2 +-
 clang/lib/AST/Decl.cpp|  2 +-
 clang/lib/AST/DeclCXX.cpp | 10 +-
 clang/lib/CodeGen/CGCall.cpp  |  3 ++-
 clang/lib/Sema/SemaDecl.cpp   |  8 +---
 clang/lib/Sema/SemaDeclCXX.cpp|  9 +
 clang/lib/Serialization/ASTReaderDecl.cpp |  4 ++--
 .../Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp  |  2 +-
 9 files changed, 28 insertions(+), 23 deletions(-)

diff --git a/clang/include/clang/AST/Decl.h b/clang/include/clang/AST/Decl.h
index d9b00b1628ab25c..d8ea8c1dfb4f292 100644
--- a/clang/include/clang/AST/Decl.h
+++ b/clang/include/clang/AST/Decl.h
@@ -4063,7 +4063,7 @@ class EnumDecl : public TagDecl {
 /// returned from function calls. This takes into account the target-specific
 /// and version-specific rules along with the rules determined by the
 /// language.
-enum class ArgPassingKind {
+enum class RecordArgPassingKind {
   /// The argument of this type can be passed directly in registers.
   CanPassInRegs,
 
@@ -4216,14 +4216,15 @@ class RecordDecl : public TagDecl {
   /// it must have at least one trivial, non-deleted copy or move constructor.
   /// FIXME: This should be set as part of completeDefinition.
   bool canPassInRegisters() const {
-return getArgPassingRestrictions() == ArgPassingKind::CanPassInRegs;
+return getArgPassingRestrictions() == RecordArgPassingKind::CanPassInRegs;
   }
 
-  ArgPassingKind getArgPassingRestrictions() const {
-return static_cast(RecordDeclBits.ArgPassingRestrictions);
+  RecordArgPassingKind getArgPassingRestrictions() const {
+return static_cast(
+RecordDeclBits.ArgPassingRestrictions);
   }
 
-  void setArgPassingRestrictions(ArgPassingKind Kind) {
+  void setArgPassingRestrictions(RecordArgPassingKind Kind) {
 RecordDeclBits.ArgPassingRestrictions = llvm::to_underlying(Kind);
   }
 
diff --git a/clang/include/clang/AST/DeclBase.h 
b/clang/include/clang/AST/DeclBase.h
index 6704c0cd41ecd3d..df1d6e8a3b5af72 100644
--- a/clang/include/clang/AST/DeclBase.h
+++ b/clang/include/clang/AST/DeclBase.h
@@ -1399,7 +1399,7 @@ enum class DeductionCandidate : unsigned char {
   Aggregate,
 };
 
-enum class ArgPassingKind;
+enum class RecordArgPassingKind;
 enum class OMPDeclareReductionInitKind;
 enum class ObjCImplementationControl;
 enum class LinkageSpecLanguageIDs;
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index 28243a76712d63e..6efc177d61c03ba 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -4932,7 +4932,7 @@ RecordDecl::RecordDecl(Kind DK, TagKind TK, const 
ASTContext &C,
   setHasNonTrivialToPrimitiveDestructCUnion(false);
   setHasNonTrivialToPrimitiveCopyCUnion(false);
   setParamDestroyedInCallee(false);
-  setArgPassingRestrictions(ArgPassingKind::CanPassInRegs);
+  setArgPassingRestrictions(RecordArgPassingKind::CanPassInRegs);
   setIsRandomized(false);
   setODRHash(0);
 }
diff --git a/clang/lib/AST/DeclCXX.cpp b/clang/lib/AST/DeclCXX.cpp
index 066b62b7c24110d..4002c63e9f94c12 100644
--- a/clang/lib/AST/DeclCXX.cpp
+++ b/clang/lib/AST/DeclCXX.cpp
@@ -446,8 +446,8 @@ CXXRecordDecl::setBases(CXXBaseSpecifier const * const 
*Bases,
   setHasVolatileMember(true);
 
 if (BaseClassDecl->getArgPassingRestrictions() ==
-ArgPassingKind::CanNeverPassInRegs)
-  setArgPassingRestrictions(ArgPassingKind::CanNeverPassInRegs);
+RecordArgPassingKind::CanNeverPassInRegs)
+  setArgPassingRestrictions(RecordArgPassingKind::CanNeverPassInRegs);
 
 // Keep track of the presence of mutable fields.
 if (BaseClassDecl->hasMutableFields())
@@ -1032,7 +1032,7 @@ void CXXRecordDecl::addedMember(Decl *D) {
 
 // Structs with __weak fields should never be passed directly.
 if (LT == Qualifiers::OCL_Weak)
-  setArgPassingRestrictions(ArgPassingKind::CanNeverPassInRegs);
+  setArgPassingRestrictions(RecordArgPassingKind:

[lldb] [clang] [clang][NFC] Rename ArgPassingKind to RecordArgPassingKind (PR #70955)

2023-11-01 Thread Vlad Serebrennikov via cfe-commits

https://github.com/Endilll closed 
https://github.com/llvm/llvm-project/pull/70955
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [analyzer][NFC] Rework SVal kind representation (PR #71039)

2023-11-02 Thread Vlad Serebrennikov via cfe-commits

https://github.com/Endilll edited 
https://github.com/llvm/llvm-project/pull/71039
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [analyzer][NFC] Rework SVal kind representation (PR #71039)

2023-11-02 Thread Vlad Serebrennikov via cfe-commits

https://github.com/Endilll commented:

Converting packed `unsigned Kind` into non-packed `SValKind Kind` is definitely 
going to help debuggers to display the value correctly.

But I have to point out that this patch doesn't address the fact that `const 
void* Data` is not friendly to debuggers, especially with type information 
encoded in another member. So even with this patch applied, someone would still 
have to write (and maintain) a custom formatter on debugger side to display 
`Data` correctly.

If you refactor `const void* Data` to be a `llvm::PointerUnion`, then it will 
be picked up automatically (`PointerUnion` is a popular type, so I've already 
written a formatter for it.) Together with removing `BaseBits` from `Kind` and 
making the latter non-packed, `SVal` will have a debugger-friendly layout.

That said, debugger-friendliness is probably not among top priorities, so I'm 
not going to block this patch, if this is the direction you and reviewers want 
to take.

https://github.com/llvm/llvm-project/pull/71039
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [analyzer][NFC] Rework SVal kind representation (PR #71039)

2023-11-02 Thread Vlad Serebrennikov via cfe-commits


@@ -105,38 +86,25 @@ class SVal {
 return llvm::dyn_cast(*this);
   }
 
-  unsigned getRawKind() const { return Kind; }
-  BaseKind getBaseKind() const { return (BaseKind) (Kind & BaseMask); }
-  unsigned getSubKind() const { return Kind >> BaseBits; }
+  SValKind getKind() const { return Kind; }
 
   // This method is required for using SVal in a FoldingSetNode.  It
   // extracts a unique signature for this SVal object.
   void Profile(llvm::FoldingSetNodeID &ID) const {
-ID.AddInteger((unsigned) getRawKind());
+ID.AddInteger((unsigned)getKind());

Endilll wrote:

I think recently introduced `llvm::to_underlying()` is a better fit here.

https://github.com/llvm/llvm-project/pull/71039
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] [clang][NFC] Refactor `clang::Linkage` (PR #71049)

2023-11-02 Thread Vlad Serebrennikov via cfe-commits

https://github.com/Endilll created 
https://github.com/llvm/llvm-project/pull/71049

This patch introduces a new enumerator `Invalid = 0`, shifting other 
enumerators by +1. Contrary to how it might sound, this actually affirms status 
quo of how this enum is stored in `clang::Decl`:
```
  /// If 0, we have not computed the linkage of this declaration.
  /// Otherwise, it is the linkage + 1.
  mutable unsigned CacheValidAndLinkage : 3;
```
This patch makes debuggers to not be mistaken about enumerator stored in this 
bit-field. It also converts `clang::Linkage` to a scoped enum.

>From 05089e60021c321b4113db7e4bdf59bdaaa19de7 Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov 
Date: Thu, 2 Nov 2023 14:40:12 +0300
Subject: [PATCH] [clang][NFC] Refactor `clang::Linkage`

This patch introduces a new enumerator `Invalid = 0`, shifting other 
enumerators by +1. Contrary to how it might sound, this actually affirms status 
quo of how this enum is stored in `clang::Decl`:
```
  /// If 0, we have not computed the linkage of this declaration.
  /// Otherwise, it is the linkage + 1.
  mutable unsigned CacheValidAndLinkage : 3;
```
This patch makes debuggers to not be mistaken about enumerator stored in this 
bit-field. It also converts `clang::Linkage` to a scoped enum.
---
 clang-tools-extra/clang-doc/Serialize.cpp |  4 +-
 clang-tools-extra/clangd/Quality.cpp  |  3 +-
 .../clangd/SemanticHighlighting.cpp   |  3 +-
 clang/include/clang/AST/DeclBase.h| 11 ++--
 clang/include/clang/AST/Type.h|  2 +-
 clang/include/clang/Basic/Linkage.h   | 53 +++---
 clang/include/clang/Basic/Visibility.h| 28 +-
 clang/lib/AST/APValue.cpp |  2 +-
 clang/lib/AST/Decl.cpp| 28 +++---
 clang/lib/AST/ItaniumMangle.cpp   |  4 +-
 clang/lib/AST/MicrosoftMangle.cpp |  5 +-
 clang/lib/AST/Type.cpp|  8 +--
 clang/lib/CodeGen/CodeGenModule.cpp   |  4 +-
 clang/lib/CodeGen/ItaniumCXXABI.cpp   | 15 +++--
 clang/lib/CodeGen/MicrosoftCXXABI.cpp | 15 +++--
 clang/lib/Index/IndexSymbol.cpp   | 20 ---
 clang/lib/Sema/SemaChecking.cpp   |  2 +-
 clang/lib/Sema/SemaDecl.cpp   | 24 
 clang/lib/Sema/SemaExpr.cpp   |  2 +-
 clang/lib/Sema/SemaModule.cpp |  6 +-
 clang/lib/Sema/SemaOverload.cpp   |  2 +-
 clang/lib/Sema/SemaTemplate.cpp   |  4 +-
 clang/lib/Serialization/ASTReaderDecl.cpp |  4 +-
 clang/lib/Serialization/ASTWriterDecl.cpp |  6 +-
 .../ClangExtDefMapGen.cpp |  8 ++-
 clang/tools/libclang/CIndex.cpp   | 14 +++--
 clang/tools/libclang/CXIndexDataConsumer.cpp  | 56 +--
 clang/unittests/AST/DeclTest.cpp  |  8 +--
 28 files changed, 189 insertions(+), 152 deletions(-)

diff --git a/clang-tools-extra/clang-doc/Serialize.cpp 
b/clang-tools-extra/clang-doc/Serialize.cpp
index ac8e253ac06ea0b..3b074d849e8a9cf 100644
--- a/clang-tools-extra/clang-doc/Serialize.cpp
+++ b/clang-tools-extra/clang-doc/Serialize.cpp
@@ -257,8 +257,8 @@ static bool isPublic(const clang::AccessSpecifier AS,
  const clang::Linkage Link) {
   if (AS == clang::AccessSpecifier::AS_private)
 return false;
-  else if ((Link == clang::Linkage::ModuleLinkage) ||
-   (Link == clang::Linkage::ExternalLinkage))
+  else if ((Link == clang::Linkage::Module) ||
+   (Link == clang::Linkage::External))
 return true;
   return false; // otherwise, linkage is some form of internal linkage
 }
diff --git a/clang-tools-extra/clangd/Quality.cpp 
b/clang-tools-extra/clangd/Quality.cpp
index 8840f805f0e87c7..7371d95fbf27547 100644
--- a/clang-tools-extra/clangd/Quality.cpp
+++ b/clang-tools-extra/clangd/Quality.cpp
@@ -274,7 +274,8 @@ computeScope(const NamedDecl *D) {
 return SymbolRelevanceSignals::ClassScope;
   // ExternalLinkage threshold could be tweaked, e.g. module-visible as global.
   // Avoid caching linkage if it may change after enclosing code completion.
-  if (hasUnstableLinkage(D) || D->getLinkageInternal() < ExternalLinkage)
+  if (hasUnstableLinkage(D) || llvm::to_underlying(D->getLinkageInternal()) <
+   llvm::to_underlying(Linkage::External))
 return SymbolRelevanceSignals::FileScope;
   return SymbolRelevanceSignals::GlobalScope;
 }
diff --git a/clang-tools-extra/clangd/SemanticHighlighting.cpp 
b/clang-tools-extra/clangd/SemanticHighlighting.cpp
index 7649e37e1f96663..49e479abf456210 100644
--- a/clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ b/clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -617,7 +617,8 @@ std::optional scopeModifier(const 
NamedDecl *D) {
   if (DC->isTranslationUnit() && D->isTemplateParameter())
 return std::nullopt;
   // ExternalLinkage threshold could be tweaked, e.g. module-visibl

[clang] [clang-tools-extra] [clang][NFC] Refactor `clang::Linkage` (PR #71049)

2023-11-02 Thread Vlad Serebrennikov via cfe-commits


@@ -84,22 +88,33 @@ inline bool isUniqueGVALinkage(GVALinkage L) {
 }
 
 inline bool isExternallyVisible(Linkage L) {
-  return L >= VisibleNoLinkage;
+  switch (L) {
+  case Linkage::Invalid:
+llvm_unreachable("Linkage hasn't been computed!");

Endilll wrote:

@AaronBallman I sprinkled a lot of `llvm_unreachable` in this patch, following 
an example I've seen in one of the switches on `Linkage`. Let me know if you'd 
like this to be handled in a different way.

https://github.com/llvm/llvm-project/pull/71049
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] [clang][NFC] Refactor `clang::Linkage` (PR #71049)

2023-11-02 Thread Vlad Serebrennikov via cfe-commits


@@ -2214,7 +2214,7 @@ void ASTWriter::WriteDeclAbbrevs() {
   Abv->Add(BitCodeAbbrevOp(0));   // TSCSpec
   Abv->Add(BitCodeAbbrevOp(0));   // InitStyle
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isARCPseudoStrong
-  Abv->Add(BitCodeAbbrevOp(0));   // Linkage
+  Abv->Add(BitCodeAbbrevOp(1)); // Linkage

Endilll wrote:

@ChuanqiXu9 confirmed that touching this is fine (thank you!). If I guess 
correctly that this value corresponds to `Linkage::None` we have in some 
default constructors, we should consider changing that default to 
`Linkage::Invalid`.

`Linkage::None` being default feels like we computed the linkage and arrived at 
`Linkage::None` even when it's not the case.

CC @AaronBallman 

https://github.com/llvm/llvm-project/pull/71049
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [analyzer][NFC] Rework SVal kind representation (PR #71039)

2023-11-02 Thread Vlad Serebrennikov via cfe-commits

Endilll wrote:

> I've considered this but I found the number of alternatives too large to make 
> it feasible. Consider that we have 11 possible SValKinds, which would require 
> 4 bits to encode. Requiring all Data pointers to be aligned as such seems 
> rough - although not impossible.

Sorry, I missed the part that you can have 11 different types there. 
`alignas(16)` might not be unreasonable, but it depends and requires 
consideration.

> I'd say it's one baby step in that direction, but not the end of the journey. 
> How about looking at this like that?

No objections to this point of view. I just wanted to make sure debugger 
struggles are brought up in the discussion and understood.

https://github.com/llvm/llvm-project/pull/71039
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [analyzer][NFC] Rework SVal kind representation (PR #71039)

2023-11-02 Thread Vlad Serebrennikov via cfe-commits

https://github.com/Endilll approved this pull request.


https://github.com/llvm/llvm-project/pull/71039
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Remove diagnostic that came with `[[clang::preferred_type]]` (PR #70632)

2023-11-02 Thread Vlad Serebrennikov via cfe-commits

https://github.com/Endilll closed 
https://github.com/llvm/llvm-project/pull/70632
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [clang-tools-extra] [clang][NFC] Annotate `Type` bit-fields with `clang::preferred_type` (PR #70349)

2023-11-02 Thread Vlad Serebrennikov via cfe-commits

https://github.com/Endilll updated 
https://github.com/llvm/llvm-project/pull/70349

>From 7329f68092d5f8f5a5978e5a6cbad6ada87d4fe8 Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov 
Date: Thu, 26 Oct 2023 16:09:25 +0300
Subject: [PATCH 1/6] [clang][NFC] Annotate `Type` bit-fields with
 `clang::preferred_type`

---
 clang/include/clang/AST/DeclBase.h|  2 +-
 clang/include/clang/AST/DependenceFlags.h |  2 +-
 clang/include/clang/AST/Type.h| 46 ++-
 clang/include/clang/Basic/Linkage.h   |  2 +-
 4 files changed, 47 insertions(+), 5 deletions(-)

diff --git a/clang/include/clang/AST/DeclBase.h 
b/clang/include/clang/AST/DeclBase.h
index 978e4255e877ec2..0307691fdd480bf 100644
--- a/clang/include/clang/AST/DeclBase.h
+++ b/clang/include/clang/AST/DeclBase.h
@@ -49,7 +49,7 @@ class ExternalSourceSymbolAttr;
 class FunctionDecl;
 class FunctionType;
 class IdentifierInfo;
-enum Linkage : unsigned char;
+enum Linkage : unsigned;
 class LinkageSpecDecl;
 class Module;
 class NamedDecl;
diff --git a/clang/include/clang/AST/DependenceFlags.h 
b/clang/include/clang/AST/DependenceFlags.h
index 3b3c1afb096addd..e91b6ff35b34966 100644
--- a/clang/include/clang/AST/DependenceFlags.h
+++ b/clang/include/clang/AST/DependenceFlags.h
@@ -49,7 +49,7 @@ struct ExprDependenceScope {
 using ExprDependence = ExprDependenceScope::ExprDependence;
 
 struct TypeDependenceScope {
-  enum TypeDependence : uint8_t {
+  enum TypeDependence : unsigned {
 /// Whether this type contains an unexpanded parameter pack
 /// (for C++11 variadic templates)
 UnexpandedPack = 1,
diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index 1e8e1303e65f6ba..f24b1dccc240785 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -1611,22 +1611,28 @@ class alignas(TypeAlignment) Type : public 
ExtQualsTypeCommonBase {
 template  friend class TypePropertyCache;
 
 /// TypeClass bitfield - Enum that specifies what subclass this belongs to.
+[[clang::preferred_type(TypeClass)]]
 unsigned TC : 8;
 
 /// Store information on the type dependency.
+[[clang::preferred_type(TypeDependence)]]
 unsigned Dependence : llvm::BitWidth;
 
 /// True if the cache (i.e. the bitfields here starting with
 /// 'Cache') is valid.
+[[clang::preferred_type(bool)]]
 mutable unsigned CacheValid : 1;
 
 /// Linkage of this type.
+[[clang::preferred_type(Linkage)]]
 mutable unsigned CachedLinkage : 3;
 
 /// Whether this type involves and local or unnamed types.
+[[clang::preferred_type(bool)]]
 mutable unsigned CachedLocalOrUnnamed : 1;
 
 /// Whether this type comes from an AST file.
+[[clang::preferred_type(bool)]]
 mutable unsigned FromAST : 1;
 
 bool isCacheValid() const {
@@ -1652,10 +1658,12 @@ class alignas(TypeAlignment) Type : public 
ExtQualsTypeCommonBase {
   class ArrayTypeBitfields {
 friend class ArrayType;
 
+[[clang::preferred_type(TypeBitfields)]]
 unsigned : NumTypeBits;
 
 /// CVR qualifiers from declarations like
 /// 'int X[static restrict 4]'. For function parameters only.
+[[clang::preferred_type(Qualifiers)]]
 unsigned IndexTypeQuals : 3;
 
 /// Storage class qualifiers from declarations like
@@ -1671,12 +1679,14 @@ class alignas(TypeAlignment) Type : public 
ExtQualsTypeCommonBase {
 unsigned : NumArrayTypeBits;
 
 /// Whether we have a stored size expression.
+[[clang::preferred_type(bool)]]
 unsigned HasStoredSizeExpr : 1;
   };
 
   class BuiltinTypeBitfields {
 friend class BuiltinType;
 
+[[clang::preferred_type(TypeBitfields)]]
 unsigned : NumTypeBits;
 
 /// The kind (BuiltinType::Kind) of builtin type this is.
@@ -1691,15 +1701,18 @@ class alignas(TypeAlignment) Type : public 
ExtQualsTypeCommonBase {
 friend class FunctionProtoType;
 friend class FunctionType;
 
+[[clang::preferred_type(TypeBitfields)]]
 unsigned : NumTypeBits;
 
 /// Extra information which affects how the function is called, like
 /// regparm and the calling convention.
+[[clang::preferred_type(CallingConv)]]
 unsigned ExtInfo : 13;
 
 /// The ref-qualifier associated with a \c FunctionProtoType.
 ///
 /// This is a value of type \c RefQualifierKind.
+[[clang::preferred_type(RefQualifierKind)]]
 unsigned RefQualifier : 2;
 
 /// Used only by FunctionProtoType, put here to pack with the
@@ -1708,8 +1721,10 @@ class alignas(TypeAlignment) Type : public 
ExtQualsTypeCommonBase {
 ///
 /// C++ 8.3.5p4: The return type, the parameter type list and the
 /// cv-qualifier-seq, [...], are part of the function type.
+[[clang::preferred_type(Qualifiers)]]
 unsigned FastTypeQuals : Qualifiers::FastWidth;
 /// Whether this function has extended Qualifiers.
+[[clang::preferred_type(bool)]]
 unsigned HasExtQuals : 1;
 
 /// The number of parameters 

[clang-tools-extra] [clang] [clang][NFC] Refactor `clang::Linkage` (PR #71049)

2023-11-02 Thread Vlad Serebrennikov via cfe-commits


@@ -1921,7 +1920,20 @@ bool NamedDecl::declarationReplaces(NamedDecl *OldD, 
bool IsKnownNewer) const {
 }
 
 bool NamedDecl::hasLinkage() const {
-  return getFormalLinkage() != NoLinkage;
+  switch (getFormalLinkage()) {
+  case Linkage::Invalid:
+llvm_unreachable("Linkage hasn't been computed!");
+  case Linkage::None:
+return false;
+  case Linkage::Internal:
+return true;
+  case Linkage::UniqueExternal:
+  case Linkage::VisibleNone:
+llvm_unreachable("Non-formal linkage is not allowed here!");

Endilll wrote:

As I was making sure that `Linkage::Invalid` doesn't creep up where it wasn't 
before, I converted this to a switch. Then I realized that `UniqueExternal` and 
`VisibleNone` is not something `getFormalLinkage()` allowed to return, and did 
a drive-by fix. Since this patch is up for review anyway, I can remove `[NFC]` 
tag.

https://github.com/llvm/llvm-project/pull/71049
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] [clang][NFC] Refactor `clang::Linkage` (PR #71049)

2023-11-02 Thread Vlad Serebrennikov via cfe-commits


@@ -560,7 +562,7 @@ bool CXIndexDataConsumer::handleDecl(const NamedDecl *D,
 
   if (shouldSuppressRefs())
 markEntityOccurrenceInFile(D, Loc);
-  
+

Endilll wrote:

I guess that's clang-format at work. I'll revert this.

https://github.com/llvm/llvm-project/pull/71049
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   3   4   5   6   7   8   9   10   >