r347372 - clang::tooling::Diagnostic: Don't store offset in the scratch space.
Alexander Kornienko via cfe-commits
cfe-commits at lists.llvm.org
Tue Nov 20 17:08:46 PST 2018
Author: alexfh
Date: Tue Nov 20 17:08:46 2018
New Revision: 347372
URL: http://llvm.org/viewvc/llvm-project?rev=347372&view=rev
Log:
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.
Modified:
cfe/trunk/lib/Tooling/Core/Diagnostic.cpp
Modified: cfe/trunk/lib/Tooling/Core/Diagnostic.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Core/Diagnostic.cpp?rev=347372&r1=347371&r2=347372&view=diff
==============================================================================
--- cfe/trunk/lib/Tooling/Core/Diagnostic.cpp (original)
+++ cfe/trunk/lib/Tooling/Core/Diagnostic.cpp Tue Nov 20 17:08:46 2018
@@ -23,10 +23,15 @@ DiagnosticMessage::DiagnosticMessage(llv
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,
More information about the cfe-commits
mailing list