forked from OSchip/llvm-project
Fix a crash when diagnostic points to a macro definition on command line.
Reviewers: klimek Reviewed By: klimek Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D3620 llvm-svn: 208068
This commit is contained in:
parent
ddb2fde175
commit
238795e9c6
|
@ -239,7 +239,10 @@ bool ClangTidyDiagnosticConsumer::relatesToUserCode(SourceLocation Location) {
|
|||
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 {
|
||||
|
|
|
@ -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 @@ class A { A(int) {} };
|
|||
|
||||
// CHECK2-NOT: warning:
|
||||
// CHECK3-NOT: warning:
|
||||
|
||||
#define MACRO_FROM_COMMAND_LINE
|
||||
// CHECK4: :[[@LINE-1]]:9: warning: 'MACRO_FROM_COMMAND_LINE' macro redefined
|
||||
|
|
Loading…
Reference in New Issue