Author: Simon Pilgrim Date: 2020-01-13T15:07:55Z New Revision: 7af67259cdd66811941514a263dd0f81c491d8f1
URL: https://github.com/llvm/llvm-project/commit/7af67259cdd66811941514a263dd0f81c491d8f1 DIFF: https://github.com/llvm/llvm-project/commit/7af67259cdd66811941514a263dd0f81c491d8f1.diff LOG: Sema::getOwningModule - take const Decl* type. Fixes static analyzer warning that const_cast was being used despite only const methods being called. Added: Modified: clang/include/clang/Sema/Sema.h clang/lib/Sema/SemaOverload.cpp Removed: ################################################################################ diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h index 851b25922f5a..b95a5017d907 100644 --- a/clang/include/clang/Sema/Sema.h +++ b/clang/include/clang/Sema/Sema.h @@ -1725,7 +1725,9 @@ class Sema final { public: /// Get the module owning an entity. - Module *getOwningModule(Decl *Entity) { return Entity->getOwningModule(); } + Module *getOwningModule(const Decl *Entity) { + return Entity->getOwningModule(); + } /// Make a merged definition of an existing hidden definition \p ND /// visible at the specified location. diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp index be02a199a51a..56d9522eee01 100644 --- a/clang/lib/Sema/SemaOverload.cpp +++ b/clang/lib/Sema/SemaOverload.cpp @@ -9673,8 +9673,7 @@ bool Sema::isEquivalentInternalLinkageDeclaration(const NamedDecl *A, // entity in diff erent modules. if (!VA->getDeclContext()->getRedeclContext()->Equals( VB->getDeclContext()->getRedeclContext()) || - getOwningModule(const_cast<ValueDecl *>(VA)) == - getOwningModule(const_cast<ValueDecl *>(VB)) || + getOwningModule(VA) == getOwningModule(VB) || VA->isExternallyVisible() || VB->isExternallyVisible()) return false; @@ -9711,12 +9710,12 @@ void Sema::diagnoseEquivalentInternalLinkageDeclarations( SourceLocation Loc, const NamedDecl *D, ArrayRef<const NamedDecl *> Equiv) { Diag(Loc, diag::ext_equivalent_internal_linkage_decl_in_modules) << D; - Module *M = getOwningModule(const_cast<NamedDecl*>(D)); + Module *M = getOwningModule(D); Diag(D->getLocation(), diag::note_equivalent_internal_linkage_decl) << !M << (M ? M->getFullModuleName() : ""); for (auto *E : Equiv) { - Module *M = getOwningModule(const_cast<NamedDecl*>(E)); + Module *M = getOwningModule(E); Diag(E->getLocation(), diag::note_equivalent_internal_linkage_decl) << !M << (M ? M->getFullModuleName() : ""); } _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits