diff options
author | David Blaikie <dblaikie@gmail.com> | 2012-06-06 18:52:13 +0000 |
---|---|---|
committer | David Blaikie <dblaikie@gmail.com> | 2012-06-06 18:52:13 +0000 |
commit | 8c0b3787e7ccc7978b42dfbb84da2b802c743a5d (patch) | |
tree | e336113d6242ee1e318912bea56957a9b3a6d617 /test/Frontend | |
parent | 80d7c52653800d3338cca2c4388348010d2b1921 (diff) |
Add a -rewrite-includes option, which is similar to -rewrite-macros, but only expands #include directives.
Patch contributed by Lubos Lunak (l.lunax@suse.cz).
Review by Matt Beaumont-Gay (matthewbg@google.com).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158093 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Frontend')
-rw-r--r-- | test/Frontend/Inputs/rewrite-includes1.h | 3 | ||||
-rw-r--r-- | test/Frontend/Inputs/rewrite-includes2.h | 1 | ||||
-rw-r--r-- | test/Frontend/Inputs/rewrite-includes3.h | 1 | ||||
-rw-r--r-- | test/Frontend/Inputs/rewrite-includes4.h | 1 | ||||
-rw-r--r-- | test/Frontend/Inputs/rewrite-includes5.h | 1 | ||||
-rw-r--r-- | test/Frontend/Inputs/rewrite-includes6.h | 2 | ||||
-rw-r--r-- | test/Frontend/Inputs/rewrite-includes7.h | 4 | ||||
-rw-r--r-- | test/Frontend/rewrite-includes.c | 145 |
8 files changed, 158 insertions, 0 deletions
diff --git a/test/Frontend/Inputs/rewrite-includes1.h b/test/Frontend/Inputs/rewrite-includes1.h new file mode 100644 index 0000000000..1b6c80d5f4 --- /dev/null +++ b/test/Frontend/Inputs/rewrite-includes1.h @@ -0,0 +1,3 @@ +#pragma clang system_header +included_line1 +#include "rewrite-includes2.h" diff --git a/test/Frontend/Inputs/rewrite-includes2.h b/test/Frontend/Inputs/rewrite-includes2.h new file mode 100644 index 0000000000..1114e51cc1 --- /dev/null +++ b/test/Frontend/Inputs/rewrite-includes2.h @@ -0,0 +1 @@ +included_line2 diff --git a/test/Frontend/Inputs/rewrite-includes3.h b/test/Frontend/Inputs/rewrite-includes3.h new file mode 100644 index 0000000000..3757bc8b34 --- /dev/null +++ b/test/Frontend/Inputs/rewrite-includes3.h @@ -0,0 +1 @@ +included_line3 diff --git a/test/Frontend/Inputs/rewrite-includes4.h b/test/Frontend/Inputs/rewrite-includes4.h new file mode 100644 index 0000000000..b4e25d26f6 --- /dev/null +++ b/test/Frontend/Inputs/rewrite-includes4.h @@ -0,0 +1 @@ +included_line4 diff --git a/test/Frontend/Inputs/rewrite-includes5.h b/test/Frontend/Inputs/rewrite-includes5.h new file mode 100644 index 0000000000..934bf413e5 --- /dev/null +++ b/test/Frontend/Inputs/rewrite-includes5.h @@ -0,0 +1 @@ +included_line5 diff --git a/test/Frontend/Inputs/rewrite-includes6.h b/test/Frontend/Inputs/rewrite-includes6.h new file mode 100644 index 0000000000..c18e5013af --- /dev/null +++ b/test/Frontend/Inputs/rewrite-includes6.h @@ -0,0 +1,2 @@ +#pragma once +included_line6 diff --git a/test/Frontend/Inputs/rewrite-includes7.h b/test/Frontend/Inputs/rewrite-includes7.h new file mode 100644 index 0000000000..da00d4fb97 --- /dev/null +++ b/test/Frontend/Inputs/rewrite-includes7.h @@ -0,0 +1,4 @@ +#ifndef REWRITE_INCLUDES_7 +#define REWRITE_INCLUDES_7 +included_line7 +#endif diff --git a/test/Frontend/rewrite-includes.c b/test/Frontend/rewrite-includes.c new file mode 100644 index 0000000000..58d82ab407 --- /dev/null +++ b/test/Frontend/rewrite-includes.c @@ -0,0 +1,145 @@ +// RUN: %clang_cc1 -verify -rewrite-includes -DFIRST -I %S/Inputs %s -o - | FileCheck -strict-whitespace %s +// RUN: %clang_cc1 -verify -rewrite-includes -P -DFIRST -I %S/Inputs %s -o - | FileCheck -check-prefix=CHECKNL -strict-whitespace %s +// STARTCOMPARE +#define A(a,b) a ## b +A(1,2) +#include "rewrite-includes1.h" +#ifdef FIRST +#define HEADER "rewrite-includes3.h" +#include HEADER +#else +#include "rewrite-includes4.h" +#endif +#/**/include /**/ "rewrite-includes5.h" /**/ \ + +#include "rewrite-includes6.h" // comment + +#include "rewrite-includes6.h" /* comment + continues */ +#include "rewrite-includes7.h" +#include "rewrite-includes7.h" +// ENDCOMPARE +// CHECK: {{^}}// STARTCOMPARE{{$}} +// CHECK-NEXT: {{^}}#define A(a,b) a ## b{{$}} +// CHECK-NEXT: {{^}}A(1,2){{$}} +// CHECK-NEXT: {{^}}#if 0 /* expanded by -rewrite-includes */{{$}} +// CHECK-NEXT: {{^}}#include "rewrite-includes1.h"{{$}} +// CHECK-NEXT: {{^}}#endif /* expanded by -rewrite-includes */{{$}} +// CHECK-NEXT: {{^}}# 1 "{{.*}}/Inputs/rewrite-includes1.h" 1{{$}} +// CHECK-NEXT: {{^}}#if 0 /* expanded by -rewrite-includes */{{$}} +// CHECK-NEXT: {{^}}#pragma clang system_header{{$}} +// CHECK-NEXT: {{^}}#endif /* expanded by -rewrite-includes */{{$}} +// CHECK-NEXT: {{^}}# 2 "{{.*}}/Inputs/rewrite-includes1.h" 3{{$}} +// CHECK-NEXT: {{^}}included_line1{{$}} +// CHECK-NEXT: {{^}}#if 0 /* expanded by -rewrite-includes */{{$}} +// CHECK-NEXT: {{^}}#include "rewrite-includes2.h"{{$}} +// CHECK-NEXT: {{^}}#endif /* expanded by -rewrite-includes */{{$}} +// CHECK-NEXT: {{^}}# 1 "{{.*}}/Inputs/rewrite-includes2.h" 1 3{{$}} +// CHECK-NEXT: {{^}}included_line2{{$}} +// CHECK-NEXT: {{^}}# 4 "{{.*}}/Inputs/rewrite-includes1.h" 2 3{{$}} +// CHECK-NEXT: {{^}}# 7 "{{.*}}rewrite-includes.c" 2{{$}} +// CHECK-NEXT: {{^}}#ifdef FIRST{{$}} +// CHECK-NEXT: {{^}}#define HEADER "rewrite-includes3.h"{{$}} +// CHECK-NEXT: {{^}}#if 0 /* expanded by -rewrite-includes */{{$}} +// CHECK-NEXT: {{^}}#include HEADER{{$}} +// CHECK-NEXT: {{^}}#endif /* expanded by -rewrite-includes */{{$}} +// CHECK-NEXT: {{^}}# 1 "{{.*}}/Inputs/rewrite-includes3.h" 1{{$}} +// CHECK-NEXT: {{^}}included_line3{{$}} +// CHECK-NEXT: {{^}}# 10 "{{.*}}rewrite-includes.c" 2{{$}} +// CHECK-NEXT: {{^}}#else{{$}} +// CHECK-NEXT: {{^}}#if 0 /* expanded by -rewrite-includes */{{$}} +// CHECK-NEXT: {{^}}#include "rewrite-includes4.h"{{$}} +// CHECK-NEXT: {{^}}#endif /* expanded by -rewrite-includes */{{$}} +// CHECK-NEXT: {{^}}# 12 "{{.*}}rewrite-includes.c"{{$}} +// CHECK-NEXT: {{^}}#endif{{$}} +// CHECK-NEXT: {{^}}#if 0 /* expanded by -rewrite-includes */{{$}} +// CHECK-NEXT: {{^}}#/**/include /**/ "rewrite-includes5.h" /**/ {{\\}}{{$}} +// CHECK-NEXT: {{^}} {{$}} +// CHECK-NEXT: {{^}}#endif /* expanded by -rewrite-includes */{{$}} +// CHECK-NEXT: {{^}}# 1 "{{.*}}/Inputs/rewrite-includes5.h" 1{{$}} +// CHECK-NEXT: {{^}}included_line5{{$}} +// CHECK-NEXT: {{^}}# 15 "{{.*}}rewrite-includes.c" 2{{$}} +// CHECK-NEXT: {{^}}#if 0 /* expanded by -rewrite-includes */{{$}} +// CHECK-NEXT: {{^}}#include "rewrite-includes6.h" // comment{{$}} +// CHECK-NEXT: {{^}}#endif /* expanded by -rewrite-includes */{{$}} +// CHECK-NEXT: {{^}}# 1 "{{.*}}/Inputs/rewrite-includes6.h" 1{{$}} +// CHECK-NEXT: {{^}}#if 0 /* expanded by -rewrite-includes */{{$}} +// CHECK-NEXT: {{^}}#pragma once{{$}} +// CHECK-NEXT: {{^}}#endif /* expanded by -rewrite-includes */{{$}} +// CHECK-NEXT: {{^}}# 2 "{{.*}}/Inputs/rewrite-includes6.h"{{$}} +// CHECK-NEXT: {{^}}included_line6{{$}} +// CHECK-NEXT: {{^}}# 16 "{{.*}}rewrite-includes.c" 2{{$}} +// CHECK-NEXT: {{^}} {{$}} +// CHECK-NEXT: {{^}}#if 0 /* expanded by -rewrite-includes */{{$}} +// CHECK-NEXT: {{^}}#include "rewrite-includes6.h" /* comment{{$}} +// CHECK-NEXT: {{^}} continues */{{$}} +// CHECK-NEXT: {{^}}#endif /* expanded by -rewrite-includes */{{$}} +// CHECK-NEXT: {{^}}# 19 "{{.*}}rewrite-includes.c"{{$}} +// CHECK-NEXT: {{^}}#if 0 /* expanded by -rewrite-includes */{{$}} +// CHECK-NEXT: {{^}}#include "rewrite-includes7.h"{{$}} +// CHECK-NEXT: {{^}}#endif /* expanded by -rewrite-includes */{{$}} +// CHECK-NEXT: {{^}}# 1 "{{.*}}/Inputs/rewrite-includes7.h" 1{{$}} +// CHECK-NEXT: {{^}}#ifndef REWRITE_INCLUDES_7{{$}} +// CHECK-NEXT: {{^}}#define REWRITE_INCLUDES_7{{$}} +// CHECK-NEXT: {{^}}included_line7{{$}} +// CHECK-NEXT: {{^}}#endif{{$}} +// CHECK-NEXT: {{^}}# 20 "{{.*}}rewrite-includes.c" 2{{$}} +// CHECK-NEXT: {{^}}#if 0 /* expanded by -rewrite-includes */{{$}} +// CHECK-NEXT: {{^}}#include "rewrite-includes7.h"{{$}} +// CHECK-NEXT: {{^}}#endif /* expanded by -rewrite-includes */{{$}} +// CHECK-NEXT: {{^}}# 21 "{{.*}}rewrite-includes.c"{{$}} +// CHECK-NEXT: {{^}}// ENDCOMPARE{{$}} + +// CHECKNL: {{^}}// STARTCOMPARE{{$}} +// CHECKNL-NEXT: {{^}}#define A(a,b) a ## b{{$}} +// CHECKNL-NEXT: {{^}}A(1,2){{$}} +// CHECKNL-NEXT: {{^}}#if 0 /* expanded by -rewrite-includes */{{$}} +// CHECKNL-NEXT: {{^}}#include "rewrite-includes1.h"{{$}} +// CHECKNL-NEXT: {{^}}#endif /* expanded by -rewrite-includes */{{$}} +// CHECKNL-NEXT: {{^}}#if 0 /* expanded by -rewrite-includes */{{$}} +// CHECKNL-NEXT: {{^}}#pragma clang system_header{{$}} +// CHECKNL-NEXT: {{^}}#endif /* expanded by -rewrite-includes */{{$}} +// CHECKNL-NEXT: {{^}}included_line1{{$}} +// CHECKNL-NEXT: {{^}}#if 0 /* expanded by -rewrite-includes */{{$}} +// CHECKNL-NEXT: {{^}}#include "rewrite-includes2.h"{{$}} +// CHECKNL-NEXT: {{^}}#endif /* expanded by -rewrite-includes */{{$}} +// CHECKNL-NEXT: {{^}}included_line2{{$}} +// CHECKNL-NEXT: {{^}}#ifdef FIRST{{$}} +// CHECKNL-NEXT: {{^}}#define HEADER "rewrite-includes3.h"{{$}} +// CHECKNL-NEXT: {{^}}#if 0 /* expanded by -rewrite-includes */{{$}} +// CHECKNL-NEXT: {{^}}#include HEADER{{$}} +// CHECKNL-NEXT: {{^}}#endif /* expanded by -rewrite-includes */{{$}} +// CHECKNL-NEXT: {{^}}included_line3{{$}} +// CHECKNL-NEXT: {{^}}#else{{$}} +// CHECKNL-NEXT: {{^}}#if 0 /* expanded by -rewrite-includes */{{$}} +// CHECKNL-NEXT: {{^}}#include "rewrite-includes4.h"{{$}} +// CHECKNL-NEXT: {{^}}#endif /* expanded by -rewrite-includes */{{$}} +// CHECKNL-NEXT: {{^}}#endif{{$}} +// CHECKNL-NEXT: {{^}}#if 0 /* expanded by -rewrite-includes */{{$}} +// CHECKNL-NEXT: {{^}}#/**/include /**/ "rewrite-includes5.h" /**/ {{\\}}{{$}} +// CHECKNL-NEXT: {{^}} {{$}} +// CHECKNL-NEXT: {{^}}#endif /* expanded by -rewrite-includes */{{$}} +// CHECKNL-NEXT: {{^}}included_line5{{$}} +// CHECKNL-NEXT: {{^}}#if 0 /* expanded by -rewrite-includes */{{$}} +// CHECKNL-NEXT: {{^}}#include "rewrite-includes6.h" // comment{{$}} +// CHECKNL-NEXT: {{^}}#endif /* expanded by -rewrite-includes */{{$}} +// CHECKNL-NEXT: {{^}}#if 0 /* expanded by -rewrite-includes */{{$}} +// CHECKNL-NEXT: {{^}}#pragma once{{$}} +// CHECKNL-NEXT: {{^}}#endif /* expanded by -rewrite-includes */{{$}} +// CHECKNL-NEXT: {{^}}included_line6{{$}} +// CHECKNL-NEXT: {{^}} {{$}} +// CHECKNL-NEXT: {{^}}#if 0 /* expanded by -rewrite-includes */{{$}} +// CHECKNL-NEXT: {{^}}#include "rewrite-includes6.h" /* comment{{$}} +// CHECKNL-NEXT: {{^}} continues */{{$}} +// CHECKNL-NEXT: {{^}}#endif /* expanded by -rewrite-includes */{{$}} +// CHECKNL-NEXT: {{^}}#if 0 /* expanded by -rewrite-includes */{{$}} +// CHECKNL-NEXT: {{^}}#include "rewrite-includes7.h"{{$}} +// CHECKNL-NEXT: {{^}}#endif /* expanded by -rewrite-includes */{{$}} +// CHECKNL-NEXT: {{^}}#ifndef REWRITE_INCLUDES_7{{$}} +// CHECKNL-NEXT: {{^}}#define REWRITE_INCLUDES_7{{$}} +// CHECKNL-NEXT: {{^}}included_line7{{$}} +// CHECKNL-NEXT: {{^}}#endif{{$}} +// CHECKNL-NEXT: {{^}}#if 0 /* expanded by -rewrite-includes */{{$}} +// CHECKNL-NEXT: {{^}}#include "rewrite-includes7.h"{{$}} +// CHECKNL-NEXT: {{^}}#endif /* expanded by -rewrite-includes */{{$}} +// CHECKNL-NEXT: {{^}}// ENDCOMPARE{{$}} |