#include "IncorrectRoundingsCheck.h"
#include "IntegerDivisionCheck.h"
#include "LambdaFunctionNameCheck.h"
+#include "MacroParenthesesCheck.h"
#include "MacroRepeatedSideEffectsCheck.h"
#include "MisplacedOperatorInStrlenInAllocCheck.h"
#include "MisplacedWideningCastCheck.h"
"bugprone-integer-division");
CheckFactories.registerCheck<LambdaFunctionNameCheck>(
"bugprone-lambda-function-name");
+ CheckFactories.registerCheck<MacroParenthesesCheck>(
+ "bugprone-macro-parentheses");
CheckFactories.registerCheck<MacroRepeatedSideEffectsCheck>(
"bugprone-macro-repeated-side-effects");
CheckFactories.registerCheck<MisplacedOperatorInStrlenInAllocCheck>(
IncorrectRoundingsCheck.cpp
IntegerDivisionCheck.cpp
LambdaFunctionNameCheck.cpp
+ MacroParenthesesCheck.cpp
MacroRepeatedSideEffectsCheck.cpp
MisplacedOperatorInStrlenInAllocCheck.cpp
MisplacedWideningCastCheck.cpp
namespace clang {
namespace tidy {
-namespace misc {
+namespace bugprone {
namespace {
class MacroParenthesesPPCallbacks : public PPCallbacks {
&Compiler.getPreprocessor(), this));
}
-} // namespace misc
+} // namespace bugprone
} // namespace tidy
} // namespace clang
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_MACRO_PARENTHESES_H
-#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_MACRO_PARENTHESES_H
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_MACROPARENTHESESCHECK_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_MACROPARENTHESESCHECK_H
#include "../ClangTidy.h"
namespace clang {
namespace tidy {
-namespace misc {
+namespace bugprone {
/// Finds macros that can have unexpected behaviour due to missing parentheses.
///
void registerPPCallbacks(CompilerInstance &Compiler) override;
};
-} // namespace misc
+} // namespace bugprone
} // namespace tidy
} // namespace clang
-#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_MACRO_PARENTHESES_H
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_MACROPARENTHESESCHECK_H
MisplacedConstCheck.cpp
UnconventionalAssignOperatorCheck.cpp
DefinitionsInHeadersCheck.cpp
- MacroParenthesesCheck.cpp
MiscTidyModule.cpp
NewDeleteOverloadsCheck.cpp
NonCopyableObjects.cpp
#include "../ClangTidyModule.h"
#include "../ClangTidyModuleRegistry.h"
#include "DefinitionsInHeadersCheck.h"
-#include "MacroParenthesesCheck.h"
#include "MisplacedConstCheck.h"
#include "NewDeleteOverloadsCheck.h"
#include "NonCopyableObjects.h"
"misc-unconventional-assign-operator");
CheckFactories.registerCheck<DefinitionsInHeadersCheck>(
"misc-definitions-in-headers");
- CheckFactories.registerCheck<MacroParenthesesCheck>(
- "misc-macro-parentheses");
CheckFactories.registerCheck<NewDeleteOverloadsCheck>(
"misc-new-delete-overloads");
CheckFactories.registerCheck<NonCopyableObjectsCheck>(
Warns if global, non-trivial objects with static storage are constructed,
unless the object is statically initialized with a ``constexpr`` constructor
or has no explicit constructor.
-
+
- New `fuchsia-trailing-return
<http://clang.llvm.org/extra/clang-tidy/checks/fuchsia-trailing-return.html>`_ check
- Functions that have trailing returns are disallowed, except for those
- using ``decltype`` specifiers and lambda with otherwise unutterable
+ Functions that have trailing returns are disallowed, except for those
+ using ``decltype`` specifiers and lambda with otherwise unutterable
return types.
- New `modernize-use-uncaught-exceptions
- The 'misc-lambda-function-name' check was renamed to `bugprone-lambda-function-name
<http://clang.llvm.org/extra/clang-tidy/checks/bugprone-lambda-function-name.html>`_
+- The 'misc-macro-parentheses' check was renamed to `bugprone-macro-parentheses
+ <http://clang.llvm.org/extra/clang-tidy/checks/bugprone-macro-parentheses.html>`_
+
- The 'misc-macro-repeated-side-effects' check was renamed to `bugprone-macro-repeated-side-effects
<http://clang.llvm.org/extra/clang-tidy/checks/bugprone-macro-repeated-side-effects.html>`_
-.. title:: clang-tidy - misc-macro-parentheses
+.. title:: clang-tidy - bugprone-macro-parentheses
-misc-macro-parentheses
-======================
+bugprone-macro-parentheses
+==========================
Finds macros that can have unexpected behaviour due to missing parentheses.
bugprone-incorrect-roundings
bugprone-integer-division
bugprone-lambda-function-name
+ bugprone-macro-parentheses
bugprone-macro-repeated-side-effects
bugprone-misplaced-operator-in-strlen-in-alloc
bugprone-misplaced-widening-cast
llvm-namespace-comment
llvm-twine-local
misc-definitions-in-headers
- misc-macro-parentheses
misc-misplaced-const
misc-new-delete-overloads
misc-non-copyable-objects
-// RUN: %check_clang_tidy %s misc-macro-parentheses %t -- -- -DVAL=0+0
+// RUN: %check_clang_tidy %s bugprone-macro-parentheses %t -- -- -DVAL=0+0
// The previous command-line is producing warnings and fixes with the source
// locations from a virtual buffer. VAL is replaced by '0+0'.
-// RUN: %check_clang_tidy %s misc-macro-parentheses %t
+// RUN: %check_clang_tidy %s bugprone-macro-parentheses %t
#define BAD1 -1
-// CHECK-MESSAGES: :[[@LINE-1]]:27: warning: macro replacement list should be enclosed in parentheses [misc-macro-parentheses]
+// CHECK-MESSAGES: :[[@LINE-1]]:27: warning: macro replacement list should be enclosed in parentheses [bugprone-macro-parentheses]
#define BAD2 1+2
-// CHECK-MESSAGES: :[[@LINE-1]]:28: warning: macro replacement list should be enclosed in parentheses [misc-macro-parentheses]
+// CHECK-MESSAGES: :[[@LINE-1]]:28: warning: macro replacement list should be enclosed in parentheses [bugprone-macro-parentheses]
#define BAD3(A) (A+1)
-// CHECK-MESSAGES: :[[@LINE-1]]:28: warning: macro argument should be enclosed in parentheses [misc-macro-parentheses]
+// CHECK-MESSAGES: :[[@LINE-1]]:28: warning: macro argument should be enclosed in parentheses [bugprone-macro-parentheses]
#define BAD4(x) ((unsigned char)(x & 0xff))
-// CHECK-MESSAGES: :[[@LINE-1]]:44: warning: macro argument should be enclosed in parentheses [misc-macro-parentheses]
+// CHECK-MESSAGES: :[[@LINE-1]]:44: warning: macro argument should be enclosed in parentheses [bugprone-macro-parentheses]
#define BAD5(X) A*B=(C*)X+2
-// CHECK-MESSAGES: :[[@LINE-1]]:35: warning: macro argument should be enclosed in parentheses [misc-macro-parentheses]
+// CHECK-MESSAGES: :[[@LINE-1]]:35: warning: macro argument should be enclosed in parentheses [bugprone-macro-parentheses]
#define GOOD1 1
#define GOOD2 (1+2)