diff options
Diffstat (limited to 'test')
18 files changed, 72 insertions, 0 deletions
diff --git a/test/Modules/Inputs/suggest-include/empty.h b/test/Modules/Inputs/suggest-include/empty.h new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/test/Modules/Inputs/suggest-include/empty.h diff --git a/test/Modules/Inputs/suggest-include/module.modulemap b/test/Modules/Inputs/suggest-include/module.modulemap new file mode 100644 index 0000000000..46afd7b2c2 --- /dev/null +++ b/test/Modules/Inputs/suggest-include/module.modulemap @@ -0,0 +1,22 @@ +module X { + module Empty { header "empty.h" } + + exclude header "textual1.h" + textual header "textual2.h" + textual header "textual3.h" + + module A { header "usetextual1.h" } + module B { header "usetextual2.h" } + module C { header "usetextual3.h" } + module D { header "usetextual4.h" } + module E { header "usetextual5.h" } + + module P { private header "private1.h" } + module Q { private header "private2.h" } + module R { private header "private3.h" } + module S { header "useprivate1.h" export * } + module T { header "useprivate3.h" } +} + +module Other { textual header "textual4.h" } + diff --git a/test/Modules/Inputs/suggest-include/private1.h b/test/Modules/Inputs/suggest-include/private1.h new file mode 100644 index 0000000000..afc7ac71bb --- /dev/null +++ b/test/Modules/Inputs/suggest-include/private1.h @@ -0,0 +1 @@ +extern int private1; diff --git a/test/Modules/Inputs/suggest-include/private2.h b/test/Modules/Inputs/suggest-include/private2.h new file mode 100644 index 0000000000..24a1893d31 --- /dev/null +++ b/test/Modules/Inputs/suggest-include/private2.h @@ -0,0 +1 @@ +extern int private2; diff --git a/test/Modules/Inputs/suggest-include/private3.h b/test/Modules/Inputs/suggest-include/private3.h new file mode 100644 index 0000000000..26852af2a6 --- /dev/null +++ b/test/Modules/Inputs/suggest-include/private3.h @@ -0,0 +1 @@ +extern int private3; diff --git a/test/Modules/Inputs/suggest-include/textual1.h b/test/Modules/Inputs/suggest-include/textual1.h new file mode 100644 index 0000000000..5b18bfb368 --- /dev/null +++ b/test/Modules/Inputs/suggest-include/textual1.h @@ -0,0 +1 @@ +#define FOO(X) X diff --git a/test/Modules/Inputs/suggest-include/textual2.h b/test/Modules/Inputs/suggest-include/textual2.h new file mode 100644 index 0000000000..0c06d4ea45 --- /dev/null +++ b/test/Modules/Inputs/suggest-include/textual2.h @@ -0,0 +1 @@ +EXPAND_MACRO diff --git a/test/Modules/Inputs/suggest-include/textual3.h b/test/Modules/Inputs/suggest-include/textual3.h new file mode 100644 index 0000000000..1e52521161 --- /dev/null +++ b/test/Modules/Inputs/suggest-include/textual3.h @@ -0,0 +1 @@ +extern int textual3; diff --git a/test/Modules/Inputs/suggest-include/textual4.h b/test/Modules/Inputs/suggest-include/textual4.h new file mode 100644 index 0000000000..091e0c0ac1 --- /dev/null +++ b/test/Modules/Inputs/suggest-include/textual4.h @@ -0,0 +1 @@ +extern int textual4; diff --git a/test/Modules/Inputs/suggest-include/textual5.h b/test/Modules/Inputs/suggest-include/textual5.h new file mode 100644 index 0000000000..d808617d50 --- /dev/null +++ b/test/Modules/Inputs/suggest-include/textual5.h @@ -0,0 +1 @@ +extern int textual5; diff --git a/test/Modules/Inputs/suggest-include/useprivate1.h b/test/Modules/Inputs/suggest-include/useprivate1.h new file mode 100644 index 0000000000..817b900ecc --- /dev/null +++ b/test/Modules/Inputs/suggest-include/useprivate1.h @@ -0,0 +1 @@ +#include "private1.h" diff --git a/test/Modules/Inputs/suggest-include/useprivate3.h b/test/Modules/Inputs/suggest-include/useprivate3.h new file mode 100644 index 0000000000..5d5d221b87 --- /dev/null +++ b/test/Modules/Inputs/suggest-include/useprivate3.h @@ -0,0 +1 @@ +#include "private3.h" diff --git a/test/Modules/Inputs/suggest-include/usetextual1.h b/test/Modules/Inputs/suggest-include/usetextual1.h new file mode 100644 index 0000000000..34ab1c76bc --- /dev/null +++ b/test/Modules/Inputs/suggest-include/usetextual1.h @@ -0,0 +1,2 @@ +#include "textual1.h" +FOO(extern int usetextual1;) diff --git a/test/Modules/Inputs/suggest-include/usetextual2.h b/test/Modules/Inputs/suggest-include/usetextual2.h new file mode 100644 index 0000000000..95b2445736 --- /dev/null +++ b/test/Modules/Inputs/suggest-include/usetextual2.h @@ -0,0 +1,2 @@ +#define EXPAND_MACRO extern int usetextual2; +#include "textual2.h" diff --git a/test/Modules/Inputs/suggest-include/usetextual3.h b/test/Modules/Inputs/suggest-include/usetextual3.h new file mode 100644 index 0000000000..15a75cc839 --- /dev/null +++ b/test/Modules/Inputs/suggest-include/usetextual3.h @@ -0,0 +1 @@ +#include "textual3.h" diff --git a/test/Modules/Inputs/suggest-include/usetextual4.h b/test/Modules/Inputs/suggest-include/usetextual4.h new file mode 100644 index 0000000000..395bb6fd65 --- /dev/null +++ b/test/Modules/Inputs/suggest-include/usetextual4.h @@ -0,0 +1 @@ +#include "textual4.h" diff --git a/test/Modules/Inputs/suggest-include/usetextual5.h b/test/Modules/Inputs/suggest-include/usetextual5.h new file mode 100644 index 0000000000..a7335d37ae --- /dev/null +++ b/test/Modules/Inputs/suggest-include/usetextual5.h @@ -0,0 +1 @@ +#include "textual5.h" diff --git a/test/Modules/suggest-include.cpp b/test/Modules/suggest-include.cpp new file mode 100644 index 0000000000..e10c3f38ab --- /dev/null +++ b/test/Modules/suggest-include.cpp @@ -0,0 +1,33 @@ +// RUN: rm -rf %t +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fimplicit-module-maps -I%S/Inputs/suggest-include %s -verify + +#include "empty.h" // import the module file + +// expected-note@usetextual1.h:2 {{previous}} +// expected-note@textual2.h:1 {{previous}} +// expected-note@textual3.h:1 {{previous}} +// expected-note@textual4.h:1 {{previous}} +// expected-note@textual5.h:1 {{previous}} +// expected-note@private1.h:1 {{previous}} +// expected-note@private2.h:1 {{previous}} +// expected-note@private3.h:1 {{previous}} + +void f() { + (void)::usetextual1; // expected-error {{missing '#include "usetextual1.h"'}} + (void)::usetextual2; // expected-error {{missing '#include "usetextual2.h"'}} + (void)::textual3; // expected-error-re {{{{^}}missing '#include "usetextual3.h"'}} + // Don't suggest a #include that includes the entity via a path that leaves + // the module. In that case we can't be sure that we've picked the right header. + (void)::textual4; // expected-error-re {{{{^}}declaration of 'textual4'}} + (void)::textual5; // expected-error-re {{{{^}}declaration of 'textual5'}} + + // Don't suggest #including a private header. + // FIXME: We could suggest including "useprivate1.h" here, as it's the only + // public way to get at this declaration. + (void)::private1; // expected-error-re {{{{^}}declaration of 'private1'}} + // FIXME: Should we be suggesting an import at all here? Should declarations + // in private headers be visible when the surrounding module is imported? + (void)::private2; // expected-error-re {{{{^}}declaration of 'private2'}} + // Even if we suggest an include for private1, we should not do so here. + (void)::private3; // expected-error-re {{{{^}}declaration of 'private3'}} +} |