Skip to content

Commit e358302

Browse files
committed
Always print real module name via printModuleUSR
1 parent 0ff713d commit e358302

File tree

4 files changed

+18
-20
lines changed

4 files changed

+18
-20
lines changed

include/swift/AST/Module.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -869,18 +869,18 @@ class ModuleEntity {
869869
ModuleEntity(const ModuleDecl *Mod) : Mod(Mod) {}
870870
ModuleEntity(const clang::Module *Mod) : Mod(static_cast<const void *>(Mod)){}
871871

872-
// @param useRealNameIfAliased Whether to use the module's real name in case
873-
// module aliasing is used. For example, if a file
874-
// has `import Foo` and `-module-alias Foo=Bar` is
875-
// passed, treat Foo as an alias and Bar as the real
876-
// module name as its dependency. This only applies
877-
// to Swift modules.
878-
// @return The module name; for Swift modules, the real module name could be
879-
// different from the name if module aliasing is used.
872+
/// @param useRealNameIfAliased Whether to use the module's real name in case
873+
/// module aliasing is used. For example, if a file
874+
/// has `import Foo` and `-module-alias Foo=Bar` is
875+
/// passed, treat Foo as an alias and Bar as the real
876+
/// module name as its dependency. This only applies
877+
/// to Swift modules.
878+
/// @return The module name; for Swift modules, the real module name could be
879+
/// different from the name if module aliasing is used.
880880
StringRef getName(bool useRealNameIfAliased = false) const;
881881

882-
// For Swift modules, it returns the same result as \c ModuleEntity::getName(bool).
883-
// For Clang modules, it returns the result of \c clang::Module::getFullModuleName.
882+
/// For Swift modules, it returns the same result as \c ModuleEntity::getName(bool).
883+
/// For Clang modules, it returns the result of \c clang::Module::getFullModuleName.
884884
std::string getFullName(bool useRealNameIfAliased = false) const;
885885

886886
bool isSystemModule() const;

include/swift/AST/USRGeneration.h

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,12 @@ bool printDeclTypeUSR(const ValueDecl *D, raw_ostream &OS);
4747
bool printValueDeclUSR(const ValueDecl *D, raw_ostream &OS);
4848

4949
/// Prints out the USR for the given ModuleEntity.
50-
/// \param useRealNameIfAliased Whether to use the module's real name in case
51-
/// module aliasing is used. For example, if a file
52-
/// has `import Foo` and `-module-alias Foo=Bar` is
53-
/// passed, treat Foo as an alias and Bar as the real
54-
/// module name as its dependency. This only applies
55-
/// to Swift modules.
50+
/// In case module aliasing is used, it prints the real module name. For example,
51+
/// if a file has `import Foo` and `-module-alias Foo=Bar` is passed, treat Foo as
52+
/// an alias and Bar as the real module name as its dependency. Note that the
53+
/// aliasing only applies to Swift modules.
5654
/// \returns true if it failed, false on success.
57-
bool printModuleUSR(ModuleEntity Mod, raw_ostream &OS, bool useRealNameIfAliased = false);
55+
bool printModuleUSR(ModuleEntity Mod, raw_ostream &OS);
5856

5957
/// Prints out the accessor USR for the given storage Decl.
6058
/// \returns true if it failed, false on success.

lib/AST/USRGeneration.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,9 +278,9 @@ swift::MangleLocalTypeDeclRequest::evaluate(Evaluator &evaluator,
278278
return NewMangler.mangleLocalTypeDecl(D);
279279
}
280280

281-
bool ide::printModuleUSR(ModuleEntity Mod, raw_ostream &OS, bool useRealNameIfAliased) {
281+
bool ide::printModuleUSR(ModuleEntity Mod, raw_ostream &OS) {
282282
if (auto *D = Mod.getAsSwiftModule()) {
283-
StringRef moduleName = useRealNameIfAliased ? D->getRealName().str() : D->getNameStr();
283+
StringRef moduleName = D->getRealName().str();
284284
return clang::index::generateFullUSRForTopLevelModuleName(moduleName, OS);
285285
} else if (auto ClangM = Mod.getAsClangModule()) {
286286
return clang::index::generateFullUSRForModule(ClangM, OS);

lib/Index/Index.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ class IndexSwiftASTWalker : public SourceEntityWalker {
482482
SmallString<128> storage;
483483
{
484484
llvm::raw_svector_ostream OS(storage);
485-
if (ide::printModuleUSR(Mod, OS, /*useRealNameIfAliased=*/true))
485+
if (ide::printModuleUSR(Mod, OS))
486486
return true;
487487
result.USR = stringStorage.copyString(OS.str());
488488
}

0 commit comments

Comments
 (0)