[PATCH] D18088: Add a new warning to notify users of mismatched SDK and deployment target
Richard Smith via cfe-commits
cfe-commits at lists.llvm.org
Wed Apr 27 18:00:33 PDT 2016
rsmith added a subscriber: rsmith.
================
Comment at: lib/Driver/ToolChains.cpp:718-720
@@ +717,5 @@
+ StringRef isysroot = A->getValue();
+ // Assume SDK has path: SOME_PATH/SDKs/PlatformXX.YY.sdk
+ size_t BeginSDK = isysroot.rfind("SDKs/");
+ size_t EndSDK = isysroot.rfind(".sdk");
+ if (BeginSDK != StringRef::npos && EndSDK != StringRef::npos) {
----------------
This seems to get a couple of corner cases wrong (`/` between the platform name and `.sdk`, `.sdk` not at the end of the path component, ...). Have you considered using `llvm::sys::path`'s path iterators here? Not a big deal either way, though.
================
Comment at: lib/Driver/ToolChains.cpp:722
@@ +721,3 @@
+ if (BeginSDK != StringRef::npos && EndSDK != StringRef::npos) {
+ StringRef SDK = isysroot.slice(BeginSDK + 5, EndSDK);
+ if (!SDK.startswith(getPlatformFamily()))
----------------
According to `slice`'s documentation, if `EndSDK < BeginSDK + 5`, this `slice` call will return a slice from `BeginSDK + 5` to the end of the string, and you won't be checking for a `.sdk` prefix as you intended to.
http://reviews.llvm.org/D18088
More information about the cfe-commits
mailing list