Skip to content

Commit 25f7db0

Browse files
authored
Merge branch 'main' into gisel-vop3p
2 parents 58464a3 + 42d49a7 commit 25f7db0

File tree

746 files changed

+29549
-23794
lines changed

Some content is hidden

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

746 files changed

+29549
-23794
lines changed

.github/workflows/issue-write.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939

4040
- name: 'Comment on PR'
4141
if: steps.download-artifact.outputs.artifact-id != ''
42-
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
42+
uses: actions/github-script@ffc2c79a5b2490bd33e0a41c1de74b877714d736 # v3.2.0
4343
with:
4444
github-token: ${{ secrets.GITHUB_TOKEN }}
4545
script: |

.github/workflows/libclang-python-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
strategy:
3131
fail-fast: false
3232
matrix:
33-
python-version: ["3.8", "3.11"]
33+
python-version: ["3.8", "3.13"]
3434
uses: ./.github/workflows/llvm-project-tests.yml
3535
with:
3636
build_target: check-clang-python

clang-tools-extra/clang-tidy/misc/UseInternalLinkageCheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ AST_MATCHER(FunctionDecl, hasBody) { return Node.hasBody(); }
5252
static bool isInMainFile(SourceLocation L, SourceManager &SM,
5353
const FileExtensionsSet &HeaderFileExtensions) {
5454
for (;;) {
55-
if (utils::isSpellingLocInHeaderFile(L, SM, HeaderFileExtensions))
55+
if (utils::isExpansionLocInHeaderFile(L, SM, HeaderFileExtensions))
5656
return false;
5757
if (SM.isInMainFile(L))
5858
return true;

clang-tools-extra/clang-tidy/utils/UseRangesCheck.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,19 @@ void UseRangesCheck::check(const MatchFinder::MatchResult &Result) {
215215
const auto *Call = Result.Nodes.getNodeAs<CallExpr>(Buffer);
216216
if (!Call)
217217
continue;
218+
219+
// FIXME: This check specifically handles `CXXNullPtrLiteralExpr`, but
220+
// a more general solution might be needed.
221+
if (Function->getName() == "find") {
222+
const unsigned ValueArgIndex = 2;
223+
if (Call->getNumArgs() <= ValueArgIndex)
224+
continue;
225+
const Expr *ValueExpr =
226+
Call->getArg(ValueArgIndex)->IgnoreParenImpCasts();
227+
if (isa<CXXNullPtrLiteralExpr>(ValueExpr))
228+
return;
229+
}
230+
218231
auto Diag = createDiag(*Call);
219232
if (auto ReplaceName = Replacer->getReplaceName(*Function))
220233
Diag << FixItHint::CreateReplacement(Call->getCallee()->getSourceRange(),

clang-tools-extra/clangd/Config.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,18 @@ struct Config {
5959
std::optional<std::string> FixedCDBPath;
6060
};
6161

62+
enum class BuiltinHeaderPolicy { Clangd, QueryDriver };
6263
/// Controls how the compile command for the current file is determined.
6364
struct {
6465
/// Edits to apply to the compile command, in sequence.
6566
std::vector<llvm::unique_function<void(std::vector<std::string> &) const>>
6667
Edits;
6768
/// Where to search for compilation databases for this file's flags.
6869
CDBSearchSpec CDBSearch = {CDBSearchSpec::Ancestors, std::nullopt};
70+
71+
/// Whether to use clangd's own builtin headers, or ones from the system
72+
/// include extractor, if available.
73+
BuiltinHeaderPolicy BuiltinHeaders = BuiltinHeaderPolicy::Clangd;
6974
} CompileFlags;
7075

7176
enum class BackgroundPolicy { Build, Skip };

clang-tools-extra/clangd/ConfigCompile.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,18 @@ struct FragmentCompiler {
290290
});
291291
}
292292

293+
if (F.BuiltinHeaders) {
294+
if (auto Val =
295+
compileEnum<Config::BuiltinHeaderPolicy>("BuiltinHeaders",
296+
*F.BuiltinHeaders)
297+
.map("Clangd", Config::BuiltinHeaderPolicy::Clangd)
298+
.map("QueryDriver", Config::BuiltinHeaderPolicy::QueryDriver)
299+
.value())
300+
Out.Apply.push_back([Val](const Params &, Config &C) {
301+
C.CompileFlags.BuiltinHeaders = *Val;
302+
});
303+
}
304+
293305
if (F.CompilationDatabase) {
294306
std::optional<Config::CDBSearchSpec> Spec;
295307
if (**F.CompilationDatabase == "Ancestors") {

clang-tools-extra/clangd/ConfigFragment.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,14 @@ struct Fragment {
170170
/// - Ancestors: search all parent directories (the default)
171171
/// - std::nullopt: do not use a compilation database, just default flags.
172172
std::optional<Located<std::string>> CompilationDatabase;
173+
174+
/// Controls whether Clangd should use its own built-in system headers (like
175+
/// stddef.h), or use the system headers from the query driver. Use the
176+
/// option value 'Clangd' (default) to indicate Clangd's headers, and use
177+
/// 'QueryDriver' to indicate QueryDriver's headers. `Clangd` is the
178+
/// fallback if no query driver is supplied or if the query driver regex
179+
/// string fails to match the compiler used in the CDB.
180+
std::optional<Located<std::string>> BuiltinHeaders;
173181
};
174182
CompileFlagsBlock CompileFlags;
175183

clang-tools-extra/clangd/ConfigYAML.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,10 @@ class Parser {
104104
if (auto Values = scalarValues(N))
105105
F.Remove = std::move(*Values);
106106
});
107+
Dict.handle("BuiltinHeaders", [&](Node &N) {
108+
if (auto BuiltinHeaders = scalarValue(N, "BuiltinHeaders"))
109+
F.BuiltinHeaders = *BuiltinHeaders;
110+
});
107111
Dict.handle("CompilationDatabase", [&](Node &N) {
108112
F.CompilationDatabase = scalarValue(N, "CompilationDatabase");
109113
});

clang-tools-extra/clangd/IncludeFixer.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ std::vector<Fix> IncludeFixer::fix(DiagnosticsEngine::Level DiagLevel,
8484
case diag::err_array_incomplete_or_sizeless_type:
8585
case diag::err_array_size_incomplete_type:
8686
case diag::err_asm_incomplete_type:
87-
case diag::err_assoc_type_incomplete:
8887
case diag::err_bad_cast_incomplete:
8988
case diag::err_call_function_incomplete_return:
9089
case diag::err_call_incomplete_argument:

clang-tools-extra/clangd/SystemIncludeExtractor.cpp

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
// in the paths that are explicitly included by the user.
3131

3232
#include "CompileCommands.h"
33+
#include "Config.h"
3334
#include "GlobalCompilationDatabase.h"
3435
#include "support/Logger.h"
3536
#include "support/Threading.h"
@@ -401,22 +402,30 @@ extractSystemIncludesAndTarget(const DriverArgs &InputArgs,
401402
if (!Info)
402403
return std::nullopt;
403404

404-
// The built-in headers are tightly coupled to parser builtins.
405-
// (These are clang's "resource dir", GCC's GCC_INCLUDE_DIR.)
406-
// We should keep using clangd's versions, so exclude the queried builtins.
407-
// They're not specially marked in the -v output, but we can get the path
408-
// with `$DRIVER -print-file-name=include`.
409-
if (auto BuiltinHeaders =
410-
run({Driver, "-print-file-name=include"}, /*OutputIsStderr=*/false)) {
411-
auto Path = llvm::StringRef(*BuiltinHeaders).trim();
412-
if (!Path.empty() && llvm::sys::path::is_absolute(Path)) {
413-
auto Size = Info->SystemIncludes.size();
414-
llvm::erase(Info->SystemIncludes, Path);
415-
vlog("System includes extractor: builtin headers {0} {1}", Path,
416-
(Info->SystemIncludes.size() != Size)
417-
? "excluded"
418-
: "not found in driver's response");
405+
switch (Config::current().CompileFlags.BuiltinHeaders) {
406+
case Config::BuiltinHeaderPolicy::Clangd: {
407+
// The built-in headers are tightly coupled to parser builtins.
408+
// (These are clang's "resource dir", GCC's GCC_INCLUDE_DIR.)
409+
// We should keep using clangd's versions, so exclude the queried
410+
// builtins. They're not specially marked in the -v output, but we can
411+
// get the path with `$DRIVER -print-file-name=include`.
412+
if (auto BuiltinHeaders = run({Driver, "-print-file-name=include"},
413+
/*OutputIsStderr=*/false)) {
414+
auto Path = llvm::StringRef(*BuiltinHeaders).trim();
415+
if (!Path.empty() && llvm::sys::path::is_absolute(Path)) {
416+
auto Size = Info->SystemIncludes.size();
417+
llvm::erase(Info->SystemIncludes, Path);
418+
vlog("System includes extractor: builtin headers {0} {1}", Path,
419+
(Info->SystemIncludes.size() != Size)
420+
? "excluded"
421+
: "not found in driver's response");
422+
}
419423
}
424+
break;
425+
}
426+
case Config::BuiltinHeaderPolicy::QueryDriver:
427+
vlog("System includes extractor: Using builtin headers from query driver.");
428+
break;
420429
}
421430

422431
log("System includes extractor: successfully executed {0}\n\tgot includes: "

0 commit comments

Comments
 (0)