[clang-tools-extra] [clang] [Clang][NFC] Rename CXXMethodDecl::isPure -> is VirtualPure (PR #78463)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Jan 17 08:30:56 PST 2024
https://github.com/cor3ntin created https://github.com/llvm/llvm-project/pull/78463
To avoid any possible confusion with the notion of pure function and the gnu::pure attribute.
>From dccf65bc3771b1885c70e47e7d786c662c7f4fd3 Mon Sep 17 00:00:00 2001
From: Corentin Jabot <corentinjabot at gmail.com>
Date: Wed, 17 Jan 2024 17:28:38 +0100
Subject: [PATCH] [Clang][NFC] Rename CXXMethodDecl::isPure -> is VirtualPure
To avoid any possible confusion with the notion of pure
function and the gnu::pure attribute.
---
.../fuchsia/MultipleInheritanceCheck.cpp | 6 +++---
.../modernize/UseEqualsDeleteCheck.cpp | 5 +++--
.../clangd/SemanticHighlighting.cpp | 2 +-
clang-tools-extra/clangd/XRefs.cpp | 2 +-
clang/include/clang/AST/Decl.h | 4 ++--
clang/include/clang/AST/DeclBase.h | 2 +-
clang/include/clang/AST/DeclCXX.h | 4 ++--
clang/include/clang/ASTMatchers/ASTMatchers.h | 4 +---
clang/lib/AST/ASTImporter.cpp | 2 +-
clang/lib/AST/ASTStructuralEquivalence.cpp | 2 +-
clang/lib/AST/Decl.cpp | 6 +++---
clang/lib/AST/DeclCXX.cpp | 6 +++---
clang/lib/AST/DeclPrinter.cpp | 2 +-
clang/lib/AST/ExprConstant.cpp | 2 +-
clang/lib/AST/Interp/Interp.cpp | 2 +-
clang/lib/AST/JSONNodeDumper.cpp | 2 +-
clang/lib/AST/ODRDiagsEmitter.cpp | 4 ++--
clang/lib/AST/ODRHash.cpp | 2 +-
clang/lib/AST/RecordLayoutBuilder.cpp | 4 ++--
clang/lib/AST/TextNodeDumper.cpp | 2 +-
clang/lib/AST/VTableBuilder.cpp | 18 +++++++++---------
clang/lib/CodeGen/CGDebugInfo.cpp | 2 +-
clang/lib/CodeGen/CGVTables.cpp | 2 +-
clang/lib/Sema/Sema.cpp | 2 +-
clang/lib/Sema/SemaDecl.cpp | 9 +++++----
clang/lib/Sema/SemaDeclCXX.cpp | 9 +++++----
clang/lib/Sema/SemaExpr.cpp | 2 +-
clang/lib/Sema/SemaOverload.cpp | 2 +-
clang/lib/Sema/SemaTemplateInstantiateDecl.cpp | 2 +-
clang/lib/Serialization/ASTReaderDecl.cpp | 2 +-
clang/lib/Serialization/ASTWriterDecl.cpp | 2 +-
.../Checkers/VirtualCallChecker.cpp | 2 +-
clang/tools/libclang/CIndex.cpp | 2 +-
33 files changed, 61 insertions(+), 60 deletions(-)
diff --git a/clang-tools-extra/clang-tidy/fuchsia/MultipleInheritanceCheck.cpp b/clang-tools-extra/clang-tidy/fuchsia/MultipleInheritanceCheck.cpp
index 8aecd3ba27b2e3c..aa1d0cce8f87bef 100644
--- a/clang-tools-extra/clang-tidy/fuchsia/MultipleInheritanceCheck.cpp
+++ b/clang-tools-extra/clang-tidy/fuchsia/MultipleInheritanceCheck.cpp
@@ -53,7 +53,7 @@ bool MultipleInheritanceCheck::isCurrentClassInterface(
// Interfaces should have exclusively pure methods.
return llvm::none_of(Node->methods(), [](const CXXMethodDecl *M) {
- return M->isUserProvided() && !M->isPure() && !M->isStatic();
+ return M->isUserProvided() && !M->isVirtualPure() && !M->isStatic();
});
}
@@ -103,8 +103,8 @@ void MultipleInheritanceCheck::check(const MatchFinder::MatchResult &Result) {
const auto *Base = cast<CXXRecordDecl>(Ty->getDecl()->getDefinition());
if (!isInterface(Base)) NumConcrete++;
}
-
- // Check virtual bases to see if there is more than one concrete
+
+ // Check virtual bases to see if there is more than one concrete
// non-virtual base.
for (const auto &V : D->vbases()) {
const auto *Ty = V.getType()->getAs<RecordType>();
diff --git a/clang-tools-extra/clang-tidy/modernize/UseEqualsDeleteCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseEqualsDeleteCheck.cpp
index 059a0af60d3ee84..e6c984aa41ef893 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseEqualsDeleteCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseEqualsDeleteCheck.cpp
@@ -17,11 +17,12 @@ namespace clang::tidy::modernize {
namespace {
AST_MATCHER(FunctionDecl, hasAnyDefinition) {
- if (Node.hasBody() || Node.isPure() || Node.isDefaulted() || Node.isDeleted())
+ if (Node.hasBody() || Node.isVirtualPure() || Node.isDefaulted() ||
+ Node.isDeleted())
return true;
if (const FunctionDecl *Definition = Node.getDefinition())
- if (Definition->hasBody() || Definition->isPure() ||
+ if (Definition->hasBody() || Definition->isVirtualPure() ||
Definition->isDefaulted() || Definition->isDeleted())
return true;
diff --git a/clang-tools-extra/clangd/SemanticHighlighting.cpp b/clang-tools-extra/clangd/SemanticHighlighting.cpp
index 37939d36425a970..79bbbfd7d861b4e 100644
--- a/clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ b/clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -265,7 +265,7 @@ bool isStatic(const Decl *D) {
bool isAbstract(const Decl *D) {
if (const auto *CMD = llvm::dyn_cast<CXXMethodDecl>(D))
- return CMD->isPure();
+ return CMD->isVirtualPure();
if (const auto *CRD = llvm::dyn_cast<CXXRecordDecl>(D))
return CRD->hasDefinition() && CRD->isAbstract();
return false;
diff --git a/clang-tools-extra/clangd/XRefs.cpp b/clang-tools-extra/clangd/XRefs.cpp
index 5f41f788a693939..5ca2080990fc224 100644
--- a/clang-tools-extra/clangd/XRefs.cpp
+++ b/clang-tools-extra/clangd/XRefs.cpp
@@ -427,7 +427,7 @@ locateASTReferent(SourceLocation CurLoc, const syntax::Token *TouchedIdentifier,
// Special case: virtual void ^method() = 0: jump to all overrides.
// FIXME: extend it to ^virtual, unfortunately, virtual location is not
// saved in the AST.
- if (CMD->isPure()) {
+ if (CMD->isVirtualPure()) {
if (TouchedIdentifier && SM.getSpellingLoc(CMD->getLocation()) ==
TouchedIdentifier->location()) {
VirtualMethods.insert(getSymbolID(CMD));
diff --git a/clang/include/clang/AST/Decl.h b/clang/include/clang/AST/Decl.h
index a807bcdd76b30d8..14b5d6cdcc45a68 100644
--- a/clang/include/clang/AST/Decl.h
+++ b/clang/include/clang/AST/Decl.h
@@ -2293,8 +2293,8 @@ class FunctionDecl : public DeclaratorDecl,
/// Whether this virtual function is pure, i.e. makes the containing class
/// abstract.
- bool isPure() const { return FunctionDeclBits.IsPure; }
- void setPure(bool P = true);
+ bool isVirtualPure() const { return FunctionDeclBits.IsVirtualPure; }
+ void setIsVirtualPure(bool P = true);
/// Whether this templated function will be late parsed.
bool isLateTemplateParsed() const {
diff --git a/clang/include/clang/AST/DeclBase.h b/clang/include/clang/AST/DeclBase.h
index 10dcbdb262d84e4..69c3dfed1e31dec 100644
--- a/clang/include/clang/AST/DeclBase.h
+++ b/clang/include/clang/AST/DeclBase.h
@@ -1697,7 +1697,7 @@ class DeclContext {
LLVM_PREFERRED_TYPE(bool)
uint64_t IsVirtualAsWritten : 1;
LLVM_PREFERRED_TYPE(bool)
- uint64_t IsPure : 1;
+ uint64_t IsVirtualPure : 1;
LLVM_PREFERRED_TYPE(bool)
uint64_t HasInheritedPrototype : 1;
LLVM_PREFERRED_TYPE(bool)
diff --git a/clang/include/clang/AST/DeclCXX.h b/clang/include/clang/AST/DeclCXX.h
index 648f5f946408700..d62cb631993276b 100644
--- a/clang/include/clang/AST/DeclCXX.h
+++ b/clang/include/clang/AST/DeclCXX.h
@@ -266,7 +266,7 @@ class CXXRecordDecl : public RecordDecl {
friend class LambdaExpr;
friend class ODRDiagsEmitter;
- friend void FunctionDecl::setPure(bool);
+ friend void FunctionDecl::setIsVirtualPure(bool);
friend void TagDecl::startDefinition();
/// Values used in DefinitionData fields to represent special members.
@@ -2121,7 +2121,7 @@ class CXXMethodDecl : public FunctionDecl {
// Member function is virtual if it is marked explicitly so, or if it is
// declared in __interface -- then it is automatically pure virtual.
- if (CD->isVirtualAsWritten() || CD->isPure())
+ if (CD->isVirtualAsWritten() || CD->isVirtualPure())
return true;
return CD->size_overridden_methods() != 0;
diff --git a/clang/include/clang/ASTMatchers/ASTMatchers.h b/clang/include/clang/ASTMatchers/ASTMatchers.h
index 82a26356c58f556..310ba957b5be6f2 100644
--- a/clang/include/clang/ASTMatchers/ASTMatchers.h
+++ b/clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -6192,9 +6192,7 @@ AST_POLYMORPHIC_MATCHER(isFinal,
/// };
/// \endcode
/// matches A::x
-AST_MATCHER(CXXMethodDecl, isPure) {
- return Node.isPure();
-}
+AST_MATCHER(CXXMethodDecl, isPure) { return Node.isVirtualPure(); }
/// Matches if the given method declaration is const.
///
diff --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp
index c8085c5dd48a596..4640ca00a2fd683 100644
--- a/clang/lib/AST/ASTImporter.cpp
+++ b/clang/lib/AST/ASTImporter.cpp
@@ -3896,7 +3896,7 @@ ExpectedDecl ASTNodeImporter::VisitFunctionDecl(FunctionDecl *D) {
ToFunction->setLexicalDeclContext(LexicalDC);
ToFunction->setVirtualAsWritten(D->isVirtualAsWritten());
ToFunction->setTrivial(D->isTrivial());
- ToFunction->setPure(D->isPure());
+ ToFunction->setIsVirtualPure(D->isVirtualPure());
ToFunction->setDefaulted(D->isDefaulted());
ToFunction->setExplicitlyDefaulted(D->isExplicitlyDefaulted());
ToFunction->setDeletedAsWritten(D->isDeletedAsWritten());
diff --git a/clang/lib/AST/ASTStructuralEquivalence.cpp b/clang/lib/AST/ASTStructuralEquivalence.cpp
index a9e0d1698a9178d..6e6275a48e8b09f 100644
--- a/clang/lib/AST/ASTStructuralEquivalence.cpp
+++ b/clang/lib/AST/ASTStructuralEquivalence.cpp
@@ -1410,7 +1410,7 @@ static bool IsStructurallyEquivalent(StructuralEquivalenceContext &Context,
Method1->isConst() == Method2->isConst() &&
Method1->isVolatile() == Method2->isVolatile() &&
Method1->isVirtual() == Method2->isVirtual() &&
- Method1->isPure() == Method2->isPure() &&
+ Method1->isVirtualPure() == Method2->isVirtualPure() &&
Method1->isDefaulted() == Method2->isDefaulted() &&
Method1->isDeleted() == Method2->isDeleted();
if (!PropertiesEqual)
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index e1440e5183a4e61..09dc9eff74a9044 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -3036,7 +3036,7 @@ FunctionDecl::FunctionDecl(Kind DK, ASTContext &C, DeclContext *DC,
FunctionDeclBits.IsInline = isInlineSpecified;
FunctionDeclBits.IsInlineSpecified = isInlineSpecified;
FunctionDeclBits.IsVirtualAsWritten = false;
- FunctionDeclBits.IsPure = false;
+ FunctionDeclBits.IsVirtualPure = false;
FunctionDeclBits.HasInheritedPrototype = false;
FunctionDeclBits.HasWrittenPrototype = true;
FunctionDeclBits.IsDeleted = false;
@@ -3203,8 +3203,8 @@ void FunctionDecl::setBody(Stmt *B) {
EndRangeLoc = B->getEndLoc();
}
-void FunctionDecl::setPure(bool P) {
- FunctionDeclBits.IsPure = P;
+void FunctionDecl::setIsVirtualPure(bool P) {
+ FunctionDeclBits.IsVirtualPure = P;
if (P)
if (auto *Parent = dyn_cast<CXXRecordDecl>(getDeclContext()))
Parent->markedVirtualFunctionPure();
diff --git a/clang/lib/AST/DeclCXX.cpp b/clang/lib/AST/DeclCXX.cpp
index 98b0a6dc28ea2f0..487f29fd3086d39 100644
--- a/clang/lib/AST/DeclCXX.cpp
+++ b/clang/lib/AST/DeclCXX.cpp
@@ -2054,7 +2054,7 @@ void CXXRecordDecl::completeDefinition(CXXFinalOverriderMap *FinalOverriders) {
// A class is abstract if it contains or inherits at least one
// pure virtual function for which the final overrider is pure
// virtual.
- if (SO->second.front().Method->isPure()) {
+ if (SO->second.front().Method->isVirtualPure()) {
data().Abstract = true;
Done = true;
break;
@@ -2273,7 +2273,7 @@ CXXMethodDecl *CXXMethodDecl::getDevirtualizedMethod(const Expr *Base,
// If the member function is marked 'final', we know that it can't be
// overridden and can therefore devirtualize it unless it's pure virtual.
if (hasAttr<FinalAttr>())
- return isPure() ? nullptr : this;
+ return isVirtualPure() ? nullptr : this;
// If Base is unknown, we cannot devirtualize.
if (!Base)
@@ -2302,7 +2302,7 @@ CXXMethodDecl *CXXMethodDecl::getDevirtualizedMethod(const Expr *Base,
// If that method is pure virtual, we can't devirtualize. If this code is
// reached, the result would be UB, not a direct call to the derived class
// function, and we can't assume the derived class function is defined.
- if (DevirtualizedMethod->isPure())
+ if (DevirtualizedMethod->isVirtualPure())
return nullptr;
// If that method is marked final, we can devirtualize it.
diff --git a/clang/lib/AST/DeclPrinter.cpp b/clang/lib/AST/DeclPrinter.cpp
index 24da6f2ef32b4fc..3eaacf13f74086a 100644
--- a/clang/lib/AST/DeclPrinter.cpp
+++ b/clang/lib/AST/DeclPrinter.cpp
@@ -871,7 +871,7 @@ void DeclPrinter::VisitFunctionDecl(FunctionDecl *D) {
prettyPrintAttributes(D, Out, AttrPrintLoc::Right);
- if (D->isPure())
+ if (D->isVirtualPure())
Out << " = 0";
else if (D->isDeletedAsWritten())
Out << " = delete";
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index f20850d14c0c860..cd0ae365f16754a 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -5839,7 +5839,7 @@ static const CXXMethodDecl *HandleVirtualDispatch(
// C++2a [class.abstract]p6:
// the effect of making a virtual call to a pure virtual function [...] is
// undefined
- if (Callee->isPure()) {
+ if (Callee->isVirtualPure()) {
Info.FFDiag(E, diag::note_constexpr_pure_virtual_call, 1) << Callee;
Info.Note(Callee->getLocation(), diag::note_declared_at);
return nullptr;
diff --git a/clang/lib/AST/Interp/Interp.cpp b/clang/lib/AST/Interp/Interp.cpp
index b95a52199846fa0..5b1f33079a89773 100644
--- a/clang/lib/AST/Interp/Interp.cpp
+++ b/clang/lib/AST/Interp/Interp.cpp
@@ -466,7 +466,7 @@ bool CheckThis(InterpState &S, CodePtr OpPC, const Pointer &This) {
}
bool CheckPure(InterpState &S, CodePtr OpPC, const CXXMethodDecl *MD) {
- if (!MD->isPure())
+ if (!MD->isVirtualPure())
return true;
const SourceInfo &E = S.Current->getSource(OpPC);
S.FFDiag(E, diag::note_constexpr_pure_virtual_call, 1) << MD;
diff --git a/clang/lib/AST/JSONNodeDumper.cpp b/clang/lib/AST/JSONNodeDumper.cpp
index 637d06cee78c852..ff3e8507e333ad0 100644
--- a/clang/lib/AST/JSONNodeDumper.cpp
+++ b/clang/lib/AST/JSONNodeDumper.cpp
@@ -930,7 +930,7 @@ void JSONNodeDumper::VisitFunctionDecl(const FunctionDecl *FD) {
JOS.attribute("storageClass", VarDecl::getStorageClassSpecifierString(SC));
attributeOnlyIfTrue("inline", FD->isInlineSpecified());
attributeOnlyIfTrue("virtual", FD->isVirtualAsWritten());
- attributeOnlyIfTrue("pure", FD->isPure());
+ attributeOnlyIfTrue("pure", FD->isVirtualPure());
attributeOnlyIfTrue("explicitlyDeleted", FD->isDeletedAsWritten());
attributeOnlyIfTrue("constexpr", FD->isConstexpr());
attributeOnlyIfTrue("variadic", FD->isVariadic());
diff --git a/clang/lib/AST/ODRDiagsEmitter.cpp b/clang/lib/AST/ODRDiagsEmitter.cpp
index 9dcd2ed04f6f7d9..203e0d7884a4d90 100644
--- a/clang/lib/AST/ODRDiagsEmitter.cpp
+++ b/clang/lib/AST/ODRDiagsEmitter.cpp
@@ -1102,8 +1102,8 @@ bool ODRDiagsEmitter::diagnoseMismatch(
const bool FirstVirtual = FirstMethod->isVirtualAsWritten();
const bool SecondVirtual = SecondMethod->isVirtualAsWritten();
- const bool FirstPure = FirstMethod->isPure();
- const bool SecondPure = SecondMethod->isPure();
+ const bool FirstPure = FirstMethod->isVirtualPure();
+ const bool SecondPure = SecondMethod->isVirtualPure();
if ((FirstVirtual || SecondVirtual) &&
(FirstVirtual != SecondVirtual || FirstPure != SecondPure)) {
DiagMethodError(MethodVirtual) << FirstPure << FirstVirtual;
diff --git a/clang/lib/AST/ODRHash.cpp b/clang/lib/AST/ODRHash.cpp
index aea1a93ae1fa828..f3319f9d62f3fbf 100644
--- a/clang/lib/AST/ODRHash.cpp
+++ b/clang/lib/AST/ODRHash.cpp
@@ -688,7 +688,7 @@ void ODRHash::AddFunctionDecl(const FunctionDecl *Function,
ID.AddInteger(Function->getStorageClass());
AddBoolean(Function->isInlineSpecified());
AddBoolean(Function->isVirtualAsWritten());
- AddBoolean(Function->isPure());
+ AddBoolean(Function->isVirtualPure());
AddBoolean(Function->isDeletedAsWritten());
AddBoolean(Function->isExplicitlyDefaulted());
diff --git a/clang/lib/AST/RecordLayoutBuilder.cpp b/clang/lib/AST/RecordLayoutBuilder.cpp
index 706991f4fb501c4..699ff5e894bc46e 100644
--- a/clang/lib/AST/RecordLayoutBuilder.cpp
+++ b/clang/lib/AST/RecordLayoutBuilder.cpp
@@ -2349,7 +2349,7 @@ static const CXXMethodDecl *computeKeyFunction(ASTContext &Context,
if (!MD->isVirtual())
continue;
- if (MD->isPure())
+ if (MD->isVirtualPure())
continue;
// Ignore implicit member functions, they are always marked as inline, but
@@ -3293,7 +3293,7 @@ void MicrosoftRecordLayoutBuilder::computeVtorDispSet(
// Seed the working set with our non-destructor, non-pure virtual methods.
for (const CXXMethodDecl *MD : RD->methods())
if (MicrosoftVTableContext::hasVtableSlot(MD) &&
- !isa<CXXDestructorDecl>(MD) && !MD->isPure())
+ !isa<CXXDestructorDecl>(MD) && !MD->isVirtualPure())
Work.insert(MD);
while (!Work.empty()) {
const CXXMethodDecl *MD = *Work.begin();
diff --git a/clang/lib/AST/TextNodeDumper.cpp b/clang/lib/AST/TextNodeDumper.cpp
index 369ff66ac4dbc6d..b82f36ed41eea50 100644
--- a/clang/lib/AST/TextNodeDumper.cpp
+++ b/clang/lib/AST/TextNodeDumper.cpp
@@ -1875,7 +1875,7 @@ void TextNodeDumper::VisitFunctionDecl(const FunctionDecl *D) {
if (D->isModulePrivate())
OS << " __module_private__";
- if (D->isPure())
+ if (D->isVirtualPure())
OS << " pure";
if (D->isDefaulted()) {
OS << " default";
diff --git a/clang/lib/AST/VTableBuilder.cpp b/clang/lib/AST/VTableBuilder.cpp
index 69861c65f6e3ac9..36580eee3387507 100644
--- a/clang/lib/AST/VTableBuilder.cpp
+++ b/clang/lib/AST/VTableBuilder.cpp
@@ -422,7 +422,7 @@ void FinalOverriders::dump(raw_ostream &Out, BaseSubobject Base,
Out << ", " << Overrider.Offset.getQuantity() << ')';
BaseOffset Offset;
- if (!Overrider.Method->isPure())
+ if (!Overrider.Method->isVirtualPure())
Offset = ComputeReturnAdjustmentBaseOffset(Context, Overrider.Method, MD);
if (!Offset.isEmpty()) {
@@ -1261,7 +1261,7 @@ ThisAdjustment ItaniumVTableBuilder::ComputeThisAdjustment(
const CXXMethodDecl *MD, CharUnits BaseOffsetInLayoutClass,
FinalOverriders::OverriderInfo Overrider) {
// Ignore adjustments for pure virtual member functions.
- if (Overrider.Method->isPure())
+ if (Overrider.Method->isVirtualPure())
return ThisAdjustment();
BaseSubobject OverriddenBaseSubobject(MD->getParent(),
@@ -1607,7 +1607,7 @@ void ItaniumVTableBuilder::AddMethods(
// Check if this overrider needs a return adjustment.
// We don't want to do this for pure virtual member functions.
BaseOffset ReturnAdjustmentOffset;
- if (!OverriderMD->isPure()) {
+ if (!OverriderMD->isVirtualPure()) {
ReturnAdjustmentOffset =
ComputeReturnAdjustmentBaseOffset(Context, OverriderMD, MD);
}
@@ -1959,7 +1959,7 @@ void ItaniumVTableBuilder::dumpLayout(raw_ostream &Out) {
std::string Str = PredefinedExpr::ComputeName(
PredefinedIdentKind::PrettyFunctionNoVirtual, MD);
Out << Str;
- if (MD->isPure())
+ if (MD->isVirtualPure())
Out << " [pure]";
if (MD->isDeleted())
@@ -2010,7 +2010,7 @@ void ItaniumVTableBuilder::dumpLayout(raw_ostream &Out) {
else
Out << "() [deleting]";
- if (DD->isPure())
+ if (DD->isVirtualPure())
Out << " [pure]";
ThunkInfo Thunk = VTableThunks.lookup(I);
@@ -2038,7 +2038,7 @@ void ItaniumVTableBuilder::dumpLayout(raw_ostream &Out) {
std::string Str = PredefinedExpr::ComputeName(
PredefinedIdentKind::PrettyFunctionNoVirtual, MD);
Out << "[unused] " << Str;
- if (MD->isPure())
+ if (MD->isVirtualPure())
Out << " [pure]";
}
@@ -3076,7 +3076,7 @@ void VFTableBuilder::AddMethods(BaseSubobject Base, unsigned BaseDepth,
// We don't want to do this for pure virtual member functions.
BaseOffset ReturnAdjustmentOffset;
ReturnAdjustment ReturnAdjustment;
- if (!FinalOverriderMD->isPure()) {
+ if (!FinalOverriderMD->isVirtualPure()) {
ReturnAdjustmentOffset =
ComputeReturnAdjustmentBaseOffset(Context, FinalOverriderMD, MD);
}
@@ -3175,7 +3175,7 @@ void VFTableBuilder::dumpLayout(raw_ostream &Out) {
std::string Str = PredefinedExpr::ComputeName(
PredefinedIdentKind::PrettyFunctionNoVirtual, MD);
Out << Str;
- if (MD->isPure())
+ if (MD->isVirtualPure())
Out << " [pure]";
if (MD->isDeleted())
@@ -3194,7 +3194,7 @@ void VFTableBuilder::dumpLayout(raw_ostream &Out) {
DD->printQualifiedName(Out);
Out << "() [scalar deleting]";
- if (DD->isPure())
+ if (DD->isVirtualPure())
Out << " [pure]";
ThunkInfo Thunk = VTableThunks.lookup(I);
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp
index 236d53bee4e8f18..152921555fe11fb 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -1926,7 +1926,7 @@ llvm::DISubprogram *CGDebugInfo::CreateCXXMemberFunction(
int ThisAdjustment = 0;
if (VTableContextBase::hasVtableSlot(Method)) {
- if (Method->isPure())
+ if (Method->isVirtualPure())
SPFlags |= llvm::DISubprogram::SPFlagPureVirtual;
else
SPFlags |= llvm::DISubprogram::SPFlagVirtual;
diff --git a/clang/lib/CodeGen/CGVTables.cpp b/clang/lib/CodeGen/CGVTables.cpp
index 27a2cab4f75319a..1a9eb6b60d31b82 100644
--- a/clang/lib/CodeGen/CGVTables.cpp
+++ b/clang/lib/CodeGen/CGVTables.cpp
@@ -793,7 +793,7 @@ void CodeGenVTables::addVTableComponent(ConstantArrayBuilder &builder,
llvm::Constant *fnPtr;
// Pure virtual member functions.
- if (cast<CXXMethodDecl>(GD.getDecl())->isPure()) {
+ if (cast<CXXMethodDecl>(GD.getDecl())->isVirtualPure()) {
if (!PureVirtualFn)
PureVirtualFn =
getSpecialVirtualFn(CGM.getCXXABI().GetPureVirtualCallName());
diff --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp
index cafbecebc8a119a..695e32b7ec1b685 100644
--- a/clang/lib/Sema/Sema.cpp
+++ b/clang/lib/Sema/Sema.cpp
@@ -957,7 +957,7 @@ static bool MethodsAndNestedClassesComplete(const CXXRecordDecl *RD,
I != E && Complete; ++I) {
if (const CXXMethodDecl *M = dyn_cast<CXXMethodDecl>(*I))
Complete = M->isDefined() || M->isDefaulted() ||
- (M->isPure() && !isa<CXXDestructorDecl>(M));
+ (M->isVirtualPure() && !isa<CXXDestructorDecl>(M));
else if (const FunctionTemplateDecl *F = dyn_cast<FunctionTemplateDecl>(*I))
// If the template function is marked as late template parsed at this
// point, it has not been instantiated and therefore we have not
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 722e2ac9e4ff8da..fcf0f72ed761b2e 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -4384,8 +4384,8 @@ bool Sema::MergeCompatibleFunctionDecls(FunctionDecl *New, FunctionDecl *Old,
mergeDeclAttributes(New, Old);
// Merge "pure" flag.
- if (Old->isPure())
- New->setPure();
+ if (Old->isVirtualPure())
+ New->setIsVirtualPure();
// Merge "used" flag.
if (Old->getMostRecentDecl()->isUsed(false))
@@ -9873,7 +9873,7 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC,
if (const CXXRecordDecl *Parent =
dyn_cast<CXXRecordDecl>(NewFD->getDeclContext())) {
if (Parent->isInterface() && cast<CXXMethodDecl>(NewFD)->isUserProvided())
- NewFD->setPure(true);
+ NewFD->setIsVirtualPure(true);
// C++ [class.union]p2
// A union can have member functions, but not virtual functions.
@@ -15929,7 +15929,8 @@ Decl *Sema::ActOnFinishFunctionBody(Decl *dcl, Stmt *Body,
// MSVC permits the use of pure specifier (=0) on function definition,
// defined at class scope, warn about this non-standard construct.
- if (getLangOpts().MicrosoftExt && FD->isPure() && !FD->isOutOfLine())
+ if (getLangOpts().MicrosoftExt && FD->isVirtualPure() &&
+ !FD->isOutOfLine())
Diag(FD->getLocation(), diag::ext_pure_function_definition);
if (!FD->isInvalidDecl()) {
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index f229e734d06b283..599c4d110417d41 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -6062,7 +6062,7 @@ void Sema::DiagnoseAbstractType(const CXXRecordDecl *RD) {
if (SO->second.size() != 1)
continue;
- if (!SO->second.front().Method->isPure())
+ if (!SO->second.front().Method->isVirtualPure())
continue;
if (!SeenPureMethods.insert(SO->second.front().Method).second)
@@ -18496,7 +18496,7 @@ bool Sema::CheckPureMethod(CXXMethodDecl *Method, SourceRange InitRange) {
Method->setRangeEnd(EndLoc);
if (Method->isVirtual() || Method->getParent()->isDependentContext()) {
- Method->setPure();
+ Method->setIsVirtualPure();
return false;
}
@@ -18767,7 +18767,7 @@ bool Sema::DefineUsedVTables() {
void Sema::MarkVirtualMemberExceptionSpecsNeeded(SourceLocation Loc,
const CXXRecordDecl *RD) {
for (const auto *I : RD->methods())
- if (I->isVirtual() && !I->isPure())
+ if (I->isVirtual() && !I->isVirtualPure())
ResolveExceptionSpec(Loc, I->getType()->castAs<FunctionProtoType>());
}
@@ -18788,7 +18788,8 @@ void Sema::MarkVirtualMembersReferenced(SourceLocation Loc,
// C++ [basic.def.odr]p2:
// [...] A virtual member function is used if it is not pure. [...]
- if (!Overrider->isPure() && (!ConstexprOnly || Overrider->isConstexpr()))
+ if (!Overrider->isVirtualPure() &&
+ (!ConstexprOnly || Overrider->isConstexpr()))
MarkFunctionReferenced(Loc, Overrider);
}
}
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 2aa192c3909cbec..269227aac0c6c50 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -20771,7 +20771,7 @@ void Sema::MarkMemberReferenced(MemberExpr *E) {
bool MightBeOdrUse = true;
if (E->performsVirtualDispatch(getLangOpts())) {
if (CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(E->getMemberDecl()))
- if (Method->isPure())
+ if (Method->isVirtualPure())
MightBeOdrUse = false;
}
SourceLocation Loc =
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index 37c62b306b3cd3f..6eb032159359598 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -15472,7 +15472,7 @@ ExprResult Sema::BuildCallToMemberFunction(Scope *S, Expr *MemExprE,
}
if (isa<CXXConstructorDecl, CXXDestructorDecl>(CurContext) &&
- TheCall->getDirectCallee()->isPure()) {
+ TheCall->getDirectCallee()->isVirtualPure()) {
const FunctionDecl *MD = TheCall->getDirectCallee();
if (isa<CXXThisExpr>(MemExpr->getBase()->IgnoreParenCasts()) &&
diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
index d768bb72e07c09a..3f6a436b7f2e64b 100644
--- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -2755,7 +2755,7 @@ Decl *TemplateDeclInstantiator::VisitCXXMethodDecl(
IsExplicitSpecialization,
Method->isThisDeclarationADefinition());
- if (D->isPure())
+ if (D->isVirtualPure())
SemaRef.CheckPureMethod(Method, SourceRange());
// Propagate access. For a non-friend declaration, the access is
diff --git a/clang/lib/Serialization/ASTReaderDecl.cpp b/clang/lib/Serialization/ASTReaderDecl.cpp
index 547eb77930b4eec..44b77354158450c 100644
--- a/clang/lib/Serialization/ASTReaderDecl.cpp
+++ b/clang/lib/Serialization/ASTReaderDecl.cpp
@@ -1135,7 +1135,7 @@ void ASTDeclReader::VisitFunctionDecl(FunctionDecl *FD) {
// Defer calling `setPure` until merging above has guaranteed we've set
// `DefinitionData` (as this will need to access it).
- FD->setPure(Pure);
+ FD->setIsVirtualPure(Pure);
// Read in the parameters.
unsigned NumParams = Record.readInt();
diff --git a/clang/lib/Serialization/ASTWriterDecl.cpp b/clang/lib/Serialization/ASTWriterDecl.cpp
index 9e3299f04918484..047ca3a051ead27 100644
--- a/clang/lib/Serialization/ASTWriterDecl.cpp
+++ b/clang/lib/Serialization/ASTWriterDecl.cpp
@@ -680,7 +680,7 @@ void ASTDeclWriter::VisitFunctionDecl(FunctionDecl *D) {
FunctionDeclBits.addBit(D->isInlined());
FunctionDeclBits.addBit(D->hasSkippedBody());
FunctionDeclBits.addBit(D->isVirtualAsWritten());
- FunctionDeclBits.addBit(D->isPure());
+ FunctionDeclBits.addBit(D->isVirtualPure());
FunctionDeclBits.addBit(D->hasInheritedPrototype());
FunctionDeclBits.addBit(D->hasWrittenPrototype());
FunctionDeclBits.addBit(D->isDeletedBit());
diff --git a/clang/lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp
index 1c589e3468c2dd4..51c6a3b9c2c2cd6 100644
--- a/clang/lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp
@@ -116,7 +116,7 @@ void VirtualCallChecker::checkPreCall(const CallEvent &Call,
if (!ObState)
return;
- bool IsPure = MD->isPure();
+ bool IsPure = MD->isVirtualPure();
// At this point we're sure that we're calling a virtual method
// during construction or destruction, so we'll emit a report.
diff --git a/clang/tools/libclang/CIndex.cpp b/clang/tools/libclang/CIndex.cpp
index 841522a0f4788fd..ac160a313b29db1 100644
--- a/clang/tools/libclang/CIndex.cpp
+++ b/clang/tools/libclang/CIndex.cpp
@@ -9007,7 +9007,7 @@ unsigned clang_CXXMethod_isPureVirtual(CXCursor C) {
const Decl *D = cxcursor::getCursorDecl(C);
const CXXMethodDecl *Method =
D ? dyn_cast_or_null<CXXMethodDecl>(D->getAsFunction()) : nullptr;
- return (Method && Method->isVirtual() && Method->isPure()) ? 1 : 0;
+ return (Method && Method->isVirtualPure()) ? 1 : 0;
}
unsigned clang_CXXMethod_isConst(CXCursor C) {
More information about the cfe-commits
mailing list