]> granicus.if.org Git - clang/commitdiff
[ms-inline asm] Extend the inline asm Sema lookup interface to determine if the
authorChad Rosier <mcrosier@apple.com>
Thu, 10 Jan 2013 22:10:16 +0000 (22:10 +0000)
committerChad Rosier <mcrosier@apple.com>
Thu, 10 Jan 2013 22:10:16 +0000 (22:10 +0000)
Decl is a VarDecl.
Part of rdar://12991541

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172120 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Sema/Sema.h
lib/Sema/SemaStmtAsm.cpp

index 27c2ec60fb9642950da447a6b7d6ddafd1859cd3..e3d7b0c4df92f98c2dbcc3ed6f60e0d9851f3d2f 100644 (file)
@@ -2677,7 +2677,7 @@ public:
                              SourceLocation RParenLoc);
 
   NamedDecl *LookupInlineAsmIdentifier(StringRef Name, SourceLocation Loc,
-                                       unsigned &Size);
+                                       unsigned &Size, bool &IsVarDecl);
   bool LookupInlineAsmField(StringRef Base, StringRef Member,
                             unsigned &Offset, SourceLocation AsmLoc);
   StmtResult ActOnMSAsmStmt(SourceLocation AsmLoc, SourceLocation LBraceLoc,
index 21d022b28c836c36293c61f9adda49b9b2635306..e0c3a730350e4594812af4b777fd71e9209ae2dc 100644 (file)
@@ -437,9 +437,11 @@ public:
     : SemaRef(Ref), AsmLoc(Loc), AsmToks(Toks), TokOffsets(Offsets) { }
   ~MCAsmParserSemaCallbackImpl() {}
 
-  void *LookupInlineAsmIdentifier(StringRef Name, void *SrcLoc, unsigned &Size){
+  void *LookupInlineAsmIdentifier(StringRef Name, void *SrcLoc, unsigned &Size,
+                                  bool &IsVarDecl){
     SourceLocation Loc = SourceLocation::getFromPtrEncoding(SrcLoc);
-    NamedDecl *OpDecl = SemaRef.LookupInlineAsmIdentifier(Name, Loc, Size);
+    NamedDecl *OpDecl = SemaRef.LookupInlineAsmIdentifier(Name, Loc, Size,
+                                                          IsVarDecl);
     return static_cast<void *>(OpDecl);
   }
 
@@ -482,8 +484,9 @@ public:
 }
 
 NamedDecl *Sema::LookupInlineAsmIdentifier(StringRef Name, SourceLocation Loc,
-                                           unsigned &Size) {
+                                           unsigned &Size, bool &IsVarDecl) {
   Size = 0;
+  IsVarDecl = false;
   LookupResult Result(*this, &Context.Idents.get(Name), Loc,
                       Sema::LookupOrdinaryName);
 
@@ -500,9 +503,10 @@ NamedDecl *Sema::LookupInlineAsmIdentifier(StringRef Name, SourceLocation Loc,
 
   NamedDecl *ND = Result.getFoundDecl();
   if (isa<VarDecl>(ND) || isa<FunctionDecl>(ND)) {
-    if (VarDecl *Var = dyn_cast<VarDecl>(ND))
+    if (VarDecl *Var = dyn_cast<VarDecl>(ND)) {
       Size = Context.getTypeInfo(Var->getType()).first;
-
+      IsVarDecl = true;
+    }
     return ND;
   }
 
@@ -652,7 +656,7 @@ StmtResult Sema::ActOnMSAsmStmt(SourceLocation AsmLoc, SourceLocation LBraceLoc,
     if (OpExpr.isInvalid())
       return StmtError();
 
-    // Need offset of variable.
+    // Need address of variable.
     if (OpDecls[i].second)
       OpExpr = BuildUnaryOp(getCurScope(), AsmLoc, clang::UO_AddrOf,
                             OpExpr.take());