diff --git a/.aspect/bazelrc/ci.bazelrc b/.aspect/bazelrc/ci.bazelrc
index 5c17b99f..58732f1e 100644
--- a/.aspect/bazelrc/ci.bazelrc
+++ b/.aspect/bazelrc/ci.bazelrc
@@ -1,3 +1,7 @@
+# Disable bzlmod since this project uses WORKSPACE
+# Docs: https://bazel.build/external/migration#disable-bzlmod
+common --noenable_bzlmod
+
# We recommend enforcing a policy that keeps your CI from being slowed down
# by individual test targets that should be optimized
# or split up into multiple test targets with sharding or manually.
diff --git a/.aspect/workflows/config.yaml b/.aspect/workflows/config.yaml
new file mode 100644
index 00000000..7e465041
--- /dev/null
+++ b/.aspect/workflows/config.yaml
@@ -0,0 +1,22 @@
+---
+queue: aspect-devx-service
+bazel:
+ rcfiles:
+ - ".aspect/bazelrc/ci.bazelrc"
+
+tasks:
+ - build:
+ targets:
+ - //...
+ - -//tools:compdb # Exclude: com_grail_bazel_compdb is incompatible with current toolchain
+ bazel:
+ flags:
+ - "--config=ci"
+ - test:
+ targets:
+ - //test
+ bazel:
+ flags:
+ - "--config=ci"
+ - finalization:
+
diff --git a/.bazelrc b/.bazelrc
index 74b7614a..57070325 100644
--- a/.bazelrc
+++ b/.bazelrc
@@ -46,6 +46,8 @@ build --per_file_copt="external/llvm-project/.*@-Wno-deprecated-anon-enum-enum-c
build --per_file_copt="external/llvm-project/.*@-Wno-ambiguous-reversed-operator" # C++20 warning
build --per_file_copt="external/com_google_protobuf/.*@-Wno-deprecated-declarations" # sprintf on macOS
build --per_file_copt="external/com_google_protobuf/.*@-Wno-unused-function"
+build --per_file_copt="external/com_google_protobuf/.*@-Wno-missing-field-initializers"
+build --per_file_copt="external/com_google_protobuf/.*@-Wno-unnecessary-virtual-specifier"
build:asserts --copt="-DFORCE_DEBUG=1"
build:asserts --copt="-DLLVM_ENABLE_ASSERTIONS=1"
diff --git a/.bazelversion b/.bazelversion
index 5e325424..18bb4182 100644
--- a/.bazelversion
+++ b/.bazelversion
@@ -1 +1 @@
-6.1.2
+7.5.0
diff --git a/.buildkite/pipeline.yaml b/.buildkite/pipeline.yaml
index 7e4f1776..9ff2afe6 100644
--- a/.buildkite/pipeline.yaml
+++ b/.buildkite/pipeline.yaml
@@ -1,9 +1,9 @@
$schema: "http://json.schemastore.org/buildkite"
steps:
- - label: ":bazel: Build and Test"
+ - label: ":lint-roller: Lint"
+ key: lint
agents:
- queue: bazel
- key: build
+ queue: aspect-small-ubuntu-lts
command: |
./tools/reformat.sh
if ! git diff --quiet; then
@@ -17,8 +17,19 @@ steps:
./tools/lint.sh
- # DO NOT remove --config=ci as that turns on sanitizers.
- bazel --bazelrc=.bazelrc --bazelrc=.aspect/bazelrc/ci.bazelrc build //... --config=ci
-
- # Don't use //... as that will also try to update snapshots
- bazel --bazelrc=.bazelrc --bazelrc=.aspect/bazelrc/ci.bazelrc test //test --config=ci
+ - key: aspect-workflows-upload
+ label: ":aspect: Setup Aspect Workflows"
+ commands: |
+ rosetta steps | buildkite-agent pipeline upload
+ agents:
+ queue: aspect-small-ubuntu-lts
+ # - label: "build and test"
+ # agents:
+ # queue: aspect-devx-service
+ # key: build
+ # command: |
+ # # DO NOT remove --config=ci as that turns on sanitizers.
+ # bazel --bazelrc=.bazelrc --bazelrc=.aspect/bazelrc/ci.bazelrc build //... --config=ci
+ #
+ # # Don't use //... as that will also try to update snapshots
+ # bazel --bazelrc=.bazelrc --bazelrc=.aspect/bazelrc/ci.bazelrc test //test --config=ci
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 5b312c23..1c29209b 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -20,18 +20,13 @@ jobs:
strategy:
matrix:
include:
- - platform: "ubuntu-22.04"
- container: "gcc:9.5.0-buster"
+ - platform: "ubuntu-24.04"
config: "dev"
- - platform: "ubuntu-22.04"
- container: "gcc:9.5.0-buster"
+ - platform: "ubuntu-24.04"
config: "release"
- # macOS 14 => arm64
- platform: "macos-14"
- container: ""
config: "release"
runs-on: ${{ matrix.platform }}
- container: ${{ matrix.container }}
env:
TAG: ${{ github.event.ref }}
permissions:
@@ -41,6 +36,20 @@ jobs:
run:
shell: bash
steps:
+ - name: "๐งน Free up disk space"
+ if: runner.os == 'Linux'
+ run: |
+ # Free up disk space on GitHub-hosted runners
+ # The LLVM 21 toolchain requires ~5GB when extracted
+ echo "Before cleanup:"
+ df -h /
+ sudo rm -rf /usr/share/dotnet
+ sudo rm -rf /usr/local/lib/android
+ sudo rm -rf /opt/ghc
+ sudo rm -rf /opt/hostedtoolcache/CodeQL
+ sudo docker image prune --all --force || true
+ echo "After cleanup:"
+ df -h /
- uses: actions/checkout@v4
- name: "๐ Check version"
run: |
@@ -53,12 +62,12 @@ jobs:
NEW_VERSION="${TAG_LIKE/v/}" ./tools/version_check.sh
- name: "๐ Install Bazelisk"
run: |
- if ! command -v bazelisk; then
+ if ! command -v bazelisk && ! command -v bazel; then
if [ "$RUNNER_OS" == "Windows" ]; then
choco install bazelisk
elif [ "$RUNNER_OS" == "Linux" ]; then
- curl -L https://github.com/bazelbuild/bazelisk/releases/download/v1.16.0/bazelisk-linux-amd64 > /usr/local/bin/bazel
- chmod +x /usr/local/bin/bazel
+ sudo curl -L https://github.com/bazelbuild/bazelisk/releases/download/v1.16.0/bazelisk-linux-amd64 -o /usr/local/bin/bazel
+ sudo chmod +x /usr/local/bin/bazel
else
sudo npm install -g @bazel/bazelisk
fi
@@ -72,26 +81,22 @@ jobs:
create_credentials_file: true
- name: "๐ง Build scip-clang"
run: |
- # Stop Windows from converting the // to /
- # https://github.com/bazelbuild/bazel/commit/866ecc8c3d5e0b899e3f0c9c6b2265f16daae842
- # https://stackoverflow.com/a/34386471
export MSYS2_ARG_CONV_EXCL="*"
if [ "$RUNNER_OS" == "macOS" ]; then
export BAZEL_MEM="13G"
- else # if [ "$RUNNER_OS" == "Linux" ]; then
+ else
export BAZEL_MEM="6G"
fi
{
echo "startup --host_jvm_args=-Xmx$BAZEL_MEM"
} > ci.bazelrc
- # Comment out the 'upload log' bit below for debugging
SUFFIX=""
if [ "$CONFIG" == "release" ]; then
if [ "$(uname -s)" == "Linux" ]; then
SUFFIX="-linux"
fi
fi
- bazel build //indexer:scip-clang --config="$CONFIG$SUFFIX" # --execution_log_binary_file=log
+ bazel --bazelrc=.bazelrc --bazelrc=.aspect/bazelrc/ci.bazelrc build //indexer:scip-clang --config="$CONFIG$SUFFIX"
if [ "$RUNNER_OS" == "Linux" ]; then
echo "--- GLIBC VERSIONS ---"
objdump -T bazel-bin/indexer/scip-clang | grep GLIBC | sed 's/.*GLIBC_\([.0-9]*\).*/\1/g' | sort -Vu
@@ -101,11 +106,6 @@ jobs:
CONFIG: ${{ matrix.config }}
- name: "๐ Identify OS"
run: echo "OS=$(uname -s | tr '[:upper:]' '[:lower:]')" >> "$GITHUB_ENV"
- # - name: '๐ชต Upload log'
- # uses: actions/upload-artifact@v3
- # with:
- # name: ${{ env.OS }}-${{ matrix.config }}-build-log
- # path: log
- name: ${{ format('๐ช Rename binary ({0})', matrix.config) }}
run: |
SUFFIX="-dev"
@@ -129,7 +129,9 @@ jobs:
name: "Create release"
if: github.event_name != 'workflow_dispatch' || inputs.create_release
needs: build-and-upload-artifacts
- runs-on: "ubuntu-22.04"
+ runs-on: "ubuntu-24.04"
+ permissions:
+ contents: write
steps:
- uses: actions/checkout@v4
- name: "๐ Create Release"
@@ -145,8 +147,6 @@ jobs:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TRIGGER: ${{ github.event_name }}
INPUT_REVISION: ${{ inputs.revision }}
- # Download everything to avoid spelling out the different
- # platforms here.
- name: "๐ฅ Download all artifacts"
uses: actions/download-artifact@v4
- name: "๐ค Upload artifacts for release"
diff --git a/README.md b/README.md
index 6a4bd42f..1c9204b1 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
# scip-clang: SCIP indexer for C and C++ 
-scip-clang is a precise code indexer based on Clang 16,
+scip-clang is a precise code indexer based on Clang 21,
which supports cross-repository code navigation for C, C++ and CUDA
in Sourcegraph.
@@ -201,7 +201,7 @@ scip-clang --compdb-path=build/small_compdb.json --show-compiler-diagnostics
Known diagnostics when indexing CUDA
1. If you see an error related to the `texture` template, that is likely
- because of the Clang version not being Clang 16 or newer.
+ because of the Clang version not being Clang 21 or newer.
See https://github.com/llvm/llvm-project/issues/61340
2. If you see any errors related to GCC headers, that's a
[known issue](https://github.com/sourcegraph/scip-clang/issues/440).
diff --git a/WORKSPACE b/WORKSPACE
index bc37ae44..39171917 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -14,16 +14,27 @@ load("//:fetch_deps.bzl", "fetch_direct_dependencies")
fetch_direct_dependencies()
# Setup the toolchain before setting up other dependencies
+# Note: bazel_toolchain_dependencies() brings in rules_cc 0.2.14
load("@toolchains_llvm//toolchain:deps.bzl", "bazel_toolchain_dependencies")
bazel_toolchain_dependencies()
+# bazel_features needs its deps called explicitly
+load("@bazel_features//:deps.bzl", "bazel_features_deps")
+
+bazel_features_deps()
+
+# Set up cc_compatibility_proxy for rules_cc 0.2.14+ in WORKSPACE mode
+load("@rules_cc//cc:extensions.bzl", "compatibility_proxy_repo")
+
+compatibility_proxy_repo()
+
load("//:setup_llvm.bzl", "setup_llvm_toolchain")
setup_llvm_toolchain(name = "llvm_toolchain")
-load("@llvm_toolchain//:toolchains.bzl", "llvm_register_toolchains")
load("@rules_python//python:repositories.bzl", "py_repositories", "python_register_toolchains")
+load("@llvm_toolchain//:toolchains.bzl", "llvm_register_toolchains")
llvm_register_toolchains()
diff --git a/fetch_deps.bzl b/fetch_deps.bzl
index 38e8c8df..0ea3e0bf 100644
--- a/fetch_deps.bzl
+++ b/fetch_deps.bzl
@@ -1,16 +1,16 @@
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive", "http_file")
_BAZEL_SKYLIB_VERSION = "1.3.0"
-_PLATFORMS_COMMIT = "3fbc687756043fb58a407c2ea8c944bc2fe1d922" # 2022 Nov 10
-_BAZEL_TOOLCHAIN_VERSION = "0.10.3"
+_PLATFORMS_VERSION = "1.0.0" # Updated from 2022 commit for visionos support
+_BAZEL_TOOLCHAIN_VERSION = "1.6.0"
_RULES_BOOST_COMMIT = "00b9b9ecb9b43564de44ea0b10e22b29dcf84d79"
-_LLVM_COMMIT = "e0f3110b854a476c16cce7b44472cd7838d344e9" # Keep in sync with Version.h
-_ABSL_COMMIT = "4ffaea74c1f5408e0757547a1ca0518ad43fa9f1"
+_LLVM_COMMIT = "2078da43e25a4623cab2d0d60decddf709aaea28" # Keep in sync with Version.h
+_ABSL_VERSION = "20240722.0"
_CXXOPTS_VERSION = "3.0.0"
_RAPIDJSON_COMMIT = "a98e99992bd633a2736cc41f96ec85ef0c50e44d"
_WYHASH_COMMIT = "ea3b25e1aef55d90f707c3a292eeb9162e2615d8"
-_SPDLOG_COMMIT = "edc51df1bdad8667b628999394a1e7c4dc6f3658"
-_PROTOBUF_VERSION = "3.21.12"
+_SPDLOG_COMMIT = "486b55554f11c9cccc913e11a87085b2a91f706f" # v1.16.0
+_PROTOBUF_VERSION = "25.3"
_SCIP_COMMIT = "aa0e511dcfefbacc3b96dcc2fe2abd9894416b1e"
_UTFCPP_VERSION = "4.0.5"
# ^ When bumping this version, check if any new fields are introduced
@@ -22,7 +22,7 @@ _UTFCPP_VERSION = "4.0.5"
# See https://github.com/google/perfetto/issues/271#issuecomment-1527691232
_PERFETTO_VERSION = "33.1" # Keep in sync with docs/Development.md
_DOCTEST_VERSION = "2.4.9"
-_DTL_VERSION = "1.20"
+_DTL_VERSION = "1.21"
_RULES_PYTHON_VERSION = "0.18.1"
def fetch_direct_dependencies():
@@ -37,17 +37,19 @@ def fetch_direct_dependencies():
http_archive(
name = "platforms",
- sha256 = "b4a3b45dc4202e2b3e34e3bc49d2b5b37295fc23ea58d88fb9e01f3642ad9b55",
- strip_prefix = "platforms-%s" % _PLATFORMS_COMMIT,
- urls = ["https://github.com/bazelbuild/platforms/archive/%s.zip" % _PLATFORMS_COMMIT],
+ sha256 = "3384eb1c30762704fbe38e440204e114154086c8fc8a8c2e3e28441028c019a8",
+ urls = [
+ "https://mirror.bazel.build/github.com/bazelbuild/platforms/releases/download/{0}/platforms-{0}.tar.gz".format(_PLATFORMS_VERSION),
+ "https://github.com/bazelbuild/platforms/releases/download/{0}/platforms-{0}.tar.gz".format(_PLATFORMS_VERSION),
+ ],
)
http_archive(
name = "toolchains_llvm",
- sha256 = "b7cd301ef7b0ece28d20d3e778697a5e3b81828393150bed04838c0c52963a01",
- strip_prefix = "toolchains_llvm-%s" % _BAZEL_TOOLCHAIN_VERSION,
+ sha256 = "2b298a1d7ea99679f5edf8af09367363e64cb9fbc46e0b7c1b1ba2b1b1b51058",
+ strip_prefix = "toolchains_llvm-v%s" % _BAZEL_TOOLCHAIN_VERSION,
canonical_id = _BAZEL_TOOLCHAIN_VERSION,
- url = "https://github.com/grailbio/bazel-toolchain/releases/download/{0}/toolchains_llvm-{0}.tar.gz".format(_BAZEL_TOOLCHAIN_VERSION),
+ url = "https://github.com/bazel-contrib/toolchains_llvm/releases/download/v{0}/toolchains_llvm-v{0}.tar.gz".format(_BAZEL_TOOLCHAIN_VERSION),
)
http_archive(
@@ -79,14 +81,14 @@ def fetch_direct_dependencies():
# Keep the name 'zlib' so that Protobuf doesn't pull in another copy.
#
# https://sourcegraph.com/github.com/protocolbuffers/protobuf/-/blob/protobuf_deps.bzl?L48-58
+ # Using zlib 1.3.1 to fix macro conflicts with macOS headers in zlib 1.2.11
http_archive(
name = "zlib",
build_file = "@scip_clang//third_party:zlib.BUILD",
- sha256 = "c3e5e9fdd5004dcb542feda5ee4f0ff0744628baf8ed2dd5d66f8ca1197cb1a1",
- strip_prefix = "zlib-1.2.11",
+ sha256 = "17e88863f3600672ab49182f217281b6fc4d3c762bde361935e436a95214d05c",
+ strip_prefix = "zlib-1.3.1",
urls = [
- "https://mirror.bazel.build/zlib.net/zlib-1.2.11.tar.gz",
- "https://zlib.net/zlib-1.2.11.tar.gz",
+ "https://github.com/madler/zlib/archive/refs/tags/v1.3.1.tar.gz",
],
)
@@ -100,17 +102,33 @@ def fetch_direct_dependencies():
],
)
+ # LLVM 18+ uses zlib-ng instead of zlib
+ http_archive(
+ name = "llvm_zlib",
+ build_file = "@llvm-raw//utils/bazel/third_party_build:zlib-ng.BUILD",
+ sha256 = "e36bb346c00472a1f9ff2a0a4643e590a254be6379da7cddd9daeb9a7f296731",
+ strip_prefix = "zlib-ng-2.0.7",
+ urls = [
+ "https://github.com/zlib-ng/zlib-ng/archive/refs/tags/2.0.7.zip",
+ ],
+ )
+
+ # Cherry-pick fix for CUDA assertion failure from
+ # https://github.com/llvm/llvm-project/pull/173762
+ # Can be removed once LLVM merges the fix and we update the commit.
http_archive(
name = "llvm-raw",
- sha256 = "04b76a5be88331f71a4e4fe96bccfebec302ddd0dbd9418fd5c186a7361c54fb",
+ sha256 = "536a4d64ab21bc85bf95ae4dc412b36e8a9c72d487a476839f3c31c3ded69e96",
strip_prefix = "llvm-project-%s" % _LLVM_COMMIT,
build_file_content = "# empty",
urls = ["https://github.com/llvm/llvm-project/archive/%s.tar.gz" % _LLVM_COMMIT],
+ patch_args = ["-p1"],
+ patches = ["//third_party:llvm-cuda-tooling.patch"],
)
http_archive(
name = "com_google_protobuf",
- sha256 = "f7042d540c969b00db92e8e1066a9b8099c8379c33f40f360eb9e1d98a36ca26",
+ sha256 = "5156b22536feaa88cf95503153a6b2cd67cc80f20f1218f154b84a12c288a220",
urls = ["https://github.com/protocolbuffers/protobuf/archive/v%s.zip" % _PROTOBUF_VERSION],
strip_prefix = "protobuf-%s" % _PROTOBUF_VERSION,
)
@@ -129,11 +147,9 @@ def fetch_direct_dependencies():
# https://sourcegraph.com/github.com/protocolbuffers/protobuf/-/blob/protobuf_deps.bzl?L39-46
http_archive(
name = "com_google_absl",
- sha256 = "fee8ec623d8bbf0ecb9563a8e08ae319d1ca9fdf8c1c84384520a6992f571659",
- strip_prefix = "abseil-cpp-%s" % _ABSL_COMMIT,
- urls = ["https://github.com/abseil/abseil-cpp/archive/%s.zip" % _ABSL_COMMIT],
- patch_args = ["-p1"],
- patches = ["//third_party:abseil.patch"],
+ sha256 = "95e90be7c3643e658670e0dd3c1b27092349c34b632c6e795686355f67eca89f",
+ strip_prefix = "abseil-cpp-%s" % _ABSL_VERSION,
+ urls = ["https://github.com/abseil/abseil-cpp/archive/%s.zip" % _ABSL_VERSION],
)
# Abseil also has a flags/argument parsing library, but let's
@@ -165,7 +181,7 @@ def fetch_direct_dependencies():
# NOTE: fmt also comes through spdlog, we don't have an explicit dep on fmt.
http_archive(
name = "spdlog",
- sha256 = "93a270dd7ec8fa672eb4feaef443dc14a4a9edc7b59aea998ae5da6cbf7b7119",
+ sha256 = "d2fef585c9879dd239dc498e2e8a1e22982b3ed67b2d14e78622b7ef25bdfdfa",
build_file = "@scip_clang//third_party:spdlog.BUILD",
strip_prefix = "spdlog-%s" % _SPDLOG_COMMIT,
urls = ["https://github.com/gabime/spdlog/archive/%s.tar.gz" % _SPDLOG_COMMIT],
@@ -180,7 +196,7 @@ def fetch_direct_dependencies():
http_archive(
name = "dtl",
- sha256 = "579f81bca88f4b9760a59d99c5a95bd8dd5dc2f20f33f1f9b5f64cb08979f54d",
+ sha256 = "90ed2dbf4e6d687737fe25f118bbcb6aed778cecc3f2115d191a032bf8643dbd",
build_file = "@scip_clang//third_party:dtl.BUILD",
strip_prefix = "dtl-%s" % _DTL_VERSION,
urls = ["https://github.com/cubicdaiya/dtl/archive/v%s.tar.gz" % _DTL_VERSION],
diff --git a/indexer/ApproximateNameResolver.cc b/indexer/ApproximateNameResolver.cc
index f63042fc..3c4cab93 100644
--- a/indexer/ApproximateNameResolver.cc
+++ b/indexer/ApproximateNameResolver.cc
@@ -14,6 +14,64 @@
namespace scip_clang {
+namespace {
+
+// Helper to get CXXRecordDecl from a type, handling TemplateSpecializationType
+// for dependent base types.
+clang::CXXRecordDecl *tryFindDeclForBaseType(const clang::Type *type) {
+ if (!type)
+ return nullptr;
+
+ // Direct record type (non-dependent base)
+ if (const auto *recordType = type->getAs())
+ return llvm::dyn_cast(recordType->getDecl());
+
+ // Handle InjectedClassNameType (inside template definitions)
+ if (const auto *injectedType = type->getAs())
+ type = injectedType->getInjectedSpecializationType().getTypePtrOrNull();
+ if (!type)
+ return nullptr;
+
+ // Handle TemplateSpecializationType (e.g., T0 as a dependent base type)
+ const auto *templateSpecType =
+ type->getAs();
+ if (!templateSpecType)
+ return nullptr;
+
+ auto *templateDecl = llvm::dyn_cast_or_null(
+ templateSpecType->getTemplateName().getAsTemplateDecl());
+ if (!templateDecl)
+ return nullptr;
+
+ return templateDecl->getTemplatedDecl();
+}
+
+// Reimplementation of the removed CXXRecordDecl::lookupDependentName
+llvm::SmallVector
+lookupDependentName(clang::CXXRecordDecl *record, clang::DeclarationName name,
+ llvm::function_ref filter) {
+ llvm::SmallVector results;
+ for (auto *decl : record->lookup(name)) {
+ if (filter(decl)) {
+ results.push_back(decl);
+ }
+ }
+ if (!results.empty())
+ return results;
+
+ // Search in base classes
+ for (const auto &base : record->bases()) {
+ auto *baseRecord =
+ tryFindDeclForBaseType(base.getType().getTypePtrOrNull());
+ if (!baseRecord || !baseRecord->hasDefinition())
+ continue;
+ auto baseResults =
+ lookupDependentName(baseRecord->getDefinition(), name, filter);
+ results.append(baseResults.begin(), baseResults.end());
+ }
+ return results;
+}
+} // namespace
MemberLookupKey::MemberLookupKey(const clang::Type *type,
const clang::DeclarationNameInfo &declNameInfo)
: canonicalTypePtr(type->getCanonicalTypeInternal().getTypePtrOrNull()),
@@ -66,7 +124,7 @@ ApproximateNameResolver::tryResolveMember(
}
cxxRecordDecl = cxxRecordDecl->getDefinition();
auto lookupResults =
- cxxRecordDecl->lookupDependentName(declNameInfo.getName(), filter);
+ lookupDependentName(cxxRecordDecl, declNameInfo.getName(), filter);
for (auto *namedDecl : lookupResults) {
auto *unresolvedUsingValueDecl =
llvm::dyn_cast(namedDecl);
diff --git a/indexer/CompilationDatabase.cc b/indexer/CompilationDatabase.cc
index 1a62ccd1..18d3370c 100644
--- a/indexer/CompilationDatabase.cc
+++ b/indexer/CompilationDatabase.cc
@@ -20,6 +20,7 @@
#include "rapidjson/rapidjson.h"
#include "rapidjson/reader.h"
#include "spdlog/fmt/fmt.h"
+#include "spdlog/fmt/ranges.h"
#include "indexer/CommandLineCleaner.h"
#include "indexer/CompilationDatabase.h"
@@ -97,7 +98,7 @@ struct ClangToolchainInfo : public ToolchainInfo {
findResourceDirInvocation(findResourceDirInvocation),
compilerDriverPath(compilerDriverPath),
findDriverInvocation(findDriverInvocation),
- cleaner(std::move(cleaner)){};
+ cleaner(std::move(cleaner)) {};
virtual CompilerKind kind() const override {
return CompilerKind::Clang;
diff --git a/indexer/DebugHelpers.cc b/indexer/DebugHelpers.cc
index 3cc1beb4..df89392a 100644
--- a/indexer/DebugHelpers.cc
+++ b/indexer/DebugHelpers.cc
@@ -175,7 +175,6 @@ std::string formatKind(clang::NestedNameSpecifier::SpecifierKind kind) {
HANDLE_KIND(Namespace)
HANDLE_KIND(NamespaceAlias)
HANDLE_KIND(TypeSpec)
- HANDLE_KIND(TypeSpecWithTemplate)
HANDLE_KIND(Global)
HANDLE_KIND(Super)
}
diff --git a/indexer/Driver.cc b/indexer/Driver.cc
index 3faf5d67..6f199e16 100644
--- a/indexer/Driver.cc
+++ b/indexer/Driver.cc
@@ -31,6 +31,7 @@
#include "rapidjson/error/en.h"
#include "rapidjson/filereadstream.h"
#include "spdlog/fmt/fmt.h"
+#include "spdlog/fmt/ranges.h"
#include "spdlog/sinks/stdout_sinks.h"
#include "spdlog/spdlog.h"
@@ -231,8 +232,8 @@ struct DriverOptions {
projectRootPath(AbsolutePath("/"), RootKind::Project), compdbPath(),
indexOutputPath(), statsFilePath(), packageMapPath(),
showCompilerDiagnostics(cliOpts.showCompilerDiagnostics),
- showProgress(cliOpts.showProgress), ipcOptions{cliOpts.ipcSizeHintBytes,
- cliOpts.receiveTimeout},
+ showProgress(cliOpts.showProgress),
+ ipcOptions{cliOpts.ipcSizeHintBytes, cliOpts.receiveTimeout},
numWorkers(cliOpts.numWorkers), deterministic(cliOpts.deterministic),
preprocessorRecordHistoryFilterRegex(
cliOpts.preprocessorRecordHistoryFilterRegex),
@@ -257,7 +258,7 @@ struct DriverOptions {
: (llvm::sys::path::is_absolute(path)
? AbsolutePath(std::string(path))
: this->projectRootPath.makeAbsolute(
- RootRelativePathRef(path, RootKind::Project)));
+ RootRelativePathRef(path, RootKind::Project)));
};
// Strictly speaking, there is a TOCTOU problem here, as scip-clang
diff --git a/indexer/Indexer.cc b/indexer/Indexer.cc
index 34b5bd06..87522da7 100644
--- a/indexer/Indexer.cc
+++ b/indexer/Indexer.cc
@@ -530,7 +530,8 @@ void TuIndexer::saveFunctionDecl(const clang::FunctionDecl &functionDecl) {
}
auto symbol = optSymbol.value();
- if (functionDecl.isPure() || functionDecl.isThisDeclarationADefinition()) {
+ if (functionDecl.isPureVirtual()
+ || functionDecl.isThisDeclarationADefinition()) {
scip::SymbolInformation symbolInfo{};
this->getDocComment(functionDecl).addTo(symbolInfo);
if (auto *cxxMethodDecl =
@@ -671,33 +672,6 @@ void TuIndexer::saveNestedNameSpecifierLoc(
case Kind::NamespaceAlias:
case Kind::Global:
case Kind::Super:
- case Kind::TypeSpecWithTemplate:
- // FIXME(def: template-specialization-support)
- // Adding support for TypeSpecWithTemplate needs extra care
- // for (partial) template specializations. Example code:
- //
- // template
- // struct X {
- // template
- // struct Y {};
- // };
- //
- // template <>
- // struct X {
- // template
- // struct Y { int[42] magic; };
- // };
- //
- // template void f() {
- // typename X::template Y y{};
- // //^^^^^^^^^^^^^^ TypeSpecWithTemplate
- // std::cout << sizeof(y) << '\n';
- // }
- //
- // In 'template Y', clangd will navigate to 'Y' in the body of 'X',
- // even when there is partial template specialization of X
- // (so calling f() will print a different value).
- // Ideally, we should surface such specializations too.
break;
}
nameSpecLoc = nameSpecLoc.getPrefix();
@@ -834,6 +808,17 @@ void TuIndexer::saveTemplateSpecializationTypeLoc(
const clang::TemplateSpecializationTypeLoc &templateSpecializationTypeLoc) {
auto *templateSpecializationType = templateSpecializationTypeLoc.getTypePtr();
auto templateName = templateSpecializationType->getTemplateName();
+
+ // Unwrap QualifiedTemplateName and DeducedTemplateStorage to get the
+ // underlying template. These wrappers preserve source-level qualifications
+ // but we need the actual template declaration for indexing.
+ if (auto *qualifiedName = templateName.getAsQualifiedTemplateName()) {
+ templateName = qualifiedName->getUnderlyingTemplate();
+ }
+ if (auto *deducedStorage = templateName.getAsDeducedTemplateName()) {
+ templateName = deducedStorage->getUnderlying();
+ }
+
using Kind = clang::TemplateName::NameKind;
switch (templateName.getKind()) {
case Kind::Template: {
@@ -871,6 +856,7 @@ void TuIndexer::saveTemplateSpecializationTypeLoc(
case Kind::OverloadedTemplate:
case Kind::AssumedTemplate:
case Kind::QualifiedTemplate:
+ case Kind::DeducedTemplate:
case Kind::DependentTemplate:
case Kind::SubstTemplateTemplateParm:
case Kind::SubstTemplateTemplateParmPack:
diff --git a/indexer/Indexer.h b/indexer/Indexer.h
index 4722f001..c4c73ac1 100644
--- a/indexer/Indexer.h
+++ b/indexer/Indexer.h
@@ -80,7 +80,6 @@ struct FileLocalSourceRange {
r.endLine);
}
DERIVE_CMP_ALL(FileLocalSourceRange)
- DERIVE_EQ_ALL(FileLocalSourceRange)
static std::pair
fromNonEmpty(const clang::SourceManager &, clang::SourceRange inclusiveRange);
diff --git a/indexer/JsonIpcQueue.h b/indexer/JsonIpcQueue.h
index 2ae259cd..751c4f92 100644
--- a/indexer/JsonIpcQueue.h
+++ b/indexer/JsonIpcQueue.h
@@ -11,7 +11,6 @@
#include "boost/interprocess/ipc/message_queue.hpp"
#pragma clang diagnostic pop
-#include "llvm/ADT/Optional.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/JSON.h"
#include "llvm/Support/raw_ostream.h"
diff --git a/indexer/PackageMap.cc b/indexer/PackageMap.cc
index 9bfb78cc..2d539fdc 100644
--- a/indexer/PackageMap.cc
+++ b/indexer/PackageMap.cc
@@ -64,7 +64,7 @@ PackageMap::PackageMap(const RootPath &projectRootPath,
void PackageMap::populate(const StdPath &packageMapPath) {
std::error_code error;
- auto path = std::string_view(packageMapPath.c_str());
+ std::string path(packageMapPath.c_str());
if (!llvm::sys::fs::exists(path)) {
spdlog::error("package map not found at path: {}", path);
std::exit(EXIT_FAILURE);
diff --git a/indexer/Path.cc b/indexer/Path.cc
index 3f3877b2..38874117 100644
--- a/indexer/Path.cc
+++ b/indexer/Path.cc
@@ -59,7 +59,7 @@ bool AbsolutePathRef::isNormalized() const {
auto start = llvm::sys::path::begin(this->value);
auto end = llvm::sys::path::end(this->value);
for (auto it = start; it != end; ++it) {
- if (it->equals(".") || it->equals("..")) {
+ if (*it == "." || *it == "..") {
return false;
}
}
diff --git a/indexer/Preprocessing.cc b/indexer/Preprocessing.cc
index 1fb0a296..8839edaf 100644
--- a/indexer/Preprocessing.cc
+++ b/indexer/Preprocessing.cc
@@ -302,7 +302,8 @@ void IndexerPreprocessorWrapper::InclusionDirective(
llvm::StringRef /*fileName*/, bool /*isAngled*/,
clang::CharSourceRange fileNameRange,
clang::OptionalFileEntryRef optFileEntry, clang::StringRef /*searchPath*/,
- clang::StringRef /*relativePath*/, const clang::Module * /*importModule*/,
+ clang::StringRef /*relativePath*/,
+ const clang::Module * /*suggestedModule*/, bool /*moduleImported*/,
clang::SrcMgr::CharacteristicKind /*fileType*/) {
if (!optFileEntry.has_value() || fileNameRange.isInvalid()) {
return;
diff --git a/indexer/Preprocessing.h b/indexer/Preprocessing.h
index 211c83d7..66e53969 100644
--- a/indexer/Preprocessing.h
+++ b/indexer/Preprocessing.h
@@ -272,7 +272,8 @@ class IndexerPreprocessorWrapper final : public clang::PPCallbacks {
llvm::StringRef /*fileName*/, bool /*isAngled*/,
clang::CharSourceRange fileNameRange,
clang::OptionalFileEntryRef optFileEntry, clang::StringRef /*searchPath*/,
- clang::StringRef /*relativePath*/, const clang::Module * /*importModule*/,
+ clang::StringRef /*relativePath*/,
+ const clang::Module * /*suggestedModule*/, bool /*moduleImported*/,
clang::SrcMgr::CharacteristicKind /*fileType*/) override;
// FIXME(issue: https://github.com/sourcegraph/scip-clang/issues/21):
diff --git a/indexer/Version.h b/indexer/Version.h
index e8bb30ce..517b8fbd 100644
--- a/indexer/Version.h
+++ b/indexer/Version.h
@@ -17,7 +17,7 @@ constexpr bool debugMode = false;
#define VERSION "0.3.2"
#define LLVM_COMMIT \
- "e0f3110b854a476c16cce7b44472cd7838d344e9" // Keep synced with fetch_deps.bzl
+ "2078da43e25a4623cab2d0d60decddf709aaea28" // Keep synced with fetch_deps.bzl
// TODO: Add scip-clang Git SHA + dirty bit.
diff --git a/indexer/os/Linux.cc b/indexer/os/Linux.cc
index bcd2d9d4..1539968b 100644
--- a/indexer/os/Linux.cc
+++ b/indexer/os/Linux.cc
@@ -21,9 +21,9 @@
extern "C" {
// If we are linked against the LLVM sanitizers, this symbol will be
// replaced with the definition from the sanitizer runtime
-void __attribute__((weak))
-__sanitizer_symbolize_pc(void *pc, const char *fmt, char *outBuf,
- size_t outBufSize) {
+void __attribute__((weak)) __sanitizer_symbolize_pc(void *pc, const char *fmt,
+ char *outBuf,
+ size_t outBufSize) {
(void)pc;
(void)fmt;
std::snprintf(outBuf, outBufSize, "");
diff --git a/proto/BUILD b/proto/BUILD
index 60a582ac..c8232413 100644
--- a/proto/BUILD
+++ b/proto/BUILD
@@ -1,21 +1,17 @@
-load("@com_google_protobuf//:protobuf.bzl", "cc_proto_library")
+load("@rules_proto//proto:defs.bzl", "proto_library")
-cc_proto_library(
- name = "proto",
+proto_library(
+ name = "fwd_decls_proto",
srcs = ["fwd_decls.proto"],
)
+cc_proto_library(
+ name = "fwd_decls_cc_proto",
+ deps = [":fwd_decls_proto"],
+)
+
cc_library(
name = "fwd_decls",
- srcs = ["fwd_decls.pb.cc"],
- hdrs = ["fwd_decls.pb.h"],
- copts = [
- "-Wno-unused-function",
- # Generated code uses sprintf in some places, which
- # is deprecated on macOS
- "-Wno-deprecated-declarations",
- "-Wno-covered-switch-default",
- ],
visibility = ["//visibility:public"],
- deps = [":proto"],
+ deps = [":fwd_decls_cc_proto"],
)
diff --git a/settings.bzl b/settings.bzl
index d1e5440c..4abaa429 100644
--- a/settings.bzl
+++ b/settings.bzl
@@ -1,7 +1,5 @@
# Keep LLVM versions list in sync with setup_llvm.bzl
ASAN_LINKOPTS = [
- "-Wl,-rpath,@loader_path/../../../../../../external/llvm_toolchain_llvm/lib/clang/15.0.6/lib/darwin",
- # macOS release builds use 15.0.7 for x86_64
- "-Wl,-rpath,@loader_path/../../../../../../external/llvm_toolchain_llvm/lib/clang/15.0.7/lib/darwin",
- "-Wl,-rpath,@loader_path/../../../../../../external/llvm_toolchain_llvm/lib/clang/15.0.6/lib/linux",
+ "-Wl,-rpath,@loader_path/../../../../../../external/llvm_toolchain_llvm/lib/clang/21/lib/darwin",
+ "-Wl,-rpath,@loader_path/../../../../../../external/llvm_toolchain_llvm/lib/clang/21/lib/linux",
]
diff --git a/setup_deps.bzl b/setup_deps.bzl
index 6dccda3c..870e18d5 100644
--- a/setup_deps.bzl
+++ b/setup_deps.bzl
@@ -2,8 +2,6 @@ load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")
load("@com_github_nelhage_rules_boost//:boost/boost.bzl", "boost_deps")
load("@com_grail_bazel_compdb//:deps.bzl", "bazel_compdb_deps")
load("@llvm-raw//utils/bazel:configure.bzl", "llvm_configure")
-load("@llvm-raw//utils/bazel:terminfo.bzl", "llvm_terminfo_disable")
-load("@llvm-raw//utils/bazel:zlib.bzl", "llvm_zlib_external")
load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
load("@python_3_10//:defs.bzl", "interpreter")
load("@rules_python//python:pip.bzl", "pip_parse")
@@ -14,9 +12,6 @@ def setup_dependencies():
boost_deps()
bazel_compdb_deps()
- llvm_terminfo_disable(name = "llvm_terminfo")
- llvm_zlib_external(name = "llvm_zlib", external_zlib = "@zlib//:zlib")
-
# FIXME: Should we allow all targets in a release build?
# Limit the number of backends here to save on compile time for now.
llvm_configure(name = "llvm-project", targets = ["AArch64", "X86"])
diff --git a/setup_llvm.bzl b/setup_llvm.bzl
index 42ab79a0..225ee0ad 100644
--- a/setup_llvm.bzl
+++ b/setup_llvm.bzl
@@ -1,31 +1,94 @@
load("@toolchains_llvm//toolchain:rules.bzl", grailbio_llvm_toolchain = "llvm_toolchain")
+# macOS SDK path for system libc++ headers
+# This is the standard location for Xcode Command Line Tools SDK
+_MACOS_SDK = "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk"
+
def setup_llvm_toolchain(name):
# NOTE: The ASan build uses paths which involve the version.
# Keep the version list in sync with settings.bzl
- mapping = {
- "linux-aarch64": {"version": "15.0.6", "triple": "aarch64-linux-gnu", "sha256": "8ca4d68cf103da8331ca3f35fe23d940c1b78fb7f0d4763c1c059e352f5d1bec"},
- "linux-x86_64": {"version": "15.0.6", "triple": "x86_64-linux-gnu-ubuntu-18.04", "sha256": "38bc7f5563642e73e69ac5626724e206d6d539fbef653541b34cae0ba9c3f036"},
- "darwin-aarch64": {"version": "15.0.6", "triple": "arm64-apple-darwin21.0", "sha256": "32bc7b8eee3d98f72dd4e5651e6da990274ee2d28c5c19a7d8237eb817ce8d91"},
- "darwin-arm64": {"version": "15.0.6", "triple": "arm64-apple-darwin21.0", "sha256": "32bc7b8eee3d98f72dd4e5651e6da990274ee2d28c5c19a7d8237eb817ce8d91"},
- "darwin-x86_64": {"version": "15.0.7", "triple": "x86_64-apple-darwin21.0", "sha256": "d16b6d536364c5bec6583d12dd7e6cf841b9f508c4430d9ee886726bd9983f1c"},
- "windows": {"version": "15.0.6", "sha256": "22e2f2c38be4c44db7a1e9da5e67de2a453c5b4be9cf91e139592a63877ac0a2", "url": "https://github.com/llvm/llvm-project/releases/download/llvmorg-15.0.6/LLVM-15.0.6-win64.exe"},
- }
- llvm_versions, sha256, strip_prefix, urls = {}, {}, {}, {}
- for (k, v) in mapping.items():
- llvm_versions[k] = v["version"]
- sha256[k] = v["sha256"]
- if "url" in v:
- urls[k] = [v["url"]]
- else:
- prefix = "clang+llvm-{version}-{triple}".format(version = v["version"], triple = v["triple"])
- strip_prefix[k] = prefix
- urls[k] = ["https://github.com/llvm/llvm-project/releases/download/llvmorg-{version}/{prefix}.tar.xz".format(version = v["version"], prefix = prefix)]
-
+ #
+ # LLVM 21 uses new naming convention: LLVM-VERSION-Platform.tar.xz
+ # with strip prefix LLVM-VERSION-Platform
+ #
+ # On macOS, we use stdlib = "libc++" to use the system's libc++ instead of
+ # the bundled LLVM libc++. This avoids the __hash_memory ABI mismatch issue
+ # where LLVM 21's libc++ headers reference symbols that Apple's system libc++
+ # doesn't have.
+ #
+ # IMPORTANT: stdlib="libc++" only affects LINKING, not header search paths!
+ # By default, the toolchain still uses LLVM's bundled libc++ headers from
+ # {toolchain_path_prefix}/include/c++/v1, which causes the ABI mismatch.
+ #
+ # To fix this, we use cxx_flags to:
+ # 1. Add -nostdinc++ to disable the default C++ stdlib header search
+ # 2. Use -isystem to add macOS SDK headers explicitly
+ #
+ # We also set sysroot to the macOS SDK so the toolchain knows where to find
+ # system headers and frameworks.
grailbio_llvm_toolchain(
name = name,
- llvm_versions = llvm_versions,
- strip_prefix = strip_prefix,
- urls = urls,
- sha256 = sha256,
+ # Use system libc++ on macOS to avoid ABI mismatch with LLVM 21's bundled headers.
+ # On Linux, use the bundled libc++ (builtin-libc++) for hermetic builds.
+ stdlib = {
+ "darwin-aarch64": "libc++",
+ "darwin-x86_64": "libc++",
+ "": "builtin-libc++", # Default for all other platforms
+ },
+ # Point to macOS SDK for system headers and frameworks
+ sysroot = {
+ "darwin-aarch64": _MACOS_SDK,
+ "darwin-x86_64": _MACOS_SDK,
+ },
+ # Add extra cxx_flags to use macOS SDK libc++ headers instead of LLVM's bundled ones.
+ # -nostdinc++ disables the default C++ header search paths (including LLVM's bundled headers)
+ # -isystem adds the macOS SDK's libc++ headers as a system include path
+ # NOTE: We use extra_cxx_flags (not cxx_flags) to ADD to defaults rather than replace them.
+ extra_cxx_flags = {
+ "darwin-aarch64": [
+ "-nostdinc++",
+ "-isystem",
+ _MACOS_SDK + "/usr/include/c++/v1",
+ ],
+ "darwin-x86_64": [
+ "-nostdinc++",
+ "-isystem",
+ _MACOS_SDK + "/usr/include/c++/v1",
+ ],
+ },
+ # Override link_libs for darwin platforms to use dynamic libc++ instead
+ # of the default static -l:libc++.a which doesn't exist on macOS.
+ # We explicitly link -lc++ and -lc++abi dynamically.
+ link_libs = {
+ "darwin-aarch64": ["-lc++", "-lc++abi"],
+ "darwin-x86_64": ["-lc++", "-lc++abi"],
+ },
+ llvm_versions = {
+ "linux-aarch64": "21.1.8",
+ "linux-x86_64": "21.1.8",
+ "darwin-aarch64": "21.1.8",
+ "darwin-x86_64": "21.1.8",
+ "windows-x86_64": "21.1.8",
+ },
+ sha256 = {
+ "linux-aarch64": "65ce0b329514e5643407db2d02a5bd34bf33d159055dafa82825c8385bd01993",
+ "linux-x86_64": "b3b7f2801d15d50736acea3c73982994d025b01c2f035b91ae3b49d1b575732b",
+ "darwin-aarch64": "b95bdd32a33a81ee4d40363aaeb26728a26783fcef26a4d80f65457433ea4669",
+ "darwin-x86_64": "b95bdd32a33a81ee4d40363aaeb26728a26783fcef26a4d80f65457433ea4669", # Use ARM64 via Rosetta
+ "windows-x86_64": "749d22f565fcd5718dbed06512572d0e5353b502c03fe1f7f17ee8b8aca21a47",
+ },
+ strip_prefix = {
+ "linux-aarch64": "LLVM-21.1.8-Linux-ARM64",
+ "linux-x86_64": "LLVM-21.1.8-Linux-X64",
+ "darwin-aarch64": "LLVM-21.1.8-macOS-ARM64",
+ "darwin-x86_64": "LLVM-21.1.8-macOS-ARM64", # Use ARM64 via Rosetta
+ "windows-x86_64": "clang+llvm-21.1.8-x86_64-pc-windows-msvc",
+ },
+ urls = {
+ "linux-aarch64": ["https://github.com/llvm/llvm-project/releases/download/llvmorg-21.1.8/LLVM-21.1.8-Linux-ARM64.tar.xz"],
+ "linux-x86_64": ["https://github.com/llvm/llvm-project/releases/download/llvmorg-21.1.8/LLVM-21.1.8-Linux-X64.tar.xz"],
+ "darwin-aarch64": ["https://github.com/llvm/llvm-project/releases/download/llvmorg-21.1.8/LLVM-21.1.8-macOS-ARM64.tar.xz"],
+ "darwin-x86_64": ["https://github.com/llvm/llvm-project/releases/download/llvmorg-21.1.8/LLVM-21.1.8-macOS-ARM64.tar.xz"], # Use ARM64 via Rosetta
+ "windows-x86_64": ["https://github.com/llvm/llvm-project/releases/download/llvmorg-21.1.8/clang+llvm-21.1.8-x86_64-pc-windows-msvc.tar.xz"],
+ },
)
diff --git a/test/Snapshot.cc b/test/Snapshot.cc
index c8828134..81100cc5 100644
--- a/test/Snapshot.cc
+++ b/test/Snapshot.cc
@@ -122,7 +122,8 @@ bool isTuMainFilePath(std::string_view p) {
// static
FormatOptions SnapshotPrinter::readFormatOptions(AbsolutePathRef path) {
- std::ifstream tuStream(path.asStringView(), std::ios::in | std::ios::binary);
+ std::ifstream tuStream(std::string(path.asStringView()),
+ std::ios::in | std::ios::binary);
std::string prefix = "// format-options:";
test::FormatOptions formatOptions{};
for (std::string line; std::getline(tuStream, line);) {
@@ -219,7 +220,7 @@ void SnapshotPrinter::printDocument(const scip::Document &document,
[](const scip::Occurrence &lhs, const scip::Occurrence &rhs) -> bool {
return scip::compareOccurrences(lhs, rhs) == std::strong_ordering::less;
});
- std::ifstream input(sourceFilePath.asStringView());
+ std::ifstream input(std::string(sourceFilePath.asStringView()));
ENFORCE(input.is_open(),
"failed to open document at '{}' to read source code",
sourceFilePath.asStringView());
diff --git a/test/index/aliases/aliases.snapshot.cc b/test/index/aliases/aliases.snapshot.cc
index b67bd259..1304f35a 100644
--- a/test/index/aliases/aliases.snapshot.cc
+++ b/test/index/aliases/aliases.snapshot.cc
@@ -232,7 +232,7 @@
// ^^^^ reference [..] i/j/zero.
static int zero_int = zero;
// ^^^^^^^^ definition [..] i/zero_int.
-// ^^^^ reference [..] i/j/zero.
+// ^^^^ reference [..] i/zero.
using k::SAlias;
// ^ reference [..] i/k/
diff --git a/test/index/cuda/kernelcall.snapshot.cu b/test/index/cuda/kernelcall.snapshot.cu
index cb05b1a1..c830a875 100644
--- a/test/index/cuda/kernelcall.snapshot.cu
+++ b/test/index/cuda/kernelcall.snapshot.cu
@@ -52,7 +52,6 @@
// ^^ reference local 5
g1<<>>(42); // expected-error {{use of undeclared identifier 'undeclared'}}
-// ^^ reference [..] g1(d4f767463ce0a6b3).
}
// Make sure we can call static member kernels.
diff --git a/test/index/functions/ctors_dtors.snapshot.cc b/test/index/functions/ctors_dtors.snapshot.cc
index b50c63be..db723fa2 100644
--- a/test/index/functions/ctors_dtors.snapshot.cc
+++ b/test/index/functions/ctors_dtors.snapshot.cc
@@ -23,7 +23,7 @@
// ^ definition local 3
typename remove_ref::type&& move(T&& arg) {
// ^^^^^^^^^^ reference [..] remove_ref#
-// ^^^^ definition [..] move(721d19cf58c53974).
+// ^^^^ definition [..] move(14e6c83231ab878e).
// ^ reference local 3
// ^^^ definition local 4
return static_cast::type&&>(arg);
@@ -90,13 +90,13 @@
C c3{move(c1)};
// ^ reference [..] C#
// ^^ definition local 10
-// ^^^^ reference [..] move(721d19cf58c53974).
+// ^^^^ reference [..] move(14e6c83231ab878e).
// ^^ reference local 7
D d3{move(d1)};
// ^ reference [..] D#
// ^^ definition local 11
// ^^ reference [..] D#D(ece7426db7e2c886).
-// ^^^^ reference [..] move(721d19cf58c53974).
+// ^^^^ reference [..] move(14e6c83231ab878e).
// ^^ reference local 8
C c4 = {};
@@ -134,12 +134,12 @@
C c10 = move(c1);
// ^ reference [..] C#
// ^^^ definition local 20
-// ^^^^ reference [..] move(721d19cf58c53974).
+// ^^^^ reference [..] move(14e6c83231ab878e).
// ^^ reference local 7
D d10 = move(d1);
// ^ reference [..] D#
// ^^^ definition local 21
// ^^^^ reference [..] D#D(ece7426db7e2c886).
-// ^^^^ reference [..] move(721d19cf58c53974).
+// ^^^^ reference [..] move(14e6c83231ab878e).
// ^^ reference local 8
}
diff --git a/test/index/types/inheritance.snapshot.cc b/test/index/types/inheritance.snapshot.cc
index f7dc5682..00a57974 100644
--- a/test/index/types/inheritance.snapshot.cc
+++ b/test/index/types/inheritance.snapshot.cc
@@ -40,7 +40,6 @@
template <>
struct SpecializedBase {};
-// ^^^^^^^^^^^^^^^ reference [..] SpecializedBase#
// ^^^^^^^^^^^^^^^ definition [..] SpecializedBase#
template
@@ -117,7 +116,6 @@
template <>
struct DerivedFromSelf {};
-// ^^^^^^^^^^^^^^^ reference [..] DerivedFromSelf#
// ^^^^^^^^^^^^^^^ definition [..] DerivedFromSelf#
void useDerivedFromSelf() {
diff --git a/test/index/types/templates.snapshot.cc b/test/index/types/templates.snapshot.cc
index e570668a..e68045d9 100644
--- a/test/index/types/templates.snapshot.cc
+++ b/test/index/types/templates.snapshot.cc
@@ -18,7 +18,7 @@
F fmap(A f(B), F fa) {
//^ reference local 4
// ^ reference local 3
-// ^^^^ definition [..] fmap(48b319d339a486cb).
+// ^^^^ definition [..] fmap(22a739e3a02d9724).
// ^ reference local 2
// ^ definition local 5
// ^ reference local 3
@@ -41,7 +41,7 @@
// ^^ definition local 9
// ^^ definition local 10
void g(As ...) {}
-// ^ definition [..] g(c3d59a70a6e5360c).
+// ^ definition [..] g(da52d0cc43a6b199).
// ^^ reference local 10
// ^^ reference local 9
diff --git a/test/test_main.cc b/test/test_main.cc
index 2df6b998..7420658a 100644
--- a/test/test_main.cc
+++ b/test/test_main.cc
@@ -18,6 +18,7 @@
#include "cxxopts.hpp"
#include "doctest/doctest.h"
#include "spdlog/fmt/fmt.h"
+#include "spdlog/fmt/ranges.h"
#include "llvm/Support/YAMLTraits.h"
diff --git a/third_party/llvm-cuda-tooling.patch b/third_party/llvm-cuda-tooling.patch
new file mode 100644
index 00000000..32ee13d8
--- /dev/null
+++ b/third_party/llvm-cuda-tooling.patch
@@ -0,0 +1,29 @@
+diff --git a/clang/lib/Tooling/Tooling.cpp b/clang/lib/Tooling/Tooling.cpp
+index a1b2c3d4e5f6..b2c3d4e5f6a7 100644
+--- a/clang/lib/Tooling/Tooling.cpp
++++ b/clang/lib/Tooling/Tooling.cpp
+@@ -107,13 +107,17 @@ static bool ignoreExtraCC1Commands(const driver::Compilation *Compilation) {
+ // tooling will consider host-compilation only. For tooling on device
+ // compilation, device compilation only option, such as
+ // `--cuda-device-only`, needs specifying.
+- assert(Actions.size() > 1);
+- assert(
+- isa(Actions.front()) ||
+- // On MacOSX real actions may end up being wrapped in
+- // BindArchAction.
+- (isa(Actions.front()) &&
+- isa(*Actions.front()->input_begin())));
++ if (Actions.size() > 1) {
++ assert(
++ isa(Actions.front()) ||
++ // On MacOSX real actions may end up being wrapped in
++ // BindArchAction.
++ (isa(Actions.front()) &&
++ isa(*Actions.front()->input_begin())));
++ }
++ // FIXME: CUDA/HIP can produce a single top-level OffloadAction (e.g.
++ // -fsyntax-only, -E, -M), which contradicts the expectation of at least
++ // two top-level actions.
+ OffloadCompilation = true;
+ break;
+ }
diff --git a/third_party/scip.BUILD b/third_party/scip.BUILD
index c7ad9ad0..b0378cb3 100644
--- a/third_party/scip.BUILD
+++ b/third_party/scip.BUILD
@@ -1,22 +1,19 @@
-load("@com_google_protobuf//:protobuf.bzl", "cc_proto_library")
+load("@rules_proto//proto:defs.bzl", "proto_library")
-cc_proto_library(
- name = "proto",
+proto_library(
+ name = "scip_proto",
srcs = ["scip.proto"],
+ # Add prefix so generated headers are at scip/scip.pb.h
+ import_prefix = "scip",
+)
+
+cc_proto_library(
+ name = "scip_cc_proto",
+ deps = [":scip_proto"],
)
cc_library(
name = "scip",
- srcs = ["scip.pb.cc"],
- hdrs = ["scip.pb.h"],
- deps = [":proto"],
- include_prefix = "scip",
visibility = ["//visibility:public"],
- copts = [
- "-Wno-unused-function",
- # Generated code uses sprintf in some places, which
- # is deprecated on macOS
- "-Wno-deprecated-declarations",
- "-Wno-covered-switch-default",
- ],
+ deps = [":scip_cc_proto"],
)
diff --git a/tools/reformat.sh b/tools/reformat.sh
index db2bcbd2..d498f2d7 100755
--- a/tools/reformat.sh
+++ b/tools/reformat.sh
@@ -3,9 +3,21 @@ set -euo pipefail
PROJECT_ROOT="$(dirname "${BASH_SOURCE[0]}")/.."
+# Try to use the LLVM toolchain clang-format, fall back to system clang-format
+# (LLVM 21 binaries require glibc 2.34+ which may not be available on older CI agents)
+CLANG_FORMAT=""
if [ ! -f "bazel-bin/external/llvm_toolchain/clang-format" ]; then
bazel build @llvm_toolchain//:clang-format
fi
+if bazel-bin/external/llvm_toolchain/clang-format --version >/dev/null 2>&1; then
+ CLANG_FORMAT="bazel-bin/external/llvm_toolchain/clang-format"
+elif command -v clang-format >/dev/null 2>&1; then
+ echo "Warning: Using system clang-format (LLVM toolchain version not compatible with this system)"
+ CLANG_FORMAT="clang-format"
+else
+ echo "Warning: No clang-format available, skipping C++ formatting"
+ CLANG_FORMAT=""
+fi
if [ ! -f "bazel-bin/third_party/bazel_buildtools/buildifier" ]; then
bazel build //third_party/bazel_buildtools:buildifier
@@ -14,6 +26,8 @@ fi
(
cd "$PROJECT_ROOT"
git ls-files BUILD WORKSPACE "**/BUILD" "**/.BUILD" "**.bzl" | xargs bazel-bin/third_party/bazel_buildtools/buildifier
- git ls-files "**.cc" "**.h" | xargs bazel-bin/external/llvm_toolchain/clang-format -i
+ if [ -n "$CLANG_FORMAT" ]; then
+ git ls-files "**.cc" "**.h" | xargs "$CLANG_FORMAT" -i
+ fi
git ls-files "**.py" | sed -e "s|^|$PWD/|" | xargs bazel run //tools:reformat_python --
)