summaryrefslogtreecommitdiff
path: root/lib/Tooling/Core/Diagnostic.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Tooling/Core/Diagnostic.cpp')
-rw-r--r--lib/Tooling/Core/Diagnostic.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/Tooling/Core/Diagnostic.cpp b/lib/Tooling/Core/Diagnostic.cpp
index 9e4833f2eff4d..e3a33d9a37556 100644
--- a/lib/Tooling/Core/Diagnostic.cpp
+++ b/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,