[PATCH] D59135: Add check for matching HeaderFilter before emitting Diagnostic
Alexander Kornienko via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Mar 13 06:53:51 PDT 2019
alexfh requested changes to this revision.
alexfh added inline comments.
This revision now requires changes to proceed.
================
Comment at: clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp:453
+
+ StringRef FileName(Loc.printToString(Loc.getManager()));
+ if(getHeaderFilter()->match(FileName))
----------------
That'll result in a dangling pointer. `SourceLocation::printToString` returns a temporary std::string that will be destroyed at the end of expression, but `FileName` will point to its data.
Also, the `printToString` method will contain much more than just the filename. `SourceManager::getPresumedLoc` should do a better job here.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D59135/new/
https://reviews.llvm.org/D59135
More information about the cfe-commits
mailing list