Skip to content

Commit 1f7dc38

Browse files
committed
Bump to LLVM 17.0.6
1 parent a22935e commit 1f7dc38

11 files changed

+117
-91
lines changed

ClangTidyCheck.h

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#include "ClangTidyOptions.h"
1414
#include "clang/ASTMatchers/ASTMatchFinder.h"
1515
#include "clang/Basic/Diagnostic.h"
16-
#include "llvm/ADT/Optional.h"
16+
#include <optional>
1717
#include <type_traits>
1818
#include <utility>
1919
#include <vector>
@@ -154,8 +154,8 @@ class ClangTidyCheck : public ast_matchers::MatchFinder::MatchCallback {
154154
///
155155
/// Reads the option with the check-local name \p LocalName from the
156156
/// ``CheckOptions``. If the corresponding key is not present, return
157-
/// ``None``.
158-
llvm::Optional<StringRef> get(StringRef LocalName) const;
157+
/// ``std::nullopt``.
158+
std::optional<StringRef> get(StringRef LocalName) const;
159159

160160
/// Read a named option from the ``Context``.
161161
///
@@ -169,8 +169,8 @@ class ClangTidyCheck : public ast_matchers::MatchFinder::MatchCallback {
169169
/// Reads the option with the check-local name \p LocalName from local or
170170
/// global ``CheckOptions``. Gets local option first. If local is not
171171
/// present, falls back to get global option. If global option is not
172-
/// present either, return ``None``.
173-
llvm::Optional<StringRef> getLocalOrGlobal(StringRef LocalName) const;
172+
/// present either, return ``std::nullopt``.
173+
std::optional<StringRef> getLocalOrGlobal(StringRef LocalName) const;
174174

175175
/// Read a named option from the ``Context``.
176176
///
@@ -185,20 +185,20 @@ class ClangTidyCheck : public ast_matchers::MatchFinder::MatchCallback {
185185
///
186186
/// Reads the option with the check-local name \p LocalName from the
187187
/// ``CheckOptions``. If the corresponding key is not present, return
188-
/// ``None``.
188+
/// ``std::nullopt``.
189189
///
190190
/// If the corresponding key can't be parsed as a ``T``, emit a
191-
/// diagnostic and return ``None``.
191+
/// diagnostic and return ``std::nullopt``.
192192
template <typename T>
193-
std::enable_if_t<std::is_integral<T>::value, llvm::Optional<T>>
193+
std::enable_if_t<std::is_integral<T>::value, std::optional<T>>
194194
get(StringRef LocalName) const {
195-
if (llvm::Optional<StringRef> Value = get(LocalName)) {
195+
if (std::optional<StringRef> Value = get(LocalName)) {
196196
T Result{};
197197
if (!StringRef(*Value).getAsInteger(10, Result))
198198
return Result;
199199
diagnoseBadIntegerOption(NamePrefix + LocalName, *Value);
200200
}
201-
return None;
201+
return std::nullopt;
202202
}
203203

204204
/// Read a named option from the ``Context`` and parse it as an
@@ -222,27 +222,27 @@ class ClangTidyCheck : public ast_matchers::MatchFinder::MatchCallback {
222222
/// Reads the option with the check-local name \p LocalName from local or
223223
/// global ``CheckOptions``. Gets local option first. If local is not
224224
/// present, falls back to get global option. If global option is not
225-
/// present either, return ``None``.
225+
/// present either, return ``std::nullopt``.
226226
///
227227
/// If the corresponding key can't be parsed as a ``T``, emit a
228-
/// diagnostic and return ``None``.
228+
/// diagnostic and return ``std::nullopt``.
229229
template <typename T>
230-
std::enable_if_t<std::is_integral<T>::value, llvm::Optional<T>>
230+
std::enable_if_t<std::is_integral<T>::value, std::optional<T>>
231231
getLocalOrGlobal(StringRef LocalName) const {
232-
llvm::Optional<StringRef> ValueOr = get(LocalName);
232+
std::optional<StringRef> ValueOr = get(LocalName);
233233
bool IsGlobal = false;
234234
if (!ValueOr) {
235235
IsGlobal = true;
236236
ValueOr = getLocalOrGlobal(LocalName);
237237
if (!ValueOr)
238-
return None;
238+
return std::nullopt;
239239
}
240240
T Result{};
241241
if (!StringRef(*ValueOr).getAsInteger(10, Result))
242242
return Result;
243243
diagnoseBadIntegerOption(
244244
IsGlobal ? Twine(LocalName) : NamePrefix + LocalName, *ValueOr);
245-
return None;
245+
return std::nullopt;
246246
}
247247

248248
/// Read a named option from the ``Context`` and parse it as an
@@ -266,20 +266,20 @@ class ClangTidyCheck : public ast_matchers::MatchFinder::MatchCallback {
266266
///
267267
/// Reads the option with the check-local name \p LocalName from the
268268
/// ``CheckOptions``. If the corresponding key is not present, return
269-
/// ``None``.
269+
/// ``std::nullopt``.
270270
///
271271
/// If the corresponding key can't be parsed as a ``T``, emit a
272-
/// diagnostic and return ``None``.
272+
/// diagnostic and return ``std::nullopt``.
273273
///
274274
/// \ref clang::tidy::OptionEnumMapping must be specialized for ``T`` to
275275
/// supply the mapping required to convert between ``T`` and a string.
276276
template <typename T>
277-
std::enable_if_t<std::is_enum<T>::value, llvm::Optional<T>>
277+
std::enable_if_t<std::is_enum<T>::value, std::optional<T>>
278278
get(StringRef LocalName, bool IgnoreCase = false) const {
279-
if (llvm::Optional<int64_t> ValueOr =
279+
if (std::optional<int64_t> ValueOr =
280280
getEnumInt(LocalName, typeEraseMapping<T>(), false, IgnoreCase))
281281
return static_cast<T>(*ValueOr);
282-
return None;
282+
return std::nullopt;
283283
}
284284

285285
/// Read a named option from the ``Context`` and parse it as an
@@ -306,20 +306,20 @@ class ClangTidyCheck : public ast_matchers::MatchFinder::MatchCallback {
306306
/// Reads the option with the check-local name \p LocalName from local or
307307
/// global ``CheckOptions``. Gets local option first. If local is not
308308
/// present, falls back to get global option. If global option is not
309-
/// present either, returns ``None``.
309+
/// present either, returns ``std::nullopt``.
310310
///
311311
/// If the corresponding key can't be parsed as a ``T``, emit a
312-
/// diagnostic and return ``None``.
312+
/// diagnostic and return ``std::nullopt``.
313313
///
314314
/// \ref clang::tidy::OptionEnumMapping must be specialized for ``T`` to
315315
/// supply the mapping required to convert between ``T`` and a string.
316316
template <typename T>
317-
std::enable_if_t<std::is_enum<T>::value, llvm::Optional<T>>
317+
std::enable_if_t<std::is_enum<T>::value, std::optional<T>>
318318
getLocalOrGlobal(StringRef LocalName, bool IgnoreCase = false) const {
319-
if (llvm::Optional<int64_t> ValueOr =
319+
if (std::optional<int64_t> ValueOr =
320320
getEnumInt(LocalName, typeEraseMapping<T>(), true, IgnoreCase))
321321
return static_cast<T>(*ValueOr);
322-
return None;
322+
return std::nullopt;
323323
}
324324

325325
/// Read a named option from the ``Context`` and parse it as an
@@ -378,9 +378,9 @@ class ClangTidyCheck : public ast_matchers::MatchFinder::MatchCallback {
378378
private:
379379
using NameAndValue = std::pair<int64_t, StringRef>;
380380

381-
llvm::Optional<int64_t> getEnumInt(StringRef LocalName,
382-
ArrayRef<NameAndValue> Mapping,
383-
bool CheckGlobal, bool IgnoreCase) const;
381+
std::optional<int64_t> getEnumInt(StringRef LocalName,
382+
ArrayRef<NameAndValue> Mapping,
383+
bool CheckGlobal, bool IgnoreCase) const;
384384

385385
template <typename T>
386386
std::enable_if_t<std::is_enum<T>::value, std::vector<NameAndValue>>
@@ -407,7 +407,6 @@ class ClangTidyCheck : public ast_matchers::MatchFinder::MatchCallback {
407407

408408
private:
409409
void run(const ast_matchers::MatchFinder::MatchResult &Result) override;
410-
StringRef getID() const override { return CheckName; }
411410
std::string CheckName;
412411
ClangTidyContext *Context;
413412

@@ -422,18 +421,19 @@ class ClangTidyCheck : public ast_matchers::MatchFinder::MatchCallback {
422421
bool areDiagsSelfContained() const {
423422
return Context->areDiagsSelfContained();
424423
}
424+
StringRef getID() const override { return CheckName; }
425425
};
426426

427427
/// Read a named option from the ``Context`` and parse it as a bool.
428428
///
429429
/// Reads the option with the check-local name \p LocalName from the
430430
/// ``CheckOptions``. If the corresponding key is not present, return
431-
/// ``None``.
431+
/// ``std::nullopt``.
432432
///
433433
/// If the corresponding key can't be parsed as a bool, emit a
434-
/// diagnostic and return ``None``.
434+
/// diagnostic and return ``std::nullopt``.
435435
template <>
436-
llvm::Optional<bool>
436+
std::optional<bool>
437437
ClangTidyCheck::OptionsView::get<bool>(StringRef LocalName) const;
438438

439439
/// Read a named option from the ``Context`` and parse it as a bool.
@@ -445,7 +445,7 @@ ClangTidyCheck::OptionsView::get<bool>(StringRef LocalName) const;
445445
/// If the corresponding key can't be parsed as a bool, emit a
446446
/// diagnostic and return \p Default.
447447
template <>
448-
llvm::Optional<bool>
448+
std::optional<bool>
449449
ClangTidyCheck::OptionsView::getLocalOrGlobal<bool>(StringRef LocalName) const;
450450

451451
/// Stores an option with the check-local name \p LocalName with

ClangTidyDiagnosticConsumer.h

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@
1111

1212
#include "ClangTidyOptions.h"
1313
#include "ClangTidyProfiling.h"
14+
#include "FileExtensionsSet.h"
1415
#include "NoLintDirectiveHandler.h"
1516
#include "clang/Basic/Diagnostic.h"
1617
#include "clang/Tooling/Core/Diagnostic.h"
1718
#include "llvm/ADT/DenseMap.h"
1819
#include "llvm/ADT/StringSet.h"
1920
#include "llvm/Support/Regex.h"
21+
#include <optional>
2022

2123
namespace clang {
2224

@@ -159,6 +161,14 @@ class ClangTidyContext {
159161
/// \c CurrentFile.
160162
ClangTidyOptions getOptionsForFile(StringRef File) const;
161163

164+
const FileExtensionsSet &getHeaderFileExtensions() const {
165+
return HeaderFileExtensions;
166+
}
167+
168+
const FileExtensionsSet &getImplementationFileExtensions() const {
169+
return ImplementationFileExtensions;
170+
}
171+
162172
/// Returns \c ClangTidyStats containing issued and ignored diagnostic
163173
/// counters.
164174
const ClangTidyStats &getStats() const { return Stats; }
@@ -169,7 +179,7 @@ class ClangTidyContext {
169179

170180
/// Control storage of profile date.
171181
void setProfileStoragePrefix(StringRef ProfilePrefix);
172-
llvm::Optional<ClangTidyProfiling::StorageParams>
182+
std::optional<ClangTidyProfiling::StorageParams>
173183
getProfileStorageParams() const;
174184

175185
/// Should be called when starting to process new translation unit.
@@ -220,6 +230,9 @@ class ClangTidyContext {
220230
std::unique_ptr<CachedGlobList> CheckFilter;
221231
std::unique_ptr<CachedGlobList> WarningAsErrorFilter;
222232

233+
FileExtensionsSet HeaderFileExtensions;
234+
FileExtensionsSet ImplementationFileExtensions;
235+
223236
LangOptions LangOpts;
224237

225238
ClangTidyStats Stats;

ClangTidyForceLinker.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
#include "clang-tidy-config.h"
1313
#include "llvm/Support/Compiler.h"
1414

15-
namespace clang {
16-
namespace tidy {
15+
namespace clang::tidy {
1716

1817
// This anchor is used to force the linker to link the AbseilModule.
1918
extern volatile int AbseilModuleAnchorSource;
@@ -138,7 +137,6 @@ extern volatile int ZirconModuleAnchorSource;
138137
static int LLVM_ATTRIBUTE_UNUSED ZirconModuleAnchorDestination =
139138
ZirconModuleAnchorSource;
140139

141-
} // namespace tidy
142-
} // namespace clang
140+
} // namespace clang::tidy
143141

144142
#endif

ClangTidyModule.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@
1515
#include <functional>
1616
#include <memory>
1717

18-
namespace clang {
19-
namespace tidy {
18+
namespace clang::tidy {
2019

2120
class ClangTidyCheck;
2221
class ClangTidyContext;
@@ -65,11 +64,11 @@ class ClangTidyCheckFactories {
6564

6665
/// Create instances of checks that are enabled.
6766
std::vector<std::unique_ptr<ClangTidyCheck>>
68-
createChecks(ClangTidyContext *Context);
67+
createChecks(ClangTidyContext *Context) const;
6968

7069
/// Create instances of checks that are enabled for the current Language.
7170
std::vector<std::unique_ptr<ClangTidyCheck>>
72-
createChecksForLanguage(ClangTidyContext *Context);
71+
createChecksForLanguage(ClangTidyContext *Context) const;
7372

7473
typedef llvm::StringMap<CheckFactory> FactoryMap;
7574
FactoryMap::const_iterator begin() const { return Factories.begin(); }
@@ -94,7 +93,6 @@ class ClangTidyModule {
9493
virtual ClangTidyOptions getModuleOptions();
9594
};
9695

97-
} // end namespace tidy
98-
} // end namespace clang
96+
} // namespace clang::tidy
9997

10098
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CLANGTIDYMODULE_H

ClangTidyModuleRegistry.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,10 @@
1212
#include "ClangTidyModule.h"
1313
#include "llvm/Support/Registry.h"
1414

15-
namespace clang {
16-
namespace tidy {
15+
namespace clang::tidy {
1716

1817
typedef llvm::Registry<ClangTidyModule> ClangTidyModuleRegistry;
1918

20-
} // end namespace tidy
21-
} // end namespace clang
19+
} // namespace clang::tidy
2220

2321
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CLANGTIDYMODULEREGISTRY_H

0 commit comments

Comments
 (0)