[cfe-commits] r162043 - /cfe/trunk/lib/Sema/SemaStmt.cpp
Chad Rosier
mcrosier at apple.com
Thu Aug 16 12:52:26 PDT 2012
Author: mcrosier
Date: Thu Aug 16 14:52:25 2012
New Revision: 162043
URL: http://llvm.org/viewvc/llvm-project?rev=162043&view=rev
Log:
[ms-inline asm] Perform symbol table lookup on variables. The idea is to use
this information to determine valid MC operands. This will also be used for
semantic analysis.
Modified:
cfe/trunk/lib/Sema/SemaStmt.cpp
Modified: cfe/trunk/lib/Sema/SemaStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmt.cpp?rev=162043&r1=162042&r2=162043&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaStmt.cpp (original)
+++ cfe/trunk/lib/Sema/SemaStmt.cpp Thu Aug 16 14:52:25 2012
@@ -2824,7 +2824,8 @@
break;
}
case tok::identifier: {
- StringRef Name = AsmToks[i].getIdentifierInfo()->getName();
+ IdentifierInfo *II = AsmToks[i].getIdentifierInfo();
+ StringRef Name = II->getName();
// Valid register?
if (TI.isValidGCCRegisterName(Name)) {
@@ -2841,16 +2842,37 @@
break;
}
- // Not a register, so this must be a variable, function or label
- // reference. Track these as they are either an Input or an Output.
- // Unfortunately, we don't know which is which until after we feed
- // the patched asms to the AsmParser.
- AsmNames[NumAsmStrings].set(i);
+ // Lookup the identifier.
+ // TODO: Someone with more experience with clang should verify this the
+ // proper way of doing a symbol lookup.
+ DeclarationName DeclName(II);
+ Scope *CurScope = SemaRef.getCurScope();
+ LookupResult R(SemaRef, DeclName, AsmLoc, Sema::LookupOrdinaryName);
+ if (!SemaRef.LookupName(R, CurScope, false/*AllowBuiltinCreation*/))
+ break;
- // TODO: Lookup the identifier and patch appropriately.
+ assert (R.isSingleResult() && "Expected a single result?!");
+ NamedDecl *Decl = R.getFoundDecl();
+ switch (Decl->getKind()) {
+ default:
+ assert(0 && "Unknown decl kind.");
+ break;
+ case Decl::Var: {
+ case Decl::ParmVar:
+ AsmNames[NumAsmStrings].set(i);
+
+ VarDecl *Var = cast<VarDecl>(Decl);
+ QualType Ty = Var->getType();
+ (void)Ty; // Avoid warning.
+ // TODO: Patch identifier with valid operand. One potential idea is to
+ // probe the backend with type information to guess the possible
+ // operand.
+ break;
+ }
+ }
break;
}
- } // AsmToks[i].getKind()
+ }
}
// Emit the final (and possibly only) asm string.
More information about the cfe-commits
mailing list