[PATCH] D18175: Avoid using LookupResult's implicit copy ctor and assignment operator to avoid warnings
Marina Yatsina via cfe-commits
cfe-commits at lists.llvm.org
Tue Mar 15 15:51:04 PDT 2016
myatsina updated this revision to Diff 50780.
myatsina added a comment.
Adding requested test case + changing the code accordingly
Repository:
rL LLVM
http://reviews.llvm.org/D18175
Files:
lib/Sema/SemaStmtAsm.cpp
test/CodeGen/ms-inline-asm-errors.cpp
Index: lib/Sema/SemaStmtAsm.cpp
===================================================================
--- lib/Sema/SemaStmtAsm.cpp
+++ lib/Sema/SemaStmtAsm.cpp
@@ -623,16 +623,12 @@
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 @@
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));
Index: test/CodeGen/ms-inline-asm-errors.cpp
===================================================================
--- test/CodeGen/ms-inline-asm-errors.cpp
+++ test/CodeGen/ms-inline-asm-errors.cpp
@@ -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!}}
+ }
+}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D18175.50780.patch
Type: text/x-patch
Size: 1956 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160315/2264221e/attachment.bin>
More information about the cfe-commits
mailing list