Skip to content

Commit 6a4207d

Browse files
committed
ARM IAS: allow more depth in contextual diagnostics
Switch the context to be SmallVectors. This allows for saving additional context when providing previous emission sites. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198665 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent a83f45b commit 6a4207d

File tree

2 files changed

+60
-20
lines changed

2 files changed

+60
-20
lines changed

lib/Target/ARM/AsmParser/ARMAsmParser.cpp

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -116,46 +116,56 @@ typedef MapVector<const MCSection *, ConstantPool> ConstantPoolMapTy;
116116
class UnwindContext {
117117
MCAsmParser &Parser;
118118

119-
SMLoc FnStartLoc;
120-
SMLoc CantUnwindLoc;
121-
SMLoc PersonalityLoc;
122-
SMLoc HandlerDataLoc;
119+
typedef SmallVector<SMLoc, 4> Locs;
120+
121+
Locs FnStartLocs;
122+
Locs CantUnwindLocs;
123+
Locs PersonalityLocs;
124+
Locs HandlerDataLocs;
123125
int FPReg;
124126

125127
public:
126128
UnwindContext(MCAsmParser &P) : Parser(P), FPReg(-1) {}
127129

128-
bool hasFnStart() const { return FnStartLoc.isValid(); }
129-
bool cantUnwind() const { return CantUnwindLoc.isValid(); }
130-
bool hasHandlerData() const { return HandlerDataLoc.isValid(); }
131-
bool hasPersonality() const { return PersonalityLoc.isValid(); }
130+
bool hasFnStart() const { return !FnStartLocs.empty(); }
131+
bool cantUnwind() const { return !CantUnwindLocs.empty(); }
132+
bool hasHandlerData() const { return !HandlerDataLocs.empty(); }
133+
bool hasPersonality() const { return !PersonalityLocs.empty(); }
132134

133-
void recordFnStart(SMLoc L) { FnStartLoc = L; }
134-
void recordCantUnwind(SMLoc L) { CantUnwindLoc = L; }
135-
void recordPersonality(SMLoc L) { PersonalityLoc = L; }
136-
void recordHandlerData(SMLoc L) { HandlerDataLoc = L; }
135+
void recordFnStart(SMLoc L) { FnStartLocs.push_back(L); }
136+
void recordCantUnwind(SMLoc L) { CantUnwindLocs.push_back(L); }
137+
void recordPersonality(SMLoc L) { PersonalityLocs.push_back(L); }
138+
void recordHandlerData(SMLoc L) { HandlerDataLocs.push_back(L); }
137139

138140
void saveFPReg(int Reg) { FPReg = Reg; }
139141
int getFPReg() const { return FPReg; }
140142

141143
void emitFnStartLocNotes() const {
142-
Parser.Note(FnStartLoc, ".fnstart was specified here");
144+
for (Locs::const_iterator FI = FnStartLocs.begin(), FE = FnStartLocs.end();
145+
FI != FE; ++FI)
146+
Parser.Note(*FI, ".fnstart was specified here");
143147
}
144148
void emitCantUnwindLocNotes() const {
145-
Parser.Note(CantUnwindLoc, ".cantunwind was specified here");
149+
for (Locs::const_iterator UI = CantUnwindLocs.begin(),
150+
UE = CantUnwindLocs.end(); UI != UE; ++UI)
151+
Parser.Note(*UI, ".cantunwind was specified here");
146152
}
147153
void emitHandlerDataLocNotes() const {
148-
Parser.Note(HandlerDataLoc, ".handlerdata was specified here");
154+
for (Locs::const_iterator HI = HandlerDataLocs.begin(),
155+
HE = HandlerDataLocs.end(); HI != HE; ++HI)
156+
Parser.Note(*HI, ".handlerdata was specified here");
149157
}
150158
void emitPersonalityLocNotes() const {
151-
Parser.Note(PersonalityLoc, ".personality was specified here");
159+
for (Locs::const_iterator PI = PersonalityLocs.begin(),
160+
PE = PersonalityLocs.end(); PI != PE; ++PI)
161+
Parser.Note(*PI, ".personality was specified here");
152162
}
153163

154164
void reset() {
155-
FnStartLoc = SMLoc();
156-
CantUnwindLoc = SMLoc();
157-
PersonalityLoc = SMLoc();
158-
HandlerDataLoc = SMLoc();
165+
FnStartLocs = Locs();
166+
CantUnwindLocs = Locs();
167+
PersonalityLocs = Locs();
168+
HandlerDataLocs = Locs();
159169
FPReg = -1;
160170
}
161171
};
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
@ RUN: not llvm-mc -triple armv7-eabi -filetype asm -o /dev/null 2>&1 %s \
2+
@ RUN: | FileCheck %s
3+
4+
.syntax unified
5+
.thumb
6+
7+
.text
8+
9+
.global multiple_personality_disorder
10+
.type multiple_personality_disorder,%function
11+
multiple_personality_disorder:
12+
.fnstart
13+
.personality __gcc_personality_v0
14+
.personality __gxx_personality_v0
15+
.personality __gxx_personality_sj0
16+
.cantunwind
17+
18+
@ CHECK: error: .cantunwind can't be used with .personality directive
19+
@ CHECK: .cantunwind
20+
@ CHECK: ^
21+
@ CHECK: note: .personality was specified here
22+
@ CHECK: .personality __gcc_personality_v0
23+
@ CHECK: ^
24+
@ CHECK: note: .personality was specified here
25+
@ CHECK: .personality __gxx_personality_v0
26+
@ CHECK: ^
27+
@ CHECK: note: .personality was specified here
28+
@ CHECK: .personality __gxx_personality_sj0
29+
@ CHECK: ^
30+

0 commit comments

Comments
 (0)