Skip to content

Commit ad3e360

Browse files
authored
Merge pull request #127 from sx-aurora-dev/feature/merge-upstream-20211215
Feature/merge upstream 20211215
2 parents ebe1bd0 + 9199072 commit ad3e360

File tree

497 files changed

+13827
-7345
lines changed

Some content is hidden

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

497 files changed

+13827
-7345
lines changed

.github/workflows/new-issues.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ on:
66
jobs:
77
automate-issues-labels:
88
runs-on: ubuntu-latest
9+
if: github.repository == 'llvm/llvm-project'
910
steps:
1011
- uses: andymckay/[email protected]
1112
with:

clang-tools-extra/clangd/ClangdServer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,10 @@ struct UpdateIndexCallbacks : public ParsingCallbacks {
7171
: FIndex(FIndex), ServerCallbacks(ServerCallbacks) {}
7272

7373
void onPreambleAST(PathRef Path, llvm::StringRef Version, ASTContext &Ctx,
74-
std::shared_ptr<clang::Preprocessor> PP,
74+
Preprocessor &PP,
7575
const CanonicalIncludes &CanonIncludes) override {
7676
if (FIndex)
77-
FIndex->updatePreamble(Path, Version, Ctx, std::move(PP), CanonIncludes);
77+
FIndex->updatePreamble(Path, Version, Ctx, PP, CanonIncludes);
7878
}
7979

8080
void onMainAST(PathRef Path, ParsedAST &AST, PublishFn Publish) override {

clang-tools-extra/clangd/ParsedAST.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,8 @@ ParsedAST::build(llvm::StringRef Filename, const ParseInputs &Inputs,
395395
if (IsInsideMainFile &&
396396
tidy::shouldSuppressDiagnostic(DiagLevel, Info, *CTContext,
397397
TidySuppressedErrors,
398-
/*AllowIO=*/false)) {
398+
/*AllowIO=*/false,
399+
/*EnableNolintBlocks=*/false)) {
399400
// FIXME: should we expose the suppression error (invalid use of
400401
// NOLINT comments)?
401402
return DiagnosticsEngine::Ignored;

clang-tools-extra/clangd/Preamble.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,7 @@ class CppFilePreambleCallbacks : public PreambleCallbacks {
8484
void AfterExecute(CompilerInstance &CI) override {
8585
if (ParsedCallback) {
8686
trace::Span Tracer("Running PreambleCallback");
87-
ParsedCallback(CI.getASTContext(), CI.getPreprocessorPtr(),
88-
CanonIncludes);
87+
ParsedCallback(CI.getASTContext(), CI.getPreprocessor(), CanonIncludes);
8988
}
9089

9190
const SourceManager &SM = CI.getSourceManager();

clang-tools-extra/clangd/Preamble.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,8 @@ struct PreambleData {
7272
bool MainIsIncludeGuarded = false;
7373
};
7474

75-
using PreambleParsedCallback =
76-
std::function<void(ASTContext &, std::shared_ptr<clang::Preprocessor>,
77-
const CanonicalIncludes &)>;
75+
using PreambleParsedCallback = std::function<void(ASTContext &, Preprocessor &,
76+
const CanonicalIncludes &)>;
7877

7978
/// Build a preamble for the new inputs unless an old one can be reused.
8079
/// If \p PreambleCallback is set, it will be run on top of the AST while

clang-tools-extra/clangd/TUScheduler.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -977,11 +977,9 @@ void PreambleThread::build(Request Req) {
977977

978978
LatestBuild = clang::clangd::buildPreamble(
979979
FileName, *Req.CI, Inputs, StoreInMemory,
980-
[this, Version(Inputs.Version)](ASTContext &Ctx,
981-
std::shared_ptr<clang::Preprocessor> PP,
980+
[this, Version(Inputs.Version)](ASTContext &Ctx, Preprocessor &PP,
982981
const CanonicalIncludes &CanonIncludes) {
983-
Callbacks.onPreambleAST(FileName, Version, Ctx, std::move(PP),
984-
CanonIncludes);
982+
Callbacks.onPreambleAST(FileName, Version, Ctx, PP, CanonIncludes);
985983
});
986984
if (LatestBuild && isReliable(LatestBuild->CompileCommand))
987985
HeaderIncluders.update(FileName, LatestBuild->Includes.allHeaders());

clang-tools-extra/clangd/TUScheduler.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,7 @@ class ParsingCallbacks {
134134
/// contains only AST nodes from the #include directives at the start of the
135135
/// file. AST node in the current file should be observed on onMainAST call.
136136
virtual void onPreambleAST(PathRef Path, llvm::StringRef Version,
137-
ASTContext &Ctx,
138-
std::shared_ptr<clang::Preprocessor> PP,
137+
ASTContext &Ctx, Preprocessor &PP,
139138
const CanonicalIncludes &) {}
140139

141140
/// The argument function is run under the critical section guarding against

clang-tools-extra/clangd/index/FileIndex.cpp

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ namespace clang {
4545
namespace clangd {
4646
namespace {
4747

48-
SlabTuple indexSymbols(ASTContext &AST, std::shared_ptr<Preprocessor> PP,
48+
SlabTuple indexSymbols(ASTContext &AST, Preprocessor &PP,
4949
llvm::ArrayRef<Decl *> DeclsToIndex,
5050
const MainFileMacros *MacroRefsToIndex,
5151
const CanonicalIncludes &Includes, bool IsIndexMainAST,
@@ -77,7 +77,7 @@ SlabTuple indexSymbols(ASTContext &AST, std::shared_ptr<Preprocessor> PP,
7777

7878
SymbolCollector Collector(std::move(CollectorOpts));
7979
Collector.setPreprocessor(PP);
80-
index::indexTopLevelDecls(AST, *PP, DeclsToIndex, Collector, IndexOpts);
80+
index::indexTopLevelDecls(AST, PP, DeclsToIndex, Collector, IndexOpts);
8181
if (MacroRefsToIndex)
8282
Collector.handleMacros(*MacroRefsToIndex);
8383

@@ -219,18 +219,18 @@ FileShardedIndex::getShard(llvm::StringRef Uri) const {
219219

220220
SlabTuple indexMainDecls(ParsedAST &AST) {
221221
return indexSymbols(
222-
AST.getASTContext(), AST.getPreprocessorPtr(),
223-
AST.getLocalTopLevelDecls(), &AST.getMacros(), AST.getCanonicalIncludes(),
222+
AST.getASTContext(), AST.getPreprocessor(), AST.getLocalTopLevelDecls(),
223+
&AST.getMacros(), AST.getCanonicalIncludes(),
224224
/*IsIndexMainAST=*/true, AST.version(), /*CollectMainFileRefs=*/true);
225225
}
226226

227227
SlabTuple indexHeaderSymbols(llvm::StringRef Version, ASTContext &AST,
228-
std::shared_ptr<Preprocessor> PP,
228+
Preprocessor &PP,
229229
const CanonicalIncludes &Includes) {
230230
std::vector<Decl *> DeclsToIndex(
231231
AST.getTranslationUnitDecl()->decls().begin(),
232232
AST.getTranslationUnitDecl()->decls().end());
233-
return indexSymbols(AST, std::move(PP), DeclsToIndex,
233+
return indexSymbols(AST, PP, DeclsToIndex,
234234
/*MainFileMacros=*/nullptr, Includes,
235235
/*IsIndexMainAST=*/false, Version,
236236
/*CollectMainFileRefs=*/false);
@@ -424,12 +424,11 @@ FileIndex::FileIndex()
424424
MainFileIndex(std::make_unique<MemIndex>()) {}
425425

426426
void FileIndex::updatePreamble(PathRef Path, llvm::StringRef Version,
427-
ASTContext &AST,
428-
std::shared_ptr<Preprocessor> PP,
427+
ASTContext &AST, Preprocessor &PP,
429428
const CanonicalIncludes &Includes) {
430429
IndexFileIn IF;
431430
std::tie(IF.Symbols, std::ignore, IF.Relations) =
432-
indexHeaderSymbols(Version, AST, std::move(PP), Includes);
431+
indexHeaderSymbols(Version, AST, PP, Includes);
433432
FileShardedIndex ShardedIndex(std::move(IF));
434433
for (auto Uri : ShardedIndex.getAllSources()) {
435434
auto IF = ShardedIndex.getShard(Uri);

clang-tools-extra/clangd/index/FileIndex.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,7 @@ class FileIndex : public MergedIndex {
115115
/// Update preamble symbols of file \p Path with all declarations in \p AST
116116
/// and macros in \p PP.
117117
void updatePreamble(PathRef Path, llvm::StringRef Version, ASTContext &AST,
118-
std::shared_ptr<Preprocessor> PP,
119-
const CanonicalIncludes &Includes);
118+
Preprocessor &PP, const CanonicalIncludes &Includes);
120119

121120
/// Update symbols and references from main file \p Path with
122121
/// `indexMainDecls`.
@@ -163,7 +162,7 @@ SlabTuple indexMainDecls(ParsedAST &AST);
163162
/// Index declarations from \p AST and macros from \p PP that are declared in
164163
/// included headers.
165164
SlabTuple indexHeaderSymbols(llvm::StringRef Version, ASTContext &AST,
166-
std::shared_ptr<Preprocessor> PP,
165+
Preprocessor &PP,
167166
const CanonicalIncludes &Includes);
168167

169168
/// Takes slabs coming from a TU (multiple files) and shards them per

clang-tools-extra/clangd/index/SymbolCollector.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ class SymbolCollector::HeaderFileURICache {
186186
// Weird double-indirect access to PP, which might not be ready yet when
187187
// HeaderFiles is created but will be by the time it's used.
188188
// (IndexDataConsumer::setPreprocessor can happen before or after initialize)
189-
const std::shared_ptr<Preprocessor> &PP;
189+
Preprocessor *&PP;
190190
const SourceManager &SM;
191191
const CanonicalIncludes *Includes;
192192
llvm::StringRef FallbackDir;
@@ -195,8 +195,7 @@ class SymbolCollector::HeaderFileURICache {
195195
llvm::DenseMap<FileID, llvm::StringRef> CacheFIDToInclude;
196196

197197
public:
198-
HeaderFileURICache(const std::shared_ptr<Preprocessor> &PP,
199-
const SourceManager &SM,
198+
HeaderFileURICache(Preprocessor *&PP, const SourceManager &SM,
200199
const SymbolCollector::Options &Opts)
201200
: PP(PP), SM(SM), Includes(Opts.Includes), FallbackDir(Opts.FallbackDir) {
202201
}
@@ -304,7 +303,7 @@ SymbolCollector::~SymbolCollector() = default;
304303
void SymbolCollector::initialize(ASTContext &Ctx) {
305304
ASTCtx = &Ctx;
306305
HeaderFileURIs = std::make_unique<HeaderFileURICache>(
307-
PP, ASTCtx->getSourceManager(), Opts);
306+
this->PP, ASTCtx->getSourceManager(), Opts);
308307
CompletionAllocator = std::make_shared<GlobalCodeCompletionAllocator>();
309308
CompletionTUInfo =
310309
std::make_unique<CodeCompletionTUInfo>(CompletionAllocator);
@@ -365,7 +364,7 @@ bool SymbolCollector::handleDeclOccurrence(
365364
const Decl *D, index::SymbolRoleSet Roles,
366365
llvm::ArrayRef<index::SymbolRelation> Relations, SourceLocation Loc,
367366
index::IndexDataConsumer::ASTNodeInfo ASTNode) {
368-
assert(ASTCtx && PP.get() && HeaderFileURIs);
367+
assert(ASTCtx && PP && HeaderFileURIs);
369368
assert(CompletionAllocator && CompletionTUInfo);
370369
assert(ASTNode.OrigD);
371370
// Indexing API puts canonical decl into D, which might not have a valid
@@ -486,7 +485,7 @@ bool SymbolCollector::handleDeclOccurrence(
486485
}
487486

488487
void SymbolCollector::handleMacros(const MainFileMacros &MacroRefsToIndex) {
489-
assert(HeaderFileURIs && PP.get());
488+
assert(HeaderFileURIs && PP);
490489
const auto &SM = PP->getSourceManager();
491490
const auto *MainFileEntry = SM.getFileEntryForID(SM.getMainFileID());
492491
assert(MainFileEntry);
@@ -533,7 +532,7 @@ bool SymbolCollector::handleMacroOccurrence(const IdentifierInfo *Name,
533532
const MacroInfo *MI,
534533
index::SymbolRoleSet Roles,
535534
SourceLocation Loc) {
536-
assert(PP.get());
535+
assert(PP);
537536
// Builtin macros don't have useful locations and aren't needed in completion.
538537
if (MI->isBuiltinMacro())
539538
return true;
@@ -805,7 +804,7 @@ const Symbol *SymbolCollector::addDeclaration(const NamedDecl &ND, SymbolID ID,
805804

806805
// Add completion info.
807806
// FIXME: we may want to choose a different redecl, or combine from several.
808-
assert(ASTCtx && PP.get() && "ASTContext and Preprocessor must be set.");
807+
assert(ASTCtx && PP && "ASTContext and Preprocessor must be set.");
809808
// We use the primary template, as clang does during code completion.
810809
CodeCompletionResult SymbolCompletion(&getTemplateOrThis(ND), 0);
811810
const auto *CCS = SymbolCompletion.CreateCodeCompletionString(

0 commit comments

Comments
 (0)