| Updated patch attached with the following changes: * add the framework root directory to DirectoryHasModuleMap to cutoff lookups sooner * reassign ModuleMapFileName, rather than assume we can drop the appended characters * clarify the note about ‘module.map’ in the docs using Richard’s suggested wording
Ben
|
modulemap.patch
Description: Binary data
Documentation update:
+ Clang also accepts a module map file with the name ``module.map``, but this will be deprecated in the future. When both ``module.modulemap`` and ``module.map`` files are present, the ``module.modulemap`` file will be used.
"Will be deprecated in the future" doesn't make much sense to me. The only functional meaning of "deprecated" here is "we intend to remove this some day", so in that sense, if it'll be deprecated in the future, then it's already deprecated now. Perhaps:
+ For compatibility with previous releases, if a module map file named ``module.modulemap`` is not found, Clang will also search for a file named ``module.map``. This behavior is deprecated and we plan to eventually remove it.
Makes sense, I’ll use that.
+ StringRef Filename = llvm::sys::path::filename(ModuleMapPath); + SmallString<128> PrivateFilename(Directory->getName()); + if (Filename == "module.map")
+ llvm::sys::path::append(PrivateFilename, "module_private.map"); + else if (Filename == "module.modulemap") + llvm::sys::path::append(PrivateFilename, "module.private.modulemap");
+ else + return nullptr;
Maybe use StringSwitch?
StringSwitch does not work very well here, because in the ‘Default’ case we want to return early.
+ // Continue to allow module.map + ModuleMapFileName.erase(ModuleMapFileName.begin() + ModuleMapDirNameLen,
+ ModuleMapFileName.end()); + + llvm::sys::path::append(ModuleMapFileName, "module.map"); + return FileMgr.getFile(ModuleMapFileName);
This makes a slightly dubious assumption about what llvm::sys::path:append does to the string (that it only appends at the character level). Even though that assumption turns out to be correct (for now, at least), I'd prefer to not rely on it here.
I’m not sure I agree that sys::path::append should ever be allowed to modify the rest of the string, but I think what you’ve said applies equally well to the rest of this function, so I’m happy to just reassign the string.
Thanks,
Ben
_______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
|
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits