[PATCH] Improve clang-tidy diagnostic output and filtering.
Alexander Kornienko
alexfh at google.com
Thu Feb 6 07:06:59 PST 2014
================
Comment at: clang-tidy/ClangTidy.cpp:295
@@ +294,3 @@
+ if (!FilePath.empty()) {
+ const FileEntry *File = SourceMgr.getFileManager().getFile(FilePath);
+ FileID ID = SourceMgr.createFileID(File, SourceLocation(), SrcMgr::C_User);
----------------
Daniel Jasper wrote:
> Alexander Kornienko wrote:
> > Daniel Jasper wrote:
> > > Maybe assert that file is != NULL?
> > If you mean to assert instead of "if (!FilePath.empty())", then it's a bad idea, as we need to handle errors without locations, e.g. related to command line arguments.
> >
> > If you mean to just add an assertion, then it will be redundant, as one of the functions called by createFileID already assert that file is not NULL.
> I meant the latter. If you say it is redundant .. Ok. I still think it would be a good use for an assert.
Err, I've seen this comment _after_ committing the patch.
Does this look good?
Index: clang-tidy/ClangTidy.cpp
===================================================================
--- clang-tidy/ClangTidy.cpp (revision 200924)
+++ clang-tidy/ClangTidy.cpp (working copy)
@@ -294,6 +294,7 @@
return SourceLocation();
const FileEntry *File = SourceMgr.getFileManager().getFile(FilePath);
+ assert(File != NULL && "Invalid file name.");
FileID ID = SourceMgr.createFileID(File, SourceLocation(), SrcMgr::C_User);
return SourceMgr.getLocForStartOfFile(ID).getLocWithOffset(Offset);
}
http://llvm-reviews.chandlerc.com/D2714
COMMIT
http://llvm-reviews.chandlerc.com/rL200924
More information about the cfe-commits
mailing list