From d6d8b315d394fff2d0a1dba42c0f196e62c99a23 Mon Sep 17 00:00:00 2001 From: Marina Yatsina Date: Wed, 16 Mar 2016 09:56:58 +0000 Subject: Avoid using LookupResult's implicit copy ctor and assignment operator to avoid warnings The purpose of this patch is to keep the same functionality without using LookupResult's implicit copy ctor and assignment operator, because they cause warnings when -Wdeprecated is passed. This patch is meant to help the following review: http://reviews.llvm.org/D18123. The functionality is covered by the tests in my original commit (255890) The test case in this patch was added to test a bug caught in the review of the first version of this fix. Differential Revision: http://reviews.llvm.org/D18175 llvm-svn: 263630 --- clang/lib/Sema/SemaStmtAsm.cpp | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'clang/lib/Sema/SemaStmtAsm.cpp') diff --git a/clang/lib/Sema/SemaStmtAsm.cpp b/clang/lib/Sema/SemaStmtAsm.cpp index 11a4f8bfa85..cd4269cd7ea 100644 --- a/clang/lib/Sema/SemaStmtAsm.cpp +++ b/clang/lib/Sema/SemaStmtAsm.cpp @@ -623,16 +623,12 @@ bool Sema::LookupInlineAsmField(StringRef Base, StringRef Member, if (!LookupName(BaseResult, getCurScope())) return true; - - LookupResult CurrBaseResult(BaseResult); - + + if(!BaseResult.isSingleResult()) + return true; + NamedDecl *FoundDecl = BaseResult.getFoundDecl(); for (StringRef NextMember : Members) { - - if (!CurrBaseResult.isSingleResult()) - return true; - const RecordType *RT = nullptr; - NamedDecl *FoundDecl = CurrBaseResult.getFoundDecl(); if (VarDecl *VD = dyn_cast(FoundDecl)) RT = VD->getType()->getAs(); else if (TypedefNameDecl *TD = dyn_cast(FoundDecl)) { @@ -655,13 +651,15 @@ bool Sema::LookupInlineAsmField(StringRef Base, StringRef Member, if (!LookupQualifiedName(FieldResult, RT->getDecl())) return true; + if (!FieldResult.isSingleResult()) + return true; + FoundDecl = FieldResult.getFoundDecl(); + // FIXME: Handle IndirectFieldDecl? - FieldDecl *FD = dyn_cast(FieldResult.getFoundDecl()); + FieldDecl *FD = dyn_cast(FoundDecl); if (!FD) return true; - CurrBaseResult = FieldResult; - const ASTRecordLayout &RL = Context.getASTRecordLayout(RT->getDecl()); unsigned i = FD->getFieldIndex(); CharUnits Result = Context.toCharUnitsFromBits(RL.getFieldOffset(i)); -- cgit v1.2.3