r221724 - Make LookupResult be copyable to avoid decomposing an existing one and
Kaelyn Takata
rikka at google.com
Tue Nov 11 15:10:41 PST 2014
On Tue, Nov 11, 2014 at 3:02 PM, David Blaikie <dblaikie at gmail.com> wrote:
>
>
> On Tue, Nov 11, 2014 at 3:00 PM, Kaelyn Takata <rikka at google.com> wrote:
>
>> Author: rikka
>> Date: Tue Nov 11 17:00:42 2014
>> New Revision: 221724
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=221724&view=rev
>> Log:
>> Make LookupResult be copyable to avoid decomposing an existing one and
>> initializing a new one every time a copy is needed.
>>
>
> Looks great - though I don't see the use case - I guess that'll be in a
> follow-up commit?
>
Yup, it will be (these three patches were part of a larger set).
>
>
>>
>> Modified:
>> cfe/trunk/include/clang/AST/UnresolvedSet.h
>> cfe/trunk/include/clang/Sema/Lookup.h
>> cfe/trunk/lib/Sema/SemaLookup.cpp
>>
>> Modified: cfe/trunk/include/clang/AST/UnresolvedSet.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/UnresolvedSet.h?rev=221724&r1=221723&r2=221724&view=diff
>>
>> ==============================================================================
>> --- cfe/trunk/include/clang/AST/UnresolvedSet.h (original)
>> +++ cfe/trunk/include/clang/AST/UnresolvedSet.h Tue Nov 11 17:00:42 2014
>> @@ -98,7 +98,7 @@ class UnresolvedSetImpl {
>> private:
>> template <unsigned N> friend class UnresolvedSet;
>> UnresolvedSetImpl() {}
>> - UnresolvedSetImpl(const UnresolvedSetImpl &) LLVM_DELETED_FUNCTION;
>> + UnresolvedSetImpl(const UnresolvedSetImpl &) {};
>>
>
> Unnecessary semicolon (GCC will probably warn about this) at the end of
> this line ^
>
Oops, thanks! Fixed in r221732.
>
>
>>
>> public:
>> // We don't currently support assignment through this iterator, so we
>> might
>>
>> Modified: cfe/trunk/include/clang/Sema/Lookup.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Lookup.h?rev=221724&r1=221723&r2=221724&view=diff
>>
>> ==============================================================================
>> --- cfe/trunk/include/clang/Sema/Lookup.h (original)
>> +++ cfe/trunk/include/clang/Sema/Lookup.h Tue Nov 11 17:00:42 2014
>> @@ -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;
>>
>> Modified: cfe/trunk/lib/Sema/SemaLookup.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLookup.cpp?rev=221724&r1=221723&r2=221724&view=diff
>>
>> ==============================================================================
>> --- cfe/trunk/lib/Sema/SemaLookup.cpp (original)
>> +++ cfe/trunk/lib/Sema/SemaLookup.cpp Tue Nov 11 17:00:42 2014
>> @@ -285,7 +285,7 @@ static inline unsigned getIDNS(Sema::Loo
>> }
>>
>> 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<TypeDecl>(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(Sem
>> }
>>
>> NamedDecl *LookupResult::getAcceptableDeclSlow(NamedDecl *D) const {
>> - return findAcceptableDecl(SemaRef, D);
>> + return findAcceptableDecl(getSema(), D);
>> }
>>
>> /// @brief Perform unqualified name lookup starting from a given
>>
>>
>> _______________________________________________
>> cfe-commits mailing list
>> cfe-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20141111/5158a4b0/attachment.html>
More information about the cfe-commits
mailing list