diff --git a/cpp/ql/src/Diagnostics/ExtractionWarnings.ql b/cpp/ql/src/Diagnostics/ExtractionWarnings.ql index dcfb599bbeb4..f32768734ca0 100644 --- a/cpp/ql/src/Diagnostics/ExtractionWarnings.ql +++ b/cpp/ql/src/Diagnostics/ExtractionWarnings.ql @@ -14,5 +14,5 @@ where or warning instanceof ExtractionUnknownProblem select warning, - "Extraction failed in " + warning.getFile() + " with warning " + warning.getProblemMessage(), - warning.getSeverity() + "Extraction failed in " + warning.getFile() + " with warning " + + warning.getProblemMessage().replaceAll("$", "$$"), warning.getSeverity() diff --git a/cpp/ql/src/Diagnostics/Internal/ExtractionErrors.ql b/cpp/ql/src/Diagnostics/Internal/ExtractionErrors.ql index c7eac620b3b0..9da14fbfb468 100644 --- a/cpp/ql/src/Diagnostics/Internal/ExtractionErrors.ql +++ b/cpp/ql/src/Diagnostics/Internal/ExtractionErrors.ql @@ -17,5 +17,6 @@ from ExtractionError error where error instanceof ExtractionUnknownError or exists(error.getFile().getRelativePath()) -select error, "Extraction failed in " + error.getFile() + " with error " + error.getErrorMessage(), - error.getSeverity() +select error, + "Extraction failed in " + error.getFile() + " with error " + + error.getErrorMessage().replaceAll("$", "$$"), error.getSeverity() diff --git a/cpp/ql/test/query-tests/Diagnostics/ExtractionErrors.expected b/cpp/ql/test/query-tests/Diagnostics/ExtractionErrors.expected index f7d1b79cd17a..1fa546094224 100644 --- a/cpp/ql/test/query-tests/Diagnostics/ExtractionErrors.expected +++ b/cpp/ql/test/query-tests/Diagnostics/ExtractionErrors.expected @@ -1,2 +1,3 @@ +| containserror.cpp:9:14:9:14 | Recoverable extraction error: 'x' has already been declared in the current scope | Extraction failed in containserror.cpp with error "containserror.cpp", line 9: error: "x" has already been declared in the current scope\n \tconst char *x = "Foo2 $$@ bar2 $$@ baz2";\n \t ^\n\n | 2 | | doesnotcompile.cpp:4:2:4:2 | Recoverable extraction error: identifier 'This' is undefined | Extraction failed in doesnotcompile.cpp with error "doesnotcompile.cpp", line 4: error: identifier "This" is undefined\n \tThis is not correct C/C++ code.\n \t^\n\n | 2 | | doesnotcompile.cpp:4:10:4:10 | Recoverable extraction error: expected a ';' | Extraction failed in doesnotcompile.cpp with error "doesnotcompile.cpp", line 4: error: expected a ";"\n \tThis is not correct C/C++ code.\n \t ^\n\n | 2 | diff --git a/cpp/ql/test/query-tests/Diagnostics/ExtractionWarnings.expected b/cpp/ql/test/query-tests/Diagnostics/ExtractionWarnings.expected index 69cba1e1420c..2393f4dbde02 100644 --- a/cpp/ql/test/query-tests/Diagnostics/ExtractionWarnings.expected +++ b/cpp/ql/test/query-tests/Diagnostics/ExtractionWarnings.expected @@ -1,2 +1,3 @@ +| containserror.cpp:9:14:9:14 | Recoverable extraction error: 'x' has already been declared in the current scope | Extraction failed in containserror.cpp with warning "containserror.cpp", line 9: error: "x" has already been declared in the current scope\n \tconst char *x = "Foo2 $$@ bar2 $$@ baz2";\n \t ^\n\n | 1 | | doesnotcompile.cpp:4:2:4:2 | Recoverable extraction error: identifier 'This' is undefined | Extraction failed in doesnotcompile.cpp with warning "doesnotcompile.cpp", line 4: error: identifier "This" is undefined\n \tThis is not correct C/C++ code.\n \t^\n\n | 1 | | doesnotcompile.cpp:4:10:4:10 | Recoverable extraction error: expected a ';' | Extraction failed in doesnotcompile.cpp with warning "doesnotcompile.cpp", line 4: error: expected a ";"\n \tThis is not correct C/C++ code.\n \t ^\n\n | 1 | diff --git a/cpp/ql/test/query-tests/Diagnostics/Info.expected b/cpp/ql/test/query-tests/Diagnostics/Info.expected index a32541303609..77a298109d6f 100644 --- a/cpp/ql/test/query-tests/Diagnostics/Info.expected +++ b/cpp/ql/test/query-tests/Diagnostics/Info.expected @@ -1,4 +1,4 @@ -| containserror.cpp:0:0:0:0 | containserror.cpp | containserror.cpp | fromSource, normalTermination | +| containserror.cpp:0:0:0:0 | containserror.cpp | containserror.cpp | ExtractionProblem (severity 1), fromSource, normalTermination | | containswarning.cpp:0:0:0:0 | containswarning.cpp | containswarning.cpp | fromSource, normalTermination | | doesnotcompile.cpp:0:0:0:0 | doesnotcompile.cpp | doesnotcompile.cpp | ExtractionProblem (severity 1), fromSource, normalTermination | | file://:0:0:0:0 | | | | diff --git a/cpp/ql/test/query-tests/Diagnostics/containserror.cpp b/cpp/ql/test/query-tests/Diagnostics/containserror.cpp index 175fcc579f11..63e11dfe64fa 100644 --- a/cpp/ql/test/query-tests/Diagnostics/containserror.cpp +++ b/cpp/ql/test/query-tests/Diagnostics/containserror.cpp @@ -3,3 +3,8 @@ void containserror() { #error An error! } + +void error_with_placeholder() { + const char *x = "Foo1 $@ bar1 $@ baz1"; + const char *x = "Foo2 $@ bar2 $@ baz2"; +} \ No newline at end of file