Added a naive NOLINT implementation.
Summary: Added a naive NOLINT implementation. It doesn't care about specific linter categories, just the "// NOLINT" on the same line as a diagnostic. Reviewers: klimek Reviewed By: klimek CC: cfe-commits Differential Revision: http://llvm-reviews.chandlerc.com/D2896 llvm-svn: 202452
This commit is contained in:
parent
940ab934d4
commit
31219d3abd
|
|
@ -39,7 +39,20 @@ ClangTidyError::ClangTidyError(StringRef CheckName,
|
|||
|
||||
DiagnosticBuilder ClangTidyContext::diag(
|
||||
StringRef CheckName, SourceLocation Loc, StringRef Description,
|
||||
DiagnosticIDs::Level Level /* = DiagnosticsEngine::Warning*/) {
|
||||
DiagnosticIDs::Level Level /* = DiagnosticIDs::Warning*/) {
|
||||
assert(Loc.isValid());
|
||||
bool Invalid;
|
||||
const char *CharacterData =
|
||||
DiagEngine->getSourceManager().getCharacterData(Loc, &Invalid);
|
||||
if (!Invalid) {
|
||||
const char *P = CharacterData;
|
||||
while (*P != '\0' && *P != '\r' && *P != '\n')
|
||||
++P;
|
||||
StringRef RestOfLine(CharacterData, P - CharacterData + 1);
|
||||
// FIXME: Handle /\bNOLINT\b(\([^)]*\))?/ as cpplint.py does.
|
||||
if (RestOfLine.find("NOLINT") != StringRef::npos)
|
||||
Level = DiagnosticIDs::Ignored;
|
||||
}
|
||||
unsigned ID = DiagEngine->getDiagnosticIDs()->getCustomDiagID(
|
||||
Level, (Description + " [" + CheckName + "]").str());
|
||||
if (CheckNamesByDiagnosticID.count(ID) == 0)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,10 @@
|
|||
// RUN: clang-tidy -checks=google-explicit-constructor %s -- | FileCheck %s
|
||||
|
||||
class A { A(int i); };
|
||||
// CHECK: :[[@LINE-1]]:11: warning: Single-argument constructors must be explicit [google-explicit-constructor]
|
||||
|
||||
class B { B(int i); }; // NOLINT
|
||||
// CHECK-NOT: :[[@LINE-1]]:11: warning: Single-argument constructors must be explicit [google-explicit-constructor]
|
||||
|
||||
class C { C(int i); }; // NOLINT(we-dont-care-about-categories-yet)
|
||||
// CHECK-NOT: :[[@LINE-1]]:11: warning: Single-argument constructors must be explicit [google-explicit-constructor]
|
||||
Loading…
Reference in New Issue