summaryrefslogtreecommitdiffstats
path: root/include/clang/Basic/PartialDiagnostic.h
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-06-18 22:45:06 +0000
committerChris Lattner <sabre@nondot.org>2010-06-18 22:45:06 +0000
commit0a76aae8c03cb7dd7bdbe683485560afaf695959 (patch)
treebe02325d4dbabf2f026a3297efe51a3e3511fa05 /include/clang/Basic/PartialDiagnostic.h
parent96fb42ea29253cf2b34848dfdb3e40ef14ca8ebc (diff)
introduce a new CharSourceRange class, and enhance the diagnostics routines
to use them instead of SourceRange. CharSourceRange is just a SourceRange plus a bool that indicates whether the range has the end character resolved or whether the end location is the start of the end token. While most of the compiler wants to think of ranges that have ends that are the start of the end token, the printf diagnostic stuff wants to highlight ranges within tokens. This is transparent to the diagnostic stuff. To start taking advantage of the new capabilities, you can do something like this: Diag(..) << CharSourceRange::getCharRange(Begin,End) git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106338 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Basic/PartialDiagnostic.h')
-rw-r--r--include/clang/Basic/PartialDiagnostic.h12
1 files changed, 9 insertions, 3 deletions
diff --git a/include/clang/Basic/PartialDiagnostic.h b/include/clang/Basic/PartialDiagnostic.h
index 89fae87ae8..cd0da97e2b 100644
--- a/include/clang/Basic/PartialDiagnostic.h
+++ b/include/clang/Basic/PartialDiagnostic.h
@@ -59,7 +59,7 @@ public:
/// DiagRanges - The list of ranges added to this diagnostic. It currently
/// only support 10 ranges, could easily be extended if needed.
- SourceRange DiagRanges[10];
+ CharSourceRange DiagRanges[10];
enum { MaxFixItHints = 3 };
@@ -142,7 +142,7 @@ private:
DiagStorage = 0;
}
- void AddSourceRange(const SourceRange &R) const {
+ void AddSourceRange(const CharSourceRange &R) const {
if (!DiagStorage)
DiagStorage = getStorage();
@@ -264,10 +264,16 @@ public:
friend inline const PartialDiagnostic &operator<<(const PartialDiagnostic &PD,
const SourceRange &R) {
- PD.AddSourceRange(R);
+ PD.AddSourceRange(CharSourceRange::getTokenRange(R));
return PD;
}
+ friend inline const PartialDiagnostic &operator<<(const PartialDiagnostic &PD,
+ const CharSourceRange &R) {
+ PD.AddSourceRange(R);
+ return PD;
+ }
+
friend const PartialDiagnostic &operator<<(const PartialDiagnostic &PD,
const FixItHint &Hint) {
PD.AddFixItHint(Hint);