Skip to content

Commit 8473d40

Browse files
committed
lib: use CXX_MODULE_NAME constant for module identifier (NFC)
Use the well known specifier for explicit references to the `Cxx` module rather than re-spelling the name at the various sites.
1 parent 159259a commit 8473d40

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

lib/AST/ModuleDependencies.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "swift/AST/PluginLoader.h"
2323
#include "swift/AST/SourceFile.h"
2424
#include "swift/Frontend/Frontend.h"
25+
#include "swift/Strings.h"
2526
#include "clang/CAS/IncludeTree.h"
2627
#include "llvm/CAS/CASProvidingFileSystem.h"
2728
#include "llvm/CAS/CachingOnDiskFileSystem.h"
@@ -500,7 +501,7 @@ swift::dependencies::registerCxxInteropLibraries(
500501
RegistrationCallback(LinkLibrary("stdc++", LibraryKind::Library));
501502

502503
// Do not try to link Cxx with itself.
503-
if (mainModuleName != "Cxx") {
504+
if (mainModuleName != CXX_MODULE_NAME) {
504505
RegistrationCallback(LinkLibrary(Target.isOSWindows() && hasStaticCxx
505506
? "libswiftCxx"
506507
: "swiftCxx",
@@ -509,7 +510,7 @@ swift::dependencies::registerCxxInteropLibraries(
509510

510511
// Do not try to link CxxStdlib with the C++ standard library, Cxx or
511512
// itself.
512-
if (llvm::none_of(llvm::ArrayRef{"Cxx", "CxxStdlib", "std"},
513+
if (llvm::none_of(llvm::ArrayRef<StringRef>{CXX_MODULE_NAME, "CxxStdlib", "std"},
513514
[mainModuleName](StringRef Name) {
514515
return mainModuleName == Name;
515516
})) {

lib/DependencyScan/ScanDependencies.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1505,7 +1505,7 @@ static void resolveImplicitLinkLibraries(const CompilerInstance &instance,
15051505
addLinkLibrary({"objc", LibraryKind::Library});
15061506

15071507
if (langOpts.EnableCXXInterop) {
1508-
auto OptionalCxxDep = cache.findDependency("Cxx");
1508+
auto OptionalCxxDep = cache.findDependency(CXX_MODULE_NAME);
15091509
auto OptionalCxxStdLibDep = cache.findDependency("CxxStdlib");
15101510
bool hasStaticCxx =
15111511
OptionalCxxDep.has_value() && OptionalCxxDep.value()->isStaticLibrary();

lib/IRGen/IRGenModule.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "swift/IRGen/Linking.h"
3131
#include "swift/Runtime/Config.h"
3232
#include "swift/Runtime/RuntimeFnWrappersGen.h"
33+
#include "swift/Strings.h"
3334
#include "swift/Subsystems.h"
3435
#include "clang/AST/ASTContext.h"
3536
#include "clang/Basic/CharInfo.h"
@@ -1677,7 +1678,7 @@ void IRGenModule::addLinkLibraries() {
16771678
if (Context.LangOpts.EnableCXXInterop) {
16781679
bool hasStaticCxx = false;
16791680
bool hasStaticCxxStdlib = false;
1680-
if (const auto *M = Context.getModuleByName("Cxx"))
1681+
if (const auto *M = Context.getModuleByName(CXX_MODULE_NAME))
16811682
hasStaticCxx = M->isStaticLibrary();
16821683
if (Context.LangOpts.Target.getOS() == llvm::Triple::Win32)
16831684
if (const auto *M = Context.getModuleByName("CxxStdlib"))

0 commit comments

Comments
 (0)