r263630 - Avoid using LookupResult's implicit copy ctor and assignment operator to avoid warnings
Marina Yatsina via cfe-commits
cfe-commits at lists.llvm.org
Wed Mar 16 02:56:58 PDT 2016
Author: myatsina
Date: Wed Mar 16 04:56:58 2016
New Revision: 263630
URL: http://llvm.org/viewvc/llvm-project?rev=263630&view=rev
Log:
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
Added:
cfe/trunk/test/CodeGen/ms-inline-asm-errors.cpp (with props)
Modified:
cfe/trunk/lib/Sema/SemaStmtAsm.cpp
Modified: cfe/trunk/lib/Sema/SemaStmtAsm.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmtAsm.cpp?rev=263630&r1=263629&r2=263630&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaStmtAsm.cpp (original)
+++ cfe/trunk/lib/Sema/SemaStmtAsm.cpp Wed Mar 16 04:56:58 2016
@@ -623,16 +623,12 @@ bool Sema::LookupInlineAsmField(StringRe
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<VarDecl>(FoundDecl))
RT = VD->getType()->getAs<RecordType>();
else if (TypedefNameDecl *TD = dyn_cast<TypedefNameDecl>(FoundDecl)) {
@@ -655,13 +651,15 @@ bool Sema::LookupInlineAsmField(StringRe
if (!LookupQualifiedName(FieldResult, RT->getDecl()))
return true;
+ if (!FieldResult.isSingleResult())
+ return true;
+ FoundDecl = FieldResult.getFoundDecl();
+
// FIXME: Handle IndirectFieldDecl?
- FieldDecl *FD = dyn_cast<FieldDecl>(FieldResult.getFoundDecl());
+ FieldDecl *FD = dyn_cast<FieldDecl>(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));
Added: cfe/trunk/test/CodeGen/ms-inline-asm-errors.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ms-inline-asm-errors.cpp?rev=263630&view=auto
==============================================================================
--- cfe/trunk/test/CodeGen/ms-inline-asm-errors.cpp (added)
+++ cfe/trunk/test/CodeGen/ms-inline-asm-errors.cpp Wed Mar 16 04:56:58 2016
@@ -0,0 +1,15 @@
+// REQUIRES: x86-registered-target
+// RUN: %clang_cc1 -x c++ %s -triple i386-apple-darwin10 -std=c++11 -fasm-blocks -verify
+
+class A {
+public:
+ void foo(int a) {}
+ void foo(float a) {}
+};
+
+
+void t_fail() {
+ __asm {
+ mov ecx, [eax]A.foo // expected-error {{Unable to lookup field reference!}}
+ }
+}
Propchange: cfe/trunk/test/CodeGen/ms-inline-asm-errors.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cfe/trunk/test/CodeGen/ms-inline-asm-errors.cpp
------------------------------------------------------------------------------
svn:keywords = Author Date Id Rev URL
Propchange: cfe/trunk/test/CodeGen/ms-inline-asm-errors.cpp
------------------------------------------------------------------------------
svn:mime-type = text/plain
More information about the cfe-commits
mailing list