clang-tools
20.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 <optional>
14
#include <string>
15
#include <vector>
16
17
namespace
clang::tidy::bugprone
{
18
19
/// Checks for usages of identifiers reserved for use by the implementation.
20
///
21
/// The C and C++ standards both reserve the following names for such use:
22
/// * identifiers that begin with an underscore followed by an uppercase letter;
23
/// * identifiers in the global namespace that begin with an underscore.
24
///
25
/// The C standard additionally reserves names beginning with a double
26
/// underscore, while the C++ standard strengthens this to reserve names with a
27
/// double underscore occurring anywhere.
28
///
29
/// For the user-facing documentation see:
30
/// http://clang.llvm.org/extra/clang-tidy/checks/bugprone/reserved-identifier.html
31
class
ReservedIdentifierCheck
final :
public
RenamerClangTidyCheck
{
32
const
bool
Invert;
33
const
std::vector<StringRef> AllowedIdentifiersRaw;
34
const
llvm::SmallVector<llvm::Regex> AllowedIdentifiers;
35
36
public
:
37
ReservedIdentifierCheck
(StringRef
Name
,
ClangTidyContext
*Context);
38
39
void
storeOptions
(
ClangTidyOptions::OptionMap
&Opts)
override
;
40
41
private
:
42
std::optional<FailureInfo>
43
getDeclFailureInfo(
const
NamedDecl *
Decl
,
44
const
SourceManager &SM)
const override
;
45
std::optional<FailureInfo>
46
getMacroFailureInfo(
const
Token &MacroNameTok,
47
const
SourceManager &SM)
const override
;
48
DiagInfo
getDiagInfo(
const
NamingCheckId
&
ID
,
49
const
NamingCheckFailure
&Failure)
const override
;
50
llvm::SmallVector<llvm::Regex> parseAllowedIdentifiers()
const
;
51
};
52
53
}
// namespace clang::tidy::bugprone
54
55
#endif
// LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_RESERVEDIDENTIFIERCHECK_H
Decl
const FunctionDecl * Decl
Definition:
AvoidBindCheck.cpp:98
Name
llvm::SmallString< 256U > Name
Definition:
ChainedComparisonCheck.cpp:42
ID
StringRef ID
Definition:
ReferenceToConstructedTemporaryCheck.cpp:35
clang::tidy::ClangTidyContext
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
Definition:
ClangTidyDiagnosticConsumer.h:69
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, StringRef > NamingCheckId
Definition:
RenamerClangTidyCheck.h:105
clang::tidy::bugprone::ReservedIdentifierCheck
Checks for usages of identifiers reserved for use by the implementation.
Definition:
ReservedIdentifierCheck.h:31
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:66
clang::tidy::bugprone
Definition:
ArgumentCommentCheck.cpp:19
clang::tidy::ClangTidyOptions::OptionMap
llvm::StringMap< ClangTidyValue > OptionMap
Definition:
ClangTidyOptions.h:126
clang::tidy::RenamerClangTidyCheck::DiagInfo
Represents customized diagnostic text and how arguments should be applied.
Definition:
RenamerClangTidyCheck.h:142
clang::tidy::RenamerClangTidyCheck::NamingCheckFailure
Holds an identifier name check failure, tracking the kind of the identifier, its possible fixup and t...
Definition:
RenamerClangTidyCheck.h:82
Generated on Wed Dec 25 2024 05:24:11 for clang-tools by
1.9.6