[NFC, Refactor] Modernize StorageClass from Specifiers.h to a scoped enum (II)

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D93765
This commit is contained in:
Thorsten Schütt 2020-12-23 16:56:00 +01:00
parent abbef2fd46
commit efc82c4ad2
56 changed files with 528 additions and 573 deletions

View File

@ -632,8 +632,7 @@ void ChangeNamespaceTool::run(
return; return;
// Ignore out-of-line static methods since they will be handled by nested // Ignore out-of-line static methods since they will be handled by nested
// name specifiers. // name specifiers.
if (Func->getCanonicalDecl()->getStorageClass() == if (Func->getCanonicalDecl()->getStorageClass() == StorageClass::Static &&
StorageClass::SC_Static &&
Func->isOutOfLine()) Func->isOutOfLine())
return; return;
const auto *Context = Result.Nodes.getNodeAs<Decl>("dc"); const auto *Context = Result.Nodes.getNodeAs<Decl>("dc");

View File

@ -51,7 +51,7 @@ FixItHint generateFixItHint(const FunctionDecl *Decl) {
// A fixit can be generated for functions of static storage class but // A fixit can be generated for functions of static storage class but
// otherwise the check cannot determine the appropriate function name prefix // otherwise the check cannot determine the appropriate function name prefix
// to use. // to use.
if (Decl->getStorageClass() != SC_Static) if (Decl->getStorageClass() != StorageClass::Static)
return FixItHint(); return FixItHint();
StringRef Name = Decl->getName(); StringRef Name = Decl->getName();
@ -109,7 +109,7 @@ void FunctionNamingCheck::registerMatchers(MatchFinder *Finder) {
void FunctionNamingCheck::check(const MatchFinder::MatchResult &Result) { void FunctionNamingCheck::check(const MatchFinder::MatchResult &Result) {
const auto *MatchedDecl = Result.Nodes.getNodeAs<FunctionDecl>("function"); const auto *MatchedDecl = Result.Nodes.getNodeAs<FunctionDecl>("function");
bool IsGlobal = MatchedDecl->getStorageClass() != SC_Static; bool IsGlobal = MatchedDecl->getStorageClass() != StorageClass::Static;
diag(MatchedDecl->getLocation(), diag(MatchedDecl->getLocation(),
"%select{static function|function in global namespace}1 named %0 must " "%select{static function|function in global namespace}1 named %0 must "
"%select{be in|have an appropriate prefix followed by}1 Pascal case as " "%select{be in|have an appropriate prefix followed by}1 Pascal case as "

View File

@ -26,7 +26,7 @@ namespace {
AST_MATCHER(VarDecl, isLocalVariable) { return Node.isLocalVarDecl(); } AST_MATCHER(VarDecl, isLocalVariable) { return Node.isLocalVarDecl(); }
FixItHint generateFixItHint(const VarDecl *Decl, bool IsConst) { FixItHint generateFixItHint(const VarDecl *Decl, bool IsConst) {
if (IsConst && (Decl->getStorageClass() != SC_Static)) { if (IsConst && (Decl->getStorageClass() != StorageClass::Static)) {
// No fix available if it is not a static constant, since it is difficult // No fix available if it is not a static constant, since it is difficult
// to determine the proper fix in this case. // to determine the proper fix in this case.
return FixItHint(); return FixItHint();

View File

@ -359,8 +359,9 @@ void UseTrailingReturnTypeCheck::keepSpecifiers(
// inline int. // inline int.
const auto *M = dyn_cast<CXXMethodDecl>(&F); const auto *M = dyn_cast<CXXMethodDecl>(&F);
if (!F.isConstexpr() && !F.isInlineSpecified() && if (!F.isConstexpr() && !F.isInlineSpecified() &&
F.getStorageClass() != SC_Extern && F.getStorageClass() != SC_Static && F.getStorageClass() != StorageClass::Extern &&
!Fr && !(M && M->isVirtualAsWritten())) F.getStorageClass() != StorageClass::Static && !Fr &&
!(M && M->isVirtualAsWritten()))
return; return;
// Tokenize return type. If it contains macros which contain a mix of // Tokenize return type. If it contains macros which contain a mix of

View File

@ -1057,7 +1057,7 @@ public:
/// Returns true if a variable with function scope is a non-static local /// Returns true if a variable with function scope is a non-static local
/// variable. /// variable.
bool hasLocalStorage() const { bool hasLocalStorage() const {
if (getStorageClass() == SC_None) { if (getStorageClass() == StorageClass::None) {
// OpenCL v1.2 s6.5.3: The __constant or constant address space name is // OpenCL v1.2 s6.5.3: The __constant or constant address space name is
// used to describe variables allocated in global memory and which are // used to describe variables allocated in global memory and which are
// accessed inside a kernel(s) as read-only variables. As such, variables // accessed inside a kernel(s) as read-only variables. As such, variables
@ -1069,29 +1069,40 @@ public:
} }
// Global Named Register (GNU extension) // Global Named Register (GNU extension)
if (getStorageClass() == SC_Register && !isLocalVarDeclOrParm()) if (getStorageClass() == StorageClass::Register && !isLocalVarDeclOrParm())
return false; return false;
// Return true for: Auto, Register. // Return true for: Auto, Register.
// Return false for: Extern, Static, PrivateExtern, OpenCLWorkGroupLocal. // Return false for: Extern, Static, PrivateExtern, OpenCLWorkGroupLocal.
return getStorageClass() >= SC_Auto; switch (getStorageClass()) {
case StorageClass::Auto:
case StorageClass::Register:
return true;
case StorageClass::Extern:
case StorageClass::None:
case StorageClass::PrivateExtern:
case StorageClass::Static:
return false;
}
llvm_unreachable("unknown storage class");
} }
/// Returns true if a variable with function scope is a static local /// Returns true if a variable with function scope is a static local
/// variable. /// variable.
bool isStaticLocal() const { bool isStaticLocal() const {
return (getStorageClass() == SC_Static || return (getStorageClass() == StorageClass::Static ||
// C++11 [dcl.stc]p4 // C++11 [dcl.stc]p4
(getStorageClass() == SC_None && getTSCSpec() == TSCS_thread_local)) (getStorageClass() == StorageClass::None &&
&& !isFileVarDecl(); getTSCSpec() == TSCS_thread_local)) &&
!isFileVarDecl();
} }
/// Returns true if a variable has extern or __private_extern__ /// Returns true if a variable has extern or __private_extern__
/// storage. /// storage.
bool hasExternalStorage() const { bool hasExternalStorage() const {
return getStorageClass() == SC_Extern || return getStorageClass() == StorageClass::Extern ||
getStorageClass() == SC_PrivateExtern; getStorageClass() == StorageClass::PrivateExtern;
} }
/// Returns true for all variables that do not have local storage. /// Returns true for all variables that do not have local storage.
@ -1593,7 +1604,7 @@ public:
IdentifierInfo *Id, QualType Type, IdentifierInfo *Id, QualType Type,
ImplicitParamKind ParamKind) ImplicitParamKind ParamKind)
: VarDecl(ImplicitParam, C, DC, IdLoc, IdLoc, Id, Type, : VarDecl(ImplicitParam, C, DC, IdLoc, IdLoc, Id, Type,
/*TInfo=*/nullptr, SC_None) { /*TInfo=*/nullptr, StorageClass::None) {
NonParmVarDeclBits.ImplicitParamKind = ParamKind; NonParmVarDeclBits.ImplicitParamKind = ParamKind;
setImplicit(); setImplicit();
} }
@ -1601,7 +1612,7 @@ public:
ImplicitParamDecl(ASTContext &C, QualType Type, ImplicitParamKind ParamKind) ImplicitParamDecl(ASTContext &C, QualType Type, ImplicitParamKind ParamKind)
: VarDecl(ImplicitParam, C, /*DC=*/nullptr, SourceLocation(), : VarDecl(ImplicitParam, C, /*DC=*/nullptr, SourceLocation(),
SourceLocation(), /*Id=*/nullptr, Type, SourceLocation(), /*Id=*/nullptr, Type,
/*TInfo=*/nullptr, SC_None) { /*TInfo=*/nullptr, StorageClass::None) {
NonParmVarDeclBits.ImplicitParamKind = ParamKind; NonParmVarDeclBits.ImplicitParamKind = ParamKind;
setImplicit(); setImplicit();
} }
@ -2538,7 +2549,7 @@ public:
/// Sets the storage class as written in the source. /// Sets the storage class as written in the source.
void setStorageClass(StorageClass SClass) { void setStorageClass(StorageClass SClass) {
FunctionDeclBits.SClass = SClass; FunctionDeclBits.SClass = static_cast<uint64_t>(SClass);
} }
/// Determine whether the "inline" keyword was specified for this /// Determine whether the "inline" keyword was specified for this
@ -2565,7 +2576,7 @@ public:
bool doesDeclarationForceExternallyVisibleDefinition() const; bool doesDeclarationForceExternallyVisibleDefinition() const;
bool isStatic() const { return getStorageClass() == SC_Static; } bool isStatic() const { return getStorageClass() == StorageClass::Static; }
/// Whether this function declaration represents an C++ overloaded /// Whether this function declaration represents an C++ overloaded
/// operator, e.g., "operator+". /// operator, e.g., "operator+".

View File

@ -1843,7 +1843,7 @@ private:
const DeclarationNameInfo &NameInfo, QualType T, const DeclarationNameInfo &NameInfo, QualType T,
TypeSourceInfo *TInfo, SourceLocation EndLocation) TypeSourceInfo *TInfo, SourceLocation EndLocation)
: FunctionDecl(CXXDeductionGuide, C, DC, StartLoc, NameInfo, T, TInfo, : FunctionDecl(CXXDeductionGuide, C, DC, StartLoc, NameInfo, T, TInfo,
SC_None, false, ConstexprSpecKind::Unspecified), StorageClass::None, false, ConstexprSpecKind::Unspecified),
ExplicitSpec(ES) { ExplicitSpec(ES) {
if (EndLocation.isValid()) if (EndLocation.isValid())
setRangeEnd(EndLocation); setRangeEnd(EndLocation);
@ -2657,8 +2657,8 @@ class CXXDestructorDecl : public CXXMethodDecl {
bool isImplicitlyDeclared, ConstexprSpecKind ConstexprKind, bool isImplicitlyDeclared, ConstexprSpecKind ConstexprKind,
Expr *TrailingRequiresClause = nullptr) Expr *TrailingRequiresClause = nullptr)
: CXXMethodDecl(CXXDestructor, C, RD, StartLoc, NameInfo, T, TInfo, : CXXMethodDecl(CXXDestructor, C, RD, StartLoc, NameInfo, T, TInfo,
SC_None, isInline, ConstexprKind, SourceLocation(), StorageClass::None, isInline, ConstexprKind,
TrailingRequiresClause) { SourceLocation(), TrailingRequiresClause) {
setImplicit(isImplicitlyDeclared); setImplicit(isImplicitlyDeclared);
} }
@ -2713,7 +2713,7 @@ class CXXConversionDecl : public CXXMethodDecl {
ConstexprSpecKind ConstexprKind, SourceLocation EndLocation, ConstexprSpecKind ConstexprKind, SourceLocation EndLocation,
Expr *TrailingRequiresClause = nullptr) Expr *TrailingRequiresClause = nullptr)
: CXXMethodDecl(CXXConversion, C, RD, StartLoc, NameInfo, T, TInfo, : CXXMethodDecl(CXXConversion, C, RD, StartLoc, NameInfo, T, TInfo,
SC_None, isInline, ConstexprKind, EndLocation, StorageClass::None, isInline, ConstexprKind, EndLocation,
TrailingRequiresClause), TrailingRequiresClause),
ExplicitSpec(ES) {} ExplicitSpec(ES) {}
void anchor() override; void anchor() override;

View File

@ -388,7 +388,7 @@ class OMPCapturedExprDecl final : public VarDecl {
QualType Type, TypeSourceInfo *TInfo, QualType Type, TypeSourceInfo *TInfo,
SourceLocation StartLoc) SourceLocation StartLoc)
: VarDecl(OMPCapturedExpr, C, DC, StartLoc, StartLoc, Id, Type, TInfo, : VarDecl(OMPCapturedExpr, C, DC, StartLoc, StartLoc, Id, Type, TInfo,
SC_None) { StorageClass::None) {
setImplicit(); setImplicit();
} }

View File

@ -4723,7 +4723,7 @@ AST_POLYMORPHIC_MATCHER(isExternC, AST_POLYMORPHIC_SUPPORTED_TYPES(FunctionDecl,
AST_POLYMORPHIC_MATCHER(isStaticStorageClass, AST_POLYMORPHIC_MATCHER(isStaticStorageClass,
AST_POLYMORPHIC_SUPPORTED_TYPES(FunctionDecl, AST_POLYMORPHIC_SUPPORTED_TYPES(FunctionDecl,
VarDecl)) { VarDecl)) {
return Node.getStorageClass() == SC_Static; return Node.getStorageClass() == StorageClass::Static;
} }
/// Matches deleted function declarations. /// Matches deleted function declarations.

View File

@ -220,21 +220,31 @@ namespace clang {
}; };
/// Storage classes. /// Storage classes.
enum StorageClass { enum class StorageClass {
// These are legal on both functions and variables. // These are legal on both functions and variables.
SC_None, None,
SC_Extern, Extern,
SC_Static, Static,
SC_PrivateExtern, PrivateExtern,
// These are only legal on variables. // These are only legal on variables.
SC_Auto, Auto,
SC_Register Register
}; };
/// Checks whether the given storage class is legal for functions. /// Checks whether the given storage class is legal for functions.
inline bool isLegalForFunction(StorageClass SC) { inline bool isLegalForFunction(StorageClass SC) {
return SC <= SC_PrivateExtern; switch (SC) {
case StorageClass::None:
case StorageClass::Extern:
case StorageClass::Static:
case StorageClass::PrivateExtern:
return true;
case StorageClass::Auto:
case StorageClass::Register:
return false;
}
llvm_unreachable("unknown storage class");
} }
/// Checks whether the given storage class is legal for variables. /// Checks whether the given storage class is legal for variables.

View File

@ -10681,7 +10681,7 @@ bool ASTContext::DeclMustBeEmitted(const Decl *D) {
if (!VD->isFileVarDecl()) if (!VD->isFileVarDecl())
return false; return false;
// Global named register variables (GNU extension) are never emitted. // Global named register variables (GNU extension) are never emitted.
if (VD->getStorageClass() == SC_Register) if (VD->getStorageClass() == StorageClass::Register)
return false; return false;
if (VD->getDescribedVarTemplate() || if (VD->getDescribedVarTemplate() ||
isa<VarTemplatePartialSpecializationDecl>(VD)) isa<VarTemplatePartialSpecializationDecl>(VD))
@ -11441,7 +11441,7 @@ bool ASTContext::mayExternalizeStaticVar(const Decl *D) const {
(D->hasAttr<CUDAConstantAttr>() && (D->hasAttr<CUDAConstantAttr>() &&
!D->getAttr<CUDAConstantAttr>()->isImplicit())) && !D->getAttr<CUDAConstantAttr>()->isImplicit())) &&
isa<VarDecl>(D) && cast<VarDecl>(D)->isFileVarDecl() && 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 { bool ASTContext::shouldExternalizeStaticVar(const Decl *D) const {

View File

@ -620,7 +620,7 @@ static StorageClass getStorageClass(const Decl *D) {
if (auto *FD = dyn_cast<FunctionDecl>(D)) if (auto *FD = dyn_cast<FunctionDecl>(D))
return FD->getStorageClass(); return FD->getStorageClass();
} }
return SC_None; return StorageClass::None;
} }
LinkageInfo LinkageInfo
@ -635,7 +635,7 @@ LinkageComputer::getLVForNamespaceScopeDecl(const NamedDecl *D,
// A name having namespace scope (3.3.6) has internal linkage if it // A name having namespace scope (3.3.6) has internal linkage if it
// is the name of // is the name of
if (getStorageClass(D->getCanonicalDecl()) == SC_Static) { if (getStorageClass(D->getCanonicalDecl()) == StorageClass::Static) {
// - a variable, variable template, function, or function template // - a variable, variable template, function, or function template
// that is explicitly declared static; or // that is explicitly declared static; or
// (This bullet corresponds to C99 6.2.2p3.) // (This bullet corresponds to C99 6.2.2p3.)
@ -660,19 +660,19 @@ LinkageComputer::getLVForNamespaceScopeDecl(const NamedDecl *D,
if (PrevVar) if (PrevVar)
return getLVForDecl(PrevVar, computation); return getLVForDecl(PrevVar, computation);
if (Var->getStorageClass() != SC_Extern && if (Var->getStorageClass() != StorageClass::Extern &&
Var->getStorageClass() != SC_PrivateExtern && Var->getStorageClass() != StorageClass::PrivateExtern &&
!isSingleLineLanguageLinkage(*Var)) !isSingleLineLanguageLinkage(*Var))
return getInternalLinkageFor(Var); return getInternalLinkageFor(Var);
} }
for (const VarDecl *PrevVar = Var->getPreviousDecl(); PrevVar; for (const VarDecl *PrevVar = Var->getPreviousDecl(); PrevVar;
PrevVar = PrevVar->getPreviousDecl()) { PrevVar = PrevVar->getPreviousDecl()) {
if (PrevVar->getStorageClass() == SC_PrivateExtern && if (PrevVar->getStorageClass() == StorageClass::PrivateExtern &&
Var->getStorageClass() == SC_None) Var->getStorageClass() == StorageClass::None)
return getDeclLinkageAndVisibility(PrevVar); return getDeclLinkageAndVisibility(PrevVar);
// Explicitly declared static. // Explicitly declared static.
if (PrevVar->getStorageClass() == SC_Static) if (PrevVar->getStorageClass() == StorageClass::Static)
return getInternalLinkageFor(Var); return getInternalLinkageFor(Var);
} }
} else if (const auto *IFD = dyn_cast<IndirectFieldDecl>(D)) { } else if (const auto *IFD = dyn_cast<IndirectFieldDecl>(D)) {
@ -789,7 +789,7 @@ LinkageComputer::getLVForNamespaceScopeDecl(const NamedDecl *D,
LV.mergeVisibility(TypeLV); LV.mergeVisibility(TypeLV);
} }
if (Var->getStorageClass() == SC_PrivateExtern) if (Var->getStorageClass() == StorageClass::PrivateExtern)
LV.mergeVisibility(HiddenVisibility, true); LV.mergeVisibility(HiddenVisibility, true);
// Note that Sema::MergeVarDecl already takes care of implementing // 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 // for justification). In practice, GCC doesn't do this, so it's
// just too painful to make work. // just too painful to make work.
if (Function->getStorageClass() == SC_PrivateExtern) if (Function->getStorageClass() == StorageClass::PrivateExtern)
LV.mergeVisibility(HiddenVisibility, true); LV.mergeVisibility(HiddenVisibility, true);
// Note that Sema::MergeCompatibleFunctionDecls already takes care of // Note that Sema::MergeCompatibleFunctionDecls already takes care of
@ -1229,7 +1229,7 @@ LinkageInfo LinkageComputer::getLVForLocalDecl(const NamedDecl *D,
return getInternalLinkageFor(Function); return getInternalLinkageFor(Function);
// This is a "void f();" which got merged with a file static. // 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); return getInternalLinkageFor(Function);
LinkageInfo LV; LinkageInfo LV;
@ -1252,7 +1252,7 @@ LinkageInfo LinkageComputer::getLVForLocalDecl(const NamedDecl *D,
return getInternalLinkageFor(Var); return getInternalLinkageFor(Var);
LinkageInfo LV; LinkageInfo LV;
if (Var->getStorageClass() == SC_PrivateExtern) if (Var->getStorageClass() == StorageClass::PrivateExtern)
LV.mergeVisibility(HiddenVisibility, true); LV.mergeVisibility(HiddenVisibility, true);
else if (!hasExplicitVisibilityAlready(computation)) { else if (!hasExplicitVisibilityAlready(computation)) {
if (Optional<Visibility> Vis = getExplicitVisibility(Var, computation)) if (Optional<Visibility> Vis = getExplicitVisibility(Var, computation))
@ -1962,12 +1962,18 @@ void QualifierInfo::setTemplateParameterListsInfo(
const char *VarDecl::getStorageClassSpecifierString(StorageClass SC) { const char *VarDecl::getStorageClassSpecifierString(StorageClass SC) {
switch (SC) { switch (SC) {
case SC_None: break; case StorageClass::None:
case SC_Auto: return "auto"; break;
case SC_Extern: return "extern"; case StorageClass::Auto:
case SC_PrivateExtern: return "__private_extern__"; return "auto";
case SC_Register: return "register"; case StorageClass::Extern:
case SC_Static: return "static"; return "extern";
case StorageClass::PrivateExtern:
return "__private_extern__";
case StorageClass::Register:
return "register";
case StorageClass::Static:
return "static";
} }
llvm_unreachable("Invalid storage class"); llvm_unreachable("Invalid storage class");
@ -1986,7 +1992,7 @@ VarDecl::VarDecl(Kind DK, ASTContext &C, DeclContext *DC,
static_assert(sizeof(NonParmVarDeclBitfields) <= sizeof(unsigned), static_assert(sizeof(NonParmVarDeclBitfields) <= sizeof(unsigned),
"NonParmVarDeclBitfields too large!"); "NonParmVarDeclBitfields too large!");
AllBits = 0; AllBits = 0;
VarDeclBits.SClass = SC; VarDeclBits.SClass = static_cast<unsigned>(SC);
// Everything else is implicitly initialized to false. // 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) { VarDecl *VarDecl::CreateDeserialized(ASTContext &C, unsigned ID) {
return new (C, ID) return new (C, ID)
VarDecl(Var, C, nullptr, SourceLocation(), SourceLocation(), nullptr, VarDecl(Var, C, nullptr, SourceLocation(), SourceLocation(), nullptr,
QualType(), nullptr, SC_None); QualType(), nullptr, StorageClass::None);
} }
void VarDecl::setStorageClass(StorageClass SC) { void VarDecl::setStorageClass(StorageClass SC) {
assert(isLegalForVariable(SC)); assert(isLegalForVariable(SC));
VarDeclBits.SClass = SC; VarDeclBits.SClass = static_cast<unsigned>(SC);
} }
VarDecl::TLSKind VarDecl::getTLSKind() const { VarDecl::TLSKind VarDecl::getTLSKind() const {
@ -2720,7 +2726,7 @@ QualType ParmVarDecl::getOriginalType() const {
ParmVarDecl *ParmVarDecl::CreateDeserialized(ASTContext &C, unsigned ID) { ParmVarDecl *ParmVarDecl::CreateDeserialized(ASTContext &C, unsigned ID) {
return new (C, ID) return new (C, ID)
ParmVarDecl(ParmVar, C, nullptr, SourceLocation(), SourceLocation(), ParmVarDecl(ParmVar, C, nullptr, SourceLocation(), SourceLocation(),
nullptr, QualType(), nullptr, SC_None, nullptr); nullptr, QualType(), nullptr, StorageClass::None, nullptr);
} }
SourceRange ParmVarDecl::getSourceRange() const { SourceRange ParmVarDecl::getSourceRange() const {
@ -2830,7 +2836,7 @@ FunctionDecl::FunctionDecl(Kind DK, ASTContext &C, DeclContext *DC,
DeclContext(DK), redeclarable_base(C), Body(), ODRHash(0), DeclContext(DK), redeclarable_base(C), Body(), ODRHash(0),
EndRangeLoc(NameInfo.getEndLoc()), DNLoc(NameInfo.getInfo()) { EndRangeLoc(NameInfo.getEndLoc()), DNLoc(NameInfo.getInfo()) {
assert(T.isNull() || T->isFunctionType()); assert(T.isNull() || T->isFunctionType());
FunctionDeclBits.SClass = S; FunctionDeclBits.SClass = static_cast<uint64_t>(S);
FunctionDeclBits.IsInline = isInlineSpecified; FunctionDeclBits.IsInline = isInlineSpecified;
FunctionDeclBits.IsInlineSpecified = isInlineSpecified; FunctionDeclBits.IsInlineSpecified = isInlineSpecified;
FunctionDeclBits.IsVirtualAsWritten = false; FunctionDeclBits.IsVirtualAsWritten = false;
@ -3181,7 +3187,7 @@ bool FunctionDecl::isGlobal() const {
if (const auto *Method = dyn_cast<CXXMethodDecl>(this)) if (const auto *Method = dyn_cast<CXXMethodDecl>(this))
return Method->isStatic(); return Method->isStatic();
if (getCanonicalDecl()->getStorageClass() == SC_Static) if (getCanonicalDecl()->getStorageClass() == StorageClass::Static)
return false; return false;
for (const DeclContext *DC = getDeclContext(); for (const DeclContext *DC = getDeclContext();
@ -3288,7 +3294,7 @@ unsigned FunctionDecl::getBuiltinID(bool ConsiderWrapperFunctions) const {
// function or whether it just has the same name. // function or whether it just has the same name.
// If this is a static function, it's not a builtin. // If this is a static function, it's not a builtin.
if (!ConsiderWrapperFunctions && getStorageClass() == SC_Static) if (!ConsiderWrapperFunctions && getStorageClass() == StorageClass::Static)
return 0; return 0;
// OpenCL v1.2 s6.9.f - The library functions defined in // 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; for (const FunctionDecl *FD = getMostRecentDecl(); FD;
FD = FD->getPreviousDecl()) FD = FD->getPreviousDecl())
if (!FD->isImplicit() && FD->getStorageClass() == SC_Extern) if (!FD->isImplicit() && FD->getStorageClass() == StorageClass::Extern)
return true; return true;
return false; return false;
} }
static bool redeclForcesDefMSVC(const FunctionDecl *Redecl) { static bool redeclForcesDefMSVC(const FunctionDecl *Redecl) {
if (Redecl->getStorageClass() != SC_Extern) if (Redecl->getStorageClass() != StorageClass::Extern)
return false; return false;
for (const FunctionDecl *FD = Redecl->getPreviousDecl(); FD; for (const FunctionDecl *FD = Redecl->getPreviousDecl(); FD;
FD = FD->getPreviousDecl()) FD = FD->getPreviousDecl())
if (!FD->isImplicit() && FD->getStorageClass() == SC_Extern) if (!FD->isImplicit() && FD->getStorageClass() == StorageClass::Extern)
return false; return false;
return true; return true;
@ -3408,7 +3414,8 @@ static bool RedeclForcesDefC99(const FunctionDecl *Redecl) {
if (Redecl->isImplicit()) if (Redecl->isImplicit())
return false; return false;
if (!Redecl->isInlineSpecified() || Redecl->getStorageClass() == SC_Extern) if (!Redecl->isInlineSpecified() ||
Redecl->getStorageClass() == StorageClass::Extern)
return true; // Not an inline definition return true; // Not an inline definition
return false; return false;
@ -3442,7 +3449,7 @@ bool FunctionDecl::doesDeclarationForceExternallyVisibleDefinition() const {
// //
// FIXME: What happens if gnu_inline gets added on after the first // FIXME: What happens if gnu_inline gets added on after the first
// declaration? // declaration?
if (!isInlineSpecified() || getStorageClass() == SC_Extern) if (!isInlineSpecified() || getStorageClass() == StorageClass::Extern)
return false; return false;
const FunctionDecl *Prev = this; const FunctionDecl *Prev = this;
@ -3454,10 +3461,10 @@ bool FunctionDecl::doesDeclarationForceExternallyVisibleDefinition() const {
// If it's not the case that both 'inline' and 'extern' are // If it's not the case that both 'inline' and 'extern' are
// specified on the definition, then it is always externally visible. // specified on the definition, then it is always externally visible.
if (!Prev->isInlineSpecified() || if (!Prev->isInlineSpecified() ||
Prev->getStorageClass() != SC_Extern) Prev->getStorageClass() != StorageClass::Extern)
return false; return false;
} else if (Prev->isInlineSpecified() && } else if (Prev->isInlineSpecified() &&
Prev->getStorageClass() != SC_Extern) { Prev->getStorageClass() != StorageClass::Extern) {
return false; return false;
} }
} }
@ -3468,7 +3475,7 @@ bool FunctionDecl::doesDeclarationForceExternallyVisibleDefinition() const {
// [...] If all of the file scope declarations for a function in a // [...] If all of the file scope declarations for a function in a
// translation unit include the inline function specifier without extern, // translation unit include the inline function specifier without extern,
// then the definition in that translation unit is an inline definition. // then the definition in that translation unit is an inline definition.
if (isInlineSpecified() && getStorageClass() != SC_Extern) if (isInlineSpecified() && getStorageClass() != StorageClass::Extern)
return false; return false;
const FunctionDecl *Prev = this; const FunctionDecl *Prev = this;
bool FoundBody = false; bool FoundBody = false;
@ -3556,14 +3563,14 @@ bool FunctionDecl::isInlineDefinitionExternallyVisible() const {
// externally visible. // externally visible.
if (Context.getLangOpts().CPlusPlus) if (Context.getLangOpts().CPlusPlus)
return false; return false;
if (!(isInlineSpecified() && getStorageClass() == SC_Extern)) if (!(isInlineSpecified() && getStorageClass() == StorageClass::Extern))
return true; return true;
// If any declaration is 'inline' but not 'extern', then this definition // If any declaration is 'inline' but not 'extern', then this definition
// is externally visible. // is externally visible.
for (auto Redecl : redecls()) { for (auto Redecl : redecls()) {
if (Redecl->isInlineSpecified() && if (Redecl->isInlineSpecified() &&
Redecl->getStorageClass() != SC_Extern) Redecl->getStorageClass() != StorageClass::Extern)
return true; return true;
} }
@ -4838,9 +4845,10 @@ FunctionDecl *FunctionDecl::Create(ASTContext &C, DeclContext *DC,
} }
FunctionDecl *FunctionDecl::CreateDeserialized(ASTContext &C, unsigned ID) { FunctionDecl *FunctionDecl::CreateDeserialized(ASTContext &C, unsigned ID) {
return new (C, ID) FunctionDecl( return new (C, ID) FunctionDecl(Function, C, nullptr, SourceLocation(),
Function, C, nullptr, SourceLocation(), DeclarationNameInfo(), QualType(), DeclarationNameInfo(), QualType(), nullptr,
nullptr, SC_None, false, ConstexprSpecKind::Unspecified, nullptr); StorageClass::None, false,
ConstexprSpecKind::Unspecified, nullptr);
} }
BlockDecl *BlockDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation L) { BlockDecl *BlockDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation L) {

View File

@ -2085,7 +2085,7 @@ void CXXMethodDecl::anchor() {}
bool CXXMethodDecl::isStatic() const { bool CXXMethodDecl::isStatic() const {
const CXXMethodDecl *MD = getCanonicalDecl(); const CXXMethodDecl *MD = getCanonicalDecl();
if (MD->getStorageClass() == SC_Static) if (MD->getStorageClass() == StorageClass::Static)
return true; return true;
OverloadedOperatorKind OOK = getDeclName().getCXXOverloadedOperator(); OverloadedOperatorKind OOK = getDeclName().getCXXOverloadedOperator();
@ -2187,9 +2187,9 @@ CXXMethodDecl *CXXMethodDecl::Create(ASTContext &C, CXXRecordDecl *RD,
} }
CXXMethodDecl *CXXMethodDecl::CreateDeserialized(ASTContext &C, unsigned ID) { CXXMethodDecl *CXXMethodDecl::CreateDeserialized(ASTContext &C, unsigned ID) {
return new (C, ID) return new (C, ID) CXXMethodDecl(
CXXMethodDecl(CXXMethod, C, nullptr, SourceLocation(), CXXMethod, C, nullptr, SourceLocation(), DeclarationNameInfo(),
DeclarationNameInfo(), QualType(), nullptr, SC_None, false, QualType(), nullptr, StorageClass::None, false,
ConstexprSpecKind::Unspecified, SourceLocation(), nullptr); ConstexprSpecKind::Unspecified, SourceLocation(), nullptr);
} }
@ -2567,8 +2567,8 @@ CXXConstructorDecl::CXXConstructorDecl(
ConstexprSpecKind ConstexprKind, InheritedConstructor Inherited, ConstexprSpecKind ConstexprKind, InheritedConstructor Inherited,
Expr *TrailingRequiresClause) Expr *TrailingRequiresClause)
: CXXMethodDecl(CXXConstructor, C, RD, StartLoc, NameInfo, T, TInfo, : CXXMethodDecl(CXXConstructor, C, RD, StartLoc, NameInfo, T, TInfo,
SC_None, isInline, ConstexprKind, SourceLocation(), StorageClass::None, isInline, ConstexprKind,
TrailingRequiresClause) { SourceLocation(), TrailingRequiresClause) {
setNumCtorInitializers(0); setNumCtorInitializers(0);
setInheritingConstructor(static_cast<bool>(Inherited)); setInheritingConstructor(static_cast<bool>(Inherited));
setImplicit(isImplicitlyDeclared); setImplicit(isImplicitlyDeclared);

View File

@ -600,11 +600,19 @@ void DeclPrinter::VisitFunctionDecl(FunctionDecl *D) {
CXXDeductionGuideDecl *GuideDecl = dyn_cast<CXXDeductionGuideDecl>(D); CXXDeductionGuideDecl *GuideDecl = dyn_cast<CXXDeductionGuideDecl>(D);
if (!Policy.SuppressSpecifiers) { if (!Policy.SuppressSpecifiers) {
switch (D->getStorageClass()) { switch (D->getStorageClass()) {
case SC_None: break; case StorageClass::None:
case SC_Extern: Out << "extern "; break; break;
case SC_Static: Out << "static "; break; case StorageClass::Extern:
case SC_PrivateExtern: Out << "__private_extern__ "; break; Out << "extern ";
case SC_Auto: case SC_Register: 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"); llvm_unreachable("invalid for functions");
} }
@ -848,7 +856,7 @@ void DeclPrinter::VisitVarDecl(VarDecl *D) {
if (!Policy.SuppressSpecifiers) { if (!Policy.SuppressSpecifiers) {
StorageClass SC = D->getStorageClass(); StorageClass SC = D->getStorageClass();
if (SC != SC_None) if (SC != StorageClass::None)
Out << VarDecl::getStorageClassSpecifierString(SC) << " "; Out << VarDecl::getStorageClassSpecifierString(SC) << " ";
switch (D->getTSCSpec()) { switch (D->getTSCSpec()) {

View File

@ -1226,7 +1226,7 @@ VarTemplateSpecializationDecl::VarTemplateSpecializationDecl(
VarTemplateSpecializationDecl::VarTemplateSpecializationDecl(Kind DK, VarTemplateSpecializationDecl::VarTemplateSpecializationDecl(Kind DK,
ASTContext &C) ASTContext &C)
: VarDecl(DK, C, nullptr, SourceLocation(), SourceLocation(), nullptr, : VarDecl(DK, C, nullptr, SourceLocation(), SourceLocation(), nullptr,
QualType(), nullptr, SC_None), QualType(), nullptr, StorageClass::None),
SpecializationKind(TSK_Undeclared), IsCompleteDefinition(false) {} SpecializationKind(TSK_Undeclared), IsCompleteDefinition(false) {}
VarTemplateSpecializationDecl *VarTemplateSpecializationDecl::Create( VarTemplateSpecializationDecl *VarTemplateSpecializationDecl::Create(

View File

@ -3835,7 +3835,7 @@ bool Expr::refersToGlobalRegisterVar() const {
if (const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E)) if (const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E))
if (const auto *VD = dyn_cast<VarDecl>(DRE->getDecl())) if (const auto *VD = dyn_cast<VarDecl>(DRE->getDecl()))
if (VD->getStorageClass() == SC_Register && if (VD->getStorageClass() == StorageClass::Register &&
VD->hasAttr<AsmLabelAttr>() && !VD->isLocalVarDecl()) VD->hasAttr<AsmLabelAttr>() && !VD->isLocalVarDecl())
return true; return true;

View File

@ -765,7 +765,7 @@ void JSONNodeDumper::VisitVarDecl(const VarDecl *VD) {
JOS.attribute("type", createQualType(VD->getType())); JOS.attribute("type", createQualType(VD->getType()));
StorageClass SC = VD->getStorageClass(); StorageClass SC = VD->getStorageClass();
if (SC != SC_None) if (SC != StorageClass::None)
JOS.attribute("storageClass", VarDecl::getStorageClassSpecifierString(SC)); JOS.attribute("storageClass", VarDecl::getStorageClassSpecifierString(SC));
switch (VD->getTLSKind()) { switch (VD->getTLSKind()) {
case VarDecl::TLS_Dynamic: JOS.attribute("tls", "dynamic"); break; case VarDecl::TLS_Dynamic: JOS.attribute("tls", "dynamic"); break;
@ -799,7 +799,7 @@ void JSONNodeDumper::VisitFunctionDecl(const FunctionDecl *FD) {
VisitNamedDecl(FD); VisitNamedDecl(FD);
JOS.attribute("type", createQualType(FD->getType())); JOS.attribute("type", createQualType(FD->getType()));
StorageClass SC = FD->getStorageClass(); StorageClass SC = FD->getStorageClass();
if (SC != SC_None) if (SC != StorageClass::None)
JOS.attribute("storageClass", VarDecl::getStorageClassSpecifierString(SC)); JOS.attribute("storageClass", VarDecl::getStorageClassSpecifierString(SC));
attributeOnlyIfTrue("inline", FD->isInlineSpecified()); attributeOnlyIfTrue("inline", FD->isInlineSpecified());
attributeOnlyIfTrue("virtual", FD->isVirtualAsWritten()); attributeOnlyIfTrue("virtual", FD->isVirtualAsWritten());

View File

@ -551,7 +551,7 @@ void ODRHash::AddFunctionDecl(const FunctionDecl *Function,
AddBoolean(Method->isVolatile()); AddBoolean(Method->isVolatile());
} }
ID.AddInteger(Function->getStorageClass()); ID.AddInteger(static_cast<int>(Function->getStorageClass()));
AddBoolean(Function->isInlineSpecified()); AddBoolean(Function->isInlineSpecified());
AddBoolean(Function->isVirtualAsWritten()); AddBoolean(Function->isVirtualAsWritten());
AddBoolean(Function->isPure()); AddBoolean(Function->isPure());

View File

@ -1579,7 +1579,7 @@ void TextNodeDumper::VisitFunctionDecl(const FunctionDecl *D) {
dumpType(D->getType()); dumpType(D->getType());
StorageClass SC = D->getStorageClass(); StorageClass SC = D->getStorageClass();
if (SC != SC_None) if (SC != StorageClass::None)
OS << ' ' << VarDecl::getStorageClassSpecifierString(SC); OS << ' ' << VarDecl::getStorageClassSpecifierString(SC);
if (D->isInlineSpecified()) if (D->isInlineSpecified())
OS << " inline"; OS << " inline";
@ -1668,7 +1668,7 @@ void TextNodeDumper::VisitVarDecl(const VarDecl *D) {
dumpName(D); dumpName(D);
dumpType(D->getType()); dumpType(D->getType());
StorageClass SC = D->getStorageClass(); StorageClass SC = D->getStorageClass();
if (SC != SC_None) if (SC != StorageClass::None)
OS << ' ' << VarDecl::getStorageClassSpecifierString(SC); OS << ' ' << VarDecl::getStorageClassSpecifierString(SC);
switch (D->getTLSKind()) { switch (D->getTLSKind()) {
case VarDecl::TLS_None: case VarDecl::TLS_None:

View File

@ -2023,9 +2023,9 @@ LocalScope* CFGBuilder::addLocalScopeForVarDecl(VarDecl *VD,
// Check if variable is local. // Check if variable is local.
switch (VD->getStorageClass()) { switch (VD->getStorageClass()) {
case SC_None: case StorageClass::None:
case SC_Auto: case StorageClass::Auto:
case SC_Register: case StorageClass::Register:
break; break;
default: return Scope; default: return Scope;
} }

View File

@ -1954,7 +1954,7 @@ CodeGenFunction::GenerateCopyHelperFunction(const CGBlockInfo &blockInfo) {
FunctionDecl *FD = FunctionDecl::Create( FunctionDecl *FD = FunctionDecl::Create(
C, C.getTranslationUnitDecl(), SourceLocation(), SourceLocation(), II, C, C.getTranslationUnitDecl(), SourceLocation(), SourceLocation(), II,
FunctionTy, nullptr, SC_Static, false, false); FunctionTy, nullptr, StorageClass::Static, false, false);
setBlockHelperAttributesVisibility(blockInfo.CapturesNonExternalType, Fn, FI, setBlockHelperAttributesVisibility(blockInfo.CapturesNonExternalType, Fn, FI,
CGM); CGM);
// This is necessary to avoid inheriting the previous line number. // This is necessary to avoid inheriting the previous line number.
@ -2148,7 +2148,7 @@ CodeGenFunction::GenerateDestroyHelperFunction(const CGBlockInfo &blockInfo) {
FunctionDecl *FD = FunctionDecl::Create( FunctionDecl *FD = FunctionDecl::Create(
C, C.getTranslationUnitDecl(), SourceLocation(), SourceLocation(), II, C, C.getTranslationUnitDecl(), SourceLocation(), SourceLocation(), II,
FunctionTy, nullptr, SC_Static, false, false); FunctionTy, nullptr, StorageClass::Static, false, false);
setBlockHelperAttributesVisibility(blockInfo.CapturesNonExternalType, Fn, FI, setBlockHelperAttributesVisibility(blockInfo.CapturesNonExternalType, Fn, FI,
CGM); CGM);
@ -2400,9 +2400,10 @@ generateByrefCopyHelper(CodeGenFunction &CGF, const BlockByrefInfo &byrefInfo,
ArgTys.push_back(Context.VoidPtrTy); ArgTys.push_back(Context.VoidPtrTy);
QualType FunctionTy = Context.getFunctionType(ReturnTy, ArgTys, {}); QualType FunctionTy = Context.getFunctionType(ReturnTy, ArgTys, {});
FunctionDecl *FD = FunctionDecl::Create( FunctionDecl *FD =
Context, Context.getTranslationUnitDecl(), SourceLocation(), FunctionDecl::Create(Context, Context.getTranslationUnitDecl(),
SourceLocation(), II, FunctionTy, nullptr, SC_Static, false, false); SourceLocation(), SourceLocation(), II, FunctionTy,
nullptr, StorageClass::Static, false, false);
CGF.CGM.SetInternalFunctionAttributes(GlobalDecl(), Fn, FI); CGF.CGM.SetInternalFunctionAttributes(GlobalDecl(), Fn, FI);
@ -2475,9 +2476,10 @@ generateByrefDisposeHelper(CodeGenFunction &CGF,
ArgTys.push_back(Context.VoidPtrTy); ArgTys.push_back(Context.VoidPtrTy);
QualType FunctionTy = Context.getFunctionType(R, ArgTys, {}); QualType FunctionTy = Context.getFunctionType(R, ArgTys, {});
FunctionDecl *FD = FunctionDecl::Create( FunctionDecl *FD =
Context, Context.getTranslationUnitDecl(), SourceLocation(), FunctionDecl::Create(Context, Context.getTranslationUnitDecl(),
SourceLocation(), II, FunctionTy, nullptr, SC_Static, false, false); SourceLocation(), SourceLocation(), II, FunctionTy,
nullptr, StorageClass::Static, false, false);
CGF.CGM.SetInternalFunctionAttributes(GlobalDecl(), Fn, FI); CGF.CGM.SetInternalFunctionAttributes(GlobalDecl(), Fn, FI);

View File

@ -1700,7 +1700,7 @@ llvm::Function *CodeGenFunction::generateBuiltinOSLogHelperFunction(
IdentifierInfo *II = &Ctx.Idents.get(Name); IdentifierInfo *II = &Ctx.Idents.get(Name);
FunctionDecl *FD = FunctionDecl::Create( FunctionDecl *FD = FunctionDecl::Create(
Ctx, Ctx.getTranslationUnitDecl(), SourceLocation(), SourceLocation(), II, Ctx, Ctx.getTranslationUnitDecl(), SourceLocation(), SourceLocation(), II,
FuncionTy, nullptr, SC_PrivateExtern, false, false); FuncionTy, nullptr, StorageClass::PrivateExtern, false, false);
// Avoid generating debug location info for the function. // Avoid generating debug location info for the function.
FD->setImplicit(); FD->setImplicit();

View File

@ -1388,7 +1388,7 @@ void CodeGenFunction::EmitAndRegisterVariableArrayDimensions(
auto *ArtificialDecl = VarDecl::Create( auto *ArtificialDecl = VarDecl::Create(
getContext(), const_cast<DeclContext *>(D.getDeclContext()), getContext(), const_cast<DeclContext *>(D.getDeclContext()),
D.getLocation(), D.getLocation(), NameIdent, QT, D.getLocation(), D.getLocation(), NameIdent, QT,
getContext().CreateTypeSourceInfo(QT), SC_Auto); getContext().CreateTypeSourceInfo(QT), StorageClass::Auto);
ArtificialDecl->setImplicit(); ArtificialDecl->setImplicit();
MD = DI->EmitDeclareOfAutoVariable(ArtificialDecl, VlaSize.NumElts, MD = DI->EmitDeclareOfAutoVariable(ArtificialDecl, VlaSize.NumElts,

View File

@ -2675,7 +2675,7 @@ LValue CodeGenFunction::EmitDeclRefLValue(const DeclRefExpr *E) {
if (const auto *VD = dyn_cast<VarDecl>(ND)) { if (const auto *VD = dyn_cast<VarDecl>(ND)) {
// Global Named registers access via intrinsics only // Global Named registers access via intrinsics only
if (VD->getStorageClass() == SC_Register && if (VD->getStorageClass() == StorageClass::Register &&
VD->hasAttr<AsmLabelAttr>() && !VD->isLocalVarDecl()) VD->hasAttr<AsmLabelAttr>() && !VD->isLocalVarDecl())
return EmitGlobalNamedRegister(VD, CGM); return EmitGlobalNamedRegister(VD, CGM);

View File

@ -476,7 +476,7 @@ template <class Derived> struct GenFuncBase {
FunctionDecl *FD = FunctionDecl::Create( FunctionDecl *FD = FunctionDecl::Create(
Ctx, Ctx.getTranslationUnitDecl(), SourceLocation(), SourceLocation(), Ctx, Ctx.getTranslationUnitDecl(), SourceLocation(), SourceLocation(),
II, Ctx.getFunctionType(Ctx.VoidTy, llvm::None, {}), nullptr, II, Ctx.getFunctionType(Ctx.VoidTy, llvm::None, {}), nullptr,
SC_PrivateExtern, false, false); StorageClass::PrivateExtern, false, false);
CodeGenFunction NewCGF(CGM); CodeGenFunction NewCGF(CGM);
setCGF(&NewCGF); setCGF(&NewCGF);
CGF->StartFunction(FD, Ctx.VoidTy, F, FI, Args); CGF->StartFunction(FD, Ctx.VoidTy, F, FI, Args);

View File

@ -3642,7 +3642,7 @@ CodeGenFunction::GenerateObjCAtomicSetterCopyHelperFunction(
FunctionDecl *FD = FunctionDecl::Create( FunctionDecl *FD = FunctionDecl::Create(
C, C.getTranslationUnitDecl(), SourceLocation(), SourceLocation(), II, C, C.getTranslationUnitDecl(), SourceLocation(), SourceLocation(), II,
FunctionTy, nullptr, SC_Static, false, false); FunctionTy, nullptr, StorageClass::Static, false, false);
FunctionArgList args; FunctionArgList args;
ImplicitParamDecl DstDecl(C, FD, SourceLocation(), /*Id=*/nullptr, DestTy, ImplicitParamDecl DstDecl(C, FD, SourceLocation(), /*Id=*/nullptr, DestTy,
@ -3726,7 +3726,7 @@ CodeGenFunction::GenerateObjCAtomicGetterCopyHelperFunction(
FunctionDecl *FD = FunctionDecl::Create( FunctionDecl *FD = FunctionDecl::Create(
C, C.getTranslationUnitDecl(), SourceLocation(), SourceLocation(), II, C, C.getTranslationUnitDecl(), SourceLocation(), SourceLocation(), II,
FunctionTy, nullptr, SC_Static, false, false); FunctionTy, nullptr, StorageClass::Static, false, false);
FunctionArgList args; FunctionArgList args;
ImplicitParamDecl DstDecl(C, FD, SourceLocation(), /*Id=*/nullptr, DestTy, ImplicitParamDecl DstDecl(C, FD, SourceLocation(), /*Id=*/nullptr, DestTy,

View File

@ -4127,7 +4127,7 @@ CGOpenMPRuntimeGPU::translateParameter(const FieldDecl *FD,
const_cast<DeclContext *>(NativeParam->getDeclContext()), const_cast<DeclContext *>(NativeParam->getDeclContext()),
NativeParam->getBeginLoc(), NativeParam->getLocation(), NativeParam->getBeginLoc(), NativeParam->getLocation(),
NativeParam->getIdentifier(), ArgType, NativeParam->getIdentifier(), ArgType,
/*TInfo=*/nullptr, SC_None, /*DefArg=*/nullptr); /*TInfo=*/nullptr, StorageClass::None, /*DefArg=*/nullptr);
} }
Address Address

View File

@ -1997,7 +1997,7 @@ AddVariableConstraints(const std::string &Constraint, const Expr &AsmExpr,
const VarDecl *Variable = dyn_cast<VarDecl>(&Value); const VarDecl *Variable = dyn_cast<VarDecl>(&Value);
if (!Variable) if (!Variable)
return Constraint; return Constraint;
if (Variable->getStorageClass() != SC_Register) if (Variable->getStorageClass() != StorageClass::Register)
return Constraint; return Constraint;
AsmLabelAttr *Attr = Variable->getAttr<AsmLabelAttr>(); AsmLabelAttr *Attr = Variable->getAttr<AsmLabelAttr>();
if (!Attr) if (!Attr)

View File

@ -433,7 +433,7 @@ static llvm::Function *emitOutlinedFunctionPrologue(
DebugFunctionDecl = FunctionDecl::Create( DebugFunctionDecl = FunctionDecl::Create(
Ctx, Ctx.getTranslationUnitDecl(), FO.S->getBeginLoc(), Ctx, Ctx.getTranslationUnitDecl(), FO.S->getBeginLoc(),
SourceLocation(), DeclarationName(), FunctionTy, SourceLocation(), DeclarationName(), FunctionTy,
Ctx.getTrivialTypeSourceInfo(FunctionTy), SC_Static, Ctx.getTrivialTypeSourceInfo(FunctionTy), StorageClass::Static,
/*isInlineSpecified=*/false, /*hasWrittenPrototype=*/false); /*isInlineSpecified=*/false, /*hasWrittenPrototype=*/false);
} }
for (const FieldDecl *FD : RD->fields()) { for (const FieldDecl *FD : RD->fields()) {
@ -468,7 +468,7 @@ static llvm::Function *emitOutlinedFunctionPrologue(
Ctx, DebugFunctionDecl, Ctx, DebugFunctionDecl,
CapVar ? CapVar->getBeginLoc() : FD->getBeginLoc(), CapVar ? CapVar->getBeginLoc() : FD->getBeginLoc(),
CapVar ? CapVar->getLocation() : FD->getLocation(), II, ArgType, CapVar ? CapVar->getLocation() : FD->getLocation(), II, ArgType,
/*TInfo=*/nullptr, SC_None, /*DefArg=*/nullptr); /*TInfo=*/nullptr, StorageClass::None, /*DefArg=*/nullptr);
} else { } else {
Arg = ImplicitParamDecl::Create(Ctx, /*DC=*/nullptr, FD->getLocation(), Arg = ImplicitParamDecl::Create(Ctx, /*DC=*/nullptr, FD->getLocation(),
II, ArgType, ImplicitParamDecl::Other); II, ArgType, ImplicitParamDecl::Other);

View File

@ -2546,9 +2546,10 @@ static FunctionDecl *
createGlobalInitOrCleanupFnDecl(CodeGen::CodeGenModule &CGM, StringRef FnName) { createGlobalInitOrCleanupFnDecl(CodeGen::CodeGenModule &CGM, StringRef FnName) {
ASTContext &Ctx = CGM.getContext(); ASTContext &Ctx = CGM.getContext();
QualType FunctionTy = Ctx.getFunctionType(Ctx.VoidTy, llvm::None, {}); QualType FunctionTy = Ctx.getFunctionType(Ctx.VoidTy, llvm::None, {});
return FunctionDecl::Create( return FunctionDecl::Create(Ctx, Ctx.getTranslationUnitDecl(),
Ctx, Ctx.getTranslationUnitDecl(), SourceLocation(), SourceLocation(), SourceLocation(), SourceLocation(),
&Ctx.Idents.get(FnName), FunctionTy, nullptr, SC_Static, false, false); &Ctx.Idents.get(FnName), FunctionTy, nullptr,
StorageClass::Static, false, false);
} }
void CodeGenModule::unregisterGlobalDtorsWithUnAtExit() { void CodeGenModule::unregisterGlobalDtorsWithUnAtExit() {

View File

@ -58,8 +58,8 @@ class InterfaceStubFunctionsConsumer : public ASTConsumer {
if (isa<BlockDecl>(Parent) || isa<CXXMethodDecl>(Parent)) if (isa<BlockDecl>(Parent) || isa<CXXMethodDecl>(Parent))
return true; return true;
if ((VD->getStorageClass() == StorageClass::SC_Extern) || if ((VD->getStorageClass() == StorageClass::Extern) ||
(VD->getStorageClass() == StorageClass::SC_Static && (VD->getStorageClass() == StorageClass::Static &&
VD->getParentFunctionOrMethod() == nullptr)) VD->getParentFunctionOrMethod() == nullptr))
return true; return true;
} }
@ -75,7 +75,7 @@ class InterfaceStubFunctionsConsumer : public ASTConsumer {
if (MD->isDependentContext() || !MD->hasBody()) if (MD->isDependentContext() || !MD->hasBody())
return true; return true;
} }
if (FD->getStorageClass() == StorageClass::SC_Static) if (FD->getStorageClass() == StorageClass::Static)
return true; return true;
} }
return false; return false;

View File

@ -2318,11 +2318,9 @@ void RewriteModernObjC::SynthSelGetUidFunctionDecl() {
ArgTys.push_back(Context->getPointerType(Context->CharTy.withConst())); ArgTys.push_back(Context->getPointerType(Context->CharTy.withConst()));
QualType getFuncType = QualType getFuncType =
getSimpleFunctionType(Context->getObjCSelType(), ArgTys); getSimpleFunctionType(Context->getObjCSelType(), ArgTys);
SelGetUidFunctionDecl = FunctionDecl::Create(*Context, TUDecl, SelGetUidFunctionDecl = FunctionDecl::Create(
SourceLocation(), *Context, TUDecl, SourceLocation(), SourceLocation(), SelGetUidIdent,
SourceLocation(), getFuncType, nullptr, StorageClass::Extern);
SelGetUidIdent, getFuncType,
nullptr, SC_Extern);
} }
void RewriteModernObjC::RewriteFunctionDecl(FunctionDecl *FD) { void RewriteModernObjC::RewriteFunctionDecl(FunctionDecl *FD) {
@ -2416,11 +2414,9 @@ void RewriteModernObjC::SynthSuperConstructorFunctionDecl() {
ArgTys.push_back(argT); ArgTys.push_back(argT);
QualType msgSendType = getSimpleFunctionType(Context->getObjCIdType(), QualType msgSendType = getSimpleFunctionType(Context->getObjCIdType(),
ArgTys); ArgTys);
SuperConstructorFunctionDecl = FunctionDecl::Create(*Context, TUDecl, SuperConstructorFunctionDecl = FunctionDecl::Create(
SourceLocation(), *Context, TUDecl, SourceLocation(), SourceLocation(), msgSendIdent,
SourceLocation(), msgSendType, nullptr, StorageClass::Extern);
msgSendIdent, msgSendType,
nullptr, SC_Extern);
} }
// SynthMsgSendFunctionDecl - id objc_msgSend(id self, SEL op, ...); // SynthMsgSendFunctionDecl - id objc_msgSend(id self, SEL op, ...);
@ -2435,11 +2431,9 @@ void RewriteModernObjC::SynthMsgSendFunctionDecl() {
ArgTys.push_back(argT); ArgTys.push_back(argT);
QualType msgSendType = getSimpleFunctionType(Context->getObjCIdType(), QualType msgSendType = getSimpleFunctionType(Context->getObjCIdType(),
ArgTys, /*variadic=*/true); ArgTys, /*variadic=*/true);
MsgSendFunctionDecl = FunctionDecl::Create(*Context, TUDecl, MsgSendFunctionDecl = FunctionDecl::Create(
SourceLocation(), *Context, TUDecl, SourceLocation(), SourceLocation(), msgSendIdent,
SourceLocation(), msgSendType, nullptr, StorageClass::Extern);
msgSendIdent, msgSendType, nullptr,
SC_Extern);
} }
// SynthMsgSendSuperFunctionDecl - id objc_msgSendSuper(void); // SynthMsgSendSuperFunctionDecl - id objc_msgSendSuper(void);
@ -2449,11 +2443,9 @@ void RewriteModernObjC::SynthMsgSendSuperFunctionDecl() {
ArgTys.push_back(Context->VoidTy); ArgTys.push_back(Context->VoidTy);
QualType msgSendType = getSimpleFunctionType(Context->getObjCIdType(), QualType msgSendType = getSimpleFunctionType(Context->getObjCIdType(),
ArgTys, /*variadic=*/true); ArgTys, /*variadic=*/true);
MsgSendSuperFunctionDecl = FunctionDecl::Create(*Context, TUDecl, MsgSendSuperFunctionDecl = FunctionDecl::Create(
SourceLocation(), *Context, TUDecl, SourceLocation(), SourceLocation(), msgSendIdent,
SourceLocation(), msgSendType, nullptr, StorageClass::Extern);
msgSendIdent, msgSendType,
nullptr, SC_Extern);
} }
// SynthMsgSendStretFunctionDecl - id objc_msgSend_stret(id self, SEL op, ...); // SynthMsgSendStretFunctionDecl - id objc_msgSend_stret(id self, SEL op, ...);
@ -2468,11 +2460,9 @@ void RewriteModernObjC::SynthMsgSendStretFunctionDecl() {
ArgTys.push_back(argT); ArgTys.push_back(argT);
QualType msgSendType = getSimpleFunctionType(Context->getObjCIdType(), QualType msgSendType = getSimpleFunctionType(Context->getObjCIdType(),
ArgTys, /*variadic=*/true); ArgTys, /*variadic=*/true);
MsgSendStretFunctionDecl = FunctionDecl::Create(*Context, TUDecl, MsgSendStretFunctionDecl = FunctionDecl::Create(
SourceLocation(), *Context, TUDecl, SourceLocation(), SourceLocation(), msgSendIdent,
SourceLocation(), msgSendType, nullptr, StorageClass::Extern);
msgSendIdent, msgSendType,
nullptr, SC_Extern);
} }
// SynthMsgSendSuperStretFunctionDecl - // SynthMsgSendSuperStretFunctionDecl -
@ -2484,12 +2474,9 @@ void RewriteModernObjC::SynthMsgSendSuperStretFunctionDecl() {
ArgTys.push_back(Context->VoidTy); ArgTys.push_back(Context->VoidTy);
QualType msgSendType = getSimpleFunctionType(Context->getObjCIdType(), QualType msgSendType = getSimpleFunctionType(Context->getObjCIdType(),
ArgTys, /*variadic=*/true); ArgTys, /*variadic=*/true);
MsgSendSuperStretFunctionDecl = FunctionDecl::Create(*Context, TUDecl, MsgSendSuperStretFunctionDecl = FunctionDecl::Create(
SourceLocation(), *Context, TUDecl, SourceLocation(), SourceLocation(), msgSendIdent,
SourceLocation(), msgSendType, nullptr, StorageClass::Extern);
msgSendIdent,
msgSendType, nullptr,
SC_Extern);
} }
// SynthMsgSendFpretFunctionDecl - double objc_msgSend_fpret(id self, SEL op, ...); // SynthMsgSendFpretFunctionDecl - double objc_msgSend_fpret(id self, SEL op, ...);
@ -2504,11 +2491,9 @@ void RewriteModernObjC::SynthMsgSendFpretFunctionDecl() {
ArgTys.push_back(argT); ArgTys.push_back(argT);
QualType msgSendType = getSimpleFunctionType(Context->DoubleTy, QualType msgSendType = getSimpleFunctionType(Context->DoubleTy,
ArgTys, /*variadic=*/true); ArgTys, /*variadic=*/true);
MsgSendFpretFunctionDecl = FunctionDecl::Create(*Context, TUDecl, MsgSendFpretFunctionDecl = FunctionDecl::Create(
SourceLocation(), *Context, TUDecl, SourceLocation(), SourceLocation(), msgSendIdent,
SourceLocation(), msgSendType, nullptr, StorageClass::Extern);
msgSendIdent, msgSendType,
nullptr, SC_Extern);
} }
// SynthGetClassFunctionDecl - Class objc_getClass(const char *name); // SynthGetClassFunctionDecl - Class objc_getClass(const char *name);
@ -2518,11 +2503,9 @@ void RewriteModernObjC::SynthGetClassFunctionDecl() {
ArgTys.push_back(Context->getPointerType(Context->CharTy.withConst())); ArgTys.push_back(Context->getPointerType(Context->CharTy.withConst()));
QualType getClassType = getSimpleFunctionType(Context->getObjCClassType(), QualType getClassType = getSimpleFunctionType(Context->getObjCClassType(),
ArgTys); ArgTys);
GetClassFunctionDecl = FunctionDecl::Create(*Context, TUDecl, GetClassFunctionDecl = FunctionDecl::Create(
SourceLocation(), *Context, TUDecl, SourceLocation(), SourceLocation(), getClassIdent,
SourceLocation(), getClassType, nullptr, StorageClass::Extern);
getClassIdent, getClassType,
nullptr, SC_Extern);
} }
// SynthGetSuperClassFunctionDecl - Class class_getSuperclass(Class cls); // SynthGetSuperClassFunctionDecl - Class class_getSuperclass(Class cls);
@ -2533,12 +2516,9 @@ void RewriteModernObjC::SynthGetSuperClassFunctionDecl() {
ArgTys.push_back(Context->getObjCClassType()); ArgTys.push_back(Context->getObjCClassType());
QualType getClassType = getSimpleFunctionType(Context->getObjCClassType(), QualType getClassType = getSimpleFunctionType(Context->getObjCClassType(),
ArgTys); ArgTys);
GetSuperClassFunctionDecl = FunctionDecl::Create(*Context, TUDecl, GetSuperClassFunctionDecl = FunctionDecl::Create(
SourceLocation(), *Context, TUDecl, SourceLocation(), SourceLocation(), getSuperClassIdent,
SourceLocation(), getClassType, nullptr, StorageClass::Extern);
getSuperClassIdent,
getClassType, nullptr,
SC_Extern);
} }
// SynthGetMetaClassFunctionDecl - Class objc_getMetaClass(const char *name); // SynthGetMetaClassFunctionDecl - Class objc_getMetaClass(const char *name);
@ -2548,11 +2528,9 @@ void RewriteModernObjC::SynthGetMetaClassFunctionDecl() {
ArgTys.push_back(Context->getPointerType(Context->CharTy.withConst())); ArgTys.push_back(Context->getPointerType(Context->CharTy.withConst()));
QualType getClassType = getSimpleFunctionType(Context->getObjCClassType(), QualType getClassType = getSimpleFunctionType(Context->getObjCClassType(),
ArgTys); ArgTys);
GetMetaClassFunctionDecl = FunctionDecl::Create(*Context, TUDecl, GetMetaClassFunctionDecl = FunctionDecl::Create(
SourceLocation(), *Context, TUDecl, SourceLocation(), SourceLocation(), getClassIdent,
SourceLocation(), getClassType, nullptr, StorageClass::Extern);
getClassIdent, getClassType,
nullptr, SC_Extern);
} }
Stmt *RewriteModernObjC::RewriteObjCStringLiteral(ObjCStringLiteral *Exp) { Stmt *RewriteModernObjC::RewriteObjCStringLiteral(ObjCStringLiteral *Exp) {
@ -2586,7 +2564,7 @@ Stmt *RewriteModernObjC::RewriteObjCStringLiteral(ObjCStringLiteral *Exp) {
VarDecl *NewVD = VarDecl::Create(*Context, TUDecl, SourceLocation(), VarDecl *NewVD = VarDecl::Create(*Context, TUDecl, SourceLocation(),
SourceLocation(), &Context->Idents.get(S), SourceLocation(), &Context->Idents.get(S),
strType, nullptr, SC_Static); strType, nullptr, StorageClass::Static);
DeclRefExpr *DRE = new (Context) DeclRefExpr *DRE = new (Context)
DeclRefExpr(*Context, NewVD, false, strType, VK_LValue, SourceLocation()); DeclRefExpr(*Context, NewVD, false, strType, VK_LValue, SourceLocation());
Expr *Unop = UnaryOperator::Create( Expr *Unop = UnaryOperator::Create(
@ -3048,7 +3026,7 @@ static SourceLocation getFunctionSourceLocation (RewriteModernObjC &R,
if (!LSD->getRBraceLoc().isValid()) if (!LSD->getRBraceLoc().isValid())
return LSD->getExternLoc(); return LSD->getExternLoc();
} }
if (FD->getStorageClass() != SC_None) if (FD->getStorageClass() != StorageClass::None)
R.RewriteBlockLiteralFunctionDecl(FD); R.RewriteBlockLiteralFunctionDecl(FD);
return FD->getTypeSpecStartLoc(); return FD->getTypeSpecStartLoc();
} }
@ -3173,9 +3151,9 @@ Expr *RewriteModernObjC::SynthMsgSendStretCallExpr(FunctionDecl *MsgSendStretFla
// AST for __Stretn(receiver, args).s; // AST for __Stretn(receiver, args).s;
IdentifierInfo *ID = &Context->Idents.get(name); IdentifierInfo *ID = &Context->Idents.get(name);
FunctionDecl *FD = FunctionDecl *FD = FunctionDecl::Create(
FunctionDecl::Create(*Context, TUDecl, SourceLocation(), SourceLocation(), *Context, TUDecl, SourceLocation(), SourceLocation(), ID, FuncType,
ID, FuncType, nullptr, SC_Extern, false, false); nullptr, StorageClass::Extern, false, false);
DeclRefExpr *DRE = new (Context) DeclRefExpr *DRE = new (Context)
DeclRefExpr(*Context, FD, false, castType, VK_RValue, SourceLocation()); DeclRefExpr(*Context, FD, false, castType, VK_RValue, SourceLocation());
CallExpr *STCE = CallExpr *STCE =
@ -3593,9 +3571,9 @@ Stmt *RewriteModernObjC::RewriteObjCProtocolExpr(ObjCProtocolExpr *Exp) {
std::string Name = "_OBJC_PROTOCOL_REFERENCE_$_" + std::string Name = "_OBJC_PROTOCOL_REFERENCE_$_" +
Exp->getProtocol()->getNameAsString(); Exp->getProtocol()->getNameAsString();
IdentifierInfo *ID = &Context->Idents.get(Name); IdentifierInfo *ID = &Context->Idents.get(Name);
VarDecl *VD = VarDecl::Create(*Context, TUDecl, SourceLocation(), VarDecl *VD =
SourceLocation(), ID, getProtocolType(), VarDecl::Create(*Context, TUDecl, SourceLocation(), SourceLocation(), ID,
nullptr, SC_Extern); getProtocolType(), nullptr, StorageClass::Extern);
DeclRefExpr *DRE = new (Context) DeclRefExpr( DeclRefExpr *DRE = new (Context) DeclRefExpr(
*Context, VD, false, getProtocolType(), VK_LValue, SourceLocation()); *Context, VD, false, getProtocolType(), VK_LValue, SourceLocation());
CastExpr *castExpr = NoTypeInfoCStyleCastExpr( CastExpr *castExpr = NoTypeInfoCStyleCastExpr(
@ -4331,9 +4309,8 @@ std::string RewriteModernObjC::SynthesizeBlockDescriptor(std::string DescTag,
void RewriteModernObjC::SynthesizeBlockLiterals(SourceLocation FunLocStart, void RewriteModernObjC::SynthesizeBlockLiterals(SourceLocation FunLocStart,
StringRef FunName) { StringRef FunName) {
bool RewriteSC = (GlobalVarDecl && bool RewriteSC = (GlobalVarDecl && !Blocks.empty() &&
!Blocks.empty() && GlobalVarDecl->getStorageClass() == StorageClass::Static &&
GlobalVarDecl->getStorageClass() == SC_Static &&
GlobalVarDecl->getType().getCVRQualifiers()); GlobalVarDecl->getType().getCVRQualifiers());
if (RewriteSC) { if (RewriteSC) {
std::string SC(" void __"); std::string SC(" void __");
@ -4401,7 +4378,7 @@ void RewriteModernObjC::SynthesizeBlockLiterals(SourceLocation FunLocStart,
// Must insert any 'const/volatile/static here. Since it has been // Must insert any 'const/volatile/static here. Since it has been
// removed as result of rewriting of block literals. // removed as result of rewriting of block literals.
std::string SC; std::string SC;
if (GlobalVarDecl->getStorageClass() == SC_Static) if (GlobalVarDecl->getStorageClass() == StorageClass::Static)
SC = "static "; SC = "static ";
if (GlobalVarDecl->getType().isConstQualified()) if (GlobalVarDecl->getType().isConstQualified())
SC += "const "; SC += "const ";
@ -5201,8 +5178,8 @@ FunctionDecl *RewriteModernObjC::SynthBlockInitFunctionDecl(StringRef name) {
IdentifierInfo *ID = &Context->Idents.get(name); IdentifierInfo *ID = &Context->Idents.get(name);
QualType FType = Context->getFunctionNoProtoType(Context->VoidPtrTy); QualType FType = Context->getFunctionNoProtoType(Context->VoidPtrTy);
return FunctionDecl::Create(*Context, TUDecl, SourceLocation(), return FunctionDecl::Create(*Context, TUDecl, SourceLocation(),
SourceLocation(), ID, FType, nullptr, SC_Extern, SourceLocation(), ID, FType, nullptr,
false, false); StorageClass::Extern, false, false);
} }
Stmt *RewriteModernObjC::SynthBlockInitExpr(BlockExpr *Exp, Stmt *RewriteModernObjC::SynthBlockInitExpr(BlockExpr *Exp,
@ -5298,9 +5275,10 @@ Stmt *RewriteModernObjC::SynthBlockInitExpr(BlockExpr *Exp,
// Initialize the block descriptor. // Initialize the block descriptor.
std::string DescData = "__" + FuncName + "_block_desc_" + BlockNumber + "_DATA"; std::string DescData = "__" + FuncName + "_block_desc_" + BlockNumber + "_DATA";
VarDecl *NewVD = VarDecl::Create( VarDecl *NewVD =
*Context, TUDecl, SourceLocation(), SourceLocation(), VarDecl::Create(*Context, TUDecl, SourceLocation(), SourceLocation(),
&Context->Idents.get(DescData), Context->VoidPtrTy, nullptr, SC_Static); &Context->Idents.get(DescData), Context->VoidPtrTy,
nullptr, StorageClass::Static);
UnaryOperator *DescRefExpr = UnaryOperator::Create( UnaryOperator *DescRefExpr = UnaryOperator::Create(
const_cast<ASTContext &>(*Context), const_cast<ASTContext &>(*Context),
new (Context) DeclRefExpr(*Context, NewVD, false, Context->VoidPtrTy, new (Context) DeclRefExpr(*Context, NewVD, false, Context->VoidPtrTy,
@ -7488,10 +7466,10 @@ Stmt *RewriteModernObjC::RewriteObjCIvarRefExpr(ObjCIvarRefExpr *IV) {
Context->getPointerType(Context->CharTy), Context->getPointerType(Context->CharTy),
CK_BitCast, CK_BitCast,
BaseExpr); BaseExpr);
VarDecl *NewVD = VarDecl::Create(*Context, TUDecl, SourceLocation(), VarDecl *NewVD = VarDecl::Create(
SourceLocation(), &Context->Idents.get(IvarOffsetName), *Context, TUDecl, SourceLocation(), SourceLocation(),
Context->UnsignedLongTy, nullptr, &Context->Idents.get(IvarOffsetName), Context->UnsignedLongTy,
SC_Extern); nullptr, StorageClass::Extern);
DeclRefExpr *DRE = new (Context) DeclRefExpr *DRE = new (Context)
DeclRefExpr(*Context, NewVD, false, Context->UnsignedLongTy, DeclRefExpr(*Context, NewVD, false, Context->UnsignedLongTy,
VK_LValue, SourceLocation()); VK_LValue, SourceLocation());

View File

@ -2232,11 +2232,9 @@ void RewriteObjC::SynthSelGetUidFunctionDecl() {
ArgTys.push_back(Context->getPointerType(Context->CharTy.withConst())); ArgTys.push_back(Context->getPointerType(Context->CharTy.withConst()));
QualType getFuncType = QualType getFuncType =
getSimpleFunctionType(Context->getObjCSelType(), ArgTys); getSimpleFunctionType(Context->getObjCSelType(), ArgTys);
SelGetUidFunctionDecl = FunctionDecl::Create(*Context, TUDecl, SelGetUidFunctionDecl = FunctionDecl::Create(
SourceLocation(), *Context, TUDecl, SourceLocation(), SourceLocation(), SelGetUidIdent,
SourceLocation(), getFuncType, nullptr, StorageClass::Extern);
SelGetUidIdent, getFuncType,
nullptr, SC_Extern);
} }
void RewriteObjC::RewriteFunctionDecl(FunctionDecl *FD) { void RewriteObjC::RewriteFunctionDecl(FunctionDecl *FD) {
@ -2327,11 +2325,9 @@ void RewriteObjC::SynthSuperConstructorFunctionDecl() {
ArgTys.push_back(argT); ArgTys.push_back(argT);
QualType msgSendType = getSimpleFunctionType(Context->getObjCIdType(), QualType msgSendType = getSimpleFunctionType(Context->getObjCIdType(),
ArgTys); ArgTys);
SuperConstructorFunctionDecl = FunctionDecl::Create(*Context, TUDecl, SuperConstructorFunctionDecl = FunctionDecl::Create(
SourceLocation(), *Context, TUDecl, SourceLocation(), SourceLocation(), msgSendIdent,
SourceLocation(), msgSendType, nullptr, StorageClass::Extern);
msgSendIdent, msgSendType,
nullptr, SC_Extern);
} }
// SynthMsgSendFunctionDecl - id objc_msgSend(id self, SEL op, ...); // SynthMsgSendFunctionDecl - id objc_msgSend(id self, SEL op, ...);
@ -2346,11 +2342,9 @@ void RewriteObjC::SynthMsgSendFunctionDecl() {
ArgTys.push_back(argT); ArgTys.push_back(argT);
QualType msgSendType = getSimpleFunctionType(Context->getObjCIdType(), QualType msgSendType = getSimpleFunctionType(Context->getObjCIdType(),
ArgTys, /*variadic=*/true); ArgTys, /*variadic=*/true);
MsgSendFunctionDecl = FunctionDecl::Create(*Context, TUDecl, MsgSendFunctionDecl = FunctionDecl::Create(
SourceLocation(), *Context, TUDecl, SourceLocation(), SourceLocation(), msgSendIdent,
SourceLocation(), msgSendType, nullptr, StorageClass::Extern);
msgSendIdent, msgSendType,
nullptr, SC_Extern);
} }
// SynthMsgSendSuperFunctionDecl - id objc_msgSendSuper(struct objc_super *, SEL op, ...); // SynthMsgSendSuperFunctionDecl - id objc_msgSendSuper(struct objc_super *, SEL op, ...);
@ -2368,11 +2362,9 @@ void RewriteObjC::SynthMsgSendSuperFunctionDecl() {
ArgTys.push_back(argT); ArgTys.push_back(argT);
QualType msgSendType = getSimpleFunctionType(Context->getObjCIdType(), QualType msgSendType = getSimpleFunctionType(Context->getObjCIdType(),
ArgTys, /*variadic=*/true); ArgTys, /*variadic=*/true);
MsgSendSuperFunctionDecl = FunctionDecl::Create(*Context, TUDecl, MsgSendSuperFunctionDecl = FunctionDecl::Create(
SourceLocation(), *Context, TUDecl, SourceLocation(), SourceLocation(), msgSendIdent,
SourceLocation(), msgSendType, nullptr, StorageClass::Extern);
msgSendIdent, msgSendType,
nullptr, SC_Extern);
} }
// SynthMsgSendStretFunctionDecl - id objc_msgSend_stret(id self, SEL op, ...); // SynthMsgSendStretFunctionDecl - id objc_msgSend_stret(id self, SEL op, ...);
@ -2387,11 +2379,9 @@ void RewriteObjC::SynthMsgSendStretFunctionDecl() {
ArgTys.push_back(argT); ArgTys.push_back(argT);
QualType msgSendType = getSimpleFunctionType(Context->getObjCIdType(), QualType msgSendType = getSimpleFunctionType(Context->getObjCIdType(),
ArgTys, /*variadic=*/true); ArgTys, /*variadic=*/true);
MsgSendStretFunctionDecl = FunctionDecl::Create(*Context, TUDecl, MsgSendStretFunctionDecl = FunctionDecl::Create(
SourceLocation(), *Context, TUDecl, SourceLocation(), SourceLocation(), msgSendIdent,
SourceLocation(), msgSendType, nullptr, StorageClass::Extern);
msgSendIdent, msgSendType,
nullptr, SC_Extern);
} }
// SynthMsgSendSuperStretFunctionDecl - // SynthMsgSendSuperStretFunctionDecl -
@ -2411,12 +2401,9 @@ void RewriteObjC::SynthMsgSendSuperStretFunctionDecl() {
ArgTys.push_back(argT); ArgTys.push_back(argT);
QualType msgSendType = getSimpleFunctionType(Context->getObjCIdType(), QualType msgSendType = getSimpleFunctionType(Context->getObjCIdType(),
ArgTys, /*variadic=*/true); ArgTys, /*variadic=*/true);
MsgSendSuperStretFunctionDecl = FunctionDecl::Create(*Context, TUDecl, MsgSendSuperStretFunctionDecl = FunctionDecl::Create(
SourceLocation(), *Context, TUDecl, SourceLocation(), SourceLocation(), msgSendIdent,
SourceLocation(), msgSendType, nullptr, StorageClass::Extern);
msgSendIdent,
msgSendType, nullptr,
SC_Extern);
} }
// SynthMsgSendFpretFunctionDecl - double objc_msgSend_fpret(id self, SEL op, ...); // SynthMsgSendFpretFunctionDecl - double objc_msgSend_fpret(id self, SEL op, ...);
@ -2431,11 +2418,9 @@ void RewriteObjC::SynthMsgSendFpretFunctionDecl() {
ArgTys.push_back(argT); ArgTys.push_back(argT);
QualType msgSendType = getSimpleFunctionType(Context->DoubleTy, QualType msgSendType = getSimpleFunctionType(Context->DoubleTy,
ArgTys, /*variadic=*/true); ArgTys, /*variadic=*/true);
MsgSendFpretFunctionDecl = FunctionDecl::Create(*Context, TUDecl, MsgSendFpretFunctionDecl = FunctionDecl::Create(
SourceLocation(), *Context, TUDecl, SourceLocation(), SourceLocation(), msgSendIdent,
SourceLocation(), msgSendType, nullptr, StorageClass::Extern);
msgSendIdent, msgSendType,
nullptr, SC_Extern);
} }
// SynthGetClassFunctionDecl - id objc_getClass(const char *name); // SynthGetClassFunctionDecl - id objc_getClass(const char *name);
@ -2445,11 +2430,9 @@ void RewriteObjC::SynthGetClassFunctionDecl() {
ArgTys.push_back(Context->getPointerType(Context->CharTy.withConst())); ArgTys.push_back(Context->getPointerType(Context->CharTy.withConst()));
QualType getClassType = getSimpleFunctionType(Context->getObjCIdType(), QualType getClassType = getSimpleFunctionType(Context->getObjCIdType(),
ArgTys); ArgTys);
GetClassFunctionDecl = FunctionDecl::Create(*Context, TUDecl, GetClassFunctionDecl = FunctionDecl::Create(
SourceLocation(), *Context, TUDecl, SourceLocation(), SourceLocation(), getClassIdent,
SourceLocation(), getClassType, nullptr, StorageClass::Extern);
getClassIdent, getClassType,
nullptr, SC_Extern);
} }
// SynthGetSuperClassFunctionDecl - Class class_getSuperclass(Class cls); // SynthGetSuperClassFunctionDecl - Class class_getSuperclass(Class cls);
@ -2460,12 +2443,9 @@ void RewriteObjC::SynthGetSuperClassFunctionDecl() {
ArgTys.push_back(Context->getObjCClassType()); ArgTys.push_back(Context->getObjCClassType());
QualType getClassType = getSimpleFunctionType(Context->getObjCClassType(), QualType getClassType = getSimpleFunctionType(Context->getObjCClassType(),
ArgTys); ArgTys);
GetSuperClassFunctionDecl = FunctionDecl::Create(*Context, TUDecl, GetSuperClassFunctionDecl = FunctionDecl::Create(
SourceLocation(), *Context, TUDecl, SourceLocation(), SourceLocation(), getSuperClassIdent,
SourceLocation(), getClassType, nullptr, StorageClass::Extern);
getSuperClassIdent,
getClassType, nullptr,
SC_Extern);
} }
// SynthGetMetaClassFunctionDecl - id objc_getMetaClass(const char *name); // SynthGetMetaClassFunctionDecl - id objc_getMetaClass(const char *name);
@ -2475,11 +2455,9 @@ void RewriteObjC::SynthGetMetaClassFunctionDecl() {
ArgTys.push_back(Context->getPointerType(Context->CharTy.withConst())); ArgTys.push_back(Context->getPointerType(Context->CharTy.withConst()));
QualType getClassType = getSimpleFunctionType(Context->getObjCIdType(), QualType getClassType = getSimpleFunctionType(Context->getObjCIdType(),
ArgTys); ArgTys);
GetMetaClassFunctionDecl = FunctionDecl::Create(*Context, TUDecl, GetMetaClassFunctionDecl = FunctionDecl::Create(
SourceLocation(), *Context, TUDecl, SourceLocation(), SourceLocation(), getClassIdent,
SourceLocation(), getClassType, nullptr, StorageClass::Extern);
getClassIdent, getClassType,
nullptr, SC_Extern);
} }
Stmt *RewriteObjC::RewriteObjCStringLiteral(ObjCStringLiteral *Exp) { Stmt *RewriteObjC::RewriteObjCStringLiteral(ObjCStringLiteral *Exp) {
@ -2513,7 +2491,7 @@ Stmt *RewriteObjC::RewriteObjCStringLiteral(ObjCStringLiteral *Exp) {
VarDecl *NewVD = VarDecl::Create(*Context, TUDecl, SourceLocation(), VarDecl *NewVD = VarDecl::Create(*Context, TUDecl, SourceLocation(),
SourceLocation(), &Context->Idents.get(S), SourceLocation(), &Context->Idents.get(S),
strType, nullptr, SC_Static); strType, nullptr, StorageClass::Static);
DeclRefExpr *DRE = new (Context) DeclRefExpr *DRE = new (Context)
DeclRefExpr(*Context, NewVD, false, strType, VK_LValue, SourceLocation()); DeclRefExpr(*Context, NewVD, false, strType, VK_LValue, SourceLocation());
Expr *Unop = UnaryOperator::Create( Expr *Unop = UnaryOperator::Create(
@ -3049,9 +3027,9 @@ QualType RewriteObjC::getProtocolType() {
Stmt *RewriteObjC::RewriteObjCProtocolExpr(ObjCProtocolExpr *Exp) { Stmt *RewriteObjC::RewriteObjCProtocolExpr(ObjCProtocolExpr *Exp) {
std::string Name = "_OBJC_PROTOCOL_" + Exp->getProtocol()->getNameAsString(); std::string Name = "_OBJC_PROTOCOL_" + Exp->getProtocol()->getNameAsString();
IdentifierInfo *ID = &Context->Idents.get(Name); IdentifierInfo *ID = &Context->Idents.get(Name);
VarDecl *VD = VarDecl::Create(*Context, TUDecl, SourceLocation(), VarDecl *VD =
SourceLocation(), ID, getProtocolType(), VarDecl::Create(*Context, TUDecl, SourceLocation(), SourceLocation(), ID,
nullptr, SC_Extern); getProtocolType(), nullptr, StorageClass::Extern);
DeclRefExpr *DRE = new (Context) DeclRefExpr( DeclRefExpr *DRE = new (Context) DeclRefExpr(
*Context, VD, false, getProtocolType(), VK_LValue, SourceLocation()); *Context, VD, false, getProtocolType(), VK_LValue, SourceLocation());
Expr *DerefExpr = UnaryOperator::Create( Expr *DerefExpr = UnaryOperator::Create(
@ -3545,9 +3523,8 @@ void RewriteObjC::SynthesizeBlockLiterals(SourceLocation FunLocStart,
// Insert declaration for the function in which block literal is used. // Insert declaration for the function in which block literal is used.
if (CurFunctionDeclToDeclareForBlock && !Blocks.empty()) if (CurFunctionDeclToDeclareForBlock && !Blocks.empty())
RewriteBlockLiteralFunctionDecl(CurFunctionDeclToDeclareForBlock); RewriteBlockLiteralFunctionDecl(CurFunctionDeclToDeclareForBlock);
bool RewriteSC = (GlobalVarDecl && bool RewriteSC = (GlobalVarDecl && !Blocks.empty() &&
!Blocks.empty() && GlobalVarDecl->getStorageClass() == StorageClass::Static &&
GlobalVarDecl->getStorageClass() == SC_Static &&
GlobalVarDecl->getType().getCVRQualifiers()); GlobalVarDecl->getType().getCVRQualifiers());
if (RewriteSC) { if (RewriteSC) {
std::string SC(" void __"); std::string SC(" void __");
@ -3611,7 +3588,7 @@ void RewriteObjC::SynthesizeBlockLiterals(SourceLocation FunLocStart,
// Must insert any 'const/volatile/static here. Since it has been // Must insert any 'const/volatile/static here. Since it has been
// removed as result of rewriting of block literals. // removed as result of rewriting of block literals.
std::string SC; std::string SC;
if (GlobalVarDecl->getStorageClass() == SC_Static) if (GlobalVarDecl->getStorageClass() == StorageClass::Static)
SC = "static "; SC = "static ";
if (GlobalVarDecl->getType().isConstQualified()) if (GlobalVarDecl->getType().isConstQualified())
SC += "const "; SC += "const ";
@ -4356,8 +4333,8 @@ FunctionDecl *RewriteObjC::SynthBlockInitFunctionDecl(StringRef name) {
IdentifierInfo *ID = &Context->Idents.get(name); IdentifierInfo *ID = &Context->Idents.get(name);
QualType FType = Context->getFunctionNoProtoType(Context->VoidPtrTy); QualType FType = Context->getFunctionNoProtoType(Context->VoidPtrTy);
return FunctionDecl::Create(*Context, TUDecl, SourceLocation(), return FunctionDecl::Create(*Context, TUDecl, SourceLocation(),
SourceLocation(), ID, FType, nullptr, SC_Extern, SourceLocation(), ID, FType, nullptr,
false, false); StorageClass::Extern, false, false);
} }
Stmt *RewriteObjC::SynthBlockInitExpr(BlockExpr *Exp, Stmt *RewriteObjC::SynthBlockInitExpr(BlockExpr *Exp,
@ -4437,9 +4414,10 @@ Stmt *RewriteObjC::SynthBlockInitExpr(BlockExpr *Exp,
// Initialize the block descriptor. // Initialize the block descriptor.
std::string DescData = "__" + FuncName + "_block_desc_" + BlockNumber + "_DATA"; std::string DescData = "__" + FuncName + "_block_desc_" + BlockNumber + "_DATA";
VarDecl *NewVD = VarDecl::Create( VarDecl *NewVD =
*Context, TUDecl, SourceLocation(), SourceLocation(), VarDecl::Create(*Context, TUDecl, SourceLocation(), SourceLocation(),
&Context->Idents.get(DescData), Context->VoidPtrTy, nullptr, SC_Static); &Context->Idents.get(DescData), Context->VoidPtrTy,
nullptr, StorageClass::Static);
UnaryOperator *DescRefExpr = UnaryOperator::Create( UnaryOperator *DescRefExpr = UnaryOperator::Create(
const_cast<ASTContext &>(*Context), const_cast<ASTContext &>(*Context),
new (Context) DeclRefExpr(*Context, NewVD, false, Context->VoidPtrTy, new (Context) DeclRefExpr(*Context, NewVD, false, Context->VoidPtrTy,

View File

@ -1219,7 +1219,7 @@ void Sema::ActOnEndOfTranslationUnit() {
Diag(DiagD->getLocation(), diag::warn_unneeded_member_function) Diag(DiagD->getLocation(), diag::warn_unneeded_member_function)
<< DiagD; << DiagD;
else { else {
if (FD->getStorageClass() == SC_Static && if (FD->getStorageClass() == StorageClass::Static &&
!FD->isInlineSpecified() && !FD->isInlineSpecified() &&
!SourceMgr.isInMainFile( !SourceMgr.isInMainFile(
SourceMgr.getExpansionLoc(FD->getLocation()))) SourceMgr.getExpansionLoc(FD->getLocation())))

View File

@ -5803,8 +5803,8 @@ bool Sema::SemaBuiltinVAStart(unsigned BuiltinID, CallExpr *TheCall) {
Type = PV->getType(); Type = PV->getType();
ParamLoc = PV->getLocation(); ParamLoc = PV->getLocation();
IsCRegister = IsCRegister = PV->getStorageClass() == StorageClass::Register &&
PV->getStorageClass() == SC_Register && !getLangOpts().CPlusPlus; !getLangOpts().CPlusPlus;
} }
} }
@ -10249,8 +10249,7 @@ void CheckFreeArgumentsOnLvalue(Sema &S, const std::string &CalleeName,
const UnaryOperator *UnaryExpr, const UnaryOperator *UnaryExpr,
const VarDecl *Var) { const VarDecl *Var) {
StorageClass Class = Var->getStorageClass(); StorageClass Class = Var->getStorageClass();
if (Class == StorageClass::SC_Extern || if (Class == StorageClass::Extern || Class == StorageClass::PrivateExtern ||
Class == StorageClass::SC_PrivateExtern ||
Var->getType()->isReferenceType()) Var->getType()->isReferenceType())
return; return;

View File

@ -543,7 +543,8 @@ VarDecl *Sema::buildCoroutinePromise(SourceLocation Loc) {
auto *VD = VarDecl::Create(Context, FD, FD->getLocation(), FD->getLocation(), auto *VD = VarDecl::Create(Context, FD, FD->getLocation(), FD->getLocation(),
&PP.getIdentifierTable().get("__promise"), T, &PP.getIdentifierTable().get("__promise"), T,
Context.getTrivialTypeSourceInfo(T, Loc), SC_None); Context.getTrivialTypeSourceInfo(T, Loc),
StorageClass::None);
VD->setImplicit(); VD->setImplicit();
CheckVariableDeclarationType(VD); CheckVariableDeclarationType(VD);
if (VD->isInvalidDecl()) if (VD->isInvalidDecl())
@ -1577,7 +1578,7 @@ bool CoroutineStmtBuilder::makeGroDeclAndReturnStmt() {
auto *GroDecl = VarDecl::Create( auto *GroDecl = VarDecl::Create(
S.Context, &FD, FD.getLocation(), FD.getLocation(), S.Context, &FD, FD.getLocation(), FD.getLocation(),
&S.PP.getIdentifierTable().get("__coro_gro"), GroType, &S.PP.getIdentifierTable().get("__coro_gro"), GroType,
S.Context.getTrivialTypeSourceInfo(GroType, Loc), SC_None); S.Context.getTrivialTypeSourceInfo(GroType, Loc), StorageClass::None);
GroDecl->setImplicit(); GroDecl->setImplicit();
S.CheckVariableDeclarationType(GroDecl); S.CheckVariableDeclarationType(GroDecl);
@ -1645,7 +1646,7 @@ static VarDecl *buildVarDecl(Sema &S, SourceLocation Loc, QualType Type,
IdentifierInfo *II) { IdentifierInfo *II) {
TypeSourceInfo *TInfo = S.Context.getTrivialTypeSourceInfo(Type, Loc); TypeSourceInfo *TInfo = S.Context.getTrivialTypeSourceInfo(Type, Loc);
VarDecl *Decl = VarDecl::Create(S.Context, S.CurContext, Loc, Loc, II, Type, VarDecl *Decl = VarDecl::Create(S.Context, S.CurContext, Loc, Loc, II, Type,
TInfo, SC_None); TInfo, StorageClass::None);
Decl->setImplicit(); Decl->setImplicit();
return Decl; return Decl;
} }

View File

@ -2061,8 +2061,9 @@ FunctionDecl *Sema::CreateBuiltin(IdentifierInfo *II, QualType Type,
Parent = CLinkageDecl; Parent = CLinkageDecl;
} }
FunctionDecl *New = FunctionDecl::Create(Context, Parent, Loc, Loc, II, Type, FunctionDecl *New =
/*TInfo=*/nullptr, SC_Extern, false, FunctionDecl::Create(Context, Parent, Loc, Loc, II, Type,
/*TInfo=*/nullptr, StorageClass::Extern, false,
Type->isFunctionProtoType()); Type->isFunctionProtoType());
New->setImplicit(); New->setImplicit();
New->addAttr(BuiltinAttr::CreateImplicit(Context, ID)); New->addAttr(BuiltinAttr::CreateImplicit(Context, ID));
@ -2074,7 +2075,7 @@ FunctionDecl *Sema::CreateBuiltin(IdentifierInfo *II, QualType Type,
for (unsigned i = 0, e = FT->getNumParams(); i != e; ++i) { for (unsigned i = 0, e = FT->getNumParams(); i != e; ++i) {
ParmVarDecl *parm = ParmVarDecl::Create( ParmVarDecl *parm = ParmVarDecl::Create(
Context, New, SourceLocation(), SourceLocation(), nullptr, Context, New, SourceLocation(), SourceLocation(), nullptr,
FT->getParamType(i), /*TInfo=*/nullptr, SC_None, nullptr); FT->getParamType(i), /*TInfo=*/nullptr, StorageClass::None, nullptr);
parm->setScopeInfo(0, i); parm->setScopeInfo(0, i);
Params.push_back(parm); Params.push_back(parm);
} }
@ -3072,9 +3073,8 @@ getNoteDiagForInvalidRedeclaration(const T *Old, const T *New) {
static bool canRedefineFunction(const FunctionDecl *FD, static bool canRedefineFunction(const FunctionDecl *FD,
const LangOptions& LangOpts) { const LangOptions& LangOpts) {
return ((FD->hasAttr<GNUInlineAttr>() || LangOpts.GNUInline) && return ((FD->hasAttr<GNUInlineAttr>() || LangOpts.GNUInline) &&
!LangOpts.CPlusPlus && !LangOpts.CPlusPlus && FD->isInlineSpecified() &&
FD->isInlineSpecified() && FD->getStorageClass() == StorageClass::Extern);
FD->getStorageClass() == SC_Extern);
} }
const AttributedType *Sema::getCallingConvAttributedType(QualType T) const { const AttributedType *Sema::getCallingConvAttributedType(QualType T) const {
@ -3258,7 +3258,7 @@ bool Sema::MergeFunctionDecl(FunctionDecl *New, NamedDecl *&OldD,
// Don't complain about specializations. They are not supposed to have // Don't complain about specializations. They are not supposed to have
// storage classes. // storage classes.
if (!isa<CXXMethodDecl>(New) && !isa<CXXMethodDecl>(Old) && if (!isa<CXXMethodDecl>(New) && !isa<CXXMethodDecl>(Old) &&
New->getStorageClass() == SC_Static && New->getStorageClass() == StorageClass::Static &&
Old->hasExternalFormalLinkage() && Old->hasExternalFormalLinkage() &&
!New->getTemplateSpecializationInfo() && !New->getTemplateSpecializationInfo() &&
!canRedefineFunction(Old, getLangOpts())) { !canRedefineFunction(Old, getLangOpts())) {
@ -3689,10 +3689,9 @@ bool Sema::MergeFunctionDecl(FunctionDecl *New, NamedDecl *&OldD,
// Synthesize parameters with the same types. // Synthesize parameters with the same types.
SmallVector<ParmVarDecl*, 16> Params; SmallVector<ParmVarDecl*, 16> Params;
for (const auto &ParamType : OldProto->param_types()) { for (const auto &ParamType : OldProto->param_types()) {
ParmVarDecl *Param = ParmVarDecl::Create(Context, New, SourceLocation(), ParmVarDecl *Param = ParmVarDecl::Create(
SourceLocation(), nullptr, Context, New, SourceLocation(), SourceLocation(), nullptr,
ParamType, /*TInfo=*/nullptr, ParamType, /*TInfo=*/nullptr, StorageClass::None, nullptr);
SC_None, nullptr);
Param->setScopeInfo(0, Params.size()); Param->setScopeInfo(0, Params.size());
Param->setImplicit(); Param->setImplicit();
Params.push_back(Param); Params.push_back(Param);
@ -4072,7 +4071,7 @@ void Sema::MergeVarDecl(VarDecl *New, LookupResult &Previous) {
// Warn if an already-declared variable is made a weak_import in a subsequent // Warn if an already-declared variable is made a weak_import in a subsequent
// declaration // declaration
if (New->hasAttr<WeakImportAttr>() && if (New->hasAttr<WeakImportAttr>() &&
Old->getStorageClass() == SC_None && Old->getStorageClass() == StorageClass::None &&
!Old->hasAttr<WeakImportAttr>()) { !Old->hasAttr<WeakImportAttr>()) {
Diag(New->getLocation(), diag::warn_weak_import) << New->getDeclName(); Diag(New->getLocation(), diag::warn_weak_import) << New->getDeclName();
notePreviousDefinition(Old, New->getLocation()); notePreviousDefinition(Old, New->getLocation());
@ -4107,9 +4106,8 @@ void Sema::MergeVarDecl(VarDecl *New, LookupResult &Previous) {
getNoteDiagForInvalidRedeclaration(Old, New); getNoteDiagForInvalidRedeclaration(Old, New);
// [dcl.stc]p8: Check if we have a non-static decl followed by a static. // [dcl.stc]p8: Check if we have a non-static decl followed by a static.
if (New->getStorageClass() == SC_Static && if (New->getStorageClass() == StorageClass::Static &&
!New->isStaticDataMember() && !New->isStaticDataMember() && Old->hasExternalFormalLinkage()) {
Old->hasExternalFormalLinkage()) {
if (getLangOpts().MicrosoftExt) { if (getLangOpts().MicrosoftExt) {
Diag(New->getLocation(), diag::ext_static_non_static) Diag(New->getLocation(), diag::ext_static_non_static)
<< New->getDeclName(); << New->getDeclName();
@ -4132,9 +4130,9 @@ void Sema::MergeVarDecl(VarDecl *New, LookupResult &Previous) {
// identifier has external linkage. // identifier has external linkage.
if (New->hasExternalStorage() && Old->hasLinkage()) if (New->hasExternalStorage() && Old->hasLinkage())
/* Okay */; /* Okay */;
else if (New->getCanonicalDecl()->getStorageClass() != SC_Static && else if (New->getCanonicalDecl()->getStorageClass() != StorageClass::Static &&
!New->isStaticDataMember() && !New->isStaticDataMember() &&
Old->getCanonicalDecl()->getStorageClass() == SC_Static) { Old->getCanonicalDecl()->getStorageClass() == StorageClass::Static) {
Diag(New->getLocation(), diag::err_non_static_static) << New->getDeclName(); Diag(New->getLocation(), diag::err_non_static_static) << New->getDeclName();
Diag(OldLocation, PrevDiag); Diag(OldLocation, PrevDiag);
return New->setInvalidDecl(); return New->setInvalidDecl();
@ -4916,18 +4914,24 @@ StorageClassSpecToVarDeclStorageClass(const DeclSpec &DS) {
assert(StorageClassSpec != DeclSpec::SCS_typedef && assert(StorageClassSpec != DeclSpec::SCS_typedef &&
"Parser allowed 'typedef' as storage class VarDecl."); "Parser allowed 'typedef' as storage class VarDecl.");
switch (StorageClassSpec) { switch (StorageClassSpec) {
case DeclSpec::SCS_unspecified: return SC_None; case DeclSpec::SCS_unspecified:
return StorageClass::None;
case DeclSpec::SCS_extern: case DeclSpec::SCS_extern:
if (DS.isExternInLinkageSpec()) if (DS.isExternInLinkageSpec())
return SC_None; return StorageClass::None;
return SC_Extern; return StorageClass::Extern;
case DeclSpec::SCS_static: return SC_Static; case DeclSpec::SCS_static:
case DeclSpec::SCS_auto: return SC_Auto; return StorageClass::Static;
case DeclSpec::SCS_register: return SC_Register; case DeclSpec::SCS_auto:
case DeclSpec::SCS_private_extern: return SC_PrivateExtern; return StorageClass::Auto;
case DeclSpec::SCS_register:
return StorageClass::Register;
case DeclSpec::SCS_private_extern:
return StorageClass::PrivateExtern;
// Illegal SCSs map to None: error reporting is up to the caller. // Illegal SCSs map to None: error reporting is up to the caller.
case DeclSpec::SCS_mutable: // Fall through. case DeclSpec::SCS_mutable: // Fall through.
case DeclSpec::SCS_typedef: return SC_None; case DeclSpec::SCS_typedef:
return StorageClass::None;
} }
llvm_unreachable("unknown storage class specifier"); llvm_unreachable("unknown storage class specifier");
} }
@ -5185,7 +5189,7 @@ Decl *Sema::BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS,
// an error here // an error here
Diag(Record->getLocation(), diag::err_mutable_nonmember); Diag(Record->getLocation(), diag::err_mutable_nonmember);
Invalid = true; Invalid = true;
SC = SC_None; SC = StorageClass::None;
} }
assert(DS.getAttributes().empty() && "No attribute expected"); assert(DS.getAttributes().empty() && "No attribute expected");
@ -6846,21 +6850,21 @@ NamedDecl *Sema::ActOnVariableDeclarator(
// dllimport globals without explicit storage class are treated as extern. We // dllimport globals without explicit storage class are treated as extern. We
// have to change the storage class this early to get the right DeclContext. // have to change the storage class this early to get the right DeclContext.
if (SC == SC_None && !DC->isRecord() && if (SC == StorageClass::None && !DC->isRecord() &&
hasParsedAttr(S, D, ParsedAttr::AT_DLLImport) && hasParsedAttr(S, D, ParsedAttr::AT_DLLImport) &&
!hasParsedAttr(S, D, ParsedAttr::AT_DLLExport)) !hasParsedAttr(S, D, ParsedAttr::AT_DLLExport))
SC = SC_Extern; SC = StorageClass::Extern;
DeclContext *OriginalDC = DC; DeclContext *OriginalDC = DC;
bool IsLocalExternDecl = SC == SC_Extern && bool IsLocalExternDecl =
adjustContextForLocalExternDecl(DC); SC == StorageClass::Extern && adjustContextForLocalExternDecl(DC);
if (SCSpec == DeclSpec::SCS_mutable) { if (SCSpec == DeclSpec::SCS_mutable) {
// mutable can only appear on non-static class members, so it's always // mutable can only appear on non-static class members, so it's always
// an error here // an error here
Diag(D.getIdentifierLoc(), diag::err_mutable_nonmember); Diag(D.getIdentifierLoc(), diag::err_mutable_nonmember);
D.setInvalidType(); D.setInvalidType();
SC = SC_None; SC = StorageClass::None;
} }
if (getLangOpts().CPlusPlus11 && SCSpec == DeclSpec::SCS_register && if (getLangOpts().CPlusPlus11 && SCSpec == DeclSpec::SCS_register &&
@ -6881,7 +6885,8 @@ NamedDecl *Sema::ActOnVariableDeclarator(
// C99 6.9p2: The storage-class specifiers auto and register shall not // C99 6.9p2: The storage-class specifiers auto and register shall not
// appear in the declaration specifiers in an external declaration. // appear in the declaration specifiers in an external declaration.
// Global Register+Asm is a GNU extension we support. // Global Register+Asm is a GNU extension we support.
if (SC == SC_Auto || (SC == SC_Register && !D.getAsmLabel())) { if (SC == StorageClass::Auto ||
(SC == StorageClass::Register && !D.getAsmLabel())) {
Diag(D.getIdentifierLoc(), diag::err_typecheck_sclass_fscope); Diag(D.getIdentifierLoc(), diag::err_typecheck_sclass_fscope);
D.setInvalidType(); D.setInvalidType();
} }
@ -6920,16 +6925,16 @@ NamedDecl *Sema::ActOnVariableDeclarator(
if (DC->isRecord() && !CurContext->isRecord()) { if (DC->isRecord() && !CurContext->isRecord()) {
// This is an out-of-line definition of a static data member. // This is an out-of-line definition of a static data member.
switch (SC) { switch (SC) {
case SC_None: case StorageClass::None:
break; break;
case SC_Static: case StorageClass::Static:
Diag(D.getDeclSpec().getStorageClassSpecLoc(), Diag(D.getDeclSpec().getStorageClassSpecLoc(),
diag::err_static_out_of_line) diag::err_static_out_of_line)
<< FixItHint::CreateRemoval(D.getDeclSpec().getStorageClassSpecLoc()); << FixItHint::CreateRemoval(D.getDeclSpec().getStorageClassSpecLoc());
break; break;
case SC_Auto: case StorageClass::Auto:
case SC_Register: case StorageClass::Register:
case SC_Extern: case StorageClass::Extern:
// [dcl.stc] p2: The auto or register specifiers shall be applied only // [dcl.stc] p2: The auto or register specifiers shall be applied only
// to names of variables declared in a block or to function parameters. // to names of variables declared in a block or to function parameters.
// [dcl.stc] p6: The extern specifier cannot be used in the declaration // [dcl.stc] p6: The extern specifier cannot be used in the declaration
@ -6939,12 +6944,12 @@ NamedDecl *Sema::ActOnVariableDeclarator(
diag::err_storage_class_for_static_member) diag::err_storage_class_for_static_member)
<< FixItHint::CreateRemoval(D.getDeclSpec().getStorageClassSpecLoc()); << FixItHint::CreateRemoval(D.getDeclSpec().getStorageClassSpecLoc());
break; break;
case SC_PrivateExtern: case StorageClass::PrivateExtern:
llvm_unreachable("C storage class in c++!"); llvm_unreachable("C storage class in c++!");
} }
} }
if (SC == SC_Static && CurContext->isRecord()) { if (SC == StorageClass::Static && CurContext->isRecord()) {
if (const CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(DC)) { if (const CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(DC)) {
// Walk up the enclosing DeclContexts to check for any that are // Walk up the enclosing DeclContexts to check for any that are
// incompatible with static data members. // incompatible with static data members.
@ -7195,7 +7200,7 @@ NamedDecl *Sema::ActOnVariableDeclarator(
// that a local variable with thread storage duration still has to // that a local variable with thread storage duration still has to
// be marked 'static'. Also note that it's possible to get these // be marked 'static'. Also note that it's possible to get these
// semantics in C++ using __attribute__((gnu_inline)). // semantics in C++ using __attribute__((gnu_inline)).
if (SC == SC_Static && S->getFnParent() != nullptr && if (SC == StorageClass::Static && S->getFnParent() != nullptr &&
!NewVD->getType().isConstQualified()) { !NewVD->getType().isConstQualified()) {
FunctionDecl *CurFD = getCurFunctionDecl(); FunctionDecl *CurFD = getCurFunctionDecl();
if (CurFD && isFunctionDefinitionDiscarded(*this, CurFD)) { if (CurFD && isFunctionDefinitionDiscarded(*this, CurFD)) {
@ -7254,10 +7259,10 @@ NamedDecl *Sema::ActOnVariableDeclarator(
targetDiag(D.getIdentifierLoc(), diag::err_thread_unsupported); targetDiag(D.getIdentifierLoc(), diag::err_thread_unsupported);
// CUDA B.2.5: "__shared__ and __constant__ variables have implied static // CUDA B.2.5: "__shared__ and __constant__ variables have implied static
// storage [duration]." // storage [duration]."
if (SC == SC_None && S->getFnParent() != nullptr && if (SC == StorageClass::None && S->getFnParent() != nullptr &&
(NewVD->hasAttr<CUDASharedAttr>() || (NewVD->hasAttr<CUDASharedAttr>() ||
NewVD->hasAttr<CUDAConstantAttr>())) { NewVD->hasAttr<CUDAConstantAttr>())) {
NewVD->setStorageClass(SC_Static); NewVD->setStorageClass(StorageClass::Static);
} }
} }
@ -7266,7 +7271,8 @@ NamedDecl *Sema::ActOnVariableDeclarator(
// check the VarDecl itself. // check the VarDecl itself.
assert(!NewVD->hasAttr<DLLImportAttr>() || assert(!NewVD->hasAttr<DLLImportAttr>() ||
NewVD->getAttr<DLLImportAttr>()->isInherited() || NewVD->getAttr<DLLImportAttr>()->isInherited() ||
NewVD->isStaticDataMember() || NewVD->getStorageClass() != SC_None); NewVD->isStaticDataMember() ||
NewVD->getStorageClass() != StorageClass::None);
// In auto-retain/release, infer strong retension for variables of // In auto-retain/release, infer strong retension for variables of
// retainable type. // retainable type.
@ -7280,22 +7286,22 @@ NamedDecl *Sema::ActOnVariableDeclarator(
StringRef Label = SE->getString(); StringRef Label = SE->getString();
if (S->getFnParent() != nullptr) { if (S->getFnParent() != nullptr) {
switch (SC) { switch (SC) {
case SC_None: case StorageClass::None:
case SC_Auto: case StorageClass::Auto:
Diag(E->getExprLoc(), diag::warn_asm_label_on_auto_decl) << Label; Diag(E->getExprLoc(), diag::warn_asm_label_on_auto_decl) << Label;
break; break;
case SC_Register: case StorageClass::Register:
// Local Named register // Local Named register
if (!Context.getTargetInfo().isValidGCCRegisterName(Label) && if (!Context.getTargetInfo().isValidGCCRegisterName(Label) &&
DeclAttrsMatchCUDAMode(getLangOpts(), getCurFunctionDecl())) DeclAttrsMatchCUDAMode(getLangOpts(), getCurFunctionDecl()))
Diag(E->getExprLoc(), diag::err_asm_unknown_register_name) << Label; Diag(E->getExprLoc(), diag::err_asm_unknown_register_name) << Label;
break; break;
case SC_Static: case StorageClass::Static:
case SC_Extern: case StorageClass::Extern:
case SC_PrivateExtern: case StorageClass::PrivateExtern:
break; break;
} }
} else if (SC == SC_Register) { } else if (SC == StorageClass::Register) {
// Global Named register // Global Named register
if (DeclAttrsMatchCUDAMode(getLangOpts(), NewVD)) { if (DeclAttrsMatchCUDAMode(getLangOpts(), NewVD)) {
const auto &TI = Context.getTargetInfo(); const auto &TI = Context.getTargetInfo();
@ -8389,8 +8395,8 @@ static StorageClass getFunctionStorageClass(Sema &SemaRef, Declarator &D) {
case DeclSpec::SCS_unspecified: break; case DeclSpec::SCS_unspecified: break;
case DeclSpec::SCS_extern: case DeclSpec::SCS_extern:
if (D.getDeclSpec().isExternInLinkageSpec()) if (D.getDeclSpec().isExternInLinkageSpec())
return SC_None; return StorageClass::None;
return SC_Extern; return StorageClass::Extern;
case DeclSpec::SCS_static: { case DeclSpec::SCS_static: {
if (SemaRef.CurContext->getRedeclContext()->isFunctionOrMethod()) { if (SemaRef.CurContext->getRedeclContext()->isFunctionOrMethod()) {
// C99 6.7.1p5: // C99 6.7.1p5:
@ -8402,13 +8408,14 @@ static StorageClass getFunctionStorageClass(Sema &SemaRef, Declarator &D) {
diag::err_static_block_func); diag::err_static_block_func);
break; break;
} else } else
return SC_Static; return StorageClass::Static;
} }
case DeclSpec::SCS_private_extern: return SC_PrivateExtern; case DeclSpec::SCS_private_extern:
return StorageClass::PrivateExtern;
} }
// No explicit storage class has already been returned // No explicit storage class has already been returned
return SC_None; return StorageClass::None;
} }
static FunctionDecl *CreateNewFunctionDecl(Sema &SemaRef, Declarator &D, static FunctionDecl *CreateNewFunctionDecl(Sema &SemaRef, Declarator &D,
@ -9210,7 +9217,7 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC,
NewFD->setImplicitlyInline(); NewFD->setImplicitlyInline();
} }
if (SC == SC_Static && isa<CXXMethodDecl>(NewFD) && if (SC == StorageClass::Static && isa<CXXMethodDecl>(NewFD) &&
!CurContext->isRecord()) { !CurContext->isRecord()) {
// C++ [class.static]p1: // C++ [class.static]p1:
// A data or function member of a class may be declared static // A data or function member of a class may be declared static
@ -9540,11 +9547,11 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC,
// specialization (14.7.3) // specialization (14.7.3)
FunctionTemplateSpecializationInfo *Info = FunctionTemplateSpecializationInfo *Info =
NewFD->getTemplateSpecializationInfo(); NewFD->getTemplateSpecializationInfo();
if (Info && SC != SC_None) { if (Info && SC != StorageClass::None) {
if (SC != Info->getTemplate()->getTemplatedDecl()->getStorageClass()) if (SC != Info->getTemplate()->getTemplatedDecl()->getStorageClass())
Diag(NewFD->getLocation(), Diag(NewFD->getLocation(),
diag::err_explicit_specialization_inconsistent_storage_class) diag::err_explicit_specialization_inconsistent_storage_class)
<< SC << static_cast<int>(SC)
<< FixItHint::CreateRemoval( << FixItHint::CreateRemoval(
D.getDeclSpec().getStorageClassSpecLoc()); D.getDeclSpec().getStorageClassSpecLoc());
@ -9803,8 +9810,7 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC,
if (getLangOpts().OpenCL && NewFD->hasAttr<OpenCLKernelAttr>()) { if (getLangOpts().OpenCL && NewFD->hasAttr<OpenCLKernelAttr>()) {
// OpenCL v1.2 s6.8 static is invalid for kernel functions. // OpenCL v1.2 s6.8 static is invalid for kernel functions.
if ((getLangOpts().OpenCLVersion >= 120) if ((getLangOpts().OpenCLVersion >= 120) && (SC == StorageClass::Static)) {
&& (SC == SC_Static)) {
Diag(D.getIdentifierLoc(), diag::err_static_kernel); Diag(D.getIdentifierLoc(), diag::err_static_kernel);
D.setInvalidType(); D.setInvalidType();
} }
@ -11000,7 +11006,7 @@ void Sema::CheckMain(FunctionDecl* FD, const DeclSpec& DS) {
// appear in a declaration of main. // appear in a declaration of main.
// static main is not an error under C99, but we should warn about it. // static main is not an error under C99, but we should warn about it.
// We accept _Noreturn main as an extension. // We accept _Noreturn main as an extension.
if (FD->getStorageClass() == SC_Static) if (FD->getStorageClass() == StorageClass::Static)
Diag(DS.getStorageClassSpecLoc(), getLangOpts().CPlusPlus Diag(DS.getStorageClassSpecLoc(), getLangOpts().CPlusPlus
? diag::err_static_main : diag::warn_static_main) ? diag::err_static_main : diag::warn_static_main)
<< FixItHint::CreateRemoval(DS.getStorageClassSpecLoc()); << FixItHint::CreateRemoval(DS.getStorageClassSpecLoc());
@ -12255,7 +12261,7 @@ void Sema::AddInitializerToDecl(Decl *RealDecl, Expr *Init, bool DirectInit) {
// C99 6.7.8p4: All the expressions in an initializer for an object that has // C99 6.7.8p4: All the expressions in an initializer for an object that has
// static storage duration shall be constant expressions or string literals. // static storage duration shall be constant expressions or string literals.
} else if (VDecl->getStorageClass() == SC_Static) { } else if (VDecl->getStorageClass() == StorageClass::Static) {
CheckForConstantInitializer(Init, DclT); CheckForConstantInitializer(Init, DclT);
// C89 is stricter than C99 for aggregate initializers. // C89 is stricter than C99 for aggregate initializers.
@ -12383,7 +12389,7 @@ void Sema::AddInitializerToDecl(Decl *RealDecl, Expr *Init, bool DirectInit) {
// external linkage, so don't warn in that case. If selectany is present, // external linkage, so don't warn in that case. If selectany is present,
// this might be header code intended for C and C++ inclusion, so apply the // this might be header code intended for C and C++ inclusion, so apply the
// C++ rules. // C++ rules.
if (VDecl->getStorageClass() == SC_Extern && if (VDecl->getStorageClass() == StorageClass::Extern &&
((!getLangOpts().CPlusPlus && !VDecl->hasAttr<SelectAnyAttr>()) || ((!getLangOpts().CPlusPlus && !VDecl->hasAttr<SelectAnyAttr>()) ||
!Context.getBaseElementType(VDecl->getType()).isConstQualified()) && !Context.getBaseElementType(VDecl->getType()).isConstQualified()) &&
!(getLangOpts().CPlusPlus && VDecl->isExternC()) && !(getLangOpts().CPlusPlus && VDecl->isExternC()) &&
@ -12396,7 +12402,7 @@ void Sema::AddInitializerToDecl(Decl *RealDecl, Expr *Init, bool DirectInit) {
if (Context.getTargetInfo().getCXXABI().isMicrosoft() && if (Context.getTargetInfo().getCXXABI().isMicrosoft() &&
getLangOpts().CPlusPlus && VDecl->getType().isConstQualified() && getLangOpts().CPlusPlus && VDecl->getType().isConstQualified() &&
VDecl->hasAttr<DLLExportAttr>() && VDecl->getDefinition()) VDecl->hasAttr<DLLExportAttr>() && VDecl->getDefinition())
VDecl->setStorageClass(SC_Extern); VDecl->setStorageClass(StorageClass::Extern);
// C99 6.7.8p4. All file scoped initializers need to be constant. // C99 6.7.8p4. All file scoped initializers need to be constant.
if (!getLangOpts().CPlusPlus && !VDecl->isInvalidDecl()) if (!getLangOpts().CPlusPlus && !VDecl->isInvalidDecl())
@ -12530,14 +12536,14 @@ void Sema::ActOnUninitializedDecl(Decl *RealDecl) {
// be initialized. // be initialized.
if (!Var->isInvalidDecl() && if (!Var->isInvalidDecl() &&
Var->getType().getAddressSpace() == LangAS::opencl_constant && Var->getType().getAddressSpace() == LangAS::opencl_constant &&
Var->getStorageClass() != SC_Extern && !Var->getInit()) { Var->getStorageClass() != StorageClass::Extern && !Var->getInit()) {
Diag(Var->getLocation(), diag::err_opencl_constant_no_init); Diag(Var->getLocation(), diag::err_opencl_constant_no_init);
Var->setInvalidDecl(); Var->setInvalidDecl();
return; return;
} }
if (!Var->isInvalidDecl() && RealDecl->hasAttr<LoaderUninitializedAttr>()) { if (!Var->isInvalidDecl() && RealDecl->hasAttr<LoaderUninitializedAttr>()) {
if (Var->getStorageClass() == SC_Extern) { if (Var->getStorageClass() == StorageClass::Extern) {
Diag(Var->getLocation(), diag::err_loader_uninitialized_extern_decl) Diag(Var->getLocation(), diag::err_loader_uninitialized_extern_decl)
<< Var; << Var;
Var->setInvalidDecl(); Var->setInvalidDecl();
@ -12594,7 +12600,7 @@ void Sema::ActOnUninitializedDecl(Decl *RealDecl) {
AbstractVariableType)) AbstractVariableType))
Var->setInvalidDecl(); Var->setInvalidDecl();
if (!Type->isDependentType() && !Var->isInvalidDecl() && if (!Type->isDependentType() && !Var->isInvalidDecl() &&
Var->getStorageClass() == SC_PrivateExtern) { Var->getStorageClass() == StorageClass::PrivateExtern) {
Diag(Var->getLocation(), diag::warn_private_extern); Diag(Var->getLocation(), diag::warn_private_extern);
Diag(Var->getLocation(), diag::note_private_extern); Diag(Var->getLocation(), diag::note_private_extern);
} }
@ -12618,7 +12624,7 @@ void Sema::ActOnUninitializedDecl(Decl *RealDecl) {
Var->getLocation(), ArrayT->getElementType(), Var->getLocation(), ArrayT->getElementType(),
diag::err_array_incomplete_or_sizeless_type)) diag::err_array_incomplete_or_sizeless_type))
Var->setInvalidDecl(); Var->setInvalidDecl();
} else if (Var->getStorageClass() == SC_Static) { } else if (Var->getStorageClass() == StorageClass::Static) {
// C99 6.9.2p3: If the declaration of an identifier for an object is // 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 // a tentative definition and has internal linkage (C99 6.2.2p3), the
// declared type shall not be an incomplete type. // declared type shall not be an incomplete type.
@ -12766,21 +12772,21 @@ void Sema::ActOnCXXForRangeDecl(Decl *D) {
// for-range-declaration cannot be given a storage class specifier. // for-range-declaration cannot be given a storage class specifier.
int Error = -1; int Error = -1;
switch (VD->getStorageClass()) { switch (VD->getStorageClass()) {
case SC_None: case StorageClass::None:
break; break;
case SC_Extern: case StorageClass::Extern:
Error = 0; Error = 0;
break; break;
case SC_Static: case StorageClass::Static:
Error = 1; Error = 1;
break; break;
case SC_PrivateExtern: case StorageClass::PrivateExtern:
Error = 2; Error = 2;
break; break;
case SC_Auto: case StorageClass::Auto:
Error = 3; Error = 3;
break; break;
case SC_Register: case StorageClass::Register:
Error = 4; Error = 4;
break; break;
} }
@ -13528,9 +13534,9 @@ Decl *Sema::ActOnParamDeclarator(Scope *S, Declarator &D) {
// Verify C99 6.7.5.3p2: The only SCS allowed is 'register'. // Verify C99 6.7.5.3p2: The only SCS allowed is 'register'.
// C++03 [dcl.stc]p2 also permits 'auto'. // C++03 [dcl.stc]p2 also permits 'auto'.
StorageClass SC = SC_None; StorageClass SC = StorageClass::None;
if (DS.getStorageClassSpec() == DeclSpec::SCS_register) { if (DS.getStorageClassSpec() == DeclSpec::SCS_register) {
SC = SC_Register; SC = StorageClass::Register;
// In C++11, the 'register' storage class specifier is deprecated. // In C++11, the 'register' storage class specifier is deprecated.
// In C++17, it is not allowed, but we tolerate it as an extension. // In C++17, it is not allowed, but we tolerate it as an extension.
if (getLangOpts().CPlusPlus11) { if (getLangOpts().CPlusPlus11) {
@ -13541,7 +13547,7 @@ Decl *Sema::ActOnParamDeclarator(Scope *S, Declarator &D) {
} }
} else if (getLangOpts().CPlusPlus && } else if (getLangOpts().CPlusPlus &&
DS.getStorageClassSpec() == DeclSpec::SCS_auto) { DS.getStorageClassSpec() == DeclSpec::SCS_auto) {
SC = SC_Auto; SC = StorageClass::Auto;
} else if (DS.getStorageClassSpec() != DeclSpec::SCS_unspecified) { } else if (DS.getStorageClassSpec() != DeclSpec::SCS_unspecified) {
Diag(DS.getStorageClassSpecLoc(), Diag(DS.getStorageClassSpecLoc(),
diag::err_invalid_storage_class_in_func_decl); diag::err_invalid_storage_class_in_func_decl);
@ -13635,9 +13641,9 @@ ParmVarDecl *Sema::BuildParmVarDeclForTypedef(DeclContext *DC,
/* FIXME: setting StartLoc == Loc. /* FIXME: setting StartLoc == Loc.
Would it be worth to modify callers so as to provide proper source Would it be worth to modify callers so as to provide proper source
location for the unnamed parameters, embedding the parameter's type? */ location for the unnamed parameters, embedding the parameter's type? */
ParmVarDecl *Param = ParmVarDecl::Create(Context, DC, Loc, Loc, nullptr, ParmVarDecl *Param = ParmVarDecl::Create(
T, Context.getTrivialTypeSourceInfo(T, Loc), Context, DC, Loc, Loc, nullptr, T,
SC_None, nullptr); Context.getTrivialTypeSourceInfo(T, Loc), StorageClass::None, nullptr);
Param->setImplicit(); Param->setImplicit();
return Param; return Param;
} }
@ -13943,7 +13949,7 @@ Sema::CheckForFunctionRedefinition(FunctionDecl *FD,
} }
if (getLangOpts().GNUMode && Definition->isInlineSpecified() && if (getLangOpts().GNUMode && Definition->isInlineSpecified() &&
Definition->getStorageClass() == SC_Extern) Definition->getStorageClass() == StorageClass::Extern)
Diag(FD->getLocation(), diag::err_redefinition_extern_inline) Diag(FD->getLocation(), diag::err_redefinition_extern_inline)
<< FD << getLangOpts().CPlusPlus; << FD << getLangOpts().CPlusPlus;
else else
@ -14441,7 +14447,7 @@ Decl *Sema::ActOnFinishFunctionBody(Decl *dcl, Stmt *Body,
}; };
Diag(FD->getTypeSpecStartLoc(), diag::note_static_for_internal_linkage) Diag(FD->getTypeSpecStartLoc(), diag::note_static_for_internal_linkage)
<< /* function */ 1 << /* function */ 1
<< (FD->getStorageClass() == SC_None << (FD->getStorageClass() == StorageClass::None
? FixItHint::CreateInsertion(findBeginLoc(), "static ") ? FixItHint::CreateInsertion(findBeginLoc(), "static ")
: FixItHint{}); : FixItHint{});
} }

View File

@ -3919,7 +3919,7 @@ void Sema::AddAlignedAttr(Decl *D, const AttributeCommonInfo &CI, Expr *E,
if (isa<ParmVarDecl>(D)) { if (isa<ParmVarDecl>(D)) {
DiagKind = 0; DiagKind = 0;
} else if (const auto *VD = dyn_cast<VarDecl>(D)) { } else if (const auto *VD = dyn_cast<VarDecl>(D)) {
if (VD->getStorageClass() == SC_Register) if (VD->getStorageClass() == StorageClass::Register)
DiagKind = 1; DiagKind = 1;
if (VD->isExceptionVariable()) if (VD->isExceptionVariable())
DiagKind = 2; DiagKind = 2;
@ -4559,7 +4559,7 @@ static void handleGNUInlineAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
return; return;
} }
if (S.LangOpts.CPlusPlus && Fn->getStorageClass() != SC_Extern) if (S.LangOpts.CPlusPlus && Fn->getStorageClass() != StorageClass::Extern)
S.Diag(AL.getLoc(), diag::warn_gnu_inline_cplusplus_without_extern); S.Diag(AL.getLoc(), diag::warn_gnu_inline_cplusplus_without_extern);
D->addAttr(::new (S.Context) GNUInlineAttr(S.Context, AL)); D->addAttr(::new (S.Context) GNUInlineAttr(S.Context, AL));
@ -8350,8 +8350,8 @@ NamedDecl * Sema::DeclClonePragmaWeak(NamedDecl *ND, IdentifierInfo *II,
// FIXME: Is the DeclContext correct? // FIXME: Is the DeclContext correct?
NewFD = FunctionDecl::Create( NewFD = FunctionDecl::Create(
FD->getASTContext(), FD->getDeclContext(), Loc, Loc, FD->getASTContext(), FD->getDeclContext(), Loc, Loc,
DeclarationName(II), FD->getType(), FD->getTypeSourceInfo(), SC_None, DeclarationName(II), FD->getType(), FD->getTypeSourceInfo(),
false /*isInlineSpecified*/, FD->hasPrototype(), StorageClass::None, false /*isInlineSpecified*/, FD->hasPrototype(),
ConstexprSpecKind::Unspecified, FD->getTrailingRequiresClause()); ConstexprSpecKind::Unspecified, FD->getTrailingRequiresClause());
NewD = NewFD; NewD = NewFD;

View File

@ -5889,7 +5889,7 @@ static void ReferenceDllExportedMembers(Sema &S, CXXRecordDecl *Class) {
// class must be marked export too. // class must be marked export too.
auto *VD = dyn_cast<VarDecl>(Member); auto *VD = dyn_cast<VarDecl>(Member);
if (VD && Member->getAttr<DLLExportAttr>() && if (VD && Member->getAttr<DLLExportAttr>() &&
VD->getStorageClass() == SC_Static && VD->getStorageClass() == StorageClass::Static &&
TSK == TSK_ImplicitInstantiation) TSK == TSK_ImplicitInstantiation)
S.MarkVariableReferenced(VD->getLocation(), VD); S.MarkVariableReferenced(VD->getLocation(), VD);
@ -6669,7 +6669,7 @@ void Sema::CheckCompletedCXXClass(Scope *S, CXXRecordDecl *Record) {
// ...). // ...).
auto CheckCompletedMemberFunction = [&](CXXMethodDecl *MD) { auto CheckCompletedMemberFunction = [&](CXXMethodDecl *MD) {
// A static function cannot override anything. // A static function cannot override anything.
if (MD->getStorageClass() == SC_Static) { if (MD->getStorageClass() == StorageClass::Static) {
if (ReportOverrides(*this, diag::err_static_overrides_virtual, MD, if (ReportOverrides(*this, diag::err_static_overrides_virtual, MD,
[](const CXXMethodDecl *) { return true; })) [](const CXXMethodDecl *) { return true; }))
return; return;
@ -8092,7 +8092,7 @@ private:
} }
VarDecl *IterationVar = VarDecl::Create( VarDecl *IterationVar = VarDecl::Create(
S.Context, S.CurContext, Loc, Loc, IterationVarName, SizeType, S.Context, S.CurContext, Loc, Loc, IterationVarName, SizeType,
S.Context.getTrivialTypeSourceInfo(SizeType, Loc), SC_None); S.Context.getTrivialTypeSourceInfo(SizeType, Loc), StorageClass::None);
llvm::APInt Zero(S.Context.getTypeSize(SizeType), 0); llvm::APInt Zero(S.Context.getTypeSize(SizeType), 0);
IterationVar->setInit( IterationVar->setInit(
IntegerLiteral::Create(S.Context, Zero, SizeType, Loc)); IntegerLiteral::Create(S.Context, Zero, SizeType, Loc));
@ -8191,9 +8191,9 @@ private:
// R cmp = ...; // R cmp = ...;
IdentifierInfo *Name = &S.Context.Idents.get("cmp"); IdentifierInfo *Name = &S.Context.Idents.get("cmp");
VarDecl *VD = VarDecl *VD = VarDecl::Create(S.Context, S.CurContext, Loc, Loc, Name, R,
VarDecl::Create(S.Context, S.CurContext, Loc, Loc, Name, R, S.Context.getTrivialTypeSourceInfo(R, Loc),
S.Context.getTrivialTypeSourceInfo(R, Loc), SC_None); StorageClass::None);
S.AddInitializerToDecl(VD, Op.get(), /*DirectInit=*/false); S.AddInitializerToDecl(VD, Op.get(), /*DirectInit=*/false);
Stmt *InitStmt = new (S.Context) DeclStmt(DeclGroupRef(VD), Loc, Loc); Stmt *InitStmt = new (S.Context) DeclStmt(DeclGroupRef(VD), Loc, Loc);
@ -10186,13 +10186,13 @@ QualType Sema::CheckConstructorDeclarator(Declarator &D, QualType R,
<< SourceRange(D.getIdentifierLoc()); << SourceRange(D.getIdentifierLoc());
D.setInvalidType(); D.setInvalidType();
} }
if (SC == SC_Static) { if (SC == StorageClass::Static) {
if (!D.isInvalidType()) if (!D.isInvalidType())
Diag(D.getIdentifierLoc(), diag::err_constructor_cannot_be) Diag(D.getIdentifierLoc(), diag::err_constructor_cannot_be)
<< "static" << SourceRange(D.getDeclSpec().getStorageClassSpecLoc()) << "static" << SourceRange(D.getDeclSpec().getStorageClassSpecLoc())
<< SourceRange(D.getIdentifierLoc()); << SourceRange(D.getIdentifierLoc());
D.setInvalidType(); D.setInvalidType();
SC = SC_None; SC = StorageClass::None;
} }
if (unsigned TypeQuals = D.getDeclSpec().getTypeQualifiers()) { if (unsigned TypeQuals = D.getDeclSpec().getTypeQualifiers()) {
@ -10348,14 +10348,14 @@ QualType Sema::CheckDestructorDeclarator(Declarator &D, QualType R,
// destructor can be invoked for a const, volatile or const // destructor can be invoked for a const, volatile or const
// volatile object. A destructor shall not be declared const, // volatile object. A destructor shall not be declared const,
// volatile or const volatile (9.3.2). // volatile or const volatile (9.3.2).
if (SC == SC_Static) { if (SC == StorageClass::Static) {
if (!D.isInvalidType()) if (!D.isInvalidType())
Diag(D.getIdentifierLoc(), diag::err_destructor_cannot_be) Diag(D.getIdentifierLoc(), diag::err_destructor_cannot_be)
<< "static" << SourceRange(D.getDeclSpec().getStorageClassSpecLoc()) << "static" << SourceRange(D.getDeclSpec().getStorageClassSpecLoc())
<< SourceRange(D.getIdentifierLoc()) << SourceRange(D.getIdentifierLoc())
<< FixItHint::CreateRemoval(D.getDeclSpec().getStorageClassSpecLoc()); << FixItHint::CreateRemoval(D.getDeclSpec().getStorageClassSpecLoc());
SC = SC_None; SC = StorageClass::None;
} }
if (!D.isInvalidType()) { if (!D.isInvalidType()) {
// Destructors don't have return types, but the parser will // Destructors don't have return types, but the parser will
@ -10451,13 +10451,13 @@ void Sema::CheckConversionDeclarator(Declarator &D, QualType &R,
// Neither parameter types nor return type can be specified. The // Neither parameter types nor return type can be specified. The
// type of a conversion function (8.3.5) is "function taking no // type of a conversion function (8.3.5) is "function taking no
// parameter returning conversion-type-id." // parameter returning conversion-type-id."
if (SC == SC_Static) { if (SC == StorageClass::Static) {
if (!D.isInvalidType()) if (!D.isInvalidType())
Diag(D.getIdentifierLoc(), diag::err_conv_function_not_member) Diag(D.getIdentifierLoc(), diag::err_conv_function_not_member)
<< SourceRange(D.getDeclSpec().getStorageClassSpecLoc()) << SourceRange(D.getDeclSpec().getStorageClassSpecLoc())
<< D.getName().getSourceRange(); << D.getName().getSourceRange();
D.setInvalidType(); D.setInvalidType();
SC = SC_None; SC = StorageClass::None;
} }
TypeSourceInfo *ConvTSI = nullptr; TypeSourceInfo *ConvTSI = nullptr;
@ -10714,7 +10714,7 @@ void Sema::CheckDeductionGuideDeclarator(Declarator &D, QualType &R,
Diagnoser.check(DS.getStorageClassSpecLoc(), DS.getStorageClassSpec()); Diagnoser.check(DS.getStorageClassSpecLoc(), DS.getStorageClassSpec());
DS.ClearStorageClassSpecs(); DS.ClearStorageClassSpecs();
SC = SC_None; SC = StorageClass::None;
// 'explicit' is permitted. // 'explicit' is permitted.
Diagnoser.check(DS.getInlineSpecLoc(), "inline"); Diagnoser.check(DS.getInlineSpecLoc(), "inline");
@ -13129,7 +13129,7 @@ Sema::findInheritingConstructor(SourceLocation Loc,
Context.getTrivialTypeSourceInfo(FPT->getParamType(I), UsingLoc); Context.getTrivialTypeSourceInfo(FPT->getParamType(I), UsingLoc);
ParmVarDecl *PD = ParmVarDecl::Create( ParmVarDecl *PD = ParmVarDecl::Create(
Context, DerivedCtor, UsingLoc, UsingLoc, /*IdentifierInfo=*/nullptr, Context, DerivedCtor, UsingLoc, UsingLoc, /*IdentifierInfo=*/nullptr,
FPT->getParamType(I), TInfo, SC_None, /*DefArg=*/nullptr); FPT->getParamType(I), TInfo, StorageClass::None, /*DefArg=*/nullptr);
PD->setScopeInfo(0, I); PD->setScopeInfo(0, I);
PD->setImplicit(); PD->setImplicit();
// Ensure attributes are propagated onto parameters (this matters for // Ensure attributes are propagated onto parameters (this matters for
@ -13788,10 +13788,9 @@ buildSingleCopyAssignRecursively(Sema &S, SourceLocation Loc, QualType T,
OS << "__i" << Depth; OS << "__i" << Depth;
IterationVarName = &S.Context.Idents.get(OS.str()); IterationVarName = &S.Context.Idents.get(OS.str());
} }
VarDecl *IterationVar = VarDecl::Create(S.Context, S.CurContext, Loc, Loc, VarDecl *IterationVar = VarDecl::Create(
IterationVarName, SizeType, S.Context, S.CurContext, Loc, Loc, IterationVarName, SizeType,
S.Context.getTrivialTypeSourceInfo(SizeType, Loc), S.Context.getTrivialTypeSourceInfo(SizeType, Loc), StorageClass::None);
SC_None);
// Initialize the iteration variable to zero. // Initialize the iteration variable to zero.
llvm::APInt Zero(S.Context.getTypeSize(SizeType), 0); llvm::APInt Zero(S.Context.getTypeSize(SizeType), 0);
@ -13900,7 +13899,7 @@ CXXMethodDecl *Sema::DeclareImplicitCopyAssignment(CXXRecordDecl *ClassDecl) {
DeclarationNameInfo NameInfo(Name, ClassLoc); DeclarationNameInfo NameInfo(Name, ClassLoc);
CXXMethodDecl *CopyAssignment = CXXMethodDecl::Create( CXXMethodDecl *CopyAssignment = CXXMethodDecl::Create(
Context, ClassDecl, ClassLoc, NameInfo, QualType(), Context, ClassDecl, ClassLoc, NameInfo, QualType(),
/*TInfo=*/nullptr, /*StorageClass=*/SC_None, /*TInfo=*/nullptr, /*StorageClass=*/StorageClass::None,
/*isInline=*/true, /*isInline=*/true,
Constexpr ? ConstexprSpecKind::Constexpr : ConstexprSpecKind::Unspecified, Constexpr ? ConstexprSpecKind::Constexpr : ConstexprSpecKind::Unspecified,
SourceLocation()); SourceLocation());
@ -13918,11 +13917,10 @@ CXXMethodDecl *Sema::DeclareImplicitCopyAssignment(CXXRecordDecl *ClassDecl) {
setupImplicitSpecialMemberType(CopyAssignment, RetType, ArgType); setupImplicitSpecialMemberType(CopyAssignment, RetType, ArgType);
// Add the parameter to the operator. // Add the parameter to the operator.
ParmVarDecl *FromParam = ParmVarDecl::Create(Context, CopyAssignment, ParmVarDecl *FromParam =
ClassLoc, ClassLoc, ParmVarDecl::Create(Context, CopyAssignment, ClassLoc, ClassLoc,
/*Id=*/nullptr, ArgType, /*Id=*/nullptr, ArgType,
/*TInfo=*/nullptr, SC_None, /*TInfo=*/nullptr, StorageClass::None, nullptr);
nullptr);
CopyAssignment->setParams(FromParam); CopyAssignment->setParams(FromParam);
CopyAssignment->setTrivial( CopyAssignment->setTrivial(
@ -14226,7 +14224,7 @@ CXXMethodDecl *Sema::DeclareImplicitMoveAssignment(CXXRecordDecl *ClassDecl) {
DeclarationNameInfo NameInfo(Name, ClassLoc); DeclarationNameInfo NameInfo(Name, ClassLoc);
CXXMethodDecl *MoveAssignment = CXXMethodDecl::Create( CXXMethodDecl *MoveAssignment = CXXMethodDecl::Create(
Context, ClassDecl, ClassLoc, NameInfo, QualType(), Context, ClassDecl, ClassLoc, NameInfo, QualType(),
/*TInfo=*/nullptr, /*StorageClass=*/SC_None, /*TInfo=*/nullptr, /*StorageClass=*/StorageClass::None,
/*isInline=*/true, /*isInline=*/true,
Constexpr ? ConstexprSpecKind::Constexpr : ConstexprSpecKind::Unspecified, Constexpr ? ConstexprSpecKind::Constexpr : ConstexprSpecKind::Unspecified,
SourceLocation()); SourceLocation());
@ -14247,11 +14245,10 @@ CXXMethodDecl *Sema::DeclareImplicitMoveAssignment(CXXRecordDecl *ClassDecl) {
MoveAssignment->setType(Context.getFunctionType(RetType, ArgType, EPI)); MoveAssignment->setType(Context.getFunctionType(RetType, ArgType, EPI));
// Add the parameter to the operator. // Add the parameter to the operator.
ParmVarDecl *FromParam = ParmVarDecl::Create(Context, MoveAssignment, ParmVarDecl *FromParam =
ClassLoc, ClassLoc, ParmVarDecl::Create(Context, MoveAssignment, ClassLoc, ClassLoc,
/*Id=*/nullptr, ArgType, /*Id=*/nullptr, ArgType,
/*TInfo=*/nullptr, SC_None, /*TInfo=*/nullptr, StorageClass::None, nullptr);
nullptr);
MoveAssignment->setParams(FromParam); MoveAssignment->setParams(FromParam);
MoveAssignment->setTrivial( MoveAssignment->setTrivial(
@ -14627,11 +14624,10 @@ CXXConstructorDecl *Sema::DeclareImplicitCopyConstructor(
setupImplicitSpecialMemberType(CopyConstructor, Context.VoidTy, ArgType); setupImplicitSpecialMemberType(CopyConstructor, Context.VoidTy, ArgType);
// Add the parameter to the constructor. // Add the parameter to the constructor.
ParmVarDecl *FromParam = ParmVarDecl::Create(Context, CopyConstructor, ParmVarDecl *FromParam =
ClassLoc, ClassLoc, ParmVarDecl::Create(Context, CopyConstructor, ClassLoc, ClassLoc,
/*IdentifierInfo=*/nullptr, /*IdentifierInfo=*/nullptr, ArgType,
ArgType, /*TInfo=*/nullptr, /*TInfo=*/nullptr, StorageClass::None, nullptr);
SC_None, nullptr);
CopyConstructor->setParams(FromParam); CopyConstructor->setParams(FromParam);
CopyConstructor->setTrivial( CopyConstructor->setTrivial(
@ -14761,11 +14757,10 @@ CXXConstructorDecl *Sema::DeclareImplicitMoveConstructor(
setupImplicitSpecialMemberType(MoveConstructor, Context.VoidTy, ArgType); setupImplicitSpecialMemberType(MoveConstructor, Context.VoidTy, ArgType);
// Add the parameter to the constructor. // Add the parameter to the constructor.
ParmVarDecl *FromParam = ParmVarDecl::Create(Context, MoveConstructor, ParmVarDecl *FromParam =
ClassLoc, ClassLoc, ParmVarDecl::Create(Context, MoveConstructor, ClassLoc, ClassLoc,
/*IdentifierInfo=*/nullptr, /*IdentifierInfo=*/nullptr, ArgType,
ArgType, /*TInfo=*/nullptr, /*TInfo=*/nullptr, StorageClass::None, nullptr);
SC_None, nullptr);
MoveConstructor->setParams(FromParam); MoveConstructor->setParams(FromParam);
MoveConstructor->setTrivial( MoveConstructor->setTrivial(
@ -15249,7 +15244,7 @@ CheckOperatorNewDeleteDeclarationScope(Sema &SemaRef,
} }
if (isa<TranslationUnitDecl>(DC) && if (isa<TranslationUnitDecl>(DC) &&
FnDecl->getStorageClass() == SC_Static) { FnDecl->getStorageClass() == StorageClass::Static) {
return SemaRef.Diag(FnDecl->getLocation(), return SemaRef.Diag(FnDecl->getLocation(),
diag::err_operator_new_delete_declared_static) diag::err_operator_new_delete_declared_static)
<< FnDecl->getDeclName(); << FnDecl->getDeclName();
@ -15906,7 +15901,7 @@ VarDecl *Sema::BuildExceptionDeclaration(Scope *S,
} }
VarDecl *ExDecl = VarDecl::Create(Context, CurContext, StartLoc, Loc, Name, VarDecl *ExDecl = VarDecl::Create(Context, CurContext, StartLoc, Loc, Name,
ExDeclType, TInfo, SC_None); ExDeclType, TInfo, StorageClass::None);
ExDecl->setExceptionVariable(true); ExDecl->setExceptionVariable(true);
// In ARC, infer 'retaining' for variables of retainable type. // In ARC, infer 'retaining' for variables of retainable type.
@ -16919,7 +16914,7 @@ bool Sema::CheckOverridingFunctionAttributes(const CXXMethodDecl *New,
// suppress the calling convention mismatch error; the error about static // suppress the calling convention mismatch error; the error about static
// function override (err_static_overrides_virtual from // function override (err_static_overrides_virtual from
// Sema::CheckFunctionDeclaration) is more clear. // Sema::CheckFunctionDeclaration) is more clear.
if (New->getStorageClass() == SC_Static) if (New->getStorageClass() == StorageClass::Static)
return false; return false;
Diag(New->getLocation(), Diag(New->getLocation(),

View File

@ -4773,9 +4773,9 @@ Decl *Sema::ActOnMethodDeclaration(
? DI->getTypeLoc().getBeginLoc() ? DI->getTypeLoc().getBeginLoc()
: ArgInfo[i].NameLoc; : ArgInfo[i].NameLoc;
ParmVarDecl* Param = CheckParameter(ObjCMethod, StartLoc, ParmVarDecl *Param =
ArgInfo[i].NameLoc, ArgInfo[i].Name, CheckParameter(ObjCMethod, StartLoc, ArgInfo[i].NameLoc,
ArgType, DI, SC_None); ArgInfo[i].Name, ArgType, DI, StorageClass::None);
Param->setObjCMethodScopeInfo(i); Param->setObjCMethodScopeInfo(i);
@ -5145,8 +5145,8 @@ VarDecl *Sema::BuildObjCExceptionDecl(TypeSourceInfo *TInfo, QualType T,
Diag(IdLoc, diag::err_catch_param_not_objc_type); Diag(IdLoc, diag::err_catch_param_not_objc_type);
} }
VarDecl *New = VarDecl::Create(Context, CurContext, StartLoc, IdLoc, Id, VarDecl *New = VarDecl::Create(Context, CurContext, StartLoc, IdLoc, Id, T,
T, TInfo, SC_None); TInfo, StorageClass::None);
New->setExceptionVariable(true); New->setExceptionVariable(true);
// In ARC, infer 'retaining' for variables of retainable type. // In ARC, infer 'retaining' for variables of retainable type.

View File

@ -126,7 +126,7 @@ void Sema::NoteDeletedFunction(FunctionDecl *Decl) {
/// explicit storage class. /// explicit storage class.
static bool hasAnyExplicitStorageClass(const FunctionDecl *D) { static bool hasAnyExplicitStorageClass(const FunctionDecl *D) {
for (auto I : D->redecls()) { for (auto I : D->redecls()) {
if (I->getStorageClass() != SC_None) if (I->getStorageClass() != StorageClass::None)
return true; return true;
} }
return false; return false;
@ -5161,7 +5161,7 @@ ExprResult Sema::ActOnOMPIteratorExpr(Scope *S, SourceLocation IteratorKwLoc,
// Always try to create iterator declarator to avoid extra error messages // Always try to create iterator declarator to avoid extra error messages
// about unknown declarations use. // about unknown declarations use.
auto *VD = VarDecl::Create(Context, CurContext, StartLoc, D.DeclIdentLoc, auto *VD = VarDecl::Create(Context, CurContext, StartLoc, D.DeclIdentLoc,
D.DeclIdent, DeclTy, TInfo, SC_None); D.DeclIdent, DeclTy, TInfo, StorageClass::None);
VD->setImplicit(); VD->setImplicit();
if (S) { if (S) {
// Check for conflicting previous declaration. // Check for conflicting previous declaration.
@ -5326,7 +5326,7 @@ ExprResult Sema::ActOnOMPIteratorExpr(Scope *S, SourceLocation IteratorKwLoc,
auto *CounterVD = auto *CounterVD =
VarDecl::Create(Context, CurContext, D.IteratorDecl->getBeginLoc(), VarDecl::Create(Context, CurContext, D.IteratorDecl->getBeginLoc(),
D.IteratorDecl->getBeginLoc(), nullptr, D.IteratorDecl->getBeginLoc(), nullptr,
Res.get()->getType(), nullptr, SC_None); Res.get()->getType(), nullptr, StorageClass::None);
CounterVD->setImplicit(); CounterVD->setImplicit();
ExprResult RefRes = ExprResult RefRes =
BuildDeclRefExpr(CounterVD, CounterVD->getType(), VK_LValue, BuildDeclRefExpr(CounterVD, CounterVD->getType(), VK_LValue,
@ -6177,13 +6177,10 @@ static FunctionDecl *rewriteBuiltinFunctionDecl(Sema *Sema, ASTContext &Context,
QualType OverloadTy = Context.getFunctionType(FT->getReturnType(), QualType OverloadTy = Context.getFunctionType(FT->getReturnType(),
OverloadParams, EPI); OverloadParams, EPI);
DeclContext *Parent = FDecl->getParent(); DeclContext *Parent = FDecl->getParent();
FunctionDecl *OverloadDecl = FunctionDecl::Create(Context, Parent, FunctionDecl *OverloadDecl = FunctionDecl::Create(
FDecl->getLocation(), Context, Parent, FDecl->getLocation(), FDecl->getLocation(),
FDecl->getLocation(), FDecl->getIdentifier(), OverloadTy,
FDecl->getIdentifier(), /*TInfo=*/nullptr, StorageClass::Extern, false,
OverloadTy,
/*TInfo=*/nullptr,
SC_Extern, false,
/*hasPrototype=*/true); /*hasPrototype=*/true);
SmallVector<ParmVarDecl*, 16> Params; SmallVector<ParmVarDecl*, 16> Params;
FT = cast<FunctionProtoType>(OverloadTy); FT = cast<FunctionProtoType>(OverloadTy);
@ -6192,7 +6189,7 @@ static FunctionDecl *rewriteBuiltinFunctionDecl(Sema *Sema, ASTContext &Context,
ParmVarDecl *Parm = ParmVarDecl *Parm =
ParmVarDecl::Create(Context, OverloadDecl, SourceLocation(), ParmVarDecl::Create(Context, OverloadDecl, SourceLocation(),
SourceLocation(), nullptr, ParamType, SourceLocation(), nullptr, ParamType,
/*TInfo=*/nullptr, SC_None, nullptr); /*TInfo=*/nullptr, StorageClass::None, nullptr);
Parm->setScopeInfo(0, i); Parm->setScopeInfo(0, i);
Params.push_back(Parm); Params.push_back(Parm);
} }
@ -13461,7 +13458,7 @@ QualType Sema::CheckAddressOfOperand(ExprResult &OrigOp, SourceLocation OpLoc) {
if (const VarDecl *vd = dyn_cast<VarDecl>(dcl)) { if (const VarDecl *vd = dyn_cast<VarDecl>(dcl)) {
// in C++ it is not error to take address of a register // in C++ it is not error to take address of a register
// variable (c++03 7.1.1P3) // variable (c++03 7.1.1P3)
if (vd->getStorageClass() == SC_Register && if (vd->getStorageClass() == StorageClass::Register &&
!getLangOpts().CPlusPlus) { !getLangOpts().CPlusPlus) {
AddressOfError = AO_Register_Variable; AddressOfError = AO_Register_Variable;
} }
@ -19089,7 +19086,7 @@ ExprResult RebuildUnknownAnyExpr::resolveDecl(Expr *E, ValueDecl *VD) {
FunctionDecl *NewFD = FunctionDecl::Create( FunctionDecl *NewFD = FunctionDecl::Create(
S.Context, FD->getDeclContext(), Loc, Loc, S.Context, FD->getDeclContext(), Loc, Loc,
FD->getNameInfo().getName(), DestType, FD->getTypeSourceInfo(), FD->getNameInfo().getName(), DestType, FD->getTypeSourceInfo(),
SC_None, false /*isInlineSpecified*/, FD->hasPrototype(), StorageClass::None, false /*isInlineSpecified*/, FD->hasPrototype(),
/*ConstexprKind*/ ConstexprSpecKind::Unspecified); /*ConstexprKind*/ ConstexprSpecKind::Unspecified);
if (FD->getQualifier()) if (FD->getQualifier())

View File

@ -2970,8 +2970,8 @@ void Sema::DeclareGlobalAllocationFunction(DeclarationName Name,
auto CreateAllocationFunctionDecl = [&](Attr *ExtraAttr) { auto CreateAllocationFunctionDecl = [&](Attr *ExtraAttr) {
QualType FnType = Context.getFunctionType(Return, Params, EPI); QualType FnType = Context.getFunctionType(Return, Params, EPI);
FunctionDecl *Alloc = FunctionDecl::Create( FunctionDecl *Alloc = FunctionDecl::Create(
Context, GlobalCtx, SourceLocation(), SourceLocation(), Name, Context, GlobalCtx, SourceLocation(), SourceLocation(), Name, FnType,
FnType, /*TInfo=*/nullptr, SC_None, false, true); /*TInfo=*/nullptr, StorageClass::None, false, true);
Alloc->setImplicit(); Alloc->setImplicit();
// Global allocation functions should always be visible. // Global allocation functions should always be visible.
Alloc->setVisibleDespiteOwningModule(); Alloc->setVisibleDespiteOwningModule();
@ -2985,7 +2985,7 @@ void Sema::DeclareGlobalAllocationFunction(DeclarationName Name,
for (QualType T : Params) { for (QualType T : Params) {
ParamDecls.push_back(ParmVarDecl::Create( ParamDecls.push_back(ParmVarDecl::Create(
Context, Alloc, SourceLocation(), SourceLocation(), nullptr, T, Context, Alloc, SourceLocation(), SourceLocation(), nullptr, T,
/*TInfo=*/nullptr, SC_None, nullptr)); /*TInfo=*/nullptr, StorageClass::None, nullptr));
ParamDecls.back()->setImplicit(); ParamDecls.back()->setImplicit();
} }
Alloc->setParams(ParamDecls); Alloc->setParams(ParamDecls);

View File

@ -293,11 +293,10 @@ static ObjCMethodDecl *getNSNumberFactoryMethod(Sema &S, SourceLocation Loc,
/*isImplicitlyDeclared=*/true, /*isImplicitlyDeclared=*/true,
/*isDefined=*/false, ObjCMethodDecl::Required, /*isDefined=*/false, ObjCMethodDecl::Required,
/*HasRelatedResultType=*/false); /*HasRelatedResultType=*/false);
ParmVarDecl *value = ParmVarDecl::Create(S.Context, Method, ParmVarDecl *value = ParmVarDecl::Create(
SourceLocation(), SourceLocation(), S.Context, Method, SourceLocation(), SourceLocation(),
&CX.Idents.get("value"), &CX.Idents.get("value"), NumberType, /*TInfo=*/nullptr,
NumberType, /*TInfo=*/nullptr, StorageClass::None, nullptr);
SC_None, nullptr);
Method->setMethodParams(S.Context, value, None); Method->setMethodParams(S.Context, value, None);
} }
@ -570,13 +569,11 @@ ExprResult Sema::BuildObjCBoxedExpr(SourceRange SR, Expr *ValueExpr) {
/*isDefined=*/false, ObjCMethodDecl::Required, /*isDefined=*/false, ObjCMethodDecl::Required,
/*HasRelatedResultType=*/false); /*HasRelatedResultType=*/false);
QualType ConstCharType = Context.CharTy.withConst(); QualType ConstCharType = Context.CharTy.withConst();
ParmVarDecl *value = ParmVarDecl *value = ParmVarDecl::Create(
ParmVarDecl::Create(Context, M, Context, M, SourceLocation(), SourceLocation(),
SourceLocation(), SourceLocation(),
&Context.Idents.get("value"), &Context.Idents.get("value"),
Context.getPointerType(ConstCharType), Context.getPointerType(ConstCharType),
/*TInfo=*/nullptr, /*TInfo=*/nullptr, StorageClass::None, nullptr);
SC_None, nullptr);
M->setMethodParams(Context, value, None); M->setMethodParams(Context, value, None);
BoxingMethod = M; BoxingMethod = M;
} }
@ -686,23 +683,17 @@ ExprResult Sema::BuildObjCBoxedExpr(SourceRange SR, Expr *ValueExpr) {
SmallVector<ParmVarDecl *, 2> Params; SmallVector<ParmVarDecl *, 2> Params;
ParmVarDecl *bytes = ParmVarDecl *bytes = ParmVarDecl::Create(
ParmVarDecl::Create(Context, M, Context, M, SourceLocation(), SourceLocation(),
SourceLocation(), SourceLocation(), &Context.Idents.get("bytes"), Context.VoidPtrTy.withConst(),
&Context.Idents.get("bytes"), /*TInfo=*/nullptr, StorageClass::None, nullptr);
Context.VoidPtrTy.withConst(),
/*TInfo=*/nullptr,
SC_None, nullptr);
Params.push_back(bytes); Params.push_back(bytes);
QualType ConstCharType = Context.CharTy.withConst(); QualType ConstCharType = Context.CharTy.withConst();
ParmVarDecl *type = ParmVarDecl *type = ParmVarDecl::Create(
ParmVarDecl::Create(Context, M, Context, M, SourceLocation(), SourceLocation(),
SourceLocation(), SourceLocation(), &Context.Idents.get("type"), Context.getPointerType(ConstCharType),
&Context.Idents.get("type"), /*TInfo=*/nullptr, StorageClass::None, nullptr);
Context.getPointerType(ConstCharType),
/*TInfo=*/nullptr,
SC_None, nullptr);
Params.push_back(type); Params.push_back(type);
M->setMethodParams(Context, Params, None); M->setMethodParams(Context, Params, None);
@ -817,21 +808,15 @@ ExprResult Sema::BuildObjCArrayLiteral(SourceRange SR, MultiExprArg Elements) {
/*isImplicitlyDeclared=*/true, /*isDefined=*/false, /*isImplicitlyDeclared=*/true, /*isDefined=*/false,
ObjCMethodDecl::Required, false); ObjCMethodDecl::Required, false);
SmallVector<ParmVarDecl *, 2> Params; SmallVector<ParmVarDecl *, 2> Params;
ParmVarDecl *objects = ParmVarDecl::Create(Context, Method, ParmVarDecl *objects = ParmVarDecl::Create(
SourceLocation(), Context, Method, SourceLocation(), SourceLocation(),
SourceLocation(), &Context.Idents.get("objects"), Context.getPointerType(IdT),
&Context.Idents.get("objects"), /*TInfo=*/nullptr, StorageClass::None, nullptr);
Context.getPointerType(IdT),
/*TInfo=*/nullptr,
SC_None, nullptr);
Params.push_back(objects); Params.push_back(objects);
ParmVarDecl *cnt = ParmVarDecl::Create(Context, Method, ParmVarDecl *cnt = ParmVarDecl::Create(
SourceLocation(), Context, Method, SourceLocation(), SourceLocation(),
SourceLocation(), &Context.Idents.get("cnt"), Context.UnsignedLongTy,
&Context.Idents.get("cnt"), /*TInfo=*/nullptr, StorageClass::None, nullptr);
Context.UnsignedLongTy,
/*TInfo=*/nullptr, SC_None,
nullptr);
Params.push_back(cnt); Params.push_back(cnt);
Method->setMethodParams(Context, Params, None); Method->setMethodParams(Context, Params, None);
} }
@ -979,29 +964,20 @@ ExprResult Sema::BuildObjCDictionaryLiteral(SourceRange SR,
/*isImplicitlyDeclared=*/true, /*isDefined=*/false, /*isImplicitlyDeclared=*/true, /*isDefined=*/false,
ObjCMethodDecl::Required, false); ObjCMethodDecl::Required, false);
SmallVector<ParmVarDecl *, 3> Params; SmallVector<ParmVarDecl *, 3> Params;
ParmVarDecl *objects = ParmVarDecl::Create(Context, Method, ParmVarDecl *objects = ParmVarDecl::Create(
SourceLocation(), Context, Method, SourceLocation(), SourceLocation(),
SourceLocation(), &Context.Idents.get("objects"), Context.getPointerType(IdT),
&Context.Idents.get("objects"), /*TInfo=*/nullptr, StorageClass::None, nullptr);
Context.getPointerType(IdT),
/*TInfo=*/nullptr, SC_None,
nullptr);
Params.push_back(objects); Params.push_back(objects);
ParmVarDecl *keys = ParmVarDecl::Create(Context, Method, ParmVarDecl *keys = ParmVarDecl::Create(
SourceLocation(), Context, Method, SourceLocation(), SourceLocation(),
SourceLocation(), &Context.Idents.get("keys"), Context.getPointerType(IdT),
&Context.Idents.get("keys"), /*TInfo=*/nullptr, StorageClass::None, nullptr);
Context.getPointerType(IdT),
/*TInfo=*/nullptr, SC_None,
nullptr);
Params.push_back(keys); Params.push_back(keys);
ParmVarDecl *cnt = ParmVarDecl::Create(Context, Method, ParmVarDecl *cnt = ParmVarDecl::Create(
SourceLocation(), Context, Method, SourceLocation(), SourceLocation(),
SourceLocation(), &Context.Idents.get("cnt"), Context.UnsignedLongTy,
&Context.Idents.get("cnt"), /*TInfo=*/nullptr, StorageClass::None, nullptr);
Context.UnsignedLongTy,
/*TInfo=*/nullptr, SC_None,
nullptr);
Params.push_back(cnt); Params.push_back(cnt);
Method->setMethodParams(Context, Params, None); Method->setMethodParams(Context, Params, None);
} }

View File

@ -395,7 +395,7 @@ CXXMethodDecl *Sema::startLambdaDefinition(CXXRecordDecl *Class,
Context, Class, EndLoc, Context, Class, EndLoc,
DeclarationNameInfo(MethodName, IntroducerRange.getBegin(), DeclarationNameInfo(MethodName, IntroducerRange.getBegin(),
MethodNameLoc), MethodNameLoc),
MethodType, MethodTypeInfo, SC_None, MethodType, MethodTypeInfo, StorageClass::None,
/*isInline=*/true, ConstexprKind, EndLoc, TrailingRequiresClause); /*isInline=*/true, ConstexprKind, EndLoc, TrailingRequiresClause);
Method->setAccess(AS_public); Method->setAccess(AS_public);
if (!TemplateParams) if (!TemplateParams)
@ -867,8 +867,8 @@ VarDecl *Sema::createLambdaInitCaptureVarDecl(SourceLocation Loc,
// used as a variable, and only exists as a way to name and refer to the // used as a variable, and only exists as a way to name and refer to the
// init-capture. // init-capture.
// FIXME: Pass in separate source locations for '&' and identifier. // FIXME: Pass in separate source locations for '&' and identifier.
VarDecl *NewVD = VarDecl::Create(Context, CurContext, Loc, VarDecl *NewVD = VarDecl::Create(Context, CurContext, Loc, Loc, Id,
Loc, Id, InitCaptureType, TSI, SC_Auto); InitCaptureType, TSI, StorageClass::Auto);
NewVD->setInitCapture(true); NewVD->setInitCapture(true);
NewVD->setReferenced(true); NewVD->setReferenced(true);
// FIXME: Pass in a VarDecl::InitializationStyle. // FIXME: Pass in a VarDecl::InitializationStyle.
@ -1484,7 +1484,8 @@ static void addFunctionPointerConversion(Sema &S, SourceRange IntroducerRange,
// to the new static invoker parameters - not the call operator's. // to the new static invoker parameters - not the call operator's.
CXXMethodDecl *Invoke = CXXMethodDecl::Create( CXXMethodDecl *Invoke = CXXMethodDecl::Create(
S.Context, Class, Loc, DeclarationNameInfo(InvokerName, Loc), S.Context, Class, Loc, DeclarationNameInfo(InvokerName, Loc),
InvokerFunctionTy, CallOperator->getTypeSourceInfo(), SC_Static, InvokerFunctionTy, CallOperator->getTypeSourceInfo(),
StorageClass::Static,
/*isInline=*/true, ConstexprSpecKind::Unspecified, /*isInline=*/true, ConstexprSpecKind::Unspecified,
CallOperator->getBody()->getEndLoc()); CallOperator->getBody()->getEndLoc());
for (unsigned I = 0, N = CallOperator->getNumParams(); I != N; ++I) for (unsigned I = 0, N = CallOperator->getNumParams(); I != N; ++I)
@ -2008,10 +2009,9 @@ ExprResult Sema::BuildBlockForLambdaConversion(SourceLocation CurrentLocation,
// the lambda object. // the lambda object.
TypeSourceInfo *CapVarTSI = TypeSourceInfo *CapVarTSI =
Context.getTrivialTypeSourceInfo(Src->getType()); Context.getTrivialTypeSourceInfo(Src->getType());
VarDecl *CapVar = VarDecl::Create(Context, Block, ConvLocation, VarDecl *CapVar =
ConvLocation, nullptr, VarDecl::Create(Context, Block, ConvLocation, ConvLocation, nullptr,
Src->getType(), CapVarTSI, Src->getType(), CapVarTSI, StorageClass::None);
SC_None);
BlockDecl::Capture Capture(/*variable=*/CapVar, /*byRef=*/false, BlockDecl::Capture Capture(/*variable=*/CapVar, /*byRef=*/false,
/*nested=*/false, /*copy=*/Init.get()); /*nested=*/false, /*copy=*/Init.get());
Block->setCaptures(Context, Capture, /*CapturesCXXThis=*/false); Block->setCaptures(Context, Capture, /*CapturesCXXThis=*/false);

View File

@ -812,7 +812,7 @@ static void InsertOCLBuiltinDeclarationsFromTable(Sema &S, LookupResult &LR,
for (unsigned Index = 0; Index < GenTypeMaxCnt; Index++) { for (unsigned Index = 0; Index < GenTypeMaxCnt; Index++) {
NewOpenCLBuiltin = FunctionDecl::Create( NewOpenCLBuiltin = FunctionDecl::Create(
Context, Parent, Loc, Loc, II, FunctionList[Index], Context, Parent, Loc, Loc, II, FunctionList[Index],
/*TInfo=*/nullptr, SC_Extern, false, /*TInfo=*/nullptr, StorageClass::Extern, false,
FunctionList[Index]->isFunctionProtoType()); FunctionList[Index]->isFunctionProtoType());
NewOpenCLBuiltin->setImplicit(); NewOpenCLBuiltin->setImplicit();
@ -825,7 +825,7 @@ static void InsertOCLBuiltinDeclarationsFromTable(Sema &S, LookupResult &LR,
ParmVarDecl *Parm = ParmVarDecl::Create( ParmVarDecl *Parm = ParmVarDecl::Create(
Context, NewOpenCLBuiltin, SourceLocation(), SourceLocation(), Context, NewOpenCLBuiltin, SourceLocation(), SourceLocation(),
nullptr, FP->getParamType(IParm), nullptr, FP->getParamType(IParm),
/*TInfo=*/nullptr, SC_None, nullptr); /*TInfo=*/nullptr, StorageClass::None, nullptr);
Parm->setScopeInfo(0, IParm); Parm->setScopeInfo(0, IParm);
ParmList.push_back(Parm); ParmList.push_back(Parm);
} }

View File

@ -2576,13 +2576,9 @@ void Sema::ProcessPropertyDecl(ObjCPropertyDecl *property) {
// Invent the arguments for the setter. We don't bother making a // Invent the arguments for the setter. We don't bother making a
// nice name for the argument. // nice name for the argument.
ParmVarDecl *Argument = ParmVarDecl::Create(Context, SetterMethod, ParmVarDecl *Argument = ParmVarDecl::Create(
Loc, Loc, Context, SetterMethod, Loc, Loc, property->getIdentifier(), paramTy,
property->getIdentifier(), /*TInfo=*/nullptr, StorageClass::None, nullptr);
paramTy,
/*TInfo=*/nullptr,
SC_None,
nullptr);
SetterMethod->setMethodParams(Context, Argument, None); SetterMethod->setMethodParams(Context, Argument, None);
AddPropertyAttrs(*this, SetterMethod, property); AddPropertyAttrs(*this, SetterMethod, property);

View File

@ -1182,7 +1182,8 @@ DSAStackTy::DSAVarData DSAStackTy::getDSA(const_iterator &Iter,
// Variables with automatic storage duration that are declared in a scope // Variables with automatic storage duration that are declared in a scope
// inside the construct are private. // inside the construct are private.
if (VD && isOpenMPLocal(VD, Iter) && VD->isLocalVarDecl() && if (VD && isOpenMPLocal(VD, Iter) && VD->isLocalVarDecl() &&
(VD->getStorageClass() == SC_Auto || VD->getStorageClass() == SC_None)) { (VD->getStorageClass() == StorageClass::Auto ||
VD->getStorageClass() == StorageClass::None)) {
DVar.CKind = OMPC_private; DVar.CKind = OMPC_private;
return DVar; return DVar;
} }
@ -1398,8 +1399,8 @@ static VarDecl *buildVarDecl(Sema &SemaRef, SourceLocation Loc, QualType Type,
DeclContext *DC = SemaRef.CurContext; DeclContext *DC = SemaRef.CurContext;
IdentifierInfo *II = &SemaRef.PP.getIdentifierTable().get(Name); IdentifierInfo *II = &SemaRef.PP.getIdentifierTable().get(Name);
TypeSourceInfo *TInfo = SemaRef.Context.getTrivialTypeSourceInfo(Type, Loc); TypeSourceInfo *TInfo = SemaRef.Context.getTrivialTypeSourceInfo(Type, Loc);
auto *Decl = auto *Decl = VarDecl::Create(SemaRef.Context, DC, Loc, Loc, II, Type, TInfo,
VarDecl::Create(SemaRef.Context, DC, Loc, Loc, II, Type, TInfo, SC_None); StorageClass::None);
if (Attrs) { if (Attrs) {
for (specific_attr_iterator<AlignedAttr> I(Attrs->begin()), E(Attrs->end()); for (specific_attr_iterator<AlignedAttr> I(Attrs->begin()), E(Attrs->end());
I != E; ++I) I != E; ++I)
@ -1623,7 +1624,7 @@ const DSAStackTy::DSAVarData DSAStackTy::getTopDSA(ValueDecl *D,
!(VD->hasAttr<OMPThreadPrivateDeclAttr>() && !(VD->hasAttr<OMPThreadPrivateDeclAttr>() &&
SemaRef.getLangOpts().OpenMPUseTLS && SemaRef.getLangOpts().OpenMPUseTLS &&
SemaRef.getASTContext().getTargetInfo().isTLSSupported())) || SemaRef.getASTContext().getTargetInfo().isTLSSupported())) ||
(VD && VD->getStorageClass() == SC_Register && (VD && VD->getStorageClass() == StorageClass::Register &&
VD->hasAttr<AsmLabelAttr>() && !VD->isLocalVarDecl())) { VD->hasAttr<AsmLabelAttr>() && !VD->isLocalVarDecl())) {
DVar.RefExpr = buildDeclRefExpr( DVar.RefExpr = buildDeclRefExpr(
SemaRef, VD, D->getType().getNonReferenceType(), D->getLocation()); SemaRef, VD, D->getType().getNonReferenceType(), D->getLocation());
@ -2984,8 +2985,8 @@ Sema::CheckOMPThreadPrivateDecl(SourceLocation Loc, ArrayRef<Expr *> VarList) {
!(VD->hasAttr<OMPThreadPrivateDeclAttr>() && !(VD->hasAttr<OMPThreadPrivateDeclAttr>() &&
getLangOpts().OpenMPUseTLS && getLangOpts().OpenMPUseTLS &&
getASTContext().getTargetInfo().isTLSSupported())) || getASTContext().getTargetInfo().isTLSSupported())) ||
(VD->getStorageClass() == SC_Register && VD->hasAttr<AsmLabelAttr>() && (VD->getStorageClass() == StorageClass::Register &&
!VD->isLocalVarDecl())) { VD->hasAttr<AsmLabelAttr>() && !VD->isLocalVarDecl())) {
Diag(ILoc, diag::err_omp_var_thread_local) Diag(ILoc, diag::err_omp_var_thread_local)
<< VD << ((VD->getTLSKind() != VarDecl::TLS_None) ? 0 : 1); << VD << ((VD->getTLSKind() != VarDecl::TLS_None) ? 0 : 1);
bool IsDecl = bool IsDecl =
@ -3138,8 +3139,8 @@ Sema::DeclGroupPtrTy Sema::ActOnOpenMPAllocateDirective(
// Check if this is a TLS variable or global register. // Check if this is a TLS variable or global register.
if (VD->getTLSKind() != VarDecl::TLS_None || if (VD->getTLSKind() != VarDecl::TLS_None ||
VD->hasAttr<OMPThreadPrivateDeclAttr>() || VD->hasAttr<OMPThreadPrivateDeclAttr>() ||
(VD->getStorageClass() == SC_Register && VD->hasAttr<AsmLabelAttr>() && (VD->getStorageClass() == StorageClass::Register &&
!VD->isLocalVarDecl())) VD->hasAttr<AsmLabelAttr>() && !VD->isLocalVarDecl()))
continue; continue;
// If the used several times in the allocate directive, the same allocator // If the used several times in the allocate directive, the same allocator
@ -5984,9 +5985,10 @@ static void setPrototype(Sema &S, FunctionDecl *FD, FunctionDecl *FDWithProto,
FD->setType(NewType); FD->setType(NewType);
SmallVector<ParmVarDecl *, 16> Params; SmallVector<ParmVarDecl *, 16> Params;
for (const ParmVarDecl *P : FDWithProto->parameters()) { for (const ParmVarDecl *P : FDWithProto->parameters()) {
auto *Param = ParmVarDecl::Create(S.getASTContext(), FD, SourceLocation(), auto *Param =
ParmVarDecl::Create(S.getASTContext(), FD, SourceLocation(),
SourceLocation(), nullptr, P->getType(), SourceLocation(), nullptr, P->getType(),
/*TInfo=*/nullptr, SC_None, nullptr); /*TInfo=*/nullptr, StorageClass::None, nullptr);
Param->setScopeInfo(0, Params.size()); Param->setScopeInfo(0, Params.size());
Param->setImplicit(); Param->setImplicit();
Params.push_back(Param); Params.push_back(Param);
@ -18378,7 +18380,7 @@ Sema::ActOnOpenMPDeclareMapperDirectiveVarDecl(Scope *S, QualType MapperType,
Context.getTrivialTypeSourceInfo(MapperType, StartLoc); Context.getTrivialTypeSourceInfo(MapperType, StartLoc);
auto *VD = VarDecl::Create(Context, Context.getTranslationUnitDecl(), auto *VD = VarDecl::Create(Context, Context.getTranslationUnitDecl(),
StartLoc, StartLoc, VN.getAsIdentifierInfo(), StartLoc, StartLoc, VN.getAsIdentifierInfo(),
MapperType, TInfo, SC_None); MapperType, TInfo, StorageClass::None);
if (S) if (S)
PushOnScopeChains(VD, S, /*AddToContext=*/false); PushOnScopeChains(VD, S, /*AddToContext=*/false);
Expr *E = buildDeclRefExpr(*this, VD, MapperType, StartLoc); Expr *E = buildDeclRefExpr(*this, VD, MapperType, StartLoc);

View File

@ -1191,15 +1191,12 @@ bool ObjCSubscriptOpBuilder::findAtIndexGetter() {
/*isSynthesizedAccessorStub=*/false, /*isSynthesizedAccessorStub=*/false,
/*isImplicitlyDeclared=*/true, /*isDefined=*/false, /*isImplicitlyDeclared=*/true, /*isDefined=*/false,
ObjCMethodDecl::Required, false); ObjCMethodDecl::Required, false);
ParmVarDecl *Argument = ParmVarDecl::Create(S.Context, AtIndexGetter, ParmVarDecl *Argument = ParmVarDecl::Create(
SourceLocation(), SourceLocation(), S.Context, AtIndexGetter, SourceLocation(), SourceLocation(),
arrayRef ? &S.Context.Idents.get("index") arrayRef ? &S.Context.Idents.get("index")
: &S.Context.Idents.get("key"), : &S.Context.Idents.get("key"),
arrayRef ? S.Context.UnsignedLongTy arrayRef ? S.Context.UnsignedLongTy : S.Context.getObjCIdType(),
: S.Context.getObjCIdType(), /*TInfo=*/nullptr, StorageClass::None, nullptr);
/*TInfo=*/nullptr,
SC_None,
nullptr);
AtIndexGetter->setMethodParams(S.Context, Argument, None); AtIndexGetter->setMethodParams(S.Context, Argument, None);
} }
@ -1298,23 +1295,17 @@ bool ObjCSubscriptOpBuilder::findAtIndexSetter() {
/*isImplicitlyDeclared=*/true, /*isDefined=*/false, /*isImplicitlyDeclared=*/true, /*isDefined=*/false,
ObjCMethodDecl::Required, false); ObjCMethodDecl::Required, false);
SmallVector<ParmVarDecl *, 2> Params; SmallVector<ParmVarDecl *, 2> Params;
ParmVarDecl *object = ParmVarDecl::Create(S.Context, AtIndexSetter, ParmVarDecl *object = ParmVarDecl::Create(
SourceLocation(), SourceLocation(), S.Context, AtIndexSetter, SourceLocation(), SourceLocation(),
&S.Context.Idents.get("object"), &S.Context.Idents.get("object"), S.Context.getObjCIdType(),
S.Context.getObjCIdType(), /*TInfo=*/nullptr, StorageClass::None, nullptr);
/*TInfo=*/nullptr,
SC_None,
nullptr);
Params.push_back(object); Params.push_back(object);
ParmVarDecl *key = ParmVarDecl::Create(S.Context, AtIndexSetter, ParmVarDecl *key = ParmVarDecl::Create(
SourceLocation(), SourceLocation(), S.Context, AtIndexSetter, SourceLocation(), SourceLocation(),
arrayRef ? &S.Context.Idents.get("index") arrayRef ? &S.Context.Idents.get("index")
: &S.Context.Idents.get("key"), : &S.Context.Idents.get("key"),
arrayRef ? S.Context.UnsignedLongTy arrayRef ? S.Context.UnsignedLongTy : S.Context.getObjCIdType(),
: S.Context.getObjCIdType(), /*TInfo=*/nullptr, StorageClass::None, nullptr);
/*TInfo=*/nullptr,
SC_None,
nullptr);
Params.push_back(key); Params.push_back(key);
AtIndexSetter->setMethodParams(S.Context, Params, None); AtIndexSetter->setMethodParams(S.Context, Params, None);
} }

View File

@ -2122,7 +2122,7 @@ VarDecl *BuildForRangeVarDecl(Sema &SemaRef, SourceLocation Loc,
IdentifierInfo *II = &SemaRef.PP.getIdentifierTable().get(Name); IdentifierInfo *II = &SemaRef.PP.getIdentifierTable().get(Name);
TypeSourceInfo *TInfo = SemaRef.Context.getTrivialTypeSourceInfo(Type, Loc); TypeSourceInfo *TInfo = SemaRef.Context.getTrivialTypeSourceInfo(Type, Loc);
VarDecl *Decl = VarDecl::Create(SemaRef.Context, DC, Loc, Loc, II, Type, VarDecl *Decl = VarDecl::Create(SemaRef.Context, DC, Loc, Loc, II, Type,
TInfo, SC_None); TInfo, StorageClass::None);
Decl->setImplicit(); Decl->setImplicit();
return Decl; return Decl;
} }

View File

@ -195,7 +195,7 @@ static StringRef extractRegisterName(const Expr *Expression,
if (const DeclRefExpr *AsmDeclRef = dyn_cast<DeclRefExpr>(Expression)) { if (const DeclRefExpr *AsmDeclRef = dyn_cast<DeclRefExpr>(Expression)) {
// Handle cases where the expression is a variable // Handle cases where the expression is a variable
const VarDecl *Variable = dyn_cast<VarDecl>(AsmDeclRef->getDecl()); const VarDecl *Variable = dyn_cast<VarDecl>(AsmDeclRef->getDecl());
if (Variable && Variable->getStorageClass() == SC_Register) { if (Variable && Variable->getStorageClass() == StorageClass::Register) {
if (AsmLabelAttr *Attr = Variable->getAttr<AsmLabelAttr>()) if (AsmLabelAttr *Attr = Variable->getAttr<AsmLabelAttr>())
if (Target.isValidGCCRegisterName(Attr->getLabel())) if (Target.isValidGCCRegisterName(Attr->getLabel()))
return Target.getNormalizedGCCRegisterName(Attr->getLabel(), true); return Target.getNormalizedGCCRegisterName(Attr->getLabel(), true);

View File

@ -2218,9 +2218,10 @@ struct ConvertConstructorToDeductionGuideTransform {
// Build the parameters, needed during deduction / substitution. // Build the parameters, needed during deduction / substitution.
SmallVector<ParmVarDecl*, 4> Params; SmallVector<ParmVarDecl*, 4> Params;
for (auto T : ParamTypes) { for (auto T : ParamTypes) {
ParmVarDecl *NewParam = ParmVarDecl::Create( ParmVarDecl *NewParam =
SemaRef.Context, DC, Loc, Loc, nullptr, T, ParmVarDecl::Create(SemaRef.Context, DC, Loc, Loc, nullptr, T,
SemaRef.Context.getTrivialTypeSourceInfo(T, Loc), SC_None, nullptr); SemaRef.Context.getTrivialTypeSourceInfo(T, Loc),
StorageClass::None, nullptr);
NewParam->setScopeInfo(0, Params.size()); NewParam->setScopeInfo(0, Params.size());
FPTL.setParam(Params.size(), NewParam); FPTL.setParam(Params.size(), NewParam);
Params.push_back(NewParam); Params.push_back(NewParam);
@ -4332,7 +4333,8 @@ DeclResult Sema::ActOnVarTemplateSpecialization(
// to the implicit argument list of the primary template. // to the implicit argument list of the primary template.
Diag(TemplateNameLoc, diag::err_partial_spec_args_match_primary_template) Diag(TemplateNameLoc, diag::err_partial_spec_args_match_primary_template)
<< /*variable template*/ 1 << /*variable template*/ 1
<< /*is definition*/(SC != SC_Extern && !CurContext->isRecord()) << /*is definition*/ (SC != StorageClass::Extern &&
!CurContext->isRecord())
<< FixItHint::CreateRemoval(SourceRange(LAngleLoc, RAngleLoc)); << FixItHint::CreateRemoval(SourceRange(LAngleLoc, RAngleLoc));
// FIXME: Recover from this by treating the declaration as a redeclaration // FIXME: Recover from this by treating the declaration as a redeclaration
// of the primary template. // of the primary template.

View File

@ -2377,7 +2377,7 @@ Decl *TemplateDeclInstantiator::VisitCXXMethodDecl(
Conversion->getConstexprKind(), Conversion->getEndLoc(), Conversion->getConstexprKind(), Conversion->getEndLoc(),
TrailingRequiresClause); TrailingRequiresClause);
} else { } else {
StorageClass SC = D->isStatic() ? SC_Static : SC_None; StorageClass SC = D->isStatic() ? StorageClass::Static : StorageClass::None;
Method = CXXMethodDecl::Create(SemaRef.Context, Record, StartLoc, NameInfo, Method = CXXMethodDecl::Create(SemaRef.Context, Record, StartLoc, NameInfo,
T, TInfo, SC, D->isInlineSpecified(), T, TInfo, SC, D->isInlineSpecified(),
D->getConstexprKind(), D->getEndLoc(), D->getConstexprKind(), D->getEndLoc(),

View File

@ -10622,8 +10622,8 @@ void ASTReader::diagnoseOdrViolations() {
// class needs to be checked instead. // class needs to be checked instead.
const auto FirstStorage = FirstMethod->getStorageClass(); const auto FirstStorage = FirstMethod->getStorageClass();
const auto SecondStorage = SecondMethod->getStorageClass(); const auto SecondStorage = SecondMethod->getStorageClass();
const bool FirstStatic = FirstStorage == SC_Static; const bool FirstStatic = FirstStorage == StorageClass::Static;
const bool SecondStatic = SecondStorage == SC_Static; const bool SecondStatic = SecondStorage == StorageClass::Static;
if (FirstStatic != SecondStatic) { if (FirstStatic != SecondStatic) {
ODRDiagDeclError(FirstRecord, FirstModule, FirstMethod->getLocation(), ODRDiagDeclError(FirstRecord, FirstModule, FirstMethod->getLocation(),
FirstMethod->getSourceRange(), MethodStatic) FirstMethod->getSourceRange(), MethodStatic)

View File

@ -1412,7 +1412,7 @@ ASTDeclReader::RedeclarableResult ASTDeclReader::VisitVarDeclImpl(VarDecl *VD) {
RedeclarableResult Redecl = VisitRedeclarable(VD); RedeclarableResult Redecl = VisitRedeclarable(VD);
VisitDeclaratorDecl(VD); VisitDeclaratorDecl(VD);
VD->VarDeclBits.SClass = (StorageClass)Record.readInt(); VD->VarDeclBits.SClass = Record.readInt();
VD->VarDeclBits.TSCSpec = Record.readInt(); VD->VarDeclBits.TSCSpec = Record.readInt();
VD->VarDeclBits.InitStyle = Record.readInt(); VD->VarDeclBits.InitStyle = Record.readInt();
VD->VarDeclBits.ARCPseudoStrong = Record.readInt(); VD->VarDeclBits.ARCPseudoStrong = Record.readInt();
@ -1435,7 +1435,8 @@ ASTDeclReader::RedeclarableResult ASTDeclReader::VisitVarDeclImpl(VarDecl *VD) {
VD->setCachedLinkage(VarLinkage); VD->setCachedLinkage(VarLinkage);
// Reconstruct the one piece of the IdentifierNamespace that we need. // Reconstruct the one piece of the IdentifierNamespace that we need.
if (VD->getStorageClass() == SC_Extern && VarLinkage != NoLinkage && if (VD->getStorageClass() == StorageClass::Extern &&
VarLinkage != NoLinkage &&
VD->getLexicalDeclContext()->isFunctionOrMethod()) VD->getLexicalDeclContext()->isFunctionOrMethod())
VD->setLocalExternDecl(); VD->setLocalExternDecl();

View File

@ -983,7 +983,7 @@ void ASTDeclWriter::VisitIndirectFieldDecl(IndirectFieldDecl *D) {
void ASTDeclWriter::VisitVarDecl(VarDecl *D) { void ASTDeclWriter::VisitVarDecl(VarDecl *D) {
VisitRedeclarable(D); VisitRedeclarable(D);
VisitDeclaratorDecl(D); VisitDeclaratorDecl(D);
Record.push_back(D->getStorageClass()); Record.push_back(static_cast<uint64_t>(D->getStorageClass()));
Record.push_back(D->getTSCSpec()); Record.push_back(D->getTSCSpec());
Record.push_back(D->getInitStyle()); Record.push_back(D->getInitStyle());
Record.push_back(D->isARCPseudoStrong()); Record.push_back(D->isARCPseudoStrong());
@ -1099,21 +1099,13 @@ void ASTDeclWriter::VisitParmVarDecl(ParmVarDecl *D) {
// If the assumptions about the DECL_PARM_VAR abbrev are true, use it. Here // If the assumptions about the DECL_PARM_VAR abbrev are true, use it. Here
// we dynamically check for the properties that we optimize for, but don't // we dynamically check for the properties that we optimize for, but don't
// know are true of all PARM_VAR_DECLs. // know are true of all PARM_VAR_DECLs.
if (D->getDeclContext() == D->getLexicalDeclContext() && if (D->getDeclContext() == D->getLexicalDeclContext() && !D->hasAttrs() &&
!D->hasAttrs() && !D->hasExtInfo() && !D->isImplicit() && !D->isUsed(false) &&
!D->hasExtInfo() && !D->isInvalidDecl() && !D->isReferenced() && D->getAccess() == AS_none &&
!D->isImplicit() && !D->isModulePrivate() && D->getStorageClass() == StorageClass::None &&
!D->isUsed(false) &&
!D->isInvalidDecl() &&
!D->isReferenced() &&
D->getAccess() == AS_none &&
!D->isModulePrivate() &&
D->getStorageClass() == 0 &&
D->getInitStyle() == VarDecl::CInit && // Can params have anything else? D->getInitStyle() == VarDecl::CInit && // Can params have anything else?
D->getFunctionScopeDepth() == 0 && D->getFunctionScopeDepth() == 0 && D->getObjCDeclQualifier() == 0 &&
D->getObjCDeclQualifier() == 0 && !D->isKNRPromoted() && !D->hasInheritedDefaultArg() &&
!D->isKNRPromoted() &&
!D->hasInheritedDefaultArg() &&
D->getInit() == nullptr && D->getInit() == nullptr &&
!D->hasUninstantiatedDefaultArg()) // No default expr. !D->hasUninstantiatedDefaultArg()) // No default expr.
AbbrevToUse = Writer.getDeclParmVarAbbrev(); AbbrevToUse = Writer.getDeclParmVarAbbrev();

View File

@ -8120,7 +8120,7 @@ static const Decl *maybeGetTemplateCursor(const Decl *D) {
} }
enum CX_StorageClass clang_Cursor_getStorageClass(CXCursor C) { enum CX_StorageClass clang_Cursor_getStorageClass(CXCursor C) {
StorageClass sc = SC_None; StorageClass sc = StorageClass::None;
const Decl *D = getCursorDecl(C); const Decl *D = getCursorDecl(C);
if (D) { if (D) {
if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) { if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
@ -8134,17 +8134,17 @@ enum CX_StorageClass clang_Cursor_getStorageClass(CXCursor C) {
return CX_SC_Invalid; return CX_SC_Invalid;
} }
switch (sc) { switch (sc) {
case SC_None: case StorageClass::None:
return CX_SC_None; return CX_SC_None;
case SC_Extern: case StorageClass::Extern:
return CX_SC_Extern; return CX_SC_Extern;
case SC_Static: case StorageClass::Static:
return CX_SC_Static; return CX_SC_Static;
case SC_PrivateExtern: case StorageClass::PrivateExtern:
return CX_SC_PrivateExtern; return CX_SC_PrivateExtern;
case SC_Auto: case StorageClass::Auto:
return CX_SC_Auto; return CX_SC_Auto;
case SC_Register: case StorageClass::Register:
return CX_SC_Register; return CX_SC_Register;
} }
llvm_unreachable("Unhandled storage class!"); llvm_unreachable("Unhandled storage class!");

View File

@ -163,7 +163,8 @@ public:
CurrentSema->getPreprocessor().getIdentifierInfo(CorrectTo); CurrentSema->getPreprocessor().getIdentifierInfo(CorrectTo);
auto *NewFunction = FunctionDecl::Create( auto *NewFunction = FunctionDecl::Create(
Context, DestContext, SourceLocation(), SourceLocation(), ToIdent, Context, DestContext, SourceLocation(), SourceLocation(), ToIdent,
Context.getFunctionType(Context.VoidTy, {}, {}), nullptr, SC_Static); Context.getFunctionType(Context.VoidTy, {}, {}), nullptr,
StorageClass::Static);
DestContext->addDecl(NewFunction); DestContext->addDecl(NewFunction);
TypoCorrection Correction(ToIdent); TypoCorrection Correction(ToIdent);
Correction.addCorrectionDecl(NewFunction); Correction.addCorrectionDecl(NewFunction);