mirror of
https://github.com/boostorg/wave.git
synced 2026-01-19 04:42:16 +00:00
Emit line directives for includes with directive on first line (#223)
* Emit line directives for includes with directive on first line * Add nested include tests Thanks to Nick Nobles for this bug report and fix
This commit is contained in:
@@ -1578,9 +1578,9 @@ pp_iterator_functor<ContextT>::on_include_helper(char const* f, char const* s,
|
||||
char const* current_name = 0; // never try to match current file name
|
||||
#endif
|
||||
|
||||
// call the 'found_include_directive' hook function
|
||||
// call the 'found_include_directive' hook function
|
||||
if (ctx.get_hooks().found_include_directive(ctx.derived(), f, include_next))
|
||||
return true; // client returned false: skip file to include
|
||||
return true; // client returned true: skip file to include
|
||||
|
||||
file_path = util::impl::unescape_lit(file_path);
|
||||
std::string native_path_str;
|
||||
@@ -1607,6 +1607,7 @@ pp_iterator_functor<ContextT>::on_include_helper(char const* f, char const* s,
|
||||
boost::wave::enable_prefer_pp_numbers(ctx.get_language()),
|
||||
is_system ? base_iteration_context_type::system_header :
|
||||
base_iteration_context_type::user_header));
|
||||
new_iter_ctx->emitted_lines = (unsigned int)(-1); // force #line directive
|
||||
|
||||
// call the include policy trace function
|
||||
ctx.get_hooks().opened_include_file(ctx.derived(), dir_path, file_path,
|
||||
|
||||
74
test/testwave/testfiles/t_5_040.cpp
Normal file
74
test/testwave/testfiles/t_5_040.cpp
Normal file
@@ -0,0 +1,74 @@
|
||||
/*=============================================================================
|
||||
Boost.Wave: A Standard compliant C++ preprocessor library
|
||||
http://www.boost.org/
|
||||
|
||||
Copyright (c) 2024 Nick Nobles. Distributed under the Boost
|
||||
Software License, Version 1.0. (See accompanying file
|
||||
LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
=============================================================================*/
|
||||
|
||||
// Line directives should be emitted for included files when they begin
|
||||
// with a single #if/#ifdef/#define directive. Addresses github issue #222.
|
||||
#include "t_5_040_001.hpp" // #if as first line should emit line directive
|
||||
#include "t_5_040_002.hpp" // #define as first line should emit line directive
|
||||
#include "t_5_040_003.hpp" // ensure nested includes emit line directive
|
||||
#include "t_5_040_005.hpp" // ensure empty initial lines produce line directive
|
||||
|
||||
t_5_040_a
|
||||
#if 1
|
||||
t_5_040_b
|
||||
#endif
|
||||
|
||||
//R #line 2 "t_5_040_001.hpp"
|
||||
//R t_5_040_001a
|
||||
//R #line 6 "t_5_040_001.hpp"
|
||||
//R t_5_040_001b
|
||||
//R
|
||||
//R t_5_040_001c
|
||||
//R #line 2 "t_5_040_002.hpp"
|
||||
//R t_5_040_002
|
||||
//R #line 2 "t_5_040_004.hpp"
|
||||
//R t_5_040_004
|
||||
//R #line 2 "t_5_040_003.hpp"
|
||||
//R t_5_040_003
|
||||
//R #line 15 "t_5_040_005.hpp"
|
||||
//R t_5_040_005
|
||||
//R #line 17 "t_5_040.cpp"
|
||||
//R t_5_040_a
|
||||
//R
|
||||
//R t_5_040_b
|
||||
|
||||
//H 10: t_5_040.cpp(12): #include "t_5_040_001.hpp"
|
||||
//H 04: "t_5_040_001.hpp"
|
||||
//H 05: $S(t_5_040_001.hpp) ($B(t_5_040_001.hpp))
|
||||
//H 10: t_5_040_001.hpp(1): #if
|
||||
//H 11: t_5_040_001.hpp(1): #if 1: 1
|
||||
//H 10: t_5_040_001.hpp(3): #endif
|
||||
//H 10: t_5_040_001.hpp(7): #if
|
||||
//H 11: t_5_040_001.hpp(7): #if 1: 1
|
||||
//H 10: t_5_040_001.hpp(9): #endif
|
||||
//H 06:
|
||||
//H 10: t_5_040.cpp(13): #include "t_5_040_002.hpp"
|
||||
//H 04: "t_5_040_002.hpp"
|
||||
//H 05: t_5_040_002.hpp ($B(t_5_040_002.hpp))
|
||||
//H 10: t_5_040_002.hpp(1): #define
|
||||
//H 08: t_5_040_002.hpp(1): t_5_040_002_hpp=
|
||||
//H 06:
|
||||
//H 10: t_5_040.cpp(14): #include "t_5_040_003.hpp"
|
||||
//H 04: "t_5_040_003.hpp"
|
||||
//H 05: t_5_040_003.hpp ($B(t_5_040_003.hpp))
|
||||
//H 10: t_5_040_003.hpp(1): #include "t_5_040_004.hpp"
|
||||
//H 04: "t_5_040_004.hpp"
|
||||
//H 05: t_5_040_004.hpp ($B(t_5_040_004.hpp))
|
||||
//H 10: t_5_040_004.hpp(1): #if
|
||||
//H 11: t_5_040_004.hpp(1): #if 1: 1
|
||||
//H 10: t_5_040_004.hpp(3): #endif
|
||||
//H 06:
|
||||
//H 06:
|
||||
//H 10: t_5_040.cpp(15): #include "t_5_040_005.hpp"
|
||||
//H 04: "t_5_040_005.hpp"
|
||||
//H 05: t_5_040_005.hpp ($B(t_5_040_005.hpp))
|
||||
//H 06:
|
||||
//H 10: t_5_040.cpp(18): #if
|
||||
//H 11: t_5_040.cpp(18): #if 1: 1
|
||||
//H 10: t_5_040.cpp(20): #endif
|
||||
22
test/testwave/testfiles/t_5_040_001.hpp
Normal file
22
test/testwave/testfiles/t_5_040_001.hpp
Normal file
@@ -0,0 +1,22 @@
|
||||
#if 1
|
||||
t_5_040_001a
|
||||
#endif
|
||||
|
||||
//Ensure line directive still properly gets replaced with empty line
|
||||
t_5_040_001b
|
||||
#if 1
|
||||
t_5_040_001c
|
||||
#endif
|
||||
|
||||
// Important: The #if must be the first line of this file to ensure proper testing
|
||||
// of line directive emission. Do not move the copyright comment to the
|
||||
// beginning of this file.
|
||||
|
||||
/*=============================================================================
|
||||
Boost.Wave: A Standard compliant C++ preprocessor library
|
||||
http://www.boost.org/
|
||||
|
||||
Copyright (c) 2024 Nick Nobles. Distributed under the Boost
|
||||
Software License, Version 1.0. (See accompanying file
|
||||
LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
=============================================================================*/
|
||||
15
test/testwave/testfiles/t_5_040_002.hpp
Normal file
15
test/testwave/testfiles/t_5_040_002.hpp
Normal file
@@ -0,0 +1,15 @@
|
||||
#define t_5_040_002_hpp
|
||||
t_5_040_002
|
||||
|
||||
// Important: The #define must be the first line of this file to ensure proper testing
|
||||
// of line directive emission. Do not move the copyright comment to the
|
||||
// beginning of this file.
|
||||
|
||||
/*=============================================================================
|
||||
Boost.Wave: A Standard compliant C++ preprocessor library
|
||||
http://www.boost.org/
|
||||
|
||||
Copyright (c) 2024 Nick Nobles. Distributed under the Boost
|
||||
Software License, Version 1.0. (See accompanying file
|
||||
LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
=============================================================================*/
|
||||
15
test/testwave/testfiles/t_5_040_003.hpp
Normal file
15
test/testwave/testfiles/t_5_040_003.hpp
Normal file
@@ -0,0 +1,15 @@
|
||||
#include "t_5_040_004.hpp"
|
||||
t_5_040_003
|
||||
|
||||
// Important: The #include must be the first line of this file to ensure proper testing
|
||||
// of line directive emission. Do not move the copyright comment to the
|
||||
// beginning of this file.
|
||||
|
||||
/*=============================================================================
|
||||
Boost.Wave: A Standard compliant C++ preprocessor library
|
||||
http://www.boost.org/
|
||||
|
||||
Copyright (c) 2024 Nick Nobles. Distributed under the Boost
|
||||
Software License, Version 1.0. (See accompanying file
|
||||
LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
=============================================================================*/
|
||||
16
test/testwave/testfiles/t_5_040_004.hpp
Normal file
16
test/testwave/testfiles/t_5_040_004.hpp
Normal file
@@ -0,0 +1,16 @@
|
||||
#if 1
|
||||
t_5_040_004
|
||||
#endif
|
||||
|
||||
// Important: The #if must be the first line of this file to ensure proper testing
|
||||
// of line directive emission. Do not move the copyright comment to the
|
||||
// beginning of this file.
|
||||
|
||||
/*=============================================================================
|
||||
Boost.Wave: A Standard compliant C++ preprocessor library
|
||||
http://www.boost.org/
|
||||
|
||||
Copyright (c) 2024 Nick Nobles. Distributed under the Boost
|
||||
Software License, Version 1.0. (See accompanying file
|
||||
LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
=============================================================================*/
|
||||
15
test/testwave/testfiles/t_5_040_005.hpp
Normal file
15
test/testwave/testfiles/t_5_040_005.hpp
Normal file
@@ -0,0 +1,15 @@
|
||||
|
||||
// Important: The first line of this file must be blank to ensure proper testing
|
||||
// of line directive emission. Do not move the copyright comment to the
|
||||
// beginning of this file.
|
||||
|
||||
/*=============================================================================
|
||||
Boost.Wave: A Standard compliant C++ preprocessor library
|
||||
http://www.boost.org/
|
||||
|
||||
Copyright (c) 2024 Jeff Trull. Distributed under the Boost
|
||||
Software License, Version 1.0. (See accompanying file
|
||||
LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
=============================================================================*/
|
||||
|
||||
t_5_040_005
|
||||
@@ -146,6 +146,7 @@ t_5_036.cpp
|
||||
t_5_037.cpp
|
||||
t_5_038.cpp
|
||||
t_5_039.cpp
|
||||
t_5_040.cpp
|
||||
|
||||
#
|
||||
# unit tests from the mcpp preprocessor validation suite
|
||||
|
||||
Reference in New Issue
Block a user