Skip to content

Commit b9e9684

Browse files
anerokhisawenzel
authored andcommitted
Bump to llvm 10.0
1 parent acafa24 commit b9e9684

File tree

6 files changed

+235
-200
lines changed

6 files changed

+235
-200
lines changed

ClangTidyDiagnosticConsumer.h

Lines changed: 26 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#include "clang/Tooling/Refactoring.h"
1818
#include "llvm/ADT/DenseMap.h"
1919
#include "llvm/ADT/StringMap.h"
20-
#include "llvm/Support/Regex.h"
2120
#include "llvm/Support/Timer.h"
2221

2322
namespace clang {
@@ -33,7 +32,7 @@ class CompilationDatabase;
3332

3433
namespace tidy {
3534

36-
/// \brief A detected error complete with information to display diagnostic and
35+
/// A detected error complete with information to display diagnostic and
3736
/// automatic fix.
3837
///
3938
/// This is used as an intermediate format to transport Diagnostics without a
@@ -47,28 +46,7 @@ struct ClangTidyError : tooling::Diagnostic {
4746
bool IsWarningAsError;
4847
};
4948

50-
/// \brief Read-only set of strings represented as a list of positive and
51-
/// negative globs. Positive globs add all matched strings to the set, negative
52-
/// globs remove them in the order of appearance in the list.
53-
class GlobList {
54-
public:
55-
/// \brief \p GlobList is a comma-separated list of globs (only '*'
56-
/// metacharacter is supported) with optional '-' prefix to denote exclusion.
57-
GlobList(StringRef Globs);
58-
59-
/// \brief Returns \c true if the pattern matches \p S. The result is the last
60-
/// matching glob's Positive flag.
61-
bool contains(StringRef S) { return contains(S, false); }
62-
63-
private:
64-
bool contains(StringRef S, bool Contains);
65-
66-
bool Positive;
67-
llvm::Regex Regex;
68-
std::unique_ptr<GlobList> NextGlob;
69-
};
70-
71-
/// \brief Contains displayed and ignored diagnostic counters for a ClangTidy
49+
/// Contains displayed and ignored diagnostic counters for a ClangTidy
7250
/// run.
7351
struct ClangTidyStats {
7452
ClangTidyStats()
@@ -87,7 +65,7 @@ struct ClangTidyStats {
8765
}
8866
};
8967

90-
/// \brief Every \c ClangTidyCheck reports errors through a \c DiagnosticsEngine
68+
/// Every \c ClangTidyCheck reports errors through a \c DiagnosticsEngine
9169
/// provided by this context.
9270
///
9371
/// A \c ClangTidyCheck always has access to the active context to report
@@ -98,7 +76,7 @@ struct ClangTidyStats {
9876
/// \endcode
9977
class ClangTidyContext {
10078
public:
101-
/// \brief Initializes \c ClangTidyContext instance.
79+
/// Initializes \c ClangTidyContext instance.
10280
ClangTidyContext(std::unique_ptr<ClangTidyOptionsProvider> OptionsProvider,
10381
bool AllowEnablingAnalyzerAlphaCheckers = false);
10482
/// Sets the DiagnosticsEngine that diag() will emit diagnostics to.
@@ -110,7 +88,7 @@ class ClangTidyContext {
11088

11189
~ClangTidyContext();
11290

113-
/// \brief Report any errors detected using this method.
91+
/// Report any errors detected using this method.
11492
///
11593
/// This is still under heavy development and will likely change towards using
11694
/// tablegen'd diagnostic IDs.
@@ -119,72 +97,72 @@ class ClangTidyContext {
11997
StringRef Message,
12098
DiagnosticIDs::Level Level = DiagnosticIDs::Warning);
12199

122-
/// \brief Sets the \c SourceManager of the used \c DiagnosticsEngine.
100+
/// Sets the \c SourceManager of the used \c DiagnosticsEngine.
123101
///
124102
/// This is called from the \c ClangTidyCheck base class.
125103
void setSourceManager(SourceManager *SourceMgr);
126104

127-
/// \brief Should be called when starting to process new translation unit.
105+
/// Should be called when starting to process new translation unit.
128106
void setCurrentFile(StringRef File);
129107

130-
/// \brief Returns the main file name of the current translation unit.
108+
/// Returns the main file name of the current translation unit.
131109
StringRef getCurrentFile() const { return CurrentFile; }
132110

133-
/// \brief Sets ASTContext for the current translation unit.
111+
/// Sets ASTContext for the current translation unit.
134112
void setASTContext(ASTContext *Context);
135113

136-
/// \brief Gets the language options from the AST context.
114+
/// Gets the language options from the AST context.
137115
const LangOptions &getLangOpts() const { return LangOpts; }
138116

139-
/// \brief Returns the name of the clang-tidy check which produced this
117+
/// Returns the name of the clang-tidy check which produced this
140118
/// diagnostic ID.
141119
std::string getCheckName(unsigned DiagnosticID) const;
142120

143-
/// \brief Returns \c true if the check is enabled for the \c CurrentFile.
121+
/// Returns \c true if the check is enabled for the \c CurrentFile.
144122
///
145123
/// The \c CurrentFile can be changed using \c setCurrentFile.
146124
bool isCheckEnabled(StringRef CheckName) const;
147125

148-
/// \brief Returns \c true if the check should be upgraded to error for the
126+
/// Returns \c true if the check should be upgraded to error for the
149127
/// \c CurrentFile.
150128
bool treatAsError(StringRef CheckName) const;
151129

152-
/// \brief Returns global options.
130+
/// Returns global options.
153131
const ClangTidyGlobalOptions &getGlobalOptions() const;
154132

155-
/// \brief Returns options for \c CurrentFile.
133+
/// Returns options for \c CurrentFile.
156134
///
157135
/// The \c CurrentFile can be changed using \c setCurrentFile.
158136
const ClangTidyOptions &getOptions() const;
159137

160-
/// \brief Returns options for \c File. Does not change or depend on
138+
/// Returns options for \c File. Does not change or depend on
161139
/// \c CurrentFile.
162140
ClangTidyOptions getOptionsForFile(StringRef File) const;
163141

164-
/// \brief Returns \c ClangTidyStats containing issued and ignored diagnostic
142+
/// Returns \c ClangTidyStats containing issued and ignored diagnostic
165143
/// counters.
166144
const ClangTidyStats &getStats() const { return Stats; }
167145

168-
/// \brief Control profile collection in clang-tidy.
146+
/// Control profile collection in clang-tidy.
169147
void setEnableProfiling(bool Profile);
170148
bool getEnableProfiling() const { return Profile; }
171149

172-
/// \brief Control storage of profile date.
150+
/// Control storage of profile date.
173151
void setProfileStoragePrefix(StringRef ProfilePrefix);
174152
llvm::Optional<ClangTidyProfiling::StorageParams>
175153
getProfileStorageParams() const;
176154

177-
/// \brief Should be called when starting to process new translation unit.
155+
/// Should be called when starting to process new translation unit.
178156
void setCurrentBuildDirectory(StringRef BuildDirectory) {
179157
CurrentBuildDirectory = BuildDirectory;
180158
}
181159

182-
/// \brief Returns build directory of the current translation unit.
160+
/// Returns build directory of the current translation unit.
183161
const std::string &getCurrentBuildDirectory() {
184162
return CurrentBuildDirectory;
185163
}
186164

187-
/// \brief If the experimental alpha checkers from the static analyzer can be
165+
/// If the experimental alpha checkers from the static analyzer can be
188166
/// enabled.
189167
bool canEnableAnalyzerAlphaCheckers() const {
190168
return AllowEnablingAnalyzerAlphaCheckers;
@@ -239,11 +217,11 @@ class ClangTidyContext {
239217
/// examining source files other than the one in which the diagnostic is
240218
/// located, and in some use cases we cannot rely on such other files being
241219
/// mapped in the SourceMapper.
242-
bool ShouldSuppressDiagnostic(DiagnosticsEngine::Level DiagLevel,
220+
bool shouldSuppressDiagnostic(DiagnosticsEngine::Level DiagLevel,
243221
const Diagnostic &Info, ClangTidyContext &Context,
244222
bool CheckMacroExpansion = true);
245223

246-
/// \brief A diagnostic consumer that turns each \c Diagnostic into a
224+
/// A diagnostic consumer that turns each \c Diagnostic into a
247225
/// \c SourceManager-independent \c ClangTidyError.
248226
//
249227
// FIXME: If we move away from unit-tests, this can be moved to a private
@@ -267,11 +245,11 @@ class ClangTidyDiagnosticConsumer : public DiagnosticConsumer {
267245
void finalizeLastError();
268246
void removeIncompatibleErrors();
269247

270-
/// \brief Returns the \c HeaderFilter constructed for the options set in the
248+
/// Returns the \c HeaderFilter constructed for the options set in the
271249
/// context.
272250
llvm::Regex *getHeaderFilter();
273251

274-
/// \brief Updates \c LastErrorRelatesToUserCode and LastErrorPassesLineFilter
252+
/// Updates \c LastErrorRelatesToUserCode and LastErrorPassesLineFilter
275253
/// according to the diagnostic \p Location.
276254
void checkFilters(SourceLocation Location, const SourceManager &Sources);
277255
bool passesLineFilter(StringRef FileName, unsigned LineNumber) const;

ClangTidyForceLinker.h

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
//===- ClangTidyForceLinker.h - clang-tidy --------------------------------===//
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_CLANGTIDYFORCELINKER_H
10+
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CLANGTIDYFORCELINKER_H
11+
12+
#include "clang/Config/config.h"
13+
#include "llvm/Support/Compiler.h"
14+
15+
namespace clang {
16+
namespace tidy {
17+
18+
// This anchor is used to force the linker to link the CERTModule.
19+
extern volatile int CERTModuleAnchorSource;
20+
static int LLVM_ATTRIBUTE_UNUSED CERTModuleAnchorDestination =
21+
CERTModuleAnchorSource;
22+
23+
// This anchor is used to force the linker to link the AbseilModule.
24+
extern volatile int AbseilModuleAnchorSource;
25+
static int LLVM_ATTRIBUTE_UNUSED AbseilModuleAnchorDestination =
26+
AbseilModuleAnchorSource;
27+
28+
// This anchor is used to force the linker to link the BoostModule.
29+
extern volatile int BoostModuleAnchorSource;
30+
static int LLVM_ATTRIBUTE_UNUSED BoostModuleAnchorDestination =
31+
BoostModuleAnchorSource;
32+
33+
// This anchor is used to force the linker to link the BugproneModule.
34+
extern volatile int BugproneModuleAnchorSource;
35+
static int LLVM_ATTRIBUTE_UNUSED BugproneModuleAnchorDestination =
36+
BugproneModuleAnchorSource;
37+
38+
// This anchor is used to force the linker to link the LinuxKernelModule.
39+
extern volatile int LinuxKernelModuleAnchorSource;
40+
static int LLVM_ATTRIBUTE_UNUSED LinuxKernelModuleAnchorDestination =
41+
LinuxKernelModuleAnchorSource;
42+
43+
// This anchor is used to force the linker to link the LLVMModule.
44+
extern volatile int LLVMModuleAnchorSource;
45+
static int LLVM_ATTRIBUTE_UNUSED LLVMModuleAnchorDestination =
46+
LLVMModuleAnchorSource;
47+
48+
// This anchor is used to force the linker to link the CppCoreGuidelinesModule.
49+
extern volatile int CppCoreGuidelinesModuleAnchorSource;
50+
static int LLVM_ATTRIBUTE_UNUSED CppCoreGuidelinesModuleAnchorDestination =
51+
CppCoreGuidelinesModuleAnchorSource;
52+
53+
// This anchor is used to force the linker to link the DarwinModule.
54+
extern volatile int DarwinModuleAnchorSource;
55+
static int LLVM_ATTRIBUTE_UNUSED DarwinModuleAnchorDestination =
56+
DarwinModuleAnchorSource;
57+
58+
// This anchor is used to force the linker to link the FuchsiaModule.
59+
extern volatile int FuchsiaModuleAnchorSource;
60+
static int LLVM_ATTRIBUTE_UNUSED FuchsiaModuleAnchorDestination =
61+
FuchsiaModuleAnchorSource;
62+
63+
// This anchor is used to force the linker to link the GoogleModule.
64+
extern volatile int GoogleModuleAnchorSource;
65+
static int LLVM_ATTRIBUTE_UNUSED GoogleModuleAnchorDestination =
66+
GoogleModuleAnchorSource;
67+
68+
// This anchor is used to force the linker to link the AndroidModule.
69+
extern volatile int AndroidModuleAnchorSource;
70+
static int LLVM_ATTRIBUTE_UNUSED AndroidModuleAnchorDestination =
71+
AndroidModuleAnchorSource;
72+
73+
// This anchor is used to force the linker to link the MiscModule.
74+
extern volatile int MiscModuleAnchorSource;
75+
static int LLVM_ATTRIBUTE_UNUSED MiscModuleAnchorDestination =
76+
MiscModuleAnchorSource;
77+
78+
// This anchor is used to force the linker to link the ModernizeModule.
79+
extern volatile int ModernizeModuleAnchorSource;
80+
static int LLVM_ATTRIBUTE_UNUSED ModernizeModuleAnchorDestination =
81+
ModernizeModuleAnchorSource;
82+
83+
#if CLANG_ENABLE_STATIC_ANALYZER && \
84+
!defined(CLANG_TIDY_DISABLE_STATIC_ANALYZER_CHECKS)
85+
// This anchor is used to force the linker to link the MPIModule.
86+
extern volatile int MPIModuleAnchorSource;
87+
static int LLVM_ATTRIBUTE_UNUSED MPIModuleAnchorDestination =
88+
MPIModuleAnchorSource;
89+
#endif
90+
91+
// This anchor is used to force the linker to link the OpenMPModule.
92+
extern volatile int OpenMPModuleAnchorSource;
93+
static int LLVM_ATTRIBUTE_UNUSED OpenMPModuleAnchorDestination =
94+
OpenMPModuleAnchorSource;
95+
96+
// This anchor is used to force the linker to link the PerformanceModule.
97+
extern volatile int PerformanceModuleAnchorSource;
98+
static int LLVM_ATTRIBUTE_UNUSED PerformanceModuleAnchorDestination =
99+
PerformanceModuleAnchorSource;
100+
101+
// This anchor is used to force the linker to link the PortabilityModule.
102+
extern volatile int PortabilityModuleAnchorSource;
103+
static int LLVM_ATTRIBUTE_UNUSED PortabilityModuleAnchorDestination =
104+
PortabilityModuleAnchorSource;
105+
106+
// This anchor is used to force the linker to link the ReadabilityModule.
107+
extern volatile int ReadabilityModuleAnchorSource;
108+
static int LLVM_ATTRIBUTE_UNUSED ReadabilityModuleAnchorDestination =
109+
ReadabilityModuleAnchorSource;
110+
111+
// This anchor is used to force the linker to link the ObjCModule.
112+
extern volatile int ObjCModuleAnchorSource;
113+
static int LLVM_ATTRIBUTE_UNUSED ObjCModuleAnchorDestination =
114+
ObjCModuleAnchorSource;
115+
116+
// This anchor is used to force the linker to link the HICPPModule.
117+
extern volatile int HICPPModuleAnchorSource;
118+
static int LLVM_ATTRIBUTE_UNUSED HICPPModuleAnchorDestination =
119+
HICPPModuleAnchorSource;
120+
121+
// This anchor is used to force the linker to link the ZirconModule.
122+
extern volatile int ZirconModuleAnchorSource;
123+
static int LLVM_ATTRIBUTE_UNUSED ZirconModuleAnchorDestination =
124+
ZirconModuleAnchorSource;
125+
126+
} // namespace tidy
127+
} // namespace clang
128+
129+
#endif

ClangTidyModule.h

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,28 +13,28 @@
1313
#include "llvm/ADT/StringRef.h"
1414
#include <functional>
1515
#include <map>
16+
#include <memory>
1617
#include <string>
1718
#include <utility>
1819

1920
namespace clang {
2021
namespace tidy {
2122

22-
/// \brief A collection of \c ClangTidyCheckFactory instances.
23+
/// A collection of \c ClangTidyCheckFactory instances.
2324
///
2425
/// All clang-tidy modules register their check factories with an instance of
2526
/// this object.
2627
class ClangTidyCheckFactories {
2728
public:
28-
typedef std::function<ClangTidyCheck *(StringRef Name,
29-
ClangTidyContext *Context)>
30-
CheckFactory;
29+
using CheckFactory = std::function<std::unique_ptr<ClangTidyCheck>(
30+
StringRef Name, ClangTidyContext *Context)>;
3131

32-
/// \brief Registers check \p Factory with name \p Name.
32+
/// Registers check \p Factory with name \p Name.
3333
///
3434
/// For all checks that have default constructors, use \c registerCheck.
3535
void registerCheckFactory(StringRef Name, CheckFactory Factory);
3636

37-
/// \brief Registers the \c CheckType with the name \p Name.
37+
/// Registers the \c CheckType with the name \p Name.
3838
///
3939
/// This method should be used for all \c ClangTidyChecks that don't require
4040
/// constructor parameters.
@@ -58,16 +58,13 @@ class ClangTidyCheckFactories {
5858
template <typename CheckType> void registerCheck(StringRef CheckName) {
5959
registerCheckFactory(CheckName,
6060
[](StringRef Name, ClangTidyContext *Context) {
61-
return new CheckType(Name, Context);
61+
return std::make_unique<CheckType>(Name, Context);
6262
});
6363
}
6464

65-
/// \brief Create instances of all checks matching \p CheckRegexString and
66-
/// store them in \p Checks.
67-
///
68-
/// The caller takes ownership of the return \c ClangTidyChecks.
69-
void createChecks(ClangTidyContext *Context,
70-
std::vector<std::unique_ptr<ClangTidyCheck>> &Checks);
65+
/// Create instances of checks that are enabled.
66+
std::vector<std::unique_ptr<ClangTidyCheck>>
67+
createChecks(ClangTidyContext *Context);
7168

7269
typedef std::map<std::string, CheckFactory> FactoryMap;
7370
FactoryMap::const_iterator begin() const { return Factories.begin(); }
@@ -78,17 +75,17 @@ class ClangTidyCheckFactories {
7875
FactoryMap Factories;
7976
};
8077

81-
/// \brief A clang-tidy module groups a number of \c ClangTidyChecks and gives
78+
/// A clang-tidy module groups a number of \c ClangTidyChecks and gives
8279
/// them a prefixed name.
8380
class ClangTidyModule {
8481
public:
8582
virtual ~ClangTidyModule() {}
8683

87-
/// \brief Implement this function in order to register all \c CheckFactories
84+
/// Implement this function in order to register all \c CheckFactories
8885
/// belonging to this module.
8986
virtual void addCheckFactories(ClangTidyCheckFactories &CheckFactories) = 0;
9087

91-
/// \brief Gets default options for checks defined in this module.
88+
/// Gets default options for checks defined in this module.
9289
virtual ClangTidyOptions getModuleOptions();
9390
};
9491

0 commit comments

Comments
 (0)