[PATCH] D18088: Add a new warning to notify users of mismatched SDK and deployment target

Bob Wilson via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 15 16:16:27 PDT 2016


bob.wilson added a comment.

This is a good idea overall. See comments.


================
Comment at: include/clang/Basic/DiagnosticDriverKinds.td:198
@@ -197,2 +197,3 @@
   InGroup<DiagGroup<"missing-sysroot">>;
+def warn_incompatible_sdk : Warning<"using SDK for '%0' but deploying to '%1'">;
 def warn_debug_compression_unavailable : Warning<"cannot compress debug sections (zlib not installed)">,
----------------
Instead of the driver option, you should add this to the diagnostic: InGroup<DiagGroup<"incompatible-sdk">>

================
Comment at: include/clang/Driver/Options.td:1090
@@ -1089,1 +1089,3 @@
 def Wframe_larger_than_EQ : Joined<["-"], "Wframe-larger-than=">, Group<f_Group>, Flags<[DriverOption]>;
+def Wincompatible_sdk : Flag<["-"], "Wincompatible-sdk">, Group<f_Group>,
+  Flags<[DriverOption]>;
----------------
You should not need to add this option. See above.

================
Comment at: lib/Driver/ToolChains.cpp:333
@@ +332,3 @@
+StringRef Darwin::getPlatformFamily() const {
+  switch(TargetPlatform) {
+  case DarwinPlatformKind::MacOS:
----------------
Please add a space before the open paren.

================
Comment at: lib/Driver/ToolChains.cpp:742
@@ +741,3 @@
+
+  if(Args.hasArg(options::OPT_Wincompatible_sdk)) {
+    if (const Arg *A = Args.getLastArg(options::OPT_isysroot)) {
----------------
Please add a space before the open paren.

================
Comment at: lib/Driver/ToolChains.cpp:750
@@ +749,3 @@
+        StringRef SDK = isysroot.slice(BeginSDK + 5, EndSDK);
+        if(!SDK.startswith(getPlatformFamily()))
+          getDriver().Diag(diag::warn_incompatible_sdk) << SDK
----------------
Please add a space before the open paren. You should run the patch through clang-format since you have several formatting issues.


http://reviews.llvm.org/D18088





More information about the cfe-commits mailing list