summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorAlexander Kornienko <alexfh@google.com>2018-11-21 01:08:46 +0000
committerAlexander Kornienko <alexfh@google.com>2018-11-21 01:08:46 +0000
commitb2ac7eec4270bc84d0caa86375cbff5cf116408f (patch)
treebadccb6c28435649f7308da835d6942e39ca1ac4 /clang/lib
parentaf17a3866b9bc426fefd4ca40e297d9878ed20ee (diff)
downloadbcm5719-llvm-b2ac7eec4270bc84d0caa86375cbff5cf116408f.tar.gz
bcm5719-llvm-b2ac7eec4270bc84d0caa86375cbff5cf116408f.zip
clang::tooling::Diagnostic: Don't store offset in the scratch space.
These offsets are useless (and even harmful in certain cases) in exported diagnostics. The test will be added to clang-tidy, since it's the main user of the clang::tooling::Diagnostic class. llvm-svn: 347372
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Tooling/Core/Diagnostic.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/clang/lib/Tooling/Core/Diagnostic.cpp b/clang/lib/Tooling/Core/Diagnostic.cpp
index 9e4833f2eff..e3a33d9a375 100644
--- a/clang/lib/Tooling/Core/Diagnostic.cpp
+++ b/clang/lib/Tooling/Core/Diagnostic.cpp
@@ -23,10 +23,15 @@ DiagnosticMessage::DiagnosticMessage(llvm::StringRef Message)
DiagnosticMessage::DiagnosticMessage(llvm::StringRef Message,
const SourceManager &Sources,
SourceLocation Loc)
- : Message(Message) {
+ : Message(Message), FileOffset(0) {
assert(Loc.isValid() && Loc.isFileID());
FilePath = Sources.getFilename(Loc);
- FileOffset = Sources.getFileOffset(Loc);
+
+ // Don't store offset in the scratch space. It doesn't tell anything to the
+ // user. Moreover, it depends on the history of macro expansions and thus
+ // prevents deduplication of warnings in headers.
+ if (!FilePath.empty())
+ FileOffset = Sources.getFileOffset(Loc);
}
Diagnostic::Diagnostic(llvm::StringRef DiagnosticName,
OpenPOWER on IntegriCloud