From fc8c61a5b8ae7643f52819a6c9422ac2fb9ffb7c Mon Sep 17 00:00:00 2001 From: Kaelyn Takata Date: Tue, 11 Nov 2014 23:00:42 +0000 Subject: [PATCH] Make LookupResult be copyable to avoid decomposing an existing one and initializing a new one every time a copy is needed. llvm-svn: 221724 --- clang/include/clang/AST/UnresolvedSet.h | 2 +- clang/include/clang/Sema/Lookup.h | 18 +++++++++--------- clang/lib/Sema/SemaLookup.cpp | 12 ++++++------ 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/clang/include/clang/AST/UnresolvedSet.h b/clang/include/clang/AST/UnresolvedSet.h index 2ef5800..4266c4a 100644 --- a/clang/include/clang/AST/UnresolvedSet.h +++ b/clang/include/clang/AST/UnresolvedSet.h @@ -98,7 +98,7 @@ class UnresolvedSetImpl { private: template friend class UnresolvedSet; UnresolvedSetImpl() {} - UnresolvedSetImpl(const UnresolvedSetImpl &) LLVM_DELETED_FUNCTION; + UnresolvedSetImpl(const UnresolvedSetImpl &) {}; public: // We don't currently support assignment through this iterator, so we might diff --git a/clang/include/clang/Sema/Lookup.h b/clang/include/clang/Sema/Lookup.h index 067e422..1c6c7bb 100644 --- a/clang/include/clang/Sema/Lookup.h +++ b/clang/include/clang/Sema/Lookup.h @@ -132,7 +132,7 @@ public: : ResultKind(NotFound), Paths(nullptr), NamingClass(nullptr), - SemaRef(SemaRef), + SemaPtr(&SemaRef), NameInfo(NameInfo), LookupKind(LookupKind), IDNS(0), @@ -154,7 +154,7 @@ public: : ResultKind(NotFound), Paths(nullptr), NamingClass(nullptr), - SemaRef(SemaRef), + SemaPtr(&SemaRef), NameInfo(Name, NameLoc), LookupKind(LookupKind), IDNS(0), @@ -174,7 +174,7 @@ public: : ResultKind(NotFound), Paths(nullptr), NamingClass(nullptr), - SemaRef(Other.SemaRef), + SemaPtr(Other.SemaPtr), NameInfo(Other.NameInfo), LookupKind(Other.LookupKind), IDNS(Other.IDNS), @@ -305,7 +305,7 @@ public: if (!D->isInIdentifierNamespace(IDNS)) return nullptr; - if (isHiddenDeclarationVisible() || isVisible(SemaRef, D)) + if (isHiddenDeclarationVisible() || isVisible(getSema(), D)) return D; return getAcceptableDeclSlow(D); @@ -551,7 +551,7 @@ public: /// \brief Get the Sema object that this lookup result is searching /// with. - Sema &getSema() const { return SemaRef; } + Sema &getSema() const { return *SemaPtr; } /// A class for iterating through a result set and possibly /// filtering out results. The results returned are possibly @@ -630,9 +630,9 @@ public: private: void diagnose() { if (isAmbiguous()) - SemaRef.DiagnoseAmbiguousLookup(*this); - else if (isClassLookup() && SemaRef.getLangOpts().AccessControl) - SemaRef.CheckLookupAccess(*this); + getSema().DiagnoseAmbiguousLookup(*this); + else if (isClassLookup() && getSema().getLangOpts().AccessControl) + getSema().CheckLookupAccess(*this); } void setAmbiguous(AmbiguityKind AK) { @@ -664,7 +664,7 @@ private: QualType BaseObjectType; // Parameters. - Sema &SemaRef; + Sema *SemaPtr; DeclarationNameInfo NameInfo; SourceRange NameContextRange; Sema::LookupNameKind LookupKind; diff --git a/clang/lib/Sema/SemaLookup.cpp b/clang/lib/Sema/SemaLookup.cpp index eab819e..b6c1fad 100644 --- a/clang/lib/Sema/SemaLookup.cpp +++ b/clang/lib/Sema/SemaLookup.cpp @@ -285,7 +285,7 @@ static inline unsigned getIDNS(Sema::LookupNameKind NameKind, } void LookupResult::configure() { - IDNS = getIDNS(LookupKind, SemaRef.getLangOpts().CPlusPlus, + IDNS = getIDNS(LookupKind, getSema().getLangOpts().CPlusPlus, isForRedeclaration()); // If we're looking for one of the allocation or deallocation @@ -296,7 +296,7 @@ void LookupResult::configure() { case OO_Delete: case OO_Array_New: case OO_Array_Delete: - SemaRef.DeclareGlobalNewDelete(); + getSema().DeclareGlobalNewDelete(); break; default: @@ -307,7 +307,7 @@ void LookupResult::configure() { // up being declared. if (IdentifierInfo *Id = NameInfo.getName().getAsIdentifierInfo()) { if (unsigned BuiltinID = Id->getBuiltinID()) { - if (!SemaRef.Context.BuiltinInfo.isPredefinedLibFunction(BuiltinID)) + if (!getSema().Context.BuiltinInfo.isPredefinedLibFunction(BuiltinID)) AllowHidden = true; } } @@ -400,8 +400,8 @@ void LookupResult::resolveKind() { // canonical type. if (TypeDecl *TD = dyn_cast(D)) { if (!TD->getDeclContext()->isRecord()) { - QualType T = SemaRef.Context.getTypeDeclType(TD); - if (!UniqueTypes.insert(SemaRef.Context.getCanonicalType(T))) { + QualType T = getSema().Context.getTypeDeclType(TD); + if (!UniqueTypes.insert(getSema().Context.getCanonicalType(T))) { // The type is not unique; pull something off the back and continue // at this index. Decls[I] = Decls[--N]; @@ -1265,7 +1265,7 @@ static NamedDecl *findAcceptableDecl(Sema &SemaRef, NamedDecl *D) { } NamedDecl *LookupResult::getAcceptableDeclSlow(NamedDecl *D) const { - return findAcceptableDecl(SemaRef, D); + return findAcceptableDecl(getSema(), D); } /// @brief Perform unqualified name lookup starting from a given -- 2.7.4