Skip to content

[Clang] Reintroduce obsolete libclang symbols to avoid an ABI break #149079

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
15 changes: 15 additions & 0 deletions clang/include/clang-c/Index.h
Original file line number Diff line number Diff line change
Expand Up @@ -6953,6 +6953,21 @@ clang_getCursorUnaryOperatorKind(CXCursor cursor);
* @}
*/

CINDEX_DEPRECATED
typedef void *CXRemapping;

CINDEX_DEPRECATED CINDEX_LINKAGE CXRemapping clang_getRemappings(const char *);

CINDEX_DEPRECATED CINDEX_LINKAGE CXRemapping
clang_getRemappingsFromFileList(const char **, unsigned);

CINDEX_DEPRECATED CINDEX_LINKAGE unsigned clang_remap_getNumFiles(CXRemapping);

CINDEX_DEPRECATED CINDEX_LINKAGE void
clang_remap_getFilenames(CXRemapping, unsigned, CXString *, CXString *);

CINDEX_DEPRECATED CINDEX_LINKAGE void clang_remap_dispose(CXRemapping);

LLVM_CLANG_C_EXTERN_C_END

#endif
1 change: 1 addition & 0 deletions clang/tools/libclang/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ set(SOURCES
Indexing.cpp
FatalErrorHandler.cpp
Rewrite.cpp
Obsolete.cpp

ADDITIONAL_HEADERS
CIndexDiagnostic.h
Expand Down
48 changes: 48 additions & 0 deletions clang/tools/libclang/Obsolete.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
//===- Obsolete.cpp - Obsolete libclang functions and types -------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===--------------------------------------------------------------------===//
//
// This file contains libclang symbols whose underlying functionality has been
// removed from Clang, but which need to be kept around so as to retain ABI
// compatibility.
//
//===--------------------------------------------------------------------===//

#include "clang-c/CXString.h"
#include "clang-c/Index.h"
#include "clang-c/Platform.h"
#include "llvm/Support/raw_ostream.h"

extern "C" {

// The functions below used to be part of the C API for ARCMigrate, which has
// since been removed from Clang; they already used to print an error if Clang
// was compiled without arcmt support, so we continue doing so.
CXRemapping clang_getRemappings(const char *) {
llvm::errs() << "error: ARCMigrate has been removed from Clang";
return nullptr;
}

CXRemapping clang_getRemappingsFromFileList(const char **, unsigned) {
llvm::errs() << "error: ARCMigrate has been removed from Clang";
return nullptr;
}

unsigned clang_remap_getNumFiles(CXRemapping) {
llvm::errs() << "error: ARCMigrate has been removed from Clang";
return 0;
}

void clang_remap_getFilenames(CXRemapping, unsigned, CXString *, CXString *) {
llvm::errs() << "error: ARCMigrate has been removed from Clang";
}

void clang_remap_dispose(CXRemapping) {
llvm::errs() << "error: ARCMigrate has been removed from Clang";
}

} // extern "C"
1 change: 1 addition & 0 deletions llvm/utils/gn/secondary/clang/tools/libclang/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ shared_library("libclang") {
"Index_Internal.h",
"Indexing.cpp",
"Rewrite.cpp",
"Obsolete.cpp",
]
if (host_os == "mac") {
ldflags = [
Expand Down
Loading