]> granicus.if.org Git - clang/commitdiff
Add __has_feature(modules) to indicate when modules are available (in
authorDouglas Gregor <dgregor@apple.com>
Wed, 4 Jan 2012 21:16:09 +0000 (21:16 +0000)
committerDouglas Gregor <dgregor@apple.com>
Wed, 4 Jan 2012 21:16:09 +0000 (21:16 +0000)
any language variant), and restrict __has_feature(objc_modules) to
mean that we also have the Objective-C @import syntax. I anticipate
__has_feature(cxx_modules) and/or __has_feature(c_modules) for when we
nail down the module syntax for C/C++.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147548 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Lex/PPMacroExpansion.cpp
test/Lexer/has_feature_modules.m

index e93dc1560d8d4cb28de0bb0d5c6b8f130f9e9d82..76962e4dd7ad8c76f571a15b3b633811357c3365 100644 (file)
@@ -617,7 +617,7 @@ static bool HasFeature(const Preprocessor &PP, const IdentifierInfo *II) {
                  LangOpts.ObjCRuntimeHasWeak)
            .Case("objc_fixed_enum", LangOpts.ObjC2)
            .Case("objc_instancetype", LangOpts.ObjC2)
-           .Case("objc_modules", LangOpts.Modules)
+           .Case("objc_modules", LangOpts.ObjC2 && LangOpts.Modules)
            .Case("objc_nonfragile_abi", LangOpts.ObjCNonFragileABI)
            .Case("objc_weak_class", LangOpts.ObjCNonFragileABI)
            .Case("ownership_holds", true)
@@ -698,6 +698,7 @@ static bool HasFeature(const Preprocessor &PP, const IdentifierInfo *II) {
            .Case("is_trivial", LangOpts.CPlusPlus)
            .Case("is_trivially_copyable", LangOpts.CPlusPlus)
            .Case("is_union", LangOpts.CPlusPlus)
+           .Case("modules", LangOpts.Modules)
            .Case("tls", PP.getTargetInfo().isTLSSupported())
            .Case("underlying_type", LangOpts.CPlusPlus)
            .Default(false);
index ec4d507fcb52d45115b3aad14b872a5a12b2729a..6cea3246892ad174cb316658d0d5e1c71f6d3f6c 100644 (file)
@@ -1,7 +1,12 @@
+// RUN: %clang_cc1 -E -fmodules %s -o - | FileCheck --check-prefix=CHECK-HAS-OBJC-MODULES %s
+// RUN: %clang_cc1 -E %s -o - | FileCheck --check-prefix=CHECK-NO-OBJC-MODULES %s
+// RUN: %clang_cc1 -E -x c -fmodules %s -o - | FileCheck --check-prefix=CHECK-NO-OBJC-MODULES %s
+
 // RUN: %clang_cc1 -E -fmodules %s -o - | FileCheck --check-prefix=CHECK-HAS-MODULES %s
 // RUN: %clang_cc1 -E %s -o - | FileCheck --check-prefix=CHECK-NO-MODULES %s
+// RUN: %clang_cc1 -E -x c -fmodules %s -o - | FileCheck --check-prefix=CHECK-HAS-MODULES %s
 
-#if __has_feature(objc_modules)
+#if __has_feature(modules)
 int has_modules();
 #else
 int no_modules();
@@ -9,3 +14,12 @@ int no_modules();
 
 // CHECK-HAS-MODULES: has_modules
 // CHECK-NO-MODULES: no_modules
+
+#if __has_feature(objc_modules)
+int has_objc_modules();
+#else
+int no_objc_modules();
+#endif
+
+// CHECK-HAS-OBJC-MODULES: has_objc_modules
+// CHECK-NO-OBJC-MODULES: no_objc_modules