From 714b0881974965e8fcfbc57b452ef648290d14a1 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Fri, 21 Jun 2019 17:39:32 -0400 Subject: Parsing CPP Compiler output (#994) * Added extractLine line parsing to StringUtil. Use for matching lines instead of calcLines. calcLines uses extractLine to extract lines. Fixed problems found in output of some tests- due to how a how final line is handled. Now a final line has a \r or \n\r combination, but nothing else after it, it is considered the last line (not the line after it). * Use StringUtil::extractLine in slang-generate. * Improved comment on extractLine * Remove test code from StringUtil::extractLine * Made StringUtil::extractLine act as if line terminators are 'separators'. Added unit-test-string.cpp - to check behavior. * Adding LineParser - not entirely necessary, but slightly easier to use. * Hack to output start of tests. * WIP parsing CPPCompiler output. * Make extractLine return a bool. * First attempt at Visual Studio output parsing. * Add handling for checking error returning from CPPCompiler. * First pass parsing output of Gcc/Clang. * Split out VisualStudioCompilerUtil and GCCCompilerUtil. Simplified parsing of versions. * Simplify CPPCompiler::Output interface. * Fix problem with cpp-compiler on linux targets. * Add shared library link error. * Improving GCC/Clang parsing output. * Make cpp compiler parsing function able to return a SlangResult. * Handling for 'info' on clang * Add expected result for c-compile-shared-library-error.c * * Add flags such that link errors on shared libraries are supported. * Added StringUtil::join * Turn off the link shared library unfound symbol option on MacOS because it causes an error (and it's not needed on that target). * Add natvis inclusion back to visual studio projects. * Display message to try and determine crash problem on travisbuild. * Fix bug in handling continuations for clang. Disabled output of exception text. * WIP: See what clang is outputting that is parsing incorrectly on travis. * More handling for travis clang parsing issue. * Restore natvis to core.vcxproj * Fix visual studio project such that it still as natvis. --- tests/cpp-compiler/c-compile-error.c | 12 ++++++++++ tests/cpp-compiler/c-compile-error.c.expected | 1 + tests/cpp-compiler/c-compile-link-error.c | 12 ++++++++++ tests/cpp-compiler/c-compile-link-error.c.expected | 1 + .../c-compile-shared-library-link-error.c | 27 ++++++++++++++++++++++ .../c-compile-shared-library-link-error.c.expected | 1 + 6 files changed, 54 insertions(+) create mode 100644 tests/cpp-compiler/c-compile-error.c create mode 100644 tests/cpp-compiler/c-compile-error.c.expected create mode 100644 tests/cpp-compiler/c-compile-link-error.c create mode 100644 tests/cpp-compiler/c-compile-link-error.c.expected create mode 100644 tests/cpp-compiler/c-compile-shared-library-link-error.c create mode 100644 tests/cpp-compiler/c-compile-shared-library-link-error.c.expected (limited to 'tests/cpp-compiler') diff --git a/tests/cpp-compiler/c-compile-error.c b/tests/cpp-compiler/c-compile-error.c new file mode 100644 index 000000000..ae36dd9c5 --- /dev/null +++ b/tests/cpp-compiler/c-compile-error.c @@ -0,0 +1,12 @@ +//TEST(smoke):CPP_COMPILER_EXECUTE: + +#include +#include + +int main(int argc, char** argv) +{ + int a = b + c; + + printf("Hello World!\n"); + return 0; +} diff --git a/tests/cpp-compiler/c-compile-error.c.expected b/tests/cpp-compiler/c-compile-error.c.expected new file mode 100644 index 000000000..09646b013 --- /dev/null +++ b/tests/cpp-compiler/c-compile-error.c.expected @@ -0,0 +1 @@ +Compile: Error diff --git a/tests/cpp-compiler/c-compile-link-error.c b/tests/cpp-compiler/c-compile-link-error.c new file mode 100644 index 000000000..08b93a38b --- /dev/null +++ b/tests/cpp-compiler/c-compile-link-error.c @@ -0,0 +1,12 @@ +//TEST(smoke):CPP_COMPILER_EXECUTE: + +#include +#include + +extern int thing; + +int main(int argc, char** argv) +{ + printf("Hello World %d!\n", thing); + return 0; +} diff --git a/tests/cpp-compiler/c-compile-link-error.c.expected b/tests/cpp-compiler/c-compile-link-error.c.expected new file mode 100644 index 000000000..593b17b75 --- /dev/null +++ b/tests/cpp-compiler/c-compile-link-error.c.expected @@ -0,0 +1 @@ +Link: Error diff --git a/tests/cpp-compiler/c-compile-shared-library-link-error.c b/tests/cpp-compiler/c-compile-shared-library-link-error.c new file mode 100644 index 000000000..1339a3b52 --- /dev/null +++ b/tests/cpp-compiler/c-compile-shared-library-link-error.c @@ -0,0 +1,27 @@ +//TEST(smoke):CPP_COMPILER_SHARED_LIBRARY: + +#include +#include +#include + +#if defined(_MSC_VER) +# define DLL_EXPORT __declspec(dllexport) +#else +//# define DLL_EXPORT +# define DLL_EXPORT __attribute__ ((dllexport)) __attribute__((__visibility__("default"))) +#endif + +#ifdef __cplusplus +#define EXTERN_C extern "C" +#else +#define EXTERN_C +#endif + +extern int symbolNotFound; + +EXTERN_C DLL_EXPORT int test(int intValue, const char* textValue, char* outTextValue) +{ + strcpy(outTextValue, textValue); + return intValue + symbolNotFound; +} + diff --git a/tests/cpp-compiler/c-compile-shared-library-link-error.c.expected b/tests/cpp-compiler/c-compile-shared-library-link-error.c.expected new file mode 100644 index 000000000..593b17b75 --- /dev/null +++ b/tests/cpp-compiler/c-compile-shared-library-link-error.c.expected @@ -0,0 +1 @@ +Link: Error -- cgit v1.2.3