|
|
|||
File indexing completed on 2026-05-10 08:36:18
0001 //===--- AssertSideEffectCheck.h - clang-tidy -------------------*- C++ -*-===// 0002 // 0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 0004 // See https://llvm.org/LICENSE.txt for license information. 0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 0006 // 0007 //===----------------------------------------------------------------------===// 0008 0009 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_ASSERTSIDEEFFECTCHECK_H 0010 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_ASSERTSIDEEFFECTCHECK_H 0011 0012 #include "../ClangTidyCheck.h" 0013 #include "llvm/ADT/SmallVector.h" 0014 #include "llvm/ADT/StringRef.h" 0015 #include <string> 0016 0017 namespace clang::tidy::bugprone { 0018 0019 /// Finds `assert()` with side effect. 0020 /// 0021 /// The condition of `assert()` is evaluated only in debug builds so a 0022 /// condition with side effect can cause different behavior in debug / release 0023 /// builds. 0024 /// 0025 /// There are two options: 0026 /// 0027 /// - `AssertMacros`: A comma-separated list of the names of assert macros to 0028 /// be checked. 0029 /// - `CheckFunctionCalls`: Whether to treat non-const member and non-member 0030 /// functions as they produce side effects. Disabled by default because it 0031 /// can increase the number of false positive warnings. 0032 class AssertSideEffectCheck : public ClangTidyCheck { 0033 public: 0034 AssertSideEffectCheck(StringRef Name, ClangTidyContext *Context); 0035 void storeOptions(ClangTidyOptions::OptionMap &Opts) override; 0036 void registerMatchers(ast_matchers::MatchFinder *Finder) override; 0037 void check(const ast_matchers::MatchFinder::MatchResult &Result) override; 0038 0039 private: 0040 const bool CheckFunctionCalls; 0041 const StringRef RawAssertList; 0042 SmallVector<StringRef, 5> AssertMacros; 0043 const std::vector<StringRef> IgnoredFunctions; 0044 }; 0045 0046 } // namespace clang::tidy::bugprone 0047 0048 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_ASSERTSIDEEFFECTCHECK_H
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|