clang-tools
15.0.0git
llvm-project
clang-tools-extra
clang-tidy
bugprone
ReservedIdentifierCheck.h
Go to the documentation of this file.
1
//===--- ReservedIdentifierCheck.h - clang-tidy -----------------*- C++ -*-===//
2
//
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
9
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_RESERVEDIDENTIFIERCHECK_H
10
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_RESERVEDIDENTIFIERCHECK_H
11
12
#include "../utils/RenamerClangTidyCheck.h"
13
#include "llvm/ADT/Optional.h"
14
#include <string>
15
#include <vector>
16
17
namespace
clang
{
18
namespace
tidy {
19
namespace
bugprone {
20
21
/// Checks for usages of identifiers reserved for use by the implementation.
22
///
23
/// The C and C++ standards both reserve the following names for such use:
24
/// * identifiers that begin with an underscore followed by an uppercase letter;
25
/// * identifiers in the global namespace that begin with an underscore.
26
///
27
/// The C standard additionally reserves names beginning with a double
28
/// underscore, while the C++ standard strengthens this to reserve names with a
29
/// double underscore occurring anywhere.
30
///
31
/// For the user-facing documentation see:
32
/// http://clang.llvm.org/extra/clang-tidy/checks/bugprone/reserved-identifier.html
33
class
ReservedIdentifierCheck
final :
public
RenamerClangTidyCheck
{
34
const
bool
Invert;
35
const
std::vector<StringRef> AllowedIdentifiers;
36
37
public
:
38
ReservedIdentifierCheck
(StringRef
Name
,
ClangTidyContext
*Context);
39
40
void
storeOptions
(
ClangTidyOptions::OptionMap
&Opts)
override
;
41
42
private
:
43
llvm::Optional<FailureInfo>
44
getDeclFailureInfo(
const
NamedDecl *
Decl
,
45
const
SourceManager &SM)
const override
;
46
llvm::Optional<FailureInfo>
47
getMacroFailureInfo(
const
Token &MacroNameTok,
48
const
SourceManager &SM)
const override
;
49
DiagInfo
getDiagInfo(
const
NamingCheckId
&
ID
,
50
const
NamingCheckFailure
&Failure)
const override
;
51
};
52
53
}
// namespace bugprone
54
}
// namespace tidy
55
}
// namespace clang
56
57
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_RESERVEDIDENTIFIERCHECK_H
clang::tidy::ClangTidyOptions::OptionMap
llvm::StringMap< ClangTidyValue > OptionMap
Definition:
ClangTidyOptions.h:115
clang::tidy::RenamerClangTidyCheck::NamingCheckFailure
Holds an identifier name check failure, tracking the kind of the identifier, its possible fixup and t...
Definition:
RenamerClangTidyCheck.h:83
clang::tidy::RenamerClangTidyCheck::DiagInfo
Represents customized diagnostic text and how arguments should be applied.
Definition:
RenamerClangTidyCheck.h:145
clang::tidy::bugprone::ReservedIdentifierCheck::ReservedIdentifierCheck
ReservedIdentifierCheck(StringRef Name, ClangTidyContext *Context)
Definition:
ReservedIdentifierCheck.cpp:43
Decl
const FunctionDecl * Decl
Definition:
AvoidBindCheck.cpp:100
clang::tidy::ClangTidyContext
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
Definition:
ClangTidyDiagnosticConsumer.h:67
Name
Token Name
Definition:
MacroToEnumCheck.cpp:89
clang::tidy::bugprone::ReservedIdentifierCheck
Checks for usages of identifiers reserved for use by the implementation.
Definition:
ReservedIdentifierCheck.h:33
clang::tidy::RenamerClangTidyCheck
Base class for clang-tidy checks that want to flag declarations and/or macros for renaming based on c...
Definition:
RenamerClangTidyCheck.h:28
clang::tidy::RenamerClangTidyCheck::NamingCheckId
std::pair< SourceLocation, std::string > NamingCheckId
Definition:
RenamerClangTidyCheck.h:106
ID
static char ID
Definition:
Logger.cpp:74
clang
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
Definition:
ApplyReplacements.h:27
clang::tidy::bugprone::ReservedIdentifierCheck::storeOptions
void storeOptions(ClangTidyOptions::OptionMap &Opts) override
Should store all options supported by this check with their current values or default values for opti...
Definition:
ReservedIdentifierCheck.cpp:50
Generated on Tue Jun 28 2022 02:33:01 for clang-tools by
1.8.17