[PATCH] ARM IAS: allow more depth in contextual diagnostics
Saleem Abdulrasool
compnerd at compnerd.org
Fri Dec 27 22:59:36 PST 2013
Hi logan, rengolin, t.p.northover,
Switch the context to be SmallVectors. This allows for saving additional
context when providing previous emission sites.
http://llvm-reviews.chandlerc.com/D2487
Files:
lib/Target/ARM/AsmParser/ARMAsmParser.cpp
test/MC/ARM/unwind-stack-diagnostics.s
Index: lib/Target/ARM/AsmParser/ARMAsmParser.cpp
===================================================================
--- lib/Target/ARM/AsmParser/ARMAsmParser.cpp
+++ lib/Target/ARM/AsmParser/ARMAsmParser.cpp
@@ -114,46 +114,56 @@
class UnwindContext {
MCAsmParser &Parser;
- SMLoc FnStartLoc;
- SMLoc CantUnwindLoc;
- SMLoc PersonalityLoc;
- SMLoc HandlerDataLoc;
+ typedef SmallVector<SMLoc, 4> Locs;
+
+ Locs FnStartLocs;
+ Locs CantUnwindLocs;
+ Locs PersonalityLocs;
+ Locs HandlerDataLocs;
int FPReg;
public:
UnwindContext(MCAsmParser &P) : Parser(P), FPReg(ARM::SP) {}
- bool isValid() const { return FnStartLoc.isValid(); }
- bool cantUnwind() const { return CantUnwindLoc.isValid(); }
- bool hasHandlerData() const { return HandlerDataLoc.isValid(); }
- bool hasPersonality() const { return PersonalityLoc.isValid(); }
+ bool isValid() const { return !FnStartLocs.empty(); }
+ bool cantUnwind() const { return !CantUnwindLocs.empty(); }
+ bool hasHandlerData() const { return !HandlerDataLocs.empty(); }
+ bool hasPersonality() const { return !PersonalityLocs.empty(); }
- void recordFnStart(SMLoc L) { FnStartLoc = L; }
- void recordCantUnwind(SMLoc L) { CantUnwindLoc = L; }
- void recordPersonality(SMLoc L) { PersonalityLoc = L; }
- void recordHandlerData(SMLoc L) { HandlerDataLoc = L; }
+ void recordFnStart(SMLoc L) { FnStartLocs.push_back(L); }
+ void recordCantUnwind(SMLoc L) { CantUnwindLocs.push_back(L); }
+ void recordPersonality(SMLoc L) { PersonalityLocs.push_back(L); }
+ void recordHandlerData(SMLoc L) { HandlerDataLocs.push_back(L); }
void saveFPReg(int Reg) { FPReg = Reg; }
int getFPReg() const { return FPReg; }
void emitFnStartLocNotes() const {
- Parser.Note(FnStartLoc, ".fnstart was specified here");
+ for (Locs::const_iterator FI = FnStartLocs.begin(), FE = FnStartLocs.end();
+ FI != FE; ++FI)
+ Parser.Note(*FI, ".fnstart was specified here");
}
void emitCantUnwindLocNotes() const {
- Parser.Note(CantUnwindLoc, ".cantunwind was specified here");
+ for (Locs::const_iterator UI = CantUnwindLocs.begin(),
+ UE = CantUnwindLocs.end(); UI != UE; ++UI)
+ Parser.Note(*UI, ".cantunwind was specified here");
}
void emitHandlerDataLocNotes() const {
- Parser.Note(HandlerDataLoc, ".handlerdata was specified here");
+ for (Locs::const_iterator HI = HandlerDataLocs.begin(),
+ HE = HandlerDataLocs.end(); HI != HE; ++HI)
+ Parser.Note(*HI, ".handlerdata was specified here");
}
void emitPersonalityLocNotes() const {
- Parser.Note(PersonalityLoc, ".personality was specified here");
+ for (Locs::const_iterator PI = PersonalityLocs.begin(),
+ PE = PersonalityLocs.end(); PI != PE; ++PI)
+ Parser.Note(*PI, ".personality was specified here");
}
void reset() {
- FnStartLoc = SMLoc();
- CantUnwindLoc = SMLoc();
- PersonalityLoc = SMLoc();
- HandlerDataLoc = SMLoc();
+ FnStartLocs = Locs();
+ CantUnwindLocs = Locs();
+ PersonalityLocs = Locs();
+ HandlerDataLocs = Locs();
FPReg = ARM::SP;
}
};
Index: test/MC/ARM/unwind-stack-diagnostics.s
===================================================================
--- /dev/null
+++ test/MC/ARM/unwind-stack-diagnostics.s
@@ -0,0 +1,30 @@
+@ RUN: not llvm-mc -triple armv7-eabi -filetype asm -o /dev/null 2>&1 %s \
+@ RUN: | FileCheck %s
+
+ .syntax unified
+ .thumb
+
+ .text
+
+ .global multiple_personality_disorder
+ .type multiple_personality_disorder,%function
+multiple_personality_disorder:
+ .fnstart
+ .personality __aeabi_unwind_cpp_pr0
+ .personality __aeabi_unwind_cpp_pr1
+ .personality __aeabi_unwind_cpp_pr2
+ .cantunwind
+
+@ CHECK: error: .cantunwind can't be used with .personality directive
+@ CHECK: .cantunwind
+@ CHECK: ^
+@ CHECK: note: .personality was specified here
+@ CHECK: .personality __aeabi_unwind_cpp_pr0
+@ CHECK: ^
+@ CHECK: note: .personality was specified here
+@ CHECK: .personality __aeabi_unwind_cpp_pr1
+@ CHECK: ^
+@ CHECK: note: .personality was specified here
+@ CHECK: .personality __aeabi_unwind_cpp_pr2
+@ CHECK: ^
+
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D2487.1.patch
Type: text/x-patch
Size: 4200 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20131227/71a4d832/attachment.bin>
More information about the llvm-commits
mailing list