summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2013-12-06 09:25:54 +0000
committerDaniel Jasper <djasper@google.com>2013-12-06 09:25:54 +0000
commit69e46036a391a12d2eb3149569c335ce3634bf31 (patch)
tree784b47391470aa0167449186490ec33b12c6277d /test
parent5fe64f157d3e0ff27e538b4a8f037a97387e4de1 (diff)
downloadclang-69e46036a391a12d2eb3149569c335ce3634bf31.tar.gz
Allow string literals as module names.
In order to make the migration to modules easier, it seems to be helpful to allow a 1:1 mapping between target names of a current build system and the corresponding C++ modules. As such targets commonly contain characters like "-". ":" and "/", allowing arbitrary quote-escaped strings seems to be a straightforward option. After several offline discussions, the precise mechanisms for C++ module names especially regarding submodules and import statements has yet to be determined. Thus, this patch only enables string literals as names inside the module map files which can be used by automatic module import (through #include). Also improve the error message on missing use-declarations. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@196573 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r--test/Modules/Inputs/declare-use/h.h2
-rw-r--r--test/Modules/Inputs/string_names/a.h4
-rw-r--r--test/Modules/Inputs/string_names/b.h4
-rw-r--r--test/Modules/Inputs/string_names/c.h4
-rw-r--r--test/Modules/Inputs/string_names/module.map16
-rw-r--r--test/Modules/Inputs/string_names/sub.h4
-rw-r--r--test/Modules/declare-use1.cpp2
-rw-r--r--test/Modules/declare-use2.cpp2
-rw-r--r--test/Modules/string_names.cpp6
9 files changed, 41 insertions, 3 deletions
diff --git a/test/Modules/Inputs/declare-use/h.h b/test/Modules/Inputs/declare-use/h.h
index df99a6dd10..379e50180c 100644
--- a/test/Modules/Inputs/declare-use/h.h
+++ b/test/Modules/Inputs/declare-use/h.h
@@ -1,7 +1,7 @@
#ifndef H_H
#define H_H
#include "c.h"
-#include "d.h" // expected-error {{use of a module not declared used}}
+#include "d.h" // expected-error {{does not depend on a module exporting}}
#include "h1.h"
const int h1 = aux_h*c*7*d;
#endif
diff --git a/test/Modules/Inputs/string_names/a.h b/test/Modules/Inputs/string_names/a.h
new file mode 100644
index 0000000000..a36dc1b59d
--- /dev/null
+++ b/test/Modules/Inputs/string_names/a.h
@@ -0,0 +1,4 @@
+#ifndef A_H
+#define A_H
+const int a = 2;
+#endif
diff --git a/test/Modules/Inputs/string_names/b.h b/test/Modules/Inputs/string_names/b.h
new file mode 100644
index 0000000000..55daf72868
--- /dev/null
+++ b/test/Modules/Inputs/string_names/b.h
@@ -0,0 +1,4 @@
+#ifndef B_H
+#define B_H
+const int b = 3;
+#endif
diff --git a/test/Modules/Inputs/string_names/c.h b/test/Modules/Inputs/string_names/c.h
new file mode 100644
index 0000000000..38c278fc87
--- /dev/null
+++ b/test/Modules/Inputs/string_names/c.h
@@ -0,0 +1,4 @@
+#ifndef C_H
+#define C_H
+const int c = 2;
+#endif
diff --git a/test/Modules/Inputs/string_names/module.map b/test/Modules/Inputs/string_names/module.map
new file mode 100644
index 0000000000..4e70eda399
--- /dev/null
+++ b/test/Modules/Inputs/string_names/module.map
@@ -0,0 +1,16 @@
+module "my/module-a" {
+ header "a.h"
+ use "my/module-c"
+
+ module "Sub" {
+ header "sub.h"
+ }
+}
+
+module "my/module-b" {
+ header "b.h"
+}
+
+module "my/module-c" {
+ header "c.h"
+}
diff --git a/test/Modules/Inputs/string_names/sub.h b/test/Modules/Inputs/string_names/sub.h
new file mode 100644
index 0000000000..64b9112d3e
--- /dev/null
+++ b/test/Modules/Inputs/string_names/sub.h
@@ -0,0 +1,4 @@
+#ifndef SUB_H
+#define SUB_H
+const int sub = 2;
+#endif
diff --git a/test/Modules/declare-use1.cpp b/test/Modules/declare-use1.cpp
index 4508017c12..5b344032d2 100644
--- a/test/Modules/declare-use1.cpp
+++ b/test/Modules/declare-use1.cpp
@@ -3,5 +3,5 @@
#include "g.h"
#include "e.h"
-#include "f.h" // expected-error {{use of a module not declared used}}
+#include "f.h" // expected-error {{module XG does not depend on a module exporting 'f.h'}}
const int g2 = g1+e+f;
diff --git a/test/Modules/declare-use2.cpp b/test/Modules/declare-use2.cpp
index a2ec55e5e5..15c57ca36d 100644
--- a/test/Modules/declare-use2.cpp
+++ b/test/Modules/declare-use2.cpp
@@ -3,5 +3,5 @@
#include "h.h"
#include "e.h"
-#include "f.h" // expected-error {{use of a module not declared used}}
+#include "f.h" // expected-error {{does not depend on a module exporting}}
const int h2 = h1+e+f;
diff --git a/test/Modules/string_names.cpp b/test/Modules/string_names.cpp
new file mode 100644
index 0000000000..ed65aa8a67
--- /dev/null
+++ b/test/Modules/string_names.cpp
@@ -0,0 +1,6 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules-cache-path=%t -fmodules -fmodules-decluse -I %S/Inputs/string_names %s -fmodule-name="my/module-a" -verify
+
+#include "a.h"
+#include "b.h" // expected-error {{does not depend on a module exporting}}
+#include "c.h"