[PATCH] Improve clang-tidy diagnostic output and filtering.

Daniel Jasper djasper at google.com
Thu Feb 6 06:52:55 PST 2014


  I think this is a much cleaner solution. Thanks!


================
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);
----------------
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.

================
Comment at: clang-tidy/ClangTidy.cpp:296
@@ +295,3 @@
+    const FileEntry *File = SourceMgr.getFileManager().getFile(FilePath);
+    FileID ID = SourceMgr.createFileID(File, SourceLocation(), SrcMgr::C_User);
+    Loc = SourceMgr.getLocForStartOfFile(ID);
----------------
Alexander Kornienko wrote:
> Daniel Jasper wrote:
> > Use SourceManager::translateFile?
> An attempt to use translateFile results in the following assertion:
> 
>   tools/clang/lib/Basic/SourceManager.cpp:841: clang::FileID clang::SourceManager::getFileIDLoaded(unsigned int) const: Assertion `0 && "Invalid SLocOffset or bad function choice"' failed.
> 
> I didn't investigate this, but I'm inclined to believe this was a "bad function choice".
And you simply moved the code, so this is unrelated to this CL. Sorry for the noise.


http://llvm-reviews.chandlerc.com/D2714

BRANCH
  svn

ARCANIST PROJECT
  clang-tools-extra



More information about the cfe-commits mailing list