diff options
author | Reid Kleckner <rnk@google.com> | 2015-08-26 21:57:20 +0000 |
---|---|---|
committer | Reid Kleckner <rnk@google.com> | 2015-08-26 21:57:20 +0000 |
commit | ee6d4bd4f87934944a8aa7c5a6ffb3bed59535e6 (patch) | |
tree | d4fbd8b55954c6300b2bfca17ff4d631976ec4e4 /lib/Parse/ParseStmtAsm.cpp | |
parent | 85a91ffe2038db56dd1b2603255bbf051c712947 (diff) | |
download | clang-ee6d4bd4f87934944a8aa7c5a6ffb3bed59535e6.tar.gz |
[ms-inline-asm] Add field access to MS inline asm identifier lookup
Now we can parse code like this:
struct A {
int field;
};
int f(A o) {
__asm mov eax, o.field
}
Fixes PR19117.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@246088 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Parse/ParseStmtAsm.cpp')
-rw-r--r-- | lib/Parse/ParseStmtAsm.cpp | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/lib/Parse/ParseStmtAsm.cpp b/lib/Parse/ParseStmtAsm.cpp index 8cdae6a74b..d3281393f9 100644 --- a/lib/Parse/ParseStmtAsm.cpp +++ b/lib/Parse/ParseStmtAsm.cpp @@ -222,6 +222,25 @@ ExprResult Parser::ParseMSAsmIdentifier(llvm::SmallVectorImpl<Token> &LineToks, /*AllowConstructorName=*/false, /*ObjectType=*/ParsedType(), TemplateKWLoc, Id); + // Perform the lookup. + ExprResult Result = Actions.LookupInlineAsmIdentifier( + SS, TemplateKWLoc, Id, Info, IsUnevaluatedContext); + + // While the next two tokens are 'period' 'identifier', repeatedly parse it as + // a field access. We have to avoid consuming assembler directives that look + // like '.' 'else'. + while (Result.isUsable() && Tok.is(tok::period)) { + Token IdTok = PP.LookAhead(0); + if (IdTok.isNot(tok::identifier)) + break; + ConsumeToken(); // Consume the period. + IdentifierInfo *Id = Tok.getIdentifierInfo(); + ConsumeToken(); // Consume the identifier. + unsigned OffsetUnused; + Result = Actions.LookupInlineAsmVarDeclField( + Result.get(), Id->getName(), OffsetUnused, Info, Tok.getLocation()); + } + // Figure out how many tokens we are into LineToks. unsigned LineIndex = 0; if (Tok.is(EndOfStream)) { @@ -254,9 +273,7 @@ ExprResult Parser::ParseMSAsmIdentifier(llvm::SmallVectorImpl<Token> &LineToks, LineToks.pop_back(); LineToks.pop_back(); - // Perform the lookup. - return Actions.LookupInlineAsmIdentifier(SS, TemplateKWLoc, Id, Info, - IsUnevaluatedContext); + return Result; } /// Turn a sequence of our tokens back into a string that we can hand |