clang-tools
4.0.0
Main Page
Namespaces
Classes
Files
File List
File Members
llvm.src
tools
clang
tools
extra
clang-tidy
misc
StaticAssertCheck.h
Go to the documentation of this file.
1
//===--- StaticAssertCheck.h - clang-tidy -----------------------*- C++ -*-===//
2
//
3
// The LLVM Compiler Infrastructure
4
//
5
// This file is distributed under the University of Illinois Open Source
6
// License. See LICENSE.TXT for details.
7
//
8
//===----------------------------------------------------------------------===//
9
10
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_STATICASSERTCHECK_H
11
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_STATICASSERTCHECK_H
12
13
#include "../ClangTidy.h"
14
#include "llvm/ADT/StringRef.h"
15
#include <string>
16
17
namespace
clang {
18
namespace
tidy {
19
namespace
misc {
20
21
/// Replaces `assert()` with `static_assert()` if the condition is evaluatable
22
/// at compile time.
23
///
24
/// The condition of `static_assert()` is evaluated at compile time which is
25
/// safer and more efficient.
26
class
StaticAssertCheck
:
public
ClangTidyCheck
{
27
public
:
28
StaticAssertCheck
(StringRef
Name
,
ClangTidyContext
*
Context
);
29
void
registerMatchers
(ast_matchers::MatchFinder *
Finder
)
override
;
30
void
check
(
const
ast_matchers::MatchFinder::MatchResult &
Result
)
override
;
31
32
private
:
33
SourceLocation getLastParenLoc(
const
ASTContext *ASTCtx,
34
SourceLocation AssertLoc);
35
};
36
37
}
// namespace misc
38
}
// namespace tidy
39
}
// namespace clang
40
41
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_STATICASSERTCHECK_H
Name
const std::string Name
Definition:
USRFinder.cpp:164
Finder
std::unique_ptr< ast_matchers::MatchFinder > Finder
Definition:
ClangTidy.cpp:262
clang::tidy::misc::StaticAssertCheck
Replaces assert() with static_assert() if the condition is evaluatable at compile time...
Definition:
StaticAssertCheck.h:26
clang::tidy::ClangTidyCheck
Base class for all clang-tidy checks.
Definition:
ClangTidy.h:127
clang::tidy::misc::StaticAssertCheck::StaticAssertCheck
StaticAssertCheck(StringRef Name, ClangTidyContext *Context)
Definition:
StaticAssertCheck.cpp:27
clang::tidy::misc::StaticAssertCheck::check
void check(const ast_matchers::MatchFinder::MatchResult &Result) override
ClangTidyChecks that register ASTMatchers should do the actual work in here.
Definition:
StaticAssertCheck.cpp:78
clang::tidy::misc::StaticAssertCheck::registerMatchers
void registerMatchers(ast_matchers::MatchFinder *Finder) override
Override this to register AST matchers with Finder.
Definition:
StaticAssertCheck.cpp:30
Context
ClangTidyContext & Context
Definition:
ClangTidy.cpp:87
clang::tidy::ClangTidyContext
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
Definition:
ClangTidyDiagnosticConsumer.h:104
Result
const NamedDecl * Result
Definition:
USRFinder.cpp:162
Generated on Wed Mar 8 2017 17:01:13 for clang-tools by
1.8.6