[PATCH] D23905: [Modules] Add 'gnuinlineasm' to the 'requires-declaration' feature-list.

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 25 21:52:07 PDT 2016


On 25 Aug 2016 7:37 p.m., "Bruno Cardoso Lopes" <bruno.cardoso at gmail.com>
wrote:

bruno created this revision.
bruno added a reviewer: rsmith.
bruno added subscribers: cfe-commits, eladcohen.

This adds support for modules that require (no-)gnu-inline-asm
environment, such as the compiler builtin cpuid submodule.

This is the gnu-inline-asm variant of https://reviews.llvm.org/D23871

https://reviews.llvm.org/D23905

Files:
  docs/Modules.rst
  lib/Basic/Module.cpp
  lib/Headers/module.modulemap
  test/Modules/Inputs/GNUAsm/NeedsGNUAsmInline.framework/
Headers/NeedsGNUAsmInline.h
  test/Modules/Inputs/GNUAsm/NeedsGNUAsmInline.framework/Headers/asm.h
  test/Modules/Inputs/GNUAsm/NeedsGNUAsmInline.framework/module.map
  test/Modules/requires-gnuasminline.m

Index: test/Modules/requires-gnuasminline.m
===================================================================
--- /dev/null
+++ test/Modules/requires-gnuasminline.m
@@ -0,0 +1,6 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -Wauto-import -fmodules-cache-path=%t -fmodules \
+// RUN:     -fimplicit-module-maps -F %S/Inputs/GNUAsm %s \
+// RUN:     -fno-gnu-inline-asm -verify
+
+ at import NeedsGNUAsmInline.Asm; // expected-error{{module
'NeedsGNUAsmInline.Asm' requires feature 'gnuasminline'}}


You should add a positive test for the case where inline asm is available,
too...

Index: test/Modules/Inputs/GNUAsm/NeedsGNUAsmInline.framework/module.map
===================================================================
--- /dev/null
+++ test/Modules/Inputs/GNUAsm/NeedsGNUAsmInline.framework/module.map
@@ -0,0 +1,8 @@
+framework module NeedsGNUAsmInline {
+  header "NeedsGNUAsmInline.h"
+
+  explicit module Asm {
+    requires gnuasminline


... that way, you'd catch this typo in the test :)

+    header "asm.h"
+  }
+}
Index: test/Modules/Inputs/GNUAsm/NeedsGNUAsmInline.framework/Headers/asm.h
===================================================================
--- /dev/null
+++ test/Modules/Inputs/GNUAsm/NeedsGNUAsmInline.framework/Headers/asm.h
@@ -0,0 +1 @@
+__asm("foo");
Index: test/Modules/Inputs/GNUAsm/NeedsGNUAsmInline.framework/
Headers/NeedsGNUAsmInline.h
===================================================================
--- /dev/null
+++ test/Modules/Inputs/GNUAsm/NeedsGNUAsmInline.framework/
Headers/NeedsGNUAsmInline.h
@@ -0,0 +1 @@
+// NeedsGNUAsmInline.h
Index: lib/Headers/module.modulemap
===================================================================
--- lib/Headers/module.modulemap
+++ lib/Headers/module.modulemap
@@ -68,6 +68,7 @@
     }

     explicit module cpuid {
+      requires gnuinlineasm
       header "cpuid.h"
     }

Index: lib/Basic/Module.cpp
===================================================================
--- lib/Basic/Module.cpp
+++ lib/Basic/Module.cpp
@@ -64,6 +64,7 @@
                         .Case("blocks", LangOpts.Blocks)
                         .Case("cplusplus", LangOpts.CPlusPlus)
                         .Case("cplusplus11", LangOpts.CPlusPlus11)
+                        .Case("gnuinlineasm", LangOpts.GNUAsm)
                         .Case("objc", LangOpts.ObjC1)
                         .Case("objc_arc", LangOpts.ObjCAutoRefCount)
                         .Case("opencl", LangOpts.OpenCL)
Index: docs/Modules.rst
===================================================================
--- docs/Modules.rst
+++ docs/Modules.rst
@@ -413,6 +413,9 @@
 cplusplus11
   C++11 support is available.

+gnuinlineasm
+  GNU inline ASM is available.
+
 objc
   Objective-C support is available.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160825/cf66789e/attachment.html>


More information about the cfe-commits mailing list