diff options
author | Chih-Hung Hsieh <chh@google.com> | 2017-07-12 16:25:40 +0000 |
---|---|---|
committer | Chih-Hung Hsieh <chh@google.com> | 2017-07-12 16:25:40 +0000 |
commit | 322e8c2bc12085b084eae364c8afd97d827f9c20 (patch) | |
tree | 75c252441faa854ee737d2c9d214e9ed1a73de2b /clang/lib/Frontend/TextDiagnostic.cpp | |
parent | 76eb647e1eaa6120e068d21e79606426d20622b9 (diff) | |
download | bcm5719-llvm-322e8c2bc12085b084eae364c8afd97d827f9c20.tar.gz bcm5719-llvm-322e8c2bc12085b084eae364c8afd97d827f9c20.zip |
[clang] buildFixItInsertionLine should use Hints of the same FID and LineNo
Fix bug https://bugs.llvm.org/show_bug.cgi?id=33734
Differential Revision: https://reviews.llvm.org/D35230
llvm-svn: 307809
Diffstat (limited to 'clang/lib/Frontend/TextDiagnostic.cpp')
-rw-r--r-- | clang/lib/Frontend/TextDiagnostic.cpp | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/clang/lib/Frontend/TextDiagnostic.cpp b/clang/lib/Frontend/TextDiagnostic.cpp index 1e12ea5e597..6a72b00c602 100644 --- a/clang/lib/Frontend/TextDiagnostic.cpp +++ b/clang/lib/Frontend/TextDiagnostic.cpp @@ -1052,7 +1052,8 @@ static void highlightRange(const CharSourceRange &R, std::fill(CaretLine.begin()+StartColNo,CaretLine.begin()+EndColNo,'~'); } -static std::string buildFixItInsertionLine(unsigned LineNo, +static std::string buildFixItInsertionLine(FileID FID, + unsigned LineNo, const SourceColumnMap &map, ArrayRef<FixItHint> Hints, const SourceManager &SM, @@ -1069,7 +1070,8 @@ static std::string buildFixItInsertionLine(unsigned LineNo, // code contains no newlines and is on the same line as the caret. std::pair<FileID, unsigned> HintLocInfo = SM.getDecomposedExpansionLoc(I->RemoveRange.getBegin()); - if (LineNo == SM.getLineNumber(HintLocInfo.first, HintLocInfo.second) && + if (FID == HintLocInfo.first && + LineNo == SM.getLineNumber(HintLocInfo.first, HintLocInfo.second) && StringRef(I->CodeToInsert).find_first_of("\n\r") == StringRef::npos) { // Insert the new code into the line just below the code // that the user wrote. @@ -1105,9 +1107,6 @@ static std::string buildFixItInsertionLine(unsigned LineNo, PrevHintEndCol = HintCol + llvm::sys::locale::columnWidth(I->CodeToInsert); - } else { - FixItInsertionLine.clear(); - break; } } } @@ -1222,7 +1221,7 @@ void TextDiagnostic::emitSnippetAndCaret( } std::string FixItInsertionLine = buildFixItInsertionLine( - LineNo, sourceColMap, Hints, SM, DiagOpts.get()); + FID, LineNo, sourceColMap, Hints, SM, DiagOpts.get()); // If the source line is too long for our terminal, select only the // "interesting" source region within that line. |