clang-tools
3.8.0
Main Page
Namespaces
Classes
Files
File List
File Members
work
release-test
final
docsbuild
llvm.src
tools
clang
tools
extra
clang-tidy
misc
MacroParenthesesCheck.h
Go to the documentation of this file.
1
//===--- MacroParenthesesCheck.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_MACRO_PARENTHESES_H
11
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_MACRO_PARENTHESES_H
12
13
#include "../ClangTidy.h"
14
15
namespace
clang {
16
namespace
tidy {
17
18
/// Finds macros that can have unexpected behaviour due to missing parentheses.
19
///
20
/// Macros are expanded by the preprocessor as-is. As a result, there can be
21
/// unexpected behaviour; operators may be evaluated in unexpected order and
22
/// unary operators may become binary operators, etc.
23
///
24
/// When the replacement list has an expression, it is recommended to surround
25
/// it with parentheses. This ensures that the macro result is evaluated
26
/// completely before it is used.
27
///
28
/// It is also recommended to surround macro arguments in the replacement list
29
/// with parentheses. This ensures that the argument value is calculated
30
/// properly.
31
class
MacroParenthesesCheck
:
public
ClangTidyCheck
{
32
public
:
33
MacroParenthesesCheck
(StringRef
Name
,
ClangTidyContext
*Context)
34
:
ClangTidyCheck
(Name, Context) {}
35
void
registerPPCallbacks
(CompilerInstance &Compiler)
override
;
36
};
37
38
}
// namespace tidy
39
}
// namespace clang
40
41
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_MACRO_PARENTHESES_H
clang::tidy::MacroParenthesesCheck::MacroParenthesesCheck
MacroParenthesesCheck(StringRef Name, ClangTidyContext *Context)
Definition:
MacroParenthesesCheck.h:33
Name
StringHandle Name
Definition:
PreprocessorTracker.cpp:525
clang::tidy::ClangTidyCheck
Base class for all clang-tidy checks.
Definition:
ClangTidy.h:102
clang::tidy::MacroParenthesesCheck
Finds macros that can have unexpected behaviour due to missing parentheses.
Definition:
MacroParenthesesCheck.h:31
clang::tidy::ClangTidyContext
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
Definition:
ClangTidyDiagnosticConsumer.h:124
clang::tidy::MacroParenthesesCheck::registerPPCallbacks
void registerPPCallbacks(CompilerInstance &Compiler) override
Override this to register PPCallbacks with Compiler.
Definition:
MacroParenthesesCheck.cpp:195
Generated on Mon Mar 7 2016 09:54:11 for clang-tools by
1.8.6