SourceLocation RParenLoc);
NamedDecl *LookupInlineAsmIdentifier(StringRef Name, SourceLocation Loc,
- unsigned &Size, bool &IsVarDecl);
+ unsigned &Length, unsigned &Size,
+ unsigned &Type, bool &IsVarDecl);
bool LookupInlineAsmField(StringRef Base, StringRef Member,
unsigned &Offset, SourceLocation AsmLoc);
StmtResult ActOnMSAsmStmt(SourceLocation AsmLoc, SourceLocation LBraceLoc,
: 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);
}
}
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);
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;