Skip to content

Commit d3e18f9

Browse files
elshbeccadax
andcommitted
Update include/swift/AST/Decl.h
Co-authored-by: Becca Royal-Gordon <[email protected]>
1 parent 91a1773 commit d3e18f9

File tree

1 file changed

+27
-4
lines changed

1 file changed

+27
-4
lines changed

include/swift/AST/Decl.h

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1211,10 +1211,33 @@ class ImportDecl final : public Decl,
12111211
return scratch.get();
12121212
}
12131213

1214-
ImportPath::Module getModulePath(ImportPath::Module::Builder *outRealModuleName = nullptr) const {
1215-
if (outRealModuleName != nullptr && !RealModuleName.empty()) {
1216-
outRealModuleName->push_back(RealModuleName);
1217-
}
1214+
/// Retrieves the part of the import path that contains the module name,
1215+
/// as written in the source code.
1216+
///
1217+
/// \returns A \c ModulePath corresponding to this import decl. If module
1218+
/// aliasing was used, this will contain the aliased name of the module;
1219+
/// for instance, if you wrote 'import Foo' but passed
1220+
/// '-module-alias Foo=Bar', this module path will include 'Foo'. This
1221+
/// return value is always owned by the AST context, so it can be
1222+
/// persisted.
1223+
ImportPath::Module getModulePath() const {
1224+
return getImportPath().getModulePath(getImportKind());
1225+
}
1226+
1227+
/// Retrieves the part of the import path that contains the module name,
1228+
/// replacing any module aliases with real names.
1229+
///
1230+
/// \param scratch An \c ImportPath::Builder which may, if necessary, be used to
1231+
/// construct the return value. It may go unused, so you should not try to
1232+
/// read the result from it; use the return value instead.
1233+
/// \returns An \c ImportPath corresponding to this import decl. If module
1234+
/// aliasing was used, this will contain the real name of the module;
1235+
/// for instance, if you wrote 'import Foo' but passed
1236+
/// '-module-alias Foo=Bar', this import path will include 'Bar'. This
1237+
/// return value may be owned by \p scratch, so it should not be used
1238+
/// after \p scratch is destroyed.
1239+
ImportPath::Module getRealModulePath(ImportPath::Builder &scratch) const {
1240+
return getRealImportPath(scratch).getModulePath(getImportKind());
12181241
return getImportPath().getModulePath(getImportKind());
12191242
}
12201243

0 commit comments

Comments
 (0)