[clang] 58eadc4 - [clang][AST][NFC] Simplify ExplicitSpecifier (#193984)
via cfe-commits
cfe-commits at lists.llvm.org
Sun May 3 09:12:46 PDT 2026
Author: halbi2
Date: 2026-05-03T18:12:41+02:00
New Revision: 58eadc45c28ac5f321dd5be537192e887c01dc31
URL: https://github.com/llvm/llvm-project/commit/58eadc45c28ac5f321dd5be537192e887c01dc31
DIFF: https://github.com/llvm/llvm-project/commit/58eadc45c28ac5f321dd5be537192e887c01dc31.diff
LOG: [clang][AST][NFC] Simplify ExplicitSpecifier (#193984)
One overload of each of these functions is all that is needed.
Added:
Modified:
clang/include/clang/AST/DeclCXX.h
clang/lib/AST/DeclCXX.cpp
Removed:
################################################################################
diff --git a/clang/include/clang/AST/DeclCXX.h b/clang/include/clang/AST/DeclCXX.h
index 2af396f025c93..cc4b4ff9db273 100644
--- a/clang/include/clang/AST/DeclCXX.h
+++ b/clang/include/clang/AST/DeclCXX.h
@@ -1948,7 +1948,7 @@ class ExplicitSpecifier {
/// Check for equivalence of explicit specifiers.
/// \return true if the explicit specifier are equivalent, false otherwise.
- bool isEquivalent(const ExplicitSpecifier Other) const;
+ bool isEquivalent(ExplicitSpecifier Other) const;
/// Determine whether this specifier is known to correspond to an explicit
/// declaration. Returns false if the specifier is absent or has an
/// expression that is value-dependent or evaluates to false.
@@ -1964,10 +1964,7 @@ class ExplicitSpecifier {
void setKind(ExplicitSpecKind Kind) { ExplicitSpec.setInt(Kind); }
void setExpr(Expr *E) { ExplicitSpec.setPointer(E); }
// Retrieve the explicit specifier in the given declaration, if any.
- static ExplicitSpecifier getFromDecl(FunctionDecl *Function);
- static const ExplicitSpecifier getFromDecl(const FunctionDecl *Function) {
- return getFromDecl(const_cast<FunctionDecl *>(Function));
- }
+ static ExplicitSpecifier getFromDecl(const FunctionDecl *Function);
static ExplicitSpecifier Invalid() {
return ExplicitSpecifier(nullptr, ExplicitSpecKind::Unresolved);
}
@@ -2041,8 +2038,7 @@ class CXXDeductionGuideDecl : public FunctionDecl {
static CXXDeductionGuideDecl *CreateDeserialized(ASTContext &C,
GlobalDeclID ID);
- ExplicitSpecifier getExplicitSpecifier() { return ExplicitSpec; }
- const ExplicitSpecifier getExplicitSpecifier() const { return ExplicitSpec; }
+ ExplicitSpecifier getExplicitSpecifier() const { return ExplicitSpec; }
/// Return true if the declaration is already resolved to be explicit.
bool isExplicit() const { return ExplicitSpec.isExplicit(); }
@@ -2693,10 +2689,7 @@ class CXXConstructorDecl final
CXXConstructorDeclBits.IsSimpleExplicit = ES.isExplicit();
}
- ExplicitSpecifier getExplicitSpecifier() {
- return getCanonicalDecl()->getExplicitSpecifierInternal();
- }
- const ExplicitSpecifier getExplicitSpecifier() const {
+ ExplicitSpecifier getExplicitSpecifier() const {
return getCanonicalDecl()->getExplicitSpecifierInternal();
}
@@ -2983,11 +2976,7 @@ class CXXConversionDecl : public CXXMethodDecl {
const AssociatedConstraint &TrailingRequiresClause = {});
static CXXConversionDecl *CreateDeserialized(ASTContext &C, GlobalDeclID ID);
- ExplicitSpecifier getExplicitSpecifier() {
- return getCanonicalDecl()->ExplicitSpec;
- }
-
- const ExplicitSpecifier getExplicitSpecifier() const {
+ ExplicitSpecifier getExplicitSpecifier() const {
return getCanonicalDecl()->ExplicitSpec;
}
diff --git a/clang/lib/AST/DeclCXX.cpp b/clang/lib/AST/DeclCXX.cpp
index 3b9d888bb2c0a..1a4753fc29b88 100644
--- a/clang/lib/AST/DeclCXX.cpp
+++ b/clang/lib/AST/DeclCXX.cpp
@@ -2354,7 +2354,7 @@ bool CXXRecordDecl::isEffectivelyFinal() const {
void CXXDeductionGuideDecl::anchor() {}
-bool ExplicitSpecifier::isEquivalent(const ExplicitSpecifier Other) const {
+bool ExplicitSpecifier::isEquivalent(ExplicitSpecifier Other) const {
if ((getKind() != Other.getKind() ||
getKind() == ExplicitSpecKind::Unresolved)) {
if (getKind() == ExplicitSpecKind::Unresolved &&
@@ -2369,7 +2369,7 @@ bool ExplicitSpecifier::isEquivalent(const ExplicitSpecifier Other) const {
return true;
}
-ExplicitSpecifier ExplicitSpecifier::getFromDecl(FunctionDecl *Function) {
+ExplicitSpecifier ExplicitSpecifier::getFromDecl(const FunctionDecl *Function) {
switch (Function->getDeclKind()) {
case Decl::Kind::CXXConstructor:
return cast<CXXConstructorDecl>(Function)->getExplicitSpecifier();
More information about the cfe-commits
mailing list