File tree Expand file tree Collapse file tree 8 files changed +40
-7
lines changed Expand file tree Collapse file tree 8 files changed +40
-7
lines changed Original file line number Diff line number Diff line change 11# CHANGELOG
22
3+ * Added regular expression support to remove_compile_flags (#303 )
4+ * Fixed repeated comments in sequence diagrams (#301 )
35 * Added regular expression support to glob patterns (#299 )
46 * Enabled relative link patterns in generate_links option (#297 )
57 * Added advanced diagram filter config with anyof and allof operators (#289 )
Original file line number Diff line number Diff line change @@ -219,6 +219,14 @@ remove_compile_flags:
219219 - -I/usr/include
220220` ` `
221221
222+ ` remove_compile_flags` also accepts regular expression, so a single entry can
223+ remove a whole set of flags, e.g. :
224+
225+ ` ` ` yaml
226+ remove_compile_flags:
227+ - r: "-m.*"
228+ ` ` `
229+
222230These options can be also passed on the command line, for instance :
223231
224232` ` ` bash
Original file line number Diff line number Diff line change @@ -271,7 +271,9 @@ If this doesn't help to include paths can be customized using config options:
271271* `add_compile_flags` - which adds a list of compile flags such as include paths
272272 to each entry of the compilation database
273273* `remove_compile_flags` - which removes existing compile flags from each entry
274- of the compilation database
274+ of the compilation database, it can be provided as a regular string that
275+ must match the entire flag or as an object with `r:` key, which can contain
276+ a regular expression that will match a set of flags
275277
276278For instance :
277279
@@ -280,6 +282,7 @@ add_compile_flags:
280282 - -I/opt/my_toolchain/include
281283remove_compile_flags:
282284 - -I/usr/include
285+ - r: "-m.*"
283286` ` `
284287
285288These options can be also passed on the command line, for instance :
Original file line number Diff line number Diff line change @@ -759,7 +759,7 @@ struct config : public inheritable_diagram_options {
759759 /* ! List of compilation flags to be removed from the compilation
760760 * commands from database
761761 */
762- option<std::vector<std::string >> remove_compile_flags{
762+ option<std::vector<common::string_or_regex >> remove_compile_flags{
763763 " remove_compile_flags" };
764764
765765 /* ! Extract include paths by executing specified compiler driver.
Original file line number Diff line number Diff line change @@ -339,7 +339,7 @@ const std::string schema_str = R"(
339339 output_directory: !optional string
340340 query_driver: !optional string
341341 add_compile_flags: !optional [string]
342- remove_compile_flags: !optional [string ]
342+ remove_compile_flags: !optional [regex_or_string_t ]
343343 allow_empty_diagrams: !optional bool
344344 diagram_templates: !optional diagram_templates_t
345345 diagrams: !required map_t<string;diagram_t>
Original file line number Diff line number Diff line change @@ -44,6 +44,8 @@ std::pair<clanguml::config::config_ptr,
4444 clanguml::common::compilation_database_ptr>
4545load_config (const std::string &test_name)
4646{
47+ using clanguml::common::string_or_regex;
48+
4749 std::pair<clanguml::config::config_ptr,
4850 clanguml::common::compilation_database_ptr>
4951 res;
@@ -69,10 +71,11 @@ load_config(const std::string &test_name)
6971 LOG_DBG (" Loading compilation database from {}" ,
7072 res.first ->compilation_database_dir ());
7173
72- std::vector<std::string> remove_compile_flags{
73- std::string{" -Wno-class-memaccess" },
74- std::string{" -forward-unknown-to-host-compiler" },
75- std::string{" --generate-code=arch=compute_75,code=[compute_75,sm_75]" }};
74+ std::vector<string_or_regex> remove_compile_flags{
75+ string_or_regex{" -Wno-class-memaccess" },
76+ string_or_regex{" -forward-unknown-to-host-compiler" },
77+ string_or_regex{
78+ std::regex{" --generate-code=.*" }, " --generate-code=.*" }};
7679
7780 res.first ->remove_compile_flags .set (remove_compile_flags);
7881
Original file line number Diff line number Diff line change @@ -242,6 +242,18 @@ TEST_CASE("Test config layout")
242242 clanguml::common::model::diagram_t ::kPackage );
243243}
244244
245+ TEST_CASE (" Test add and remove compile flags options" )
246+ {
247+ auto cfg = clanguml::config::load (" ./test_config_data/complete.yml" );
248+
249+ REQUIRE (cfg.add_compile_flags ().size () == 1 );
250+ REQUIRE (cfg.add_compile_flags ()[0 ] == " -fparse-all-comments" );
251+ REQUIRE (cfg.remove_compile_flags ().size () == 2 );
252+ REQUIRE (cfg.remove_compile_flags ()[0 ] == " -Werror" );
253+ REQUIRE_FALSE (cfg.remove_compile_flags ()[1 ] == " -Wwarning" );
254+ REQUIRE (cfg.remove_compile_flags ()[1 ] == " -march=amd64" );
255+ }
256+
245257TEST_CASE (" Test config emitters" )
246258{
247259 auto cfg = clanguml::config::load (" ./test_config_data/complete.yml" );
Original file line number Diff line number Diff line change @@ -12,6 +12,11 @@ generate_links:
1212 link : " https://github.com/bkryza/clang-uml/blob/{{ git.commit }}/{{ element.source.path }}#L{{ element.source.line }}"
1313 # Tooltip pattern
1414 tooltip : " {{ element.name }}"
15+ add_compile_flags :
16+ - -fparse-all-comments
17+ remove_compile_flags :
18+ - -Werror
19+ - r : " -m.*"
1520# The map of diagrams - keys are also diagram file names
1621diagrams :
1722 config_class :
You can’t perform that action at this time.
0 commit comments