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

Daniel Jasper djasper at google.com
Thu Feb 6 04:06:18 PST 2014



================
Comment at: clang-tidy/ClangTidy.cpp:292
@@ +291,3 @@
+static SourceLocation getLocation(SourceManager &SourceMgr, StringRef FilePath,
+                           unsigned Offset) {
+  SourceLocation Loc;
----------------
Fix the indentation.

================
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);
----------------
Maybe assert that file is != NULL?

================
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);
----------------
Use SourceManager::translateFile?

================
Comment at: clang-tidy/ClangTidyDiagnosticConsumer.h:132
@@ -130,2 +131,3 @@
   SmallVector<ClangTidyError, 8> Errors;
+  SmallVector<bool, 8> RelatesToUserCode;
 };
----------------
Why not store this inside the ClangTidyError?

Or even on step further, why do we store ClangTidyErrors that don't relate to user code in the first place? Then all we'd need is a bool variable that stores whether the last non-Note error was related to user code so that we can drop uninteresting Notes. Or am I missing something?


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



More information about the cfe-commits mailing list