Skip to content

Commit 9f9ba38

Browse files
authored
LLVM and SPIRV-LLVM-Translator pulldown (WW09-13)
LLVM: llvm/llvm-project@ed95655 SPIRV-LLVM-Translator: KhronosGroup/SPIRV-LLVM-Translator@e4af3a9
2 parents 11ba5b5 + fd2bc66 commit 9f9ba38

File tree

9,163 files changed

+777292
-925689
lines changed

Some content is hidden

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

9,163 files changed

+777292
-925689
lines changed

.arcconfig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@
33
"repository.callsign" : "G",
44
"conduit_uri" : "https://reviews.llvm.org/",
55
"base": "git:HEAD^",
6-
"arc.land.onto.default": "main"
6+
"arc.land.onto.default": "main",
7+
"arc.land.onto": ["main"]
78
}

clang-tools-extra/clang-query/Query.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,6 @@ bool HelpQuery::run(llvm::raw_ostream &OS, QuerySession &QS) const {
4848
" AsIs "
4949
"Print and match the AST as clang sees it. This mode is the "
5050
"default.\n"
51-
" IgnoreImplicitCastsAndParentheses "
52-
"Omit implicit casts and parens in matching and dumping.\n"
5351
" IgnoreUnlessSpelledInSource "
5452
"Omit AST nodes unless spelled in the source.\n"
5553
" set output <feature> "

clang-tools-extra/clang-query/tool/ClangQuery.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@
3333
#include "clang/Tooling/Tooling.h"
3434
#include "llvm/LineEditor/LineEditor.h"
3535
#include "llvm/Support/CommandLine.h"
36+
#include "llvm/Support/Error.h"
3637
#include "llvm/Support/MemoryBuffer.h"
3738
#include "llvm/Support/Signals.h"
3839
#include "llvm/Support/WithColor.h"
39-
#include <fstream>
4040
#include <string>
4141

4242
using namespace clang;
@@ -73,16 +73,15 @@ static cl::opt<std::string> PreloadFile(
7373

7474
bool runCommandsInFile(const char *ExeName, std::string const &FileName,
7575
QuerySession &QS) {
76-
std::ifstream Input(FileName.c_str());
77-
if (!Input.is_open()) {
78-
llvm::errs() << ExeName << ": cannot open " << FileName << "\n";
79-
return 1;
76+
auto Buffer = llvm::MemoryBuffer::getFile(FileName);
77+
if (!Buffer) {
78+
llvm::errs() << ExeName << ": cannot open " << FileName << ": "
79+
<< Buffer.getError().message() << "\n";
80+
return true;
8081
}
8182

82-
std::string FileContent((std::istreambuf_iterator<char>(Input)),
83-
std::istreambuf_iterator<char>());
83+
StringRef FileContentRef(Buffer.get()->getBuffer());
8484

85-
StringRef FileContentRef(FileContent);
8685
while (!FileContentRef.empty()) {
8786
QueryRef Q = QueryParser::parse(FileContentRef, QS);
8887
if (!Q->run(llvm::outs(), QS))

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

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ class AnalyzerDiagnosticConsumer : public ento::PathDiagnosticConsumer {
9595

9696
class ErrorReporter {
9797
public:
98-
ErrorReporter(ClangTidyContext &Context, bool ApplyFixes,
98+
ErrorReporter(ClangTidyContext &Context, FixBehaviour ApplyFixes,
9999
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> BaseFS)
100100
: Files(FileSystemOptions(), std::move(BaseFS)),
101101
DiagOpts(new DiagnosticOptions()),
@@ -133,8 +133,9 @@ class ErrorReporter {
133133
auto Diag = Diags.Report(Loc, Diags.getCustomDiagID(Level, "%0 [%1]"))
134134
<< Message.Message << Name;
135135
// FIXME: explore options to support interactive fix selection.
136-
const llvm::StringMap<Replacements> *ChosenFix = selectFirstFix(Error);
137-
if (ApplyFixes && ChosenFix) {
136+
const llvm::StringMap<Replacements> *ChosenFix;
137+
if (ApplyFixes != FB_NoFix &&
138+
(ChosenFix = getFixIt(Error, ApplyFixes == FB_FixNotes))) {
138139
for (const auto &FileAndReplacements : *ChosenFix) {
139140
for (const auto &Repl : FileAndReplacements.second) {
140141
++TotalFixes;
@@ -187,7 +188,7 @@ class ErrorReporter {
187188
}
188189

189190
void finish() {
190-
if (ApplyFixes && TotalFixes > 0) {
191+
if (TotalFixes > 0) {
191192
Rewriter Rewrite(SourceMgr, LangOpts);
192193
for (const auto &FileAndReplacements : FileReplacements) {
193194
StringRef File = FileAndReplacements.first();
@@ -287,7 +288,7 @@ class ErrorReporter {
287288
SourceManager SourceMgr;
288289
llvm::StringMap<Replacements> FileReplacements;
289290
ClangTidyContext &Context;
290-
bool ApplyFixes;
291+
FixBehaviour ApplyFixes;
291292
unsigned TotalFixes;
292293
unsigned AppliedFixes;
293294
unsigned WarningsAsErrors;
@@ -392,6 +393,10 @@ ClangTidyASTConsumerFactory::CreateASTConsumer(
392393
std::vector<std::unique_ptr<ClangTidyCheck>> Checks =
393394
CheckFactories->createChecks(&Context);
394395

396+
llvm::erase_if(Checks, [&](std::unique_ptr<ClangTidyCheck> &Check) {
397+
return !Check->isLanguageVersionSupported(Context.getLangOpts());
398+
});
399+
395400
ast_matchers::MatchFinder::MatchFinderOptions FinderOptions;
396401

397402
std::unique_ptr<ClangTidyProfiling> Profiling;
@@ -415,8 +420,6 @@ ClangTidyASTConsumerFactory::CreateASTConsumer(
415420
}
416421

417422
for (auto &Check : Checks) {
418-
if (!Check->isLanguageVersionSupported(Context.getLangOpts()))
419-
continue;
420423
Check->registerMatchers(&*Finder);
421424
Check->registerPPCallbacks(*SM, PP, ModuleExpanderPP);
422425
}
@@ -500,7 +503,8 @@ runClangTidy(clang::tidy::ClangTidyContext &Context,
500503
const CompilationDatabase &Compilations,
501504
ArrayRef<std::string> InputFiles,
502505
llvm::IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem> BaseFS,
503-
bool EnableCheckProfile, llvm::StringRef StoreCheckProfile) {
506+
bool ApplyAnyFix, bool EnableCheckProfile,
507+
llvm::StringRef StoreCheckProfile) {
504508
ClangTool Tool(Compilations, InputFiles,
505509
std::make_shared<PCHContainerOperations>(), BaseFS);
506510

@@ -527,7 +531,7 @@ runClangTidy(clang::tidy::ClangTidyContext &Context,
527531
Context.setEnableProfiling(EnableCheckProfile);
528532
Context.setProfileStoragePrefix(StoreCheckProfile);
529533

530-
ClangTidyDiagnosticConsumer DiagConsumer(Context);
534+
ClangTidyDiagnosticConsumer DiagConsumer(Context, nullptr, true, ApplyAnyFix);
531535
DiagnosticsEngine DE(new DiagnosticIDs(), new DiagnosticOptions(),
532536
&DiagConsumer, /*ShouldOwnClient=*/false);
533537
Context.setDiagnosticsEngine(&DE);
@@ -574,7 +578,7 @@ runClangTidy(clang::tidy::ClangTidyContext &Context,
574578
}
575579

576580
void handleErrors(llvm::ArrayRef<ClangTidyError> Errors,
577-
ClangTidyContext &Context, bool Fix,
581+
ClangTidyContext &Context, FixBehaviour Fix,
578582
unsigned &WarningsAsErrorsCount,
579583
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> BaseFS) {
580584
ErrorReporter Reporter(Context, Fix, std::move(BaseFS));

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

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,17 +79,28 @@ runClangTidy(clang::tidy::ClangTidyContext &Context,
7979
const tooling::CompilationDatabase &Compilations,
8080
ArrayRef<std::string> InputFiles,
8181
llvm::IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem> BaseFS,
82-
bool EnableCheckProfile = false,
82+
bool ApplyAnyFix, bool EnableCheckProfile = false,
8383
llvm::StringRef StoreCheckProfile = StringRef());
8484

85+
/// Controls what kind of fixes clang-tidy is allowed to apply.
86+
enum FixBehaviour {
87+
/// Don't try to apply any fix.
88+
FB_NoFix,
89+
/// Only apply fixes added to warnings.
90+
FB_Fix,
91+
/// Apply fixes found in notes.
92+
FB_FixNotes
93+
};
94+
8595
// FIXME: This interface will need to be significantly extended to be useful.
8696
// FIXME: Implement confidence levels for displaying/fixing errors.
8797
//
88-
/// Displays the found \p Errors to the users. If \p Fix is true, \p
89-
/// Errors containing fixes are automatically applied and reformatted. If no
90-
/// clang-format configuration file is found, the given \P FormatStyle is used.
98+
/// Displays the found \p Errors to the users. If \p Fix is \ref FB_Fix or \ref
99+
/// FB_FixNotes, \p Errors containing fixes are automatically applied and
100+
/// reformatted. If no clang-format configuration file is found, the given \P
101+
/// FormatStyle is used.
91102
void handleErrors(llvm::ArrayRef<ClangTidyError> Errors,
92-
ClangTidyContext &Context, bool Fix,
103+
ClangTidyContext &Context, FixBehaviour Fix,
93104
unsigned &WarningsAsErrorsCount,
94105
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> BaseFS);
95106

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

Lines changed: 63 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -15,30 +15,6 @@
1515
namespace clang {
1616
namespace tidy {
1717

18-
char MissingOptionError::ID;
19-
char UnparseableEnumOptionError::ID;
20-
char UnparseableIntegerOptionError::ID;
21-
22-
std::string MissingOptionError::message() const {
23-
llvm::SmallString<128> Buffer({"option not found '", OptionName, "'"});
24-
return std::string(Buffer);
25-
}
26-
27-
std::string UnparseableEnumOptionError::message() const {
28-
llvm::SmallString<256> Buffer({"invalid configuration value '", LookupValue,
29-
"' for option '", LookupName, "'"});
30-
if (SuggestedValue)
31-
Buffer.append({"; did you mean '", *SuggestedValue, "'?"});
32-
return std::string(Buffer);
33-
}
34-
35-
std::string UnparseableIntegerOptionError::message() const {
36-
llvm::SmallString<256> Buffer({"invalid configuration value '", LookupValue,
37-
"' for option '", LookupName, "'; expected ",
38-
(IsBoolean ? "a bool" : "an integer value")});
39-
return std::string(Buffer);
40-
}
41-
4218
ClangTidyCheck::ClangTidyCheck(StringRef CheckName, ClangTidyContext *Context)
4319
: CheckName(CheckName), Context(Context),
4420
Options(CheckName, Context->getOptions().CheckOptions, Context) {
@@ -75,12 +51,12 @@ ClangTidyCheck::OptionsView::OptionsView(
7551
: NamePrefix(CheckName.str() + "."), CheckOptions(CheckOptions),
7652
Context(Context) {}
7753

78-
llvm::Expected<std::string>
54+
llvm::Optional<std::string>
7955
ClangTidyCheck::OptionsView::get(StringRef LocalName) const {
8056
const auto &Iter = CheckOptions.find(NamePrefix + LocalName.str());
8157
if (Iter != CheckOptions.end())
8258
return Iter->getValue().Value;
83-
return llvm::make_error<MissingOptionError>((NamePrefix + LocalName).str());
59+
return None;
8460
}
8561

8662
static ClangTidyOptions::OptionMap::const_iterator
@@ -97,16 +73,16 @@ findPriorityOption(const ClangTidyOptions::OptionMap &Options, StringRef NamePre
9773
return IterGlobal;
9874
}
9975

100-
llvm::Expected<std::string>
76+
llvm::Optional<std::string>
10177
ClangTidyCheck::OptionsView::getLocalOrGlobal(StringRef LocalName) const {
10278
auto Iter = findPriorityOption(CheckOptions, NamePrefix, LocalName);
10379
if (Iter != CheckOptions.end())
10480
return Iter->getValue().Value;
105-
return llvm::make_error<MissingOptionError>((NamePrefix + LocalName).str());
81+
return None;
10682
}
10783

108-
static llvm::Expected<bool> getAsBool(StringRef Value,
109-
const llvm::Twine &LookupName) {
84+
static Optional<bool> getAsBool(StringRef Value,
85+
const llvm::Twine &LookupName) {
11086

11187
if (llvm::Optional<bool> Parsed = llvm::yaml::parseBool(Value))
11288
return *Parsed;
@@ -115,46 +91,30 @@ static llvm::Expected<bool> getAsBool(StringRef Value,
11591
long long Number;
11692
if (!Value.getAsInteger(10, Number))
11793
return Number != 0;
118-
return llvm::make_error<UnparseableIntegerOptionError>(LookupName.str(),
119-
Value.str(), true);
94+
return None;
12095
}
12196

12297
template <>
123-
llvm::Expected<bool>
98+
llvm::Optional<bool>
12499
ClangTidyCheck::OptionsView::get<bool>(StringRef LocalName) const {
125-
llvm::Expected<std::string> ValueOr = get(LocalName);
126-
if (ValueOr)
127-
return getAsBool(*ValueOr, NamePrefix + LocalName);
128-
return ValueOr.takeError();
129-
}
130-
131-
template <>
132-
bool ClangTidyCheck::OptionsView::get<bool>(StringRef LocalName,
133-
bool Default) const {
134-
llvm::Expected<bool> ValueOr = get<bool>(LocalName);
135-
if (ValueOr)
136-
return *ValueOr;
137-
reportOptionParsingError(ValueOr.takeError());
138-
return Default;
100+
if (llvm::Optional<std::string> ValueOr = get(LocalName)) {
101+
if (auto Result = getAsBool(*ValueOr, NamePrefix + LocalName))
102+
return Result;
103+
diagnoseBadBooleanOption(NamePrefix + LocalName, *ValueOr);
104+
}
105+
return None;
139106
}
140107

141108
template <>
142-
llvm::Expected<bool>
109+
llvm::Optional<bool>
143110
ClangTidyCheck::OptionsView::getLocalOrGlobal<bool>(StringRef LocalName) const {
144111
auto Iter = findPriorityOption(CheckOptions, NamePrefix, LocalName);
145-
if (Iter != CheckOptions.end())
146-
return getAsBool(Iter->getValue().Value, Iter->getKey());
147-
return llvm::make_error<MissingOptionError>((NamePrefix + LocalName).str());
148-
}
149-
150-
template <>
151-
bool ClangTidyCheck::OptionsView::getLocalOrGlobal<bool>(StringRef LocalName,
152-
bool Default) const {
153-
llvm::Expected<bool> ValueOr = getLocalOrGlobal<bool>(LocalName);
154-
if (ValueOr)
155-
return *ValueOr;
156-
reportOptionParsingError(ValueOr.takeError());
157-
return Default;
112+
if (Iter != CheckOptions.end()) {
113+
if (auto Result = getAsBool(Iter->getValue().Value, Iter->getKey()))
114+
return Result;
115+
diagnoseBadBooleanOption(Iter->getKey(), Iter->getValue().Value);
116+
}
117+
return None;
158118
}
159119

160120
void ClangTidyCheck::OptionsView::store(ClangTidyOptions::OptionMap &Options,
@@ -176,14 +136,14 @@ void ClangTidyCheck::OptionsView::store<bool>(
176136
store(Options, LocalName, Value ? StringRef("true") : StringRef("false"));
177137
}
178138

179-
llvm::Expected<int64_t> ClangTidyCheck::OptionsView::getEnumInt(
139+
llvm::Optional<int64_t> ClangTidyCheck::OptionsView::getEnumInt(
180140
StringRef LocalName, ArrayRef<NameAndValue> Mapping, bool CheckGlobal,
181141
bool IgnoreCase) const {
182142
auto Iter = CheckGlobal
183143
? findPriorityOption(CheckOptions, NamePrefix, LocalName)
184144
: CheckOptions.find((NamePrefix + LocalName).str());
185145
if (Iter == CheckOptions.end())
186-
return llvm::make_error<MissingOptionError>((NamePrefix + LocalName).str());
146+
return None;
187147

188148
StringRef Value = Iter->getValue().Value;
189149
StringRef Closest;
@@ -206,39 +166,54 @@ llvm::Expected<int64_t> ClangTidyCheck::OptionsView::getEnumInt(
206166
}
207167
}
208168
if (EditDistance < 3)
209-
return llvm::make_error<UnparseableEnumOptionError>(
210-
Iter->getKey().str(), Iter->getValue().Value, Closest.str());
211-
return llvm::make_error<UnparseableEnumOptionError>(Iter->getKey().str(),
212-
Iter->getValue().Value);
169+
diagnoseBadEnumOption(Iter->getKey().str(), Iter->getValue().Value,
170+
Closest);
171+
else
172+
diagnoseBadEnumOption(Iter->getKey().str(), Iter->getValue().Value);
173+
return None;
213174
}
214175

215-
void ClangTidyCheck::OptionsView::reportOptionParsingError(
216-
llvm::Error &&Err) const {
217-
if (auto RemainingErrors =
218-
llvm::handleErrors(std::move(Err), [](const MissingOptionError &) {}))
219-
Context->configurationDiag(llvm::toString(std::move(RemainingErrors)));
176+
static constexpr llvm::StringLiteral ConfigWarning(
177+
"invalid configuration value '%0' for option '%1'%select{|; expected a "
178+
"bool|; expected an integer|; did you mean '%3'?}2");
179+
180+
void ClangTidyCheck::OptionsView::diagnoseBadBooleanOption(
181+
const Twine &Lookup, StringRef Unparsed) const {
182+
SmallString<64> Buffer;
183+
Context->configurationDiag(ConfigWarning)
184+
<< Unparsed << Lookup.toStringRef(Buffer) << 1;
220185
}
221186

222-
template <>
223-
Optional<std::string> ClangTidyCheck::OptionsView::getOptional<std::string>(
224-
StringRef LocalName) const {
225-
if (auto ValueOr = get(LocalName))
226-
return *ValueOr;
227-
else
228-
consumeError(ValueOr.takeError());
229-
return llvm::None;
187+
void ClangTidyCheck::OptionsView::diagnoseBadIntegerOption(
188+
const Twine &Lookup, StringRef Unparsed) const {
189+
SmallString<64> Buffer;
190+
Context->configurationDiag(ConfigWarning)
191+
<< Unparsed << Lookup.toStringRef(Buffer) << 2;
230192
}
231193

232-
template <>
233-
Optional<std::string>
234-
ClangTidyCheck::OptionsView::getOptionalLocalOrGlobal<std::string>(
235-
StringRef LocalName) const {
236-
if (auto ValueOr = getLocalOrGlobal(LocalName))
237-
return *ValueOr;
194+
void ClangTidyCheck::OptionsView::diagnoseBadEnumOption(
195+
const Twine &Lookup, StringRef Unparsed, StringRef Suggestion) const {
196+
SmallString<64> Buffer;
197+
auto Diag = Context->configurationDiag(ConfigWarning)
198+
<< Unparsed << Lookup.toStringRef(Buffer);
199+
if (Suggestion.empty())
200+
Diag << 0;
238201
else
239-
consumeError(ValueOr.takeError());
240-
return llvm::None;
202+
Diag << 3 << Suggestion;
241203
}
242204

205+
std::string ClangTidyCheck::OptionsView::get(StringRef LocalName,
206+
StringRef Default) const {
207+
if (llvm::Optional<std::string> Val = get(LocalName))
208+
return std::move(*Val);
209+
return Default.str();
210+
}
211+
std::string
212+
ClangTidyCheck::OptionsView::getLocalOrGlobal(StringRef LocalName,
213+
StringRef Default) const {
214+
if (llvm::Optional<std::string> Val = getLocalOrGlobal(LocalName))
215+
return std::move(*Val);
216+
return Default.str();
217+
}
243218
} // namespace tidy
244219
} // namespace clang

0 commit comments

Comments
 (0)