summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaStmt.cpp
diff options
context:
space:
mode:
authorChad Rosier <mcrosier@apple.com>2012-08-16 19:52:25 +0000
committerChad Rosier <mcrosier@apple.com>2012-08-16 19:52:25 +0000
commitefb291166414b7bfe2fa11737a650d93210f184d (patch)
treef59173b628f0c6e4ea1f171ad5ba653a653afd9a /clang/lib/Sema/SemaStmt.cpp
parent9f143c5c5f231cd2eafbca193fb69bc6efb95aee (diff)
downloadbcm5719-llvm-efb291166414b7bfe2fa11737a650d93210f184d.tar.gz
bcm5719-llvm-efb291166414b7bfe2fa11737a650d93210f184d.zip
[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. llvm-svn: 162043
Diffstat (limited to 'clang/lib/Sema/SemaStmt.cpp')
-rw-r--r--clang/lib/Sema/SemaStmt.cpp38
1 files changed, 30 insertions, 8 deletions
diff --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp
index 5bd5c8a96b2..49d1cae03ae 100644
--- a/clang/lib/Sema/SemaStmt.cpp
+++ b/clang/lib/Sema/SemaStmt.cpp
@@ -2824,7 +2824,8 @@ static void patchMSAsmStrings(Sema &SemaRef, bool &IsSimple,
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 @@ static void patchMSAsmStrings(Sema &SemaRef, bool &IsSimple,
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.
OpenPOWER on IntegriCloud