Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
13a39ea
[Sema] Fix Wunused-but-set-variable warning(NFC) (#169220)
hstk30-hw Nov 24, 2025
b53e46f
[mlir][x86vector] Lower vector.contract to FMA or packed type dot-pro…
arun-thmn Nov 24, 2025
76e7e9f
[LoongArch][NFC] Add tests for combining vand(vnot) (#160830)
ylzsx Nov 24, 2025
d124675
[mlir][x86vector] Add missing Linalg dependency (#169280)
adam-smnk Nov 24, 2025
54db657
[StaticAnalyzer] Use llvm::find_if (NFC) (#169237)
kazutakahirata Nov 24, 2025
67391fc
[mlir] Construct SmallVector with initial values (NFC) (#169239)
kazutakahirata Nov 24, 2025
2b81e9e
[Orc] Use a range-based for loop (NFC) (#169240)
kazutakahirata Nov 24, 2025
7dd531f
[SPIRV] Use range-based for loops (NFC) (#169241)
kazutakahirata Nov 24, 2025
9ce6fad
[AST] Construct iterator_range with the conversion constructor (NFC) …
kazutakahirata Nov 24, 2025
95f0fab
[clang][bytecode] Fix conditional operator scoping wrt. local variabl…
tbaederr Nov 24, 2025
f5cae7b
[ORC] Add unit test for simple cycle in WaitingOnGraph::emit. (#169281)
lhames Nov 24, 2025
02a997c
[clang-format] Handle `import` when used as template function name (#…
owenca Nov 24, 2025
c15a6cc
[Clang][ASTImporter] Fix cycle in importing template specialization o…
ganenkokb-yandex Nov 24, 2025
e888cf8
[AMDGPU] Add wave reduce intrinsics for float types - 2 (#168859)
easyonaadit Nov 24, 2025
1abb055
[IVDesc] Make getCastInsts return an ArrayRef (NFC) (#169021)
artagnon Nov 24, 2025
ce70d4b
[mlir][emitc] Refactor getEmittedExpression (NFC) (#168361)
aniragil Nov 24, 2025
f218573
[llvm][CAS] Remove unused functions (#168856)
DavidSpickett Nov 24, 2025
c745a51
[mlir:x86vector:transform] Fix bazel build after #168074. (#169294)
ingomueller-net Nov 24, 2025
6413e5a
[clangd] Implement fold range for #pragma region (#168177)
hokein Nov 24, 2025
30b1d14
[analyzer] Fix inf recursion in StackAddrEscapeChecker for self refer…
steakhal Nov 24, 2025
4604762
[AMDGPU] Add builtins for wave reduction intrinsics (#161816)
easyonaadit Nov 24, 2025
4b65caf
[AArch64][SVE] Add custom lowering for bfloat FMUL (with +bf16) (#167…
MacDue Nov 24, 2025
121e2e9
[libc++] Introduce basic_string::__allocate_long_buffer_for_growing (…
philnik777 Nov 24, 2025
f3ce5de
[libc++] Forward std::all_of and std::none_of to std::any_of (#167670)
philnik777 Nov 24, 2025
4b35ff5
[RISCV] Enable rematerialization for scalar loads (#166774)
lukel97 Nov 24, 2025
9be30e5
[clang][LoongArch] Introduce LASX and LSX conversion intrinsics (#157…
heiher Nov 24, 2025
8c6ec12
[libc++][array] Applied `[[nodiscard]]` (#168829)
H-G-Hristov Nov 24, 2025
4c4cf71
[libc++][list] Applied `[[nodiscard]]` (#169015)
H-G-Hristov Nov 24, 2025
74a62b1
[X86] avx2-builtins.c - add constexpr test coverage for _mm256_bslli_…
RKSimon Nov 24, 2025
d44d329
[clang][bytecode] Fix compound assign operators for IntAP(S) (#169303)
tbaederr Nov 24, 2025
c73de97
[IVDesciptors] Support detecting reductions with vector instructions.…
juliannagele Nov 24, 2025
840a43b
[libcxx][ci] Temporarily disable ARM jobs (#169318)
DavidSpickett Nov 24, 2025
fe9c8e4
[mlir:x86vector:transform] Fix bazel build (again) after #168074. (#1…
ingomueller-net Nov 24, 2025
5d2fc94
[InstCombine] Fix phi scalarization with binop (#169120)
mjulian31 Nov 24, 2025
d162c91
[ORC] Avoid self-dependence in SuperNode dependence graph. (#169286)
lhames Nov 24, 2025
1dc6ad0
[lldb] Show signal number description (#164176)
da-viper Nov 24, 2025
d416289
[TableGen] Eliminate the dependency on SDNode definition order (#168745)
atrosinenko Nov 24, 2025
d90bc3b
[mlir][XeGPU][VectorToXeGPU] Use 'xegpu.load' to lower 1D 'vector.tra…
dchigarev Nov 24, 2025
5adce54
merge main into amd-staging
z1-cciauto Nov 24, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 78 additions & 3 deletions clang-tools-extra/clangd/SemanticSelection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,13 @@
#include "Protocol.h"
#include "Selection.h"
#include "SourceCode.h"
#include "support/Bracket.h"
#include "support/DirectiveTree.h"
#include "support/Token.h"
#include "clang/AST/DeclBase.h"
#include "clang/Basic/SourceLocation.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Basic/TokenKinds.h"
#include "clang/Tooling/Syntax/BuildTree.h"
#include "clang/Tooling/Syntax/Nodes.h"
#include "clang/Tooling/Syntax/TokenBufferTokenManager.h"
Expand All @@ -22,9 +26,6 @@
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/Error.h"
#include "support/Bracket.h"
#include "support/DirectiveTree.h"
#include "support/Token.h"
#include <optional>
#include <queue>
#include <vector>
Expand Down Expand Up @@ -163,6 +164,69 @@ llvm::Expected<SelectionRange> getSemanticRanges(ParsedAST &AST, Position Pos) {
return std::move(Head);
}

class PragmaRegionFinder {
// Record the token range of a region:
//
// #pragma region name[[
// ...
// ]]#pragma endregion
std::vector<Token::Range> &Ranges;
const TokenStream &Code;
// Stack of starting token (the name of the region) indices for nested #pragma
// region.
std::vector<unsigned> Stack;

public:
PragmaRegionFinder(std::vector<Token::Range> &Ranges, const TokenStream &Code)
: Ranges(Ranges), Code(Code) {}

void walk(const DirectiveTree &T) {
for (const auto &C : T.Chunks)
std::visit(*this, C);
}

void operator()(const DirectiveTree::Code &C) {}

void operator()(const DirectiveTree::Directive &D) {
// Get the tokens that make up this directive.
auto Tokens = Code.tokens(D.Tokens);
if (Tokens.empty())
return;
const Token &HashToken = Tokens.front();
assert(HashToken.Kind == tok::hash);
const Token &Pragma = HashToken.nextNC();
if (Pragma.text() != "pragma")
return;
const Token &Value = Pragma.nextNC();

// Handle "#pragma region name"
if (Value.text() == "region") {
// Find the last token at the same line.
const Token *T = &Value.next();
while (T < Tokens.end() && T->Line == Pragma.Line)
T = &T->next();
--T;
Stack.push_back(T->OriginalIndex);
return;
}

// Handle "#pragma endregion"
if (Value.text() == "endregion") {
if (Stack.empty())
return; // unmatched end region; ignore.

unsigned StartIdx = Stack.back();
Stack.pop_back();
Ranges.push_back(Token::Range{StartIdx, HashToken.OriginalIndex});
}
}

void operator()(const DirectiveTree::Conditional &C) {
for (const auto &[_, SubTree] : C.Branches)
walk(SubTree);
}
};

// FIXME(kirillbobyrev): Collect comments, PP conditional regions, includes and
// other code regions (e.g. public/private/protected sections of classes,
// control flow statement bodies).
Expand Down Expand Up @@ -286,6 +350,17 @@ getFoldingRanges(const std::string &Code, bool LineFoldingOnly) {
}
AddFoldingRange(Start, End, FoldingRange::COMMENT_KIND);
}

// #pragma region
std::vector<Token::Range> Ranges;
PragmaRegionFinder(Ranges, OrigStream).walk(DirectiveStructure);
auto Ts = OrigStream.tokens();
for (const auto &R : Ranges) {
auto End = StartPosition(Ts[R.End]);
if (LineFoldingOnly)
End.line--;
AddFoldingRange(EndPosition(Ts[R.Begin]), End, FoldingRange::REGION_KIND);
}
return Result;
}

Expand Down
22 changes: 22 additions & 0 deletions clang-tools-extra/clangd/unittests/SemanticSelectionTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,22 @@ TEST(FoldingRanges, PseudoParserWithoutLineFoldings) {
Variable = 3;
#
)cpp",
R"cpp(
#pragma region R1[[
#pragma region R2[[
constexpr int a = 2;
]]#pragma endregion
]]#pragma endregion
)cpp",
R"cpp(
#pragma region[[
]]#pragma endregion
#pragma /*comment1*/ region /*comment2*/name[[
]]#pragma endregion
)cpp",
};
for (const char *Test : Tests) {
auto T = Annotations(Test);
Expand Down Expand Up @@ -470,6 +486,12 @@ TEST(FoldingRanges, PseudoParserLineFoldingsOnly) {
//[[ foo
/* bar */]]
)cpp",
R"cpp(
#pragma region abc[[
constexpr int a = 2;
]]
#pragma endregion
)cpp",
// FIXME: Support folding template arguments.
// R"cpp(
// template <[[typename foo, class bar]]> struct baz {};
Expand Down
16 changes: 16 additions & 0 deletions clang/include/clang/AST/ASTImporter.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,16 @@ class TypeSourceInfo;
llvm::SmallDenseMap<Decl *, int, 32> Aux;
};

class FunctionDeclImportCycleDetector {
public:
auto makeScopedCycleDetection(const FunctionDecl *D);

bool isCycle(const FunctionDecl *D) const;

private:
llvm::DenseSet<const FunctionDecl *> FunctionDeclsWithImportInProgress;
};

private:
std::shared_ptr<ASTImporterSharedState> SharedState = nullptr;

Expand Down Expand Up @@ -254,6 +264,12 @@ class TypeSourceInfo;
/// Declaration (from, to) pairs that are known not to be equivalent
/// (which we have already complained about).
NonEquivalentDeclSet NonEquivalentDecls;
/// A FunctionDecl can have properties that have a reference to the
/// function itself and are imported before the function is created. This
/// can come for example from auto return type or when template parameters
/// are used in the return type or parameters. This member is used to detect
/// cyclic import of FunctionDecl objects to avoid infinite recursion.
FunctionDeclImportCycleDetector FindFunctionDeclImportCycle;

using FoundDeclsTy = SmallVector<NamedDecl *, 2>;
FoundDeclsTy findDeclsInToCtx(DeclContext *DC, DeclarationName Name);
Expand Down
Loading