Skip to content

Commit

Permalink
*LAND ONLY WITH OTHER REPO PRs* - Add clang-format guards (#361)
Browse files Browse the repository at this point in the history
* Add clang-format guards

* Stub out contrib/sim_cpp11/sim_cpp11_features.pl - converge on BdeBuildSystem version

* Add stubbing choice rationale comment

* Skip blank or clang-format lines in splitter

* Allow for clang-format comments to be indented
  • Loading branch information
RMGiroux authored and GitHub Enterprise committed Jan 13, 2025
1 parent 964f78d commit ec365bc
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4,116 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,12 @@ def _parseSimCpp11Include(
f"`#undef COMPILING_{qualifiedComponentName.upper()}_XT_CPP`"
)
undefLine = idx + 1

elseLine = undefLine + 1

# Skip any empty or clang-format command lines.
while re.match(r"^($|[\t ]*// clang-format.*)", lines[elseLine - 1]):
elseLine = elseLine + 1

if len(lines) < elseLine:
raise ParseError(f"{xtCppName}:{undefLine}: Premature end of file, expected `#else`")
if not re.match(r"\s*#\s*else", lines[elseLine - 1]):
Expand Down
8 changes: 8 additions & 0 deletions BdeBuildSystem/scripts/sim_cpp11_features.pl
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,16 @@ =head1 Example
#include <bsls_compilerfeatures.h>
#if BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
// clang-format off
// Include version that can be compiled with C++03
// Generated on Mon Nov 2 13:17:20 2020
// Command line: sim_cpp11_features.pl foo.h
# define COMPILING_FOO_H
# include <foo_cpp03.h>
# undef COMPILING_FOO_H
// clang-format on
#else
#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES // $var-args=3
Expand Down Expand Up @@ -2257,12 +2261,16 @@ ($$)

my $masterPrefix = <<EOT;
#if $simCpp11Macro
// clang-format off
// Include version that can be compiled with C++03
// <timestampComment>
// Command line: <commandLine>
# define COMPILING_<CPP11_SOURCEFILE>
# include <<cpp03>>
# undef COMPILING_<CPP11_SOURCEFILE>
// clang-format on
#else
EOT
Expand Down
Loading

0 comments on commit ec365bc

Please sign in to comment.