diff options
author | Chris Lattner <sabre@nondot.org> | 2009-02-17 05:19:10 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-02-17 05:19:10 +0000 |
commit | 34837a577186f5d05ff434841e19694c438b9ac3 (patch) | |
tree | 4d6afaeda09550a48a435c40c6b7aec793aaf51a | |
parent | 3891a157cc1504b1e8558077ed852fa4a9fb6ebc (diff) |
If a source range comes through a function-like macro expansion,
highlight the arguments to the macro as well as the identifier.
Before:
t.c:3:9: error: no matching function for call to '__tg_acos'; candidates are:
return acos(x);
^~~~
after:
t.c:3:9: error: no matching function for call to '__tg_acos'; candidates are:
return acos(x);
^~~~~~~
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64743 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Driver/TextDiagnosticPrinter.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/Driver/TextDiagnosticPrinter.cpp b/lib/Driver/TextDiagnosticPrinter.cpp index 6be362399e..fb0e49e6cb 100644 --- a/lib/Driver/TextDiagnosticPrinter.cpp +++ b/lib/Driver/TextDiagnosticPrinter.cpp @@ -45,6 +45,14 @@ void TextDiagnosticPrinter::HighlightRange(const SourceRange &R, SourceLocation Begin = SM.getInstantiationLoc(R.getBegin()); SourceLocation End = SM.getInstantiationLoc(R.getEnd()); + // If the End location and the start location are the same and are a macro + // location, then the range was something that came from a macro expansion + // or _Pragma. If this is an object-like macro, the best we can do is to + // highlight the range. If this is a function-like macro, we'd also like to + // highlight the arguments. + if (Begin == End && R.getEnd().isMacroID()) + End = SM.getInstantiationRange(R.getEnd()).second; + unsigned StartLineNo = SM.getInstantiationLineNumber(Begin); if (StartLineNo > LineNo || SM.getFileID(Begin) != FID) return; // No intersection. |