summaryrefslogtreecommitdiff
path: root/test/Modules/suggest-include.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2016-04-27 21:57:05 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2016-04-27 21:57:05 +0000
commitd8ee96875e9a7d44f9d245763263738d2d210193 (patch)
treed227d860b57e76391abee91d5a37c0339af77756 /test/Modules/suggest-include.cpp
parent2febae03d5882461aa754ec7ae5fa764acbe3478 (diff)
downloadclang-d8ee96875e9a7d44f9d245763263738d2d210193.tar.gz
[modules] When diagnosing a missing module import, suggest adding a #include if
the current language doesn't have an import syntax and we can figure out a suitable file to include. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@267802 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Modules/suggest-include.cpp')
-rw-r--r--test/Modules/suggest-include.cpp33
1 files changed, 33 insertions, 0 deletions
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'}}
+}