[Dependency Scanning] Always record best version of discovered 'canImport'-ed modules

Suppose module 'Foo' exists in the search paths and specifies user module version '1.0'.

If the first encountered 'canImport' query is unversioned:
...

Followed by a versioned one:
...

The success of the first check will record an unversioned successful canImport, which will cause the second check to evaluate to 'true', which is incorrect.

This change causes even unversioned 'canImport' checks to track and record the discovered user module version.
This commit is contained in:
Artem Chikin
2025-03-31 12:25:45 -07:00
parent d2ea34c0bd
commit c9ba79c8da
9 changed files with 163 additions and 102 deletions

View File

@@ -1185,11 +1185,13 @@ public:
bool canImportModuleImpl(ImportPath::Module ModulePath, SourceLoc loc,
llvm::VersionTuple version, bool underlyingVersion,
bool isSourceCanImport,
llvm::VersionTuple &foundVersion) const;
llvm::VersionTuple &foundVersion,
llvm::VersionTuple &foundUnderlyingClangVersion) const;
/// Add successful canImport modules.
void addSucceededCanImportModule(StringRef moduleName, bool underlyingVersion,
const llvm::VersionTuple &versionInfo);
void addSucceededCanImportModule(StringRef moduleName,
const llvm::VersionTuple &versionInfo,
const llvm::VersionTuple &underlyingVersionInfo);
public:
namelookup::ImportCache &getImportCache() const;