[cfe-commits] r172120 - in /cfe/trunk: include/clang/Sema/Sema.h lib/Sema/SemaStmtAsm.cpp

Chad Rosier mcrosier at apple.com
Thu Jan 10 14:10:16 PST 2013


Author: mcrosier
Date: Thu Jan 10 16:10:16 2013
New Revision: 172120

URL: http://llvm.org/viewvc/llvm-project?rev=172120&view=rev
Log:
[ms-inline asm] Extend the inline asm Sema lookup interface to determine if the
Decl is a VarDecl.
Part of rdar://12991541

Modified:
    cfe/trunk/include/clang/Sema/Sema.h
    cfe/trunk/lib/Sema/SemaStmtAsm.cpp

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=172120&r1=172119&r2=172120&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Thu Jan 10 16:10:16 2013
@@ -2677,7 +2677,7 @@
                              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,

Modified: cfe/trunk/lib/Sema/SemaStmtAsm.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmtAsm.cpp?rev=172120&r1=172119&r2=172120&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaStmtAsm.cpp (original)
+++ cfe/trunk/lib/Sema/SemaStmtAsm.cpp Thu Jan 10 16:10:16 2013
@@ -437,9 +437,11 @@
     : 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 @@
 }
 
 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 *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 @@
     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());





More information about the cfe-commits mailing list