From 2265a97f6315992bb284ef9ff6ce36649876a386 Mon Sep 17 00:00:00 2001 From: Joakim Brannstrom Date: Tue, 1 Sep 2020 22:23:06 +0200 Subject: [PATCH 1/2] mutate: fix default config value for compile_commands search_paths --- .../mutate/source/dextool/plugin/mutate/frontend/argparser.d | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugin/mutate/source/dextool/plugin/mutate/frontend/argparser.d b/plugin/mutate/source/dextool/plugin/mutate/frontend/argparser.d index 5ba7b247c..b0936a841 100644 --- a/plugin/mutate/source/dextool/plugin/mutate/frontend/argparser.d +++ b/plugin/mutate/source/dextool/plugin/mutate/frontend/argparser.d @@ -135,7 +135,7 @@ struct ArgParser { app.put(null); app.put("# files and/or directories to look for compile_commands.json."); if (compileDb.dbs.length == 0) - app.put(`# search_paths = ["./compile_commands.json"]`); + app.put(`search_paths = ["./compile_commands.json"]`); else app.put(format("search_paths = %s", compileDb.rawDbs)); app.put(null); @@ -527,10 +527,11 @@ struct ArgParser { } } -/// Update the config from the users input. +/// Replace the config from the users input. void updateCompileDb(ref ConfigCompileDb db, string[] compile_dbs) { if (compile_dbs.length != 0) db.rawDbs = compile_dbs; + db.dbs = db.rawDbs .filter!(a => a.length != 0) .map!(a => Path(a).AbsolutePath) From 51f68d35a1afa99ddc1250558533b35e411379f3 Mon Sep 17 00:00:00 2001 From: Joakim Brannstrom Date: Tue, 1 Sep 2020 22:51:03 +0200 Subject: [PATCH 2/2] cpptooling: prettify implementation --- .../analyzer/clang/check_parse_result.d | 73 +++++++++---------- 1 file changed, 33 insertions(+), 40 deletions(-) diff --git a/libs/cpptooling/source/cpptooling/analyzer/clang/check_parse_result.d b/libs/cpptooling/source/cpptooling/analyzer/clang/check_parse_result.d index 237396d62..b28eca694 100644 --- a/libs/cpptooling/source/cpptooling/analyzer/clang/check_parse_result.d +++ b/libs/cpptooling/source/cpptooling/analyzer/clang/check_parse_result.d @@ -15,7 +15,7 @@ import clang.TranslationUnit : TranslationUnit; * * Returns: True if errors where found. */ -bool hasParseErrors(ref TranslationUnit tu) @safe { +bool hasParseErrors(ref TranslationUnit tu) @trusted { import clang.c.Index : CXDiagnosticSeverity; if (!tu.isValid) @@ -23,58 +23,51 @@ bool hasParseErrors(ref TranslationUnit tu) @safe { auto dia = tu.diagnostics; - auto rval = () @trusted { - foreach (diag; dia) { - auto severity = diag.severity; + foreach (diag; dia) { + auto severity = diag.severity; - final switch (severity) with (CXDiagnosticSeverity) { - case ignored: - case note: - case warning: - break; - case error: - case fatal: - return true; - } + final switch (severity) with (CXDiagnosticSeverity) { + case ignored: + case note: + case warning: + break; + case error: + case fatal: + return true; } - return false; - }(); - - return rval; + } + return false; } /** Log diagnostic error messages to std.logger. * * TODO Change to a template with a sink as parameter. */ -void logDiagnostic(ref TranslationUnit tu) @safe { +void logDiagnostic(ref TranslationUnit tu) @trusted { import logger = std.experimental.logger; - import clang.c.Index : CXDiagnosticSeverity; auto dia = tu.diagnostics; - () @trusted { - foreach (diag; dia) { - auto severity = diag.severity; + foreach (diag; dia) { + auto severity = diag.severity; - final switch (severity) with (CXDiagnosticSeverity) { - case ignored: - logger.info(diag.format); - break; - case note: - logger.info(diag.format); - break; - case warning: - logger.warning(diag.format); - break; - case error: - logger.error(diag.format); - break; - case fatal: - logger.error(diag.format); - break; - } + final switch (severity) with (CXDiagnosticSeverity) { + case ignored: + logger.info(diag.format); + break; + case note: + logger.info(diag.format); + break; + case warning: + logger.warning(diag.format); + break; + case error: + logger.error(diag.format); + break; + case fatal: + logger.error(diag.format); + break; } - }(); + } }