blob: 26a93943aa9a768539601755399f658b08598f05 [file] [log] [blame]
Alexander Kornienko1ca3b832015-03-02 10:46:43 +00001//===--- 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_STATIC_ASSERT_CHECK_H
11#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_STATIC_ASSERT_CHECK_H
12
13#include "../ClangTidy.h"
14#include "llvm/ADT/StringRef.h"
15#include <string>
16
17namespace clang {
18namespace tidy {
19
20/// \brief Replaces \c assert() with \c static_assert() if the condition is
21/// evaluatable at compile time.
22///
23/// The condition of \c static_assert() is evaluated at compile time which is
24/// safer and more efficient.
25class StaticAssertCheck : public ClangTidyCheck {
26public:
27 StaticAssertCheck(StringRef Name, ClangTidyContext *Context);
28 void registerMatchers(ast_matchers::MatchFinder *Finder) override;
29 void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
30
31private:
32 SourceLocation getLastParenLoc(const ASTContext *ASTCtx,
33 SourceLocation AssertLoc);
34};
35
36} // namespace tidy
37} // namespace clang
38
39#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_STATIC_ASSERT_CHECK_H