llvm.org GIT mirror llvm / e6f6980
ms-inline-asm: Fix parsing label names inside bracket expressions Summary: This fixes a couple of issues. One is ensuring that AOK_Label rewrite rules have a lower priority than AOK_Skip rules, as AOK_Skip needs to be able to skip the brackets properly. The other part of the fix ensures that we don't overwrite Identifier when looking up the identifier, and that we use the locally available information to generate the AOK_Label rewrite in ParseIntelIdentifier. Doing that in CreateMemForInlineAsm would be problematic since the Start location there may point to the beginning of a bracket expression, and not necessarily the beginning of an identifier. This also means that we don't need to carry around the InternlName field, which helps simplify the code. Test Plan: This will be tested on the clang side. Reviewers: rnk Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D5445 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218270 91177308-0d34-0410-b5e6-96231b3b80d8 Ehsan Akhgari 6 years ago
3 changed file(s) with 17 addition(s) and 20 deletion(s). Raw diff Collapse all Expand all
3434 void *OpDecl;
3535 bool IsVarDecl;
3636 unsigned Length, Size, Type;
37 StringRef InternalName;
3837
3938 void clear() {
4039 OpDecl = nullptr;
4241 Length = 1;
4342 Size = 0;
4443 Type = 0;
45 InternalName = "";
4644 }
4745 };
4846
4343
4444 const char AsmRewritePrecedence [] = {
4545 0, // AOK_Delete
46 1, // AOK_Align
47 1, // AOK_DotOperator
48 1, // AOK_Emit
49 3, // AOK_Imm
50 3, // AOK_ImmPrefix
51 2, // AOK_Input
52 2, // AOK_Output
53 4, // AOK_SizeDirective
46 2, // AOK_Align
47 2, // AOK_DotOperator
48 2, // AOK_Emit
49 4, // AOK_Imm
50 4, // AOK_ImmPrefix
51 3, // AOK_Input
52 3, // AOK_Output
53 5, // AOK_SizeDirective
5454 1, // AOK_Label
55 1 // AOK_Skip
55 2 // AOK_Skip
5656 };
5757
5858 struct AsmRewrite {
10461046 InstInfo->AsmRewrites->push_back(AsmRewrite(AOK_SizeDirective, Start,
10471047 /*Len=*/0, Size));
10481048 }
1049 if (!Info.InternalName.empty()) {
1050 // Push a rewrite for replacing the identifier name with the internal name.
1051 InstInfo->AsmRewrites->push_back(AsmRewrite(AOK_Label, Start,
1052 End.getPointer() - Start.getPointer(),
1053 Info.InternalName));
1054 }
10551049 }
10561050
10571051 // When parsing inline assembly we set the base register to a non-zero value
13461340 // If the identifier lookup was unsuccessful, assume that we are dealing with
13471341 // a label.
13481342 if (!Result) {
1349 Identifier = SemaCallback->LookupInlineAsmLabel(Identifier, getSourceManager(), Loc, false);
1350 assert(Identifier.size() && "We should have an internal name here.");
1351 Info.InternalName = Identifier;
1343 StringRef InternalName =
1344 SemaCallback->LookupInlineAsmLabel(Identifier, getSourceManager(),
1345 Loc, false);
1346 assert(InternalName.size() && "We should have an internal name here.");
1347 // Push a rewrite for replacing the identifier name with the internal name.
1348 InstInfo->AsmRewrites->push_back(AsmRewrite(AOK_Label, Loc,
1349 Identifier.size(),
1350 InternalName));
13521351 }
13531352
13541353 // Create the symbol reference.