From: Lawrence Crowl Date: Thu, 20 Jun 2013 21:15:51 +0000 (+0000) Subject: Test files for private header patch. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f3a0d0f3249898d89d6d0c6d2a927c5a77a01652;p=clang Test files for private header patch. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@184472 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/test/Modules/Inputs/private/common.h b/test/Modules/Inputs/private/common.h new file mode 100644 index 0000000000..17d5444b65 --- /dev/null +++ b/test/Modules/Inputs/private/common.h @@ -0,0 +1,6 @@ +#ifndef COMMON_H +#define COMMON_H + +typedef int common; + +#endif diff --git a/test/Modules/Inputs/private/module.map b/test/Modules/Inputs/private/module.map new file mode 100644 index 0000000000..9da44354be --- /dev/null +++ b/test/Modules/Inputs/private/module.map @@ -0,0 +1,9 @@ +module libPrivate1 { + header "public1.h" + private header "private1.h" +} + +module libPrivate2 { + header "public2.h" + private header "private2.h" +} diff --git a/test/Modules/Inputs/private/private1.h b/test/Modules/Inputs/private/private1.h new file mode 100644 index 0000000000..3f41cc0181 --- /dev/null +++ b/test/Modules/Inputs/private/private1.h @@ -0,0 +1,9 @@ +#ifndef PRIVATE1_H +#define PRIVATE1_H + +#include "common.h" + +struct mitts_off1 { common field; }; +struct mitts_off1 hidden_variable1; + +#endif diff --git a/test/Modules/Inputs/private/private2.h b/test/Modules/Inputs/private/private2.h new file mode 100644 index 0000000000..3b6cddc4d9 --- /dev/null +++ b/test/Modules/Inputs/private/private2.h @@ -0,0 +1,9 @@ +#ifndef PRIVATE2_H +#define PRIVATE2_H + +#include "common.h" + +struct mitts_off2 { common field; }; +struct mitts_off2 hidden_variable2; + +#endif diff --git a/test/Modules/Inputs/private/public1.h b/test/Modules/Inputs/private/public1.h new file mode 100644 index 0000000000..3af596a98d --- /dev/null +++ b/test/Modules/Inputs/private/public1.h @@ -0,0 +1,9 @@ +#ifndef PUBLIC1_H +#define PUBLIC1_H + +#include "private1.h" + +struct use_this1 { struct mitts_off1 field; }; +struct use_this1 public_variable1; + +#endif diff --git a/test/Modules/Inputs/private/public2.h b/test/Modules/Inputs/private/public2.h new file mode 100644 index 0000000000..03d0a858e1 --- /dev/null +++ b/test/Modules/Inputs/private/public2.h @@ -0,0 +1,9 @@ +#ifndef PUBLIC2_H +#define PUBLIC2_H + +#include "private2.h" + +struct use_this2 { struct mitts_off2 field; }; +struct use_this2 public_variable2; + +#endif diff --git a/test/Modules/Inputs/private0/common.h b/test/Modules/Inputs/private0/common.h new file mode 100644 index 0000000000..17d5444b65 --- /dev/null +++ b/test/Modules/Inputs/private0/common.h @@ -0,0 +1,6 @@ +#ifndef COMMON_H +#define COMMON_H + +typedef int common; + +#endif diff --git a/test/Modules/Inputs/private1/module.map b/test/Modules/Inputs/private1/module.map new file mode 100644 index 0000000000..445c8010db --- /dev/null +++ b/test/Modules/Inputs/private1/module.map @@ -0,0 +1,4 @@ +module libPrivate1 { + header "public1.h" + private header "private1.h" +} diff --git a/test/Modules/Inputs/private1/private1.h b/test/Modules/Inputs/private1/private1.h new file mode 100644 index 0000000000..3f41cc0181 --- /dev/null +++ b/test/Modules/Inputs/private1/private1.h @@ -0,0 +1,9 @@ +#ifndef PRIVATE1_H +#define PRIVATE1_H + +#include "common.h" + +struct mitts_off1 { common field; }; +struct mitts_off1 hidden_variable1; + +#endif diff --git a/test/Modules/Inputs/private1/public1.h b/test/Modules/Inputs/private1/public1.h new file mode 100644 index 0000000000..3af596a98d --- /dev/null +++ b/test/Modules/Inputs/private1/public1.h @@ -0,0 +1,9 @@ +#ifndef PUBLIC1_H +#define PUBLIC1_H + +#include "private1.h" + +struct use_this1 { struct mitts_off1 field; }; +struct use_this1 public_variable1; + +#endif diff --git a/test/Modules/Inputs/private2/module.map b/test/Modules/Inputs/private2/module.map new file mode 100644 index 0000000000..6c5efb6020 --- /dev/null +++ b/test/Modules/Inputs/private2/module.map @@ -0,0 +1,4 @@ +module libPrivate2 { + header "public2.h" + private header "private2.h" +} diff --git a/test/Modules/Inputs/private2/private2.h b/test/Modules/Inputs/private2/private2.h new file mode 100644 index 0000000000..3b6cddc4d9 --- /dev/null +++ b/test/Modules/Inputs/private2/private2.h @@ -0,0 +1,9 @@ +#ifndef PRIVATE2_H +#define PRIVATE2_H + +#include "common.h" + +struct mitts_off2 { common field; }; +struct mitts_off2 hidden_variable2; + +#endif diff --git a/test/Modules/Inputs/private2/public2.h b/test/Modules/Inputs/private2/public2.h new file mode 100644 index 0000000000..03d0a858e1 --- /dev/null +++ b/test/Modules/Inputs/private2/public2.h @@ -0,0 +1,9 @@ +#ifndef PUBLIC2_H +#define PUBLIC2_H + +#include "private2.h" + +struct use_this2 { struct mitts_off2 field; }; +struct use_this2 public_variable2; + +#endif diff --git a/test/Modules/private.cpp b/test/Modules/private.cpp new file mode 100644 index 0000000000..93b4b9457f --- /dev/null +++ b/test/Modules/private.cpp @@ -0,0 +1,13 @@ +// RUN: rm -rf %t +// RUN: %clang_cc1 -x objective-c -fmodules-cache-path=%t -fmodules -I %S/Inputs/private %s -verify + +#include "common.h" +@import libPrivate1; +#include "private1.h" // expected-error {{use of private header from outside its module}} +#include "public2.h" +#include "private2.h" // expected-error {{use of private header from outside its module}} + +struct use_this1 client_variable1; +struct use_this2 client_variable2; +struct mitts_off1 client_variable3; +struct mitts_off2 client_variable4; diff --git a/test/Modules/private1.cpp b/test/Modules/private1.cpp new file mode 100644 index 0000000000..e4eec0a515 --- /dev/null +++ b/test/Modules/private1.cpp @@ -0,0 +1,13 @@ +// RUN: rm -rf %t +// RUN: %clang_cc1 -x objective-c -fmodules-cache-path=%t -fmodules -I %S/Inputs/private0 -I %S/Inputs/private1 -I %S/Inputs/private2 %s -verify + +#include "common.h" +@import libPrivate1; +#include "private1.h" // expected-error {{use of private header from outside its module}} +#include "public2.h" +#include "private2.h" // expected-error {{use of private header from outside its module}} + +struct use_this1 client_variable1; +struct use_this2 client_variable2; +struct mitts_off1 client_variable3; +struct mitts_off2 client_variable4;