r180027 - [ms-inline asm] Refactor/clean up the SemaLookup interface. No functional
Chad Rosier
mcrosier at apple.com
Mon Apr 22 10:01:38 PDT 2013
Author: mcrosier
Date: Mon Apr 22 12:01:37 2013
New Revision: 180027
URL: http://llvm.org/viewvc/llvm-project?rev=180027&view=rev
Log:
[ms-inline asm] Refactor/clean up the SemaLookup interface. No functional
change indended.
Part of rdar://13663589
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=180027&r1=180026&r2=180027&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Mon Apr 22 12:01:37 2013
@@ -46,6 +46,7 @@
#include "llvm/ADT/SetVector.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallVector.h"
+#include "llvm/MC/MCParser/MCAsmParser.h"
#include <deque>
#include <string>
@@ -820,6 +821,9 @@ public:
bool OldFPContractState : 1;
};
+ typedef llvm::MCAsmParserSemaCallback::InlineAsmIdentifierInfo
+ InlineAsmIdentifierInfo;
+
public:
Sema(Preprocessor &pp, ASTContext &ctxt, ASTConsumer &consumer,
TranslationUnitKind TUKind = TU_Complete,
@@ -2797,9 +2801,8 @@ public:
Expr *AsmString, MultiExprArg Clobbers,
SourceLocation RParenLoc);
- NamedDecl *LookupInlineAsmIdentifier(StringRef Name, SourceLocation Loc,
- unsigned &Length, unsigned &Size,
- unsigned &Type, bool &IsVarDecl);
+ NamedDecl *LookupInlineAsmIdentifier(StringRef &LineBuf, SourceLocation Loc,
+ InlineAsmIdentifierInfo &Info);
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=180027&r1=180026&r2=180027&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaStmtAsm.cpp (original)
+++ cfe/trunk/lib/Sema/SemaStmtAsm.cpp Mon Apr 22 12:01:37 2013
@@ -445,14 +445,10 @@ public:
: SemaRef(Ref), AsmLoc(Loc), AsmToks(Toks), TokOffsets(Offsets) { }
~MCAsmParserSemaCallbackImpl() {}
- void *LookupInlineAsmIdentifier(StringRef Name, void *SrcLoc,
- unsigned &Length, unsigned &Size,
- unsigned &Type, bool &IsVarDecl){
- SourceLocation Loc = SourceLocation::getFromPtrEncoding(SrcLoc);
-
- NamedDecl *OpDecl = SemaRef.LookupInlineAsmIdentifier(Name, Loc, Length,
- Size, Type,
- IsVarDecl);
+ void *LookupInlineAsmIdentifier(StringRef &LineBuf,
+ InlineAsmIdentifierInfo &Info) {
+ SourceLocation Loc = SourceLocation::getFromPtrEncoding(LineBuf.data());
+ NamedDecl *OpDecl = SemaRef.LookupInlineAsmIdentifier(LineBuf, Loc, Info);
return static_cast<void *>(OpDecl);
}
@@ -520,19 +516,13 @@ static StringRef parseIdentifier(StringR
return StringRef(StartPtr, CurPtr - StartPtr);
}
-NamedDecl *Sema::LookupInlineAsmIdentifier(StringRef Name, SourceLocation Loc,
- unsigned &Length, unsigned &Size,
- unsigned &Type, bool &IsVarDecl) {
+NamedDecl *Sema::LookupInlineAsmIdentifier(StringRef &LineBuf, SourceLocation Loc,
+ InlineAsmIdentifierInfo &Info) {
+ Info.clear();
// FIXME: Temporary hack until the frontend parser is hooked up to parse
// variables.
- StringRef ParsedName = parseIdentifier(Name);
- assert (ParsedName == Name && "Identifier not parsed correctly!");
-
- Length = 1;
- Size = 0;
- Type = 0;
- IsVarDecl = false;
- LookupResult Result(*this, &Context.Idents.get(Name), Loc,
+ LineBuf = parseIdentifier(LineBuf);
+ LookupResult Result(*this, &Context.Idents.get(LineBuf), Loc,
Sema::LookupOrdinaryName);
if (!LookupName(Result, getCurScope())) {
@@ -551,13 +541,13 @@ NamedDecl *Sema::LookupInlineAsmIdentifi
return FoundDecl;
if (VarDecl *Var = dyn_cast<VarDecl>(FoundDecl)) {
QualType Ty = Var->getType();
- Type = Size = Context.getTypeSizeInChars(Ty).getQuantity();
+ Info.Type = Info.Size = Context.getTypeSizeInChars(Ty).getQuantity();
if (Ty->isArrayType()) {
const ArrayType *ATy = Context.getAsArrayType(Ty);
- Type = Context.getTypeSizeInChars(ATy->getElementType()).getQuantity();
- Length = Size / Type;
+ Info.Type = Context.getTypeSizeInChars(ATy->getElementType()).getQuantity();
+ Info.Length = Info.Size / Info.Type;
}
- IsVarDecl = true;
+ Info.IsVarDecl = true;
return FoundDecl;
}
More information about the cfe-commits
mailing list