forked from OSchip/llvm-project
Never filter-out compile errors in clang-tidy, display them as errors.
Summary: No filters should affect the display of errors. Fixed a few tests, which had compile errors. We need to think what we should do with mapped errors (-Werror). Reviewers: klimek Reviewed By: klimek Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D3982 llvm-svn: 210044
This commit is contained in:
parent
fbf9258582
commit
348cae8e2b
|
@ -336,8 +336,9 @@ ClangTidyStats runClangTidy(const ClangTidyOptions &Options,
|
|||
void handleErrors(const std::vector<ClangTidyError> &Errors, bool Fix) {
|
||||
ErrorReporter Reporter(Fix);
|
||||
for (const ClangTidyError &Error : Errors) {
|
||||
Reporter.reportDiagnostic(Error.Message, DiagnosticsEngine::Warning,
|
||||
&Error.Fix);
|
||||
Reporter.reportDiagnostic(
|
||||
Error.Message, static_cast<DiagnosticsEngine::Level>(Error.DiagLevel),
|
||||
&Error.Fix);
|
||||
for (const ClangTidyMessage &Note : Error.Notes)
|
||||
Reporter.reportDiagnostic(Note, DiagnosticsEngine::Note);
|
||||
}
|
||||
|
|
|
@ -109,7 +109,9 @@ ClangTidyMessage::ClangTidyMessage(StringRef Message,
|
|||
FileOffset = Sources.getFileOffset(Loc);
|
||||
}
|
||||
|
||||
ClangTidyError::ClangTidyError(StringRef CheckName) : CheckName(CheckName) {}
|
||||
ClangTidyError::ClangTidyError(StringRef CheckName,
|
||||
ClangTidyError::Level DiagLevel)
|
||||
: CheckName(CheckName), DiagLevel(DiagLevel) {}
|
||||
|
||||
// Returns true if GlobList starts with the negative indicator ('-'), removes it
|
||||
// from the GlobList.
|
||||
|
@ -214,7 +216,8 @@ ClangTidyDiagnosticConsumer::ClangTidyDiagnosticConsumer(ClangTidyContext &Ctx)
|
|||
void ClangTidyDiagnosticConsumer::finalizeLastError() {
|
||||
if (!Errors.empty()) {
|
||||
ClangTidyError &Error = Errors.back();
|
||||
if (!Context.getChecksFilter().isCheckEnabled(Error.CheckName)) {
|
||||
if (!Context.getChecksFilter().isCheckEnabled(Error.CheckName) &&
|
||||
Error.DiagLevel != ClangTidyError::Error) {
|
||||
++Context.Stats.ErrorsIgnoredCheckFilter;
|
||||
Errors.pop_back();
|
||||
} else if (!LastErrorRelatesToUserCode) {
|
||||
|
@ -246,7 +249,14 @@ void ClangTidyDiagnosticConsumer::HandleDiagnostic(
|
|||
? ("clang-diagnostic-" + WarningOption).str()
|
||||
: Context.getCheckName(Info.getID()).str();
|
||||
|
||||
Errors.push_back(ClangTidyError(CheckName));
|
||||
ClangTidyError::Level Level = ClangTidyError::Warning;
|
||||
if (DiagLevel == DiagnosticsEngine::Error ||
|
||||
DiagLevel == DiagnosticsEngine::Fatal) {
|
||||
Level = ClangTidyError::Error;
|
||||
LastErrorRelatesToUserCode = true;
|
||||
LastErrorPassesLineFilter = true;
|
||||
}
|
||||
Errors.push_back(ClangTidyError(CheckName, Level));
|
||||
}
|
||||
|
||||
// FIXME: Provide correct LangOptions for each file.
|
||||
|
|
|
@ -49,12 +49,19 @@ struct ClangTidyMessage {
|
|||
///
|
||||
/// FIXME: Make Diagnostics flexible enough to support this directly.
|
||||
struct ClangTidyError {
|
||||
ClangTidyError(StringRef CheckName);
|
||||
enum Level {
|
||||
Warning = DiagnosticsEngine::Warning,
|
||||
Error = DiagnosticsEngine::Error
|
||||
};
|
||||
|
||||
ClangTidyError(StringRef CheckName, Level DiagLevel);
|
||||
|
||||
std::string CheckName;
|
||||
ClangTidyMessage Message;
|
||||
tooling::Replacements Fix;
|
||||
SmallVector<ClangTidyMessage, 1> Notes;
|
||||
|
||||
Level DiagLevel;
|
||||
};
|
||||
|
||||
/// \brief Filters checks by name.
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
// RUN: clang-tidy -checks='-*,google-explicit-constructor' %s -- | FileCheck %s
|
||||
|
||||
template<typename T>
|
||||
class A { A(T); };
|
||||
// CHECK: :[[@LINE-1]]:11: warning: Single-argument constructors must be explicit [google-explicit-constructor]
|
||||
struct A { A(T); };
|
||||
// CHECK: :[[@LINE-1]]:12: warning: Single-argument constructors must be explicit [google-explicit-constructor]
|
||||
// CHECK-NOT: warning:
|
||||
|
||||
|
||||
void f() {
|
||||
A<int> a;
|
||||
A<double> b;
|
||||
A<int> a(0);
|
||||
A<double> b(0);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// RUN: clang-tidy %s.nonexistent.cpp -- | FileCheck -check-prefix=CHECK1 %s
|
||||
// RUN: clang-tidy -checks='-*,misc-use-override' %s.nonexistent.cpp -- | FileCheck -check-prefix=CHECK1 %s
|
||||
// RUN: clang-tidy -checks='google-explicit-constructor' %s -- -fan-unknown-option | FileCheck -check-prefix=CHECK2 %s
|
||||
// RUN: clang-tidy -checks='-*,google-explicit-constructor,clang-diagnostic-literal-conversion' %s -- -fan-unknown-option | FileCheck -check-prefix=CHECK3 %s
|
||||
// RUN: clang-tidy -checks='-*,misc-use-override,clang-diagnostic-macro-redefined' %s -- -DMACRO_FROM_COMMAND_LINE | FileCheck -check-prefix=CHECK4 %s
|
||||
|
@ -7,8 +7,8 @@
|
|||
// CHECK2-NOT: warning
|
||||
// CHECK3-NOT: warning
|
||||
|
||||
// CHECK1: warning: error reading '{{.*}}.nonexistent.cpp'
|
||||
// CHECK2: warning: unknown argument: '-fan-unknown-option'
|
||||
// CHECK1: error: error reading '{{.*}}.nonexistent.cpp'
|
||||
// CHECK2: error: unknown argument: '-fan-unknown-option'
|
||||
|
||||
// CHECK2: :[[@LINE+2]]:9: warning: implicit conversion from 'double' to 'int' changes value
|
||||
// CHECK3: :[[@LINE+1]]:9: warning: implicit conversion from 'double' to 'int' changes value
|
||||
|
|
|
@ -6,20 +6,21 @@
|
|||
namespace std {
|
||||
|
||||
template <typename T>
|
||||
class unique_ptr {
|
||||
struct unique_ptr {
|
||||
T& operator*() const;
|
||||
T* operator->() const;
|
||||
T* get() const;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
class shared_ptr {
|
||||
struct shared_ptr {
|
||||
T& operator*() const;
|
||||
T* operator->() const;
|
||||
T* get() const;
|
||||
};
|
||||
|
||||
} // namespace std
|
||||
#define NULL __null
|
||||
|
||||
struct int_ptr {
|
||||
int* get();
|
||||
|
|
Loading…
Reference in New Issue