From 6fa3b742e0c77d54c7f3914f929dcac1c37a81d8 Mon Sep 17 00:00:00 2001 From: Bruno Cardoso Lopes Date: Thu, 17 Nov 2016 22:45:31 +0000 Subject: [Preprocessor] Support for '-dI' flag MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Re-introduce r285411. Implement the -dI as supported by GCC: Output ‘#include’ directives in addition to the result of preprocessing. This change aims to add this option, pass it through to the preprocessor via the options class, and when inclusions occur we output some information (+ test cases). Patch by Steve O'Brien! Differential Revision: https://reviews.llvm.org/D26089 llvm-svn: 287275 --- clang/test/Preprocessor/dump_import.h | 1 + clang/test/Preprocessor/dump_import.m | 6 ++++++ clang/test/Preprocessor/dump_include.c | 11 +++++++++++ clang/test/Preprocessor/dump_include.h | 2 ++ 4 files changed, 20 insertions(+) create mode 100644 clang/test/Preprocessor/dump_import.h create mode 100644 clang/test/Preprocessor/dump_import.m create mode 100644 clang/test/Preprocessor/dump_include.c create mode 100644 clang/test/Preprocessor/dump_include.h (limited to 'clang/test') diff --git a/clang/test/Preprocessor/dump_import.h b/clang/test/Preprocessor/dump_import.h new file mode 100644 index 00000000000..fded1e52cbb --- /dev/null +++ b/clang/test/Preprocessor/dump_import.h @@ -0,0 +1 @@ +#define DUMP_IMPORT_TESTVAL 1 diff --git a/clang/test/Preprocessor/dump_import.m b/clang/test/Preprocessor/dump_import.m new file mode 100644 index 00000000000..20424ad507b --- /dev/null +++ b/clang/test/Preprocessor/dump_import.m @@ -0,0 +1,6 @@ +// RUN: %clang_cc1 -E -dI %s -o - | FileCheck %s +// CHECK: {{^}}#import "dump_ + +// See also `dump_include.c` which tests other inclusion cases with `-dI`. + +#import "dump_import.h" diff --git a/clang/test/Preprocessor/dump_include.c b/clang/test/Preprocessor/dump_include.c new file mode 100644 index 00000000000..4d7d857d5f1 --- /dev/null +++ b/clang/test/Preprocessor/dump_include.c @@ -0,0 +1,11 @@ +// RUN: %clang_cc1 -w -E -dI -isystem %S -imacros %S/dump_include.h %s -o - | FileCheck %s +// CHECK: {{^}}#__include_macros "{{.*}}dump_ +// CHECK: {{^}}#include +#include "dump_include.h" +#include_next "dump_include.h" diff --git a/clang/test/Preprocessor/dump_include.h b/clang/test/Preprocessor/dump_include.h new file mode 100644 index 00000000000..9dafaa50b5c --- /dev/null +++ b/clang/test/Preprocessor/dump_include.h @@ -0,0 +1,2 @@ +#pragma once +#define DUMP_INCLUDE_TESTVAL 1 -- cgit v1.2.3