diff options
Diffstat (limited to 'clang/lib/AST')
-rw-r--r-- | clang/lib/AST/ASTContext.cpp | 4 | ||||
-rw-r--r-- | clang/lib/AST/Decl.cpp | 82 | ||||
-rw-r--r-- | clang/lib/AST/DeclCXX.cpp | 14 | ||||
-rw-r--r-- | clang/lib/AST/DeclPrinter.cpp | 20 | ||||
-rw-r--r-- | clang/lib/AST/DeclTemplate.cpp | 2 | ||||
-rw-r--r-- | clang/lib/AST/Expr.cpp | 2 | ||||
-rw-r--r-- | clang/lib/AST/JSONNodeDumper.cpp | 4 | ||||
-rw-r--r-- | clang/lib/AST/ODRHash.cpp | 2 | ||||
-rw-r--r-- | clang/lib/AST/TextNodeDumper.cpp | 4 |
9 files changed, 75 insertions, 59 deletions
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index 44545f0..098e8ac 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -10681,7 +10681,7 @@ bool ASTContext::DeclMustBeEmitted(const Decl *D) { if (!VD->isFileVarDecl()) return false; // Global named register variables (GNU extension) are never emitted. - if (VD->getStorageClass() == SC_Register) + if (VD->getStorageClass() == StorageClass::Register) return false; if (VD->getDescribedVarTemplate() || isa<VarTemplatePartialSpecializationDecl>(VD)) @@ -11441,7 +11441,7 @@ bool ASTContext::mayExternalizeStaticVar(const Decl *D) const { (D->hasAttr<CUDAConstantAttr>() && !D->getAttr<CUDAConstantAttr>()->isImplicit())) && isa<VarDecl>(D) && cast<VarDecl>(D)->isFileVarDecl() && - cast<VarDecl>(D)->getStorageClass() == SC_Static; + cast<VarDecl>(D)->getStorageClass() == StorageClass::Static; } bool ASTContext::shouldExternalizeStaticVar(const Decl *D) const { diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp index 3cea3c23..f28f983 100644 --- a/clang/lib/AST/Decl.cpp +++ b/clang/lib/AST/Decl.cpp @@ -620,7 +620,7 @@ static StorageClass getStorageClass(const Decl *D) { if (auto *FD = dyn_cast<FunctionDecl>(D)) return FD->getStorageClass(); } - return SC_None; + return StorageClass::None; } LinkageInfo @@ -635,7 +635,7 @@ LinkageComputer::getLVForNamespaceScopeDecl(const NamedDecl *D, // A name having namespace scope (3.3.6) has internal linkage if it // is the name of - if (getStorageClass(D->getCanonicalDecl()) == SC_Static) { + if (getStorageClass(D->getCanonicalDecl()) == StorageClass::Static) { // - a variable, variable template, function, or function template // that is explicitly declared static; or // (This bullet corresponds to C99 6.2.2p3.) @@ -660,19 +660,19 @@ LinkageComputer::getLVForNamespaceScopeDecl(const NamedDecl *D, if (PrevVar) return getLVForDecl(PrevVar, computation); - if (Var->getStorageClass() != SC_Extern && - Var->getStorageClass() != SC_PrivateExtern && + if (Var->getStorageClass() != StorageClass::Extern && + Var->getStorageClass() != StorageClass::PrivateExtern && !isSingleLineLanguageLinkage(*Var)) return getInternalLinkageFor(Var); } for (const VarDecl *PrevVar = Var->getPreviousDecl(); PrevVar; PrevVar = PrevVar->getPreviousDecl()) { - if (PrevVar->getStorageClass() == SC_PrivateExtern && - Var->getStorageClass() == SC_None) + if (PrevVar->getStorageClass() == StorageClass::PrivateExtern && + Var->getStorageClass() == StorageClass::None) return getDeclLinkageAndVisibility(PrevVar); // Explicitly declared static. - if (PrevVar->getStorageClass() == SC_Static) + if (PrevVar->getStorageClass() == StorageClass::Static) return getInternalLinkageFor(Var); } } else if (const auto *IFD = dyn_cast<IndirectFieldDecl>(D)) { @@ -789,7 +789,7 @@ LinkageComputer::getLVForNamespaceScopeDecl(const NamedDecl *D, LV.mergeVisibility(TypeLV); } - if (Var->getStorageClass() == SC_PrivateExtern) + if (Var->getStorageClass() == StorageClass::PrivateExtern) LV.mergeVisibility(HiddenVisibility, true); // Note that Sema::MergeVarDecl already takes care of implementing @@ -810,7 +810,7 @@ LinkageComputer::getLVForNamespaceScopeDecl(const NamedDecl *D, // for justification). In practice, GCC doesn't do this, so it's // just too painful to make work. - if (Function->getStorageClass() == SC_PrivateExtern) + if (Function->getStorageClass() == StorageClass::PrivateExtern) LV.mergeVisibility(HiddenVisibility, true); // Note that Sema::MergeCompatibleFunctionDecls already takes care of @@ -1229,7 +1229,7 @@ LinkageInfo LinkageComputer::getLVForLocalDecl(const NamedDecl *D, return getInternalLinkageFor(Function); // This is a "void f();" which got merged with a file static. - if (Function->getCanonicalDecl()->getStorageClass() == SC_Static) + if (Function->getCanonicalDecl()->getStorageClass() == StorageClass::Static) return getInternalLinkageFor(Function); LinkageInfo LV; @@ -1252,7 +1252,7 @@ LinkageInfo LinkageComputer::getLVForLocalDecl(const NamedDecl *D, return getInternalLinkageFor(Var); LinkageInfo LV; - if (Var->getStorageClass() == SC_PrivateExtern) + if (Var->getStorageClass() == StorageClass::PrivateExtern) LV.mergeVisibility(HiddenVisibility, true); else if (!hasExplicitVisibilityAlready(computation)) { if (Optional<Visibility> Vis = getExplicitVisibility(Var, computation)) @@ -1962,12 +1962,18 @@ void QualifierInfo::setTemplateParameterListsInfo( const char *VarDecl::getStorageClassSpecifierString(StorageClass SC) { switch (SC) { - case SC_None: break; - case SC_Auto: return "auto"; - case SC_Extern: return "extern"; - case SC_PrivateExtern: return "__private_extern__"; - case SC_Register: return "register"; - case SC_Static: return "static"; + case StorageClass::None: + break; + case StorageClass::Auto: + return "auto"; + case StorageClass::Extern: + return "extern"; + case StorageClass::PrivateExtern: + return "__private_extern__"; + case StorageClass::Register: + return "register"; + case StorageClass::Static: + return "static"; } llvm_unreachable("Invalid storage class"); @@ -1986,7 +1992,7 @@ VarDecl::VarDecl(Kind DK, ASTContext &C, DeclContext *DC, static_assert(sizeof(NonParmVarDeclBitfields) <= sizeof(unsigned), "NonParmVarDeclBitfields too large!"); AllBits = 0; - VarDeclBits.SClass = SC; + VarDeclBits.SClass = static_cast<unsigned>(SC); // Everything else is implicitly initialized to false. } @@ -2000,12 +2006,12 @@ VarDecl *VarDecl::Create(ASTContext &C, DeclContext *DC, VarDecl *VarDecl::CreateDeserialized(ASTContext &C, unsigned ID) { return new (C, ID) VarDecl(Var, C, nullptr, SourceLocation(), SourceLocation(), nullptr, - QualType(), nullptr, SC_None); + QualType(), nullptr, StorageClass::None); } void VarDecl::setStorageClass(StorageClass SC) { assert(isLegalForVariable(SC)); - VarDeclBits.SClass = SC; + VarDeclBits.SClass = static_cast<unsigned>(SC); } VarDecl::TLSKind VarDecl::getTLSKind() const { @@ -2720,7 +2726,7 @@ QualType ParmVarDecl::getOriginalType() const { ParmVarDecl *ParmVarDecl::CreateDeserialized(ASTContext &C, unsigned ID) { return new (C, ID) ParmVarDecl(ParmVar, C, nullptr, SourceLocation(), SourceLocation(), - nullptr, QualType(), nullptr, SC_None, nullptr); + nullptr, QualType(), nullptr, StorageClass::None, nullptr); } SourceRange ParmVarDecl::getSourceRange() const { @@ -2830,7 +2836,7 @@ FunctionDecl::FunctionDecl(Kind DK, ASTContext &C, DeclContext *DC, DeclContext(DK), redeclarable_base(C), Body(), ODRHash(0), EndRangeLoc(NameInfo.getEndLoc()), DNLoc(NameInfo.getInfo()) { assert(T.isNull() || T->isFunctionType()); - FunctionDeclBits.SClass = S; + FunctionDeclBits.SClass = static_cast<uint64_t>(S); FunctionDeclBits.IsInline = isInlineSpecified; FunctionDeclBits.IsInlineSpecified = isInlineSpecified; FunctionDeclBits.IsVirtualAsWritten = false; @@ -3181,7 +3187,7 @@ bool FunctionDecl::isGlobal() const { if (const auto *Method = dyn_cast<CXXMethodDecl>(this)) return Method->isStatic(); - if (getCanonicalDecl()->getStorageClass() == SC_Static) + if (getCanonicalDecl()->getStorageClass() == StorageClass::Static) return false; for (const DeclContext *DC = getDeclContext(); @@ -3288,7 +3294,7 @@ unsigned FunctionDecl::getBuiltinID(bool ConsiderWrapperFunctions) const { // function or whether it just has the same name. // If this is a static function, it's not a builtin. - if (!ConsiderWrapperFunctions && getStorageClass() == SC_Static) + if (!ConsiderWrapperFunctions && getStorageClass() == StorageClass::Static) return 0; // OpenCL v1.2 s6.9.f - The library functions defined in @@ -3380,19 +3386,19 @@ bool FunctionDecl::isMSExternInline() const { for (const FunctionDecl *FD = getMostRecentDecl(); FD; FD = FD->getPreviousDecl()) - if (!FD->isImplicit() && FD->getStorageClass() == SC_Extern) + if (!FD->isImplicit() && FD->getStorageClass() == StorageClass::Extern) return true; return false; } static bool redeclForcesDefMSVC(const FunctionDecl *Redecl) { - if (Redecl->getStorageClass() != SC_Extern) + if (Redecl->getStorageClass() != StorageClass::Extern) return false; for (const FunctionDecl *FD = Redecl->getPreviousDecl(); FD; FD = FD->getPreviousDecl()) - if (!FD->isImplicit() && FD->getStorageClass() == SC_Extern) + if (!FD->isImplicit() && FD->getStorageClass() == StorageClass::Extern) return false; return true; @@ -3408,7 +3414,8 @@ static bool RedeclForcesDefC99(const FunctionDecl *Redecl) { if (Redecl->isImplicit()) return false; - if (!Redecl->isInlineSpecified() || Redecl->getStorageClass() == SC_Extern) + if (!Redecl->isInlineSpecified() || + Redecl->getStorageClass() == StorageClass::Extern) return true; // Not an inline definition return false; @@ -3442,7 +3449,7 @@ bool FunctionDecl::doesDeclarationForceExternallyVisibleDefinition() const { // // FIXME: What happens if gnu_inline gets added on after the first // declaration? - if (!isInlineSpecified() || getStorageClass() == SC_Extern) + if (!isInlineSpecified() || getStorageClass() == StorageClass::Extern) return false; const FunctionDecl *Prev = this; @@ -3454,10 +3461,10 @@ bool FunctionDecl::doesDeclarationForceExternallyVisibleDefinition() const { // If it's not the case that both 'inline' and 'extern' are // specified on the definition, then it is always externally visible. if (!Prev->isInlineSpecified() || - Prev->getStorageClass() != SC_Extern) + Prev->getStorageClass() != StorageClass::Extern) return false; } else if (Prev->isInlineSpecified() && - Prev->getStorageClass() != SC_Extern) { + Prev->getStorageClass() != StorageClass::Extern) { return false; } } @@ -3468,7 +3475,7 @@ bool FunctionDecl::doesDeclarationForceExternallyVisibleDefinition() const { // [...] If all of the file scope declarations for a function in a // translation unit include the inline function specifier without extern, // then the definition in that translation unit is an inline definition. - if (isInlineSpecified() && getStorageClass() != SC_Extern) + if (isInlineSpecified() && getStorageClass() != StorageClass::Extern) return false; const FunctionDecl *Prev = this; bool FoundBody = false; @@ -3556,14 +3563,14 @@ bool FunctionDecl::isInlineDefinitionExternallyVisible() const { // externally visible. if (Context.getLangOpts().CPlusPlus) return false; - if (!(isInlineSpecified() && getStorageClass() == SC_Extern)) + if (!(isInlineSpecified() && getStorageClass() == StorageClass::Extern)) return true; // If any declaration is 'inline' but not 'extern', then this definition // is externally visible. for (auto Redecl : redecls()) { if (Redecl->isInlineSpecified() && - Redecl->getStorageClass() != SC_Extern) + Redecl->getStorageClass() != StorageClass::Extern) return true; } @@ -4838,9 +4845,10 @@ FunctionDecl *FunctionDecl::Create(ASTContext &C, DeclContext *DC, } FunctionDecl *FunctionDecl::CreateDeserialized(ASTContext &C, unsigned ID) { - return new (C, ID) FunctionDecl( - Function, C, nullptr, SourceLocation(), DeclarationNameInfo(), QualType(), - nullptr, SC_None, false, ConstexprSpecKind::Unspecified, nullptr); + return new (C, ID) FunctionDecl(Function, C, nullptr, SourceLocation(), + DeclarationNameInfo(), QualType(), nullptr, + StorageClass::None, false, + ConstexprSpecKind::Unspecified, nullptr); } BlockDecl *BlockDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation L) { diff --git a/clang/lib/AST/DeclCXX.cpp b/clang/lib/AST/DeclCXX.cpp index b806adf..d533622 100644 --- a/clang/lib/AST/DeclCXX.cpp +++ b/clang/lib/AST/DeclCXX.cpp @@ -2085,7 +2085,7 @@ void CXXMethodDecl::anchor() {} bool CXXMethodDecl::isStatic() const { const CXXMethodDecl *MD = getCanonicalDecl(); - if (MD->getStorageClass() == SC_Static) + if (MD->getStorageClass() == StorageClass::Static) return true; OverloadedOperatorKind OOK = getDeclName().getCXXOverloadedOperator(); @@ -2187,10 +2187,10 @@ CXXMethodDecl *CXXMethodDecl::Create(ASTContext &C, CXXRecordDecl *RD, } CXXMethodDecl *CXXMethodDecl::CreateDeserialized(ASTContext &C, unsigned ID) { - return new (C, ID) - CXXMethodDecl(CXXMethod, C, nullptr, SourceLocation(), - DeclarationNameInfo(), QualType(), nullptr, SC_None, false, - ConstexprSpecKind::Unspecified, SourceLocation(), nullptr); + return new (C, ID) CXXMethodDecl( + CXXMethod, C, nullptr, SourceLocation(), DeclarationNameInfo(), + QualType(), nullptr, StorageClass::None, false, + ConstexprSpecKind::Unspecified, SourceLocation(), nullptr); } CXXMethodDecl *CXXMethodDecl::getDevirtualizedMethod(const Expr *Base, @@ -2567,8 +2567,8 @@ CXXConstructorDecl::CXXConstructorDecl( ConstexprSpecKind ConstexprKind, InheritedConstructor Inherited, Expr *TrailingRequiresClause) : CXXMethodDecl(CXXConstructor, C, RD, StartLoc, NameInfo, T, TInfo, - SC_None, isInline, ConstexprKind, SourceLocation(), - TrailingRequiresClause) { + StorageClass::None, isInline, ConstexprKind, + SourceLocation(), TrailingRequiresClause) { setNumCtorInitializers(0); setInheritingConstructor(static_cast<bool>(Inherited)); setImplicit(isImplicitlyDeclared); diff --git a/clang/lib/AST/DeclPrinter.cpp b/clang/lib/AST/DeclPrinter.cpp index ca64f8f6..68327d5 100644 --- a/clang/lib/AST/DeclPrinter.cpp +++ b/clang/lib/AST/DeclPrinter.cpp @@ -600,11 +600,19 @@ void DeclPrinter::VisitFunctionDecl(FunctionDecl *D) { CXXDeductionGuideDecl *GuideDecl = dyn_cast<CXXDeductionGuideDecl>(D); if (!Policy.SuppressSpecifiers) { switch (D->getStorageClass()) { - case SC_None: break; - case SC_Extern: Out << "extern "; break; - case SC_Static: Out << "static "; break; - case SC_PrivateExtern: Out << "__private_extern__ "; break; - case SC_Auto: case SC_Register: + case StorageClass::None: + break; + case StorageClass::Extern: + Out << "extern "; + break; + case StorageClass::Static: + Out << "static "; + break; + case StorageClass::PrivateExtern: + Out << "__private_extern__ "; + break; + case StorageClass::Auto: + case StorageClass::Register: llvm_unreachable("invalid for functions"); } @@ -848,7 +856,7 @@ void DeclPrinter::VisitVarDecl(VarDecl *D) { if (!Policy.SuppressSpecifiers) { StorageClass SC = D->getStorageClass(); - if (SC != SC_None) + if (SC != StorageClass::None) Out << VarDecl::getStorageClassSpecifierString(SC) << " "; switch (D->getTSCSpec()) { diff --git a/clang/lib/AST/DeclTemplate.cpp b/clang/lib/AST/DeclTemplate.cpp index 25235c5..7777938 100644 --- a/clang/lib/AST/DeclTemplate.cpp +++ b/clang/lib/AST/DeclTemplate.cpp @@ -1226,7 +1226,7 @@ VarTemplateSpecializationDecl::VarTemplateSpecializationDecl( VarTemplateSpecializationDecl::VarTemplateSpecializationDecl(Kind DK, ASTContext &C) : VarDecl(DK, C, nullptr, SourceLocation(), SourceLocation(), nullptr, - QualType(), nullptr, SC_None), + QualType(), nullptr, StorageClass::None), SpecializationKind(TSK_Undeclared), IsCompleteDefinition(false) {} VarTemplateSpecializationDecl *VarTemplateSpecializationDecl::Create( diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp index a274bf3..cf46a4b 100644 --- a/clang/lib/AST/Expr.cpp +++ b/clang/lib/AST/Expr.cpp @@ -3835,7 +3835,7 @@ bool Expr::refersToGlobalRegisterVar() const { if (const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E)) if (const auto *VD = dyn_cast<VarDecl>(DRE->getDecl())) - if (VD->getStorageClass() == SC_Register && + if (VD->getStorageClass() == StorageClass::Register && VD->hasAttr<AsmLabelAttr>() && !VD->isLocalVarDecl()) return true; diff --git a/clang/lib/AST/JSONNodeDumper.cpp b/clang/lib/AST/JSONNodeDumper.cpp index 7b99546..04f8de4 100644 --- a/clang/lib/AST/JSONNodeDumper.cpp +++ b/clang/lib/AST/JSONNodeDumper.cpp @@ -765,7 +765,7 @@ void JSONNodeDumper::VisitVarDecl(const VarDecl *VD) { JOS.attribute("type", createQualType(VD->getType())); StorageClass SC = VD->getStorageClass(); - if (SC != SC_None) + if (SC != StorageClass::None) JOS.attribute("storageClass", VarDecl::getStorageClassSpecifierString(SC)); switch (VD->getTLSKind()) { case VarDecl::TLS_Dynamic: JOS.attribute("tls", "dynamic"); break; @@ -799,7 +799,7 @@ void JSONNodeDumper::VisitFunctionDecl(const FunctionDecl *FD) { VisitNamedDecl(FD); JOS.attribute("type", createQualType(FD->getType())); StorageClass SC = FD->getStorageClass(); - if (SC != SC_None) + if (SC != StorageClass::None) JOS.attribute("storageClass", VarDecl::getStorageClassSpecifierString(SC)); attributeOnlyIfTrue("inline", FD->isInlineSpecified()); attributeOnlyIfTrue("virtual", FD->isVirtualAsWritten()); diff --git a/clang/lib/AST/ODRHash.cpp b/clang/lib/AST/ODRHash.cpp index 735bcff..f8e3680 100644 --- a/clang/lib/AST/ODRHash.cpp +++ b/clang/lib/AST/ODRHash.cpp @@ -551,7 +551,7 @@ void ODRHash::AddFunctionDecl(const FunctionDecl *Function, AddBoolean(Method->isVolatile()); } - ID.AddInteger(Function->getStorageClass()); + ID.AddInteger(static_cast<int>(Function->getStorageClass())); AddBoolean(Function->isInlineSpecified()); AddBoolean(Function->isVirtualAsWritten()); AddBoolean(Function->isPure()); diff --git a/clang/lib/AST/TextNodeDumper.cpp b/clang/lib/AST/TextNodeDumper.cpp index e313275..86b7aac 100644 --- a/clang/lib/AST/TextNodeDumper.cpp +++ b/clang/lib/AST/TextNodeDumper.cpp @@ -1579,7 +1579,7 @@ void TextNodeDumper::VisitFunctionDecl(const FunctionDecl *D) { dumpType(D->getType()); StorageClass SC = D->getStorageClass(); - if (SC != SC_None) + if (SC != StorageClass::None) OS << ' ' << VarDecl::getStorageClassSpecifierString(SC); if (D->isInlineSpecified()) OS << " inline"; @@ -1668,7 +1668,7 @@ void TextNodeDumper::VisitVarDecl(const VarDecl *D) { dumpName(D); dumpType(D->getType()); StorageClass SC = D->getStorageClass(); - if (SC != SC_None) + if (SC != StorageClass::None) OS << ' ' << VarDecl::getStorageClassSpecifierString(SC); switch (D->getTLSKind()) { case VarDecl::TLS_None: |