Skip to content

Commit 15b2118

Browse files
authored
Merge branch 'main' into lldb-mcp-multiple-clients
2 parents 400d78c + 18420d8 commit 15b2118

File tree

695 files changed

+23341
-12563
lines changed

Some content is hidden

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

695 files changed

+23341
-12563
lines changed

.ci/compute_projects.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@
150150
"mlir": "check-mlir",
151151
"openmp": "check-openmp",
152152
"polly": "check-polly",
153+
"lit": "check-lit",
153154
}
154155

155156
RUNTIMES = {"libcxx", "libcxxabi", "libunwind", "compiler-rt", "libc", "flang-rt"}
@@ -166,8 +167,12 @@
166167
("llvm", "utils", "gn"): "gn",
167168
(".github", "workflows", "premerge.yaml"): ".ci",
168169
("third-party",): ".ci",
170+
("llvm", "utils", "lit"): "lit",
169171
}
170172

173+
# Projects that should run tests but cannot be explicitly built.
174+
SKIP_BUILD_PROJECTS = ["CIR", "lit"]
175+
171176
# Projects that should not run any tests. These need to be metaprojects.
172177
SKIP_PROJECTS = ["docs", "gn"]
173178

@@ -315,7 +320,9 @@ def get_env_variables(modified_files: list[str], platform: str) -> Set[str]:
315320
# clang build, but it requires an explicit option to enable. We set that
316321
# option here, and remove it from the projects_to_build list.
317322
enable_cir = "ON" if "CIR" in projects_to_build else "OFF"
318-
projects_to_build.discard("CIR")
323+
# Remove any metaprojects from the list of projects to build.
324+
for project in SKIP_BUILD_PROJECTS:
325+
projects_to_build.discard(project)
319326

320327
# We use a semicolon to separate the projects/runtimes as they get passed
321328
# to the CMake invocation and thus we need to use the CMake list separator

.ci/compute_projects_test.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,30 @@ def test_third_party_benchmark(self):
413413
"check-cxx check-cxxabi check-unwind",
414414
)
415415

416+
def test_lit(self):
417+
env_variables = compute_projects.get_env_variables(
418+
["llvm/utils/lit/CMakeLists.txt"], "Linux"
419+
)
420+
self.assertEqual(
421+
env_variables["projects_to_build"],
422+
"bolt;clang;clang-tools-extra;flang;lld;lldb;llvm;mlir;polly",
423+
)
424+
self.assertEqual(
425+
env_variables["project_check_targets"],
426+
"check-bolt check-clang check-clang-tools check-flang check-lit check-lld check-lldb check-llvm check-mlir check-polly",
427+
)
428+
self.assertEqual(
429+
env_variables["runtimes_to_build"], "libcxx;libcxxabi;libunwind"
430+
)
431+
self.assertEqual(
432+
env_variables["runtimes_check_targets"],
433+
"",
434+
)
435+
self.assertEqual(
436+
env_variables["runtimes_check_targets_needs_reconfig"],
437+
"check-cxx check-cxxabi check-unwind",
438+
)
439+
416440

417441
if __name__ == "__main__":
418442
unittest.main()

.github/CODEOWNERS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@
132132
/mlir/**/Transforms/Mem2Reg.* @moxinilian
133133
/mlir/**/Transforms/SROA.* @moxinilian
134134

135+
# MLIR IRDL-related
136+
/mlir/**/*IRDL* @moxinilian
137+
135138
# BOLT
136139
/bolt/ @aaupov @maksfb @rafaelauler @ayermolo @yota9 @paschalis-mpeis @yozhu
137140

clang-tools-extra/clangd/AST.cpp

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include "clang/Basic/SourceManager.h"
3030
#include "clang/Basic/Specifiers.h"
3131
#include "clang/Index/USRGeneration.h"
32+
#include "clang/Sema/HeuristicResolver.h"
3233
#include "llvm/ADT/ArrayRef.h"
3334
#include "llvm/ADT/STLExtras.h"
3435
#include "llvm/ADT/SmallSet.h"
@@ -479,10 +480,12 @@ namespace {
479480
/// a deduced type set. The AST should be improved to simplify this scenario.
480481
class DeducedTypeVisitor : public RecursiveASTVisitor<DeducedTypeVisitor> {
481482
SourceLocation SearchedLocation;
483+
const HeuristicResolver *Resolver;
482484

483485
public:
484-
DeducedTypeVisitor(SourceLocation SearchedLocation)
485-
: SearchedLocation(SearchedLocation) {}
486+
DeducedTypeVisitor(SourceLocation SearchedLocation,
487+
const HeuristicResolver *Resolver)
488+
: SearchedLocation(SearchedLocation), Resolver(Resolver) {}
486489

487490
// Handle auto initializers:
488491
//- auto i = 1;
@@ -499,6 +502,14 @@ class DeducedTypeVisitor : public RecursiveASTVisitor<DeducedTypeVisitor> {
499502
return true;
500503

501504
if (auto *AT = D->getType()->getContainedAutoType()) {
505+
if (AT->isUndeducedAutoType()) {
506+
if (const auto *VD = dyn_cast<VarDecl>(D)) {
507+
if (Resolver && VD->hasInit()) {
508+
DeducedType = Resolver->resolveExprToType(VD->getInit());
509+
return true;
510+
}
511+
}
512+
}
502513
DeducedType = AT->desugar();
503514
}
504515
return true;
@@ -608,10 +619,12 @@ class DeducedTypeVisitor : public RecursiveASTVisitor<DeducedTypeVisitor> {
608619
};
609620
} // namespace
610621

611-
std::optional<QualType> getDeducedType(ASTContext &ASTCtx, SourceLocation Loc) {
622+
std::optional<QualType> getDeducedType(ASTContext &ASTCtx,
623+
const HeuristicResolver *Resolver,
624+
SourceLocation Loc) {
612625
if (!Loc.isValid())
613626
return {};
614-
DeducedTypeVisitor V(Loc);
627+
DeducedTypeVisitor V(Loc, Resolver);
615628
V.TraverseAST(ASTCtx);
616629
if (V.DeducedType.isNull())
617630
return std::nullopt;

clang-tools-extra/clangd/AST.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ namespace clang {
3131
class SourceManager;
3232
class Decl;
3333
class DynTypedNode;
34+
class HeuristicResolver;
3435

3536
namespace clangd {
3637

@@ -167,7 +168,8 @@ QualType declaredType(const TypeDecl *D);
167168
/// Retrieves the deduced type at a given location (auto, decltype).
168169
/// It will return the underlying type.
169170
/// If the type is an undeduced auto, returns the type itself.
170-
std::optional<QualType> getDeducedType(ASTContext &, SourceLocation Loc);
171+
std::optional<QualType> getDeducedType(ASTContext &, const HeuristicResolver *,
172+
SourceLocation Loc);
171173

172174
// Find the abbreviated-function-template `auto` within a type, or returns null.
173175
// Similar to getContainedAutoTypeLoc, but these `auto`s are

clang-tools-extra/clangd/Hover.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1309,7 +1309,9 @@ std::optional<HoverInfo> getHover(ParsedAST &AST, Position Pos,
13091309
}
13101310
} else if (Tok.kind() == tok::kw_auto || Tok.kind() == tok::kw_decltype) {
13111311
HoverCountMetric.record(1, "keyword");
1312-
if (auto Deduced = getDeducedType(AST.getASTContext(), Tok.location())) {
1312+
if (auto Deduced =
1313+
getDeducedType(AST.getASTContext(), AST.getHeuristicResolver(),
1314+
Tok.location())) {
13131315
HI = getDeducedTypeHoverContents(*Deduced, Tok, AST.getASTContext(), PP,
13141316
Index);
13151317
HighlightRange = Tok.range(SM).toCharRange(SM);

clang-tools-extra/clangd/InlayHints.cpp

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -633,13 +633,30 @@ class InlayHintVisitor : public RecursiveASTVisitor<InlayHintVisitor> {
633633
}
634634

635635
if (auto *AT = D->getType()->getContainedAutoType()) {
636-
if (AT->isDeduced() && !D->getType()->isDependentType()) {
637-
// Our current approach is to place the hint on the variable
638-
// and accordingly print the full type
639-
// (e.g. for `const auto& x = 42`, print `const int&`).
640-
// Alternatively, we could place the hint on the `auto`
641-
// (and then just print the type deduced for the `auto`).
642-
addTypeHint(D->getLocation(), D->getType(), /*Prefix=*/": ");
636+
if (AT->isDeduced()) {
637+
QualType T;
638+
// If the type is dependent, HeuristicResolver *may* be able to
639+
// resolve it to something that's useful to print. In other
640+
// cases, it can't, and the resultng type would just be printed
641+
// as "<dependent type>", in which case don't hint it at all.
642+
if (D->getType()->isDependentType()) {
643+
if (D->hasInit()) {
644+
QualType Resolved = Resolver->resolveExprToType(D->getInit());
645+
if (Resolved != AST.DependentTy) {
646+
T = Resolved;
647+
}
648+
}
649+
} else {
650+
T = D->getType();
651+
}
652+
if (!T.isNull()) {
653+
// Our current approach is to place the hint on the variable
654+
// and accordingly print the full type
655+
// (e.g. for `const auto& x = 42`, print `const int&`).
656+
// Alternatively, we could place the hint on the `auto`
657+
// (and then just print the type deduced for the `auto`).
658+
addTypeHint(D->getLocation(), T, /*Prefix=*/": ");
659+
}
643660
}
644661
}
645662

clang-tools-extra/clangd/XRefs.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -806,7 +806,9 @@ std::vector<LocatedSymbol> locateSymbolAt(ParsedAST &AST, Position Pos,
806806
if (Tok.kind() == tok::kw_auto || Tok.kind() == tok::kw_decltype) {
807807
// go-to-definition on auto should find the definition of the deduced
808808
// type, if possible
809-
if (auto Deduced = getDeducedType(AST.getASTContext(), Tok.location())) {
809+
if (auto Deduced =
810+
getDeducedType(AST.getASTContext(), AST.getHeuristicResolver(),
811+
Tok.location())) {
810812
auto LocSym = locateSymbolForType(AST, *Deduced, Index);
811813
if (!LocSym.empty())
812814
return LocSym;
@@ -1965,7 +1967,7 @@ std::vector<const CXXRecordDecl *> findRecordTypeAt(ParsedAST &AST,
19651967

19661968
// Return the type most associated with an AST node.
19671969
// This isn't precisely defined: we want "go to type" to do something useful.
1968-
static QualType typeForNode(const ASTContext &Ctx,
1970+
static QualType typeForNode(const ASTContext &Ctx, const HeuristicResolver *H,
19691971
const SelectionTree::Node *N) {
19701972
// If we're looking at a namespace qualifier, walk up to what it's qualifying.
19711973
// (If we're pointing at a *class* inside a NNS, N will be a TypeLoc).
@@ -1978,7 +1980,7 @@ static QualType typeForNode(const ASTContext &Ctx,
19781980
if (const TypeLoc *TL = N->ASTNode.get<TypeLoc>()) {
19791981
if (llvm::isa<DeducedType>(TL->getTypePtr()))
19801982
if (auto Deduced = getDeducedType(
1981-
N->getDeclContext().getParentASTContext(), TL->getBeginLoc()))
1983+
N->getDeclContext().getParentASTContext(), H, TL->getBeginLoc()))
19821984
return *Deduced;
19831985
// Exception: an alias => underlying type.
19841986
if (llvm::isa<TypedefType>(TL->getTypePtr()))
@@ -2161,7 +2163,8 @@ std::vector<LocatedSymbol> findType(ParsedAST &AST, Position Pos,
21612163
// information about the type you may have not known before
21622164
// (since unique_ptr<unique_ptr<T>> != unique_ptr<T>).
21632165
for (const QualType &Type : unwrapFindType(
2164-
typeForNode(AST.getASTContext(), N), AST.getHeuristicResolver()))
2166+
typeForNode(AST.getASTContext(), AST.getHeuristicResolver(), N),
2167+
AST.getHeuristicResolver()))
21652168
llvm::copy(locateSymbolForType(AST, Type, Index),
21662169
std::back_inserter(LocatedSymbols));
21672170

clang-tools-extra/clangd/refactor/tweaks/ExpandDeducedType.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,8 @@ Expected<Tweak::Effect> ExpandDeducedType::apply(const Selection &Inputs) {
133133
auto &SrcMgr = Inputs.AST->getSourceManager();
134134

135135
std::optional<clang::QualType> DeducedType =
136-
getDeducedType(Inputs.AST->getASTContext(), Range.getBegin());
136+
getDeducedType(Inputs.AST->getASTContext(),
137+
Inputs.AST->getHeuristicResolver(), Range.getBegin());
137138

138139
// if we can't resolve the type, return an error message
139140
if (DeducedType == std::nullopt || (*DeducedType)->isUndeducedAutoType())

clang-tools-extra/clangd/unittests/ASTTests.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,8 @@ TEST(GetDeducedType, KwAutoKwDecltypeExpansion) {
244244
for (Position Pos : File.points()) {
245245
auto Location = sourceLocationInMainFile(SM.get(), Pos);
246246
ASSERT_TRUE(!!Location) << llvm::toString(Location.takeError());
247-
auto DeducedType = getDeducedType(AST.getASTContext(), *Location);
247+
auto DeducedType = getDeducedType(AST.getASTContext(),
248+
AST.getHeuristicResolver(), *Location);
248249
if (T.DeducedType == nullptr) {
249250
EXPECT_FALSE(DeducedType);
250251
} else {

0 commit comments

Comments
 (0)