From: Chad Rosier Date: Thu, 18 Oct 2012 20:27:06 +0000 (+0000) Subject: [ms-inline asm] Add a size argument to the LookupInlineAsmIdentifier() callback, X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c337d1457e4600107a1b3793f62ca96a33f1308b;p=clang [ms-inline asm] Add a size argument to the LookupInlineAsmIdentifier() callback, which will be used by the asm matcher in the near future. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166221 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Sema/Sema.h b/include/clang/Sema/Sema.h index 15303ef817..658a60c62f 100644 --- a/include/clang/Sema/Sema.h +++ b/include/clang/Sema/Sema.h @@ -2631,7 +2631,8 @@ public: Expr *AsmString, MultiExprArg Clobbers, SourceLocation RParenLoc); - NamedDecl *LookupInlineAsmIdentifier(StringRef Name, SourceLocation Loc); + NamedDecl *LookupInlineAsmIdentifier(StringRef Name, SourceLocation Loc, + unsigned &Size); StmtResult ActOnMSAsmStmt(SourceLocation AsmLoc, SourceLocation LBraceLoc, ArrayRef AsmToks, SourceLocation EndLoc); diff --git a/lib/Sema/SemaStmtAsm.cpp b/lib/Sema/SemaStmtAsm.cpp index 875821c14d..172cfe55be 100644 --- a/lib/Sema/SemaStmtAsm.cpp +++ b/lib/Sema/SemaStmtAsm.cpp @@ -367,14 +367,16 @@ public: MCAsmParserSemaCallbackImpl(class Sema *Ref) { SemaRef = Ref; } ~MCAsmParserSemaCallbackImpl() {} - void *LookupInlineAsmIdentifier(StringRef Name, void *SrcLoc) { + void *LookupInlineAsmIdentifier(StringRef Name, void *SrcLoc, unsigned &Size){ SourceLocation Loc = SourceLocation::getFromPtrEncoding(SrcLoc); - NamedDecl *OpDecl = SemaRef->LookupInlineAsmIdentifier(Name, Loc); + NamedDecl *OpDecl = SemaRef->LookupInlineAsmIdentifier(Name, Loc, Size); return static_cast(OpDecl); } }; -NamedDecl *Sema::LookupInlineAsmIdentifier(StringRef Name, SourceLocation Loc) { +NamedDecl *Sema::LookupInlineAsmIdentifier(StringRef Name, SourceLocation Loc, + unsigned &Size) { + Size = 0; LookupResult Result(*this, &Context.Idents.get(Name), Loc, Sema::LookupOrdinaryName); @@ -391,6 +393,9 @@ NamedDecl *Sema::LookupInlineAsmIdentifier(StringRef Name, SourceLocation Loc) { NamedDecl *ND = Result.getFoundDecl(); if (isa(ND) || isa(ND)) { + if (VarDecl *Var = dyn_cast(ND)) + Size = Context.getTypeInfo(Var->getType()).first; + return ND; }