From: John McCall Date: Thu, 26 Aug 2010 03:08:43 +0000 (+0000) Subject: De-memberify the VarDecl and FunctionDecl StorageClass enums. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d931b086984257de68868a64a235c2b4b34003fb;p=clang De-memberify the VarDecl and FunctionDecl StorageClass enums. This lets us remove Sema.h's dependency on Expr.h and Decl.h. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112156 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/AST/Decl.h b/include/clang/AST/Decl.h index bfe0b2934a..cb794ff60a 100644 --- a/include/clang/AST/Decl.h +++ b/include/clang/AST/Decl.h @@ -490,36 +490,11 @@ struct EvaluatedStmt { APValue Evaluated; }; -// \brief Describes the kind of template specialization that a -// particular template specialization declaration represents. -enum TemplateSpecializationKind { - /// This template specialization was formed from a template-id but - /// has not yet been declared, defined, or instantiated. - TSK_Undeclared = 0, - /// This template specialization was implicitly instantiated from a - /// template. (C++ [temp.inst]). - TSK_ImplicitInstantiation, - /// This template specialization was declared or defined by an - /// explicit specialization (C++ [temp.expl.spec]) or partial - /// specialization (C++ [temp.class.spec]). - TSK_ExplicitSpecialization, - /// This template specialization was instantiated from a template - /// due to an explicit instantiation declaration request - /// (C++0x [temp.explicit]). - TSK_ExplicitInstantiationDeclaration, - /// This template specialization was instantiated from a template - /// due to an explicit instantiation definition request - /// (C++ [temp.explicit]). - TSK_ExplicitInstantiationDefinition -}; - /// VarDecl - An instance of this class is created to represent a variable /// declaration or definition. class VarDecl : public DeclaratorDecl, public Redeclarable { public: - enum StorageClass { - None, Auto, Register, Extern, Static, PrivateExtern - }; + typedef clang::StorageClass StorageClass; /// getStorageClassSpecifierString - Return the string used to /// specify the storage class \arg SC. @@ -595,8 +570,14 @@ public: StorageClass getStorageClassAsWritten() const { return (StorageClass) SClassAsWritten; } - void setStorageClass(StorageClass SC) { SClass = SC; } - void setStorageClassAsWritten(StorageClass SC) { SClassAsWritten = SC; } + void setStorageClass(StorageClass SC) { + assert(isLegalForVariable(SC)); + SClass = SC; + } + void setStorageClassAsWritten(StorageClass SC) { + assert(isLegalForVariable(SC)); + SClassAsWritten = SC; + } void setThreadSpecified(bool T) { ThreadSpecified = T; } bool isThreadSpecified() const { @@ -606,25 +587,26 @@ public: /// hasLocalStorage - Returns true if a variable with function scope /// is a non-static local variable. bool hasLocalStorage() const { - if (getStorageClass() == None) + if (getStorageClass() == SC_None) return !isFileVarDecl(); // Return true for: Auto, Register. // Return false for: Extern, Static, PrivateExtern. - return getStorageClass() <= Register; + return getStorageClass() >= SC_Auto; } /// isStaticLocal - Returns true if a variable with function scope is a /// static local variable. bool isStaticLocal() const { - return getStorageClass() == Static && !isFileVarDecl(); + return getStorageClass() == SC_Static && !isFileVarDecl(); } /// hasExternStorage - Returns true if a variable has extern or /// __private_extern__ storage. bool hasExternalStorage() const { - return getStorageClass() == Extern || getStorageClass() == PrivateExtern; + return getStorageClass() == SC_Extern || + getStorageClass() == SC_PrivateExtern; } /// hasGlobalStorage - Returns true for all variables that do not @@ -937,7 +919,7 @@ class ImplicitParamDecl : public VarDecl { protected: ImplicitParamDecl(Kind DK, DeclContext *DC, SourceLocation L, IdentifierInfo *Id, QualType Tw) - : VarDecl(DK, DC, L, Id, Tw, /*TInfo=*/0, VarDecl::None, VarDecl::None) {} + : VarDecl(DK, DC, L, Id, Tw, /*TInfo=*/0, SC_None, SC_None) {} public: static ImplicitParamDecl *Create(ASTContext &C, DeclContext *DC, SourceLocation L, IdentifierInfo *Id, @@ -1081,9 +1063,7 @@ public: class FunctionDecl : public DeclaratorDecl, public DeclContext, public Redeclarable { public: - enum StorageClass { - None, Extern, Static, PrivateExtern - }; + typedef clang::StorageClass StorageClass; /// \brief The kind of templated function a FunctionDecl can be. enum TemplatedKind { @@ -1178,8 +1158,8 @@ public: static FunctionDecl *Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName N, QualType T, TypeSourceInfo *TInfo, - StorageClass S = None, - StorageClass SCAsWritten = None, + StorageClass S = SC_None, + StorageClass SCAsWritten = SC_None, bool isInline = false, bool hasWrittenPrototype = true) { DeclarationNameInfo NameInfo(N, L); @@ -1190,8 +1170,8 @@ public: static FunctionDecl *Create(ASTContext &C, DeclContext *DC, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, - StorageClass S = None, - StorageClass SCAsWritten = None, + StorageClass S = SC_None, + StorageClass SCAsWritten = SC_None, bool isInline = false, bool hasWrittenPrototype = true); @@ -1372,12 +1352,18 @@ public: } StorageClass getStorageClass() const { return StorageClass(SClass); } - void setStorageClass(StorageClass SC) { SClass = SC; } + void setStorageClass(StorageClass SC) { + assert(isLegalForFunction(SC)); + SClass = SC; + } StorageClass getStorageClassAsWritten() const { return StorageClass(SClassAsWritten); } - void setStorageClassAsWritten(StorageClass SC) { SClassAsWritten = SC; } + void setStorageClassAsWritten(StorageClass SC) { + assert(isLegalForFunction(SC)); + SClassAsWritten = SC; + } /// \brief Determine whether the "inline" keyword was specified for this /// function. diff --git a/include/clang/AST/DeclCXX.h b/include/clang/AST/DeclCXX.h index 3e665d45e4..b529cf0346 100644 --- a/include/clang/AST/DeclCXX.h +++ b/include/clang/AST/DeclCXX.h @@ -1069,7 +1069,7 @@ protected: const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, bool isStatic, StorageClass SCAsWritten, bool isInline) - : FunctionDecl(DK, RD, NameInfo, T, TInfo, (isStatic ? Static : None), + : FunctionDecl(DK, RD, NameInfo, T, TInfo, (isStatic ? SC_Static : SC_None), SCAsWritten, isInline) {} public: @@ -1077,10 +1077,10 @@ public: const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, bool isStatic = false, - StorageClass SCAsWritten = FunctionDecl::None, + StorageClass SCAsWritten = SC_None, bool isInline = false); - bool isStatic() const { return getStorageClass() == Static; } + bool isStatic() const { return getStorageClass() == SC_Static; } bool isInstance() const { return !isStatic(); } bool isVirtual() const { @@ -1398,7 +1398,7 @@ class CXXConstructorDecl : public CXXMethodDecl { bool isExplicitSpecified, bool isInline, bool isImplicitlyDeclared) : CXXMethodDecl(CXXConstructor, RD, NameInfo, T, TInfo, false, - FunctionDecl::None, isInline), + SC_None, isInline), IsExplicitSpecified(isExplicitSpecified), ImplicitlyDefined(false), BaseOrMemberInitializers(0), NumBaseOrMemberInitializers(0) { setImplicit(isImplicitlyDeclared); @@ -1544,7 +1544,7 @@ class CXXDestructorDecl : public CXXMethodDecl { CXXDestructorDecl(CXXRecordDecl *RD, const DeclarationNameInfo &NameInfo, QualType T, bool isInline, bool isImplicitlyDeclared) : CXXMethodDecl(CXXDestructor, RD, NameInfo, T, /*TInfo=*/0, false, - FunctionDecl::None, isInline), + SC_None, isInline), ImplicitlyDefined(false), OperatorDelete(0) { setImplicit(isImplicitlyDeclared); } @@ -1605,7 +1605,7 @@ class CXXConversionDecl : public CXXMethodDecl { QualType T, TypeSourceInfo *TInfo, bool isInline, bool isExplicitSpecified) : CXXMethodDecl(CXXConversion, RD, NameInfo, T, TInfo, false, - FunctionDecl::None, isInline), + SC_None, isInline), IsExplicitSpecified(isExplicitSpecified) { } public: diff --git a/include/clang/AST/DeclTemplate.h b/include/clang/AST/DeclTemplate.h index c99ac25798..3861cd9a91 100644 --- a/include/clang/AST/DeclTemplate.h +++ b/include/clang/AST/DeclTemplate.h @@ -1016,8 +1016,7 @@ class NonTypeTemplateParmDecl NonTypeTemplateParmDecl(DeclContext *DC, SourceLocation L, unsigned D, unsigned P, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo) - : VarDecl(NonTypeTemplateParm, DC, L, Id, T, TInfo, VarDecl::None, - VarDecl::None), + : VarDecl(NonTypeTemplateParm, DC, L, Id, T, TInfo, SC_None, SC_None), TemplateParmPosition(D, P), DefaultArgumentAndInherited(0, false) { } diff --git a/include/clang/Basic/Specifiers.h b/include/clang/Basic/Specifiers.h index c808a0d75c..e757a2f4a1 100644 --- a/include/clang/Basic/Specifiers.h +++ b/include/clang/Basic/Specifiers.h @@ -95,6 +95,51 @@ namespace clang { VK_XValue }; + // \brief Describes the kind of template specialization that a + // particular template specialization declaration represents. + enum TemplateSpecializationKind { + /// This template specialization was formed from a template-id but + /// has not yet been declared, defined, or instantiated. + TSK_Undeclared = 0, + /// This template specialization was implicitly instantiated from a + /// template. (C++ [temp.inst]). + TSK_ImplicitInstantiation, + /// This template specialization was declared or defined by an + /// explicit specialization (C++ [temp.expl.spec]) or partial + /// specialization (C++ [temp.class.spec]). + TSK_ExplicitSpecialization, + /// This template specialization was instantiated from a template + /// due to an explicit instantiation declaration request + /// (C++0x [temp.explicit]). + TSK_ExplicitInstantiationDeclaration, + /// This template specialization was instantiated from a template + /// due to an explicit instantiation definition request + /// (C++ [temp.explicit]). + TSK_ExplicitInstantiationDefinition + }; + + /// \brief Storage classes. + enum StorageClass { + // These are legal on both functions and variables. + SC_None, + SC_Extern, + SC_Static, + SC_PrivateExtern, + + // These are only legal on variables. + SC_Auto, + SC_Register + }; + + /// Checks whether the given storage class is legal for functions. + inline bool isLegalForFunction(StorageClass SC) { + return SC <= SC_PrivateExtern; + } + + /// Checks whether the given storage class is legal for variables. + inline bool isLegalForVariable(StorageClass SC) { + return true; + } } // end namespace clang #endif // LLVM_CLANG_BASIC_SPECIFIERS_H diff --git a/include/clang/Frontend/DeclXML.def b/include/clang/Frontend/DeclXML.def index 16551ee03e..18451189bc 100644 --- a/include/clang/Frontend/DeclXML.def +++ b/include/clang/Frontend/DeclXML.def @@ -95,10 +95,10 @@ NODE_XML(FunctionDecl, "Function") TYPE_ATTRIBUTE_XML(getType()->getAs()->getResultType()) ATTRIBUTE_XML(getType()->getAs(), "function_type") ATTRIBUTE_ENUM_OPT_XML(getStorageClass(), "storage_class") - ENUM_XML(FunctionDecl::None, "") - ENUM_XML(FunctionDecl::Extern, "extern") - ENUM_XML(FunctionDecl::Static, "static") - ENUM_XML(FunctionDecl::PrivateExtern, "__private_extern__") + ENUM_XML(SC_None, "") + ENUM_XML(SC_Extern, "extern") + ENUM_XML(SC_Static, "static") + ENUM_XML(SC_PrivateExtern, "__private_extern__") END_ENUM_XML ATTRIBUTE_OPT_XML(isInlineSpecified(), "inline") //ATTRIBUTE_OPT_XML(isVariadic(), "variadic") // in the type reference @@ -289,12 +289,12 @@ NODE_XML(VarDecl, "Var") ATTRIBUTE_XML(getNameAsString(), "name") TYPE_ATTRIBUTE_XML(getType()) ATTRIBUTE_ENUM_OPT_XML(getStorageClass(), "storage_class") - ENUM_XML(VarDecl::None, "") - ENUM_XML(VarDecl::Auto, "auto") - ENUM_XML(VarDecl::Register, "register") - ENUM_XML(VarDecl::Extern, "extern") - ENUM_XML(VarDecl::Static, "static") - ENUM_XML(VarDecl::PrivateExtern, "__private_extern__") + ENUM_XML(SC_None, "") + ENUM_XML(SC_Auto, "auto") + ENUM_XML(SC_Register, "register") + ENUM_XML(SC_Extern, "extern") + ENUM_XML(SC_Static, "static") + ENUM_XML(SC_PrivateExtern, "__private_extern__") END_ENUM_XML SUB_NODE_OPT_XML(Expr) // init expr END_NODE_XML diff --git a/include/clang/Sema/DelayedDiagnostic.h b/include/clang/Sema/DelayedDiagnostic.h index 655f8332be..6a9a1bf5b6 100644 --- a/include/clang/Sema/DelayedDiagnostic.h +++ b/include/clang/Sema/DelayedDiagnostic.h @@ -56,7 +56,7 @@ public: CXXRecordDecl *DerivedClass, AccessSpecifier Access) : Access(Access), IsMember(false), - Target(reinterpret_cast(BaseClass)), + Target(BaseClass), NamingClass(DerivedClass), Diag(0, Context.getDiagAllocator()) { } @@ -71,7 +71,7 @@ public: // ...and these apply to hierarchy conversions. CXXRecordDecl *getBaseClass() const { - assert(!IsMember); return reinterpret_cast(Target); + assert(!IsMember); return cast(Target); } CXXRecordDecl *getDerivedClass() const { return NamingClass; } diff --git a/include/clang/Sema/Sema.h b/include/clang/Sema/Sema.h index e6e97dfed5..8a880739e4 100644 --- a/include/clang/Sema/Sema.h +++ b/include/clang/Sema/Sema.h @@ -20,9 +20,9 @@ #include "clang/Sema/IdentifierResolver.h" #include "clang/Sema/ObjCMethodList.h" #include "clang/AST/OperationKinds.h" -#include "clang/AST/Decl.h" -#include "clang/AST/Expr.h" +#include "clang/AST/DeclBase.h" #include "clang/AST/DeclarationName.h" +#include "clang/AST/ExternalASTSource.h" #include "llvm/ADT/OwningPtr.h" #include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/SmallVector.h" @@ -40,6 +40,7 @@ namespace clang { class ASTConsumer; class ASTContext; class ArrayType; + class BlockDecl; class CXXBasePath; class CXXBasePaths; typedef llvm::SmallVector CXXCastPath; @@ -62,8 +63,10 @@ namespace clang { class DeclContext; class DeclRefExpr; class DeclSpec; + class DeclaratorDecl; class DeducedTemplateArgument; class DesignatedInitExpr; + class EnumConstantDecl; class Expr; class ExtVectorType; class ExternalSemaSource; @@ -71,6 +74,7 @@ namespace clang { class FullExpr; class FunctionDecl; class FunctionProtoType; + class FunctionTemplateDecl; class ImplicitConversionSequence; class InitListExpr; class InitializationKind; @@ -116,12 +120,13 @@ namespace clang { class TemplateTemplateParmDecl; class Token; class TypedefDecl; - class TypedefDecl; class UnresolvedLookupExpr; class UnresolvedMemberExpr; + class UnresolvedSetImpl; class UnresolvedSetIterator; class UsingDecl; class UsingShadowDecl; + class ValueDecl; class VarDecl; class VisibleDeclConsumer; @@ -652,8 +657,8 @@ public: TypeSourceInfo *TSInfo, QualType T, IdentifierInfo *Name, SourceLocation NameLoc, - VarDecl::StorageClass StorageClass, - VarDecl::StorageClass StorageClassAsWritten); + StorageClass SC, + StorageClass SCAsWritten); virtual void ActOnParamDefaultArgument(Decl *param, SourceLocation EqualLoc, ExprArg defarg); @@ -2487,13 +2492,13 @@ public: MultiTemplateParamsArg TemplateParams); QualType CheckConstructorDeclarator(Declarator &D, QualType R, - FunctionDecl::StorageClass& SC); + StorageClass& SC); void CheckConstructor(CXXConstructorDecl *Constructor); QualType CheckDestructorDeclarator(Declarator &D, QualType R, - FunctionDecl::StorageClass& SC); + StorageClass& SC); bool CheckDestructor(CXXDestructorDecl *Destructor); void CheckConversionDeclarator(Declarator &D, QualType &R, - FunctionDecl::StorageClass& SC); + StorageClass& SC); Decl *ActOnConversionDeclarator(CXXConversionDecl *Conversion); //===--------------------------------------------------------------------===// diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp index 00b052d476..bef6194e26 100644 --- a/lib/AST/Decl.cpp +++ b/lib/AST/Decl.cpp @@ -116,7 +116,7 @@ static Linkage getLinkageForNamespaceScopeDecl(const NamedDecl *D) { // (This bullet corresponds to C99 6.2.2p3.) if (const VarDecl *Var = dyn_cast(D)) { // Explicitly declared static. - if (Var->getStorageClass() == VarDecl::Static) + if (Var->getStorageClass() == SC_Static) return InternalLinkage; // - an object or reference that is explicitly declared const @@ -125,8 +125,8 @@ static Linkage getLinkageForNamespaceScopeDecl(const NamedDecl *D) { // (there is no equivalent in C99) if (Context.getLangOptions().CPlusPlus && Var->getType().isConstant(Context) && - Var->getStorageClass() != VarDecl::Extern && - Var->getStorageClass() != VarDecl::PrivateExtern) { + Var->getStorageClass() != SC_Extern && + Var->getStorageClass() != SC_PrivateExtern) { bool FoundExtern = false; for (const VarDecl *PrevVar = Var->getPreviousDeclaration(); PrevVar && !FoundExtern; @@ -149,7 +149,7 @@ static Linkage getLinkageForNamespaceScopeDecl(const NamedDecl *D) { Function = cast(D); // Explicitly declared static. - if (Function->getStorageClass() == FunctionDecl::Static) + if (Function->getStorageClass() == SC_Static) return InternalLinkage; } else if (const FieldDecl *Field = dyn_cast(D)) { // - a data member of an anonymous union. @@ -165,8 +165,8 @@ static Linkage getLinkageForNamespaceScopeDecl(const NamedDecl *D) { // - an object or reference, unless it has internal linkage; or if (const VarDecl *Var = dyn_cast(D)) { if (!Context.getLangOptions().CPlusPlus && - (Var->getStorageClass() == VarDecl::Extern || - Var->getStorageClass() == VarDecl::PrivateExtern)) { + (Var->getStorageClass() == SC_Extern || + Var->getStorageClass() == SC_PrivateExtern)) { // C99 6.2.2p4: // For an identifier declared with the storage-class specifier // extern in a scope in which a prior declaration of that @@ -200,9 +200,9 @@ static Linkage getLinkageForNamespaceScopeDecl(const NamedDecl *D) { // as if it were declared with the storage-class specifier // extern. if (!Context.getLangOptions().CPlusPlus && - (Function->getStorageClass() == FunctionDecl::Extern || - Function->getStorageClass() == FunctionDecl::PrivateExtern || - Function->getStorageClass() == FunctionDecl::None)) { + (Function->getStorageClass() == SC_Extern || + Function->getStorageClass() == SC_PrivateExtern || + Function->getStorageClass() == SC_None)) { // C99 6.2.2p4: // For an identifier declared with the storage-class specifier // extern in a scope in which a prior declaration of that @@ -383,8 +383,8 @@ Linkage NamedDecl::getLinkage() const { } if (const VarDecl *Var = dyn_cast(this)) - if (Var->getStorageClass() == VarDecl::Extern || - Var->getStorageClass() == VarDecl::PrivateExtern) { + if (Var->getStorageClass() == SC_Extern || + Var->getStorageClass() == SC_PrivateExtern) { if (Var->getPreviousDeclaration()) if (Linkage L = Var->getPreviousDeclaration()->getLinkage()) return L; @@ -637,12 +637,12 @@ QualifierInfo::setTemplateParameterListsInfo(ASTContext &Context, const char *VarDecl::getStorageClassSpecifierString(StorageClass SC) { switch (SC) { - case VarDecl::None: break; - case VarDecl::Auto: return "auto"; break; - case VarDecl::Extern: return "extern"; break; - case VarDecl::PrivateExtern: return "__private_extern__"; break; - case VarDecl::Register: return "register"; break; - case VarDecl::Static: return "static"; break; + case SC_None: break; + case SC_Auto: return "auto"; break; + case SC_Extern: return "extern"; break; + case SC_PrivateExtern: return "__private_extern__"; break; + case SC_Register: return "register"; break; + case SC_Static: return "static"; break; } assert(0 && "Invalid storage class"); @@ -672,14 +672,14 @@ bool VarDecl::isExternC() const { ASTContext &Context = getASTContext(); if (!Context.getLangOptions().CPlusPlus) return (getDeclContext()->isTranslationUnit() && - getStorageClass() != Static) || + getStorageClass() != SC_Static) || (getDeclContext()->isFunctionOrMethod() && hasExternalStorage()); for (const DeclContext *DC = getDeclContext(); !DC->isTranslationUnit(); DC = DC->getParent()) { if (const LinkageSpecDecl *Linkage = dyn_cast(DC)) { if (Linkage->getLanguage() == LinkageSpecDecl::lang_c) - return getStorageClass() != Static; + return getStorageClass() != SC_Static; break; } @@ -724,8 +724,8 @@ VarDecl::DefinitionKind VarDecl::isThisDeclarationADefinition() const { if (hasExternalStorage()) return DeclarationOnly; - if (getStorageClassAsWritten() == Extern || - getStorageClassAsWritten() == PrivateExtern) { + if (getStorageClassAsWritten() == SC_Extern || + getStorageClassAsWritten() == SC_PrivateExtern) { for (const VarDecl *PrevVar = getPreviousDeclaration(); PrevVar; PrevVar = PrevVar->getPreviousDeclaration()) { if (PrevVar->getLinkage() == InternalLinkage && PrevVar->hasInit()) @@ -978,13 +978,13 @@ bool FunctionDecl::isExternC() const { // In C, any non-static, non-overloadable function has external // linkage. if (!Context.getLangOptions().CPlusPlus) - return getStorageClass() != Static && !getAttr(); + return getStorageClass() != SC_Static && !getAttr(); for (const DeclContext *DC = getDeclContext(); !DC->isTranslationUnit(); DC = DC->getParent()) { if (const LinkageSpecDecl *Linkage = dyn_cast(DC)) { if (Linkage->getLanguage() == LinkageSpecDecl::lang_c) - return getStorageClass() != Static && + return getStorageClass() != SC_Static && !getAttr(); break; @@ -1001,7 +1001,7 @@ bool FunctionDecl::isGlobal() const { if (const CXXMethodDecl *Method = dyn_cast(this)) return Method->isStatic(); - if (getStorageClass() == Static) + if (getStorageClass() == SC_Static) return false; for (const DeclContext *DC = getDeclContext(); @@ -1060,7 +1060,7 @@ unsigned FunctionDecl::getBuiltinID() const { // function or whether it just has the same name. // If this is a static function, it's not a builtin. - if (getStorageClass() == Static) + if (getStorageClass() == SC_Static) return 0; // If this function is at translation-unit scope and we're not in @@ -1194,7 +1194,7 @@ bool FunctionDecl::isInlineDefinitionExternallyVisible() const { for (redecl_iterator Redecl = redecls_begin(), RedeclEnd = redecls_end(); Redecl != RedeclEnd; ++Redecl) { - if (Redecl->isInlineSpecified() && Redecl->getStorageClass() != Extern) + if (Redecl->isInlineSpecified() && Redecl->getStorageClass() != SC_Extern) return true; } @@ -1213,7 +1213,7 @@ bool FunctionDecl::isInlineDefinitionExternallyVisible() const { if (!Redecl->getLexicalDeclContext()->isTranslationUnit()) continue; - if (!Redecl->isInlineSpecified() || Redecl->getStorageClass() == Extern) + if (!Redecl->isInlineSpecified() || Redecl->getStorageClass() == SC_Extern) return true; // Not an inline definition } diff --git a/lib/AST/DeclPrinter.cpp b/lib/AST/DeclPrinter.cpp index a42be556f2..f18d2f0215 100644 --- a/lib/AST/DeclPrinter.cpp +++ b/lib/AST/DeclPrinter.cpp @@ -335,10 +335,11 @@ void DeclPrinter::VisitEnumConstantDecl(EnumConstantDecl *D) { void DeclPrinter::VisitFunctionDecl(FunctionDecl *D) { if (!Policy.SuppressSpecifiers) { switch (D->getStorageClass()) { - case FunctionDecl::None: break; - case FunctionDecl::Extern: Out << "extern "; break; - case FunctionDecl::Static: Out << "static "; break; - case FunctionDecl::PrivateExtern: Out << "__private_extern__ "; break; + 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: llvm_unreachable("invalid for functions"); } if (D->isInlineSpecified()) Out << "inline "; @@ -505,7 +506,7 @@ void DeclPrinter::VisitFieldDecl(FieldDecl *D) { } void DeclPrinter::VisitVarDecl(VarDecl *D) { - if (!Policy.SuppressSpecifiers && D->getStorageClass() != VarDecl::None) + if (!Policy.SuppressSpecifiers && D->getStorageClass() != SC_None) Out << VarDecl::getStorageClassSpecifierString(D->getStorageClass()) << " "; if (!Policy.SuppressSpecifiers && D->isThreadSpecified()) diff --git a/lib/AST/StmtDumper.cpp b/lib/AST/StmtDumper.cpp index 44601e0bdf..850bba40b7 100644 --- a/lib/AST/StmtDumper.cpp +++ b/lib/AST/StmtDumper.cpp @@ -225,7 +225,7 @@ void StmtDumper::DumpDeclarator(Decl *D) { OS << "\""; // Emit storage class for vardecls. if (VarDecl *V = dyn_cast(VD)) { - if (V->getStorageClass() != VarDecl::None) + if (V->getStorageClass() != SC_None) OS << VarDecl::getStorageClassSpecifierString(V->getStorageClass()) << " "; } diff --git a/lib/Checker/BasicStore.cpp b/lib/Checker/BasicStore.cpp index 002d4ee835..f82e1b20be 100644 --- a/lib/Checker/BasicStore.cpp +++ b/lib/Checker/BasicStore.cpp @@ -437,11 +437,11 @@ Store BasicStoreManager::BindDeclInternal(Store store, const VarRegion* VR, // will not be called more than once. // Static global variables should not be visited here. - assert(!(VD->getStorageClass() == VarDecl::Static && + assert(!(VD->getStorageClass() == SC_Static && VD->isFileVarDecl())); // Process static variables. - if (VD->getStorageClass() == VarDecl::Static) { + if (VD->getStorageClass() == SC_Static) { // C99: 6.7.8 Initialization // If an object that has static storage duration is not initialized // explicitly, then: diff --git a/lib/CodeGen/CGBlocks.cpp b/lib/CodeGen/CGBlocks.cpp index 5feca9d2e0..04f1ef24b2 100644 --- a/lib/CodeGen/CGBlocks.cpp +++ b/lib/CodeGen/CGBlocks.cpp @@ -722,7 +722,7 @@ CodeGenFunction::GenerateBlockFunction(GlobalDecl GD, const BlockExpr *BExpr, ++i) { const VarDecl *VD = dyn_cast(i->first); - if (VD->getStorageClass() == VarDecl::Static || VD->hasExternalStorage()) + if (VD->getStorageClass() == SC_Static || VD->hasExternalStorage()) LocalDeclMap[VD] = i->second; } @@ -803,8 +803,8 @@ CodeGenFunction::GenerateBlockFunction(GlobalDecl GD, const BlockExpr *BExpr, getContext().getTranslationUnitDecl(), SourceLocation(), ID, FnType, 0, - FunctionDecl::Static, - FunctionDecl::None, + SC_Static, + SC_None, false, HasPrototype); if (FunctionProtoType *FT = dyn_cast(FnType)) { const FunctionDecl *CFD = dyn_cast(CurCodeDecl); @@ -814,7 +814,7 @@ CodeGenFunction::GenerateBlockFunction(GlobalDecl GD, const BlockExpr *BExpr, Params.push_back(ParmVarDecl::Create(getContext(), FD, SourceLocation(), 0, FT->getArgType(i), /*TInfo=*/0, - VarDecl::None, VarDecl::None, 0)); + SC_None, SC_None, 0)); FD->setParams(Params.data(), Params.size()); } @@ -916,7 +916,7 @@ CharUnits BlockFunction::getBlockOffset(CharUnits Size, CharUnits Align) { getContext().getTranslationUnitDecl(), SourceLocation(), 0, QualType(PadTy), 0, - VarDecl::None, VarDecl::None); + SC_None, SC_None); Expr *E = new (getContext()) DeclRefExpr(PadDecl, PadDecl->getType(), SourceLocation()); BlockLayout.push_back(E); @@ -962,8 +962,8 @@ GenerateCopyHelperFunction(bool BlockHasCopyDispose, const llvm::StructType *T, FunctionDecl *FD = FunctionDecl::Create(getContext(), getContext().getTranslationUnitDecl(), SourceLocation(), II, R, 0, - FunctionDecl::Static, - FunctionDecl::None, + SC_Static, + SC_None, false, true); CGF.StartFunction(FD, R, Fn, Args, SourceLocation()); @@ -1044,8 +1044,8 @@ GenerateDestroyHelperFunction(bool BlockHasCopyDispose, FunctionDecl *FD = FunctionDecl::Create(getContext(), getContext().getTranslationUnitDecl(), SourceLocation(), II, R, 0, - FunctionDecl::Static, - FunctionDecl::None, + SC_Static, + SC_None, false, true); CGF.StartFunction(FD, R, Fn, Args, SourceLocation()); @@ -1129,8 +1129,8 @@ GeneratebyrefCopyHelperFunction(const llvm::Type *T, int flag) { FunctionDecl *FD = FunctionDecl::Create(getContext(), getContext().getTranslationUnitDecl(), SourceLocation(), II, R, 0, - FunctionDecl::Static, - FunctionDecl::None, + SC_Static, + SC_None, false, true); CGF.StartFunction(FD, R, Fn, Args, SourceLocation()); @@ -1193,8 +1193,8 @@ BlockFunction::GeneratebyrefDestroyHelperFunction(const llvm::Type *T, FunctionDecl *FD = FunctionDecl::Create(getContext(), getContext().getTranslationUnitDecl(), SourceLocation(), II, R, 0, - FunctionDecl::Static, - FunctionDecl::None, + SC_Static, + SC_None, false, true); CGF.StartFunction(FD, R, Fn, Args, SourceLocation()); diff --git a/lib/CodeGen/CGDecl.cpp b/lib/CodeGen/CGDecl.cpp index fa75daee86..8ce196b64e 100644 --- a/lib/CodeGen/CGDecl.cpp +++ b/lib/CodeGen/CGDecl.cpp @@ -107,11 +107,11 @@ void CodeGenFunction::EmitBlockVarDecl(const VarDecl &D) { CGM.ErrorUnsupported(&D, "__asm__"); switch (D.getStorageClass()) { - case VarDecl::None: - case VarDecl::Auto: - case VarDecl::Register: + case SC_None: + case SC_Auto: + case SC_Register: return EmitLocalBlockVarDecl(D); - case VarDecl::Static: { + case SC_Static: { llvm::GlobalValue::LinkageTypes Linkage = llvm::GlobalValue::InternalLinkage; @@ -126,8 +126,8 @@ void CodeGenFunction::EmitBlockVarDecl(const VarDecl &D) { return EmitStaticBlockVarDecl(D, Linkage); } - case VarDecl::Extern: - case VarDecl::PrivateExtern: + case SC_Extern: + case SC_PrivateExtern: // Don't emit it now, allow it to be emitted lazily on its first use. return; } @@ -568,7 +568,7 @@ void CodeGenFunction::EmitLocalBlockVarDecl(const VarDecl &D, } else { // Targets that don't support recursion emit locals as globals. const char *Class = - D.getStorageClass() == VarDecl::Register ? ".reg." : ".auto."; + D.getStorageClass() == SC_Register ? ".reg." : ".auto."; DeclPtr = CreateStaticBlockVarDecl(D, Class, llvm::GlobalValue ::InternalLinkage); diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp index e6388373ea..d8e12e7cb9 100644 --- a/lib/CodeGen/CodeGenModule.cpp +++ b/lib/CodeGen/CodeGenModule.cpp @@ -145,7 +145,7 @@ void CodeGenModule::ErrorUnsupported(const Decl *D, const char *Type, LangOptions::VisibilityMode CodeGenModule::getDeclVisibilityMode(const Decl *D) const { if (const VarDecl *VD = dyn_cast(D)) - if (VD->getStorageClass() == VarDecl::PrivateExtern) + if (VD->getStorageClass() == SC_PrivateExtern) return LangOptions::Hidden; if (const VisibilityAttr *attr = D->getAttr()) { @@ -965,7 +965,7 @@ CodeGenModule::GetOrCreateLLVMGlobal(llvm::StringRef MangledName, GV->setConstant(DeclIsConstantGlobal(Context, D)); // FIXME: Merge with other attribute handling code. - if (D->getStorageClass() == VarDecl::PrivateExtern) + if (D->getStorageClass() == SC_PrivateExtern) GV->setVisibility(llvm::GlobalValue::HiddenVisibility); if (D->hasAttr() || diff --git a/lib/Index/Entity.cpp b/lib/Index/Entity.cpp index 7a247191be..749dcc8993 100644 --- a/lib/Index/Entity.cpp +++ b/lib/Index/Entity.cpp @@ -134,7 +134,7 @@ Entity EntityGetter::VisitVarDecl(VarDecl *D) { return Entity(); // If it's static it cannot be referred to by another translation unit. - if (D->getStorageClass() == VarDecl::Static) + if (D->getStorageClass() == SC_Static) return Entity(D); return VisitNamedDecl(D); @@ -142,7 +142,7 @@ Entity EntityGetter::VisitVarDecl(VarDecl *D) { Entity EntityGetter::VisitFunctionDecl(FunctionDecl *D) { // If it's static it cannot be refered to by another translation unit. - if (D->getStorageClass() == FunctionDecl::Static) + if (D->getStorageClass() == SC_Static) return Entity(D); return VisitNamedDecl(D); diff --git a/lib/Rewrite/RewriteObjC.cpp b/lib/Rewrite/RewriteObjC.cpp index b3ba72d220..80b9681a7e 100644 --- a/lib/Rewrite/RewriteObjC.cpp +++ b/lib/Rewrite/RewriteObjC.cpp @@ -2265,8 +2265,8 @@ void RewriteObjC::SynthSelGetUidFunctionDecl() { SelGetUidFunctionDecl = FunctionDecl::Create(*Context, TUDecl, SourceLocation(), SelGetUidIdent, getFuncType, 0, - FunctionDecl::Extern, - FunctionDecl::None, false); + SC_Extern, + SC_None, false); } void RewriteObjC::RewriteFunctionDecl(FunctionDecl *FD) { @@ -2364,8 +2364,8 @@ void RewriteObjC::SynthSuperContructorFunctionDecl() { SuperContructorFunctionDecl = FunctionDecl::Create(*Context, TUDecl, SourceLocation(), msgSendIdent, msgSendType, 0, - FunctionDecl::Extern, - FunctionDecl::None, false); + SC_Extern, + SC_None, false); } // SynthMsgSendFunctionDecl - id objc_msgSend(id self, SEL op, ...); @@ -2386,8 +2386,8 @@ void RewriteObjC::SynthMsgSendFunctionDecl() { MsgSendFunctionDecl = FunctionDecl::Create(*Context, TUDecl, SourceLocation(), msgSendIdent, msgSendType, 0, - FunctionDecl::Extern, - FunctionDecl::None, false); + SC_Extern, + SC_None, false); } // SynthMsgSendSuperFunctionDecl - id objc_msgSendSuper(struct objc_super *, SEL op, ...); @@ -2411,8 +2411,8 @@ void RewriteObjC::SynthMsgSendSuperFunctionDecl() { MsgSendSuperFunctionDecl = FunctionDecl::Create(*Context, TUDecl, SourceLocation(), msgSendIdent, msgSendType, 0, - FunctionDecl::Extern, - FunctionDecl::None, false); + SC_Extern, + SC_None, false); } // SynthMsgSendStretFunctionDecl - id objc_msgSend_stret(id self, SEL op, ...); @@ -2433,8 +2433,8 @@ void RewriteObjC::SynthMsgSendStretFunctionDecl() { MsgSendStretFunctionDecl = FunctionDecl::Create(*Context, TUDecl, SourceLocation(), msgSendIdent, msgSendType, 0, - FunctionDecl::Extern, - FunctionDecl::None, false); + SC_Extern, + SC_None, false); } // SynthMsgSendSuperStretFunctionDecl - @@ -2460,8 +2460,8 @@ void RewriteObjC::SynthMsgSendSuperStretFunctionDecl() { MsgSendSuperStretFunctionDecl = FunctionDecl::Create(*Context, TUDecl, SourceLocation(), msgSendIdent, msgSendType, 0, - FunctionDecl::Extern, - FunctionDecl::None, false); + SC_Extern, + SC_None, false); } // SynthMsgSendFpretFunctionDecl - double objc_msgSend_fpret(id self, SEL op, ...); @@ -2482,8 +2482,8 @@ void RewriteObjC::SynthMsgSendFpretFunctionDecl() { MsgSendFpretFunctionDecl = FunctionDecl::Create(*Context, TUDecl, SourceLocation(), msgSendIdent, msgSendType, 0, - FunctionDecl::Extern, - FunctionDecl::None, false); + SC_Extern, + SC_None, false); } // SynthGetClassFunctionDecl - id objc_getClass(const char *name); @@ -2499,8 +2499,8 @@ void RewriteObjC::SynthGetClassFunctionDecl() { GetClassFunctionDecl = FunctionDecl::Create(*Context, TUDecl, SourceLocation(), getClassIdent, getClassType, 0, - FunctionDecl::Extern, - FunctionDecl::None, false); + SC_Extern, + SC_None, false); } // SynthGetSuperClassFunctionDecl - Class class_getSuperclass(Class cls); @@ -2518,8 +2518,8 @@ void RewriteObjC::SynthGetSuperClassFunctionDecl() { SourceLocation(), getSuperClassIdent, getClassType, 0, - FunctionDecl::Extern, - FunctionDecl::None, + SC_Extern, + SC_None, false); } @@ -2536,8 +2536,8 @@ void RewriteObjC::SynthGetMetaClassFunctionDecl() { GetMetaClassFunctionDecl = FunctionDecl::Create(*Context, TUDecl, SourceLocation(), getClassIdent, getClassType, 0, - FunctionDecl::Extern, - FunctionDecl::None, false); + SC_Extern, + SC_None, false); } Stmt *RewriteObjC::RewriteObjCStringLiteral(ObjCStringLiteral *Exp) { @@ -2571,7 +2571,7 @@ Stmt *RewriteObjC::RewriteObjCStringLiteral(ObjCStringLiteral *Exp) { VarDecl *NewVD = VarDecl::Create(*Context, TUDecl, SourceLocation(), &Context->Idents.get(S), strType, 0, - VarDecl::Static, VarDecl::None); + SC_Static, SC_None); DeclRefExpr *DRE = new (Context) DeclRefExpr(NewVD, strType, SourceLocation()); Expr *Unop = new (Context) UnaryOperator(DRE, UO_AddrOf, Context->getPointerType(DRE->getType()), @@ -3080,7 +3080,7 @@ Stmt *RewriteObjC::RewriteObjCProtocolExpr(ObjCProtocolExpr *Exp) { IdentifierInfo *ID = &Context->Idents.get(Name); VarDecl *VD = VarDecl::Create(*Context, TUDecl, SourceLocation(), ID, getProtocolType(), 0, - VarDecl::Extern, VarDecl::None); + SC_Extern, SC_None); DeclRefExpr *DRE = new (Context) DeclRefExpr(VD, getProtocolType(), SourceLocation()); Expr *DerefExpr = new (Context) UnaryOperator(DRE, UO_AddrOf, Context->getPointerType(DRE->getType()), @@ -4344,7 +4344,7 @@ void RewriteObjC::SynthesizeBlockLiterals(SourceLocation FunLocStart, RewriteBlockLiteralFunctionDecl(CurFunctionDeclToDeclareForBlock); bool RewriteSC = (GlobalVarDecl && !Blocks.empty() && - GlobalVarDecl->getStorageClass() == VarDecl::Static && + GlobalVarDecl->getStorageClass() == SC_Static && GlobalVarDecl->getType().getCVRQualifiers()); if (RewriteSC) { std::string SC(" void __"); @@ -4402,7 +4402,7 @@ void RewriteObjC::SynthesizeBlockLiterals(SourceLocation FunLocStart, // Must insert any 'const/volatile/static here. Since it has been // removed as result of rewriting of block literals. std::string SC; - if (GlobalVarDecl->getStorageClass() == VarDecl::Static) + if (GlobalVarDecl->getStorageClass() == SC_Static) SC = "static "; if (GlobalVarDecl->getType().isConstQualified()) SC += "const "; @@ -5115,8 +5115,8 @@ FunctionDecl *RewriteObjC::SynthBlockInitFunctionDecl(llvm::StringRef name) { IdentifierInfo *ID = &Context->Idents.get(name); QualType FType = Context->getFunctionNoProtoType(Context->VoidPtrTy); return FunctionDecl::Create(*Context, TUDecl,SourceLocation(), - ID, FType, 0, FunctionDecl::Extern, - FunctionDecl::None, false, false); + ID, FType, 0, SC_Extern, + SC_None, false, false); } Stmt *RewriteObjC::SynthBlockInitExpr(BlockExpr *Exp, @@ -5197,7 +5197,7 @@ Stmt *RewriteObjC::SynthBlockInitExpr(BlockExpr *Exp, VarDecl *NewVD = VarDecl::Create(*Context, TUDecl, SourceLocation(), &Context->Idents.get(DescData.c_str()), Context->VoidPtrTy, 0, - VarDecl::Static, VarDecl::None); + SC_Static, SC_None); UnaryOperator *DescRefExpr = new (Context) UnaryOperator( new (Context) DeclRefExpr(NewVD, Context->VoidPtrTy, SourceLocation()), diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 158566a384..3473bffce8 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -578,7 +578,7 @@ bool Sema::ShouldWarnIfUnusedFileScopedDecl(const DeclaratorDecl *D) const { return false; } else { // 'static inline' functions are used in headers; don't warn. - if (FD->getStorageClass() == FunctionDecl::Static && + if (FD->getStorageClass() == SC_Static && FD->isInlineSpecified()) return false; } @@ -835,8 +835,8 @@ NamedDecl *Sema::LazilyCreateBuiltin(IdentifierInfo *II, unsigned bid, FunctionDecl *New = FunctionDecl::Create(Context, Context.getTranslationUnitDecl(), Loc, II, R, /*TInfo=*/0, - FunctionDecl::Extern, - FunctionDecl::None, false, + SC_Extern, + SC_None, false, /*hasPrototype=*/true); New->setImplicit(); @@ -847,7 +847,7 @@ NamedDecl *Sema::LazilyCreateBuiltin(IdentifierInfo *II, unsigned bid, for (unsigned i = 0, e = FT->getNumArgs(); i != e; ++i) Params.push_back(ParmVarDecl::Create(Context, New, SourceLocation(), 0, FT->getArgType(i), /*TInfo=*/0, - VarDecl::None, VarDecl::None, 0)); + SC_None, SC_None, 0)); New->setParams(Params.data(), Params.size()); } @@ -1080,7 +1080,7 @@ static bool canRedefineFunction(const FunctionDecl *FD, const LangOptions& LangOpts) { return (LangOpts.GNUMode && !LangOpts.C99 && !LangOpts.CPlusPlus && FD->isInlineSpecified() && - FD->getStorageClass() == FunctionDecl::Extern); + FD->getStorageClass() == SC_Extern); } /// MergeFunctionDecl - We just parsed a function 'New' from @@ -1134,8 +1134,8 @@ bool Sema::MergeFunctionDecl(FunctionDecl *New, Decl *OldD) { // Don't complain about this if we're in GNU89 mode and the old function // is an extern inline function. if (!isa(New) && !isa(Old) && - New->getStorageClass() == FunctionDecl::Static && - Old->getStorageClass() != FunctionDecl::Static && + New->getStorageClass() == SC_Static && + Old->getStorageClass() != SC_Static && !canRedefineFunction(Old, getLangOptions())) { Diag(New->getLocation(), diag::err_static_non_static) << New; @@ -1316,7 +1316,7 @@ bool Sema::MergeFunctionDecl(FunctionDecl *New, Decl *OldD) { ParmVarDecl *Param = ParmVarDecl::Create(Context, New, SourceLocation(), 0, *ParamType, /*TInfo=*/0, - VarDecl::None, VarDecl::None, + SC_None, SC_None, 0); Param->setImplicit(); Params.push_back(Param); @@ -1434,8 +1434,8 @@ bool Sema::MergeCompatibleFunctionDecls(FunctionDecl *New, FunctionDecl *Old) { MergeDeclAttributes(New, Old, Context); // Merge the storage class. - if (Old->getStorageClass() != FunctionDecl::Extern && - Old->getStorageClass() != FunctionDecl::None) + if (Old->getStorageClass() != SC_Extern && + Old->getStorageClass() != SC_None) New->setStorageClass(Old->getStorageClass()); // Merge "pure" flag. @@ -1520,8 +1520,8 @@ void Sema::MergeVarDecl(VarDecl *New, LookupResult &Previous) { New->setType(MergedT); // C99 6.2.2p4: Check if we have a static decl followed by a non-static. - if (New->getStorageClass() == VarDecl::Static && - (Old->getStorageClass() == VarDecl::None || Old->hasExternalStorage())) { + if (New->getStorageClass() == SC_Static && + (Old->getStorageClass() == SC_None || Old->hasExternalStorage())) { Diag(New->getLocation(), diag::err_static_non_static) << New->getDeclName(); Diag(Old->getLocation(), diag::note_previous_definition); return New->setInvalidDecl(); @@ -1537,8 +1537,8 @@ void Sema::MergeVarDecl(VarDecl *New, LookupResult &Previous) { // identifier has external linkage. if (New->hasExternalStorage() && Old->hasLinkage()) /* Okay */; - else if (New->getStorageClass() != VarDecl::Static && - Old->getStorageClass() == VarDecl::Static) { + else if (New->getStorageClass() != SC_Static && + Old->getStorageClass() == SC_Static) { Diag(New->getLocation(), diag::err_non_static_static) << New->getDeclName(); Diag(Old->getLocation(), diag::note_previous_definition); return New->setInvalidDecl(); @@ -1780,38 +1780,38 @@ static bool InjectAnonymousStructOrUnionMembers(Sema &SemaRef, Scope *S, /// StorageClassSpecToVarDeclStorageClass - Maps a DeclSpec::SCS to /// a VarDecl::StorageClass. Any error reporting is up to the caller: -/// illegal input values are mapped to VarDecl::None. -static VarDecl::StorageClass +/// illegal input values are mapped to SC_None. +static StorageClass StorageClassSpecToVarDeclStorageClass(DeclSpec::SCS StorageClassSpec) { switch (StorageClassSpec) { - case DeclSpec::SCS_unspecified: return VarDecl::None; - case DeclSpec::SCS_extern: return VarDecl::Extern; - case DeclSpec::SCS_static: return VarDecl::Static; - case DeclSpec::SCS_auto: return VarDecl::Auto; - case DeclSpec::SCS_register: return VarDecl::Register; - case DeclSpec::SCS_private_extern: return VarDecl::PrivateExtern; + case DeclSpec::SCS_unspecified: return SC_None; + case DeclSpec::SCS_extern: return SC_Extern; + case DeclSpec::SCS_static: return SC_Static; + case DeclSpec::SCS_auto: return SC_Auto; + case DeclSpec::SCS_register: return SC_Register; + case DeclSpec::SCS_private_extern: return SC_PrivateExtern; // Illegal SCSs map to None: error reporting is up to the caller. case DeclSpec::SCS_mutable: // Fall through. - case DeclSpec::SCS_typedef: return VarDecl::None; + case DeclSpec::SCS_typedef: return SC_None; } llvm_unreachable("unknown storage class specifier"); } /// StorageClassSpecToFunctionDeclStorageClass - Maps a DeclSpec::SCS to -/// a FunctionDecl::StorageClass. Any error reporting is up to the caller: -/// illegal input values are mapped to FunctionDecl::None. -static FunctionDecl::StorageClass +/// a StorageClass. Any error reporting is up to the caller: +/// illegal input values are mapped to SC_None. +static StorageClass StorageClassSpecToFunctionDeclStorageClass(DeclSpec::SCS StorageClassSpec) { switch (StorageClassSpec) { - case DeclSpec::SCS_unspecified: return FunctionDecl::None; - case DeclSpec::SCS_extern: return FunctionDecl::Extern; - case DeclSpec::SCS_static: return FunctionDecl::Static; - case DeclSpec::SCS_private_extern: return FunctionDecl::PrivateExtern; + case DeclSpec::SCS_unspecified: return SC_None; + case DeclSpec::SCS_extern: return SC_Extern; + case DeclSpec::SCS_static: return SC_Static; + case DeclSpec::SCS_private_extern: return SC_PrivateExtern; // Illegal SCSs map to None: error reporting is up to the caller. case DeclSpec::SCS_auto: // Fall through. case DeclSpec::SCS_mutable: // Fall through. case DeclSpec::SCS_register: // Fall through. - case DeclSpec::SCS_typedef: return FunctionDecl::None; + case DeclSpec::SCS_typedef: return SC_None; } llvm_unreachable("unknown storage class specifier"); } @@ -1954,7 +1954,7 @@ Decl *Sema::BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS, // an error here Diag(Record->getLocation(), diag::err_mutable_nonmember); Invalid = true; - SC = VarDecl::None; + SC = SC_None; } SCSpec = DS.getStorageClassSpecAsWritten(); VarDecl::StorageClass SCAsWritten @@ -2688,7 +2688,7 @@ Sema::ActOnVariableDeclarator(Scope* S, Declarator& D, DeclContext* DC, // an error here Diag(D.getIdentifierLoc(), diag::err_mutable_nonmember); D.setInvalidType(); - SC = VarDecl::None; + SC = SC_None; } SCSpec = D.getDeclSpec().getStorageClassSpecAsWritten(); VarDecl::StorageClass SCAsWritten @@ -2706,11 +2706,11 @@ Sema::ActOnVariableDeclarator(Scope* S, Declarator& D, DeclContext* DC, if (!DC->isRecord() && S->getFnParent() == 0) { // C99 6.9p2: The storage-class specifiers auto and register shall not // appear in the declaration specifiers in an external declaration. - if (SC == VarDecl::Auto || SC == VarDecl::Register) { + if (SC == SC_Auto || SC == SC_Register) { // If this is a register variable with an asm label specified, then this // is a GNU extension. - if (SC == VarDecl::Register && D.getAsmLabel()) + if (SC == SC_Register && D.getAsmLabel()) Diag(D.getIdentifierLoc(), diag::err_unsupported_global_register); else Diag(D.getIdentifierLoc(), diag::err_typecheck_sclass_fscope); @@ -2719,14 +2719,14 @@ Sema::ActOnVariableDeclarator(Scope* S, Declarator& D, DeclContext* DC, } if (DC->isRecord() && !CurContext->isRecord()) { // This is an out-of-line definition of a static data member. - if (SC == VarDecl::Static) { + if (SC == SC_Static) { Diag(D.getDeclSpec().getStorageClassSpecLoc(), diag::err_static_out_of_line) << FixItHint::CreateRemoval(D.getDeclSpec().getStorageClassSpecLoc()); - } else if (SC == VarDecl::None) - SC = VarDecl::Static; + } else if (SC == SC_None) + SC = SC_Static; } - if (SC == VarDecl::Static) { + if (SC == SC_Static) { if (const CXXRecordDecl *RD = dyn_cast(DC)) { if (RD->isLocalClass()) Diag(D.getIdentifierLoc(), @@ -3004,7 +3004,7 @@ void Sema::CheckVariableDeclaration(VarDecl *NewVD, if (NewVD->isFileVarDecl()) Diag(NewVD->getLocation(), diag::err_vla_decl_in_file_scope) << SizeRange; - else if (NewVD->getStorageClass() == VarDecl::Static) + else if (NewVD->getStorageClass() == SC_Static) Diag(NewVD->getLocation(), diag::err_vla_decl_has_static_storage) << SizeRange; else @@ -3147,7 +3147,7 @@ Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC, // TODO: consider using NameInfo for diagnostic. DeclarationNameInfo NameInfo = GetNameForDeclarator(D); DeclarationName Name = NameInfo.getName(); - FunctionDecl::StorageClass SC = FunctionDecl::None; + FunctionDecl::StorageClass SC = SC_None; switch (D.getDeclSpec().getStorageClassSpec()) { default: assert(0 && "Unknown storage class!"); case DeclSpec::SCS_auto: @@ -3157,8 +3157,8 @@ Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC, diag::err_typecheck_sclass_func); D.setInvalidType(); break; - case DeclSpec::SCS_unspecified: SC = FunctionDecl::None; break; - case DeclSpec::SCS_extern: SC = FunctionDecl::Extern; break; + case DeclSpec::SCS_unspecified: SC = SC_None; break; + case DeclSpec::SCS_extern: SC = SC_Extern; break; case DeclSpec::SCS_static: { if (CurContext->getLookupContext()->isFunctionOrMethod()) { // C99 6.7.1p5: @@ -3168,12 +3168,12 @@ Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC, // See also (C++ [dcl.stc]p4). Diag(D.getDeclSpec().getStorageClassSpecLoc(), diag::err_static_block_func); - SC = FunctionDecl::None; + SC = SC_None; } else - SC = FunctionDecl::Static; + SC = SC_Static; break; } - case DeclSpec::SCS_private_extern: SC = FunctionDecl::PrivateExtern;break; + case DeclSpec::SCS_private_extern: SC = SC_PrivateExtern;break; } if (D.getDeclSpec().isThreadSpecified()) @@ -3279,7 +3279,7 @@ Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC, return 0; } - bool isStatic = SC == FunctionDecl::Static; + bool isStatic = SC == SC_Static; // [class.free]p1: // Any allocation function for a class T is a static member @@ -3468,7 +3468,7 @@ Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC, NewFD->setAccess(AS_public); } - if (SC == FunctionDecl::Static && isa(NewFD) && + if (SC == SC_Static && isa(NewFD) && !CurContext->isRecord()) { // C++ [class.static]p1: // A data or function member of a class may be declared static @@ -3963,7 +3963,7 @@ void Sema::CheckMain(FunctionDecl* FD) { // shall not appear in a declaration of main. // static main is not an error under C99, but we should warn about it. bool isInline = FD->isInlineSpecified(); - bool isStatic = FD->getStorageClass() == FunctionDecl::Static; + bool isStatic = FD->getStorageClass() == SC_Static; if (isInline || isStatic) { unsigned diagID = diag::warn_unusual_main_decl; if (isInline || getLangOptions().CPlusPlus) @@ -4190,7 +4190,7 @@ void Sema::AddInitializerToDecl(Decl *RealDecl, Expr *Init, bool DirectInit) { // C++ 3.6.2p2, allow dynamic initialization of static initializers. // Don't check invalid declarations to avoid emitting useless diagnostics. if (!getLangOptions().CPlusPlus && !VDecl->isInvalidDecl()) { - if (VDecl->getStorageClass() == VarDecl::Static) // C99 6.7.8p4. + if (VDecl->getStorageClass() == SC_Static) // C99 6.7.8p4. CheckForConstantInitializer(Init, DclT); } } @@ -4242,7 +4242,7 @@ void Sema::AddInitializerToDecl(Decl *RealDecl, Expr *Init, bool DirectInit) { } } } else if (VDecl->isFileVarDecl()) { - if (VDecl->getStorageClass() == VarDecl::Extern && + if (VDecl->getStorageClass() == SC_Extern && (!getLangOptions().CPlusPlus || !Context.getBaseElementType(VDecl->getType()).isConstQualified())) Diag(VDecl->getLocation(), diag::warn_extern_init); @@ -4394,7 +4394,7 @@ void Sema::ActOnUninitializedDecl(Decl *RealDecl, ArrayT->getElementType(), diag::err_illegal_decl_array_incomplete_type)) Var->setInvalidDecl(); - } else if (Var->getStorageClass() == VarDecl::Static) { + } else if (Var->getStorageClass() == SC_Static) { // C99 6.9.2p3: If the declaration of an identifier for an object is // a tentative definition and has internal linkage (C99 6.2.2p3), the // declared type shall not be an incomplete type. @@ -4529,11 +4529,11 @@ Decl *Sema::ActOnParamDeclarator(Scope *S, Declarator &D) { const DeclSpec &DS = D.getDeclSpec(); // Verify C99 6.7.5.3p2: The only SCS allowed is 'register'. - VarDecl::StorageClass StorageClass = VarDecl::None; - VarDecl::StorageClass StorageClassAsWritten = VarDecl::None; + VarDecl::StorageClass StorageClass = SC_None; + VarDecl::StorageClass StorageClassAsWritten = SC_None; if (DS.getStorageClassSpec() == DeclSpec::SCS_register) { - StorageClass = VarDecl::Register; - StorageClassAsWritten = VarDecl::Register; + StorageClass = SC_Register; + StorageClassAsWritten = SC_Register; } else if (DS.getStorageClassSpec() != DeclSpec::SCS_unspecified) { Diag(DS.getStorageClassSpecLoc(), diag::err_invalid_storage_class_in_func_decl); @@ -4624,7 +4624,7 @@ ParmVarDecl *Sema::BuildParmVarDeclForTypedef(DeclContext *DC, QualType T) { ParmVarDecl *Param = ParmVarDecl::Create(Context, DC, Loc, 0, T, Context.getTrivialTypeSourceInfo(T, Loc), - VarDecl::None, VarDecl::None, 0); + SC_None, SC_None, 0); Param->setImplicit(); return Param; } diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp index 46623d2818..177013e6d5 100644 --- a/lib/Sema/SemaDeclAttr.cpp +++ b/lib/Sema/SemaDeclAttr.cpp @@ -534,9 +534,9 @@ static void HandleOwnershipAttr(Decl *d, const AttributeList &AL, Sema &S) { static bool isStaticVarOrStaticFunciton(Decl *D) { if (VarDecl *VD = dyn_cast(D)) - return VD->getStorageClass() == VarDecl::Static; + return VD->getStorageClass() == SC_Static; if (FunctionDecl *FD = dyn_cast(D)) - return FD->getStorageClass() == FunctionDecl::Static; + return FD->getStorageClass() == SC_Static; return false; } diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp index e2662722b4..20d1177a21 100644 --- a/lib/Sema/SemaDeclCXX.cpp +++ b/lib/Sema/SemaDeclCXX.cpp @@ -1632,7 +1632,7 @@ BuildImplicitMemberInitializer(Sema &SemaRef, CXXConstructorDecl *Constructor, = VarDecl::Create(SemaRef.Context, SemaRef.CurContext, Loc, IterationVarName, SizeType, SemaRef.Context.getTrivialTypeSourceInfo(SizeType, Loc), - VarDecl::None, VarDecl::None); + SC_None, SC_None); IndexVariables.push_back(IterationVar); // Create a reference to the iteration variable. @@ -2895,7 +2895,7 @@ void Sema::ActOnFinishDelayedCXXMethodDeclaration(Scope *S, Decl *MethodD) { /// will be updated to reflect a well-formed type for the constructor and /// returned. QualType Sema::CheckConstructorDeclarator(Declarator &D, QualType R, - FunctionDecl::StorageClass &SC) { + StorageClass &SC) { bool isVirtual = D.getDeclSpec().isVirtualSpecified(); // C++ [class.ctor]p3: @@ -2910,13 +2910,13 @@ QualType Sema::CheckConstructorDeclarator(Declarator &D, QualType R, << SourceRange(D.getIdentifierLoc()); D.setInvalidType(); } - if (SC == FunctionDecl::Static) { + if (SC == SC_Static) { if (!D.isInvalidType()) Diag(D.getIdentifierLoc(), diag::err_constructor_cannot_be) << "static" << SourceRange(D.getDeclSpec().getStorageClassSpecLoc()) << SourceRange(D.getIdentifierLoc()); D.setInvalidType(); - SC = FunctionDecl::None; + SC = SC_None; } DeclaratorChunk::FunctionTypeInfo &FTI = D.getTypeObject(0).Fun; @@ -3033,7 +3033,7 @@ FTIHasSingleVoidArgument(DeclaratorChunk::FunctionTypeInfo &FTI) { /// will be updated to reflect a well-formed type for the destructor and /// returned. QualType Sema::CheckDestructorDeclarator(Declarator &D, QualType R, - FunctionDecl::StorageClass& SC) { + StorageClass& SC) { // C++ [class.dtor]p1: // [...] A typedef-name that names a class is a class-name // (7.1.3); however, a typedef-name that names a class shall not @@ -3052,14 +3052,14 @@ QualType Sema::CheckDestructorDeclarator(Declarator &D, QualType R, // destructor can be invoked for a const, volatile or const // volatile object. A destructor shall not be declared const, // volatile or const volatile (9.3.2). - if (SC == FunctionDecl::Static) { + if (SC == SC_Static) { if (!D.isInvalidType()) Diag(D.getIdentifierLoc(), diag::err_destructor_cannot_be) << "static" << SourceRange(D.getDeclSpec().getStorageClassSpecLoc()) << SourceRange(D.getIdentifierLoc()) << FixItHint::CreateRemoval(D.getDeclSpec().getStorageClassSpecLoc()); - SC = FunctionDecl::None; + SC = SC_None; } if (D.getDeclSpec().hasTypeSpecifier() && !D.isInvalidType()) { // Destructors don't have return types, but the parser will @@ -3127,18 +3127,18 @@ QualType Sema::CheckDestructorDeclarator(Declarator &D, QualType R, /// false. Either way, the type @p R will be updated to reflect a /// well-formed type for the conversion operator. void Sema::CheckConversionDeclarator(Declarator &D, QualType &R, - FunctionDecl::StorageClass& SC) { + StorageClass& SC) { // C++ [class.conv.fct]p1: // Neither parameter types nor return type can be specified. The // type of a conversion function (8.3.5) is "function taking no // parameter returning conversion-type-id." - if (SC == FunctionDecl::Static) { + if (SC == SC_Static) { if (!D.isInvalidType()) Diag(D.getIdentifierLoc(), diag::err_conv_function_not_member) << "static" << SourceRange(D.getDeclSpec().getStorageClassSpecLoc()) << SourceRange(D.getIdentifierLoc()); D.setInvalidType(); - SC = FunctionDecl::None; + SC = SC_None; } QualType ConvType = GetTypeFromParser(D.getName().ConversionFunctionId); @@ -4664,7 +4664,7 @@ BuildSingleCopyAssign(Sema &S, SourceLocation Loc, QualType T, VarDecl *IterationVar = VarDecl::Create(S.Context, S.CurContext, Loc, IterationVarName, SizeType, S.Context.getTrivialTypeSourceInfo(SizeType, Loc), - VarDecl::None, VarDecl::None); + SC_None, SC_None); // Initialize the iteration variable to zero. llvm::APInt Zero(S.Context.getTypeSize(SizeType), 0); @@ -4872,7 +4872,7 @@ CXXMethodDecl *Sema::DeclareImplicitCopyAssignment(CXXRecordDecl *ClassDecl) { ExceptSpec.data(), FunctionType::ExtInfo()), /*TInfo=*/0, /*isStatic=*/false, - /*StorageClassAsWritten=*/FunctionDecl::None, + /*StorageClassAsWritten=*/SC_None, /*isInline=*/true); CopyAssignment->setAccess(AS_public); CopyAssignment->setImplicit(); @@ -4884,8 +4884,8 @@ CXXMethodDecl *Sema::DeclareImplicitCopyAssignment(CXXRecordDecl *ClassDecl) { ClassDecl->getLocation(), /*Id=*/0, ArgType, /*TInfo=*/0, - VarDecl::None, - VarDecl::None, 0); + SC_None, + SC_None, 0); CopyAssignment->setParams(&FromParam, 1); // Note that we have added this copy-assignment operator. @@ -5362,8 +5362,8 @@ CXXConstructorDecl *Sema::DeclareImplicitCopyConstructor( ClassDecl->getLocation(), /*IdentifierInfo=*/0, ArgType, /*TInfo=*/0, - VarDecl::None, - VarDecl::None, 0); + SC_None, + SC_None, 0); CopyConstructor->setParams(&FromParam, 1); if (Scope *S = getScopeForContext(ClassDecl)) PushOnScopeChains(CopyConstructor, S, false); @@ -5658,7 +5658,7 @@ CheckOperatorNewDeleteDeclarationScope(Sema &SemaRef, } if (isa(DC) && - FnDecl->getStorageClass() == FunctionDecl::Static) { + FnDecl->getStorageClass() == SC_Static) { return SemaRef.Diag(FnDecl->getLocation(), diag::err_operator_new_delete_declared_static) << FnDecl->getDeclName(); @@ -6135,8 +6135,8 @@ VarDecl *Sema::BuildExceptionDeclaration(Scope *S, QualType ExDeclType, } VarDecl *ExDecl = VarDecl::Create(Context, CurContext, Loc, - Name, ExDeclType, TInfo, VarDecl::None, - VarDecl::None); + Name, ExDeclType, TInfo, SC_None, + SC_None); ExDecl->setExceptionVariable(true); if (!Invalid) { diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp index a0348540e5..ac9d076863 100644 --- a/lib/Sema/SemaDeclObjC.cpp +++ b/lib/Sema/SemaDeclObjC.cpp @@ -1528,7 +1528,7 @@ Decl *Sema::ActOnMethodDeclaration( ParmVarDecl* Param = ParmVarDecl::Create(Context, ObjCMethod, ArgInfo[i].NameLoc, ArgInfo[i].Name, ArgType, DI, - VarDecl::None, VarDecl::None, 0); + SC_None, SC_None, 0); if (ArgType->isObjCObjectType()) { Diag(ArgInfo[i].NameLoc, @@ -1705,7 +1705,7 @@ VarDecl *Sema::BuildObjCExceptionDecl(TypeSourceInfo *TInfo, } VarDecl *New = VarDecl::Create(Context, CurContext, NameLoc, Name, T, TInfo, - VarDecl::None, VarDecl::None); + SC_None, SC_None); New->setExceptionVariable(true); if (Invalid) diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index a452bf3557..cbb7842ad5 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -6291,7 +6291,7 @@ QualType Sema::CheckAddressOfOperand(Expr *op, SourceLocation OpLoc) { if (const VarDecl *vd = dyn_cast(dcl)) { // in C++ it is not error to take address of a register // variable (c++03 7.1.1P3) - if (vd->getStorageClass() == VarDecl::Register && + if (vd->getStorageClass() == SC_Register && !getLangOptions().CPlusPlus) { Diag(OpLoc, diag::err_typecheck_address_of) << "register variable" << op->getSourceRange(); diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp index 5d850839f9..8f61933626 100644 --- a/lib/Sema/SemaExprCXX.cpp +++ b/lib/Sema/SemaExprCXX.cpp @@ -1283,8 +1283,8 @@ void Sema::DeclareGlobalAllocationFunction(DeclarationName Name, FunctionType::ExtInfo()); FunctionDecl *Alloc = FunctionDecl::Create(Context, GlobalCtx, SourceLocation(), Name, - FnType, /*TInfo=*/0, FunctionDecl::None, - FunctionDecl::None, false, true); + FnType, /*TInfo=*/0, SC_None, + SC_None, false, true); Alloc->setImplicit(); if (AddMallocAttr) @@ -1292,8 +1292,8 @@ void Sema::DeclareGlobalAllocationFunction(DeclarationName Name, ParmVarDecl *Param = ParmVarDecl::Create(Context, Alloc, SourceLocation(), 0, Argument, /*TInfo=*/0, - VarDecl::None, - VarDecl::None, 0); + SC_None, + SC_None, 0); Alloc->setParams(&Param, 1); // FIXME: Also add this declaration to the IdentifierResolver, but diff --git a/lib/Sema/SemaObjCProperty.cpp b/lib/Sema/SemaObjCProperty.cpp index 61d7603cdf..7c3918ac97 100644 --- a/lib/Sema/SemaObjCProperty.cpp +++ b/lib/Sema/SemaObjCProperty.cpp @@ -1134,8 +1134,8 @@ void Sema::ProcessPropertyDecl(ObjCPropertyDecl *property, property->getIdentifier(), property->getType(), /*TInfo=*/0, - VarDecl::None, - VarDecl::None, + SC_None, + SC_None, 0); SetterMethod->setMethodParams(Context, &Argument, 1, 1); CD->addDecl(SetterMethod); diff --git a/lib/Serialization/ASTReaderDecl.cpp b/lib/Serialization/ASTReaderDecl.cpp index d5649ad7be..053b91acb7 100644 --- a/lib/Serialization/ASTReaderDecl.cpp +++ b/lib/Serialization/ASTReaderDecl.cpp @@ -312,8 +312,8 @@ void ASTDeclReader::VisitFunctionDecl(FunctionDecl *FD) { // after everything else is read. VisitRedeclarable(FD); - FD->setStorageClass((FunctionDecl::StorageClass)Record[Idx++]); - FD->setStorageClassAsWritten((FunctionDecl::StorageClass)Record[Idx++]); + FD->setStorageClass((StorageClass)Record[Idx++]); + FD->setStorageClassAsWritten((StorageClass)Record[Idx++]); FD->setInlineSpecified(Record[Idx++]); FD->setVirtualAsWritten(Record[Idx++]); FD->setPure(Record[Idx++]); @@ -554,8 +554,8 @@ void ASTDeclReader::VisitFieldDecl(FieldDecl *FD) { void ASTDeclReader::VisitVarDecl(VarDecl *VD) { VisitDeclaratorDecl(VD); - VD->setStorageClass((VarDecl::StorageClass)Record[Idx++]); - VD->setStorageClassAsWritten((VarDecl::StorageClass)Record[Idx++]); + VD->setStorageClass((StorageClass)Record[Idx++]); + VD->setStorageClassAsWritten((StorageClass)Record[Idx++]); VD->setThreadSpecified(Record[Idx++]); VD->setCXXDirectInitializer(Record[Idx++]); VD->setExceptionVariable(Record[Idx++]); @@ -1368,7 +1368,7 @@ Decl *ASTReader::ReadDeclRecord(unsigned Index, DeclID ID) { break; case DECL_VAR: D = VarDecl::Create(*Context, 0, SourceLocation(), 0, QualType(), 0, - VarDecl::None, VarDecl::None); + SC_None, SC_None); break; case DECL_IMPLICIT_PARAM: @@ -1377,7 +1377,7 @@ Decl *ASTReader::ReadDeclRecord(unsigned Index, DeclID ID) { case DECL_PARM_VAR: D = ParmVarDecl::Create(*Context, 0, SourceLocation(), 0, QualType(), 0, - VarDecl::None, VarDecl::None, 0); + SC_None, SC_None, 0); break; case DECL_FILE_SCOPE_ASM: D = FileScopeAsmDecl::Create(*Context, 0, SourceLocation(), 0);