Skip to content

Commit fbbae18

Browse files
committed
LLVM and SPIRV-LLVM-Translator pulldown (WW01)
LLVM: llvm/llvm-project@202a4c0 SPIRV-LLVM-Translator: KhronosGroup/SPIRV-LLVM-Translator@c0e19d6
2 parents b9854a1 + d28865a commit fbbae18

File tree

1,495 files changed

+73951
-31035
lines changed

Some content is hidden

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

1,495 files changed

+73951
-31035
lines changed

.github/workflows/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Github action workflows should be stored in this directrory.
1+
Github action workflows should be stored in this directory.

.github/workflows/docs.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,4 +167,3 @@ jobs:
167167
run: |
168168
cmake -B flang-build -GNinja -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_PROJECTS="clang;mlir;flang" -DLLVM_ENABLE_SPHINX=ON -DSPHINX_WARNINGS_AS_ERRORS=OFF ./llvm
169169
TZ=UTC ninja -C flang-build docs-flang-html docs-flang-man
170-

.github/workflows/libcxx-build-and-test.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,4 +207,3 @@ jobs:
207207
**/CMakeError.log
208208
**/CMakeOutput.log
209209
**/crash_diagnostics/*
210-

clang-tools-extra/clangd/Hover.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1194,7 +1194,7 @@ void maybeAddSymbolProviders(ParsedAST &AST, HoverInfo &HI,
11941194

11951195
const SourceManager &SM = AST.getSourceManager();
11961196
llvm::SmallVector<include_cleaner::Header> RankedProviders =
1197-
include_cleaner::headersForSymbol(Sym, SM, AST.getPragmaIncludes().get());
1197+
include_cleaner::headersForSymbol(Sym, SM, &AST.getPragmaIncludes());
11981198
if (RankedProviders.empty())
11991199
return;
12001200

@@ -1254,7 +1254,7 @@ void maybeAddUsedSymbols(ParsedAST &AST, HoverInfo &HI, const Inclusion &Inc) {
12541254
llvm::DenseSet<include_cleaner::Symbol> UsedSymbols;
12551255
include_cleaner::walkUsed(
12561256
AST.getLocalTopLevelDecls(), collectMacroReferences(AST),
1257-
AST.getPragmaIncludes().get(), AST.getPreprocessor(),
1257+
&AST.getPragmaIncludes(), AST.getPreprocessor(),
12581258
[&](const include_cleaner::SymbolReference &Ref,
12591259
llvm::ArrayRef<include_cleaner::Header> Providers) {
12601260
if (Ref.RT != include_cleaner::RefType::Explicit ||

clang-tools-extra/clangd/IncludeCleaner.cpp

Lines changed: 3 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848
#include <cassert>
4949
#include <iterator>
5050
#include <map>
51-
#include <memory>
5251
#include <optional>
5352
#include <string>
5453
#include <utility>
@@ -237,18 +236,6 @@ removeAllUnusedIncludes(llvm::ArrayRef<Diag> UnusedIncludes) {
237236
Diag.Fixes.front().Edits.begin(),
238237
Diag.Fixes.front().Edits.end());
239238
}
240-
241-
// TODO(hokein): emit a suitable text for the label.
242-
ChangeAnnotation Annotation = {/*label=*/"",
243-
/*needsConfirmation=*/true,
244-
/*description=*/""};
245-
static const ChangeAnnotationIdentifier RemoveAllUnusedID =
246-
"RemoveAllUnusedIncludes";
247-
for (unsigned I = 0; I < RemoveAll.Edits.size(); ++I) {
248-
ChangeAnnotationIdentifier ID = RemoveAllUnusedID + std::to_string(I);
249-
RemoveAll.Edits[I].annotationId = ID;
250-
RemoveAll.Annotations.push_back({ID, Annotation});
251-
}
252239
return RemoveAll;
253240
}
254241

@@ -268,20 +255,8 @@ addAllMissingIncludes(llvm::ArrayRef<Diag> MissingIncludeDiags) {
268255
Edits.try_emplace(Edit.newText, Edit);
269256
}
270257
}
271-
// FIXME(hokein): emit used symbol reference in the annotation.
272-
ChangeAnnotation Annotation = {/*label=*/"",
273-
/*needsConfirmation=*/true,
274-
/*description=*/""};
275-
static const ChangeAnnotationIdentifier AddAllMissingID =
276-
"AddAllMissingIncludes";
277-
unsigned I = 0;
278-
for (auto &It : Edits) {
279-
ChangeAnnotationIdentifier ID = AddAllMissingID + std::to_string(I++);
258+
for (auto &It : Edits)
280259
AddAllMissing.Edits.push_back(std::move(It.second));
281-
AddAllMissing.Edits.back().annotationId = ID;
282-
283-
AddAllMissing.Annotations.push_back({ID, Annotation});
284-
}
285260
return AddAllMissing;
286261
}
287262
Fix fixAll(const Fix &RemoveAllUnused, const Fix &AddAllMissing) {
@@ -292,11 +267,6 @@ Fix fixAll(const Fix &RemoveAllUnused, const Fix &AddAllMissing) {
292267
FixAll.Edits.push_back(F);
293268
for (const auto &F : AddAllMissing.Edits)
294269
FixAll.Edits.push_back(F);
295-
296-
for (const auto &A : RemoveAllUnused.Annotations)
297-
FixAll.Annotations.push_back(A);
298-
for (const auto &A : AddAllMissing.Annotations)
299-
FixAll.Annotations.push_back(A);
300270
return FixAll;
301271
}
302272

@@ -311,7 +281,7 @@ getUnused(ParsedAST &AST,
311281
auto IncludeID = static_cast<IncludeStructure::HeaderID>(*MFI.HeaderID);
312282
if (ReferencedFiles.contains(IncludeID))
313283
continue;
314-
if (!mayConsiderUnused(MFI, AST, AST.getPragmaIncludes().get())) {
284+
if (!mayConsiderUnused(MFI, AST, &AST.getPragmaIncludes())) {
315285
dlog("{0} was not used, but is not eligible to be diagnosed as unused",
316286
MFI.Written);
317287
continue;
@@ -403,7 +373,7 @@ IncludeCleanerFindings computeIncludeCleanerFindings(ParsedAST &AST) {
403373
.getBuiltinDir();
404374
include_cleaner::walkUsed(
405375
AST.getLocalTopLevelDecls(), /*MacroRefs=*/Macros,
406-
AST.getPragmaIncludes().get(), AST.getPreprocessor(),
376+
&AST.getPragmaIncludes(), AST.getPreprocessor(),
407377
[&](const include_cleaner::SymbolReference &Ref,
408378
llvm::ArrayRef<include_cleaner::Header> Providers) {
409379
bool Satisfied = false;

clang-tools-extra/clangd/InlayHints.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ std::string summarizeExpr(const Expr *E) {
286286
// Step through implicit nodes that clang doesn't classify as such.
287287
std::string VisitCXXMemberCallExpr(const CXXMemberCallExpr *E) {
288288
// Call to operator bool() inside if (X): dispatch to X.
289-
if (E->getNumArgs() == 0 &&
289+
if (E->getNumArgs() == 0 && E->getMethodDecl() &&
290290
E->getMethodDecl()->getDeclName().getNameKind() ==
291291
DeclarationName::CXXConversionFunctionName &&
292292
E->getSourceRange() ==

clang-tools-extra/clangd/ParsedAST.cpp

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -653,18 +653,23 @@ ParsedAST::build(llvm::StringRef Filename, const ParseInputs &Inputs,
653653
}
654654

655655
IncludeStructure Includes;
656+
include_cleaner::PragmaIncludes PI;
656657
// If we are using a preamble, copy existing includes.
657658
if (Preamble) {
658659
Includes = Preamble->Includes;
659660
Includes.MainFileIncludes = Patch->preambleIncludes();
660661
// Replay the preamble includes so that clang-tidy checks can see them.
661662
ReplayPreamble::attach(Patch->preambleIncludes(), *Clang,
662663
Patch->modifiedBounds());
664+
PI = *Preamble->Pragmas;
663665
}
664666
// Important: collectIncludeStructure is registered *after* ReplayPreamble!
665667
// Otherwise we would collect the replayed includes again...
666668
// (We can't *just* use the replayed includes, they don't have Resolved path).
667669
Includes.collect(*Clang);
670+
// Same for pragma-includes, we're already inheriting preamble includes, so we
671+
// should only receive callbacks for non-preamble mainfile includes.
672+
PI.record(*Clang);
668673
// Copy over the macros in the preamble region of the main file, and combine
669674
// with non-preamble macros below.
670675
MainFileMacros Macros;
@@ -735,7 +740,7 @@ ParsedAST::build(llvm::StringRef Filename, const ParseInputs &Inputs,
735740
ParsedAST Result(Filename, Inputs.Version, std::move(Preamble),
736741
std::move(Clang), std::move(Action), std::move(Tokens),
737742
std::move(Macros), std::move(Marks), std::move(ParsedDecls),
738-
std::move(Diags), std::move(Includes));
743+
std::move(Diags), std::move(Includes), std::move(PI));
739744
llvm::move(getIncludeCleanerDiags(Result, Inputs.Contents),
740745
std::back_inserter(Result.Diags));
741746
return std::move(Result);
@@ -828,23 +833,21 @@ ParsedAST::ParsedAST(PathRef TUPath, llvm::StringRef Version,
828833
syntax::TokenBuffer Tokens, MainFileMacros Macros,
829834
std::vector<PragmaMark> Marks,
830835
std::vector<Decl *> LocalTopLevelDecls,
831-
std::vector<Diag> Diags, IncludeStructure Includes)
836+
std::vector<Diag> Diags, IncludeStructure Includes,
837+
include_cleaner::PragmaIncludes PI)
832838
: TUPath(TUPath), Version(Version), Preamble(std::move(Preamble)),
833839
Clang(std::move(Clang)), Action(std::move(Action)),
834840
Tokens(std::move(Tokens)), Macros(std::move(Macros)),
835841
Marks(std::move(Marks)), Diags(std::move(Diags)),
836842
LocalTopLevelDecls(std::move(LocalTopLevelDecls)),
837-
Includes(std::move(Includes)) {
838-
Resolver = std::make_unique<HeuristicResolver>(getASTContext());
843+
Includes(std::move(Includes)), PI(std::move(PI)),
844+
Resolver(std::make_unique<HeuristicResolver>(getASTContext())) {
839845
assert(this->Clang);
840846
assert(this->Action);
841847
}
842848

843-
std::shared_ptr<const include_cleaner::PragmaIncludes>
844-
ParsedAST::getPragmaIncludes() const {
845-
if (!Preamble)
846-
return nullptr;
847-
return Preamble->Pragmas;
849+
const include_cleaner::PragmaIncludes &ParsedAST::getPragmaIncludes() const {
850+
return PI;
848851
}
849852

850853
std::optional<llvm::StringRef> ParsedAST::preambleVersion() const {

clang-tools-extra/clangd/ParsedAST.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,8 @@ class ParsedAST {
103103
/// Tokens recorded while parsing the main file.
104104
/// (!) does not have tokens from the preamble.
105105
const syntax::TokenBuffer &getTokens() const { return Tokens; }
106-
/// Returns the PramaIncludes from the preamble.
107-
/// Might be null if AST is built without a preamble.
108-
std::shared_ptr<const include_cleaner::PragmaIncludes>
109-
getPragmaIncludes() const;
106+
/// Returns the PramaIncludes for preamble + main file includes.
107+
const include_cleaner::PragmaIncludes &getPragmaIncludes() const;
110108

111109
/// Returns the version of the ParseInputs this AST was built from.
112110
llvm::StringRef version() const { return Version; }
@@ -129,7 +127,7 @@ class ParsedAST {
129127
std::unique_ptr<FrontendAction> Action, syntax::TokenBuffer Tokens,
130128
MainFileMacros Macros, std::vector<PragmaMark> Marks,
131129
std::vector<Decl *> LocalTopLevelDecls, std::vector<Diag> Diags,
132-
IncludeStructure Includes);
130+
IncludeStructure Includes, include_cleaner::PragmaIncludes PI);
133131
Path TUPath;
134132
std::string Version;
135133
// In-memory preambles must outlive the AST, it is important that this member
@@ -159,6 +157,7 @@ class ParsedAST {
159157
// top-level decls from the preamble.
160158
std::vector<Decl *> LocalTopLevelDecls;
161159
IncludeStructure Includes;
160+
include_cleaner::PragmaIncludes PI;
162161
std::unique_ptr<HeuristicResolver> Resolver;
163162
};
164163

clang-tools-extra/clangd/XRefs.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1339,7 +1339,7 @@ maybeFindIncludeReferences(ParsedAST &AST, Position Pos,
13391339
auto Converted = convertIncludes(AST);
13401340
include_cleaner::walkUsed(
13411341
AST.getLocalTopLevelDecls(), collectMacroReferences(AST),
1342-
AST.getPragmaIncludes().get(), AST.getPreprocessor(),
1342+
&AST.getPragmaIncludes(), AST.getPreprocessor(),
13431343
[&](const include_cleaner::SymbolReference &Ref,
13441344
llvm::ArrayRef<include_cleaner::Header> Providers) {
13451345
if (Ref.RT != include_cleaner::RefType::Explicit ||

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ FileShardedIndex::getShard(llvm::StringRef Uri) const {
223223
SlabTuple indexMainDecls(ParsedAST &AST) {
224224
return indexSymbols(
225225
AST.getASTContext(), AST.getPreprocessor(), AST.getLocalTopLevelDecls(),
226-
&AST.getMacros(), *AST.getPragmaIncludes(),
226+
&AST.getMacros(), AST.getPragmaIncludes(),
227227
/*IsIndexMainAST=*/true, AST.version(), /*CollectMainFileRefs=*/true);
228228
}
229229

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -821,7 +821,8 @@ void SymbolCollector::setIncludeLocation(const Symbol &S, SourceLocation DefLoc,
821821

822822
// Use the expansion location to get the #include header since this is
823823
// where the symbol is exposed.
824-
IncludeFiles[S.ID] = SM.getDecomposedExpansionLoc(DefLoc).first;
824+
if (FileID FID = SM.getDecomposedExpansionLoc(DefLoc).first; FID.isValid())
825+
IncludeFiles[S.ID] = FID;
825826

826827
// We update providers for a symbol with each occurence, as SymbolCollector
827828
// might run while parsing, rather than at the end of a translation unit.
@@ -879,16 +880,15 @@ void SymbolCollector::finish() {
879880
const Symbol *S = Symbols.find(SID);
880881
if (!S)
881882
continue;
882-
assert(IncludeFiles.contains(SID));
883883

884-
const auto FID = IncludeFiles.at(SID);
884+
FileID FID = IncludeFiles.lookup(SID);
885885
// Determine if the FID is #include'd or #import'ed.
886886
Symbol::IncludeDirective Directives = Symbol::Invalid;
887887
auto CollectDirectives = shouldCollectIncludePath(S->SymInfo.Kind);
888888
if ((CollectDirectives & Symbol::Include) != 0)
889889
Directives |= Symbol::Include;
890890
// Only allow #import for symbols from ObjC-like files.
891-
if ((CollectDirectives & Symbol::Import) != 0) {
891+
if ((CollectDirectives & Symbol::Import) != 0 && FID.isValid()) {
892892
auto [It, Inserted] = FileToContainsImportsOrObjC.try_emplace(FID);
893893
if (Inserted)
894894
It->second = FilesWithObjCConstructs.contains(FID) ||
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// RUN: rm -rf %t.dir && mkdir -p %t.dir
2+
// RUN: echo '[{"directory": "%/t.dir", "command": "clang --target=x86_64-pc-windows-msvc -x c GH75115.test", "file": "GH75115.test"}]' > %t.dir/compile_commands.json
3+
// RUN: clangd -enable-config=0 --compile-commands-dir=%t.dir -check=%s 2>&1 | FileCheck -strict-whitespace %s
4+
5+
// CHECK: Building preamble...
6+
// CHECK-NEXT: Built preamble
7+
// CHECK-NEXT: Indexing headers...
8+
// CHECK-NEXT: Building AST...
9+
// CHECK-NEXT: Indexing AST...
10+
// CHECK-NEXT: Building inlay hints
11+
// CHECK-NEXT: semantic highlighting
12+
// CHECK-NEXT: Testing features at each token
13+
// CHECK-NEXT: All checks completed, 0 errors
14+
15+
#define assert

0 commit comments

Comments
 (0)