From 51be6e3487c4b7f43d9f5b2db962382b79295acb Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Tue, 8 Jan 2013 22:04:34 +0000 Subject: [PATCH] Tighten types a bit. No functionality change. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171902 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Sema/Sema.h | 7 ++++--- lib/Sema/SemaDecl.cpp | 16 ++++++---------- lib/Sema/SemaDeclAttr.cpp | 4 ++-- 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/include/clang/Sema/Sema.h b/include/clang/Sema/Sema.h index 1845e2ca7d..27c2ec60fb 100644 --- a/include/clang/Sema/Sema.h +++ b/include/clang/Sema/Sema.h @@ -1669,7 +1669,7 @@ public: bool isIncompatibleTypedef(TypeDecl *Old, TypedefNameDecl *New); /// Attribute merging methods. Return true if a new attribute was added. - AvailabilityAttr *mergeAvailabilityAttr(Decl *D, SourceRange Range, + AvailabilityAttr *mergeAvailabilityAttr(NamedDecl *D, SourceRange Range, IdentifierInfo *Platform, VersionTuple Introduced, VersionTuple Deprecated, @@ -1683,9 +1683,10 @@ public: FormatAttr *mergeFormatAttr(Decl *D, SourceRange Range, StringRef Format, int FormatIdx, int FirstArg); SectionAttr *mergeSectionAttr(Decl *D, SourceRange Range, StringRef Name); - bool mergeDeclAttribute(Decl *New, InheritableAttr *Attr); + bool mergeDeclAttribute(NamedDecl *New, InheritableAttr *Attr); - void mergeDeclAttributes(Decl *New, Decl *Old, bool MergeDeprecation = true); + void mergeDeclAttributes(NamedDecl *New, Decl *Old, + bool MergeDeprecation = true); void MergeTypedefNameDecl(TypedefNameDecl *New, LookupResult &OldDecls); bool MergeFunctionDecl(FunctionDecl *New, Decl *Old, Scope *S); bool MergeCompatibleFunctionDecls(FunctionDecl *New, FunctionDecl *Old, diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 58ba3eeae7..5b610b9605 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -1788,23 +1788,19 @@ DeclHasAttr(const Decl *D, const Attr *A) { return false; } -bool Sema::mergeDeclAttribute(Decl *D, InheritableAttr *Attr) { +bool Sema::mergeDeclAttribute(NamedDecl *D, InheritableAttr *Attr) { InheritableAttr *NewAttr = NULL; if (AvailabilityAttr *AA = dyn_cast(Attr)) { NewAttr = mergeAvailabilityAttr(D, AA->getRange(), AA->getPlatform(), AA->getIntroduced(), AA->getDeprecated(), AA->getObsoleted(), AA->getUnavailable(), AA->getMessage()); - if (NewAttr) { - NamedDecl *ND = cast(D); - ND->ClearLVCache(); - } + if (NewAttr) + D->ClearLVCache(); } else if (VisibilityAttr *VA = dyn_cast(Attr)) { NewAttr = mergeVisibilityAttr(D, VA->getRange(), VA->getVisibility()); - if (NewAttr) { - NamedDecl *ND = cast(D); - ND->ClearLVCache(); - } + if (NewAttr) + D->ClearLVCache(); } else if (DLLImportAttr *ImportA = dyn_cast(Attr)) NewAttr = mergeDLLImportAttr(D, ImportA->getRange()); else if (DLLExportAttr *ExportA = dyn_cast(Attr)) @@ -1875,7 +1871,7 @@ static void checkNewAttributesAfterDef(Sema &S, Decl *New, const Decl *Old) { } /// mergeDeclAttributes - Copy attributes from the Old decl to the New one. -void Sema::mergeDeclAttributes(Decl *New, Decl *Old, +void Sema::mergeDeclAttributes(NamedDecl *New, Decl *Old, bool MergeDeprecation) { // attributes declared post-definition are currently ignored checkNewAttributesAfterDef(*this, New, Old); diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp index 75268b8cc5..a13da7c941 100644 --- a/lib/Sema/SemaDeclAttr.cpp +++ b/lib/Sema/SemaDeclAttr.cpp @@ -2032,7 +2032,7 @@ static bool checkAvailabilityAttr(Sema &S, SourceRange Range, return false; } -AvailabilityAttr *Sema::mergeAvailabilityAttr(Decl *D, SourceRange Range, +AvailabilityAttr *Sema::mergeAvailabilityAttr(NamedDecl *D, SourceRange Range, IdentifierInfo *Platform, VersionTuple Introduced, VersionTuple Deprecated, @@ -2147,7 +2147,7 @@ static void handleAvailabilityAttr(Sema &S, Decl *D, if (SE) Str = SE->getString(); - AvailabilityAttr *NewAttr = S.mergeAvailabilityAttr(D, Attr.getRange(), + AvailabilityAttr *NewAttr = S.mergeAvailabilityAttr(ND, Attr.getRange(), Platform, Introduced.Version, Deprecated.Version, -- 2.40.0