|
|
|||
File indexing completed on 2026-05-10 08:36:18
0001 //===--- MacroParenthesesCheck.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_MACROPARENTHESESCHECK_H 0010 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_MACROPARENTHESESCHECK_H 0011 0012 #include "../ClangTidyCheck.h" 0013 0014 namespace clang::tidy::bugprone { 0015 0016 /// Finds macros that can have unexpected behaviour due to missing parentheses. 0017 /// 0018 /// Macros are expanded by the preprocessor as-is. As a result, there can be 0019 /// unexpected behaviour; operators may be evaluated in unexpected order and 0020 /// unary operators may become binary operators, etc. 0021 /// 0022 /// When the replacement list has an expression, it is recommended to surround 0023 /// it with parentheses. This ensures that the macro result is evaluated 0024 /// completely before it is used. 0025 /// 0026 /// It is also recommended to surround macro arguments in the replacement list 0027 /// with parentheses. This ensures that the argument value is calculated 0028 /// properly. 0029 class MacroParenthesesCheck : public ClangTidyCheck { 0030 public: 0031 MacroParenthesesCheck(StringRef Name, ClangTidyContext *Context) 0032 : ClangTidyCheck(Name, Context) {} 0033 void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP, 0034 Preprocessor *ModuleExpanderPP) override; 0035 }; 0036 0037 } // namespace clang::tidy::bugprone 0038 0039 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_MACROPARENTHESESCHECK_H
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|