Skip to content

Commit ae1b53a

Browse files
author
Frank Laub
authored
Merge pull request #23 from plaidml/flaub-sync
Update to latest LLVM
2 parents 560f8ef + 724aef5 commit ae1b53a

File tree

6,207 files changed

+282292
-77489
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

6,207 files changed

+282292
-77489
lines changed

.git-blame-ignore-revs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,12 @@ b9c1b51e45b845debb76d8658edabca70ca56079
2222

2323
# r302496: That is the revert of r302421
2424
ff63090b0e1072bd398b8efef8ae2291613a6ec9
25+
26+
# Fix more line endings changed in r320089. NFC.
27+
d8f0e6caa91e230a486c948ab643174e40bdf215
28+
29+
# Correct line endings that got mixed up in r320089; NFC.
30+
29dc5ded45447915d96ef7ca3f02acf2232282e0
31+
32+
# Remove line-endings added by r320089. NFC.
33+
100a0eedc00b2bf48bcdc6c209c000745a4a0e48

clang-tools-extra/clang-tidy/ClangTidy.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -329,12 +329,11 @@ static void setStaticAnalyzerCheckerOpts(const ClangTidyOptions &Opts,
329329
AnalyzerOptionsRef AnalyzerOptions) {
330330
StringRef AnalyzerPrefix(AnalyzerCheckNamePrefix);
331331
for (const auto &Opt : Opts.CheckOptions) {
332-
StringRef OptName(Opt.first);
333-
if (!OptName.startswith(AnalyzerPrefix))
332+
StringRef OptName(Opt.getKey());
333+
if (!OptName.consume_front(AnalyzerPrefix))
334334
continue;
335335
// Analyzer options are always local options so we can ignore priority.
336-
AnalyzerOptions->Config[OptName.substr(AnalyzerPrefix.size())] =
337-
Opt.second.Value;
336+
AnalyzerOptions->Config[OptName] = Opt.getValue().Value;
338337
}
339338
}
340339

@@ -450,8 +449,8 @@ ClangTidyASTConsumerFactory::CreateASTConsumer(
450449
std::vector<std::string> ClangTidyASTConsumerFactory::getCheckNames() {
451450
std::vector<std::string> CheckNames;
452451
for (const auto &CheckFactory : *CheckFactories) {
453-
if (Context.isCheckEnabled(CheckFactory.first))
454-
CheckNames.push_back(CheckFactory.first);
452+
if (Context.isCheckEnabled(CheckFactory.getKey()))
453+
CheckNames.emplace_back(CheckFactory.getKey());
455454
}
456455

457456
#if CLANG_ENABLE_STATIC_ANALYZER

clang-tools-extra/clang-tidy/ClangTidyCheck.cpp

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ llvm::Expected<std::string>
7272
ClangTidyCheck::OptionsView::get(StringRef LocalName) const {
7373
const auto &Iter = CheckOptions.find(NamePrefix + LocalName.str());
7474
if (Iter != CheckOptions.end())
75-
return Iter->second.Value;
75+
return Iter->getValue().Value;
7676
return llvm::make_error<MissingOptionError>((NamePrefix + LocalName).str());
7777
}
7878

@@ -85,7 +85,7 @@ findPriorityOption(const ClangTidyOptions::OptionMap &Options, StringRef NamePre
8585
return IterGlobal;
8686
if (IterGlobal == Options.end())
8787
return IterLocal;
88-
if (IterLocal->second.Priority >= IterGlobal->second.Priority)
88+
if (IterLocal->getValue().Priority >= IterGlobal->getValue().Priority)
8989
return IterLocal;
9090
return IterGlobal;
9191
}
@@ -94,7 +94,7 @@ llvm::Expected<std::string>
9494
ClangTidyCheck::OptionsView::getLocalOrGlobal(StringRef LocalName) const {
9595
auto Iter = findPriorityOption(CheckOptions, NamePrefix, LocalName);
9696
if (Iter != CheckOptions.end())
97-
return Iter->second.Value;
97+
return Iter->getValue().Value;
9898
return llvm::make_error<MissingOptionError>((NamePrefix + LocalName).str());
9999
}
100100

@@ -135,7 +135,7 @@ llvm::Expected<bool>
135135
ClangTidyCheck::OptionsView::getLocalOrGlobal<bool>(StringRef LocalName) const {
136136
auto Iter = findPriorityOption(CheckOptions, NamePrefix, LocalName);
137137
if (Iter != CheckOptions.end())
138-
return getAsBool(Iter->second.Value, Iter->first);
138+
return getAsBool(Iter->getValue().Value, Iter->getKey());
139139
return llvm::make_error<MissingOptionError>((NamePrefix + LocalName).str());
140140
}
141141

@@ -155,23 +155,29 @@ void ClangTidyCheck::OptionsView::store(ClangTidyOptions::OptionMap &Options,
155155
Options[NamePrefix + LocalName.str()] = Value;
156156
}
157157

158-
void ClangTidyCheck::OptionsView::store(ClangTidyOptions::OptionMap &Options,
159-
StringRef LocalName,
160-
int64_t Value) const {
158+
void ClangTidyCheck::OptionsView::storeInt(ClangTidyOptions::OptionMap &Options,
159+
StringRef LocalName,
160+
int64_t Value) const {
161161
store(Options, LocalName, llvm::itostr(Value));
162162
}
163163

164-
llvm::Expected<int64_t>
165-
ClangTidyCheck::OptionsView::getEnumInt(StringRef LocalName,
166-
ArrayRef<NameAndValue> Mapping,
167-
bool CheckGlobal, bool IgnoreCase) {
164+
template <>
165+
void ClangTidyCheck::OptionsView::store<bool>(
166+
ClangTidyOptions::OptionMap &Options, StringRef LocalName,
167+
bool Value) const {
168+
store(Options, LocalName, Value ? StringRef("true") : StringRef("false"));
169+
}
170+
171+
llvm::Expected<int64_t> ClangTidyCheck::OptionsView::getEnumInt(
172+
StringRef LocalName, ArrayRef<NameAndValue> Mapping, bool CheckGlobal,
173+
bool IgnoreCase) const {
168174
auto Iter = CheckGlobal
169175
? findPriorityOption(CheckOptions, NamePrefix, LocalName)
170176
: CheckOptions.find((NamePrefix + LocalName).str());
171177
if (Iter == CheckOptions.end())
172178
return llvm::make_error<MissingOptionError>((NamePrefix + LocalName).str());
173179

174-
StringRef Value = Iter->second.Value;
180+
StringRef Value = Iter->getValue().Value;
175181
StringRef Closest;
176182
unsigned EditDistance = -1;
177183
for (const auto &NameAndEnum : Mapping) {
@@ -193,9 +199,9 @@ ClangTidyCheck::OptionsView::getEnumInt(StringRef LocalName,
193199
}
194200
if (EditDistance < 3)
195201
return llvm::make_error<UnparseableEnumOptionError>(
196-
Iter->first, Iter->second.Value, std::string(Closest));
197-
return llvm::make_error<UnparseableEnumOptionError>(Iter->first,
198-
Iter->second.Value);
202+
Iter->getKey().str(), Iter->getValue().Value, Closest.str());
203+
return llvm::make_error<UnparseableEnumOptionError>(Iter->getKey().str(),
204+
Iter->getValue().Value);
199205
}
200206

201207
void ClangTidyCheck::OptionsView::logErrToStdErr(llvm::Error &&Err) {

clang-tools-extra/clang-tidy/ClangTidyCheck.h

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ class ClangTidyCheck : public ast_matchers::MatchFinder::MatchCallback {
330330
/// supply the mapping required to convert between ``T`` and a string.
331331
template <typename T>
332332
std::enable_if_t<std::is_enum<T>::value, llvm::Expected<T>>
333-
get(StringRef LocalName, bool IgnoreCase = false) {
333+
get(StringRef LocalName, bool IgnoreCase = false) const {
334334
if (llvm::Expected<int64_t> ValueOr =
335335
getEnumInt(LocalName, typeEraseMapping<T>(), false, IgnoreCase))
336336
return static_cast<T>(*ValueOr);
@@ -349,7 +349,7 @@ class ClangTidyCheck : public ast_matchers::MatchFinder::MatchCallback {
349349
/// supply the mapping required to convert between ``T`` and a string.
350350
template <typename T>
351351
std::enable_if_t<std::is_enum<T>::value, T>
352-
get(StringRef LocalName, T Default, bool IgnoreCase = false) {
352+
get(StringRef LocalName, T Default, bool IgnoreCase = false) const {
353353
if (auto ValueOr = get<T>(LocalName, IgnoreCase))
354354
return *ValueOr;
355355
else
@@ -370,8 +370,7 @@ class ClangTidyCheck : public ast_matchers::MatchFinder::MatchCallback {
370370
/// supply the mapping required to convert between ``T`` and a string.
371371
template <typename T>
372372
std::enable_if_t<std::is_enum<T>::value, llvm::Expected<T>>
373-
getLocalOrGlobal(StringRef LocalName,
374-
bool IgnoreCase = false) {
373+
getLocalOrGlobal(StringRef LocalName, bool IgnoreCase = false) const {
375374
if (llvm::Expected<int64_t> ValueOr =
376375
getEnumInt(LocalName, typeEraseMapping<T>(), true, IgnoreCase))
377376
return static_cast<T>(*ValueOr);
@@ -391,7 +390,8 @@ class ClangTidyCheck : public ast_matchers::MatchFinder::MatchCallback {
391390
/// supply the mapping required to convert between ``T`` and a string.
392391
template <typename T>
393392
std::enable_if_t<std::is_enum<T>::value, T>
394-
getLocalOrGlobal(StringRef LocalName, T Default, bool IgnoreCase = false) {
393+
getLocalOrGlobal(StringRef LocalName, T Default,
394+
bool IgnoreCase = false) const {
395395
if (auto ValueOr = getLocalOrGlobal<T>(LocalName, IgnoreCase))
396396
return *ValueOr;
397397
else
@@ -405,9 +405,13 @@ class ClangTidyCheck : public ast_matchers::MatchFinder::MatchCallback {
405405
StringRef Value) const;
406406

407407
/// Stores an option with the check-local name \p LocalName with
408-
/// ``int64_t`` value \p Value to \p Options.
409-
void store(ClangTidyOptions::OptionMap &Options, StringRef LocalName,
410-
int64_t Value) const;
408+
/// integer value \p Value to \p Options.
409+
template <typename T>
410+
std::enable_if_t<std::is_integral<T>::value>
411+
store(ClangTidyOptions::OptionMap &Options, StringRef LocalName,
412+
T Value) const {
413+
storeInt(Options, LocalName, Value);
414+
}
411415

412416
/// Stores an option with the check-local name \p LocalName as the string
413417
/// representation of the Enum \p Value to \p Options.
@@ -416,7 +420,8 @@ class ClangTidyCheck : public ast_matchers::MatchFinder::MatchCallback {
416420
/// supply the mapping required to convert between ``T`` and a string.
417421
template <typename T>
418422
std::enable_if_t<std::is_enum<T>::value>
419-
store(ClangTidyOptions::OptionMap &Options, StringRef LocalName, T Value) {
423+
store(ClangTidyOptions::OptionMap &Options, StringRef LocalName,
424+
T Value) const {
420425
ArrayRef<std::pair<T, StringRef>> Mapping =
421426
OptionEnumMapping<T>::getEnumMapping();
422427
auto Iter = llvm::find_if(
@@ -432,11 +437,11 @@ class ClangTidyCheck : public ast_matchers::MatchFinder::MatchCallback {
432437

433438
llvm::Expected<int64_t> getEnumInt(StringRef LocalName,
434439
ArrayRef<NameAndValue> Mapping,
435-
bool CheckGlobal, bool IgnoreCase);
440+
bool CheckGlobal, bool IgnoreCase) const;
436441

437442
template <typename T>
438443
std::enable_if_t<std::is_enum<T>::value, std::vector<NameAndValue>>
439-
typeEraseMapping() {
444+
typeEraseMapping() const {
440445
ArrayRef<std::pair<T, StringRef>> Mapping =
441446
OptionEnumMapping<T>::getEnumMapping();
442447
std::vector<NameAndValue> Result;
@@ -448,6 +453,9 @@ class ClangTidyCheck : public ast_matchers::MatchFinder::MatchCallback {
448453
return Result;
449454
}
450455

456+
void storeInt(ClangTidyOptions::OptionMap &Options, StringRef LocalName,
457+
int64_t Value) const;
458+
451459
static void logErrToStdErr(llvm::Error &&Err);
452460

453461
std::string NamePrefix;
@@ -509,6 +517,13 @@ template <>
509517
bool ClangTidyCheck::OptionsView::getLocalOrGlobal<bool>(StringRef LocalName,
510518
bool Default) const;
511519

520+
/// Stores an option with the check-local name \p LocalName with
521+
/// bool value \p Value to \p Options.
522+
template <>
523+
void ClangTidyCheck::OptionsView::store<bool>(
524+
ClangTidyOptions::OptionMap &Options, StringRef LocalName,
525+
bool Value) const;
526+
512527
} // namespace tidy
513528
} // namespace clang
514529

clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include "llvm/ADT/STLExtras.h"
3232
#include "llvm/ADT/SmallString.h"
3333
#include "llvm/ADT/StringMap.h"
34+
#include "llvm/Support/ErrorHandling.h"
3435
#include "llvm/Support/FormatVariadic.h"
3536
#include "llvm/Support/Regex.h"
3637
#include <tuple>
@@ -590,6 +591,7 @@ void ClangTidyDiagnosticConsumer::removeIncompatibleErrors() {
590591
// An event can be either the begin or the end of an interval.
591592
enum EventType {
592593
ET_Begin = 1,
594+
ET_Insert = 0,
593595
ET_End = -1,
594596
};
595597

@@ -621,10 +623,17 @@ void ClangTidyDiagnosticConsumer::removeIncompatibleErrors() {
621623
// one will be processed before, disallowing the second one, and the
622624
// end point of the first one will also be processed before,
623625
// disallowing the first one.
624-
if (Type == ET_Begin)
626+
switch (Type) {
627+
case ET_Begin:
625628
Priority = std::make_tuple(Begin, Type, -End, -ErrorSize, ErrorId);
626-
else
629+
break;
630+
case ET_Insert:
631+
Priority = std::make_tuple(Begin, Type, -End, ErrorSize, ErrorId);
632+
break;
633+
case ET_End:
627634
Priority = std::make_tuple(End, Type, -Begin, ErrorSize, ErrorId);
635+
break;
636+
}
628637
}
629638

630639
bool operator<(const Event &Other) const {
@@ -662,19 +671,19 @@ void ClangTidyDiagnosticConsumer::removeIncompatibleErrors() {
662671
}
663672

664673
// Build events from error intervals.
665-
std::map<std::string, std::vector<Event>> FileEvents;
674+
llvm::StringMap<std::vector<Event>> FileEvents;
666675
for (unsigned I = 0; I < ErrorFixes.size(); ++I) {
667676
for (const auto &FileAndReplace : *ErrorFixes[I].second) {
668677
for (const auto &Replace : FileAndReplace.second) {
669678
unsigned Begin = Replace.getOffset();
670679
unsigned End = Begin + Replace.getLength();
671-
const std::string &FilePath = std::string(Replace.getFilePath());
672-
// FIXME: Handle empty intervals, such as those from insertions.
673-
if (Begin == End)
674-
continue;
675-
auto &Events = FileEvents[FilePath];
676-
Events.emplace_back(Begin, End, Event::ET_Begin, I, Sizes[I]);
677-
Events.emplace_back(Begin, End, Event::ET_End, I, Sizes[I]);
680+
auto &Events = FileEvents[Replace.getFilePath()];
681+
if (Begin == End) {
682+
Events.emplace_back(Begin, End, Event::ET_Insert, I, Sizes[I]);
683+
} else {
684+
Events.emplace_back(Begin, End, Event::ET_Begin, I, Sizes[I]);
685+
Events.emplace_back(Begin, End, Event::ET_End, I, Sizes[I]);
686+
}
678687
}
679688
}
680689
}
@@ -686,14 +695,20 @@ void ClangTidyDiagnosticConsumer::removeIncompatibleErrors() {
686695
llvm::sort(Events);
687696
int OpenIntervals = 0;
688697
for (const auto &Event : Events) {
689-
if (Event.Type == Event::ET_End)
690-
--OpenIntervals;
691-
// This has to be checked after removing the interval from the count if it
692-
// is an end event, or before adding it if it is a begin event.
693-
if (OpenIntervals != 0)
694-
Apply[Event.ErrorId] = false;
695-
if (Event.Type == Event::ET_Begin)
696-
++OpenIntervals;
698+
switch (Event.Type) {
699+
case Event::ET_Begin:
700+
if (OpenIntervals++ != 0)
701+
Apply[Event.ErrorId] = false;
702+
break;
703+
case Event::ET_Insert:
704+
if (OpenIntervals != 0)
705+
Apply[Event.ErrorId] = false;
706+
break;
707+
case Event::ET_End:
708+
if (--OpenIntervals != 0)
709+
Apply[Event.ErrorId] = false;
710+
break;
711+
}
697712
}
698713
assert(OpenIntervals == 0 && "Amount of begin/end points doesn't match");
699714
}

clang-tools-extra/clang-tidy/ClangTidyModule.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ namespace tidy {
1818

1919
void ClangTidyCheckFactories::registerCheckFactory(StringRef Name,
2020
CheckFactory Factory) {
21-
Factories[std::string(Name)] = std::move(Factory);
21+
Factories.insert_or_assign(Name, std::move(Factory));
2222
}
2323

2424
std::vector<std::unique_ptr<ClangTidyCheck>>
2525
ClangTidyCheckFactories::createChecks(ClangTidyContext *Context) {
2626
std::vector<std::unique_ptr<ClangTidyCheck>> Checks;
2727
for (const auto &Factory : Factories) {
28-
if (Context->isCheckEnabled(Factory.first))
29-
Checks.emplace_back(Factory.second(Factory.first, Context));
28+
if (Context->isCheckEnabled(Factory.getKey()))
29+
Checks.emplace_back(Factory.getValue()(Factory.getKey(), Context));
3030
}
3131
return Checks;
3232
}

clang-tools-extra/clang-tidy/ClangTidyModule.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class ClangTidyCheckFactories {
6969
std::vector<std::unique_ptr<ClangTidyCheck>>
7070
createChecks(ClangTidyContext *Context);
7171

72-
typedef std::map<std::string, CheckFactory> FactoryMap;
72+
typedef llvm::StringMap<CheckFactory> FactoryMap;
7373
FactoryMap::const_iterator begin() const { return Factories.begin(); }
7474
FactoryMap::const_iterator end() const { return Factories.end(); }
7575
bool empty() const { return Factories.empty(); }

clang-tools-extra/clang-tidy/ClangTidyOptions.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ struct NOptionMap {
7070
NOptionMap(IO &, const ClangTidyOptions::OptionMap &OptionMap) {
7171
Options.reserve(OptionMap.size());
7272
for (const auto &KeyValue : OptionMap)
73-
Options.emplace_back(KeyValue.first, KeyValue.second.Value);
73+
Options.emplace_back(KeyValue.getKey(), KeyValue.getValue().Value);
7474
}
7575
ClangTidyOptions::OptionMap denormalize(IO &) {
7676
ClangTidyOptions::OptionMap Map;
@@ -114,11 +114,9 @@ ClangTidyOptions ClangTidyOptions::getDefaults() {
114114
Options.SystemHeaders = false;
115115
Options.FormatStyle = "none";
116116
Options.User = llvm::None;
117-
unsigned Priority = 0;
118117
for (const ClangTidyModuleRegistry::entry &Module :
119118
ClangTidyModuleRegistry::entries())
120-
Options =
121-
Options.mergeWith(Module.instantiate()->getModuleOptions(), ++Priority);
119+
Options = Options.mergeWith(Module.instantiate()->getModuleOptions(), 0);
122120
return Options;
123121
}
124122

@@ -159,8 +157,10 @@ ClangTidyOptions ClangTidyOptions::mergeWith(const ClangTidyOptions &Other,
159157
mergeVectors(Result.ExtraArgsBefore, Other.ExtraArgsBefore);
160158

161159
for (const auto &KeyValue : Other.CheckOptions) {
162-
Result.CheckOptions[KeyValue.first] = ClangTidyValue(
163-
KeyValue.second.Value, KeyValue.second.Priority + Priority);
160+
Result.CheckOptions.insert_or_assign(
161+
KeyValue.getKey(),
162+
ClangTidyValue(KeyValue.getValue().Value,
163+
KeyValue.getValue().Priority + Priority));
164164
}
165165

166166
return Result;

0 commit comments

Comments
 (0)