Hi klimek,
http://reviews.llvm.org/D3620
Files:
clang-tidy/ClangTidyDiagnosticConsumer.cpp
test/clang-tidy/diagnostic.cpp
Index: clang-tidy/ClangTidyDiagnosticConsumer.cpp
===================================================================
--- clang-tidy/ClangTidyDiagnosticConsumer.cpp
+++ clang-tidy/ClangTidyDiagnosticConsumer.cpp
@@ -239,7 +239,10 @@
if (FID == Sources.getMainFileID())
return true;
- return HeaderFilter.match(Sources.getFileEntryForID(FID)->getName());
+ const FileEntry *File = Sources.getFileEntryForID(FID);
+ // -DMACRO definitions on the command line have locations in a virtual buffer
+ // that doesn't have a FileEntry. Don't skip these as well.
+ return !File || HeaderFilter.match(File->getName());
}
struct LessClangTidyError {
Index: test/clang-tidy/diagnostic.cpp
===================================================================
--- test/clang-tidy/diagnostic.cpp
+++ test/clang-tidy/diagnostic.cpp
@@ -1,6 +1,7 @@
// RUN: clang-tidy -disable-checks='' %s.nonexistent.cpp -- | FileCheck
-check-prefix=CHECK1 %s
// RUN: clang-tidy -disable-checks='' %s -- -fan-unknown-option | FileCheck
-check-prefix=CHECK2 %s
// RUN: clang-tidy
-checks='(google-explicit-constructor|clang-diagnostic-literal-conversion)'
-disable-checks='' %s -- -fan-unknown-option | FileCheck -check-prefix=CHECK3 %s
+// RUN: clang-tidy -checks='clang-diagnostic-macro-redefined'
-disable-checks='' %s -- -DMACRO_FROM_COMMAND_LINE | FileCheck
-check-prefix=CHECK4 %s
// CHECK1-NOT: warning
// CHECK2-NOT: warning
@@ -19,3 +20,6 @@
// CHECK2-NOT: warning:
// CHECK3-NOT: warning:
+
+#define MACRO_FROM_COMMAND_LINE
+// CHECK4: :[[@LINE-1]]:9: warning: 'MACRO_FROM_COMMAND_LINE' macro redefined
Index: clang-tidy/ClangTidyDiagnosticConsumer.cpp
===================================================================
--- clang-tidy/ClangTidyDiagnosticConsumer.cpp
+++ clang-tidy/ClangTidyDiagnosticConsumer.cpp
@@ -239,7 +239,10 @@
if (FID == Sources.getMainFileID())
return true;
- return HeaderFilter.match(Sources.getFileEntryForID(FID)->getName());
+ const FileEntry *File = Sources.getFileEntryForID(FID);
+ // -DMACRO definitions on the command line have locations in a virtual buffer
+ // that doesn't have a FileEntry. Don't skip these as well.
+ return !File || HeaderFilter.match(File->getName());
}
struct LessClangTidyError {
Index: test/clang-tidy/diagnostic.cpp
===================================================================
--- test/clang-tidy/diagnostic.cpp
+++ test/clang-tidy/diagnostic.cpp
@@ -1,6 +1,7 @@
// RUN: clang-tidy -disable-checks='' %s.nonexistent.cpp -- | FileCheck -check-prefix=CHECK1 %s
// RUN: clang-tidy -disable-checks='' %s -- -fan-unknown-option | FileCheck -check-prefix=CHECK2 %s
// RUN: clang-tidy -checks='(google-explicit-constructor|clang-diagnostic-literal-conversion)' -disable-checks='' %s -- -fan-unknown-option | FileCheck -check-prefix=CHECK3 %s
+// RUN: clang-tidy -checks='clang-diagnostic-macro-redefined' -disable-checks='' %s -- -DMACRO_FROM_COMMAND_LINE | FileCheck -check-prefix=CHECK4 %s
// CHECK1-NOT: warning
// CHECK2-NOT: warning
@@ -19,3 +20,6 @@
// CHECK2-NOT: warning:
// CHECK3-NOT: warning:
+
+#define MACRO_FROM_COMMAND_LINE
+// CHECK4: :[[@LINE-1]]:9: warning: 'MACRO_FROM_COMMAND_LINE' macro redefined
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits