Skip to content

Commit 1600450

Browse files
authored
[Clang] Reintroduce obsolete libclang symbols to avoid an ABI break (#149079)
For more context, see #119269 (comment), but briefly, when removing ARCMigrate, I also removed some symbols in libclang, which constitutes an ABI break that we don’t want, so this pr reintroduces the removed symbols; the declarations are marked as deprecated for future removal, and the implementations print an error and do nothing, which is what we used to do when ARCMigrate was disabled.
1 parent 85349b4 commit 1600450

File tree

4 files changed

+65
-0
lines changed

4 files changed

+65
-0
lines changed

clang/include/clang-c/Index.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6953,6 +6953,21 @@ clang_getCursorUnaryOperatorKind(CXCursor cursor);
69536953
* @}
69546954
*/
69556955

6956+
CINDEX_DEPRECATED
6957+
typedef void *CXRemapping;
6958+
6959+
CINDEX_DEPRECATED CINDEX_LINKAGE CXRemapping clang_getRemappings(const char *);
6960+
6961+
CINDEX_DEPRECATED CINDEX_LINKAGE CXRemapping
6962+
clang_getRemappingsFromFileList(const char **, unsigned);
6963+
6964+
CINDEX_DEPRECATED CINDEX_LINKAGE unsigned clang_remap_getNumFiles(CXRemapping);
6965+
6966+
CINDEX_DEPRECATED CINDEX_LINKAGE void
6967+
clang_remap_getFilenames(CXRemapping, unsigned, CXString *, CXString *);
6968+
6969+
CINDEX_DEPRECATED CINDEX_LINKAGE void clang_remap_dispose(CXRemapping);
6970+
69566971
LLVM_CLANG_C_EXTERN_C_END
69576972

69586973
#endif

clang/tools/libclang/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ set(SOURCES
4242
Indexing.cpp
4343
FatalErrorHandler.cpp
4444
Rewrite.cpp
45+
Obsolete.cpp
4546

4647
ADDITIONAL_HEADERS
4748
CIndexDiagnostic.h

clang/tools/libclang/Obsolete.cpp

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
//===- Obsolete.cpp - Obsolete libclang functions and types -------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===--------------------------------------------------------------------===//
8+
//
9+
// This file contains libclang symbols whose underlying functionality has been
10+
// removed from Clang, but which need to be kept around so as to retain ABI
11+
// compatibility.
12+
//
13+
//===--------------------------------------------------------------------===//
14+
15+
#include "clang-c/CXString.h"
16+
#include "clang-c/Index.h"
17+
#include "clang-c/Platform.h"
18+
#include "llvm/Support/raw_ostream.h"
19+
20+
extern "C" {
21+
22+
// The functions below used to be part of the C API for ARCMigrate, which has
23+
// since been removed from Clang; they already used to print an error if Clang
24+
// was compiled without arcmt support, so we continue doing so.
25+
CXRemapping clang_getRemappings(const char *) {
26+
llvm::errs() << "error: ARCMigrate has been removed from Clang";
27+
return nullptr;
28+
}
29+
30+
CXRemapping clang_getRemappingsFromFileList(const char **, unsigned) {
31+
llvm::errs() << "error: ARCMigrate has been removed from Clang";
32+
return nullptr;
33+
}
34+
35+
unsigned clang_remap_getNumFiles(CXRemapping) {
36+
llvm::errs() << "error: ARCMigrate has been removed from Clang";
37+
return 0;
38+
}
39+
40+
void clang_remap_getFilenames(CXRemapping, unsigned, CXString *, CXString *) {
41+
llvm::errs() << "error: ARCMigrate has been removed from Clang";
42+
}
43+
44+
void clang_remap_dispose(CXRemapping) {
45+
llvm::errs() << "error: ARCMigrate has been removed from Clang";
46+
}
47+
48+
} // extern "C"

llvm/utils/gn/secondary/clang/tools/libclang/BUILD.gn

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ shared_library("libclang") {
8787
"Index_Internal.h",
8888
"Indexing.cpp",
8989
"Rewrite.cpp",
90+
"Obsolete.cpp",
9091
]
9192
if (host_os == "mac") {
9293
ldflags = [

0 commit comments

Comments
 (0)