Skip to content

Commit 05ca21c

Browse files
committed
API digester support for Xcc options
1 parent e293876 commit 05ca21c

File tree

6 files changed

+37
-1
lines changed

6 files changed

+37
-1
lines changed

include/swift/Option/Options.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1556,7 +1556,7 @@ def Xfrontend : Separate<["-"], "Xfrontend">, Flags<[HelpHidden]>,
15561556

15571557
def Xcc : Separate<["-"], "Xcc">,
15581558
Flags<[FrontendOption, SwiftSymbolGraphExtractOption,
1559-
SwiftSynthesizeInterfaceOption]>,
1559+
SwiftSynthesizeInterfaceOption, SwiftAPIDigesterOption]>,
15601560
MetaVarName<"<arg>">,
15611561
HelpText<"Pass <arg> to the C/C++/Objective-C compiler">;
15621562

lib/DriverTool/swift_api_digester_main.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2273,6 +2273,7 @@ class SwiftAPIDigesterInvocation {
22732273
std::string ResourceDir;
22742274
std::string ModuleCachePath;
22752275
bool DisableFailOnError;
2276+
std::vector<std::string> ClangImporterArgs;
22762277

22772278
public:
22782279
SwiftAPIDigesterInvocation(const std::string &ExecPath)
@@ -2375,6 +2376,7 @@ class SwiftAPIDigesterInvocation {
23752376
ParsedArgs.getAllArgValues(OPT_use_interface_for_module);
23762377
ResourceDir = ParsedArgs.getLastArgValue(OPT_resource_dir).str();
23772378
ModuleCachePath = ParsedArgs.getLastArgValue(OPT_module_cache_path).str();
2379+
ClangImporterArgs = ParsedArgs.getAllArgValues(OPT_Xcc);
23782380
DebugMapping = ParsedArgs.hasArg(OPT_debug_mapping);
23792381
DisableFailOnError = ParsedArgs.hasArg(OPT_disable_fail_on_error);
23802382

@@ -2456,6 +2458,11 @@ class SwiftAPIDigesterInvocation {
24562458
InitInvoke.getLangOptions().Target.isOSDarwin();
24572459
InitInvoke.getClangImporterOptions().ModuleCachePath = ModuleCachePath;
24582460

2461+
// Pass -Xcc arguments to the Clang importer
2462+
for (const auto &arg : ClangImporterArgs) {
2463+
InitInvoke.getClangImporterOptions().ExtraArgs.push_back(arg);
2464+
}
2465+
24592466
if (!SwiftVersion.empty()) {
24602467
using version::Version;
24612468
bool isValid = false;

lib/Option/features.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@
5353
},
5454
{
5555
"name": "internal-import-bridging-header"
56+
},
57+
{
58+
"name": "api-digester-Xcc"
5659
}
5760
]
5861
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
@import ObjectiveC;
2+
3+
#ifdef MY_MACRO
4+
@interface Hidden : NSObject
5+
@end
6+
#endif
7+
8+
@interface NotHidden : NSObject
9+
@end
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module XccTest {
2+
header "XccTest.h"
3+
export *
4+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// REQUIRES: VENDOR=apple
2+
3+
// RUN: %empty-directory(%t)
4+
// RUN: %empty-directory(%t.module-cache)
5+
6+
// RUN: %api-digester -dump-sdk -module XccTest -o %t.with-define.json -module-cache-path %t.module-cache %clang-importer-sdk-nosource -I %S/Inputs/XccTest -Xcc -DMY_MACRO
7+
// RUN: %api-digester -dump-sdk -module XccTest -o %t.without-define.json -module-cache-path %t.module-cache %clang-importer-sdk-nosource -I %S/Inputs/XccTest
8+
9+
// RUN: grep -q "Hidden" %t.with-define.json
10+
// RUN: grep -q "NotHidden" %t.with-define.json
11+
12+
// RUN: not grep -q "Hidden" %t.without-define.json
13+
// RUN: grep -q "NotHidden" %t.without-define.json

0 commit comments

Comments
 (0)