diff --git a/clang-tools-extra/clang-tidy/fuchsia/MultipleInheritanceCheck.cpp b/clang-tools-extra/clang-tidy/fuchsia/MultipleInheritanceCheck.cpp index 8aecd3ba27b2e3..b5ce23ae8feda2 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->isPureVirtual() && !M->isStatic(); }); } @@ -103,8 +103,8 @@ void MultipleInheritanceCheck::check(const MatchFinder::MatchResult &Result) { const auto *Base = cast(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(); diff --git a/clang-tools-extra/clang-tidy/modernize/UseEqualsDeleteCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseEqualsDeleteCheck.cpp index 059a0af60d3ee8..9561cc71183d97 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.isPureVirtual() || Node.isDefaulted() || + Node.isDeleted()) return true; if (const FunctionDecl *Definition = Node.getDefinition()) - if (Definition->hasBody() || Definition->isPure() || + if (Definition->hasBody() || Definition->isPureVirtual() || Definition->isDefaulted() || Definition->isDeleted()) return true; diff --git a/clang-tools-extra/clangd/SemanticHighlighting.cpp b/clang-tools-extra/clangd/SemanticHighlighting.cpp index 37939d36425a97..ee3772e3d380c1 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(D)) - return CMD->isPure(); + return CMD->isPureVirtual(); if (const auto *CRD = llvm::dyn_cast(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 5f41f788a69393..250d571eea191c 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->isPureVirtual()) { 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 a807bcdd76b30d..18e5bf2a549240 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 isPureVirtual() const { return FunctionDeclBits.IsPureVirtual; } + void setIsPureVirtual(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 10dcbdb262d84e..1cd91e43826f6c 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 IsPureVirtual : 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 648f5f94640870..8b0d4a935378b4 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::setIsPureVirtual(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->isPureVirtual()) 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 82a26356c58f55..b86c11a54a3fab 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.isPureVirtual(); } /// Matches if the given method declaration is const. /// diff --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp index c8085c5dd48a59..676216c5b1e8cb 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->setIsPureVirtual(D->isPureVirtual()); 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 a9e0d1698a9178..12b169fed74ffb 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->isPureVirtual() == Method2->isPureVirtual() && 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 e1440e5183a4e6..8471707287792c 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.IsPureVirtual = 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::setIsPureVirtual(bool P) { + FunctionDeclBits.IsPureVirtual = P; if (P) if (auto *Parent = dyn_cast(getDeclContext())) Parent->markedVirtualFunctionPure(); diff --git a/clang/lib/AST/DeclCXX.cpp b/clang/lib/AST/DeclCXX.cpp index 98b0a6dc28ea2f..f2557c3480adf4 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->isPureVirtual()) { 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()) - return isPure() ? nullptr : this; + return isPureVirtual() ? 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->isPureVirtual()) 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 24da6f2ef32b4f..822ac12c4c7dd4 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->isPureVirtual()) Out << " = 0"; else if (D->isDeletedAsWritten()) Out << " = delete"; diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp index f20850d14c0c86..0884988c48b4e8 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->isPureVirtual()) { 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 b95a52199846fa..38d618983e7130 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->isPureVirtual()) 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 637d06cee78c85..cb3d3b0df1ee34 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->isPureVirtual()); 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 9dcd2ed04f6f7d..5b1cdc16e2ea2c 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->isPureVirtual(); + const bool SecondPure = SecondMethod->isPureVirtual(); 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 aea1a93ae1fa82..f72e22ec2104a5 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->isPureVirtual()); AddBoolean(Function->isDeletedAsWritten()); AddBoolean(Function->isExplicitlyDefaulted()); diff --git a/clang/lib/AST/RecordLayoutBuilder.cpp b/clang/lib/AST/RecordLayoutBuilder.cpp index 706991f4fb501c..6dfaadd92e7973 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->isPureVirtual()) 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(MD) && !MD->isPure()) + !isa(MD) && !MD->isPureVirtual()) 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 369ff66ac4dbc6..48c6729a673819 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->isPureVirtual()) OS << " pure"; if (D->isDefaulted()) { OS << " default"; diff --git a/clang/lib/AST/VTableBuilder.cpp b/clang/lib/AST/VTableBuilder.cpp index 69861c65f6e3ac..a956ca5b37acfe 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->isPureVirtual()) 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->isPureVirtual()) 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->isPureVirtual()) { 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->isPureVirtual()) Out << " [pure]"; if (MD->isDeleted()) @@ -2010,7 +2010,7 @@ void ItaniumVTableBuilder::dumpLayout(raw_ostream &Out) { else Out << "() [deleting]"; - if (DD->isPure()) + if (DD->isPureVirtual()) 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->isPureVirtual()) 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->isPureVirtual()) { 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->isPureVirtual()) 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->isPureVirtual()) Out << " [pure]"; ThunkInfo Thunk = VTableThunks.lookup(I); diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index 236d53bee4e8f1..c5b96f93b42c38 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->isPureVirtual()) SPFlags |= llvm::DISubprogram::SPFlagPureVirtual; else SPFlags |= llvm::DISubprogram::SPFlagVirtual; diff --git a/clang/lib/CodeGen/CGVTables.cpp b/clang/lib/CodeGen/CGVTables.cpp index 27a2cab4f75319..8dee3f74b44b4e 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(GD.getDecl())->isPure()) { + if (cast(GD.getDecl())->isPureVirtual()) { if (!PureVirtualFn) PureVirtualFn = getSpecialVirtualFn(CGM.getCXXABI().GetPureVirtualCallName()); diff --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp index cafbecebc8a119..70832d1a14552d 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(*I)) Complete = M->isDefined() || M->isDefaulted() || - (M->isPure() && !isa(M)); + (M->isPureVirtual() && !isa(M)); else if (const FunctionTemplateDecl *F = dyn_cast(*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 722e2ac9e4ff8d..cceb05f8c76d60 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->isPureVirtual()) + New->setIsPureVirtual(); // 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(NewFD->getDeclContext())) { if (Parent->isInterface() && cast(NewFD)->isUserProvided()) - NewFD->setPure(true); + NewFD->setIsPureVirtual(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->isPureVirtual() && + !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 f229e734d06b28..2dc5977a6788a2 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->isPureVirtual()) 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->setIsPureVirtual(); 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->isPureVirtual()) ResolveExceptionSpec(Loc, I->getType()->castAs()); } @@ -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->isPureVirtual() && + (!ConstexprOnly || Overrider->isConstexpr())) MarkFunctionReferenced(Loc, Overrider); } } diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 2aa192c3909cbe..9648acc9ad5bb8 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(E->getMemberDecl())) - if (Method->isPure()) + if (Method->isPureVirtual()) MightBeOdrUse = false; } SourceLocation Loc = diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp index 37c62b306b3cd3..bbbd0abc82d740 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(CurContext) && - TheCall->getDirectCallee()->isPure()) { + TheCall->getDirectCallee()->isPureVirtual()) { const FunctionDecl *MD = TheCall->getDirectCallee(); if (isa(MemExpr->getBase()->IgnoreParenCasts()) && diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp index d768bb72e07c09..8ca9416f9da80c 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->isPureVirtual()) 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 547eb77930b4ee..e26ea5ac97ab24 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->setIsPureVirtual(Pure); // Read in the parameters. unsigned NumParams = Record.readInt(); diff --git a/clang/lib/Serialization/ASTWriterDecl.cpp b/clang/lib/Serialization/ASTWriterDecl.cpp index 9e3299f0491848..bb1f51786d2813 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->isPureVirtual()); 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 1c589e3468c2dd..33a9a07f9d32d1 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->isPureVirtual(); // 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 841522a0f4788f..00c0dff9cce4c4 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(D->getAsFunction()) : nullptr; - return (Method && Method->isVirtual() && Method->isPure()) ? 1 : 0; + return (Method && Method->isPureVirtual()) ? 1 : 0; } unsigned clang_CXXMethod_isConst(CXCursor C) {