summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaStmtAsm.cpp
diff options
context:
space:
mode:
authorChad Rosier <mcrosier@apple.com>2013-01-17 19:21:24 +0000
committerChad Rosier <mcrosier@apple.com>2013-01-17 19:21:24 +0000
commit4edf11fcf0e445845773806666cb0e7bc7296d41 (patch)
treeddb00f9fe1514237cab8d6df0ea05b5237380a77 /clang/lib/Sema/SemaStmtAsm.cpp
parent1dc66cafca8ab775eb5d647b80e8dad3288e647f (diff)
downloadbcm5719-llvm-4edf11fcf0e445845773806666cb0e7bc7296d41.tar.gz
bcm5719-llvm-4edf11fcf0e445845773806666cb0e7bc7296d41.zip
[ms-inline asm] Extend the Sema interface to get the size and length of a
VarDecl. Part of rdar://12576868 llvm-svn: 172742
Diffstat (limited to 'clang/lib/Sema/SemaStmtAsm.cpp')
-rw-r--r--clang/lib/Sema/SemaStmtAsm.cpp24
1 files changed, 19 insertions, 5 deletions
diff --git a/clang/lib/Sema/SemaStmtAsm.cpp b/clang/lib/Sema/SemaStmtAsm.cpp
index 008a99a174c..4646ef7b389 100644
--- a/clang/lib/Sema/SemaStmtAsm.cpp
+++ b/clang/lib/Sema/SemaStmtAsm.cpp
@@ -437,10 +437,13 @@ public:
: SemaRef(Ref), AsmLoc(Loc), AsmToks(Toks), TokOffsets(Offsets) { }
~MCAsmParserSemaCallbackImpl() {}
- void *LookupInlineAsmIdentifier(StringRef Name, void *SrcLoc, unsigned &Size,
- bool &IsVarDecl){
+ 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, Size,
+
+ NamedDecl *OpDecl = SemaRef.LookupInlineAsmIdentifier(Name, Loc, Length,
+ Size, Type,
IsVarDecl);
return static_cast<void *>(OpDecl);
}
@@ -484,8 +487,11 @@ public:
}
NamedDecl *Sema::LookupInlineAsmIdentifier(StringRef Name, SourceLocation Loc,
- unsigned &Size, bool &IsVarDecl) {
+ unsigned &Length, unsigned &Size,
+ unsigned &Type, bool &IsVarDecl) {
+ Length = 1;
Size = 0;
+ Type = 0;
IsVarDecl = false;
LookupResult Result(*this, &Context.Idents.get(Name), Loc,
Sema::LookupOrdinaryName);
@@ -504,7 +510,15 @@ 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)) {
- Size = Context.getTypeInfo(Var->getType()).first;
+ Type = Context.getTypeInfo(Var->getType()).first;
+ QualType Ty = Var->getType();
+ if (Ty->isArrayType()) {
+ const ArrayType *ATy = Context.getAsArrayType(Ty);
+ Length = Type / Context.getTypeInfo(ATy->getElementType()).first;
+ Type /= Length; // Type is in terms of a single element.
+ }
+ Type /= 8; // Type is in terms of bits, but we want bytes.
+ Size = Length * Type;
IsVarDecl = true;
}
return ND;
OpenPOWER on IntegriCloud